perf(startup): load canvas, node-pty, ssh2, html-to-text and the OpenCode SDK on first use
Main module evaluation drops from ~420 ms to ~330 ms. Types stay as import type; the DeepSeek Harness chunks stay static because the protocol chunk shares code with Main startup paths.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { createCanvas } from '@napi-rs/canvas'
|
||||
// @napi-rs/canvas is a native module (~85 ms to load); load it on first OCR render (P6).
|
||||
|
||||
export async function* renderOcrPdf(
|
||||
buffer: Buffer,
|
||||
@@ -6,7 +6,10 @@ export async function* renderOcrPdf(
|
||||
signal?: AbortSignal
|
||||
): AsyncGenerator<{ pageNumber: number; data: Buffer; width: number; height: number }> {
|
||||
signal?.throwIfAborted()
|
||||
const { getDocument } = await import('pdfjs-dist/legacy/build/pdf.mjs')
|
||||
const [{ getDocument }, { createCanvas }] = await Promise.all([
|
||||
import('pdfjs-dist/legacy/build/pdf.mjs'),
|
||||
import('@napi-rs/canvas')
|
||||
])
|
||||
const task = getDocument({
|
||||
data: Uint8Array.from(buffer), disableFontFace: true,
|
||||
isOffscreenCanvasSupported: false, useSystemFonts: false, useWorkerFetch: false
|
||||
|
||||
Reference in New Issue
Block a user