@firecrawl/anydoc-wasm

中文文档
0.2.4发布于 2026/08/28MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 31.9万

WebAssembly bindings for anydoc: convert documents (doc, docx, odt, rtf, epub, pdf, presentations, spreadsheets, csv) to GitHub-Flavored Markdown in the browser

原始使用文档
文档目录3 节
  1. Errors
  2. Building
  3. Demo page

@firecrawl/anydoc-wasm

WebAssembly bindings for anydoc, plus the source of the demo page at firecrawl.github.io/anydoc.

The API mirrors the Rust library, minus the path-based to_markdown: wasm has no filesystem, so conversion always starts from bytes.

npm install @firecrawl/anydoc-wasm
import init, {
  formatFromBytes,
  toMarkdownBytes,
  toDocument,
} from '@firecrawl/anydoc-wasm';

await init();

// With the format detected from the content:
const markdown = toMarkdownBytes(bytes);

// Or name it, which signature-less formats (CSV) need:
const fromCsv = toMarkdownBytes(bytes, 'csv');

// Or stop at the document model, which also carries embedded assets:
const document = toDocument(bytes);

// Format detection on its own:
formatFromBytes(bytes); // 'docx', or undefined when nothing matches

The package is built with wasm-pack --target web: it loads with a plain <script type="module"> and with bundlers that handle the new URL(..., import.meta.url) asset pattern (Vite, webpack 5, Rollup). In Node, pass the module bytes to initSync instead of calling init (see test.mjs).

Calls are synchronous: wasm runs single-threaded on the calling thread, so convert on a worker if the main thread must stay responsive.

Errors

A conversion throws only when no complete Markdown could come out of the bytes. The thrown value is an Error whose code names what went wrong:

try {
  return toMarkdownBytes(bytes);
} catch (error) {
  // No document comes out of these, so record the file and take the next one.
  if (error.code === 'encrypted' || error.code === 'unsupported') {
    unconverted.push({ name, reason: error.code });
    return null;
  }
  throw error;
}
codeMeaning
unsupportedUnknown format, or one that cannot be converted
needsOcrPages of a PDF are scanned or image-only; pages names them
malformedStructurally unusable: no meaningful content could be extracted
encryptedEncrypted or password-protected
resourceLimitCrossed a fixed safety limit (decompression, nesting, node count)
missingPartA part required for any meaningful output is absent

error.message carries the detail, naming the package part at fault where the format identifies one. TypeScript gets the union as ConvertErrorCode. The crate's io code has no counterpart here: there is no filesystem to read from.

Building

wasm-pack build wasm --release --target web --scope firecrawl
node --test wasm/test.mjs

This produces the npm package in wasm/pkg/: the module, the JS glue, and TypeScript definitions. Publishing runs from ../.github/workflows/release.yml on release tags.

Demo page

www/ holds the static demo site, which imports the module from www/pkg/. Build into that directory, then serve www/:

wasm-pack build wasm --release --target web --no-pack --out-dir www/pkg
python -m http.server -d wasm/www

../.github/workflows/pages.yml builds and deploys the same layout to GitHub Pages on every push to main.

版本与发布记录

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

版本发布日期距今
0.2.4latest2026/08/282 个月前
0.2.32026/08/212 个月前
0.2.22026/08/212 个月前
0.2.12026/08/212 个月前
0.2.02026/08/202 个月前
0.1.92026/08/143 个月前

关于 @firecrawl/anydoc-wasm 的常见问题

@firecrawl/anydoc-wasm 是什么?

WebAssembly bindings for anydoc: convert documents (doc, docx, odt, rtf, epub, pdf, presentations, spreadsheets, csv) to GitHub-Flavored Markdown in the browser

如何安装 @firecrawl/anydoc-wasm?

在项目目录运行 npm install @firecrawl/anydoc-wasm,或使用 pnpm add / yarn add / bun add。

@firecrawl/anydoc-wasm 支持 TypeScript 吗?

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

@firecrawl/anydoc-wasm 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@firecrawl/anydoc-wasm 可以商用吗?

@firecrawl/anydoc-wasm 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@firecrawl/anydoc-wasm 的下载量有多少?

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

@firecrawl/anydoc-wasm 还在维护吗?

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