@pairdraw/web-capture 0.20.0 → 0.21.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.
|
@@ -534,7 +534,9 @@ const CAPTURED_STYLE_PROPERTIES = [
|
|
|
534
534
|
"align-self",
|
|
535
535
|
"aspect-ratio",
|
|
536
536
|
"background-color",
|
|
537
|
+
"background-clip",
|
|
537
538
|
"background-image",
|
|
539
|
+
"background-origin",
|
|
538
540
|
"background-position",
|
|
539
541
|
"background-repeat",
|
|
540
542
|
"background-size",
|
|
@@ -568,6 +570,7 @@ const CAPTURED_STYLE_PROPERTIES = [
|
|
|
568
570
|
"font-weight",
|
|
569
571
|
"gap",
|
|
570
572
|
"height",
|
|
573
|
+
"isolation",
|
|
571
574
|
"justify-content",
|
|
572
575
|
"left",
|
|
573
576
|
"letter-spacing",
|
|
@@ -602,7 +605,8 @@ const CAPTURED_STYLE_PROPERTIES = [
|
|
|
602
605
|
"text-underline-offset",
|
|
603
606
|
"top",
|
|
604
607
|
"white-space",
|
|
605
|
-
"width"
|
|
608
|
+
"width",
|
|
609
|
+
"z-index"
|
|
606
610
|
];
|
|
607
611
|
const CAPTURED = new Set(CAPTURED_STYLE_PROPERTIES);
|
|
608
612
|
/** Whether a capture keeps this property; others are dropped when a capture is read. */
|
|
@@ -624,8 +628,10 @@ const IMPLIED_VALUES = {
|
|
|
624
628
|
"align-items": ["normal"],
|
|
625
629
|
"align-self": ["auto"],
|
|
626
630
|
"aspect-ratio": ["auto"],
|
|
631
|
+
"background-clip": ["border-box"],
|
|
627
632
|
"background-color": ["rgba(0, 0, 0, 0)", "transparent"],
|
|
628
633
|
"background-image": ["none"],
|
|
634
|
+
"background-origin": ["padding-box"],
|
|
629
635
|
"background-position": ["0% 0%"],
|
|
630
636
|
"background-repeat": ["repeat"],
|
|
631
637
|
"background-size": ["auto"],
|
|
@@ -634,6 +640,8 @@ const IMPLIED_VALUES = {
|
|
|
634
640
|
"flex-direction": ["row"],
|
|
635
641
|
"flex-wrap": ["nowrap"],
|
|
636
642
|
gap: ["normal"],
|
|
643
|
+
isolation: ["auto"],
|
|
644
|
+
"z-index": ["auto"],
|
|
637
645
|
height: ["auto"],
|
|
638
646
|
"justify-content": ["normal"],
|
|
639
647
|
"max-height": ["none"],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clipboard.js","names":["SIDES"],"sources":["../../../src/record.ts","../../../src/design-document.ts","../../../src/html.ts","../../../src/limits.ts","../../../src/schema.ts","../../../src/styles.ts","../../../src/urls.ts","../../../src/parse.ts","../../../src/clipboard.ts","../../../src/capturer/clipboard.ts"],"sourcesContent":["/**\n * The value a style or attribute record sets for `key`, or undefined when it sets none. Records\n * are typed as setting every key, which they do not.\n */\nexport function ownValue(\n record: Readonly<Record<string, string>>,\n key: string\n): string | undefined {\n return Object.hasOwn(record, key) ? record[key] : undefined\n}\n","import { omit } from 'es-toolkit'\n\nimport type { WebCapture } from './format'\nimport { ownValue } from './record'\nimport type { WebCaptureBox, WebCaptureElement, WebCaptureNode, WebCaptureText } from './types'\n\n/**\n * An element of the styled DOM `@pairdraw/dom-css` builds layers from. The shape matches its\n * `DesignElement`, so a capture imports through `sceneGraphFromStyledHTML` without a CSS runtime.\n */\nexport interface WebCaptureDesignElement {\n type: 'element'\n tagName: string\n attrs: Record<string, string>\n computedStyle: Record<string, string>\n children: WebCaptureDesignNode[]\n}\n\nexport type WebCaptureDesignNode = WebCaptureDesignElement | WebCaptureText\n\n/** The styled DOM of a capture, matching `@pairdraw/dom-css`'s `DesignDocument`. */\nexport interface WebCaptureDesignDocument {\n type: 'document'\n children: WebCaptureDesignNode[]\n}\n\nconst SIDES = ['top', 'right', 'bottom', 'left'] as const\ntype Side = (typeof SIDES)[number]\n\n/**\n * Displays the importer has no layout for, mapped to the closest one it has. A grid of\n * fixed-size cells wraps as a row of them does, and a table row is a row of its cells.\n */\nconst DISPLAY_FALLBACKS: Record<string, Record<string, string>> = {\n grid: { display: 'flex', 'flex-direction': 'row', 'flex-wrap': 'wrap' },\n 'inline-grid': { display: 'inline-flex', 'flex-direction': 'row', 'flex-wrap': 'wrap' },\n 'table-row': { display: 'flex', 'flex-direction': 'row', 'flex-wrap': 'nowrap' },\n table: { display: 'block' },\n 'inline-table': { display: 'inline-block' },\n 'table-row-group': { display: 'block' },\n 'table-header-group': { display: 'block' },\n 'table-footer-group': { display: 'block' },\n 'table-cell': { display: 'block' },\n 'table-caption': { display: 'block' },\n 'list-item': { display: 'block' },\n 'flow-root': { display: 'block' }\n}\n\n/**\n * Inline text tags the importer lays out inline when they say nothing of their display. Left\n * without one, a run such as a link or a bold word stays text instead of a box around text.\n */\nconst INLINE_TEXT_TAGS = new Set(['a', 'b', 'code', 'em', 'i', 'small', 'span', 'strong', 'u'])\n\nfunction pixels(value: string | undefined): number {\n if (!value?.endsWith('px')) return 0\n const parsed = Number.parseFloat(value)\n return Number.isFinite(parsed) ? parsed : 0\n}\n\nfunction px(value: number): string {\n return `${Math.round(value * 100) / 100}px`\n}\n\nconst MARGINS = SIDES.map((side) => `margin-${side}` as const)\n\n/** The element's margins in pixels, and its style without them. */\nfunction splitMargins(style: Record<string, string>) {\n const margins = { top: 0, right: 0, bottom: 0, left: 0 }\n for (const side of SIDES) margins[side] = pixels(style[`margin-${side}`])\n return { margins, style: omit(style, MARGINS) }\n}\n\nfunction isAbsolute(style: Record<string, string>): boolean {\n return style.position === 'absolute' || style.position === 'fixed'\n}\n\nfunction isInline(style: Record<string, string>): boolean {\n return (ownValue(style, 'display') ?? '').startsWith('inline')\n}\n\n/**\n * Places an absolute box in its parent layer. CSS measures `left` and `top` from the containing\n * block, which may be a further ancestor or the viewport, so the recorded boxes place it where\n * the page drew it. Without them, it sits at its offset plus its margin, as CSS places it.\n */\nfunction placeAbsolute(\n style: Record<string, string>,\n margins: Record<Side, number>,\n box: WebCaptureBox | undefined,\n parentBox: WebCaptureBox | undefined\n): void {\n if (box && parentBox) {\n style.left = px(box.x - parentBox.x)\n style.top = px(box.y - parentBox.y)\n return\n }\n if (ownValue(style, 'left') !== undefined) style.left = px(pixels(style.left) + margins.left)\n if (ownValue(style, 'top') !== undefined) style.top = px(pixels(style.top) + margins.top)\n}\n\n/**\n * A box in normal flow keeps the room its margins took inside a transparent box padded by them.\n * Negative margins, which pull neighbours over each other, are dropped.\n */\nfunction marginBox(\n element: WebCaptureDesignElement,\n margins: Record<Side, number>\n): WebCaptureDesignElement {\n const style: Record<string, string> = { display: 'block' }\n for (const side of SIDES) {\n if (margins[side] > 0) style[`padding-${side}`] = px(margins[side])\n }\n const alignSelf = ownValue(element.computedStyle, 'align-self')\n if (alignSelf === undefined) {\n return { type: 'element', tagName: 'div', attrs: {}, computedStyle: style, children: [element] }\n }\n // The box is the flex item now, so it aligns itself as the element did.\n style['align-self'] = alignSelf\n const child = { ...element, computedStyle: omit(element.computedStyle, ['align-self']) }\n return { type: 'element', tagName: 'div', attrs: {}, computedStyle: style, children: [child] }\n}\n\nfunction convertChildren(\n children: readonly WebCaptureNode[],\n parentBox: WebCaptureBox | undefined\n): WebCaptureDesignNode[] {\n return children.map((child): WebCaptureDesignNode =>\n child.type === 'text' ? child : convertElement(child, parentBox)\n )\n}\n\nconst GRID_DISPLAYS = new Set(['grid', 'inline-grid'])\n\ntype BoxedElement = WebCaptureElement & { box: WebCaptureBox }\n\nfunction hasBox(element: WebCaptureElement): element is BoxedElement {\n return element.box !== undefined\n}\n\n/**\n * A grid whose items can stay where the page drew them: the capture recorded the grid's box and\n * every item's, and the grid holds no loose text. Null otherwise, and for anything but a grid.\n */\nfunction placeableGrid(\n element: WebCaptureElement\n): { box: WebCaptureBox; items: BoxedElement[] } | null {\n if (!GRID_DISPLAYS.has(ownValue(element.computedStyle, 'display') ?? '') || !hasBox(element)) {\n return null\n }\n const items: BoxedElement[] = []\n for (const child of element.children) {\n if (child.type === 'text') {\n if (child.text.trim().length > 0) return null\n } else if (hasBox(child)) {\n items.push(child)\n } else {\n return null\n }\n }\n return { box: element.box, items }\n}\n\n/**\n * Auto layout has no grid tracks, so a grid keeps its drawn size and its items become absolute\n * boxes where the page drew them. Their margins already moved their boxes.\n */\nfunction gridStyle(style: Record<string, string>, box: WebCaptureBox): Record<string, string> {\n return {\n ...omit(style, ['gap', 'row-gap', 'column-gap']),\n display: style.display === 'inline-grid' ? 'inline-block' : 'block',\n width: px(box.width),\n height: px(box.height),\n 'box-sizing': 'border-box'\n }\n}\n\nconst PLACEMENT = [...MARGINS, 'position', ...SIDES]\n\nfunction placeGridItem(item: BoxedElement, grid: WebCaptureBox): WebCaptureDesignElement {\n // Without margins or a position of its own, the item converts to itself, not a margin box.\n const converted = convertElement({ ...item, computedStyle: omit(item.computedStyle, PLACEMENT) })\n converted.computedStyle = {\n ...converted.computedStyle,\n position: 'absolute',\n left: px(item.box.x - grid.x),\n top: px(item.box.y - grid.y),\n width: px(item.box.width),\n height: px(item.box.height),\n 'box-sizing': 'border-box'\n }\n return converted\n}\n\n/**\n * The style an element is laid out with, the closest display the importer has standing in for\n * one it lacks, and its converted children.\n */\nfunction layoutOf(element: WebCaptureElement) {\n const grid = placeableGrid(element)\n if (grid) {\n return {\n displayed: gridStyle(element.computedStyle, grid.box),\n children: grid.items.map((item) => placeGridItem(item, grid.box))\n }\n }\n const display = ownValue(element.computedStyle, 'display') ?? ''\n return {\n displayed: { ...element.computedStyle, ...DISPLAY_FALLBACKS[display] },\n children: convertChildren(element.children, element.box)\n }\n}\n\n/** Input types Chrome paints as a small intrinsic glyph, whatever box `width` gives them. */\nconst GLYPH_INPUT_TYPES: Record<string, true> = { checkbox: true, radio: true }\n\n/**\n * A checkbox or radio wider than its glyph: Chrome honors the width for layout but paints only\n * a small square centered in the box (`input { width: 100% }` in a flex label). Import the\n * square at the glyph's size, centered in a box that keeps the room the wide element took, so\n * following content stays where the page put it. Null when the box already fits the glyph.\n */\nfunction glyphBox(\n element: WebCaptureElement,\n converted: WebCaptureDesignElement,\n margins: Record<Side, number>,\n parentBox: WebCaptureBox | undefined\n): WebCaptureDesignElement | null {\n const box = element.box\n if (\n element.tagName !== 'input' ||\n !Object.hasOwn(GLYPH_INPUT_TYPES, element.attrs.type) ||\n !box ||\n box.width <= 0 ||\n box.height <= 0\n ) {\n return null\n }\n const side = Math.min(box.width, box.height)\n if (box.width - side < 1) return null\n const style = converted.computedStyle\n // The wrapper takes the placement, so the square must not be positioned or margined itself.\n const absolute = isAbsolute(style)\n style.width = px(side)\n style.height = px(side)\n style['box-sizing'] = 'border-box'\n delete style.position\n delete style.left\n delete style.top\n delete style.right\n delete style.bottom\n const wrapper: Record<string, string> = {\n display: 'flex',\n 'justify-content': 'center',\n 'align-items': 'center',\n width: px(box.width),\n height: px(box.height),\n 'box-sizing': 'border-box'\n }\n const alignSelf = ownValue(style, 'align-self')\n if (alignSelf !== undefined) {\n wrapper['align-self'] = alignSelf\n delete style['align-self']\n }\n const wrapped: WebCaptureDesignElement = {\n type: 'element',\n tagName: 'div',\n attrs: {},\n computedStyle: wrapper,\n children: [converted]\n }\n if (absolute) {\n wrapper.position = element.computedStyle.position === 'fixed' ? 'fixed' : 'absolute'\n for (const key of ['left', 'top']) {\n const value = ownValue(element.computedStyle, key)\n if (value !== undefined) wrapper[key] = value\n }\n placeAbsolute(wrapper, margins, box, parentBox)\n return wrapped\n }\n return SIDES.some((side) => margins[side] > 0) ? marginBox(wrapped, margins) : wrapped\n}\n\n/** What a box records of its size and border, which a word box drawn as a run of text drops. */\nconst WORD_BOX_PROPERTIES = [\n 'display',\n 'width',\n 'height',\n 'min-width',\n 'max-width',\n 'min-height',\n 'max-height',\n 'box-sizing',\n ...SIDES.flatMap((side) => ['style', 'width', 'color'].map((part) => `border-${side}-${part}`))\n]\n\n/** Properties that make a box draw something besides its text, or change where its text sits. */\nconst DRAWN_BOX_PROPERTIES = [\n 'background-color',\n 'background-image',\n 'box-shadow',\n 'opacity',\n 'overflow',\n ...SIDES.map((side) => `padding-${side}` as const)\n]\n\n/**\n * An inline-block that holds one line of text and draws nothing else, as pages that fade words\n * in box each word. It reads as a run of the text around it, not a box: kept as a box, every word\n * becomes a layer of its own and wraps at its own width.\n */\nfunction isWordBox(element: WebCaptureElement, style: Record<string, string>): boolean {\n if (style.display !== 'inline-block' || !INLINE_TEXT_TAGS.has(element.tagName)) return false\n if (!element.children.every((child) => child.type === 'text')) return false\n if (DRAWN_BOX_PROPERTIES.some((property) => ownValue(style, property) !== undefined)) return false\n if (SIDES.some((side) => pixels(style[`margin-${side}`]) !== 0)) return false\n if (SIDES.some((side) => pixels(style[`border-${side}-width`]) > 0)) return false\n const lineHeight = pixels(style['line-height']) || pixels(style['font-size']) * 1.5\n return element.box !== undefined && element.box.height < lineHeight * 1.5\n}\n\nfunction convertElement(\n element: WebCaptureElement,\n parentBox?: WebCaptureBox\n): WebCaptureDesignElement {\n const { displayed, children } = layoutOf(element)\n if (isWordBox(element, displayed)) {\n return {\n type: 'element',\n tagName: element.tagName,\n attrs: { ...element.attrs },\n computedStyle: omit(displayed, [...WORD_BOX_PROPERTIES, ...MARGINS]),\n children\n }\n }\n const inline = isInline(displayed)\n const split = splitMargins(displayed)\n const { margins } = split\n const style =\n displayed.display === 'inline' && INLINE_TEXT_TAGS.has(element.tagName)\n ? omit(split.style, ['display'])\n : split.style\n const converted: WebCaptureDesignElement = {\n type: 'element',\n tagName: element.tagName,\n attrs: { ...element.attrs },\n computedStyle: style,\n children\n }\n const glyph = glyphBox(element, converted, margins, parentBox)\n if (glyph) return glyph\n if (isAbsolute(style)) {\n placeAbsolute(style, margins, element.box, parentBox)\n return converted\n }\n const spaced = SIDES.some((side) => margins[side] > 0)\n return spaced && !inline ? marginBox(converted, margins) : converted\n}\n\n/**\n * The capture as the styled DOM layers are built from. The root keeps the size it had on the\n * page and drops its own position and margins, so it lands where a paste puts it.\n */\nexport function webCaptureDesignDocument(capture: WebCapture): WebCaptureDesignDocument {\n const { root } = capture\n const { displayed, children } = layoutOf(root)\n const style = omit(splitMargins(displayed).style, ['position', ...SIDES])\n // The box a capture records is the border box, padding and borders included.\n if (root.box) {\n style.width = px(root.box.width)\n style.height = px(root.box.height)\n style['box-sizing'] = 'border-box'\n }\n return {\n type: 'document',\n children: [\n {\n type: 'element',\n tagName: root.tagName,\n attrs: { ...root.attrs },\n computedStyle: style,\n children\n }\n ]\n }\n}\n","import { escapeAttribute, escapeText } from 'entities'\n\nimport {\n webCaptureDesignDocument,\n type WebCaptureDesignElement,\n type WebCaptureDesignNode\n} from './design-document'\nimport type { WebCapture } from './format'\nimport { ownValue } from './record'\n\nconst VOID_TAGS = new Set(['area', 'br', 'col', 'hr', 'img', 'input', 'source', 'wbr'])\n\n/** Tags whose start ends an open `<p>` when HTML is parsed, which would lift them out of it. */\nconst CLOSES_PARAGRAPH = new Set([\n 'address',\n 'article',\n 'aside',\n 'blockquote',\n 'details',\n 'div',\n 'dl',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'header',\n 'hgroup',\n 'hr',\n 'main',\n 'menu',\n 'nav',\n 'ol',\n 'p',\n 'pre',\n 'section',\n 'table',\n 'ul'\n])\n\n/**\n * The tag an element is written with. A script can put a block inside a `<p>`, as the capture's\n * own spacers around a margined box do, but parsing would end the paragraph there; a `<div>`\n * holds it in place, and the element's styles say how it lays out either way.\n */\nfunction writtenTag(element: WebCaptureDesignElement): string {\n const holdsBlock = element.children.some(\n (child) => child.type === 'element' && CLOSES_PARAGRAPH.has(child.tagName)\n )\n return element.tagName === 'p' && holdsBlock ? 'div' : element.tagName\n}\n\nexport interface WebCaptureHTMLOptions {\n /** Keep inlined images; without them an image keeps only its size and description. */\n images?: boolean\n}\n\nfunction styleAttribute(style: Record<string, string>): string {\n return Object.entries(style)\n .map(([property, value]) => `${property}: ${value}`)\n .join('; ')\n}\n\nfunction attributes(element: WebCaptureDesignElement, options: WebCaptureHTMLOptions): string {\n const attrs: Record<string, string> = { ...element.attrs }\n if (options.images === false && ownValue(attrs, 'src')?.startsWith('data:')) delete attrs.src\n // A captured field holds the text it showed; an `<input>` holds it as its value.\n if (element.tagName === 'input') {\n const text = element.children.map((child) => (child.type === 'text' ? child.text : '')).join('')\n if (text) attrs.value = text\n }\n const style = styleAttribute(element.computedStyle)\n if (style) attrs.style = style\n return Object.entries(attrs)\n .map(([name, value]) => ` ${name}=\"${escapeAttribute(value)}\"`)\n .join('')\n}\n\nfunction serialize(node: WebCaptureDesignNode, options: WebCaptureHTMLOptions): string {\n if (node.type === 'text') return escapeText(node.text)\n const tag = writtenTag(node)\n const open = `<${tag}${attributes(node, options)}>`\n if (VOID_TAGS.has(tag)) return open\n const children = node.children.map((child) => serialize(child, options)).join('')\n return `${open}${children}</${tag}>`\n}\n\n/**\n * The capture as static HTML whose elements carry their styles inline, for applications that\n * read clipboard HTML but not the capture itself, and for importing it as HTML. It is the styled\n * DOM a paste builds layers from, so the HTML importer reads the capture as the paste does.\n */\nexport function webCaptureToHTML(capture: WebCapture, options: WebCaptureHTMLOptions = {}): string {\n return webCaptureDesignDocument(capture)\n .children.map((node) => serialize(node, options))\n .join('')\n}\n","/** The capture format identifier that clipboard payloads and files carry. */\nexport const WEB_CAPTURE_FORMAT = 'pairdraw/web-capture'\n\n/** The capture format version this package writes and reads. */\nexport const WEB_CAPTURE_VERSION = 1\n\n/** Elements one capture holds at most; a capturer stops descending once it reaches this. */\nexport const MAX_CAPTURE_ELEMENTS = 20_000\n\n/** How deep a capture nests; deeper elements are left out, as browsers rarely draw them. */\nexport const MAX_CAPTURE_DEPTH = 256\n\n/** Bytes one inlined image may take; a larger image stays a link the importer records. */\nexport const MAX_CAPTURE_IMAGE_BYTES = 8 * 1024 * 1024\n\n/** Bytes all inlined images of a capture take together. */\nexport const MAX_CAPTURE_IMAGES_BYTES = 48 * 1024 * 1024\n\n/** Characters of serialized capture JSON a reader accepts, images included. */\nexport const MAX_CAPTURE_JSON_LENGTH = 96 * 1024 * 1024\n\n/** Characters of plain web HTML a paste styles; a larger fragment is refused. */\nexport const MAX_WEB_HTML_LENGTH = 8 * 1024 * 1024\n","import * as v from 'valibot'\n\nimport { MAX_CAPTURE_JSON_LENGTH, WEB_CAPTURE_FORMAT, WEB_CAPTURE_VERSION } from './limits'\nimport type { WebCaptureElement, WebCaptureNode } from './types'\n\nconst finiteSchema = v.pipe(v.number(), v.finite())\nconst sizeSchema = v.pipe(v.number(), v.finite(), v.minValue(0))\nconst shortStringSchema = v.pipe(v.string(), v.maxLength(4096))\n\nconst webCaptureBoxSchema = v.object({\n x: finiteSchema,\n y: finiteSchema,\n width: sizeSchema,\n height: sizeSchema\n})\n\nconst webCaptureTextSchema = v.object({\n type: v.literal('text'),\n text: v.pipe(v.string(), v.maxLength(1_000_000))\n})\n\n/** HTML and SVG tag names, lowercase as a capturer writes them. */\nconst tagNameSchema = v.pipe(v.string(), v.regex(/^[a-z][a-z0-9-]{0,63}$/))\n/** Attribute names; which of them an import keeps is decided when a capture is read. */\nconst attributeNameSchema = v.pipe(v.string(), v.regex(/^[a-z][a-z0-9:_-]{0,63}$/))\n/** Attribute values hold inlined images as data URLs, so they may be large. */\nconst attributeValueSchema = v.pipe(v.string(), v.maxLength(MAX_CAPTURE_JSON_LENGTH))\nconst propertyNameSchema = v.pipe(v.string(), v.regex(/^-?[a-z][a-z-]{0,63}$/))\n\nconst webCaptureElementSchema: v.GenericSchema<unknown, WebCaptureElement> = v.object({\n type: v.literal('element'),\n tagName: tagNameSchema,\n attrs: v.record(attributeNameSchema, attributeValueSchema),\n computedStyle: v.record(propertyNameSchema, shortStringSchema),\n box: v.optional(webCaptureBoxSchema),\n children: v.array(v.lazy(() => webCaptureNodeSchema))\n})\n\nconst webCaptureNodeSchema: v.GenericSchema<unknown, WebCaptureNode> = v.union([\n webCaptureTextSchema,\n webCaptureElementSchema\n])\n\nexport const webCaptureFontSchema = v.object({\n family: shortStringSchema,\n weight: shortStringSchema,\n style: shortStringSchema\n})\n\nexport const webCaptureViewportSchema = v.object({\n width: sizeSchema,\n height: sizeSchema,\n devicePixelRatio: v.pipe(v.number(), v.finite(), v.minValue(0))\n})\n\nconst webCaptureSourceSchema = v.object({\n url: v.optional(shortStringSchema),\n title: v.optional(shortStringSchema)\n})\n\n/** A page or element captured with the styles the browser computed for it. */\nexport const webCaptureSchema = v.object({\n format: v.literal(WEB_CAPTURE_FORMAT),\n version: v.literal(WEB_CAPTURE_VERSION),\n /** Whether a whole page or one element of it was captured. */\n scope: v.picklist(['page', 'element']),\n source: webCaptureSourceSchema,\n /** When the capture was made, as an ISO 8601 timestamp. */\n capturedAt: shortStringSchema,\n viewport: webCaptureViewportSchema,\n root: webCaptureElementSchema,\n fonts: v.array(webCaptureFontSchema),\n /** Whether the capturer stopped at its element limit, leaving later content out. */\n truncated: v.boolean()\n})\n","import { ownValue } from './record'\n\n/**\n * The computed properties a capture keeps for each element: those `@pairdraw/dom-css` builds\n * layers from, plus margins, which a capture turns into spacing when it is imported.\n */\nexport const CAPTURED_STYLE_PROPERTIES = [\n 'align-items',\n 'align-self',\n 'aspect-ratio',\n 'background-color',\n 'background-image',\n 'background-position',\n 'background-repeat',\n 'background-size',\n 'border-bottom-color',\n 'border-bottom-left-radius',\n 'border-bottom-right-radius',\n 'border-bottom-style',\n 'border-bottom-width',\n 'border-left-color',\n 'border-left-style',\n 'border-left-width',\n 'border-right-color',\n 'border-right-style',\n 'border-right-width',\n 'border-top-color',\n 'border-top-left-radius',\n 'border-top-right-radius',\n 'border-top-style',\n 'border-top-width',\n 'bottom',\n 'box-shadow',\n 'box-sizing',\n 'color',\n 'column-gap',\n 'display',\n 'flex-direction',\n 'flex-wrap',\n 'font-family',\n 'font-size',\n 'font-style',\n 'font-weight',\n 'gap',\n 'height',\n 'justify-content',\n 'left',\n 'letter-spacing',\n 'line-height',\n 'margin-bottom',\n 'margin-left',\n 'margin-right',\n 'margin-top',\n 'max-height',\n 'max-width',\n 'min-height',\n 'min-width',\n 'object-fit',\n 'opacity',\n 'order',\n 'overflow',\n 'padding-bottom',\n 'padding-left',\n 'padding-right',\n 'padding-top',\n 'position',\n 'right',\n 'row-gap',\n 'text-align',\n 'text-decoration-color',\n 'text-decoration-line',\n 'text-decoration-style',\n 'text-decoration-thickness',\n 'text-indent',\n 'text-shadow',\n 'text-transform',\n 'text-underline-offset',\n 'top',\n 'white-space',\n 'width'\n] as const\n\nexport type CapturedStyleProperty = (typeof CAPTURED_STYLE_PROPERTIES)[number]\n\nconst CAPTURED = new Set<string>(CAPTURED_STYLE_PROPERTIES)\n\n/** Whether a capture keeps this property; others are dropped when a capture is read. */\nexport function isCapturedStyleProperty(property: string): property is CapturedStyleProperty {\n return CAPTURED.has(property)\n}\n\nconst SIDES = ['top', 'right', 'bottom', 'left'] as const\n\n/**\n * Values the importer reads exactly as it reads a missing property, so leaving them out only\n * makes the capture smaller. Inherited text properties are always kept: a nested run reads\n * a missing one from its parent, which differs from the value the page computed.\n */\nconst IMPLIED_VALUES: Partial<Record<CapturedStyleProperty, readonly string[]>> = {\n 'align-items': ['normal'],\n 'align-self': ['auto'],\n 'aspect-ratio': ['auto'],\n 'background-color': ['rgba(0, 0, 0, 0)', 'transparent'],\n 'background-image': ['none'],\n 'background-position': ['0% 0%'],\n 'background-repeat': ['repeat'],\n 'background-size': ['auto'],\n 'box-shadow': ['none'],\n 'column-gap': ['normal'],\n 'flex-direction': ['row'],\n 'flex-wrap': ['nowrap'],\n gap: ['normal'],\n height: ['auto'],\n 'justify-content': ['normal'],\n 'max-height': ['none'],\n 'max-width': ['none'],\n 'min-height': ['auto', '0px'],\n 'min-width': ['auto', '0px'],\n 'object-fit': ['fill'],\n opacity: ['1'],\n order: ['0'],\n overflow: ['visible'],\n 'row-gap': ['normal'],\n 'text-indent': ['0px'],\n width: ['auto']\n}\n\nconst ZERO_LENGTH_PROPERTIES = [\n 'border-bottom-left-radius',\n 'border-bottom-right-radius',\n 'border-top-left-radius',\n 'border-top-right-radius',\n ...SIDES.map((side) => `padding-${side}` as const),\n ...SIDES.map((side) => `margin-${side}` as const)\n]\n\nconst TEXT_DECORATION_DETAILS = [\n 'text-decoration-color',\n 'text-decoration-style',\n 'text-decoration-thickness',\n 'text-underline-offset'\n]\n\n/**\n * The style without values that change nothing on import: defaults, borders without a style,\n * offsets of boxes in normal flow, and decoration details of undecorated text.\n */\nexport function withoutImpliedValues(style: Record<string, string>): Record<string, string> {\n const dropped = new Set<string>()\n for (const [property, values] of Object.entries(IMPLIED_VALUES)) {\n if (values.includes(ownValue(style, property) ?? '')) dropped.add(property)\n }\n for (const property of ZERO_LENGTH_PROPERTIES) {\n if (style[property] === '0px') dropped.add(property)\n }\n for (const side of SIDES) {\n const borderStyle = ownValue(style, `border-${side}-style`)\n if (borderStyle !== undefined && borderStyle !== 'none' && borderStyle !== 'hidden') continue\n for (const part of ['style', 'width', 'color']) dropped.add(`border-${side}-${part}`)\n }\n // Sticky boxes sit in normal flow until the page scrolls, which a still capture never does.\n const position = ownValue(style, 'position')\n const inFlow = position === undefined || position === 'static' || position === 'sticky'\n if (inFlow) dropped.add('position')\n for (const side of SIDES) {\n if (inFlow || style[side] === 'auto') dropped.add(side)\n }\n const decoration = ownValue(style, 'text-decoration-line')\n if (decoration === undefined || decoration === 'none') {\n for (const property of TEXT_DECORATION_DETAILS) dropped.add(property)\n }\n return Object.fromEntries(Object.entries(style).filter(([property]) => !dropped.has(property)))\n}\n","const LINK_PROTOCOLS = new Set(['http:', 'https:', 'mailto:'])\nconst IMAGE_PROTOCOLS = new Set(['http:', 'https:'])\n/** Raster images the canvas decodes; SVG is rasterized by the capturer instead. */\nconst DATA_IMAGE =\n /^data:image\\/(?:png|jpeg|gif|webp|avif|bmp|x-icon|vnd\\.microsoft\\.icon);base64,/i\n\nfunction resolve(value: string, base: string | undefined): URL | null {\n try {\n return new URL(value.trim(), base)\n } catch {\n return null\n }\n}\n\n/** A link a layer may keep: http, https, or mailto, resolved against the page; never script. */\nexport function safeLinkURL(value: string, base?: string): string | null {\n const url = resolve(value, base)\n return url && LINK_PROTOCOLS.has(url.protocol) ? url.href : null\n}\n\n/** An image source a layer may keep: an inlined raster image, or an http(s) address. */\nexport function safeImageSource(value: string, base?: string): string | null {\n const trimmed = value.trim()\n if (DATA_IMAGE.test(trimmed)) return trimmed\n const url = resolve(trimmed, base)\n return url && IMAGE_PROTOCOLS.has(url.protocol) ? url.href : null\n}\n","import * as v from 'valibot'\n\nimport type { WebCapture, WebCaptureReadResult } from './format'\nimport {\n MAX_CAPTURE_DEPTH,\n MAX_CAPTURE_ELEMENTS,\n MAX_CAPTURE_JSON_LENGTH,\n WEB_CAPTURE_FORMAT,\n WEB_CAPTURE_VERSION\n} from './limits'\nimport { webCaptureSchema } from './schema'\nimport { isCapturedStyleProperty } from './styles'\nimport type { WebCaptureElement, WebCaptureNode } from './types'\nimport { safeImageSource, safeLinkURL } from './urls'\n\n/** Read first, so a capture from a newer capturer is told apart from a damaged one. */\nconst captureHeaderSchema = v.looseObject({\n format: v.literal(WEB_CAPTURE_FORMAT),\n version: v.number()\n})\n\n/** Attributes a layer can use: names, links, images, control kinds, and accessible labels. */\nconst KEPT_ATTRIBUTES = new Set([\n 'id',\n 'class',\n 'href',\n 'src',\n 'alt',\n 'title',\n 'type',\n 'role',\n 'aria-label',\n 'lang',\n 'dir'\n])\n\n/** Elements that never draw, whatever a capture claims. */\nconst DROPPED_TAGS = new Set([\n 'script',\n 'style',\n 'link',\n 'meta',\n 'head',\n 'title',\n 'template',\n 'noscript',\n 'iframe',\n 'frame',\n 'object',\n 'embed',\n 'base'\n])\n\n/**\n * JSON nesting a capture within `MAX_CAPTURE_DEPTH` takes: an object and a `children` array per\n * element, the capture around the root, and the records of the deepest element, with room to\n * spare. Deeper values are refused before validation, whose recursion they could overflow.\n */\nconst MAX_JSON_NESTING = 2 * MAX_CAPTURE_DEPTH + 16\n\n/** Whether a value nests deeper than `limit`, walked without recursion; a cycle counts as deep. */\nfunction nestsDeeperThan(value: unknown, limit: number): boolean {\n const pending: { value: unknown; depth: number }[] = [{ value, depth: 0 }]\n for (let next = pending.pop(); next; next = pending.pop()) {\n if (typeof next.value !== 'object' || next.value === null) continue\n if (next.depth >= limit) return true\n const depth = next.depth + 1\n for (const child of Object.values(next.value)) pending.push({ value: child, depth })\n }\n return false\n}\n\ninterface Budget {\n elements: number\n truncated: boolean\n}\n\nfunction keptAttributes(\n attrs: Record<string, string>,\n base: string | undefined\n): Record<string, string> {\n const kept: Record<string, string> = {}\n for (const [name, value] of Object.entries(attrs)) {\n if (!KEPT_ATTRIBUTES.has(name)) continue\n if (name === 'href') {\n const href = safeLinkURL(value, base)\n if (href) kept.href = href\n } else if (name === 'src') {\n const src = safeImageSource(value, base)\n if (src) kept.src = src\n } else {\n kept[name] = value\n }\n }\n return kept\n}\n\n/** The `url(...)` sources of a value, with the spans they occupy. */\nconst BACKGROUND_URL = /url\\(\\s*(['\"]?)(.*?)\\1\\s*\\)/g\n\n/**\n * A `background-image` list with every `url(...)` source limited to what an image layer may\n * keep; a layer whose source is unsafe is dropped, and a list left empty paints nothing.\n * Gradient layers carry no address and pass through as written.\n */\nfunction keptBackgroundImage(value: string, base: string | undefined): string | null {\n const layers: string[] = []\n let cursor = 0\n let dropped = false\n for (const match of value.matchAll(BACKGROUND_URL)) {\n const source = safeImageSource(match[2], base)\n if (source) layers.push(value.slice(cursor, match.index) + `url(\"${source}\")`)\n else dropped = true\n cursor = match.index + match[0].length\n }\n if (cursor === 0 && !dropped) return value\n layers.push(value.slice(cursor))\n // Split at top-level commas only: a gradient's own commas stay inside its parentheses.\n const kept: string[] = []\n let depth = 0\n let current = ''\n for (const character of layers.join('')) {\n if (character === '(') depth++\n else if (character === ')') depth--\n if (character === ',' && depth === 0) {\n kept.push(current)\n current = ''\n continue\n }\n current += character\n }\n kept.push(current)\n const painted = kept\n .map((layer) => layer.trim())\n .filter((layer) => layer.length > 0 && layer !== 'none')\n return painted.length > 0 ? painted.join(', ') : null\n}\n\nfunction keptStyle(\n style: Record<string, string>,\n base: string | undefined\n): Record<string, string> {\n const kept: Record<string, string> = {}\n for (const [property, value] of Object.entries(style)) {\n if (!isCapturedStyleProperty(property)) continue\n if (property === 'background-image') {\n const image = keptBackgroundImage(value, base)\n if (image) kept[property] = image\n continue\n }\n kept[property] = value\n }\n return kept\n}\n\nfunction normalizeElement(\n element: WebCaptureElement,\n base: string | undefined,\n depth: number,\n budget: Budget\n): WebCaptureElement {\n const children: WebCaptureNode[] = []\n for (const child of element.children) {\n if (child.type === 'text') {\n children.push(child)\n continue\n }\n if (DROPPED_TAGS.has(child.tagName)) continue\n if (depth + 1 > MAX_CAPTURE_DEPTH || budget.elements >= MAX_CAPTURE_ELEMENTS) {\n budget.truncated = true\n continue\n }\n budget.elements++\n children.push(normalizeElement(child, base, depth + 1, budget))\n }\n return {\n type: 'element',\n tagName: element.tagName,\n attrs: keptAttributes(element.attrs, base),\n ...(element.box ? { box: element.box } : {}),\n computedStyle: keptStyle(element.computedStyle, base),\n children\n }\n}\n\n/**\n * A capture as an import may use it: only the attributes and properties layers read, links\n * limited to http, https, and mailto, images limited to raster data URLs and http(s) addresses,\n * and at most `MAX_CAPTURE_ELEMENTS` elements. Captures come from any page, so every reader\n * goes through this.\n */\nexport function normalizeWebCapture(capture: WebCapture): WebCapture {\n const budget: Budget = { elements: 1, truncated: false }\n const base = capture.source.url\n const root = normalizeElement(capture.root, base, 0, budget)\n return { ...capture, root, truncated: capture.truncated || budget.truncated }\n}\n\n/** Reads a capture that is already a value, such as one a capturer handed over. */\nexport function readWebCapture(value: unknown): WebCaptureReadResult {\n if (nestsDeeperThan(value, MAX_JSON_NESTING)) return { ok: false, error: 'invalid' }\n const header = v.safeParse(captureHeaderSchema, value)\n if (!header.success) return { ok: false, error: 'invalid' }\n if (header.output.version !== WEB_CAPTURE_VERSION) {\n return { ok: false, error: 'unsupported-version' }\n }\n const parsed = v.safeParse(webCaptureSchema, value)\n if (!parsed.success) return { ok: false, error: 'invalid' }\n return { ok: true, capture: normalizeWebCapture(parsed.output) }\n}\n\n/** Reads a capture serialized as JSON, as files and clipboard payloads hold it. */\nexport function parseWebCapture(text: string): WebCaptureReadResult {\n if (text.length > MAX_CAPTURE_JSON_LENGTH) return { ok: false, error: 'too-large' }\n const json = v.safeParse(v.pipe(v.string(), v.parseJson()), text)\n if (!json.success) return { ok: false, error: 'invalid' }\n return readWebCapture(json.output)\n}\n","import { compact } from 'es-toolkit'\nimport { Inflate, deflateSync, strToU8 } from 'fflate'\nimport { fromUint8Array, isValid, toUint8Array } from 'js-base64'\n\nimport type { WebCapture, WebCaptureReadResult } from './format'\nimport { webCaptureToHTML } from './html'\nimport { MAX_CAPTURE_JSON_LENGTH } from './limits'\nimport { normalizeWebCapture, parseWebCapture } from './parse'\n\n/**\n * Clipboard HTML carries a capture between these markers, as Base64 of the DEFLATE-compressed\n * JSON, the way Figma and Pairdraw carry their layers in an HTML comment.\n */\nexport const WEB_CAPTURE_CLIPBOARD_START = '<!--(pairdraw-web-capture)'\nexport const WEB_CAPTURE_CLIPBOARD_END = '(/pairdraw-web-capture)-->'\n\n/** Compressed bytes inflated per step, so an oversized payload stops early. */\nconst INFLATE_STEP = 16 * 1024\n\nexport interface WebCaptureClipboardPayload {\n /** The capture in markers, followed by its content as styled HTML for other applications. */\n html: string\n /** The page's title and address, for applications that only read text. */\n text: string\n}\n\n/** What the clipboard holds after copying a capture: the capture itself and a readable copy. */\nexport function encodeWebCaptureClipboard(captured: WebCapture): WebCaptureClipboardPayload {\n const capture = normalizeWebCapture(captured)\n const compressed = deflateSync(strToU8(JSON.stringify(capture)), { level: 6 })\n const marker = `${WEB_CAPTURE_CLIPBOARD_START}${fromUint8Array(compressed)}${WEB_CAPTURE_CLIPBOARD_END}`\n const html = `<meta charset=\"utf-8\">${marker}${webCaptureToHTML(capture, { images: false })}`\n const text = compact([capture.source.title, capture.source.url]).join('\\n')\n return { html, text }\n}\n\nfunction markedPayload(html: string): string | null {\n const start = html.indexOf(WEB_CAPTURE_CLIPBOARD_START)\n if (start === -1) return null\n const from = start + WEB_CAPTURE_CLIPBOARD_START.length\n const end = html.indexOf(WEB_CAPTURE_CLIPBOARD_END, from)\n return end === -1 ? null : html.slice(from, end)\n}\n\n/** Whether clipboard HTML holds a complete capture marker. */\nexport function hasWebCaptureClipboardMarker(html: string): boolean {\n return markedPayload(html) !== null\n}\n\n/** Inflates at most `MAX_CAPTURE_JSON_LENGTH` bytes of text. */\nfunction inflateText(bytes: Uint8Array): { text: string } | 'invalid' | 'too-large' {\n const decoder = new TextDecoder()\n // An object, since the inflate callback changes it where control flow analysis cannot see.\n const state = { text: '', length: 0, overflow: false }\n const inflate = new Inflate((chunk) => {\n state.length += chunk.length\n if (state.length > MAX_CAPTURE_JSON_LENGTH) state.overflow = true\n else state.text += decoder.decode(chunk, { stream: true })\n })\n try {\n for (let offset = 0; offset < bytes.length; offset += INFLATE_STEP) {\n if (state.overflow) break\n const end = offset + INFLATE_STEP\n inflate.push(bytes.subarray(offset, end), end >= bytes.length)\n }\n } catch {\n return 'invalid'\n }\n return state.overflow ? 'too-large' : { text: state.text + decoder.decode() }\n}\n\n/**\n * The capture clipboard HTML holds, or null when it holds none. Clipboard HTML is writable by\n * any page, so the payload is size-limited, validated, and normalized before it is returned.\n */\nexport function readWebCaptureClipboard(html: string): WebCaptureReadResult | null {\n const payload = markedPayload(html)\n if (payload === null) return null\n const encoded = payload.trim()\n if (encoded.length > MAX_CAPTURE_JSON_LENGTH) return { ok: false, error: 'too-large' }\n if (!isValid(encoded)) return { ok: false, error: 'invalid' }\n const inflated = inflateText(toUint8Array(encoded))\n if (typeof inflated === 'string') return { ok: false, error: inflated }\n return parseWebCapture(inflated.text)\n}\n","import { encodeWebCaptureClipboard, type WebCaptureClipboardPayload } from '#web-capture/clipboard'\nimport type { WebCapture } from '#web-capture/format'\n\n/** The part of the asynchronous clipboard a capture write uses. */\nexport type CaptureClipboard = Pick<Clipboard, 'write'>\n\nexport interface WriteCaptureClipboardOptions {\n /** The clipboard to write; the page's own by default. */\n clipboard?: CaptureClipboard\n /** Builds a clipboard item; the page's `ClipboardItem` by default. */\n createItem?: (items: Record<string, Promise<Blob>>) => ClipboardItem\n}\n\n/** Thrown when the page has no asynchronous clipboard, which only secure pages offer. */\nexport class CaptureClipboardUnavailableError extends Error {\n constructor() {\n super('Copying a capture needs a page served over HTTPS')\n this.name = 'CaptureClipboardUnavailableError'\n }\n}\n\nfunction isPayload(\n value: WebCapture | WebCaptureClipboardPayload\n): value is WebCaptureClipboardPayload {\n return 'html' in value && 'text' in value\n}\n\n/**\n * Copies a capture so it pastes into a Pairdraw canvas, as HTML for Pairdraw and other\n * applications and as the page's title and address for plain text. Pass the capture's promise\n * straight from the click that asked for it: the write starts inside that click and resolves\n * its data later, so a capture that takes a while still counts as the click's own.\n */\nexport async function writeWebCaptureClipboard(\n capture:\n | WebCapture\n | WebCaptureClipboardPayload\n | Promise<WebCapture | WebCaptureClipboardPayload>,\n options: WriteCaptureClipboardOptions = {}\n): Promise<void> {\n const clipboard =\n options.clipboard ?? (typeof navigator === 'undefined' ? undefined : navigator.clipboard)\n const createItem =\n options.createItem ??\n (typeof ClipboardItem === 'undefined'\n ? undefined\n : (items: Record<string, Promise<Blob>>) => new ClipboardItem(items))\n // `navigator.clipboard` is missing outside secure contexts.\n if (!clipboard || !createItem) throw new CaptureClipboardUnavailableError()\n const payload = Promise.resolve(capture).then((value) =>\n isPayload(value) ? value : encodeWebCaptureClipboard(value)\n )\n await clipboard.write([\n createItem({\n 'text/html': payload.then((value) => new Blob([value.html], { type: 'text/html' })),\n 'text/plain': payload.then((value) => new Blob([value.text], { type: 'text/plain' }))\n })\n ])\n}\n"],"mappings":";;;;;;;;;;AAIA,SAAgB,SACd,QACA,KACoB;CACpB,OAAO,OAAO,OAAO,QAAQ,GAAG,IAAI,OAAO,OAAO,KAAA;AACpD;;;ACiBA,MAAMA,UAAQ;CAAC;CAAO;CAAS;CAAU;AAAM;;;;;AAO/C,MAAM,oBAA4D;CAChE,MAAM;EAAE,SAAS;EAAQ,kBAAkB;EAAO,aAAa;CAAO;C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AC,GAC1B;CACf,MAAM,YACJ,QAAQ,cAAc,OAAO,cAAc,cAAc,KAAA,IAAY,UAAU;CACjF,MAAM,aACJ,QAAQ,eACP,OAAO,kBAAkB,cACtB,KAAA,KACC,UAAyC,IAAI,cAAc,KAAK;CAEvE,IAAI,CAAC,aAAa,CAAC,YAAY,MAAM,IAAI,iCAAiC;CAC1E,MAAM,UAAU,QAAQ,QAAQ,OAAO,CAAC,CAAC,MAAM,UAC7C,UAAU,KAAK,IAAI,QAAQ,0BAA0B,KAAK,CAC5D;CACA,MAAM,UAAU,MAAM,CACpB,WAAW;EACT,aAAa,QAAQ,MAAM,UAAU,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,EAAE,MAAM,YAAY,CAAC,CAAC;EAClF,cAAc,QAAQ,MAAM,UAAU,IAAI,KAAK,CAAC,MAAM,IAAI,GAAG,EAAE,MAAM,aAAa,CAAC,CAAC;CACtF,CAAC,CACH,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"clipboard.js","names":["SIDES"],"sources":["../../../src/record.ts","../../../src/design-document.ts","../../../src/html.ts","../../../src/limits.ts","../../../src/schema.ts","../../../src/styles.ts","../../../src/urls.ts","../../../src/parse.ts","../../../src/clipboard.ts","../../../src/capturer/clipboard.ts"],"sourcesContent":["/**\n * The value a style or attribute record sets for `key`, or undefined when it sets none. Records\n * are typed as setting every key, which they do not.\n */\nexport function ownValue(\n record: Readonly<Record<string, string>>,\n key: string\n): string | undefined {\n return Object.hasOwn(record, key) ? record[key] : undefined\n}\n","import { omit } from 'es-toolkit'\n\nimport type { WebCapture } from './format'\nimport { ownValue } from './record'\nimport type { WebCaptureBox, WebCaptureElement, WebCaptureNode, WebCaptureText } from './types'\n\n/**\n * An element of the styled DOM `@pairdraw/dom-css` builds layers from. The shape matches its\n * `DesignElement`, so a capture imports through `sceneGraphFromStyledHTML` without a CSS runtime.\n */\nexport interface WebCaptureDesignElement {\n type: 'element'\n tagName: string\n attrs: Record<string, string>\n computedStyle: Record<string, string>\n children: WebCaptureDesignNode[]\n}\n\nexport type WebCaptureDesignNode = WebCaptureDesignElement | WebCaptureText\n\n/** The styled DOM of a capture, matching `@pairdraw/dom-css`'s `DesignDocument`. */\nexport interface WebCaptureDesignDocument {\n type: 'document'\n children: WebCaptureDesignNode[]\n}\n\nconst SIDES = ['top', 'right', 'bottom', 'left'] as const\ntype Side = (typeof SIDES)[number]\n\n/**\n * Displays the importer has no layout for, mapped to the closest one it has. A grid of\n * fixed-size cells wraps as a row of them does, and a table row is a row of its cells.\n */\nconst DISPLAY_FALLBACKS: Record<string, Record<string, string>> = {\n grid: { display: 'flex', 'flex-direction': 'row', 'flex-wrap': 'wrap' },\n 'inline-grid': { display: 'inline-flex', 'flex-direction': 'row', 'flex-wrap': 'wrap' },\n 'table-row': { display: 'flex', 'flex-direction': 'row', 'flex-wrap': 'nowrap' },\n table: { display: 'block' },\n 'inline-table': { display: 'inline-block' },\n 'table-row-group': { display: 'block' },\n 'table-header-group': { display: 'block' },\n 'table-footer-group': { display: 'block' },\n 'table-cell': { display: 'block' },\n 'table-caption': { display: 'block' },\n 'list-item': { display: 'block' },\n 'flow-root': { display: 'block' }\n}\n\n/**\n * Inline text tags the importer lays out inline when they say nothing of their display. Left\n * without one, a run such as a link or a bold word stays text instead of a box around text.\n */\nconst INLINE_TEXT_TAGS = new Set(['a', 'b', 'code', 'em', 'i', 'small', 'span', 'strong', 'u'])\n\nfunction pixels(value: string | undefined): number {\n if (!value?.endsWith('px')) return 0\n const parsed = Number.parseFloat(value)\n return Number.isFinite(parsed) ? parsed : 0\n}\n\nfunction px(value: number): string {\n return `${Math.round(value * 100) / 100}px`\n}\n\nconst MARGINS = SIDES.map((side) => `margin-${side}` as const)\n\n/** The element's margins in pixels, and its style without them. */\nfunction splitMargins(style: Record<string, string>) {\n const margins = { top: 0, right: 0, bottom: 0, left: 0 }\n for (const side of SIDES) margins[side] = pixels(style[`margin-${side}`])\n return { margins, style: omit(style, MARGINS) }\n}\n\nfunction isAbsolute(style: Record<string, string>): boolean {\n return style.position === 'absolute' || style.position === 'fixed'\n}\n\nfunction isInline(style: Record<string, string>): boolean {\n return (ownValue(style, 'display') ?? '').startsWith('inline')\n}\n\n/**\n * Places an absolute box in its parent layer. CSS measures `left` and `top` from the containing\n * block, which may be a further ancestor or the viewport, so the recorded boxes place it where\n * the page drew it. Without them, it sits at its offset plus its margin, as CSS places it.\n */\nfunction placeAbsolute(\n style: Record<string, string>,\n margins: Record<Side, number>,\n box: WebCaptureBox | undefined,\n parentBox: WebCaptureBox | undefined\n): void {\n if (box && parentBox) {\n style.left = px(box.x - parentBox.x)\n style.top = px(box.y - parentBox.y)\n return\n }\n if (ownValue(style, 'left') !== undefined) style.left = px(pixels(style.left) + margins.left)\n if (ownValue(style, 'top') !== undefined) style.top = px(pixels(style.top) + margins.top)\n}\n\n/**\n * A box in normal flow keeps the room its margins took inside a transparent box padded by them.\n * Negative margins, which pull neighbours over each other, are dropped.\n */\nfunction marginBox(\n element: WebCaptureDesignElement,\n margins: Record<Side, number>\n): WebCaptureDesignElement {\n const style: Record<string, string> = { display: 'block' }\n for (const side of SIDES) {\n if (margins[side] > 0) style[`padding-${side}`] = px(margins[side])\n }\n const alignSelf = ownValue(element.computedStyle, 'align-self')\n if (alignSelf === undefined) {\n return { type: 'element', tagName: 'div', attrs: {}, computedStyle: style, children: [element] }\n }\n // The box is the flex item now, so it aligns itself as the element did.\n style['align-self'] = alignSelf\n const child = { ...element, computedStyle: omit(element.computedStyle, ['align-self']) }\n return { type: 'element', tagName: 'div', attrs: {}, computedStyle: style, children: [child] }\n}\n\nfunction convertChildren(\n children: readonly WebCaptureNode[],\n parentBox: WebCaptureBox | undefined\n): WebCaptureDesignNode[] {\n return children.map((child): WebCaptureDesignNode =>\n child.type === 'text' ? child : convertElement(child, parentBox)\n )\n}\n\nconst GRID_DISPLAYS = new Set(['grid', 'inline-grid'])\n\ntype BoxedElement = WebCaptureElement & { box: WebCaptureBox }\n\nfunction hasBox(element: WebCaptureElement): element is BoxedElement {\n return element.box !== undefined\n}\n\n/**\n * A grid whose items can stay where the page drew them: the capture recorded the grid's box and\n * every item's, and the grid holds no loose text. Null otherwise, and for anything but a grid.\n */\nfunction placeableGrid(\n element: WebCaptureElement\n): { box: WebCaptureBox; items: BoxedElement[] } | null {\n if (!GRID_DISPLAYS.has(ownValue(element.computedStyle, 'display') ?? '') || !hasBox(element)) {\n return null\n }\n const items: BoxedElement[] = []\n for (const child of element.children) {\n if (child.type === 'text') {\n if (child.text.trim().length > 0) return null\n } else if (hasBox(child)) {\n items.push(child)\n } else {\n return null\n }\n }\n return { box: element.box, items }\n}\n\n/**\n * Auto layout has no grid tracks, so a grid keeps its drawn size and its items become absolute\n * boxes where the page drew them. Their margins already moved their boxes.\n */\nfunction gridStyle(style: Record<string, string>, box: WebCaptureBox): Record<string, string> {\n return {\n ...omit(style, ['gap', 'row-gap', 'column-gap']),\n display: style.display === 'inline-grid' ? 'inline-block' : 'block',\n width: px(box.width),\n height: px(box.height),\n 'box-sizing': 'border-box'\n }\n}\n\nconst PLACEMENT = [...MARGINS, 'position', ...SIDES]\n\nfunction placeGridItem(item: BoxedElement, grid: WebCaptureBox): WebCaptureDesignElement {\n // Without margins or a position of its own, the item converts to itself, not a margin box.\n const converted = convertElement({ ...item, computedStyle: omit(item.computedStyle, PLACEMENT) })\n converted.computedStyle = {\n ...converted.computedStyle,\n position: 'absolute',\n left: px(item.box.x - grid.x),\n top: px(item.box.y - grid.y),\n width: px(item.box.width),\n height: px(item.box.height),\n 'box-sizing': 'border-box'\n }\n return converted\n}\n\n/**\n * The style an element is laid out with, the closest display the importer has standing in for\n * one it lacks, and its converted children.\n */\nfunction layoutOf(element: WebCaptureElement) {\n const grid = placeableGrid(element)\n if (grid) {\n return {\n displayed: gridStyle(element.computedStyle, grid.box),\n children: grid.items.map((item) => placeGridItem(item, grid.box))\n }\n }\n const display = ownValue(element.computedStyle, 'display') ?? ''\n return {\n displayed: { ...element.computedStyle, ...DISPLAY_FALLBACKS[display] },\n children: convertChildren(element.children, element.box)\n }\n}\n\n/** Input types Chrome paints as a small intrinsic glyph, whatever box `width` gives them. */\nconst GLYPH_INPUT_TYPES: Record<string, true> = { checkbox: true, radio: true }\n\n/**\n * A checkbox or radio wider than its glyph: Chrome honors the width for layout but paints only\n * a small square centered in the box (`input { width: 100% }` in a flex label). Import the\n * square at the glyph's size, centered in a box that keeps the room the wide element took, so\n * following content stays where the page put it. Null when the box already fits the glyph.\n */\nfunction glyphBox(\n element: WebCaptureElement,\n converted: WebCaptureDesignElement,\n margins: Record<Side, number>,\n parentBox: WebCaptureBox | undefined\n): WebCaptureDesignElement | null {\n const box = element.box\n if (\n element.tagName !== 'input' ||\n !Object.hasOwn(GLYPH_INPUT_TYPES, element.attrs.type) ||\n !box ||\n box.width <= 0 ||\n box.height <= 0\n ) {\n return null\n }\n const side = Math.min(box.width, box.height)\n if (box.width - side < 1) return null\n const style = converted.computedStyle\n // The wrapper takes the placement, so the square must not be positioned or margined itself.\n const absolute = isAbsolute(style)\n style.width = px(side)\n style.height = px(side)\n style['box-sizing'] = 'border-box'\n delete style.position\n delete style.left\n delete style.top\n delete style.right\n delete style.bottom\n const wrapper: Record<string, string> = {\n display: 'flex',\n 'justify-content': 'center',\n 'align-items': 'center',\n width: px(box.width),\n height: px(box.height),\n 'box-sizing': 'border-box'\n }\n const alignSelf = ownValue(style, 'align-self')\n if (alignSelf !== undefined) {\n wrapper['align-self'] = alignSelf\n delete style['align-self']\n }\n const wrapped: WebCaptureDesignElement = {\n type: 'element',\n tagName: 'div',\n attrs: {},\n computedStyle: wrapper,\n children: [converted]\n }\n if (absolute) {\n wrapper.position = element.computedStyle.position === 'fixed' ? 'fixed' : 'absolute'\n for (const key of ['left', 'top']) {\n const value = ownValue(element.computedStyle, key)\n if (value !== undefined) wrapper[key] = value\n }\n placeAbsolute(wrapper, margins, box, parentBox)\n return wrapped\n }\n return SIDES.some((side) => margins[side] > 0) ? marginBox(wrapped, margins) : wrapped\n}\n\n/** What a box records of its size and border, which a word box drawn as a run of text drops. */\nconst WORD_BOX_PROPERTIES = [\n 'display',\n 'width',\n 'height',\n 'min-width',\n 'max-width',\n 'min-height',\n 'max-height',\n 'box-sizing',\n ...SIDES.flatMap((side) => ['style', 'width', 'color'].map((part) => `border-${side}-${part}`))\n]\n\n/** Properties that make a box draw something besides its text, or change where its text sits. */\nconst DRAWN_BOX_PROPERTIES = [\n 'background-color',\n 'background-image',\n 'box-shadow',\n 'opacity',\n 'overflow',\n ...SIDES.map((side) => `padding-${side}` as const)\n]\n\n/**\n * An inline-block that holds one line of text and draws nothing else, as pages that fade words\n * in box each word. It reads as a run of the text around it, not a box: kept as a box, every word\n * becomes a layer of its own and wraps at its own width.\n */\nfunction isWordBox(element: WebCaptureElement, style: Record<string, string>): boolean {\n if (style.display !== 'inline-block' || !INLINE_TEXT_TAGS.has(element.tagName)) return false\n if (!element.children.every((child) => child.type === 'text')) return false\n if (DRAWN_BOX_PROPERTIES.some((property) => ownValue(style, property) !== undefined)) return false\n if (SIDES.some((side) => pixels(style[`margin-${side}`]) !== 0)) return false\n if (SIDES.some((side) => pixels(style[`border-${side}-width`]) > 0)) return false\n const lineHeight = pixels(style['line-height']) || pixels(style['font-size']) * 1.5\n return element.box !== undefined && element.box.height < lineHeight * 1.5\n}\n\nfunction convertElement(\n element: WebCaptureElement,\n parentBox?: WebCaptureBox\n): WebCaptureDesignElement {\n const { displayed, children } = layoutOf(element)\n if (isWordBox(element, displayed)) {\n return {\n type: 'element',\n tagName: element.tagName,\n attrs: { ...element.attrs },\n computedStyle: omit(displayed, [...WORD_BOX_PROPERTIES, ...MARGINS]),\n children\n }\n }\n const inline = isInline(displayed)\n const split = splitMargins(displayed)\n const { margins } = split\n const style =\n displayed.display === 'inline' && INLINE_TEXT_TAGS.has(element.tagName)\n ? omit(split.style, ['display'])\n : split.style\n const converted: WebCaptureDesignElement = {\n type: 'element',\n tagName: element.tagName,\n attrs: { ...element.attrs },\n computedStyle: style,\n children\n }\n const glyph = glyphBox(element, converted, margins, parentBox)\n if (glyph) return glyph\n if (isAbsolute(style)) {\n placeAbsolute(style, margins, element.box, parentBox)\n return converted\n }\n const spaced = SIDES.some((side) => margins[side] > 0)\n return spaced && !inline ? marginBox(converted, margins) : converted\n}\n\n/**\n * The capture as the styled DOM layers are built from. The root keeps the size it had on the\n * page and drops its own position and margins, so it lands where a paste puts it.\n */\nexport function webCaptureDesignDocument(capture: WebCapture): WebCaptureDesignDocument {\n const { root } = capture\n const { displayed, children } = layoutOf(root)\n const style = omit(splitMargins(displayed).style, ['position', ...SIDES])\n // The box a capture records is the border box, padding and borders included.\n if (root.box) {\n style.width = px(root.box.width)\n style.height = px(root.box.height)\n style['box-sizing'] = 'border-box'\n }\n return {\n type: 'document',\n children: [\n {\n type: 'element',\n tagName: root.tagName,\n attrs: { ...root.attrs },\n computedStyle: style,\n children\n }\n ]\n }\n}\n","import { escapeAttribute, escapeText } from 'entities'\n\nimport {\n webCaptureDesignDocument,\n type WebCaptureDesignElement,\n type WebCaptureDesignNode\n} from './design-document'\nimport type { WebCapture } from './format'\nimport { ownValue } from './record'\n\nconst VOID_TAGS = new Set(['area', 'br', 'col', 'hr', 'img', 'input', 'source', 'wbr'])\n\n/** Tags whose start ends an open `<p>` when HTML is parsed, which would lift them out of it. */\nconst CLOSES_PARAGRAPH = new Set([\n 'address',\n 'article',\n 'aside',\n 'blockquote',\n 'details',\n 'div',\n 'dl',\n 'fieldset',\n 'figcaption',\n 'figure',\n 'footer',\n 'form',\n 'h1',\n 'h2',\n 'h3',\n 'h4',\n 'h5',\n 'h6',\n 'header',\n 'hgroup',\n 'hr',\n 'main',\n 'menu',\n 'nav',\n 'ol',\n 'p',\n 'pre',\n 'section',\n 'table',\n 'ul'\n])\n\n/**\n * The tag an element is written with. A script can put a block inside a `<p>`, as the capture's\n * own spacers around a margined box do, but parsing would end the paragraph there; a `<div>`\n * holds it in place, and the element's styles say how it lays out either way.\n */\nfunction writtenTag(element: WebCaptureDesignElement): string {\n const holdsBlock = element.children.some(\n (child) => child.type === 'element' && CLOSES_PARAGRAPH.has(child.tagName)\n )\n return element.tagName === 'p' && holdsBlock ? 'div' : element.tagName\n}\n\nexport interface WebCaptureHTMLOptions {\n /** Keep inlined images; without them an image keeps only its size and description. */\n images?: boolean\n}\n\nfunction styleAttribute(style: Record<string, string>): string {\n return Object.entries(style)\n .map(([property, value]) => `${property}: ${value}`)\n .join('; ')\n}\n\nfunction attributes(element: WebCaptureDesignElement, options: WebCaptureHTMLOptions): string {\n const attrs: Record<string, string> = { ...element.attrs }\n if (options.images === false && ownValue(attrs, 'src')?.startsWith('data:')) delete attrs.src\n // A captured field holds the text it showed; an `<input>` holds it as its value.\n if (element.tagName === 'input') {\n const text = element.children.map((child) => (child.type === 'text' ? child.text : '')).join('')\n if (text) attrs.value = text\n }\n const style = styleAttribute(element.computedStyle)\n if (style) attrs.style = style\n return Object.entries(attrs)\n .map(([name, value]) => ` ${name}=\"${escapeAttribute(value)}\"`)\n .join('')\n}\n\nfunction serialize(node: WebCaptureDesignNode, options: WebCaptureHTMLOptions): string {\n if (node.type === 'text') return escapeText(node.text)\n const tag = writtenTag(node)\n const open = `<${tag}${attributes(node, options)}>`\n if (VOID_TAGS.has(tag)) return open\n const children = node.children.map((child) => serialize(child, options)).join('')\n return `${open}${children}</${tag}>`\n}\n\n/**\n * The capture as static HTML whose elements carry their styles inline, for applications that\n * read clipboard HTML but not the capture itself, and for importing it as HTML. It is the styled\n * DOM a paste builds layers from, so the HTML importer reads the capture as the paste does.\n */\nexport function webCaptureToHTML(capture: WebCapture, options: WebCaptureHTMLOptions = {}): string {\n return webCaptureDesignDocument(capture)\n .children.map((node) => serialize(node, options))\n .join('')\n}\n","/** The capture format identifier that clipboard payloads and files carry. */\nexport const WEB_CAPTURE_FORMAT = 'pairdraw/web-capture'\n\n/** The capture format version this package writes and reads. */\nexport const WEB_CAPTURE_VERSION = 1\n\n/** Elements one capture holds at most; a capturer stops descending once it reaches this. */\nexport const MAX_CAPTURE_ELEMENTS = 20_000\n\n/** How deep a capture nests; deeper elements are left out, as browsers rarely draw them. */\nexport const MAX_CAPTURE_DEPTH = 256\n\n/** Bytes one inlined image may take; a larger image stays a link the importer records. */\nexport const MAX_CAPTURE_IMAGE_BYTES = 8 * 1024 * 1024\n\n/** Bytes all inlined images of a capture take together. */\nexport const MAX_CAPTURE_IMAGES_BYTES = 48 * 1024 * 1024\n\n/** Characters of serialized capture JSON a reader accepts, images included. */\nexport const MAX_CAPTURE_JSON_LENGTH = 96 * 1024 * 1024\n\n/** Characters of plain web HTML a paste styles; a larger fragment is refused. */\nexport const MAX_WEB_HTML_LENGTH = 8 * 1024 * 1024\n","import * as v from 'valibot'\n\nimport { MAX_CAPTURE_JSON_LENGTH, WEB_CAPTURE_FORMAT, WEB_CAPTURE_VERSION } from './limits'\nimport type { WebCaptureElement, WebCaptureNode } from './types'\n\nconst finiteSchema = v.pipe(v.number(), v.finite())\nconst sizeSchema = v.pipe(v.number(), v.finite(), v.minValue(0))\nconst shortStringSchema = v.pipe(v.string(), v.maxLength(4096))\n\nconst webCaptureBoxSchema = v.object({\n x: finiteSchema,\n y: finiteSchema,\n width: sizeSchema,\n height: sizeSchema\n})\n\nconst webCaptureTextSchema = v.object({\n type: v.literal('text'),\n text: v.pipe(v.string(), v.maxLength(1_000_000))\n})\n\n/** HTML and SVG tag names, lowercase as a capturer writes them. */\nconst tagNameSchema = v.pipe(v.string(), v.regex(/^[a-z][a-z0-9-]{0,63}$/))\n/** Attribute names; which of them an import keeps is decided when a capture is read. */\nconst attributeNameSchema = v.pipe(v.string(), v.regex(/^[a-z][a-z0-9:_-]{0,63}$/))\n/** Attribute values hold inlined images as data URLs, so they may be large. */\nconst attributeValueSchema = v.pipe(v.string(), v.maxLength(MAX_CAPTURE_JSON_LENGTH))\nconst propertyNameSchema = v.pipe(v.string(), v.regex(/^-?[a-z][a-z-]{0,63}$/))\n\nconst webCaptureElementSchema: v.GenericSchema<unknown, WebCaptureElement> = v.object({\n type: v.literal('element'),\n tagName: tagNameSchema,\n attrs: v.record(attributeNameSchema, attributeValueSchema),\n computedStyle: v.record(propertyNameSchema, shortStringSchema),\n box: v.optional(webCaptureBoxSchema),\n children: v.array(v.lazy(() => webCaptureNodeSchema))\n})\n\nconst webCaptureNodeSchema: v.GenericSchema<unknown, WebCaptureNode> = v.union([\n webCaptureTextSchema,\n webCaptureElementSchema\n])\n\nexport const webCaptureFontSchema = v.object({\n family: shortStringSchema,\n weight: shortStringSchema,\n style: shortStringSchema\n})\n\nexport const webCaptureViewportSchema = v.object({\n width: sizeSchema,\n height: sizeSchema,\n devicePixelRatio: v.pipe(v.number(), v.finite(), v.minValue(0))\n})\n\nconst webCaptureSourceSchema = v.object({\n url: v.optional(shortStringSchema),\n title: v.optional(shortStringSchema)\n})\n\n/** A page or element captured with the styles the browser computed for it. */\nexport const webCaptureSchema = v.object({\n format: v.literal(WEB_CAPTURE_FORMAT),\n version: v.literal(WEB_CAPTURE_VERSION),\n /** Whether a whole page or one element of it was captured. */\n scope: v.picklist(['page', 'element']),\n source: webCaptureSourceSchema,\n /** When the capture was made, as an ISO 8601 timestamp. */\n capturedAt: shortStringSchema,\n viewport: webCaptureViewportSchema,\n root: webCaptureElementSchema,\n fonts: v.array(webCaptureFontSchema),\n /** Whether the capturer stopped at its element limit, leaving later content out. */\n truncated: v.boolean()\n})\n","import { ownValue } from './record'\n\n/**\n * The computed properties a capture keeps for each element: those `@pairdraw/dom-css` builds\n * layers from, plus margins, which a capture turns into spacing when it is imported.\n */\nexport const CAPTURED_STYLE_PROPERTIES = [\n 'align-items',\n 'align-self',\n 'aspect-ratio',\n 'background-color',\n 'background-clip',\n 'background-image',\n 'background-origin',\n 'background-position',\n 'background-repeat',\n 'background-size',\n 'border-bottom-color',\n 'border-bottom-left-radius',\n 'border-bottom-right-radius',\n 'border-bottom-style',\n 'border-bottom-width',\n 'border-left-color',\n 'border-left-style',\n 'border-left-width',\n 'border-right-color',\n 'border-right-style',\n 'border-right-width',\n 'border-top-color',\n 'border-top-left-radius',\n 'border-top-right-radius',\n 'border-top-style',\n 'border-top-width',\n 'bottom',\n 'box-shadow',\n 'box-sizing',\n 'color',\n 'column-gap',\n 'display',\n 'flex-direction',\n 'flex-wrap',\n 'font-family',\n 'font-size',\n 'font-style',\n 'font-weight',\n 'gap',\n 'height',\n 'isolation',\n 'justify-content',\n 'left',\n 'letter-spacing',\n 'line-height',\n 'margin-bottom',\n 'margin-left',\n 'margin-right',\n 'margin-top',\n 'max-height',\n 'max-width',\n 'min-height',\n 'min-width',\n 'object-fit',\n 'opacity',\n 'order',\n 'overflow',\n 'padding-bottom',\n 'padding-left',\n 'padding-right',\n 'padding-top',\n 'position',\n 'right',\n 'row-gap',\n 'text-align',\n 'text-decoration-color',\n 'text-decoration-line',\n 'text-decoration-style',\n 'text-decoration-thickness',\n 'text-indent',\n 'text-shadow',\n 'text-transform',\n 'text-underline-offset',\n 'top',\n 'white-space',\n 'width',\n 'z-index'\n] as const\n\nexport type CapturedStyleProperty = (typeof CAPTURED_STYLE_PROPERTIES)[number]\n\nconst CAPTURED = new Set<string>(CAPTURED_STYLE_PROPERTIES)\n\n/** Whether a capture keeps this property; others are dropped when a capture is read. */\nexport function isCapturedStyleProperty(property: string): property is CapturedStyleProperty {\n return CAPTURED.has(property)\n}\n\nconst SIDES = ['top', 'right', 'bottom', 'left'] as const\n\n/**\n * Values the importer reads exactly as it reads a missing property, so leaving them out only\n * makes the capture smaller. Inherited text properties are always kept: a nested run reads\n * a missing one from its parent, which differs from the value the page computed.\n */\nconst IMPLIED_VALUES: Partial<Record<CapturedStyleProperty, readonly string[]>> = {\n 'align-items': ['normal'],\n 'align-self': ['auto'],\n 'aspect-ratio': ['auto'],\n 'background-clip': ['border-box'],\n 'background-color': ['rgba(0, 0, 0, 0)', 'transparent'],\n 'background-image': ['none'],\n 'background-origin': ['padding-box'],\n 'background-position': ['0% 0%'],\n 'background-repeat': ['repeat'],\n 'background-size': ['auto'],\n 'box-shadow': ['none'],\n 'column-gap': ['normal'],\n 'flex-direction': ['row'],\n 'flex-wrap': ['nowrap'],\n gap: ['normal'],\n isolation: ['auto'],\n 'z-index': ['auto'],\n height: ['auto'],\n 'justify-content': ['normal'],\n 'max-height': ['none'],\n 'max-width': ['none'],\n 'min-height': ['auto', '0px'],\n 'min-width': ['auto', '0px'],\n 'object-fit': ['fill'],\n opacity: ['1'],\n order: ['0'],\n overflow: ['visible'],\n 'row-gap': ['normal'],\n 'text-indent': ['0px'],\n width: ['auto']\n}\n\nconst ZERO_LENGTH_PROPERTIES = [\n 'border-bottom-left-radius',\n 'border-bottom-right-radius',\n 'border-top-left-radius',\n 'border-top-right-radius',\n ...SIDES.map((side) => `padding-${side}` as const),\n ...SIDES.map((side) => `margin-${side}` as const)\n]\n\nconst TEXT_DECORATION_DETAILS = [\n 'text-decoration-color',\n 'text-decoration-style',\n 'text-decoration-thickness',\n 'text-underline-offset'\n]\n\n/**\n * The style without values that change nothing on import: defaults, borders without a style,\n * offsets of boxes in normal flow, and decoration details of undecorated text.\n */\nexport function withoutImpliedValues(style: Record<string, string>): Record<string, string> {\n const dropped = new Set<string>()\n for (const [property, values] of Object.entries(IMPLIED_VALUES)) {\n if (values.includes(ownValue(style, property) ?? '')) dropped.add(property)\n }\n for (const property of ZERO_LENGTH_PROPERTIES) {\n if (style[property] === '0px') dropped.add(property)\n }\n for (const side of SIDES) {\n const borderStyle = ownValue(style, `border-${side}-style`)\n if (borderStyle !== undefined && borderStyle !== 'none' && borderStyle !== 'hidden') continue\n for (const part of ['style', 'width', 'color']) dropped.add(`border-${side}-${part}`)\n }\n // Sticky boxes sit in normal flow until the page scrolls, which a still capture never does.\n const position = ownValue(style, 'position')\n const inFlow = position === undefined || position === 'static' || position === 'sticky'\n if (inFlow) dropped.add('position')\n for (const side of SIDES) {\n if (inFlow || style[side] === 'auto') dropped.add(side)\n }\n const decoration = ownValue(style, 'text-decoration-line')\n if (decoration === undefined || decoration === 'none') {\n for (const property of TEXT_DECORATION_DETAILS) dropped.add(property)\n }\n return Object.fromEntries(Object.entries(style).filter(([property]) => !dropped.has(property)))\n}\n","const LINK_PROTOCOLS = new Set(['http:', 'https:', 'mailto:'])\nconst IMAGE_PROTOCOLS = new Set(['http:', 'https:'])\n/** Raster images the canvas decodes; SVG is rasterized by the capturer instead. */\nconst DATA_IMAGE =\n /^data:image\\/(?:png|jpeg|gif|webp|avif|bmp|x-icon|vnd\\.microsoft\\.icon);base64,/i\n\nfunction resolve(value: string, base: string | undefined): URL | null {\n try {\n return new URL(value.trim(), base)\n } catch {\n return null\n }\n}\n\n/** A link a layer may keep: http, https, or mailto, resolved against the page; never script. */\nexport function safeLinkURL(value: string, base?: string): string | null {\n const url = resolve(value, base)\n return url && LINK_PROTOCOLS.has(url.protocol) ? url.href : null\n}\n\n/** An image source a layer may keep: an inlined raster image, or an http(s) address. */\nexport function safeImageSource(value: string, base?: string): string | null {\n const trimmed = value.trim()\n if (DATA_IMAGE.test(trimmed)) return trimmed\n const url = resolve(trimmed, base)\n return url && IMAGE_PROTOCOLS.has(url.protocol) ? url.href : null\n}\n","import * as v from 'valibot'\n\nimport type { WebCapture, WebCaptureReadResult } from './format'\nimport {\n MAX_CAPTURE_DEPTH,\n MAX_CAPTURE_ELEMENTS,\n MAX_CAPTURE_JSON_LENGTH,\n WEB_CAPTURE_FORMAT,\n WEB_CAPTURE_VERSION\n} from './limits'\nimport { webCaptureSchema } from './schema'\nimport { isCapturedStyleProperty } from './styles'\nimport type { WebCaptureElement, WebCaptureNode } from './types'\nimport { safeImageSource, safeLinkURL } from './urls'\n\n/** Read first, so a capture from a newer capturer is told apart from a damaged one. */\nconst captureHeaderSchema = v.looseObject({\n format: v.literal(WEB_CAPTURE_FORMAT),\n version: v.number()\n})\n\n/** Attributes a layer can use: names, links, images, control kinds, and accessible labels. */\nconst KEPT_ATTRIBUTES = new Set([\n 'id',\n 'class',\n 'href',\n 'src',\n 'alt',\n 'title',\n 'type',\n 'role',\n 'aria-label',\n 'lang',\n 'dir'\n])\n\n/** Elements that never draw, whatever a capture claims. */\nconst DROPPED_TAGS = new Set([\n 'script',\n 'style',\n 'link',\n 'meta',\n 'head',\n 'title',\n 'template',\n 'noscript',\n 'iframe',\n 'frame',\n 'object',\n 'embed',\n 'base'\n])\n\n/**\n * JSON nesting a capture within `MAX_CAPTURE_DEPTH` takes: an object and a `children` array per\n * element, the capture around the root, and the records of the deepest element, with room to\n * spare. Deeper values are refused before validation, whose recursion they could overflow.\n */\nconst MAX_JSON_NESTING = 2 * MAX_CAPTURE_DEPTH + 16\n\n/** Whether a value nests deeper than `limit`, walked without recursion; a cycle counts as deep. */\nfunction nestsDeeperThan(value: unknown, limit: number): boolean {\n const pending: { value: unknown; depth: number }[] = [{ value, depth: 0 }]\n for (let next = pending.pop(); next; next = pending.pop()) {\n if (typeof next.value !== 'object' || next.value === null) continue\n if (next.depth >= limit) return true\n const depth = next.depth + 1\n for (const child of Object.values(next.value)) pending.push({ value: child, depth })\n }\n return false\n}\n\ninterface Budget {\n elements: number\n truncated: boolean\n}\n\nfunction keptAttributes(\n attrs: Record<string, string>,\n base: string | undefined\n): Record<string, string> {\n const kept: Record<string, string> = {}\n for (const [name, value] of Object.entries(attrs)) {\n if (!KEPT_ATTRIBUTES.has(name)) continue\n if (name === 'href') {\n const href = safeLinkURL(value, base)\n if (href) kept.href = href\n } else if (name === 'src') {\n const src = safeImageSource(value, base)\n if (src) kept.src = src\n } else {\n kept[name] = value\n }\n }\n return kept\n}\n\n/** The `url(...)` sources of a value, with the spans they occupy. */\nconst BACKGROUND_URL = /url\\(\\s*(['\"]?)(.*?)\\1\\s*\\)/g\n\n/**\n * A `background-image` list with every `url(...)` source limited to what an image layer may\n * keep; a layer whose source is unsafe is dropped, and a list left empty paints nothing.\n * Gradient layers carry no address and pass through as written.\n */\nfunction keptBackgroundImage(value: string, base: string | undefined): string | null {\n const layers: string[] = []\n let cursor = 0\n let dropped = false\n for (const match of value.matchAll(BACKGROUND_URL)) {\n const source = safeImageSource(match[2], base)\n if (source) layers.push(value.slice(cursor, match.index) + `url(\"${source}\")`)\n else dropped = true\n cursor = match.index + match[0].length\n }\n if (cursor === 0 && !dropped) return value\n layers.push(value.slice(cursor))\n // Split at top-level commas only: a gradient's own commas stay inside its parentheses.\n const kept: string[] = []\n let depth = 0\n let current = ''\n for (const character of layers.join('')) {\n if (character === '(') depth++\n else if (character === ')') depth--\n if (character === ',' && depth === 0) {\n kept.push(current)\n current = ''\n continue\n }\n current += character\n }\n kept.push(current)\n const painted = kept\n .map((layer) => layer.trim())\n .filter((layer) => layer.length > 0 && layer !== 'none')\n return painted.length > 0 ? painted.join(', ') : null\n}\n\nfunction keptStyle(\n style: Record<string, string>,\n base: string | undefined\n): Record<string, string> {\n const kept: Record<string, string> = {}\n for (const [property, value] of Object.entries(style)) {\n if (!isCapturedStyleProperty(property)) continue\n if (property === 'background-image') {\n const image = keptBackgroundImage(value, base)\n if (image) kept[property] = image\n continue\n }\n kept[property] = value\n }\n return kept\n}\n\nfunction normalizeElement(\n element: WebCaptureElement,\n base: string | undefined,\n depth: number,\n budget: Budget\n): WebCaptureElement {\n const children: WebCaptureNode[] = []\n for (const child of element.children) {\n if (child.type === 'text') {\n children.push(child)\n continue\n }\n if (DROPPED_TAGS.has(child.tagName)) continue\n if (depth + 1 > MAX_CAPTURE_DEPTH || budget.elements >= MAX_CAPTURE_ELEMENTS) {\n budget.truncated = true\n continue\n }\n budget.elements++\n children.push(normalizeElement(child, base, depth + 1, budget))\n }\n return {\n type: 'element',\n tagName: element.tagName,\n attrs: keptAttributes(element.attrs, base),\n ...(element.box ? { box: element.box } : {}),\n computedStyle: keptStyle(element.computedStyle, base),\n children\n }\n}\n\n/**\n * A capture as an import may use it: only the attributes and properties layers read, links\n * limited to http, https, and mailto, images limited to raster data URLs and http(s) addresses,\n * and at most `MAX_CAPTURE_ELEMENTS` elements. Captures come from any page, so every reader\n * goes through this.\n */\nexport function normalizeWebCapture(capture: WebCapture): WebCapture {\n const budget: Budget = { elements: 1, truncated: false }\n const base = capture.source.url\n const root = normalizeElement(capture.root, base, 0, budget)\n return { ...capture, root, truncated: capture.truncated || budget.truncated }\n}\n\n/** Reads a capture that is already a value, such as one a capturer handed over. */\nexport function readWebCapture(value: unknown): WebCaptureReadResult {\n if (nestsDeeperThan(value, MAX_JSON_NESTING)) return { ok: false, error: 'invalid' }\n const header = v.safeParse(captureHeaderSchema, value)\n if (!header.success) return { ok: false, error: 'invalid' }\n if (header.output.version !== WEB_CAPTURE_VERSION) {\n return { ok: false, error: 'unsupported-version' }\n }\n const parsed = v.safeParse(webCaptureSchema, value)\n if (!parsed.success) return { ok: false, error: 'invalid' }\n return { ok: true, capture: normalizeWebCapture(parsed.output) }\n}\n\n/** Reads a capture serialized as JSON, as files and clipboard payloads hold it. */\nexport function parseWebCapture(text: string): WebCaptureReadResult {\n if (text.length > MAX_CAPTURE_JSON_LENGTH) return { ok: false, error: 'too-large' }\n const json = v.safeParse(v.pipe(v.string(), v.parseJson()), text)\n if (!json.success) return { ok: false, error: 'invalid' }\n return readWebCapture(json.output)\n}\n","import { compact } from 'es-toolkit'\nimport { Inflate, deflateSync, strToU8 } from 'fflate'\nimport { fromUint8Array, isValid, toUint8Array } from 'js-base64'\n\nimport type { WebCapture, WebCaptureReadResult } from './format'\nimport { webCaptureToHTML } from './html'\nimport { MAX_CAPTURE_JSON_LENGTH } from './limits'\nimport { normalizeWebCapture, parseWebCapture } from './parse'\n\n/**\n * Clipboard HTML carries a capture between these markers, as Base64 of the DEFLATE-compressed\n * JSON, the way Figma and Pairdraw carry their layers in an HTML comment.\n */\nexport const WEB_CAPTURE_CLIPBOARD_START = '<!--(pairdraw-web-capture)'\nexport const WEB_CAPTURE_CLIPBOARD_END = '(/pairdraw-web-capture)-->'\n\n/** Compressed bytes inflated per step, so an oversized payload stops early. */\nconst INFLATE_STEP = 16 * 1024\n\nexport interface WebCaptureClipboardPayload {\n /** The capture in markers, followed by its content as styled HTML for other applications. */\n html: string\n /** The page's title and address, for applications that only read text. */\n text: string\n}\n\n/** What the clipboard holds after copying a capture: the capture itself and a readable copy. */\nexport function encodeWebCaptureClipboard(captured: WebCapture): WebCaptureClipboardPayload {\n const capture = normalizeWebCapture(captured)\n const compressed = deflateSync(strToU8(JSON.stringify(capture)), { level: 6 })\n const marker = `${WEB_CAPTURE_CLIPBOARD_START}${fromUint8Array(compressed)}${WEB_CAPTURE_CLIPBOARD_END}`\n const html = `<meta charset=\"utf-8\">${marker}${webCaptureToHTML(capture, { images: false })}`\n const text = compact([capture.source.title, capture.source.url]).join('\\n')\n return { html, text }\n}\n\nfunction markedPayload(html: string): string | null {\n const start = html.indexOf(WEB_CAPTURE_CLIPBOARD_START)\n if (start === -1) return null\n const from = start + WEB_CAPTURE_CLIPBOARD_START.length\n const end = html.indexOf(WEB_CAPTURE_CLIPBOARD_END, from)\n return end === -1 ? null : html.slice(from, end)\n}\n\n/** Whether clipboard HTML holds a complete capture marker. */\nexport function hasWebCaptureClipboardMarker(html: string): boolean {\n return markedPayload(html) !== null\n}\n\n/** Inflates at most `MAX_CAPTURE_JSON_LENGTH` bytes of text. */\nfunction inflateText(bytes: Uint8Array): { text: string } | 'invalid' | 'too-large' {\n const decoder = new TextDecoder()\n // An object, since the inflate callback changes it where control flow analysis cannot see.\n const state = { text: '', length: 0, overflow: false }\n const inflate = new Inflate((chunk) => {\n state.length += chunk.length\n if (state.length > MAX_CAPTURE_JSON_LENGTH) state.overflow = true\n else state.text += decoder.decode(chunk, { stream: true })\n })\n try {\n for (let offset = 0; offset < bytes.length; offset += INFLATE_STEP) {\n if (state.overflow) break\n const end = offset + INFLATE_STEP\n inflate.push(bytes.subarray(offset, end), end >= bytes.length)\n }\n } catch {\n return 'invalid'\n }\n return state.overflow ? 'too-large' : { text: state.text + decoder.decode() }\n}\n\n/**\n * The capture clipboard HTML holds, or null when it holds none. Clipboard HTML is writable by\n * any page, so the payload is size-limited, validated, and normalized before it is returned.\n */\nexport function readWebCaptureClipboard(html: string): WebCaptureReadResult | null {\n const payload = markedPayload(html)\n if (payload === null) return null\n const encoded = payload.trim()\n if (encoded.length > MAX_CAPTURE_JSON_LENGTH) return { ok: false, error: 'too-large' }\n if (!isValid(encoded)) return { ok: false, error: 'invalid' }\n const inflated = inflateText(toUint8Array(encoded))\n if (typeof inflated === 'string') return { ok: false, error: inflated }\n return parseWebCapture(inflated.text)\n}\n","import { encodeWebCaptureClipboard, type WebCaptureClipboardPayload } from '#web-capture/clipboard'\nimport type { WebCapture } from '#web-capture/format'\n\n/** The part of the asynchronous clipboard a capture write uses. */\nexport type CaptureClipboard = Pick<Clipboard, 'write'>\n\nexport interface WriteCaptureClipboardOptions {\n /** The clipboard to write; the page's own by default. */\n clipboard?: CaptureClipboard\n /** Builds a clipboard item; the page's `ClipboardItem` by default. */\n createItem?: (items: Record<string, Promise<Blob>>) => ClipboardItem\n}\n\n/** Thrown when the page has no asynchronous clipboard, which only secure pages offer. */\nexport class CaptureClipboardUnavailableError extends Error {\n constructor() {\n super('Copying a capture needs a page served over HTTPS')\n this.name = 'CaptureClipboardUnavailableError'\n }\n}\n\nfunction isPayload(\n value: WebCapture | WebCaptureClipboardPayload\n): value is WebCaptureClipboardPayload {\n return 'html' in value && 'text' in value\n}\n\n/**\n * Copies a capture so it pastes into a Pairdraw canvas, as HTML for Pairdraw and other\n * applications and as the page's title and address for plain text. Pass the capture's promise\n * straight from the click that asked for it: the write starts inside that click and resolves\n * its data later, so a capture that takes a while still counts as the click's own.\n */\nexport async function writeWebCaptureClipboard(\n capture:\n | WebCapture\n | WebCaptureClipboardPayload\n | Promise<WebCapture | WebCaptureClipboardPayload>,\n options: WriteCaptureClipboardOptions = {}\n): Promise<void> {\n const clipboard =\n options.clipboard ?? (typeof navigator === 'undefined' ? undefined : navigator.clipboard)\n const createItem =\n options.createItem ??\n (typeof ClipboardItem === 'undefined'\n ? undefined\n : (items: Record<string, Promise<Blob>>) => new ClipboardItem(items))\n // `navigator.clipboard` is missing outside secure contexts.\n if (!clipboard || !createItem) throw new CaptureClipboardUnavailableError()\n const payload = Promise.resolve(capture).then((value) =>\n isPayload(value) ? value : encodeWebCaptureClipboard(value)\n )\n await clipboard.write([\n createItem({\n 'text/html': payload.then((value) => new Blob([value.html], { type: 'text/html' })),\n 'text/plain': payload.then((value) => new Blob([value.text], { type: 'text/plain' }))\n })\n ])\n}\n"],"mappings":";;;;;;;;;;AAIA,SAAgB,SACd,QACA,KACoB;CACpB,OAAO,OAAO,OAAO,QAAQ,GAAG,IAAI,OAAO,OAAO,KAAA;AACpD;;;ACiBA,MAAMA,UAAQ;CAAC;CAAO;CAAS;CAAU;AAAM;;;;;AAO/C,MAAM,oBAA4D;CAChE,MAAM;EAAE,SAAS;EAAQ,kBAAkB;EAAO,aAAa;CAAO;CACtE,eAAe;EAAE,SAAS;EAAe,kBAAkB;EAAO,aAAa;CAAO;CACtF,aAAa;EAAE,SAAS;EAAQ,kBAAkB;EAAO,aAAa;CAAS;CAC/E,OAAO,EAAE,SAAS,QAAQ;CAC1B,gBAAgB,EAAE,SAAS,eAAe;CAC1C,mBAAmB,EAAE,SAAS,QAAQ;CACtC,sBAAsB,EAAE,SAAS,QAAQ;CACzC,sBAAsB,EAAE,SAAS,QAAQ;CACzC,cAAc,EAAE,SAAS,QAAQ;CACjC,iBAAiB,EAAE,SAAS,QAAQ;CACpC,aAAa,EAAE,SAAS,QAAQ;CAChC,aAAa,EAAE,SAAS,QAAQ;AAClC;;;;;AAMA,MAAM,mCAAmB,IAAI,IAAI;CAAC;CAAK;CAAK;CAAQ;CAAM;CAAK;CAAS;CAAQ;CAAU;AAAG,CAAC;AAE9F,SAAS,OAAO,OAAmC;CACjD,IAAI,CAAC,OAAO,SAAS,IAAI,GAAG,OAAO;CACnC,MAAM,SAAS,OAAO,WAAW,KAAK;CACtC,OAAO,OAAO,SAAS,MAAM,IAAI,SAAS;AAC5C;AAEA,SAAS,GAAG,OAAuB;CACjC,OAAO,GAAG,KAAK,MAAM,QA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@@ -91,7 +91,7 @@ declare function hasWebContent(html: string, options?: Pick<SanitizeWebHTMLOptio
|
|
|
91
91
|
* The computed properties a capture keeps for each element: those `@pairdraw/dom-css` builds
|
|
92
92
|
* layers from, plus margins, which a capture turns into spacing when it is imported.
|
|
93
93
|
*/
|
|
94
|
-
declare const CAPTURED_STYLE_PROPERTIES: readonly ["align-items", "align-self", "aspect-ratio", "background-color", "background-image", "background-position", "background-repeat", "background-size", "border-bottom-color", "border-bottom-left-radius", "border-bottom-right-radius", "border-bottom-style", "border-bottom-width", "border-left-color", "border-left-style", "border-left-width", "border-right-color", "border-right-style", "border-right-width", "border-top-color", "border-top-left-radius", "border-top-right-radius", "border-top-style", "border-top-width", "bottom", "box-shadow", "box-sizing", "color", "column-gap", "display", "flex-direction", "flex-wrap", "font-family", "font-size", "font-style", "font-weight", "gap", "height", "justify-content", "left", "letter-spacing", "line-height", "margin-bottom", "margin-left", "margin-right", "margin-top", "max-height", "max-width", "min-height", "min-width", "object-fit", "opacity", "order", "overflow", "padding-bottom", "padding-left", "padding-right", "padding-top", "position", "right", "row-gap", "text-align", "text-decoration-color", "text-decoration-line", "text-decoration-style", "text-decoration-thickness", "text-indent", "text-shadow", "text-transform", "text-underline-offset", "top", "white-space", "width"];
|
|
94
|
+
declare const CAPTURED_STYLE_PROPERTIES: readonly ["align-items", "align-self", "aspect-ratio", "background-color", "background-clip", "background-image", "background-origin", "background-position", "background-repeat", "background-size", "border-bottom-color", "border-bottom-left-radius", "border-bottom-right-radius", "border-bottom-style", "border-bottom-width", "border-left-color", "border-left-style", "border-left-width", "border-right-color", "border-right-style", "border-right-width", "border-top-color", "border-top-left-radius", "border-top-right-radius", "border-top-style", "border-top-width", "bottom", "box-shadow", "box-sizing", "color", "column-gap", "display", "flex-direction", "flex-wrap", "font-family", "font-size", "font-style", "font-weight", "gap", "height", "isolation", "justify-content", "left", "letter-spacing", "line-height", "margin-bottom", "margin-left", "margin-right", "margin-top", "max-height", "max-width", "min-height", "min-width", "object-fit", "opacity", "order", "overflow", "padding-bottom", "padding-left", "padding-right", "padding-top", "position", "right", "row-gap", "text-align", "text-decoration-color", "text-decoration-line", "text-decoration-style", "text-decoration-thickness", "text-indent", "text-shadow", "text-transform", "text-underline-offset", "top", "white-space", "width", "z-index"];
|
|
95
95
|
type CapturedStyleProperty = (typeof CAPTURED_STYLE_PROPERTIES)[number];
|
|
96
96
|
/** Whether a capture keeps this property; others are dropped when a capture is read. */
|
|
97
97
|
declare function isCapturedStyleProperty(property: string): property is CapturedStyleProperty;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/design-document.ts","../src/html.ts","../src/limits.ts","../src/parse.ts","../src/sanitize.ts","../src/styles.ts","../src/urls.ts"],"mappings":";;;;;;UAUiB;EACf;EACA;EACA,OAAO;EACP,eAAe;EACf,UAAU;;KAGA,uBAAuB,0BAA0B;;UAG5C;EACf;EACA,UAAU;;;;;;iBAoVI,yBAAyB,SAAS,aAAa;;;UCjT9C;;EAEf;;;;;;;iBAsCc,iBAAiB,SAAS,YAAY,UAAS;;;;cCjGlD;;cAGA;;cAGA;;cAGA;;cAGA;;cAGA;;cAGA;;cAGA;;;;;;;;;iBCyKG,oBAAoB,SAAS,aAAa;;iBAQ1C,eAAe,iBAAiB;;iBAahC,gBAAgB,eAAe;;;UCxK9B;;EAEf,SAAS,KAAK;;EAEd;;;;;;;;;;;iBA+Dc,gBAAgB,cAAc,UAAS;;iBAcvC,cAAc,cAAc,UAAS,KAAK;;;;;;;cCvH7C;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/design-document.ts","../src/html.ts","../src/limits.ts","../src/parse.ts","../src/sanitize.ts","../src/styles.ts","../src/urls.ts"],"mappings":";;;;;;UAUiB;EACf;EACA;EACA,OAAO;EACP,eAAe;EACf,UAAU;;KAGA,uBAAuB,0BAA0B;;UAG5C;EACf;EACA,UAAU;;;;;;iBAoVI,yBAAyB,SAAS,aAAa;;;UCjT9C;;EAEf;;;;;;;iBAsCc,iBAAiB,SAAS,YAAY,UAAS;;;;cCjGlD;;cAGA;;cAGA;;cAGA;;cAGA;;cAGA;;cAGA;;cAGA;;;;;;;;;iBCyKG,oBAAoB,SAAS,aAAa;;iBAQ1C,eAAe,iBAAiB;;iBAahC,gBAAgB,eAAe;;;UCxK9B;;EAEf,SAAS,KAAK;;EAEd;;;;;;;;;;;iBA+Dc,gBAAgB,cAAc,UAAS;;iBAcvC,cAAc,cAAc,UAAS,KAAK;;;;;;;cCvH7C;KAgFD,gCAAgC;;iBAK5B,wBAAwB,mBAAmB,YAAY;;;;;iBAgEvD,qBAAqB,OAAO,yBAAyB;;;;iBC5IrD,YAAY,eAAe;;iBAM3B,gBAAgB,eAAe"}
|
package/package.json
CHANGED
package/src/styles.ts
CHANGED
|
@@ -9,7 +9,9 @@ export const CAPTURED_STYLE_PROPERTIES = [
|
|
|
9
9
|
'align-self',
|
|
10
10
|
'aspect-ratio',
|
|
11
11
|
'background-color',
|
|
12
|
+
'background-clip',
|
|
12
13
|
'background-image',
|
|
14
|
+
'background-origin',
|
|
13
15
|
'background-position',
|
|
14
16
|
'background-repeat',
|
|
15
17
|
'background-size',
|
|
@@ -43,6 +45,7 @@ export const CAPTURED_STYLE_PROPERTIES = [
|
|
|
43
45
|
'font-weight',
|
|
44
46
|
'gap',
|
|
45
47
|
'height',
|
|
48
|
+
'isolation',
|
|
46
49
|
'justify-content',
|
|
47
50
|
'left',
|
|
48
51
|
'letter-spacing',
|
|
@@ -77,7 +80,8 @@ export const CAPTURED_STYLE_PROPERTIES = [
|
|
|
77
80
|
'text-underline-offset',
|
|
78
81
|
'top',
|
|
79
82
|
'white-space',
|
|
80
|
-
'width'
|
|
83
|
+
'width',
|
|
84
|
+
'z-index'
|
|
81
85
|
] as const
|
|
82
86
|
|
|
83
87
|
export type CapturedStyleProperty = (typeof CAPTURED_STYLE_PROPERTIES)[number]
|
|
@@ -100,8 +104,10 @@ const IMPLIED_VALUES: Partial<Record<CapturedStyleProperty, readonly string[]>>
|
|
|
100
104
|
'align-items': ['normal'],
|
|
101
105
|
'align-self': ['auto'],
|
|
102
106
|
'aspect-ratio': ['auto'],
|
|
107
|
+
'background-clip': ['border-box'],
|
|
103
108
|
'background-color': ['rgba(0, 0, 0, 0)', 'transparent'],
|
|
104
109
|
'background-image': ['none'],
|
|
110
|
+
'background-origin': ['padding-box'],
|
|
105
111
|
'background-position': ['0% 0%'],
|
|
106
112
|
'background-repeat': ['repeat'],
|
|
107
113
|
'background-size': ['auto'],
|
|
@@ -110,6 +116,8 @@ const IMPLIED_VALUES: Partial<Record<CapturedStyleProperty, readonly string[]>>
|
|
|
110
116
|
'flex-direction': ['row'],
|
|
111
117
|
'flex-wrap': ['nowrap'],
|
|
112
118
|
gap: ['normal'],
|
|
119
|
+
isolation: ['auto'],
|
|
120
|
+
'z-index': ['auto'],
|
|
113
121
|
height: ['auto'],
|
|
114
122
|
'justify-content': ['normal'],
|
|
115
123
|
'max-height': ['none'],
|