@exercode/problem-utils-browser

中文文档
2.1.27发布于 2026/11/07Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 3212

Exercode browser judging utilities

原始使用文档

@exercode/problem-utils-browser

Puppeteer helpers, browser grading presets, and Markdown-to-PDF export. Install this package's matching Chrome headless shell with bun run exercode-browser browsers install chrome-headless-shell.

See the repository documentation.

clickAndDetectCanceledSubmit(page, buttonSelector) uses a native Puppeteer pointer click to activate a form control and reports whether the page cancels its submit event. It supports delegated document/window handlers and observes the form associated with the control when the check starts. Checks on the same page run sequentially so each pointer action has its own cancellation result. Controls that fail Puppeteer's visibility check or native clickability calculation return false; transparent controls such as opacity: 0 remain pointer-reachable and are activated normally. Submissions may navigate; a temporary CDP binding preserves the cancellation state before the document unloads, including when a canceled submission explicitly redirects. Uncanceled submissions return false, and graders should stop on that verdict. Use this when an exercise requires the learner to cancel form submission before inspecting the resulting DOM. Create the page with createBrowserPage before navigating to learner content (as the presets do): it observes submit events before learner scripts, including window capture handlers that stop immediate propagation. Load this interactive content with page.goto: the initial blank document is not instrumented, and page.setContent/document.open replace document listeners and lose the early observer.

submitFormAndCaptureRequest(page, selector, timeoutMs) clicks a form control and captures its main-frame navigation as { method, path, params } without sending the submission to the server. It supports URL-encoded GET/POST fields and returns undefined when no navigation occurs before the timeout (2 seconds by default). Use it on a page without another request-interception handler. Its temporary interception is removed after success, timeout, or click failure.

版本与发布记录

@exercode/problem-utils-browser 共发布 37 个版本,首次发布于 2026/09/11;过去 12 个月发布了 37 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.1.27latest2026/11/077 天前
2.1.262026/11/0310 天前
2.1.252026/10/3113 天前
2.1.242026/10/3113 天前
2.1.232026/10/3114 天前
2.1.222026/10/3114 天前

关于 @exercode/problem-utils-browser 的常见问题

@exercode/problem-utils-browser 是什么?

Exercode browser judging utilities

如何安装 @exercode/problem-utils-browser?

在项目目录运行 npm install @exercode/problem-utils-browser,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 exercode-browser,可以用 npx exercode-browser 直接运行。

@exercode/problem-utils-browser 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@exercode/problem-utils-browser 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@exercode/problem-utils-browser 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=24。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@exercode/problem-utils-browser 可以商用吗?

@exercode/problem-utils-browser 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@exercode/problem-utils-browser 的下载量有多少?

根据 npm 官方下载统计,@exercode/problem-utils-browser 在 2026/10/14 – 2026/11/12 这 30 天内被下载 3,212 次,日均约 107 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@exercode/problem-utils-browser 还在维护吗?

最新版本 2.1.27 发布于 2026/11/07(7 天前);至今共发布 37 个版本,其中过去 12 个月发布了 37 个;首次发布于 2026/09/11。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。