Files
webstudio/packages/css-data/bin/html.css.ts
T
Bogdan Chadkin 3dd8c2f482 refactor: upgrade html-tags (#3946)
The new version exports types with normal casing,
the package is completely esm and reexports json with new syntax.

https://github.com/sindresorhus/html-tags/blob/main/index.js#L1

Also reused voidHtmlTags in collapsed instance logic.
2024-08-16 11:24:57 +02:00

19 lines
793 B
TypeScript

import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
import type { StyleValue } from "@webstudio-is/css-engine";
import { parseCss } from "../src/parse-css";
const css = readFileSync("./src/html.css", "utf8");
const parsed = parseCss(css);
const result: [string, StyleValue][] = [];
for (const styleDecl of parsed) {
result.push([`${styleDecl.selector}:${styleDecl.property}`, styleDecl.value]);
}
let code = "";
code += `import type { HtmlTags } from "html-tags";\n`;
code += `import type { StyleValue } from "@webstudio-is/css-engine";\n\n`;
const map = "new Map<`${HtmlTags}:${string}`, StyleValue>";
code += `export const html = ${map}(${JSON.stringify(result)})`;
mkdirSync("./src/__generated__", { recursive: true });
writeFileSync("./src/__generated__/html.ts", code);