@pairdraw/dom-css 0.16.2 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/behaviours/states/layers.js +27 -1
- package/dist/chunks/behaviours/states/layers.js.map +1 -1
- package/dist/chunks/behaviours/states/tailwind.js +16 -3
- package/dist/chunks/behaviours/states/tailwind.js.map +1 -1
- package/dist/chunks/browser.js +31 -4
- package/dist/chunks/browser.js.map +1 -1
- package/dist/chunks/export/bundle.js +21 -15
- package/dist/chunks/export/bundle.js.map +1 -1
- package/dist/chunks/export/storybook/export.js +1 -1
- package/dist/chunks/export/storybook/export.js.map +1 -1
- package/dist/chunks/import/html.js +103 -44
- package/dist/chunks/import/html.js.map +1 -1
- package/dist/export.d.ts +0 -7
- package/package.json +3 -3
- package/src/export/bundle.ts +24 -22
- package/src/export/html.ts +19 -2
- package/src/export/storybook/export.ts +1 -1
- package/src/import/jsx/core.ts +30 -5
- package/src/import/scene-graph.ts +5 -3
- package/src/runtime/headless/styles.ts +142 -64
- package/src/tokens/stylesheet.ts +42 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","names":["parse","parse"],"sources":["../../../src/import/style-attribute.ts","../../../src/runtime/headless/styles.ts","../../../src/runtime/headless/runtime.ts","../../../src/runtime/index.ts","../../../src/import/tailwind.ts","../../../src/import/html.ts"],"sourcesContent":["import { parse } from '@acemir/cssom'\nimport type { CSSStyleRuleLike } from '@acemir/cssom'\n\nimport type { DesignStyleDeclaration } from '../types'\n\nfunction firstStyleRule(cssText: string): CSSStyleRuleLike | null {\n const [rule] = parse(cssText).cssRules\n if (!rule || typeof rule !== 'object' || !('style' in rule)) return null\n return rule as CSSStyleRuleLike\n}\n\nexport function parseStyleAttribute(value: string | undefined): DesignStyleDeclaration | undefined {\n if (!value) return undefined\n\n const rule = firstStyleRule(`*{${value}}`)\n if (!rule) return undefined\n\n const style: DesignStyleDeclaration = {}\n for (const property of Array.from(rule.style)) {\n const propertyValue = rule.style.getPropertyValue(property)\n if (propertyValue) style[property] = propertyValue\n }\n\n return Object.keys(style).length > 0 ? style : undefined\n}\n","import type {\n DesignDocument,\n DesignElement,\n DesignNode,\n DesignStyleDeclaration\n} from '#dom-css/types'\nimport {\n parse,\n type CSSGroupingRuleLike,\n type CSSStyleDeclarationLike,\n type CSSStyleRuleLike\n} from '@acemir/cssom'\n\nimport { tryParseColor } from '@pairdraw/scene-graph/color'\nimport { parseCSSNumber, splitCSSValue } from '@pairdraw/scene-graph/css'\n\ninterface HeadlessCSSRule {\n selector: string\n specificity: number\n order: number\n style: DesignStyleDeclaration\n}\n\ninterface ParsedHeadlessCSS {\n rules: HeadlessCSSRule[]\n customProperties: DesignStyleDeclaration\n}\n\ninterface AncestorContext {\n element: DesignElement\n parent: AncestorContext | null\n}\n\nconst INHERITED_PROPERTIES = new Set([\n 'color',\n 'font-family',\n 'font-size',\n 'font-weight',\n 'line-height'\n])\n\nfunction styleToRecord(\n style: CSSStyleDeclarationLike,\n customProperties: DesignStyleDeclaration = {}\n): DesignStyleDeclaration {\n const result: DesignStyleDeclaration = {}\n for (const property of Array.from({ length: style.length }, (_, index) => style[index])) {\n const value = resolveCSSValue(style.getPropertyValue(property), customProperties)\n if (property && value) result[property] = value\n }\n return expandStyleShorthands(result)\n}\n\nfunction isStyleRule(rule: unknown): rule is CSSStyleRuleLike {\n return (\n typeof rule === 'object' &&\n rule !== null &&\n 'selectorText' in rule &&\n 'style' in rule &&\n typeof rule.selectorText === 'string'\n )\n}\n\nfunction isGroupingRule(rule: unknown): rule is CSSGroupingRuleLike {\n return (\n typeof rule === 'object' && rule !== null && 'cssRules' in rule && Array.isArray(rule.cssRules)\n )\n}\n\nfunction collectStyleRules(rules: unknown[]): CSSStyleRuleLike[] {\n return rules.flatMap((rule) => {\n if (isStyleRule(rule)) return [rule]\n if (isGroupingRule(rule)) return collectStyleRules(rule.cssRules)\n return []\n })\n}\n\nfunction parseRules(cssText: string): ParsedHeadlessCSS {\n let order = 0\n const sheet = parse(cssText)\n const styleRules = collectStyleRules(sheet.cssRules)\n const customProperties = collectCustomProperties(styleRules)\n const rules = styleRules.flatMap((rule) => {\n const style = styleToRecord(rule.style, customProperties)\n return rule.selectorText\n .split(',')\n .map((selector) => selector.trim())\n .filter((selector) => selector.length > 0)\n .map((selector) => ({\n selector,\n specificity: selectorSpecificity(selector),\n order: order++,\n style\n }))\n })\n return { rules, customProperties }\n}\n\nfunction collectCustomProperties(rules: CSSStyleRuleLike[]): DesignStyleDeclaration {\n const customProperties: DesignStyleDeclaration = {}\n for (const rule of rules) {\n if (!rule.selectorText.split(',').some((selector) => selector.trim() === ':root')) continue\n Object.assign(customProperties, styleToRecord(rule.style))\n }\n return customProperties\n}\n\nfunction resolveCSSValue(value: string, customProperties: DesignStyleDeclaration): string {\n const withVariables = value.replaceAll(/var\\((--[\\w-]+)(?:,[^)]+)?\\)/g, (_, name: string) => {\n return customProperties[name] ?? ''\n })\n return resolveSimpleCalc(withVariables)\n}\n\nfunction resolveSimpleCalc(value: string): string {\n const calc = value.match(/^calc\\(([-\\d.]+)(rem|px)?\\s*\\*\\s*([-\\d.]+)\\)$/)\n if (!calc?.[1] || !calc[3]) return value\n\n const base = Number.parseFloat(calc[1])\n const multiplier = Number.parseFloat(calc[3])\n const unit = calc.at(2) ?? 'px'\n if (!Number.isFinite(base) || !Number.isFinite(multiplier)) return value\n return `${unit === 'rem' ? base * multiplier * 16 : base * multiplier}px`\n}\n\nconst BORDER_STYLES = new Set([\n 'none',\n 'hidden',\n 'dotted',\n 'dashed',\n 'solid',\n 'double',\n 'groove',\n 'ridge',\n 'inset',\n 'outset'\n])\n\n/**\n * Shorthands as the longhands they set, in declaration order, so a later declaration wins over\n * an earlier one whether it is a shorthand, a logical side, or a single side, as in CSS.\n */\nfunction expandStyleShorthands(style: DesignStyleDeclaration): DesignStyleDeclaration {\n const result: DesignStyleDeclaration = {}\n for (const [property, value] of Object.entries(style)) {\n result[property] = value\n Object.assign(result, longhandsOf(property, value))\n }\n return result\n}\n\nfunction longhandsOf(property: string, value: string): DesignStyleDeclaration {\n if (property === 'margin' || property === 'padding') return boxSides(property, value)\n const logical = /^(margin|padding)-(inline|block)$/u.exec(property)\n if (logical) return logicalSides(property, value, logical[2] === 'inline')\n if (property === 'border') return borderLonghands(value)\n if (property === 'background') {\n const color = splitCSSValue(value).find(isColor)\n return color ? { 'background-color': color } : {}\n }\n return {}\n}\n\nfunction boxSides(property: string, value: string): DesignStyleDeclaration {\n const [top, right = top, bottom = top, left = right] = splitCSSValue(value)\n if (!top || !right || !bottom || !left) return {}\n return {\n [`${property}-top`]: top,\n [`${property}-right`]: right,\n [`${property}-bottom`]: bottom,\n [`${property}-left`]: left\n }\n}\n\n/** `padding-inline` and `padding-block` as the sides they set in left-to-right, horizontal text. */\nfunction logicalSides(property: string, value: string, inline: boolean): DesignStyleDeclaration {\n const box = property.slice(0, property.lastIndexOf('-'))\n const [first, second = first] = splitCSSValue(value)\n if (!first || !second) return {}\n const [start, end] = inline ? ['left', 'right'] : ['top', 'bottom']\n return { [`${box}-${start}`]: first, [`${box}-${end}`]: second }\n}\n\nfunction borderLonghands(value: string): DesignStyleDeclaration {\n const parts = splitCSSValue(value)\n const longhands: DesignStyleDeclaration = {}\n const color = parts.find(isColor)\n const width = parts.find((part) => parseCSSNumber(part) !== null)\n const style = parts.find((part) => BORDER_STYLES.has(part.toLowerCase()))\n if (color) longhands['border-color'] = color\n if (width) longhands['border-width'] = width\n if (style) longhands['border-style'] = style.toLowerCase()\n return longhands\n}\n\n/** Any CSS color, including `transparent`, which a shorthand may set on purpose. */\nfunction isColor(value: string): boolean {\n return tryParseColor(value) !== null\n}\n\nfunction classList(element: DesignElement): Set<string> {\n const className = 'class' in element.attrs ? element.attrs.class : ''\n return new Set(className.split(/\\s+/).filter((name) => name.length > 0))\n}\n\nfunction elementId(element: DesignElement): string | undefined {\n return 'id' in element.attrs ? element.attrs.id : undefined\n}\n\nfunction selectorSpecificity(selector: string): number {\n const idCount = selector.match(/#[\\w-]+/g)?.length ?? 0\n const classCount = selector.match(/\\.[\\w-]+/g)?.length ?? 0\n // A tag counts once per compound; the universal selector, alone or as in `*.card`, counts zero.\n const tagCount = selector.split(/[\\s>]+/).filter((part) => /^[a-z]/iu.test(part)).length\n return idCount * 100 + classCount * 10 + tagCount\n}\n\nfunction matchesSimpleSelector(element: DesignElement, selector: string): boolean {\n if (selector.includes(':') || selector.includes('[')) return false\n\n const idMatch = selector.match(/#([\\w-]+)/)\n if (idMatch?.[1] && elementId(element) !== idMatch[1]) return false\n\n const classes = selector.match(/\\.[\\w-]+/g) ?? []\n const elementClasses = classList(element)\n if (!classes.every((name) => elementClasses.has(name.slice(1)))) return false\n\n const tag = selector.replace(/#[\\w-]+/g, '').replace(/\\.[\\w-]+/g, '')\n // The universal selector, as Tailwind's preflight uses for `box-sizing`, matches any element.\n return tag.length === 0 || tag === '*' || element.tagName.toLowerCase() === tag.toLowerCase()\n}\n\nfunction matchesSelector(\n element: DesignElement,\n selector: string,\n parent: AncestorContext | null\n): boolean {\n const childParts = selector.split('>').map((part) => part.trim())\n if (childParts.length > 1) return matchesChildSelector(element, childParts, parent)\n\n const descendantParts = selector.split(/\\s+/).filter((part) => part.length > 0)\n if (descendantParts.length > 1) return matchesDescendantSelector(element, descendantParts, parent)\n\n return matchesSimpleSelector(element, selector)\n}\n\nfunction matchesSelectorParts(\n element: DesignElement,\n parts: string[],\n parent: AncestorContext | null,\n directParentOnly: boolean\n): boolean {\n const current = parts.at(-1)\n if (!current || !matchesSimpleSelector(element, current)) return false\n\n let ancestor = parent\n for (const selector of parts.slice(0, -1).reverse()) {\n if (!directParentOnly) {\n while (ancestor && !matchesSimpleSelector(ancestor.element, selector)) {\n ancestor = ancestor.parent\n }\n }\n if (!ancestor || !matchesSimpleSelector(ancestor.element, selector)) return false\n ancestor = ancestor.parent\n }\n return true\n}\n\nfunction matchesChildSelector(\n element: DesignElement,\n parts: string[],\n parent: AncestorContext | null\n): boolean {\n return matchesSelectorParts(element, parts, parent, true)\n}\n\nfunction matchesDescendantSelector(\n element: DesignElement,\n parts: string[],\n parent: AncestorContext | null\n): boolean {\n return matchesSelectorParts(element, parts, parent, false)\n}\n\nfunction applyComputedStyles(\n node: DesignNode,\n rules: HeadlessCSSRule[],\n parent: AncestorContext | null,\n inheritedStyle: DesignStyleDeclaration\n): DesignNode {\n if (node.type === 'text') return node\n\n const computedStyle: DesignStyleDeclaration = pickInheritedStyle(inheritedStyle)\n const matchingRules = rules\n .filter((rule) => matchesSelector(node, rule.selector, parent))\n .sort((left, right) => left.specificity - right.specificity || left.order - right.order)\n\n for (const rule of matchingRules) Object.assign(computedStyle, rule.style)\n Object.assign(computedStyle, expandStyleShorthands(node.inlineStyle ?? {}))\n\n const context = { element: node, parent }\n return {\n ...node,\n computedStyle: Object.keys(computedStyle).length > 0 ? computedStyle : undefined,\n children: node.children.map((child) =>\n applyComputedStyles(child, rules, context, computedStyle)\n )\n }\n}\n\nfunction pickInheritedStyle(style: DesignStyleDeclaration): DesignStyleDeclaration {\n const inherited: DesignStyleDeclaration = {}\n for (const property of INHERITED_PROPERTIES) {\n const value = style[property]\n if (value) inherited[property] = value\n }\n return inherited\n}\n\nexport function computeHeadlessStyles(document: DesignDocument, cssText = ''): DesignDocument {\n const stylesheetText = [document.stylesheets?.map((sheet) => sheet.cssText).join('\\n'), cssText]\n .filter((text): text is string => !!text)\n .join('\\n')\n const { rules } = parseRules(stylesheetText)\n\n return {\n ...document,\n children: document.children.map((child) => applyComputedStyles(child, rules, null, {}))\n }\n}\n","import { serializeHTML } from '#dom-css/export/html'\nimport { INLINE_TAGS } from '#dom-css/import/flow'\nimport { parseStyleAttribute } from '#dom-css/import/style-attribute'\nimport type { CSSRuntime, DesignDocument, DesignElement, DesignNode } from '#dom-css/types'\nimport { parseFragment, type DefaultTreeAdapterTypes } from 'parse5'\n\nimport { computeHeadlessStyles } from './styles'\n\nfunction attrsToRecord(attrs: DefaultTreeAdapterTypes.Element['attrs']): Record<string, string> {\n const result: Record<string, string> = {}\n for (const attr of attrs) result[attr.name] = attr.value\n return result\n}\n\nfunction isTextNode(\n node: DefaultTreeAdapterTypes.ChildNode\n): node is DefaultTreeAdapterTypes.TextNode {\n return node.nodeName === '#text'\n}\n\nconst NON_RENDERED_TAGS = new Set(['head', 'link', 'meta', 'script', 'style', 'template', 'title'])\n\nfunction isInlineElement(node: DefaultTreeAdapterTypes.ChildNode | undefined): boolean {\n return node !== undefined && 'tagName' in node && INLINE_TAGS.has(node.tagName.toLowerCase())\n}\n\n/**\n * Text, and the spaces in or beside inline elements, which CSS draws among their words; spaces\n * between blocks lay nothing out, so they are left out.\n */\nfunction keepsText(\n node: DefaultTreeAdapterTypes.TextNode,\n siblings: readonly DefaultTreeAdapterTypes.ChildNode[],\n index: number,\n inInline: boolean\n): boolean {\n if (node.value.trim().length > 0) return true\n return (\n node.value.length > 0 &&\n (inInline || isInlineElement(siblings[index - 1]) || isInlineElement(siblings[index + 1]))\n )\n}\n\nfunction childrenToDesignNodes(\n nodes: readonly DefaultTreeAdapterTypes.ChildNode[],\n inInline: boolean\n): DesignNode[] {\n return nodes\n .map((node, index) => childToDesignNode(node, index, nodes, inInline))\n .filter((child): child is DesignNode => child !== null)\n}\n\nfunction childToDesignNode(\n node: DefaultTreeAdapterTypes.ChildNode,\n index: number,\n siblings: readonly DefaultTreeAdapterTypes.ChildNode[],\n inInline: boolean\n): DesignNode | null {\n if (isTextNode(node)) {\n return keepsText(node, siblings, index, inInline) ? { type: 'text', text: node.value } : null\n }\n\n if (!('tagName' in node)) return null\n if (NON_RENDERED_TAGS.has(node.tagName.toLowerCase())) return null\n\n const attrs = attrsToRecord(node.attrs)\n const element: DesignElement = {\n type: 'element',\n tagName: node.tagName.toLowerCase(),\n attrs,\n children: childrenToDesignNodes(node.childNodes, isInlineElement(node))\n }\n\n const inlineStyle = parseStyleAttribute(attrs.style)\n if (inlineStyle) element.inlineStyle = inlineStyle\n\n return element\n}\n\nfunction parseHTML(html: string): DesignDocument {\n const fragment = parseFragment(html)\n return {\n type: 'document',\n children: childrenToDesignNodes(fragment.childNodes, false)\n }\n}\n\nexport function createHeadlessCSSRuntime(): CSSRuntime {\n return {\n kind: 'headless',\n parseHTML,\n serializeHTML(document: DesignDocument) {\n return serializeHTML(document)\n },\n async computeStyles(document: DesignDocument, cssText = '') {\n return computeHeadlessStyles(document, cssText)\n }\n }\n}\n","import type { CSSRuntime } from '../types'\nimport { createBrowserCSSRuntime } from './browser/runtime'\nimport { createHeadlessCSSRuntime } from './headless/runtime'\n\nexport { createBrowserCSSRuntime } from './browser/runtime'\nexport type { BrowserCSSRuntimeOptions } from './browser/runtime'\nexport { createHeadlessCSSRuntime } from './headless/runtime'\n\nexport function createCSSRuntime(): CSSRuntime {\n return typeof document !== 'undefined' ? createBrowserCSSRuntime() : createHeadlessCSSRuntime()\n}\n","import { compile } from 'tailwindcss'\n\nexport interface CompileTailwindCSSOptions {\n css?: string\n base?: string\n loadStylesheet?: (id: string, base: string) => Promise<string>\n}\n\nconst DEFAULT_TAILWIND_CSS = '@import \"tailwindcss\";'\n\nexport async function compileTailwindCSS(\n classes: string | Iterable<string>,\n options: CompileTailwindCSSOptions = {}\n): Promise<string> {\n const compiler = await compile(tailwindCompilerCSS(options.css), {\n base: options.base,\n loadStylesheet: async (id, base) => {\n const content = options.loadStylesheet\n ? await options.loadStylesheet(id, base)\n : await loadTailwindStylesheet(id)\n return { path: id, base, content }\n }\n })\n return compiler.build(normalizeClasses(classes))\n}\n\nfunction tailwindCompilerCSS(css: string | undefined): string {\n const trimmed = css?.trim()\n if (!trimmed) return DEFAULT_TAILWIND_CSS\n if (containsTailwindImport(trimmed)) return trimmed\n return `${DEFAULT_TAILWIND_CSS}\\n${trimmed}`\n}\n\nfunction containsTailwindImport(css: string): boolean {\n const withoutComments = css.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n return /^\\s*@import\\s+(?:\"tailwindcss(?:\\/[^\"]*)?\"|'tailwindcss(?:\\/[^']*)?')/m.test(\n withoutComments\n )\n}\n\nfunction normalizeClasses(classes: string | Iterable<string>): string[] {\n const classNames = typeof classes === 'string' ? [classes] : Array.from(classes)\n return classNames\n .flatMap((className) => className.split(/\\s+/))\n .map((className) => className.trim())\n .filter((className) => className.length > 0)\n}\n\nasync function loadTailwindStylesheet(id: string): Promise<string> {\n const stylesheet = id === 'tailwindcss' ? 'tailwindcss/index.css' : id\n const url = new URL(import.meta.resolve(stylesheet))\n const { readFile } = await import(/* @vite-ignore */ 'node:fs/promises')\n return readFile(url, 'utf8')\n}\n","import { parse, type DefaultTreeAdapterTypes } from 'parse5'\n\nimport type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport { createCSSRuntime } from '../runtime'\nimport type { CSSComputeOptions, CSSRuntime, DesignDocument } from '../types'\nimport { mergeCSSText } from './css-text'\nimport { designDocumentToSceneGraph, type ToSceneGraphOptions } from './scene-graph'\nimport { compileTailwindCSS, type CompileTailwindCSSOptions } from './tailwind'\n\nexport interface HTMLToDesignDocumentOptions {\n cssText?: string\n runtime?: CSSRuntime\n compute?: CSSComputeOptions\n}\n\nexport interface HTMLToSceneGraphOptions extends HTMLToDesignDocumentOptions, ToSceneGraphOptions {}\n\nexport interface TailwindHTMLToDesignDocumentOptions\n extends Omit<HTMLToDesignDocumentOptions, 'cssText'>, CompileTailwindCSSOptions {}\n\nexport interface TailwindHTMLToSceneGraphOptions\n extends TailwindHTMLToDesignDocumentOptions, ToSceneGraphOptions {}\n\nfunction runtimeForOptions(runtime: CSSRuntime | undefined) {\n return runtime ?? createCSSRuntime()\n}\n\nfunction getChildNodes(node: DefaultTreeAdapterTypes.Node): DefaultTreeAdapterTypes.ChildNode[] {\n return 'childNodes' in node ? node.childNodes : []\n}\n\nfunction textContent(node: DefaultTreeAdapterTypes.Node): string {\n if (node.nodeName === '#text' && 'value' in node) return node.value\n return getChildNodes(node).map(textContent).join('')\n}\n\nfunction collectStyleText(node: DefaultTreeAdapterTypes.Node, styles: string[]): void {\n if ('tagName' in node && node.tagName.toLowerCase() === 'style') {\n const css = textContent(node).trim()\n if (css) styles.push(css)\n return\n }\n\n for (const child of getChildNodes(node)) collectStyleText(child, styles)\n}\n\nfunction extractEmbeddedCSSText(html: string): string | undefined {\n const styles: string[] = []\n collectStyleText(parse(html), styles)\n return styles.length > 0 ? styles.join('\\n') : undefined\n}\n\nexport async function htmlToDesignDocument(\n html: string,\n options: HTMLToDesignDocumentOptions = {}\n): Promise<DesignDocument> {\n const runtime = runtimeForOptions(options.runtime)\n const document = runtime.parseHTML(html)\n const cssText = mergeCSSText(extractEmbeddedCSSText(html), options.cssText)\n return runtime.computeStyles(document, cssText, options.compute)\n}\n\nexport async function htmlToSceneGraph(\n html: string,\n options: HTMLToSceneGraphOptions = {}\n): Promise<SceneGraph> {\n const document = await htmlToDesignDocument(html, options)\n return designDocumentToSceneGraph(document, options)\n}\n\nexport async function tailwindHTMLToDesignDocument(\n html: string,\n candidates: string | Iterable<string>,\n options: TailwindHTMLToDesignDocumentOptions = {}\n): Promise<DesignDocument> {\n const cssText = await compileTailwindCSS(candidates, options)\n return htmlToDesignDocument(html, { ...options, cssText })\n}\n\nexport async function tailwindHTMLToSceneGraph(\n html: string,\n candidates: string | Iterable<string>,\n options: TailwindHTMLToSceneGraphOptions = {}\n): Promise<SceneGraph> {\n const document = await tailwindHTMLToDesignDocument(html, candidates, options)\n return designDocumentToSceneGraph(document, options)\n}\n"],"mappings":";;;;;;;;;AAKA,SAAS,eAAe,SAA0C;CAChE,MAAM,CAAC,QAAQA,QAAM,OAAO,CAAC,CAAC;CAC9B,IAAI,CAAC,QAAQ,OAAO,SAAS,YAAY,EAAE,WAAW,OAAO,OAAO;CACpE,OAAO;AACT;AAEA,SAAgB,oBAAoB,OAA+D;CACjG,IAAI,CAAC,OAAO,OAAO,KAAA;CAEnB,MAAM,OAAO,eAAe,KAAK,MAAM,EAAE;CACzC,IAAI,CAAC,MAAM,OAAO,KAAA;CA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AAEA,eAAsB,6BACpB,MACA,YACA,UAA+C,CAAC,GACvB;CACzB,MAAM,UAAU,MAAM,mBAAmB,YAAY,OAAO;CAC5D,OAAO,qBAAqB,MAAM;EAAE,GAAG;EAAS;CAAQ,CAAC;AAC3D;AAEA,eAAsB,yBACpB,MACA,YACA,UAA2C,CAAC,GACvB;CACrB,MAAM,WAAW,MAAM,6BAA6B,MAAM,YAAY,OAAO;CAC7E,OAAO,2BAA2B,UAAU,OAAO;AACrD"}
|
|
1
|
+
{"version":3,"file":"html.js","names":["parse","parse"],"sources":["../../../src/import/style-attribute.ts","../../../src/runtime/headless/styles.ts","../../../src/runtime/headless/runtime.ts","../../../src/runtime/index.ts","../../../src/import/tailwind.ts","../../../src/import/html.ts"],"sourcesContent":["import { parse } from '@acemir/cssom'\nimport type { CSSStyleRuleLike } from '@acemir/cssom'\n\nimport type { DesignStyleDeclaration } from '../types'\n\nfunction firstStyleRule(cssText: string): CSSStyleRuleLike | null {\n const [rule] = parse(cssText).cssRules\n if (!rule || typeof rule !== 'object' || !('style' in rule)) return null\n return rule as CSSStyleRuleLike\n}\n\nexport function parseStyleAttribute(value: string | undefined): DesignStyleDeclaration | undefined {\n if (!value) return undefined\n\n const rule = firstStyleRule(`*{${value}}`)\n if (!rule) return undefined\n\n const style: DesignStyleDeclaration = {}\n for (const property of Array.from(rule.style)) {\n const propertyValue = rule.style.getPropertyValue(property)\n if (propertyValue) style[property] = propertyValue\n }\n\n return Object.keys(style).length > 0 ? style : undefined\n}\n","import type {\n DesignDocument,\n DesignElement,\n DesignNode,\n DesignStyleDeclaration\n} from '#dom-css/types'\nimport {\n parse,\n type CSSGroupingRuleLike,\n type CSSStyleDeclarationLike,\n type CSSStyleRuleLike\n} from '@acemir/cssom'\n\nimport { tryParseColor } from '@pairdraw/scene-graph/color'\nimport { parseCSSNumber, splitCSSValue } from '@pairdraw/scene-graph/css'\n\ninterface HeadlessCSSRule {\n selector: string\n specificity: number\n order: number\n /** Declared values with `var()` unresolved, so each element resolves them in its own scope. */\n declarations: DesignStyleDeclaration\n}\n\ninterface ParsedHeadlessCSS {\n rules: HeadlessCSSRule[]\n customProperties: DesignStyleDeclaration\n}\n\ninterface AncestorContext {\n element: DesignElement\n parent: AncestorContext | null\n}\n\nconst INHERITED_PROPERTIES = new Set([\n 'color',\n 'font-family',\n 'font-size',\n 'font-weight',\n 'line-height'\n])\n\n/** Declared values as written, before custom properties and shorthands are resolved. */\nfunction declarationsOf(style: CSSStyleDeclarationLike): DesignStyleDeclaration {\n const result: DesignStyleDeclaration = {}\n for (const property of Array.from({ length: style.length }, (_, index) => style[index])) {\n const value = style.getPropertyValue(property).trim()\n if (property && value) result[property] = value\n }\n return result\n}\n\nfunction resolveDeclarations(\n declarations: DesignStyleDeclaration,\n customProperties: DesignStyleDeclaration\n): DesignStyleDeclaration {\n const resolved: DesignStyleDeclaration = {}\n for (const [property, value] of Object.entries(declarations)) {\n const resolvedValue = resolveCSSValue(value, customProperties)\n if (resolvedValue) resolved[property] = resolvedValue\n }\n return expandStyleShorthands(resolved)\n}\n\n/** Adds the custom properties a declaration block sets, resolved against those already in scope. */\nfunction declareCustomProperties(\n scope: DesignStyleDeclaration,\n declarations: DesignStyleDeclaration\n): void {\n for (const [name, value] of Object.entries(declarations)) {\n if (!name.startsWith('--')) continue\n const resolved = resolveCSSValue(value, scope)\n if (resolved) scope[name] = resolved\n }\n}\n\nfunction isStyleRule(rule: unknown): rule is CSSStyleRuleLike {\n return (\n typeof rule === 'object' &&\n rule !== null &&\n 'selectorText' in rule &&\n 'style' in rule &&\n typeof rule.selectorText === 'string'\n )\n}\n\nfunction isGroupingRule(rule: unknown): rule is CSSGroupingRuleLike {\n return (\n typeof rule === 'object' && rule !== null && 'cssRules' in rule && Array.isArray(rule.cssRules)\n )\n}\n\nfunction collectStyleRules(rules: unknown[]): CSSStyleRuleLike[] {\n return rules.flatMap((rule) => {\n if (isStyleRule(rule)) return [rule]\n if (isGroupingRule(rule)) return collectStyleRules(rule.cssRules)\n return []\n })\n}\n\nfunction parseRules(cssText: string): ParsedHeadlessCSS {\n let order = 0\n const sheet = parse(cssText)\n const styleRules = collectStyleRules(sheet.cssRules)\n const customProperties = collectCustomProperties(styleRules)\n const rules = styleRules.flatMap((rule) => {\n const declarations = declarationsOf(rule.style)\n return rule.selectorText\n .split(',')\n .map((selector) => selector.trim())\n .filter((selector) => selector.length > 0)\n .map((selector) => ({\n selector,\n specificity: selectorSpecificity(selector),\n order: order++,\n declarations\n }))\n })\n return { rules, customProperties }\n}\n\nfunction collectCustomProperties(rules: CSSStyleRuleLike[]): DesignStyleDeclaration {\n const customProperties: DesignStyleDeclaration = {}\n for (const rule of rules) {\n if (!rule.selectorText.split(',').some((selector) => selector.trim() === ':root')) continue\n declareCustomProperties(customProperties, declarationsOf(rule.style))\n }\n return customProperties\n}\n\nfunction resolveCSSValue(value: string, customProperties: DesignStyleDeclaration): string {\n return resolveSimpleCalc(resolveVariables(value, customProperties))\n}\n\nconst CUSTOM_PROPERTY_NAME = /^--[\\w-]+$/\n\n/** `var()` references as their values; a fallback can hold parentheses and other `var()`s. */\nfunction resolveVariables(value: string, customProperties: DesignStyleDeclaration): string {\n let result = ''\n let index = 0\n for (;;) {\n const start = value.indexOf('var(', index)\n const end = start === -1 ? -1 : closingParenthesis(value, start + 3)\n if (end === -1) return result + value.slice(index)\n const inner = value.slice(start + 4, end)\n const comma = inner.indexOf(',')\n const name = (comma === -1 ? inner : inner.slice(0, comma)).trim()\n const declared: string | undefined = Object.hasOwn(customProperties, name)\n ? customProperties[name]\n : undefined\n const fallback = comma === -1 ? '' : inner.slice(comma + 1).trim()\n result += value.slice(index, start)\n result += CUSTOM_PROPERTY_NAME.test(name)\n ? (declared ?? resolveVariables(fallback, customProperties))\n : value.slice(start, end + 1)\n index = end + 1\n }\n}\n\n/** The index of the `)` closing the `(` at `open`, or -1 when it is never closed. */\nfunction closingParenthesis(value: string, open: number): number {\n let depth = 0\n for (let index = open; index < value.length; index++) {\n if (value[index] === '(') depth++\n else if (value[index] === ')' && --depth === 0) return index\n }\n return -1\n}\n\n/** `calc()` of a product, with the length on either side, as pixels. */\nfunction resolveSimpleCalc(value: string): string {\n const calc = /^calc\\(\\s*([-\\d.]+)(rem|px)?\\s*\\*\\s*([-\\d.]+)(rem|px)?\\s*\\)$/.exec(value)\n if (!calc?.[1] || !calc[3] || (calc[2] && calc[4])) return value\n\n const left = Number.parseFloat(calc[1])\n const right = Number.parseFloat(calc[3])\n // An unmatched group is undefined at run time, though the match array types it as a string.\n const unit = calc[2] || calc[4] || 'px'\n if (!Number.isFinite(left) || !Number.isFinite(right)) return value\n return `${unit === 'rem' ? left * right * 16 : left * right}px`\n}\n\nconst BORDER_STYLES = new Set([\n 'none',\n 'hidden',\n 'dotted',\n 'dashed',\n 'solid',\n 'double',\n 'groove',\n 'ridge',\n 'inset',\n 'outset'\n])\n\n/**\n * Shorthands as the longhands they set, in declaration order, so a later declaration wins over\n * an earlier one whether it is a shorthand, a logical side, or a single side, as in CSS.\n */\nfunction expandStyleShorthands(style: DesignStyleDeclaration): DesignStyleDeclaration {\n const result: DesignStyleDeclaration = {}\n for (const [property, value] of Object.entries(style)) {\n result[property] = value\n Object.assign(result, longhandsOf(property, value))\n }\n return result\n}\n\nfunction longhandsOf(property: string, value: string): DesignStyleDeclaration {\n if (property === 'margin' || property === 'padding') return boxSides(property, value)\n const logical = /^(margin|padding)-(inline|block)$/u.exec(property)\n if (logical) return logicalSides(property, value, logical[2] === 'inline')\n if (property === 'border') return borderLonghands(value)\n if (property === 'background') {\n const color = splitCSSValue(value).find(isColor)\n return color ? { 'background-color': color } : {}\n }\n return {}\n}\n\nfunction boxSides(property: string, value: string): DesignStyleDeclaration {\n const [top, right = top, bottom = top, left = right] = splitCSSValue(value)\n if (!top || !right || !bottom || !left) return {}\n return {\n [`${property}-top`]: top,\n [`${property}-right`]: right,\n [`${property}-bottom`]: bottom,\n [`${property}-left`]: left\n }\n}\n\n/** `padding-inline` and `padding-block` as the sides they set in left-to-right, horizontal text. */\nfunction logicalSides(property: string, value: string, inline: boolean): DesignStyleDeclaration {\n const box = property.slice(0, property.lastIndexOf('-'))\n const [first, second = first] = splitCSSValue(value)\n if (!first || !second) return {}\n const [start, end] = inline ? ['left', 'right'] : ['top', 'bottom']\n return { [`${box}-${start}`]: first, [`${box}-${end}`]: second }\n}\n\nfunction borderLonghands(value: string): DesignStyleDeclaration {\n const parts = splitCSSValue(value)\n const longhands: DesignStyleDeclaration = {}\n const color = parts.find(isColor)\n const width = parts.find((part) => parseCSSNumber(part) !== null)\n const style = parts.find((part) => BORDER_STYLES.has(part.toLowerCase()))\n if (color) longhands['border-color'] = color\n if (width) longhands['border-width'] = width\n if (style) longhands['border-style'] = style.toLowerCase()\n return longhands\n}\n\n/** Any CSS color, including `transparent`, which a shorthand may set on purpose. */\nfunction isColor(value: string): boolean {\n return tryParseColor(value) !== null\n}\n\nfunction classList(element: DesignElement): Set<string> {\n const className = 'class' in element.attrs ? element.attrs.class : ''\n return new Set(className.split(/\\s+/).filter((name) => name.length > 0))\n}\n\nfunction elementId(element: DesignElement): string | undefined {\n return 'id' in element.attrs ? element.attrs.id : undefined\n}\n\nfunction selectorSpecificity(selector: string): number {\n const idCount = selector.match(/#[\\w-]+/g)?.length ?? 0\n const classCount = selector.match(/\\.[\\w-]+/g)?.length ?? 0\n // A tag counts once per compound; the universal selector, alone or as in `*.card`, counts zero.\n const tagCount = selector.split(/[\\s>]+/).filter((part) => /^[a-z]/iu.test(part)).length\n return idCount * 100 + classCount * 10 + tagCount\n}\n\nfunction matchesSimpleSelector(element: DesignElement, selector: string): boolean {\n if (selector.includes(':') || selector.includes('[')) return false\n\n const idMatch = selector.match(/#([\\w-]+)/)\n if (idMatch?.[1] && elementId(element) !== idMatch[1]) return false\n\n const classes = selector.match(/\\.[\\w-]+/g) ?? []\n const elementClasses = classList(element)\n if (!classes.every((name) => elementClasses.has(name.slice(1)))) return false\n\n const tag = selector.replace(/#[\\w-]+/g, '').replace(/\\.[\\w-]+/g, '')\n // The universal selector, as Tailwind's preflight uses for `box-sizing`, matches any element.\n return tag.length === 0 || tag === '*' || element.tagName.toLowerCase() === tag.toLowerCase()\n}\n\ninterface SelectorStep {\n compound: string\n /** How this compound relates to the one after it: `>` for a parent, ` ` for any ancestor. */\n combinator: '>' | ' '\n}\n\n/** A complex selector as its compounds, rightmost last; `null` when a combinator lacks a side. */\nfunction selectorSteps(selector: string): SelectorStep[] | null {\n const tokens = selector\n .replaceAll('>', ' > ')\n .split(/\\s+/)\n .filter((token) => token.length > 0)\n const steps: SelectorStep[] = []\n let pending: '>' | null = null\n for (const token of tokens) {\n if (token === '>') {\n if (pending || steps.length === 0) return null\n pending = '>'\n continue\n }\n const previous = steps.at(-1)\n if (previous) previous.combinator = pending ?? ' '\n steps.push({ compound: token, combinator: ' ' })\n pending = null\n }\n return pending ? null : steps\n}\n\nfunction matchesSelector(\n element: DesignElement,\n selector: string,\n parent: AncestorContext | null\n): boolean {\n const steps = selectorSteps(selector)\n return steps !== null && matchesSteps(element, steps, steps.length - 1, parent)\n}\n\n/** Whether the element matches the compound at `index` and some ancestors match those before. */\nfunction matchesSteps(\n element: DesignElement,\n steps: SelectorStep[],\n index: number,\n parent: AncestorContext | null\n): boolean {\n const step = steps.at(index)\n if (!step || !matchesSimpleSelector(element, step.compound)) return false\n if (index === 0) return true\n const previous = steps.at(index - 1)\n if (!previous) return false\n if (previous.combinator === '>') {\n return parent !== null && matchesSteps(parent.element, steps, index - 1, parent.parent)\n }\n for (let ancestor = parent; ancestor; ancestor = ancestor.parent) {\n if (matchesSteps(ancestor.element, steps, index - 1, ancestor.parent)) return true\n }\n return false\n}\n\nfunction applyComputedStyles(\n node: DesignNode,\n rules: HeadlessCSSRule[],\n parent: AncestorContext | null,\n inheritedStyle: DesignStyleDeclaration,\n inheritedCustomProperties: DesignStyleDeclaration\n): DesignNode {\n if (node.type === 'text') return node\n\n const computedStyle: DesignStyleDeclaration = pickInheritedStyle(inheritedStyle)\n const matchingRules = rules\n .filter((rule) => matchesSelector(node, rule.selector, parent))\n .sort((left, right) => left.specificity - right.specificity || left.order - right.order)\n\n // Custom properties cascade and inherit like any property, so `var()` resolves per element.\n const customProperties = { ...inheritedCustomProperties }\n for (const rule of matchingRules) declareCustomProperties(customProperties, rule.declarations)\n declareCustomProperties(customProperties, node.inlineStyle ?? {})\n\n for (const rule of matchingRules) {\n Object.assign(computedStyle, resolveDeclarations(rule.declarations, customProperties))\n }\n Object.assign(computedStyle, resolveDeclarations(node.inlineStyle ?? {}, customProperties))\n\n const context = { element: node, parent }\n return {\n ...node,\n computedStyle: Object.keys(computedStyle).length > 0 ? computedStyle : undefined,\n children: node.children.map((child) =>\n applyComputedStyles(child, rules, context, computedStyle, customProperties)\n )\n }\n}\n\nfunction pickInheritedStyle(style: DesignStyleDeclaration): DesignStyleDeclaration {\n const inherited: DesignStyleDeclaration = {}\n for (const property of INHERITED_PROPERTIES) {\n const value = style[property]\n if (value) inherited[property] = value\n }\n return inherited\n}\n\nexport function computeHeadlessStyles(document: DesignDocument, cssText = ''): DesignDocument {\n const stylesheetText = [document.stylesheets?.map((sheet) => sheet.cssText).join('\\n'), cssText]\n .filter((text): text is string => !!text)\n .join('\\n')\n const { rules, customProperties } = parseRules(stylesheetText)\n // A fragment has no document element, so `:root` reaches its elements through inheritance only.\n const rootStyle: DesignStyleDeclaration = {}\n for (const rule of rules.filter(({ selector }) => selector === ':root')) {\n Object.assign(rootStyle, resolveDeclarations(rule.declarations, customProperties))\n }\n\n return {\n ...document,\n children: document.children.map((child) =>\n applyComputedStyles(child, rules, null, rootStyle, customProperties)\n )\n }\n}\n","import { serializeHTML } from '#dom-css/export/html'\nimport { INLINE_TAGS } from '#dom-css/import/flow'\nimport { parseStyleAttribute } from '#dom-css/import/style-attribute'\nimport type { CSSRuntime, DesignDocument, DesignElement, DesignNode } from '#dom-css/types'\nimport { parseFragment, type DefaultTreeAdapterTypes } from 'parse5'\n\nimport { computeHeadlessStyles } from './styles'\n\nfunction attrsToRecord(attrs: DefaultTreeAdapterTypes.Element['attrs']): Record<string, string> {\n const result: Record<string, string> = {}\n for (const attr of attrs) result[attr.name] = attr.value\n return result\n}\n\nfunction isTextNode(\n node: DefaultTreeAdapterTypes.ChildNode\n): node is DefaultTreeAdapterTypes.TextNode {\n return node.nodeName === '#text'\n}\n\nconst NON_RENDERED_TAGS = new Set(['head', 'link', 'meta', 'script', 'style', 'template', 'title'])\n\nfunction isInlineElement(node: DefaultTreeAdapterTypes.ChildNode | undefined): boolean {\n return node !== undefined && 'tagName' in node && INLINE_TAGS.has(node.tagName.toLowerCase())\n}\n\n/**\n * Text, and the spaces in or beside inline elements, which CSS draws among their words; spaces\n * between blocks lay nothing out, so they are left out.\n */\nfunction keepsText(\n node: DefaultTreeAdapterTypes.TextNode,\n siblings: readonly DefaultTreeAdapterTypes.ChildNode[],\n index: number,\n inInline: boolean\n): boolean {\n if (node.value.trim().length > 0) return true\n return (\n node.value.length > 0 &&\n (inInline || isInlineElement(siblings[index - 1]) || isInlineElement(siblings[index + 1]))\n )\n}\n\nfunction childrenToDesignNodes(\n nodes: readonly DefaultTreeAdapterTypes.ChildNode[],\n inInline: boolean\n): DesignNode[] {\n return nodes\n .map((node, index) => childToDesignNode(node, index, nodes, inInline))\n .filter((child): child is DesignNode => child !== null)\n}\n\nfunction childToDesignNode(\n node: DefaultTreeAdapterTypes.ChildNode,\n index: number,\n siblings: readonly DefaultTreeAdapterTypes.ChildNode[],\n inInline: boolean\n): DesignNode | null {\n if (isTextNode(node)) {\n return keepsText(node, siblings, index, inInline) ? { type: 'text', text: node.value } : null\n }\n\n if (!('tagName' in node)) return null\n if (NON_RENDERED_TAGS.has(node.tagName.toLowerCase())) return null\n\n const attrs = attrsToRecord(node.attrs)\n const element: DesignElement = {\n type: 'element',\n tagName: node.tagName.toLowerCase(),\n attrs,\n children: childrenToDesignNodes(node.childNodes, isInlineElement(node))\n }\n\n const inlineStyle = parseStyleAttribute(attrs.style)\n if (inlineStyle) element.inlineStyle = inlineStyle\n\n return element\n}\n\nfunction parseHTML(html: string): DesignDocument {\n const fragment = parseFragment(html)\n return {\n type: 'document',\n children: childrenToDesignNodes(fragment.childNodes, false)\n }\n}\n\nexport function createHeadlessCSSRuntime(): CSSRuntime {\n return {\n kind: 'headless',\n parseHTML,\n serializeHTML(document: DesignDocument) {\n return serializeHTML(document)\n },\n async computeStyles(document: DesignDocument, cssText = '') {\n return computeHeadlessStyles(document, cssText)\n }\n }\n}\n","import type { CSSRuntime } from '../types'\nimport { createBrowserCSSRuntime } from './browser/runtime'\nimport { createHeadlessCSSRuntime } from './headless/runtime'\n\nexport { createBrowserCSSRuntime } from './browser/runtime'\nexport type { BrowserCSSRuntimeOptions } from './browser/runtime'\nexport { createHeadlessCSSRuntime } from './headless/runtime'\n\nexport function createCSSRuntime(): CSSRuntime {\n return typeof document !== 'undefined' ? createBrowserCSSRuntime() : createHeadlessCSSRuntime()\n}\n","import { compile } from 'tailwindcss'\n\nexport interface CompileTailwindCSSOptions {\n css?: string\n base?: string\n loadStylesheet?: (id: string, base: string) => Promise<string>\n}\n\nconst DEFAULT_TAILWIND_CSS = '@import \"tailwindcss\";'\n\nexport async function compileTailwindCSS(\n classes: string | Iterable<string>,\n options: CompileTailwindCSSOptions = {}\n): Promise<string> {\n const compiler = await compile(tailwindCompilerCSS(options.css), {\n base: options.base,\n loadStylesheet: async (id, base) => {\n const content = options.loadStylesheet\n ? await options.loadStylesheet(id, base)\n : await loadTailwindStylesheet(id)\n return { path: id, base, content }\n }\n })\n return compiler.build(normalizeClasses(classes))\n}\n\nfunction tailwindCompilerCSS(css: string | undefined): string {\n const trimmed = css?.trim()\n if (!trimmed) return DEFAULT_TAILWIND_CSS\n if (containsTailwindImport(trimmed)) return trimmed\n return `${DEFAULT_TAILWIND_CSS}\\n${trimmed}`\n}\n\nfunction containsTailwindImport(css: string): boolean {\n const withoutComments = css.replace(/\\/\\*[\\s\\S]*?\\*\\//g, '')\n return /^\\s*@import\\s+(?:\"tailwindcss(?:\\/[^\"]*)?\"|'tailwindcss(?:\\/[^']*)?')/m.test(\n withoutComments\n )\n}\n\nfunction normalizeClasses(classes: string | Iterable<string>): string[] {\n const classNames = typeof classes === 'string' ? [classes] : Array.from(classes)\n return classNames\n .flatMap((className) => className.split(/\\s+/))\n .map((className) => className.trim())\n .filter((className) => className.length > 0)\n}\n\nasync function loadTailwindStylesheet(id: string): Promise<string> {\n const stylesheet = id === 'tailwindcss' ? 'tailwindcss/index.css' : id\n const url = new URL(import.meta.resolve(stylesheet))\n const { readFile } = await import(/* @vite-ignore */ 'node:fs/promises')\n return readFile(url, 'utf8')\n}\n","import { parse, type DefaultTreeAdapterTypes } from 'parse5'\n\nimport type { SceneGraph } from '@pairdraw/scene-graph'\n\nimport { createCSSRuntime } from '../runtime'\nimport type { CSSComputeOptions, CSSRuntime, DesignDocument } from '../types'\nimport { mergeCSSText } from './css-text'\nimport { designDocumentToSceneGraph, type ToSceneGraphOptions } from './scene-graph'\nimport { compileTailwindCSS, type CompileTailwindCSSOptions } from './tailwind'\n\nexport interface HTMLToDesignDocumentOptions {\n cssText?: string\n runtime?: CSSRuntime\n compute?: CSSComputeOptions\n}\n\nexport interface HTMLToSceneGraphOptions extends HTMLToDesignDocumentOptions, ToSceneGraphOptions {}\n\nexport interface TailwindHTMLToDesignDocumentOptions\n extends Omit<HTMLToDesignDocumentOptions, 'cssText'>, CompileTailwindCSSOptions {}\n\nexport interface TailwindHTMLToSceneGraphOptions\n extends TailwindHTMLToDesignDocumentOptions, ToSceneGraphOptions {}\n\nfunction runtimeForOptions(runtime: CSSRuntime | undefined) {\n return runtime ?? createCSSRuntime()\n}\n\nfunction getChildNodes(node: DefaultTreeAdapterTypes.Node): DefaultTreeAdapterTypes.ChildNode[] {\n return 'childNodes' in node ? node.childNodes : []\n}\n\nfunction textContent(node: DefaultTreeAdapterTypes.Node): string {\n if (node.nodeName === '#text' && 'value' in node) return node.value\n return getChildNodes(node).map(textContent).join('')\n}\n\nfunction collectStyleText(node: DefaultTreeAdapterTypes.Node, styles: string[]): void {\n if ('tagName' in node && node.tagName.toLowerCase() === 'style') {\n const css = textContent(node).trim()\n if (css) styles.push(css)\n return\n }\n\n for (const child of getChildNodes(node)) collectStyleText(child, styles)\n}\n\nfunction extractEmbeddedCSSText(html: string): string | undefined {\n const styles: string[] = []\n collectStyleText(parse(html), styles)\n return styles.length > 0 ? styles.join('\\n') : undefined\n}\n\nexport async function htmlToDesignDocument(\n html: string,\n options: HTMLToDesignDocumentOptions = {}\n): Promise<DesignDocument> {\n const runtime = runtimeForOptions(options.runtime)\n const document = runtime.parseHTML(html)\n const cssText = mergeCSSText(extractEmbeddedCSSText(html), options.cssText)\n return runtime.computeStyles(document, cssText, options.compute)\n}\n\nexport async function htmlToSceneGraph(\n html: string,\n options: HTMLToSceneGraphOptions = {}\n): Promise<SceneGraph> {\n const document = await htmlToDesignDocument(html, options)\n return designDocumentToSceneGraph(document, options)\n}\n\nexport async function tailwindHTMLToDesignDocument(\n html: string,\n candidates: string | Iterable<string>,\n options: TailwindHTMLToDesignDocumentOptions = {}\n): Promise<DesignDocument> {\n const cssText = await compileTailwindCSS(candidates, options)\n return htmlToDesignDocument(html, { ...options, cssText })\n}\n\nexport async function tailwindHTMLToSceneGraph(\n html: string,\n candidates: string | Iterable<string>,\n options: TailwindHTMLToSceneGraphOptions = {}\n): Promise<SceneGraph> {\n const document = await tailwindHTMLToDesignDocument(html, candidates, options)\n return designDocumentToSceneGraph(document, options)\n}\n"],"mappings":";;;;;;;;;AAKA,SAAS,eAAe,SAA0C;CAChE,MAAM,CAAC,QAAQA,QAAM,OAAO,CAAC,CAAC;CAC9B,IAAI,CAAC,QAAQ,OAAO,SAAS,YAAY,EAAE,WAAW,OAAO,OAAO;CACpE,OAAO;AACT;AAEA,SAAgB,oBAAoB,OAA+D;CACjG,IAAI,CAAC,OAAO,OAAO,KAAA;CAEnB,MAAM,OAAO,eAAe,KAAK,MAAM,EAAE;CACzC,IAAI,CA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,CAAC,KAAK;EACnC,IAAI,KAAK,OAAO,KAAK,GAAG;EACxB;CACF;CAEA,KAAK,MAAM,SAAS,cAAc,IAAI,GAAG,iBAAiB,OAAO,MAAM;AACzE;AAEA,SAAS,uBAAuB,MAAkC;CAChE,MAAM,SAAmB,CAAC;CAC1B,iBAAiB,MAAM,IAAI,GAAG,MAAM;CACpC,OAAO,OAAO,SAAS,IAAI,OAAO,KAAK,IAAI,IAAI,KAAA;AACjD;AAEA,eAAsB,qBACpB,MACA,UAAuC,CAAC,GACf;CACzB,MAAM,UAAU,kBAAkB,QAAQ,OAAO;CACjD,MAAM,WAAW,QAAQ,UAAU,IAAI;CACvC,MAAM,UAAU,aAAa,uBAAuB,IAAI,GAAG,QAAQ,OAAO;CAC1E,OAAO,QAAQ,cAAc,UAAU,SAAS,QAAQ,OAAO;AACjE;AAEA,eAAsB,iBACpB,MACA,UAAmC,CAAC,GACf;CACrB,MAAM,WAAW,MAAM,qBAAqB,MAAM,OAAO;CACzD,OAAO,2BAA2B,UAAU,OAAO;AACrD;AAEA,eAAsB,6BACpB,MACA,YACA,UAA+C,CAAC,GACvB;CACzB,MAAM,UAAU,MAAM,mBAAmB,YAAY,OAAO;CAC5D,OAAO,qBAAqB,MAAM;EAAE,GAAG;EAAS;CAAQ,CAAC;AAC3D;AAEA,eAAsB,yBACpB,MACA,YACA,UAA2C,CAAC,GACvB;CACrB,MAAM,WAAW,MAAM,6BAA6B,MAAM,YAAY,OAAO;CAC7E,OAAO,2BAA2B,UAAU,OAAO;AACrD"}
|
package/dist/export.d.ts
CHANGED
|
@@ -418,13 +418,6 @@ declare function modeAttribute(collection: VariableCollection, mode: VariableCol
|
|
|
418
418
|
};
|
|
419
419
|
/** The scope a mode applies in when it names none: `[data-theme="dark"]` for Theme / Dark. */
|
|
420
420
|
declare function defaultModeCondition(collection: VariableCollection, mode: VariableCollectionMode): string;
|
|
421
|
-
/**
|
|
422
|
-
* Variables as a stylesheet of custom properties. The default mode of every collection is the
|
|
423
|
-
* base set, in `:root` or, for Tailwind, in `@theme` when the token has a Tailwind namespace;
|
|
424
|
-
* every other mode overrides the values that differ, under its condition. Aliases stay `var()`
|
|
425
|
-
* references, and number formulas `calc()` over them; both are declared again in each mode that
|
|
426
|
-
* changes what they point to.
|
|
427
|
-
*/
|
|
428
421
|
declare function buildTokenStylesheet(source: TokenSource, { format, include }: TokenStylesheetOptions, validate: TokenValidator): TokenStylesheet;
|
|
429
422
|
/**
|
|
430
423
|
* Browsers check token strings with their own CSS parser. Elsewhere, in the CLI and MCP, the CSS
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pairdraw/dom-css",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@acemir/cssom": "^0.9.31",
|
|
14
|
-
"@pairdraw/emit": "^0.
|
|
14
|
+
"@pairdraw/emit": "^0.18.0",
|
|
15
15
|
"css-tree": "^3.2.1",
|
|
16
16
|
"cssesc": "^3.0.0",
|
|
17
17
|
"dedent": "^1.7.2",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"twirlwind": "^0.4.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@pairdraw/scene-graph": "^0.
|
|
27
|
+
"@pairdraw/scene-graph": "^0.18.0"
|
|
28
28
|
},
|
|
29
29
|
"exports": {
|
|
30
30
|
".": {
|
package/src/export/bundle.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { CSSFontFaceRule } from '@acemir/cssom'
|
|
2
1
|
import { isValid, toUint8Array } from 'js-base64'
|
|
3
2
|
import { parseFragment, serialize, type DefaultTreeAdapterTypes } from 'parse5'
|
|
4
3
|
|
|
@@ -276,22 +275,21 @@ interface FontFaceCSSOptions {
|
|
|
276
275
|
display?: string
|
|
277
276
|
}
|
|
278
277
|
|
|
279
|
-
function fontFaceCSS(
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
)
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
rule.style.setProperty('font-style', asset.style)
|
|
289
|
-
rule.style.setProperty('font-display', options.display ?? asset.display ?? 'swap')
|
|
290
|
-
if (asset.stretch) rule.style.setProperty('font-stretch', asset.stretch)
|
|
278
|
+
function fontFaceCSS(asset: WebFontFaceAsset, options: FontFaceCSSOptions): string {
|
|
279
|
+
const declarations: [property: string, value: string][] = [
|
|
280
|
+
['font-family', JSON.stringify(asset.family)],
|
|
281
|
+
['src', fontSourceValue(asset, options.from)],
|
|
282
|
+
['font-weight', serializeFontWeight(asset.weight)],
|
|
283
|
+
['font-style', asset.style],
|
|
284
|
+
['font-display', options.display ?? asset.display ?? 'swap']
|
|
285
|
+
]
|
|
286
|
+
if (asset.stretch) declarations.push(['font-stretch', asset.stretch])
|
|
291
287
|
if (asset.unicodeRange && asset.unicodeRange.length > 0) {
|
|
292
|
-
|
|
288
|
+
declarations.push(['unicode-range', asset.unicodeRange.join(',')])
|
|
293
289
|
}
|
|
294
|
-
|
|
290
|
+
// Written out rather than serialized by a CSS object model, which a browser bundle cannot load.
|
|
291
|
+
const body = declarations.map(([property, value]) => ` ${property}: ${value};`).join('\n')
|
|
292
|
+
return `@font-face {\n${body}\n}\n`
|
|
295
293
|
}
|
|
296
294
|
|
|
297
295
|
/** Every font face a document's text uses, once each. */
|
|
@@ -302,14 +300,12 @@ export function designFontRequests(document: DesignDocument): WebFontFaceRequest
|
|
|
302
300
|
}
|
|
303
301
|
|
|
304
302
|
/** `@font-face` rules for font files, as a stylesheet in the folder `options.from`. */
|
|
305
|
-
export
|
|
303
|
+
export function fontFaceStylesheet(
|
|
306
304
|
assets: readonly WebFontFaceAsset[],
|
|
307
305
|
options: FontFaceCSSOptions
|
|
308
|
-
):
|
|
306
|
+
): string {
|
|
309
307
|
if (assets.length === 0) return ''
|
|
310
|
-
|
|
311
|
-
const cssom = await import('@acemir/cssom')
|
|
312
|
-
return assets.map((asset) => fontFaceCSS(cssom.CSSFontFaceRule, asset, options)).join('')
|
|
308
|
+
return assets.map((asset) => fontFaceCSS(asset, options)).join('')
|
|
313
309
|
}
|
|
314
310
|
|
|
315
311
|
async function fontFaceAssets(
|
|
@@ -320,7 +316,7 @@ async function fontFaceAssets(
|
|
|
320
316
|
const assets = await options.fonts(designFontRequests(document), `${options.assetBasePath}/fonts`)
|
|
321
317
|
// The page's stylesheet sits in the asset folder, beside the fonts' own folder.
|
|
322
318
|
return {
|
|
323
|
-
css:
|
|
319
|
+
css: fontFaceStylesheet(assets, { from: options.assetBasePath }),
|
|
324
320
|
files: assets
|
|
325
321
|
}
|
|
326
322
|
}
|
|
@@ -374,8 +370,14 @@ function stylesheetLink(path: string): string {
|
|
|
374
370
|
return `<link rel="stylesheet" href="${assetURL(path)}">`
|
|
375
371
|
}
|
|
376
372
|
|
|
373
|
+
/**
|
|
374
|
+
* A `<style>` element holding `css`. The HTML parser ends the element at the first `</style`
|
|
375
|
+
* in any letter case, whatever the CSS around it means, and style values can come from an
|
|
376
|
+
* imported document, so each one is written `<\/style`, which CSS strings and URLs read back
|
|
377
|
+
* as `</style`.
|
|
378
|
+
*/
|
|
377
379
|
function styleTag(css: string): string {
|
|
378
|
-
return css ? `<style>${css}</style>` : ''
|
|
380
|
+
return css ? `<style>${css.replace(/<\/(?=style)/gi, '<\\/')}</style>` : ''
|
|
379
381
|
}
|
|
380
382
|
|
|
381
383
|
type ResolvedBundleOptions = Required<Omit<ExportHTMLBundleOptions, 'loadTailwindStylesheet'>> &
|
package/src/export/html.ts
CHANGED
|
@@ -78,6 +78,22 @@ export function mergeClassNames(...values: Array<string | undefined>): string |
|
|
|
78
78
|
return className.length > 0 ? className : undefined
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Characters that end an attribute name or quote one. Imported JSX props can have any name, and
|
|
83
|
+
* one holding these would write other attributes, so such a name is left out.
|
|
84
|
+
*/
|
|
85
|
+
const UNSAFE_ATTRIBUTE_NAME = /[\s"'/=>]/
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* HTML, SVG, and custom element names. Imported JSX can name any tag, and one holding spaces or
|
|
89
|
+
* quotes would write attributes, so another name is written as a `div` with the same content.
|
|
90
|
+
*/
|
|
91
|
+
const SAFE_TAG_NAME = /^[a-z][\w.:-]*$/i
|
|
92
|
+
|
|
93
|
+
function safeTagName(tagName: string): string {
|
|
94
|
+
return SAFE_TAG_NAME.test(tagName) ? tagName : 'div'
|
|
95
|
+
}
|
|
96
|
+
|
|
81
97
|
function serializeAttrs(node: DesignElement, options: SerializeHTMLOptions): string {
|
|
82
98
|
const style = serializeStyle(node)
|
|
83
99
|
const tailwindClass =
|
|
@@ -92,6 +108,7 @@ function serializeAttrs(node: DesignElement, options: SerializeHTMLOptions): str
|
|
|
92
108
|
if (style && options.style !== 'tailwind') attrs.style = style
|
|
93
109
|
const serialized = Object.entries(attrs)
|
|
94
110
|
.filter((entry): entry is [string, string] => typeof entry[1] === 'string' && entry[1] !== '')
|
|
111
|
+
.filter(([name]) => name !== '' && !UNSAFE_ATTRIBUTE_NAME.test(name))
|
|
95
112
|
.map(([name, value]) => `${name}="${escapeAttribute(value)}"`)
|
|
96
113
|
|
|
97
114
|
if (serialized.length === 0) return ''
|
|
@@ -113,7 +130,7 @@ function serializeElement(
|
|
|
113
130
|
depth: number
|
|
114
131
|
): string {
|
|
115
132
|
// SVG names such as `linearGradient` keep their case, as an SVG parser needs them.
|
|
116
|
-
const tagName = node.tagName
|
|
133
|
+
const tagName = safeTagName(node.tagName)
|
|
117
134
|
const attrs = serializeAttrs(node, options)
|
|
118
135
|
if (VOID_ELEMENTS.has(tagName.toLowerCase())) return `<${tagName}${attrs}>`
|
|
119
136
|
const children = [
|
|
@@ -143,7 +160,7 @@ export function serializeNode(
|
|
|
143
160
|
export function serializedElements(document: DesignDocument): (DesignElement | null)[] {
|
|
144
161
|
const visit = (node: DesignNode): (DesignElement | null)[] => {
|
|
145
162
|
if (node.type === 'text') return []
|
|
146
|
-
if (VOID_ELEMENTS.has(node.tagName.toLowerCase())) return [node]
|
|
163
|
+
if (VOID_ELEMENTS.has(safeTagName(node.tagName).toLowerCase())) return [node]
|
|
147
164
|
return [node, ...(node.shader?.frame ? [null] : []), ...node.children.flatMap(visit)]
|
|
148
165
|
}
|
|
149
166
|
return document.children.flatMap(visit)
|
|
@@ -339,7 +339,7 @@ async function storyFonts(
|
|
|
339
339
|
if (requests.size === 0) return []
|
|
340
340
|
const assets = await options.fonts([...requests.values()], `${folder}/fonts`)
|
|
341
341
|
if (assets.length === 0) return []
|
|
342
|
-
const css =
|
|
342
|
+
const css = fontFaceStylesheet(assets, { from: folder, display: 'block' })
|
|
343
343
|
return [...assets, { path: `${folder}/fonts.css`, content: css }]
|
|
344
344
|
}
|
|
345
345
|
|
package/src/import/jsx/core.ts
CHANGED
|
@@ -35,12 +35,37 @@ function styleObjectToDeclaration(style: JSXStyleObject): DesignStyleDeclaration
|
|
|
35
35
|
return Object.fromEntries(entries)
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
/** Declarations split at `;` outside quotes and parentheses, so `url(data:…;base64,…)` stays whole. */
|
|
39
|
+
function splitDeclarations(style: string): string[] {
|
|
40
|
+
const declarations: string[] = []
|
|
41
|
+
let depth = 0
|
|
42
|
+
let quote: string | null = null
|
|
43
|
+
let start = 0
|
|
44
|
+
for (let index = 0; index < style.length; index++) {
|
|
45
|
+
const character = style[index]
|
|
46
|
+
if (quote) {
|
|
47
|
+
if (character === '\\') index++
|
|
48
|
+
else if (character === quote) quote = null
|
|
49
|
+
} else if (character === '"' || character === "'") quote = character
|
|
50
|
+
else if (character === '(') depth++
|
|
51
|
+
else if (character === ')') depth = Math.max(0, depth - 1)
|
|
52
|
+
else if (character === ';' && depth === 0) {
|
|
53
|
+
declarations.push(style.slice(start, index))
|
|
54
|
+
start = index + 1
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
declarations.push(style.slice(start))
|
|
58
|
+
return declarations
|
|
59
|
+
}
|
|
60
|
+
|
|
38
61
|
function styleStringToDeclaration(style: string): DesignStyleDeclaration | undefined {
|
|
39
|
-
const entries = style
|
|
40
|
-
.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
62
|
+
const entries = splitDeclarations(style)
|
|
63
|
+
.map((declaration) => {
|
|
64
|
+
const colon = declaration.indexOf(':')
|
|
65
|
+
if (colon === -1) return ['', ''] as const
|
|
66
|
+
const property = declaration.slice(0, colon).trim()
|
|
67
|
+
return [property.toLowerCase(), declaration.slice(colon + 1).trim()] as const
|
|
68
|
+
})
|
|
44
69
|
.filter(([property, value]) => property.length > 0 && value.length > 0)
|
|
45
70
|
|
|
46
71
|
if (entries.length === 0) return undefined
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
} from '@pairdraw/scene-graph'
|
|
11
11
|
import { TRANSPARENT } from '@pairdraw/scene-graph/constants'
|
|
12
12
|
import { parseCSSAlignSelf, parseCSSNumber, parseCSSShadows } from '@pairdraw/scene-graph/css'
|
|
13
|
+
import { normalizeEffects } from '@pairdraw/scene-graph/effects'
|
|
13
14
|
import { computeImageHash } from '@pairdraw/scene-graph/images'
|
|
14
15
|
|
|
15
16
|
import type { DesignDocument, DesignElement, DesignNode, DesignStyleDeclaration } from '../types'
|
|
@@ -328,7 +329,7 @@ function applyElementStyle(
|
|
|
328
329
|
}
|
|
329
330
|
|
|
330
331
|
const effects = parseCSSShadows(pickStyle(style, 'box-shadow'))
|
|
331
|
-
if (effects.length > 0) node.effects = effects
|
|
332
|
+
if (effects.length > 0) node.effects = normalizeEffects(effects)
|
|
332
333
|
|
|
333
334
|
const opacity = parseCSSNumber(pickStyle(style, 'opacity'))
|
|
334
335
|
if (opacity !== null) node.opacity = opacity
|
|
@@ -368,7 +369,7 @@ function applyTextStyle(node: SceneNode, style: DesignStyleDeclaration): void {
|
|
|
368
369
|
if (opacity !== null) node.opacity = opacity
|
|
369
370
|
|
|
370
371
|
const effects = parseCSSShadows(pickStyle(style, 'text-shadow'))
|
|
371
|
-
if (effects.length > 0) node.effects = effects
|
|
372
|
+
if (effects.length > 0) node.effects = normalizeEffects(effects)
|
|
372
373
|
|
|
373
374
|
const textAlign = pickStyle(style, 'text-align')?.toUpperCase()
|
|
374
375
|
if (textAlign === 'CENTER' || textAlign === 'RIGHT' || textAlign === 'JUSTIFIED') {
|
|
@@ -512,7 +513,8 @@ function createElementNode(
|
|
|
512
513
|
}
|
|
513
514
|
|
|
514
515
|
const node = graph.createNode('FRAME', parentId, {
|
|
515
|
-
|
|
516
|
+
// The HTML export writes each layer's own name as `data-name`.
|
|
517
|
+
name: element.attrs['data-name'] || element.attrs.id || element.attrs.class || element.tagName,
|
|
516
518
|
clipsContent: false
|
|
517
519
|
})
|
|
518
520
|
applyElementStyle(graph, node, element, style)
|