惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
小众软件
小众软件
博客园 - 三生石上(FineUI控件)
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园_首页
Last Week in AI
Last Week in AI
美团技术团队
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Apple Machine Learning Research
Apple Machine Learning Research
WordPress大学
WordPress大学
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
博客园 - Franky
The Cloudflare Blog
罗磊的独立博客
月光博客
月光博客
N
Netflix TechBlog - Medium
C
Check Point Blog
Microsoft Security Blog
Microsoft Security Blog
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
IT之家
IT之家
Jina AI
Jina AI
J
Java Code Geeks

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(pdf): resolve standard fonts from pdfjs package root ...
anyech · 2026-04-30 · via Recent Commits to openclaw:main

@@ -1,7 +1,11 @@

1+

import { existsSync } from "node:fs";

2+

import { createRequire } from "node:module";

3+

import path from "node:path";

14

import { beforeEach, describe, expect, it, vi } from "vitest";

253-

const { canvasSizes, pdfDocument } = vi.hoisted(() => ({

6+

const { canvasSizes, getDocumentMock, pdfDocument } = vi.hoisted(() => ({

47

canvasSizes: [] as Array<{ width: number; height: number }>,

8+

getDocumentMock: vi.fn(),

59

pdfDocument: {

610

numPages: 2,

711

getPage: vi.fn(async () => ({

@@ -16,7 +20,7 @@ const { canvasSizes, pdfDocument } = vi.hoisted(() => ({

1620

}));

17211822

vi.mock("pdfjs-dist/legacy/build/pdf.mjs", () => ({

19-

getDocument: vi.fn(() => ({ promise: Promise.resolve(pdfDocument) })),

23+

getDocument: getDocumentMock,

2024

}));

21252226

vi.mock("@napi-rs/canvas", () => ({

@@ -30,9 +34,13 @@ vi.mock("@napi-rs/canvas", () => ({

30343135

import { createPdfDocumentExtractor } from "./document-extractor.js";

323637+

const require = createRequire(import.meta.url);

38+3339

describe("PDF document extractor", () => {

3440

beforeEach(() => {

3541

canvasSizes.length = 0;

42+

getDocumentMock.mockReset();

43+

getDocumentMock.mockReturnValue({ promise: Promise.resolve(pdfDocument) });

3644

pdfDocument.getPage.mockClear();

3745

});

3846

@@ -59,4 +67,34 @@ describe("PDF document extractor", () => {

5967

expect(result?.images).toHaveLength(1);

6068

expect(canvasSizes).toEqual([{ width: 10, height: 10 }]);

6169

});

70+71+

it("passes standardFontDataUrl to pdfjs getDocument as a package-root filesystem path", async () => {

72+

const extractor = createPdfDocumentExtractor();

73+74+

await extractor.extract({

75+

buffer: Buffer.from("%PDF-1.4"),

76+

mimeType: "application/pdf",

77+

maxPages: 1,

78+

maxPixels: 4_000_000,

79+

minTextChars: 200,

80+

});

81+82+

expect(getDocumentMock).toHaveBeenCalledTimes(1);

83+

const [params] = getDocumentMock.mock.calls[0] ?? [];

84+

expect(params).toMatchObject({

85+

disableWorker: true,

86+

});

87+

expect(typeof params.standardFontDataUrl).toBe("string");

88+89+

const expectedStandardFontDataUrl =

90+

path.join(path.dirname(require.resolve("pdfjs-dist/package.json")), "standard_fonts") + "/";

91+

expect(params.standardFontDataUrl).toBe(expectedStandardFontDataUrl);

92+

expect(path.isAbsolute(params.standardFontDataUrl)).toBe(true);

93+

expect(params.standardFontDataUrl.endsWith("/")).toBe(true);

94+

expect(params.standardFontDataUrl.startsWith("file://")).toBe(false);

95+

expect(existsSync(params.standardFontDataUrl)).toBe(true);

96+

expect(existsSync(path.join(params.standardFontDataUrl, "LiberationSans-Regular.ttf"))).toBe(

97+

true,

98+

);

99+

});

62100

});