@acanthis-dec/linovelib 1.1.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["searchNovels","z"],"sources":["../src/coefficients.ts","../src/utils.ts","../src/chapter.ts","../src/novel.ts","../src/cover.ts","../src/queue.ts","../src/search/common.ts","../src/search/v2.ts","../src/session.ts","../src/client.ts"],"sourcesContent":["import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport type { DescrambleCoefficients } from \"@acanthis-dec/core\";\nimport { deobfuscate } from \"@acanthis-dec/deobfuscator\";\nimport { parse } from \"@babel/parser\";\nimport traverseModule from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport * as cheerio from \"cheerio\";\nimport { z } from \"zod\";\n\ntype TraverseFunction = typeof traverseModule;\n\nconst traverse =\n\t(traverseModule as unknown as { default?: TraverseFunction }).default ??\n\ttraverseModule;\n\nexport const descrambleCoefficientsSchema = z.object({\n\tmodulus: z.number().int(),\n\tincrement: z.number().int(),\n\tmultiplier: z.number().int(),\n\tseedOffset: z.number().int(),\n\tseedMultiplier: z.number().int(),\n});\n\nfunction getObfuscatedPart(fullCode: string): string {\n\treturn fullCode\n\t\t.split(/\\r?\\n/)\n\t\t.map((line) => line.trim())\n\t\t.filter((line) => line !== \"\")\n\t\t.slice(-2)\n\t\t.join(\"\\n\");\n}\n\nexport async function extractCoefficients(\n\tscript: string,\n): Promise<DescrambleCoefficients> {\n\tconst obfuscatedPart = getObfuscatedPart(script);\n\tconst deObfCode = await deobfuscate(obfuscatedPart);\n\tconst ast = parse(deObfCode, { sourceType: \"module\", plugins: [\"jsx\"] });\n\tconst coefficients: Partial<DescrambleCoefficients> = {};\n\ttraverse(ast, {\n\t\tBinaryExpression(path) {\n\t\t\tconst { node } = path;\n\t\t\tif (\n\t\t\t\tnode.operator === \"%\" &&\n\t\t\t\tt.isNumericLiteral(node.right) &&\n\t\t\t\tt.isBinaryExpression(node.left) &&\n\t\t\t\tnode.left.operator === \"+\" &&\n\t\t\t\tt.isNumericLiteral(node.left.right) &&\n\t\t\t\tt.isBinaryExpression(node.left.left) &&\n\t\t\t\tnode.left.left.operator === \"*\" &&\n\t\t\t\tt.isNumericLiteral(node.left.left.right)\n\t\t\t) {\n\t\t\t\tcoefficients.modulus = node.right.value;\n\t\t\t\tconst leftSide = node.left;\n\t\t\t\tif (t.isBinaryExpression(leftSide) && leftSide.operator === \"+\") {\n\t\t\t\t\tif (t.isNumericLiteral(leftSide.right)) {\n\t\t\t\t\t\tcoefficients.increment = leftSide.right.value;\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\tt.isBinaryExpression(leftSide.left) &&\n\t\t\t\t\t\tleftSide.left.operator === \"*\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tif (t.isNumericLiteral(leftSide.left.right)) {\n\t\t\t\t\t\t\tcoefficients.multiplier = leftSide.left.right.value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tnode.operator === \"+\" &&\n\t\t\t\tt.isNumericLiteral(node.right) &&\n\t\t\t\tt.isBinaryExpression(node.left) &&\n\t\t\t\tnode.left.operator === \"*\" &&\n\t\t\t\tt.isNumericLiteral(node.left.right)\n\t\t\t) {\n\t\t\t\tconst potentialOffset = node.right.value;\n\t\t\t\tconst potentialMultiplier = node.left.right.value;\n\t\t\t\tconst numberTransformed = node.left.left;\n\t\t\t\tif (\n\t\t\t\t\tt.isCallExpression(numberTransformed) &&\n\t\t\t\t\tt.isIdentifier(numberTransformed.callee) &&\n\t\t\t\t\t(numberTransformed.callee.name === \"Number\" ||\n\t\t\t\t\t\tnumberTransformed.callee.name === \"parseInt\")\n\t\t\t\t) {\n\t\t\t\t\tcoefficients.seedOffset = potentialOffset;\n\t\t\t\t\tcoefficients.seedMultiplier = potentialMultiplier;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t});\n\tif (\n\t\tcoefficients.modulus === undefined ||\n\t\tcoefficients.increment === undefined ||\n\t\tcoefficients.multiplier === undefined ||\n\t\tcoefficients.seedOffset === undefined ||\n\t\tcoefficients.seedMultiplier === undefined\n\t) {\n\t\tthrow new Error(\"Failed to extract all coefficients\");\n\t}\n\treturn coefficients as DescrambleCoefficients;\n}\n\nexport function extractChapterLogScriptUrl(html: string): string {\n\tconst $ = cheerio.load(html);\n\tconst chapterLogScriptUrl =\n\t\t$(\n\t\t\t$(\"script\")\n\t\t\t\t.toArray()\n\t\t\t\t.find((el) => {\n\t\t\t\t\tconst scriptContent = $(el).attr(\"src\") || \"\";\n\t\t\t\t\treturn /chapterlog\\.js/.test(scriptContent);\n\t\t\t\t}),\n\t\t).attr(\"src\") || \"\";\n\treturn chapterLogScriptUrl.startsWith(\"http\")\n\t\t? chapterLogScriptUrl\n\t\t: `https://www.linovelib.com${chapterLogScriptUrl}`;\n}\n\nexport interface CoefficientResult {\n\tcoefficients: DescrambleCoefficients;\n\tversion: string;\n}\n\nexport async function getCoefficientsFromPage(\n\thtml: string,\n\tfetchClient: BrowserFetchClient,\n\tcachedVersion?: string,\n): Promise<CoefficientResult | undefined> {\n\tconst scriptUrl = extractChapterLogScriptUrl(html);\n\tif (!scriptUrl) {\n\t\tthrow new Error(\"Chapter log script URL not found\");\n\t}\n\tconst version = scriptUrl.match(/chapterlog\\.js\\?(v.*)/)?.[1] || \"\";\n\tif (version === cachedVersion) {\n\t\treturn undefined; // No need to fetch and extract again\n\t}\n\tconst scriptContent = await fetchClient.text(scriptUrl);\n\tif (!scriptContent.mimeType.includes(\"javascript\")) {\n\t\tthrow new Error(\"Fetched content is not JavaScript\");\n\t}\n\tconst coefficients = await extractCoefficients(scriptContent.data);\n\treturn {\n\t\tcoefficients,\n\t\tversion: version,\n\t};\n}\n","export function extractNovelIdFromUrl(url: string): string | undefined {\n\tconst match = url.match(/\\/novel\\/(\\d+)\\.html/);\n\treturn match ? match[1] : undefined;\n}\n\nexport interface NovelAndChapterIds {\n\tnovelId: string | undefined;\n\tchapterId: string | undefined;\n}\n\nexport function extractChapterIdFromUrl(\n\turl: string,\n): NovelAndChapterIds | undefined {\n\tconst match = url.match(/\\/novel\\/(\\d+)\\/(\\d+)\\.html/);\n\tif (match) {\n\t\treturn {\n\t\t\tnovelId: match[1],\n\t\t\tchapterId: match[2],\n\t\t};\n\t}\n\treturn undefined;\n}\n\nexport function transformChapterName(name: string): string {\n\tconst chapNameTransDict: Record<string, string> = {\n\t\t\"\\u004e\": \"\\u5973\",\n\t};\n\treturn name.replace(/./g, (char) => chapNameTransDict[char] || char);\n}\n\nexport function transformContent(content: string): string {\n\tconst contentTransDict: Record<string, string> = {\n\t\t\"\\u201c\": \"\\u300c\",\n\t\t\"\\u201d\": \"\\u300d\",\n\t\t\"\\u2018\": \"\\u300e\",\n\t\t\"\\u2019\": \"\\u300f\",\n\t\t\"\\ue82c\": \"\\u7684\",\n\t\t\"\\ue852\": \"\\u4e00\",\n\t\t\"\\ue82d\": \"\\u662f\",\n\t\t\"\\ue819\": \"\\u4e86\",\n\t\t\"\\ue856\": \"\\u6211\",\n\t\t\"\\ue857\": \"\\u4e0d\",\n\t\t\"\\ue816\": \"\\u4eba\",\n\t\t\"\\ue83c\": \"\\u5728\",\n\t\t\"\\ue830\": \"\\u4ed6\",\n\t\t\"\\ue82e\": \"\\u6709\",\n\t\t\"\\ue836\": \"\\u8fd9\",\n\t\t\"\\ue859\": \"\\u4e2a\",\n\t\t\"\\ue80a\": \"\\u4e0a\",\n\t\t\"\\ue855\": \"\\u4eec\",\n\t\t\"\\ue842\": \"\\u6765\",\n\t\t\"\\ue858\": \"\\u5230\",\n\t\t\"\\ue80b\": \"\\u65f6\",\n\t\t\"\\ue81f\": \"\\u5927\",\n\t\t\"\\ue84a\": \"\\u5730\",\n\t\t\"\\ue853\": \"\\u4e3a\",\n\t\t\"\\ue81e\": \"\\u5b50\",\n\t\t\"\\ue822\": \"\\u4e2d\",\n\t\t\"\\ue813\": \"\\u4f60\",\n\t\t\"\\ue85b\": \"\\u8bf4\",\n\t\t\"\\ue807\": \"\\u751f\",\n\t\t\"\\ue818\": \"\\u56fd\",\n\t\t\"\\ue810\": \"\\u5e74\",\n\t\t\"\\ue812\": \"\\u7740\",\n\t\t\"\\ue851\": \"\\u5c31\",\n\t\t\"\\ue801\": \"\\u90a3\",\n\t\t\"\\ue80c\": \"\\u548c\",\n\t\t\"\\ue815\": \"\\u8981\",\n\t\t\"\\ue84c\": \"\\u5979\",\n\t\t\"\\ue840\": \"\\u51fa\",\n\t\t\"\\ue848\": \"\\u4e5f\",\n\t\t\"\\ue835\": \"\\u5f97\",\n\t\t\"\\ue800\": \"\\u91cc\",\n\t\t\"\\ue826\": \"\\u540e\",\n\t\t\"\\ue863\": \"\\u81ea\",\n\t\t\"\\ue861\": \"\\u4ee5\",\n\t\t\"\\ue854\": \"\\u4f1a\",\n\t\t\"\\ue827\": \"\\u5bb6\",\n\t\t\"\\ue83b\": \"\\u53ef\",\n\t\t\"\\ue85d\": \"\\u4e0b\",\n\t\t\"\\ue84d\": \"\\u800c\",\n\t\t\"\\ue862\": \"\\u8fc7\",\n\t\t\"\\ue81c\": \"\\u5929\",\n\t\t\"\\ue81d\": \"\\u53bb\",\n\t\t\"\\ue860\": \"\\u80fd\",\n\t\t\"\\ue843\": \"\\u5bf9\",\n\t\t\"\\ue82f\": \"\\u5c0f\",\n\t\t\"\\ue802\": \"\\u591a\",\n\t\t\"\\ue831\": \"\\u7136\",\n\t\t\"\\ue84b\": \"\\u4e8e\",\n\t\t\"\\ue837\": \"\\u5fc3\",\n\t\t\"\\ue829\": \"\\u5b66\",\n\t\t\"\\ue85e\": \"\\u4e48\",\n\t\t\"\\ue83a\": \"\\u4e4b\",\n\t\t\"\\ue832\": \"\\u90fd\",\n\t\t\"\\ue808\": \"\\u597d\",\n\t\t\"\\ue841\": \"\\u770b\",\n\t\t\"\\ue821\": \"\\u8d77\",\n\t\t\"\\ue845\": \"\\u53d1\",\n\t\t\"\\ue803\": \"\\u5f53\",\n\t\t\"\\ue828\": \"\\u6ca1\",\n\t\t\"\\ue81b\": \"\\u6210\",\n\t\t\"\\ue83e\": \"\\u53ea\",\n\t\t\"\\ue820\": \"\\u5982\",\n\t\t\"\\ue84e\": \"\\u4e8b\",\n\t\t\"\\ue85a\": \"\\u628a\",\n\t\t\"\\ue806\": \"\\u8fd8\",\n\t\t\"\\ue83f\": \"\\u7528\",\n\t\t\"\\ue833\": \"\\u7b2c\",\n\t\t\"\\ue811\": \"\\u6837\",\n\t\t\"\\ue804\": \"\\u9053\",\n\t\t\"\\ue814\": \"\\u60f3\",\n\t\t\"\\ue80f\": \"\\u4f5c\",\n\t\t\"\\ue84f\": \"\\u79cd\",\n\t\t\"\\ue80e\": \"\\u5f00\",\n\t\t\"\\ue823\": \"\\u7f8e\",\n\t\t\"\\ue849\": \"\\u4e73\",\n\t\t\"\\ue805\": \"\\u9634\",\n\t\t\"\\ue809\": \"\\u6db2\",\n\t\t\"\\ue81a\": \"\\u830e\",\n\t\t\"\\ue844\": \"\\u6b32\",\n\t\t\"\\ue847\": \"\\u547b\",\n\t\t\"\\ue850\": \"\\u8089\",\n\t\t\"\\ue824\": \"\\u4ea4\",\n\t\t\"\\ue85f\": \"\\u6027\",\n\t\t\"\\ue817\": \"\\u80f8\",\n\t\t\"\\ue85c\": \"\\u79c1\",\n\t\t\"\\ue838\": \"\\u7a74\",\n\t\t\"\\ue82a\": \"\\u6deb\",\n\t\t\"\\ue83d\": \"\\u81c0\",\n\t\t\"\\ue82b\": \"\\u8214\",\n\t\t\"\\ue80d\": \"\\u5c04\",\n\t\t\"\\ue839\": \"\\u8131\",\n\t\t\"\\ue834\": \"\\u88f8\",\n\t\t\"\\ue846\": \"\\u9a9a\",\n\t\t\"\\ue825\": \"\\u5507\",\n\t};\n\treturn content.replace(/./g, (char) => contentTransDict[char] || char);\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport {\n\tbuildDescrambleMapping,\n\ttype DescrambleCoefficients,\n} from \"@acanthis-dec/core\";\nimport * as cheerio from \"cheerio\";\nimport type { AnyNode, Element } from \"domhandler\";\nimport { getCoefficientsFromPage } from \"./coefficients\";\nimport type { NovelChapterQueue } from \"./queue\";\nimport { transformContent } from \"./utils\";\n\nfunction extractChapterId($: cheerio.CheerioAPI): string {\n\tconst scriptTags = $(\"script\");\n\tlet chapterId = \"\";\n\tscriptTags.each((_, el) => {\n\t\tconst scriptContent = $(el).html();\n\t\tif (scriptContent) {\n\t\t\tconst match = scriptContent.match(/chapterid\\s*:\\s*'(\\d+)'/);\n\t\t\tif (match?.[1]) {\n\t\t\t\tchapterId = match[1];\n\t\t\t\treturn false; // Break the loop\n\t\t\t}\n\t\t}\n\t});\n\treturn chapterId;\n}\n\nexport interface DecryptResult {\n\tcontent: string;\n\tversion: string;\n\tcoefficients: DescrambleCoefficients;\n}\n\nasync function decrypt(\n\thtml: string,\n\tfetchClient: BrowserFetchClient,\n\tcachedJsVersion?: string,\n\tcachedCoefficients?: DescrambleCoefficients,\n): Promise<DecryptResult> {\n\tconst $ = cheerio.load(html);\n\tconst coefficientResult = await getCoefficientsFromPage(\n\t\thtml,\n\t\tfetchClient,\n\t\tcachedJsVersion,\n\t);\n\tconst version = coefficientResult?.version || cachedJsVersion;\n\tconst coefficients = coefficientResult?.coefficients || cachedCoefficients;\n\tif (!version) {\n\t\tthrow new Error(\"Failed to determine chapterlog.js version\");\n\t}\n\tif (!coefficients) {\n\t\tthrow new Error(\"Failed to obtain descrambling coefficients\");\n\t}\n\tconst chapterId = extractChapterId($);\n\tconst container = $(\"#TextContent, #acontent\");\n\tif (!container.length) {\n\t\treturn {\n\t\t\tcontent: \"\",\n\t\t\tversion,\n\t\t\tcoefficients: coefficients,\n\t\t};\n\t}\n\n\tcontainer.find(\"p\").each((_, el) => {\n\t\tconst $el = $(el);\n\t\tconst innerHtml = $el.html();\n\t\tif (innerHtml) {\n\t\t\tconst cleanedHtml = innerHtml.replace(/^\\s+|(?<=>)\\s+/g, \"\");\n\t\t\t$el.html(cleanedHtml);\n\t\t}\n\t});\n\n\tcontainer.find(\"img.imagecontent\").each((_, el) => {\n\t\tconst imgSrc = $(el).attr(\"data-src\") || $(el).attr(\"src\");\n\t\tif (imgSrc) {\n\t\t\t$(el).attr(\"src\", imgSrc).removeAttr(\"data-src\");\n\t\t}\n\t});\n\n\tcontainer.find(\"div.dag\").remove();\n\tcontainer.find(\"script\").remove();\n\n\tconst allChildren = container\n\t\t.contents()\n\t\t.toArray()\n\t\t.filter((node) => !(node.type === \"tag\" && node.tagName === \"div\"));\n\tconst sortableEntries: { element: Element; originalPos: number }[] = [];\n\tallChildren.forEach((node, index) => {\n\t\tif (node.type === \"tag\" && node.tagName === \"p\") {\n\t\t\tconst text = $(node).text().trim();\n\t\t\tif (text.length > 0) {\n\t\t\t\tsortableEntries.push({ element: node, originalPos: index });\n\t\t\t}\n\t\t}\n\t});\n\n\tconst seed =\n\t\tparseInt(chapterId, 10) * coefficients?.seedMultiplier +\n\t\tcoefficients?.seedOffset;\n\n\tconst mapping = buildDescrambleMapping(\n\t\tsortableEntries.length,\n\t\tseed,\n\t\tcoefficients,\n\t\t20,\n\t);\n\n\tconst restoredChildren: (AnyNode | null)[] = [...allChildren];\n\n\tsortableEntries.forEach((entry, i) => {\n\t\tconst targetIndex = mapping[i] ?? i;\n\t\tconst actualSlot = sortableEntries[targetIndex]?.originalPos ?? 0;\n\t\trestoredChildren[actualSlot] = entry.element;\n\t});\n\n\tconst newContainer = $(\"<div></div>\");\n\trestoredChildren.forEach((node) => {\n\t\tif (node && node.type === \"tag\") {\n\t\t\tnewContainer.append(node);\n\t\t\tnewContainer.append(\"\\n\");\n\t\t}\n\t});\n\n\treturn {\n\t\tcontent: newContainer.html() || \"\",\n\t\tversion,\n\t\tcoefficients: coefficients,\n\t};\n}\n\nexport async function getChapter(\n\tid: string,\n\tnovelId: string,\n\tchapterQueue: NovelChapterQueue,\n\tfetchClient: BrowserFetchClient,\n\tcachedJsVersion?: string,\n\tcachedCoefficients?: DescrambleCoefficients,\n): Promise<DecryptResult | undefined> {\n\tconst firstPageHtml = await chapterQueue.fetchChapterPart(\n\t\t`https://www.linovelib.com/novel/${novelId}/${id}.html`,\n\t);\n\tlet $ = cheerio.load(firstPageHtml);\n\tconst chapterName = $(\"h1\").text().trim();\n\tlet nextPageId =\n\t\t$(\"div.mlfy_page a:last\")\n\t\t\t.attr(\"href\")\n\t\t\t?.match(/\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\tfirstPageHtml.match(/url_next:'\\/novel\\/(\\d+)\\/([\\d_]+)\\.html'/)?.[2] ||\n\t\t\"\";\n\tlet content = await decrypt(\n\t\tfirstPageHtml,\n\t\tfetchClient,\n\t\tcachedJsVersion,\n\t\tcachedCoefficients,\n\t);\n\tcachedCoefficients = content.coefficients;\n\tcachedJsVersion = content.version;\n\twhile (nextPageId?.includes(id)) {\n\t\tconst nextPageHtml = await chapterQueue.fetchChapterPart(\n\t\t\t`https://www.linovelib.com/novel/${novelId}/${nextPageId}.html`,\n\t\t);\n\t\tconst nextContent = await decrypt(\n\t\t\tnextPageHtml,\n\t\t\tfetchClient,\n\t\t\tcachedJsVersion,\n\t\t\tcachedCoefficients,\n\t\t);\n\t\tcontent = {\n\t\t\t...content,\n\t\t\tcontent: content.content + nextContent.content,\n\t\t};\n\t\t$ = cheerio.load(nextPageHtml);\n\t\tnextPageId =\n\t\t\t$(\"div.mlfy_page a:last\")\n\t\t\t\t.attr(\"href\")\n\t\t\t\t?.match(/\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\t\tnextPageHtml.match(/url_next:'\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\t\t\"\";\n\t}\n\t// content = `<h2>${chapterName}</h2>\\n${transformContent(content)}`;\n\tcontent = {\n\t\t...content,\n\t\tcontent: `<h2>${chapterName}</h2>\\n${transformContent(content.content)}`,\n\t};\n\treturn content;\n}\n","import type {\n\tBrowserFetchClient,\n\tRetryOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type { Chapter, Novel, NovelStatus, Volume } from \"@acanthis-dec/core\";\nimport * as cheerio from \"cheerio\";\nimport type { Element } from \"domhandler\";\nimport { novelIdToCoverUrl } from \"./cover\";\nimport type { NovelChapterQueue } from \"./queue\";\n\nexport function extractVolumesArray(catalog: string): Element[] {\n\tconst $ = cheerio.load(catalog);\n\tconst results: Element[] = [];\n\t$(\"#volume-list div.volume\").each((_, elem) => {\n\t\t$(elem).remove(\"div.volume\");\n\t\tresults.push(elem);\n\t});\n\treturn results;\n}\n\nfunction processVolumeName(novelTitle: string, volumeName: string): string {\n\t// Remove novel title from volume name if present\n\tif (volumeName.startsWith(novelTitle)) {\n\t\treturn volumeName.slice(novelTitle.length).trim();\n\t}\n\tif (!Number.isNaN(Number(volumeName))) {\n\t\treturn `第 ${volumeName} 卷`;\n\t}\n\treturn volumeName.trim();\n}\n\ninterface FixTask {\n\tchapter: Chapter; // 引用待修改的章节对象\n\tnextChapterEl: Element; // 依赖的下一个章节 DOM 节点\n}\n\nexport function parseVolumeOrChapterId(url: string): string {\n\tif (url.includes(\"javascript:cid(0)\")) {\n\t\treturn \"TOBEDETERMINED\";\n\t}\n\tconst match = url.match(/\\/novel\\/\\d+\\/(\\d+|vol_\\d+)\\.html/);\n\treturn match ? (match[1] ?? \"\") : \"\";\n}\n\nasync function parseChapterIdFromNextChapter(\n\tnextChapterEl: Element,\n\tchapterQueue: NovelChapterQueue,\n): Promise<string> {\n\tconst nextChapterPath = nextChapterEl.attribs.href ?? \"\";\n\tconst nextChapterContent = await chapterQueue.fetchChapterPart(\n\t\t`https://www.linovelib.com${nextChapterPath}`,\n\t);\n\tconst $temp = cheerio.load(nextChapterContent);\n\tconst chapterPath =\n\t\t$temp(\"div.mlfy_page a:first\").attr(\"href\") ??\n\t\tnextChapterContent.match(\n\t\t\t/url_previous:'(\\/novel\\/\\d+\\/[\\d_]+\\.html)'/,\n\t\t)?.[1] ??\n\t\t\"\";\n\treturn parseVolumeOrChapterId(chapterPath);\n}\n\nasync function getNovelVolumes(\n\ttitle: string,\n\turl: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n\tchapterQueue?: NovelChapterQueue,\n): Promise<Volume[]> {\n\tconst catalogHtml = await fetchClient.text(url, { retry });\n\tconst volumeEls = extractVolumesArray(catalogHtml.data);\n\n\tconst volumes: Volume[] = [];\n\tconst fixTasks: FixTask[] = [];\n\n\t// --- 第一步:同步解析整个 DOM 树,建立完整的目录结构 ---\n\t// 预先将所有的 volumeEl 加载好,方便跨卷时能够安全地索引\n\tconst parsedVolumes = volumeEls.map((el) => {\n\t\tconst $ = cheerio.load(el);\n\t\treturn {\n\t\t\t$,\n\t\t\tvolumeName: processVolumeName(title, $(\"h2\").text()),\n\t\t\tvolumeId: parseVolumeOrChapterId($(\"h2 a\").attr(\"href\") ?? \"\"),\n\t\t\tvolumeCover: $(\"a.volume-cover img\").attr(\"data-original\") ?? \"\",\n\t\t\tchapterEls: $(\"ul.chapter-list li a\").toArray(),\n\t\t};\n\t});\n\n\tfor (let vIndex = 0; vIndex < parsedVolumes.length; vIndex++) {\n\t\tconst vData = parsedVolumes[vIndex] as {\n\t\t\t$: cheerio.CheerioAPI;\n\t\t\tvolumeName: string;\n\t\t\tvolumeId: string;\n\t\t\tvolumeCover: string;\n\t\t\tchapterEls: Element[];\n\t\t};\n\t\tconst chapters: Chapter[] = [];\n\n\t\tfor (let cIndex = 0; cIndex < vData.chapterEls.length; cIndex++) {\n\t\t\tconst chapterEl = vData.chapterEls[cIndex];\n\t\t\tif (!chapterEl) {\n\t\t\t\tcontinue; // 这个章节节点不存在,跳过\n\t\t\t}\n\t\t\tconst $chapter = cheerio.load(chapterEl);\n\n\t\t\tconst chapterName = $chapter.text().trim();\n\t\t\tconst chapterPath = chapterEl.attribs.href ?? \"\";\n\t\t\tconst chapterId = parseVolumeOrChapterId(chapterPath);\n\n\t\t\tconst chapterObj: Chapter = {\n\t\t\t\tid: chapterId,\n\t\t\t\tplatform: \"linovelib\",\n\t\t\t\ttitle: chapterName,\n\t\t\t\tvolumeId: vData.volumeId,\n\t\t\t};\n\t\t\tchapters.push(chapterObj);\n\n\t\t\t// 如果需要后续修复,寻找它的下一个章节节点\n\t\t\tif (chapterId === \"TOBEDETERMINED\" && chapterQueue) {\n\t\t\t\tlet nextChapterEl: Element | null = null;\n\n\t\t\t\tif (cIndex < vData.chapterEls.length - 1) {\n\t\t\t\t\t// 情况 A:本卷还有下一章\n\t\t\t\t\tconst potentialNextEl = vData.chapterEls[cIndex + 1];\n\t\t\t\t\tif (potentialNextEl) {\n\t\t\t\t\t\tnextChapterEl = potentialNextEl;\n\t\t\t\t\t}\n\t\t\t\t} else if (vIndex < parsedVolumes.length - 1) {\n\t\t\t\t\t// 情况 B:本卷结束了,去找下一卷的第一章\n\t\t\t\t\tconst nextVolData = parsedVolumes[vIndex + 1];\n\t\t\t\t\tif (nextVolData) {\n\t\t\t\t\t\tif (nextVolData.chapterEls.length > 0) {\n\t\t\t\t\t\t\tconst potentialNextEl = nextVolData.chapterEls[0];\n\t\t\t\t\t\t\tif (potentialNextEl) {\n\t\t\t\t\t\t\t\tnextChapterEl = potentialNextEl;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// 如果找到了合法的下一章,扔进任务清单\n\t\t\t\tif (nextChapterEl) {\n\t\t\t\t\tfixTasks.push({\n\t\t\t\t\t\tchapter: chapterObj, // JS 对象引用,后续直接修改 id\n\t\t\t\t\t\tnextChapterEl,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tvolumes.push({\n\t\t\tid: vData.volumeId,\n\t\t\tplatform: \"linovelib\",\n\t\t\ttitle: vData.volumeName,\n\t\t\tcoverUrl: vData.volumeCover,\n\t\t\tchapters: chapters,\n\t\t});\n\t}\n\n\t// --- 第二步:集中并发/队列处理,回填数据 ---\n\tif (fixTasks.length > 0 && chapterQueue) {\n\t\t// 使用 Promise.all 配合你的 p-queue (concurrency=1)\n\t\tawait Promise.all(\n\t\t\tfixTasks.map(async (task) => {\n\t\t\t\t// 此时推入 MQ,由 MQ 内部控制并发率和流控\n\t\t\t\tconst realId = await parseChapterIdFromNextChapter(\n\t\t\t\t\ttask.nextChapterEl,\n\t\t\t\t\tchapterQueue,\n\t\t\t\t);\n\t\t\t\tif (realId) {\n\t\t\t\t\ttask.chapter.id = realId; // 利用引用直接修改 volumes 数组内部的值\n\t\t\t\t}\n\t\t\t}),\n\t\t);\n\t}\n\n\treturn volumes;\n}\n\nexport async function getNovelInfo(\n\tid: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n\tchapterQueue?: NovelChapterQueue,\n): Promise<Novel | undefined> {\n\tconst url = `https://www.linovelib.com/novel/${id}.html`;\n\tconst html = (\n\t\tawait fetchClient.text(url, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $ = cheerio.load(html);\n\tconst title = $(\"h1.book-name\").text().trim();\n\tconst coverUrl = $(\"div.book-img img\").attr(\"src\") || novelIdToCoverUrl(id);\n\tconst summary = (() => {\n\t\tconst $container = $(\".book-dec.Jbook-dec\").clone();\n\t\t$container.find(\".notice\").remove();\n\t\tconst paragraphs: string[] = [];\n\t\t$container\n\t\t\t.find(\"p\")\n\t\t\t.not(\".backupname\")\n\t\t\t.each((_, el) => {\n\t\t\t\tparagraphs.push($(el).text().trim());\n\t\t\t});\n\t\treturn paragraphs.join(\"\\n\");\n\t})();\n\tconst author = $(\"div.au-name a:first\").text().trim();\n\tconst status: NovelStatus = $(\"div.book-label a.state\")\n\t\t.text()\n\t\t.includes(\"完结\")\n\t\t? \"completed\"\n\t\t: \"ongoing\";\n\tconst genres = $(\"div.book-label span\")\n\t\t.children(\"a\")\n\t\t.map((_, el) => $(el).text())\n\t\t.toArray()\n\t\t.join(\",\");\n\tconst novel: Novel = {\n\t\tid,\n\t\tplatform: \"linovelib\",\n\t\ttitle,\n\t\tcoverUrl,\n\t\tsummary,\n\t\tauthor,\n\t\tstatus,\n\t\tgenres: genres.split(\",\").map((g) => g.trim()),\n\t\tvolumes: [], // Volumes and chapters will be fetched separately\n\t};\n\tnovel.volumes = (\n\t\tawait getNovelVolumes(\n\t\t\ttitle,\n\t\t\t`https://www.linovelib.com${$(\"a.read-btn\").attr(\"href\")}`,\n\t\t\tfetchClient,\n\t\t\tretry,\n\t\t\tchapterQueue,\n\t\t)\n\t).map((v) => {\n\t\tv.novelId = novel.id;\n\t\treturn v;\n\t});\n\treturn novel;\n}\n\nexport interface NovelUpdateInfo {\n\tcoverUrl: string;\n\tchapterCount: number;\n}\n\nexport async function getUpdateInfo(\n\tid: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n): Promise<NovelUpdateInfo | null> {\n\tconst url = `https://www.linovelib.com/novel/${id}.html`;\n\tconst html = (\n\t\tawait fetchClient.text(url, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $ = cheerio.load(html);\n\tif ($(\"h1.book-name\").length === 0) {\n\t\treturn null;\n\t}\n\tconst catalogUrl = `https://www.linovelib.com${$(\"a.read-btn\").attr(\"href\")}`;\n\tconst catalogHtml = (\n\t\tawait fetchClient.text(catalogUrl, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $catalog = cheerio.load(catalogHtml);\n\tconst chapterCount = $catalog(\n\t\t\"#volume-list div.volume ul.chapter-list li a\",\n\t).length;\n\tconst coverUrl = $(\"div.book-img img\").attr(\"src\") || novelIdToCoverUrl(id);\n\treturn {\n\t\tcoverUrl,\n\t\tchapterCount,\n\t};\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport { load } from \"cheerio\";\nimport { extractVolumesArray, parseVolumeOrChapterId } from \"./novel\";\n\nexport function novelIdToCoverUrl(novelId: string): string {\n\tconst prefix = novelId.length > 3 ? novelId[0] : \"0\";\n\treturn `https://www.linovelib.com/files/article/image/${prefix}/${novelId}/${novelId}s.jpg`;\n}\n\nexport async function getNovelCoverUrl(\n\tid: string,\n\tfetchClient: BrowserFetchClient,\n): Promise<string> {\n\tconst novelUrl = `https://www.linovelib.com/novel/${id}.html`;\n\tconst html = await fetchClient.text(novelUrl);\n\tconst $ = load(html.data);\n\tconst coverUrl = $(\"div.book-img img\").attr(\"src\") || novelIdToCoverUrl(id);\n\treturn coverUrl;\n}\n\nexport async function getVolumeCoverUrl(\n\tid: string,\n\tnovelId: string,\n\tfetchClient: BrowserFetchClient,\n): Promise<string> {\n\tconst catalogUrl = `https://www.linovelib.com/novel/${novelId}/catalog`;\n\tconst html = await fetchClient.text(catalogUrl);\n\tconst $ = load(html.data);\n\tconst volumes = extractVolumesArray(html.data);\n\tconst volume = volumes.find((v) => {\n\t\tconst volumeId = parseVolumeOrChapterId(\n\t\t\t$(v).find(\"h2 a\").attr(\"href\") ?? \"\",\n\t\t);\n\t\treturn volumeId === id;\n\t});\n\tif (!volume) {\n\t\tthrow new Error(`Volume not found for ID: ${id}`);\n\t}\n\tconst coverUrl =\n\t\t$(volume).find(\"a.volume-cover img\").attr(\"data-original\") || \"\";\n\treturn coverUrl;\n}\n","import {\n\ttype BrowserFetchClient,\n\tCloudflareBlockError,\n\tdefaultRetryPolicy,\n\ttype RetryOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type { Novel } from \"@acanthis-dec/core\";\nimport PQueue from \"p-queue\";\nimport type { Logger } from \"winston\";\nimport { getNovelInfo, getUpdateInfo, type NovelUpdateInfo } from \"./novel\";\n\n/**\n * Simple backoff strategy for request rate limiting\n * - Normal delay: 500-1000ms random\n * - Failure delay: 8000ms (8 seconds)\n */\nclass SimpleBackoff {\n\treadonly NORMAL_DELAY_MIN = 500;\n\treadonly NORMAL_DELAY_MAX = 1000;\n\treadonly FAILURE_DELAY = 15000;\n\n\t/**\n\t * Get delay for normal (successful) operation\n\t * @returns Random delay in range [500, 1000]ms. If isMobile is true, returns random delay in range [2000, 5000]ms\n\t */\n\tgetDelayForSuccess(): number {\n\t\treturn (\n\t\t\tthis.NORMAL_DELAY_MIN +\n\t\t\tMath.random() * (this.NORMAL_DELAY_MAX - this.NORMAL_DELAY_MIN)\n\t\t);\n\t}\n}\n\nexport class NovelChapterQueue {\n\tprivate queue: PQueue;\n\tprivate client: BrowserFetchClient;\n\tprivate backoff: SimpleBackoff;\n\tprivate logger?: Logger | undefined;\n\tprivate lastFetchTime = 0;\n\n\tconstructor(client: BrowserFetchClient, logger?: Logger) {\n\t\tthis.queue = new PQueue({ concurrency: 1 });\n\t\tthis.client = client;\n\t\tthis.backoff = new SimpleBackoff();\n\t\tthis.logger = logger;\n\t\tthis.queue.on(\"add\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 任务已添加,当前排队数: ${this.queue.size} (等待中任务数: ${this.queue.pending})`,\n\t\t\t);\n\t\t});\n\t\tthis.queue.on(\"next\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 任务完成或超时,开始下一个任务。剩余:${this.queue.size} `,\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate async _sleep(ms: number) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, ms));\n\t}\n\n\tasync fetchChapterPart(url: string): Promise<string> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tconst delay = this.backoff.getDelayForSuccess();\n\t\t\tif (Date.now() - this.lastFetchTime < delay) {\n\t\t\t\tconst waitTime = delay - (Date.now() - this.lastFetchTime);\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelChapterQueue] 请求过快,等待 ${Math.floor(waitTime)}ms`,\n\t\t\t\t);\n\t\t\t\tawait this._sleep(waitTime);\n\t\t\t}\n\t\t\tconst match = url.match(/\\/novel\\/(\\d+)\\/(\\d+)(?:_(\\d+))?\\.html/);\n\t\t\tif (!match) {\n\t\t\t\tthrow new Error(`Invalid chapter URL: ${url}`);\n\t\t\t}\n\t\t\tconst novelId = match[1];\n\t\t\tconst chapterId = match[2];\n\t\t\tconst partId = match[3] || \"1\";\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 开始获取小说${novelId}章节${chapterId}的第${partId}部分内容`,\n\t\t\t);\n\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelChapterQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${Math.floor(this.backoff.FAILURE_DELAY / 1000)}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelChapterQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst content = (await this.client.text(url, { retry })).data ?? \"\";\n\t\t\tthis.lastFetchTime = Date.now();\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 小说${novelId}-章节${chapterId}_${partId} 获取成功。`,\n\t\t\t);\n\t\t\treturn content;\n\t\t});\n\t}\n}\n\nexport class NovelInfoQueue {\n\tprivate queue: PQueue;\n\tprivate client: BrowserFetchClient;\n\tprivate backoff: SimpleBackoff;\n\tprivate chapterQueue: NovelChapterQueue;\n\tprivate logger?: Logger | undefined;\n\tprivate lastFetchTime = 0;\n\n\tconstructor(\n\t\tclient: BrowserFetchClient,\n\t\tchapterQueue: NovelChapterQueue,\n\t\tlogger?: Logger,\n\t) {\n\t\tthis.queue = new PQueue({ concurrency: 1 });\n\t\tthis.client = client;\n\t\tthis.backoff = new SimpleBackoff();\n\t\tthis.chapterQueue = chapterQueue;\n\t\tthis.logger = logger;\n\t\tthis.queue.on(\"add\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 任务已添加,当前排队数: ${this.queue.size} (等待中任务数: ${this.queue.pending})`,\n\t\t\t);\n\t\t});\n\t\tthis.queue.on(\"next\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 任务完成或超时,开始下一个任务。剩余:${this.queue.size} `,\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate async _sleep(ms: number) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, ms));\n\t}\n\n\tasync fetchNovelInfo(id: string): Promise<Novel> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tconst delay = this.backoff.getDelayForSuccess();\n\t\t\tif (Date.now() - this.lastFetchTime < delay) {\n\t\t\t\tconst waitTime = delay - (Date.now() - this.lastFetchTime);\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelInfoQueue] 请求过快,等待 ${Math.floor(waitTime)}ms`,\n\t\t\t\t);\n\t\t\t\tawait this._sleep(waitTime);\n\t\t\t}\n\t\t\tthis.logger?.debug(`[NovelInfoQueue] 开始获取小说${id}的信息`);\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${Math.floor(this.backoff.FAILURE_DELAY / 1000)}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst novel = await getNovelInfo(\n\t\t\t\tid,\n\t\t\t\tthis.client,\n\t\t\t\tretry,\n\t\t\t\tthis.chapterQueue,\n\t\t\t);\n\t\t\tif (!novel) {\n\t\t\t\tthrow new Error(`无法获取小说信息: ${id}`);\n\t\t\t}\n\t\t\tthis.logger?.debug(`[NovelInfoQueue] 小说${id} 信息获取成功。`);\n\t\t\tthis.lastFetchTime = Date.now();\n\t\t\treturn novel;\n\t\t});\n\t}\n\n\tasync fetchNovelUpdateInfo(id: string): Promise<NovelUpdateInfo | null> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tconst delay = this.backoff.getDelayForSuccess();\n\t\t\tif (Date.now() - this.lastFetchTime < delay) {\n\t\t\t\tconst waitTime = delay - (Date.now() - this.lastFetchTime);\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelInfoQueue] 请求过快,等待 ${Math.floor(waitTime)}ms`,\n\t\t\t\t);\n\t\t\t\tawait this._sleep(waitTime);\n\t\t\t}\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 开始获取小说${id}的更新信息(封面和章节数)`,\n\t\t\t);\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${Math.floor(this.backoff.FAILURE_DELAY / 1000)}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst updateInfo = await getUpdateInfo(id, this.client, retry);\n\t\t\tif (!updateInfo) {\n\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t`[NovelInfoQueue] 无法获取小说${id}的更新信息,可能是因为小说不存在或已被删除`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelInfoQueue] 小说${id} 更新信息获取成功。 封面: ${updateInfo.coverUrl}, 章节数: ${updateInfo.chapterCount}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.lastFetchTime = Date.now();\n\t\t\treturn updateInfo;\n\t\t});\n\t}\n}\n","import type { NovelSearchResult } from \"@acanthis-dec/core\";\nimport type * as cheerio from \"cheerio\";\nimport { extractNovelIdFromUrl } from \"../utils\";\n\nexport function parseSearchHtml($: cheerio.CheerioAPI): NovelSearchResult[] {\n\tconst results: NovelSearchResult[] = [];\n\t$(\"div.search-html-box div.search-result-list\").each((_, el) => {\n\t\tconst $el = $(el);\n\t\tconst title = $el.find(\"h2\").text().trim();\n\t\tconst url = $el.find(\"h2 a\").attr(\"href\") || \"\";\n\t\tconst id = extractNovelIdFromUrl(url) ?? \"\";\n\t\tconst coverUrl = $el.find(\"img\").attr(\"src\") || \"\";\n\t\tresults.push({\n\t\t\ttitle,\n\t\t\tplatform: \"linovelib\",\n\t\t\tid,\n\t\t\tcoverUrl,\n\t\t});\n\t});\n\treturn results;\n}\n\nexport function parseBookHtml($: cheerio.CheerioAPI): NovelSearchResult {\n\treturn {\n\t\ttitle: $(\"h1.book-name\").text().trim(),\n\t\tplatform: \"linovelib\",\n\t\tid: extractNovelIdFromUrl($(\"meta[name=url]\").attr(\"content\") ?? \"\") || \"\",\n\t\tcoverUrl: $(\"div.book-img img\").attr(\"src\") || \"\",\n\t};\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport { type NovelSearchResult, runTimeout } from \"@acanthis-dec/core\";\nimport { Mutex } from \"async-mutex\";\nimport { load } from \"cheerio\";\nimport { parseBookHtml, parseSearchHtml } from \"./common\";\n\nexport async function refreshSearchTicket(\n\tfetchClient: BrowserFetchClient,\n): Promise<void> {\n\tawait fetchClient.text(\"https://www.linovelib.com/S6/?search_guard=css\", {\n\t\theaders: {\n\t\t\torigin: \"https://www.linovelib.com\",\n\t\t\treferer: \"https://www.linovelib.com/\",\n\t\t\t\"Sec-Fetch-Site\": \"same-origin\",\n\t\t},\n\t});\n\tconst guardJsResp = await fetchClient.text(\n\t\t\"https://www.linovelib.com/S6/?search_guard=js\",\n\t\t{\n\t\t\theaders: {\n\t\t\t\torigin: \"https://www.linovelib.com\",\n\t\t\t\treferer: \"https://www.linovelib.com/\",\n\t\t\t\t\"Sec-Fetch-Site\": \"same-origin\",\n\t\t\t},\n\t\t},\n\t);\n\tif (guardJsResp.mimeType !== \"application/javascript\") {\n\t\tthrow new Error(`Unexpected response type: ${guardJsResp.mimeType}`);\n\t}\n\tconst guardJsToken = guardJsResp.data.match(/jieqiSearchJs=([^;\"]+)/)?.[1];\n\tif (!guardJsToken) {\n\t\tthrow new Error(\n\t\t\t\"Failed to extract jieqiSearchJs token from guard JS response\",\n\t\t);\n\t}\n\tawait fetchClient.cookieStore.set(\"jieqiSearchJs\", guardJsToken, {\n\t\tdomain: \"www.linovelib.com\",\n\t\tpath: \"/\",\n\t\tmaxAge: 3600,\n\t\tsameSite: \"Lax\",\n\t\tsecure: true,\n\t\thttpOnly: true,\n\t});\n\tconst request = async () =>\n\t\tfetchClient.text(\n\t\t\t`https://www.linovelib.com/S6/?search_guard=redeem&r=${Date.now()}`,\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\torigin: \"https://www.linovelib.com\",\n\t\t\t\t\treferer: \"https://www.linovelib.com/\",\n\t\t\t\t\t\"Sec-Fetch-Site\": \"same-origin\",\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\tawait runTimeout(request, 120);\n\tawait runTimeout(request, 800);\n\tawait runTimeout(request, 2000);\n}\n\nexport class EmptyBodyError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"EmptyBodyError\";\n\t}\n}\n\nexport class SearchTicketManager {\n\tprivate mutex = new Mutex();\n\tprivate readonly ticketCookieKey = \"jieqiSearchTicket\";\n\tprivate readonly domain = \"www.linovelib.com\";\n\tprivate prefetching = false;\n\n\tconstructor(private fetchClient: BrowserFetchClient) {}\n\n\tprivate async hasValidTicket(): Promise<boolean> {\n\t\tconst cookies = await this.fetchClient.cookieStore.getForUrl(\n\t\t\t`https://${this.domain}/`,\n\t\t);\n\t\treturn cookies.some((c) => c.name === this.ticketCookieKey);\n\t}\n\n\tprivate async consumeTicket(): Promise<void> {\n\t\tawait this.fetchClient.cookieStore.delete(\n\t\t\tthis.ticketCookieKey,\n\t\t\tthis.domain,\n\t\t);\n\t}\n\n\t/**\n\t * 唯一入口:确保 ticket 存在 -> 执行业务请求 -> 消费(清空) ticket。\n\t * 整个过程串行、互斥,同一时刻只允许一个调用在跑。\n\t */\n\tasync runExclusive<T>(task: () => Promise<T>): Promise<T> {\n\t\treturn this.mutex.runExclusive(async () => {\n\t\t\tif (!(await this.hasValidTicket())) {\n\t\t\t\tawait refreshSearchTicket(this.fetchClient);\n\t\t\t}\n\n\t\t\twhile (true) {\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await task();\n\n\t\t\t\t\t// 请求成功后:旧票作废\n\t\t\t\t\tawait this.consumeTicket();\n\n\t\t\t\t\treturn result;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (error instanceof EmptyBodyError) {\n\t\t\t\t\t\tawait refreshSearchTicket(this.fetchClient);\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\tawait this.consumeTicket();\n\t\t\t\t\tthrow error;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\t/**\n\t * 后台预取:模拟源站\"成功页面里嵌入 refresh 逻辑\"的行为。\n\t * 不在调用方持有的锁内执行,而是自己重新抢锁,\n\t * 这样不会拖慢刚刚那次请求的 return。\n\t */\n\tschedulePrefetch(): void {\n\t\tif (this.prefetching) return; // 已经有一个在跑,不重复触发\n\t\tthis.prefetching = true;\n\n\t\tthis.mutex\n\t\t\t.runExclusive(async () => {\n\t\t\t\t// 双重检查:等到真正拿到锁时,可能已经被别的调用刷新过了\n\t\t\t\tif (await this.hasValidTicket()) return;\n\t\t\t\tawait refreshSearchTicket(this.fetchClient);\n\t\t\t})\n\t\t\t.catch((err) => {\n\t\t\t\t// prefetch 失败不影响主流程,只记录,不往外抛\n\t\t\t\t// 下次真正需要 ticket 时 ensureToken 会自然重试\n\t\t\t\tconsole.error(\"[SearchTicketManager] prefetch failed:\", err);\n\t\t\t})\n\t\t\t.finally(() => {\n\t\t\t\tthis.prefetching = false;\n\t\t\t});\n\t}\n}\n\nasync function obtainFromNextPage(\n\tpath: string,\n\tfetchClient: BrowserFetchClient,\n\tticketManager: SearchTicketManager,\n): Promise<NovelSearchResult[]> {\n\tconst html = await ticketManager.runExclusive(async () => {\n\t\tconst response = await fetchClient.text(\n\t\t\t`https://www.linovelib.com${path}`,\n\t\t\t{\n\t\t\t\theaders: {\n\t\t\t\t\torigin: \"https://www.linovelib.com\",\n\t\t\t\t\treferer: \"https://www.linovelib.com/S6/\",\n\t\t\t\t},\n\t\t\t},\n\t\t);\n\t\tif (response.mimeType !== \"text/html\") {\n\t\t\tthrow new Error(`Unexpected response type: ${response.mimeType}`);\n\t\t}\n\t\tif (response.data === \"\") {\n\t\t\tthrow new EmptyBodyError(\"Empty response body when fetching next page\");\n\t\t}\n\t\treturn response.data;\n\t});\n\tconst $ = load(html);\n\tconst results: NovelSearchResult[] = [];\n\tresults.push(...parseSearchHtml($));\n\tif ($(\"a.next\").length > 0) {\n\t\tresults.push(\n\t\t\t...(await obtainFromNextPage(\n\t\t\t\t$(\"a.next\").attr(\"href\") || \"\",\n\t\t\t\tfetchClient,\n\t\t\t\tticketManager,\n\t\t\t)),\n\t\t);\n\t}\n\treturn results;\n}\n\nexport async function searchNovelsV2(\n\tkeyword: string,\n\tfetchClient: BrowserFetchClient,\n\tticketManager: SearchTicketManager,\n): Promise<NovelSearchResult[]> {\n\tconst searchHtml = await ticketManager.runExclusive(async () => {\n\t\tconst tr = await fetchClient.text(\"https://www.linovelib.com/S6/\", {\n\t\t\tmethod: \"POST\",\n\t\t\tbody: new URLSearchParams({\n\t\t\t\tsearchkey: keyword,\n\t\t\t}),\n\t\t\theaders: {\n\t\t\t\torigin: \"https://www.linovelib.com\",\n\t\t\t\treferer: \"https://www.linovelib.com/\",\n\t\t\t},\n\t\t});\n\t\tif (tr?.mimeType !== \"text/html\") {\n\t\t\tthrow new Error(`Unexpected response type: ${tr?.mimeType}`);\n\t\t}\n\t\tif (tr?.data === \"\") {\n\t\t\tthrow new EmptyBodyError(\n\t\t\t\t\"Empty response body when fetching search results\",\n\t\t\t);\n\t\t}\n\t\treturn tr.data;\n\t});\n\tconst results: NovelSearchResult[] = [];\n\tconst $ = load(searchHtml);\n\tif ($(\"div.book-html-box\").length > 0) {\n\t\treturn [parseBookHtml($)];\n\t}\n\tresults.push(...parseSearchHtml($));\n\tconst pages =\n\t\t$(\"em#pagestats\")\n\t\t\t.text()\n\t\t\t.match(/1\\/(\\d+)/)?.[1] || \"1\";\n\tif (Number(pages) > 1) {\n\t\tresults.push(\n\t\t\t...(await obtainFromNextPage(\n\t\t\t\t$(\"a.next\").attr(\"href\") || \"\",\n\t\t\t\tfetchClient,\n\t\t\t\tticketManager,\n\t\t\t)),\n\t\t);\n\t}\n\tticketManager.schedulePrefetch();\n\treturn results;\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\n\nexport interface LoginConfig {\n\tusername: string;\n\tpassword: string;\n}\n\nexport async function refreshSessionId(\n\tfetchClient: BrowserFetchClient,\n\tloginConfig: LoginConfig,\n): Promise<boolean> {\n\tawait fetchClient.request({\n\t\turl: \"https://www.linovelib.com/login.php\",\n\t\tmethod: \"GET\",\n\t\theaders: {\n\t\t\treferer: \"https://www.linovelib.com/\",\n\t\t},\n\t});\n\tconst response = await fetchClient.request({\n\t\turl: \"https://www.linovelib.com/login.php?do=submit&jumpurl=https%3A%2F%2Fwww.linovelib.com%2F\",\n\t\tmethod: \"POST\",\n\t\tbody: new URLSearchParams({\n\t\t\tusername: loginConfig.username,\n\t\t\tpassword: loginConfig.password,\n\t\t\tusecookie: \"3153600000\",\n\t\t\tsubmit: \"登录\",\n\t\t\taction: \"login\",\n\t\t}),\n\t\tfollowRedirects: false,\n\t});\n\treturn (\n\t\tresponse.cookies.findIndex((cookie) => cookie.name === \"PHPSESSID\") !== -1\n\t);\n}\n\nexport async function hasValidSession(\n\tfetchClient: BrowserFetchClient,\n): Promise<boolean> {\n\tconst response = await fetchClient.text(\"https://www.linovelib.com\");\n\tif (response.data.includes(\"用户中心\")) return true;\n\telse return false;\n}\n\nexport async function ensureValidSession(\n\tfetchClient: BrowserFetchClient,\n\tloginConfig: LoginConfig,\n): Promise<boolean> {\n\tif (!(await hasValidSession(fetchClient))) {\n\t\tconst isValid =\n\t\t\t(await refreshSessionId(fetchClient, loginConfig)) &&\n\t\t\t(await hasValidSession(fetchClient));\n\t\tif (!isValid) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n","import {\n\ttype BinaryResponse,\n\tBrowserFetchClient,\n\ttype BrowserFetchClientOptions,\n\ttype BrowserProfileName,\n\ttype FlareSolverrOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type {\n\tDescrambleCoefficients,\n\tNovel,\n\tNovelSearchResult,\n} from \"@acanthis-dec/core\";\nimport type { StorageService } from \"@acanthis-dec/storage\";\nimport { deepmerge } from \"deepmerge-ts\";\nimport type { Logger } from \"winston\";\nimport z from \"zod\";\nimport { getChapter } from \"./chapter\";\nimport { descrambleCoefficientsSchema } from \"./coefficients\";\nimport { getVolumeCoverUrl, novelIdToCoverUrl } from \"./cover\";\nimport type { NovelUpdateInfo } from \"./novel\";\nimport { NovelChapterQueue, NovelInfoQueue } from \"./queue\";\nimport { SearchTicketManager, searchNovels } from \"./search\";\nimport { ensureValidSession } from \"./session\";\n\nexport type SessionOptions =\n\t| {\n\t\t\tenabled: false;\n\t }\n\t| {\n\t\t\tenabled: true;\n\t\t\tusername: string;\n\t\t\tpassword: string;\n\t };\n\nexport type ImpersonateOptions =\n\t| {\n\t\t\tenabled: true;\n\t\t\tprofile: BrowserProfileName;\n\t }\n\t| {\n\t\t\tenabled: false;\n\t };\n\nexport type CookieStoreOptions =\n\t| {\n\t\t\ttype: \"memory\" | \"database\";\n\t }\n\t| {\n\t\t\ttype: \"file\";\n\t\t\tpath: string;\n\t };\n\nexport type LinovelibClientOptions = {\n\tsession: SessionOptions;\n\tflareSolverr: FlareSolverrOptions;\n\timpersonate: ImpersonateOptions;\n\tcookies: CookieStoreOptions;\n\tproxy?: string | undefined;\n};\n\nexport class LinovelibClient {\n\tprivate storage?: StorageService | undefined;\n\tprivate fetchClient: BrowserFetchClient;\n\tprivate novelChapterQueue: NovelChapterQueue;\n\tprivate novelInfoQueue: NovelInfoQueue;\n\tprivate searchTicketManager: SearchTicketManager;\n\tprivate options?: LinovelibClientOptions;\n\tprivate logger?: Logger | undefined;\n\tprivate isSessionValid?: boolean = undefined;\n\n\tconstructor(\n\t\toptions?: LinovelibClientOptions,\n\t\tstorage?: StorageService,\n\t\tlogger?: Logger,\n\t) {\n\t\tconst defaultOptions: LinovelibClientOptions = {\n\t\t\tsession: {\n\t\t\t\tenabled: false,\n\t\t\t},\n\t\t\tflareSolverr: {\n\t\t\t\tenabled: true,\n\t\t\t\thost: \"http://localhost:8191\",\n\t\t\t\ttimeoutMs: 60000,\n\t\t\t\tsessionId: \"acanthis-linovelib-client\",\n\t\t\t},\n\t\t\timpersonate: {\n\t\t\t\tenabled: true,\n\t\t\t\tprofile: \"chrome-latest-linux\",\n\t\t\t},\n\t\t\tcookies: {\n\t\t\t\ttype: \"memory\",\n\t\t\t},\n\t\t};\n\t\tthis.options = deepmerge(\n\t\t\tdefaultOptions,\n\t\t\toptions ?? {},\n\t\t) as LinovelibClientOptions;\n\t\tthis.storage = storage;\n\t\tthis.logger = logger;\n\t\tconst browserFetchOptions: BrowserFetchClientOptions = {};\n\t\tif (this.options?.flareSolverr.enabled) {\n\t\t\tbrowserFetchOptions.flareSolverr = {\n\t\t\t\tenabled: true,\n\t\t\t\thost: this.options.flareSolverr.host,\n\t\t\t\ttimeoutMs: this.options.flareSolverr.timeoutMs ?? 60000,\n\t\t\t\tsessionId:\n\t\t\t\t\tthis.options.flareSolverr.sessionId ?? \"acanthis-linovelib-client\",\n\t\t\t};\n\t\t} else {\n\t\t\tbrowserFetchOptions.flareSolverr = {\n\t\t\t\tenabled: false,\n\t\t\t};\n\t\t}\n\t\tif (this.options?.proxy) {\n\t\t\tbrowserFetchOptions.proxy = this.options.proxy;\n\t\t}\n\t\tif (this.options?.impersonate.enabled) {\n\t\t\tbrowserFetchOptions.profile = this.options.impersonate.profile;\n\t\t}\n\t\tswitch (this.options?.cookies.type) {\n\t\t\tcase \"memory\":\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"memory\",\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"file\":\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"file\",\n\t\t\t\t\tpath: this.options.cookies.path,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"database\":\n\t\t\t\tif (!this.storage) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"StorageService is required for database cookie store\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"custom\",\n\t\t\t\t\tstore: this.storage.getCookieStore(),\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"memory\",\n\t\t\t\t};\n\t\t}\n\t\tthis.fetchClient = new BrowserFetchClient(browserFetchOptions);\n\t\tthis.novelChapterQueue = new NovelChapterQueue(\n\t\t\tthis.fetchClient,\n\t\t\tthis.logger,\n\t\t);\n\t\tthis.novelInfoQueue = new NovelInfoQueue(\n\t\t\tthis.fetchClient,\n\t\t\tthis.novelChapterQueue,\n\t\t\tthis.logger,\n\t\t);\n\t\tthis.searchTicketManager = new SearchTicketManager(this.fetchClient);\n\t}\n\n\tasync getNovelInfo(id: string): Promise<Novel | undefined> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await this.novelInfoQueue.fetchNovelInfo(id);\n\t}\n\n\tasync getNovelUpdateInfo(id: string): Promise<NovelUpdateInfo | null> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await this.novelInfoQueue.fetchNovelUpdateInfo(id);\n\t}\n\n\tasync searchNovels(keyword: string): Promise<NovelSearchResult[]> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await searchNovels(\n\t\t\tkeyword,\n\t\t\tthis.fetchClient,\n\t\t\tthis.searchTicketManager,\n\t\t);\n\t}\n\n\tasync getNovelCover(\n\t\tid: string,\n\t): Promise<{ data: BinaryResponse; url: string }> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\tconst coverUrl = await novelIdToCoverUrl(id);\n\t\tconst coverData = await this.getCover(\n\t\t\tcoverUrl,\n\t\t\t`https://www.linovelib.com/novel/${id}.html`,\n\t\t);\n\t\treturn { data: coverData, url: coverUrl };\n\t}\n\n\tasync getVolumeCover(\n\t\tnovelId: string,\n\t\tvolumeId: string,\n\t): Promise<{ data: BinaryResponse; url: string }> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\tconst coverUrl = await getVolumeCoverUrl(\n\t\t\tvolumeId,\n\t\t\tnovelId,\n\t\t\tthis.fetchClient,\n\t\t);\n\t\tconst coverData = await this.getCover(\n\t\t\tcoverUrl,\n\t\t\t`https://www.linovelib.com/novel/${novelId}/catalog`,\n\t\t);\n\t\treturn { data: coverData, url: coverUrl };\n\t}\n\n\tasync getCover(url: string, referer?: string): Promise<BinaryResponse> {\n\t\treturn await this.fetchClient.binary(url, {\n\t\t\theaders: {\n\t\t\t\tReferer: referer || \"https://www.linovelib.com/\",\n\t\t\t},\n\t\t});\n\t}\n\n\tasync getChapter(\n\t\tnovelId: string,\n\t\tchapterId: string,\n\t): Promise<string | undefined> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\tconst cachedJsVersion = this.storage\n\t\t\t? ((await this.storage.getCache(\"chapterlog_js_version\", z.string())) ??\n\t\t\t\tundefined)\n\t\t\t: undefined;\n\t\tconst cachedCoefficients = this.storage\n\t\t\t? ((await this.storage.getCache<DescrambleCoefficients>(\n\t\t\t\t\t\"coefficients\",\n\t\t\t\t\tdescrambleCoefficientsSchema,\n\t\t\t\t)) ?? undefined)\n\t\t\t: undefined;\n\t\tconst result = await getChapter(\n\t\t\tchapterId,\n\t\t\tnovelId,\n\t\t\tthis.novelChapterQueue,\n\t\t\tthis.fetchClient,\n\t\t\tcachedJsVersion,\n\t\t\tcachedCoefficients,\n\t\t);\n\t\tif (this.storage && result) {\n\t\t\tawait this.storage.setCache(\"chapterlog_js_version\", result.version);\n\t\t\tawait this.storage.setCache(\"coefficients\", result.coefficients);\n\t\t}\n\t\treturn result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AC/B,UAAU,KAAK,QAAQ,QAAQ;EAChC,CAAC;EAEF,MAAM,kBAAkB,KAAK,UACxB,MAAM,KAAK,QAAQ,SAAS,yBAAyBC,IAAE,OAAO,CAAC,KAClE,KAAA,IACC,KAAA;EACH,MAAM,qBAAqB,KAAK,UAC3B,MAAM,KAAK,QAAQ,SACrB,gBACA,4BACD,KAAM,KAAA,IACL,KAAA;EACH,MAAM,SAAS,MAAM,WACpB,WACA,SACA,KAAK,mBACL,KAAK,aACL,iBACA,kBACD;EACA,IAAI,KAAK,WAAW,QAAQ;GAC3B,MAAM,KAAK,QAAQ,SAAS,yBAAyB,OAAO,OAAO;GACnE,MAAM,KAAK,QAAQ,SAAS,gBAAgB,OAAO,YAAY;EAChE;EACA,OAAO,QAAQ;CAChB;AACD"}
1
+ {"version":3,"file":"index.mjs","names":["z","decodePng","searchNovels"],"sources":["../src/coefficients.ts","../src/utils.ts","../src/chapter.ts","../src/novel.ts","../src/cover.ts","../src/queue.ts","../src/search/common.ts","../src/search/captcha.ts","../src/search/v3.ts","../src/session.ts","../src/client.ts","../src/illustration.ts"],"sourcesContent":["import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport type { DescrambleCoefficients } from \"@acanthis-dec/core\";\nimport { deobfuscate } from \"@acanthis-dec/deobfuscator\";\nimport { parse } from \"@babel/parser\";\nimport traverseModule from \"@babel/traverse\";\nimport * as t from \"@babel/types\";\nimport * as cheerio from \"cheerio\";\nimport { z } from \"zod\";\n\ntype TraverseFunction = typeof traverseModule;\n\nconst traverse =\n\t(traverseModule as unknown as { default?: TraverseFunction }).default ??\n\ttraverseModule;\n\nexport const descrambleCoefficientsSchema = z.object({\n\tmodulus: z.number().int(),\n\tincrement: z.number().int(),\n\tmultiplier: z.number().int(),\n\tseedOffset: z.number().int(),\n\tseedMultiplier: z.number().int(),\n});\n\nfunction getObfuscatedPart(fullCode: string): string {\n\treturn fullCode\n\t\t.split(/\\r?\\n/)\n\t\t.map((line) => line.trim())\n\t\t.filter((line) => line !== \"\")\n\t\t.slice(-2)\n\t\t.join(\"\\n\");\n}\n\nexport async function extractCoefficients(\n\tscript: string,\n): Promise<DescrambleCoefficients> {\n\tconst obfuscatedPart = getObfuscatedPart(script);\n\tconst deObfCode = await deobfuscate(obfuscatedPart);\n\tconst ast = parse(deObfCode, { sourceType: \"module\", plugins: [\"jsx\"] });\n\tconst coefficients: Partial<DescrambleCoefficients> = {};\n\ttraverse(ast, {\n\t\tBinaryExpression(path) {\n\t\t\tconst { node } = path;\n\t\t\tif (\n\t\t\t\tnode.operator === \"%\" &&\n\t\t\t\tt.isNumericLiteral(node.right) &&\n\t\t\t\tt.isBinaryExpression(node.left) &&\n\t\t\t\tnode.left.operator === \"+\" &&\n\t\t\t\tt.isNumericLiteral(node.left.right) &&\n\t\t\t\tt.isBinaryExpression(node.left.left) &&\n\t\t\t\tnode.left.left.operator === \"*\" &&\n\t\t\t\tt.isNumericLiteral(node.left.left.right)\n\t\t\t) {\n\t\t\t\tcoefficients.modulus = node.right.value;\n\t\t\t\tconst leftSide = node.left;\n\t\t\t\tif (t.isBinaryExpression(leftSide) && leftSide.operator === \"+\") {\n\t\t\t\t\tif (t.isNumericLiteral(leftSide.right)) {\n\t\t\t\t\t\tcoefficients.increment = leftSide.right.value;\n\t\t\t\t\t}\n\t\t\t\t\tif (\n\t\t\t\t\t\tt.isBinaryExpression(leftSide.left) &&\n\t\t\t\t\t\tleftSide.left.operator === \"*\"\n\t\t\t\t\t) {\n\t\t\t\t\t\tif (t.isNumericLiteral(leftSide.left.right)) {\n\t\t\t\t\t\t\tcoefficients.multiplier = leftSide.left.right.value;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (\n\t\t\t\tnode.operator === \"+\" &&\n\t\t\t\tt.isNumericLiteral(node.right) &&\n\t\t\t\tt.isBinaryExpression(node.left) &&\n\t\t\t\tnode.left.operator === \"*\" &&\n\t\t\t\tt.isNumericLiteral(node.left.right)\n\t\t\t) {\n\t\t\t\tconst potentialOffset = node.right.value;\n\t\t\t\tconst potentialMultiplier = node.left.right.value;\n\t\t\t\tconst numberTransformed = node.left.left;\n\t\t\t\tif (\n\t\t\t\t\tt.isCallExpression(numberTransformed) &&\n\t\t\t\t\tt.isIdentifier(numberTransformed.callee) &&\n\t\t\t\t\t(numberTransformed.callee.name === \"Number\" ||\n\t\t\t\t\t\tnumberTransformed.callee.name === \"parseInt\")\n\t\t\t\t) {\n\t\t\t\t\tcoefficients.seedOffset = potentialOffset;\n\t\t\t\t\tcoefficients.seedMultiplier = potentialMultiplier;\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t});\n\tif (\n\t\tcoefficients.modulus === undefined ||\n\t\tcoefficients.increment === undefined ||\n\t\tcoefficients.multiplier === undefined ||\n\t\tcoefficients.seedOffset === undefined ||\n\t\tcoefficients.seedMultiplier === undefined\n\t) {\n\t\tthrow new Error(\"Failed to extract all coefficients\");\n\t}\n\treturn coefficients as DescrambleCoefficients;\n}\n\nexport function extractChapterLogScriptUrl(html: string): string {\n\tconst $ = cheerio.load(html);\n\tconst chapterLogScriptUrl =\n\t\t$(\n\t\t\t$(\"script\")\n\t\t\t\t.toArray()\n\t\t\t\t.find((el) => {\n\t\t\t\t\tconst scriptContent = $(el).attr(\"src\") || \"\";\n\t\t\t\t\treturn /chapterlog\\.js/.test(scriptContent);\n\t\t\t\t}),\n\t\t).attr(\"src\") || \"\";\n\treturn chapterLogScriptUrl.startsWith(\"http\")\n\t\t? chapterLogScriptUrl\n\t\t: `https://www.linovelib.com${chapterLogScriptUrl}`;\n}\n\nexport interface CoefficientResult {\n\tcoefficients: DescrambleCoefficients;\n\tversion: string;\n}\n\nexport async function getCoefficientsFromPage(\n\thtml: string,\n\tfetchClient: BrowserFetchClient,\n\tcachedVersion?: string,\n): Promise<CoefficientResult | undefined> {\n\tconst scriptUrl = extractChapterLogScriptUrl(html);\n\tif (!scriptUrl) {\n\t\tthrow new Error(\"Chapter log script URL not found\");\n\t}\n\tconst version = scriptUrl.match(/chapterlog\\.js\\?(v.*)/)?.[1] || \"\";\n\tif (version === cachedVersion) {\n\t\treturn undefined; // No need to fetch and extract again\n\t}\n\tconst scriptContent = await fetchClient.text(scriptUrl);\n\tif (!scriptContent.mimeType.includes(\"javascript\")) {\n\t\tthrow new Error(\"Fetched content is not JavaScript\");\n\t}\n\tconst coefficients = await extractCoefficients(scriptContent.data);\n\treturn {\n\t\tcoefficients,\n\t\tversion: version,\n\t};\n}\n","export function extractNovelIdFromUrl(url: string): string | undefined {\n\tconst match = url.match(/\\/novel\\/(\\d+)\\.html/);\n\treturn match ? match[1] : undefined;\n}\n\nexport interface NovelAndChapterIds {\n\tnovelId: string | undefined;\n\tchapterId: string | undefined;\n}\n\nexport function extractChapterIdFromUrl(\n\turl: string,\n): NovelAndChapterIds | undefined {\n\tconst match = url.match(/\\/novel\\/(\\d+)\\/(\\d+)\\.html/);\n\tif (match) {\n\t\treturn {\n\t\t\tnovelId: match[1],\n\t\t\tchapterId: match[2],\n\t\t};\n\t}\n\treturn undefined;\n}\n\nexport function transformChapterName(name: string): string {\n\tconst chapNameTransDict: Record<string, string> = {\n\t\t\"\\u004e\": \"\\u5973\",\n\t};\n\treturn name.replace(/./g, (char) => chapNameTransDict[char] || char);\n}\n\nexport function transformContent(content: string): string {\n\tconst contentTransDict: Record<string, string> = {\n\t\t\"\\u201c\": \"\\u300c\",\n\t\t\"\\u201d\": \"\\u300d\",\n\t\t\"\\u2018\": \"\\u300e\",\n\t\t\"\\u2019\": \"\\u300f\",\n\t\t\"\\ue82c\": \"\\u7684\",\n\t\t\"\\ue852\": \"\\u4e00\",\n\t\t\"\\ue82d\": \"\\u662f\",\n\t\t\"\\ue819\": \"\\u4e86\",\n\t\t\"\\ue856\": \"\\u6211\",\n\t\t\"\\ue857\": \"\\u4e0d\",\n\t\t\"\\ue816\": \"\\u4eba\",\n\t\t\"\\ue83c\": \"\\u5728\",\n\t\t\"\\ue830\": \"\\u4ed6\",\n\t\t\"\\ue82e\": \"\\u6709\",\n\t\t\"\\ue836\": \"\\u8fd9\",\n\t\t\"\\ue859\": \"\\u4e2a\",\n\t\t\"\\ue80a\": \"\\u4e0a\",\n\t\t\"\\ue855\": \"\\u4eec\",\n\t\t\"\\ue842\": \"\\u6765\",\n\t\t\"\\ue858\": \"\\u5230\",\n\t\t\"\\ue80b\": \"\\u65f6\",\n\t\t\"\\ue81f\": \"\\u5927\",\n\t\t\"\\ue84a\": \"\\u5730\",\n\t\t\"\\ue853\": \"\\u4e3a\",\n\t\t\"\\ue81e\": \"\\u5b50\",\n\t\t\"\\ue822\": \"\\u4e2d\",\n\t\t\"\\ue813\": \"\\u4f60\",\n\t\t\"\\ue85b\": \"\\u8bf4\",\n\t\t\"\\ue807\": \"\\u751f\",\n\t\t\"\\ue818\": \"\\u56fd\",\n\t\t\"\\ue810\": \"\\u5e74\",\n\t\t\"\\ue812\": \"\\u7740\",\n\t\t\"\\ue851\": \"\\u5c31\",\n\t\t\"\\ue801\": \"\\u90a3\",\n\t\t\"\\ue80c\": \"\\u548c\",\n\t\t\"\\ue815\": \"\\u8981\",\n\t\t\"\\ue84c\": \"\\u5979\",\n\t\t\"\\ue840\": \"\\u51fa\",\n\t\t\"\\ue848\": \"\\u4e5f\",\n\t\t\"\\ue835\": \"\\u5f97\",\n\t\t\"\\ue800\": \"\\u91cc\",\n\t\t\"\\ue826\": \"\\u540e\",\n\t\t\"\\ue863\": \"\\u81ea\",\n\t\t\"\\ue861\": \"\\u4ee5\",\n\t\t\"\\ue854\": \"\\u4f1a\",\n\t\t\"\\ue827\": \"\\u5bb6\",\n\t\t\"\\ue83b\": \"\\u53ef\",\n\t\t\"\\ue85d\": \"\\u4e0b\",\n\t\t\"\\ue84d\": \"\\u800c\",\n\t\t\"\\ue862\": \"\\u8fc7\",\n\t\t\"\\ue81c\": \"\\u5929\",\n\t\t\"\\ue81d\": \"\\u53bb\",\n\t\t\"\\ue860\": \"\\u80fd\",\n\t\t\"\\ue843\": \"\\u5bf9\",\n\t\t\"\\ue82f\": \"\\u5c0f\",\n\t\t\"\\ue802\": \"\\u591a\",\n\t\t\"\\ue831\": \"\\u7136\",\n\t\t\"\\ue84b\": \"\\u4e8e\",\n\t\t\"\\ue837\": \"\\u5fc3\",\n\t\t\"\\ue829\": \"\\u5b66\",\n\t\t\"\\ue85e\": \"\\u4e48\",\n\t\t\"\\ue83a\": \"\\u4e4b\",\n\t\t\"\\ue832\": \"\\u90fd\",\n\t\t\"\\ue808\": \"\\u597d\",\n\t\t\"\\ue841\": \"\\u770b\",\n\t\t\"\\ue821\": \"\\u8d77\",\n\t\t\"\\ue845\": \"\\u53d1\",\n\t\t\"\\ue803\": \"\\u5f53\",\n\t\t\"\\ue828\": \"\\u6ca1\",\n\t\t\"\\ue81b\": \"\\u6210\",\n\t\t\"\\ue83e\": \"\\u53ea\",\n\t\t\"\\ue820\": \"\\u5982\",\n\t\t\"\\ue84e\": \"\\u4e8b\",\n\t\t\"\\ue85a\": \"\\u628a\",\n\t\t\"\\ue806\": \"\\u8fd8\",\n\t\t\"\\ue83f\": \"\\u7528\",\n\t\t\"\\ue833\": \"\\u7b2c\",\n\t\t\"\\ue811\": \"\\u6837\",\n\t\t\"\\ue804\": \"\\u9053\",\n\t\t\"\\ue814\": \"\\u60f3\",\n\t\t\"\\ue80f\": \"\\u4f5c\",\n\t\t\"\\ue84f\": \"\\u79cd\",\n\t\t\"\\ue80e\": \"\\u5f00\",\n\t\t\"\\ue823\": \"\\u7f8e\",\n\t\t\"\\ue849\": \"\\u4e73\",\n\t\t\"\\ue805\": \"\\u9634\",\n\t\t\"\\ue809\": \"\\u6db2\",\n\t\t\"\\ue81a\": \"\\u830e\",\n\t\t\"\\ue844\": \"\\u6b32\",\n\t\t\"\\ue847\": \"\\u547b\",\n\t\t\"\\ue850\": \"\\u8089\",\n\t\t\"\\ue824\": \"\\u4ea4\",\n\t\t\"\\ue85f\": \"\\u6027\",\n\t\t\"\\ue817\": \"\\u80f8\",\n\t\t\"\\ue85c\": \"\\u79c1\",\n\t\t\"\\ue838\": \"\\u7a74\",\n\t\t\"\\ue82a\": \"\\u6deb\",\n\t\t\"\\ue83d\": \"\\u81c0\",\n\t\t\"\\ue82b\": \"\\u8214\",\n\t\t\"\\ue80d\": \"\\u5c04\",\n\t\t\"\\ue839\": \"\\u8131\",\n\t\t\"\\ue834\": \"\\u88f8\",\n\t\t\"\\ue846\": \"\\u9a9a\",\n\t\t\"\\ue825\": \"\\u5507\",\n\t};\n\treturn content.replace(/./g, (char) => contentTransDict[char] || char);\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport {\n\tbuildDescrambleMapping,\n\ttype DescrambleCoefficients,\n} from \"@acanthis-dec/core\";\nimport * as cheerio from \"cheerio\";\nimport type { AnyNode, Element } from \"domhandler\";\nimport { getCoefficientsFromPage } from \"./coefficients\";\nimport type { NovelChapterQueue } from \"./queue\";\nimport { transformContent } from \"./utils\";\n\nfunction extractChapterId($: cheerio.CheerioAPI): string {\n\tconst scriptTags = $(\"script\");\n\tlet chapterId = \"\";\n\tscriptTags.each((_, el) => {\n\t\tconst scriptContent = $(el).html();\n\t\tif (scriptContent) {\n\t\t\tconst match = scriptContent.match(/chapterid\\s*:\\s*'(\\d+)'/);\n\t\t\tif (match?.[1]) {\n\t\t\t\tchapterId = match[1];\n\t\t\t\treturn false; // Break the loop\n\t\t\t}\n\t\t}\n\t});\n\treturn chapterId;\n}\n\nexport interface DecryptResult {\n\tcontent: string;\n\tversion: string;\n\tcoefficients: DescrambleCoefficients;\n}\n\nasync function decrypt(\n\thtml: string,\n\tfetchClient: BrowserFetchClient,\n\tcachedJsVersion?: string,\n\tcachedCoefficients?: DescrambleCoefficients,\n): Promise<DecryptResult> {\n\tconst $ = cheerio.load(html);\n\tconst coefficientResult = await getCoefficientsFromPage(\n\t\thtml,\n\t\tfetchClient,\n\t\tcachedJsVersion,\n\t);\n\tconst version = coefficientResult?.version || cachedJsVersion;\n\tconst coefficients = coefficientResult?.coefficients || cachedCoefficients;\n\tif (!version) {\n\t\tthrow new Error(\"Failed to determine chapterlog.js version\");\n\t}\n\tif (!coefficients) {\n\t\tthrow new Error(\"Failed to obtain descrambling coefficients\");\n\t}\n\tconst chapterId = extractChapterId($);\n\tconst container = $(\"#TextContent, #acontent\");\n\tif (!container.length) {\n\t\treturn {\n\t\t\tcontent: \"\",\n\t\t\tversion,\n\t\t\tcoefficients: coefficients,\n\t\t};\n\t}\n\n\tcontainer.find(\"p\").each((_, el) => {\n\t\tconst $el = $(el);\n\t\tconst innerHtml = $el.html();\n\t\tif (innerHtml) {\n\t\t\tconst cleanedHtml = innerHtml.replace(/^\\s+|(?<=>)\\s+/g, \"\");\n\t\t\t$el.html(cleanedHtml);\n\t\t}\n\t});\n\n\tcontainer.find(\"img.imagecontent\").each((_, el) => {\n\t\tconst imgSrc = $(el).attr(\"data-src\") || $(el).attr(\"src\");\n\t\tif (imgSrc) {\n\t\t\t$(el).attr(\"src\", imgSrc).removeAttr(\"data-src\");\n\t\t}\n\t});\n\n\tcontainer.find(\"div.dag\").remove();\n\tcontainer.find(\"script\").remove();\n\n\tconst allChildren = container\n\t\t.contents()\n\t\t.toArray()\n\t\t.filter((node) => !(node.type === \"tag\" && node.tagName === \"div\"));\n\tconst sortableEntries: { element: Element; originalPos: number }[] = [];\n\tallChildren.forEach((node, index) => {\n\t\tif (node.type === \"tag\" && node.tagName === \"p\") {\n\t\t\tconst text = $(node).text().trim();\n\t\t\tif (text.length > 0) {\n\t\t\t\tsortableEntries.push({ element: node, originalPos: index });\n\t\t\t}\n\t\t}\n\t});\n\n\tconst seed =\n\t\tparseInt(chapterId, 10) * coefficients?.seedMultiplier +\n\t\tcoefficients?.seedOffset;\n\n\tconst mapping = buildDescrambleMapping(\n\t\tsortableEntries.length,\n\t\tseed,\n\t\tcoefficients,\n\t\t20,\n\t);\n\n\tconst restoredChildren: (AnyNode | null)[] = [...allChildren];\n\n\tsortableEntries.forEach((entry, i) => {\n\t\tconst targetIndex = mapping[i] ?? i;\n\t\tconst actualSlot = sortableEntries[targetIndex]?.originalPos ?? 0;\n\t\trestoredChildren[actualSlot] = entry.element;\n\t});\n\n\tconst newContainer = $(\"<div></div>\");\n\trestoredChildren.forEach((node) => {\n\t\tif (node && node.type === \"tag\") {\n\t\t\tnewContainer.append(node);\n\t\t\tnewContainer.append(\"\\n\");\n\t\t}\n\t});\n\n\treturn {\n\t\tcontent: newContainer.html() || \"\",\n\t\tversion,\n\t\tcoefficients: coefficients,\n\t};\n}\n\nexport async function getChapter(\n\tid: string,\n\tnovelId: string,\n\tchapterQueue: NovelChapterQueue,\n\tfetchClient: BrowserFetchClient,\n\tcachedJsVersion?: string,\n\tcachedCoefficients?: DescrambleCoefficients,\n): Promise<DecryptResult | undefined> {\n\tconst firstPageHtml = await chapterQueue.fetchChapterPart(\n\t\t`https://www.linovelib.com/novel/${novelId}/${id}.html`,\n\t);\n\tlet $ = cheerio.load(firstPageHtml);\n\tconst chapterName = $(\"h1\").text().trim();\n\tlet nextPageId =\n\t\t$(\"div.mlfy_page a:last\")\n\t\t\t.attr(\"href\")\n\t\t\t?.match(/\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\tfirstPageHtml.match(/url_next:'\\/novel\\/(\\d+)\\/([\\d_]+)\\.html'/)?.[2] ||\n\t\t\"\";\n\tlet content = await decrypt(\n\t\tfirstPageHtml,\n\t\tfetchClient,\n\t\tcachedJsVersion,\n\t\tcachedCoefficients,\n\t);\n\tcachedCoefficients = content.coefficients;\n\tcachedJsVersion = content.version;\n\twhile (nextPageId?.includes(id)) {\n\t\tconst nextPageHtml = await chapterQueue.fetchChapterPart(\n\t\t\t`https://www.linovelib.com/novel/${novelId}/${nextPageId}.html`,\n\t\t);\n\t\tconst nextContent = await decrypt(\n\t\t\tnextPageHtml,\n\t\t\tfetchClient,\n\t\t\tcachedJsVersion,\n\t\t\tcachedCoefficients,\n\t\t);\n\t\tcontent = {\n\t\t\t...content,\n\t\t\tcontent: content.content + nextContent.content,\n\t\t};\n\t\t$ = cheerio.load(nextPageHtml);\n\t\tnextPageId =\n\t\t\t$(\"div.mlfy_page a:last\")\n\t\t\t\t.attr(\"href\")\n\t\t\t\t?.match(/\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\t\tnextPageHtml.match(/url_next:'\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/)?.[2] ||\n\t\t\t\"\";\n\t}\n\t// content = `<h2>${chapterName}</h2>\\n${transformContent(content)}`;\n\tcontent = {\n\t\t...content,\n\t\tcontent: `<h2>${chapterName}</h2>\\n${transformContent(content.content)}`,\n\t};\n\treturn content;\n}\n","import type {\n\tBrowserFetchClient,\n\tRetryOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type { Chapter, Novel, NovelStatus, Volume } from \"@acanthis-dec/core\";\nimport * as cheerio from \"cheerio\";\nimport type { Element } from \"domhandler\";\nimport { novelIdToCoverUrl } from \"./cover\";\nimport type { NovelChapterQueue } from \"./queue\";\n\nexport function extractVolumesArray(catalog: string): Element[] {\n\tconst $ = cheerio.load(catalog);\n\tconst results: Element[] = [];\n\t$(\"#volume-list div.volume\").each((_, elem) => {\n\t\t$(elem).remove(\"div.volume\");\n\t\tresults.push(elem);\n\t});\n\treturn results;\n}\n\nfunction processVolumeName(novelTitle: string, volumeName: string): string {\n\t// Remove novel title from volume name if present\n\tif (volumeName.startsWith(novelTitle)) {\n\t\treturn volumeName.slice(novelTitle.length).trim();\n\t}\n\tif (!Number.isNaN(Number(volumeName))) {\n\t\treturn `第 ${volumeName} 卷`;\n\t}\n\treturn volumeName.trim();\n}\n\nexport function isUnresolvedChapterId(id: string): boolean {\n\treturn id.startsWith(\"TOBEDETERMINED\");\n}\n\nexport function parseVolumeOrChapterId(url: string): string {\n\tif (url.includes(\"javascript:cid(0)\")) {\n\t\treturn \"TOBEDETERMINED\";\n\t}\n\tconst match = url.match(/\\/novel\\/\\d+\\/(\\d+|vol_\\d+)\\.html/);\n\treturn match ? (match[1] ?? \"\") : \"\";\n}\n\nfunction extractChapterIdFromLink(\n\thref: string | undefined,\n\tnovelId: string,\n): string {\n\tif (!href) {\n\t\treturn \"\";\n\t}\n\tconst match = href.match(/\\/novel\\/(\\d+)\\/(\\d+)(?:_\\d+)?\\.html/);\n\tif (!match || match[1] !== novelId) {\n\t\treturn \"\";\n\t}\n\tconst chapterId = match[2] ?? \"\";\n\treturn /^\\d+$/.test(chapterId) ? chapterId : \"\";\n}\n\nasync function parseChapterIdFromNextChapter(\n\tnovelId: string,\n\tnextChapterId: string,\n\tchapterQueue: NovelChapterQueue,\n): Promise<string> {\n\tif (!/^\\d+$/.test(nextChapterId)) {\n\t\treturn \"\";\n\t}\n\ttry {\n\t\tconst nextChapterContent = await chapterQueue.fetchChapterPart(\n\t\t\t`https://www.linovelib.com/novel/${novelId}/${nextChapterId}.html`,\n\t\t);\n\t\tconst $temp = cheerio.load(nextChapterContent);\n\t\tconst domHref = $temp(\"div.mlfy_page a:first\").attr(\"href\");\n\t\tconst domChapterId = extractChapterIdFromLink(domHref, novelId);\n\t\tif (domChapterId) {\n\t\t\treturn domChapterId;\n\t\t}\n\t\tconst scriptHref = nextChapterContent.match(\n\t\t\t/url_previous\\s*:\\s*['\"](\\/novel\\/\\d+\\/[\\d_]+\\.html)['\"]/,\n\t\t)?.[1];\n\t\treturn extractChapterIdFromLink(scriptHref, novelId);\n\t} catch {\n\t\treturn \"\";\n\t}\n}\n\nexport async function parseNextChapterIdFromPrevChapter(\n\tnovelId: string,\n\tprevChapterId: string,\n\tchapterQueue: NovelChapterQueue,\n): Promise<string> {\n\tif (!/^\\d+$/.test(prevChapterId)) {\n\t\treturn \"\";\n\t}\n\tconst MAX_PAGES = 50;\n\tconst visited = new Set<string>();\n\tlet currentPageId = prevChapterId;\n\n\tfor (let page = 0; page < MAX_PAGES; page++) {\n\t\tif (visited.has(currentPageId)) {\n\t\t\treturn \"\";\n\t\t}\n\t\tvisited.add(currentPageId);\n\n\t\tlet html = \"\";\n\t\ttry {\n\t\t\thtml = await chapterQueue.fetchChapterPart(\n\t\t\t\t`https://www.linovelib.com/novel/${novelId}/${currentPageId}.html`,\n\t\t\t);\n\t\t} catch {\n\t\t\treturn \"\";\n\t\t}\n\n\t\tconst $ = cheerio.load(html);\n\t\tconst domMatch = $(\"div.mlfy_page a:last\")\n\t\t\t.attr(\"href\")\n\t\t\t?.match(/\\/novel\\/(\\d+)\\/([\\d_]+)\\.html/);\n\t\tconst scriptMatch = html.match(\n\t\t\t/url_next\\s*:\\s*['\"]\\/novel\\/(\\d+)\\/([\\d_]+)\\.html['\"]/,\n\t\t);\n\t\tconst nextPageId =\n\t\t\t(domMatch?.[1] === novelId ? domMatch[2] : undefined) ??\n\t\t\t(scriptMatch?.[1] === novelId ? scriptMatch[2] : undefined) ??\n\t\t\t\"\";\n\n\t\tif (!nextPageId || visited.has(nextPageId)) {\n\t\t\treturn \"\";\n\t\t}\n\t\tif (nextPageId.startsWith(`${prevChapterId}_`)) {\n\t\t\tcurrentPageId = nextPageId;\n\t\t\tcontinue;\n\t\t}\n\t\tif (/^\\d+$/.test(nextPageId) && nextPageId !== prevChapterId) {\n\t\t\treturn nextPageId;\n\t\t}\n\t\treturn \"\";\n\t}\n\n\treturn \"\";\n}\n\nexport async function getNovelVolumes(\n\tnovelId: string,\n\ttitle: string,\n\turl: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n\tchapterQueue?: NovelChapterQueue,\n): Promise<Volume[]> {\n\tconst catalogHtml = await fetchClient.text(url, { retry });\n\tconst volumeEls = extractVolumesArray(catalogHtml.data);\n\n\tconst volumes: Volume[] = [];\n\tconst flatChapters: Array<{\n\t\tchapter: Chapter;\n\t\tvIndex: number;\n\t\tcIndex: number;\n\t}> = [];\n\n\t// --- 第一步:同步解析整个 DOM 树,建立完整的目录结构 ---\n\tconst parsedVolumes = volumeEls.map((el) => {\n\t\tconst $ = cheerio.load(el);\n\t\treturn {\n\t\t\t$,\n\t\t\tvolumeName: processVolumeName(title, $(\"h2\").text()),\n\t\t\tvolumeId: parseVolumeOrChapterId($(\"h2 a\").attr(\"href\") ?? \"\"),\n\t\t\tvolumeCover: $(\"a.volume-cover img\").attr(\"data-original\") ?? \"\",\n\t\t\tchapterEls: $(\"ul.chapter-list li a\").toArray(),\n\t\t};\n\t});\n\n\tfor (let vIndex = 0; vIndex < parsedVolumes.length; vIndex++) {\n\t\tconst vData = parsedVolumes[vIndex];\n\t\tif (!vData) {\n\t\t\tcontinue;\n\t\t}\n\t\tconst chapters: Chapter[] = [];\n\n\t\tfor (let cIndex = 0; cIndex < vData.chapterEls.length; cIndex++) {\n\t\t\tconst chapterEl = vData.chapterEls[cIndex];\n\t\t\tif (!chapterEl) {\n\t\t\t\tcontinue; // 这个章节节点不存在,跳过\n\t\t\t}\n\t\t\tconst $chapter = cheerio.load(chapterEl);\n\n\t\t\tconst chapterName = $chapter.text().trim();\n\t\t\tconst chapterPath = chapterEl.attribs.href ?? \"\";\n\t\t\tconst chapterId = parseVolumeOrChapterId(chapterPath);\n\n\t\t\tconst chapterObj: Chapter = {\n\t\t\t\tid: chapterId,\n\t\t\t\tplatform: \"linovelib\",\n\t\t\t\ttitle: chapterName,\n\t\t\t\tvolumeId: vData.volumeId,\n\t\t\t};\n\t\t\tchapters.push(chapterObj);\n\t\t\tflatChapters.push({\n\t\t\t\tchapter: chapterObj,\n\t\t\t\tvIndex,\n\t\t\t\tcIndex: chapters.length - 1,\n\t\t\t});\n\t\t}\n\n\t\tvolumes.push({\n\t\t\tid: vData.volumeId,\n\t\t\tplatform: \"linovelib\",\n\t\t\ttitle: vData.volumeName,\n\t\t\tcoverUrl: vData.volumeCover,\n\t\t\tchapters,\n\t\t});\n\t}\n\n\t// --- 第二步:两阶段双向推导隐藏章节 ID ---\n\tif (chapterQueue) {\n\t\t// 第一阶段:反向单跳推导(仅当紧邻下一章已有合法纯数字 ID 时请求)\n\t\tconst phase1Tasks: Array<Promise<void>> = [];\n\t\tfor (let i = 0; i < flatChapters.length; i++) {\n\t\t\tconst current = flatChapters[i];\n\t\t\tconst next = flatChapters[i + 1];\n\t\t\tif (\n\t\t\t\tcurrent &&\n\t\t\t\tnext &&\n\t\t\t\tcurrent.chapter.id === \"TOBEDETERMINED\" &&\n\t\t\t\t/^\\d+$/.test(next.chapter.id)\n\t\t\t) {\n\t\t\t\tconst nextChapterId = next.chapter.id;\n\t\t\t\tphase1Tasks.push(\n\t\t\t\t\t(async () => {\n\t\t\t\t\t\tconst realId = await parseChapterIdFromNextChapter(\n\t\t\t\t\t\t\tnovelId,\n\t\t\t\t\t\t\tnextChapterId,\n\t\t\t\t\t\t\tchapterQueue,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif (/^\\d+$/.test(realId) && realId !== nextChapterId) {\n\t\t\t\t\t\t\tcurrent.chapter.id = realId;\n\t\t\t\t\t\t}\n\t\t\t\t\t})(),\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (phase1Tasks.length > 0) {\n\t\t\tawait Promise.all(phase1Tasks);\n\t\t}\n\n\t\t// 第二阶段:正向链式推导兜底(按顺序从前往后解锁连续隐藏章节与全书末章)\n\t\tfor (let i = 0; i < flatChapters.length; i++) {\n\t\t\tconst current = flatChapters[i];\n\t\t\tconst prev = flatChapters[i - 1];\n\t\t\tif (\n\t\t\t\tcurrent &&\n\t\t\t\tprev &&\n\t\t\t\tcurrent.chapter.id === \"TOBEDETERMINED\" &&\n\t\t\t\t/^\\d+$/.test(prev.chapter.id)\n\t\t\t) {\n\t\t\t\tconst realId = await parseNextChapterIdFromPrevChapter(\n\t\t\t\t\tnovelId,\n\t\t\t\t\tprev.chapter.id,\n\t\t\t\t\tchapterQueue,\n\t\t\t\t);\n\t\t\t\tif (/^\\d+$/.test(realId) && realId !== prev.chapter.id) {\n\t\t\t\t\tcurrent.chapter.id = realId;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t// --- 第三步:未决章节唯一占位符兜底 ---\n\tfor (const entry of flatChapters) {\n\t\tif (entry.chapter.id === \"TOBEDETERMINED\" || entry.chapter.id === \"\") {\n\t\t\tentry.chapter.id = `TOBEDETERMINED_${entry.vIndex}_${entry.cIndex}`;\n\t\t}\n\t}\n\n\treturn volumes;\n}\n\nexport async function getNovelInfo(\n\tid: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n\tchapterQueue?: NovelChapterQueue,\n): Promise<Novel | undefined> {\n\tconst url = `https://www.linovelib.com/novel/${id}.html`;\n\tconst html = (\n\t\tawait fetchClient.text(url, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $ = cheerio.load(html);\n\tconst title = $(\"h1.book-name\").text().trim();\n\tconst coverUrl = $(\"div.book-img img\").attr(\"src\") || novelIdToCoverUrl(id);\n\tconst summary = (() => {\n\t\tconst $container = $(\".book-dec.Jbook-dec\").clone();\n\t\t$container.find(\".notice\").remove();\n\t\tconst paragraphs: string[] = [];\n\t\t$container\n\t\t\t.find(\"p\")\n\t\t\t.not(\".backupname\")\n\t\t\t.each((_, el) => {\n\t\t\t\tparagraphs.push($(el).text().trim());\n\t\t\t});\n\t\treturn paragraphs.join(\"\\n\");\n\t})();\n\tconst author = $(\"div.au-name a:first\").text().trim();\n\tconst status: NovelStatus = $(\"div.book-label a.state\")\n\t\t.text()\n\t\t.includes(\"完结\")\n\t\t? \"completed\"\n\t\t: \"ongoing\";\n\tconst genres = $(\"div.book-label span\")\n\t\t.children(\"a\")\n\t\t.map((_, el) => $(el).text())\n\t\t.toArray()\n\t\t.join(\",\");\n\tconst novel: Novel = {\n\t\tid,\n\t\tplatform: \"linovelib\",\n\t\ttitle,\n\t\tcoverUrl,\n\t\tsummary,\n\t\tauthor,\n\t\tstatus,\n\t\tgenres: genres.split(\",\").map((g) => g.trim()),\n\t\tvolumes: [], // Volumes and chapters will be fetched separately\n\t};\n\tnovel.volumes = (\n\t\tawait getNovelVolumes(\n\t\t\tid,\n\t\t\ttitle,\n\t\t\t`https://www.linovelib.com${$(\"a.read-btn\").attr(\"href\")}`,\n\t\t\tfetchClient,\n\t\t\tretry,\n\t\t\tchapterQueue,\n\t\t)\n\t).map((v) => {\n\t\tv.novelId = novel.id;\n\t\treturn v;\n\t});\n\treturn novel;\n}\n\nexport interface NovelUpdateInfo {\n\tcoverUrl: string;\n\tchapterCount: number;\n}\n\nexport async function getUpdateInfo(\n\tid: string,\n\tfetchClient: BrowserFetchClient,\n\tretry: RetryOptions,\n): Promise<NovelUpdateInfo | null> {\n\tconst url = `https://www.linovelib.com/novel/${id}.html`;\n\tconst html = (\n\t\tawait fetchClient.text(url, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $ = cheerio.load(html);\n\tif ($(\"h1.book-name\").length === 0) {\n\t\treturn null;\n\t}\n\tconst catalogUrl = `https://www.linovelib.com${$(\"a.read-btn\").attr(\"href\")}`;\n\tconst catalogHtml = (\n\t\tawait fetchClient.text(catalogUrl, {\n\t\t\tretry,\n\t\t})\n\t).data;\n\tconst $catalog = cheerio.load(catalogHtml);\n\tconst chapterCount = $catalog(\n\t\t\"#volume-list div.volume ul.chapter-list li a\",\n\t).length;\n\tconst coverUrl = $(\"div.book-img img\").attr(\"src\") || novelIdToCoverUrl(id);\n\treturn {\n\t\tcoverUrl,\n\t\tchapterCount,\n\t};\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport { load } from \"cheerio\";\nimport { extractVolumesArray, parseVolumeOrChapterId } from \"./novel\";\n\nexport function novelIdToCoverUrl(novelId: string): string {\n\tconst prefix = novelId.length > 3 ? novelId[0] : \"0\";\n\treturn `https://www.linovelib.com/files/article/image/${prefix}/${novelId}/${novelId}s.jpg`;\n}\n\nexport async function getNovelCoverUrl(\n\tid: string,\n\tfetchClient: BrowserFetchClient,\n): Promise<string> {\n\tconst novelUrl = `https://www.linovelib.com/novel/${id}.html`;\n\tconst html = await fetchClient.text(novelUrl);\n\tconst $ = load(html.data);\n\tconst coverUrl = $(\"div.book-img img\").attr(\"src\") || novelIdToCoverUrl(id);\n\treturn coverUrl;\n}\n\nexport async function getVolumeCoverUrl(\n\tid: string,\n\tnovelId: string,\n\tfetchClient: BrowserFetchClient,\n): Promise<string> {\n\tconst catalogUrl = `https://www.linovelib.com/novel/${novelId}/catalog`;\n\tconst html = await fetchClient.text(catalogUrl);\n\tconst $ = load(html.data);\n\tconst volumes = extractVolumesArray(html.data);\n\tconst volume = volumes.find((v) => {\n\t\tconst volumeId = parseVolumeOrChapterId(\n\t\t\t$(v).find(\"h2 a\").attr(\"href\") ?? \"\",\n\t\t);\n\t\treturn volumeId === id;\n\t});\n\tif (!volume) {\n\t\tthrow new Error(`Volume not found for ID: ${id}`);\n\t}\n\tconst coverUrl =\n\t\t$(volume).find(\"a.volume-cover img\").attr(\"data-original\") || \"\";\n\treturn coverUrl;\n}\n","import {\n\ttype BrowserFetchClient,\n\tCloudflareBlockError,\n\tdefaultRetryPolicy,\n\ttype RetryOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type { Novel } from \"@acanthis-dec/core\";\nimport PQueue from \"p-queue\";\nimport type { Logger } from \"winston\";\nimport { getNovelInfo, getUpdateInfo, type NovelUpdateInfo } from \"./novel\";\n\n/**\n * Simple backoff strategy for request rate limiting\n * - Normal delay: 500-1000ms random\n * - Failure delay: 8000ms (8 seconds)\n */\nclass SimpleBackoff {\n\treadonly NORMAL_DELAY_MIN = 500;\n\treadonly NORMAL_DELAY_MAX = 1000;\n\treadonly FAILURE_DELAY = 15000;\n\n\t/**\n\t * Get delay for normal (successful) operation\n\t * @returns Random delay in range [500, 1000]ms. If isMobile is true, returns random delay in range [2000, 5000]ms\n\t */\n\tgetDelayForSuccess(): number {\n\t\treturn (\n\t\t\tthis.NORMAL_DELAY_MIN +\n\t\t\tMath.random() * (this.NORMAL_DELAY_MAX - this.NORMAL_DELAY_MIN)\n\t\t);\n\t}\n}\n\nexport class NovelChapterQueue {\n\tprivate queue: PQueue;\n\tprivate client: BrowserFetchClient;\n\tprivate backoff: SimpleBackoff;\n\tprivate logger?: Logger | undefined;\n\tprivate lastFetchTime = 0;\n\n\tconstructor(client: BrowserFetchClient, logger?: Logger) {\n\t\tthis.queue = new PQueue({ concurrency: 1 });\n\t\tthis.client = client;\n\t\tthis.backoff = new SimpleBackoff();\n\t\tthis.logger = logger;\n\t\tthis.queue.addEventListener(\"add\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 任务已添加,当前排队数: ${this.queue.size} (等待中任务数: ${this.queue.pending})`,\n\t\t\t);\n\t\t});\n\t\tthis.queue.addEventListener(\"next\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 任务完成或超时,开始下一个任务。剩余:${this.queue.size} `,\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate async _sleep(ms: number) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, ms));\n\t}\n\n\tasync fetchChapterPart(url: string): Promise<string> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tconst delay = this.backoff.getDelayForSuccess();\n\t\t\tif (Date.now() - this.lastFetchTime < delay) {\n\t\t\t\tconst waitTime = delay - (Date.now() - this.lastFetchTime);\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelChapterQueue] 请求过快,等待 ${Math.floor(waitTime)}ms`,\n\t\t\t\t);\n\t\t\t\tawait this._sleep(waitTime);\n\t\t\t}\n\t\t\tconst match = url.match(/\\/novel\\/(\\d+)\\/(\\d+)(?:_(\\d+))?\\.html/);\n\t\t\tif (!match) {\n\t\t\t\tthrow new Error(`Invalid chapter URL: ${url}`);\n\t\t\t}\n\t\t\tconst novelId = match[1];\n\t\t\tconst chapterId = match[2];\n\t\t\tconst partId = match[3] || \"1\";\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 开始获取小说${novelId}章节${chapterId}的第${partId}部分内容`,\n\t\t\t);\n\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelChapterQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${Math.floor(this.backoff.FAILURE_DELAY / 1000)}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelChapterQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst content = (await this.client.text(url, { retry })).data ?? \"\";\n\t\t\tthis.lastFetchTime = Date.now();\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelChapterQueue] 小说${novelId}-章节${chapterId}_${partId} 获取成功。`,\n\t\t\t);\n\t\t\treturn content;\n\t\t});\n\t}\n}\n\nexport class NovelInfoQueue {\n\tprivate queue: PQueue;\n\tprivate client: BrowserFetchClient;\n\tprivate backoff: SimpleBackoff;\n\tprivate chapterQueue: NovelChapterQueue;\n\tprivate logger?: Logger | undefined;\n\tprivate lastFetchTime = 0;\n\n\tconstructor(\n\t\tclient: BrowserFetchClient,\n\t\tchapterQueue: NovelChapterQueue,\n\t\tlogger?: Logger,\n\t) {\n\t\tthis.queue = new PQueue({ concurrency: 1 });\n\t\tthis.client = client;\n\t\tthis.backoff = new SimpleBackoff();\n\t\tthis.chapterQueue = chapterQueue;\n\t\tthis.logger = logger;\n\t\tthis.queue.addEventListener(\"add\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 任务已添加,当前排队数: ${this.queue.size} (等待中任务数: ${this.queue.pending})`,\n\t\t\t);\n\t\t});\n\t\tthis.queue.addEventListener(\"next\", () => {\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 任务完成或超时,开始下一个任务。剩余:${this.queue.size} `,\n\t\t\t);\n\t\t});\n\t}\n\n\tprivate async _sleep(ms: number) {\n\t\treturn new Promise((resolve) => setTimeout(resolve, ms));\n\t}\n\n\tasync fetchNovelInfo(id: string): Promise<Novel> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tconst delay = this.backoff.getDelayForSuccess();\n\t\t\tif (Date.now() - this.lastFetchTime < delay) {\n\t\t\t\tconst waitTime = delay - (Date.now() - this.lastFetchTime);\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelInfoQueue] 请求过快,等待 ${Math.floor(waitTime)}ms`,\n\t\t\t\t);\n\t\t\t\tawait this._sleep(waitTime);\n\t\t\t}\n\t\t\tthis.logger?.debug(`[NovelInfoQueue] 开始获取小说${id}的信息`);\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${Math.floor(this.backoff.FAILURE_DELAY / 1000)}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst novel = await getNovelInfo(\n\t\t\t\tid,\n\t\t\t\tthis.client,\n\t\t\t\tretry,\n\t\t\t\tthis.chapterQueue,\n\t\t\t);\n\t\t\tif (!novel) {\n\t\t\t\tthrow new Error(`无法获取小说信息: ${id}`);\n\t\t\t}\n\t\t\tthis.logger?.debug(`[NovelInfoQueue] 小说${id} 信息获取成功。`);\n\t\t\tthis.lastFetchTime = Date.now();\n\t\t\treturn novel;\n\t\t});\n\t}\n\n\tasync fetchNovelUpdateInfo(id: string): Promise<NovelUpdateInfo | null> {\n\t\treturn await this.queue.add(async () => {\n\t\t\tconst delay = this.backoff.getDelayForSuccess();\n\t\t\tif (Date.now() - this.lastFetchTime < delay) {\n\t\t\t\tconst waitTime = delay - (Date.now() - this.lastFetchTime);\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelInfoQueue] 请求过快,等待 ${Math.floor(waitTime)}ms`,\n\t\t\t\t);\n\t\t\t\tawait this._sleep(waitTime);\n\t\t\t}\n\t\t\tthis.logger?.debug(\n\t\t\t\t`[NovelInfoQueue] 开始获取小说${id}的更新信息(封面和章节数)`,\n\t\t\t);\n\t\t\tconst retry: RetryOptions = {\n\t\t\t\tretries: 10,\n\t\t\t\tfactor: 2,\n\t\t\t\tminRetryDelayMs: 0,\n\t\t\t\tmaxRetryDelayMs: 0,\n\t\t\t\trandomize: false,\n\t\t\t\tonFailedAttempt: async (ctx) => {\n\t\t\t\t\tif (ctx.error instanceof CloudflareBlockError) {\n\t\t\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求被 Cloudflare 阻挡,错误信息: ${ctx.error.message}。正在等待 ${Math.floor(this.backoff.FAILURE_DELAY / 1000)}s 后重试...`,\n\t\t\t\t\t\t);\n\t\t\t\t\t\tawait this._sleep(this.backoff.FAILURE_DELAY);\n\t\t\t\t\t}\n\t\t\t\t\tif (ctx.attemptNumber >= (retry.retries ?? 3)) {\n\t\t\t\t\t\tthis.logger?.error(\n\t\t\t\t\t\t\t`[NovelInfoQueue] 请求重试次数已达上限 (${ctx.attemptNumber} 次),错误信息: ${ctx.error.message}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tshouldRetry: async (ctx) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tdefaultRetryPolicy(ctx) || ctx.error instanceof CloudflareBlockError\n\t\t\t\t\t);\n\t\t\t\t},\n\t\t\t};\n\n\t\t\tconst updateInfo = await getUpdateInfo(id, this.client, retry);\n\t\t\tif (!updateInfo) {\n\t\t\t\tthis.logger?.warn(\n\t\t\t\t\t`[NovelInfoQueue] 无法获取小说${id}的更新信息,可能是因为小说不存在或已被删除`,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tthis.logger?.debug(\n\t\t\t\t\t`[NovelInfoQueue] 小说${id} 更新信息获取成功。 封面: ${updateInfo.coverUrl}, 章节数: ${updateInfo.chapterCount}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tthis.lastFetchTime = Date.now();\n\t\t\treturn updateInfo;\n\t\t});\n\t}\n}\n","import type { NovelSearchResult } from \"@acanthis-dec/core\";\nimport type * as cheerio from \"cheerio\";\nimport { extractNovelIdFromUrl } from \"../utils\";\n\nexport function parseSearchHtml($: cheerio.CheerioAPI): NovelSearchResult[] {\n\tconst results: NovelSearchResult[] = [];\n\t$(\"div.search-html-box div.search-result-list\").each((_, el) => {\n\t\tconst $el = $(el);\n\t\tconst title = $el.find(\"h2\").text().trim();\n\t\tconst url = $el.find(\"h2 a\").attr(\"href\") || \"\";\n\t\tconst id = extractNovelIdFromUrl(url) ?? \"\";\n\t\tconst coverUrl = $el.find(\"img\").attr(\"src\") || \"\";\n\t\tresults.push({\n\t\t\ttitle,\n\t\t\tplatform: \"linovelib\",\n\t\t\tid,\n\t\t\tcoverUrl,\n\t\t});\n\t});\n\treturn results;\n}\n\nexport function parseBookHtml($: cheerio.CheerioAPI): NovelSearchResult {\n\treturn {\n\t\ttitle: $(\"h1.book-name\").text().trim(),\n\t\tplatform: \"linovelib\",\n\t\tid: extractNovelIdFromUrl($(\"meta[name=url]\").attr(\"content\") ?? \"\") || \"\",\n\t\tcoverUrl: $(\"div.book-img img\").attr(\"src\") || \"\",\n\t};\n}\n","import { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { decode as decodePng } from \"fast-png\";\nimport type { InferenceSession } from \"onnxruntime-node\";\n\nconst MODEL_FILENAME = \"captcha_cropped.onnx\";\nconst TARGET_HEIGHT = 64;\nconst CHARSET = [\n\t\"\",\n\t...\"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\",\n];\n\nlet sessionPromise: Promise<InferenceSession> | undefined;\n\nfunction moduleDirectory(): string {\n\treturn fileURLToPath(new URL(\".\", import.meta.url));\n}\n\n/**\n * 模型可能出现的几个位置:\n * - 环境变量显式指定(部署时最可靠)\n * - 与当前模块同级(api-server 打包后把模型拷到 dist 目录)\n * - 包内 dist/../assets(npm 发布形态 / linovelib tsdown 产物)\n * - 包内 src/search/../../assets(workspace 内直接执行 TS 源码)\n * - 进程工作目录(Docker 镜像内 /app/captcha_cropped.onnx)\n */\nfunction resolveModelPath(): string {\n\tconst candidates = [\n\t\tprocess.env.LINOVELIB_CAPTCHA_MODEL_PATH,\n\t\tjoin(moduleDirectory(), MODEL_FILENAME),\n\t\tjoin(moduleDirectory(), \"..\", \"assets\", MODEL_FILENAME),\n\t\tjoin(moduleDirectory(), \"..\", \"..\", \"assets\", MODEL_FILENAME),\n\t\tjoin(process.cwd(), MODEL_FILENAME),\n\t].filter((candidate): candidate is string => Boolean(candidate));\n\n\tfor (const candidate of candidates) {\n\t\tif (existsSync(candidate)) return candidate;\n\t}\n\n\tthrow new Error(\n\t\t`无法找到搜索验证码识别模型 ${MODEL_FILENAME},尝试过的路径: ${candidates.join(\", \")}`,\n\t);\n}\n\nasync function getSession(): Promise<InferenceSession> {\n\tif (!sessionPromise) {\n\t\tsessionPromise = (async () => {\n\t\t\tconst ort = await import(\"onnxruntime-node\");\n\t\t\t// 模型输出维度声明为动态,ONNX Runtime 会为 CTC 输出发出无害的 shape 警告,这里静音。\n\t\t\tort.env.logLevel = \"error\";\n\t\t\tconst model = await readFile(resolveModelPath());\n\t\t\treturn await ort.InferenceSession.create(model, {\n\t\t\t\texecutionProviders: [\"cpu\"],\n\t\t\t\tgraphOptimizationLevel: \"all\",\n\t\t\t\tintraOpNumThreads: 1,\n\t\t\t\tinterOpNumThreads: 1,\n\t\t\t});\n\t\t})();\n\t\tsessionPromise.catch(() => {\n\t\t\tsessionPromise = undefined;\n\t\t});\n\t}\n\treturn sessionPromise;\n}\n\ninterface DecodedImage {\n\twidth: number;\n\theight: number;\n\tchannels: number;\n\tdata: Uint8Array;\n}\n\n/**\n * 验证码字符使用高饱和度颜色绘制在浅色噪点背景上。\n * 直接转灰度会让部分颜色的字符与背景对比度不足,因此同时尝试多种通道变换,\n * 让模型对同一张图投票,可以明显降低误识别率。\n */\nfunction channelVariants(image: DecodedImage): Uint8Array[] {\n\tconst { width, height, channels, data } = image;\n\tconst total = width * height;\n\tconst saturation = new Uint8Array(total);\n\tconst maxChannel = new Uint8Array(total);\n\tconst minChannel = new Uint8Array(total);\n\n\tfor (let i = 0; i < total; i++) {\n\t\tconst offset = i * channels;\n\t\tconst r = data[offset] ?? 0;\n\t\tconst g = data[offset + 1] ?? r;\n\t\tconst b = data[offset + 2] ?? g;\n\t\tconst max = Math.max(r, g, b);\n\t\tconst min = Math.min(r, g, b);\n\t\tsaturation[i] = max - min;\n\t\tmaxChannel[i] = max;\n\t\tminChannel[i] = min;\n\t}\n\n\treturn [saturation, maxChannel, minChannel];\n}\n\nfunction resizeBilinear(\n\tsource: Uint8Array,\n\tsourceWidth: number,\n\tsourceHeight: number,\n\ttargetWidth: number,\n\ttargetHeight: number,\n): Uint8Array {\n\tconst output = new Uint8Array(targetWidth * targetHeight);\n\tconst scaleX = sourceWidth / targetWidth;\n\tconst scaleY = sourceHeight / targetHeight;\n\n\tfor (let y = 0; y < targetHeight; y++) {\n\t\tconst sourceY = Math.min(\n\t\t\tsourceHeight - 1,\n\t\t\tMath.max(0, (y + 0.5) * scaleY - 0.5),\n\t\t);\n\t\tconst y0 = Math.floor(sourceY);\n\t\tconst y1 = Math.min(sourceHeight - 1, y0 + 1);\n\t\tconst weightY = sourceY - y0;\n\n\t\tfor (let x = 0; x < targetWidth; x++) {\n\t\t\tconst sourceX = Math.min(\n\t\t\t\tsourceWidth - 1,\n\t\t\t\tMath.max(0, (x + 0.5) * scaleX - 0.5),\n\t\t\t);\n\t\t\tconst x0 = Math.floor(sourceX);\n\t\t\tconst x1 = Math.min(sourceWidth - 1, x0 + 1);\n\t\t\tconst weightX = sourceX - x0;\n\n\t\t\tconst topLeft = source[y0 * sourceWidth + x0] ?? 0;\n\t\t\tconst topRight = source[y0 * sourceWidth + x1] ?? topLeft;\n\t\t\tconst bottomLeft = source[y1 * sourceWidth + x0] ?? topLeft;\n\t\t\tconst bottomRight = source[y1 * sourceWidth + x1] ?? bottomLeft;\n\n\t\t\tconst top = topLeft + (topRight - topLeft) * weightX;\n\t\t\tconst bottom = bottomLeft + (bottomRight - bottomLeft) * weightX;\n\t\t\toutput[y * targetWidth + x] = Math.round(top + (bottom - top) * weightY);\n\t\t}\n\t}\n\n\treturn output;\n}\n\ninterface DecodedText {\n\ttext: string;\n\t/** CTC 每步最大概率的平均值,用于在多个通道变体之间择优。 */\n\tconfidence: number;\n}\n\nfunction decodeCtcOutput(\n\tdata: Float32Array,\n\tdims: readonly number[],\n): DecodedText {\n\tconst steps = dims[0] ?? 0;\n\tconst classes = dims[dims.length - 1] ?? 0;\n\tlet text = \"\";\n\tlet previous = -1;\n\tlet confidenceSum = 0;\n\n\tfor (let step = 0; step < steps; step++) {\n\t\tconst offset = step * classes;\n\t\tlet bestIndex = 0;\n\t\tlet bestValue = Number.NEGATIVE_INFINITY;\n\t\tfor (let index = 0; index < classes; index++) {\n\t\t\tconst value = data[offset + index] ?? Number.NEGATIVE_INFINITY;\n\t\t\tif (value > bestValue) {\n\t\t\t\tbestValue = value;\n\t\t\t\tbestIndex = index;\n\t\t\t}\n\t\t}\n\n\t\t// 对当前时间步做 softmax,取最大概率作为该步置信度。\n\t\tlet expSum = 0;\n\t\tfor (let index = 0; index < classes; index++) {\n\t\t\texpSum += Math.exp((data[offset + index] ?? 0) - bestValue);\n\t\t}\n\t\tconfidenceSum += expSum > 0 ? 1 / expSum : 0;\n\n\t\tif (bestIndex !== previous && bestIndex !== 0) {\n\t\t\ttext += CHARSET[bestIndex] ?? \"\";\n\t\t}\n\t\tprevious = bestIndex;\n\t}\n\n\treturn {\n\t\ttext,\n\t\tconfidence: steps > 0 ? confidenceSum / steps : 0,\n\t};\n}\n\nfunction chooseBest(decoded: DecodedText[]): DecodedText {\n\tconst fourCharacter = decoded.filter((item) => item.text.length === 4);\n\tif (fourCharacter.length === 0) {\n\t\treturn decoded.reduce((best, item) =>\n\t\t\titem.confidence > best.confidence ? item : best,\n\t\t);\n\t}\n\n\tconst votes = new Map<string, { count: number; confidence: number }>();\n\tfor (const item of fourCharacter) {\n\t\tconst current = votes.get(item.text);\n\t\tif (current) {\n\t\t\tcurrent.count += 1;\n\t\t\tcurrent.confidence = Math.max(current.confidence, item.confidence);\n\t\t} else {\n\t\t\tvotes.set(item.text, { count: 1, confidence: item.confidence });\n\t\t}\n\t}\n\n\tlet winner = fourCharacter[0] as DecodedText;\n\tlet winnerCount = -1;\n\tlet winnerConfidence = -1;\n\tfor (const [text, vote] of votes) {\n\t\tif (\n\t\t\tvote.count > winnerCount ||\n\t\t\t(vote.count === winnerCount && vote.confidence > winnerConfidence)\n\t\t) {\n\t\t\twinner = { text, confidence: vote.confidence };\n\t\t\twinnerCount = vote.count;\n\t\t\twinnerConfidence = vote.confidence;\n\t\t}\n\t}\n\treturn winner;\n}\n\n/**\n * 识别 linovelib 搜索验证码(4 位数字/字母图片)。\n * 使用 ddddocr 的 common_old 裁剪模型(MIT),见 assets/THIRD-PARTY-NOTICES.md。\n */\nexport async function solveCaptcha(\n\timage: Buffer | Uint8Array,\n): Promise<string> {\n\tconst decoded = decodePng(image) as unknown as DecodedImage;\n\tconst targetWidth = Math.round(\n\t\t(decoded.width * TARGET_HEIGHT) / decoded.height,\n\t);\n\tconst ort = await import(\"onnxruntime-node\");\n\tconst session = await getSession();\n\tconst inputName = session.inputNames[0];\n\tconst outputName = session.outputNames[0];\n\tif (!inputName || !outputName) {\n\t\tthrow new Error(\"验证码识别模型缺少输入或输出节点\");\n\t}\n\n\tconst decodedTexts: DecodedText[] = [];\n\tfor (const variant of channelVariants(decoded)) {\n\t\tconst resized = resizeBilinear(\n\t\t\tvariant,\n\t\t\tdecoded.width,\n\t\t\tdecoded.height,\n\t\t\ttargetWidth,\n\t\t\tTARGET_HEIGHT,\n\t\t);\n\t\tconst input = new Float32Array(resized.length);\n\t\tfor (let i = 0; i < resized.length; i++) {\n\t\t\tinput[i] = (resized[i] ?? 0) / 255;\n\t\t}\n\n\t\tconst result = await session.run({\n\t\t\t[inputName]: new ort.Tensor(\"float32\", input, [\n\t\t\t\t1,\n\t\t\t\t1,\n\t\t\t\tTARGET_HEIGHT,\n\t\t\t\ttargetWidth,\n\t\t\t]),\n\t\t});\n\t\tconst output = result[outputName];\n\t\tif (!output) {\n\t\t\tthrow new Error(\"验证码识别模型没有返回结果\");\n\t\t}\n\t\tdecodedTexts.push(\n\t\t\tdecodeCtcOutput(\n\t\t\t\toutput.data as Float32Array,\n\t\t\t\toutput.dims as readonly number[],\n\t\t\t),\n\t\t);\n\t}\n\n\tif (decodedTexts.length === 0) {\n\t\tthrow new Error(\"验证码识别失败:没有任何可用结果\");\n\t}\n\treturn chooseBest(decodedTexts).text;\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\nimport type { NovelSearchResult } from \"@acanthis-dec/core\";\nimport { Mutex } from \"async-mutex\";\nimport { load } from \"cheerio\";\nimport { solveCaptcha } from \"./captcha\";\nimport { parseBookHtml, parseSearchHtml } from \"./common\";\n\nconst SEARCH_URL = \"https://www.linovelib.com/S6/\";\nconst ORIGIN = \"https://www.linovelib.com\";\n\n/** 站点要求两次搜索 POST 之间至少间隔 5 秒,这里留一点余量。 */\nconst MIN_SEARCH_INTERVAL_MS = 5200;\nconst MAX_VERIFICATION_ATTEMPTS = 3;\nconst MAX_RATE_LIMIT_ATTEMPTS = 3;\nconst NEXT_PAGE_DELAY_MIN_MS = 300;\nconst NEXT_PAGE_DELAY_MAX_MS = 800;\n\nconst searchRequestHeaders = {\n\torigin: ORIGIN,\n\treferer: `${ORIGIN}/`,\n};\n\nconst searchRefererHeaders = {\n\torigin: ORIGIN,\n\treferer: SEARCH_URL,\n};\n\nfunction sleep(ms: number): Promise<void> {\n\treturn new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nfunction isVerificationPage(html: string): boolean {\n\treturn (\n\t\thtml.includes('name=\"search_challenge\"') ||\n\t\thtml.includes(\"<title>搜索验证</title>\")\n\t);\n}\n\nfunction isRateLimitedPage(html: string): boolean {\n\treturn html.includes(\"两次搜索的间隔时间不得少于\");\n}\n\nfunction isBookPage(html: string): boolean {\n\treturn html.includes(\"book-html-box\");\n}\n\n/** 搜索验证流程无法自动完成时抛出,便于上层区分站点验证码问题。 */\nexport class SearchVerificationError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"SearchVerificationError\";\n\t}\n}\n\nexport class SearchRateLimitError extends Error {\n\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"SearchRateLimitError\";\n\t}\n}\n\n/**\n * 新版搜索会话。\n *\n * 站点现状(2026-11):\n * - 未验证客户端 POST/GET 搜索页会返回「搜索验证」图片验证码页;\n * - 提交正确验证码后服务端会下发约 30 分钟有效的验证 cookie,期间搜索免验证;\n * - 两次搜索间隔不得少于 5 秒,否则返回错误页;\n * - 验证过期后任意搜索/翻页请求都会重新出现验证码页。\n *\n * 该类负责串行化搜索请求、维护最小搜索间隔、自动识别并提交验证码,并复用验证态。\n */\nexport class SearchSession {\n\tprivate readonly mutex = new Mutex();\n\tprivate lastSearchAt = 0;\n\n\tconstructor(private readonly fetchClient: BrowserFetchClient) {}\n\n\tasync search(keyword: string): Promise<NovelSearchResult[]> {\n\t\treturn await this.mutex.runExclusive(async () => {\n\t\t\tconst html = await this.requestSearch(keyword);\n\t\t\treturn await this.parseResults(html);\n\t\t});\n\t}\n\n\tprivate async parseResults(html: string): Promise<NovelSearchResult[]> {\n\t\tconst $ = load(html);\n\t\tif (isBookPage(html) && $(\"div.book-html-box\").length > 0) {\n\t\t\treturn [parseBookHtml($)];\n\t\t}\n\n\t\tconst results = parseSearchHtml($);\n\t\tconst totalPages = Number(\n\t\t\t$(\"em#pagestats\")\n\t\t\t\t.text()\n\t\t\t\t.match(/1\\/(\\d+)/)?.[1] ?? \"1\",\n\t\t);\n\t\tconst nextHref = $(\"a.next\").attr(\"href\");\n\t\tif (totalPages > 1 && nextHref) {\n\t\t\tresults.push(...(await this.collectNextPages(nextHref)));\n\t\t}\n\t\treturn results;\n\t}\n\n\tprivate async collectNextPages(\n\t\tstartHref: string,\n\t): Promise<NovelSearchResult[]> {\n\t\tconst results: NovelSearchResult[] = [];\n\t\tlet href: string | undefined = startHref;\n\n\t\twhile (href) {\n\t\t\tconst delay =\n\t\t\t\tNEXT_PAGE_DELAY_MIN_MS +\n\t\t\t\tMath.random() * (NEXT_PAGE_DELAY_MAX_MS - NEXT_PAGE_DELAY_MIN_MS);\n\t\t\tawait sleep(delay);\n\n\t\t\tconst html = await this.fetchPage(new URL(href, SEARCH_URL).toString());\n\t\t\tconst $ = load(html);\n\t\t\tresults.push(...parseSearchHtml($));\n\t\t\thref = $(\"a.next\").attr(\"href\") || undefined;\n\t\t}\n\n\t\treturn results;\n\t}\n\n\tprivate async fetchPage(url: string): Promise<string> {\n\t\tlet response = await this.fetchClient.text(url, {\n\t\t\theaders: searchRefererHeaders,\n\t\t});\n\t\tif (response.mimeType !== \"text/html\") {\n\t\t\tthrow new Error(`Unexpected response type: ${response.mimeType}`);\n\t\t}\n\t\tif (isVerificationPage(response.data)) {\n\t\t\t// 验证态过期:先完成验证,再重新获取目标页(验证响应固定是关键词第一页)。\n\t\t\tawait this.verifySearch(response.data);\n\t\t\tresponse = await this.fetchClient.text(url, {\n\t\t\t\theaders: searchRefererHeaders,\n\t\t\t});\n\t\t\tif (response.mimeType !== \"text/html\") {\n\t\t\t\tthrow new Error(`Unexpected response type: ${response.mimeType}`);\n\t\t\t}\n\t\t\tif (isVerificationPage(response.data)) {\n\t\t\t\tthrow new SearchVerificationError(\"搜索验证后翻页仍被要求验证\");\n\t\t\t}\n\t\t}\n\t\tif (response.data === \"\") {\n\t\t\tthrow new Error(\"Empty response body when fetching search page\");\n\t\t}\n\t\treturn response.data;\n\t}\n\n\tprivate async requestSearch(keyword: string): Promise<string> {\n\t\tfor (let attempt = 0; attempt < MAX_RATE_LIMIT_ATTEMPTS; attempt++) {\n\t\t\tawait this.waitForSearchSlot();\n\t\t\tconst response = await this.fetchClient.text(SEARCH_URL, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: new URLSearchParams({\n\t\t\t\t\tsearchkey: keyword,\n\t\t\t\t}),\n\t\t\t\theaders: searchRequestHeaders,\n\t\t\t});\n\t\t\tthis.lastSearchAt = Date.now();\n\n\t\t\tif (response.mimeType !== \"text/html\") {\n\t\t\t\tthrow new Error(`Unexpected response type: ${response.mimeType}`);\n\t\t\t}\n\t\t\tif (response.data === \"\") {\n\t\t\t\tthrow new Error(\"Empty response body when fetching search results\");\n\t\t\t}\n\t\t\tif (isRateLimitedPage(response.data)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (isVerificationPage(response.data)) {\n\t\t\t\treturn await this.verifySearch(response.data);\n\t\t\t}\n\t\t\treturn response.data;\n\t\t}\n\n\t\tthrow new SearchRateLimitError(\n\t\t\t`搜索请求被站点限流,已重试 ${MAX_RATE_LIMIT_ATTEMPTS} 次`,\n\t\t);\n\t}\n\n\tprivate async verifySearch(verificationHtml: string): Promise<string> {\n\t\tlet currentHtml = verificationHtml;\n\n\t\tfor (let attempt = 0; attempt < MAX_VERIFICATION_ATTEMPTS; attempt++) {\n\t\t\tconst $ = load(currentHtml);\n\t\t\tconst challenge = $(\"input[name=search_challenge]\").attr(\"value\");\n\t\t\tconst searchkey = $(\"input[name=searchkey]\").attr(\"value\");\n\t\t\tconst searchtype = $(\"input[name=searchtype]\").attr(\"value\") ?? \"all\";\n\t\t\tconst imageSrc = $(\"#search-captcha\").attr(\"src\");\n\n\t\t\tif (!challenge || !imageSrc || !searchkey) {\n\t\t\t\tthrow new SearchVerificationError(\"无法解析搜索验证码页面\");\n\t\t\t}\n\n\t\t\tconst image = await this.fetchClient.binary(\n\t\t\t\tnew URL(imageSrc, SEARCH_URL).toString(),\n\t\t\t\t{ headers: searchRefererHeaders },\n\t\t\t);\n\t\t\tif (!image.mimeType.startsWith(\"image/\")) {\n\t\t\t\tthrow new SearchVerificationError(\n\t\t\t\t\t`验证码图片响应类型异常: ${image.mimeType}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tlet code: string;\n\t\t\ttry {\n\t\t\t\tcode = await solveCaptcha(image.data);\n\t\t\t} catch (error) {\n\t\t\t\tthrow new SearchVerificationError(\n\t\t\t\t\t`验证码识别失败: ${error instanceof Error ? error.message : String(error)}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tawait this.waitForSearchSlot();\n\t\t\tconst response = await this.fetchClient.text(SEARCH_URL, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\tbody: new URLSearchParams({\n\t\t\t\t\tsearchkey,\n\t\t\t\t\tsearchtype,\n\t\t\t\t\tsearch_challenge: challenge,\n\t\t\t\t\tsearch_code: code,\n\t\t\t\t}),\n\t\t\t\theaders: searchRefererHeaders,\n\t\t\t});\n\t\t\tthis.lastSearchAt = Date.now();\n\n\t\t\tif (response.mimeType !== \"text/html\") {\n\t\t\t\tthrow new Error(`Unexpected response type: ${response.mimeType}`);\n\t\t\t}\n\n\t\t\tif (!isVerificationPage(response.data)) {\n\t\t\t\treturn response.data;\n\t\t\t}\n\t\t\t// 验证码错误或过期,页面会带上一张新的验证码,换一张重试。\n\t\t\tcurrentHtml = response.data;\n\t\t}\n\n\t\tthrow new SearchVerificationError(\n\t\t\t`搜索验证码连续识别失败(已尝试 ${MAX_VERIFICATION_ATTEMPTS} 次)`,\n\t\t);\n\t}\n\n\tprivate async waitForSearchSlot(): Promise<void> {\n\t\tconst elapsed = Date.now() - this.lastSearchAt;\n\t\tif (elapsed < MIN_SEARCH_INTERVAL_MS) {\n\t\t\tawait sleep(MIN_SEARCH_INTERVAL_MS - elapsed);\n\t\t}\n\t}\n}\n\nexport async function searchNovelsV3(\n\tkeyword: string,\n\t_fetchClient: BrowserFetchClient,\n\tsession: SearchSession,\n): Promise<NovelSearchResult[]> {\n\treturn await session.search(keyword);\n}\n","import type { BrowserFetchClient } from \"@acanthis-dec/browser-fetch\";\n\nexport interface LoginConfig {\n\tusername: string;\n\tpassword: string;\n}\n\nexport async function refreshSessionId(\n\tfetchClient: BrowserFetchClient,\n\tloginConfig: LoginConfig,\n): Promise<boolean> {\n\tawait fetchClient.request({\n\t\turl: \"https://www.linovelib.com/login.php\",\n\t\tmethod: \"GET\",\n\t\theaders: {\n\t\t\treferer: \"https://www.linovelib.com/\",\n\t\t},\n\t});\n\tconst response = await fetchClient.request({\n\t\turl: \"https://www.linovelib.com/login.php?do=submit&jumpurl=https%3A%2F%2Fwww.linovelib.com%2F\",\n\t\tmethod: \"POST\",\n\t\tbody: new URLSearchParams({\n\t\t\tusername: loginConfig.username,\n\t\t\tpassword: loginConfig.password,\n\t\t\tusecookie: \"3153600000\",\n\t\t\tsubmit: \"登录\",\n\t\t\taction: \"login\",\n\t\t}),\n\t\tfollowRedirects: false,\n\t});\n\treturn (\n\t\tresponse.cookies.findIndex((cookie) => cookie.name === \"PHPSESSID\") !== -1\n\t);\n}\n\nexport async function hasValidSession(\n\tfetchClient: BrowserFetchClient,\n): Promise<boolean> {\n\tconst response = await fetchClient.text(\"https://www.linovelib.com\");\n\tif (response.data.includes(\"用户中心\")) return true;\n\telse return false;\n}\n\nexport async function ensureValidSession(\n\tfetchClient: BrowserFetchClient,\n\tloginConfig: LoginConfig,\n): Promise<boolean> {\n\tif (!(await hasValidSession(fetchClient))) {\n\t\tconst isValid =\n\t\t\t(await refreshSessionId(fetchClient, loginConfig)) &&\n\t\t\t(await hasValidSession(fetchClient));\n\t\tif (!isValid) {\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n","import {\n\ttype BinaryResponse,\n\tBrowserFetchClient,\n\ttype BrowserFetchClientOptions,\n\ttype BrowserProfileName,\n\ttype FlareSolverrOptions,\n} from \"@acanthis-dec/browser-fetch\";\nimport type {\n\tDescrambleCoefficients,\n\tNovel,\n\tNovelSearchResult,\n} from \"@acanthis-dec/core\";\nimport type { StorageService } from \"@acanthis-dec/storage\";\nimport { deepmerge } from \"deepmerge-ts\";\nimport type { Logger } from \"winston\";\nimport z from \"zod\";\nimport { getChapter } from \"./chapter\";\nimport { descrambleCoefficientsSchema } from \"./coefficients\";\nimport { getVolumeCoverUrl, novelIdToCoverUrl } from \"./cover\";\nimport type { NovelUpdateInfo } from \"./novel\";\nimport { NovelChapterQueue, NovelInfoQueue } from \"./queue\";\nimport { SearchSession, searchNovels } from \"./search\";\nimport { ensureValidSession } from \"./session\";\n\nexport type SessionOptions =\n\t| {\n\t\t\tenabled: false;\n\t }\n\t| {\n\t\t\tenabled: true;\n\t\t\tusername: string;\n\t\t\tpassword: string;\n\t };\n\nexport type ImpersonateOptions =\n\t| {\n\t\t\tenabled: true;\n\t\t\tprofile: BrowserProfileName;\n\t }\n\t| {\n\t\t\tenabled: false;\n\t };\n\nexport type CookieStoreOptions =\n\t| {\n\t\t\ttype: \"memory\" | \"database\";\n\t }\n\t| {\n\t\t\ttype: \"file\";\n\t\t\tpath: string;\n\t };\n\nexport type LinovelibClientOptions = {\n\tsession: SessionOptions;\n\tflareSolverr: FlareSolverrOptions;\n\timpersonate: ImpersonateOptions;\n\tcookies: CookieStoreOptions;\n\tproxy?: string | undefined;\n};\n\nexport class LinovelibClient {\n\tprivate storage?: StorageService | undefined;\n\tprivate fetchClient: BrowserFetchClient;\n\tprivate novelChapterQueue: NovelChapterQueue;\n\tprivate novelInfoQueue: NovelInfoQueue;\n\tprivate searchSession: SearchSession;\n\tprivate options?: LinovelibClientOptions;\n\tprivate logger?: Logger | undefined;\n\tprivate isSessionValid?: boolean = undefined;\n\n\tconstructor(\n\t\toptions?: LinovelibClientOptions,\n\t\tstorage?: StorageService,\n\t\tlogger?: Logger,\n\t) {\n\t\tconst defaultOptions: LinovelibClientOptions = {\n\t\t\tsession: {\n\t\t\t\tenabled: false,\n\t\t\t},\n\t\t\tflareSolverr: {\n\t\t\t\tenabled: true,\n\t\t\t\thost: \"http://localhost:8191\",\n\t\t\t\ttimeoutMs: 60000,\n\t\t\t\tsessionId: \"acanthis-linovelib-client\",\n\t\t\t},\n\t\t\timpersonate: {\n\t\t\t\tenabled: true,\n\t\t\t\tprofile: \"chrome-latest-linux\",\n\t\t\t},\n\t\t\tcookies: {\n\t\t\t\ttype: \"memory\",\n\t\t\t},\n\t\t};\n\t\tthis.options = deepmerge(\n\t\t\tdefaultOptions,\n\t\t\toptions ?? {},\n\t\t) as LinovelibClientOptions;\n\t\tthis.storage = storage;\n\t\tthis.logger = logger;\n\t\tconst browserFetchOptions: BrowserFetchClientOptions = {};\n\t\tif (this.options?.flareSolverr.enabled) {\n\t\t\tbrowserFetchOptions.flareSolverr = {\n\t\t\t\tenabled: true,\n\t\t\t\thost: this.options.flareSolverr.host,\n\t\t\t\ttimeoutMs: this.options.flareSolverr.timeoutMs ?? 60000,\n\t\t\t\tsessionId:\n\t\t\t\t\tthis.options.flareSolverr.sessionId ?? \"acanthis-linovelib-client\",\n\t\t\t};\n\t\t} else {\n\t\t\tbrowserFetchOptions.flareSolverr = {\n\t\t\t\tenabled: false,\n\t\t\t};\n\t\t}\n\t\tif (this.options?.proxy) {\n\t\t\tbrowserFetchOptions.proxy = this.options.proxy;\n\t\t}\n\t\tif (this.options?.impersonate.enabled) {\n\t\t\tbrowserFetchOptions.profile = this.options.impersonate.profile;\n\t\t}\n\t\tswitch (this.options?.cookies.type) {\n\t\t\tcase \"memory\":\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"memory\",\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"file\":\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"file\",\n\t\t\t\t\tpath: this.options.cookies.path,\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tcase \"database\":\n\t\t\t\tif (!this.storage) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"StorageService is required for database cookie store\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"custom\",\n\t\t\t\t\tstore: this.storage.getCookieStore(),\n\t\t\t\t};\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbrowserFetchOptions.cookieStore = {\n\t\t\t\t\ttype: \"memory\",\n\t\t\t\t};\n\t\t}\n\t\tthis.fetchClient = new BrowserFetchClient(browserFetchOptions);\n\t\tthis.novelChapterQueue = new NovelChapterQueue(\n\t\t\tthis.fetchClient,\n\t\t\tthis.logger,\n\t\t);\n\t\tthis.novelInfoQueue = new NovelInfoQueue(\n\t\t\tthis.fetchClient,\n\t\t\tthis.novelChapterQueue,\n\t\t\tthis.logger,\n\t\t);\n\t\tthis.searchSession = new SearchSession(this.fetchClient);\n\t}\n\n\tasync getNovelInfo(id: string): Promise<Novel | undefined> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await this.novelInfoQueue.fetchNovelInfo(id);\n\t}\n\n\tasync getNovelUpdateInfo(id: string): Promise<NovelUpdateInfo | null> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await this.novelInfoQueue.fetchNovelUpdateInfo(id);\n\t}\n\n\tasync searchNovels(keyword: string): Promise<NovelSearchResult[]> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await searchNovels(keyword, this.fetchClient, this.searchSession);\n\t}\n\n\tasync getNovelCover(\n\t\tid: string,\n\t): Promise<{ data: BinaryResponse; url: string }> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\tconst coverUrl = await novelIdToCoverUrl(id);\n\t\tconst coverData = await this.getCover(\n\t\t\tcoverUrl,\n\t\t\t`https://www.linovelib.com/novel/${id}.html`,\n\t\t);\n\t\treturn { data: coverData, url: coverUrl };\n\t}\n\n\tasync getVolumeCover(\n\t\tnovelId: string,\n\t\tvolumeId: string,\n\t): Promise<{ data: BinaryResponse; url: string }> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\tconst coverUrl = await getVolumeCoverUrl(\n\t\t\tvolumeId,\n\t\t\tnovelId,\n\t\t\tthis.fetchClient,\n\t\t);\n\t\tconst coverData = await this.getCover(\n\t\t\tcoverUrl,\n\t\t\t`https://www.linovelib.com/novel/${novelId}/catalog`,\n\t\t);\n\t\treturn { data: coverData, url: coverUrl };\n\t}\n\n\tasync getCover(url: string, referer?: string): Promise<BinaryResponse> {\n\t\treturn await this.fetchClient.binary(url, {\n\t\t\theaders: {\n\t\t\t\tReferer: referer || \"https://www.linovelib.com/\",\n\t\t\t},\n\t\t});\n\t}\n\n\tasync getIllustration(\n\t\turl: string,\n\t\treferer?: string,\n\t): Promise<BinaryResponse> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\treturn await this.getCover(url, referer || \"https://www.linovelib.com/\");\n\t}\n\n\tasync getChapter(\n\t\tnovelId: string,\n\t\tchapterId: string,\n\t): Promise<string | undefined> {\n\t\tif (this.options?.session.enabled && !this.isSessionValid) {\n\t\t\tthis.isSessionValid = await ensureValidSession(this.fetchClient, {\n\t\t\t\tusername: this.options.session.username,\n\t\t\t\tpassword: this.options.session.password,\n\t\t\t});\n\t\t}\n\t\tconst cachedJsVersion = this.storage\n\t\t\t? ((await this.storage.getCache(\"chapterlog_js_version\", z.string())) ??\n\t\t\t\tundefined)\n\t\t\t: undefined;\n\t\tconst cachedCoefficients = this.storage\n\t\t\t? ((await this.storage.getCache<DescrambleCoefficients>(\n\t\t\t\t\t\"coefficients\",\n\t\t\t\t\tdescrambleCoefficientsSchema,\n\t\t\t\t)) ?? undefined)\n\t\t\t: undefined;\n\t\tconst result = await getChapter(\n\t\t\tchapterId,\n\t\t\tnovelId,\n\t\t\tthis.novelChapterQueue,\n\t\t\tthis.fetchClient,\n\t\t\tcachedJsVersion,\n\t\t\tcachedCoefficients,\n\t\t);\n\t\tif (this.storage && result) {\n\t\t\tawait this.storage.setCache(\"chapterlog_js_version\", result.version);\n\t\t\tawait this.storage.setCache(\"coefficients\", result.coefficients);\n\t\t}\n\t\treturn result?.content;\n\t}\n}\n","import { load } from \"cheerio\";\n\nfunction normalizeIllustrationUrl(\n\trawSrc: string | undefined,\n): string | undefined {\n\tif (!rawSrc) {\n\t\treturn undefined;\n\t}\n\tconst trimmed = rawSrc.trim();\n\tif (!trimmed) {\n\t\treturn undefined;\n\t}\n\tconst normalized = trimmed.startsWith(\"//\") ? `https:${trimmed}` : trimmed;\n\tif (!normalized.startsWith(\"http://\") && !normalized.startsWith(\"https://\")) {\n\t\treturn undefined;\n\t}\n\treturn normalized;\n}\n\nexport function extractChapterIllustrationUrls(html: string): string[] {\n\tconst $ = load(html, null, false);\n\tconst urls = new Set<string>();\n\t$(\"img\").each((_, el) => {\n\t\tconst normalized = normalizeIllustrationUrl($(el).attr(\"src\"));\n\t\tif (normalized) {\n\t\t\turls.add(normalized);\n\t\t}\n\t});\n\treturn [...urls];\n}\n\nexport function rewriteChapterIllustrations(\n\thtml: string,\n\tmapUrl: (originalUrl: string) => string,\n): string {\n\tconst $ = load(html, null, false);\n\t$(\"img\").each((_, el) => {\n\t\tconst $el = $(el);\n\t\tconst normalized = normalizeIllustrationUrl($el.attr(\"src\"));\n\t\tif (normalized) {\n\t\t\t$el.attr(\"src\", mapUrl(normalized));\n\t\t}\n\t});\n\treturn $.html();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAWA,MAAM,WACJ,eAA6D,WAC9D;AAED,MAAa,+BAA+BA,IAAE,OAAO;CACpD,SAASA,IAAE,OAAO,CAAC,CAAC,IAAI;CACxB,WAAWA,IAAE,OAAO,CAAC,CAAC,IAAI;CAC1B,YAAYA,IAAE,OAAO,CAAC,CAAC,IAAI;CAC3B,YAAYA,IAAE,OAAO,CAAC,CAAC,IAAI;CAC3B,gBAAgBA,IAAE,OAAO,CAAC,CAAC,IAAI;AAChC,CAAC;AAED,SAAS,kBAAkB,UAA0B;CACpD,OAAO,SACL,MAAM,OAAO,CAAC,CACd,KAAK,SAAS,KAAK,KAAK,CAAC,CAAC,CAC1B,QAAQ,SAAS,SAAS,EAAE,CAAC,CAC7B,MAAM,EAAE,CAAC,CACT,KAAK,IAAI;AACZ;AAEA,eAAsB,oBACrB,QACkC;CAClC,MAAM,iBAAiB,kBAAkB,MAAM;CAC/C,MAAM,YAAY,MAAM,YAAY,cAAc;CAClD,MAAM,MAAM,MAAM,WAAW;EAAE,YAAY;EAAU,SAAS,CAAC,KAAK;CAAE,CAAC;CACvE,MAAM,eAAgD,CAAC;CACvD,SAAS,KAAK,EACb,iBAAiB,MAAM;EACtB,MAAM,EAAE,SAAS;EACjB,IACC,KAAK,aAAa,OAClB,EAAE,iBAAiB,KAAK,KAAK,KAC7B,EAAE,mBAAmB,KAAK,IAAI,KAC9B,KAAK,KAAK,aAAa,OACvB,EAAE,iBAAiB,KAAK,KAAK,KAAK,KAClC,EAAE,mBAAmB,KAAK,KAAK,IAAI,KACnC,KAAK,KAAK,KAAK,aAAa,OAC5B,EAAE,iBAAiB,KAAK,KAAK,KAAK,KAAK,GACtC;GACD,aAAa,UAAU,KAAK,MAAM;GAClC,MAAM,WAAW,KAAK;GACtB,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GAC3B,MAAM,KAAK,QAAQ,SAAS,yBAAyB,OAAO,OAAO;GACnE,MAAM,KAAK,QAAQ,SAAS,gBAAgB,OAAO,YAAY;EAChE;EACA,OAAO,QAAQ;CAChB;AACD;;AC1RA,SAAS,yBACR,QACqB;CACrB,IAAI,CAAC,QACJ;CAED,MAAM,UAAU,OAAO,KAAK;CAC5B,IAAI,CAAC,SACJ;CAED,MAAM,aAAa,QAAQ,WAAW,IAAI,IAAI,SAAS,YAAY;CACnE,IAAI,CAAC,WAAW,WAAW,SAAS,KAAK,CAAC,WAAW,WAAW,UAAU,GACzE;CAED,OAAO;AACR;AAEA,SAAgB,+BAA+B,MAAwB;CACtE,MAAM,IAAI,KAAK,MAAM,MAAM,KAAK;CAChC,MAAM,uBAAO,IAAI,IAAY;CAC7B,EAAE,KAAK,CAAC,CAAC,MAAM,GAAG,OAAO;EACxB,MAAM,aAAa,yBAAyB,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC;EAC7D,IAAI,YACH,KAAK,IAAI,UAAU;CAErB,CAAC;CACD,OAAO,CAAC,GAAG,IAAI;AAChB;AAEA,SAAgB,4BACf,MACA,QACS;CACT,MAAM,IAAI,KAAK,MAAM,MAAM,KAAK;CAChC,EAAE,KAAK,CAAC,CAAC,MAAM,GAAG,OAAO;EACxB,MAAM,MAAM,EAAE,EAAE;EAChB,MAAM,aAAa,yBAAyB,IAAI,KAAK,KAAK,CAAC;EAC3D,IAAI,YACH,IAAI,KAAK,OAAO,OAAO,UAAU,CAAC;CAEpC,CAAC;CACD,OAAO,EAAE,KAAK;AACf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@acanthis-dec/linovelib",
3
- "version": "1.1.2",
3
+ "version": "1.3.0",
4
4
  "description": "An Acanthis adapter for Linovelib site.",
5
5
  "author": "ConstasJ <constasj@qq.com>",
6
6
  "license": "MIT",
@@ -13,6 +13,7 @@
13
13
  },
14
14
  "files": [
15
15
  "dist",
16
+ "assets",
16
17
  "package.json",
17
18
  "README.md",
18
19
  "README.zh-CN.md"
@@ -26,29 +27,31 @@
26
27
  "url": "https://github.com/ConstasJ/Acanthis/issues"
27
28
  },
28
29
  "dependencies": {
29
- "@babel/parser": "^7.29.7",
30
- "@babel/traverse": "^7.29.7",
31
- "@babel/types": "^7.29.7",
30
+ "@acanthis-dec/browser-fetch": "1.1.2",
31
+ "@acanthis-dec/core": "1.2.0",
32
+ "@acanthis-dec/deobfuscator": "1.0.2",
33
+ "@acanthis-dec/storage": "1.1.0",
34
+ "@babel/parser": "^8.1.2",
35
+ "@babel/traverse": "^8.1.2",
36
+ "@babel/types": "^8.1.2",
32
37
  "async-mutex": "^0.5.0",
33
38
  "cheerio": "^1.2.0",
34
- "deepmerge-ts": "^7.1.5",
35
- "p-queue": "^9.3.0",
39
+ "deepmerge-ts": "^8.0.2",
40
+ "fast-png": "^8.0.0",
41
+ "onnxruntime-node": "^1.31.1",
42
+ "p-queue": "^10.0.0",
36
43
  "winston": "^3.19.0",
37
- "zod": "^4.4.3",
38
- "@acanthis-dec/browser-fetch": "1.1.1",
39
- "@acanthis-dec/core": "1.1.0",
40
- "@acanthis-dec/deobfuscator": "1.0.2",
41
- "@acanthis-dec/storage": "1.0.7"
44
+ "zod": "^4.6.7"
42
45
  },
43
46
  "devDependencies": {
47
+ "@acanthis-dec/config-tsdown": "1.0.0",
48
+ "@acanthis-dec/config-typescript": "1.0.0",
44
49
  "@types/babel__traverse": "^7.28.0",
45
- "@types/node": "25.9.2",
50
+ "@types/node": "26.6.6",
46
51
  "domhandler": "^6.0.1",
47
- "tsdown": "0.22.2",
48
- "tsx": "4.22.4",
49
- "typescript": "6.0.3",
50
- "@acanthis-dec/config-tsdown": "1.0.0",
51
- "@acanthis-dec/config-typescript": "1.0.0"
52
+ "tsdown": "0.23.7",
53
+ "tsx": "4.23.15",
54
+ "typescript": "7.0.2"
52
55
  },
53
56
  "scripts": {
54
57
  "build": "tsdown",