libreoffice-engine.ts 760 B

1234567891011121314151617
  1. /** Select the single LibreOffice payload from the kit's declared native targets. */
  2. /**
  3. * Require a declared native target even when its optional npm package is absent.
  4. * Targets without a declared native engine use WASM.
  5. * @param manifest - Installed LibreOffice kit package manifest.
  6. * @param target - Node platform and architecture of the distribution.
  7. * @returns Engine suffix used by the kit's npm packages.
  8. */
  9. export function selectOfficeEngine(
  10. manifest: { optionalDependencies?: Record<string, string> },
  11. target: { platform: string; arch: string },
  12. ): string {
  13. const native = `${target.platform}-${target.arch}`
  14. return Object.hasOwn(manifest.optionalDependencies ?? {}, `@deepseek-ai/libreoffice-kit-${native}`)
  15. ? native : 'wasm'
  16. }