Skip to content
المشاريع

حول

An internal component used by DeepSeek Harness

التصميم والوسائط

كيف تُقاس هذه الأرقام

243 نجمة24 التفرعات +1 خلال 24 ساعة

النمو المقاس للنجوم

خلال 24 ساعة
+١
خلال 7 أيام
+١٧
خلال 15 يومًا
+٢٠
خلال شهر
جارٍ جمع السجل

تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.

README.md

الأصل

Upgrade to alpha6. description: "Font-friendly Office-to-PDF conversion in Node.js, with prebuilt LibreOffice engines." kind: "package-library"

@deepseek-ai/libreoffice-kit

English | 中文

Current goal

Font-friendly Office conversion, rendering, and native editing in Node.js. 0.2.5 provides persistent DOCX, XLSX, and PPTX editing with optional native Skia Graphite rendering alongside format conversion, spreadsheet recalculation, the CLI, direct PNG rendering, and shared converter-factory font caches.

Windows Ganesh shared output requires Vulkan external-memory and Win32 keyed-mutex support. On the tested Adreno X2-45 driver 32.0.163.2, these capabilities are unavailable: explicit "ganesh" fails with an availability error, while "auto" resolves to "raster". Graphite uses Dawn/WebGPU and was qualified separately on that device.

The priorities are document layout and readable text, explicit control over available fonts and substitutions, and an engine that applications can bundle and run offline. Size reduction serves that goal: retain the import, layout, drawing, and PDF-export machinery these documents need while removing unrelated desktop features and resources.

The API supports Office export and recalculation plus direct PNG rendering of Office and PDF inputs. Use it in a Node.js service, a desktop application, or a document-processing job. Applications manage their own authorization, storage, and preview interfaces.

Binary .doc, .xls, and .ppt support covers OLE compound documents such as Office 97–2003. RTF/HTML files renamed to these suffixes and .wps are not accepted. missingFonts reports declarations found in OOXML; binary formats return an empty list while LibreOffice performs font matching.

Quick start

Requires Node.js 22.19.0 or newer. Install 0.2.5 with its optional engines once it is published. Before publication, prepare and qualify local packages using the build guide:

npm install @deepseek-ai/[email protected]

This installs at most one engine: the native engine for macOS or Windows on ARM64/x64, or glibc Linux on ARM64/x64. Linux engines require glibc 2.28 or newer at runtime. Hosts without a matching target, such as musl Linux, Linux ARM32, or FreeBSD, get no engine by default and need the portable WASM engine, which is never installed automatically and must match the adapter exactly:

npm install @deepseek-ai/[email protected]

The package installs the dsoffice command. From a local installation:

npm exec -- dsoffice render --input report.docx --output-dir report-pages --pages 1
npm exec -- dsoffice convert --input report.docx --output report.pdf
npm exec -- dsoffice recalculate --input budget.xlsx --output recalculated.xlsx
import { createConverter } from '@deepseek-ai/libreoffice-kit';

const converter = await createConverter({
  timeoutMs: 120_000,
  // Omit to discover fonts in conventional system/user directories.
  // fontDirectories: ['/absolute/path/to/fonts'],
});
try {
  const result = await converter.render({
    inputPath: '/private/work/document.docx',
    outputPath: '/private/work/document.pdf',
  });
  console.log(result.backend, result.missingFonts, result.pageCount);
} finally {
  await converter.dispose();
}

Supply absolute paths in caller-owned private directories; the output must not already exist. The PDF is written to outputPath, and render returns the selected backend, missing-font names, and the PDF's page count. Each render owns a fresh native process or Node worker and private profile. Renders on one converter are serialized; cancellation and disposal wait for engine exit and cleanup. See the Node API for cancellation, errors, and resource limits.

Native editing

The @deepseek-ai/libreoffice-kit/editor entry opens one native process per DOCX, XLSX, or PPTX document. Applications supply document bytes and their own interface, explicitly enable edits, render document tiles or Impress playback, and save original-format snapshots. Closing a document waits for its process and private files to be cleaned up. See the editor API for ownership, pixel formats, and optional shared-surface transport.

Native Word, Excel and PowerPoint views hide comment bodies, anchors, tags, cell indicators and hover popups in both read-only and editing modes. Original-format snapshots retain comment text, authors and reply links; the editor provides no comment viewer.

On macOS and Windows, renderBackend selects how the native editor draws. The default "auto" uses LibreOffice's existing Skia Ganesh GPU backend (Vulkan on Windows, Metal on macOS) and keeps CPU drawing when the driver is denylisted or the GPU context cannot start; the resolved backend is reported so callers can surface that fallback. "ganesh" requires the GPU backend and rejects the open when it is unavailable, "graphite" opts into the experimental Dawn/WebGPU recorder, and "raster" forces CPU drawing for diagnostics. Failures never select another backend silently. Graphite recording failures and WebGPU device errors stop GPU output and report the first failure. The 0.2.5 Node API keeps the published 0.2.4 engines: native preview engines for macOS and Windows on ARM64 and x64, Linux glibc engines that draw with raster only, and the portable WASM engine. Shared-image receivers still release frames after display completion, and switching backends requires explicitly opening a new document process.

Font control

  • Use available fonts. The API discovers conventional system/user font directories, or indexes the roots supplied through fontDirectories. Custom roots replace the default list. fontkit reads font metadata and glyph coverage; selected files are passed to the engine as original font bytes.
  • Preserve requested families when available. Exact installed families take priority, including handwriting and decorative fonts. WASM font requests also carry weight and italic information so matching installed faces can be selected; the catalog can supply additional fonts for missing glyphs.
  • Make substitutions configurable. Default fontFallbacks cover common Latin and Simplified Chinese families, including Carlito for missing Calibri and Caladea for missing Cambria. Caller-supplied groups replace the defaults. Mixed text and symbols keep a text family as the primary substitute; symbol-only requests can prefer symbol fonts. These preferences only select available fonts; they do not install them. See the default groups.
  • Expose missing families and font budgets. missingFonts reports unavailable families declared in readable document XML. maxFontFiles, maxFontFileBytes, and maxLoadedFontBytes bound indexing and explicit imports. Each operation rediscovers and revalidates fonts. Unchanged file metadata is shared in memory and in a bounded user-local disk cache; see cache options and invalidation.

No font collection is bundled or downloaded. Deployments supply fonts appropriate to their documents and redistribution rights; minimal containers need fonts installed or a configured font directory. WASM uses only imported fonts and rejects conversion with unavailable if none are usable. Native macOS and Windows can also use OS-managed fonts.

This improves control over font choice, but does not guarantee identical output to Microsoft Office or between engines. Native LibreOffice resolves installed originals and metric-compatible families before configured substitutions, and handles face selection itself. Font metrics can change line breaks and pagination; missingFonts is not a complete missing-glyph report. Comparing engines requires identical document bytes, fonts, and export options.

Engines and distribution

The Node package manifest declares the native engines as optional dependencies; the WASM engine is released alongside them but installed only on request:

Engine Role
@deepseek-ai/libreoffice-kit-darwin-arm64 Native helper for macOS on Apple Silicon.
@deepseek-ai/libreoffice-kit-darwin-x64 Native helper for Intel macOS.
@deepseek-ai/libreoffice-kit-linux-arm64-glibc Preliminary native helper for Linux ARM64; same glibc 2.28 and zlib requirements and conversion/rendering-only capabilities as x64.
@deepseek-ai/libreoffice-kit-linux-x64-glibc Native helper for Linux x64; requires glibc 2.28 or newer and zlib. Built in manylinux_2_28 with a statically linked C++ runtime. Conversion and rendering only: no native preview (openDocument() rejects).
@deepseek-ai/libreoffice-kit-win32-arm64 Native helper for Windows ARM64; requires ARM64 Node.js and the Microsoft Visual C++ v14 ARM64 Redistributable.
@deepseek-ai/libreoffice-kit-win32-x64 Native helper for Windows x64; requires the Microsoft Visual C++ v14 x64 Redistributable.
@deepseek-ai/libreoffice-kit-wasm Portable Node WASM engine, installed manually with the exact ENGINE_VERSIONS.wasm version, for hosts without a usable native engine.

Linux ARM64 support is preliminary. The previous CI build compiled successfully but crashed on ordinary documents. The engine must be rebuilt with the UNO instruction-cache fix and qualified for conversion and rendering on ARM64 before release.

The WASM package has no npm os, CPU, or libc restriction, so a direct dependency installs it on any host without --force; installation eligibility alone does not certify every host. Document layout and PDF serialization remain on the CPU; macOS and Windows native editors can select Graphite for GPU drawing.

A normal installation downloads at most one engine: the matching native package, or none. The adapter prefers a compatible installed native engine. When none is usable — the host has no native target (for example musl Linux, Linux ARM32, FreeBSD, Windows ia32), the native package is not installed, or the host glibc is below the native minimum — it uses a manually installed WASM engine; without one, conversion rejects with unavailable and an error naming npm install @deepseek-ai/[email protected]. A corrupt installed native engine still rejects with unavailable; conversion failures do not switch engines. Native preview is available only when discoverRuntime().nativePreview is true: with preview-capable macOS and Windows engines. Linux engines convert and render only; openDocument() rejects them.

The adapter locates engine packages with Node module resolution from its own installation. Applications that store engine files elsewhere, such as Electron applications that unpack them from an ASAR archive, pass the same resolveEnginePackage(name) option to createConverter, createConverterFactory, openDocument, and discoverRuntime. It returns the absolute path of the named engine package's package.json, or throws an error with code MODULE_NOT_FOUND when the native package is absent. The adapter itself contains no Electron or ASAR handling; see the package README and the Electron example.

The Node API and platform engines have independently pinned compatible versions. Installation uses prepared packages; no install hook or conversion compiles LibreOffice, downloads extra engines, or discovers the user's LibreOffice installation. npm distributes standard .tgz packages. GitHub Release engine downloads use verified XZ transfer archives for application builders to prepare and bundle. See packaging and release procedures for these distribution paths and installed-conversion checks.

What was reduced, and why

The recipes reduce build components, linked code, installed resources, and transfer size separately:

Layer Changes in the code Reason
Native build Disable Java/Python, scripting and extensions, Base database connectivity, PDF import, help/dictionaries, galleries/templates/icon themes, remote control, updates, and unused curl/WebDAV/CMIS/LDAP integrations. Local OOXML → PDF needs document import and PDF export; desktop automation, database access, PDF input, and online services add dependencies outside that path.
Native linkage Statically link Core on every native target, restrict exports, and discard unreachable code. System libraries and the Windows CRT remain dynamic. Reduce code retained by shared-library export boundaries.
Native payload Remove the verified duplicate macOS urelibs alias, SDK tools, launchers, Quick Look/Spotlight resources, disabled libraries, Basic/Python scripts, notebookbars, menus, and toolbars. Strip nonessential symbols while preserving dynamic exports; restore and verify macOS signatures. Avoid shipping duplicate libraries and desktop/development resources in an application conversion engine.
WASM build and payload Build Writer, Calc, and Impress for headless Node workers, with Java/Python, bundled fonts, OpenCL/OpenGL, and Skia disabled. Prune icon archives, notebookbars, menus/toolbars, Android sample documents, splash images, and shell resources from dsoffice.data. Keep the document engines and CPU rendering path while reducing resources loaded into the WASM filesystem. The resource-pruning pass preserves retained bytes and metadata, regenerates offsets, and leaves the compiled module unchanged. The packaged loader references the dsoffice asset names.
Font payload Omit bundled font collections; load original font files supplied by the deployment at runtime. Avoid a fixed font payload and let applications choose the fonts needed for their documents, including CJK coverage and Office-compatible alternatives.
Release transfer Use XZ for GitHub Release engine downloads, with separate size/hash checks for the compressed envelope and exact installation tar. Reduce transfer bytes without changing installed engine contents. This is separate from payload pruning and from npm's .tgz format.

The authoritative recipes are native configuration, native payload pruning, WASM configuration, and WASM resource pruning.

Native payload pruning removes XSLT resources and their filter registry, plus CREDITS.fodt. Installation LICENSE.html copies are removed only when byte-identical third-party notices remain under licenses/. The removed XSLT formats include Word 2003 XML, SpreadsheetML, UOF, DocBook, and XHTML; binary Office and OOXML conversion filters remain.

Windows statically links OpenSSL and disables NSS/GPGME. Payload pruning removes linked archives, scanner/GPG helpers, MSI installers, Shell extensions, ActiveX/SharePoint integrations, .NET CLI bindings, desktop launchers, Python wizards, and branding images. Static service registration omits desktop accessibility and OLE server registration. The conversion helper, selected UNO components, and runtime .ini files remain; see packaging.

Writer, Calc, Impress, binary Office and OOXML filters, PDF export, PDFium for embedded PDF/EMF graphics, shared layout/drawing libraries, charts, ICU and language resources remain. The native en-US build language selects UI resources; it does not restrict document text to English. Required runtime configuration and some UI resources remain because document services still use them. Matching source recipes, patches, hashes, and license notices travel with every engine package. These retained dependencies explain why the result is still a substantial document engine.

Recorded size and fidelity checks

The existing local candidate measurements compare the preceding 0.1.2 gzip packages with the independently versioned 0.0.1 XZ packages. They combine payload changes and compression changes; the download reduction is not solely code removal. These are historical candidate measurements, not current npm download sizes. MB means 1,000,000 bytes; unpacked size sums regular files and excludes filesystem allocation and dependency packages.

Engine Previous download 0.0.1 download Reduction Previous unpacked 0.0.1 unpacked
macOS ARM64 98.85 MB 60.49 MB 38.81% 301.04 MB 269.43 MB
Node WASM 56.47 MB 35.85 MB 36.51% 210.24 MB 190.64 MB

The recorded local macOS ARM64 check installed the same candidate offline with native and WASM selection. Six synthetic DOCX/XLSX/PPTX documents per engine, covering Chinese/English text, tables, formulas, and images, retained identical extracted text, page counts, and 96-DPI rendered pixels against the preceding packages. This covers those fixtures and that host; it does not establish universal document fidelity or other-platform qualification. Runtime suites also cover external-link suppression, font substitutions, limits, and cancellation; release qualification requires installed-engine evidence.

Build guide

See Building and qualifying engines for platform prerequisites, caller-selected paths, explicit parallelism, and package qualification. Use the source and toolchain versions pinned in the checkout being built. .github/workflows/libreoffice-kit-build-native.yml compiles every declared engine on hosted runners, and .github/workflows/libreoffice-kit-candidate.yml assembles and uploads the qualification candidate from those artifacts.

Development

Native sources and the Node WASM recipe use the same LibreOffice revision pinned by the engine/core submodule. .gitmodules owns its upstream URL and the gitlink owns its commit. Checkout scripts keep that submodule pristine and create disposable, patchable trees under ignored .build/ directories. This repository owns component selection and the complete packaging recipe; each engine ships the matching source and license materials.

Run the repository checks without building LibreOffice:

pnpm verify:metadata
pnpm test
pnpm test:packaging

Real engine tests additionally require pnpm run build:adapter, prepared engine payloads, and LIBREOFFICE_RUNTIME_ENTRY pointing to the absolute path of packages/entry/lib/index.js. Build platforms sequentially with explicit parallelism suited to CPU and memory; pnpm gha:matrix lists the platform matrix. Build output remains ignored.

Benchmarks measure the public disk API in separate native and WASM installations and distinguish first font indexing from converter reuse. Use the same source revision, documents, font roots, and PDF options for comparisons; frontend transport and painting are separate measurements.

استكشف مشاريع مشابهة ومرتبطة

جارٍ التحميل…