mirror of
https://github.com/2234839/web-font.git
synced 2026-11-20 17:24:48 +08:00
- 慢路径 subset(查询字+锚点字) 顺带建 .gidx, 冷启动 39.75s→0.43s - 去 async generator/worker 池/流式 pipeTo: LLRT 下非确定性饿死/segfault - eventsCache(fontPath+查询签名 LRU64): 重复查询免裁剪, 稳态 42ms - server 层 _bodyBytes 通道: header+body 单帧写回 + Content-Length - 修复 bodyBytes 分支头部双写导致响应尾部截断(done 事件丢失) - tcp 层 fire-and-forget write, close 只 end 不 destroy(保写缓冲) - 慢路径并发度 GLYPH_MATCH_SLOW_CONCURRENCY 可配(默认1) - 聚类排序+剪枝(PRUNE_MARGIN=0.35)减少冷路径裁剪量
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { implInterface } from "../interface";
|
||
import * as fs from "fs/promises";
|
||
|
||
/**
|
||
* 不再引入 web-streams-polyfill:polyfill 覆盖原生 ReadableStream/WritableStream
|
||
* 后,与 LLRT 原生 socket/net 的组合会出现非确定性写挂起、数据串扰
|
||
* (响应 body 混入别的连接的 HTTP 头)等问题;LLRT 自带 WHATWG streams。
|
||
|
||
/**
|
||
* LLRT 的 fs 适配层
|
||
*
|
||
* LLRT 的 fs.readdir 返回字符串数组,需要转换为 { name, isFile } 对象。
|
||
* LLRT 的 fs/promises 没有 unlink 方法,implInterface 中会自动用 rm 代替。
|
||
*/
|
||
implInterface({
|
||
stat: fs.stat,
|
||
readFile: fs.readFile,
|
||
writeFile: fs.writeFile,
|
||
async readdir(path) {
|
||
const names = await fs.readdir(path);
|
||
return Promise.all(
|
||
names.map(async (name) => {
|
||
const s = await fs.stat(`${path}/${name}`);
|
||
return { name, isFile: () => s.isFile(), isDirectory: () => s.isDirectory() };
|
||
})
|
||
);
|
||
},
|
||
mkdir: async (path) => {
|
||
await fs.mkdir(path, { recursive: true });
|
||
},
|
||
/** LLRT 没有 unlink,用 rm 代替,忽略返回值 */
|
||
rm: async (path: string) => {
|
||
await fs.rm(path);
|
||
},
|
||
});
|