mirror of
https://github.com/2234839/web-font.git
synced 2026-09-04 23:02:27 +08:00
- 修复 fonteditor-core 模块声明(添加 FontEditor 命名空间、FontType 类型、SubsetOptions 接口) - 修复 llrt.ts 中 mkdir 和 rm 方法的返回类型问题 - 修复 tcp_server.ts 中 chunk 类型问题(添加 Buffer 类型检查和转换) - 修复 font_detail.ts 中缺失的 ORIGIN 导入 - 修复 subset.ts 中 subsetQueueTimeoutSeconds 的导入 - 为 Font 类添加 optimize() 和 write() 方法声明
32 lines
912 B
TypeScript
32 lines
912 B
TypeScript
import "web-streams-polyfill/polyfill";
|
||
import { implInterface } from "../interface";
|
||
import * as fs from "fs/promises";
|
||
|
||
/**
|
||
* 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);
|
||
},
|
||
});
|