@jayyuen66/dsh-scrapling 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/client.js CHANGED
@@ -5,7 +5,7 @@ window.__ModuleLoader__.load({
5
5
  "use strict";
6
6
  var module = { exports: {} };
7
7
  var exports = module.exports;
8
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("zod");const n=e=>e.length>0&&!(e in Object.prototype);function r(e,t,n){n===void 0?e[t]=void 0:Object.defineProperty(e,t,n)}function i(e,t,i){if(!n(t))throw Error(`claimApply 的 flag 不得为空、也不得命中 Object.prototype 的成员(__proto__ 一类会让占位静默失灵或遮蔽全局成员):${t}`);let a=globalThis,o=Object.hasOwn(a,t)?a[t]:void 0;if(o===!0||typeof o==`symbol`)return!1;let s=Object.getOwnPropertyDescriptor(a,t),c=Symbol(t);a[t]=c;try{e.effect(()=>()=>{a[t]===c&&r(a,t,s)},i)}catch(e){throw a[t]===c&&r(a,t,s),e}return!0}function a(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const o=[{id:`runtime`,title:{zh:`运行环境`,en:`Runtime`},note:{zh:`Python 与数据目录。装完 scrapling 之后这里一般不用动。`,en:`Python and the data directory. Usually untouched once scrapling is installed.`},fields:[{key:`pythonBin`,kind:`text`,label:{zh:`Python 解释器`,en:`Python interpreter`},hint:{zh:`留空:先用仓内 _env/.venv(装了才用),否则用 PATH 上的 python3(Windows 上是 python);装了 pyenv/conda 时填绝对路径。`,en:`Empty: use the repo's _env/.venv when it exists, else python3 from PATH (python on Windows); give an absolute path under pyenv/conda.`},fallback:``},{key:`failFastOnMissingPython`,kind:`boolean`,label:{zh:`Python 缺失时拒绝加载`,en:`Fail fast without Python`},hint:{zh:`开:Python 起不来就不注册任何工具并报错。关:只警告,工具全部消失。`,en:`On: register nothing and error out. Off: warn and register nothing.`},fallback:!0},{key:`dataDir`,kind:`text`,label:{zh:`数据目录`,en:`Data directory`},hint:{zh:`留空用 ~/.dsh-scrapling;选择器自愈的指纹库落在这里,需要可写。`,en:`Leave empty for ~/.dsh-scrapling; the adaptive selector store lives here and must be writable.`},fallback:``}]},{id:`tools`,title:{zh:`工具开关`,en:`Tools`},note:{zh:`关掉的工具不会注册给模型,也不会在会话提示里占位置。`,en:`A disabled tool is never registered with the model and leaves the system prompt too.`},fields:[{key:`fetchEnabled`,kind:`boolean`,label:{zh:`scrapling_fetch`,en:`scrapling_fetch`},hint:{zh:`curl_cffi 静态抓取。`,en:`Static fetching over curl_cffi.`},fallback:!0},{key:`extractEnabled`,kind:`boolean`,label:{zh:`scrapling_extract`,en:`scrapling_extract`},hint:{zh:`对给定 HTML 做选择器抽取,不发请求。`,en:`Extract from given HTML without any request.`},fallback:!0},{key:`locateEnabled`,kind:`boolean`,label:{zh:`scrapling_locate`,en:`scrapling_locate`},hint:{zh:`按文本、正则或相似元素定位,返回可复用的选择器。`,en:`Locate by text, regex, or similar elements and return reusable selectors.`},fallback:!0},{key:`linksEnabled`,kind:`boolean`,label:{zh:`scrapling_links`,en:`scrapling_links`},hint:{zh:`列出页面链接与下一页候选。`,en:`List page links and next-page candidates.`},fallback:!0},{key:`renderEnabled`,kind:`boolean`,label:{zh:`scrapling_render`,en:`scrapling_render`},hint:{zh:`Playwright 渲染,能读 SPA。`,en:`Playwright rendering; reads SPAs.`},fallback:!0},{key:`captureXhrEnabled`,kind:`boolean`,label:{zh:`scrapling_capture_xhr`,en:`scrapling_capture_xhr`},hint:{zh:`只回传 XHR 的 URL/状态/字节数;站点数据在接口里时用它找那个接口。`,en:`Returns XHR url/status/bytes only — use it to locate the JSON endpoint.`},fallback:!0},{key:`networkEnabled`,kind:`boolean`,label:{zh:`scrapling_session_network`,en:`scrapling_session_network`},hint:{zh:`读已开会话攒下的网络历史;会话需先用 recordNetwork 打开记录。`,en:`Read a session's recorded network history; the session must have recordNetwork on.`},fallback:!0},{key:`sessionEnabled`,kind:`boolean`,label:{zh:`scrapling_session_*`,en:`scrapling_session_*`},hint:{zh:`跨请求复用 cookie 与浏览器实例,只管 open / fetch / list / close 这一组;network 与 state_* 各自有独立开关。`,en:`Reuse cookies and the browser across requests; covers open / fetch / list / close only. The network and state_* groups have their own switches.`},fallback:!0},{key:`sessionStateEnabled`,kind:`boolean`,label:{zh:`scrapling_session_state_*`,en:`scrapling_session_state_*`},hint:{zh:`存/取浏览器登录态;需部署侧配好 sessionStateDir。`,en:`Save/load browser login state; needs a deployment-side sessionStateDir.`},fallback:!0},{key:`crawlEnabled`,kind:`boolean`,label:{zh:`scrapling_crawl`,en:`scrapling_crawl`},hint:{zh:`后台 Spider 作业,只守起始域;需 profile 带作业后端。`,en:`Background spider jobs confined to the start domain; needs a jobs backend.`},fallback:!0},{key:`answerEnabled`,kind:`boolean`,label:{zh:`scrapling_answer`,en:`scrapling_answer`},hint:{zh:`抓完页面交给模型问答。`,en:`Answer a question over a fetched page.`},fallback:!0},{key:`sessionReadEnabled`,kind:`boolean`,label:{zh:`scrapling_session_read`,en:`scrapling_session_read`},hint:{zh:`读浏览器会话当前页,不再发请求。`,en:`Read the current page of a browser session without another request.`},fallback:!0},{key:`sessionActionsEnabled`,kind:`boolean`,label:{zh:`scrapling_session_act`,en:`scrapling_session_act`},hint:{zh:`结构化浏览器动作;还要部署侧打开 allowBrowserActions。`,en:`Structured browser actions; the deployment must also set allowBrowserActions.`},fallback:!0},{key:`downloadEnabled`,kind:`boolean`,label:{zh:`scrapling_download`,en:`scrapling_download`},hint:{zh:`下载文件到插件目录;还要部署侧打开 allowFileDownloads。`,en:`Download files into the plugin directory; the deployment must also set allowFileDownloads.`},fallback:!0},{key:`screenshotEnabled`,kind:`boolean`,label:{zh:`scrapling_screenshot`,en:`scrapling_screenshot`},hint:{zh:`页面截图;没有 attachment 服务时不注册。`,en:`Page screenshots; not registered when no attachment service is mounted.`},fallback:!0}]},{id:`output`,title:{zh:`抽取与输出`,en:`Extraction & output`},note:{zh:`这几个数字直接决定模型每轮看到多少 token。`,en:`These numbers are the per-call token bill the model pays.`},fields:[{key:`extractionType`,kind:`enum`,label:{zh:`默认抽取形态`,en:`Default extraction`},hint:{zh:`markdown 最省 token;html 保留标签;text 只留文字。`,en:`markdown is cheapest; html keeps tags; text keeps words only.`},fallback:`markdown`,options:[`markdown`,`html`,`text`]},{key:`mainContentOnly`,kind:`boolean`,label:{zh:`只保留正文`,en:`Main content only`},hint:{zh:`去掉导航、页脚、侧栏。开:更短更干净;关:要连同导航、按钮这类页面控件一起抓时用。`,en:`Drop nav/footer/sidebar. On for shorter output; off when you need page chrome.`},fallback:!0},{key:`fetchMaxOutputChars`,kind:`number`,label:{zh:`静态抓取正文上限`,en:`fetch output cap`},hint:{zh:`预算按 UTF-8 字节计,超出部分截断并标注;同一数值也作为 sidecar 的字符上限,最终取更紧的一档。`,en:`UTF-8 bytes; the payload is clipped and flagged. The same value also caps sidecar characters, so the tighter limit wins.`},fallback:2e5},{key:`extractMaxOutputChars`,kind:`number`,label:{zh:`抽取结果上限`,en:`extract output cap`},hint:{zh:`预算按 UTF-8 字节计;同一数值也作为 sidecar 的字符上限。`,en:`UTF-8 bytes; the same value also caps sidecar characters.`},fallback:2e5},{key:`renderMaxOutputChars`,kind:`number`,label:{zh:`渲染结果上限`,en:`render output cap`},hint:{zh:`预算按 UTF-8 字节计;会话类工具共用这一档,同一数值也作为 sidecar 的字符上限。`,en:`UTF-8 bytes; the session tools share this budget, and the same value also caps sidecar characters.`},fallback:2e5},{key:`xhrMaxOutputChars`,kind:`number`,label:{zh:`XHR 快照上限`,en:`XHR snapshot cap`},hint:{zh:`预算按 UTF-8 字节计;同一数值也作为 sidecar 的字符上限。`,en:`UTF-8 bytes; the same value also caps sidecar characters.`},fallback:12e4},{key:`crawlMaxItems`,kind:`number`,label:{zh:`爬虫默认页数上限`,en:`Crawl page cap`},hint:{zh:`爬虫工具每次调用的默认上限,模型可按次调小。`,en:`Default per-call page cap; the model may lower it per call.`},fallback:1e3},{key:`stripInlineImages`,kind:`boolean`,label:{zh:`剥掉内嵌 base64 图片`,en:`Strip inline base64 images`},hint:{zh:`默认开。内嵌 data: URI 图片对模型是纯 token 噪音——模型从 base64 里读不出任何图形信息,只留 alt 文本;代码围栏内的原样保留。没有内联图的页面不受影响。要从 base64 里取配色或指纹这类原始数据时才关掉。`,en:`On by default. Inline data: URI images are pure token noise - the model cannot read a shape out of base64, so only the alt text is kept; ones inside code fences are left alone. Pages without inline images are unaffected. Turn it off to read the raw base64 (colours, fingerprints).`},fallback:!0}]},{id:`browser`,title:{zh:`浏览器行为`,en:`Browser behaviour`},note:{zh:`只在渲染 / XHR 两条路径上生效。`,en:`Only affects the render / XHR paths.`},fields:[{key:`headless`,kind:`boolean`,label:{zh:`无头运行`,en:`Headless`},hint:{zh:`关掉会弹出浏览器窗口,反检测站点上成功率更高。`,en:`Off shows a window and beats more anti-bot checks.`},fallback:!0},{key:`networkIdle`,kind:`boolean`,label:{zh:`等网络静默`,en:`Wait for network idle`},hint:{zh:`等到没有在途请求再返回。更准,但慢;埋了长连接的站点可能一直等不到。`,en:`Wait until no requests are in flight. Slower, and pages with long-lived sockets never settle.`},fallback:!1},{key:`blockAds`,kind:`boolean`,label:{zh:`拦截广告与追踪`,en:`Block ads and trackers`},hint:{zh:`约 3500 个已知广告域。省流量,偶尔误伤。`,en:`~3,500 known ad domains. Saves bandwidth, occasionally over-blocks.`},fallback:!0},{key:`pierceShadow`,kind:`boolean`,label:{zh:`穿透 Shadow DOM`,en:`Pierce Shadow DOM`},hint:{zh:`把 open shadow root 里的内容并进正文,默认关;页面把正文封进 shadow DOM 时才打开。`,en:`Merge open shadow root content into the body; off by default. On when a page hides its content in shadow DOM.`},fallback:!1},{key:`waitSelectorState`,kind:`enum`,label:{zh:`等待选择器的状态`,en:`Wait selector state`},hint:{zh:`配 waitSelector 用;attached 最宽松。`,en:`Used with waitSelector; attached is the loosest.`},fallback:`attached`,options:[`attached`,`detached`,`hidden`,`visible`]}]},{id:`timeouts`,title:{zh:`超时与回收`,en:`Timeouts & teardown`},note:{zh:`抓取慢若不在这几项里,先看页面上要等的东西。`,en:`If a fetch is slow for a reason other than these, look at what the page waits for.`},fields:[{key:`fetchTimeoutMs`,kind:`number`,label:{zh:`单次抓取超时(毫秒)`,en:`Per-fetch timeout (ms)`},hint:{zh:`同时是工具的超时预算与 Python 侧的请求上限。`,en:`Also the tool budget and the Python-side request cap.`},fallback:12e4},{key:`sidecarHandshakeTimeoutMs`,kind:`number`,label:{zh:`sidecar 握手超时(毫秒)`,en:`Handshake timeout (ms)`},hint:{zh:`冷启动要拉起一个 Python 进程并导入 Scrapling。`,en:`Cold start spawns a Python process and imports Scrapling.`},fallback:3e4},{key:`sidecarGraceMs`,kind:`number`,label:{zh:`退出宽限(毫秒)`,en:`Shutdown grace (ms)`},hint:{zh:`插件卸载后等 Python 收尾的时间。`,en:`How long Python gets to finish after the plugin unloads.`},fallback:5e3}]},{id:`network`,title:{zh:`网络与安全`,en:`Network & safety`},note:{zh:`通常什么都不用填:TUN 模式的代理由系统接管,环境里的 HTTPS_PROXY 与 macOS / Windows 的「系统代理」都会被自动接上。`,en:`Usually nothing to fill: a TUN-mode proxy is taken from the system, and both HTTPS_PROXY in the environment and the macOS / Windows system proxy are picked up automatically.`},fields:[{key:`proxyUrl`,kind:`text`,format:`url`,secret:!0,label:{zh:`代理地址`,en:`Proxy URL`},hint:{zh:`如 http://127.0.0.1:7890 或 socks5://127.0.0.1:7890,可带 user:pass@。留空=依次跟随环境变量与系统代理设置;填了就压过那两者。值按密码遮罩显示,点「显示」可查看。`,en:`e.g. http://127.0.0.1:7890 or socks5://127.0.0.1:7890, user:pass@ allowed. Empty follows the environment and then the OS proxy settings; setting it outranks both. Masked like a password; press Show to reveal it.`},fallback:``},{key:`proxyBypass`,kind:`text`,label:{zh:`代理绕过清单`,en:`Proxy bypass`},hint:{zh:`逗号分隔的主机名,命中即直连;内网站点要填。整台机器直连填 *。浏览器会话不逐条生效(它的代理在开场时定死)。`,en:`Comma-separated hostnames that connect directly; list your internal sites. Use * for the whole machine. Not applied per URL inside a browser session (its proxy is fixed at open).`},fallback:``},{key:`syntheticDnsRanges`,kind:`text`,label:{zh:`合成 DNS 段(兜底)`,en:`Synthetic DNS ranges (fallback)`},hint:{zh:`平时留空:fake-ip 型代理由系统自动认出,这里只用于识别失灵时。列进来的段等于放弃对它们的 SSRF 防护。`,en:`Leave empty: fake-ip resolvers are detected automatically. Only for detection failures. Listed ranges give up SSRF protection.`},fallback:``},{key:`allowedHosts`,kind:`text`,label:{zh:`额外放行的内网主机`,en:`Extra allowed hosts`},hint:{zh:`逗号分隔。指到内网等于主动放弃对那些目标的 SSRF 防护,只在真要抓自建站点时填。`,en:`Comma-separated. Pointing these at internal hosts gives up SSRF protection for them — only for self-hosted targets.`},fallback:``},{key:`nat64Prefixes`,kind:`text`,label:{zh:`额外 NAT64 前缀`,en:`Extra NAT64 prefixes`},hint:{zh:`用运营商自建 NAT64 的网络才需要,形如 2001:4860:4860::/96。`,en:`Only for carrier-grade NAT64 networks, e.g. 2001:4860:4860::/96.`},fallback:``},{key:`provideWebFetch`,kind:`boolean`,label:{zh:`接管内置 web_fetch`,en:`Provide the built-in web_fetch`},hint:{zh:`默认开;部署配置里仍要写 fetchProvider: "scrapling",否则 base bundle 那条 fetchProvider: http 仍然赢。`,en:`On by default; the deployment config still needs fetchProvider: "scrapling", otherwise the base bundle's fetchProvider: http wins.`},fallback:!0},{key:`provideWebSearch`,kind:`boolean`,label:{zh:`接管内置 web_search`,en:`Provide the built-in web_search`},hint:{zh:`默认开;部署配置里仍要写 searchProvider: "scrapling",否则不会接管。`,en:`On by default; the deployment config still needs searchProvider: "scrapling", otherwise it does not take over.`},fallback:!0},{key:`searchBackend`,kind:`enum`,options:[`auto`,`tavily`,`bing`,`brave`,`serper`,`duckduckgo`,`searxng`],label:{zh:`搜索发现后端`,en:`Search discovery backend`},hint:{zh:`auto 有 Tavily key 走 Tavily、配了 SearXNG 走 SearXNG;两者都没有时,只有打开「允许公共搜索回退」才走公共引擎(DuckDuckGo → Bing)。只有 Tavily 与 Bing 打过真实端点;其余四条按文档形状实现,真实 key 未验。`,en:`auto uses Tavily when a key is set, SearXNG when an instance is configured; with neither, only "Allow public search fallback" routes to public engines (DuckDuckGo → Bing). Only Tavily and Bing have been run against the real endpoints; the other four follow their documented shapes and are unverified with real keys.`},fallback:`auto`},{key:`searchPublicFallback`,kind:`boolean`,label:{zh:`允许公共搜索回退`,en:`Allow public search fallback`},hint:{zh:`默认关。打开后 auto 后端在没配 key、也没配 SearXNG 时会回落到 DuckDuckGo/Bing —— 查询词会发给公共引擎。`,en:`Off by default. When enabled, the auto backend falls back to DuckDuckGo/Bing if no API key or SearXNG is configured — queries are then sent to public engines.`},fallback:!1},{key:`tavilyApiKey`,kind:`text`,secret:!0,label:{zh:`Tavily API key`,en:`Tavily API key`},hint:{zh:`Tavily 后端必填;没配时 search 报 SEARCH_AUTH,不会静默换后端。`,en:`Required by the Tavily backend; without it search reports SEARCH_AUTH instead of silently switching backends.`},fallback:``},{key:`braveApiKey`,kind:`text`,secret:!0,label:{zh:`Brave Search API key`,en:`Brave Search API key`},hint:{zh:`Brave 后端必填;没配时 search 报 SEARCH_AUTH。`,en:`Required by the Brave backend; without it search reports SEARCH_AUTH.`},fallback:``},{key:`serperApiKey`,kind:`text`,secret:!0,label:{zh:`Serper API key`,en:`Serper API key`},hint:{zh:`Serper 后端必填;没配时 search 报 SEARCH_AUTH。`,en:`Required by the Serper backend; without it search reports SEARCH_AUTH.`},fallback:``},{key:`searxngEndpoint`,kind:`text`,format:`url`,label:{zh:`SearXNG 实例地址`,en:`SearXNG instance URL`},hint:{zh:`SearXNG 后端必填,例如 https://searx.example.com;会拼上 /search?format=json。留空表示这条后端不可用。`,en:`Required by the SearXNG backend, e.g. https://searx.example.com; /search?format=json is appended. Empty means the backend is unusable.`},fallback:``}]},{id:`answer`,title:{zh:`页面问答`,en:`Page Q&A`},note:{zh:`provider 与 model 留空跟随当前会话用的模型,不额外烧一份额度;token 上限留空用默认值。`,en:`provider and model blank follow the session's own model, costing no extra quota; the token cap falls back to its default.`},fields:[{key:`answerProvider`,kind:`text`,label:{zh:`回答用 provider`,en:`Answer provider`},hint:{zh:`留空跟随会话模型。`,en:`Blank follows the session model.`},fallback:``},{key:`answerModel`,kind:`text`,label:{zh:`回答用模型 id`,en:`Answer model id`},hint:{zh:`与 provider 一起生效。`,en:`Takes effect together with the provider.`},fallback:``},{key:`answerMaxTokens`,kind:`number`,label:{zh:`单次回答 token 上限`,en:`Answer token cap`},hint:{zh:`一次回答的输出预算。`,en:`Output budget per answer.`},fallback:2e3}]}],s=o.flatMap(e=>e.fields);s.map(e=>e.key);const c=`dshScrapling`,l={zh:{save:`保存`,saving:`保存中…`,undo:`撤销`,reveal:`显示`,conceal:`隐藏`,statusLoading:`正在读取设置…`,statusReadonly:`这个连接以只读方式运行,设置改不了。`,statusClean:`没有未保存的改动`,statusChanged:`已改动 {count} 项,未保存`,statusInvalid:`有 {count} 项填的不是合法数字,改好后才能保存`,rejected:`保存被宿主拒绝了,设置未改动`,stale:`设置已经被别处改过,请重新打开这张卡再保存`,failed:`保存失败:{reason}`,runtimeTitle:`运行环境`,runtimeHint:`能力包装在数据目录的 runtime/ 下;安装是后台作业,关掉这张卡也会继续。`,runtimeUnavailable:`宿主没有提供远程读面;请在终端运行:`,runtimeJobsMissing:`这个 profile 没有作业后端;请在终端运行:`,runtimeInstall:`安装`,runtimeRepair:`修复`,runtimeCancel:`取消`,runtimePython:`解释器`,runtimeDataDir:`数据目录`,runtimeJobRunning:`正在安装 {pack}…`,runtimeJobEnded:`安装结束:{status}`,runtimeError:`安装失败:{reason}`,"runtime.state.ready":`就绪`,"runtime.state.missing":`未安装`,"runtime.state.corrupt":`文件缺失`,"runtime.state.installing":`安装中`,"runtime.state.blocked":`暂不提供`,"runtime.pack.core":`核心(Python + Scrapling)`,"runtime.pack.browser":`完整 Chromium`,"runtime.pack.search":`搜索发现`,"runtime.pack.media":`截图与下载`,"runtime.pack.adaptive-redis":`自适应存储(Redis)`,"runtime.pack.mcp":`MCP(未验证)`},en:{save:`Save`,saving:`Saving…`,undo:`Undo`,reveal:`Show`,conceal:`Hide`,statusLoading:`Reading settings…`,statusReadonly:`This connection runs read-only; settings cannot be changed here.`,statusClean:`No unsaved changes`,statusChanged:`{count} change(s) not saved yet`,statusInvalid:`{count} field(s) are not valid numbers; fix them to save`,rejected:`The host refused the save; nothing changed`,stale:`Settings changed elsewhere; reopen this page before saving`,failed:`Save failed: {reason}`,runtimeTitle:`Runtime`,runtimeHint:`Capability packs live under runtime/ in the data directory; installs run as background jobs and keep going when this page closes.`,runtimeUnavailable:`The host offers no remote surface; run this in a terminal:`,runtimeJobsMissing:`This profile has no jobs backend; run this in a terminal:`,runtimeInstall:`Install`,runtimeRepair:`Repair`,runtimeCancel:`Cancel`,runtimePython:`Interpreter`,runtimeDataDir:`Data directory`,runtimeJobRunning:`Installing {pack}…`,runtimeJobEnded:`Install finished: {status}`,runtimeError:`Install failed: {reason}`,"runtime.state.ready":`Ready`,"runtime.state.missing":`Not installed`,"runtime.state.corrupt":`Files missing`,"runtime.state.installing":`Installing`,"runtime.state.blocked":`Unavailable`,"runtime.pack.core":`Core (Python + Scrapling)`,"runtime.pack.browser":`Full Chromium`,"runtime.pack.search":`Search discovery`,"runtime.pack.media":`Screenshots & downloads`,"runtime.pack.adaptive-redis":`Adaptive storage (Redis)`,"runtime.pack.mcp":`MCP (unverified)`}},u={zh:{"row.url":`URL`,"row.http":`HTTP`,"row.body":`正文`,"row.matched":`匹配`,"row.sessionCount":`会话数`,"row.session":`会话`,"row.name":`名称`,"row.type":`类型`,"row.start":`起始`,"row.pageCap":`上限`,"row.job":`作业`,"row.inspect":`在轨迹里查看`,"row.truncated":`已截断`},en:{"row.url":`URL`,"row.http":`HTTP`,"row.body":`Body`,"row.matched":`Matched`,"row.sessionCount":`Sessions`,"row.session":`Session`,"row.name":`Name`,"row.type":`Type`,"row.start":`Start`,"row.pageCap":`Page cap`,"row.job":`Job`,"row.inspect":`Inspect this call`,"row.truncated":`Truncated`}};function d(){let e={zh:{...l.zh,...u.zh},en:{...l.en,...u.en}};for(let t of o){e.zh[`group.${t.id}.title`]=t.title.zh,e.zh[`group.${t.id}.note`]=t.note.zh,e.en[`group.${t.id}.title`]=t.title.en,e.en[`group.${t.id}.note`]=t.note.en;for(let n of t.fields)e.zh[`field.${n.key}.label`]=n.label.zh,e.zh[`field.${n.key}.hint`]=n.hint.zh,e.en[`field.${n.key}.label`]=n.label.en,e.en[`field.${n.key}.hint`]=n.hint.en}return e}const f=[`core`,`browser`,`search`,`media`,`adaptive-redis`,`mcp`];new Set(f);function p(e){return`runtime.state.${e}`}function m(e){return`runtime.pack.${e}`}function h(e,t=30){return e.length<=t?{hint:e}:{detail:e}}function g(t){return(0,e.createElement)(`div`,{className:`dsu-form`},t.children)}function _(t){return(0,e.createElement)(`section`,{className:`dsu-section`},(0,e.createElement)(`h2`,{className:`dsu-sectionTitle`},t.title),t.hint===void 0?null:(0,e.createElement)(`p`,{className:`dsu-sectionHint`},t.hint),t.children)}function v(t){if(t.items.length===0)return null;let n=t.items.map((t,n)=>(0,e.createElement)(`span`,{key:n},n===0?t:`· ${t}`));return(0,e.createElement)(`div`,{className:`dsu-statusbar`},...n)}function y(t){let n=(0,e.useId)(),[r,i]=(0,e.useState)(!1),[a,o]=(0,e.useState)(!1),s=(0,e.useRef)(!1),c=(0,e.useRef)(!1),l=(0,e.useRef)(!1),u=(0,e.useRef)(null),d=(0,e.useRef)(null),f=(0,e.useRef)(null),p=(0,e.useCallback)(()=>{f.current!==null&&(clearTimeout(f.current),f.current=null)},[]),m=(0,e.useCallback)(()=>{let e=u.current,t=d.current;
8
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("react"),t=require("zod");const n=e=>e.length>0&&!(e in Object.prototype);function r(e,t,n){n===void 0?e[t]=void 0:Object.defineProperty(e,t,n)}function i(e,t,i){if(!n(t))throw Error(`claimApply 的 flag 不得为空、也不得命中 Object.prototype 的成员(__proto__ 一类会让占位静默失灵或遮蔽全局成员):${t}`);let a=globalThis,o=Object.hasOwn(a,t)?a[t]:void 0;if(o===!0||typeof o==`symbol`)return!1;let s=Object.getOwnPropertyDescriptor(a,t),c=Symbol(t);a[t]=c;try{e.effect(()=>()=>{a[t]===c&&r(a,t,s)},i)}catch(e){throw a[t]===c&&r(a,t,s),e}return!0}function a(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const o=[{id:`runtime`,title:{zh:`运行环境`,en:`Runtime`},note:{zh:`Python 与数据目录。装完 scrapling 之后这里一般不用动。`,en:`Python and the data directory. Usually untouched once scrapling is installed.`},fields:[{key:`pythonBin`,kind:`text`,label:{zh:`Python 解释器`,en:`Python interpreter`},hint:{zh:`留空:先用仓内 _env/.venv(装了才用),否则用 PATH 上的 python3(Windows 上是 python);装了 pyenv/conda 时填绝对路径。`,en:`Empty: use the repo's _env/.venv when it exists, else python3 from PATH (python on Windows); give an absolute path under pyenv/conda.`},fallback:``},{key:`failFastOnMissingPython`,kind:`boolean`,label:{zh:`Python 缺失时拒绝加载`,en:`Fail fast without Python`},hint:{zh:`开:Python 起不来就不注册任何工具并报错。关:只警告,工具全部消失。`,en:`On: register nothing and error out. Off: warn and register nothing.`},fallback:!0},{key:`dataDir`,kind:`text`,label:{zh:`数据目录`,en:`Data directory`},hint:{zh:`留空用 ~/.dsh-scrapling;选择器自愈的指纹库落在这里,需要可写。`,en:`Leave empty for ~/.dsh-scrapling; the adaptive selector store lives here and must be writable.`},fallback:``}]},{id:`tools`,title:{zh:`工具开关`,en:`Tools`},note:{zh:`关掉的工具不会注册给模型,也不会在会话提示里占位置。`,en:`A disabled tool is never registered with the model and leaves the system prompt too.`},fields:[{key:`fetchEnabled`,kind:`boolean`,label:{zh:`scrapling_fetch`,en:`scrapling_fetch`},hint:{zh:`curl_cffi 静态抓取。`,en:`Static fetching over curl_cffi.`},fallback:!0},{key:`extractEnabled`,kind:`boolean`,label:{zh:`scrapling_extract`,en:`scrapling_extract`},hint:{zh:`对给定 HTML 做选择器抽取,不发请求。`,en:`Extract from given HTML without any request.`},fallback:!0},{key:`locateEnabled`,kind:`boolean`,label:{zh:`scrapling_locate`,en:`scrapling_locate`},hint:{zh:`按文本、正则或相似元素定位,返回可复用的选择器。`,en:`Locate by text, regex, or similar elements and return reusable selectors.`},fallback:!0},{key:`linksEnabled`,kind:`boolean`,label:{zh:`scrapling_links`,en:`scrapling_links`},hint:{zh:`列出页面链接与下一页候选。`,en:`List page links and next-page candidates.`},fallback:!0},{key:`renderEnabled`,kind:`boolean`,label:{zh:`scrapling_render`,en:`scrapling_render`},hint:{zh:`Playwright 渲染,能读 SPA。`,en:`Playwright rendering; reads SPAs.`},fallback:!0},{key:`captureXhrEnabled`,kind:`boolean`,label:{zh:`scrapling_capture_xhr`,en:`scrapling_capture_xhr`},hint:{zh:`只回传 XHR 的 URL/状态/字节数;站点数据在接口里时用它找那个接口。`,en:`Returns XHR url/status/bytes only — use it to locate the JSON endpoint.`},fallback:!0},{key:`networkEnabled`,kind:`boolean`,label:{zh:`scrapling_session_network`,en:`scrapling_session_network`},hint:{zh:`读已开会话攒下的网络历史;会话需先用 recordNetwork 打开记录。`,en:`Read a session's recorded network history; the session must have recordNetwork on.`},fallback:!0},{key:`sessionEnabled`,kind:`boolean`,label:{zh:`scrapling_session_*`,en:`scrapling_session_*`},hint:{zh:`跨请求复用 cookie 与浏览器实例,只管 open / fetch / list / close 这一组;network 与 state_* 各自有独立开关。`,en:`Reuse cookies and the browser across requests; covers open / fetch / list / close only. The network and state_* groups have their own switches.`},fallback:!0},{key:`sessionStateEnabled`,kind:`boolean`,label:{zh:`scrapling_session_state_*`,en:`scrapling_session_state_*`},hint:{zh:`存/取浏览器登录态;需部署侧配好 sessionStateDir。`,en:`Save/load browser login state; needs a deployment-side sessionStateDir.`},fallback:!0},{key:`crawlEnabled`,kind:`boolean`,label:{zh:`scrapling_crawl`,en:`scrapling_crawl`},hint:{zh:`后台 Spider 作业,只守起始域;需 profile 带作业后端。`,en:`Background spider jobs confined to the start domain; needs a jobs backend.`},fallback:!0},{key:`answerEnabled`,kind:`boolean`,label:{zh:`scrapling_answer`,en:`scrapling_answer`},hint:{zh:`抓完页面交给模型问答。`,en:`Answer a question over a fetched page.`},fallback:!0},{key:`sessionReadEnabled`,kind:`boolean`,label:{zh:`scrapling_session_read`,en:`scrapling_session_read`},hint:{zh:`读浏览器会话当前页,不再发请求。`,en:`Read the current page of a browser session without another request.`},fallback:!0},{key:`sessionActionsEnabled`,kind:`boolean`,label:{zh:`scrapling_session_act`,en:`scrapling_session_act`},hint:{zh:`结构化浏览器动作;还要部署侧打开 allowBrowserActions。`,en:`Structured browser actions; the deployment must also set allowBrowserActions.`},fallback:!0},{key:`downloadEnabled`,kind:`boolean`,label:{zh:`scrapling_download`,en:`scrapling_download`},hint:{zh:`下载文件到插件目录;还要部署侧打开 allowFileDownloads。`,en:`Download files into the plugin directory; the deployment must also set allowFileDownloads.`},fallback:!0},{key:`screenshotEnabled`,kind:`boolean`,label:{zh:`scrapling_screenshot`,en:`scrapling_screenshot`},hint:{zh:`页面截图;没有 attachment 服务时不注册。`,en:`Page screenshots; not registered when no attachment service is mounted.`},fallback:!0}]},{id:`output`,title:{zh:`抽取与输出`,en:`Extraction & output`},note:{zh:`这几个数字直接决定模型每轮看到多少 token。`,en:`These numbers are the per-call token bill the model pays.`},fields:[{key:`extractionType`,kind:`enum`,label:{zh:`默认抽取形态`,en:`Default extraction`},hint:{zh:`markdown 最省 token;html 保留标签;text 只留文字。`,en:`markdown is cheapest; html keeps tags; text keeps words only.`},fallback:`markdown`,options:[`markdown`,`html`,`text`]},{key:`mainContentOnly`,kind:`boolean`,label:{zh:`只保留正文`,en:`Main content only`},hint:{zh:`去掉导航、页脚、侧栏。开:更短更干净;关:要连同导航、按钮这类页面控件一起抓时用。`,en:`Drop nav/footer/sidebar. On for shorter output; off when you need page chrome.`},fallback:!0},{key:`fetchMaxOutputChars`,kind:`number`,label:{zh:`静态抓取正文上限`,en:`fetch output cap`},hint:{zh:`预算按 UTF-8 字节计,超出部分截断并标注;同一数值也作为 sidecar 的字符上限,最终取更紧的一档。`,en:`UTF-8 bytes; the payload is clipped and flagged. The same value also caps sidecar characters, so the tighter limit wins.`},fallback:2e5},{key:`extractMaxOutputChars`,kind:`number`,label:{zh:`抽取结果上限`,en:`extract output cap`},hint:{zh:`预算按 UTF-8 字节计;同一数值也作为 sidecar 的字符上限。`,en:`UTF-8 bytes; the same value also caps sidecar characters.`},fallback:2e5},{key:`renderMaxOutputChars`,kind:`number`,label:{zh:`渲染结果上限`,en:`render output cap`},hint:{zh:`预算按 UTF-8 字节计;会话类工具共用这一档,同一数值也作为 sidecar 的字符上限。`,en:`UTF-8 bytes; the session tools share this budget, and the same value also caps sidecar characters.`},fallback:2e5},{key:`xhrMaxOutputChars`,kind:`number`,label:{zh:`XHR 快照上限`,en:`XHR snapshot cap`},hint:{zh:`预算按 UTF-8 字节计;同一数值也作为 sidecar 的字符上限。`,en:`UTF-8 bytes; the same value also caps sidecar characters.`},fallback:12e4},{key:`crawlMaxItems`,kind:`number`,label:{zh:`爬虫默认页数上限`,en:`Crawl page cap`},hint:{zh:`爬虫工具每次调用的默认上限,模型可按次调小。`,en:`Default per-call page cap; the model may lower it per call.`},fallback:1e3},{key:`stripInlineImages`,kind:`boolean`,label:{zh:`剥掉内嵌 base64 图片`,en:`Strip inline base64 images`},hint:{zh:`默认开。内嵌 data: URI 图片对模型是纯 token 噪音——模型从 base64 里读不出任何图形信息,只留 alt 文本;代码围栏内的原样保留。没有内联图的页面不受影响。要从 base64 里取配色或指纹这类原始数据时才关掉。`,en:`On by default. Inline data: URI images are pure token noise - the model cannot read a shape out of base64, so only the alt text is kept; ones inside code fences are left alone. Pages without inline images are unaffected. Turn it off to read the raw base64 (colours, fingerprints).`},fallback:!0}]},{id:`browser`,title:{zh:`浏览器行为`,en:`Browser behaviour`},note:{zh:`只在渲染 / XHR 两条路径上生效。`,en:`Only affects the render / XHR paths.`},fields:[{key:`headless`,kind:`boolean`,label:{zh:`无头运行`,en:`Headless`},hint:{zh:`关掉会弹出浏览器窗口,反检测站点上成功率更高。`,en:`Off shows a window and beats more anti-bot checks.`},fallback:!0},{key:`networkIdle`,kind:`boolean`,label:{zh:`等网络静默`,en:`Wait for network idle`},hint:{zh:`等到没有在途请求再返回。更准,但慢;埋了长连接的站点可能一直等不到。`,en:`Wait until no requests are in flight. Slower, and pages with long-lived sockets never settle.`},fallback:!1},{key:`blockAds`,kind:`boolean`,label:{zh:`拦截广告与追踪`,en:`Block ads and trackers`},hint:{zh:`约 3500 个已知广告域。省流量,偶尔误伤。`,en:`~3,500 known ad domains. Saves bandwidth, occasionally over-blocks.`},fallback:!0},{key:`pierceShadow`,kind:`boolean`,label:{zh:`穿透 Shadow DOM`,en:`Pierce Shadow DOM`},hint:{zh:`把 open shadow root 里的内容并进正文,默认关;页面把正文封进 shadow DOM 时才打开。`,en:`Merge open shadow root content into the body; off by default. On when a page hides its content in shadow DOM.`},fallback:!1},{key:`waitSelectorState`,kind:`enum`,label:{zh:`等待选择器的状态`,en:`Wait selector state`},hint:{zh:`配 waitSelector 用;attached 最宽松。`,en:`Used with waitSelector; attached is the loosest.`},fallback:`attached`,options:[`attached`,`detached`,`hidden`,`visible`]}]},{id:`timeouts`,title:{zh:`超时与回收`,en:`Timeouts & teardown`},note:{zh:`抓取慢若不在这几项里,先看页面上要等的东西。`,en:`If a fetch is slow for a reason other than these, look at what the page waits for.`},fields:[{key:`fetchTimeoutMs`,kind:`number`,label:{zh:`单次抓取超时(毫秒)`,en:`Per-fetch timeout (ms)`},hint:{zh:`同时是工具的超时预算与 Python 侧的请求上限。`,en:`Also the tool budget and the Python-side request cap.`},fallback:12e4},{key:`sidecarHandshakeTimeoutMs`,kind:`number`,label:{zh:`sidecar 握手超时(毫秒)`,en:`Handshake timeout (ms)`},hint:{zh:`冷启动要拉起一个 Python 进程并导入 Scrapling。`,en:`Cold start spawns a Python process and imports Scrapling.`},fallback:3e4},{key:`sidecarGraceMs`,kind:`number`,label:{zh:`退出宽限(毫秒)`,en:`Shutdown grace (ms)`},hint:{zh:`插件卸载后等 Python 收尾的时间。`,en:`How long Python gets to finish after the plugin unloads.`},fallback:5e3}]},{id:`network`,title:{zh:`网络与安全`,en:`Network & safety`},note:{zh:`通常什么都不用填:TUN 模式的代理由系统接管,环境里的 HTTPS_PROXY 与 macOS / Windows 的「系统代理」都会被自动接上。`,en:`Usually nothing to fill: a TUN-mode proxy is taken from the system, and both HTTPS_PROXY in the environment and the macOS / Windows system proxy are picked up automatically.`},fields:[{key:`proxyUrl`,kind:`text`,format:`url`,schemes:[`http:`,`https:`,`socks5:`,`socks5h:`],secret:!0,label:{zh:`代理地址`,en:`Proxy URL`},hint:{zh:`如 http://127.0.0.1:7890 或 socks5://127.0.0.1:7890,可带 user:pass@。留空=依次跟随环境变量与系统代理设置;填了就压过那两者。值按密码遮罩显示,点「显示」可查看。`,en:`e.g. http://127.0.0.1:7890 or socks5://127.0.0.1:7890, user:pass@ allowed. Empty follows the environment and then the OS proxy settings; setting it outranks both. Masked like a password; press Show to reveal it.`},fallback:``},{key:`proxyBypass`,kind:`text`,label:{zh:`代理绕过清单`,en:`Proxy bypass`},hint:{zh:`逗号分隔的主机名,命中即直连;内网站点要填。整台机器直连填 *。浏览器会话不逐条生效(它的代理在开场时定死)。`,en:`Comma-separated hostnames that connect directly; list your internal sites. Use * for the whole machine. Not applied per URL inside a browser session (its proxy is fixed at open).`},fallback:``},{key:`syntheticDnsRanges`,kind:`text`,label:{zh:`合成 DNS 段(兜底)`,en:`Synthetic DNS ranges (fallback)`},hint:{zh:`平时留空:fake-ip 型代理由系统自动认出,这里只用于识别失灵时。列进来的段等于放弃对它们的 SSRF 防护。`,en:`Leave empty: fake-ip resolvers are detected automatically. Only for detection failures. Listed ranges give up SSRF protection.`},fallback:``},{key:`allowedHosts`,kind:`text`,label:{zh:`额外放行的内网主机`,en:`Extra allowed hosts`},hint:{zh:`逗号分隔。指到内网等于主动放弃对那些目标的 SSRF 防护,只在真要抓自建站点时填。`,en:`Comma-separated. Pointing these at internal hosts gives up SSRF protection for them — only for self-hosted targets.`},fallback:``},{key:`nat64Prefixes`,kind:`text`,label:{zh:`额外 NAT64 前缀`,en:`Extra NAT64 prefixes`},hint:{zh:`用运营商自建 NAT64 的网络才需要,形如 2001:4860:4860::/96。`,en:`Only for carrier-grade NAT64 networks, e.g. 2001:4860:4860::/96.`},fallback:``},{key:`provideWebFetch`,kind:`boolean`,label:{zh:`接管内置 web_fetch`,en:`Provide the built-in web_fetch`},hint:{zh:`默认开;部署配置里仍要写 fetchProvider: "scrapling",否则 base bundle 那条 fetchProvider: http 仍然赢。`,en:`On by default; the deployment config still needs fetchProvider: "scrapling", otherwise the base bundle's fetchProvider: http wins.`},fallback:!0},{key:`provideWebSearch`,kind:`boolean`,label:{zh:`接管内置 web_search`,en:`Provide the built-in web_search`},hint:{zh:`默认开;部署配置里仍要写 searchProvider: "scrapling",否则不会接管。`,en:`On by default; the deployment config still needs searchProvider: "scrapling", otherwise it does not take over.`},fallback:!0},{key:`searchBackend`,kind:`enum`,options:[`auto`,`tavily`,`bing`,`brave`,`serper`,`duckduckgo`,`searxng`],label:{zh:`搜索发现后端`,en:`Search discovery backend`},hint:{zh:`auto 有 Tavily key 走 Tavily、配了 SearXNG 走 SearXNG;两者都没有时,只有打开「允许公共搜索回退」才走公共引擎(DuckDuckGo → Bing)。只有 Tavily 与 Bing 打过真实端点;其余四条按文档形状实现,真实 key 未验。`,en:`auto uses Tavily when a key is set, SearXNG when an instance is configured; with neither, only "Allow public search fallback" routes to public engines (DuckDuckGo → Bing). Only Tavily and Bing have been run against the real endpoints; the other four follow their documented shapes and are unverified with real keys.`},fallback:`auto`},{key:`searchPublicFallback`,kind:`boolean`,label:{zh:`允许公共搜索回退`,en:`Allow public search fallback`},hint:{zh:`默认关。打开后 auto 后端在没配 key、也没配 SearXNG 时会回落到 DuckDuckGo/Bing —— 查询词会发给公共引擎。`,en:`Off by default. When enabled, the auto backend falls back to DuckDuckGo/Bing if no API key or SearXNG is configured — queries are then sent to public engines.`},fallback:!1},{key:`tavilyApiKey`,kind:`text`,secret:!0,label:{zh:`Tavily API key`,en:`Tavily API key`},hint:{zh:`Tavily 后端必填;没配时 search 报 SEARCH_AUTH,不会静默换后端。`,en:`Required by the Tavily backend; without it search reports SEARCH_AUTH instead of silently switching backends.`},fallback:``},{key:`braveApiKey`,kind:`text`,secret:!0,label:{zh:`Brave Search API key`,en:`Brave Search API key`},hint:{zh:`Brave 后端必填;没配时 search 报 SEARCH_AUTH。`,en:`Required by the Brave backend; without it search reports SEARCH_AUTH.`},fallback:``},{key:`serperApiKey`,kind:`text`,secret:!0,label:{zh:`Serper API key`,en:`Serper API key`},hint:{zh:`Serper 后端必填;没配时 search 报 SEARCH_AUTH。`,en:`Required by the Serper backend; without it search reports SEARCH_AUTH.`},fallback:``},{key:`searxngEndpoint`,kind:`text`,format:`url`,schemes:[`http:`,`https:`],label:{zh:`SearXNG 实例地址`,en:`SearXNG instance URL`},hint:{zh:`SearXNG 后端必填,例如 https://searx.example.com;会拼上 /search?format=json。留空表示这条后端不可用。`,en:`Required by the SearXNG backend, e.g. https://searx.example.com; /search?format=json is appended. Empty means the backend is unusable.`},fallback:``}]},{id:`answer`,title:{zh:`页面问答`,en:`Page Q&A`},note:{zh:`provider 与 model 留空跟随当前会话用的模型,不额外烧一份额度;token 上限留空用默认值。`,en:`provider and model blank follow the session's own model, costing no extra quota; the token cap falls back to its default.`},fields:[{key:`answerProvider`,kind:`text`,label:{zh:`回答用 provider`,en:`Answer provider`},hint:{zh:`留空跟随会话模型。`,en:`Blank follows the session model.`},fallback:``},{key:`answerModel`,kind:`text`,label:{zh:`回答用模型 id`,en:`Answer model id`},hint:{zh:`与 provider 一起生效。`,en:`Takes effect together with the provider.`},fallback:``},{key:`answerMaxTokens`,kind:`number`,label:{zh:`单次回答 token 上限`,en:`Answer token cap`},hint:{zh:`一次回答的输出预算。`,en:`Output budget per answer.`},fallback:2e3}]}],s=o.flatMap(e=>e.fields);s.map(e=>e.key);const c=`dshScrapling`,l={zh:{save:`保存`,saving:`保存中…`,undo:`撤销`,reveal:`显示`,conceal:`隐藏`,statusLoading:`正在读取设置…`,statusReadonly:`这个连接以只读方式运行,设置改不了。`,statusClean:`没有未保存的改动`,statusChanged:`已改动 {count} 项,未保存`,statusInvalid:`有 {count} 项填的不是合法数字,改好后才能保存`,rejected:`保存被宿主拒绝了,设置未改动`,stale:`设置已经被别处改过,请重新打开这张卡再保存`,failed:`保存失败:{reason}`,runtimeTitle:`运行环境`,runtimeHint:`能力包装在数据目录的 runtime/ 下;安装是后台作业,关掉这张卡也会继续。`,runtimeUnavailable:`宿主没有提供远程读面;请在终端运行:`,runtimeJobsMissing:`这个 profile 没有作业后端;请在终端运行:`,runtimeInstall:`安装`,runtimeRepair:`修复`,runtimeCancel:`取消`,runtimePython:`解释器`,runtimeDataDir:`数据目录`,runtimeJobRunning:`正在安装 {pack}…`,runtimeJobEnded:`安装结束:{status}`,runtimeError:`安装失败:{reason}`,"runtime.state.ready":`就绪`,"runtime.state.missing":`未安装`,"runtime.state.corrupt":`文件缺失`,"runtime.state.installing":`安装中`,"runtime.state.blocked":`暂不提供`,"runtime.pack.core":`核心(Python + Scrapling)`,"runtime.pack.browser":`完整 Chromium`,"runtime.pack.search":`搜索发现`,"runtime.pack.media":`截图与下载`,"runtime.pack.adaptive-redis":`自适应存储(Redis)`,"runtime.pack.mcp":`MCP(未验证)`},en:{save:`Save`,saving:`Saving…`,undo:`Undo`,reveal:`Show`,conceal:`Hide`,statusLoading:`Reading settings…`,statusReadonly:`This connection runs read-only; settings cannot be changed here.`,statusClean:`No unsaved changes`,statusChanged:`{count} change(s) not saved yet`,statusInvalid:`{count} field(s) are not valid numbers; fix them to save`,rejected:`The host refused the save; nothing changed`,stale:`Settings changed elsewhere; reopen this page before saving`,failed:`Save failed: {reason}`,runtimeTitle:`Runtime`,runtimeHint:`Capability packs live under runtime/ in the data directory; installs run as background jobs and keep going when this page closes.`,runtimeUnavailable:`The host offers no remote surface; run this in a terminal:`,runtimeJobsMissing:`This profile has no jobs backend; run this in a terminal:`,runtimeInstall:`Install`,runtimeRepair:`Repair`,runtimeCancel:`Cancel`,runtimePython:`Interpreter`,runtimeDataDir:`Data directory`,runtimeJobRunning:`Installing {pack}…`,runtimeJobEnded:`Install finished: {status}`,runtimeError:`Install failed: {reason}`,"runtime.state.ready":`Ready`,"runtime.state.missing":`Not installed`,"runtime.state.corrupt":`Files missing`,"runtime.state.installing":`Installing`,"runtime.state.blocked":`Unavailable`,"runtime.pack.core":`Core (Python + Scrapling)`,"runtime.pack.browser":`Full Chromium`,"runtime.pack.search":`Search discovery`,"runtime.pack.media":`Screenshots & downloads`,"runtime.pack.adaptive-redis":`Adaptive storage (Redis)`,"runtime.pack.mcp":`MCP (unverified)`}},u={zh:{"row.url":`URL`,"row.http":`HTTP`,"row.body":`正文`,"row.matched":`匹配`,"row.sessionCount":`会话数`,"row.session":`会话`,"row.name":`名称`,"row.type":`类型`,"row.start":`起始`,"row.pageCap":`上限`,"row.job":`作业`,"row.inspect":`在轨迹里查看`,"row.truncated":`已截断`},en:{"row.url":`URL`,"row.http":`HTTP`,"row.body":`Body`,"row.matched":`Matched`,"row.sessionCount":`Sessions`,"row.session":`Session`,"row.name":`Name`,"row.type":`Type`,"row.start":`Start`,"row.pageCap":`Page cap`,"row.job":`Job`,"row.inspect":`Inspect this call`,"row.truncated":`Truncated`}};function d(){let e={zh:{...l.zh,...u.zh},en:{...l.en,...u.en}};for(let t of o){e.zh[`group.${t.id}.title`]=t.title.zh,e.zh[`group.${t.id}.note`]=t.note.zh,e.en[`group.${t.id}.title`]=t.title.en,e.en[`group.${t.id}.note`]=t.note.en;for(let n of t.fields)e.zh[`field.${n.key}.label`]=n.label.zh,e.zh[`field.${n.key}.hint`]=n.hint.zh,e.en[`field.${n.key}.label`]=n.label.en,e.en[`field.${n.key}.hint`]=n.hint.en}return e}const f=[`core`,`browser`,`search`,`media`,`adaptive-redis`,`mcp`];new Set(f);function p(e){return`runtime.state.${e}`}function m(e){return`runtime.pack.${e}`}function h(e,t=30){return e.length<=t?{hint:e}:{detail:e}}function g(t){return(0,e.createElement)(`div`,{className:`dsu-form`},t.children)}function _(t){return(0,e.createElement)(`section`,{className:`dsu-section`},(0,e.createElement)(`h2`,{className:`dsu-sectionTitle`},t.title),t.hint===void 0?null:(0,e.createElement)(`p`,{className:`dsu-sectionHint`},t.hint),t.children)}function v(t){if(t.items.length===0)return null;let n=t.items.map((t,n)=>(0,e.createElement)(`span`,{key:n},n===0?t:`· ${t}`));return(0,e.createElement)(`div`,{className:`dsu-statusbar`},...n)}function y(t){let n=(0,e.useId)(),[r,i]=(0,e.useState)(!1),[a,o]=(0,e.useState)(!1),s=(0,e.useRef)(!1),c=(0,e.useRef)(!1),l=(0,e.useRef)(!1),u=(0,e.useRef)(null),d=(0,e.useRef)(null),f=(0,e.useRef)(null),p=(0,e.useCallback)(()=>{f.current!==null&&(clearTimeout(f.current),f.current=null)},[]),m=(0,e.useCallback)(()=>{let e=u.current,t=d.current;
9
9
  /* v8 ignore next 3 -- place 只在 open 的 layout effect 与挂载期监听器里调用;refs 为空只可能是卸载竞态 */
10
10
  if(e===null||t===null)return;let n=e.getBoundingClientRect(),r=t.offsetWidth,i=t.offsetHeight,{left:a}=n,o=n.bottom+8;o+i>window.innerHeight-8&&(o=n.top-i-8),a+r>window.innerWidth-8&&(a=window.innerWidth-r-8);let s=Math.max(8,window.innerWidth-r-8),c=Math.max(8,window.innerHeight-i-8);t.style.left=`${Math.min(Math.max(8,a),s)}px`,t.style.top=`${Math.min(Math.max(8,o),c)}px`},[]),h=(0,e.useCallback)(()=>{p(),l.current=!1,o(!1),i(!1)},[p]),g=(0,e.useCallback)(()=>{p(),i(!0)},[p]),_=(0,e.useCallback)(()=>{p(),!(s.current||c.current||l.current)&&(f.current=setTimeout(()=>{
11
11
  /* v8 ignore next 3 -- 任何重新进入/钉住都会 cancelHide;这次复查只防未来的异步路径 */
@@ -29,7 +29,7 @@ t!==null&&(t.offsetTop<e.scrollTop?e.scrollTop=t.offsetTop:t.offsetTop+t.offsetH
29
29
  /* v8 ignore next 3 -- enabled 为空已在上一条返回 */
30
30
  if(t===void 0)return;a(t.index)}else if(e.key===`Enter`||e.key===` `){if(e.preventDefault(),!n){S();return}C(i)}else(e.key===`Tab`||e.key===`Escape`)&&b()},E=[],D;for(let[n,r]of p.entries())r.group!==D&&(r.group!==void 0&&E.push((0,e.createElement)(`div`,{key:`group-${n}-${r.group}`,className:`dsu-optionGroup`,role:`presentation`},r.group)),D=r.group),E.push((0,e.createElement)(`button`,{key:`option-${r.value}`,type:`button`,role:`option`,id:`${c}-${n}`,className:`dsu-option`,tabIndex:-1,"aria-selected":r.value===t.value,"data-active":n===i,disabled:r.disabled===!0,onMouseDown:e=>{e.preventDefault()},onClick:()=>{C(n)},onMouseEnter:()=>{
31
31
  /* v8 ignore next -- happy-dom 对 disabled 元素不派发 mouse 事件;浏览器实现各有差异,保留禁用检查 */
32
- r.disabled!==!0&&a(n)}},(0,e.createElement)(`span`,null,r.label),(0,e.createElement)(`svg`,{className:`dsu-check`,width:14,height:14,viewBox:`0 0 14 14`,"aria-hidden":!0},(0,e.createElement)(`path`,{d:`M2.5 7.5l3 3 6-7`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`}))));return(0,e.createElement)(x,{...t,controlId:l},(0,e.createElement)(`div`,{className:`dsu-selectWrap`,onBlur:e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||b()}},(0,e.createElement)(`button`,{ref:o,type:`button`,id:l,className:`dsu-select dsu-input`,role:`combobox`,"aria-haspopup":`listbox`,"aria-expanded":n,"aria-controls":`${c}-list`,"aria-activedescendant":n&&v?`${c}-${i}`:void 0,"aria-describedby":u,"data-field":t.field,disabled:d===!0||p.length===0,onClick:()=>{n?b():S()},onKeyDown:T},(0,e.createElement)(`span`,{className:`dsu-selectValue`},g),(0,e.createElement)(`svg`,{className:`dsu-chevron`,width:14,height:14,viewBox:`0 0 14 14`,"aria-hidden":!0},(0,e.createElement)(`path`,{d:`M3 5l4 4 4-4`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`}))),(0,e.createElement)(`div`,{ref:s,id:`${c}-list`,role:`listbox`,className:`dsu-menu`,"aria-label":t.label,hidden:!n},...E)))}function T(t){let n=!t.writable||t.busy||!t.dirty,r;return r=t.error===null?t.writable?t.dirty?t.dirtyLabel:t.cleanLabel:t.readOnlyLabel:t.error,(0,e.createElement)(`div`,{className:`dsu-savebar`,"data-dirty":t.dirty},(0,e.createElement)(`button`,{type:`button`,className:`dsu-btn dsu-btnPrimary`,"data-field":`save`,disabled:n,onClick:t.onSave},t.busy?t.savingLabel:t.saveLabel),(0,e.createElement)(`button`,{type:`button`,className:`dsu-btn`,"data-field":`discard`,disabled:n,onClick:t.onDiscard},t.revertLabel),(0,e.createElement)(`span`,{className:t.error===null?`dsu-status`:`dsu-status dsu-statusError`},r))}const E={status:`loading`,writable:!1};function D(){return E}function ee(){return()=>void 0}function O(e){return typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):``}function te(e,t,n,r={}){let i=r[e.key];if(i!==void 0)return i;let a=n[e.key];if(a!==void 0)return O(a);let o=t?.[e.key];return o===void 0?String(e.fallback):O(o)}const ne=t.z.enum([`true`,`false`]),re=t.z.string().regex(/^[1-9]\d*$/u).transform(Number);function k(e,n){if(e.kind===`boolean`){let e=ne.safeParse(n);return e.success?{kind:`value`,value:e.data===`true`}:{kind:`invalid`}}let r=n.trim();if(r===``)return{kind:`clear`};if(e.kind===`number`){let e=re.safeParse(r);return e.success?{kind:`value`,value:e.data}:{kind:`invalid`}}if(e.kind===`enum`){let n=t.z.string().refine(t=>(e.options??[]).includes(t),{error:`取值不在字段选项内`}).safeParse(r);return n.success?{kind:`value`,value:n.data}:{kind:`invalid`}}if(e.format===`url`){let e=t.z.url().safeParse(r);return e.success?{kind:`value`,value:e.data}:{kind:`invalid`}}return{kind:`value`,value:r}}function ie(e){return s.filter(t=>Object.hasOwn(e,t.key)).filter(t=>e[t.key]!==void 0).map(t=>{let n=e[t.key];return n===null||n===t.fallback?{op:`unset`,path:[t.key]}:{op:`set`,path:[t.key],value:n}})}const A=`dsu-btn`,j=`dsu-hint`;function ae(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`head`);return typeof Reflect.get(e,`querySelector`)==`function`&&typeof Reflect.get(e,`createElement`)==`function`&&typeof t==`object`&&!!t&&typeof Reflect.get(t,`append`)==`function`}function oe(){let e=Reflect.get(globalThis,`document`);return ae(e)?e:void 0}function M(e,t,n){if(e.querySelector(`#${t}`)!=null)return()=>void 0;let r=e.createElement(`style`);return r.id=t,r.textContent=n,e.head.append(r),()=>{r.remove()}}function se(e){return M(e,`dsh-scrapling-settings-css`,`
32
+ r.disabled!==!0&&a(n)}},(0,e.createElement)(`span`,null,r.label),(0,e.createElement)(`svg`,{className:`dsu-check`,width:14,height:14,viewBox:`0 0 14 14`,"aria-hidden":!0},(0,e.createElement)(`path`,{d:`M2.5 7.5l3 3 6-7`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`}))));return(0,e.createElement)(x,{...t,controlId:l},(0,e.createElement)(`div`,{className:`dsu-selectWrap`,onBlur:e=>{let t=e.relatedTarget;t instanceof Node&&e.currentTarget.contains(t)||b()}},(0,e.createElement)(`button`,{ref:o,type:`button`,id:l,className:`dsu-select dsu-input`,role:`combobox`,"aria-haspopup":`listbox`,"aria-expanded":n,"aria-controls":`${c}-list`,"aria-activedescendant":n&&v?`${c}-${i}`:void 0,"aria-describedby":u,"data-field":t.field,disabled:d===!0||p.length===0,onClick:()=>{n?b():S()},onKeyDown:T},(0,e.createElement)(`span`,{className:`dsu-selectValue`},g),(0,e.createElement)(`svg`,{className:`dsu-chevron`,width:14,height:14,viewBox:`0 0 14 14`,"aria-hidden":!0},(0,e.createElement)(`path`,{d:`M3 5l4 4 4-4`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`}))),(0,e.createElement)(`div`,{ref:s,id:`${c}-list`,role:`listbox`,className:`dsu-menu`,"aria-label":t.label,hidden:!n},...E)))}function T(t){let n=!t.writable||t.busy||!t.dirty,r;return r=t.error===null?t.writable?t.dirty?t.dirtyLabel:t.cleanLabel:t.readOnlyLabel:t.error,(0,e.createElement)(`div`,{className:`dsu-savebar`,"data-dirty":t.dirty},(0,e.createElement)(`button`,{type:`button`,className:`dsu-btn dsu-btnPrimary`,"data-field":`save`,disabled:n,onClick:t.onSave},t.busy?t.savingLabel:t.saveLabel),(0,e.createElement)(`button`,{type:`button`,className:`dsu-btn`,"data-field":`discard`,disabled:n,onClick:t.onDiscard},t.revertLabel),(0,e.createElement)(`span`,{className:t.error===null?`dsu-status`:`dsu-status dsu-statusError`},r))}const E={status:`loading`,writable:!1};function D(){return E}function ee(){return()=>void 0}function O(e){return typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):``}function te(e,t,n,r={}){let i=r[e.key];if(i!==void 0)return i;let a=n[e.key];if(a!==void 0)return O(a);let o=t?.[e.key];return o===void 0?String(e.fallback):O(o)}const ne=t.z.enum([`true`,`false`]),re=t.z.string().regex(/^[1-9]\d*$/u).transform(Number);function ie(e,n){let r=t.z.url().safeParse(n);if(!r.success)return{kind:`invalid`};let i=e.schemes;return i!==void 0&&!i.includes(new URL(r.data).protocol)?{kind:`invalid`}:{kind:`value`,value:r.data}}function ae(e,n){if(e.kind===`boolean`){let e=ne.safeParse(n);return e.success?{kind:`value`,value:e.data===`true`}:{kind:`invalid`}}let r=n.trim();if(r===``)return{kind:`clear`};if(e.kind===`number`){let e=re.safeParse(r);return e.success?{kind:`value`,value:e.data}:{kind:`invalid`}}if(e.kind===`enum`){let n=t.z.string().refine(t=>(e.options??[]).includes(t),{error:`取值不在字段选项内`}).safeParse(r);return n.success?{kind:`value`,value:n.data}:{kind:`invalid`}}return e.format===`url`?ie(e,r):{kind:`value`,value:r}}function oe(e){return s.filter(t=>Object.hasOwn(e,t.key)).filter(t=>e[t.key]!==void 0).map(t=>{let n=e[t.key];return n===null||n===t.fallback?{op:`unset`,path:[t.key]}:{op:`set`,path:[t.key],value:n}})}const k=`dsu-btn`,A=`dsu-hint`;function se(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`head`);return typeof Reflect.get(e,`querySelector`)==`function`&&typeof Reflect.get(e,`createElement`)==`function`&&typeof t==`object`&&!!t&&typeof Reflect.get(t,`append`)==`function`}function j(){let e=Reflect.get(globalThis,`document`);return se(e)?e:void 0}function M(e,t,n){if(e.querySelector(`#${t}`)!=null)return()=>void 0;let r=e.createElement(`style`);return r.id=t,r.textContent=n,e.head.append(r),()=>{r.remove()}}function ce(e){return M(e,`dsh-scrapling-settings-css`,`
33
33
  .dss-secret{display:flex;gap:8px;align-items:center;width:100%}
34
34
  .dss-reveal{flex:none;white-space:nowrap}
35
35
  .dss-packs{display:flex;flex-direction:column;gap:8px}
@@ -116,7 +116,7 @@ r.disabled!==!0&&a(n)}},(0,e.createElement)(`span`,null,r.label),(0,e.createElem
116
116
  @media (prefers-reduced-motion:reduce){
117
117
  .dsu-switch,.dsu-knob,.dsu-chevron,.dsu-btn{transition:none}
118
118
  }
119
- `)}function ce(e,t){return e.secret===!0&&!t?`password`:`text`}function le(t){let{field:n,label:r,shown:i,disabled:a,revealed:o,onReveal:s,t:c,onChange:l}=t,u=(0,e.createElement)(`input`,{type:ce(n,o),autoComplete:`off`,spellCheck:!1,className:`dsu-input`,value:i,disabled:a,"data-field":n.key,"aria-label":r,onChange:e=>{l(e.target.value)}}),d=(0,e.createElement)(`button`,{type:`button`,className:`dsu-btn dss-reveal`,disabled:a,"aria-pressed":o,"aria-label":r,onClick:()=>{s()}},c(o?`conceal`:`reveal`));return(0,e.createElement)(`div`,{className:`dss-secret`},u,d)}function ue(t){let{field:n,label:r,shown:i,disabled:a,onChange:o}=t;return(0,e.createElement)(`input`,{type:`text`,inputMode:`numeric`,className:`dsu-input`,value:i,disabled:a,"data-field":n.key,"aria-label":r,onChange:e=>{o(e.target.value)}})}function de(t){let{field:n,t:r,shown:i,disabled:a,revealed:o,onReveal:s,onChange:c}=t,l=r(`field.${n.key}.label`),u={label:l,...h(r(`field.${n.key}.hint`)),field:n.key,disabled:a};return n.kind===`boolean`?(0,e.createElement)(S,{...u,checked:i===`true`,onChange:e=>{c(String(e))}}):n.kind===`enum`?(0,e.createElement)(w,{...u,value:i,options:(n.options??[]).map(e=>({value:e,label:e})),onChange:c}):n.secret===!0?(0,e.createElement)(x,u,le({field:n,label:l,shown:i,disabled:a,revealed:o,onReveal:s,t:r,onChange:c})):n.kind===`number`?(0,e.createElement)(x,u,ue({field:n,label:l,shown:i,disabled:a,onChange:c})):(0,e.createElement)(C,{...u,value:i,onChange:c})}function fe(t){let{group:n,t:r,shown:i,disabled:a,revealed:o,onReveal:s,onChange:c}=t;return(0,e.createElement)(_,{title:r(`group.${n.id}.title`),hint:r(`group.${n.id}.note`)},n.fields.map(e=>de({field:e,t:r,shown:i(e),disabled:a,revealed:o(e),onReveal:()=>{s(e)},onChange:t=>{c(e,t)}})))}function pe(e,t,n,r){return t.status===`loading`?e(`statusLoading`):r>0?e(`statusInvalid`,{count:r}):t.status===`unavailable`||!t.writable?e(`statusReadonly`):n===0?e(`statusClean`):e(`statusChanged`,{count:n})}const N={values:{},baseRevision:void 0,invalid:[],invalidText:{}};function me(t){let{t:n,saving:r,editable:i,changed:a,invalid:o,onSave:s,onUndo:c}=t;return(0,e.createElement)(T,{dirty:a>0&&o===0,busy:r,writable:i,error:o>0?n(`statusInvalid`,{count:o}):null,saveLabel:n(`save`),savingLabel:n(`saving`),revertLabel:n(`undo`),dirtyLabel:n(`statusChanged`,{count:a}),cleanLabel:n(`statusClean`),readOnlyLabel:n(`statusReadonly`),onSave:s,onDiscard:c})}function he(t){let[n,r]=(0,e.useState)(null),[i,a]=(0,e.useState)(``),[o,s]=(0,e.useState)(``),c=(0,e.useCallback)(async()=>{if(t!==void 0)try{r(await t.status()),s(``)}catch(e){s(String(e))}},[t]),l=n?.job?.status===`running`||n?.job?.status===`stopping`;return(0,e.useEffect)(()=>{t!==void 0&&c()},[t,c]),(0,e.useEffect)(()=>{let e;return t!==void 0&&l&&(e=setInterval(()=>{c()},2e3)),()=>{e!==void 0&&clearInterval(e)}},[t,l,c]),{snapshot:n,busy:i,failure:o,act:(0,e.useCallback)((e,n)=>{t!==void 0&&(a(e),s(``),(async()=>{try{let r=n===`repair`?await t.repair(e):await t.install(e);r.ok?await c():s(r.error)}catch(e){s(String(e))}finally{a(``)}})())},[t,c]),cancel:(0,e.useCallback)(()=>{let e=n?.job;t!==void 0&&e!=null&&(a(`cancel`),s(``),(async()=>{try{let n=await t.cancel(e.id);n.ok?await c():s(n.error)}catch(e){s(String(e))}finally{a(``)}})())},[t,c,n])}}function ge(t){let{pack:n,state:r,t:i,disabled:a,running:o,activePack:s,onAct:c,onCancel:l}=t,u=i(r===null?`statusLoading`:p(r)),d=i(m(n)),f=a||r===null||r===`blocked`||r===`installing`,h=[(0,e.createElement)(`button`,{type:`button`,className:A,key:`install`,disabled:f||r===`ready`,onClick:()=>{c(n,`install`)}},i(`runtimeInstall`)),(0,e.createElement)(`button`,{type:`button`,className:A,key:`repair`,disabled:f||r===`missing`,onClick:()=>{c(n,`repair`)}},i(`runtimeRepair`))];return o&&s===n&&h.push((0,e.createElement)(`button`,{type:`button`,className:A,key:`cancel`,disabled:a,onClick:l},i(`runtimeCancel`))),(0,e.createElement)(`div`,{className:`dss-pack`,key:n},(0,e.createElement)(`div`,null,(0,e.createElement)(`div`,{className:`dsu-label`},d),(0,e.createElement)(`p`,{className:j},u)),(0,e.createElement)(`div`,{className:`dss-packActions`},...h))}function _e(t){let{reader:n,t:r,snapshot:i,busy:a,failure:o,onAct:s,onCancel:c}=t,l=(0,e.createElement)(`code`,{className:`dss-command`},`dsh-scrapling setup --feature <pack> --apply`),u=o===``?null:(0,e.createElement)(`p`,{className:`${j} dsu-error`,role:`alert`},r(`runtimeError`,{reason:o}));if(n===void 0)return(0,e.createElement)(_,{title:r(`runtimeTitle`),hint:r(`runtimeHint`)},(0,e.createElement)(`p`,{className:j},r(`runtimeUnavailable`)),l);let d=i?.jobsReady??!1,p=i?.job??null,h=p!==null&&(p.status===`running`||p.status===`stopping`),g=i===null?null:(0,e.createElement)(`p`,{className:j},`${r(`runtimePython`)}: ${i.python.path} (${i.python.via})`,(0,e.createElement)(`br`),`${r(`runtimeDataDir`)}: ${i.dataDir}`),v=p===null?``:r(m(p.pack)),y=p===null?null:(0,e.createElement)(`p`,{className:j},h?r(`runtimeJobRunning`,{pack:v}):r(`runtimeJobEnded`,{status:p.status})),b=p===null||p.output===``?null:(0,e.createElement)(`pre`,{className:`dss-job`},p.output),x=a!==``||!d||i===null,S=f.map(e=>ge({pack:e,state:i?.packs[e]??null,t:r,disabled:x,running:h,activePack:p?.pack??null,onAct:s,onCancel:c})),C=i!==null&&!d?(0,e.createElement)(`div`,null,(0,e.createElement)(`p`,{className:j},r(`runtimeJobsMissing`)),l):null;return(0,e.createElement)(_,{title:r(`runtimeTitle`),hint:r(`runtimeHint`)},g,u,y,b,(0,e.createElement)(`div`,{className:`dss-packs`},...S),C)}async function P(e){let{form:t,draft:n,ops:r,state:i,t:a,setDraft:o,setFailure:s,setSaving:c}=e;c(!0),s(``);try{await t.mutate(r,n.baseRevision)?o(e=>{let t={...e.values};for(let e of r){let[n]=e.path;Reflect.deleteProperty(t,n)}return Object.keys(t).length===0?N:{...e,values:t}}):s(n.baseRevision!==void 0&&n.baseRevision!==i.revision?a(`stale`):a(`rejected`))}catch(e){s(a(`failed`,{reason:String(e)}))}finally{c(!1)}}function F(t){let{form:n,t:r}=t,[i,a]=(0,e.useState)(N),[s,c]=(0,e.useState)(``),[l,u]=(0,e.useState)(!1),[d,f]=(0,e.useState)([]),p=(0,e.useSyncExternalStore)(n===void 0?ee:n.subscribe,n===void 0?D:n.getSnapshot),m=he(t.runtime);if(t.view!==`page`||n===void 0)return(0,e.createElement)(g,null);let h=p.writable&&p.status===`ready`,_=ie(i.values),y=async()=>{i.invalid.length>0||_.length===0||await P({form:n,draft:i,ops:_,state:p,t:r,setDraft:a,setFailure:c,setSaving:u})},b=(e,t)=>{c(``);let n=k(e,t);a(r=>{let i={...r.values},a={...r.invalidText},o=r.invalid.filter(t=>t!==e.key),s=r.baseRevision??p.revision;return n.kind===`invalid`?(Reflect.deleteProperty(i,e.key),a[e.key]=t,{values:i,baseRevision:s,invalid:[...o,e.key],invalidText:a}):(Reflect.deleteProperty(a,e.key),i[e.key]=n.kind===`clear`?null:n.value,{values:i,baseRevision:s,invalid:o,invalidText:a})})},x=o.map(e=>fe({group:e,t:r,shown:e=>te(e,p.value,i.values,i.invalidText),disabled:!h||l,revealed:e=>d.includes(e.key),onReveal:e=>{f(t=>t.includes(e.key)?t.filter(t=>t!==e.key):[...t,e.key])},onChange:b})),S=me({t:r,saving:l,editable:h,changed:_.length,invalid:i.invalid.length,onSave:()=>{y()},onUndo:()=>{a(N),c(``)}}),C=(0,e.createElement)(v,{items:[pe(r,p,_.length,i.invalid.length)]}),w=s===``?null:(0,e.createElement)(`p`,{className:`dsu-error`,role:`alert`,"aria-live":`assertive`},s);return(0,e.createElement)(g,null,C,w,...x,_e({reader:t.runtime,t:r,snapshot:m.snapshot,busy:m.busy,failure:m.failure,onAct:m.act,onCancel:m.cancel}),S)}const I=`@jayyuen66/dsh-scrapling`;function L(e,t){return e[t]}const R=`scraplingRuntime`,z=`remote.${R}`;function B(e,n){let r=e.safeParse(n);if(!r.success)throw TypeError(t.z.prettifyError(r.error));return r.data}const V=`runtime request requires a known pack`,ve=t.z.object({pack:t.z.enum(f,{error:V})},{error:V}),H=`runtime cancel requires a jobId`,ye=t.z.object({jobId:t.z.string({error:H}).min(1,{error:H})},{error:H}),U={mode:`strict`,typeSymbol:`${I}#runtime-pack-request`,create:()=>({parse(e){return B(ve,e)}})},be={mode:`strict`,typeSymbol:`${I}#runtime-cancel-request`,create:()=>({parse(e){return B(ye,e)}})},xe=t.z.enum([`ready`,`missing`,`corrupt`,`installing`,`blocked`]),Se=t.z.enum([`running`,`stopping`,`completed`,`killed`,`failed`]),W=t.z.enum(f),Ce=t.z.object({id:t.z.string(),pack:W,status:Se,output:t.z.string()}),we=t.z.object({ok:t.z.literal(!0),packs:t.z.partialRecord(W,xe),python:t.z.object({path:t.z.string(),via:t.z.string(),version:t.z.string()}),dataDir:t.z.string(),jobsReady:t.z.boolean(),job:Ce.nullable()}),Te=t.z.literal([400,404,409,500,503]),G=t.z.discriminatedUnion(`ok`,[t.z.object({ok:t.z.literal(!0),jobId:t.z.string()}),t.z.object({ok:t.z.literal(!1),error:t.z.string(),status:Te})]),Ee=[{id:`${I}#${R}/status`,service:R,namespace:R,method:`status`,invocation:{kind:`direct`},parameters:[],result:{mode:`src-json`}},{id:`${I}#${R}/installPack`,service:R,namespace:R,method:`installPack`,invocation:{kind:`direct`},parameters:[{name:`request`,wire:`request`,source:`json`,codec:U}],result:{mode:`src-json`}},{id:`${I}#${R}/repairPack`,service:R,namespace:R,method:`repairPack`,invocation:{kind:`direct`},parameters:[{name:`request`,wire:`request`,source:`json`,codec:U}],result:{mode:`src-json`}},{id:`${I}#${R}/cancelJob`,service:R,namespace:R,method:`cancelJob`,invocation:{kind:`direct`},parameters:[{name:`request`,wire:`request`,source:`json`,codec:be}],result:{mode:`src-json`}}];function De(e){return a(e)&&typeof L(e,`$mount`)==`function`}function Oe(e){return a(e)?typeof L(e,`status`)==`function`&&typeof L(e,`installPack`)==`function`&&typeof L(e,`repairPack`)==`function`&&typeof L(e,`cancelJob`)==`function`:!1}async function K(e,t){let n=await e;if(n.ok)return B(t,n.value);throw Error(`${n.error.code}: ${n.error.message}`)}function ke(e){let t,n=async()=>{let n=e.get?.(`remote`);if(!De(n))throw Error(`运行环境读面不可用:宿主网关没有提供 remote 服务`);try{t??=n.$mount({package:I,descriptors:Ee}),await t}catch(e){throw t=void 0,e}let r=e.get?.(z,!1);if(!Oe(r))throw Error(`${z} 未提供:宿主网关没有挂上这枚命名空间`);return r};return{async status(){return K((await n()).status(),we)},async install(e){return K((await n()).installPack({pack:e}),G)},async repair(e){return K((await n()).repairPack({pack:e}),G)},async cancel(e){return K((await n()).cancelJob({jobId:e}),G)}}}function Ae(e){return typeof e.get==`function`?ke(e):void 0}const q=`row.session`,J=[`scrapling_fetch`,`scrapling_extract`,`scrapling_locate`,`scrapling_links`,`scrapling_render`,`scrapling_capture_xhr`,`scrapling_answer`,`scrapling_session_open`,`scrapling_session_fetch`,`scrapling_session_network`,`scrapling_session_state_save`,`scrapling_session_state_load`,`scrapling_session_list`,`scrapling_session_close`,`scrapling_crawl`,`scrapling_session_read`,`scrapling_session_act`,`scrapling_download`,`scrapling_screenshot`];function Y(e){return typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):``}function X(...e){for(let t of e){let e=Y(t);if(e!==``)return e}return``}function je(e,t,n){let r=Y(t.selector);return{tool:e,title:r===``?e:`${e} ${r}`,fields:[{labelKey:`row.matched`,value:Y(n.count)}]}}function Me(e,t,n){let r=[],i=Y(t.baseUrl);return i!==``&&r.push({labelKey:`row.url`,value:i}),r.push({labelKey:`row.matched`,value:Y(n.count)}),{tool:e,title:e,fields:r}}function Z(e,t,n){let r=a(t)?t:{},i=a(n)?n:{},o=X(i.url,r.url);if(e===`scrapling_extract`||e===`scrapling_locate`)return je(e,r,i);if(e===`scrapling_links`)return Me(e,r,i);if(e===`scrapling_session_list`)return{tool:e,title:e,fields:[{labelKey:`row.sessionCount`,value:Y(i.count)}]};if(e===`scrapling_session_open`)return{tool:e,title:e,fields:[{labelKey:`row.type`,value:Y(r.sessionType)},{labelKey:q,value:Y(i.sessionId)}]};if(e===`scrapling_session_close`)return{tool:e,title:e,fields:[{labelKey:q,value:Y(r.sessionId)}]};if(e===`scrapling_session_network`||e===`scrapling_session_state_save`||e===`scrapling_session_state_load`){let t=[{labelKey:q,value:Y(r.sessionId)}],n=Y(r.name);return n!==``&&t.push({labelKey:`row.name`,value:n}),{tool:e,title:e,fields:t}}if(e===`scrapling_crawl`)return{tool:e,title:e,fields:[{labelKey:`row.start`,value:o},{labelKey:`row.pageCap`,value:Y(r.maxPages)},{labelKey:`row.job`,value:Y(i.jobId)}]};let s=[];o!==``&&s.push({labelKey:`row.url`,value:o});let c=i.statusCode;return typeof c==`number`&&s.push({labelKey:`row.http`,value:String(c)}),i.truncated===!0&&s.push({labelKey:`row.body`,value:``,valueKey:`row.truncated`}),{tool:e,title:e,fields:s}}const Ne=[`url`,`baseUrl`,`selector`,`sessionType`,`sessionId`,`name`,`maxPages`];function Q(e){if(e===void 0)return{};let t={};for(let n of Ne){let r=e.text(n)??e.value(n);r!==void 0&&(t[n]=r)}return t}function $(e){return e.phase===`result`?e.block.meta:void 0}function Pe(t){let{toolName:n,block:r,inspect:i,t:a}=t,o=$(t),s=Z(n,Q(r.args),o),c=[(0,e.createElement)(`div`,{className:`dsh-scrapling-rowTitle`,key:`title`},s.title)];return s.fields.length>0&&c.push((0,e.createElement)(`ul`,{className:`dsh-scrapling-rowFields`,key:`fields`},s.fields.map(t=>(0,e.createElement)(`li`,{className:`dsh-scrapling-rowField`,key:t.labelKey},(0,e.createElement)(`span`,{className:`dsh-scrapling-rowLabel`},a(t.labelKey)),(0,e.createElement)(`span`,{className:`dsh-scrapling-rowValue`},t.valueKey===void 0?t.value:a(t.valueKey)))))),i!==void 0&&c.push((0,e.createElement)(`button`,{type:`button`,className:`dsh-scrapling-rowButton`,key:`inspect`,onClick:()=>{i()}},a(`row.inspect`))),(0,e.createElement)(`div`,{className:`dsh-scrapling-row`,"data-tool":n},...c)}const Fe=[`slots`,`configForms`,`locale`];function Ie(t){let n=t.locale.bind(c),r=[];for(let i of J)r.push(t.slots.register({name:`tool.call.toolview`,key:i,locale:c},t=>(0,e.createElement)(Pe,{...t,t:n})));return()=>{for(let e of r)e()}}function Le(t){i(t,`__dshScraplingToolviewApplied`,`dsh-scrapling toolview`)&&(t.effect(()=>{let e=oe();if(e===void 0)return()=>void 0;let t=se(e),n=M(e,`dsh-scrapling-row-css`,`
119
+ `)}function le(e,t){return e.secret===!0&&!t?`password`:`text`}function ue(t){let{field:n,label:r,shown:i,disabled:a,revealed:o,onReveal:s,t:c,onChange:l}=t,u=(0,e.createElement)(`input`,{type:le(n,o),autoComplete:`off`,spellCheck:!1,className:`dsu-input`,value:i,disabled:a,"data-field":n.key,"aria-label":r,onChange:e=>{l(e.target.value)}}),d=(0,e.createElement)(`button`,{type:`button`,className:`dsu-btn dss-reveal`,disabled:a,"aria-pressed":o,"aria-label":r,onClick:()=>{s()}},c(o?`conceal`:`reveal`));return(0,e.createElement)(`div`,{className:`dss-secret`},u,d)}function de(t){let{field:n,label:r,shown:i,disabled:a,onChange:o}=t;return(0,e.createElement)(`input`,{type:`text`,inputMode:`numeric`,className:`dsu-input`,value:i,disabled:a,"data-field":n.key,"aria-label":r,onChange:e=>{o(e.target.value)}})}function fe(t){let{field:n,t:r,shown:i,disabled:a,revealed:o,onReveal:s,onChange:c}=t,l=r(`field.${n.key}.label`),u={label:l,...h(r(`field.${n.key}.hint`)),field:n.key,disabled:a};return n.kind===`boolean`?(0,e.createElement)(S,{...u,checked:i===`true`,onChange:e=>{c(String(e))}}):n.kind===`enum`?(0,e.createElement)(w,{...u,value:i,options:(n.options??[]).map(e=>({value:e,label:e})),onChange:c}):n.secret===!0?(0,e.createElement)(x,u,ue({field:n,label:l,shown:i,disabled:a,revealed:o,onReveal:s,t:r,onChange:c})):n.kind===`number`?(0,e.createElement)(x,u,de({field:n,label:l,shown:i,disabled:a,onChange:c})):(0,e.createElement)(C,{...u,value:i,onChange:c})}function pe(t){let{group:n,t:r,shown:i,disabled:a,revealed:o,onReveal:s,onChange:c}=t;return(0,e.createElement)(_,{title:r(`group.${n.id}.title`),hint:r(`group.${n.id}.note`)},n.fields.map(e=>fe({field:e,t:r,shown:i(e),disabled:a,revealed:o(e),onReveal:()=>{s(e)},onChange:t=>{c(e,t)}})))}function me(e,t,n,r){return t.status===`loading`?e(`statusLoading`):r>0?e(`statusInvalid`,{count:r}):t.status===`unavailable`||!t.writable?e(`statusReadonly`):n===0?e(`statusClean`):e(`statusChanged`,{count:n})}const N={values:{},baseRevision:void 0,invalid:[],invalidText:{}};function he(e,t){let n={...e.values};for(let e of t){let[t]=e.path;Reflect.deleteProperty(n,t)}return Object.keys(n).length===0?N:{...e,values:n,baseRevision:void 0}}function ge(t){let{t:n,saving:r,editable:i,changed:a,invalid:o,onSave:s,onUndo:c}=t;return(0,e.createElement)(T,{dirty:a>0&&o===0,busy:r,writable:i,error:o>0?n(`statusInvalid`,{count:o}):null,saveLabel:n(`save`),savingLabel:n(`saving`),revertLabel:n(`undo`),dirtyLabel:n(`statusChanged`,{count:a}),cleanLabel:n(`statusClean`),readOnlyLabel:n(`statusReadonly`),onSave:s,onDiscard:c})}function _e(t){let[n,r]=(0,e.useState)(null),[i,a]=(0,e.useState)(``),[o,s]=(0,e.useState)(``),c=(0,e.useRef)(0),l=(0,e.useCallback)(async()=>{if(t===void 0)return;c.current+=1;let e=c.current;try{let n=await t.status();if(e!==c.current)return;r(n),s(``)}catch(t){if(e!==c.current)return;s(String(t))}},[t]),u=n?.job?.status===`running`||n?.job?.status===`stopping`;return(0,e.useEffect)(()=>{t!==void 0&&l()},[t,l]),(0,e.useEffect)(()=>{let e;return t!==void 0&&u&&(e=setInterval(()=>{l()},2e3)),()=>{e!==void 0&&clearInterval(e)}},[t,u,l]),{snapshot:n,busy:i,failure:o,act:(0,e.useCallback)((e,n)=>{t!==void 0&&(a(e),s(``),(async()=>{try{let r=n===`repair`?await t.repair(e):await t.install(e);r.ok?await l():s(r.error)}catch(e){s(String(e))}finally{a(``)}})())},[t,l]),cancel:(0,e.useCallback)(()=>{let e=n?.job;t!==void 0&&e!=null&&(a(`cancel`),s(``),(async()=>{try{let n=await t.cancel(e.id);n.ok?await l():s(n.error)}catch(e){s(String(e))}finally{a(``)}})())},[t,l,n])}}function P(t){let{pack:n,state:r,t:i,disabled:a,running:o,activePack:s,onAct:c,onCancel:l}=t,u=i(r===null?`statusLoading`:p(r)),d=i(m(n)),f=a||o||r===null||r===`blocked`||r===`installing`,h=[(0,e.createElement)(`button`,{type:`button`,className:k,key:`install`,disabled:f||r===`ready`,onClick:()=>{c(n,`install`)}},i(`runtimeInstall`)),(0,e.createElement)(`button`,{type:`button`,className:k,key:`repair`,disabled:f||r===`missing`,onClick:()=>{c(n,`repair`)}},i(`runtimeRepair`))];return o&&s===n&&h.push((0,e.createElement)(`button`,{type:`button`,className:k,key:`cancel`,disabled:a,onClick:l},i(`runtimeCancel`))),(0,e.createElement)(`div`,{className:`dss-pack`,key:n},(0,e.createElement)(`div`,null,(0,e.createElement)(`div`,{className:`dsu-label`},d),(0,e.createElement)(`p`,{className:A},u)),(0,e.createElement)(`div`,{className:`dss-packActions`},...h))}function F(t){let{reader:n,t:r,snapshot:i,busy:a,failure:o,onAct:s,onCancel:c}=t,l=(0,e.createElement)(`code`,{className:`dss-command`},`dsh-scrapling setup --feature <pack> --apply`),u=o===``?null:(0,e.createElement)(`p`,{className:`${A} dsu-error`,role:`alert`},r(`runtimeError`,{reason:o}));if(n===void 0)return(0,e.createElement)(_,{title:r(`runtimeTitle`),hint:r(`runtimeHint`)},(0,e.createElement)(`p`,{className:A},r(`runtimeUnavailable`)),l);let d=i?.jobsReady??!1,p=i?.job??null,h=p!==null&&(p.status===`running`||p.status===`stopping`),g=i===null?null:(0,e.createElement)(`p`,{className:A},`${r(`runtimePython`)}: ${i.python.path} (${i.python.via})`,(0,e.createElement)(`br`),`${r(`runtimeDataDir`)}: ${i.dataDir}`),v=p===null?``:r(m(p.pack)),y=p===null?null:(0,e.createElement)(`p`,{className:A},h?r(`runtimeJobRunning`,{pack:v}):r(`runtimeJobEnded`,{status:p.status})),b=p===null||p.output===``?null:(0,e.createElement)(`pre`,{className:`dss-job`},p.output),x=a!==``||!d||i===null,S=f.map(e=>P({pack:e,state:i?.packs[e]??null,t:r,disabled:x,running:h,activePack:p?.pack??null,onAct:s,onCancel:c})),C=i!==null&&!d?(0,e.createElement)(`div`,null,(0,e.createElement)(`p`,{className:A},r(`runtimeJobsMissing`)),l):null;return(0,e.createElement)(_,{title:r(`runtimeTitle`),hint:r(`runtimeHint`)},g,u,y,b,(0,e.createElement)(`div`,{className:`dss-packs`},...S),C)}async function I(e){let{form:t,draft:n,ops:r,state:i,t:a,setDraft:o,setFailure:s,setSaving:c}=e;c(!0),s(``);try{await t.mutate(r,n.baseRevision)?o(e=>he(e,r)):s(n.baseRevision!==void 0&&n.baseRevision!==i.revision?a(`stale`):a(`rejected`))}catch(e){s(a(`failed`,{reason:String(e)}))}finally{c(!1)}}function ve(t){let{form:n,t:r}=t,[i,a]=(0,e.useState)(N),[s,c]=(0,e.useState)(``),[l,u]=(0,e.useState)(!1),[d,f]=(0,e.useState)([]),p=(0,e.useSyncExternalStore)(n===void 0?ee:n.subscribe,n===void 0?D:n.getSnapshot),m=_e(t.runtime);if(t.view!==`page`||n===void 0)return(0,e.createElement)(g,null);let h=p.writable&&p.status===`ready`,_=oe(i.values),y=async()=>{i.invalid.length>0||_.length===0||await I({form:n,draft:i,ops:_,state:p,t:r,setDraft:a,setFailure:c,setSaving:u})},b=(e,t)=>{c(``);let n=ae(e,t);a(r=>{let i={...r.values},a={...r.invalidText},o=r.invalid.filter(t=>t!==e.key),s=r.baseRevision??p.revision;return n.kind===`invalid`?(Reflect.deleteProperty(i,e.key),a[e.key]=t,{values:i,baseRevision:s,invalid:[...o,e.key],invalidText:a}):(Reflect.deleteProperty(a,e.key),i[e.key]=n.kind===`clear`?null:n.value,{values:i,baseRevision:s,invalid:o,invalidText:a})})},x=o.map(e=>pe({group:e,t:r,shown:e=>te(e,p.value,i.values,i.invalidText),disabled:!h||l,revealed:e=>d.includes(e.key),onReveal:e=>{f(t=>t.includes(e.key)?t.filter(t=>t!==e.key):[...t,e.key])},onChange:b})),S=ge({t:r,saving:l,editable:h,changed:_.length,invalid:i.invalid.length,onSave:()=>{y()},onUndo:()=>{a(N),f([]),c(``)}}),C=(0,e.createElement)(v,{items:[me(r,p,_.length,i.invalid.length)]}),w=s===``?null:(0,e.createElement)(`p`,{className:`dsu-error`,role:`alert`,"aria-live":`assertive`},s);return(0,e.createElement)(g,null,C,w,...x,F({reader:t.runtime,t:r,snapshot:m.snapshot,busy:m.busy,failure:m.failure,onAct:m.act,onCancel:m.cancel}),S)}const L=`@jayyuen66/dsh-scrapling`;function R(e,t){return e[t]}const z=`scraplingRuntime`,B=`remote.${z}`;function V(e,n){let r=e.safeParse(n);if(!r.success)throw TypeError(t.z.prettifyError(r.error));return r.data}const H=`runtime request requires a known pack`,ye=t.z.object({pack:t.z.enum(f,{error:H})},{error:H}),U=`runtime cancel requires a jobId`,be=t.z.object({jobId:t.z.string({error:U}).min(1,{error:U})},{error:U}),W={mode:`strict`,typeSymbol:`${L}#runtime-pack-request`,create:()=>({parse(e){return V(ye,e)}})},xe={mode:`strict`,typeSymbol:`${L}#runtime-cancel-request`,create:()=>({parse(e){return V(be,e)}})},Se=t.z.enum([`ready`,`missing`,`corrupt`,`installing`,`blocked`]),Ce=t.z.enum([`running`,`stopping`,`completed`,`killed`,`failed`]),G=t.z.enum(f),we=t.z.object({id:t.z.string(),pack:G,status:Ce,output:t.z.string()}),Te=t.z.object({ok:t.z.literal(!0),packs:t.z.partialRecord(G,Se),python:t.z.object({path:t.z.string(),via:t.z.string(),version:t.z.string()}),dataDir:t.z.string(),jobsReady:t.z.boolean(),job:we.nullable()}),Ee=t.z.literal([400,404,409,500,503]),K=t.z.discriminatedUnion(`ok`,[t.z.object({ok:t.z.literal(!0),jobId:t.z.string()}),t.z.object({ok:t.z.literal(!1),error:t.z.string(),status:Ee})]),De=[{id:`${L}#${z}/status`,service:z,namespace:z,method:`status`,invocation:{kind:`direct`},parameters:[],result:{mode:`src-json`}},{id:`${L}#${z}/installPack`,service:z,namespace:z,method:`installPack`,invocation:{kind:`direct`},parameters:[{name:`request`,wire:`request`,source:`json`,codec:W}],result:{mode:`src-json`}},{id:`${L}#${z}/repairPack`,service:z,namespace:z,method:`repairPack`,invocation:{kind:`direct`},parameters:[{name:`request`,wire:`request`,source:`json`,codec:W}],result:{mode:`src-json`}},{id:`${L}#${z}/cancelJob`,service:z,namespace:z,method:`cancelJob`,invocation:{kind:`direct`},parameters:[{name:`request`,wire:`request`,source:`json`,codec:xe}],result:{mode:`src-json`}}];function Oe(e){return a(e)&&typeof R(e,`$mount`)==`function`}function ke(e){return a(e)?typeof R(e,`status`)==`function`&&typeof R(e,`installPack`)==`function`&&typeof R(e,`repairPack`)==`function`&&typeof R(e,`cancelJob`)==`function`:!1}async function q(e,t){let n=await e;if(n.ok)return V(t,n.value);throw Error(`${n.error.code}: ${n.error.message}`)}function Ae(e){let t,n=async()=>{let n=e.get?.(`remote`);if(!Oe(n))throw Error(`运行环境读面不可用:宿主网关没有提供 remote 服务`);try{t??=n.$mount({package:L,descriptors:De}),await t}catch(e){throw t=void 0,e}let r=e.get?.(B,!1);if(!ke(r))throw Error(`${B} 未提供:宿主网关没有挂上这枚命名空间`);return r};return{async status(){return q((await n()).status(),Te)},async install(e){return q((await n()).installPack({pack:e}),K)},async repair(e){return q((await n()).repairPack({pack:e}),K)},async cancel(e){return q((await n()).cancelJob({jobId:e}),K)}}}function je(e){return typeof e.get==`function`?Ae(e):void 0}const J=`row.session`,Y=[`scrapling_fetch`,`scrapling_extract`,`scrapling_locate`,`scrapling_links`,`scrapling_render`,`scrapling_capture_xhr`,`scrapling_answer`,`scrapling_session_open`,`scrapling_session_fetch`,`scrapling_session_network`,`scrapling_session_state_save`,`scrapling_session_state_load`,`scrapling_session_list`,`scrapling_session_close`,`scrapling_crawl`,`scrapling_session_read`,`scrapling_session_act`,`scrapling_download`,`scrapling_screenshot`];function X(e){return typeof e==`string`?e:typeof e==`number`||typeof e==`boolean`?String(e):``}function Me(...e){for(let t of e){let e=X(t);if(e!==``)return e}return``}function Ne(e,t,n){let r=X(t.selector);return{tool:e,title:r===``?e:`${e} ${r}`,fields:[{labelKey:`row.matched`,value:X(n.count)}]}}function Pe(e,t,n){let r=[],i=X(t.baseUrl);return i!==``&&r.push({labelKey:`row.url`,value:i}),r.push({labelKey:`row.matched`,value:X(n.count)}),{tool:e,title:e,fields:r}}function Z(e,t,n){let r=a(t)?t:{},i=a(n)?n:{},o=Me(i.url,r.url);if(e===`scrapling_extract`||e===`scrapling_locate`)return Ne(e,r,i);if(e===`scrapling_links`)return Pe(e,r,i);if(e===`scrapling_session_list`)return{tool:e,title:e,fields:[{labelKey:`row.sessionCount`,value:X(i.count)}]};if(e===`scrapling_session_open`)return{tool:e,title:e,fields:[{labelKey:`row.type`,value:X(r.sessionType)},{labelKey:J,value:X(i.sessionId)}]};if(e===`scrapling_session_close`)return{tool:e,title:e,fields:[{labelKey:J,value:X(r.sessionId)}]};if(e===`scrapling_session_network`||e===`scrapling_session_state_save`||e===`scrapling_session_state_load`){let t=[{labelKey:J,value:X(r.sessionId)}],n=X(r.name);return n!==``&&t.push({labelKey:`row.name`,value:n}),{tool:e,title:e,fields:t}}if(e===`scrapling_crawl`)return{tool:e,title:e,fields:[{labelKey:`row.start`,value:o},{labelKey:`row.pageCap`,value:X(r.maxPages)},{labelKey:`row.job`,value:X(i.jobId)}]};let s=[];o!==``&&s.push({labelKey:`row.url`,value:o});let c=i.statusCode;return typeof c==`number`&&s.push({labelKey:`row.http`,value:String(c)}),i.truncated===!0&&s.push({labelKey:`row.body`,value:``,valueKey:`row.truncated`}),{tool:e,title:e,fields:s}}const Fe=[`url`,`baseUrl`,`selector`,`sessionType`,`sessionId`,`name`,`maxPages`];function Q(e){if(e===void 0)return{};let t={};for(let n of Fe){let r=e.text(n)??e.value(n);r!==void 0&&(t[n]=r)}return t}function $(e){return e.phase===`result`?e.block.meta:void 0}function Ie(t){let{toolName:n,block:r,inspect:i,t:a}=t,o=$(t),s=Z(n,Q(r.args),o),c=[(0,e.createElement)(`div`,{className:`dsh-scrapling-rowTitle`,key:`title`},s.title)];return s.fields.length>0&&c.push((0,e.createElement)(`ul`,{className:`dsh-scrapling-rowFields`,key:`fields`},s.fields.map(t=>(0,e.createElement)(`li`,{className:`dsh-scrapling-rowField`,key:t.labelKey},(0,e.createElement)(`span`,{className:`dsh-scrapling-rowLabel`},a(t.labelKey)),(0,e.createElement)(`span`,{className:`dsh-scrapling-rowValue`},t.valueKey===void 0?t.value:a(t.valueKey)))))),i!==void 0&&c.push((0,e.createElement)(`button`,{type:`button`,className:`dsh-scrapling-rowButton`,key:`inspect`,onClick:()=>{i()}},a(`row.inspect`))),(0,e.createElement)(`div`,{className:`dsh-scrapling-row`,"data-tool":n},...c)}const Le=[`slots`,`configForms`,`locale`];function Re(t){let n=t.locale.bind(c),r=[];for(let i of Y)r.push(t.slots.register({name:`tool.call.toolview`,key:i,locale:c},t=>(0,e.createElement)(Ie,{...t,t:n})));return()=>{for(let e of r)e()}}function ze(t){i(t,`__dshScraplingToolviewApplied`,`dsh-scrapling toolview`)&&(t.effect(()=>{let e=j();if(e===void 0)return()=>void 0;let t=ce(e),n=M(e,`dsh-scrapling-row-css`,`
120
120
  .dsh-scrapling-row{display:flex;flex-direction:column;gap:2px;min-width:0}
121
121
  .dsh-scrapling-rowTitle{color:var(--dsw-alias-label-primary);font-size:13px;line-height:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
122
122
  .dsh-scrapling-rowFields{display:flex;flex-wrap:wrap;gap:2px 12px;margin:0;padding:0;list-style:none}
@@ -126,7 +126,7 @@ r.disabled!==!0&&a(n)}},(0,e.createElement)(`span`,null,r.label),(0,e.createElem
126
126
  .dsh-scrapling-rowButton{align-self:flex-start;border:0;background:0 0;padding:0;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:12px;cursor:pointer}
127
127
  .dsh-scrapling-rowButton:hover{color:var(--dsw-alias-label-primary)}
128
128
  .dsh-scrapling-rowButton:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}
129
- `);return()=>{t(),n()}},`dsh-scrapling: client styles`),t.effect(()=>{let e=d(),n=[t.locale.register(c,`zh`,e.zh),t.locale.register(c,`en`,e.en)],r;return t.slots.inject(`tool.call.toolview`,()=>{r=Ie(t)}),()=>{r?.();for(let e of n)e()}},`dsh-scrapling: dictionaries and tool rows`),t.effect(()=>{let n=t.configForms.get(`scrapling`),r=t.locale.bind(c),i={getSnapshot:()=>n.getSnapshot(),subscribe:e=>n.subscribe(e),mutate:(e,t)=>n.mutate(e,t)},a;return t.slots.inject(`plugins.bundle.config`,()=>{let n=Ae(t);a=t.slots.register({name:`plugins.bundle.config`,key:`@jayyuen66/dsh-scrapling`,locale:c},t=>(0,e.createElement)(F,{...t,t:r,form:i,runtime:n}))}),()=>{a?.()}},`dsh-scrapling: settings card`))}exports.ROW_TOOLS=J,exports.apply=Le,exports.buildRow=Z,exports.inject=Fe,exports.readArgs=Q,exports.resultMetaOf=$;
129
+ `);return()=>{t(),n()}},`dsh-scrapling: client styles`),t.effect(()=>{let e=d(),n=[t.locale.register(c,`zh`,e.zh),t.locale.register(c,`en`,e.en)],r;return t.slots.inject(`tool.call.toolview`,()=>{r=Re(t)}),()=>{r?.();for(let e of n)e()}},`dsh-scrapling: dictionaries and tool rows`),t.effect(()=>{let n=t.configForms.get(`scrapling`),r=t.locale.bind(c),i={getSnapshot:()=>n.getSnapshot(),subscribe:e=>n.subscribe(e),mutate:(e,t)=>n.mutate(e,t)},a;return t.slots.inject(`plugins.bundle.config`,()=>{let n=je(t);a=t.slots.register({name:`plugins.bundle.config`,key:`@jayyuen66/dsh-scrapling`,locale:c},t=>(0,e.createElement)(ve,{...t,t:r,form:i,runtime:n}))}),()=>{a?.()}},`dsh-scrapling: settings card`))}exports.ROW_TOOLS=Y,exports.apply=ze,exports.buildRow=Z,exports.inject=Le,exports.readArgs=Q,exports.resultMetaOf=$;
130
130
  return module.exports;
131
131
  },
132
132
  });