/
githubmirror
/
angular-cli
Обзор
Документация
Войти
/
githubmirror
/
angular-cli
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
packages/angular/ssr/node/src/common-engine/inline-css-processor.ts
28 строк
923 B
Alan Agius
refactor: replace `critters` with `beasties`
28 окт 2024, 20:57
28 окт 2024, 20:57
15677d0
Код
Авторство
О чём код?
/** * @license * Copyright Google LLC All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.dev/license */ import { ɵInlineCriticalCssProcessor as InlineCriticalCssProcessor } from '@angular/ssr'; import { readFile } from 'node:fs/promises'; export class CommonEngineInlineCriticalCssProcessor { private readonly resourceCache = new Map<string, string>(); async process(html: string, outputPath: string | undefined): Promise<string> { const beasties = new InlineCriticalCssProcessor(async (path) => { let resourceContent = this.resourceCache.get(path); if (resourceContent === undefined) { resourceContent = await readFile(path, 'utf-8'); this.resourceCache.set(path, resourceContent); } return resourceContent; }, outputPath); return beasties.process(html); } }