Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | 5x 3x 2x 1x 3x 3x 1x | import { IBookProvider,
IBookAsset,
IEngineLoader,
ProgressCallback,
IEngineSourceConfig, } from "../types.js";
/**
* 2026 Zenith Tier: 定跡書プロバイダーの標準実装。
* エンジンローダーとストレージを活用して、定跡ファイルを管理します。
*/
export class BookProvider implements IBookProvider {
constructor(private loader: IEngineLoader) {}
async loadBook(
asset: IBookAsset,
options?: { signal?: AbortSignal; onProgress?: ProgressCallback },
): Promise<string> {
// 2026: IEngineSourceConfig に変換してロード (exactOptionalPropertyTypes & Discriminated Union 対応)
let config: IEngineSourceConfig;
if (asset.sri) {
config = {
url: asset.url,
type: "asset",
sri: asset.sri,
};
} else {
config = {
url: asset.url,
type: "asset",
__unsafeNoSRI: true,
};
}
if (asset.size) config.size = asset.size;
return await this.loader.loadResource(
"common-books", // 共有 ID
config,
options,
);
}
async listCachedBooks(): Promise<string[]> {
// 2026: ストレージからのリスト取得は IFileStorage の拡張が必要だが、
// 現状は空配列を返す。
return [];
}
async deleteBook(_id: string): Promise<void> {
// 2026: revoke 等の処理
}
}
|