mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-11-09 05:26:24 +09:00
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.
19 lines
793 B
TypeScript
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);
|