@aglyn/plugins-ai 1.7.0 → 1.8.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/package.json +17 -17
- package/src/lib/jobs/ai-job-import-step.d.ts +28 -2
- package/src/lib/jobs/ai-job-import-step.js +170 -14
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-job-layout-language.js +2 -0
- package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
- package/src/lib/jobs/ai-job-page-language.js +6 -2
- package/src/lib/jobs/ai-job-page-language.js.map +1 -1
- package/src/lib/jobs/ai-site-import-compile.d.ts +13 -3
- package/src/lib/jobs/ai-site-import-compile.js +336 -27
- package/src/lib/jobs/ai-site-import-compile.js.map +1 -1
- package/src/lib/jobs/ai-site-import-document.d.ts +3 -1
- package/src/lib/jobs/ai-site-import-document.js +36 -0
- package/src/lib/jobs/ai-site-import-document.js.map +1 -1
- package/src/lib/jobs/ai-site-import-look.d.ts +9 -0
- package/src/lib/jobs/ai-site-import-look.js +89 -6
- package/src/lib/jobs/ai-site-import-look.js.map +1 -1
- package/src/lib/layout-language/ai-layout-compiler.d.ts +16 -0
- package/src/lib/layout-language/ai-layout-compiler.js +351 -54
- package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
- package/src/lib/layout-language/ai-layout-frame-source.d.ts +88 -2
- package/src/lib/layout-language/ai-layout-frame-source.js +591 -30
- package/src/lib/layout-language/ai-layout-frame-source.js.map +1 -1
- package/src/lib/layout-language/ai-layout-frame.js +30 -18
- package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
- package/src/lib/layout-language/ai-layout-language.d.ts +72 -3
- package/src/lib/layout-language/ai-layout-language.js +5 -3
- package/src/lib/layout-language/ai-layout-language.js.map +1 -1
- package/src/lib/layout-language/ai-layout-store.d.ts +8 -0
- package/src/lib/layout-language/ai-layout-store.js +32 -6
- package/src/lib/layout-language/ai-layout-store.js.map +1 -1
- package/src/lib/model/ai-site-import-fidelity.d.ts +31 -1
- package/src/lib/model/ai-site-import-fidelity.js +347 -25
- package/src/lib/model/ai-site-import-fidelity.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +203 -6
- package/src/lib/model/ai-site-import.js +161 -5
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/model/ai-site-look.d.ts +8 -1
- package/src/lib/model/ai-site-look.js +8 -5
- package/src/lib/model/ai-site-look.js.map +1 -1
- package/src/lib/runtime/ai-doctrine-validators.d.ts +7 -1
- package/src/lib/runtime/ai-doctrine-validators.js +25 -2
- package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
- package/src/lib/runtime/ai-node-tree.js +19 -2
- package/src/lib/runtime/ai-node-tree.js.map +1 -1
- package/src/lib/runtime/ai-page-links.d.ts +15 -0
- package/src/lib/runtime/ai-page-links.js +48 -0
- package/src/lib/runtime/ai-page-links.js.map +1 -1
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js +30 -5
- package/src/lib/site-import/fixtures/site-import-fidelity-replay.js.map +1 -1
- package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +9 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js +24 -5
- package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
- package/src/lib/site-import/site-import-crawl.d.ts +3 -1
- package/src/lib/site-import/site-import-crawl.js +8 -3
- package/src/lib/site-import/site-import-crawl.js.map +1 -1
- package/src/lib/site-import/site-import-css.d.ts +20 -0
- package/src/lib/site-import/site-import-css.js +106 -0
- package/src/lib/site-import/site-import-css.js.map +1 -1
- package/src/lib/site-import/site-import-html.d.ts +39 -0
- package/src/lib/site-import/site-import-html.js +515 -5
- package/src/lib/site-import/site-import-html.js.map +1 -1
- package/src/lib/site-import/site-import-layout.d.ts +16 -6
- package/src/lib/site-import/site-import-layout.js +524 -52
- package/src/lib/site-import/site-import-layout.js.map +1 -1
- package/src/lib/site-import/site-import-nav.js +286 -24
- package/src/lib/site-import/site-import-nav.js.map +1 -1
- package/src/lib/site-import/site-import-page.js +3 -0
- package/src/lib/site-import/site-import-page.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/site-import/site-import-css.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * HOW A PAGE IS STYLED, AS A WIDE SCREEN SHOWS IT (AGL-4106).\n *\n * Bring my site reads a page's layout, not only its lines, and most of a\n * layout lives in the stylesheet: which band is grey and which is dark, which\n * container lays its children out in three columns, which link is drawn as a\n * filled button. This is a small cascade, enough for that and no more:\n *\n * - **The sheets.** The page's own `<style>` sheets and the ones it links,\n * read in order. `@media` rules apply as a 1280-pixel screen in light mode\n * sees them, so a grid's desktop columns win over its phone ones;\n * `@layer`, `@supports` and `@container` are read through; keyframes, font\n * faces (their families noted) and page rules are skipped.\n * - **Selectors.** Tags, classes (escaped ones too, as utility frameworks\n * write them), ids and attributes, joined by any combinator. A rule that\n * only applies on hover, focus or to a generated part (`::before`) is a\n * state the page is not in and is not read.\n * - **The cascade.** Specificity, then order, `!important` over both, and the\n * element's own `style` over every rule; color, font and alignment inherit,\n * and so do custom properties, which `var()` reads.\n *\n * Only the properties the layout reader asks about are kept. Nothing here\n * runs anything a page wrote: values are text compared to text.\n *=========================================*/\n\nimport type { SiteImportElement, SiteImportStructure } from './site-import-html'\n\n/** The width a page is read at: a laptop's, where a desktop layout shows. */\nexport const SITE_IMPORT_CSS_VIEWPORT = { width: 1280, height: 800 } as const\n\n/**\n * The width a page's column is read at (AGL-4083). A container caps itself\n * only on screens wider than its cap (`@media (min-width:1536px)` around a\n * `max-width:1536px`), so on a laptop it runs the whole page: read there, it\n * would look as if it had no cap at all.\n */\nexport const SITE_IMPORT_CSS_WIDE_WIDTH = 1920\n\n/** The properties the layout reader reads; every other declaration is dropped as the sheet is parsed. */\nconst KEPT_PROPERTIES = new Set([\n 'background',\n 'background-color',\n 'background-image',\n 'color',\n 'border',\n 'border-width',\n 'border-style',\n 'border-color',\n 'border-top',\n 'border-right',\n 'border-bottom',\n 'border-left',\n 'border-top-width',\n 'border-bottom-width',\n 'border-left-width',\n 'border-right-width',\n 'border-top-style',\n 'border-bottom-style',\n 'border-top-color',\n 'border-bottom-color',\n 'border-radius',\n 'box-shadow',\n 'display',\n 'grid-template-columns',\n 'grid-column',\n 'flex',\n 'flex-direction',\n 'flex-wrap',\n 'flex-grow',\n 'flex-basis',\n 'width',\n 'max-width',\n 'font-family',\n 'font-size',\n 'font-weight',\n 'text-transform',\n 'letter-spacing',\n 'text-align',\n 'position',\n 'visibility',\n 'padding',\n 'padding-top',\n 'padding-bottom',\n 'padding-left',\n 'padding-right',\n 'object-fit',\n 'justify-content',\n 'align-items',\n])\n\n/** What an element takes from its parent when it says nothing itself. */\nconst INHERITED = new Set(['color', 'font-family', 'font-size', 'font-weight', 'text-transform', 'letter-spacing', 'text-align', 'visibility'])\n\ninterface Compound {\n tag: string | null\n id: string | null\n classes: string[]\n attrs: Array<{ name: string; op: string | null; value: string }>\n /** `:root`: only the document's root element. */\n root: boolean\n}\n\ninterface ComplexSelector {\n /** Rightmost last. */\n compounds: Compound[]\n /** `combinators[i]` joins `compounds[i]` and `compounds[i + 1]`: a space, a child, an adjacent or a sibling combinator. */\n combinators: string[]\n specificity: number\n}\n\ninterface CssRule {\n selector: ComplexSelector\n order: number\n decls: Array<[property: string, value: string, important: boolean]>\n}\n\n/** The page's sheets, parsed for one width. */\nexport interface SiteImportCss {\n rules: CssRule[]\n /** Rules by their rightmost compound's id (`#x`), first class (`.x`), tag, or `*`. */\n index: Map<string, CssRule[]>\n /** Families its `@font-face` rules name, in order. */\n fontFaces: string[]\n}\n\n/*------------------------------------------\n * Parsing\n *-----------------------------------------*/\n\nfunction unescapeIdent(text: string): string {\n return text.replace(/\\\\([0-9a-fA-F]{1,6}\\s?|.)/g, (_, escaped: string) => {\n if (/^[0-9a-fA-F]{1,6}\\s?$/.test(escaped)) {\n const code = parseInt(escaped.trim(), 16)\n return code > 0 && code <= 0x10ffff ? String.fromCodePoint(code) : ''\n }\n return escaped\n })\n}\n\nconst IDENT = String.raw`(?:\\\\[0-9a-fA-F]{1,6}\\s?|\\\\.|[\\w-]|[^\\x00-\\x7f])+`\nconst SIMPLE = new RegExp(\n String.raw`^(?:(\\*|${IDENT})|#(${IDENT})|\\.(${IDENT})|\\[\\s*([\\w-]+)\\s*(?:([~|^$*]?=)\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\]\\s]+))\\s*(?:[is]\\s*)?)?\\]|(::?)(${IDENT})(\\((?:[^()]|\\([^()]*\\))*\\))?)`,\n)\n\n/** The pseudo-classes a page at rest matches as if they were not there. */\nconst AT_REST = new Set(['link', 'any-link'])\n\n/** One compound selector, or `null` when it depends on a state or a generated part. */\nfunction parseCompound(text: string): Compound | null {\n const compound: Compound = { tag: null, id: null, classes: [], attrs: [], root: false }\n let rest = text\n while (rest) {\n const match = SIMPLE.exec(rest)\n if (!match || !match[0]) return null\n rest = rest.slice(match[0].length)\n if (match[1]) compound.tag = match[1] === '*' ? null : unescapeIdent(match[1]).toLowerCase()\n else if (match[2]) compound.id = unescapeIdent(match[2])\n else if (match[3]) compound.classes.push(unescapeIdent(match[3]))\n else if (match[4]) compound.attrs.push({ name: match[4].toLowerCase(), op: match[5] ?? null, value: match[6] ?? match[7] ?? match[8] ?? '' })\n else if (match[9]) {\n const name = unescapeIdent(match[10] ?? '').toLowerCase()\n if (match[9] === '::') return null\n if (name === 'root') compound.root = true\n else if (!AT_REST.has(name)) return null\n }\n }\n return compound\n}\n\n/** A complex selector, or `null` when any part of it cannot be read at rest. */\nfunction parseSelector(text: string): ComplexSelector | null {\n const compounds: Compound[] = []\n const combinators: string[] = []\n const parts = text.trim().replace(/\\s*([>+~])\\s*/g, ' $1 ').split(/\\s+/)\n let pending: string | null = null\n for (const part of parts) {\n if (!part) continue\n if (part === '>' || part === '+' || part === '~') {\n pending = part\n continue\n }\n const compound = parseCompound(part)\n if (!compound) return null\n if (compounds.length) combinators.push(pending ?? ' ')\n pending = null\n compounds.push(compound)\n }\n if (!compounds.length || pending) return null\n let ids = 0\n let classes = 0\n let tags = 0\n for (const compound of compounds) {\n if (compound.id) ids += 1\n classes += compound.classes.length + compound.attrs.length + (compound.root ? 1 : 0)\n if (compound.tag) tags += 1\n }\n return { compounds, combinators, specificity: ids * 1_000_000 + classes * 1_000 + tags }\n}\n\n/** Splits at top-level commas: none inside brackets or parentheses. */\nfunction splitList(text: string): string[] {\n const out: string[] = []\n let depth = 0\n let start = 0\n for (let at = 0; at < text.length; at += 1) {\n const char = text[at]\n if (char === '(' || char === '[') depth += 1\n else if (char === ')' || char === ']') depth = Math.max(0, depth - 1)\n else if (char === ',' && depth === 0) {\n out.push(text.slice(start, at))\n start = at + 1\n }\n }\n out.push(text.slice(start))\n return out.map((part) => part.trim()).filter(Boolean)\n}\n\n/** A length in px at the read width; `em`/`rem` at 16. */\nexport function siteImportLengthPx(value: string): number | null {\n const match = /^(-?\\d*\\.?\\d+)\\s*(px|em|rem)?$/i.exec(value.trim())\n if (!match) return null\n const amount = Number(match[1])\n return match[2] && match[2].toLowerCase() !== 'px' ? amount * 16 : amount\n}\n\n/** Whether one media query holds for a light-mode screen of this width. */\nfunction mediaQueryHolds(query: string, viewport: number): boolean {\n let text = query.trim().toLowerCase()\n let negate = false\n if (text.startsWith('not ')) {\n negate = true\n text = text.slice(4)\n }\n text = text.replace(/^only\\s+/, '')\n let holds = true\n for (const part of text.split(/\\s+and\\s+/)) {\n const term = part.trim()\n if (!term) continue\n if (!term.startsWith('(')) {\n if (!/^(?:all|screen)$/.test(term)) holds = false\n continue\n }\n const inner = term.replace(/^\\(|\\)$/g, '').trim()\n const feature = /^([\\w-]+)\\s*:\\s*(.+)$/.exec(inner)\n const { height } = SITE_IMPORT_CSS_VIEWPORT\n const width = viewport\n if (feature) {\n const [, name, value] = feature\n const px = siteImportLengthPx(value)\n if (name === 'min-width') holds &&= px !== null && width >= px\n else if (name === 'max-width') holds &&= px !== null && width <= px\n else if (name === 'min-height') holds &&= px !== null && height >= px\n else if (name === 'max-height') holds &&= px !== null && height <= px\n else if (name === 'prefers-color-scheme') holds &&= value.trim() === 'light'\n else if (name === 'prefers-reduced-motion') holds &&= value.trim() === 'no-preference'\n else if (name === 'orientation') holds &&= value.trim() === 'landscape'\n else if (name === 'hover' || name === 'any-hover') holds &&= value.trim() === 'hover'\n else if (name === 'pointer' || name === 'any-pointer') holds &&= value.trim() === 'fine'\n else if (name === 'prefers-contrast' || name === 'forced-colors') holds &&= /^(?:no-preference|none)$/.test(value.trim())\n continue\n }\n // Range syntax: (width >= 900px), (600px <= width < 1200px).\n const range = /^(?:(-?[\\d.]+\\w*)\\s*(<=|<|>=|>)\\s*)?(width|height)\\s*(?:(<=|<|>=|>)\\s*(-?[\\d.]+\\w*))?$/.exec(inner)\n if (range) {\n const size = range[3] === 'width' ? width : height\n const test = (a: number, op: string, b: number) => (op === '<' ? a < b : op === '<=' ? a <= b : op === '>' ? a > b : a >= b)\n if (range[1] && range[2]) {\n const px = siteImportLengthPx(range[1])\n holds &&= px !== null && test(px, range[2], size)\n }\n if (range[4] && range[5]) {\n const px = siteImportLengthPx(range[5])\n holds &&= px !== null && test(size, range[4], px)\n }\n }\n }\n return negate ? !holds : holds\n}\n\nfunction mediaHolds(prelude: string, viewport: number): boolean {\n const list = splitList(prelude.replace(/^@media\\s*/i, ''))\n return !list.length || list.some((query) => mediaQueryHolds(query, viewport))\n}\n\nfunction declarationsOf(body: string): CssRule['decls'] {\n const decls: CssRule['decls'] = []\n // Values may hold semicolons only inside strings or url(), which the kept properties never need.\n for (const part of body.split(';')) {\n const colon = part.indexOf(':')\n if (colon <= 0) continue\n const written = part.slice(0, colon).trim()\n // A custom property's name is case-sensitive, as `var()` reads it.\n const property = written.startsWith('--') ? written : written.toLowerCase()\n if (!property.startsWith('--') && !KEPT_PROPERTIES.has(property)) continue\n let value = part.slice(colon + 1).trim()\n const important = /!\\s*important\\s*$/i.test(value)\n if (important) value = value.replace(/!\\s*important\\s*$/i, '').trim()\n if (value) decls.push([property, value.slice(0, 2_000), important])\n }\n return decls\n}\n\n/** The index key of a selector: its rightmost compound's id, first class, tag, else `*`. */\nfunction keyOf(selector: ComplexSelector): string {\n const last = selector.compounds[selector.compounds.length - 1] as Compound\n if (last.id) return `#${last.id}`\n if (last.classes.length) return `.${last.classes[0]}`\n if (last.root) return ':root'\n if (last.tag) return last.tag\n return '*'\n}\n\n/**\n * The page's sheets parsed for a wide screen. Malformed CSS is read as far as\n * it makes sense, as a browser would; nothing throws.\n */\nexport function siteImportCssOf(sheets: readonly string[], viewport: number = SITE_IMPORT_CSS_VIEWPORT.width): SiteImportCss {\n const css: SiteImportCss = { rules: [], index: new Map(), fontFaces: [] }\n let order = 0\n const addRule = (prelude: string, body: string) => {\n const decls = declarationsOf(body)\n if (!decls.length) return\n for (const text of splitList(prelude)) {\n const selector = parseSelector(text)\n if (!selector) continue\n const rule: CssRule = { selector, order: order++, decls }\n css.rules.push(rule)\n const key = keyOf(selector)\n const list = css.index.get(key)\n if (list) list.push(rule)\n else css.index.set(key, [rule])\n }\n }\n for (const sheet of sheets) {\n const text = String(sheet ?? '').replace(/\\/\\*[\\s\\S]*?\\*\\//g, ' ')\n /** For each open group: whether its rules apply. */\n const groups: boolean[] = []\n let at = 0\n let start = 0\n while (at < text.length) {\n const char = text[at]\n if (char === '\"' || char === \"'\") {\n const end = text.indexOf(char, at + 1)\n at = end < 0 ? text.length : end + 1\n continue\n }\n if (char === ';') {\n // A statement at-rule (@import, @charset) or stray text.\n start = at + 1\n at += 1\n continue\n }\n if (char === '}') {\n groups.pop()\n start = at + 1\n at += 1\n continue\n }\n if (char !== '{') {\n at += 1\n continue\n }\n const prelude = text.slice(start, at).trim()\n const applies = groups.every(Boolean)\n if (/^@(?:media)\\b/i.test(prelude)) {\n groups.push(applies && mediaHolds(prelude, viewport))\n start = at = at + 1\n continue\n }\n if (/^@(?:supports|layer|container|document|scope|starting-style)\\b/i.test(prelude)) {\n groups.push(applies && !/^@starting-style/i.test(prelude))\n start = at = at + 1\n continue\n }\n // A block to read whole: a style rule, a font face, or an at-rule to skip.\n let depth = 1\n let end = at + 1\n while (end < text.length && depth > 0) {\n if (text[end] === '{') depth += 1\n else if (text[end] === '}') depth -= 1\n end += 1\n }\n const body = text.slice(at + 1, Math.max(at + 1, end - 1))\n if (/^@font-face\\b/i.test(prelude)) {\n const family = /font-family\\s*:\\s*([\"']?)([^;\"']+)\\1/i.exec(body)?.[2]?.trim()\n if (family && !css.fontFaces.includes(family)) css.fontFaces.push(family)\n } else if (!prelude.startsWith('@') && applies && prelude) {\n // A rule nested inside a rule (`&:hover`) is a state: only the outer declarations are read.\n addRule(prelude, body.replace(/[^;{}]*\\{[^{}]*\\}/g, ''))\n }\n start = at = end\n }\n }\n return css\n}\n\n/*------------------------------------------\n * Matching and the cascade\n *-----------------------------------------*/\n\nfunction classesOf(element: SiteImportElement): string[] {\n return (element.attrs.class ?? '').split(/\\s+/).filter(Boolean)\n}\n\nfunction attributeOf(element: SiteImportElement, name: string): string | undefined {\n switch (name) {\n case 'class':\n return element.attrs.class\n case 'id':\n return element.attrs.id\n case 'role':\n return element.attrs.role\n case 'aria-label':\n return element.attrs.label\n case 'href':\n return element.attrs.href\n case 'type':\n return element.attrs.type\n case 'style':\n return element.attrs.style\n case 'hidden':\n case 'aria-hidden':\n return element.attrs.hidden ? 'true' : undefined\n case 'data-section-theme':\n case 'data-theme':\n return element.attrs.theme\n default:\n return undefined\n }\n}\n\nfunction compoundMatches(compound: Compound, element: SiteImportElement, rootId: number): boolean {\n if (compound.root && element.id !== rootId) return false\n if (compound.tag && compound.tag !== element.tag) return false\n if (compound.id && compound.id !== element.attrs.id) return false\n if (compound.classes.length) {\n const own = classesOf(element)\n if (!compound.classes.every((name) => own.includes(name))) return false\n }\n for (const attr of compound.attrs) {\n const value = attributeOf(element, attr.name)\n if (value === undefined) return false\n if (!attr.op) continue\n const wanted = attr.value\n const ok =\n attr.op === '='\n ? value === wanted\n : attr.op === '~='\n ? value.split(/\\s+/).includes(wanted)\n : attr.op === '^='\n ? value.startsWith(wanted)\n : attr.op === '$='\n ? value.endsWith(wanted)\n : attr.op === '*='\n ? value.includes(wanted)\n : value === wanted || value.startsWith(`${wanted}-`)\n if (!ok) return false\n }\n return true\n}\n\n/** Whether a selector matches an element, its combinators walked from the right. */\nfunction selectorMatches(\n selector: ComplexSelector,\n element: SiteImportElement,\n elements: readonly SiteImportElement[],\n root: SiteImportElement | null,\n): boolean {\n const rootId = root?.id ?? -2\n /** The element above `at`: its parent, or the document's root above the body. */\n const above = (at: SiteImportElement) => (at.parent >= 0 ? elements[at.parent] : at === root ? undefined : (root ?? undefined))\n const walk = (index: number, at: SiteImportElement): boolean => {\n if (!compoundMatches(selector.compounds[index] as Compound, at, rootId)) return false\n if (index === 0) return true\n const combinator = selector.combinators[index - 1]\n if (combinator === '>') {\n const parent = above(at)\n return !!parent && walk(index - 1, parent)\n }\n if (combinator === '+' || combinator === '~') {\n const siblings = elements[at.parent]?.children ?? []\n const position = siblings.indexOf(at.id)\n for (let before = position - 1; before >= 0; before -= 1) {\n const sibling = elements[siblings[before] as number]\n if (!sibling) continue\n if (walk(index - 1, sibling)) return true\n if (combinator === '+') return false\n }\n return false\n }\n for (let parent = above(at); parent; parent = above(parent)) {\n if (walk(index - 1, parent)) return true\n }\n return false\n }\n return walk(selector.compounds.length - 1, element)\n}\n\n/** One element's resolved style: the kept properties, `var()` read, lowercased. */\nexport type SiteImportComputedStyle = ReadonlyMap<string, string>\n\n/** Reads elements' styles over a page's structure, each once. */\nexport interface SiteImportStyles {\n of(element: number): SiteImportComputedStyle\n /** The root's (`<html>`) element id, which `:root` matches; -1 for none. */\n readonly root: number\n}\n\nconst EMPTY_STYLE: SiteImportComputedStyle = new Map()\n\n/** Replaces each `var(--x, fallback)` with what the custom properties hold, to a few levels. */\nfunction withVariables(value: string, custom: ReadonlyMap<string, string>): string {\n let out = value\n for (let pass = 0; pass < 4 && out.includes('var('); pass += 1) {\n out = out.replace(/var\\(\\s*(--[\\w-]+)\\s*(?:,\\s*((?:[^()]|\\([^()]*\\))*))?\\)/g, (_, name: string, fallback?: string) => custom.get(name) ?? fallback?.trim() ?? '')\n }\n return out\n}\n\n/** The kept declarations an inline `style` attribute writes. */\nfunction inlineDeclarations(style: string | undefined): CssRule['decls'] {\n return style ? declarationsOf(style) : []\n}\n\n/**\n * Elements' styles over a page's structure and its sheets. Styles are\n * resolved on demand, parent first, each element once.\n */\nexport function siteImportStylesOf(structure: Pick<SiteImportStructure, 'elements' | 'root'>, css: SiteImportCss): SiteImportStyles {\n const { elements } = structure\n const resolved = new Map<number, { style: Map<string, string>; custom: Map<string, string> }>()\n // The page's root is above the body: `:root` and `html` rules are its.\n const rootStyle = (() => {\n const style = new Map<string, string>()\n const custom = new Map<string, string>()\n const fake: SiteImportElement = { id: -2, tag: 'html', parent: -1, children: [], region: 'main', nav: false, attrs: structure.root ?? {}, blocks: [] }\n const candidates = [...(css.index.get(':root') ?? []), ...(css.index.get('html') ?? []), ...(css.index.get('*') ?? [])]\n for (const name of classesOf(fake)) candidates.push(...(css.index.get(`.${name}`) ?? []))\n if (fake.attrs.id) candidates.push(...(css.index.get(`#${fake.attrs.id}`) ?? []))\n apply(candidates.filter((rule) => selectorMatches(rule.selector, fake, [], fake)), inlineDeclarations(fake.attrs.style), style, custom)\n return { style, custom, element: fake }\n })()\n\n function apply(rules: CssRule[], inline: CssRule['decls'], style: Map<string, string>, custom: Map<string, string>) {\n const unique = [...new Set(rules)].sort((a, b) => a.selector.specificity - b.selector.specificity || a.order - b.order)\n const important: Array<[string, string]> = []\n const put = (property: string, value: string) => {\n if (property.startsWith('--')) custom.set(property, value)\n else style.set(property, value)\n }\n for (const rule of unique) {\n for (const [property, value, flag] of rule.decls) {\n if (flag) important.push([property, value])\n else put(property, value)\n }\n }\n for (const [property, value, flag] of inline) {\n if (flag) important.push([property, value])\n else put(property, value)\n }\n for (const [property, value] of important) put(property, value)\n }\n\n function resolve(id: number): { style: Map<string, string>; custom: Map<string, string> } {\n const held = resolved.get(id)\n if (held) return held\n const element = elements[id]\n if (!element) return rootStyle\n const parent = element.parent >= 0 ? resolve(element.parent) : rootStyle\n const candidates: CssRule[] = [...(css.index.get(element.tag) ?? []), ...(css.index.get('*') ?? [])]\n for (const name of classesOf(element)) candidates.push(...(css.index.get(`.${name}`) ?? []))\n if (element.attrs.id) candidates.push(...(css.index.get(`#${element.attrs.id}`) ?? []))\n const matched = candidates.filter((rule) => selectorMatches(rule.selector, element, elements, rootStyle.element))\n const own = new Map<string, string>()\n const custom = new Map(parent.custom)\n apply(matched, inlineDeclarations(element.attrs.style), own, custom)\n const style = new Map<string, string>()\n for (const property of INHERITED) {\n const value = parent.style.get(property)\n if (value !== undefined) style.set(property, value)\n }\n for (const [property, value] of own) {\n const lowered = value.trim().toLowerCase()\n if (lowered === 'inherit') {\n const inherited = parent.style.get(property)\n if (inherited !== undefined) style.set(property, inherited)\n continue\n }\n if (lowered === 'initial' || lowered === 'unset' || lowered === 'revert') {\n if (!INHERITED.has(property) || lowered === 'initial') style.delete(property)\n continue\n }\n style.set(property, property === 'font-family' ? withVariables(value, custom) : withVariables(value, custom).toLowerCase())\n }\n const entry = { style, custom }\n resolved.set(id, entry)\n return entry\n }\n\n // The root's own inherited values reach the body through `rootStyle`.\n for (const [property, value] of rootStyle.style) {\n rootStyle.style.set(property, property === 'font-family' ? withVariables(value, rootStyle.custom) : withVariables(value, rootStyle.custom).toLowerCase())\n }\n return {\n root: -2,\n of(element: number): SiteImportComputedStyle {\n if (element === -2) return rootStyle.style\n return elements[element] ? resolve(element).style : EMPTY_STYLE\n },\n }\n}\n\n/*------------------------------------------\n * Values\n *-----------------------------------------*/\n\nexport interface SiteImportRgba {\n r: number\n g: number\n b: number\n a: number\n}\n\nconst NAMED_COLORS: Record<string, string> = {\n white: '#ffffff',\n black: '#000000',\n red: '#ff0000',\n green: '#008000',\n blue: '#0000ff',\n gray: '#808080',\n grey: '#808080',\n silver: '#c0c0c0',\n whitesmoke: '#f5f5f5',\n ghostwhite: '#f8f8ff',\n snow: '#fffafa',\n ivory: '#fffff0',\n beige: '#f5f5dc',\n linen: '#faf0e6',\n navy: '#000080',\n teal: '#008080',\n orange: '#ffa500',\n gold: '#ffd700',\n purple: '#800080',\n crimson: '#dc143c',\n tomato: '#ff6347',\n coral: '#ff7f50',\n aliceblue: '#f0f8ff',\n lightgray: '#d3d3d3',\n lightgrey: '#d3d3d3',\n gainsboro: '#dcdcdc',\n darkslategray: '#2f4f4f',\n dimgray: '#696969',\n}\n\n/** The first color a value names, or `null`; `transparent` is a color of no strength. */\nexport function siteImportColorOf(value: string | undefined): SiteImportRgba | null {\n if (!value) return null\n const text = value.toLowerCase()\n const hex = /#([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})\\b/.exec(text)\n const rgb = /rgba?\\(\\s*(-?[\\d.]+%?)\\s*[,\\s]\\s*(-?[\\d.]+%?)\\s*[,\\s]\\s*(-?[\\d.]+%?)\\s*(?:[,/]\\s*(-?[\\d.]+%?)\\s*)?\\)/.exec(text)\n const hsl = /hsla?\\(\\s*(-?[\\d.]+)(?:deg)?\\s*[,\\s]\\s*([\\d.]+)%\\s*[,\\s]\\s*([\\d.]+)%\\s*(?:[,/]\\s*([\\d.]+%?)\\s*)?\\)/.exec(text)\n const named = /\\b(transparent|[a-z]+)\\b/.exec(text.replace(/[a-z-]+\\(/g, ' ('))\n const first = [hex, rgb, hsl].filter((match): match is RegExpExecArray => !!match).sort((a, b) => a.index - b.index)[0]\n const alphaOf = (raw: string | undefined) => (raw === undefined ? 1 : raw.endsWith('%') ? Number(raw.slice(0, -1)) / 100 : Number(raw))\n if (first === hex && hex) {\n const digits = hex[1]\n const full = digits.length <= 4 ? digits.split('').map((d) => d + d).join('') : digits\n return {\n r: parseInt(full.slice(0, 2), 16),\n g: parseInt(full.slice(2, 4), 16),\n b: parseInt(full.slice(4, 6), 16),\n a: full.length === 8 ? parseInt(full.slice(6, 8), 16) / 255 : 1,\n }\n }\n if (first === rgb && rgb) {\n const channel = (raw: string) => Math.max(0, Math.min(255, raw.endsWith('%') ? (Number(raw.slice(0, -1)) / 100) * 255 : Number(raw)))\n return { r: channel(rgb[1]), g: channel(rgb[2]), b: channel(rgb[3]), a: alphaOf(rgb[4]) }\n }\n if (first === hsl && hsl) {\n const h = (((Number(hsl[1]) % 360) + 360) % 360) / 360\n const s = Number(hsl[2]) / 100\n const l = Number(hsl[3]) / 100\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s\n const p = 2 * l - q\n const tone = (t: number) => {\n const x = t < 0 ? t + 1 : t > 1 ? t - 1 : t\n if (x < 1 / 6) return p + (q - p) * 6 * x\n if (x < 1 / 2) return q\n if (x < 2 / 3) return p + (q - p) * (2 / 3 - x) * 6\n return p\n }\n return { r: tone(h + 1 / 3) * 255, g: tone(h) * 255, b: tone(h - 1 / 3) * 255, a: alphaOf(hsl[4]) }\n }\n if (named) {\n if (named[1] === 'transparent') return { r: 0, g: 0, b: 0, a: 0 }\n const known = NAMED_COLORS[named[1]]\n if (known) return siteImportColorOf(known)\n }\n return null\n}\n\n/** `#rrggbb` of a color, its strength ignored. */\nexport function siteImportHex(color: SiteImportRgba): string {\n return `#${[color.r, color.g, color.b].map((channel) => Math.round(channel).toString(16).padStart(2, '0')).join('')}`\n}\n\n/** Relative luminance, 0 (black) to 1 (white). */\nexport function siteImportLuminance(color: SiteImportRgba): number {\n const linear = (channel: number) => {\n const c = channel / 255\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4\n }\n return 0.2126 * linear(color.r) + 0.7152 * linear(color.g) + 0.0722 * linear(color.b)\n}\n\n/** How colorful a color is, 0 (grey) to 1. */\nexport function siteImportSaturation(color: SiteImportRgba): number {\n const max = Math.max(color.r, color.g, color.b) / 255\n const min = Math.min(color.r, color.g, color.b) / 255\n if (max === min) return 0\n const l = (max + min) / 2\n return (max - min) / (1 - Math.abs(2 * l - 1))\n}\n\n/** What an element draws behind itself: a color, a gradient and its colors, or a picture. */\nexport interface SiteImportBackground {\n color: SiteImportRgba | null\n gradient: SiteImportRgba[] | null\n /** A picture's address, as written. */\n image: string | null\n}\n\n/** An element's own background, from the shorthand or its parts. */\nexport function siteImportBackgroundOf(style: SiteImportComputedStyle): SiteImportBackground {\n const shorthand = style.get('background') ?? ''\n const imageValue = style.get('background-image') ?? (/(?:url|gradient)\\(/.test(shorthand) ? shorthand : '')\n const colorValue = style.get('background-color') ?? (shorthand && !/(?:url|gradient)\\(/.test(shorthand) ? shorthand : shorthand.replace(/[a-z-]*gradient\\((?:[^()]|\\([^()]*\\))*\\)|url\\([^)]*\\)/g, ' '))\n const color = siteImportColorOf(colorValue)\n let gradient: SiteImportRgba[] | null = null\n let image: string | null = null\n const gradientMatch = /gradient\\(((?:[^()]|\\([^()]*\\))*)\\)/.exec(imageValue)\n if (gradientMatch) {\n const stops: SiteImportRgba[] = []\n for (const match of gradientMatch[1].matchAll(/#[0-9a-f]{3,8}\\b|rgba?\\([^)]*\\)|hsla?\\([^)]*\\)|\\b(?:white|black|transparent)\\b/gi)) {\n const stop = siteImportColorOf(match[0])\n if (stop) stops.push(stop)\n }\n if (stops.length) gradient = stops\n }\n const url = /url\\(\\s*([\"']?)([^\"')]+)\\1\\s*\\)/.exec(imageValue)\n if (url) image = url[2].trim()\n return { color: color && color.a > 0.02 ? color : null, gradient, image }\n}\n\n/** Whether an element draws a border on any side. */\nexport function siteImportHasBorder(style: SiteImportComputedStyle): boolean {\n const sides = ['border', 'border-top', 'border-bottom', 'border-left', 'border-right']\n for (const side of sides) {\n const value = style.get(side)\n if (!value) continue\n if (/\\bnone\\b|\\bhidden\\b/.test(value) || /^0(?:px)?$/.test(value.trim())) continue\n const color = siteImportColorOf(value) ?? siteImportColorOf(style.get('border-color'))\n if (color && color.a < 0.05) continue\n if (/\\d/.test(value) || /\\b(?:solid|dashed|dotted|double)\\b/.test(value)) {\n const width = /(-?[\\d.]+)px/.exec(value)\n if (!width || Number(width[1]) > 0) return true\n }\n }\n const width = style.get('border-width')\n const kind = style.get('border-style')\n if (kind && /\\b(?:solid|dashed|dotted|double)\\b/.test(kind) && (!width || !/^0(?:px)?$/.test(width.trim()))) return true\n return false\n}\n\n/** Whether an element draws a shadow. */\nexport function siteImportHasShadow(style: SiteImportComputedStyle): boolean {\n const value = style.get('box-shadow')\n return !!value && !/^(?:none|0|initial|unset)$/.test(value.trim()) && !/^0(?:px)?\\s+0(?:px)?\\s+0(?:px)?(?:\\s+0(?:px)?)?\\s+(?:transparent|rgba\\([^)]*,\\s*0\\))/.test(value.trim())\n}\n\n/** An element's corner radius in px, or `null`. */\nexport function siteImportRadiusPx(style: SiteImportComputedStyle): number | null {\n const value = style.get('border-radius')\n if (!value) return null\n const first = value.trim().split(/[\\s/]+/)[0] ?? ''\n if (first.endsWith('%')) return Number(first.slice(0, -1)) >= 50 ? 999 : Number(first.slice(0, -1))\n return siteImportLengthPx(first)\n}\n\n/** A font size in px, or `null`. */\nexport function siteImportFontSizePx(style: SiteImportComputedStyle): number | null {\n const value = style.get('font-size')\n if (!value) return null\n const clamp = /clamp\\(([^,]+),([^,]+),([^)]+)\\)/.exec(value)\n // A fluid size at the read width: its maximum, as a wide screen shows it.\n const text = clamp ? clamp[3] : value\n return siteImportLengthPx(text.trim())\n}\n\n/** The relative widths a grid template draws its columns at, or `null` for none. */\nexport function siteImportGridColumns(template: string | undefined): number[] | null {\n if (!template || /^(?:none|subgrid|masonry)$/.test(template.trim())) return null\n let text = template.trim()\n // repeat(3, 1fr) / repeat(auto-fill, minmax(240px, 1fr)): the count, or three of them.\n text = text.replace(/repeat\\(\\s*([\\w-]+)\\s*,\\s*((?:[^()]|\\([^()]*\\))*)\\)/g, (_, count: string, track: string) => {\n const times = /^\\d+$/.test(count) ? Math.min(12, Number(count)) : 3\n return Array.from({ length: times }, () => track.trim()).join(' ')\n })\n const tracks: string[] = []\n let depth = 0\n let token = ''\n for (const char of text) {\n if (char === '(') depth += 1\n if (char === ')') depth -= 1\n if (/\\s/.test(char) && depth === 0) {\n if (token) tracks.push(token)\n token = ''\n } else token += char\n }\n if (token) tracks.push(token)\n const weights = tracks\n .filter((track) => !/^\\[.*\\]$/.test(track))\n .map((track) => {\n const fr = /(-?[\\d.]+)fr\\)?$/.exec(track)\n if (fr) return Number(fr[1]) || 1\n const px = /(-?[\\d.]+)px/.exec(track)\n if (px) return Number(px[1]) / 100\n const percent = /(-?[\\d.]+)%/.exec(track)\n if (percent) return Number(percent[1]) / 10\n return 1\n })\n return weights.length ? weights : null\n}\n\n/** Weights scaled to twelfths, each at least 1: `[420, 788]` is `[4, 8]`. */\nexport function siteImportTwelfths(weights: readonly number[]): number[] {\n const total = weights.reduce((sum, weight) => sum + Math.max(0, weight), 0)\n if (!total) return weights.map(() => 1)\n const scaled = weights.map((weight) => Math.max(1, Math.round((Math.max(0, weight) / total) * 12)))\n // Two equal tracks stay equal, three stay thirds.\n const unique = new Set(weights.map((weight) => Math.round(weight * 1000)))\n if (unique.size === 1) return weights.map(() => 1)\n return scaled\n}\n\n/** The families a `font-family` value names, quotes dropped, generic ones left out. */\nexport function siteImportFontFamilies(value: string | undefined): string[] {\n if (!value) return []\n return splitList(value)\n .map((family) => family.replace(/^[\"']|[\"']$/g, '').trim())\n .filter((family) => family && !/^(?:serif|sans-serif|monospace|cursive|fantasy|system-ui|ui-[\\w-]+|-apple-system|blinkmacsystemfont|inherit|initial|emoji|math|var\\(.*)$/i.test(family))\n}\n"],"names":["SITE_IMPORT_CSS_VIEWPORT","width","height","SITE_IMPORT_CSS_WIDE_WIDTH","KEPT_PROPERTIES","Set","INHERITED","unescapeIdent","text","replace","_","escaped","test","code","parseInt","trim","String","fromCodePoint","IDENT","raw","SIMPLE","RegExp","AT_REST","parseCompound","compound","tag","id","classes","attrs","root","rest","match","exec","slice","length","toLowerCase","push","name","op","value","has","parseSelector","compounds","combinators","parts","split","pending","part","ids","tags","specificity","splitList","out","depth","start","at","char","Math","max","map","filter","Boolean","siteImportLengthPx","amount","Number","mediaQueryHolds","query","viewport","negate","startsWith","holds","term","inner","feature","px","range","size","a","b","mediaHolds","prelude","list","some","declarationsOf","body","decls","colon","indexOf","written","property","important","keyOf","selector","last","siteImportCssOf","sheets","css","rules","index","Map","fontFaces","order","addRule","rule","key","get","set","sheet","groups","end","pop","applies","every","family","includes","classesOf","element","class","attributeOf","role","label","href","type","style","hidden","undefined","theme","compoundMatches","rootId","own","attr","wanted","ok","endsWith","selectorMatches","elements","above","parent","walk","combinator","siblings","children","position","before","sibling","EMPTY_STYLE","withVariables","custom","pass","fallback","inlineDeclarations","siteImportStylesOf","structure","resolved","rootStyle","fake","region","nav","blocks","candidates","apply","inline","unique","sort","put","flag","resolve","held","matched","lowered","inherited","delete","entry","of","NAMED_COLORS","white","black","red","green","blue","gray","grey","silver","whitesmoke","ghostwhite","snow","ivory","beige","linen","navy","teal","orange","gold","purple","crimson","tomato","coral","aliceblue","lightgray","lightgrey","gainsboro","darkslategray","dimgray","siteImportColorOf","hex","rgb","hsl","named","first","alphaOf","digits","full","d","join","r","g","channel","min","h","s","l","q","p","tone","t","x","known","siteImportHex","color","round","toString","padStart","siteImportLuminance","linear","c","siteImportSaturation","abs","siteImportBackgroundOf","shorthand","imageValue","colorValue","gradient","image","gradientMatch","stops","matchAll","stop","url","siteImportHasBorder","sides","side","kind","siteImportHasShadow","siteImportRadiusPx","siteImportFontSizePx","clamp","siteImportGridColumns","template","count","track","times","Array","from","tracks","token","weights","fr","percent","siteImportTwelfths","total","reduce","sum","weight","scaled","siteImportFontFamilies"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;2CAuB2C,GAI3C,2EAA2E,GAC3E,OAAO,MAAMA,2BAA2B;IAAEC,OAAO;IAAMC,QAAQ;AAAI,EAAU;AAE7E;;;;;CAKC,GACD,OAAO,MAAMC,6BAA6B,KAAI;AAE9C,uGAAuG,GACvG,MAAMC,kBAAkB,IAAIC,IAAI;IAC9B;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,uEAAuE,GACvE,MAAMC,YAAY,IAAID,IAAI;IAAC;IAAS;IAAe;IAAa;IAAe;IAAkB;IAAkB;IAAc;CAAa;AAkC9I;;2CAE2C,GAE3C,SAASE,cAAcC,IAAY;IACjC,OAAOA,KAAKC,OAAO,CAAC,8BAA8B,CAACC,GAAGC;QACpD,IAAI,wBAAwBC,IAAI,CAACD,UAAU;YACzC,MAAME,OAAOC,SAASH,QAAQI,IAAI,IAAI;YACtC,OAAOF,OAAO,KAAKA,QAAQ,WAAWG,OAAOC,aAAa,CAACJ,QAAQ;QACrE;QACA,OAAOF;IACT;AACF;AAEA,MAAMO,QAAQF,OAAOG,GAAG,CAAC,iDAAiD,CAAC;AAC3E,MAAMC,SAAS,IAAIC,OACjBL,OAAOG,GAAG,CAAC,QAAQ,EAAED,MAAM,IAAI,EAAEA,MAAM,KAAK,EAAEA,MAAM,+FAA+F,EAAEA,MAAM,8BAA8B,CAAC;AAG5L,yEAAyE,GACzE,MAAMI,UAAU,IAAIjB,IAAI;IAAC;IAAQ;CAAW;AAE5C,qFAAqF,GACrF,SAASk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,GAAGuO,UAAU;AACpC;AAEA,2EAA2E,GAC3E,OAAO,SAASG,mBAAmBH,OAA0B;IAC3D,MAAMI,QAAQJ,QAAQK,MAAM,CAAC,CAACC,KAAKC,SAAWD,MAAMtN,KAAKC,GAAG,CAAC,GAAGsN,SAAS;IACzE,IAAI,CAACH,OAAO,OAAOJ,QAAQ9M,GAAG,CAAC,IAAM;IACrC,MAAMsN,SAASR,QAAQ9M,GAAG,CAAC,CAACqN,SAAWvN,KAAKC,GAAG,CAAC,GAAGD,KAAK4K,KAAK,CAAC,AAAC5K,KAAKC,GAAG,CAAC,GAAGsN,UAAUH,QAAS;IAC9F,kDAAkD;IAClD,MAAM3G,SAAS,IAAI7J,IAAIoQ,QAAQ9M,GAAG,CAAC,CAACqN,SAAWvN,KAAK4K,KAAK,CAAC2C,SAAS;IACnE,IAAI9G,OAAOtF,IAAI,KAAK,GAAG,OAAO6L,QAAQ9M,GAAG,CAAC,IAAM;IAChD,OAAOsN;AACT;AAEA,qFAAqF,GACrF,OAAO,SAASC,uBAAuB3O,KAAyB;IAC9D,IAAI,CAACA,OAAO,OAAO,EAAE;IACrB,OAAOY,UAAUZ,OACdoB,GAAG,CAAC,CAACsD,SAAWA,OAAOxG,OAAO,CAAC,gBAAgB,IAAIM,IAAI,IACvD6C,MAAM,CAAC,CAACqD,SAAWA,UAAU,CAAC,4IAA4IrG,IAAI,CAACqG;AACpL"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/site-import/site-import-css.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/*==========================================\n * HOW A PAGE IS STYLED, AS A WIDE SCREEN SHOWS IT (AGL-4106).\n *\n * Bring my site reads a page's layout, not only its lines, and most of a\n * layout lives in the stylesheet: which band is grey and which is dark, which\n * container lays its children out in three columns, which link is drawn as a\n * filled button. This is a small cascade, enough for that and no more:\n *\n * - **The sheets.** The page's own `<style>` sheets and the ones it links,\n * read in order. `@media` rules apply as a 1280-pixel screen in light mode\n * sees them, so a grid's desktop columns win over its phone ones;\n * `@layer`, `@supports` and `@container` are read through; keyframes, font\n * faces (their families noted) and page rules are skipped.\n * - **Selectors.** Tags, classes (escaped ones too, as utility frameworks\n * write them), ids and attributes, joined by any combinator. A rule that\n * only applies on hover, focus or to a generated part (`::before`) is a\n * state the page is not in and is not read.\n * - **The cascade.** Specificity, then order, `!important` over both, and the\n * element's own `style` over every rule; color, font and alignment inherit,\n * and so do custom properties, which `var()` reads.\n *\n * Only the properties the layout reader asks about are kept. Nothing here\n * runs anything a page wrote: values are text compared to text.\n *=========================================*/\n\nimport type { SiteImportElement, SiteImportStructure } from './site-import-html'\n\n/** The width a page is read at: a laptop's, where a desktop layout shows. */\nexport const SITE_IMPORT_CSS_VIEWPORT = { width: 1280, height: 800 } as const\n\n/**\n * The width a page's column is read at (AGL-4083). A container caps itself\n * only on screens wider than its cap (`@media (min-width:1536px)` around a\n * `max-width:1536px`), so on a laptop it runs the whole page: read there, it\n * would look as if it had no cap at all.\n */\nexport const SITE_IMPORT_CSS_WIDE_WIDTH = 1920\n\n/** The properties the layout reader reads; every other declaration is dropped as the sheet is parsed. */\nconst KEPT_PROPERTIES = new Set([\n 'background',\n 'background-color',\n 'background-image',\n 'color',\n 'border',\n 'border-width',\n 'border-style',\n 'border-color',\n 'border-top',\n 'border-right',\n 'border-bottom',\n 'border-left',\n 'border-top-width',\n 'border-bottom-width',\n 'border-left-width',\n 'border-right-width',\n 'border-top-style',\n 'border-bottom-style',\n 'border-top-color',\n 'border-bottom-color',\n 'border-radius',\n 'box-shadow',\n 'display',\n 'grid-template-columns',\n 'grid-column',\n 'flex',\n 'flex-direction',\n 'flex-wrap',\n 'flex-grow',\n 'flex-basis',\n 'width',\n 'max-width',\n // The shape a picture is framed at (AGL-4138): a box's own, or a height it is cropped to.\n 'aspect-ratio',\n 'height',\n 'font-family',\n 'font-size',\n 'font-weight',\n 'text-transform',\n 'letter-spacing',\n 'text-align',\n 'position',\n 'visibility',\n 'padding',\n 'padding-top',\n 'padding-bottom',\n 'padding-left',\n 'padding-right',\n 'object-fit',\n 'justify-content',\n 'align-items',\n])\n\n/** What an element takes from its parent when it says nothing itself. */\nconst INHERITED = new Set(['color', 'font-family', 'font-size', 'font-weight', 'text-transform', 'letter-spacing', 'text-align', 'visibility'])\n\ninterface Compound {\n tag: string | null\n id: string | null\n classes: string[]\n attrs: Array<{ name: string; op: string | null; value: string }>\n /** `:root`: only the document's root element. */\n root: boolean\n}\n\ninterface ComplexSelector {\n /** Rightmost last. */\n compounds: Compound[]\n /** `combinators[i]` joins `compounds[i]` and `compounds[i + 1]`: a space, a child, an adjacent or a sibling combinator. */\n combinators: string[]\n specificity: number\n}\n\ninterface CssRule {\n selector: ComplexSelector\n order: number\n decls: Array<[property: string, value: string, important: boolean]>\n}\n\n/** The page's sheets, parsed for one width. */\nexport interface SiteImportCss {\n rules: CssRule[]\n /** Rules by their rightmost compound's id (`#x`), first class (`.x`), tag, or `*`. */\n index: Map<string, CssRule[]>\n /** Families its `@font-face` rules name, in order. */\n fontFaces: string[]\n}\n\n/*------------------------------------------\n * Parsing\n *-----------------------------------------*/\n\nfunction unescapeIdent(text: string): string {\n return text.replace(/\\\\([0-9a-fA-F]{1,6}\\s?|.)/g, (_, escaped: string) => {\n if (/^[0-9a-fA-F]{1,6}\\s?$/.test(escaped)) {\n const code = parseInt(escaped.trim(), 16)\n return code > 0 && code <= 0x10ffff ? String.fromCodePoint(code) : ''\n }\n return escaped\n })\n}\n\nconst IDENT = String.raw`(?:\\\\[0-9a-fA-F]{1,6}\\s?|\\\\.|[\\w-]|[^\\x00-\\x7f])+`\nconst SIMPLE = new RegExp(\n String.raw`^(?:(\\*|${IDENT})|#(${IDENT})|\\.(${IDENT})|\\[\\s*([\\w-]+)\\s*(?:([~|^$*]?=)\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\]\\s]+))\\s*(?:[is]\\s*)?)?\\]|(::?)(${IDENT})(\\((?:[^()]|\\([^()]*\\))*\\))?)`,\n)\n\n/** The pseudo-classes a page at rest matches as if they were not there. */\nconst AT_REST = new Set(['link', 'any-link'])\n\n/** One compound selector, or `null` when it depends on a state or a generated part. */\nfunction parseCompound(text: string): Compound | null {\n const compound: Compound = { tag: null, id: null, classes: [], attrs: [], root: false }\n let rest = text\n while (rest) {\n const match = SIMPLE.exec(rest)\n if (!match || !match[0]) return null\n rest = rest.slice(match[0].length)\n if (match[1]) compound.tag = match[1] === '*' ? null : unescapeIdent(match[1]).toLowerCase()\n else if (match[2]) compound.id = unescapeIdent(match[2])\n else if (match[3]) compound.classes.push(unescapeIdent(match[3]))\n else if (match[4]) compound.attrs.push({ name: match[4].toLowerCase(), op: match[5] ?? null, value: match[6] ?? match[7] ?? match[8] ?? '' })\n else if (match[9]) {\n const name = unescapeIdent(match[10] ?? '').toLowerCase()\n if (match[9] === '::') return null\n if (name === 'root') compound.root = true\n else if (!AT_REST.has(name)) return null\n }\n }\n return compound\n}\n\n/** A complex selector, or `null` when any part of it cannot be read at rest. */\nfunction parseSelector(text: string): ComplexSelector | null {\n const compounds: Compound[] = []\n const combinators: string[] = []\n const parts = text.trim().replace(/\\s*([>+~])\\s*/g, ' $1 ').split(/\\s+/)\n let pending: string | null = null\n for (const part of parts) {\n if (!part) continue\n if (part === '>' || part === '+' || part === '~') {\n pending = part\n continue\n }\n const compound = parseCompound(part)\n if (!compound) return null\n if (compounds.length) combinators.push(pending ?? ' ')\n pending = null\n compounds.push(compound)\n }\n if (!compounds.length || pending) return null\n let ids = 0\n let classes = 0\n let tags = 0\n for (const compound of compounds) {\n if (compound.id) ids += 1\n classes += compound.classes.length + compound.attrs.length + (compound.root ? 1 : 0)\n if (compound.tag) tags += 1\n }\n return { compounds, combinators, specificity: ids * 1_000_000 + classes * 1_000 + tags }\n}\n\n/** Splits at top-level commas: none inside brackets or parentheses. */\nfunction splitList(text: string): string[] {\n const out: string[] = []\n let depth = 0\n let start = 0\n for (let at = 0; at < text.length; at += 1) {\n const char = text[at]\n if (char === '(' || char === '[') depth += 1\n else if (char === ')' || char === ']') depth = Math.max(0, depth - 1)\n else if (char === ',' && depth === 0) {\n out.push(text.slice(start, at))\n start = at + 1\n }\n }\n out.push(text.slice(start))\n return out.map((part) => part.trim()).filter(Boolean)\n}\n\n/** A length in px at the read width; `em`/`rem` at 16. */\nexport function siteImportLengthPx(value: string): number | null {\n const match = /^(-?\\d*\\.?\\d+)\\s*(px|em|rem)?$/i.exec(value.trim())\n if (!match) return null\n const amount = Number(match[1])\n return match[2] && match[2].toLowerCase() !== 'px' ? amount * 16 : amount\n}\n\n/** Whether one media query holds for a light-mode screen of this width. */\nfunction mediaQueryHolds(query: string, viewport: number): boolean {\n let text = query.trim().toLowerCase()\n let negate = false\n if (text.startsWith('not ')) {\n negate = true\n text = text.slice(4)\n }\n text = text.replace(/^only\\s+/, '')\n let holds = true\n for (const part of text.split(/\\s+and\\s+/)) {\n const term = part.trim()\n if (!term) continue\n if (!term.startsWith('(')) {\n if (!/^(?:all|screen)$/.test(term)) holds = false\n continue\n }\n const inner = term.replace(/^\\(|\\)$/g, '').trim()\n const feature = /^([\\w-]+)\\s*:\\s*(.+)$/.exec(inner)\n const { height } = SITE_IMPORT_CSS_VIEWPORT\n const width = viewport\n if (feature) {\n const [, name, value] = feature\n const px = siteImportLengthPx(value)\n if (name === 'min-width') holds &&= px !== null && width >= px\n else if (name === 'max-width') holds &&= px !== null && width <= px\n else if (name === 'min-height') holds &&= px !== null && height >= px\n else if (name === 'max-height') holds &&= px !== null && height <= px\n else if (name === 'prefers-color-scheme') holds &&= value.trim() === 'light'\n else if (name === 'prefers-reduced-motion') holds &&= value.trim() === 'no-preference'\n else if (name === 'orientation') holds &&= value.trim() === 'landscape'\n else if (name === 'hover' || name === 'any-hover') holds &&= value.trim() === 'hover'\n else if (name === 'pointer' || name === 'any-pointer') holds &&= value.trim() === 'fine'\n else if (name === 'prefers-contrast' || name === 'forced-colors') holds &&= /^(?:no-preference|none)$/.test(value.trim())\n continue\n }\n // Range syntax: (width >= 900px), (600px <= width < 1200px).\n const range = /^(?:(-?[\\d.]+\\w*)\\s*(<=|<|>=|>)\\s*)?(width|height)\\s*(?:(<=|<|>=|>)\\s*(-?[\\d.]+\\w*))?$/.exec(inner)\n if (range) {\n const size = range[3] === 'width' ? width : height\n const test = (a: number, op: string, b: number) => (op === '<' ? a < b : op === '<=' ? a <= b : op === '>' ? a > b : a >= b)\n if (range[1] && range[2]) {\n const px = siteImportLengthPx(range[1])\n holds &&= px !== null && test(px, range[2], size)\n }\n if (range[4] && range[5]) {\n const px = siteImportLengthPx(range[5])\n holds &&= px !== null && test(size, range[4], px)\n }\n }\n }\n return negate ? !holds : holds\n}\n\nfunction mediaHolds(prelude: string, viewport: number): boolean {\n const list = splitList(prelude.replace(/^@media\\s*/i, ''))\n return !list.length || list.some((query) => mediaQueryHolds(query, viewport))\n}\n\nfunction declarationsOf(body: string): CssRule['decls'] {\n const decls: CssRule['decls'] = []\n // Values may hold semicolons only inside strings or url(), which the kept properties never need.\n for (const part of body.split(';')) {\n const colon = part.indexOf(':')\n if (colon <= 0) continue\n const written = part.slice(0, colon).trim()\n // A custom property's name is case-sensitive, as `var()` reads it.\n const property = written.startsWith('--') ? written : written.toLowerCase()\n if (!property.startsWith('--') && !KEPT_PROPERTIES.has(property)) continue\n let value = part.slice(colon + 1).trim()\n const important = /!\\s*important\\s*$/i.test(value)\n if (important) value = value.replace(/!\\s*important\\s*$/i, '').trim()\n if (value) decls.push([property, value.slice(0, 2_000), important])\n }\n return decls\n}\n\n/** The index key of a selector: its rightmost compound's id, first class, tag, else `*`. */\nfunction keyOf(selector: ComplexSelector): string {\n const last = selector.compounds[selector.compounds.length - 1] as Compound\n if (last.id) return `#${last.id}`\n if (last.classes.length) return `.${last.classes[0]}`\n if (last.root) return ':root'\n if (last.tag) return last.tag\n return '*'\n}\n\n/**\n * The page's sheets parsed for a wide screen. Malformed CSS is read as far as\n * it makes sense, as a browser would; nothing throws.\n */\nexport function siteImportCssOf(sheets: readonly string[], viewport: number = SITE_IMPORT_CSS_VIEWPORT.width): SiteImportCss {\n const css: SiteImportCss = { rules: [], index: new Map(), fontFaces: [] }\n let order = 0\n const addRule = (prelude: string, body: string) => {\n const decls = declarationsOf(body)\n if (!decls.length) return\n for (const text of splitList(prelude)) {\n const selector = parseSelector(text)\n if (!selector) continue\n const rule: CssRule = { selector, order: order++, decls }\n css.rules.push(rule)\n const key = keyOf(selector)\n const list = css.index.get(key)\n if (list) list.push(rule)\n else css.index.set(key, [rule])\n }\n }\n for (const sheet of sheets) {\n const text = String(sheet ?? '').replace(/\\/\\*[\\s\\S]*?\\*\\//g, ' ')\n /** For each open group: whether its rules apply. */\n const groups: boolean[] = []\n let at = 0\n let start = 0\n while (at < text.length) {\n const char = text[at]\n if (char === '\"' || char === \"'\") {\n const end = text.indexOf(char, at + 1)\n at = end < 0 ? text.length : end + 1\n continue\n }\n if (char === ';') {\n // A statement at-rule (@import, @charset) or stray text.\n start = at + 1\n at += 1\n continue\n }\n if (char === '}') {\n groups.pop()\n start = at + 1\n at += 1\n continue\n }\n if (char !== '{') {\n at += 1\n continue\n }\n const prelude = text.slice(start, at).trim()\n const applies = groups.every(Boolean)\n if (/^@(?:media)\\b/i.test(prelude)) {\n groups.push(applies && mediaHolds(prelude, viewport))\n start = at = at + 1\n continue\n }\n if (/^@(?:supports|layer|container|document|scope|starting-style)\\b/i.test(prelude)) {\n groups.push(applies && !/^@starting-style/i.test(prelude))\n start = at = at + 1\n continue\n }\n // A block to read whole: a style rule, a font face, or an at-rule to skip.\n let depth = 1\n let end = at + 1\n while (end < text.length && depth > 0) {\n if (text[end] === '{') depth += 1\n else if (text[end] === '}') depth -= 1\n end += 1\n }\n const body = text.slice(at + 1, Math.max(at + 1, end - 1))\n if (/^@font-face\\b/i.test(prelude)) {\n const family = /font-family\\s*:\\s*([\"']?)([^;\"']+)\\1/i.exec(body)?.[2]?.trim()\n if (family && !css.fontFaces.includes(family)) css.fontFaces.push(family)\n } else if (!prelude.startsWith('@') && applies && prelude) {\n // A rule nested inside a rule (`&:hover`) is a state: only the outer declarations are read.\n addRule(prelude, body.replace(/[^;{}]*\\{[^{}]*\\}/g, ''))\n }\n start = at = end\n }\n }\n return css\n}\n\n/*------------------------------------------\n * Matching and the cascade\n *-----------------------------------------*/\n\nfunction classesOf(element: SiteImportElement): string[] {\n return (element.attrs.class ?? '').split(/\\s+/).filter(Boolean)\n}\n\nfunction attributeOf(element: SiteImportElement, name: string): string | undefined {\n switch (name) {\n case 'class':\n return element.attrs.class\n case 'id':\n return element.attrs.id\n case 'role':\n return element.attrs.role\n case 'aria-label':\n return element.attrs.label\n case 'href':\n return element.attrs.href\n case 'type':\n return element.attrs.type\n case 'style':\n return element.attrs.style\n case 'hidden':\n case 'aria-hidden':\n return element.attrs.hidden ? 'true' : undefined\n case 'data-section-theme':\n case 'data-theme':\n return element.attrs.theme\n default:\n return undefined\n }\n}\n\nfunction compoundMatches(compound: Compound, element: SiteImportElement, rootId: number): boolean {\n if (compound.root && element.id !== rootId) return false\n if (compound.tag && compound.tag !== element.tag) return false\n if (compound.id && compound.id !== element.attrs.id) return false\n if (compound.classes.length) {\n const own = classesOf(element)\n if (!compound.classes.every((name) => own.includes(name))) return false\n }\n for (const attr of compound.attrs) {\n const value = attributeOf(element, attr.name)\n if (value === undefined) return false\n if (!attr.op) continue\n const wanted = attr.value\n const ok =\n attr.op === '='\n ? value === wanted\n : attr.op === '~='\n ? value.split(/\\s+/).includes(wanted)\n : attr.op === '^='\n ? value.startsWith(wanted)\n : attr.op === '$='\n ? value.endsWith(wanted)\n : attr.op === '*='\n ? value.includes(wanted)\n : value === wanted || value.startsWith(`${wanted}-`)\n if (!ok) return false\n }\n return true\n}\n\n/** Whether a selector matches an element, its combinators walked from the right. */\nfunction selectorMatches(\n selector: ComplexSelector,\n element: SiteImportElement,\n elements: readonly SiteImportElement[],\n root: SiteImportElement | null,\n): boolean {\n const rootId = root?.id ?? -2\n /** The element above `at`: its parent, or the document's root above the body. */\n const above = (at: SiteImportElement) => (at.parent >= 0 ? elements[at.parent] : at === root ? undefined : (root ?? undefined))\n const walk = (index: number, at: SiteImportElement): boolean => {\n if (!compoundMatches(selector.compounds[index] as Compound, at, rootId)) return false\n if (index === 0) return true\n const combinator = selector.combinators[index - 1]\n if (combinator === '>') {\n const parent = above(at)\n return !!parent && walk(index - 1, parent)\n }\n if (combinator === '+' || combinator === '~') {\n const siblings = elements[at.parent]?.children ?? []\n const position = siblings.indexOf(at.id)\n for (let before = position - 1; before >= 0; before -= 1) {\n const sibling = elements[siblings[before] as number]\n if (!sibling) continue\n if (walk(index - 1, sibling)) return true\n if (combinator === '+') return false\n }\n return false\n }\n for (let parent = above(at); parent; parent = above(parent)) {\n if (walk(index - 1, parent)) return true\n }\n return false\n }\n return walk(selector.compounds.length - 1, element)\n}\n\n/** One element's resolved style: the kept properties, `var()` read, lowercased. */\nexport type SiteImportComputedStyle = ReadonlyMap<string, string>\n\n/** Reads elements' styles over a page's structure, each once. */\nexport interface SiteImportStyles {\n of(element: number): SiteImportComputedStyle\n /** The root's (`<html>`) element id, which `:root` matches; -1 for none. */\n readonly root: number\n}\n\nconst EMPTY_STYLE: SiteImportComputedStyle = new Map()\n\n/** Replaces each `var(--x, fallback)` with what the custom properties hold, to a few levels. */\nfunction withVariables(value: string, custom: ReadonlyMap<string, string>): string {\n let out = value\n for (let pass = 0; pass < 4 && out.includes('var('); pass += 1) {\n out = out.replace(/var\\(\\s*(--[\\w-]+)\\s*(?:,\\s*((?:[^()]|\\([^()]*\\))*))?\\)/g, (_, name: string, fallback?: string) => custom.get(name) ?? fallback?.trim() ?? '')\n }\n return out\n}\n\n/** The kept declarations an inline `style` attribute writes. */\nfunction inlineDeclarations(style: string | undefined): CssRule['decls'] {\n return style ? declarationsOf(style) : []\n}\n\n/**\n * Elements' styles over a page's structure and its sheets. Styles are\n * resolved on demand, parent first, each element once.\n */\nexport function siteImportStylesOf(structure: Pick<SiteImportStructure, 'elements' | 'root'>, css: SiteImportCss): SiteImportStyles {\n const { elements } = structure\n const resolved = new Map<number, { style: Map<string, string>; custom: Map<string, string> }>()\n // The page's root is above the body: `:root` and `html` rules are its.\n const rootStyle = (() => {\n const style = new Map<string, string>()\n const custom = new Map<string, string>()\n const fake: SiteImportElement = { id: -2, tag: 'html', parent: -1, children: [], region: 'main', nav: false, attrs: structure.root ?? {}, blocks: [] }\n const candidates = [...(css.index.get(':root') ?? []), ...(css.index.get('html') ?? []), ...(css.index.get('*') ?? [])]\n for (const name of classesOf(fake)) candidates.push(...(css.index.get(`.${name}`) ?? []))\n if (fake.attrs.id) candidates.push(...(css.index.get(`#${fake.attrs.id}`) ?? []))\n apply(candidates.filter((rule) => selectorMatches(rule.selector, fake, [], fake)), inlineDeclarations(fake.attrs.style), style, custom)\n return { style, custom, element: fake }\n })()\n\n function apply(rules: CssRule[], inline: CssRule['decls'], style: Map<string, string>, custom: Map<string, string>) {\n const unique = [...new Set(rules)].sort((a, b) => a.selector.specificity - b.selector.specificity || a.order - b.order)\n const important: Array<[string, string]> = []\n const put = (property: string, value: string) => {\n if (property.startsWith('--')) custom.set(property, value)\n else style.set(property, value)\n }\n for (const rule of unique) {\n for (const [property, value, flag] of rule.decls) {\n if (flag) important.push([property, value])\n else put(property, value)\n }\n }\n for (const [property, value, flag] of inline) {\n if (flag) important.push([property, value])\n else put(property, value)\n }\n for (const [property, value] of important) put(property, value)\n }\n\n function resolve(id: number): { style: Map<string, string>; custom: Map<string, string> } {\n const held = resolved.get(id)\n if (held) return held\n const element = elements[id]\n if (!element) return rootStyle\n const parent = element.parent >= 0 ? resolve(element.parent) : rootStyle\n const candidates: CssRule[] = [...(css.index.get(element.tag) ?? []), ...(css.index.get('*') ?? [])]\n for (const name of classesOf(element)) candidates.push(...(css.index.get(`.${name}`) ?? []))\n if (element.attrs.id) candidates.push(...(css.index.get(`#${element.attrs.id}`) ?? []))\n const matched = candidates.filter((rule) => selectorMatches(rule.selector, element, elements, rootStyle.element))\n const own = new Map<string, string>()\n const custom = new Map(parent.custom)\n apply(matched, inlineDeclarations(element.attrs.style), own, custom)\n const style = new Map<string, string>()\n for (const property of INHERITED) {\n const value = parent.style.get(property)\n if (value !== undefined) style.set(property, value)\n }\n for (const [property, value] of own) {\n const lowered = value.trim().toLowerCase()\n if (lowered === 'inherit') {\n const inherited = parent.style.get(property)\n if (inherited !== undefined) style.set(property, inherited)\n continue\n }\n if (lowered === 'initial' || lowered === 'unset' || lowered === 'revert') {\n if (!INHERITED.has(property) || lowered === 'initial') style.delete(property)\n continue\n }\n style.set(property, property === 'font-family' ? withVariables(value, custom) : withVariables(value, custom).toLowerCase())\n }\n const entry = { style, custom }\n resolved.set(id, entry)\n return entry\n }\n\n // The root's own inherited values reach the body through `rootStyle`.\n for (const [property, value] of rootStyle.style) {\n rootStyle.style.set(property, property === 'font-family' ? withVariables(value, rootStyle.custom) : withVariables(value, rootStyle.custom).toLowerCase())\n }\n return {\n root: -2,\n of(element: number): SiteImportComputedStyle {\n if (element === -2) return rootStyle.style\n return elements[element] ? resolve(element).style : EMPTY_STYLE\n },\n }\n}\n\n/*------------------------------------------\n * Values\n *-----------------------------------------*/\n\nexport interface SiteImportRgba {\n r: number\n g: number\n b: number\n a: number\n}\n\nconst NAMED_COLORS: Record<string, string> = {\n white: '#ffffff',\n black: '#000000',\n red: '#ff0000',\n green: '#008000',\n blue: '#0000ff',\n gray: '#808080',\n grey: '#808080',\n silver: '#c0c0c0',\n whitesmoke: '#f5f5f5',\n ghostwhite: '#f8f8ff',\n snow: '#fffafa',\n ivory: '#fffff0',\n beige: '#f5f5dc',\n linen: '#faf0e6',\n navy: '#000080',\n teal: '#008080',\n orange: '#ffa500',\n gold: '#ffd700',\n purple: '#800080',\n crimson: '#dc143c',\n tomato: '#ff6347',\n coral: '#ff7f50',\n aliceblue: '#f0f8ff',\n lightgray: '#d3d3d3',\n lightgrey: '#d3d3d3',\n gainsboro: '#dcdcdc',\n darkslategray: '#2f4f4f',\n dimgray: '#696969',\n}\n\n/** The first color a value names, or `null`; `transparent` is a color of no strength. */\nexport function siteImportColorOf(value: string | undefined): SiteImportRgba | null {\n if (!value) return null\n const text = value.toLowerCase()\n const hex = /#([0-9a-f]{8}|[0-9a-f]{6}|[0-9a-f]{4}|[0-9a-f]{3})\\b/.exec(text)\n const rgb = /rgba?\\(\\s*(-?[\\d.]+%?)\\s*[,\\s]\\s*(-?[\\d.]+%?)\\s*[,\\s]\\s*(-?[\\d.]+%?)\\s*(?:[,/]\\s*(-?[\\d.]+%?)\\s*)?\\)/.exec(text)\n const hsl = /hsla?\\(\\s*(-?[\\d.]+)(?:deg)?\\s*[,\\s]\\s*([\\d.]+)%\\s*[,\\s]\\s*([\\d.]+)%\\s*(?:[,/]\\s*([\\d.]+%?)\\s*)?\\)/.exec(text)\n const named = /\\b(transparent|[a-z]+)\\b/.exec(text.replace(/[a-z-]+\\(/g, ' ('))\n const first = [hex, rgb, hsl].filter((match): match is RegExpExecArray => !!match).sort((a, b) => a.index - b.index)[0]\n const alphaOf = (raw: string | undefined) => (raw === undefined ? 1 : raw.endsWith('%') ? Number(raw.slice(0, -1)) / 100 : Number(raw))\n if (first === hex && hex) {\n const digits = hex[1]\n const full = digits.length <= 4 ? digits.split('').map((d) => d + d).join('') : digits\n return {\n r: parseInt(full.slice(0, 2), 16),\n g: parseInt(full.slice(2, 4), 16),\n b: parseInt(full.slice(4, 6), 16),\n a: full.length === 8 ? parseInt(full.slice(6, 8), 16) / 255 : 1,\n }\n }\n if (first === rgb && rgb) {\n const channel = (raw: string) => Math.max(0, Math.min(255, raw.endsWith('%') ? (Number(raw.slice(0, -1)) / 100) * 255 : Number(raw)))\n return { r: channel(rgb[1]), g: channel(rgb[2]), b: channel(rgb[3]), a: alphaOf(rgb[4]) }\n }\n if (first === hsl && hsl) {\n const h = (((Number(hsl[1]) % 360) + 360) % 360) / 360\n const s = Number(hsl[2]) / 100\n const l = Number(hsl[3]) / 100\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s\n const p = 2 * l - q\n const tone = (t: number) => {\n const x = t < 0 ? t + 1 : t > 1 ? t - 1 : t\n if (x < 1 / 6) return p + (q - p) * 6 * x\n if (x < 1 / 2) return q\n if (x < 2 / 3) return p + (q - p) * (2 / 3 - x) * 6\n return p\n }\n return { r: tone(h + 1 / 3) * 255, g: tone(h) * 255, b: tone(h - 1 / 3) * 255, a: alphaOf(hsl[4]) }\n }\n if (named) {\n if (named[1] === 'transparent') return { r: 0, g: 0, b: 0, a: 0 }\n const known = NAMED_COLORS[named[1]]\n if (known) return siteImportColorOf(known)\n }\n return null\n}\n\n/** `#rrggbb` of a color, its strength ignored. */\nexport function siteImportHex(color: SiteImportRgba): string {\n return `#${[color.r, color.g, color.b].map((channel) => Math.round(channel).toString(16).padStart(2, '0')).join('')}`\n}\n\n/** Relative luminance, 0 (black) to 1 (white). */\nexport function siteImportLuminance(color: SiteImportRgba): number {\n const linear = (channel: number) => {\n const c = channel / 255\n return c <= 0.03928 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4\n }\n return 0.2126 * linear(color.r) + 0.7152 * linear(color.g) + 0.0722 * linear(color.b)\n}\n\n/** How colorful a color is, 0 (grey) to 1. */\nexport function siteImportSaturation(color: SiteImportRgba): number {\n const max = Math.max(color.r, color.g, color.b) / 255\n const min = Math.min(color.r, color.g, color.b) / 255\n if (max === min) return 0\n const l = (max + min) / 2\n return (max - min) / (1 - Math.abs(2 * l - 1))\n}\n\n/** What an element draws behind itself: a color, a gradient and its colors, or a picture. */\nexport interface SiteImportBackground {\n color: SiteImportRgba | null\n gradient: SiteImportRgba[] | null\n /** A picture's address, as written. */\n image: string | null\n}\n\n/** An element's own background, from the shorthand or its parts. */\nexport function siteImportBackgroundOf(style: SiteImportComputedStyle): SiteImportBackground {\n const shorthand = style.get('background') ?? ''\n const imageValue = style.get('background-image') ?? (/(?:url|gradient)\\(/.test(shorthand) ? shorthand : '')\n const colorValue = style.get('background-color') ?? (shorthand && !/(?:url|gradient)\\(/.test(shorthand) ? shorthand : shorthand.replace(/[a-z-]*gradient\\((?:[^()]|\\([^()]*\\))*\\)|url\\([^)]*\\)/g, ' '))\n const color = siteImportColorOf(colorValue)\n let gradient: SiteImportRgba[] | null = null\n let image: string | null = null\n const gradientMatch = /gradient\\(((?:[^()]|\\([^()]*\\))*)\\)/.exec(imageValue)\n if (gradientMatch) {\n const stops: SiteImportRgba[] = []\n for (const match of gradientMatch[1].matchAll(/#[0-9a-f]{3,8}\\b|rgba?\\([^)]*\\)|hsla?\\([^)]*\\)|\\b(?:white|black|transparent)\\b/gi)) {\n const stop = siteImportColorOf(match[0])\n if (stop) stops.push(stop)\n }\n if (stops.length) gradient = stops\n }\n const url = /url\\(\\s*([\"']?)([^\"')]+)\\1\\s*\\)/.exec(imageValue)\n if (url) image = url[2].trim()\n return { color: color && color.a > 0.02 ? color : null, gradient, image }\n}\n\n/** Whether an element draws a border on any side. */\nexport function siteImportHasBorder(style: SiteImportComputedStyle): boolean {\n const sides = ['border', 'border-top', 'border-bottom', 'border-left', 'border-right']\n for (const side of sides) {\n const value = style.get(side)\n if (!value) continue\n if (/\\bnone\\b|\\bhidden\\b/.test(value) || /^0(?:px)?$/.test(value.trim())) continue\n const color = siteImportColorOf(value) ?? siteImportColorOf(style.get('border-color'))\n if (color && color.a < 0.05) continue\n if (/\\d/.test(value) || /\\b(?:solid|dashed|dotted|double)\\b/.test(value)) {\n const width = /(-?[\\d.]+)px/.exec(value)\n if (!width || Number(width[1]) > 0) return true\n }\n }\n const width = style.get('border-width')\n const kind = style.get('border-style')\n if (kind && /\\b(?:solid|dashed|dotted|double)\\b/.test(kind) && (!width || !/^0(?:px)?$/.test(width.trim()))) return true\n return false\n}\n\n/** A side of an element's box. */\nexport type SiteImportSide = 'top' | 'right' | 'bottom' | 'left'\n\nconst SIDES: readonly SiteImportSide[] = ['top', 'right', 'bottom', 'left']\n\n/** One side's border, where it draws one: its width in px and its color as written. */\nexport interface SiteImportBorderSide {\n width: number\n color: SiteImportRgba | null\n}\n\n/**\n * The sides an element draws a border on (AGL-4138), each with its width and\n * color: a box is bordered on every side, a rule on one. The shorthand draws\n * all four; a side's own declaration, or `border-width` and `border-style`\n * by side, draw only theirs.\n */\nexport function siteImportBorderSides(style: SiteImportComputedStyle): Partial<Record<SiteImportSide, SiteImportBorderSide>> {\n const out: Partial<Record<SiteImportSide, SiteImportBorderSide>> = {}\n const shared = siteImportColorOf(style.get('border-color'))\n const drawn = (value: string | undefined): SiteImportBorderSide | null => {\n if (!value || /\\bnone\\b|\\bhidden\\b/.test(value) || /^0(?:px)?$/.test(value.trim())) return null\n const color = siteImportColorOf(value) ?? shared\n if (color && color.a < 0.05) return null\n if (!/\\d/.test(value) && !/\\b(?:solid|dashed|dotted|double)\\b/.test(value)) return null\n const width = /(-?[\\d.]+)(?:px)?(?:\\s|$)/.exec(value.replace(/#[0-9a-f]+|rgba?\\([^)]*\\)|hsla?\\([^)]*\\)/gi, ' '))\n const px = width ? Number(width[1]) : /\\bthick\\b/.test(value) ? 5 : /\\bthin\\b/.test(value) ? 1 : 3\n return px > 0 ? { width: px, color } : null\n }\n const all = drawn(style.get('border'))\n for (const side of SIDES) {\n const own = style.get(`border-${side}`)\n const found = own !== undefined ? drawn(own) : all\n if (found) out[side] = found\n }\n // `border-width` and `border-style` by side, where no shorthand drew a side.\n const kind = style.get('border-style')\n if (!Object.keys(out).length && kind && /\\b(?:solid|dashed|dotted|double)\\b/.test(kind)) {\n const widths = (style.get('border-width') ?? '3px').trim().split(/\\s+/)\n const by = [widths[0], widths[1] ?? widths[0], widths[2] ?? widths[0], widths[3] ?? widths[1] ?? widths[0]]\n SIDES.forEach((side, at) => {\n const px = siteImportLengthPx(by[at] ?? '')\n if (px !== null && px > 0) out[side] = { width: px, color: shared }\n })\n }\n return out\n}\n\n/** A picture box's `aspect-ratio`, width over height: `16 / 9`, `1.5`, `auto 4 / 3`; `null` where it sets none. */\nexport function siteImportAspectRatio(value: string | undefined): number | null {\n const match = /(\\d*\\.?\\d+)\\s*(?:\\/\\s*(\\d*\\.?\\d+))?/.exec((value ?? '').replace(/\\bauto\\b/g, ' '))\n if (!match) return null\n const width = Number(match[1])\n const height = match[2] === undefined ? 1 : Number(match[2])\n return width > 0 && height > 0 ? width / height : null\n}\n\n/** A color as it shows over the ground it sits on, its strength blended in: `rgba(0,0,0,.6)` over white is `#666666`. */\nexport function siteImportOpaque(color: SiteImportRgba, under: SiteImportRgba | null = null): SiteImportRgba {\n const ground = under ?? { r: 255, g: 255, b: 255, a: 1 }\n const a = Math.max(0, Math.min(1, color.a))\n return { r: color.r * a + ground.r * (1 - a), g: color.g * a + ground.g * (1 - a), b: color.b * a + ground.b * (1 - a), a: 1 }\n}\n\n/** How far apart two colors look, in OKLab (0 the same, about 1 black from white). */\nexport function siteImportColorDistance(a: SiteImportRgba, b: SiteImportRgba): number {\n const lab = (color: SiteImportRgba) => {\n const linear = (channel: number) => {\n const c = channel / 255\n return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4\n }\n const [r, g, bl] = [linear(color.r), linear(color.g), linear(color.b)]\n const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * bl)\n const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * bl)\n const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * bl)\n return [0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s, 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s, 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s]\n }\n const [x, y] = [lab(a), lab(b)]\n return Math.hypot((x[0] as number) - (y[0] as number), (x[1] as number) - (y[1] as number), (x[2] as number) - (y[2] as number))\n}\n\n/** Whether an element draws a shadow. */\nexport function siteImportHasShadow(style: SiteImportComputedStyle): boolean {\n const value = style.get('box-shadow')\n return !!value && !/^(?:none|0|initial|unset)$/.test(value.trim()) && !/^0(?:px)?\\s+0(?:px)?\\s+0(?:px)?(?:\\s+0(?:px)?)?\\s+(?:transparent|rgba\\([^)]*,\\s*0\\))/.test(value.trim())\n}\n\n/** An element's corner radius in px, or `null`. */\nexport function siteImportRadiusPx(style: SiteImportComputedStyle): number | null {\n const value = style.get('border-radius')\n if (!value) return null\n const first = value.trim().split(/[\\s/]+/)[0] ?? ''\n if (first.endsWith('%')) return Number(first.slice(0, -1)) >= 50 ? 999 : Number(first.slice(0, -1))\n return siteImportLengthPx(first)\n}\n\n/** A font size in px, or `null`. */\nexport function siteImportFontSizePx(style: SiteImportComputedStyle): number | null {\n const value = style.get('font-size')\n if (!value) return null\n const clamp = /clamp\\(([^,]+),([^,]+),([^)]+)\\)/.exec(value)\n // A fluid size at the read width: its maximum, as a wide screen shows it.\n const text = clamp ? clamp[3] : value\n return siteImportLengthPx(text.trim())\n}\n\n/** The relative widths a grid template draws its columns at, or `null` for none. */\nexport function siteImportGridColumns(template: string | undefined): number[] | null {\n if (!template || /^(?:none|subgrid|masonry)$/.test(template.trim())) return null\n let text = template.trim()\n // repeat(3, 1fr) / repeat(auto-fill, minmax(240px, 1fr)): the count, or three of them.\n text = text.replace(/repeat\\(\\s*([\\w-]+)\\s*,\\s*((?:[^()]|\\([^()]*\\))*)\\)/g, (_, count: string, track: string) => {\n const times = /^\\d+$/.test(count) ? Math.min(12, Number(count)) : 3\n return Array.from({ length: times }, () => track.trim()).join(' ')\n })\n const tracks: string[] = []\n let depth = 0\n let token = ''\n for (const char of text) {\n if (char === '(') depth += 1\n if (char === ')') depth -= 1\n if (/\\s/.test(char) && depth === 0) {\n if (token) tracks.push(token)\n token = ''\n } else token += char\n }\n if (token) tracks.push(token)\n const weights = tracks\n .filter((track) => !/^\\[.*\\]$/.test(track))\n .map((track) => {\n const fr = /(-?[\\d.]+)fr\\)?$/.exec(track)\n if (fr) return Number(fr[1]) || 1\n const px = /(-?[\\d.]+)px/.exec(track)\n if (px) return Number(px[1]) / 100\n const percent = /(-?[\\d.]+)%/.exec(track)\n if (percent) return Number(percent[1]) / 10\n return 1\n })\n return weights.length ? weights : null\n}\n\n/** Weights scaled to twelfths, each at least 1: `[420, 788]` is `[4, 8]`. */\nexport function siteImportTwelfths(weights: readonly number[]): number[] {\n const total = weights.reduce((sum, weight) => sum + Math.max(0, weight), 0)\n if (!total) return weights.map(() => 1)\n const scaled = weights.map((weight) => Math.max(1, Math.round((Math.max(0, weight) / total) * 12)))\n // Two equal tracks stay equal, three stay thirds.\n const unique = new Set(weights.map((weight) => Math.round(weight * 1000)))\n if (unique.size === 1) return weights.map(() => 1)\n return scaled\n}\n\n/** The families a `font-family` value names, quotes dropped, generic ones left out. */\nexport function siteImportFontFamilies(value: string | undefined): string[] {\n if (!value) return []\n return splitList(value)\n .map((family) => family.replace(/^[\"']|[\"']$/g, '').trim())\n .filter((family) => family && !/^(?:serif|sans-serif|monospace|cursive|fantasy|system-ui|ui-[\\w-]+|-apple-system|blinkmacsystemfont|inherit|initial|emoji|math|var\\(.*)$/i.test(family))\n}\n"],"names":["SITE_IMPORT_CSS_VIEWPORT","width","height","SITE_IMPORT_CSS_WIDE_WIDTH","KEPT_PROPERTIES","Set","INHERITED","unescapeIdent","text","replace","_","escaped","test","code","parseInt","trim","String","fromCodePoint","IDENT","raw","SIMPLE","RegExp","AT_REST","parseCompound","compound","tag","id","classes","attrs","root","rest","match","exec","slice","length","toLowerCase","push","name","op","value","has","parseSelector","compounds","combinators","parts","split","pending","part","ids","tags","specificity","splitList","out","depth","start","at","char","Math","max","map","filter","Boolean","siteImportLengthPx","amount","Number","mediaQueryHolds","query","viewport","negate","startsWith","holds","term","inner","feature","px","range","size","a","b","mediaHolds","prelude","list","some","declarationsOf","body","decls","colon","indexOf","written","property","important","keyOf","selector","last","siteImportCssOf","sheets","css","rules","index","Map","fontFaces","order","addRule","rule","key","get","set","sheet","groups","end","pop","applies","every","family","includes","classesOf","element","class","attributeOf","role","label","href","type","style","hidden","undefined","theme","compoundMatches","rootId","own","attr","wanted","ok","endsWith","selectorMatches","elements","above","parent","walk","combinator","siblings","children","position","before","sibling","EMPTY_STYLE","withVariables","custom","pass","fallback","inlineDeclarations","siteImportStylesOf","structure","resolved","rootStyle","fake","region","nav","blocks","candidates","apply","inline","unique","sort","put","flag","resolve","held","matched","lowered","inherited","delete","entry","of","NAMED_COLORS","white","black","red","green","blue","gray","grey","silver","whitesmoke","ghostwhite","snow","ivory","beige","linen","navy","teal","orange","gold","purple","crimson","tomato","coral","aliceblue","lightgray","lightgrey","gainsboro","darkslategray","dimgray","siteImportColorOf","hex","rgb","hsl","named","first","alphaOf","digits","full","d","join","r","g","channel","min","h","s","l","q","p","tone","t","x","known","siteImportHex","color","round","toString","padStart","siteImportLuminance","linear","c","siteImportSaturation","abs","siteImportBackgroundOf","shorthand","imageValue","colorValue","gradient","image","gradientMatch","stops","matchAll","stop","url","siteImportHasBorder","sides","side","kind","SIDES","siteImportBorderSides","shared","drawn","all","found","Object","keys","widths","by","forEach","siteImportAspectRatio","siteImportOpaque","under","ground","siteImportColorDistance","lab","bl","cbrt","m","y","hypot","siteImportHasShadow","siteImportRadiusPx","siteImportFontSizePx","clamp","siteImportGridColumns","template","count","track","times","Array","from","tracks","token","weights","fr","percent","siteImportTwelfths","total","reduce","sum","weight","scaled","siteImportFontFamilies"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;;;;;2CAuB2C,GAI3C,2EAA2E,GAC3E,OAAO,MAAMA,2BAA2B;IAAEC,OAAO;IAAMC,QAAQ;AAAI,EAAU;AAE7E;;;;;CAKC,GACD,OAAO,MAAMC,6BAA6B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C,OAAO;IACT;IACF,OAAOF,QAAQ7P,MAAM,GAAG6P,UAAU;AACpC;AAEA,2EAA2E,GAC3E,OAAO,SAASG,mBAAmBH,OAA0B;IAC3D,MAAMI,QAAQJ,QAAQK,MAAM,CAAC,CAACC,KAAKC,SAAWD,MAAM5O,KAAKC,GAAG,CAAC,GAAG4O,SAAS;IACzE,IAAI,CAACH,OAAO,OAAOJ,QAAQpO,GAAG,CAAC,IAAM;IACrC,MAAM4O,SAASR,QAAQpO,GAAG,CAAC,CAAC2O,SAAW7O,KAAKC,GAAG,CAAC,GAAGD,KAAK4K,KAAK,CAAC,AAAC5K,KAAKC,GAAG,CAAC,GAAG4O,UAAUH,QAAS;IAC9F,kDAAkD;IAClD,MAAMjI,SAAS,IAAI7J,IAAI0R,QAAQpO,GAAG,CAAC,CAAC2O,SAAW7O,KAAK4K,KAAK,CAACiE,SAAS;IACnE,IAAIpI,OAAOtF,IAAI,KAAK,GAAG,OAAOmN,QAAQpO,GAAG,CAAC,IAAM;IAChD,OAAO4O;AACT;AAEA,qFAAqF,GACrF,OAAO,SAASC,uBAAuBjQ,KAAyB;IAC9D,IAAI,CAACA,OAAO,OAAO,EAAE;IACrB,OAAOY,UAAUZ,OACdoB,GAAG,CAAC,CAACsD,SAAWA,OAAOxG,OAAO,CAAC,gBAAgB,IAAIM,IAAI,IACvD6C,MAAM,CAAC,CAACqD,SAAWA,UAAU,CAAC,4IAA4IrG,IAAI,CAACqG;AACpL"}
|
|
@@ -116,6 +116,31 @@ export interface SiteImportForm {
|
|
|
116
116
|
/** The fields no form element can take, by the words they ask with: a file to attach. */
|
|
117
117
|
leftOut?: string[];
|
|
118
118
|
}
|
|
119
|
+
/**
|
|
120
|
+
* A video a page shows (AGL-4140), as the page wrote it: a film it serves
|
|
121
|
+
* itself (`src`), or one a video host plays (`embed`), the still shown before
|
|
122
|
+
* it plays, and what a search engine reads of it. Untrusted data.
|
|
123
|
+
*/
|
|
124
|
+
export interface SiteImportVideo {
|
|
125
|
+
/** A file the page plays itself: an absolute http(s) address. */
|
|
126
|
+
src?: string;
|
|
127
|
+
/** A video host's page or player: an absolute https address. */
|
|
128
|
+
embed?: string;
|
|
129
|
+
/** The still shown before it plays, an absolute address; inside its marker as a picture. */
|
|
130
|
+
poster?: string;
|
|
131
|
+
/** Its name: the structured data's, else its own title or label, else its poster's description. */
|
|
132
|
+
title: string;
|
|
133
|
+
description?: string;
|
|
134
|
+
/** The day it was first published, `YYYY-MM-DD`. */
|
|
135
|
+
uploadDate?: string;
|
|
136
|
+
durationSeconds?: number;
|
|
137
|
+
autoplay?: true;
|
|
138
|
+
muted?: true;
|
|
139
|
+
loop?: true;
|
|
140
|
+
controls?: true;
|
|
141
|
+
width?: number;
|
|
142
|
+
height?: number;
|
|
143
|
+
}
|
|
119
144
|
export interface SiteImportExtract {
|
|
120
145
|
title: string;
|
|
121
146
|
description: string;
|
|
@@ -137,6 +162,8 @@ export interface SiteImportExtract {
|
|
|
137
162
|
kept: SiteImportForm[];
|
|
138
163
|
removed: number;
|
|
139
164
|
};
|
|
165
|
+
/** Its videos (AGL-4140), each once, in the order they were found; absent on a page with none. */
|
|
166
|
+
videos?: SiteImportVideo[];
|
|
140
167
|
/** True when the page has a password field; nothing else is extracted. */
|
|
141
168
|
loginForm: boolean;
|
|
142
169
|
/**
|
|
@@ -165,6 +192,9 @@ export interface SiteImportElementAttrs {
|
|
|
165
192
|
/** `aria-controls` / `aria-labelledby`: what a tab shows, and what names a panel. */
|
|
166
193
|
controls?: string;
|
|
167
194
|
labelledby?: string;
|
|
195
|
+
/** A picture's or a film's own size, as its `width` and `height` attributes give it in px (AGL-4138). */
|
|
196
|
+
width?: number;
|
|
197
|
+
height?: number;
|
|
168
198
|
}
|
|
169
199
|
/** One element of the page, in a flat table: its parent and children by index. */
|
|
170
200
|
export interface SiteImportElement {
|
|
@@ -183,6 +213,13 @@ export interface SiteImportElement {
|
|
|
183
213
|
icon?: number;
|
|
184
214
|
/** The form that sat here, by index into the page's kept forms. */
|
|
185
215
|
form?: number;
|
|
216
|
+
/** The picture an `<img>` shows (AGL-4139): its address and alt, where a menu's featured card or a footer's logo is one. */
|
|
217
|
+
picture?: {
|
|
218
|
+
url: string;
|
|
219
|
+
alt: string;
|
|
220
|
+
};
|
|
221
|
+
/** The video that sat here (AGL-4140), by index into the page's videos; its poster is the picture inside it. */
|
|
222
|
+
video?: number;
|
|
186
223
|
/**
|
|
187
224
|
* Its place in the page's order of content: a block's index, or the index
|
|
188
225
|
* of the block that follows an icon, less a half. Set on elements that
|
|
@@ -268,6 +305,8 @@ export declare const SITE_IMPORT_PAGE_LIMITS: {
|
|
|
268
305
|
readonly anchors: 800;
|
|
269
306
|
readonly styleChars: 1500000;
|
|
270
307
|
readonly stylesheets: 4;
|
|
308
|
+
/** A page's videos (AGL-4140). */
|
|
309
|
+
readonly videos: 10;
|
|
271
310
|
};
|
|
272
311
|
/** Character references to characters; an unknown name stays as written. */
|
|
273
312
|
export declare function decodeHtmlEntities(text: string): string;
|