muon-ui 0.26.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.
- package/README.md +5 -0
- package/android.d.ts +4 -4
- package/dist/android/lib/index.cjs +13 -10
- package/dist/android/lib/index.cjs.map +1 -1
- package/dist/android/lib/index.mjs +14 -11
- package/dist/android/lib/index.mjs.map +1 -1
- package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.aar +0 -0
- package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.aar.md5 +1 -1
- package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.aar.sha1 +1 -1
- package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.aar.sha256 +1 -1
- package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.aar.sha512 +1 -1
- package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.module +10 -10
- package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.module.md5 +1 -1
- package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.module.sha1 +1 -1
- package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.module.sha256 +1 -1
- package/dist/android/maven/dev/muon/runtime/0.1.0/runtime-0.1.0.module.sha512 +1 -1
- package/dist/android/maven/dev/muon/runtime/maven-metadata.xml +1 -1
- package/dist/android/maven/dev/muon/runtime/maven-metadata.xml.md5 +1 -1
- package/dist/android/maven/dev/muon/runtime/maven-metadata.xml.sha1 +1 -1
- package/dist/android/maven/dev/muon/runtime/maven-metadata.xml.sha256 +1 -1
- package/dist/android/maven/dev/muon/runtime/maven-metadata.xml.sha512 +1 -1
- package/dist/android/renderer/renderer.js +41 -14
- package/dist/android/renderer/renderer.js.map +1 -1
- package/dist/cli.cjs +82 -56
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.mjs +2 -2
- package/dist/native/linux-amd64/muon-builder +0 -0
- package/dist/native/linux-amd64/muon-launcher +0 -0
- package/dist/native/linux-amd64/muon-runtime-helper +0 -0
- package/dist/native/linux-arm64/muon-builder +0 -0
- package/dist/native/linux-arm64/muon-launcher +0 -0
- package/dist/native/linux-arm64/muon-runtime-helper +0 -0
- package/dist/native/linux-armhf/muon-builder +0 -0
- package/dist/native/linux-armhf/muon-launcher +0 -0
- package/dist/native/linux-armhf/muon-runtime-helper +0 -0
- package/dist/native/windows-amd64/muon-builder.exe +0 -0
- package/dist/native/windows-amd64/muon-launcher.exe +0 -0
- package/dist/native/windows-amd64/muon-plugin-inspector.exe +0 -0
- package/dist/native/windows-i686/muon-builder.exe +0 -0
- package/dist/native/windows-i686/muon-launcher.exe +0 -0
- package/dist/native/windows-i686/muon-plugin-inspector.exe +0 -0
- package/dist/runtime/linux-amd64/libmuon-ui.so +0 -0
- package/dist/runtime/linux-amd64/muon-core +0 -0
- package/dist/runtime/linux-amd64/plugins/node-bridge.mjs +5 -5
- package/dist/runtime/linux-amd64/plugins/node.so +0 -0
- package/dist/runtime/linux-arm64/libmuon-ui.so +0 -0
- package/dist/runtime/linux-arm64/muon-core +0 -0
- package/dist/runtime/linux-arm64/plugins/node-bridge.mjs +5 -5
- package/dist/runtime/linux-arm64/plugins/node.so +0 -0
- package/dist/runtime/linux-armhf/libmuon-ui.so +0 -0
- package/dist/runtime/linux-armhf/muon-core +0 -0
- package/dist/runtime/linux-armhf/plugins/node-bridge.mjs +5 -5
- package/dist/runtime/linux-armhf/plugins/node.so +0 -0
- package/dist/runtime/windows-amd64/libcardio.dll +0 -0
- package/dist/runtime/windows-amd64/libmuon-ui.dll +0 -0
- package/dist/runtime/windows-amd64/muon-core.exe +0 -0
- package/dist/runtime/windows-amd64/plugins/node-bridge.mjs +5 -5
- package/dist/runtime/windows-amd64/plugins/node.dll +0 -0
- package/dist/runtime/windows-i686/libcardio.dll +0 -0
- package/dist/runtime/windows-i686/libmuon-ui.dll +0 -0
- package/dist/runtime/windows-i686/muon-core.exe +0 -0
- package/dist/runtime/windows-i686/plugins/node-bridge.mjs +5 -5
- package/dist/runtime/windows-i686/plugins/node.dll +0 -0
- package/dist/{vite-internals-DseKep-X.cjs → vite-internals-CueaxMaY.cjs} +4225 -1963
- package/dist/vite-internals-CueaxMaY.cjs.map +1 -0
- package/dist/vite.cjs +100 -1294
- package/dist/vite.cjs.map +1 -1
- package/dist/vite.mjs +6102 -5128
- package/dist/vite.mjs.map +1 -1
- package/images/get-started-android.png +0 -0
- package/muon-virtual-modules.d.ts +53 -0
- package/package.json +13 -13
- package/vite.d.ts +8 -0
- package/dist/vite-internals-DseKep-X.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderer.js","names":["isRecord","isRecord"],"sources":["../../src/renderer/android-api.ts","../../src/renderer/native-plugin-api.ts","../../src/renderer/webview-rpc.ts","../../src/renderer/bootstrap.ts","../../src/renderer/native-plugin-metadata.ts","../../src/renderer/entry.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 type { MuonWebViewRpcClient } from './webview-rpc.js';\n\nconst browserFunctionNames = [\n 'reload',\n 'toggleFullscreen',\n 'enterFullscreen',\n 'exitFullscreen',\n 'zoomIn',\n 'zoomOut',\n 'resetZoom',\n 'close',\n] as const;\n\nconst environmentFunctionNames = [\n 'getVariables',\n 'getConfigValues',\n 'getProcessId',\n 'getRuntimeInfo',\n] as const;\n\nconst filesystemFunctionNames = [\n 'readFile',\n 'writeFile',\n 'readTextFile',\n 'writeTextFile',\n 'stat',\n 'lstat',\n 'exists',\n 'access',\n 'readdir',\n 'mkdir',\n 'rm',\n 'unlink',\n 'rmdir',\n 'rename',\n 'copyFile',\n 'appendFile',\n 'appendTextFile',\n 'truncate',\n 'realpath',\n 'readlink',\n 'symlink',\n 'watch',\n] as const;\n\n/** Fully-qualified built-in function paths implemented by the Android backend. */\nexport const muonAndroidBuiltinFunctionPaths = [\n ...browserFunctionNames.map((name) => `muon.browser.${name}` as const),\n ...environmentFunctionNames.map(\n (name) => `muon.environments.${name}` as const\n ),\n ...filesystemFunctionNames.map((name) => `muon.fs.${name}` as const),\n] as const;\n\n/** A built-in function path available on Android. */\nexport type MuonAndroidBuiltinFunctionPath =\n (typeof muonAndroidBuiltinFunctionPaths)[number];\n\n/** Capability ids assigned to Android built-in namespaces. */\nexport interface MuonAndroidCapabilityIds {\n /** Capability for browser operations. */\n readonly 'muon.browser': string;\n\n /** Capability for environment information. */\n readonly 'muon.environments': string;\n\n /** Capability for sandboxed filesystem operations. */\n readonly 'muon.fs': string;\n}\n\n/** Android browser functions available in simple mode. */\nexport type MuonAndroidBrowserApi = Readonly<\n Record<(typeof browserFunctionNames)[number], () => Promise<void>>\n>;\n\n/** Runtime information reported by the Android WebView backend. */\nexport interface MuonAndroidRuntimeInfo {\n /** Selects the Android arm of the shared runtime-information union. */\n readonly backend: 'android-webview';\n\n /** Android operating-system identifier. */\n readonly os: 'android';\n\n /** User-visible Android release string. */\n readonly osVersion: string;\n\n /** Android SDK level running this application process. */\n readonly apiLevel: number;\n\n /** Primary ABI selected for this process. */\n readonly abi: string;\n\n /** Android application package name. */\n readonly applicationId: string;\n\n /** Android application version name. */\n readonly applicationVersion: string;\n\n /** Package providing WebView to this process. */\n readonly webViewPackage: string;\n\n /** Version of the WebView provider package. */\n readonly webViewVersion: string;\n}\n\n/** Android environment functions available in simple mode. */\nexport interface MuonAndroidEnvironmentsApi {\n /** Returns the current process environment variables. */\n readonly getVariables: () => Promise<Record<string, string>>;\n\n /** Returns the merged application string configuration. */\n readonly getConfigValues: () => Promise<Record<string, string>>;\n\n /** Returns the current Android application process id. */\n readonly getProcessId: () => Promise<number>;\n\n /** Returns Android and WebView runtime information. */\n readonly getRuntimeInfo: () => Promise<MuonAndroidRuntimeInfo>;\n}\n\n/** Options shared by Android filesystem operations. */\nexport interface MuonAndroidFsOperationOptions {\n /** Signal used to request best-effort cancellation. */\n readonly signal?: AbortSignal;\n}\n\n/** Options for reading part or all of a binary file. */\nexport interface MuonAndroidFsReadFileOptions extends MuonAndroidFsOperationOptions {\n /** Non-negative byte offset. */\n readonly position?: number;\n\n /** Maximum number of bytes to return. */\n readonly length?: number;\n}\n\n/** Options for writing binary data. */\nexport interface MuonAndroidFsWriteFileOptions extends MuonAndroidFsOperationOptions {\n /** Non-negative byte offset, or undefined to replace the file. */\n readonly position?: number;\n}\n\n/** Access modes checked by the Android filesystem backend. */\nexport type MuonAndroidFsAccessMode = 'read' | 'write' | 'execute';\n\n/** Options for checking filesystem access. */\nexport interface MuonAndroidFsAccessOptions extends MuonAndroidFsOperationOptions {\n /** Access modes that must all be allowed. */\n readonly mode?: readonly MuonAndroidFsAccessMode[];\n}\n\n/** Options for directory enumeration. */\nexport interface MuonAndroidFsReadDirectoryOptions extends MuonAndroidFsOperationOptions {\n /** Returns metadata-bearing entries when true. */\n readonly withFileTypes?: boolean;\n}\n\n/** Options for directory creation. */\nexport interface MuonAndroidFsMakeDirectoryOptions extends MuonAndroidFsOperationOptions {\n /** Creates missing parent directories when true. */\n readonly recursive?: boolean;\n}\n\n/** Options for recursive or missing-tolerant removal. */\nexport interface MuonAndroidFsRemoveOptions extends MuonAndroidFsOperationOptions {\n /** Removes directory trees when true. */\n readonly recursive?: boolean;\n\n /** Suppresses a missing-path error when true. */\n readonly force?: boolean;\n}\n\n/** Options for copying a regular file. */\nexport interface MuonAndroidFsCopyFileOptions extends MuonAndroidFsOperationOptions {\n /** Replaces an existing destination unless false. */\n readonly overwrite?: boolean;\n}\n\n/** Filesystem entry kinds reported by Android. */\nexport type MuonAndroidFsEntryType =\n | 'file'\n | 'directory'\n | 'symlink'\n | 'blockDevice'\n | 'characterDevice'\n | 'fifo'\n | 'socket'\n | 'other';\n\n/** Metadata returned for an Android filesystem entry. */\nexport interface MuonAndroidFsStats {\n /** Entry kind. */\n readonly type: MuonAndroidFsEntryType;\n\n /** Regular-file byte length, or zero for other entry kinds. */\n readonly size: number;\n\n /** Last modification time in Unix epoch milliseconds. */\n readonly mtimeMs: number;\n\n /** Whether no filesystem write permission bit is set. */\n readonly readonly: boolean;\n\n /** Returns whether this entry is a regular file. */\n readonly isFile: () => boolean;\n\n /** Returns whether this entry is a directory. */\n readonly isDirectory: () => boolean;\n\n /** Returns whether this entry is a symbolic link. */\n readonly isSymbolicLink: () => boolean;\n}\n\n/** Directory entry with Android filesystem metadata. */\nexport interface MuonAndroidFsDirent extends MuonAndroidFsStats {\n /** Entry name relative to the enumerated directory. */\n readonly name: string;\n}\n\n/** Symbolic-link kinds accepted by the shared API. */\nexport type MuonAndroidFsSymlinkType = 'file' | 'dir' | 'junction';\n\n/** Event delivered by an Android filesystem watcher. */\nexport interface MuonAndroidFsWatchEvent {\n /** Event kind. */\n readonly eventType: 'rename' | 'change' | 'error';\n\n /** Changed child name, or null for the watched path itself. */\n readonly filename: string | null;\n\n /** Diagnostic for an error event. */\n readonly message?: string;\n}\n\n/** Listener invoked for Android filesystem watch events. */\nexport type MuonAndroidFsWatchListener = (\n event: MuonAndroidFsWatchEvent\n) => void | Promise<void>;\n\n/** Handle for an active Android filesystem watcher. */\nexport interface MuonAndroidFsWatcher {\n /** Releases the native watcher lease and stops polling. */\n readonly close: () => Promise<void>;\n}\n\n/** Android filesystem functions available in simple mode. */\nexport interface MuonAndroidFsApi {\n /** Reads binary file data. */\n readonly readFile: (\n path: string,\n options?: MuonAndroidFsReadFileOptions\n ) => Promise<ArrayBuffer>;\n\n /** Writes binary file data. */\n readonly writeFile: (\n path: string,\n data: BufferSource,\n options?: MuonAndroidFsWriteFileOptions\n ) => Promise<void>;\n\n /** Reads strict UTF-8 text without NUL bytes. */\n readonly readTextFile: (\n path: string,\n encoding: 'utf8' | 'utf-8',\n options?: MuonAndroidFsOperationOptions\n ) => Promise<string>;\n\n /** Writes strict UTF-8 text without NUL bytes. */\n readonly writeTextFile: (\n path: string,\n data: string,\n encoding: 'utf8' | 'utf-8',\n options?: MuonAndroidFsOperationOptions\n ) => Promise<void>;\n\n /** Reads metadata while following symbolic links. */\n readonly stat: (\n path: string,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<MuonAndroidFsStats>;\n\n /** Reads metadata without following symbolic links. */\n readonly lstat: (\n path: string,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<MuonAndroidFsStats>;\n\n /** Tests whether a path exists. */\n readonly exists: (\n path: string,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<boolean>;\n\n /** Tests requested access modes. */\n readonly access: (\n path: string,\n options?: MuonAndroidFsAccessOptions\n ) => Promise<boolean>;\n\n /** Enumerates a directory as names or metadata-bearing entries. */\n readonly readdir: (\n path: string,\n options?: MuonAndroidFsReadDirectoryOptions\n ) => Promise<string[] | MuonAndroidFsDirent[]>;\n\n /** Creates a directory. */\n readonly mkdir: (\n path: string,\n options?: MuonAndroidFsMakeDirectoryOptions\n ) => Promise<void>;\n\n /** Removes a file or directory tree. */\n readonly rm: (\n path: string,\n options?: MuonAndroidFsRemoveOptions\n ) => Promise<void>;\n\n /** Removes a file or symbolic link. */\n readonly unlink: (\n path: string,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<void>;\n\n /** Removes an empty directory. */\n readonly rmdir: (\n path: string,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<void>;\n\n /** Renames a filesystem entry. */\n readonly rename: (\n oldPath: string,\n newPath: string,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<void>;\n\n /** Copies a regular file. */\n readonly copyFile: (\n source: string,\n destination: string,\n options?: MuonAndroidFsCopyFileOptions\n ) => Promise<void>;\n\n /** Appends binary data to a file. */\n readonly appendFile: (\n path: string,\n data: BufferSource,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<void>;\n\n /** Appends strict UTF-8 text to a file. */\n readonly appendTextFile: (\n path: string,\n data: string,\n encoding: 'utf8' | 'utf-8',\n options?: MuonAndroidFsOperationOptions\n ) => Promise<void>;\n\n /** Truncates or extends a file. */\n readonly truncate: (\n path: string,\n lengthOrOptions?: number | MuonAndroidFsOperationOptions,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<void>;\n\n /** Resolves an existing path to its canonical absolute path. */\n readonly realpath: (\n path: string,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<string>;\n\n /** Reads a symbolic-link target. */\n readonly readlink: (\n path: string,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<string>;\n\n /** Creates a symbolic link. */\n readonly symlink: (\n target: string,\n path: string,\n typeOrOptions?: MuonAndroidFsSymlinkType | MuonAndroidFsOperationOptions,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<void>;\n\n /** Watches a path until the returned handle is closed. */\n readonly watch: (\n path: string,\n listener: MuonAndroidFsWatchListener,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<MuonAndroidFsWatcher>;\n}\n\n/** Built-in API object exposed by Android simple mode. */\nexport interface MuonAndroidSimpleApi {\n /** Operations for the owning Activity and WebView. */\n readonly browser: MuonAndroidBrowserApi;\n\n /** Information about the current Android application process. */\n readonly environments: MuonAndroidEnvironmentsApi;\n\n /** Sandboxed real-path filesystem operations. */\n readonly fs: MuonAndroidFsApi;\n}\n\nconst escapeRegularExpression = (source: string): string =>\n source.replace(/[\\\\^$+?.()|[\\]{}]/gu, '\\\\$&');\n\nconst createFunctionAllowExpression = (allow: string): RegExp => {\n let source = '^';\n for (let index = 0; index < allow.length; index += 1) {\n const character = allow[index] ?? '';\n const next = allow[index + 1];\n if (character === '*' && next === '*') {\n source += '.*';\n index += 1;\n } else if (character === '*') {\n source += '[^.]*';\n } else {\n source += escapeRegularExpression(character);\n }\n }\n source += '$';\n return new RegExp(source, 'u');\n};\n\n/**\n * Expands Android capability allow patterns into available function paths.\n *\n * @param allows - Exact paths or glob patterns requested by a validate build.\n * @returns Available Android paths in stable metadata order.\n * @remarks An exact unsupported path, or a pattern matching no Android\n * functions, fails during the build instead of producing a runtime stub.\n */\nexport const expandMuonAndroidFunctionAllows = (\n allows: readonly string[]\n): readonly MuonAndroidBuiltinFunctionPath[] => {\n const selected = new Set<MuonAndroidBuiltinFunctionPath>();\n for (const allow of allows) {\n if (!allow.includes('*')) {\n const functionPath = muonAndroidBuiltinFunctionPaths.find(\n (candidate) => candidate === allow\n );\n if (functionPath === undefined) {\n throw new Error(`Muon function is unavailable for Android: ${allow}`);\n }\n selected.add(functionPath);\n continue;\n }\n\n const expression = createFunctionAllowExpression(allow);\n const matches = muonAndroidBuiltinFunctionPaths.filter((functionPath) =>\n expression.test(functionPath)\n );\n if (matches.length === 0) {\n throw new Error(\n `Muon function pattern is unavailable for Android: ${allow}`\n );\n }\n for (const functionPath of matches) {\n selected.add(functionPath);\n }\n }\n return muonAndroidBuiltinFunctionPaths.filter((functionPath) =>\n selected.has(functionPath)\n );\n};\n\nconst createVoidNamespace = <TName extends string>(\n client: MuonWebViewRpcClient,\n capabilityId: string,\n namespace: string,\n functionNames: readonly TName[]\n): Readonly<Record<TName, () => Promise<void>>> => {\n const entries = functionNames.map(\n (name) =>\n [\n name,\n async () => {\n await client.call(capabilityId, `${namespace}.${name}`, []);\n },\n ] as const\n );\n return Object.freeze(Object.fromEntries(entries)) as Readonly<\n Record<TName, () => Promise<void>>\n >;\n};\n\nconst parseNativeJson = async <T>(source: Promise<unknown>): Promise<T> => {\n const value = await source;\n if (typeof value !== 'string') {\n throw new TypeError('Android native JSON result is invalid');\n }\n return JSON.parse(value) as T;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst validatePath = (value: string, name = 'path'): string => {\n if (typeof value !== 'string' || value.length === 0) {\n throw new TypeError(`${name} must be a non-empty string`);\n }\n if (value.includes('\\0')) {\n throw new TypeError(`${name} must not contain NUL`);\n }\n return value;\n};\n\nconst validateSafeUnsignedInteger = (value: number, name: string): number => {\n if (!Number.isSafeInteger(value) || value < 0) {\n throw new TypeError(`${name} must be a non-negative safe integer`);\n }\n return value;\n};\n\nconst validateEncoding = (value: string): 'utf8' | 'utf-8' => {\n if (value !== 'utf8' && value !== 'utf-8') {\n throw new TypeError('encoding must be utf8 or utf-8');\n }\n return value;\n};\n\nconst getOperationSignal = (\n options: MuonAndroidFsOperationOptions | undefined\n): AbortSignal | undefined => {\n if (options === undefined) {\n return undefined;\n }\n if (!isRecord(options)) {\n throw new TypeError('filesystem options must be an object');\n }\n const { signal } = options;\n if (signal !== undefined && !(signal instanceof AbortSignal)) {\n throw new TypeError('signal must be an AbortSignal');\n }\n return signal;\n};\n\nconst normalizeOptionalSafeUnsignedInteger = (\n options: object,\n name: string\n): number | undefined => {\n const value = (options as Record<string, unknown>)[name];\n return value === undefined\n ? undefined\n : validateSafeUnsignedInteger(value as number, name);\n};\n\nconst normalizeReadFileOptions = (\n options: MuonAndroidFsReadFileOptions | undefined\n): Readonly<{ position?: number; length?: number }> => {\n const source = options ?? {};\n const position = normalizeOptionalSafeUnsignedInteger(source, 'position');\n const length = normalizeOptionalSafeUnsignedInteger(source, 'length');\n return Object.freeze({\n ...(position === undefined ? {} : { position }),\n ...(length === undefined ? {} : { length }),\n });\n};\n\nconst normalizeWriteFileOptions = (\n options: MuonAndroidFsWriteFileOptions | undefined\n): Readonly<{ position?: number }> => {\n const source = options ?? {};\n const position = normalizeOptionalSafeUnsignedInteger(source, 'position');\n return Object.freeze(position === undefined ? {} : { position });\n};\n\nconst normalizeBooleanOptions = (\n options: MuonAndroidFsOperationOptions | undefined,\n names: readonly string[]\n): Readonly<Record<string, boolean>> => {\n const source = options ?? {};\n const result: Record<string, boolean> = {};\n for (const name of names) {\n const value = source[name as keyof typeof source];\n if (value !== undefined) {\n if (typeof value !== 'boolean') {\n throw new TypeError(`${name} must be a boolean`);\n }\n result[name] = value;\n }\n }\n return Object.freeze(result);\n};\n\nconst normalizeAccessOptions = (\n options: MuonAndroidFsAccessOptions | undefined\n): Readonly<{ mode?: readonly MuonAndroidFsAccessMode[] }> => {\n if (options?.mode === undefined) {\n return Object.freeze({});\n }\n if (!Array.isArray(options.mode)) {\n throw new TypeError('mode must be an array');\n }\n const mode = options.mode.map((value) => {\n if (value !== 'read' && value !== 'write' && value !== 'execute') {\n throw new TypeError('mode entries must be read, write, or execute');\n }\n return value;\n });\n return Object.freeze({ mode: Object.freeze(mode) });\n};\n\nconst validateBufferSource = (value: BufferSource): BufferSource => {\n if (!(value instanceof ArrayBuffer) && !ArrayBuffer.isView(value)) {\n throw new TypeError('data must be a BufferSource');\n }\n return value;\n};\n\nconst createAbortReason = (signal: AbortSignal): unknown =>\n signal.reason ?? new DOMException('The operation was aborted', 'AbortError');\n\nconst addStatsMethods = <T extends Record<string, unknown>>(\n value: T\n): T & MuonAndroidFsStats => {\n const types: readonly MuonAndroidFsEntryType[] = [\n 'file',\n 'directory',\n 'symlink',\n 'blockDevice',\n 'characterDevice',\n 'fifo',\n 'socket',\n 'other',\n ];\n if (\n typeof value.type !== 'string' ||\n !types.includes(value.type as MuonAndroidFsEntryType) ||\n typeof value.size !== 'number' ||\n !Number.isFinite(value.size) ||\n value.size < 0 ||\n typeof value.mtimeMs !== 'number' ||\n !Number.isFinite(value.mtimeMs) ||\n typeof value.readonly !== 'boolean'\n ) {\n throw new TypeError('Android filesystem metadata is invalid');\n }\n Object.defineProperties(value, {\n isFile: { value: () => value.type === 'file' },\n isDirectory: { value: () => value.type === 'directory' },\n isSymbolicLink: { value: () => value.type === 'symlink' },\n });\n return value as T & MuonAndroidFsStats;\n};\n\nconst parseStats = async (\n source: Promise<unknown>\n): Promise<MuonAndroidFsStats> => {\n const value = await parseNativeJson<Record<string, unknown>>(source);\n if (!isRecord(value)) {\n throw new TypeError('Android filesystem metadata is invalid');\n }\n return addStatsMethods(value);\n};\n\nconst parseDirectoryEntries = async (\n source: Promise<unknown>,\n withFileTypes: boolean\n): Promise<string[] | MuonAndroidFsDirent[]> => {\n const values = await parseNativeJson<unknown[]>(source);\n if (!Array.isArray(values)) {\n throw new TypeError('Android directory result is invalid');\n }\n if (!withFileTypes) {\n if (!values.every((value) => typeof value === 'string')) {\n throw new TypeError('Android directory name result is invalid');\n }\n return values as string[];\n }\n return values.map((value) => {\n if (!isRecord(value) || typeof value.name !== 'string') {\n throw new TypeError('Android directory entry result is invalid');\n }\n return addStatsMethods(value) as unknown as MuonAndroidFsDirent;\n });\n};\n\ninterface MuonAndroidFsWatchSnapshot {\n readonly root: MuonAndroidFsStats;\n readonly entries: readonly MuonAndroidFsDirent[];\n}\n\nconst parseWatchSnapshot = async (\n source: Promise<unknown>\n): Promise<MuonAndroidFsWatchSnapshot> => {\n const value = await parseNativeJson<Record<string, unknown>>(source);\n if (\n !isRecord(value) ||\n !isRecord(value.root) ||\n !Array.isArray(value.entries)\n ) {\n throw new TypeError('Android filesystem watch snapshot is invalid');\n }\n const root = addStatsMethods(value.root);\n const entries = value.entries\n .map((entry) => {\n if (!isRecord(entry) || typeof entry.name !== 'string') {\n throw new TypeError('Android filesystem watch entry is invalid');\n }\n return addStatsMethods(entry) as unknown as MuonAndroidFsDirent;\n })\n .sort((left, right) => left.name.localeCompare(right.name));\n return { root, entries };\n};\n\nconst filesystemStatusKey = (entry: MuonAndroidFsStats): string =>\n [entry.type, entry.size, entry.mtimeMs, entry.readonly].join(':');\n\nconst notifyFilesystemWatchListener = (\n listener: MuonAndroidFsWatchListener,\n event: MuonAndroidFsWatchEvent\n): void => {\n let result: void | Promise<void>;\n try {\n result = listener(event);\n } catch {\n // Listener failures do not stop the native watcher lease.\n return;\n }\n if (result !== undefined) {\n const observeResult = async (): Promise<void> => {\n try {\n await result;\n } catch {\n // Asynchronous listener failures are ignored by the public contract.\n }\n };\n globalThis.queueMicrotask(observeResult);\n }\n};\n\nconst emitFilesystemWatchDiff = (\n previous: MuonAndroidFsWatchSnapshot,\n next: MuonAndroidFsWatchSnapshot,\n listener: MuonAndroidFsWatchListener\n): void => {\n if (filesystemStatusKey(previous.root) !== filesystemStatusKey(next.root)) {\n notifyFilesystemWatchListener(listener, {\n eventType: 'change',\n filename: null,\n });\n }\n const previousEntries = new Map(\n previous.entries.map((entry) => [entry.name, entry] as const)\n );\n const nextEntries = new Map(\n next.entries.map((entry) => [entry.name, entry] as const)\n );\n for (const [name, entry] of previousEntries) {\n const nextEntry = nextEntries.get(name);\n if (nextEntry === undefined) {\n notifyFilesystemWatchListener(listener, {\n eventType: 'rename',\n filename: name,\n });\n } else if (filesystemStatusKey(entry) !== filesystemStatusKey(nextEntry)) {\n notifyFilesystemWatchListener(listener, {\n eventType: 'change',\n filename: name,\n });\n }\n }\n for (const name of nextEntries.keys()) {\n if (!previousEntries.has(name)) {\n notifyFilesystemWatchListener(listener, {\n eventType: 'rename',\n filename: name,\n });\n }\n }\n};\n\nconst createMuonAndroidFsApi = (\n client: MuonWebViewRpcClient,\n capabilityId: string\n): MuonAndroidFsApi => {\n const call = (\n functionName: (typeof filesystemFunctionNames)[number],\n arguments_: readonly unknown[],\n options: MuonAndroidFsOperationOptions | undefined\n ): Promise<unknown> => {\n const signal = getOperationSignal(options);\n return client.call(\n capabilityId,\n `muon.fs.${functionName}`,\n arguments_,\n signal === undefined ? undefined : { signal }\n );\n };\n\n const callVoid = async (\n functionName: (typeof filesystemFunctionNames)[number],\n arguments_: readonly unknown[],\n options: MuonAndroidFsOperationOptions | undefined\n ): Promise<void> => {\n await call(functionName, arguments_, options);\n };\n\n const callString = async (\n functionName: (typeof filesystemFunctionNames)[number],\n arguments_: readonly unknown[],\n options: MuonAndroidFsOperationOptions | undefined\n ): Promise<string> => {\n const value = await call(functionName, arguments_, options);\n if (typeof value !== 'string') {\n throw new TypeError('Android filesystem string result is invalid');\n }\n return value;\n };\n\n const callBoolean = async (\n functionName: (typeof filesystemFunctionNames)[number],\n arguments_: readonly unknown[],\n options: MuonAndroidFsOperationOptions | undefined\n ): Promise<boolean> => {\n const value = await call(functionName, arguments_, options);\n if (typeof value !== 'boolean') {\n throw new TypeError('Android filesystem boolean result is invalid');\n }\n return value;\n };\n\n const api: MuonAndroidFsApi = {\n readFile: async (path, options) => {\n const value = await call(\n 'readFile',\n [validatePath(path), normalizeReadFileOptions(options)],\n options\n );\n if (!(value instanceof ArrayBuffer)) {\n throw new TypeError('Android filesystem binary result is invalid');\n }\n return value;\n },\n writeFile: async (path, data, options) =>\n await callVoid(\n 'writeFile',\n [\n validatePath(path),\n validateBufferSource(data),\n normalizeWriteFileOptions(options),\n ],\n options\n ),\n readTextFile: async (path, encoding, options) =>\n await callString(\n 'readTextFile',\n [validatePath(path), validateEncoding(encoding)],\n options\n ),\n writeTextFile: async (path, data, encoding, options) => {\n if (typeof data !== 'string') {\n throw new TypeError('data must be a string');\n }\n await callVoid(\n 'writeTextFile',\n [validatePath(path), data, validateEncoding(encoding)],\n options\n );\n },\n stat: async (path, options) =>\n await parseStats(call('stat', [validatePath(path)], options)),\n lstat: async (path, options) =>\n await parseStats(call('lstat', [validatePath(path)], options)),\n exists: async (path, options) =>\n await callBoolean('exists', [validatePath(path)], options),\n access: async (path, options) =>\n await callBoolean(\n 'access',\n [validatePath(path), normalizeAccessOptions(options)],\n options\n ),\n readdir: async (path, options) => {\n const nativeOptions = normalizeBooleanOptions(options, ['withFileTypes']);\n return await parseDirectoryEntries(\n call('readdir', [validatePath(path), nativeOptions], options),\n nativeOptions.withFileTypes === true\n );\n },\n mkdir: async (path, options) =>\n await callVoid(\n 'mkdir',\n [validatePath(path), normalizeBooleanOptions(options, ['recursive'])],\n options\n ),\n rm: async (path, options) =>\n await callVoid(\n 'rm',\n [\n validatePath(path),\n normalizeBooleanOptions(options, ['recursive', 'force']),\n ],\n options\n ),\n unlink: async (path, options) =>\n await callVoid('unlink', [validatePath(path)], options),\n rmdir: async (path, options) =>\n await callVoid('rmdir', [validatePath(path)], options),\n rename: async (oldPath, newPath, options) =>\n await callVoid(\n 'rename',\n [validatePath(oldPath, 'oldPath'), validatePath(newPath, 'newPath')],\n options\n ),\n copyFile: async (source, destination, options) =>\n await callVoid(\n 'copyFile',\n [\n validatePath(source, 'source'),\n validatePath(destination, 'destination'),\n normalizeBooleanOptions(options, ['overwrite']),\n ],\n options\n ),\n appendFile: async (path, data, options) =>\n await callVoid(\n 'appendFile',\n [validatePath(path), validateBufferSource(data)],\n options\n ),\n appendTextFile: async (path, data, encoding, options) => {\n if (typeof data !== 'string') {\n throw new TypeError('data must be a string');\n }\n await callVoid(\n 'appendTextFile',\n [validatePath(path), data, validateEncoding(encoding)],\n options\n );\n },\n truncate: async (path, lengthOrOptions, options) => {\n const operationOptions =\n typeof lengthOrOptions === 'object' && lengthOrOptions !== null\n ? lengthOrOptions\n : options;\n const length =\n typeof lengthOrOptions === 'number'\n ? validateSafeUnsignedInteger(lengthOrOptions, 'length')\n : 0;\n await callVoid(\n 'truncate',\n [validatePath(path), { length }],\n operationOptions\n );\n },\n realpath: async (path, options) =>\n await callString('realpath', [validatePath(path)], options),\n readlink: async (path, options) =>\n await callString('readlink', [validatePath(path)], options),\n symlink: async (target, path, typeOrOptions, options) => {\n if (typeof target !== 'string' || target.length === 0) {\n throw new TypeError('target must be a non-empty string');\n }\n if (target.includes('\\0')) {\n throw new TypeError('target must not contain NUL');\n }\n const operationOptions =\n typeof typeOrOptions === 'object' && typeOrOptions !== null\n ? typeOrOptions\n : options;\n const type = typeof typeOrOptions === 'string' ? typeOrOptions : 'file';\n if (type !== 'file' && type !== 'dir' && type !== 'junction') {\n throw new TypeError('type must be file, dir, or junction');\n }\n if (type === 'junction') {\n throw new TypeError(\n 'junction symbolic links are unavailable on Android'\n );\n }\n await callVoid(\n 'symlink',\n [target, validatePath(path), type],\n operationOptions\n );\n },\n watch: async (path, listener, options) => {\n const validatedPath = validatePath(path);\n if (typeof listener !== 'function') {\n throw new TypeError('listener must be a function');\n }\n const signal = getOperationSignal(options);\n if (signal !== undefined && Boolean(signal.aborted)) {\n throw createAbortReason(signal);\n }\n const runWatchRpc = async (\n request: Readonly<Record<string, unknown>>,\n operationOptions: MuonAndroidFsOperationOptions | undefined\n ): Promise<Record<string, unknown>> =>\n await parseNativeJson<Record<string, unknown>>(\n call('watch', [request], operationOptions)\n );\n const lease = await runWatchRpc({ operation: 'acquire' }, undefined);\n if (typeof lease.token !== 'string' || lease.token.length === 0) {\n throw new TypeError('Android filesystem watcher lease is invalid');\n }\n const token = lease.token;\n let released = false;\n const releaseLease = async (): Promise<void> => {\n if (released) {\n return;\n }\n released = true;\n try {\n await runWatchRpc({ operation: 'release', token }, undefined);\n } catch {\n // Context release is the final fallback for an unavailable transport.\n }\n };\n if (signal !== undefined && Boolean(signal.aborted)) {\n await releaseLease();\n throw createAbortReason(signal);\n }\n\n let snapshot: MuonAndroidFsWatchSnapshot;\n try {\n snapshot = await parseWatchSnapshot(\n call(\n 'watch',\n [{ operation: 'snapshot', path: validatedPath, token }],\n options\n )\n );\n } catch (error) {\n await releaseLease();\n throw error;\n }\n\n let closed = false;\n let polling = false;\n let pollPromise: Promise<void> | undefined = undefined;\n let timer: ReturnType<typeof globalThis.setInterval> | undefined =\n undefined;\n let closePromise: Promise<void> | undefined = undefined;\n const beginClose = async (waitForPoll: boolean): Promise<void> => {\n if (closePromise !== undefined) {\n await closePromise;\n return;\n }\n const pendingPoll = waitForPoll ? pollPromise : undefined;\n closePromise = (async () => {\n if (closed) {\n return;\n }\n closed = true;\n if (timer !== undefined) {\n globalThis.clearInterval(timer);\n timer = undefined;\n }\n if (signal !== undefined) {\n signal.removeEventListener('abort', onAbort);\n }\n if (pendingPoll !== undefined) {\n try {\n await pendingPoll;\n } catch {\n // Poll errors are reported to the listener before lease release.\n }\n }\n await releaseLease();\n })();\n await closePromise;\n };\n const close = async (): Promise<void> => {\n await beginClose(true);\n };\n const onAbort = async (): Promise<void> => {\n await close();\n };\n const runPoll = async (): Promise<void> => {\n try {\n const next = await parseWatchSnapshot(\n call(\n 'watch',\n [{ operation: 'snapshot', path: validatedPath, token }],\n undefined\n )\n );\n if (closed) {\n return;\n }\n emitFilesystemWatchDiff(snapshot, next, listener);\n snapshot = next;\n } catch (error) {\n if (closed) {\n return;\n }\n notifyFilesystemWatchListener(listener, {\n eventType: 'error',\n filename: null,\n message: error instanceof Error ? error.message : String(error),\n });\n await beginClose(false);\n }\n };\n const poll = async (): Promise<void> => {\n if (closed || polling) {\n return;\n }\n polling = true;\n const currentPoll = runPoll();\n pollPromise = currentPoll;\n try {\n await currentPoll;\n } finally {\n if (pollPromise === currentPoll) {\n pollPromise = undefined;\n }\n polling = false;\n }\n };\n timer = globalThis.setInterval(async () => {\n await poll();\n }, 100);\n if (signal !== undefined) {\n signal.addEventListener('abort', onAbort, { once: true });\n if (signal.aborted) {\n await close();\n throw createAbortReason(signal);\n }\n }\n return Object.freeze({ close });\n },\n };\n return Object.freeze(api);\n};\n\n/**\n * Creates the Android simple-mode `window.muon` object.\n *\n * @param client - WebView RPC client used by every exposed function.\n * @param capabilityIds - Namespace capability ids generated for this page.\n * @returns An immutable object containing only implemented Android functions.\n */\nexport const createMuonAndroidSimpleApi = (\n client: MuonWebViewRpcClient,\n capabilityIds: MuonAndroidCapabilityIds\n): MuonAndroidSimpleApi =>\n Object.freeze({\n browser: createVoidNamespace(\n client,\n capabilityIds['muon.browser'],\n 'muon.browser',\n browserFunctionNames\n ),\n environments: Object.freeze({\n getVariables: () =>\n parseNativeJson<Record<string, string>>(\n client.call(\n capabilityIds['muon.environments'],\n 'muon.environments.getVariables',\n []\n )\n ),\n getConfigValues: () =>\n parseNativeJson<Record<string, string>>(\n client.call(\n capabilityIds['muon.environments'],\n 'muon.environments.getConfigValues',\n []\n )\n ),\n getProcessId: async () => {\n const value = await client.call(\n capabilityIds['muon.environments'],\n 'muon.environments.getProcessId',\n []\n );\n if (\n typeof value !== 'number' ||\n !Number.isInteger(value) ||\n value <= 0 ||\n value > 0xffffffff\n ) {\n throw new TypeError('Android process id result is invalid');\n }\n return value;\n },\n getRuntimeInfo: () =>\n parseNativeJson<MuonAndroidRuntimeInfo>(\n client.call(\n capabilityIds['muon.environments'],\n 'muon.environments.getRuntimeInfo',\n []\n )\n ),\n }),\n fs: createMuonAndroidFsApi(client, capabilityIds['muon.fs']),\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 {\n MuonAndroidRendererMetadata,\n MuonNativeNamespaceMetadata,\n} from './native-plugin-metadata.js';\nimport type { MuonWebViewRpcClient } from './webview-rpc.js';\n\n/** Existing root objects merged with native namespaces in simple mode. */\nexport type MuonAndroidNativePluginBaseRoots = Readonly<Record<string, object>>;\n\nconst getNamespaceSegments = (namespace: string): readonly string[] =>\n namespace.split('.');\n\nconst getOrCreateNamespace = (\n roots: Record<string, Record<string, unknown>>,\n namespace: string\n): Record<string, unknown> => {\n const segments = getNamespaceSegments(namespace);\n let current = roots[segments[0]!];\n if (current === undefined) {\n current = {};\n roots[segments[0]!] = current;\n }\n for (const segment of segments.slice(1)) {\n const existing = current[segment];\n if (existing === undefined) {\n const created: Record<string, unknown> = {};\n Object.defineProperty(current, segment, {\n configurable: false,\n enumerable: !segment.startsWith('__'),\n writable: false,\n value: created,\n });\n current = created;\n } else if (typeof existing === 'object' && existing !== null) {\n current = existing as Record<string, unknown>;\n } else {\n throw new Error(`Muon plugin namespace conflicts with ${namespace}`);\n }\n }\n return current;\n};\n\nconst deepFreeze = (value: unknown, seen: WeakSet<object>): void => {\n if (\n value === null ||\n (typeof value !== 'object' && typeof value !== 'function')\n ) {\n return;\n }\n if (seen.has(value)) {\n return;\n }\n seen.add(value);\n for (const key of Reflect.ownKeys(value)) {\n deepFreeze(Reflect.get(value, key), seen);\n }\n Object.freeze(value);\n};\n\nconst executeSetupScript = (\n pluginNamespace: MuonNativeNamespaceMetadata,\n namespaceObject: Record<string, unknown>,\n target: Record<PropertyKey, unknown>\n): void => {\n if (pluginNamespace.setupScript.length === 0) {\n return;\n }\n const setup = Function(\n 'namespace',\n 'globalThis',\n 'isAllowed',\n `\"use strict\";\\n${pluginNamespace.setupScript}`\n ) as (\n namespace: Record<string, unknown>,\n global: Record<PropertyKey, unknown>,\n isAllowed: (name: string) => boolean\n ) => void;\n const allowed = new Set(pluginNamespace.allowedFunctions);\n setup(namespaceObject, target, (name) => allowed.has(name));\n};\n\n/**\n * Installs loaded native plugin functions in the trusted simple-mode context.\n *\n * @param client - Typed WebView RPC client.\n * @param metadata - Runtime metadata captured before document loading.\n * @param baseRoots - Existing Android platform API root objects.\n * @param target - Global-like object receiving plugin roots.\n * @returns A function that restores the previous root descriptors.\n */\nexport const installMuonAndroidNativePluginApi = (\n client: MuonWebViewRpcClient,\n metadata: MuonAndroidRendererMetadata,\n baseRoots: MuonAndroidNativePluginBaseRoots,\n target: Record<PropertyKey, unknown> = globalThis as unknown as Record<\n PropertyKey,\n unknown\n >\n): (() => void) => {\n if (metadata.mode !== 'simple') {\n return () => {};\n }\n const namespaceMetadata = new Map(\n metadata.namespaces.map((namespace) => [namespace.namespace, namespace])\n );\n const roots: Record<string, Record<string, unknown>> = {};\n for (const [name, value] of Object.entries(baseRoots)) {\n roots[name] = { ...(value as Record<string, unknown>) };\n }\n\n for (const pluginNamespace of metadata.namespaces) {\n getOrCreateNamespace(roots, pluginNamespace.namespace);\n }\n for (const function_ of metadata.functions) {\n const pluginNamespace = namespaceMetadata.get(function_.namespace);\n if (\n pluginNamespace === undefined ||\n !pluginNamespace.allowedFunctions.includes(function_.name)\n ) {\n throw new Error(\n `Android native plugin function is not allowed: ${function_.namespace}.${function_.name}`\n );\n }\n const namespaceObject = getOrCreateNamespace(roots, function_.namespace);\n if (Reflect.has(namespaceObject, function_.name)) {\n throw new Error(\n `Muon plugin function conflicts with ${function_.namespace}.${function_.name}`\n );\n }\n const call = (...arguments_: readonly unknown[]): Promise<unknown> =>\n client.call(\n function_.capabilityId,\n `${function_.namespace}.${function_.publicName}`,\n arguments_\n );\n Object.defineProperty(namespaceObject, function_.name, {\n configurable: false,\n enumerable: !function_.name.startsWith('__'),\n writable: false,\n value: call,\n });\n }\n\n const previousDescriptors = new Map<string, PropertyDescriptor | undefined>();\n for (const [name, root] of Object.entries(roots)) {\n previousDescriptors.set(\n name,\n Object.getOwnPropertyDescriptor(target, name)\n );\n Object.defineProperty(target, name, {\n configurable: true,\n enumerable: true,\n writable: false,\n value: root,\n });\n }\n try {\n for (const pluginNamespace of metadata.namespaces) {\n executeSetupScript(\n pluginNamespace,\n getOrCreateNamespace(roots, pluginNamespace.namespace),\n target\n );\n }\n const seen = new WeakSet<object>();\n for (const root of Object.values(roots)) {\n deepFreeze(root, seen);\n }\n } catch (error) {\n for (const [name, previous] of previousDescriptors) {\n if (previous === undefined) {\n Reflect.deleteProperty(target, name);\n } else {\n Object.defineProperty(target, name, previous);\n }\n }\n throw error;\n }\n\n return () => {\n for (const [name, previous] of previousDescriptors) {\n if (previous === undefined) {\n Reflect.deleteProperty(target, name);\n } else {\n Object.defineProperty(target, name, previous);\n }\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 type {\n MuonAndroidRendererMetadata,\n MuonNativeFunctionMetadata,\n MuonNativeTypeMetadata,\n} from './native-plugin-metadata.js';\n\n/** A message exchanged between JavaScript and the Android WebView host. */\nexport type MuonWebViewRpcMessage = string | ArrayBuffer;\n\n/** Receives a message from the Android WebView host. */\nexport type MuonWebViewRpcMessageHandler = (\n message: MuonWebViewRpcMessage\n) => void;\n\n/** Supplies the platform-specific message channel used by the RPC client. */\nexport interface MuonWebViewRpcTransport {\n /** Sends one text or binary message to the Android WebView host. */\n readonly send: (message: MuonWebViewRpcMessage) => void;\n\n /** Replaces or removes the handler for messages received from the host. */\n readonly setMessageHandler: (\n handler: MuonWebViewRpcMessageHandler | undefined\n ) => void;\n}\n\n/** Options controlling one WebView RPC call. */\nexport interface MuonWebViewRpcCallOptions {\n /** Cancels the native RPC call when aborted. */\n readonly signal?: AbortSignal;\n}\n\n/** The kind of payload represented by a WebView RPC binary frame. */\nexport type MuonWebViewRpcBinaryFrameKind =\n 'argument' | 'result' | 'renderer-argument' | 'renderer-result';\n\n/** Values required to encode a WebView RPC binary frame. */\nexport interface MuonWebViewRpcBinaryFrame {\n /** Identifies whether the payload is a call argument or a call result. */\n readonly kind: MuonWebViewRpcBinaryFrameKind;\n\n /** Identifies the RPC call owning the payload. */\n readonly callId: number;\n\n /** Identifies this payload within the owning message. */\n readonly attachment: number;\n\n /** Contains the payload bytes. */\n readonly payload: ArrayBuffer;\n}\n\n/** Provides asynchronous calls over a WebView RPC transport. */\nexport interface MuonWebViewRpcClient {\n /**\n * Calls one native capability function.\n *\n * @param capabilityId - Capability token supplied by the generated module.\n * @param functionPath - Fully-qualified native function path.\n * @param arguments_ - Function arguments.\n * @param options - Optional cancellation settings.\n * @returns The native result.\n */\n readonly call: (\n capabilityId: string,\n functionPath: string,\n arguments_: readonly unknown[],\n options?: MuonWebViewRpcCallOptions\n ) => Promise<unknown>;\n\n /** Releases the JavaScript context and rejects all outstanding calls. */\n readonly dispose: () => void;\n\n /** Returns the number of calls awaiting a native result. */\n readonly getPendingCallCount: () => number;\n}\n\n/** The message event emitted by an object injected with addWebMessageListener. */\nexport interface MuonWebViewJavaScriptMessageEvent {\n /** Contains text or binary data sent by the Android host. */\n readonly data: MuonWebViewRpcMessage;\n}\n\n/** The JavaScript object injected by AndroidX WebKit. */\nexport interface MuonWebViewJavaScriptBridge {\n /** Sends text or binary data to the Android host. */\n readonly postMessage: (message: MuonWebViewRpcMessage) => void;\n\n /** Receives replies posted by the Android host. */\n onmessage: ((event: MuonWebViewJavaScriptMessageEvent) => void) | null;\n}\n\ninterface PendingCall {\n readonly resolve: (value: unknown) => void;\n readonly reject: (reason: unknown) => void;\n readonly signal: AbortSignal | undefined;\n readonly returnType: MuonNativeTypeMetadata | undefined;\n readonly rendererFunctionTransfers: readonly number[];\n abortListener: (() => void) | undefined;\n}\n\ninterface EncodedArguments {\n readonly value: readonly unknown[];\n readonly attachments: readonly ArrayBuffer[];\n readonly rendererFunctionTransfers: readonly number[];\n}\n\ninterface RendererFunctionSource {\n readonly value: (...arguments_: readonly unknown[]) => unknown;\n readonly leases: Set<string>;\n pendingTransfers: number;\n}\n\ninterface PluginFunctionProxyState {\n readonly proxyId: number;\n readonly leaseToken: string;\n readonly type: MuonNativeTypeMetadata;\n released: boolean;\n}\n\ninterface PendingRendererFunctionCall {\n readonly callId: number;\n readonly functionId: number;\n readonly expectsResult: boolean;\n readonly functionType: MuonNativeTypeMetadata;\n readonly encodedArguments: readonly unknown[];\n readonly expectedAttachmentLengths: readonly number[];\n readonly attachments: Array<ArrayBuffer | undefined>;\n receivedAttachmentCount: number;\n}\n\ntype EncodeFunctionValue = (\n value: unknown,\n type: MuonNativeTypeMetadata,\n rendererFunctionTransfers: number[]\n) => unknown;\n\ntype DecodeFunctionValue = (\n value: unknown,\n type: MuonNativeTypeMetadata\n) => unknown;\n\nconst binaryHeaderLength = 16;\nconst binaryMagic = [0x4d, 0x52, 0x50, 0x43] as const;\nconst protocolVersion = 1;\nconst maximumCallId = 0x7fffffff;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst isUnsignedInteger = (value: unknown): value is number =>\n typeof value === 'number' &&\n Number.isInteger(value) &&\n value >= 0 &&\n value <= 0xffffffff;\n\nconst nativeValueTypes = new Set<MuonNativeTypeMetadata['type']>([\n 'void',\n 'bool',\n 'i8',\n 'u8',\n 'i16',\n 'u16',\n 'i32',\n 'u32',\n 'i64',\n 'u64',\n 'f32',\n 'f64',\n 'string',\n 'pointer',\n 'function',\n 'buffer_view',\n]);\n\nconst isNativeTypeMetadata = (\n value: unknown,\n allowVoid: boolean,\n depth = 0\n): value is MuonNativeTypeMetadata => {\n if (\n !isRecord(value) ||\n depth > 16 ||\n !nativeValueTypes.has(value.type as MuonNativeTypeMetadata['type']) ||\n (!allowVoid && value.type === 'void')\n ) {\n return false;\n }\n if (value.type !== 'function') {\n return true;\n }\n return (\n Array.isArray(value.args) &&\n value.args.every((argument) =>\n isNativeTypeMetadata(argument, false, depth + 1)\n ) &&\n isNativeTypeMetadata(value.returnType, true, depth + 1)\n );\n};\n\nconst areNativeTypesEqual = (\n first: MuonNativeTypeMetadata,\n second: MuonNativeTypeMetadata\n): boolean => {\n if (first.type !== second.type) {\n return false;\n }\n if (first.type !== 'function' || second.type !== 'function') {\n return true;\n }\n const firstArguments = first.args ?? [];\n const secondArguments = second.args ?? [];\n if (\n firstArguments.length !== secondArguments.length ||\n first.returnType === undefined ||\n second.returnType === undefined ||\n !areNativeTypesEqual(first.returnType, second.returnType)\n ) {\n return false;\n }\n return firstArguments.every((argument, index) =>\n areNativeTypesEqual(argument, secondArguments[index]!)\n );\n};\n\nconst collectBinaryAttachmentLengths = (\n value: unknown,\n lengths: Map<number, number>\n): boolean => {\n if (Array.isArray(value)) {\n return value.every((element) =>\n collectBinaryAttachmentLengths(element, lengths)\n );\n }\n if (!isRecord(value)) {\n return true;\n }\n if (value.type === 'binary') {\n if (\n !isUnsignedInteger(value.attachment) ||\n !isUnsignedInteger(value.byteLength) ||\n lengths.has(value.attachment)\n ) {\n return false;\n }\n lengths.set(value.attachment, value.byteLength);\n return true;\n }\n return Object.values(value).every((element) =>\n collectBinaryAttachmentLengths(element, lengths)\n );\n};\n\nconst getContiguousBinaryAttachmentLengths = (\n value: unknown\n): readonly number[] | undefined => {\n const descriptors = new Map<number, number>();\n if (!collectBinaryAttachmentLengths(value, descriptors)) {\n return undefined;\n }\n const lengths: number[] = [];\n for (let attachment = 0; attachment < descriptors.size; attachment += 1) {\n const byteLength = descriptors.get(attachment);\n if (byteLength === undefined) {\n return undefined;\n }\n lengths.push(byteLength);\n }\n return lengths;\n};\n\nconst copyArrayBufferView = (value: ArrayBufferView): ArrayBuffer => {\n const copy = new Uint8Array(value.byteLength);\n copy.set(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));\n return copy.buffer;\n};\n\nconst encodeArgumentValue = (\n value: unknown,\n attachments: ArrayBuffer[],\n ancestors: Set<object>\n): unknown => {\n let payload: ArrayBuffer | undefined;\n if (value instanceof ArrayBuffer) {\n payload = value.slice(0);\n } else if (ArrayBuffer.isView(value)) {\n payload = copyArrayBufferView(value);\n }\n\n if (payload !== undefined) {\n const attachment = attachments.length;\n attachments.push(payload);\n return {\n type: 'binary',\n attachment,\n byteLength: payload.byteLength,\n };\n }\n\n if (Array.isArray(value)) {\n if (ancestors.has(value)) {\n throw new TypeError('WebView RPC arguments cannot contain cycles');\n }\n ancestors.add(value);\n const encoded = value.map((element) =>\n encodeArgumentValue(element, attachments, ancestors)\n );\n ancestors.delete(value);\n return encoded;\n }\n\n if (isRecord(value)) {\n if (ancestors.has(value)) {\n throw new TypeError('WebView RPC arguments cannot contain cycles');\n }\n ancestors.add(value);\n const encoded: Record<string, unknown> = {};\n for (const [key, element] of Object.entries(value)) {\n encoded[key] = encodeArgumentValue(element, attachments, ancestors);\n }\n ancestors.delete(value);\n return encoded;\n }\n\n return value;\n};\n\nconst encodeArguments = (arguments_: readonly unknown[]): EncodedArguments => {\n const attachments: ArrayBuffer[] = [];\n const ancestors = new Set<object>();\n const value = arguments_.map((argument) =>\n encodeArgumentValue(argument, attachments, ancestors)\n );\n return { value, attachments, rendererFunctionTransfers: [] };\n};\n\nconst encodeInt64Argument = (value: unknown, unsigned: boolean): string => {\n if (typeof value !== 'number') {\n throw new TypeError(`expected ${unsigned ? 'u64' : 'i64'}`);\n }\n const truncated = Number.isFinite(value) ? Math.trunc(value) : 0;\n const bits = BigInt.asUintN(64, BigInt(truncated));\n return unsigned ? bits.toString() : BigInt.asIntN(64, bits).toString();\n};\n\nconst encodeNumberArgument = (\n value: unknown,\n type: MuonNativeTypeMetadata['type']\n): number => {\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n throw new TypeError(`expected ${type}`);\n }\n const integerRanges: Readonly<\n Partial<Record<MuonNativeTypeMetadata['type'], readonly [number, number]>>\n > = {\n i8: [-128, 127],\n u8: [0, 255],\n i16: [-32768, 32767],\n u16: [0, 65535],\n i32: [-2147483648, 2147483647],\n u32: [0, 4294967295],\n };\n const range = integerRanges[type];\n if (\n range !== undefined &&\n (!Number.isInteger(value) || value < range[0] || value > range[1])\n ) {\n throw new TypeError(`expected ${type}`);\n }\n if (\n type === 'f32' &&\n (value < -3.4028234663852886e38 || value > 3.4028234663852886e38)\n ) {\n throw new TypeError('expected f32');\n }\n return value;\n};\n\nconst encodeNativeArgumentValue = (\n value: unknown,\n type: MuonNativeTypeMetadata,\n attachments: ArrayBuffer[],\n rendererFunctionTransfers: number[],\n encodeFunctionValue: EncodeFunctionValue\n): unknown => {\n switch (type.type) {\n case 'bool':\n if (typeof value !== 'boolean') {\n throw new TypeError('expected bool');\n }\n return value;\n case 'i8':\n case 'u8':\n case 'i16':\n case 'u16':\n case 'i32':\n case 'u32':\n case 'f32':\n case 'f64':\n return encodeNumberArgument(value, type.type);\n case 'i64':\n return encodeInt64Argument(value, false);\n case 'u64':\n return encodeInt64Argument(value, true);\n case 'pointer':\n if (value === null || value === undefined) {\n return null;\n }\n if (\n typeof value !== 'number' ||\n !Number.isFinite(value) ||\n !Number.isInteger(value) ||\n value < 0 ||\n value >= 2 ** 64\n ) {\n throw new TypeError('expected pointer');\n }\n return value;\n case 'string':\n if (value === null || value === undefined) {\n return null;\n }\n if (typeof value !== 'string' || value.includes('\\0')) {\n throw new TypeError('expected string');\n }\n return value;\n case 'buffer_view': {\n let payload: ArrayBuffer;\n if (value instanceof ArrayBuffer) {\n payload = value.slice(0);\n } else if (ArrayBuffer.isView(value)) {\n payload = copyArrayBufferView(value);\n } else {\n throw new TypeError('expected buffer_view');\n }\n const attachment = attachments.length;\n attachments.push(payload);\n return { type: 'binary', attachment, byteLength: payload.byteLength };\n }\n case 'function':\n if (value === null || value === undefined) {\n return null;\n }\n return encodeFunctionValue(value, type, rendererFunctionTransfers);\n case 'void':\n throw new TypeError('void arguments are unavailable');\n }\n};\n\nconst encodeNativeArguments = (\n function_: MuonNativeFunctionMetadata,\n arguments_: readonly unknown[],\n encodeFunctionValue: EncodeFunctionValue,\n releaseRendererFunctionTransfers: (functionIds: readonly number[]) => void\n): EncodedArguments => {\n if (arguments_.length !== function_.args.length) {\n throw new TypeError(\n `Invalid argument count for ${function_.namespace}.${function_.publicName}`\n );\n }\n const attachments: ArrayBuffer[] = [];\n const rendererFunctionTransfers: number[] = [];\n let currentIndex = 0;\n try {\n const value = arguments_.map((argument, index) => {\n currentIndex = index;\n return encodeNativeArgumentValue(\n argument,\n function_.args[index]!,\n attachments,\n rendererFunctionTransfers,\n encodeFunctionValue\n );\n });\n return { value, attachments, rendererFunctionTransfers };\n } catch (error) {\n releaseRendererFunctionTransfers(rendererFunctionTransfers);\n const diagnostic = error instanceof Error ? error.message : 'invalid value';\n throw new TypeError(`Invalid argument ${currentIndex}: ${diagnostic}`);\n }\n};\n\nconst decodeNativeResult = (\n value: unknown,\n type: MuonNativeTypeMetadata,\n decodeFunctionValue: DecodeFunctionValue\n): unknown => {\n if (type.type === 'void') {\n return undefined;\n }\n if (type.type === 'i64' || type.type === 'u64') {\n if (typeof value !== 'string') {\n throw new TypeError('Android native 64-bit result is invalid');\n }\n const parsed = BigInt(value);\n return Number(\n type.type === 'i64'\n ? BigInt.asIntN(64, parsed)\n : BigInt.asIntN(64, BigInt.asUintN(64, parsed))\n );\n }\n if (type.type === 'string') {\n if (value !== null && typeof value !== 'string') {\n throw new TypeError('Android native string result is invalid');\n }\n return value;\n }\n if (type.type === 'bool') {\n if (typeof value !== 'boolean') {\n throw new TypeError('Android native bool result is invalid');\n }\n return value;\n }\n if (type.type === 'function') {\n if (value === null) {\n return null;\n }\n return decodeFunctionValue(value, type);\n }\n if (type.type === 'buffer_view') {\n throw new TypeError('Android native result transport is invalid');\n }\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n throw new TypeError('Android native numeric result is invalid');\n }\n return value;\n};\n\nconst decodeHostNativeValue = (\n value: unknown,\n type: MuonNativeTypeMetadata,\n attachments: readonly (ArrayBuffer | undefined)[],\n decodeFunctionValue: DecodeFunctionValue\n): unknown => {\n if (type.type !== 'buffer_view') {\n return decodeNativeResult(value, type, decodeFunctionValue);\n }\n if (\n !isRecord(value) ||\n value.type !== 'binary' ||\n !isUnsignedInteger(value.attachment) ||\n !isUnsignedInteger(value.byteLength)\n ) {\n throw new TypeError('Android native binary value is invalid');\n }\n const payload = attachments[value.attachment];\n if (payload === undefined || payload.byteLength !== value.byteLength) {\n throw new TypeError('Android native binary attachment is missing');\n }\n return payload;\n};\n\nconst createAbortError = (): DOMException =>\n new DOMException('The operation was aborted', 'AbortError');\n\n/**\n * Encodes one binary attachment into the transport-independent RPC frame.\n *\n * @param frame - Frame metadata and payload.\n * @returns A new buffer containing the frame header and payload.\n */\nexport const encodeMuonWebViewRpcBinaryFrame = (\n frame: MuonWebViewRpcBinaryFrame\n): ArrayBuffer => {\n if (\n !Number.isInteger(frame.callId) ||\n frame.callId <= 0 ||\n frame.callId > maximumCallId\n ) {\n throw new RangeError('WebView RPC callId is out of range');\n }\n if (!isUnsignedInteger(frame.attachment)) {\n throw new RangeError('WebView RPC attachment is out of range');\n }\n\n const encoded = new ArrayBuffer(\n binaryHeaderLength + frame.payload.byteLength\n );\n const bytes = new Uint8Array(encoded);\n bytes.set(binaryMagic, 0);\n bytes[4] = protocolVersion;\n bytes[5] =\n frame.kind === 'argument'\n ? 1\n : frame.kind === 'result'\n ? 2\n : frame.kind === 'renderer-argument'\n ? 3\n : 4;\n const view = new DataView(encoded);\n view.setUint32(8, frame.callId);\n view.setUint32(12, frame.attachment);\n bytes.set(new Uint8Array(frame.payload), binaryHeaderLength);\n return encoded;\n};\n\n/**\n * Decodes and validates one transport-independent RPC binary frame.\n *\n * @param message - Candidate frame received from the WebView channel.\n * @returns The decoded frame, or `undefined` when the message is malformed.\n */\nexport const decodeMuonWebViewRpcBinaryFrame = (\n message: ArrayBuffer\n): MuonWebViewRpcBinaryFrame | undefined => {\n if (message.byteLength < binaryHeaderLength) {\n return undefined;\n }\n\n const bytes = new Uint8Array(message);\n if (\n bytes[0] !== binaryMagic[0] ||\n bytes[1] !== binaryMagic[1] ||\n bytes[2] !== binaryMagic[2] ||\n bytes[3] !== binaryMagic[3] ||\n bytes[4] !== protocolVersion ||\n (bytes[5] !== 1 && bytes[5] !== 2 && bytes[5] !== 3 && bytes[5] !== 4) ||\n bytes[6] !== 0 ||\n bytes[7] !== 0\n ) {\n return undefined;\n }\n\n const view = new DataView(message);\n const callId = view.getUint32(8);\n if (callId === 0 || callId > maximumCallId) {\n return undefined;\n }\n\n return {\n kind:\n bytes[5] === 1\n ? 'argument'\n : bytes[5] === 2\n ? 'result'\n : bytes[5] === 3\n ? 'renderer-argument'\n : 'renderer-result',\n callId,\n attachment: view.getUint32(12),\n payload: message.slice(binaryHeaderLength),\n };\n};\n\n/**\n * Adapts an AndroidX WebKit JavaScript object to the RPC transport contract.\n *\n * @param bridge - Object injected by `WebViewCompat.addWebMessageListener`.\n * @returns A transport backed by that object.\n */\nexport const createMuonWebViewRpcTransport = (\n bridge: MuonWebViewJavaScriptBridge\n): MuonWebViewRpcTransport => {\n let handler: MuonWebViewRpcMessageHandler | undefined = undefined;\n return {\n send: (message) => bridge.postMessage(message),\n setMessageHandler: (nextHandler) => {\n handler = nextHandler;\n bridge.onmessage =\n nextHandler === undefined\n ? null\n : (event) => {\n handler?.(event.data);\n };\n },\n };\n};\n\n/**\n * Creates a JavaScript RPC client for an Android WebView message channel.\n *\n * @param transport - Platform-specific bidirectional message transport.\n * @returns The RPC client bound to the transport.\n */\nexport const createMuonWebViewRpcClient = (\n transport: MuonWebViewRpcTransport,\n rendererMetadata?: MuonAndroidRendererMetadata\n): MuonWebViewRpcClient => {\n const pendingCalls = new Map<number, PendingCall>();\n const rendererFunctionIds = new WeakMap<Function, number>();\n const rendererFunctions = new Map<number, RendererFunctionSource>();\n const pendingRendererFunctionCalls = new Map<\n number,\n PendingRendererFunctionCall\n >();\n const rendererResultTransfers = new Map<number, readonly number[]>();\n const pluginProxyStates = new WeakMap<Function, PluginFunctionProxyState>();\n const livePluginProxyStates = new Set<PluginFunctionProxyState>();\n const functionsByPath = new Map<string, MuonNativeFunctionMetadata>(\n (rendererMetadata?.functions ?? []).map(\n (function_) =>\n [`${function_.namespace}.${function_.publicName}`, function_] as const\n )\n );\n let nextCallId = 1;\n let nextRendererFunctionId = 1;\n let disposed = false;\n\n const sendTextMessage = (value: Record<string, unknown>): void => {\n transport.send(JSON.stringify({ version: protocolVersion, ...value }));\n };\n\n const releaseRendererFunctionIfIdle = (functionId: number): void => {\n const source = rendererFunctions.get(functionId);\n if (\n source !== undefined &&\n source.pendingTransfers === 0 &&\n source.leases.size === 0\n ) {\n rendererFunctions.delete(functionId);\n }\n };\n\n const releaseRendererFunctionTransfers = (\n functionIds: readonly number[]\n ): void => {\n for (const functionId of functionIds) {\n const source = rendererFunctions.get(functionId);\n if (source !== undefined && source.pendingTransfers > 0) {\n source.pendingTransfers -= 1;\n releaseRendererFunctionIfIdle(functionId);\n }\n }\n };\n\n let pluginProxyFinalizer:\n FinalizationRegistry<PluginFunctionProxyState> | undefined;\n\n const releasePluginProxy = (state: PluginFunctionProxyState): void => {\n if (state.released) {\n return;\n }\n state.released = true;\n livePluginProxyStates.delete(state);\n pluginProxyFinalizer?.unregister(state);\n if (!disposed) {\n sendTextMessage({\n type: 'plugin-proxy-release',\n proxyId: state.proxyId,\n leaseToken: state.leaseToken,\n });\n }\n };\n\n if (typeof FinalizationRegistry === 'function') {\n pluginProxyFinalizer = new FinalizationRegistry((state) => {\n try {\n releasePluginProxy(state);\n } catch {\n // A collected proxy has no caller to observe a closed transport.\n }\n });\n }\n\n const encodeFunctionValue: EncodeFunctionValue = (\n value,\n type,\n rendererFunctionTransfers\n ) => {\n if (typeof value !== 'function') {\n throw new TypeError('expected function');\n }\n const proxy = pluginProxyStates.get(value);\n if (proxy !== undefined) {\n if (proxy.released) {\n throw new TypeError('muon function proxy is released');\n }\n if (!areNativeTypesEqual(proxy.type, type)) {\n throw new TypeError('function signature mismatch');\n }\n return {\n type: 'function',\n kind: 'plugin-proxy',\n proxyId: proxy.proxyId,\n leaseToken: proxy.leaseToken,\n };\n }\n if (rendererMetadata === undefined) {\n throw new TypeError('renderer function context is unavailable');\n }\n\n let functionId = rendererFunctionIds.get(value);\n let source =\n functionId === undefined ? undefined : rendererFunctions.get(functionId);\n if (source === undefined) {\n if (nextRendererFunctionId > maximumCallId) {\n throw new RangeError('Renderer function ids were exhausted');\n }\n functionId = nextRendererFunctionId;\n nextRendererFunctionId += 1;\n source = {\n value: value as (...arguments_: readonly unknown[]) => unknown,\n leases: new Set<string>(),\n pendingTransfers: 0,\n };\n rendererFunctionIds.set(value, functionId);\n rendererFunctions.set(functionId, source);\n }\n source.pendingTransfers += 1;\n const transferredFunctionId = functionId;\n if (transferredFunctionId === undefined) {\n throw new TypeError('Renderer function identity is unavailable');\n }\n rendererFunctionTransfers.push(transferredFunctionId);\n return {\n type: 'function',\n kind: 'renderer-source',\n rendererContextId: rendererMetadata.contextId,\n functionId: transferredFunctionId,\n };\n };\n\n const invokeCall = (\n target:\n | {\n readonly kind: 'plugin';\n readonly capabilityId: string;\n readonly functionPath: string;\n readonly functionMetadata: MuonNativeFunctionMetadata | undefined;\n }\n | {\n readonly kind: 'plugin-proxy';\n readonly state: PluginFunctionProxyState;\n },\n arguments_: readonly unknown[],\n options: MuonWebViewRpcCallOptions | undefined\n ): Promise<unknown> => {\n if (disposed) {\n return Promise.reject(new Error('muon WebView RPC client was disposed'));\n }\n if (target.kind === 'plugin-proxy' && target.state.released) {\n return Promise.reject(new Error('muon function proxy is released'));\n }\n if (options?.signal?.aborted === true) {\n return Promise.reject(createAbortError());\n }\n if (nextCallId > maximumCallId) {\n return Promise.reject(new RangeError('WebView RPC callId was exhausted'));\n }\n\n const callId = nextCallId;\n nextCallId += 1;\n let encodedArguments: EncodedArguments;\n let callMessage: string;\n let returnType: MuonNativeTypeMetadata | undefined;\n try {\n if (target.kind === 'plugin') {\n encodedArguments =\n target.functionMetadata === undefined\n ? encodeArguments(arguments_)\n : encodeNativeArguments(\n target.functionMetadata,\n arguments_,\n encodeFunctionValue,\n releaseRendererFunctionTransfers\n );\n returnType = target.functionMetadata?.returnType;\n callMessage = JSON.stringify({\n version: protocolVersion,\n type: 'call',\n callId,\n capabilityId: target.capabilityId,\n functionPath: target.functionPath,\n arguments: encodedArguments.value,\n });\n } else {\n const functionArguments = target.state.type.args;\n const functionReturnType = target.state.type.returnType;\n if (\n functionArguments === undefined ||\n functionReturnType === undefined\n ) {\n throw new TypeError('muon function proxy signature is invalid');\n }\n encodedArguments = encodeNativeArguments(\n {\n id: target.state.proxyId,\n namespace: 'muon',\n name: 'proxy',\n publicName: 'proxy',\n capabilityId: 'proxy',\n args: functionArguments,\n returnType: functionReturnType,\n },\n arguments_,\n encodeFunctionValue,\n releaseRendererFunctionTransfers\n );\n returnType = functionReturnType;\n callMessage = JSON.stringify({\n version: protocolVersion,\n type: 'call',\n callKind: 'plugin-proxy',\n callId,\n proxyId: target.state.proxyId,\n leaseToken: target.state.leaseToken,\n arguments: encodedArguments.value,\n });\n }\n } catch (error) {\n return Promise.reject(error);\n }\n\n return new Promise<unknown>((resolve, reject) => {\n const pending: PendingCall = {\n resolve,\n reject,\n signal: options?.signal,\n returnType,\n rendererFunctionTransfers: encodedArguments.rendererFunctionTransfers,\n abortListener: undefined,\n };\n if (pending.signal !== undefined) {\n pending.abortListener = () => {\n if (takePending(callId) === undefined) {\n return;\n }\n try {\n sendTextMessage({ type: 'cancel', callId });\n } finally {\n reject(createAbortError());\n }\n };\n pending.signal.addEventListener('abort', pending.abortListener, {\n once: true,\n });\n }\n pendingCalls.set(callId, pending);\n\n try {\n transport.send(callMessage);\n encodedArguments.attachments.forEach((payload, attachment) => {\n transport.send(\n encodeMuonWebViewRpcBinaryFrame({\n kind: 'argument',\n callId,\n attachment,\n payload,\n })\n );\n });\n } catch (error) {\n const failed = takePending(callId);\n failed?.reject(error);\n }\n });\n };\n\n const decodeFunctionValue: DecodeFunctionValue = (value, type) => {\n if (\n !isRecord(value) ||\n value.type !== 'function' ||\n value.kind !== 'plugin-proxy' ||\n !Number.isInteger(value.proxyId) ||\n typeof value.proxyId !== 'number' ||\n value.proxyId <= 0 ||\n value.proxyId > maximumCallId ||\n typeof value.leaseToken !== 'string' ||\n value.leaseToken.length === 0\n ) {\n throw new TypeError('Android native function proxy is invalid');\n }\n const state: PluginFunctionProxyState = {\n proxyId: value.proxyId,\n leaseToken: value.leaseToken,\n type,\n released: false,\n };\n const callable = (...arguments_: readonly unknown[]): Promise<unknown> =>\n invokeCall({ kind: 'plugin-proxy', state }, arguments_, undefined);\n const release = (): void => releasePluginProxy(state);\n Object.defineProperty(callable, 'release', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: release,\n });\n const dispose = Reflect.get(Symbol, 'dispose');\n if (typeof dispose === 'symbol') {\n Object.defineProperty(callable, dispose, {\n configurable: false,\n enumerable: false,\n writable: false,\n value: release,\n });\n }\n pluginProxyStates.set(callable, state);\n livePluginProxyStates.add(state);\n pluginProxyFinalizer?.register(callable, state, state);\n return callable;\n };\n\n const detachAbortListener = (pending: PendingCall): void => {\n if (pending.signal !== undefined && pending.abortListener !== undefined) {\n pending.signal.removeEventListener('abort', pending.abortListener);\n pending.abortListener = undefined;\n }\n };\n\n const takePending = (callId: number): PendingCall | undefined => {\n const pending = pendingCalls.get(callId);\n if (pending === undefined) {\n return undefined;\n }\n pendingCalls.delete(callId);\n detachAbortListener(pending);\n releaseRendererFunctionTransfers(pending.rendererFunctionTransfers);\n return pending;\n };\n\n const sendRendererFunctionFailure = (\n callId: number,\n error: unknown\n ): void => {\n const diagnostic = error instanceof Error ? error.message : String(error);\n sendTextMessage({\n type: 'renderer-function-result',\n callId,\n success: false,\n error: diagnostic,\n });\n };\n\n const executeRendererFunctionCall = async (\n pending: PendingRendererFunctionCall\n ): Promise<void> => {\n const source = rendererFunctions.get(pending.functionId);\n if (source === undefined) {\n if (pending.expectsResult && !disposed) {\n sendRendererFunctionFailure(\n pending.callId,\n new Error('Renderer function source is unavailable')\n );\n }\n return;\n }\n try {\n const argumentTypes = pending.functionType.args;\n const returnType = pending.functionType.returnType;\n if (\n argumentTypes === undefined ||\n returnType === undefined ||\n argumentTypes.length !== pending.encodedArguments.length\n ) {\n throw new TypeError('Renderer function signature is invalid');\n }\n const arguments_ = pending.encodedArguments.map((argument, index) =>\n decodeHostNativeValue(\n argument,\n argumentTypes[index]!,\n pending.attachments,\n decodeFunctionValue\n )\n );\n const result = await source.value(...arguments_);\n if (!pending.expectsResult || disposed) {\n return;\n }\n\n const attachments: ArrayBuffer[] = [];\n const rendererFunctionTransfers: number[] = [];\n let encodedResult: unknown = null;\n try {\n if (returnType.type !== 'void') {\n encodedResult = encodeNativeArgumentValue(\n result,\n returnType,\n attachments,\n rendererFunctionTransfers,\n encodeFunctionValue\n );\n }\n } catch (error) {\n releaseRendererFunctionTransfers(rendererFunctionTransfers);\n throw error;\n }\n if (rendererFunctionTransfers.length !== 0) {\n rendererResultTransfers.set(pending.callId, rendererFunctionTransfers);\n }\n try {\n sendTextMessage({\n type: 'renderer-function-result',\n callId: pending.callId,\n success: true,\n value: encodedResult,\n });\n attachments.forEach((payload, attachment) => {\n transport.send(\n encodeMuonWebViewRpcBinaryFrame({\n kind: 'renderer-result',\n callId: pending.callId,\n attachment,\n payload,\n })\n );\n });\n } catch (error) {\n rendererResultTransfers.delete(pending.callId);\n releaseRendererFunctionTransfers(rendererFunctionTransfers);\n throw error;\n }\n } catch (error) {\n if (pending.expectsResult && !disposed) {\n sendRendererFunctionFailure(pending.callId, error);\n }\n }\n };\n\n const beginRendererFunctionCall = (\n pending: PendingRendererFunctionCall\n ): void => {\n pendingRendererFunctionCalls.delete(pending.callId);\n void executeRendererFunctionCall(pending);\n };\n\n const handleRendererFunctionCall = (\n parsed: Record<string, unknown>\n ): void => {\n if (\n !Number.isInteger(parsed.callId) ||\n typeof parsed.callId !== 'number' ||\n parsed.callId <= 0 ||\n parsed.callId > maximumCallId ||\n !Number.isInteger(parsed.functionId) ||\n typeof parsed.functionId !== 'number' ||\n parsed.functionId <= 0 ||\n parsed.functionId > maximumCallId ||\n typeof parsed.expectsResult !== 'boolean' ||\n !isNativeTypeMetadata(parsed.functionType, false) ||\n parsed.functionType.type !== 'function' ||\n !Array.isArray(parsed.arguments) ||\n pendingRendererFunctionCalls.has(parsed.callId)\n ) {\n return;\n }\n const expectedAttachmentLengths = getContiguousBinaryAttachmentLengths(\n parsed.arguments\n );\n if (expectedAttachmentLengths === undefined) {\n if (parsed.expectsResult) {\n sendRendererFunctionFailure(\n parsed.callId,\n new TypeError('Renderer function binary descriptors are invalid')\n );\n }\n return;\n }\n const pending: PendingRendererFunctionCall = {\n callId: parsed.callId,\n functionId: parsed.functionId,\n expectsResult: parsed.expectsResult,\n functionType: parsed.functionType,\n encodedArguments: parsed.arguments,\n expectedAttachmentLengths,\n attachments: new Array<ArrayBuffer | undefined>(\n expectedAttachmentLengths.length\n ),\n receivedAttachmentCount: 0,\n };\n pendingRendererFunctionCalls.set(pending.callId, pending);\n if (expectedAttachmentLengths.length === 0) {\n beginRendererFunctionCall(pending);\n }\n };\n\n const handleTextMessage = (message: string): void => {\n let parsed: unknown;\n try {\n parsed = JSON.parse(message) as unknown;\n } catch {\n return;\n }\n if (!isRecord(parsed) || parsed.version !== protocolVersion) {\n return;\n }\n\n if (parsed.type === 'renderer-function-call') {\n handleRendererFunctionCall(parsed);\n return;\n }\n if (parsed.type === 'renderer-function-lease') {\n if (\n !Number.isInteger(parsed.functionId) ||\n typeof parsed.functionId !== 'number' ||\n parsed.functionId <= 0 ||\n typeof parsed.leaseToken !== 'string' ||\n parsed.leaseToken.length === 0 ||\n typeof parsed.acquire !== 'boolean'\n ) {\n return;\n }\n const source = rendererFunctions.get(parsed.functionId);\n if (source === undefined) {\n return;\n }\n if (parsed.acquire) {\n source.leases.add(parsed.leaseToken);\n } else {\n source.leases.delete(parsed.leaseToken);\n releaseRendererFunctionIfIdle(parsed.functionId);\n }\n return;\n }\n if (parsed.type === 'renderer-function-result-consumed') {\n if (\n !Number.isInteger(parsed.callId) ||\n typeof parsed.callId !== 'number' ||\n parsed.callId <= 0\n ) {\n return;\n }\n const transfers = rendererResultTransfers.get(parsed.callId);\n if (transfers !== undefined) {\n rendererResultTransfers.delete(parsed.callId);\n releaseRendererFunctionTransfers(transfers);\n }\n return;\n }\n if (\n parsed.type !== 'result' ||\n !Number.isInteger(parsed.callId) ||\n typeof parsed.callId !== 'number' ||\n parsed.callId <= 0 ||\n parsed.callId > maximumCallId ||\n typeof parsed.success !== 'boolean'\n ) {\n return;\n }\n\n const pending = takePending(parsed.callId);\n if (pending === undefined) {\n return;\n }\n if (parsed.success) {\n try {\n if (pending.returnType === undefined) {\n pending.resolve(parsed.value);\n } else {\n if (parsed.valueType !== pending.returnType.type) {\n throw new TypeError('Android native result type is invalid');\n }\n pending.resolve(\n decodeNativeResult(\n parsed.value,\n pending.returnType,\n decodeFunctionValue\n )\n );\n }\n } catch (error) {\n pending.reject(error);\n }\n } else {\n pending.reject(\n new Error(\n typeof parsed.error === 'string'\n ? parsed.error\n : 'Native WebView RPC call failed'\n )\n );\n }\n };\n\n const handleBinaryMessage = (message: ArrayBuffer): void => {\n const frame = decodeMuonWebViewRpcBinaryFrame(message);\n if (frame === undefined) {\n return;\n }\n if (frame.kind === 'renderer-argument') {\n const pending = pendingRendererFunctionCalls.get(frame.callId);\n if (\n pending === undefined ||\n frame.attachment >= pending.expectedAttachmentLengths.length ||\n pending.expectedAttachmentLengths[frame.attachment] !==\n frame.payload.byteLength ||\n pending.attachments[frame.attachment] !== undefined\n ) {\n return;\n }\n pending.attachments[frame.attachment] = frame.payload;\n pending.receivedAttachmentCount += 1;\n if (\n pending.receivedAttachmentCount ===\n pending.expectedAttachmentLengths.length\n ) {\n beginRendererFunctionCall(pending);\n }\n return;\n }\n if (frame.kind !== 'result') {\n return;\n }\n const pending = takePending(frame.callId);\n if (pending === undefined) {\n return;\n }\n if (\n pending.returnType !== undefined &&\n pending.returnType.type !== 'buffer_view'\n ) {\n pending.reject(new TypeError('Unexpected Android native binary result'));\n return;\n }\n pending.resolve(frame.payload);\n };\n\n transport.setMessageHandler((message) => {\n if (disposed) {\n return;\n }\n if (typeof message === 'string') {\n handleTextMessage(message);\n } else {\n handleBinaryMessage(message);\n }\n });\n\n const call = (\n capabilityId: string,\n functionPath: string,\n arguments_: readonly unknown[],\n options?: MuonWebViewRpcCallOptions\n ): Promise<unknown> => {\n return invokeCall(\n {\n kind: 'plugin',\n capabilityId,\n functionPath,\n functionMetadata: functionsByPath.get(functionPath),\n },\n arguments_,\n options\n );\n };\n\n const dispose = (): void => {\n if (disposed) {\n return;\n }\n disposed = true;\n transport.setMessageHandler(undefined);\n try {\n transport.send(\n JSON.stringify({ version: protocolVersion, type: 'release' })\n );\n } catch {\n // The JavaScript context is being released, so transport errors are final.\n }\n for (const pending of pendingCalls.values()) {\n detachAbortListener(pending);\n releaseRendererFunctionTransfers(pending.rendererFunctionTransfers);\n pending.reject(new Error('muon WebView RPC client was disposed'));\n }\n pendingCalls.clear();\n pendingRendererFunctionCalls.clear();\n for (const transfers of rendererResultTransfers.values()) {\n releaseRendererFunctionTransfers(transfers);\n }\n rendererResultTransfers.clear();\n rendererFunctions.clear();\n for (const state of livePluginProxyStates) {\n state.released = true;\n pluginProxyFinalizer?.unregister(state);\n }\n livePluginProxyStates.clear();\n };\n\n return {\n call,\n dispose,\n getPendingCallCount: () => pendingCalls.size,\n };\n};\n\n/**\n * Installs the capability call boundary consumed by generated muon modules.\n *\n * @param client - WebView RPC client used for generated capability calls.\n * @param target - Global-like object on which to install the boundary.\n * @returns A function that restores the previous property state.\n */\nexport const installMuonWebViewCapabilityBridge = (\n client: MuonWebViewRpcClient,\n target: Record<PropertyKey, unknown> = globalThis as unknown as Record<\n PropertyKey,\n unknown\n >\n): (() => void) => {\n const property = '__muon_plugin_call';\n const previous = Object.getOwnPropertyDescriptor(target, property);\n Object.defineProperty(target, property, {\n configurable: true,\n enumerable: false,\n writable: true,\n value: (\n capabilityId: string,\n functionPath: string,\n arguments_: readonly unknown[]\n ) => client.call(capabilityId, functionPath, arguments_),\n });\n\n return () => {\n if (previous === undefined) {\n Reflect.deleteProperty(target, property);\n } else {\n Object.defineProperty(target, property, previous);\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 { createMuonAndroidSimpleApi } from './android-api.js';\nimport { installMuonAndroidNativePluginApi } from './native-plugin-api.js';\nimport type { MuonAndroidRendererMetadata } from './native-plugin-metadata.js';\nimport {\n createMuonWebViewRpcClient,\n createMuonWebViewRpcTransport,\n installMuonWebViewCapabilityBridge,\n type MuonWebViewJavaScriptBridge,\n} from './webview-rpc.js';\n\n/**\n * Installs the packaged Android API before application scripts execute.\n * @param bridge - Native WebView transport restricted to the trusted origin.\n * @param metadata - Metadata from the native context for this document.\n * @param target - Object receiving the public API and capability bridge.\n * @returns Releases the context and restores previous global properties.\n */\nexport const bootstrapMuonAndroid = (\n bridge: MuonWebViewJavaScriptBridge,\n metadata: MuonAndroidRendererMetadata,\n target: Record<PropertyKey, unknown>\n): (() => void) => {\n const client = createMuonWebViewRpcClient(\n createMuonWebViewRpcTransport(bridge),\n metadata\n );\n const uninstallCapabilities = installMuonWebViewCapabilityBridge(\n client,\n target\n );\n const uninstallApi = installMuonAndroidNativePluginApi(\n client,\n metadata,\n {\n muon: createMuonAndroidSimpleApi(client, {\n 'muon.browser': 'browser-capability',\n 'muon.environments': 'environment-capability',\n 'muon.fs': 'fs-capability',\n }),\n },\n target\n );\n return () => {\n uninstallApi();\n uninstallCapabilities();\n client.dispose();\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\n/** Value kinds supported by the native Muon plugin ABI. */\nexport type MuonNativeValueType =\n | 'void'\n | 'bool'\n | 'i8'\n | 'u8'\n | 'i16'\n | 'u16'\n | 'i32'\n | 'u32'\n | 'i64'\n | 'u64'\n | 'f32'\n | 'f64'\n | 'string'\n | 'pointer'\n | 'function'\n | 'buffer_view';\n\n/** Recursive value metadata copied from one loaded native plugin. */\nexport interface MuonNativeTypeMetadata {\n /** ABI value kind. */\n readonly type: MuonNativeValueType;\n\n /** Argument types when this value is a function. */\n readonly args?: readonly MuonNativeTypeMetadata[];\n\n /** Return type when this value is a function. */\n readonly returnType?: MuonNativeTypeMetadata;\n}\n\n/** One namespace produced by a loaded native plugin. */\nexport interface MuonNativeNamespaceMetadata {\n /** Dot-separated namespace exposed in simple mode. */\n readonly namespace: string;\n\n /** Trusted plugin setup source executed after allowed functions exist. */\n readonly setupScript: string;\n\n /** Function property names that setup source may use. */\n readonly allowedFunctions: readonly string[];\n}\n\n/** One callable function produced by a loaded native plugin. */\nexport interface MuonNativeFunctionMetadata {\n /** Runtime-wide native function identifier. */\n readonly id: number;\n\n /** Dot-separated namespace owning this function. */\n readonly namespace: string;\n\n /** Property name exposed in simple mode. */\n readonly name: string;\n\n /** Public name used by capability policies. */\n readonly publicName: string;\n\n /** Capability id assigned by the Android package registry. */\n readonly capabilityId: string;\n\n /** Ordered native argument types. */\n readonly args: readonly MuonNativeTypeMetadata[];\n\n /** Native result type. */\n readonly returnType: MuonNativeTypeMetadata;\n}\n\n/** Renderer metadata captured before the trusted WebView document starts. */\nexport interface MuonAndroidRendererMetadata {\n /** Transport schema version. */\n readonly version: 1;\n\n /** Native RPC context that owns renderer function sources. */\n readonly contextId: number;\n\n /** Page exposure mode selected by the Android host. */\n readonly mode: 'simple' | 'validate';\n\n /** Loaded and allowed plugin namespaces. */\n readonly namespaces: readonly MuonNativeNamespaceMetadata[];\n\n /** Loaded and allowed plugin functions. */\n readonly functions: readonly MuonNativeFunctionMetadata[];\n}\n\nconst valueTypes = new Set<MuonNativeValueType>([\n 'void',\n 'bool',\n 'i8',\n 'u8',\n 'i16',\n 'u16',\n 'i32',\n 'u32',\n 'i64',\n 'u64',\n 'f32',\n 'f64',\n 'string',\n 'pointer',\n 'function',\n 'buffer_view',\n]);\nconst identifierExpression = /^[A-Za-z_$][A-Za-z0-9_$]*$/u;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst readType = (\n value: unknown,\n allowVoid: boolean,\n depth: number\n): MuonNativeTypeMetadata => {\n if (!isRecord(value) || depth > 16 || !valueTypes.has(value.type as never)) {\n throw new TypeError('Android native plugin type metadata is invalid');\n }\n const type = value.type as MuonNativeValueType;\n if (!allowVoid && type === 'void') {\n throw new TypeError('Android native plugin argument type is invalid');\n }\n if (type !== 'function') {\n return Object.freeze({ type });\n }\n if (!Array.isArray(value.args) || !isRecord(value.returnType)) {\n throw new TypeError('Android native function metadata is invalid');\n }\n const args = value.args.map((argument) =>\n readType(argument, false, depth + 1)\n );\n const returnType = readType(value.returnType, true, depth + 1);\n return Object.freeze({ type, args: Object.freeze(args), returnType });\n};\n\nconst readIdentifier = (value: unknown, label: string): string => {\n if (typeof value !== 'string' || !identifierExpression.test(value)) {\n throw new TypeError(`Android native plugin ${label} is invalid`);\n }\n return value;\n};\n\nconst readNamespaceName = (value: unknown): string => {\n if (\n typeof value !== 'string' ||\n value.split('.').some((segment) => !identifierExpression.test(segment))\n ) {\n throw new TypeError('Android native plugin namespace is invalid');\n }\n return value;\n};\n\n/**\n * Validates renderer metadata injected by the trusted Android host.\n *\n * @param value - Candidate document-start metadata value.\n * @returns A deeply immutable metadata snapshot.\n */\nexport const readMuonAndroidRendererMetadata = (\n value: unknown\n): MuonAndroidRendererMetadata => {\n if (\n !isRecord(value) ||\n value.version !== 1 ||\n !Number.isInteger(value.contextId) ||\n typeof value.contextId !== 'number' ||\n value.contextId <= 0 ||\n value.contextId > 0x7fffffff ||\n (value.mode !== 'simple' && value.mode !== 'validate') ||\n !Array.isArray(value.namespaces) ||\n !Array.isArray(value.functions)\n ) {\n throw new TypeError('Android native plugin renderer metadata is invalid');\n }\n\n const namespaces = value.namespaces.map((candidate) => {\n if (\n !isRecord(candidate) ||\n typeof candidate.setupScript !== 'string' ||\n !Array.isArray(candidate.allowedFunctions)\n ) {\n throw new TypeError(\n 'Android native plugin namespace metadata is invalid'\n );\n }\n const allowedFunctions = candidate.allowedFunctions.map((name) =>\n readIdentifier(name, 'allowed function name')\n );\n return Object.freeze({\n namespace: readNamespaceName(candidate.namespace),\n setupScript: candidate.setupScript,\n allowedFunctions: Object.freeze(allowedFunctions),\n });\n });\n\n const functions = value.functions.map((candidate) => {\n if (\n !isRecord(candidate) ||\n !Number.isInteger(candidate.id) ||\n typeof candidate.id !== 'number' ||\n candidate.id < 0 ||\n candidate.id > 0xffffffff ||\n typeof candidate.capabilityId !== 'string' ||\n candidate.capabilityId.length === 0 ||\n !Array.isArray(candidate.args)\n ) {\n throw new TypeError('Android native plugin function metadata is invalid');\n }\n return Object.freeze({\n id: candidate.id,\n namespace: readNamespaceName(candidate.namespace),\n name: readIdentifier(candidate.name, 'function name'),\n publicName: readIdentifier(candidate.publicName, 'public function name'),\n capabilityId: candidate.capabilityId,\n args: Object.freeze(\n candidate.args.map((argument) => readType(argument, false, 0))\n ),\n returnType: readType(candidate.returnType, true, 0),\n });\n });\n\n return Object.freeze({\n version: 1,\n contextId: value.contextId,\n mode: value.mode,\n namespaces: Object.freeze(namespaces),\n functions: Object.freeze(functions),\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 { bootstrapMuonAndroid } from './bootstrap.js';\nimport { readMuonAndroidRendererMetadata } from './native-plugin-metadata.js';\nimport type { MuonWebViewJavaScriptBridge } from './webview-rpc.js';\n\nif (window === window.top) {\n const dispose = bootstrapMuonAndroid(\n Reflect.get(globalThis, 'muonAndroidRpc') as MuonWebViewJavaScriptBridge,\n readMuonAndroidRendererMetadata(\n Reflect.get(globalThis, '__muon_android_plugin_metadata')\n ),\n globalThis as unknown as Record<PropertyKey, unknown>\n );\n window.addEventListener('pagehide', dispose, { once: true });\n}\n"],"mappings":";;;;;;;;;;;CAOA,IAAM,uBAAuB;EAC3B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CAEA,IAAM,2BAA2B;EAC/B;EACA;EACA;EACA;CACF;CAEA,IAAM,0BAA0B;EAC9B;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CAG+C;EAC7C,GAAG,qBAAqB,KAAK,SAAS,gBAAgB,MAAe;EACrE,GAAG,yBAAyB,KACzB,SAAS,qBAAqB,MACjC;EACA,GAAG,wBAAwB,KAAK,SAAS,WAAW,MAAe;CACrE;CA+ZA,IAAM,uBACJ,QACA,cACA,WACA,kBACiD;EACjD,MAAM,UAAU,cAAc,KAC3B,SACC,CACE,MACA,YAAY;GACV,MAAM,OAAO,KAAK,cAAc,GAAG,UAAU,GAAG,QAAQ,CAAC,CAAC;EAC5D,CACF,CACJ;EACA,OAAO,OAAO,OAAO,OAAO,YAAY,OAAO,CAAC;CAGlD;CAEA,IAAM,kBAAkB,OAAU,WAAyC;EACzE,MAAM,QAAQ,MAAM;EACpB,IAAI,OAAO,UAAU,UACnB,MAAM,IAAI,UAAU,uCAAuC;EAE7D,OAAO,KAAK,MAAM,KAAK;CACzB;CAEA,IAAMA,cAAY,UAChB,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;CAErE,IAAM,gBAAgB,OAAe,OAAO,WAAmB;EAC7D,IAAI,OAAO,UAAU,YAAY,MAAM,WAAW,GAChD,MAAM,IAAI,UAAU,GAAG,KAAK,4BAA4B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BAAgB,GACxC,gCACE,QAAQ,IAAI,YAAY,gCAAgC,CAC1D,GACA,UACF;EACA,OAAO,iBAAiB,YAAY,SAAS,EAAE,MAAM,KAAK,CAAC;CAC7D"}
|
|
1
|
+
{"version":3,"file":"renderer.js","names":["isRecord","isRecord"],"sources":["../../function-paths.ts","../../renderer/android-api.ts","../../renderer/native-plugin-api.ts","../../renderer/webview-rpc.ts","../../renderer/bootstrap.ts","../../renderer/native-plugin-metadata.ts","../../renderer/entry.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\n/** Browser functions implemented by Android. */\nexport const browserFunctionNames = [\n 'reload',\n 'toggleFullscreen',\n 'enterFullscreen',\n 'exitFullscreen',\n 'zoomIn',\n 'zoomOut',\n 'resetZoom',\n 'close',\n] as const;\n\n/** Environment functions implemented by Android. */\nexport const environmentFunctionNames = [\n 'getVariables',\n 'getConfigValues',\n 'getProcessId',\n 'getRuntimeInfo',\n] as const;\n\n/** Filesystem functions implemented by Android. */\nexport const filesystemFunctionNames = [\n 'readFile',\n 'writeFile',\n 'readTextFile',\n 'writeTextFile',\n 'stat',\n 'lstat',\n 'exists',\n 'access',\n 'readdir',\n 'mkdir',\n 'rm',\n 'unlink',\n 'rmdir',\n 'rename',\n 'copyFile',\n 'appendFile',\n 'appendTextFile',\n 'truncate',\n 'realpath',\n 'readlink',\n 'symlink',\n 'watch',\n] as const;\n\n/** Fully-qualified built-in function paths implemented by the Android backend. */\nexport const muonAndroidBuiltinFunctionPaths = [\n ...browserFunctionNames.map((name) => `muon.browser.${name}` as const),\n ...environmentFunctionNames.map(\n (name) => `muon.environments.${name}` as const\n ),\n ...filesystemFunctionNames.map((name) => `muon.fs.${name}` as const),\n] as const;\n\n/** A built-in function path available on Android. */\nexport type MuonAndroidBuiltinFunctionPath =\n (typeof muonAndroidBuiltinFunctionPaths)[number];\n\nconst escapeRegularExpression = (source: string): string =>\n source.replace(/[\\\\^$+?.()|[\\]{}]/gu, '\\\\$&');\n\nconst createFunctionAllowExpression = (allow: string): RegExp => {\n let source = '^';\n for (let index = 0; index < allow.length; index += 1) {\n const character = allow[index] ?? '';\n const next = allow[index + 1];\n if (character === '*' && next === '*') {\n source += '.*';\n index += 1;\n } else if (character === '*') {\n source += '[^.]*';\n } else {\n source += escapeRegularExpression(character);\n }\n }\n source += '$';\n return new RegExp(source, 'u');\n};\n\n/**\n * Expands Android capability allow patterns into available function paths.\n *\n * @param allows - Exact paths or glob patterns requested by a validate build.\n * @param catalog - Available public functions; defaults to Android builtins.\n * @returns Available Android paths in stable metadata order.\n * @remarks An exact unsupported path, or a pattern matching no Android\n * functions, fails during the build instead of producing a runtime stub.\n */\nexport const expandMuonAndroidFunctionAllows = (\n allows: readonly string[],\n catalog: readonly string[] = muonAndroidBuiltinFunctionPaths\n): readonly string[] => {\n const selected = new Set<string>();\n for (const allow of allows) {\n if (!allow.includes('*')) {\n const functionPath = catalog.find((candidate) => candidate === allow);\n if (functionPath === undefined) {\n throw new Error(`Muon function is unavailable for Android: ${allow}`);\n }\n selected.add(functionPath);\n continue;\n }\n\n const expression = createFunctionAllowExpression(allow);\n const matches = catalog.filter((functionPath) =>\n expression.test(functionPath)\n );\n if (matches.length === 0) {\n throw new Error(\n `Muon function pattern is unavailable for Android: ${allow}`\n );\n }\n for (const functionPath of matches) {\n selected.add(functionPath);\n }\n }\n return catalog.filter((functionPath) => selected.has(functionPath));\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 { MuonWebViewRpcClient } from './webview-rpc.js';\n\nimport {\n browserFunctionNames,\n environmentFunctionNames,\n filesystemFunctionNames,\n} from '../function-paths.js';\nexport {\n muonAndroidBuiltinFunctionPaths,\n expandMuonAndroidFunctionAllows,\n type MuonAndroidBuiltinFunctionPath,\n} from '../function-paths.js';\n\n/** Capability ids assigned to Android built-in namespaces. */\nexport interface MuonAndroidCapabilityIds {\n /** Capability for browser operations. */\n readonly 'muon.browser': string;\n\n /** Capability for environment information. */\n readonly 'muon.environments': string;\n\n /** Capability for sandboxed filesystem operations. */\n readonly 'muon.fs': string;\n}\n\n/** Android browser functions available in simple mode. */\nexport type MuonAndroidBrowserApi = Readonly<\n Record<(typeof browserFunctionNames)[number], () => Promise<void>>\n>;\n\n/** Runtime information reported by the Android WebView backend. */\nexport interface MuonAndroidRuntimeInfo {\n /** Selects the Android arm of the shared runtime-information union. */\n readonly backend: 'android-webview';\n\n /** Android operating-system identifier. */\n readonly os: 'android';\n\n /** User-visible Android release string. */\n readonly osVersion: string;\n\n /** Android SDK level running this application process. */\n readonly apiLevel: number;\n\n /** Primary ABI selected for this process. */\n readonly abi: string;\n\n /** Android application package name. */\n readonly applicationId: string;\n\n /** Android application version name. */\n readonly applicationVersion: string;\n\n /** Package providing WebView to this process. */\n readonly webViewPackage: string;\n\n /** Version of the WebView provider package. */\n readonly webViewVersion: string;\n}\n\n/** Android environment functions available in simple mode. */\nexport interface MuonAndroidEnvironmentsApi {\n /** Returns the current process environment variables. */\n readonly getVariables: () => Promise<Record<string, string>>;\n\n /** Returns the merged application string configuration. */\n readonly getConfigValues: () => Promise<Record<string, string>>;\n\n /** Returns the current Android application process id. */\n readonly getProcessId: () => Promise<number>;\n\n /** Returns Android and WebView runtime information. */\n readonly getRuntimeInfo: () => Promise<MuonAndroidRuntimeInfo>;\n}\n\n/** Options shared by Android filesystem operations. */\nexport interface MuonAndroidFsOperationOptions {\n /** Signal used to request best-effort cancellation. */\n readonly signal?: AbortSignal;\n}\n\n/** Options for reading part or all of a binary file. */\nexport interface MuonAndroidFsReadFileOptions extends MuonAndroidFsOperationOptions {\n /** Non-negative byte offset. */\n readonly position?: number;\n\n /** Maximum number of bytes to return. */\n readonly length?: number;\n}\n\n/** Options for writing binary data. */\nexport interface MuonAndroidFsWriteFileOptions extends MuonAndroidFsOperationOptions {\n /** Non-negative byte offset, or undefined to replace the file. */\n readonly position?: number;\n}\n\n/** Access modes checked by the Android filesystem backend. */\nexport type MuonAndroidFsAccessMode = 'read' | 'write' | 'execute';\n\n/** Options for checking filesystem access. */\nexport interface MuonAndroidFsAccessOptions extends MuonAndroidFsOperationOptions {\n /** Access modes that must all be allowed. */\n readonly mode?: readonly MuonAndroidFsAccessMode[];\n}\n\n/** Options for directory enumeration. */\nexport interface MuonAndroidFsReadDirectoryOptions extends MuonAndroidFsOperationOptions {\n /** Returns metadata-bearing entries when true. */\n readonly withFileTypes?: boolean;\n}\n\n/** Options for directory creation. */\nexport interface MuonAndroidFsMakeDirectoryOptions extends MuonAndroidFsOperationOptions {\n /** Creates missing parent directories when true. */\n readonly recursive?: boolean;\n}\n\n/** Options for recursive or missing-tolerant removal. */\nexport interface MuonAndroidFsRemoveOptions extends MuonAndroidFsOperationOptions {\n /** Removes directory trees when true. */\n readonly recursive?: boolean;\n\n /** Suppresses a missing-path error when true. */\n readonly force?: boolean;\n}\n\n/** Options for copying a regular file. */\nexport interface MuonAndroidFsCopyFileOptions extends MuonAndroidFsOperationOptions {\n /** Replaces an existing destination unless false. */\n readonly overwrite?: boolean;\n}\n\n/** Filesystem entry kinds reported by Android. */\nexport type MuonAndroidFsEntryType =\n | 'file'\n | 'directory'\n | 'symlink'\n | 'blockDevice'\n | 'characterDevice'\n | 'fifo'\n | 'socket'\n | 'other';\n\n/** Metadata returned for an Android filesystem entry. */\nexport interface MuonAndroidFsStats {\n /** Entry kind. */\n readonly type: MuonAndroidFsEntryType;\n\n /** Regular-file byte length, or zero for other entry kinds. */\n readonly size: number;\n\n /** Last modification time in Unix epoch milliseconds. */\n readonly mtimeMs: number;\n\n /** Whether no filesystem write permission bit is set. */\n readonly readonly: boolean;\n\n /** Returns whether this entry is a regular file. */\n readonly isFile: () => boolean;\n\n /** Returns whether this entry is a directory. */\n readonly isDirectory: () => boolean;\n\n /** Returns whether this entry is a symbolic link. */\n readonly isSymbolicLink: () => boolean;\n}\n\n/** Directory entry with Android filesystem metadata. */\nexport interface MuonAndroidFsDirent extends MuonAndroidFsStats {\n /** Entry name relative to the enumerated directory. */\n readonly name: string;\n}\n\n/** Symbolic-link kinds accepted by the shared API. */\nexport type MuonAndroidFsSymlinkType = 'file' | 'dir' | 'junction';\n\n/** Event delivered by an Android filesystem watcher. */\nexport interface MuonAndroidFsWatchEvent {\n /** Event kind. */\n readonly eventType: 'rename' | 'change' | 'error';\n\n /** Changed child name, or null for the watched path itself. */\n readonly filename: string | null;\n\n /** Diagnostic for an error event. */\n readonly message?: string;\n}\n\n/** Listener invoked for Android filesystem watch events. */\nexport type MuonAndroidFsWatchListener = (\n event: MuonAndroidFsWatchEvent\n) => void | Promise<void>;\n\n/** Handle for an active Android filesystem watcher. */\nexport interface MuonAndroidFsWatcher {\n /** Releases the native watcher lease and stops polling. */\n readonly close: () => Promise<void>;\n}\n\n/** Android filesystem functions available in simple mode. */\nexport interface MuonAndroidFsApi {\n /** Reads binary file data. */\n readonly readFile: (\n path: string,\n options?: MuonAndroidFsReadFileOptions\n ) => Promise<ArrayBuffer>;\n\n /** Writes binary file data. */\n readonly writeFile: (\n path: string,\n data: BufferSource,\n options?: MuonAndroidFsWriteFileOptions\n ) => Promise<void>;\n\n /** Reads strict UTF-8 text without NUL bytes. */\n readonly readTextFile: (\n path: string,\n encoding: 'utf8' | 'utf-8',\n options?: MuonAndroidFsOperationOptions\n ) => Promise<string>;\n\n /** Writes strict UTF-8 text without NUL bytes. */\n readonly writeTextFile: (\n path: string,\n data: string,\n encoding: 'utf8' | 'utf-8',\n options?: MuonAndroidFsOperationOptions\n ) => Promise<void>;\n\n /** Reads metadata while following symbolic links. */\n readonly stat: (\n path: string,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<MuonAndroidFsStats>;\n\n /** Reads metadata without following symbolic links. */\n readonly lstat: (\n path: string,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<MuonAndroidFsStats>;\n\n /** Tests whether a path exists. */\n readonly exists: (\n path: string,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<boolean>;\n\n /** Tests requested access modes. */\n readonly access: (\n path: string,\n options?: MuonAndroidFsAccessOptions\n ) => Promise<boolean>;\n\n /** Enumerates a directory as names or metadata-bearing entries. */\n readonly readdir: (\n path: string,\n options?: MuonAndroidFsReadDirectoryOptions\n ) => Promise<string[] | MuonAndroidFsDirent[]>;\n\n /** Creates a directory. */\n readonly mkdir: (\n path: string,\n options?: MuonAndroidFsMakeDirectoryOptions\n ) => Promise<void>;\n\n /** Removes a file or directory tree. */\n readonly rm: (\n path: string,\n options?: MuonAndroidFsRemoveOptions\n ) => Promise<void>;\n\n /** Removes a file or symbolic link. */\n readonly unlink: (\n path: string,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<void>;\n\n /** Removes an empty directory. */\n readonly rmdir: (\n path: string,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<void>;\n\n /** Renames a filesystem entry. */\n readonly rename: (\n oldPath: string,\n newPath: string,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<void>;\n\n /** Copies a regular file. */\n readonly copyFile: (\n source: string,\n destination: string,\n options?: MuonAndroidFsCopyFileOptions\n ) => Promise<void>;\n\n /** Appends binary data to a file. */\n readonly appendFile: (\n path: string,\n data: BufferSource,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<void>;\n\n /** Appends strict UTF-8 text to a file. */\n readonly appendTextFile: (\n path: string,\n data: string,\n encoding: 'utf8' | 'utf-8',\n options?: MuonAndroidFsOperationOptions\n ) => Promise<void>;\n\n /** Truncates or extends a file. */\n readonly truncate: (\n path: string,\n lengthOrOptions?: number | MuonAndroidFsOperationOptions,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<void>;\n\n /** Resolves an existing path to its canonical absolute path. */\n readonly realpath: (\n path: string,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<string>;\n\n /** Reads a symbolic-link target. */\n readonly readlink: (\n path: string,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<string>;\n\n /** Creates a symbolic link. */\n readonly symlink: (\n target: string,\n path: string,\n typeOrOptions?: MuonAndroidFsSymlinkType | MuonAndroidFsOperationOptions,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<void>;\n\n /** Watches a path until the returned handle is closed. */\n readonly watch: (\n path: string,\n listener: MuonAndroidFsWatchListener,\n options?: MuonAndroidFsOperationOptions\n ) => Promise<MuonAndroidFsWatcher>;\n}\n\n/** Built-in API object exposed by Android simple mode. */\nexport interface MuonAndroidSimpleApi {\n /** Operations for the owning Activity and WebView. */\n readonly browser: MuonAndroidBrowserApi;\n\n /** Information about the current Android application process. */\n readonly environments: MuonAndroidEnvironmentsApi;\n\n /** Sandboxed real-path filesystem operations. */\n readonly fs: MuonAndroidFsApi;\n}\n\nconst createVoidNamespace = <TName extends string>(\n client: MuonWebViewRpcClient,\n capabilityId: string,\n namespace: string,\n functionNames: readonly TName[]\n): Readonly<Record<TName, () => Promise<void>>> => {\n const entries = functionNames.map(\n (name) =>\n [\n name,\n async () => {\n await client.call(capabilityId, `${namespace}.${name}`, []);\n },\n ] as const\n );\n return Object.freeze(Object.fromEntries(entries)) as Readonly<\n Record<TName, () => Promise<void>>\n >;\n};\n\nconst parseNativeJson = async <T>(source: Promise<unknown>): Promise<T> => {\n const value = await source;\n if (typeof value !== 'string') {\n throw new TypeError('Android native JSON result is invalid');\n }\n return JSON.parse(value) as T;\n};\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst validatePath = (value: string, name = 'path'): string => {\n if (typeof value !== 'string' || value.length === 0) {\n throw new TypeError(`${name} must be a non-empty string`);\n }\n if (value.includes('\\0')) {\n throw new TypeError(`${name} must not contain NUL`);\n }\n return value;\n};\n\nconst validateSafeUnsignedInteger = (value: number, name: string): number => {\n if (!Number.isSafeInteger(value) || value < 0) {\n throw new TypeError(`${name} must be a non-negative safe integer`);\n }\n return value;\n};\n\nconst validateEncoding = (value: string): 'utf8' | 'utf-8' => {\n if (value !== 'utf8' && value !== 'utf-8') {\n throw new TypeError('encoding must be utf8 or utf-8');\n }\n return value;\n};\n\nconst getOperationSignal = (\n options: MuonAndroidFsOperationOptions | undefined\n): AbortSignal | undefined => {\n if (options === undefined) {\n return undefined;\n }\n if (!isRecord(options)) {\n throw new TypeError('filesystem options must be an object');\n }\n const { signal } = options;\n if (signal !== undefined && !(signal instanceof AbortSignal)) {\n throw new TypeError('signal must be an AbortSignal');\n }\n return signal;\n};\n\nconst normalizeOptionalSafeUnsignedInteger = (\n options: object,\n name: string\n): number | undefined => {\n const value = (options as Record<string, unknown>)[name];\n return value === undefined\n ? undefined\n : validateSafeUnsignedInteger(value as number, name);\n};\n\nconst normalizeReadFileOptions = (\n options: MuonAndroidFsReadFileOptions | undefined\n): Readonly<{ position?: number; length?: number }> => {\n const source = options ?? {};\n const position = normalizeOptionalSafeUnsignedInteger(source, 'position');\n const length = normalizeOptionalSafeUnsignedInteger(source, 'length');\n return Object.freeze({\n ...(position === undefined ? {} : { position }),\n ...(length === undefined ? {} : { length }),\n });\n};\n\nconst normalizeWriteFileOptions = (\n options: MuonAndroidFsWriteFileOptions | undefined\n): Readonly<{ position?: number }> => {\n const source = options ?? {};\n const position = normalizeOptionalSafeUnsignedInteger(source, 'position');\n return Object.freeze(position === undefined ? {} : { position });\n};\n\nconst normalizeBooleanOptions = (\n options: MuonAndroidFsOperationOptions | undefined,\n names: readonly string[]\n): Readonly<Record<string, boolean>> => {\n const source = options ?? {};\n const result: Record<string, boolean> = {};\n for (const name of names) {\n const value = source[name as keyof typeof source];\n if (value !== undefined) {\n if (typeof value !== 'boolean') {\n throw new TypeError(`${name} must be a boolean`);\n }\n result[name] = value;\n }\n }\n return Object.freeze(result);\n};\n\nconst normalizeAccessOptions = (\n options: MuonAndroidFsAccessOptions | undefined\n): Readonly<{ mode?: readonly MuonAndroidFsAccessMode[] }> => {\n if (options?.mode === undefined) {\n return Object.freeze({});\n }\n if (!Array.isArray(options.mode)) {\n throw new TypeError('mode must be an array');\n }\n const mode = options.mode.map((value) => {\n if (value !== 'read' && value !== 'write' && value !== 'execute') {\n throw new TypeError('mode entries must be read, write, or execute');\n }\n return value;\n });\n return Object.freeze({ mode: Object.freeze(mode) });\n};\n\nconst validateBufferSource = (value: BufferSource): BufferSource => {\n if (!(value instanceof ArrayBuffer) && !ArrayBuffer.isView(value)) {\n throw new TypeError('data must be a BufferSource');\n }\n return value;\n};\n\nconst createAbortReason = (signal: AbortSignal): unknown =>\n signal.reason ?? new DOMException('The operation was aborted', 'AbortError');\n\nconst addStatsMethods = <T extends Record<string, unknown>>(\n value: T\n): T & MuonAndroidFsStats => {\n const types: readonly MuonAndroidFsEntryType[] = [\n 'file',\n 'directory',\n 'symlink',\n 'blockDevice',\n 'characterDevice',\n 'fifo',\n 'socket',\n 'other',\n ];\n if (\n typeof value.type !== 'string' ||\n !types.includes(value.type as MuonAndroidFsEntryType) ||\n typeof value.size !== 'number' ||\n !Number.isFinite(value.size) ||\n value.size < 0 ||\n typeof value.mtimeMs !== 'number' ||\n !Number.isFinite(value.mtimeMs) ||\n typeof value.readonly !== 'boolean'\n ) {\n throw new TypeError('Android filesystem metadata is invalid');\n }\n Object.defineProperties(value, {\n isFile: { value: () => value.type === 'file' },\n isDirectory: { value: () => value.type === 'directory' },\n isSymbolicLink: { value: () => value.type === 'symlink' },\n });\n return value as T & MuonAndroidFsStats;\n};\n\nconst parseStats = async (\n source: Promise<unknown>\n): Promise<MuonAndroidFsStats> => {\n const value = await parseNativeJson<Record<string, unknown>>(source);\n if (!isRecord(value)) {\n throw new TypeError('Android filesystem metadata is invalid');\n }\n return addStatsMethods(value);\n};\n\nconst parseDirectoryEntries = async (\n source: Promise<unknown>,\n withFileTypes: boolean\n): Promise<string[] | MuonAndroidFsDirent[]> => {\n const values = await parseNativeJson<unknown[]>(source);\n if (!Array.isArray(values)) {\n throw new TypeError('Android directory result is invalid');\n }\n if (!withFileTypes) {\n if (!values.every((value) => typeof value === 'string')) {\n throw new TypeError('Android directory name result is invalid');\n }\n return values as string[];\n }\n return values.map((value) => {\n if (!isRecord(value) || typeof value.name !== 'string') {\n throw new TypeError('Android directory entry result is invalid');\n }\n return addStatsMethods(value) as unknown as MuonAndroidFsDirent;\n });\n};\n\ninterface MuonAndroidFsWatchSnapshot {\n readonly root: MuonAndroidFsStats;\n readonly entries: readonly MuonAndroidFsDirent[];\n}\n\nconst parseWatchSnapshot = async (\n source: Promise<unknown>\n): Promise<MuonAndroidFsWatchSnapshot> => {\n const value = await parseNativeJson<Record<string, unknown>>(source);\n if (\n !isRecord(value) ||\n !isRecord(value.root) ||\n !Array.isArray(value.entries)\n ) {\n throw new TypeError('Android filesystem watch snapshot is invalid');\n }\n const root = addStatsMethods(value.root);\n const entries = value.entries\n .map((entry) => {\n if (!isRecord(entry) || typeof entry.name !== 'string') {\n throw new TypeError('Android filesystem watch entry is invalid');\n }\n return addStatsMethods(entry) as unknown as MuonAndroidFsDirent;\n })\n .sort((left, right) => left.name.localeCompare(right.name));\n return { root, entries };\n};\n\nconst filesystemStatusKey = (entry: MuonAndroidFsStats): string =>\n [entry.type, entry.size, entry.mtimeMs, entry.readonly].join(':');\n\nconst notifyFilesystemWatchListener = (\n listener: MuonAndroidFsWatchListener,\n event: MuonAndroidFsWatchEvent\n): void => {\n let result: void | Promise<void>;\n try {\n result = listener(event);\n } catch {\n // Listener failures do not stop the native watcher lease.\n return;\n }\n if (result !== undefined) {\n const observeResult = async (): Promise<void> => {\n try {\n await result;\n } catch {\n // Asynchronous listener failures are ignored by the public contract.\n }\n };\n globalThis.queueMicrotask(observeResult);\n }\n};\n\nconst emitFilesystemWatchDiff = (\n previous: MuonAndroidFsWatchSnapshot,\n next: MuonAndroidFsWatchSnapshot,\n listener: MuonAndroidFsWatchListener\n): void => {\n if (filesystemStatusKey(previous.root) !== filesystemStatusKey(next.root)) {\n notifyFilesystemWatchListener(listener, {\n eventType: 'change',\n filename: null,\n });\n }\n const previousEntries = new Map(\n previous.entries.map((entry) => [entry.name, entry] as const)\n );\n const nextEntries = new Map(\n next.entries.map((entry) => [entry.name, entry] as const)\n );\n for (const [name, entry] of previousEntries) {\n const nextEntry = nextEntries.get(name);\n if (nextEntry === undefined) {\n notifyFilesystemWatchListener(listener, {\n eventType: 'rename',\n filename: name,\n });\n } else if (filesystemStatusKey(entry) !== filesystemStatusKey(nextEntry)) {\n notifyFilesystemWatchListener(listener, {\n eventType: 'change',\n filename: name,\n });\n }\n }\n for (const name of nextEntries.keys()) {\n if (!previousEntries.has(name)) {\n notifyFilesystemWatchListener(listener, {\n eventType: 'rename',\n filename: name,\n });\n }\n }\n};\n\nconst createMuonAndroidFsApi = (\n client: MuonWebViewRpcClient,\n capabilityId: string\n): MuonAndroidFsApi => {\n const call = (\n functionName: (typeof filesystemFunctionNames)[number],\n arguments_: readonly unknown[],\n options: MuonAndroidFsOperationOptions | undefined\n ): Promise<unknown> => {\n const signal = getOperationSignal(options);\n return client.call(\n capabilityId,\n `muon.fs.${functionName}`,\n arguments_,\n signal === undefined ? undefined : { signal }\n );\n };\n\n const callVoid = async (\n functionName: (typeof filesystemFunctionNames)[number],\n arguments_: readonly unknown[],\n options: MuonAndroidFsOperationOptions | undefined\n ): Promise<void> => {\n await call(functionName, arguments_, options);\n };\n\n const callString = async (\n functionName: (typeof filesystemFunctionNames)[number],\n arguments_: readonly unknown[],\n options: MuonAndroidFsOperationOptions | undefined\n ): Promise<string> => {\n const value = await call(functionName, arguments_, options);\n if (typeof value !== 'string') {\n throw new TypeError('Android filesystem string result is invalid');\n }\n return value;\n };\n\n const callBoolean = async (\n functionName: (typeof filesystemFunctionNames)[number],\n arguments_: readonly unknown[],\n options: MuonAndroidFsOperationOptions | undefined\n ): Promise<boolean> => {\n const value = await call(functionName, arguments_, options);\n if (typeof value !== 'boolean') {\n throw new TypeError('Android filesystem boolean result is invalid');\n }\n return value;\n };\n\n const api: MuonAndroidFsApi = {\n readFile: async (path, options) => {\n const value = await call(\n 'readFile',\n [validatePath(path), normalizeReadFileOptions(options)],\n options\n );\n if (!(value instanceof ArrayBuffer)) {\n throw new TypeError('Android filesystem binary result is invalid');\n }\n return value;\n },\n writeFile: async (path, data, options) =>\n await callVoid(\n 'writeFile',\n [\n validatePath(path),\n validateBufferSource(data),\n normalizeWriteFileOptions(options),\n ],\n options\n ),\n readTextFile: async (path, encoding, options) =>\n await callString(\n 'readTextFile',\n [validatePath(path), validateEncoding(encoding)],\n options\n ),\n writeTextFile: async (path, data, encoding, options) => {\n if (typeof data !== 'string') {\n throw new TypeError('data must be a string');\n }\n await callVoid(\n 'writeTextFile',\n [validatePath(path), data, validateEncoding(encoding)],\n options\n );\n },\n stat: async (path, options) =>\n await parseStats(call('stat', [validatePath(path)], options)),\n lstat: async (path, options) =>\n await parseStats(call('lstat', [validatePath(path)], options)),\n exists: async (path, options) =>\n await callBoolean('exists', [validatePath(path)], options),\n access: async (path, options) =>\n await callBoolean(\n 'access',\n [validatePath(path), normalizeAccessOptions(options)],\n options\n ),\n readdir: async (path, options) => {\n const nativeOptions = normalizeBooleanOptions(options, ['withFileTypes']);\n return await parseDirectoryEntries(\n call('readdir', [validatePath(path), nativeOptions], options),\n nativeOptions.withFileTypes === true\n );\n },\n mkdir: async (path, options) =>\n await callVoid(\n 'mkdir',\n [validatePath(path), normalizeBooleanOptions(options, ['recursive'])],\n options\n ),\n rm: async (path, options) =>\n await callVoid(\n 'rm',\n [\n validatePath(path),\n normalizeBooleanOptions(options, ['recursive', 'force']),\n ],\n options\n ),\n unlink: async (path, options) =>\n await callVoid('unlink', [validatePath(path)], options),\n rmdir: async (path, options) =>\n await callVoid('rmdir', [validatePath(path)], options),\n rename: async (oldPath, newPath, options) =>\n await callVoid(\n 'rename',\n [validatePath(oldPath, 'oldPath'), validatePath(newPath, 'newPath')],\n options\n ),\n copyFile: async (source, destination, options) =>\n await callVoid(\n 'copyFile',\n [\n validatePath(source, 'source'),\n validatePath(destination, 'destination'),\n normalizeBooleanOptions(options, ['overwrite']),\n ],\n options\n ),\n appendFile: async (path, data, options) =>\n await callVoid(\n 'appendFile',\n [validatePath(path), validateBufferSource(data)],\n options\n ),\n appendTextFile: async (path, data, encoding, options) => {\n if (typeof data !== 'string') {\n throw new TypeError('data must be a string');\n }\n await callVoid(\n 'appendTextFile',\n [validatePath(path), data, validateEncoding(encoding)],\n options\n );\n },\n truncate: async (path, lengthOrOptions, options) => {\n const operationOptions =\n typeof lengthOrOptions === 'object' && lengthOrOptions !== null\n ? lengthOrOptions\n : options;\n const length =\n typeof lengthOrOptions === 'number'\n ? validateSafeUnsignedInteger(lengthOrOptions, 'length')\n : 0;\n await callVoid(\n 'truncate',\n [validatePath(path), { length }],\n operationOptions\n );\n },\n realpath: async (path, options) =>\n await callString('realpath', [validatePath(path)], options),\n readlink: async (path, options) =>\n await callString('readlink', [validatePath(path)], options),\n symlink: async (target, path, typeOrOptions, options) => {\n if (typeof target !== 'string' || target.length === 0) {\n throw new TypeError('target must be a non-empty string');\n }\n if (target.includes('\\0')) {\n throw new TypeError('target must not contain NUL');\n }\n const operationOptions =\n typeof typeOrOptions === 'object' && typeOrOptions !== null\n ? typeOrOptions\n : options;\n const type = typeof typeOrOptions === 'string' ? typeOrOptions : 'file';\n if (type !== 'file' && type !== 'dir' && type !== 'junction') {\n throw new TypeError('type must be file, dir, or junction');\n }\n if (type === 'junction') {\n throw new TypeError(\n 'junction symbolic links are unavailable on Android'\n );\n }\n await callVoid(\n 'symlink',\n [target, validatePath(path), type],\n operationOptions\n );\n },\n watch: async (path, listener, options) => {\n const validatedPath = validatePath(path);\n if (typeof listener !== 'function') {\n throw new TypeError('listener must be a function');\n }\n const signal = getOperationSignal(options);\n if (signal !== undefined && Boolean(signal.aborted)) {\n throw createAbortReason(signal);\n }\n const runWatchRpc = async (\n request: Readonly<Record<string, unknown>>,\n operationOptions: MuonAndroidFsOperationOptions | undefined\n ): Promise<Record<string, unknown>> =>\n await parseNativeJson<Record<string, unknown>>(\n call('watch', [request], operationOptions)\n );\n const lease = await runWatchRpc({ operation: 'acquire' }, undefined);\n if (typeof lease.token !== 'string' || lease.token.length === 0) {\n throw new TypeError('Android filesystem watcher lease is invalid');\n }\n const token = lease.token;\n let released = false;\n const releaseLease = async (): Promise<void> => {\n if (released) {\n return;\n }\n released = true;\n try {\n await runWatchRpc({ operation: 'release', token }, undefined);\n } catch {\n // Context release is the final fallback for an unavailable transport.\n }\n };\n if (signal !== undefined && Boolean(signal.aborted)) {\n await releaseLease();\n throw createAbortReason(signal);\n }\n\n let snapshot: MuonAndroidFsWatchSnapshot;\n try {\n snapshot = await parseWatchSnapshot(\n call(\n 'watch',\n [{ operation: 'snapshot', path: validatedPath, token }],\n options\n )\n );\n } catch (error) {\n await releaseLease();\n throw error;\n }\n\n let closed = false;\n let polling = false;\n let pollPromise: Promise<void> | undefined = undefined;\n let timer: ReturnType<typeof globalThis.setInterval> | undefined =\n undefined;\n let closePromise: Promise<void> | undefined = undefined;\n const beginClose = async (waitForPoll: boolean): Promise<void> => {\n if (closePromise !== undefined) {\n await closePromise;\n return;\n }\n const pendingPoll = waitForPoll ? pollPromise : undefined;\n closePromise = (async () => {\n if (closed) {\n return;\n }\n closed = true;\n if (timer !== undefined) {\n globalThis.clearInterval(timer);\n timer = undefined;\n }\n if (signal !== undefined) {\n signal.removeEventListener('abort', onAbort);\n }\n if (pendingPoll !== undefined) {\n try {\n await pendingPoll;\n } catch {\n // Poll errors are reported to the listener before lease release.\n }\n }\n await releaseLease();\n })();\n await closePromise;\n };\n const close = async (): Promise<void> => {\n await beginClose(true);\n };\n const onAbort = async (): Promise<void> => {\n await close();\n };\n const runPoll = async (): Promise<void> => {\n try {\n const next = await parseWatchSnapshot(\n call(\n 'watch',\n [{ operation: 'snapshot', path: validatedPath, token }],\n undefined\n )\n );\n if (closed) {\n return;\n }\n emitFilesystemWatchDiff(snapshot, next, listener);\n snapshot = next;\n } catch (error) {\n if (closed) {\n return;\n }\n notifyFilesystemWatchListener(listener, {\n eventType: 'error',\n filename: null,\n message: error instanceof Error ? error.message : String(error),\n });\n await beginClose(false);\n }\n };\n const poll = async (): Promise<void> => {\n if (closed || polling) {\n return;\n }\n polling = true;\n const currentPoll = runPoll();\n pollPromise = currentPoll;\n try {\n await currentPoll;\n } finally {\n if (pollPromise === currentPoll) {\n pollPromise = undefined;\n }\n polling = false;\n }\n };\n timer = globalThis.setInterval(async () => {\n await poll();\n }, 100);\n if (signal !== undefined) {\n signal.addEventListener('abort', onAbort, { once: true });\n if (signal.aborted) {\n await close();\n throw createAbortReason(signal);\n }\n }\n return Object.freeze({ close });\n },\n };\n return Object.freeze(api);\n};\n\n/**\n * Creates the Android simple-mode `window.muon` object.\n *\n * @param client - WebView RPC client used by every exposed function.\n * @param capabilityIds - Namespace capability ids generated for this page.\n * @returns An immutable object containing only implemented Android functions.\n */\nexport const createMuonAndroidSimpleApi = (\n client: MuonWebViewRpcClient,\n capabilityIds: MuonAndroidCapabilityIds\n): MuonAndroidSimpleApi =>\n Object.freeze({\n browser: createVoidNamespace(\n client,\n capabilityIds['muon.browser'],\n 'muon.browser',\n browserFunctionNames\n ),\n environments: Object.freeze({\n getVariables: () =>\n parseNativeJson<Record<string, string>>(\n client.call(\n capabilityIds['muon.environments'],\n 'muon.environments.getVariables',\n []\n )\n ),\n getConfigValues: () =>\n parseNativeJson<Record<string, string>>(\n client.call(\n capabilityIds['muon.environments'],\n 'muon.environments.getConfigValues',\n []\n )\n ),\n getProcessId: async () => {\n const value = await client.call(\n capabilityIds['muon.environments'],\n 'muon.environments.getProcessId',\n []\n );\n if (\n typeof value !== 'number' ||\n !Number.isInteger(value) ||\n value <= 0 ||\n value > 0xffffffff\n ) {\n throw new TypeError('Android process id result is invalid');\n }\n return value;\n },\n getRuntimeInfo: () =>\n parseNativeJson<MuonAndroidRuntimeInfo>(\n client.call(\n capabilityIds['muon.environments'],\n 'muon.environments.getRuntimeInfo',\n []\n )\n ),\n }),\n fs: createMuonAndroidFsApi(client, capabilityIds['muon.fs']),\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 {\n MuonAndroidRendererMetadata,\n MuonNativeNamespaceMetadata,\n} from './native-plugin-metadata.js';\nimport type { MuonWebViewRpcClient } from './webview-rpc.js';\n\n/** Existing root objects merged with native namespaces in simple mode. */\nexport type MuonAndroidNativePluginBaseRoots = Readonly<Record<string, object>>;\n\nconst getNamespaceSegments = (namespace: string): readonly string[] =>\n namespace.split('.');\n\nconst getOrCreateNamespace = (\n roots: Record<string, Record<string, unknown>>,\n namespace: string\n): Record<string, unknown> => {\n const segments = getNamespaceSegments(namespace);\n let current = roots[segments[0]!];\n if (current === undefined) {\n current = {};\n roots[segments[0]!] = current;\n }\n for (const segment of segments.slice(1)) {\n const existing = current[segment];\n if (existing === undefined) {\n const created: Record<string, unknown> = {};\n Object.defineProperty(current, segment, {\n configurable: false,\n enumerable: !segment.startsWith('__'),\n writable: false,\n value: created,\n });\n current = created;\n } else if (typeof existing === 'object' && existing !== null) {\n current = existing as Record<string, unknown>;\n } else {\n throw new Error(`Muon plugin namespace conflicts with ${namespace}`);\n }\n }\n return current;\n};\n\nconst deepFreeze = (value: unknown, seen: WeakSet<object>): void => {\n if (\n value === null ||\n (typeof value !== 'object' && typeof value !== 'function')\n ) {\n return;\n }\n if (seen.has(value)) {\n return;\n }\n seen.add(value);\n for (const key of Reflect.ownKeys(value)) {\n deepFreeze(Reflect.get(value, key), seen);\n }\n Object.freeze(value);\n};\n\nconst executeSetupScript = (\n pluginNamespace: MuonNativeNamespaceMetadata,\n namespaceObject: Record<string, unknown>,\n target: Record<PropertyKey, unknown>\n): void => {\n if (pluginNamespace.setupScript.length === 0) {\n return;\n }\n const setup = Function(\n 'namespace',\n 'globalThis',\n 'isAllowed',\n `\"use strict\";\\n${pluginNamespace.setupScript}`\n ) as (\n namespace: Record<string, unknown>,\n global: Record<PropertyKey, unknown>,\n isAllowed: (name: string) => boolean\n ) => void;\n const allowed = new Set(pluginNamespace.allowedFunctions);\n setup(namespaceObject, target, (name) => allowed.has(name));\n};\n\n/**\n * Installs loaded native plugin functions in the trusted simple-mode context.\n *\n * @param client - Typed WebView RPC client.\n * @param metadata - Runtime metadata captured before document loading.\n * @param baseRoots - Existing Android platform API root objects.\n * @param target - Global-like object receiving plugin roots.\n * @returns A function that restores the previous root descriptors.\n */\nexport const installMuonAndroidNativePluginApi = (\n client: MuonWebViewRpcClient,\n metadata: MuonAndroidRendererMetadata,\n baseRoots: MuonAndroidNativePluginBaseRoots,\n target: Record<PropertyKey, unknown> = globalThis as unknown as Record<\n PropertyKey,\n unknown\n >\n): (() => void) => {\n if (metadata.mode !== 'simple') {\n return () => {};\n }\n const namespaceMetadata = new Map(\n metadata.namespaces.map((namespace) => [namespace.namespace, namespace])\n );\n const roots: Record<string, Record<string, unknown>> = {};\n for (const [name, value] of Object.entries(baseRoots)) {\n roots[name] = { ...(value as Record<string, unknown>) };\n }\n\n for (const pluginNamespace of metadata.namespaces) {\n getOrCreateNamespace(roots, pluginNamespace.namespace);\n }\n for (const function_ of metadata.functions) {\n const pluginNamespace = namespaceMetadata.get(function_.namespace);\n if (\n pluginNamespace === undefined ||\n !pluginNamespace.allowedFunctions.includes(function_.name)\n ) {\n throw new Error(\n `Android native plugin function is not allowed: ${function_.namespace}.${function_.name}`\n );\n }\n const namespaceObject = getOrCreateNamespace(roots, function_.namespace);\n if (Reflect.has(namespaceObject, function_.name)) {\n throw new Error(\n `Muon plugin function conflicts with ${function_.namespace}.${function_.name}`\n );\n }\n const call = (...arguments_: readonly unknown[]): Promise<unknown> =>\n client.call(\n function_.capabilityId,\n `${function_.namespace}.${function_.publicName}`,\n arguments_\n );\n Object.defineProperty(namespaceObject, function_.name, {\n configurable: false,\n enumerable: !function_.name.startsWith('__'),\n writable: false,\n value: call,\n });\n }\n\n const previousDescriptors = new Map<string, PropertyDescriptor | undefined>();\n for (const [name, root] of Object.entries(roots)) {\n previousDescriptors.set(\n name,\n Object.getOwnPropertyDescriptor(target, name)\n );\n Object.defineProperty(target, name, {\n configurable: true,\n enumerable: true,\n writable: false,\n value: root,\n });\n }\n try {\n for (const pluginNamespace of metadata.namespaces) {\n executeSetupScript(\n pluginNamespace,\n getOrCreateNamespace(roots, pluginNamespace.namespace),\n target\n );\n }\n const seen = new WeakSet<object>();\n for (const root of Object.values(roots)) {\n deepFreeze(root, seen);\n }\n } catch (error) {\n for (const [name, previous] of previousDescriptors) {\n if (previous === undefined) {\n Reflect.deleteProperty(target, name);\n } else {\n Object.defineProperty(target, name, previous);\n }\n }\n throw error;\n }\n\n return () => {\n for (const [name, previous] of previousDescriptors) {\n if (previous === undefined) {\n Reflect.deleteProperty(target, name);\n } else {\n Object.defineProperty(target, name, previous);\n }\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 type {\n MuonAndroidRendererMetadata,\n MuonNativeFunctionMetadata,\n MuonNativeTypeMetadata,\n} from './native-plugin-metadata.js';\n\n/** A message exchanged between JavaScript and the Android WebView host. */\nexport type MuonWebViewRpcMessage = string | ArrayBuffer;\n\n/** Receives a message from the Android WebView host. */\nexport type MuonWebViewRpcMessageHandler = (\n message: MuonWebViewRpcMessage\n) => void;\n\n/** Supplies the platform-specific message channel used by the RPC client. */\nexport interface MuonWebViewRpcTransport {\n /** Sends one text or binary message to the Android WebView host. */\n readonly send: (message: MuonWebViewRpcMessage) => void;\n\n /** Replaces or removes the handler for messages received from the host. */\n readonly setMessageHandler: (\n handler: MuonWebViewRpcMessageHandler | undefined\n ) => void;\n}\n\n/** Options controlling one WebView RPC call. */\nexport interface MuonWebViewRpcCallOptions {\n /** Cancels the native RPC call when aborted. */\n readonly signal?: AbortSignal;\n}\n\n/** The kind of payload represented by a WebView RPC binary frame. */\nexport type MuonWebViewRpcBinaryFrameKind =\n 'argument' | 'result' | 'renderer-argument' | 'renderer-result';\n\n/** Values required to encode a WebView RPC binary frame. */\nexport interface MuonWebViewRpcBinaryFrame {\n /** Identifies whether the payload is a call argument or a call result. */\n readonly kind: MuonWebViewRpcBinaryFrameKind;\n\n /** Identifies the RPC call owning the payload. */\n readonly callId: number;\n\n /** Identifies this payload within the owning message. */\n readonly attachment: number;\n\n /** Contains the payload bytes. */\n readonly payload: ArrayBuffer;\n}\n\n/** Provides asynchronous calls over a WebView RPC transport. */\nexport interface MuonWebViewRpcClient {\n /**\n * Calls one native capability function.\n *\n * @param capabilityId - Capability token supplied by the generated module.\n * @param functionPath - Fully-qualified native function path.\n * @param arguments_ - Function arguments.\n * @param options - Optional cancellation settings.\n * @returns The native result.\n */\n readonly call: (\n capabilityId: string,\n functionPath: string,\n arguments_: readonly unknown[],\n options?: MuonWebViewRpcCallOptions\n ) => Promise<unknown>;\n\n /** Releases the JavaScript context and rejects all outstanding calls. */\n readonly dispose: () => void;\n\n /** Returns the number of calls awaiting a native result. */\n readonly getPendingCallCount: () => number;\n}\n\n/** The message event emitted by an object injected with addWebMessageListener. */\nexport interface MuonWebViewJavaScriptMessageEvent {\n /** Contains text or binary data sent by the Android host. */\n readonly data: MuonWebViewRpcMessage;\n}\n\n/** The JavaScript object injected by AndroidX WebKit. */\nexport interface MuonWebViewJavaScriptBridge {\n /** Sends text or binary data to the Android host. */\n readonly postMessage: (message: MuonWebViewRpcMessage) => void;\n\n /** Receives replies posted by the Android host. */\n onmessage: ((event: MuonWebViewJavaScriptMessageEvent) => void) | null;\n}\n\ninterface PendingCall {\n readonly resolve: (value: unknown) => void;\n readonly reject: (reason: unknown) => void;\n readonly signal: AbortSignal | undefined;\n readonly returnType: MuonNativeTypeMetadata | undefined;\n readonly rendererFunctionTransfers: readonly number[];\n abortListener: (() => void) | undefined;\n}\n\ninterface EncodedArguments {\n readonly value: readonly unknown[];\n readonly attachments: readonly ArrayBuffer[];\n readonly rendererFunctionTransfers: readonly number[];\n}\n\ninterface RendererFunctionSource {\n readonly value: (...arguments_: readonly unknown[]) => unknown;\n readonly leases: Set<string>;\n pendingTransfers: number;\n}\n\ninterface PluginFunctionProxyState {\n readonly proxyId: number;\n readonly leaseToken: string;\n readonly type: MuonNativeTypeMetadata;\n released: boolean;\n}\n\ninterface PendingRendererFunctionCall {\n readonly callId: number;\n readonly functionId: number;\n readonly expectsResult: boolean;\n readonly functionType: MuonNativeTypeMetadata;\n readonly encodedArguments: readonly unknown[];\n readonly expectedAttachmentLengths: readonly number[];\n readonly attachments: Array<ArrayBuffer | undefined>;\n receivedAttachmentCount: number;\n}\n\ntype EncodeFunctionValue = (\n value: unknown,\n type: MuonNativeTypeMetadata,\n rendererFunctionTransfers: number[]\n) => unknown;\n\ntype DecodeFunctionValue = (\n value: unknown,\n type: MuonNativeTypeMetadata\n) => unknown;\n\nconst binaryHeaderLength = 16;\nconst binaryMagic = [0x4d, 0x52, 0x50, 0x43] as const;\nconst protocolVersion = 1;\nconst maximumCallId = 0x7fffffff;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst isUnsignedInteger = (value: unknown): value is number =>\n typeof value === 'number' &&\n Number.isInteger(value) &&\n value >= 0 &&\n value <= 0xffffffff;\n\nconst nativeValueTypes = new Set<MuonNativeTypeMetadata['type']>([\n 'void',\n 'bool',\n 'i8',\n 'u8',\n 'i16',\n 'u16',\n 'i32',\n 'u32',\n 'i64',\n 'u64',\n 'f32',\n 'f64',\n 'string',\n 'pointer',\n 'function',\n 'buffer_view',\n]);\n\nconst isNativeTypeMetadata = (\n value: unknown,\n allowVoid: boolean,\n depth = 0\n): value is MuonNativeTypeMetadata => {\n if (\n !isRecord(value) ||\n depth > 16 ||\n !nativeValueTypes.has(value.type as MuonNativeTypeMetadata['type']) ||\n (!allowVoid && value.type === 'void')\n ) {\n return false;\n }\n if (value.type !== 'function') {\n return true;\n }\n return (\n Array.isArray(value.args) &&\n value.args.every((argument) =>\n isNativeTypeMetadata(argument, false, depth + 1)\n ) &&\n isNativeTypeMetadata(value.returnType, true, depth + 1)\n );\n};\n\nconst areNativeTypesEqual = (\n first: MuonNativeTypeMetadata,\n second: MuonNativeTypeMetadata\n): boolean => {\n if (first.type !== second.type) {\n return false;\n }\n if (first.type !== 'function' || second.type !== 'function') {\n return true;\n }\n const firstArguments = first.args ?? [];\n const secondArguments = second.args ?? [];\n if (\n firstArguments.length !== secondArguments.length ||\n first.returnType === undefined ||\n second.returnType === undefined ||\n !areNativeTypesEqual(first.returnType, second.returnType)\n ) {\n return false;\n }\n return firstArguments.every((argument, index) =>\n areNativeTypesEqual(argument, secondArguments[index]!)\n );\n};\n\nconst collectBinaryAttachmentLengths = (\n value: unknown,\n lengths: Map<number, number>\n): boolean => {\n if (Array.isArray(value)) {\n return value.every((element) =>\n collectBinaryAttachmentLengths(element, lengths)\n );\n }\n if (!isRecord(value)) {\n return true;\n }\n if (value.type === 'binary') {\n if (\n !isUnsignedInteger(value.attachment) ||\n !isUnsignedInteger(value.byteLength) ||\n lengths.has(value.attachment)\n ) {\n return false;\n }\n lengths.set(value.attachment, value.byteLength);\n return true;\n }\n return Object.values(value).every((element) =>\n collectBinaryAttachmentLengths(element, lengths)\n );\n};\n\nconst getContiguousBinaryAttachmentLengths = (\n value: unknown\n): readonly number[] | undefined => {\n const descriptors = new Map<number, number>();\n if (!collectBinaryAttachmentLengths(value, descriptors)) {\n return undefined;\n }\n const lengths: number[] = [];\n for (let attachment = 0; attachment < descriptors.size; attachment += 1) {\n const byteLength = descriptors.get(attachment);\n if (byteLength === undefined) {\n return undefined;\n }\n lengths.push(byteLength);\n }\n return lengths;\n};\n\nconst copyArrayBufferView = (value: ArrayBufferView): ArrayBuffer => {\n const copy = new Uint8Array(value.byteLength);\n copy.set(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));\n return copy.buffer;\n};\n\nconst encodeArgumentValue = (\n value: unknown,\n attachments: ArrayBuffer[],\n ancestors: Set<object>\n): unknown => {\n let payload: ArrayBuffer | undefined;\n if (value instanceof ArrayBuffer) {\n payload = value.slice(0);\n } else if (ArrayBuffer.isView(value)) {\n payload = copyArrayBufferView(value);\n }\n\n if (payload !== undefined) {\n const attachment = attachments.length;\n attachments.push(payload);\n return {\n type: 'binary',\n attachment,\n byteLength: payload.byteLength,\n };\n }\n\n if (Array.isArray(value)) {\n if (ancestors.has(value)) {\n throw new TypeError('WebView RPC arguments cannot contain cycles');\n }\n ancestors.add(value);\n const encoded = value.map((element) =>\n encodeArgumentValue(element, attachments, ancestors)\n );\n ancestors.delete(value);\n return encoded;\n }\n\n if (isRecord(value)) {\n if (ancestors.has(value)) {\n throw new TypeError('WebView RPC arguments cannot contain cycles');\n }\n ancestors.add(value);\n const encoded: Record<string, unknown> = {};\n for (const [key, element] of Object.entries(value)) {\n encoded[key] = encodeArgumentValue(element, attachments, ancestors);\n }\n ancestors.delete(value);\n return encoded;\n }\n\n return value;\n};\n\nconst encodeArguments = (arguments_: readonly unknown[]): EncodedArguments => {\n const attachments: ArrayBuffer[] = [];\n const ancestors = new Set<object>();\n const value = arguments_.map((argument) =>\n encodeArgumentValue(argument, attachments, ancestors)\n );\n return { value, attachments, rendererFunctionTransfers: [] };\n};\n\nconst encodeInt64Argument = (value: unknown, unsigned: boolean): string => {\n if (typeof value !== 'number') {\n throw new TypeError(`expected ${unsigned ? 'u64' : 'i64'}`);\n }\n const truncated = Number.isFinite(value) ? Math.trunc(value) : 0;\n const bits = BigInt.asUintN(64, BigInt(truncated));\n return unsigned ? bits.toString() : BigInt.asIntN(64, bits).toString();\n};\n\nconst encodeNumberArgument = (\n value: unknown,\n type: MuonNativeTypeMetadata['type']\n): number => {\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n throw new TypeError(`expected ${type}`);\n }\n const integerRanges: Readonly<\n Partial<Record<MuonNativeTypeMetadata['type'], readonly [number, number]>>\n > = {\n i8: [-128, 127],\n u8: [0, 255],\n i16: [-32768, 32767],\n u16: [0, 65535],\n i32: [-2147483648, 2147483647],\n u32: [0, 4294967295],\n };\n const range = integerRanges[type];\n if (\n range !== undefined &&\n (!Number.isInteger(value) || value < range[0] || value > range[1])\n ) {\n throw new TypeError(`expected ${type}`);\n }\n if (\n type === 'f32' &&\n (value < -3.4028234663852886e38 || value > 3.4028234663852886e38)\n ) {\n throw new TypeError('expected f32');\n }\n return value;\n};\n\nconst encodeNativeArgumentValue = (\n value: unknown,\n type: MuonNativeTypeMetadata,\n attachments: ArrayBuffer[],\n rendererFunctionTransfers: number[],\n encodeFunctionValue: EncodeFunctionValue\n): unknown => {\n switch (type.type) {\n case 'bool':\n if (typeof value !== 'boolean') {\n throw new TypeError('expected bool');\n }\n return value;\n case 'i8':\n case 'u8':\n case 'i16':\n case 'u16':\n case 'i32':\n case 'u32':\n case 'f32':\n case 'f64':\n return encodeNumberArgument(value, type.type);\n case 'i64':\n return encodeInt64Argument(value, false);\n case 'u64':\n return encodeInt64Argument(value, true);\n case 'pointer':\n if (value === null || value === undefined) {\n return null;\n }\n if (\n typeof value !== 'number' ||\n !Number.isFinite(value) ||\n !Number.isInteger(value) ||\n value < 0 ||\n value >= 2 ** 64\n ) {\n throw new TypeError('expected pointer');\n }\n return value;\n case 'string':\n if (value === null || value === undefined) {\n return null;\n }\n if (typeof value !== 'string' || value.includes('\\0')) {\n throw new TypeError('expected string');\n }\n return value;\n case 'buffer_view': {\n let payload: ArrayBuffer;\n if (value instanceof ArrayBuffer) {\n payload = value.slice(0);\n } else if (ArrayBuffer.isView(value)) {\n payload = copyArrayBufferView(value);\n } else {\n throw new TypeError('expected buffer_view');\n }\n const attachment = attachments.length;\n attachments.push(payload);\n return { type: 'binary', attachment, byteLength: payload.byteLength };\n }\n case 'function':\n if (value === null || value === undefined) {\n return null;\n }\n return encodeFunctionValue(value, type, rendererFunctionTransfers);\n case 'void':\n throw new TypeError('void arguments are unavailable');\n }\n};\n\nconst encodeNativeArguments = (\n function_: MuonNativeFunctionMetadata,\n arguments_: readonly unknown[],\n encodeFunctionValue: EncodeFunctionValue,\n releaseRendererFunctionTransfers: (functionIds: readonly number[]) => void\n): EncodedArguments => {\n if (arguments_.length !== function_.args.length) {\n throw new TypeError(\n `Invalid argument count for ${function_.namespace}.${function_.publicName}`\n );\n }\n const attachments: ArrayBuffer[] = [];\n const rendererFunctionTransfers: number[] = [];\n let currentIndex = 0;\n try {\n const value = arguments_.map((argument, index) => {\n currentIndex = index;\n return encodeNativeArgumentValue(\n argument,\n function_.args[index]!,\n attachments,\n rendererFunctionTransfers,\n encodeFunctionValue\n );\n });\n return { value, attachments, rendererFunctionTransfers };\n } catch (error) {\n releaseRendererFunctionTransfers(rendererFunctionTransfers);\n const diagnostic = error instanceof Error ? error.message : 'invalid value';\n throw new TypeError(`Invalid argument ${currentIndex}: ${diagnostic}`);\n }\n};\n\nconst decodeNativeResult = (\n value: unknown,\n type: MuonNativeTypeMetadata,\n decodeFunctionValue: DecodeFunctionValue\n): unknown => {\n if (type.type === 'void') {\n return undefined;\n }\n if (type.type === 'i64' || type.type === 'u64') {\n if (typeof value !== 'string') {\n throw new TypeError('Android native 64-bit result is invalid');\n }\n const parsed = BigInt(value);\n return Number(\n type.type === 'i64'\n ? BigInt.asIntN(64, parsed)\n : BigInt.asIntN(64, BigInt.asUintN(64, parsed))\n );\n }\n if (type.type === 'string') {\n if (value !== null && typeof value !== 'string') {\n throw new TypeError('Android native string result is invalid');\n }\n return value;\n }\n if (type.type === 'bool') {\n if (typeof value !== 'boolean') {\n throw new TypeError('Android native bool result is invalid');\n }\n return value;\n }\n if (type.type === 'function') {\n if (value === null) {\n return null;\n }\n return decodeFunctionValue(value, type);\n }\n if (type.type === 'buffer_view') {\n throw new TypeError('Android native result transport is invalid');\n }\n if (typeof value !== 'number' || !Number.isFinite(value)) {\n throw new TypeError('Android native numeric result is invalid');\n }\n return value;\n};\n\nconst decodeHostNativeValue = (\n value: unknown,\n type: MuonNativeTypeMetadata,\n attachments: readonly (ArrayBuffer | undefined)[],\n decodeFunctionValue: DecodeFunctionValue\n): unknown => {\n if (type.type !== 'buffer_view') {\n return decodeNativeResult(value, type, decodeFunctionValue);\n }\n if (\n !isRecord(value) ||\n value.type !== 'binary' ||\n !isUnsignedInteger(value.attachment) ||\n !isUnsignedInteger(value.byteLength)\n ) {\n throw new TypeError('Android native binary value is invalid');\n }\n const payload = attachments[value.attachment];\n if (payload === undefined || payload.byteLength !== value.byteLength) {\n throw new TypeError('Android native binary attachment is missing');\n }\n return payload;\n};\n\nconst createAbortError = (): DOMException =>\n new DOMException('The operation was aborted', 'AbortError');\n\n/**\n * Encodes one binary attachment into the transport-independent RPC frame.\n *\n * @param frame - Frame metadata and payload.\n * @returns A new buffer containing the frame header and payload.\n */\nexport const encodeMuonWebViewRpcBinaryFrame = (\n frame: MuonWebViewRpcBinaryFrame\n): ArrayBuffer => {\n if (\n !Number.isInteger(frame.callId) ||\n frame.callId <= 0 ||\n frame.callId > maximumCallId\n ) {\n throw new RangeError('WebView RPC callId is out of range');\n }\n if (!isUnsignedInteger(frame.attachment)) {\n throw new RangeError('WebView RPC attachment is out of range');\n }\n\n const encoded = new ArrayBuffer(\n binaryHeaderLength + frame.payload.byteLength\n );\n const bytes = new Uint8Array(encoded);\n bytes.set(binaryMagic, 0);\n bytes[4] = protocolVersion;\n bytes[5] =\n frame.kind === 'argument'\n ? 1\n : frame.kind === 'result'\n ? 2\n : frame.kind === 'renderer-argument'\n ? 3\n : 4;\n const view = new DataView(encoded);\n view.setUint32(8, frame.callId);\n view.setUint32(12, frame.attachment);\n bytes.set(new Uint8Array(frame.payload), binaryHeaderLength);\n return encoded;\n};\n\n/**\n * Decodes and validates one transport-independent RPC binary frame.\n *\n * @param message - Candidate frame received from the WebView channel.\n * @returns The decoded frame, or `undefined` when the message is malformed.\n */\nexport const decodeMuonWebViewRpcBinaryFrame = (\n message: ArrayBuffer\n): MuonWebViewRpcBinaryFrame | undefined => {\n if (message.byteLength < binaryHeaderLength) {\n return undefined;\n }\n\n const bytes = new Uint8Array(message);\n if (\n bytes[0] !== binaryMagic[0] ||\n bytes[1] !== binaryMagic[1] ||\n bytes[2] !== binaryMagic[2] ||\n bytes[3] !== binaryMagic[3] ||\n bytes[4] !== protocolVersion ||\n (bytes[5] !== 1 && bytes[5] !== 2 && bytes[5] !== 3 && bytes[5] !== 4) ||\n bytes[6] !== 0 ||\n bytes[7] !== 0\n ) {\n return undefined;\n }\n\n const view = new DataView(message);\n const callId = view.getUint32(8);\n if (callId === 0 || callId > maximumCallId) {\n return undefined;\n }\n\n return {\n kind:\n bytes[5] === 1\n ? 'argument'\n : bytes[5] === 2\n ? 'result'\n : bytes[5] === 3\n ? 'renderer-argument'\n : 'renderer-result',\n callId,\n attachment: view.getUint32(12),\n payload: message.slice(binaryHeaderLength),\n };\n};\n\n/**\n * Adapts an AndroidX WebKit JavaScript object to the RPC transport contract.\n *\n * @param bridge - Object injected by `WebViewCompat.addWebMessageListener`.\n * @returns A transport backed by that object.\n */\nexport const createMuonWebViewRpcTransport = (\n bridge: MuonWebViewJavaScriptBridge\n): MuonWebViewRpcTransport => {\n let handler: MuonWebViewRpcMessageHandler | undefined = undefined;\n return {\n send: (message) => bridge.postMessage(message),\n setMessageHandler: (nextHandler) => {\n handler = nextHandler;\n bridge.onmessage =\n nextHandler === undefined\n ? null\n : (event) => {\n handler?.(event.data);\n };\n },\n };\n};\n\n/**\n * Creates a JavaScript RPC client for an Android WebView message channel.\n *\n * @param transport - Platform-specific bidirectional message transport.\n * @returns The RPC client bound to the transport.\n */\nexport const createMuonWebViewRpcClient = (\n transport: MuonWebViewRpcTransport,\n rendererMetadata?: MuonAndroidRendererMetadata\n): MuonWebViewRpcClient => {\n const pendingCalls = new Map<number, PendingCall>();\n const rendererFunctionIds = new WeakMap<Function, number>();\n const rendererFunctions = new Map<number, RendererFunctionSource>();\n const pendingRendererFunctionCalls = new Map<\n number,\n PendingRendererFunctionCall\n >();\n const rendererResultTransfers = new Map<number, readonly number[]>();\n const pluginProxyStates = new WeakMap<Function, PluginFunctionProxyState>();\n const livePluginProxyStates = new Set<PluginFunctionProxyState>();\n const functionsByPath = new Map<string, MuonNativeFunctionMetadata>(\n (rendererMetadata?.functions ?? []).map(\n (function_) =>\n [`${function_.namespace}.${function_.publicName}`, function_] as const\n )\n );\n let nextCallId = 1;\n let nextRendererFunctionId = 1;\n let disposed = false;\n\n const sendTextMessage = (value: Record<string, unknown>): void => {\n transport.send(JSON.stringify({ version: protocolVersion, ...value }));\n };\n\n const releaseRendererFunctionIfIdle = (functionId: number): void => {\n const source = rendererFunctions.get(functionId);\n if (\n source !== undefined &&\n source.pendingTransfers === 0 &&\n source.leases.size === 0\n ) {\n rendererFunctions.delete(functionId);\n }\n };\n\n const releaseRendererFunctionTransfers = (\n functionIds: readonly number[]\n ): void => {\n for (const functionId of functionIds) {\n const source = rendererFunctions.get(functionId);\n if (source !== undefined && source.pendingTransfers > 0) {\n source.pendingTransfers -= 1;\n releaseRendererFunctionIfIdle(functionId);\n }\n }\n };\n\n let pluginProxyFinalizer:\n FinalizationRegistry<PluginFunctionProxyState> | undefined;\n\n const releasePluginProxy = (state: PluginFunctionProxyState): void => {\n if (state.released) {\n return;\n }\n state.released = true;\n livePluginProxyStates.delete(state);\n pluginProxyFinalizer?.unregister(state);\n if (!disposed) {\n sendTextMessage({\n type: 'plugin-proxy-release',\n proxyId: state.proxyId,\n leaseToken: state.leaseToken,\n });\n }\n };\n\n if (typeof FinalizationRegistry === 'function') {\n pluginProxyFinalizer = new FinalizationRegistry((state) => {\n try {\n releasePluginProxy(state);\n } catch {\n // A collected proxy has no caller to observe a closed transport.\n }\n });\n }\n\n const encodeFunctionValue: EncodeFunctionValue = (\n value,\n type,\n rendererFunctionTransfers\n ) => {\n if (typeof value !== 'function') {\n throw new TypeError('expected function');\n }\n const proxy = pluginProxyStates.get(value);\n if (proxy !== undefined) {\n if (proxy.released) {\n throw new TypeError('muon function proxy is released');\n }\n if (!areNativeTypesEqual(proxy.type, type)) {\n throw new TypeError('function signature mismatch');\n }\n return {\n type: 'function',\n kind: 'plugin-proxy',\n proxyId: proxy.proxyId,\n leaseToken: proxy.leaseToken,\n };\n }\n if (rendererMetadata === undefined) {\n throw new TypeError('renderer function context is unavailable');\n }\n\n let functionId = rendererFunctionIds.get(value);\n let source =\n functionId === undefined ? undefined : rendererFunctions.get(functionId);\n if (source === undefined) {\n if (nextRendererFunctionId > maximumCallId) {\n throw new RangeError('Renderer function ids were exhausted');\n }\n functionId = nextRendererFunctionId;\n nextRendererFunctionId += 1;\n source = {\n value: value as (...arguments_: readonly unknown[]) => unknown,\n leases: new Set<string>(),\n pendingTransfers: 0,\n };\n rendererFunctionIds.set(value, functionId);\n rendererFunctions.set(functionId, source);\n }\n source.pendingTransfers += 1;\n const transferredFunctionId = functionId;\n if (transferredFunctionId === undefined) {\n throw new TypeError('Renderer function identity is unavailable');\n }\n rendererFunctionTransfers.push(transferredFunctionId);\n return {\n type: 'function',\n kind: 'renderer-source',\n rendererContextId: rendererMetadata.contextId,\n functionId: transferredFunctionId,\n };\n };\n\n const invokeCall = (\n target:\n | {\n readonly kind: 'plugin';\n readonly capabilityId: string;\n readonly functionPath: string;\n readonly functionMetadata: MuonNativeFunctionMetadata | undefined;\n }\n | {\n readonly kind: 'plugin-proxy';\n readonly state: PluginFunctionProxyState;\n },\n arguments_: readonly unknown[],\n options: MuonWebViewRpcCallOptions | undefined\n ): Promise<unknown> => {\n if (disposed) {\n return Promise.reject(new Error('muon WebView RPC client was disposed'));\n }\n if (target.kind === 'plugin-proxy' && target.state.released) {\n return Promise.reject(new Error('muon function proxy is released'));\n }\n if (options?.signal?.aborted === true) {\n return Promise.reject(createAbortError());\n }\n if (nextCallId > maximumCallId) {\n return Promise.reject(new RangeError('WebView RPC callId was exhausted'));\n }\n\n const callId = nextCallId;\n nextCallId += 1;\n let encodedArguments: EncodedArguments;\n let callMessage: string;\n let returnType: MuonNativeTypeMetadata | undefined;\n try {\n if (target.kind === 'plugin') {\n encodedArguments =\n target.functionMetadata === undefined\n ? encodeArguments(arguments_)\n : encodeNativeArguments(\n target.functionMetadata,\n arguments_,\n encodeFunctionValue,\n releaseRendererFunctionTransfers\n );\n returnType = target.functionMetadata?.returnType;\n callMessage = JSON.stringify({\n version: protocolVersion,\n type: 'call',\n callId,\n capabilityId: target.capabilityId,\n functionPath: target.functionPath,\n arguments: encodedArguments.value,\n });\n } else {\n const functionArguments = target.state.type.args;\n const functionReturnType = target.state.type.returnType;\n if (\n functionArguments === undefined ||\n functionReturnType === undefined\n ) {\n throw new TypeError('muon function proxy signature is invalid');\n }\n encodedArguments = encodeNativeArguments(\n {\n id: target.state.proxyId,\n namespace: 'muon',\n name: 'proxy',\n publicName: 'proxy',\n capabilityId: 'proxy',\n args: functionArguments,\n returnType: functionReturnType,\n },\n arguments_,\n encodeFunctionValue,\n releaseRendererFunctionTransfers\n );\n returnType = functionReturnType;\n callMessage = JSON.stringify({\n version: protocolVersion,\n type: 'call',\n callKind: 'plugin-proxy',\n callId,\n proxyId: target.state.proxyId,\n leaseToken: target.state.leaseToken,\n arguments: encodedArguments.value,\n });\n }\n } catch (error) {\n return Promise.reject(error);\n }\n\n return new Promise<unknown>((resolve, reject) => {\n const pending: PendingCall = {\n resolve,\n reject,\n signal: options?.signal,\n returnType,\n rendererFunctionTransfers: encodedArguments.rendererFunctionTransfers,\n abortListener: undefined,\n };\n if (pending.signal !== undefined) {\n pending.abortListener = () => {\n if (takePending(callId) === undefined) {\n return;\n }\n try {\n sendTextMessage({ type: 'cancel', callId });\n } finally {\n reject(createAbortError());\n }\n };\n pending.signal.addEventListener('abort', pending.abortListener, {\n once: true,\n });\n }\n pendingCalls.set(callId, pending);\n\n try {\n transport.send(callMessage);\n encodedArguments.attachments.forEach((payload, attachment) => {\n transport.send(\n encodeMuonWebViewRpcBinaryFrame({\n kind: 'argument',\n callId,\n attachment,\n payload,\n })\n );\n });\n } catch (error) {\n const failed = takePending(callId);\n failed?.reject(error);\n }\n });\n };\n\n const decodeFunctionValue: DecodeFunctionValue = (value, type) => {\n if (\n !isRecord(value) ||\n value.type !== 'function' ||\n value.kind !== 'plugin-proxy' ||\n !Number.isInteger(value.proxyId) ||\n typeof value.proxyId !== 'number' ||\n value.proxyId <= 0 ||\n value.proxyId > maximumCallId ||\n typeof value.leaseToken !== 'string' ||\n value.leaseToken.length === 0\n ) {\n throw new TypeError('Android native function proxy is invalid');\n }\n const state: PluginFunctionProxyState = {\n proxyId: value.proxyId,\n leaseToken: value.leaseToken,\n type,\n released: false,\n };\n const callable = (...arguments_: readonly unknown[]): Promise<unknown> =>\n invokeCall({ kind: 'plugin-proxy', state }, arguments_, undefined);\n const release = (): void => releasePluginProxy(state);\n Object.defineProperty(callable, 'release', {\n configurable: false,\n enumerable: false,\n writable: false,\n value: release,\n });\n const dispose = Reflect.get(Symbol, 'dispose');\n if (typeof dispose === 'symbol') {\n Object.defineProperty(callable, dispose, {\n configurable: false,\n enumerable: false,\n writable: false,\n value: release,\n });\n }\n pluginProxyStates.set(callable, state);\n livePluginProxyStates.add(state);\n pluginProxyFinalizer?.register(callable, state, state);\n return callable;\n };\n\n const detachAbortListener = (pending: PendingCall): void => {\n if (pending.signal !== undefined && pending.abortListener !== undefined) {\n pending.signal.removeEventListener('abort', pending.abortListener);\n pending.abortListener = undefined;\n }\n };\n\n const takePending = (callId: number): PendingCall | undefined => {\n const pending = pendingCalls.get(callId);\n if (pending === undefined) {\n return undefined;\n }\n pendingCalls.delete(callId);\n detachAbortListener(pending);\n releaseRendererFunctionTransfers(pending.rendererFunctionTransfers);\n return pending;\n };\n\n const sendRendererFunctionFailure = (\n callId: number,\n error: unknown\n ): void => {\n const diagnostic = error instanceof Error ? error.message : String(error);\n sendTextMessage({\n type: 'renderer-function-result',\n callId,\n success: false,\n error: diagnostic,\n });\n };\n\n const executeRendererFunctionCall = async (\n pending: PendingRendererFunctionCall\n ): Promise<void> => {\n const source = rendererFunctions.get(pending.functionId);\n if (source === undefined) {\n if (pending.expectsResult && !disposed) {\n sendRendererFunctionFailure(\n pending.callId,\n new Error('Renderer function source is unavailable')\n );\n }\n return;\n }\n try {\n const argumentTypes = pending.functionType.args;\n const returnType = pending.functionType.returnType;\n if (\n argumentTypes === undefined ||\n returnType === undefined ||\n argumentTypes.length !== pending.encodedArguments.length\n ) {\n throw new TypeError('Renderer function signature is invalid');\n }\n const arguments_ = pending.encodedArguments.map((argument, index) =>\n decodeHostNativeValue(\n argument,\n argumentTypes[index]!,\n pending.attachments,\n decodeFunctionValue\n )\n );\n const result = await source.value(...arguments_);\n if (!pending.expectsResult || disposed) {\n return;\n }\n\n const attachments: ArrayBuffer[] = [];\n const rendererFunctionTransfers: number[] = [];\n let encodedResult: unknown = null;\n try {\n if (returnType.type !== 'void') {\n encodedResult = encodeNativeArgumentValue(\n result,\n returnType,\n attachments,\n rendererFunctionTransfers,\n encodeFunctionValue\n );\n }\n } catch (error) {\n releaseRendererFunctionTransfers(rendererFunctionTransfers);\n throw error;\n }\n if (rendererFunctionTransfers.length !== 0) {\n rendererResultTransfers.set(pending.callId, rendererFunctionTransfers);\n }\n try {\n sendTextMessage({\n type: 'renderer-function-result',\n callId: pending.callId,\n success: true,\n value: encodedResult,\n });\n attachments.forEach((payload, attachment) => {\n transport.send(\n encodeMuonWebViewRpcBinaryFrame({\n kind: 'renderer-result',\n callId: pending.callId,\n attachment,\n payload,\n })\n );\n });\n } catch (error) {\n rendererResultTransfers.delete(pending.callId);\n releaseRendererFunctionTransfers(rendererFunctionTransfers);\n throw error;\n }\n } catch (error) {\n if (pending.expectsResult && !disposed) {\n sendRendererFunctionFailure(pending.callId, error);\n }\n }\n };\n\n const beginRendererFunctionCall = (\n pending: PendingRendererFunctionCall\n ): void => {\n pendingRendererFunctionCalls.delete(pending.callId);\n void executeRendererFunctionCall(pending);\n };\n\n const handleRendererFunctionCall = (\n parsed: Record<string, unknown>\n ): void => {\n if (\n !Number.isInteger(parsed.callId) ||\n typeof parsed.callId !== 'number' ||\n parsed.callId <= 0 ||\n parsed.callId > maximumCallId ||\n !Number.isInteger(parsed.functionId) ||\n typeof parsed.functionId !== 'number' ||\n parsed.functionId <= 0 ||\n parsed.functionId > maximumCallId ||\n typeof parsed.expectsResult !== 'boolean' ||\n !isNativeTypeMetadata(parsed.functionType, false) ||\n parsed.functionType.type !== 'function' ||\n !Array.isArray(parsed.arguments) ||\n pendingRendererFunctionCalls.has(parsed.callId)\n ) {\n return;\n }\n const expectedAttachmentLengths = getContiguousBinaryAttachmentLengths(\n parsed.arguments\n );\n if (expectedAttachmentLengths === undefined) {\n if (parsed.expectsResult) {\n sendRendererFunctionFailure(\n parsed.callId,\n new TypeError('Renderer function binary descriptors are invalid')\n );\n }\n return;\n }\n const pending: PendingRendererFunctionCall = {\n callId: parsed.callId,\n functionId: parsed.functionId,\n expectsResult: parsed.expectsResult,\n functionType: parsed.functionType,\n encodedArguments: parsed.arguments,\n expectedAttachmentLengths,\n attachments: new Array<ArrayBuffer | undefined>(\n expectedAttachmentLengths.length\n ),\n receivedAttachmentCount: 0,\n };\n pendingRendererFunctionCalls.set(pending.callId, pending);\n if (expectedAttachmentLengths.length === 0) {\n beginRendererFunctionCall(pending);\n }\n };\n\n const handleTextMessage = (message: string): void => {\n let parsed: unknown;\n try {\n parsed = JSON.parse(message) as unknown;\n } catch {\n return;\n }\n if (!isRecord(parsed) || parsed.version !== protocolVersion) {\n return;\n }\n\n if (parsed.type === 'renderer-function-call') {\n handleRendererFunctionCall(parsed);\n return;\n }\n if (parsed.type === 'renderer-function-lease') {\n if (\n !Number.isInteger(parsed.functionId) ||\n typeof parsed.functionId !== 'number' ||\n parsed.functionId <= 0 ||\n typeof parsed.leaseToken !== 'string' ||\n parsed.leaseToken.length === 0 ||\n typeof parsed.acquire !== 'boolean'\n ) {\n return;\n }\n const source = rendererFunctions.get(parsed.functionId);\n if (source === undefined) {\n return;\n }\n if (parsed.acquire) {\n source.leases.add(parsed.leaseToken);\n } else {\n source.leases.delete(parsed.leaseToken);\n releaseRendererFunctionIfIdle(parsed.functionId);\n }\n return;\n }\n if (parsed.type === 'renderer-function-result-consumed') {\n if (\n !Number.isInteger(parsed.callId) ||\n typeof parsed.callId !== 'number' ||\n parsed.callId <= 0\n ) {\n return;\n }\n const transfers = rendererResultTransfers.get(parsed.callId);\n if (transfers !== undefined) {\n rendererResultTransfers.delete(parsed.callId);\n releaseRendererFunctionTransfers(transfers);\n }\n return;\n }\n if (\n parsed.type !== 'result' ||\n !Number.isInteger(parsed.callId) ||\n typeof parsed.callId !== 'number' ||\n parsed.callId <= 0 ||\n parsed.callId > maximumCallId ||\n typeof parsed.success !== 'boolean'\n ) {\n return;\n }\n\n const pending = takePending(parsed.callId);\n if (pending === undefined) {\n return;\n }\n if (parsed.success) {\n try {\n if (pending.returnType === undefined) {\n pending.resolve(parsed.value);\n } else {\n if (parsed.valueType !== pending.returnType.type) {\n throw new TypeError('Android native result type is invalid');\n }\n pending.resolve(\n decodeNativeResult(\n parsed.value,\n pending.returnType,\n decodeFunctionValue\n )\n );\n }\n } catch (error) {\n pending.reject(error);\n }\n } else {\n pending.reject(\n new Error(\n typeof parsed.error === 'string'\n ? parsed.error\n : 'Native WebView RPC call failed'\n )\n );\n }\n };\n\n const handleBinaryMessage = (message: ArrayBuffer): void => {\n const frame = decodeMuonWebViewRpcBinaryFrame(message);\n if (frame === undefined) {\n return;\n }\n if (frame.kind === 'renderer-argument') {\n const pending = pendingRendererFunctionCalls.get(frame.callId);\n if (\n pending === undefined ||\n frame.attachment >= pending.expectedAttachmentLengths.length ||\n pending.expectedAttachmentLengths[frame.attachment] !==\n frame.payload.byteLength ||\n pending.attachments[frame.attachment] !== undefined\n ) {\n return;\n }\n pending.attachments[frame.attachment] = frame.payload;\n pending.receivedAttachmentCount += 1;\n if (\n pending.receivedAttachmentCount ===\n pending.expectedAttachmentLengths.length\n ) {\n beginRendererFunctionCall(pending);\n }\n return;\n }\n if (frame.kind !== 'result') {\n return;\n }\n const pending = takePending(frame.callId);\n if (pending === undefined) {\n return;\n }\n if (\n pending.returnType !== undefined &&\n pending.returnType.type !== 'buffer_view'\n ) {\n pending.reject(new TypeError('Unexpected Android native binary result'));\n return;\n }\n pending.resolve(frame.payload);\n };\n\n transport.setMessageHandler((message) => {\n if (disposed) {\n return;\n }\n if (typeof message === 'string') {\n handleTextMessage(message);\n } else {\n handleBinaryMessage(message);\n }\n });\n\n const call = (\n capabilityId: string,\n functionPath: string,\n arguments_: readonly unknown[],\n options?: MuonWebViewRpcCallOptions\n ): Promise<unknown> => {\n return invokeCall(\n {\n kind: 'plugin',\n capabilityId,\n functionPath,\n functionMetadata: functionsByPath.get(functionPath),\n },\n arguments_,\n options\n );\n };\n\n const dispose = (): void => {\n if (disposed) {\n return;\n }\n disposed = true;\n transport.setMessageHandler(undefined);\n try {\n transport.send(\n JSON.stringify({ version: protocolVersion, type: 'release' })\n );\n } catch {\n // The JavaScript context is being released, so transport errors are final.\n }\n for (const pending of pendingCalls.values()) {\n detachAbortListener(pending);\n releaseRendererFunctionTransfers(pending.rendererFunctionTransfers);\n pending.reject(new Error('muon WebView RPC client was disposed'));\n }\n pendingCalls.clear();\n pendingRendererFunctionCalls.clear();\n for (const transfers of rendererResultTransfers.values()) {\n releaseRendererFunctionTransfers(transfers);\n }\n rendererResultTransfers.clear();\n rendererFunctions.clear();\n for (const state of livePluginProxyStates) {\n state.released = true;\n pluginProxyFinalizer?.unregister(state);\n }\n livePluginProxyStates.clear();\n };\n\n return {\n call,\n dispose,\n getPendingCallCount: () => pendingCalls.size,\n };\n};\n\n/**\n * Installs the capability call boundary consumed by generated muon modules.\n *\n * @param client - WebView RPC client used for generated capability calls.\n * @param target - Global-like object on which to install the boundary.\n * @returns A function that restores the previous property state.\n */\nexport const installMuonWebViewCapabilityBridge = (\n client: MuonWebViewRpcClient,\n target: Record<PropertyKey, unknown> = globalThis as unknown as Record<\n PropertyKey,\n unknown\n >\n): (() => void) => {\n const property = '__muon_plugin_call';\n const previous = Object.getOwnPropertyDescriptor(target, property);\n Object.defineProperty(target, property, {\n configurable: true,\n enumerable: false,\n writable: true,\n value: (\n capabilityId: string,\n functionPath: string,\n arguments_: readonly unknown[]\n ) => client.call(capabilityId, functionPath, arguments_),\n });\n\n return () => {\n if (previous === undefined) {\n Reflect.deleteProperty(target, property);\n } else {\n Object.defineProperty(target, property, previous);\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 {\n createMuonAndroidSimpleApi,\n muonAndroidBuiltinFunctionPaths,\n} from './android-api.js';\nimport { installMuonAndroidNativePluginApi } from './native-plugin-api.js';\nimport type { MuonAndroidRendererMetadata } from './native-plugin-metadata.js';\nimport {\n createMuonWebViewRpcClient,\n createMuonWebViewRpcTransport,\n installMuonWebViewCapabilityBridge,\n type MuonWebViewJavaScriptBridge,\n type MuonWebViewRpcClient,\n} from './webview-rpc.js';\n\n// Virtual modules use public arguments; platform RPC uses Android wire values.\n// Reuse the simple API conversions with the capability supplied by the module.\nconst createCapabilityClient = (\n client: MuonWebViewRpcClient\n): MuonWebViewRpcClient => ({\n ...client,\n call: async (id, path, args, options) => {\n if (\n !(muonAndroidBuiltinFunctionPaths as readonly string[]).includes(path)\n ) {\n return await client.call(id, path, args, options);\n }\n const api = createMuonAndroidSimpleApi(client, {\n 'muon.browser': id,\n 'muon.environments': id,\n 'muon.fs': id,\n });\n const [, namespace, name] = path.split('.');\n const functions = Reflect.get(api, namespace!) as object;\n const call = Reflect.get(functions, name!) as (\n ...args: readonly unknown[]\n ) => Promise<unknown>;\n return await call(...args);\n },\n});\n\n/**\n * Installs the packaged Android API before application scripts execute.\n * @param bridge - Native WebView transport restricted to the trusted origin.\n * @param metadata - Metadata from the native context for this document.\n * @param target - Object receiving the public API and capability bridge.\n * @returns Releases the context and restores previous global properties.\n */\nexport const bootstrapMuonAndroid = (\n bridge: MuonWebViewJavaScriptBridge,\n metadata: MuonAndroidRendererMetadata,\n target: Record<PropertyKey, unknown>\n): (() => void) => {\n const client = createMuonWebViewRpcClient(\n createMuonWebViewRpcTransport(bridge),\n metadata\n );\n const uninstallCapabilities = installMuonWebViewCapabilityBridge(\n metadata.mode === 'validate' ? createCapabilityClient(client) : client,\n target\n );\n const api = createMuonAndroidSimpleApi(client, {\n 'muon.browser': 'browser-capability',\n 'muon.environments': 'environment-capability',\n 'muon.fs': 'fs-capability',\n });\n const allowed = new Set(metadata.builtinFunctions);\n const builtin = Object.fromEntries(\n Object.entries(api).flatMap(([namespace, functions]) => {\n const selected = Object.entries(functions).filter(([name]) =>\n allowed.has(`muon.${namespace}.${name}`)\n );\n return selected.length === 0\n ? []\n : [[namespace, Object.fromEntries(selected)]];\n })\n );\n const uninstallApi = installMuonAndroidNativePluginApi(\n client,\n metadata,\n Object.keys(builtin).length === 0 ? {} : { muon: builtin },\n target\n );\n return () => {\n uninstallApi();\n uninstallCapabilities();\n client.dispose();\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\n/** Value kinds supported by the native Muon plugin ABI. */\nexport type MuonNativeValueType =\n | 'void'\n | 'bool'\n | 'i8'\n | 'u8'\n | 'i16'\n | 'u16'\n | 'i32'\n | 'u32'\n | 'i64'\n | 'u64'\n | 'f32'\n | 'f64'\n | 'string'\n | 'pointer'\n | 'function'\n | 'buffer_view';\n\n/** Recursive value metadata copied from one loaded native plugin. */\nexport interface MuonNativeTypeMetadata {\n /** ABI value kind. */\n readonly type: MuonNativeValueType;\n\n /** Argument types when this value is a function. */\n readonly args?: readonly MuonNativeTypeMetadata[];\n\n /** Return type when this value is a function. */\n readonly returnType?: MuonNativeTypeMetadata;\n}\n\n/** One namespace produced by a loaded native plugin. */\nexport interface MuonNativeNamespaceMetadata {\n /** Dot-separated namespace exposed in simple mode. */\n readonly namespace: string;\n\n /** Trusted plugin setup source executed after allowed functions exist. */\n readonly setupScript: string;\n\n /** Function property names that setup source may use. */\n readonly allowedFunctions: readonly string[];\n}\n\n/** One callable function produced by a loaded native plugin. */\nexport interface MuonNativeFunctionMetadata {\n /** Runtime-wide native function identifier. */\n readonly id: number;\n\n /** Dot-separated namespace owning this function. */\n readonly namespace: string;\n\n /** Property name exposed in simple mode. */\n readonly name: string;\n\n /** Public name used by capability policies. */\n readonly publicName: string;\n\n /** Capability id assigned by the Android package registry. */\n readonly capabilityId: string;\n\n /** Ordered native argument types. */\n readonly args: readonly MuonNativeTypeMetadata[];\n\n /** Native result type. */\n readonly returnType: MuonNativeTypeMetadata;\n}\n\n/** Renderer metadata captured before the trusted WebView document starts. */\nexport interface MuonAndroidRendererMetadata {\n /** Transport schema version. */\n readonly version: 1;\n\n /** Native RPC context that owns renderer function sources. */\n readonly contextId: number;\n\n /** Page exposure mode selected by the Android host. */\n readonly mode: 'simple' | 'validate';\n\n /** Built-in public function paths allowed by the native host. */\n readonly builtinFunctions: readonly string[];\n\n /** Loaded and allowed plugin namespaces. */\n readonly namespaces: readonly MuonNativeNamespaceMetadata[];\n\n /** Loaded and allowed plugin functions. */\n readonly functions: readonly MuonNativeFunctionMetadata[];\n}\n\nconst valueTypes = new Set<MuonNativeValueType>([\n 'void',\n 'bool',\n 'i8',\n 'u8',\n 'i16',\n 'u16',\n 'i32',\n 'u32',\n 'i64',\n 'u64',\n 'f32',\n 'f64',\n 'string',\n 'pointer',\n 'function',\n 'buffer_view',\n]);\nconst identifierExpression = /^[A-Za-z_$][A-Za-z0-9_$]*$/u;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\nconst readType = (\n value: unknown,\n allowVoid: boolean,\n depth: number\n): MuonNativeTypeMetadata => {\n if (!isRecord(value) || depth > 16 || !valueTypes.has(value.type as never)) {\n throw new TypeError('Android native plugin type metadata is invalid');\n }\n const type = value.type as MuonNativeValueType;\n if (!allowVoid && type === 'void') {\n throw new TypeError('Android native plugin argument type is invalid');\n }\n if (type !== 'function') {\n return Object.freeze({ type });\n }\n if (!Array.isArray(value.args) || !isRecord(value.returnType)) {\n throw new TypeError('Android native function metadata is invalid');\n }\n const args = value.args.map((argument) =>\n readType(argument, false, depth + 1)\n );\n const returnType = readType(value.returnType, true, depth + 1);\n return Object.freeze({ type, args: Object.freeze(args), returnType });\n};\n\nconst readIdentifier = (value: unknown, label: string): string => {\n if (typeof value !== 'string' || !identifierExpression.test(value)) {\n throw new TypeError(`Android native plugin ${label} is invalid`);\n }\n return value;\n};\n\nconst readNamespaceName = (value: unknown): string => {\n if (\n typeof value !== 'string' ||\n value.split('.').some((segment) => !identifierExpression.test(segment))\n ) {\n throw new TypeError('Android native plugin namespace is invalid');\n }\n return value;\n};\n\n/**\n * Validates renderer metadata injected by the trusted Android host.\n *\n * @param value - Candidate document-start metadata value.\n * @returns A deeply immutable metadata snapshot.\n */\nexport const readMuonAndroidRendererMetadata = (\n value: unknown\n): MuonAndroidRendererMetadata => {\n if (\n !isRecord(value) ||\n value.version !== 1 ||\n !Number.isInteger(value.contextId) ||\n typeof value.contextId !== 'number' ||\n value.contextId <= 0 ||\n value.contextId > 0x7fffffff ||\n (value.mode !== 'simple' && value.mode !== 'validate') ||\n !Array.isArray(value.builtinFunctions) ||\n value.builtinFunctions.some((path) => typeof path !== 'string') ||\n !Array.isArray(value.namespaces) ||\n !Array.isArray(value.functions)\n ) {\n throw new TypeError('Android native plugin renderer metadata is invalid');\n }\n\n const namespaces = value.namespaces.map((candidate) => {\n if (\n !isRecord(candidate) ||\n typeof candidate.setupScript !== 'string' ||\n !Array.isArray(candidate.allowedFunctions)\n ) {\n throw new TypeError(\n 'Android native plugin namespace metadata is invalid'\n );\n }\n const allowedFunctions = candidate.allowedFunctions.map((name) =>\n readIdentifier(name, 'allowed function name')\n );\n return Object.freeze({\n namespace: readNamespaceName(candidate.namespace),\n setupScript: candidate.setupScript,\n allowedFunctions: Object.freeze(allowedFunctions),\n });\n });\n\n const functions = value.functions.map((candidate) => {\n if (\n !isRecord(candidate) ||\n !Number.isInteger(candidate.id) ||\n typeof candidate.id !== 'number' ||\n candidate.id < 0 ||\n candidate.id > 0xffffffff ||\n typeof candidate.capabilityId !== 'string' ||\n candidate.capabilityId.length === 0 ||\n !Array.isArray(candidate.args)\n ) {\n throw new TypeError('Android native plugin function metadata is invalid');\n }\n return Object.freeze({\n id: candidate.id,\n namespace: readNamespaceName(candidate.namespace),\n name: readIdentifier(candidate.name, 'function name'),\n publicName: readIdentifier(candidate.publicName, 'public function name'),\n capabilityId: candidate.capabilityId,\n args: Object.freeze(\n candidate.args.map((argument) => readType(argument, false, 0))\n ),\n returnType: readType(candidate.returnType, true, 0),\n });\n });\n\n return Object.freeze({\n version: 1,\n contextId: value.contextId,\n mode: value.mode,\n builtinFunctions: Object.freeze([...value.builtinFunctions] as string[]),\n namespaces: Object.freeze(namespaces),\n functions: Object.freeze(functions),\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 { bootstrapMuonAndroid } from './bootstrap.js';\nimport { readMuonAndroidRendererMetadata } from './native-plugin-metadata.js';\nimport type { MuonWebViewJavaScriptBridge } from './webview-rpc.js';\n\nif (window === window.top) {\n const dispose = bootstrapMuonAndroid(\n Reflect.get(globalThis, 'muonAndroidRpc') as MuonWebViewJavaScriptBridge,\n readMuonAndroidRendererMetadata(\n Reflect.get(globalThis, '__muon_android_plugin_metadata')\n ),\n globalThis as unknown as Record<PropertyKey, unknown>\n );\n window.addEventListener('pagehide', dispose, { once: true });\n}\n"],"mappings":";;;;;;;;;;;;CAMA,IAAa,uBAAuB;EAClC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;;CAGA,IAAa,2BAA2B;EACtC;EACA;EACA;EACA;CACF;;CAG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