@henrikvilhelmberglund/vite-plugin-monkey 4.0.4
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +10 -0
- package/client.d.ts +1085 -0
- package/dist/client/index.d.ts +802 -0
- package/dist/client/index.mjs +69 -0
- package/dist/client/index.mjs.map +1 -0
- package/dist/client/metafile-esm.json +1 -0
- package/dist/native/index.d.ts +29 -0
- package/dist/native/index.mjs +58 -0
- package/dist/native/index.mjs.map +1 -0
- package/dist/native/metafile-esm.json +1 -0
- package/dist/node/index.d.ts +845 -0
- package/dist/node/index.mjs +2487 -0
- package/dist/node/index.mjs.map +1 -0
- package/global.d.ts +1294 -0
- package/package.json +89 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/node/_logger.ts","../../src/node/_util.ts","../../src/node/unimport.ts","../../src/node/cdn.ts","../../src/node/inject_template.ts","../../src/node/option.ts","../../src/node/plugins/server.ts","../../src/node/open_browser.ts","../../src/node/userscript/greasemonkey.ts","../../src/node/userscript/tampermonkey.ts","../../src/node/userscript/violentmonkey.ts","../../src/node/userscript/index.ts","../../src/node/plugins/virtualHtml.ts","../../src/node/plugins/fixViteAsset.ts","../../src/node/plugins/fixViteClient.ts","../../src/node/plugins/externalGlobals.ts","../../src/node/plugins/externalLoader.ts","../../src/node/plugins/externalResource.ts","../../src/node/plugins/finalBundle.ts","../../src/node/_lazy.ts","../../src/node/systemjs.ts","../../src/node/util.ts","../../src/node/topLevelAwait.ts","../../src/node/plugins/perview.ts","../../src/node/plugins/redirectClient.ts","../../src/node/plugins/inlinesAsset.ts","../../src/node/plugins/index.ts","../../src/node/index.ts"],"sourcesContent":["import pc from 'picocolors';\n\nexport type Message = string | number | null | undefined;\ntype OutputOptions = {\n /**\n * @default false\n */\n time?: boolean;\n};\n\nconst log = (tag: string, message: Message, options?: OutputOptions) => {\n console.log(\n [\n (options?.time ?? false) === true\n ? pc.dim(new Date().toLocaleTimeString())\n : '',\n pc.bold(pc.blue(`[${tag}]`)),\n message,\n ]\n .filter((s) => s)\n .join('\\x20'),\n );\n};\nconst info = (tag: string, message: Message, options?: OutputOptions) => {\n log(tag, pc.white(message), options);\n};\nconst warn = (tag: string, message: Message, options?: OutputOptions) => {\n log(tag, pc.yellow(message), options);\n};\nconst error = (tag: string, message: Message, options?: OutputOptions) => {\n log(tag, pc.red(message), options);\n};\nexport const createLogger = (tag: string) => ({\n info: async (message: Message, options?: OutputOptions) => {\n info(tag, message, options);\n },\n warn: async (message: Message, options?: OutputOptions) => {\n warn(tag, message, options);\n },\n error: async (message: Message, options?: OutputOptions) => {\n error(tag, message, options);\n },\n});\n\n/**\n * default logger\n */\nexport const logger = createLogger('plugin-monkey');\n\nexport type Logger = ReturnType<typeof createLogger>;\n","import * as acornWalk from 'acorn-walk';\nimport { readFileSync } from 'node:fs';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport type { OutputBundle, PluginContext } from 'rollup';\nimport { normalizePath, transformWithEsbuild } from 'vite';\nimport { logger } from './_logger';\nimport { FinalMonkeyOption } from './types';\nimport { resolve } from 'import-meta-resolve';\nimport { pathToFileURL } from 'node:url';\nimport { GmApiNames } from './unimport';\n\nexport const delay = async (n = 0) => {\n await new Promise<void>((res) => {\n setTimeout(res, n);\n });\n};\n\nconst get_vite_start_time = () => {\n // @see https://github.com/vitejs/vite/blob/c703a3348adeaad9dc92d805a381866917f2a03b/packages/vite/src/node/server/index.ts#L741\n const n: unknown = Reflect.get(globalThis, '__vite_start_time') ?? 0;\n if (typeof n != 'number') {\n return 0;\n } else {\n return n;\n }\n};\n\nexport const isFirstBoot = (n = 1000) => get_vite_start_time() < n;\n\nexport const GM_keywords = [\n 'GM.addElement',\n 'GM.addStyle',\n 'GM.deleteValue',\n 'GM.getResourceUrl',\n 'GM.getValue',\n 'GM.info',\n 'GM.listValues',\n 'GM.notification',\n 'GM.openInTab',\n 'GM.registerMenuCommand',\n 'GM.setClipboard',\n 'GM.setValue',\n 'GM.xmlHttpRequest',\n 'GM.cookie',\n ...GmApiNames.filter((s) => s.startsWith('GM_')),\n 'unsafeWindow',\n 'window.close',\n 'window.focus',\n 'window.onurlchange',\n];\ntype RawPackageJson = {\n name?: string;\n version?: string;\n description?: string;\n license?: string;\n author?: string | { name: string };\n homepage?: string;\n repository?: string | { url?: string };\n bugs?: string | { url?: string };\n};\ntype PackageJson = {\n name: string;\n version: string;\n description?: string;\n license?: string;\n author?: string;\n homepage?: string;\n repository?: string;\n bugs?: string;\n};\n\nexport const projectPkg = (() => {\n let rawTarget: RawPackageJson = {};\n try {\n rawTarget = JSON.parse(\n readFileSync(path.resolve(process.cwd(), 'package.json'), 'utf-8'),\n );\n } catch {\n rawTarget = {};\n }\n\n const target: PackageJson = {\n name: 'monkey',\n version: '1.0.0',\n };\n Object.entries(rawTarget).forEach(([k, v]) => {\n if (typeof v == 'string') {\n Reflect.set(target, k, v);\n }\n });\n if (\n rawTarget.author instanceof Object &&\n typeof rawTarget.author?.name == 'string'\n ) {\n target.author = rawTarget.author?.name;\n }\n if (\n rawTarget.bugs instanceof Object &&\n typeof rawTarget.bugs?.url == 'string'\n ) {\n target.bugs = rawTarget.bugs?.url;\n }\n if (\n rawTarget.repository instanceof Object &&\n typeof rawTarget.repository?.url == 'string'\n ) {\n const { url } = rawTarget.repository;\n if (url.startsWith('http')) {\n target.repository = url;\n } else if (url.startsWith('git+http')) {\n target.repository = url.slice(4);\n }\n }\n return target;\n})();\n\nexport const compatResolve = (id: string) => {\n return resolve(id, pathToFileURL(process.cwd() + '/any.js').href);\n};\n\nexport const existFile = async (path: string) => {\n try {\n return (await fs.stat(path)).isFile();\n } catch {\n return false;\n }\n};\n\n/**\n * unstable\n */\nconst resolvePackageJsonFromPath = async (name: string) => {\n const p = normalizePath(process.cwd()).split('/');\n for (let i = p.length; i > 0; i--) {\n const p2 = `${p.slice(0, i).join('/')}/node_modules/${name}/package.json`;\n if (await existFile(p2)) {\n return p2;\n }\n }\n};\n\nexport const getModuleRealInfo = async (importName: string) => {\n const importName2 = normalizePath(importName.split('?')[0]);\n const resolveName = normalizePath(compatResolve(importName2)).replace(\n /.*\\/node_modules\\/[^/]+\\//,\n '',\n );\n let version: string | undefined = undefined;\n const nameList = importName2.split('/');\n let pkgName = importName2;\n while (nameList.length > 0) {\n pkgName = nameList.join('/');\n const filePath = await (async () => {\n const p = await resolvePackageJsonFromPath(pkgName);\n if (p) {\n return p;\n }\n try {\n return compatResolve(`${pkgName}/package.json`);\n } catch {\n return undefined;\n }\n })();\n if (filePath === undefined || !(await existFile(filePath))) {\n nameList.pop();\n continue;\n }\n const modulePack: PackageJson = JSON.parse(\n await fs.readFile(filePath, 'utf-8'),\n );\n version = modulePack.version;\n break;\n }\n if (version === undefined) {\n logger.warn(\n `not found module ${importName2} version, use ${importName2}@latest`,\n );\n pkgName = importName2;\n version = 'latest';\n }\n return { version, name: pkgName, resolveName };\n};\n\nexport const mergeObj = <T, S>(target: T | undefined, source: S) => {\n if (target === undefined) return { ...source } as T & S;\n const obj = { ...target };\n for (const k in source) {\n // @ts-ignore\n if (obj[k] === undefined) {\n // @ts-ignore\n obj[k] = source[k];\n }\n }\n return obj as T & S;\n};\n\nexport const miniCode = async (code: string, type: 'css' | 'js' = 'js') => {\n return (\n await transformWithEsbuild(code, 'any_name.' + type, {\n minify: true,\n sourcemap: false,\n legalComments: 'none',\n })\n ).code.trimEnd();\n};\n\nexport const toValidURL = (url: unknown) => {\n if (typeof url != 'string') return;\n try {\n return new URL(url);\n } catch {}\n};\n\nexport const isTopLevelAwaitAvailableTarget = async (\n target?: string | string[],\n) => {\n target = getFinalTarget(target);\n return transformWithEsbuild(`await 1`, 'any.js', {\n target,\n logLevel: 'silent',\n })\n .then(() => true)\n .catch(() => false);\n};\n\n// https://github.com/vitejs/vite/blob/b9511f1ed8e36a618214944c69e2de6504ebcb3c/packages/vite/src/node/constants.ts#L20\nexport const ESBUILD_MODULES_TARGET = [\n 'es2020',\n 'edge88',\n 'firefox78',\n 'chrome87',\n 'safari14',\n];\n\nexport const getFinalTarget = (target?: string | string[]) => {\n if (target === 'modules') {\n target = ESBUILD_MODULES_TARGET;\n }\n return target;\n};\n\nexport const moduleExportExpressionWrapper = (expression: string) => {\n let n = 0;\n let identifier = ``;\n while (expression.includes(identifier)) {\n identifier = `_${(n || ``).toString(16)}`;\n n++;\n }\n // https://github.com/lisonge/vite-plugin-monkey/issues/70\n return `(()=>{const ${identifier}=${expression};('default' in ${identifier})||(${identifier}.default=${identifier});return ${identifier}})()`;\n};\n\n// https://stackoverflow.com/questions/7616461\nexport const cyrb53hash = (str = ``, seed = 0) => {\n let h1 = 0xdeadbeef ^ seed,\n h2 = 0x41c6ce57 ^ seed;\n for (let i = 0, ch; i < str.length; i++) {\n ch = str.charCodeAt(i);\n h1 = Math.imul(h1 ^ ch, 2654435761);\n h2 = Math.imul(h2 ^ ch, 1597334677);\n }\n h1 = Math.imul(h1 ^ (h1 >>> 16), 2246822507);\n h1 ^= Math.imul(h2 ^ (h2 >>> 13), 3266489909);\n h2 = Math.imul(h2 ^ (h2 >>> 16), 2246822507);\n h2 ^= Math.imul(h1 ^ (h1 >>> 13), 3266489909);\n\n return (4294967296 * (2097151 & h2) + (h1 >>> 0))\n .toString(36)\n .substring(0, 8);\n};\n\nexport async function* walk(dirPath: string) {\n const pathnames = (await fs.readdir(dirPath)).map((s) =>\n path.join(dirPath, s),\n );\n while (pathnames.length > 0) {\n const pathname = pathnames.pop()!;\n const state = await fs.lstat(pathname);\n if (state.isFile()) {\n yield pathname;\n } else if (state.isDirectory()) {\n pathnames.push(\n ...(await fs.readdir(pathname)).map((s) => path.join(pathname, s)),\n );\n }\n }\n}\n\nexport const collectGrant = (\n context: PluginContext,\n bundleOrCode: OutputBundle | string | string[],\n): Set<string> => {\n const codes: string[] = [];\n if (typeof bundleOrCode == 'string') {\n codes.push(bundleOrCode);\n } else if (Array.isArray(bundleOrCode)) {\n codes.push(...bundleOrCode);\n } else {\n Object.values(bundleOrCode).forEach((chunk) => {\n if (chunk.type == 'chunk') {\n codes.push(chunk.code);\n }\n });\n }\n const unusedMembers = new Set(GM_keywords.filter((s) => s.includes(`.`)));\n const unusedIdentifiers = new Set(\n GM_keywords.filter((s) => !s.includes(`.`)),\n );\n const usedGm = new Set<string>();\n for (const code of codes) {\n if (!code.trim()) continue;\n const ast = context.parse(code);\n acornWalk.simple(\n ast,\n {\n MemberExpression(node: any) {\n if (unusedMembers.size == 0) return;\n const memberName = node.object?.name + '.' + node.property?.name;\n for (const unusedName of unusedMembers.values()) {\n if (memberName.endsWith(unusedName)) {\n usedGm.add(unusedName);\n unusedMembers.delete(unusedName);\n break;\n }\n }\n },\n Identifier(node: any) {\n if (unusedIdentifiers.size == 0) return;\n const identifier = node.name;\n if (unusedIdentifiers.has(identifier)) {\n usedGm.add(identifier);\n unusedIdentifiers.delete(identifier);\n }\n },\n },\n { ...acornWalk.base },\n );\n if (unusedMembers.size == 0 && unusedIdentifiers.size == 0) {\n break;\n }\n }\n return usedGm;\n};\n\nexport const getInjectCssCode = async (\n finalOption: FinalMonkeyOption,\n rawBundle: OutputBundle,\n) => {\n const cssTexts: string[] = [];\n Object.entries(rawBundle).forEach(([k, v]) => {\n if (v.type == 'asset' && k.endsWith('.css')) {\n cssTexts.push(v.source.toString());\n delete rawBundle[k];\n }\n });\n const css = cssTexts.join('').trim();\n if (css) {\n // use \\x20 to compat unocss, see https://github.com/lisonge/vite-plugin-monkey/issues/45\n return await finalOption.cssSideEffects(`\\x20` + css + `\\x20`);\n }\n};\n","export const GmApiNames = [\n 'GM',\n 'GM_addElement',\n 'GM_addStyle',\n 'GM_addValueChangeListener',\n 'GM_cookie',\n 'GM_deleteValue',\n 'GM_download',\n 'GM_getResourceText',\n 'GM_getResourceURL',\n 'GM_getTab',\n 'GM_getTabs',\n 'GM_getValue',\n 'GM_info',\n 'GM_listValues',\n 'GM_log',\n 'GM_notification',\n 'GM_openInTab',\n 'GM_registerMenuCommand',\n 'GM_removeValueChangeListener',\n 'GM_saveTab',\n 'GM_setClipboard',\n 'GM_setValue',\n 'GM_unregisterMenuCommand',\n 'GM_xmlhttpRequest',\n 'GM_webRequest',\n];\n\nexport const preset = {\n from: 'vite-plugin-monkey/dist/client',\n imports: [...GmApiNames, 'unsafeWindow', 'monkeyWindow'],\n};\n","import type { ModuleToUrlFc } from './types';\n\n/**\n * `https://cdn.jsdelivr.net/npm/${name}@${version}/${pathname}`\n * @param exportVarName cdn-exportVarName or resourceName\n * @param pathname jsdelivr support file combine, normally you don't need set pathname\n * @see https://www.jsdelivr.com/features\n */\nexport const jsdelivr = (\n exportVarName = '',\n pathname = '',\n): [string, ModuleToUrlFc] => {\n return [\n exportVarName,\n (version, name, _importName = '', resolveName = '') => {\n const p = pathname || resolveName;\n if (p) {\n return `https://cdn.jsdelivr.net/npm/${name}@${version}/${p}`;\n } else {\n return `https://cdn.jsdelivr.net/npm/${name}@${version}`;\n }\n },\n ];\n};\n\n/**\n * `https://fastly.jsdelivr.net/npm/${name}@${version}/${pathname}`\n * @param exportVarName cdn-exportVarName or resourceName\n * @param pathname jsdelivr support file combine, normally you don't need set pathname\n * @see https://www.jsdelivr.com/features\n */\nexport const jsdelivrFastly = (\n exportVarName = '',\n pathname = '',\n): [string, ModuleToUrlFc] => {\n return [\n exportVarName,\n (version, name, _importName = '', resolveName = '') => {\n const p = pathname || resolveName;\n if (p) {\n return `https://fastly.jsdelivr.net/npm/${name}@${version}/${p}`;\n } else {\n return `https://fastly.jsdelivr.net/npm/${name}@${version}`;\n }\n },\n ];\n};\n\n/**\n * `https://unpkg.com/${name}@${version}/${pathname}`\n * @param exportVarName cdn-exportVarName or resourceName\n * @see https://unpkg.com/\n */\nexport const unpkg = (\n exportVarName = '',\n pathname = '',\n): [string, ModuleToUrlFc] => {\n return [\n exportVarName,\n (version, name, _importName = '', resolveName = '') => {\n const p = pathname || resolveName;\n if (p) {\n return `https://unpkg.com/${name}@${version}/${p}`;\n } else {\n return `https://unpkg.com/${name}@${version}`;\n }\n },\n ];\n};\n\n/**\n * `https://lf9-cdn-tos.bytecdntp.com/cdn/expire-10-y/${name}/${version}/${pathname}`\n * @param exportVarName cdn-exportVarName or resourceName\n * @see https://cdn.bytedance.com/\n */\nexport const bytecdntp = (\n exportVarName = '',\n pathname = '',\n): [string, ModuleToUrlFc] => {\n return [\n exportVarName,\n (version, name, _importName = '', resolveName = '') => {\n const p = pathname || resolveName;\n return `https://lf9-cdn-tos.bytecdntp.com/cdn/expire-10-y/${name}/${version}/${p}`;\n },\n ];\n};\n\n/**\n * `https://cdn.jsdelivr.net/npm/${name}@${version}/${pathname}`\n * @deprecated bootcdn will return virus-infected code. Please stop using it and switch to other sources\n */\nexport const bootcdn = (\n exportVarName = '',\n pathname = '',\n): [string, ModuleToUrlFc] => {\n console.warn(\n 'bootcdn will return virus-infected code. Please stop using it and switch to other sources. now it will return jsdelivr url.',\n );\n return [\n exportVarName,\n (version, name, _importName = '', resolveName = '') => {\n const p = pathname || resolveName;\n return `https://fastly.jsdelivr.net/npm/${name}@${version}/${p}`;\n },\n ];\n};\n\n/**\n * `https://lib.baomitu.com/${name}/${version}/${pathname}`\n * @param exportVarName cdn-exportVarName or resourceName\n * @see https://cdn.baomitu.com/\n */\nexport const baomitu = (\n exportVarName = '',\n pathname = '',\n): [string, ModuleToUrlFc] => {\n return [\n exportVarName,\n (version, name, _importName = '', resolveName = '') => {\n const p = pathname || resolveName;\n return `https://lib.baomitu.com/${name}/${version}/${p}`;\n },\n ];\n};\n\n/**\n * `https://cdn.staticfile.org/${name}/${version}/${pathname}`\n * @param exportVarName cdn-exportVarName or resourceName\n * @see https://staticfile.org/\n */\nexport const staticfile = (\n exportVarName = '',\n pathname = '',\n): [string, ModuleToUrlFc] => {\n return [\n exportVarName,\n (version, name, _importName = '', resolveName = '') => {\n const p = pathname || resolveName;\n return `https://cdn.staticfile.org/${name}/${version}/${p}`;\n },\n ];\n};\n/**\n * `https://cdnjs.cloudflare.com/ajax/libs/${name}/${version}/${pathname}`\n * @param exportVarName cdn-exportVarName or resourceName\n * @see https://cdnjs.com/libraries\n */\nexport const cdnjs = (\n exportVarName = '',\n pathname = '',\n): [string, ModuleToUrlFc] => {\n return [\n exportVarName,\n (version, name, _importName = '', resolveName = '') => {\n const p = pathname || resolveName;\n return `https://cdnjs.cloudflare.com/ajax/libs/${name}/${version}/${p}`;\n },\n ];\n};\n\n/**\n * `https://unpkg.zhimg.com/${name}/${version}/${pathname}`\n * @param exportVarName cdn-exportVarName or resourceName\n * @link https://unpkg.zhimg.com/\n */\nexport const zhimg = (\n exportVarName = '',\n pathname = '',\n): [string, ModuleToUrlFc] => {\n return [\n exportVarName,\n (version, name, _importName = '', resolveName = '') => {\n const p = pathname || resolveName;\n return `https://unpkg.zhimg.com/${name}@${version}/${p}`;\n },\n ];\n};\n\n/**\n * `https://npm.elemecdn.com/${name}@${version}/${pathname}`\n * @param exportVarName cdn-exportVarName or resourceName\n */\nexport const elemecdn = (\n exportVarName = '',\n pathname = '',\n): [string, ModuleToUrlFc] => {\n return [\n exportVarName,\n (version, name, _importName = '', resolveName = '') => {\n const p = pathname || resolveName;\n return `https://npm.elemecdn.com/${name}@${version}/${p}`;\n },\n ];\n};\n\n/**\n * `https://code.bdstatic.com/npm/${name}@${version}/${pathname}`\n * @param exportVarName cdn-exportVarName or resourceName\n */\nexport const bdstatic = (\n exportVarName = '',\n pathname = '',\n): [string, ModuleToUrlFc] => {\n return [\n exportVarName,\n (version, name, _importName = '', resolveName = '') => {\n const p = pathname || resolveName;\n return `https://code.bdstatic.com/npm/${name}@${version}/${p}`;\n },\n ];\n};\n\n/**\n * `https://registry.npmmirror.com/${name}/${version}/files/${pathname}`\n * @param exportVarName cdn-exportVarName or resourceName\n */\nexport const npmmirror = (\n exportVarName = '',\n pathname = '',\n): [string, ModuleToUrlFc] => {\n return [\n exportVarName,\n (version, name, _importName = '', resolveName = '') => {\n const p = pathname || resolveName;\n if (p) {\n return `https://registry.npmmirror.com/${name}/${version}/files/${p}`;\n } else {\n return `https://registry.npmmirror.com/${name}/${version}/files`;\n }\n },\n ];\n};\n","export const fn2string = <T extends (...args: any[]) => any>(\n fn: T,\n ...args: Parameters<T>\n) => {\n return `;(${fn})(...${JSON.stringify(args, undefined, 2)});`;\n};\n\nconst htmlText = /* html */ `\n<!DOCTYPE html>\n<html>\n <head>\n <meta charset=\"UTF-8\" />\n <link rel=\"icon\" type=\"image/svg+xml\" href=\"https://vitejs.dev/logo.svg\" />\n <title>Vite</title>\n </head>\n <script type=\"module\" data-source=\"vite-plugin-monkey\">\n __CODE__\n </script>\n</html>\n`.trimStart();\n\nexport const fcToHtml = <T extends (...args: any[]) => any>(\n fn: T,\n ...args: Parameters<T>\n) => {\n return htmlText.replace(\n `__CODE__`,\n `;(${fn})(...${JSON.stringify(args, void 0, 2)});`,\n );\n};\n\nexport const serverInjectFn = ({ entrySrc = `` }) => {\n // @ts-ignore\n window.GM; // must exist, see https://github.com/Tampermonkey/tampermonkey/issues/1567\n\n const key = `__monkeyWindow-` + new URL(entrySrc).origin;\n // @ts-ignore\n document[key] = window;\n console.log(`[vite-plugin-monkey] mount monkeyWindow to document`);\n\n const entryScript = document.createElement('script');\n entryScript.type = 'module';\n entryScript.src = entrySrc;\n document.head.insertBefore(entryScript, document.head.firstChild);\n console.log(`[vite-plugin-monkey] mount entry module to document.head`);\n};\n\nexport const cssInjectFn = (css: string) => {\n const style = document.createElement('style');\n style.dataset.source = 'vite-plugin-monkey';\n style.textContent = css;\n document.head.append(style);\n};\n\nexport const mountGmApiFn = (meta: ImportMeta, apiNames: string[] = []) => {\n const key = `__monkeyWindow-` + new URL(meta.url).origin;\n // @ts-ignore\n const monkeyWindow: Window = document[key];\n if (!monkeyWindow) {\n console.log(`[vite-plugin-monkey] not found monkeyWindow`);\n return;\n }\n\n // @ts-ignore\n window.unsafeWindow = window;\n console.log(`[vite-plugin-monkey] mount unsafeWindow to unsafeWindow`);\n\n let mountedApiSize = 0;\n apiNames.forEach((apiName) => {\n // @ts-ignore\n const fn = monkeyWindow[apiName];\n if (fn) {\n // @ts-ignore\n window[apiName] = monkeyWindow[apiName];\n mountedApiSize++;\n }\n });\n console.log(\n `[vite-plugin-monkey] mount ${mountedApiSize}/${apiNames.length} GM_api to unsafeWindow`,\n );\n};\n\nexport const virtualHtmlTemplate = async (url: string) => {\n const delay = (n = 0) => new Promise<void>((res) => setTimeout(res, n));\n await delay();\n const u = new URL(url, location.origin);\n u.searchParams.set('origin', u.origin);\n if (window == window.parent) {\n location.href = u.href;\n await delay(500);\n window.close();\n return;\n }\n // if in iframe, like codesandbox\n const style = document.createElement('style');\n document.head.append(style);\n style.innerText = /* css */ `\n body {\n font-family: Arial, sans-serif;\n margin: 0;\n }\n .App {\n margin: 25px;\n }\n p {\n font-size: 1.5em;\n }\n a {\n color: blue;\n text-decoration: none;\n font-size: 1.5em;\n }\n a:hover {\n text-decoration: underline;\n }\n`.trim();\n document.body.innerHTML = /* html */ `\n <div class=\"App\">\n <h1>PREVIEW PAGE</h1>\n <p>Click the links below to install userscripts:</p>\n <a target=\"_blank\"></a></th>\n </div>\n `.trim();\n await delay();\n const a = document.querySelector('a')!;\n a.href = location.href;\n a.text = location.href;\n};\n\nexport const previewTemplate = async (urls: string[]) => {\n const delay = (n = 0) => new Promise<void>((res) => setTimeout(res, n));\n await delay();\n const style = document.createElement('style');\n document.head.append(style);\n style.innerText = /* css */ `\n body {\n font-family: Arial, sans-serif;\n margin: 0;\n }\n .App {\n margin: 25px;\n }\n p {\n font-size: 1.5em;\n }\n table {\n width: 100%;\n border-collapse: collapse;\n font-size: 1.5em;\n }\n th, td {\n border: 1px solid black;\n padding: 8px;\n text-align: left;\n }\n th {\n background-color: #f2f2f2;\n }\n a {\n color: blue;\n text-decoration: none;\n }\n a:hover {\n text-decoration: underline;\n }\n`.trim();\n if (window == window.parent && urls.length == 1) {\n const u = new URL(urls[0], location.origin);\n location.href = u.href;\n await delay(500);\n window.close();\n return;\n } else if (urls.length == 0) {\n document.body.innerHTML = /* html */ `\n <div class=\"App\">\n <h1> There is no script to install </h1>\n </div>\n `.trim();\n return;\n } else {\n document.body.innerHTML = /* html */ `\n <div class=\"App\">\n <h1>PREVIEW PAGE</h1>\n <p>Click the links below to install userscripts:</p>\n <table>\n <tr>\n <th>No.</th>\n <th>Install Link</th>\n </tr>\n </table>\n </div>\n `.trim();\n await delay();\n const table = document.querySelector<HTMLElement>(`table`)!;\n urls.sort().forEach((u, index) => {\n const tr = document.createElement('tr');\n const td1 = document.createElement('td');\n const td2 = document.createElement('td');\n const a = document.createElement('a');\n td1.innerText = `${index + 1}`;\n if (window != window.parent) {\n a.target = '_blank';\n }\n a.href = u;\n a.textContent = new URL(u, location.origin).href;\n td2.append(a);\n tr.append(td1);\n tr.append(td2);\n table.append(tr);\n });\n }\n};\n","import { logger } from './_logger';\nimport { miniCode, projectPkg } from './_util';\nimport { jsdelivr } from './cdn';\nimport { fn2string } from './inject_template';\nimport type {\n FinalMonkeyOption,\n IArray,\n IPromise,\n Mod2UrlFn,\n MonkeyOption,\n Pkg2UrlFn,\n PkgOptions,\n} from './types';\n\nexport const resolvedOption = (\n pluginOption: MonkeyOption,\n): FinalMonkeyOption => {\n const build = pluginOption.build ?? {};\n\n if (build.minifyCss !== undefined) {\n logger.warn(\n `monkeyConfig.build.minifyCss is deprecated, use viteConfig.build.cssMinify in vite>=4.2.0`,\n { time: false },\n );\n }\n\n const { externalResource = {} } = build;\n const externalResource2: Record<\n string,\n {\n resourceUrl: Pkg2UrlFn;\n resourceName: Pkg2UrlFn;\n loader?: (pkgOptions: PkgOptions) => unknown;\n nodeLoader?: (pkgOptions: PkgOptions) => IPromise<string>;\n }\n > = {};\n\n for (const [k, v] of Object.entries(externalResource)) {\n if (typeof v == 'string') {\n externalResource2[k] = {\n resourceName: () => k,\n resourceUrl: () => v,\n };\n } else if (typeof v == 'function') {\n externalResource2[k] = {\n resourceName: () => k,\n resourceUrl: v,\n };\n } else if (v instanceof Array) {\n let resourceUrl2: Pkg2UrlFn;\n let resourceName2: Pkg2UrlFn = () => k;\n const [resourceName, resourceUrl] = v;\n if (typeof resourceName == 'string') {\n resourceName2 = (pkg) => resourceName || pkg.importName;\n } else {\n resourceName2 = (pkg) =>\n resourceName(pkg.version, pkg.name, pkg.importName, pkg.resolveName);\n }\n if (typeof resourceUrl == 'string') {\n resourceUrl2 = () => resourceUrl;\n } else {\n resourceUrl2 = (pkg) =>\n resourceUrl(pkg.version, pkg.name, pkg.importName, pkg.resolveName);\n }\n externalResource2[k] = {\n resourceName: resourceName2,\n resourceUrl: resourceUrl2,\n };\n } else {\n const { resourceUrl, loader, nodeLoader, resourceName } = v;\n let resourceUrl2: Pkg2UrlFn;\n let resourceName2: Pkg2UrlFn = () => k;\n let nodeLoader2:\n | undefined\n | ((pkgOptions: PkgOptions) => IPromise<string>) = undefined;\n if (typeof resourceUrl == 'string') {\n resourceUrl2 = () => resourceUrl;\n } else {\n resourceUrl2 = resourceUrl;\n }\n if (typeof resourceName == 'string') {\n resourceName2 = () => resourceName;\n } else if (typeof resourceName == 'function') {\n resourceName2 = resourceName;\n }\n if (typeof nodeLoader == 'function') {\n nodeLoader2 = nodeLoader;\n } else if (typeof nodeLoader == 'string') {\n nodeLoader2 = () => nodeLoader;\n }\n externalResource2[k] = {\n resourceName: resourceName2,\n resourceUrl: resourceUrl2,\n loader,\n nodeLoader: nodeLoader2,\n };\n }\n }\n\n const server = pluginOption.server ?? {};\n\n const { prefix } = server;\n let prefix2: (name: string) => string = (s) => 'server:' + s;\n if (typeof prefix == 'function') {\n prefix2 = prefix;\n } else if (typeof prefix == 'string') {\n prefix2 = () => prefix;\n } else if (prefix === false) {\n prefix2 = (name: string) => name;\n }\n const externalGlobals2 = build?.externalGlobals ?? {};\n const externalGlobals: [string, IArray<string | Mod2UrlFn>][] = [];\n if (externalGlobals2 instanceof Array) {\n externalGlobals2.forEach((s) => externalGlobals.push(s));\n } else {\n Object.entries(externalGlobals2).forEach((s) => externalGlobals.push(s));\n }\n\n let {\n name = {},\n description = {},\n 'exclude-match': excludeMatch = [],\n match = [],\n exclude = [],\n include = [],\n antifeature = [],\n require = [],\n connect = [],\n grant = [],\n webRequest = [],\n $extra = [],\n } = pluginOption.userscript ?? {};\n if (typeof name == 'string') {\n name = { '': name };\n } else if (!('' in name)) {\n name = { '': projectPkg.name, ...name };\n }\n if (typeof description == 'string') {\n description = {\n '': description,\n };\n } else if (!('' in description) && projectPkg.description) {\n description = { '': projectPkg.description, ...description };\n }\n if (!(excludeMatch instanceof Array)) {\n excludeMatch = [excludeMatch];\n }\n if (!(match instanceof Array)) {\n match = [match];\n }\n if (!(exclude instanceof Array)) {\n exclude = [exclude];\n }\n if (!(include instanceof Array)) {\n include = [include];\n }\n if (!(antifeature instanceof Array)) {\n antifeature = [antifeature];\n }\n if (!(require instanceof Array)) {\n require = [require];\n }\n if (!(connect instanceof Array)) {\n connect = [connect];\n }\n if (!(webRequest instanceof Array)) {\n webRequest = [webRequest];\n }\n\n const grantSet = new Set<string>();\n if (typeof grant == 'string') {\n grantSet.add(grant);\n } else if (grant instanceof Array) {\n grant.forEach((s) => grantSet.add(s));\n }\n\n const extra: [string, ...string[]][] = [];\n ($extra instanceof Array ? $extra : Object.entries($extra)).forEach(\n ([k, v]) => {\n extra.push([k, ...(v instanceof Array ? v : [v])]);\n },\n );\n\n const {\n icon64,\n icon64URL,\n icon,\n iconURL,\n namespace = `vite-plugin-monkey`,\n version = projectPkg.version,\n author = projectPkg.author ?? 'monkey',\n copyright,\n downloadURL,\n defaulticon,\n contributionURL,\n updateURL,\n supportURL = projectPkg.bugs,\n homepageURL = projectPkg.homepage,\n homepage = projectPkg.homepage,\n website,\n license = projectPkg.license,\n incompatible,\n source = projectPkg.repository,\n resource = {},\n noframes = false,\n 'run-at': runAt,\n 'inject-into': injectInto,\n contributionAmount,\n compatible,\n sandbox,\n unwrap = false,\n } = pluginOption.userscript ?? {};\n\n const { fileName = projectPkg.name + '.user.js' } = build;\n let { metaFileName } = build;\n if (typeof metaFileName == 'string') {\n const t = metaFileName;\n metaFileName = () => t;\n } else if (metaFileName === true) {\n metaFileName = () => fileName.replace(/\\.user\\.js$/, '.meta.js');\n } else if (metaFileName === false) {\n metaFileName = undefined;\n }\n\n const metaFileFc = metaFileName;\n\n const cssSideEffects =\n build.cssSideEffects ||\n (() => {\n return (e: string) => {\n // @ts-ignore\n if (typeof GM_addStyle == 'function') {\n // @ts-ignore\n GM_addStyle(e);\n return;\n }\n const o = document.createElement('style');\n o.textContent = e;\n document.head.append(o);\n };\n });\n\n const config: FinalMonkeyOption = {\n userscript: {\n name,\n namespace,\n version,\n icon64,\n icon64URL,\n icon,\n iconURL,\n author,\n copyright,\n downloadURL,\n defaulticon,\n contributionURL,\n updateURL,\n supportURL,\n homepageURL,\n homepage,\n website,\n license,\n incompatible,\n source,\n resource,\n noframes,\n 'run-at': runAt,\n 'inject-into': injectInto,\n contributionAmount,\n compatible,\n 'exclude-match': excludeMatch.map((s) => String(s)),\n match: match.map((s) => String(s)),\n include: include.map((s) => String(s)),\n exclude: exclude.map((s) => String(s)),\n antifeature,\n require,\n connect,\n description,\n $extra: extra,\n grant: grantSet,\n sandbox,\n unwrap,\n webRequest: webRequest.map((w) => JSON.stringify(w)),\n },\n clientAlias: pluginOption.clientAlias ?? '$',\n entry: pluginOption.entry,\n format: {\n align: pluginOption.format?.align ?? 2,\n generate: pluginOption.format?.generate ?? ((o) => o.userscript),\n },\n server: {\n mountGmApi: server.mountGmApi ?? false,\n open:\n server.open ??\n (process.platform == 'win32' || process.platform == 'darwin'),\n prefix: prefix2,\n closePreviewAutomatically: server.closePreviewAutomatically ?? false,\n },\n build: {\n fileName,\n metaFileName: metaFileFc ? () => metaFileFc(fileName) : undefined,\n autoGrant: build.autoGrant ?? true,\n externalGlobals: externalGlobals,\n externalResource: externalResource2,\n },\n collectRequireUrls: [],\n collectResource: {},\n globalsPkg2VarName: {},\n requirePkgList: [],\n systemjs: build.systemjs ?? jsdelivr()[1],\n cssSideEffects: async (css) => {\n const codeOrFc = await cssSideEffects(css);\n if (typeof codeOrFc == 'string') {\n return codeOrFc;\n }\n return miniCode(fn2string(codeOrFc, css), 'js');\n },\n };\n\n return config;\n};\n","import { DomUtils, ElementType, parseDocument } from 'htmlparser2';\nimport fs from 'node:fs/promises';\nimport path from 'node:path';\nimport { Plugin, ResolvedConfig, normalizePath } from 'vite';\nimport { logger } from '../_logger';\nimport { cyrb53hash, existFile, isFirstBoot, toValidURL } from '../_util';\nimport { fn2string, mountGmApiFn, serverInjectFn } from '../inject_template';\nimport { openBrowser } from '../open_browser';\nimport type { FinalMonkeyOption } from '../types';\nimport { GmApiNames, preset } from '../unimport';\nimport { finalMonkeyOptionToComment } from '../userscript';\n\nexport const installUserPath = '/__vite-plugin-monkey.install.user.js';\nconst gmApiPath = '/__vite-plugin-monkey.gm.api.js';\nconst entryPath = '/__vite-plugin-monkey.entry.js';\nconst pullPath = '/__vite-plugin-monkey.pull.js';\nconst restartStoreKey = '__vite_plugin_monkey_install_url';\n\nexport const serverPlugin = (finalOption: FinalMonkeyOption): Plugin => {\n let viteConfig: ResolvedConfig;\n return {\n name: 'monkey:server',\n apply: 'serve',\n async config(userConfig) {\n return {\n preview: {\n host: userConfig.preview?.host ?? '127.0.0.1',\n cors: true,\n },\n server: {\n host: userConfig.server?.host ?? '127.0.0.1',\n open: userConfig.server?.open ?? finalOption.server.open,\n cors: true,\n },\n };\n },\n async configResolved(resolvedConfig) {\n viteConfig = resolvedConfig;\n },\n async configureServer(server) {\n for (const [k, v] of Object.entries(finalOption.userscript.name)) {\n Reflect.set(\n finalOption.userscript.name,\n k,\n finalOption.server.prefix(v),\n );\n }\n\n // support dev env\n finalOption.userscript.grant.add('*');\n\n server.middlewares.use(async (req, res, next) => {\n const reqUrl = req.url;\n if (\n reqUrl &&\n [installUserPath, entryPath, pullPath, gmApiPath].some((u) =>\n reqUrl.startsWith(u),\n )\n ) {\n Object.entries({\n 'access-control-allow-origin': '*',\n 'content-type': 'application/javascript',\n }).forEach(([k, v]) => {\n res.setHeader(k, v);\n });\n const usp = new URLSearchParams(reqUrl.split('?', 2)[1]);\n\n if (reqUrl.startsWith(installUserPath)) {\n let origin = toValidURL(usp.get(`origin`))?.origin;\n if (!origin) {\n let { https, host, port } = viteConfig.server;\n if (host == '0.0.0.0') {\n host = '127.0.0.1';\n }\n origin = `${https ? 'https' : 'http'}://${host}:${port}`;\n logger.warn(\n `can not get origin from install url query parameter, use ${origin}`,\n {\n time: true,\n },\n );\n }\n Reflect.set(globalThis, restartStoreKey, origin);\n const u = new URL(entryPath, origin);\n res.end(\n [\n await finalMonkeyOptionToComment(\n finalOption,\n new Set(),\n 'serve',\n ),\n fn2string(serverInjectFn, {\n entrySrc: u.href,\n }),\n '',\n ].join('\\n\\n'),\n );\n } else if (reqUrl.startsWith(entryPath)) {\n const htmlText = await server.transformIndexHtml(\n '/',\n `<html><head></head></html>`,\n req.originalUrl,\n );\n\n const doc = parseDocument(htmlText);\n type Element =\n ReturnType<typeof DomUtils.findAll> extends Array<infer T>\n ? T\n : never;\n const scriptList = DomUtils.getElementsByTagType(\n ElementType.Script,\n doc,\n ) as Element[];\n\n const entryList: string[] = finalOption.server.mountGmApi\n ? [gmApiPath]\n : [];\n scriptList.forEach((p) => {\n const src = p.attribs.src ?? '';\n const textNode = p.firstChild;\n let text = '';\n if (textNode?.type == ElementType.Text) {\n text = textNode.data ?? '';\n }\n if (src) {\n entryList.push(src);\n } else {\n const usp = new URLSearchParams({\n text: Buffer.from(text, 'utf-8').toString('base64url'),\n });\n entryList.push(pullPath + `?` + usp.toString());\n }\n });\n\n let realEntry = finalOption.entry;\n if (path.isAbsolute(realEntry)) {\n realEntry = normalizePath(\n path.relative(viteConfig.root, realEntry),\n );\n }\n const entryUrl = new URL(realEntry, 'http://127.0.0.1');\n entryList.push(entryUrl.pathname + entryUrl.search);\n res.end(\n entryList.map((s) => `import ${JSON.stringify(s)};`).join('\\n'),\n );\n } else if (reqUrl.startsWith(pullPath)) {\n res.end(\n Buffer.from(usp.get('text') ?? '', 'base64url').toString('utf-8'),\n );\n } else if (reqUrl.startsWith(gmApiPath)) {\n if (finalOption.server.mountGmApi) {\n res.end(\n `;(${mountGmApiFn})(import.meta, ${JSON.stringify(GmApiNames)});`,\n );\n } else {\n res.end('');\n }\n }\n return;\n }\n\n next();\n });\n\n if (finalOption.server.open) {\n const cacheUserPath = `node_modules/.vite/__vite-plugin-monkey.cache.${cyrb53hash(\n viteConfig.configFile,\n )}.user.js`;\n let cacheComment = '';\n if (await existFile(cacheUserPath)) {\n cacheComment = (await fs.readFile(cacheUserPath)).toString('utf-8');\n } else {\n await fs.mkdir(path.dirname(cacheUserPath)).catch(() => {});\n }\n const newComment = await finalMonkeyOptionToComment(\n finalOption,\n new Set(),\n 'serve',\n );\n const installUrl = Reflect.get(globalThis, restartStoreKey);\n if (!isFirstBoot() && cacheComment != newComment && installUrl) {\n openBrowser(installUrl, true, logger);\n logger.info('reopen, config comment has changed', { time: true });\n }\n await fs.writeFile(cacheUserPath, newComment).catch(() => {});\n }\n },\n };\n};\n","import spawn from 'cross-spawn';\nimport { execSync } from 'node:child_process';\nimport path from 'node:path';\nimport type { Options } from 'open';\nimport colors from 'picocolors';\nimport type { Logger } from './_logger';\nimport { compatResolve } from './_util';\n\n// https://github.com/sindresorhus/open#app\nconst OSX_CHROME = 'google chrome';\n\n/**\n * Reads the BROWSER environment variable and decides what to do with it.\n * Returns true if it opened a browser or ran a node.js script, otherwise false.\n */\nexport function openBrowser(\n url: string,\n opt: string | true,\n logger: Logger,\n): boolean {\n // The browser executable to open.\n // See https://github.com/sindresorhus/open#app for documentation.\n const browser = typeof opt === 'string' ? opt : process.env.BROWSER || '';\n if (browser.toLowerCase().endsWith('.js')) {\n return executeNodeScript(browser, url, logger);\n } else if (browser.toLowerCase() !== 'none') {\n return startBrowserProcess(browser, url);\n }\n return false;\n}\n\nfunction executeNodeScript(scriptPath: string, url: string, logger: Logger) {\n const extraArgs = process.argv.slice(2);\n const child = spawn(process.execPath, [scriptPath, ...extraArgs, url], {\n stdio: 'inherit',\n });\n child.on('close', (code: unknown) => {\n if (code !== 0) {\n logger.error(\n colors.red(\n `\\nThe script specified as BROWSER environment variable failed.\\n\\n${colors.cyan(\n scriptPath,\n )} exited with code ${code}.`,\n ),\n { time: true },\n );\n }\n });\n return true;\n}\n\nfunction startBrowserProcess(browser: string | undefined, url: string) {\n // If we're on OS X, the user hasn't specifically\n // requested a different browser, we can try opening\n // Chrome with AppleScript. This lets us reuse an\n // existing tab when possible instead of creating a new one.\n const shouldTryOpenChromeWithAppleScript =\n process.platform === 'darwin' && (browser === '' || browser === OSX_CHROME);\n\n if (shouldTryOpenChromeWithAppleScript) {\n try {\n // Try our best to reuse existing tab\n // on OS X Google Chrome with AppleScript\n execSync('ps cax | grep \"Google Chrome\"');\n execSync('osascript openChrome.applescript \"' + encodeURI(url) + '\"', {\n cwd: path.dirname(compatResolve('vite/bin/openChrome.applescript')),\n stdio: 'ignore',\n });\n return true;\n } catch (err) {\n // Ignore errors\n }\n }\n\n // Another special case: on OS X, check if BROWSER has been set to \"open\".\n // In this case, instead of passing the string `open` to `open` function (which won't work),\n // just ignore it (thus ensuring the intended behavior, i.e. opening the system browser):\n // https://github.com/facebook/create-react-app/pull/1690#issuecomment-283518768\n if (process.platform === 'darwin' && browser === 'open') {\n browser = undefined;\n }\n\n // Fallback to open\n // (It will always open new tab)\n try {\n const options: Options = browser ? { app: { name: browser } } : {};\n // open is esm only, cjs need\n import('open').then(({ default: open }) => {\n open(url, options).catch(() => {}); // Prevent `unhandledRejection` error.\n });\n return true;\n } catch (err) {\n return false;\n }\n}\n","import { IArray, LocaleType } from '../types';\n\nexport type GreaseRunAt = 'document-start' | 'document-end' | 'document-idle';\n\nexport type GreaseGrant =\n | 'GM.info'\n | 'GM.deleteValue'\n | 'GM.getValue'\n | 'GM.listValues'\n | 'GM.setValue'\n | 'GM.getResourceUrl'\n | 'GM.notification'\n | 'GM.openInTab'\n | 'GM.registerMenuCommand'\n | 'GM.setClipboard'\n | 'GM.xmlHttpRequest'\n | 'unsafeWindow';\n\nexport const GreaseGrantValueList: GreaseGrant[] = [\n 'GM.info',\n 'GM.deleteValue',\n 'GM.getValue',\n 'GM.listValues',\n 'GM.setValue',\n 'GM.getResourceUrl',\n 'GM.notification',\n 'GM.openInTab',\n 'GM.registerMenuCommand',\n 'GM.setClipboard',\n 'GM.xmlHttpRequest',\n 'unsafeWindow',\n];\n\n/**\n * @see https://wiki.greasespot.net/Metadata_Block\n */\nexport interface GreasemonkeyUserScript {\n /**\n * @see https://wiki.greasespot.net/Metadata_Block#.40name\n *\n */\n name?: string | LocaleType<string>;\n\n /**\n * @see https://wiki.greasespot.net/Metadata_Block#.40namespace\n */\n namespace?: string;\n\n /**\n * @see https://wiki.greasespot.net/Metadata_Block#.40version\n *\n */\n version?: string;\n\n /**\n * @see https://wiki.greasespot.net/Metadata_Block#.40description\n *\n */\n description?: string | LocaleType<string>;\n\n /**\n * @see https://wiki.greasespot.net/Metadata_Block#.40icon\n */\n icon?: string;\n\n /**\n * @see https://wiki.greasespot.net/Metadata_Block#.40include\n */\n include?: IArray<string | RegExp>;\n\n /**\n * @see https://wiki.greasespot.net/Metadata_Block#.40match\n */\n match?: IArray<string | RegExp>;\n\n /**\n * @see https://wiki.greasespot.net/Metadata_Block#.40exclude\n */\n exclude?: IArray<string | RegExp>;\n\n /**\n * @see https://wiki.greasespot.net/Metadata_Block#.40require\n */\n require?: IArray<string>;\n\n /**\n * @see https://wiki.greasespot.net/Metadata_Block#.40resource\n */\n resource?: Record<string, string>;\n\n /**\n * @see https://wiki.greasespot.net/Metadata_Block#.40noframes\n */\n noframes?: boolean;\n}\n","import { WebRequestRule } from '../../shared/types';\nimport { IArray, LocaleType } from '../types';\n\nexport type TamperRunAt =\n | 'document-start'\n | 'document-body'\n | 'document-end'\n | 'document-idle'\n | 'context-menu';\n\nexport type TamperGrant =\n | 'unsafeWindow'\n | 'window.close'\n | 'window.focus'\n | 'window.onurlchange'\n | 'GM_addStyle'\n | 'GM_addElement'\n | 'GM_deleteValue'\n | 'GM_listValues'\n | 'GM_addValueChangeListener'\n | 'GM_removeValueChangeListener'\n | 'GM_setValue'\n | 'GM_getValue'\n | 'GM_log'\n | 'GM_getResourceText'\n | 'GM_getResourceURL'\n | 'GM_registerMenuCommand'\n | 'GM_unregisterMenuCommand'\n | 'GM_openInTab'\n | 'GM_xmlhttpRequest'\n | 'GM_download'\n | 'GM_getTab'\n | 'GM_saveTab'\n | 'GM_getTabs'\n | 'GM_notification'\n | 'GM_setClipboard'\n | 'GM_info'\n | 'GM_cookie'\n | 'GM_webRequest';\n\nexport const TamperGrantValueList: TamperGrant[] = [\n 'unsafeWindow',\n 'window.close',\n 'window.focus',\n 'window.onurlchange',\n 'GM_addStyle',\n 'GM_addElement',\n 'GM_deleteValue',\n 'GM_listValues',\n 'GM_addValueChangeListener',\n 'GM_removeValueChangeListener',\n 'GM_setValue',\n 'GM_getValue',\n 'GM_log',\n 'GM_getResourceText',\n 'GM_getResourceURL',\n 'GM_registerMenuCommand',\n 'GM_unregisterMenuCommand',\n 'GM_openInTab',\n 'GM_xmlhttpRequest',\n 'GM_download',\n 'GM_getTab',\n 'GM_saveTab',\n 'GM_getTabs',\n 'GM_notification',\n 'GM_setClipboard',\n 'GM_info',\n 'GM_cookie',\n 'GM_webRequest',\n];\n\nexport type AntifeatureType = {\n tag?: string;\n type: 'ads' | 'tracking' | 'miner';\n description: string;\n};\n\n/**\n * @see https://www.tampermonkey.net/documentation.php\n */\nexport interface TampermonkeyUserScript {\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:name\n *\n */\n name?: string | LocaleType<string>;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:namespace\n */\n namespace?: string;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:copyright\n */\n copyright?: string;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:version\n *\n */\n version?: string;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:author\n *\n */\n author?: string;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:description\n *\n */\n description?: string | LocaleType<string>;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:homepage\n *\n */\n homepage?: string;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:homepage\n *\n */\n homepageURL?: string;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:homepage\n */\n website?: string;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:homepage\n */\n source?: string;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:icon\n */\n icon?: string;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:icon\n */\n iconURL?: string;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:icon\n */\n defaulticon?: string;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:icon64\n */\n icon64?: string;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:icon64\n */\n icon64URL?: string;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:updateURL\n */\n updateURL?: string;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:downloadURL\n */\n downloadURL?: string;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:supportURL\n */\n supportURL?: string;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:include\n */\n include?: IArray<string | RegExp>;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:match\n */\n match?: IArray<string | RegExp>;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:exclude\n */\n exclude?: IArray<string | RegExp>;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:require\n */\n require?: IArray<string>;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:resource\n */\n resource?: Record<string, string>;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:connect\n */\n connect?: IArray<string>;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:sandbox\n */\n sandbox?: 'raw' | 'JavaScript' | 'DOM';\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:antifeature\n */\n antifeature?: IArray<AntifeatureType>;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:noframes\n */\n noframes?: boolean;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:webRequest\n */\n webRequest?: IArray<WebRequestRule>;\n\n /**\n * @see https://www.tampermonkey.net/documentation.php#meta:unwrap\n */\n unwrap?: boolean;\n}\n","import { IArray, LocaleType } from '../types';\n\nexport type ViolentRunAt = 'document-end' | 'document-start' | 'document-idle';\nexport type ViolentInjectInto = 'page' | 'content' | 'auto';\n\nexport type ViolentGrant =\n | 'window.close'\n | 'window.focus'\n | 'GM_info'\n | 'GM_getValue'\n | 'GM_setValue'\n | 'GM_deleteValue'\n | 'GM_listValues'\n | 'GM_addValueChangeListener'\n | 'GM_removeValueChangeListener'\n | 'GM_getResourceText'\n | 'GM_getResourceURL'\n | 'GM_addElement'\n | 'GM_addStyle'\n | 'GM_openInTab'\n | 'GM_registerMenuCommand'\n | 'GM_unregisterMenuCommand'\n | 'GM_notification'\n | 'GM_setClipboard'\n | 'GM_xmlhttpRequest'\n | 'GM_download'\n | 'GM.addStyle'\n | 'GM.addElement'\n | 'GM.registerMenuCommand'\n | 'GM.deleteValue'\n | 'GM.getResourceUrl'\n | 'GM.getValue'\n | 'GM.info'\n | 'GM.listValues'\n | 'GM.notification'\n | 'GM.openInTab'\n | 'GM.setClipboard'\n | 'GM.setValue'\n | 'GM.xmlHttpRequest';\n\nexport const ViolentGrantValueList: ViolentGrant[] = [\n 'window.close',\n 'window.focus',\n 'GM_info',\n 'GM_getValue',\n 'GM_setValue',\n 'GM_deleteValue',\n 'GM_listValues',\n 'GM_addValueChangeListener',\n 'GM_removeValueChangeListener',\n 'GM_getResourceText',\n 'GM_getResourceURL',\n 'GM_addElement',\n 'GM_addStyle',\n 'GM_openInTab',\n 'GM_registerMenuCommand',\n 'GM_unregisterMenuCommand',\n 'GM_notification',\n 'GM_setClipboard',\n 'GM_xmlhttpRequest',\n 'GM_download',\n 'GM.addStyle',\n 'GM.addElement',\n 'GM.registerMenuCommand',\n 'GM.deleteValue',\n 'GM.getResourceUrl',\n 'GM.getValue',\n 'GM.info',\n 'GM.listValues',\n 'GM.notification',\n 'GM.openInTab',\n 'GM.setClipboard',\n 'GM.setValue',\n 'GM.xmlHttpRequest',\n];\n\n/**\n * @see https://violentmonkey.github.io/api/metadata-block/\n */\nexport interface ViolentmonkeyUserScript {\n /**\n * @see https://violentmonkey.github.io/api/metadata-block/#name\n *\n */\n name?: string | LocaleType<string>;\n\n /**\n * @see https://violentmonkey.github.io/api/metadata-block/#namespace\n */\n namespace?: string;\n\n /**\n * @see https://violentmonkey.github.io/api/metadata-block/#version\n *\n */\n version?: string;\n\n /**\n * @see https://violentmonkey.github.io/api/metadata-block/#description\n *\n */\n description?: string | LocaleType<string>;\n\n /**\n * @see https://violentmonkey.github.io/api/metadata-block/#icon\n */\n icon?: string;\n\n /**\n * @see https://violentmonkey.github.io/api/metadata-block/#downloadurl\n */\n downloadURL?: string;\n\n /**\n * @see https://violentmonkey.github.io/api/metadata-block/#supporturl\n */\n supportURL?: string;\n\n /**\n * @see https://violentmonkey.github.io/api/metadata-block/#homepageurl\n *\n */\n homepageURL?: string;\n\n /**\n * @see https://violentmonkey.github.io/api/metadata-block/#include--exclude\n * @see https://violentmonkey.github.io/api/matching/#include--exclude\n */\n include?: IArray<string | RegExp>;\n\n /**\n * @see https://violentmonkey.github.io/api/metadata-block/#match--exclude-match\n * @see https://violentmonkey.github.io/api/matching/#match--exclude-match\n */\n match?: IArray<string | RegExp>;\n\n /**\n * @see https://violentmonkey.github.io/api/metadata-block/#match--exclude-match\n * @see https://violentmonkey.github.io/api/matching/#match--exclude-match\n */\n 'exclude-match'?: IArray<string | RegExp>;\n\n /**\n * @see https://violentmonkey.github.io/api/metadata-block/#include--exclude\n * @see https://violentmonkey.github.io/api/matching/#include--exclude\n */\n exclude?: IArray<string | RegExp>;\n\n /**\n * @see https://violentmonkey.github.io/api/metadata-block/#require\n */\n require?: IArray<string>;\n\n /**\n * @see https://violentmonkey.github.io/api/metadata-block/#resource\n */\n resource?: Record<string, string>;\n\n /**\n * @see https://violentmonkey.github.io/api/metadata-block/#noframes\n */\n noframes?: boolean;\n\n /**\n * @see https://violentmonkey.github.io/api/metadata-block/#inject-into\n */\n 'inject-into'?: ViolentInjectInto;\n\n /**\n * @see https://violentmonkey.github.io/api/metadata-block/#unwrap\n */\n unwrap?: boolean;\n}\n","import type { FinalMonkeyOption, IArray, LocaleType } from '../types';\nimport type { Format } from './common';\nimport type {\n GreaseGrant,\n GreasemonkeyUserScript,\n GreaseRunAt,\n} from './greasemonkey';\nimport { GreaseGrantValueList } from './greasemonkey';\nimport type {\n AntifeatureType,\n TamperGrant,\n TampermonkeyUserScript,\n TamperRunAt,\n} from './tampermonkey';\nimport { TamperGrantValueList } from './tampermonkey';\nimport type {\n ViolentGrant,\n ViolentmonkeyUserScript,\n ViolentRunAt,\n} from './violentmonkey';\nimport { ViolentGrantValueList, ViolentInjectInto } from './violentmonkey';\n\nexport type {\n GreasemonkeyUserScript,\n TampermonkeyUserScript,\n ViolentmonkeyUserScript,\n Format,\n};\n\n/**\n * @see https://greasyfork.org/help/meta-keys\n */\ntype GreasyforkUserScript = {\n /**\n * @see https://greasyfork.org/help/meta-keys\n * @default package.json.license\n */\n license?: string;\n\n /**\n * @see https://greasyfork.org/help/meta-keys\n */\n contributionURL?: string;\n\n /**\n * @see https://greasyfork.org/help/meta-keys\n */\n contributionAmount?: string;\n\n /**\n * @see https://greasyfork.org/help/meta-keys\n */\n compatible?: string;\n\n /**\n * @see https://greasyfork.org/help/meta-keys\n */\n incompatible?: string;\n};\n\ntype MergemonkeyUserScript = {\n /**\n * @default package.json.name??'monkey'\n * @default {...{'':package.json.name??'monkey'},...name} // if name is object\n */\n name?: string | LocaleType<string>;\n\n /**\n * @default 'vite-plugin-monkey'\n */\n namespace?: string;\n\n /**\n * @default package.json.version??'1.0.0'\n */\n version?: string;\n\n /**\n * @default package.json.description\n * @default {...{'':package.json.description},...description} // if description is object\n */\n description?: string | LocaleType<string>;\n\n /**\n * @default package.json.author??'monkey'\n */\n author?: string;\n\n /**\n * @default package.json.homepage\n */\n homepage?: string;\n\n /**\n * @default package.json.homepage\n */\n homepageURL?: string;\n\n /**\n * @default package.json.repository\n */\n source?: string;\n\n /**\n * @default package.json.bugs\n */\n supportURL?: string;\n\n /**\n * @see https://wiki.greasespot.net/Metadata_Block#.40run-at\n *\n * @see https://www.tampermonkey.net/documentation.php#meta:run_at\n *\n * @see https://violentmonkey.github.io/api/metadata-block/#run-at\n *\n */\n 'run-at'?: GreaseRunAt | TamperRunAt | ViolentRunAt;\n\n /**\n * @see https://wiki.greasespot.net/Metadata_Block#.40grant\n *\n * @see https://www.tampermonkey.net/documentation.php#meta:grant\n *\n * @see https://violentmonkey.github.io/api/metadata-block/#grant\n *\n * if set '\\*', will add all GM_* to UserScript\n */\n grant?: IArray<GreaseGrant | TamperGrant | ViolentGrant> | 'none' | '*';\n\n /**\n * custom extra meta\n * @example\n * [['antifeature', ['miner', 'hello233']]]\n * // -->\n * // \\@antifeature miner hello233\n */\n $extra?: [string, IArray<string>][] | Record<string, IArray<string>>;\n};\n\n/**\n * UserScript, merge metadata from Greasemonkey, Tampermonkey, Violentmonkey, Greasyfork\n */\nexport type MonkeyUserScript = GreasemonkeyUserScript &\n TampermonkeyUserScript &\n ViolentmonkeyUserScript &\n GreasyforkUserScript &\n MergemonkeyUserScript;\n\nexport type FinalUserScript = {\n name: LocaleType<string>;\n namespace: string;\n version: string;\n description: LocaleType<string>;\n icon?: string;\n include: string[];\n match: string[];\n exclude: string[];\n require: string[];\n resource: Record<string, string>;\n noframes: boolean;\n unwrap: boolean;\n webRequest: string[];\n\n author: string;\n copyright?: string;\n homepage?: string;\n homepageURL?: string;\n website?: string;\n source?: string;\n iconURL?: string;\n defaulticon?: string;\n icon64?: string;\n icon64URL?: string;\n updateURL?: string;\n downloadURL?: string;\n supportURL?: string;\n connect: string[];\n sandbox?: string;\n antifeature: AntifeatureType[];\n\n 'exclude-match': string[];\n 'inject-into'?: ViolentInjectInto;\n 'run-at'?: GreaseRunAt | TamperRunAt | ViolentRunAt;\n grant: Set<string>;\n $extra: [string, ...string[]][];\n} & GreasyforkUserScript;\n\nexport const finalMonkeyOptionToComment = async (\n {\n userscript,\n format,\n collectRequireUrls,\n collectResource,\n }: FinalMonkeyOption,\n collectGrantSet: Set<string>,\n mode: `serve` | `build` | `meta`,\n): Promise<string> => {\n let attrList: [string, ...string[]][] = [];\n const {\n name,\n namespace,\n version,\n author,\n description,\n license,\n copyright,\n\n icon,\n iconURL,\n icon64,\n icon64URL,\n defaulticon,\n\n homepage,\n homepageURL,\n website,\n source,\n\n supportURL,\n downloadURL,\n updateURL,\n\n include,\n match,\n exclude,\n require,\n 'exclude-match': excludeMatch,\n\n 'inject-into': injectInto,\n 'run-at': runAt,\n\n compatible,\n incompatible,\n\n antifeature,\n contributionAmount,\n contributionURL,\n\n connect,\n sandbox,\n resource,\n grant,\n noframes,\n unwrap,\n webRequest,\n $extra,\n } = userscript;\n Object.entries({\n namespace,\n version,\n author,\n license,\n copyright,\n icon,\n iconURL,\n icon64,\n icon64URL,\n defaulticon,\n homepage,\n homepageURL,\n website,\n source,\n supportURL,\n downloadURL,\n updateURL,\n 'inject-into': injectInto,\n 'run-at': runAt,\n compatible,\n incompatible,\n contributionAmount,\n contributionURL,\n sandbox,\n }).forEach(([k, v]) => {\n if (typeof v == 'string') {\n attrList.push([k, v]);\n }\n });\n Object.entries(name).forEach(([k, v]) => {\n if (k == '') {\n attrList.push(['name', v]);\n } else {\n attrList.push(['name:' + k, v]);\n }\n });\n Object.entries(description).forEach(([k, v]) => {\n if (k == '') {\n attrList.push(['description', v]);\n } else {\n attrList.push(['description:' + k, v]);\n }\n });\n\n Object.entries({\n include,\n match,\n exclude,\n 'exclude-match': excludeMatch,\n }).forEach(([k, v]) => {\n v.forEach((v2) => {\n attrList.push([k, v2]);\n });\n });\n\n [...require, ...collectRequireUrls].forEach((s) => {\n attrList.push(['require', s]);\n });\n\n Object.entries({ ...resource, ...collectResource }).forEach(([k, v]) => {\n attrList.push(['resource', k, v]);\n });\n\n connect.forEach((s) => {\n attrList.push(['connect', s]);\n });\n\n webRequest.forEach((s) => {\n attrList.push(['webRequest', s]);\n });\n\n if (grant.has('none')) {\n attrList.push(['grant', 'none']);\n } else if (grant.has('*')) {\n new Set([\n ...GreaseGrantValueList,\n ...ViolentGrantValueList,\n ...TamperGrantValueList,\n ]).forEach((s) => {\n attrList.push(['grant', s]);\n });\n } else {\n new Set([...Array.from(collectGrantSet.values()).flat(), ...grant]).forEach(\n (s) => {\n if (!s.trim()) return;\n attrList.push(['grant', s]);\n },\n );\n }\n antifeature.forEach(({ description, type, tag }) => {\n attrList.push([\n tag ? `antifeature:${tag}` : 'antifeature',\n type,\n description,\n ]);\n });\n if (noframes) {\n attrList.push(['noframes']);\n }\n if (unwrap) {\n attrList.push(['unwrap']);\n }\n attrList.push(...$extra);\n\n attrList = defaultSortFormat(attrList);\n\n let { align = 2 } = format;\n\n if (align === true) {\n align = 2;\n }\n\n // format\n if (typeof align == 'number' && Number.isInteger(align) && align >= 1) {\n const alignN = align;\n\n const formatKey = (subAttrList: [string, ...string[]][]) => {\n if (subAttrList.length == 0) return;\n const maxLen = Math.max(...subAttrList.map((s) => s[1].length));\n subAttrList.forEach((s) => {\n s[1] = s[1].padEnd(alignN + maxLen);\n });\n };\n\n formatKey(attrList.filter((s) => s[0] == 'resource'));\n formatKey(\n attrList.filter(\n (s) => s[0] == 'antifeature' || s[0].startsWith('antifeature:'),\n ),\n );\n\n // format all\n const maxLen = Math.max(...attrList.map((s) => s[0].length));\n attrList.forEach((s) => {\n s[0] = s[0].padEnd(alignN + maxLen);\n });\n } else if (typeof align == 'function') {\n attrList = await align(attrList);\n }\n\n const uString = [\n '==UserScript==',\n ...attrList.map(\n (attr) =>\n '@' +\n attr\n .map((v) => {\n return v.endsWith('\\x20') ? v : v + '\\x20';\n })\n .join('')\n .trimEnd(),\n ),\n '==/UserScript==',\n ]\n .map((s) => '//\\x20' + s)\n .join('\\n');\n\n return format.generate({ userscript: uString, mode });\n};\n\nconst stringSort = (a: [string, ...string[]], b: [string, ...string[]]) => {\n const minLen = Math.min(a.length, b.length);\n for (let i = 0; i < minLen; i++) {\n if (a[i] > b[i]) {\n return 1;\n } else if (a[i] < b[i]) {\n return -1;\n }\n }\n if (a.length > b.length) {\n return 1;\n } else if (a.length < b.length) {\n return -1;\n }\n return 0;\n};\n\nconst defaultSortFormat = (p0: [string, ...string[]][]) => {\n const filter = (\n predicate: (value: [string, ...string[]], index: number) => boolean,\n ): [string, ...string[]][] => {\n const notMatchList: [string, ...string[]][] = [];\n const matchList: [string, ...string[]][] = [];\n p0.forEach((value, index) => {\n if (!predicate(value, index)) {\n notMatchList.push(value);\n } else {\n matchList.push(value);\n }\n });\n p0 = notMatchList;\n return matchList;\n };\n return [\n filter(([k]) => k == 'name'),\n filter(([k]) => k.startsWith('name:')),\n filter(([k]) => k == 'namespace'),\n filter(([k]) => k == 'version'),\n filter(([k]) => k == 'author'),\n filter(([k]) => k == 'description'),\n filter(([k]) => k.startsWith('description:')),\n filter(([k]) => k == 'license'),\n filter(([k]) => k == 'copyright'),\n\n filter(([k]) => k == 'icon'),\n filter(([k]) => k == 'iconURL'),\n filter(([k]) => k == 'icon64'),\n filter(([k]) => k == 'icon64URL'),\n filter(([k]) => k == 'defaulticon'),\n\n filter(([k]) => k == 'homepage'),\n filter(([k]) => k == 'homepageURL'),\n filter(([k]) => k == 'website'),\n filter(([k]) => k == 'source'),\n\n filter(([k]) => k == 'supportURL'),\n filter(([k]) => k == 'downloadURL'),\n filter(([k]) => k == 'updateURL'),\n\n filter(([k]) => k == 'include'),\n filter(([k]) => k == 'match'),\n filter(([k]) => k == 'exclude'),\n filter(([k]) => k == 'exclude-match'),\n filter(([k]) => k == 'webRequest'),\n\n filter(([k]) => k == 'require'),\n\n filter(([k]) => k == 'resource').sort(stringSort),\n\n filter(([k]) => k == 'sandbox'),\n\n filter(([k]) => k == 'connect'),\n\n filter(([k]) => k == 'grant').sort(stringSort),\n\n filter(([k]) => k == 'inject-into'),\n filter(([k]) => k == 'run-at'),\n\n filter(([k]) => k == 'compatible'),\n filter(([k]) => k == 'incompatible'),\n filter(([k]) => k == 'antifeature').sort(stringSort),\n filter(([k]) => k.startsWith('antifeature:')).sort(stringSort),\n filter(([k]) => k == 'contributionAmount'),\n filter(([k]) => k == 'contributionURL'),\n filter(([k]) => k == 'noframes'),\n filter(([k]) => k == 'unwrap'),\n p0,\n ].flat(1);\n};\n","import type { Plugin } from 'vite';\nimport { virtualHtmlTemplate, fcToHtml } from '../inject_template';\nimport type { FinalMonkeyOption } from '../types';\nimport { installUserPath } from './server';\n\n// https://github.com/vitejs/vite/blob/2401253b9aa487c50edb5ec571d5ba7adc949e27/packages/vite/src/node/server/middlewares/indexHtml.ts#L275\n\nexport const virtualHtmlPlugin = (finalOption: FinalMonkeyOption): Plugin => {\n return {\n name: 'monkey:virtualHtml',\n apply: 'serve',\n configureServer(server) {\n server.middlewares.use(async (req, res, next) => {\n const url = req.url || '/';\n if (['/', '/index.html'].includes(url)) {\n res.setHeader('content-type', 'text/html');\n res.setHeader('cache-control', 'no-cache');\n res.setHeader('access-control-allow-origin', '*');\n return res.end(fcToHtml(virtualHtmlTemplate, installUserPath));\n }\n next();\n });\n },\n };\n};\n","import { Plugin, ResolvedConfig } from 'vite';\nimport type { FinalMonkeyOption } from '../types';\n\n// should use import.meta['url'], becase vite will replace import.meta.url to self.location\nconst template = `\nexport default ((()=>{\n try{\n return new URL(__VALUE__, import.meta['url']).href\n }catch(_){\n return __VALUE__\n }\n})())\n`.trimStart();\n// https://github.com/vitejs/vite/blob/9c114c5c72a6af87e3330d5573362554b4511265/packages/vite/src/node/plugins/asset.ts#L172\n\n// TODO the relative path of the *.vue file template does not work\n\nexport const fixViteAssetPlugin = (finalOption: FinalMonkeyOption): Plugin => {\n let viteConfig: ResolvedConfig;\n return {\n name: 'monkey:fixViteAsset',\n apply: 'serve',\n async configResolved(resolvedConfig) {\n viteConfig = resolvedConfig;\n },\n async transform(code, id) {\n const [_, query = 'url'] = id.split('?', 2);\n if (\n (query.split('&').includes('url') || viteConfig.assetsInclude(id)) &&\n code.match(/^\\s*export\\s+default/)\n ) {\n const ast: any = this.parse(code);\n if (ast.type == 'Program') {\n const defaultNode = ast.body?.[0];\n if (defaultNode?.type == 'ExportDefaultDeclaration') {\n const declarationNode = defaultNode?.declaration;\n const value = declarationNode?.value;\n if (\n declarationNode?.type == 'Literal' &&\n typeof value == 'string'\n ) {\n return template.replace(/__VALUE__/g, JSON.stringify(value));\n }\n }\n }\n }\n },\n };\n};\n","import type { Plugin } from 'vite';\nimport type { FinalMonkeyOption } from '../types';\n\nexport const fixViteClientPlugin = (finalOption: FinalMonkeyOption): Plugin => {\n return {\n name: 'monkey:fixViteClient',\n apply: 'serve',\n async transform(code, id) {\n if (id.endsWith('node_modules/vite/dist/client/client.mjs')) {\n // use import.meta['url'] instead of import.meta.url, because vite will replace import.meta.url to file system path\n code = code.replace(\n /__HMR_PROTOCOL__/g,\n `(__HMR_PROTOCOL__ || ((()=>{const u = new URL(import.meta['url'], location.origin);return u.protocol === 'https:' ? 'wss' : 'ws'})()))`,\n );\n\n code = code.replace(\n /__BASE__/g,\n `((()=>{const b = __BASE__; const u = new URL(import.meta['url'], location.origin); return b !== '/' ? b : (u.origin+'/');})())`,\n );\n\n // work with vite@3\n // see https://github.com/vitejs/vite/blob/v3.0.0/packages/vite/src/client/client.ts#L302\n // vite@4 not need\n // see https://github.com/vitejs/vite/blob/v4.0.0/packages/vite/src/client/client.ts\n code = code.replace(\n '`${location.protocol}//${hostAndPath}`',\n \"`${new URL(import.meta['url'], location.origin).protocol}//${hostAndPath}`\",\n );\n return code;\n }\n },\n };\n};\n","import { normalizePath, Plugin } from 'vite';\nimport type { FinalMonkeyOption } from '../types';\nimport { getModuleRealInfo } from '../_util';\n\n// const dynamicImportPrefix = '\\0monkey-dynamic-import:';\n\nexport const externalGlobalsPlugin = (\n finalOption: FinalMonkeyOption,\n): Plugin => {\n const { globalsPkg2VarName, requirePkgList } = finalOption;\n return {\n name: 'monkey:externalGlobals',\n enforce: 'pre',\n apply: 'build',\n async config() {\n for (const [moduleName, varName2LibUrl] of finalOption.build\n .externalGlobals) {\n const { name, version } = await getModuleRealInfo(moduleName);\n\n if (typeof varName2LibUrl == 'string') {\n globalsPkg2VarName[moduleName] = varName2LibUrl;\n } else if (typeof varName2LibUrl == 'function') {\n globalsPkg2VarName[moduleName] = await varName2LibUrl(\n version,\n name,\n moduleName,\n );\n } else if (varName2LibUrl instanceof Array) {\n const [varName, ...libUrlList] = varName2LibUrl;\n if (typeof varName == 'string') {\n globalsPkg2VarName[moduleName] = varName;\n } else if (typeof varName == 'function') {\n globalsPkg2VarName[moduleName] = await varName(\n version,\n name,\n moduleName,\n );\n }\n for (const libUrl of libUrlList) {\n // keep add order\n if (typeof libUrl == 'string') {\n requirePkgList.push({ url: libUrl, moduleName });\n } else if (typeof libUrl == 'function') {\n requirePkgList.push({\n url: await libUrl(version, name, moduleName),\n moduleName,\n });\n }\n }\n }\n }\n return {\n build: {\n rollupOptions: {\n external(source, _importer, _isResolved) {\n return source in globalsPkg2VarName;\n },\n // output: {\n // globals: globalsPkg2VarName,\n // inlineDynamicImports: true, // see https://rollupjs.org/guide/en/#outputinlinedynamicimports\n // },\n },\n },\n };\n },\n\n // async resolveDynamicImport(specifier, _importer) {\n // if (typeof specifier == 'string' && specifier in globalsPkg2VarName) {\n // return dynamicImportPrefix + specifier + '\\0';\n // }\n // },\n\n // async load(id) {\n // if (id.startsWith(dynamicImportPrefix) && id.endsWith('\\0')) {\n // const rawId = id.slice(dynamicImportPrefix.length, id.length - 1);\n // if (rawId in globalsPkg2VarName) {\n // return `export {default} from '${rawId}';export * from '${rawId}';`;\n // }\n // }\n // },\n\n async generateBundle() {\n const usedModIdSet = new Set(\n Array.from(this.getModuleIds()).map((s) => normalizePath(s)),\n );\n // Array.from(usedModIdSet).forEach((id) => {\n // if (id.startsWith(dynamicImportPrefix) && id.endsWith('\\0')) {\n // usedModIdSet.add(id.slice(dynamicImportPrefix.length, id.length - 1));\n // }\n // });\n finalOption.collectRequireUrls = requirePkgList\n .filter((p) => usedModIdSet.has(p.moduleName))\n .map((p) => p.url);\n },\n };\n};\n","import { Plugin, transformWithEsbuild } from 'vite';\nimport type { FinalMonkeyOption } from '../types';\n\nconst cssLoader = (resourceName: string) => {\n // @ts-ignore\n const css = GM_getResourceText(resourceName);\n // @ts-ignore\n GM_addStyle(css);\n return css;\n};\n\nconst jsonLoader = (resourceName: string): unknown =>\n // @ts-ignore\n JSON.parse(GM_getResourceText(resourceName));\n\nconst urlLoader = (resourceName: string, mediaType: string) =>\n // @ts-ignore\n GM_getResourceURL(resourceName, false).replace(\n /^data:application;base64,/,\n `data:${mediaType};base64,`,\n );\n\nconst rawLoader = (resourceName: string) =>\n // @ts-ignore\n GM_getResourceText(resourceName);\n\nconst moduleSourceCode = [\n `export const cssLoader = ${cssLoader}`,\n `export const jsonLoader = ${jsonLoader}`,\n `export const urlLoader = ${urlLoader}`,\n `export const rawLoader = ${rawLoader}`,\n].join(';');\n\nexport const externalLoaderPlugin = (\n finalOption: FinalMonkeyOption,\n): Plugin => {\n return {\n name: 'monkey:externalLoader',\n enforce: 'pre',\n apply: 'build',\n async resolveId(id) {\n if (id == 'virtual:plugin-monkey-loader') {\n return '\\0' + id;\n }\n },\n async load(id) {\n if (id == '\\0virtual:plugin-monkey-loader') {\n return transformWithEsbuild(\n moduleSourceCode,\n '/virtual/plugin-monkey-loader/index.js',\n {\n minify: true,\n sourcemap: true,\n legalComments: 'none',\n },\n );\n }\n },\n };\n};\n","import { normalizePath, Plugin, ResolvedConfig } from 'vite';\nimport type { FinalMonkeyOption, PkgOptions } from '../types';\nimport { getModuleRealInfo, miniCode } from '../_util';\nimport { lookup, mimes } from 'mrmime';\nimport { URLSearchParams } from 'node:url';\n\nconst resourceImportPrefix = '\\0monkey-resource-import:';\n\nexport const externalResourcePlugin = (\n finalOption: FinalMonkeyOption,\n): Plugin => {\n const resourceRecord: Record<\n string,\n { resourceName: string; resourceUrl: string }\n > = {};\n let viteConfig: ResolvedConfig;\n return {\n name: 'monkey:externalResource',\n enforce: 'pre',\n apply: 'build',\n configResolved(config) {\n viteConfig = config;\n },\n async resolveId(id) {\n const { externalResource } = finalOption.build;\n if (id in externalResource) {\n return resourceImportPrefix + id + '\\0';\n }\n // see https://github.com/vitejs/vite/blob/5d56e421625b408879672a1dd4e774bae3df674f/packages/vite/src/node/plugins/css.ts#L431-L434\n const [resource, query] = id.split('?', 2);\n if (resource.endsWith('.css') && query) {\n const id2 = [\n resource,\n '?',\n query\n .split('&')\n .filter((e) => e != 'used')\n .join(`&`),\n ].join('');\n if (id2 in externalResource) {\n return resourceImportPrefix + id2 + '\\0';\n }\n }\n },\n async load(id) {\n if (id.startsWith(resourceImportPrefix) && id.endsWith('\\0')) {\n const { externalResource } = finalOption.build;\n const importName = id.substring(\n resourceImportPrefix.length,\n id.length - 1,\n );\n if (!(importName in externalResource)) {\n return;\n }\n const pkg = await getModuleRealInfo(importName);\n const {\n resourceName: resourceNameFn,\n resourceUrl: resourceUrlFn,\n loader,\n nodeLoader,\n } = externalResource[importName];\n const resourceName = await resourceNameFn({ ...pkg, importName });\n const resourceUrl = await resourceUrlFn({ ...pkg, importName });\n resourceRecord[importName] = {\n resourceName,\n resourceUrl,\n };\n\n if (nodeLoader) {\n return miniCode(\n await nodeLoader({\n ...pkg,\n resourceName,\n resourceUrl,\n importName,\n }),\n );\n } else if (loader) {\n let fnText: string;\n if (\n loader.prototype && // not arrow function\n loader.name.length > 0 &&\n loader.name != 'function' // not anonymous function\n ) {\n if (Reflect.get(loader, Symbol.toStringTag) == 'AsyncFunction') {\n fnText = loader\n .toString()\n .replace(/^[\\s\\S]+?\\(/, 'async function(');\n } else {\n fnText = loader.toString().replace(/^[\\s\\S]+?\\(/, 'function(');\n }\n } else {\n fnText = loader.toString();\n }\n return miniCode(\n `export default (${fnText})(${JSON.stringify({\n resourceUrl,\n importName,\n ...pkg,\n } as PkgOptions)})`,\n );\n }\n\n let moduleCode: string | undefined = undefined;\n const [resource, query] = importName.split('?', 2);\n const ext = resource.split('.').pop()!;\n const mimeType = lookup(ext) ?? 'application/octet-stream';\n const suffixSet = new URLSearchParams(query);\n if (suffixSet.has('url') || suffixSet.has('inline')) {\n moduleCode = [\n `import {urlLoader as loader} from 'virtual:plugin-monkey-loader'`,\n `export default loader(...${JSON.stringify([\n resourceName,\n mimeType,\n ])})`,\n ].join(';');\n } else if (suffixSet.has('raw')) {\n moduleCode = [\n `import {rawLoader as loader} from 'virtual:plugin-monkey-loader'`,\n `export default loader(...${JSON.stringify([resourceName])})`,\n ].join(';');\n } else if (ext == 'json') {\n // export name will bring side effect\n moduleCode = [\n `import {jsonLoader as loader} from 'virtual:plugin-monkey-loader'`,\n `export default loader(...${JSON.stringify([resourceName])})`,\n ].join(';');\n } else if (ext == 'css') {\n moduleCode = [\n `import {cssLoader as loader} from 'virtual:plugin-monkey-loader'`,\n `export default loader(...${JSON.stringify([resourceName])})`,\n ].join(';');\n } else if (viteConfig.assetsInclude(importName.split('?', 1)[0])) {\n const mediaType = mimes[ext];\n moduleCode = [\n `import {urlLoader as loader} from 'virtual:plugin-monkey-loader'`,\n `export default loader(...${JSON.stringify([\n resourceName,\n mediaType,\n ])})`,\n ].join(';');\n }\n if (moduleCode) {\n if (\n moduleCode.includes('rawLoader') ||\n moduleCode.includes('jsonLoader') ||\n moduleCode.includes('cssLoader')\n ) {\n finalOption.userscript.grant.add('GM_getResourceText');\n } else if (moduleCode.includes('urlLoader')) {\n finalOption.userscript.grant.add('GM_getResourceURL');\n }\n return miniCode(moduleCode);\n }\n\n throw new Error(`module: ${importName} not found loader`);\n }\n },\n generateBundle() {\n const usedModIdSet = new Set(\n Array.from(this.getModuleIds()).map((s) => normalizePath(s)),\n );\n Array.from(usedModIdSet).forEach((id) => {\n if (id.startsWith(resourceImportPrefix) && id.endsWith('\\0')) {\n usedModIdSet.add(\n id.substring(resourceImportPrefix.length, id.length - 1),\n );\n }\n });\n const collectResource: Record<string, string> = {};\n Object.entries(resourceRecord).forEach(\n ([importName, { resourceName, resourceUrl }]) => {\n if (usedModIdSet.has(importName)) {\n collectResource[resourceName] = resourceUrl;\n }\n },\n );\n finalOption.collectResource = collectResource;\n },\n };\n};\n","import type { OutputChunk, RollupOutput } from 'rollup';\nimport { Plugin, build } from 'vite';\nimport { lazyValue } from '../_lazy';\nimport {\n collectGrant,\n getInjectCssCode,\n moduleExportExpressionWrapper,\n} from '../_util';\nimport { getSystemjsRequireUrls, systemjsTexts } from '../systemjs';\nimport {\n findSafeTlaIdentifier,\n transformIdentifierToTla,\n transformTlaToIdentifier,\n} from '../topLevelAwait';\nimport type { FinalMonkeyOption } from '../types';\nimport { finalMonkeyOptionToComment } from '../userscript';\n\nconst __entry_name = `__monkey.entry.js`;\n\n// https://github.com/vitejs/vite/blob/1df2cfcbebd95a139da7dc30aad487c81b153b45/packages/plugin-legacy/src/index.ts#L718\nconst polyfillId = '\\0vite/legacy-polyfills';\n\nconst systemJsImportMapPrefix = `user`;\n\nexport const finalBundlePlugin = (finalOption: FinalMonkeyOption): Plugin => {\n return {\n name: 'monkey:finalBundle',\n apply: 'build',\n enforce: 'post',\n async generateBundle(_, rawBundle) {\n const entryChunks: OutputChunk[] = [];\n const chunks: OutputChunk[] = [];\n Object.values(rawBundle).forEach((chunk) => {\n if (chunk.type == 'chunk') {\n if (chunk.facadeModuleId != polyfillId) {\n chunks.push(chunk);\n }\n if (chunk.isEntry) {\n if (chunk.facadeModuleId == polyfillId) {\n entryChunks.unshift(chunk);\n } else {\n entryChunks.push(chunk);\n }\n }\n }\n });\n\n const fristEntryChunk = entryChunks.find(\n (s) => s.facadeModuleId != polyfillId,\n );\n\n const hasDynamicImport = entryChunks.some(\n (e) => e.dynamicImports.length > 0,\n );\n\n const usedModules = new Set<string>();\n\n const tlaIdentifier = lazyValue(() => findSafeTlaIdentifier(rawBundle));\n\n const buildResult = (await build({\n logLevel: 'error',\n configFile: false,\n esbuild: false,\n plugins: [\n {\n name: 'mokey:mock',\n enforce: 'pre',\n resolveId(source, importer, options) {\n if (!importer && options.isEntry) {\n return '\\0' + source;\n }\n const chunk = Object.values(rawBundle).find(\n (chunk) =>\n chunk.type == 'chunk' && source.endsWith(chunk.fileName),\n ) as OutputChunk | undefined;\n if (chunk) {\n return '\\0' + source;\n }\n },\n async load(id) {\n if (!id.startsWith('\\0')) return;\n\n if (id.endsWith(__entry_name)) {\n return entryChunks\n .map((a) => `import ${JSON.stringify(`./${a.fileName}`)};`)\n .join('\\n');\n }\n const [k, chunk] =\n Object.entries(rawBundle).find(([k, chunk]) =>\n id.endsWith(chunk.fileName),\n ) ?? [];\n if (chunk && chunk.type == 'chunk' && k) {\n usedModules.add(k);\n if (!hasDynamicImport) {\n const ch = transformTlaToIdentifier(\n this,\n chunk,\n tlaIdentifier.value,\n );\n if (ch) return ch;\n }\n return {\n code: chunk.code,\n map: chunk.map,\n };\n }\n },\n generateBundle(_, iifeBundle) {\n if (hasDynamicImport) {\n return;\n }\n Object.entries(iifeBundle).forEach(([k, chunk]) => {\n transformIdentifierToTla(this, chunk, tlaIdentifier.value);\n });\n },\n },\n ],\n build: {\n write: false,\n minify: false,\n target: 'esnext',\n rollupOptions: {\n external(source) {\n return source in finalOption.globalsPkg2VarName;\n },\n output: {\n globals: finalOption.globalsPkg2VarName,\n },\n },\n lib: {\n entry: __entry_name,\n formats: [hasDynamicImport ? 'system' : 'iife'] as any,\n name: hasDynamicImport ? undefined : '__expose__',\n fileName: () => `__entry.js`,\n },\n },\n })) as RollupOutput[];\n usedModules.forEach((k) => {\n if (fristEntryChunk != rawBundle[k]) {\n delete rawBundle[k];\n }\n });\n\n const buildBundle = buildResult[0].output.flat();\n let finalJsCode = ``;\n if (hasDynamicImport) {\n const systemJsModules: string[] = [];\n let entryName = '';\n Object.entries(buildBundle).forEach(([k, chunk]) => {\n if (chunk.type == 'chunk') {\n const name = JSON.stringify(`./` + chunk.fileName);\n systemJsModules.push(\n chunk.code\n .trimStart()\n .replace(/^System\\.register\\(/, `System.register(${name}, `),\n );\n if (chunk.isEntry) {\n entryName = name;\n }\n }\n });\n systemJsModules.push(`System.import(${entryName}, \"./\");`);\n finalJsCode = systemJsModules.join('\\n');\n const usedModuleIds = Array.from(this.getModuleIds()).filter(\n (d) => d in finalOption.globalsPkg2VarName,\n );\n // {vue:'xxx:vue'}\n const importsMap = usedModuleIds.reduce(\n (p: Record<string, string>, c) => {\n p[c] = `${systemJsImportMapPrefix}:${c}`;\n return p;\n },\n {},\n );\n // inject SystemJs external globals\n finalJsCode = [\n Object.keys(importsMap).length > 0\n ? `System.addImportMap({ imports: ${JSON.stringify(importsMap)} });`\n : ``,\n ...usedModuleIds.map(\n (id) =>\n `System.set(${JSON.stringify(\n `${systemJsImportMapPrefix}:${id}`,\n )}, ${moduleExportExpressionWrapper(\n finalOption.globalsPkg2VarName[id],\n )});`,\n ),\n '\\n' + finalJsCode,\n ]\n .filter((s) => s)\n .join('\\n');\n\n if (typeof finalOption.systemjs == 'function') {\n finalOption.collectRequireUrls.push(\n ...getSystemjsRequireUrls(finalOption.systemjs),\n );\n } else {\n finalJsCode =\n (await systemjsTexts.value).join('\\n') + '\\n' + finalJsCode;\n }\n } else {\n // use iife\n Object.entries(buildBundle).forEach(([k, chunk]) => {\n if (chunk.type == 'chunk' && chunk.isEntry) {\n finalJsCode = chunk.code;\n }\n });\n }\n\n const injectCssCode = await getInjectCssCode(finalOption, rawBundle);\n\n let collectGrantSet: Set<string>;\n if (finalOption.build.autoGrant) {\n collectGrantSet = collectGrant(\n this,\n chunks.map((s) => s.code).concat(injectCssCode || ``),\n );\n } else {\n collectGrantSet = new Set<string>();\n }\n\n const comment = await finalMonkeyOptionToComment(\n finalOption,\n collectGrantSet,\n 'build',\n );\n\n const mergedCode = [comment, injectCssCode, finalJsCode]\n .filter((s) => s)\n .join(`\\n\\n`)\n .trimEnd();\n if (fristEntryChunk) {\n fristEntryChunk.fileName = finalOption.build.fileName;\n fristEntryChunk.code = mergedCode;\n } else {\n this.emitFile({\n type: 'asset',\n fileName: finalOption.build.fileName,\n source: mergedCode,\n });\n }\n\n if (finalOption.build.metaFileName) {\n this.emitFile({\n type: 'asset',\n fileName: finalOption.build.metaFileName(),\n source: await finalMonkeyOptionToComment(\n finalOption,\n collectGrantSet,\n 'meta',\n ),\n });\n }\n },\n };\n};\n","type AnyFunction = (...args: any[]) => any;\n\nconst lazyValuePlaceholder = {};\n\n/**\n * lazy side effect by `__PURE__` comment\n */\nexport const lazy = <T extends object>(fn: () => T) => {\n let temp: T | undefined = undefined;\n let o = {\n get k() {\n if (temp === undefined) {\n temp = fn();\n }\n return temp;\n },\n };\n const wm = lazyValue(() => new WeakMap<AnyFunction, AnyFunction>());\n return new Proxy(lazyValuePlaceholder as T, {\n get(_, p, receiver) {\n const v: unknown = Reflect.get(o.k, p, receiver);\n if (typeof v == 'function') {\n const f = v as AnyFunction;\n let fBind = wm.value.get(f);\n if (fBind === undefined) {\n fBind = f.bind(o.k);\n wm.value.set(f, fBind);\n }\n return fBind;\n }\n return v;\n },\n set(_, p, newValue, receiver) {\n return Reflect.set(o.k, p, newValue, receiver);\n },\n has(_, p) {\n return Reflect.has(o.k, p);\n },\n ownKeys() {\n return Reflect.ownKeys(o.k);\n },\n isExtensible() {\n return Reflect.isExtensible(o.k);\n },\n deleteProperty(_, p) {\n return Reflect.deleteProperty(o.k, p);\n },\n setPrototypeOf(_, v) {\n return Reflect.setPrototypeOf(o.k, v);\n },\n getOwnPropertyDescriptor(_, p) {\n return Reflect.getOwnPropertyDescriptor(o.k, p);\n },\n defineProperty(_, property, attributes) {\n return Reflect.defineProperty(o.k, property, attributes);\n },\n getPrototypeOf() {\n return Reflect.getPrototypeOf(o.k);\n },\n preventExtensions() {\n return Reflect.preventExtensions(o.k);\n },\n apply(_, thisArg, argArray) {\n // @ts-ignore\n return Reflect.apply(o.k, thisArg, argArray);\n },\n construct(_, argArray, newTarget) {\n // @ts-ignore\n return Reflect.construct(o.k, argArray, newTarget);\n },\n });\n};\n\nexport const lazyValue = <T>(fn: () => T) => {\n let temp: T | typeof lazyValuePlaceholder = lazyValuePlaceholder;\n return {\n get value() {\n if (temp === lazyValuePlaceholder) {\n temp = fn();\n }\n return temp as T;\n },\n };\n};\n","import module from 'node:module';\nimport type systemjsPkgT from 'systemjs/package.json';\nimport { ModuleToUrlFc } from './types';\nimport fs from 'node:fs/promises';\nimport { lazyValue } from './_lazy';\nimport { dataUrl } from './util';\n\nconst _require = module.createRequire(import.meta.url);\n\nconst systemjsPkg: typeof systemjsPkgT = _require(`systemjs/package.json`);\n\nconst systemjsSubPaths = [\n 'dist/system.min.js',\n 'dist/extras/named-register.min.js',\n];\n\n// https://github.com/systemjs/systemjs/blob/main/docs/api.md#systemconstructor\nconst customSystemInstanceCode = `;(typeof System!='undefined')&&(System=new System.constructor());`;\n\nconst systemjsAbsolutePaths = systemjsSubPaths.map((s) => {\n return _require.resolve(`systemjs/` + s);\n});\n\nexport const systemjsTexts = lazyValue(() => {\n return Promise.all(\n systemjsAbsolutePaths\n .map((s) =>\n fs.readFile(s, 'utf-8').then((s) =>\n s\n .trim()\n .replace(/^\\/\\*[\\s\\S]*?\\*\\//, '')\n .replace(/\\/\\/.*map$/, '')\n .trim(),\n ),\n )\n .concat([Promise.resolve(customSystemInstanceCode)]),\n );\n});\n\nexport const getSystemjsRequireUrls = (fn: ModuleToUrlFc) => {\n return systemjsSubPaths\n .map((p) => {\n return fn(systemjsPkg.version, systemjsPkg.name, p, p);\n })\n .concat([dataUrl(customSystemInstanceCode)]);\n};\n","import type { InlinePreset } from 'unimport';\nimport { transformWithEsbuild } from 'vite';\nimport { preset } from './unimport';\n\n/**\n * transform function and parameter to iife code then mini code then transform code to data url string\n *\n * this tool function is used to make umd-cdn and iife-cdn work normally, such as element-plus and vue\n *\n * @example\n * // this example comes form https://github.com/lisonge/vite-plugin-monkey/blob/main/playground/ex-vue-demi/vite.config.ts\n * const externalGlobals = [\n * [\n * 'vue',\n * cdn\n * .jsdelivr('Vue', 'dist/vue.global.prod.js')\n * .concat('https://unpkg.com/vue-demi@latest/lib/index.iife.js')\n * .concat(\n * await util.fn2dataUrl(() => {\n * // \\@ts-ignore\n * window.Vue = Vue; // work with element-plus\n * }),\n * ),\n * ],\n * ['pinia', cdn.jsdelivr('Pinia', 'dist/pinia.iife.prod.js')],\n * ['element-plus', cdn.jsdelivr('ElementPlus', 'dist/index.full.min.js')],\n * ];\n */\nexport const fn2dataUrl = async <T extends (...args: any[]) => any>(\n fn: T,\n ...args: Parameters<T>\n) => {\n return (\n 'data:application/javascript,' +\n encodeURIComponent(\n (\n await transformWithEsbuild(\n `;(${fn})(...${JSON.stringify(args)})`,\n 'any_name.js',\n {\n minify: true,\n sourcemap: false,\n legalComments: 'none',\n },\n )\n ).code.trimEnd(),\n )\n );\n};\n\n/**\n * string -> javascript data url\n */\nexport function dataUrl(code: string): string;\n/**\n * function and it parameters -> iife -> mini_iife -> javascript data url\n */\nexport function dataUrl<T extends (...args: any[]) => any>(\n fn: T,\n ...args: Parameters<T>\n): Promise<string>;\nexport function dataUrl(p0: any, ...args: any[]): string | Promise<string> {\n if (typeof p0 == 'string') {\n return `data:application/javascript,` + encodeURIComponent(p0);\n }\n return fn2dataUrl(p0, ...args);\n}\n\n/**\n * GM api preset when you use unimport/unplugin-auto-import\n *\n * Note, there is not comment in unimport.d.ts/auto-imports.d.ts file\n */\nexport const unimportPreset: InlinePreset = preset;\n","import type { Node as AcornNode } from 'acorn';\nimport * as acornWalk from 'acorn-walk';\nimport MagicString from 'magic-string';\nimport type {\n OutputAsset,\n OutputBundle,\n OutputChunk,\n PluginContext,\n} from 'rollup';\n\ntype CallAcornNode = AcornNode & {\n callee: AcornNode & { name: string };\n arguments: AcornNode[];\n};\n\nconst awaitOffset = `await`.length;\nconst initTlaIdentifier = `_TLA_`;\n\nexport const findSafeTlaIdentifier = (rawBundle: OutputBundle) => {\n const codes: string[] = [];\n for (const chunk of Object.values(rawBundle)) {\n if (chunk.type == 'chunk') {\n codes.push(chunk.code);\n }\n }\n let x = 0;\n let identifier = initTlaIdentifier;\n while (codes.some((code) => code.includes(identifier))) {\n x++;\n identifier = initTlaIdentifier + x.toString(36);\n }\n return identifier;\n};\n\nconst startWith = (\n text: string,\n searchString: string,\n position = 0,\n ignoreString: string,\n) => {\n for (let i = position; i < text.length; i++) {\n if (ignoreString.includes(text[i])) {\n continue;\n }\n return text.startsWith(searchString, i);\n }\n return false;\n};\n\nexport const transformTlaToIdentifier = (\n context: PluginContext,\n chunk: OutputAsset | OutputChunk,\n identifier: string,\n) => {\n if (chunk.type == 'chunk') {\n const code = chunk.code;\n if (!code.includes(`await`)) {\n return;\n }\n const ast = context.parse(code);\n const tlaNodes: AcornNode[] = [];\n const tlaForOfNodes: AcornNode[] = [];\n acornWalk.simple(\n ast,\n {\n AwaitExpression(node) {\n // top level await\n tlaNodes.push(node);\n },\n // @ts-ignore\n ForOfStatement(node: AcornNode & { await: boolean }) {\n if (node.await === true) {\n tlaForOfNodes.push(node);\n }\n },\n },\n { ...acornWalk.base, Function: () => {} },\n );\n if (tlaNodes.length > 0 || tlaForOfNodes.length > 0) {\n const ms = new MagicString(code);\n tlaNodes.forEach((node) => {\n if (\n !startWith(chunk.code, '(', node.start + awaitOffset, '\\x20\\t\\r\\n')\n ) {\n // await xxx -> await (xxx)\n ms.appendLeft(node.start + awaitOffset, `(`);\n ms.appendRight(node.end, `)`);\n }\n\n // await (xxx) -> __topLevelAwait__ (xxx)\n ms.update(node.start, node.start + awaitOffset, identifier);\n });\n tlaForOfNodes.forEach((node) => {\n // for await(const x of xxx){} -> __topLevelAwait_FOR ((async()=>{ /*start*/for await(const x of xxx){}/*end*/ })());\n ms.appendLeft(node.start, `${identifier + `FOR`}((async()=>{`);\n ms.appendRight(node.end, `})());`);\n });\n return {\n code: ms.toString(),\n map: ms.generateMap(),\n };\n }\n }\n};\n\nexport const transformIdentifierToTla = (\n context: PluginContext,\n chunk: OutputAsset | OutputChunk,\n identifier: string,\n) => {\n if (chunk.type == 'chunk') {\n if (!chunk.code.includes(identifier)) {\n return;\n }\n\n const base = Object.keys(acornWalk.base).reduce<\n Record<string, acornWalk.RecursiveWalkerFn<any>>\n >((p, key) => {\n if (key in p) return p;\n p[key] = (node, state, callback) => {\n if (chunk.code.substring(node.start, node.end).includes(identifier)) {\n return acornWalk.base[key](node, state, callback);\n }\n };\n return p;\n }, {});\n const ast = context.parse(chunk.code);\n const tlaCallNodes: CallAcornNode[] = [];\n const forTlaCallNodes: CallAcornNode[] = [];\n const topFnNodes: AcornNode[] = [];\n acornWalk.simple(\n ast,\n {\n // @ts-ignore\n CallExpression(node: CallAcornNode) {\n const { name, type } = node.callee ?? {};\n if (type === `Identifier`) {\n if (name === identifier) {\n // top level await\n tlaCallNodes.push(node);\n } else if (name === identifier + `FOR`) {\n // top level for await\n forTlaCallNodes.push(node);\n }\n }\n },\n },\n {\n ...base,\n Function: (node, state, callback) => {\n if (topFnNodes.length == 0) {\n topFnNodes.push(node);\n }\n if (chunk.code.substring(node.start, node.end).includes(identifier)) {\n return acornWalk.base.Function(node, state, callback);\n }\n },\n },\n );\n if (tlaCallNodes.length > 0 || forTlaCallNodes.length > 0) {\n const ms = new MagicString(chunk.code, {});\n tlaCallNodes.forEach((node) => {\n const callee = node.callee;\n // __topLevelAwait__ (xxx) -> await (xxx)\n ms.update(callee.start, callee.end, 'await');\n });\n forTlaCallNodes.forEach((node) => {\n // __topLevelAwait_FOR ((async()=>{ /*start*/for await(const x of xxx){}/*end*/ })()); -> for await(const x of xxx){}\n // @ts-ignore\n const forOfNode = node.arguments?.[0]?.callee?.body\n ?.body?.[0] as AcornNode;\n ms.update(node.start, forOfNode.start, '');\n ms.update(forOfNode.end, node.end, '');\n });\n topFnNodes.forEach((node) => {\n ms.appendLeft(node.start, `async\\x20`);\n });\n chunk.code = ms.toString();\n // TODO sourcemap\n // https://github.com/keik/merge-source-map\n if (chunk.map) {\n chunk.map;\n }\n }\n }\n};\n","import path from 'node:path';\nimport type { Plugin, ResolvedConfig } from 'vite';\nimport { normalizePath } from 'vite';\nimport { walk } from '../_util';\nimport { fcToHtml, previewTemplate } from '../inject_template';\nimport type { FinalMonkeyOption } from '../types';\n\nexport const perviewPlugin = (finalOption: FinalMonkeyOption): Plugin => {\n let viteConfig: ResolvedConfig;\n return {\n name: 'monkey:perview',\n apply: 'serve',\n configResolved(config) {\n viteConfig = config;\n },\n async configurePreviewServer(server) {\n server.middlewares.use(async (req, res, next) => {\n if (['/', '/index.html'].includes((req.url ?? '').split('?')[0])) {\n const distDirPath = path.join(process.cwd(), viteConfig.build.outDir);\n const urls: string[] = [];\n for await (const pathname of walk(distDirPath)) {\n if (pathname.endsWith('.user.js')) {\n const fileName = normalizePath(\n path.relative(distDirPath, pathname),\n );\n urls.push(`/` + fileName);\n }\n }\n res.setHeader('content-type', 'text/html; charset=utf-8');\n res.end(fcToHtml(previewTemplate, urls));\n return;\n }\n next();\n if (finalOption.server.closePreviewAutomatically) {\n setTimeout(() => {\n server.close();\n }, 3000);\n }\n });\n },\n };\n};\n","import type { Plugin } from 'vite';\nimport type { FinalMonkeyOption } from '../types';\n\nexport const redirectClientPlugin = (\n finalOption: FinalMonkeyOption,\n): Plugin => {\n return {\n name: 'monkey:redirectClient',\n enforce: 'pre',\n apply: 'build',\n resolveId(source, importer, options) {\n if (source == 'vite-plugin-monkey/dist/client') {\n return this.resolve(\n 'vite-plugin-monkey/dist/native',\n importer,\n options,\n );\n }\n },\n };\n};\n","import fs from 'node:fs/promises';\nimport type { Plugin, ResolvedConfig } from 'vite';\nimport type { FinalMonkeyOption } from '../types';\n\n// https://github.com/vitejs/vite/blob/42e0d6af67743841bd38ed504cb8cbaaafb6313f/packages/vite/src/node/plugins/asset.ts#L327\n\nexport const inlinesAssetPlugin = (finalOption: FinalMonkeyOption): Plugin => {\n let viteConfig: ResolvedConfig;\n return {\n name: 'monkey:inlinesAsset',\n enforce: 'post',\n apply: 'build',\n async configResolved(resolvedConfig) {\n viteConfig = resolvedConfig;\n },\n async transform(code, id) {\n if (\n viteConfig.assetsInclude(id) &&\n [`.svg`, `.svg?inline`, `.svg?url`].some((s) => id.endsWith(s)) &&\n code.includes(`__VITE_ASSET__`)\n ) {\n const base64Text = (await fs.readFile(id.split('?')[0])).toString(\n 'base64',\n );\n return `export default ${JSON.stringify(\n `data:image/svg+xml;base64,` + base64Text,\n )}`;\n }\n },\n generateBundle(opts, bundle) {\n for (const key in bundle) {\n if ([`.svg`].some((s) => key.endsWith(s))) {\n delete bundle[key];\n }\n }\n },\n };\n};\n","import { virtualHtmlPlugin } from './virtualHtml';\nimport { fixViteAssetPlugin } from './fixViteAsset';\nimport { fixViteClientPlugin } from './fixViteClient';\nimport { serverPlugin } from './server';\nimport { externalGlobalsPlugin } from './externalGlobals';\nimport { externalLoaderPlugin } from './externalLoader';\nimport { externalResourcePlugin } from './externalResource';\nimport { finalBundlePlugin } from './finalBundle';\nimport { perviewPlugin } from './perview';\nimport { redirectClientPlugin } from './redirectClient';\nimport { inlinesAssetPlugin } from './inlinesAsset';\n\nconst monkeyPluginList = [\n // only serve\n virtualHtmlPlugin,\n fixViteAssetPlugin,\n fixViteClientPlugin,\n serverPlugin,\n\n // only build pre\n redirectClientPlugin,\n externalLoaderPlugin,\n externalResourcePlugin,\n externalGlobalsPlugin,\n\n // only build post\n inlinesAssetPlugin,\n\n // only build, final build\n finalBundlePlugin,\n\n // only preview\n perviewPlugin,\n];\nexport default monkeyPluginList;\n","import type { Plugin } from 'vite';\nimport { resolvedOption } from './option';\nimport monkeyPluginList from './plugins';\nimport type { MonkeyOption } from './types';\nimport type {\n Format,\n GreasemonkeyUserScript,\n MonkeyUserScript,\n TampermonkeyUserScript,\n ViolentmonkeyUserScript,\n} from './userscript';\n\nexport * as cdn from './cdn';\nexport * as util from './util';\nexport type {\n MonkeyUserScript,\n TampermonkeyUserScript,\n ViolentmonkeyUserScript,\n GreasemonkeyUserScript,\n Format,\n MonkeyOption,\n};\n\nexport default (pluginOption: MonkeyOption): Plugin[] => {\n const finalPluginOption = resolvedOption(pluginOption);\n\n const monkeyPlugin: Plugin = {\n name: 'monkey:entry',\n enforce: 'post',\n async config(userConfig, { command }) {\n const isServe = command == 'serve';\n\n return {\n resolve: {\n alias: {\n [finalPluginOption.clientAlias]: 'vite-plugin-monkey/dist/client',\n },\n },\n define: {\n 'process.env.NODE_ENV':\n userConfig.define?.['process.env.NODE_ENV'] ??\n JSON.stringify(\n userConfig.mode ?? (isServe ? 'development' : 'production'),\n ),\n },\n esbuild: {\n supported: {\n 'top-level-await': true,\n },\n },\n build: {\n assetsInlineLimit: Number.MAX_SAFE_INTEGER,\n chunkSizeWarningLimit: Number.MAX_SAFE_INTEGER,\n modulePreload: false,\n assetsDir: './',\n cssCodeSplit: false,\n minify: userConfig.build?.minify ?? false,\n cssMinify: userConfig.build?.cssMinify ?? true,\n rollupOptions: {\n // serve pre-bundling need\n input: finalPluginOption.entry,\n },\n sourcemap: false,\n\n // TODO\n // sourcemap: sourcemap,\n },\n };\n },\n };\n\n return [monkeyPlugin, ...monkeyPluginList.map((m) => m(finalPluginOption))];\n};\n"],"mappings":";;;;;;;AAAA,OAAO,QAAQ;AAUf,IAAM,MAAM,CAAC,KAAa,SAAkB,YAA4B;AACtE,UAAQ;AAAA,IACN;AAAA,QACG,mCAAS,SAAQ,WAAW,OACzB,GAAG,KAAI,oBAAI,KAAK,GAAE,mBAAmB,CAAC,IACtC;AAAA,MACJ,GAAG,KAAK,GAAG,KAAK,IAAI,GAAG,GAAG,CAAC;AAAA,MAC3B;AAAA,IACF,EACG,OAAO,CAAC,MAAM,CAAC,EACf,KAAK,GAAM;AAAA,EAChB;AACF;AACA,IAAM,OAAO,CAAC,KAAa,SAAkB,YAA4B;AACvE,MAAI,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GA;AAAA;AAAA,EAGA;AAAA;AAAA,EAGA;AACF;AACA,IAAO,kBAAQ;;;ACXf,IAAO,eAAQ,CAAC,iBAAyC;AACvD,QAAM,oBAAoB,eAAe,YAAY;AAErD,QAAM,eAAuB;AAAA,IAC3B,MAAM;AAAA,IACN,SAAS;AAAA,IACT,MAAM,OAAO,YAAY,EAAE,QAAQ,GAAG;AA7B1C;AA8BM,YAAM,UAAU,WAAW;AAE3B,aAAO;AAAA,QACL,SAAS;AAAA,UACP,OAAO;AAAA,YACL,CAAC,kBAAkB,WAAW,GAAG;AAAA,UACnC;AAAA,QACF;AAAA,QACA,QAAQ;AAAA,UACN,0BACE,gBAAW,WAAX,mBAAoB,4BACpB,KAAK;AAAA,YACH,WAAW,SAAS,UAAU,gBAAgB;AAAA,UAChD;AAAA,QACJ;AAAA,QACA,SAAS;AAAA,UACP,WAAW;AAAA,YACT,mBAAmB;AAAA,UACrB;AAAA,QACF;AAAA,QACA,OAAO;AAAA,UACL,mBAAmB,OAAO;AAAA,UAC1B,uBAAuB,OAAO;AAAA,UAC9B,eAAe;AAAA,UACf,WAAW;AAAA,UACX,cAAc;AAAA,UACd,UAAQ,gBAAW,UAAX,mBAAkB,WAAU;AAAA,UACpC,aAAW,gBAAW,UAAX,mBAAkB,cAAa;AAAA,UAC1C,eAAe;AAAA;AAAA,YAEb,OAAO,kBAAkB;AAAA,UAC3B;AAAA,UACA,WAAW;AAAA;AAAA;AAAA,QAIb;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAEA,SAAO,CAAC,cAAc,GAAG,gBAAiB,IAAI,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;AAC5E;","names":["path","build","name","require","fs","path","normalizePath","path","logger","path","require","description","maxLen","htmlText","usp","path","normalizePath","fs","normalizePath","normalizePath","transformWithEsbuild","normalizePath","URLSearchParams","normalizePath","fs","transformWithEsbuild","transformWithEsbuild","fs","s","acornWalk","base","chunk","k","_","path","normalizePath","path","normalizePath","fs"]}
|