@shbernal/ts-pptx 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +238 -0
- package/dist/autopage-tmfjRzL4.js +420 -0
- package/dist/autopage-tmfjRzL4.js.map +1 -0
- package/dist/browser.d.ts +23 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +103 -0
- package/dist/browser.js.map +1 -0
- package/dist/diagnostics-DYQC7xLV.js +0 -0
- package/dist/diagnostics-DYQC7xLV.js.map +1 -0
- package/dist/diagnostics-DzY9Tyfm.d.ts +693 -0
- package/dist/diagnostics-DzY9Tyfm.d.ts.map +1 -0
- package/dist/embedded-fonts-MaynAHa9.js +94 -0
- package/dist/embedded-fonts-MaynAHa9.js.map +1 -0
- package/dist/enums-D3aF4QGb.d.ts +452 -0
- package/dist/enums-D3aF4QGb.d.ts.map +1 -0
- package/dist/errors-DGE9zh3U.js +93 -0
- package/dist/errors-DGE9zh3U.js.map +1 -0
- package/dist/errors-DRLpOpgQ.d.ts +160 -0
- package/dist/errors-DRLpOpgQ.d.ts.map +1 -0
- package/dist/fit-CbxyHN69.js +0 -0
- package/dist/fit-CbxyHN69.js.map +1 -0
- package/dist/html-dom-wVa3TiG7.js +666 -0
- package/dist/html-dom-wVa3TiG7.js.map +1 -0
- package/dist/html.d.ts +26 -0
- package/dist/html.d.ts.map +1 -0
- package/dist/html.js +60 -0
- package/dist/html.js.map +1 -0
- package/dist/image-size-C5Z1sKof.js +252 -0
- package/dist/image-size-C5Z1sKof.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +75 -0
- package/dist/index.js.map +1 -0
- package/dist/inspect.d.ts +173 -0
- package/dist/inspect.d.ts.map +1 -0
- package/dist/inspect.js +285 -0
- package/dist/inspect.js.map +1 -0
- package/dist/math.d.ts +37 -0
- package/dist/math.d.ts.map +1 -0
- package/dist/math.js +106 -0
- package/dist/math.js.map +1 -0
- package/dist/measure.d.ts +223 -0
- package/dist/measure.d.ts.map +1 -0
- package/dist/measure.js +3 -0
- package/dist/node.d.ts +12 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +60 -0
- package/dist/node.js.map +1 -0
- package/dist/package-CaOLXSNi.d.ts +193 -0
- package/dist/package-CaOLXSNi.d.ts.map +1 -0
- package/dist/pres-5x1bjCzk.d.ts +202 -0
- package/dist/pres-5x1bjCzk.d.ts.map +1 -0
- package/dist/presentation-B0JWdTN1.js +4286 -0
- package/dist/presentation-B0JWdTN1.js.map +1 -0
- package/dist/presentation-RGOiun5P.d.ts +3249 -0
- package/dist/presentation-RGOiun5P.d.ts.map +1 -0
- package/dist/presentation-types-BVw0EknS.d.ts +538 -0
- package/dist/presentation-types-BVw0EknS.d.ts.map +1 -0
- package/dist/read.d.ts +73 -0
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +4 -0
- package/dist/script.d.ts +553 -0
- package/dist/script.d.ts.map +1 -0
- package/dist/script.js +0 -0
- package/dist/script.js.map +1 -0
- package/dist/shapes-BZU8UTW2.js +5365 -0
- package/dist/shapes-BZU8UTW2.js.map +1 -0
- package/dist/slide-B6mDaM-P.d.ts +3396 -0
- package/dist/slide-B6mDaM-P.d.ts.map +1 -0
- package/dist/text-WRUbOy2r.js +11238 -0
- package/dist/text-WRUbOy2r.js.map +1 -0
- package/dist/units-B-JUKwCS.js +144 -0
- package/dist/units-B-JUKwCS.js.map +1 -0
- package/dist/units-internal-7JcMfYti.js +723 -0
- package/dist/units-internal-7JcMfYti.js.map +1 -0
- package/dist/zip.d.ts +68 -0
- package/dist/zip.d.ts.map +1 -0
- package/dist/zip.js +163 -0
- package/dist/zip.js.map +1 -0
- package/package.json +214 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html-dom-wVa3TiG7.js","names":[],"sources":["../src/gen/table/html-dom.ts"],"sourcesContent":["/**\n * ts-pptx: HTML-table → slides (browser DOM path)\n *\n * The browser-only tableToSlides() flow: reproduce a rendered HTML table as a\n * PowerPoint table across as many slides as needed. Out of active scope (see\n * AGENTS.md) — the DOM-independent parts are factored into pure helpers\n * (`resolveHtmlColWidth`, `htmlBorderToProps`) that are unit-tested directly.\n *\n * This module is imported only by the browser entry (`browser.ts`, which adds the\n * `tableToSlides` method), so it bundles into the browser/standalone chunks — never\n * the Node build or the shared core chunk. That is why the live-DOM code below needs\n * no `v8 ignore` fence: the whole file is coverage-excluded via the `dist/browser*.js`\n * chunk globs (see vitest.config.ts), while the pure helpers stay unit-tested from src.\n */\n\nimport { SlideObjectType } from '../../enums.js'\nimport type {\n\tAddSlideProps,\n\tBorderProps,\n\tPresLayout,\n\tTableCell,\n\tTableToSlidesDocument,\n\tTableToSlidesElement,\n\tTableToSlidesProps,\n\tTableCellProps,\n} from '../../types/index.js'\nimport type { Slide } from '../../types/slide.js'\nimport type { SlideLayoutInternal } from '../../types/internal.js'\nimport { inch2Emu } from '../../units-internal.js'\nimport { warn } from '../../diagnostics.js'\nimport { EMU_PER_INCH } from '../../units.js'\nimport { getSlidesForTableRows } from './autopage.js'\nimport { InvalidOptionError } from '../../errors.js'\n\ntype MarginTuple = [number, number, number, number]\ntype BorderTuple = [BorderProps, BorderProps, BorderProps, BorderProps]\n/**\n * What `tableToSlides` needs a presentation to be: somewhere to put slides, and a layout to\n * size them against. Structural on purpose — stating the two members rather than naming the\n * class is what lets the free function on `ts-pptx/html` take any presentation instance\n * (Node, browser, or standalone) without the entry importing one.\n */\nexport type TableToSlidesHost = {\n\taddSlide: (options?: AddSlideProps) => Slide\n\tpresLayout: PresLayout\n}\n\n/**\n * The whole DOM surface `genTableToSlides` needs: the table element, and a way to read a\n * cell's computed style.\n *\n * Resolving this once up front is what decouples the flow from `window`/`document`. Given the\n * element itself, both halves come from the element's own `ownerDocument`/`defaultView`, so no\n * global is read at all — which is what lets the same implementation run outside a browser.\n */\ntype DomContext = {\n\ttable: Element\n\tgetComputedStyle: (el: Element) => CSSStyleDeclaration\n}\n\n/**\n * Stand-in for `getComputedStyle` on a document that has no view — a document produced by\n * parsing rather than by a browsing context has a `null` `defaultView` and therefore no\n * cascade to compute against. Every property reads as `''`, which every consumer below\n * already treats as \"not set\", so styling degrades to defaults instead of throwing.\n */\nconst NO_COMPUTED_STYLE = {\n\tgetPropertyValue: () => '',\n} as unknown as CSSStyleDeclaration\n\n/**\n * Bind a style reader to the document's own view, falling back to {@link NO_COMPUTED_STYLE}.\n * @param {Document | null} doc - the table's owner document\n * @returns {(el: Element) => CSSStyleDeclaration} computed-style reader\n */\nfunction resolveStyleReader(doc: Document | null): (el: Element) => CSSStyleDeclaration {\n\tconst view = doc?.defaultView\n\treturn view ? view.getComputedStyle.bind(view) : () => NO_COMPUTED_STYLE\n}\n\n/**\n * Resolve the table element and its style reader from whatever the caller passed.\n *\n * An **element** needs no ambient DOM: the document and its view are reached through\n * `ownerDocument`/`defaultView`. A **string id** does need one, taken from `options.document`\n * when supplied and otherwise from `globalThis.document`; with neither, the error names both\n * remedies rather than surfacing a bare `document is not defined`.\n *\n * This is the one place the public structural element type ({@link TableToSlidesElement},\n * which any DOM satisfies) is narrowed to `lib.dom`'s `Element`, so the rest of the flow can\n * be written against ordinary DOM types. The cast is safe in the only sense that matters here:\n * everything downstream reads standard members and tolerates them being absent — that is what\n * makes the conversion portable in the first place.\n * @param {TableToSlidesElement | string} target - the table element, or the id of one\n * @param {TableToSlidesProps} options - generation options (may carry an explicit `document`)\n * @returns {DomContext} resolved DOM context\n */\nfunction resolveDomContext(target: TableToSlidesElement | string, options: TableToSlidesProps): DomContext {\n\tconst asElement = (element: TableToSlidesElement): Element => element as unknown as Element\n\n\tif (typeof target !== 'string') {\n\t\tconst table = asElement(target)\n\t\treturn { table, getComputedStyle: resolveStyleReader(table.ownerDocument) }\n\t}\n\n\tconst doc = options.document ?? (globalThis as { document?: TableToSlidesDocument }).document\n\tif (!doc) {\n\t\tthrow new InvalidOptionError(\n\t\t\t'html/no-document',\n\t\t\t'tableToSlides: no DOM available to resolve the table id \"' +\n\t\t\t\ttarget +\n\t\t\t\t'\" — pass the <table> element itself, or supply a document via `options.document`.'\n\t\t)\n\t}\n\tconst found = doc.getElementById(target)\n\tif (!found)\n\t\tthrow new InvalidOptionError('html/table-not-found', 'tableToSlides: Table ID \"' + target + '\" does not exist!')\n\tconst table = asElement(found)\n\treturn { table, getComputedStyle: resolveStyleReader(table.ownerDocument) }\n}\n\n// ===== DOM-table helpers (browser path) =====\n// DOM-independent helpers factored out of the browser-only tableToSlides() flow\n// so they can be unit-tested without a rendered page (see AGENTS.md scope note).\n\n/**\n * Convert one 0-255 RGB component to its two-digit hex form.\n *\n * Lives here rather than beside the other color code in `gen/drawingml/color.ts` because\n * `getComputedStyle` colors are the only thing in the package that arrives as RGB\n * components — nothing else in the library calls this.\n * @param {number} c - component color\n * @returns {string} hex string\n */\nfunction componentToHex(c: number): string {\n\tconst hex = c.toString(16)\n\treturn hex.length === 1 ? '0' + hex : hex\n}\n\n/**\n * Converts RGB colors from css selectors to Hex for Presentation colors\n * @param {number} r - red value\n * @param {number} g - green value\n * @param {number} b - blue value\n * @returns {string} XML string\n */\nfunction rgbToHex(r: number, g: number, b: number): string {\n\treturn (componentToHex(r) + componentToHex(g) + componentToHex(b)).toUpperCase()\n}\n\n/**\n * Convert a computed CSS border (width string + color string) from `getComputedStyle` into a\n * pptx `BorderProps`.\n *\n * Preserves *fractional* widths: a hairline CSS border such as `0.5px` must not be rounded to\n * `0pt` and silently vanish — the table serializer (`valToPts`) emits fractional points just\n * fine, so there is no reason to integer-round here. A\n * computed width of `0` (or a non-finite value) yields `{ type: 'none' }` so we never emit a\n * zero-width line.\n * @param {string} widthStr - computed `border-<side>-width`, e.g. `\"0.5px\"`\n * @param {string} colorStr - computed `border-<side>-color`, e.g. `\"rgb(102, 102, 102)\"`\n * @returns {BorderProps} border props for the cell side\n */\nexport function htmlBorderToProps(widthStr: string, colorStr: string): BorderProps {\n\tconst pt = Number(String(widthStr).replace('px', ''))\n\tif (!isFinite(pt) || pt <= 0) return { type: 'none' }\n\treturn { width: pt, color: cssColorToHex(colorStr) ?? '000000' }\n}\n\n/**\n * Convert a computed CSS color to a pptx hex color, or report that it has none.\n *\n * A browser normalizes every computed color to `rgb()`/`rgba()`, which is why the flow below\n * originally only parsed that form. Outside a browser there is no normalization step, so a\n * computed color comes back however the stylesheet wrote it — `#ff0000` is what happy-dom\n * returns. Feeding that to the `rgb()` parser produced `Number('#ff0000')` → `NaN` → the\n * literal color string `\"NANNANNAN\"`, an invalid value emitted without complaint.\n *\n * Handles `rgb()`/`rgba()` and `#rgb`/`#rrggbb`. Everything else — a named color, a `color()`\n * function, an empty string — returns `undefined` rather than a guess, so the caller can\n * apply its own default instead of emitting nonsense.\n *\n * A fully transparent color (`alpha === 0`) also returns `undefined`: it states the absence of\n * a color, and pptx has no way to say \"transparent\" in a solid fill.\n * @param {string} value - computed CSS color, e.g. `\"rgb(255, 0, 0)\"` or `\"#ff0000\"`\n * @returns {string | undefined} six-digit uppercase hex, or `undefined` when unparseable\n */\nexport function cssColorToHex(value: string): string | undefined {\n\tconst raw = String(value ?? '').trim()\n\n\tconst rgbMatch = /^rgba?\\(([^)]*)\\)$/i.exec(raw)\n\tif (rgbMatch) {\n\t\tconst parts = (rgbMatch[1] ?? '').split(/[,/\\s]+/).filter((part) => part.length > 0)\n\t\tif (parts.length < 3) return undefined\n\t\tconst channels = parts.slice(0, 3).map((part) => Number(part.replace('%', '')))\n\t\tif (channels.some((channel) => !isFinite(channel))) return undefined\n\t\tif (parts.length > 3 && Number(parts[3]) === 0) return undefined\n\t\t// Clamp and round before hex conversion: a browser always computes whole 0-255\n\t\t// channels, but nothing guarantees another DOM does, and `(255.5).toString(16)`\n\t\t// is `\"ff.8\"` — a malformed color rather than a wrong one.\n\t\tconst [r = 0, g = 0, b = 0] = channels.map((channel) => Math.max(0, Math.min(255, Math.round(channel))))\n\t\treturn rgbToHex(r, g, b)\n\t}\n\n\tconst hexMatch = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(raw)\n\tif (hexMatch) {\n\t\tconst digits = hexMatch[1] ?? ''\n\t\tconst full =\n\t\t\tdigits.length === 3\n\t\t\t\t? digits\n\t\t\t\t\t\t.split('')\n\t\t\t\t\t\t.map((digit) => digit + digit)\n\t\t\t\t\t\t.join('')\n\t\t\t\t: digits\n\t\treturn full.toUpperCase()\n\t}\n\n\treturn undefined\n}\n\n/**\n * Resolve a single HTML-table column width for `tableToSlides`.\n *\n * Precedence: an explicit `data-pptx-width` wins outright; otherwise the proportional width\n * derived from the live table is used, raised to `data-pptx-min-width` when that floor is larger.\n *\n * Hidden tables report `offsetWidth` 0 for every cell, which makes `calcWidth` non-finite (a 0/0\n * proportional calc). Fall back to `0` there so an explicit `data-pptx-width` / `data-pptx-min-width`\n * override still drives the column instead of emitting a `NaN` width.\n * @param {number} calcWidth - proportional width derived from `offsetWidth` (may be `NaN` for hidden tables)\n * @param {number} setWidth - `data-pptx-width` override (`0`/`NaN` when absent or invalid)\n * @param {number} minWidth - `data-pptx-min-width` floor (`0`/`NaN` when absent or invalid)\n * @returns {number} resolved column width\n */\nexport function resolveHtmlColWidth(calcWidth: number, setWidth: number, minWidth: number): number {\n\tconst safeCalc = isFinite(calcWidth) ? calcWidth : 0\n\tif (isFinite(setWidth) && setWidth > 0) return setWidth\n\treturn isFinite(minWidth) && minWidth > safeCalc ? minWidth : safeCalc\n}\n\n/** A CSS value that is a bare number, or a number with a `px`/`%` unit. Nothing else parses. */\nconst CSS_LENGTH = /^\\s*(-?(?:\\d+\\.?\\d*|\\.\\d+))\\s*(px|%)?\\s*$/i\n\n/**\n * Parse a single computed CSS length in **px** to its numeric magnitude.\n *\n * A bare number is read as px (computed styles do not emit one, but an inline `style` read\n * back by a non-browser DOM can). Everything else — `''`, `auto`, `3em`, and deliberately\n * `30%` — is `NaN`: a percentage is meaningful only relative to something, so it cannot be\n * turned into an absolute length here. (Percentages *are* usable as a proportional column\n * basis; that is {@link parseCssWidthBasis}'s job, not this one's.) Callers decide what a\n * `NaN` means for them.\n * @param {string} value - computed CSS value, e.g. `\"1.5px\"`\n * @returns {number} magnitude in px, or `NaN` when the value is not an absolute px length\n */\nexport function parseCssPx(value: string): number {\n\tconst match = CSS_LENGTH.exec(String(value ?? ''))\n\tif (!match || match[2] === '%') return NaN\n\treturn Number(match[1])\n}\n\n/**\n * Parse a whole row of computed CSS widths into a column basis, or reject the set.\n *\n * The result is only ever used *proportionally* (each column's share of the total), so the\n * unit does not have to be absolute — it only has to be the same for every column. Hence:\n *\n * - all `px` (or bare numbers) → their magnitudes\n * - all `%` → their magnitudes; `[25%, 25%, 50%]` is a perfectly good 1:1:2 basis\n * - anything else, or a **mix** of units, or a single unparseable entry (`auto`, `''`,\n * `3em`) → `[]`, meaning \"no usable basis\"\n *\n * Rejecting the whole set on one bad entry is deliberate: a partial basis would silently\n * give the unparseable columns zero width, which is worse than falling back to an equal\n * split. Negative magnitudes reject for the same reason.\n * @param {readonly string[]} values - computed `width` per column, in column order\n * @returns {number[]} per-column basis, or `[]` when the set is not usable\n */\nexport function parseCssWidthBasis(values: readonly string[]): number[] {\n\tconst basis: number[] = []\n\tlet unit = ''\n\tfor (const value of values) {\n\t\tconst match = CSS_LENGTH.exec(String(value ?? ''))\n\t\tif (!match) return []\n\t\tconst magnitude = Number(match[1])\n\t\tif (!isFinite(magnitude) || magnitude < 0) return []\n\t\tconst valueUnit = (match[2] ?? 'px').toLowerCase()\n\t\tif (!unit) unit = valueUnit\n\t\telse if (unit !== valueUnit) return []\n\t\tbasis.push(magnitude)\n\t}\n\treturn basis\n}\n\n/**\n * Choose which vector the proportional column math runs on, degrading gracefully.\n *\n * `offsetWidth` is the ideal basis — it is the width the table actually rendered at — but it\n * requires a layout engine, and reports `0` for every cell both in a hidden table and on any\n * DOM outside a browser. So:\n *\n * 1. **measured** (`offsetWidth`) when it carries any width at all — the browser path, unchanged\n * 2. **CSS widths** when the stylesheet states them (see {@link parseCssWidthBasis})\n * 3. **equal split** otherwise — a basis of all-ones, which the existing proportional math\n * turns into equal columns for free\n *\n * Only the basis changes; `data-pptx-width` / `data-pptx-min-width` overrides still apply\n * downstream via {@link resolveHtmlColWidth} and still win outright.\n * @param {readonly number[]} measured - per-column `offsetWidth`\n * @param {readonly number[]} cssWidths - per-column CSS width basis (`[]` when unusable)\n * @returns {number[]} the basis vector to run the proportional calc on\n */\nexport function pickColWidthBasis(measured: readonly number[], cssWidths: readonly number[]): number[] {\n\tconst sum = (arr: readonly number[]): number => arr.reduce((acc, n) => acc + (isFinite(n) ? n : 0), 0)\n\tif (sum(measured) > 0) return [...measured]\n\tif (cssWidths.length === measured.length && sum(cssWidths) > 0) return [...cssWidths]\n\treturn measured.map(() => 1)\n}\n\n/** One cell's span attributes, as far as the grid walk cares. */\nexport type GridCellSpans = { colspan?: number; rowspan?: number }\n\n/**\n * Read a `colspan`/`rowspan` as the number of grid tracks it covers.\n *\n * Lenient on purpose: `0`, a negative, a fraction, an unparseable attribute and an absent one all\n * mean `1`. A bad span attribute should cost its own cell nothing and the rest of the grid nothing\n * — the alternative, propagating a `NaN` or a negative into the column walk, shifts every\n * subsequent column.\n * @param {unknown} value - the raw attribute value\n * @returns {number} tracks covered, at least 1\n */\nfunction gridSpan(value: unknown): number {\n\tconst num = Math.floor(Number(value))\n\treturn isFinite(num) && num > 1 ? num : 1\n}\n\n/**\n * Measure the column grid a set of table rows actually occupies.\n *\n * An HTML table is not a rectangle of cells — a row states only the cells it *starts*, so its\n * length says nothing about how many grid columns it fills: a `colspan` fills several, and a\n * `rowspan` started higher up fills one without the row mentioning it. The pptx side has no such\n * model: `<a:tblGrid>` declares N columns and every `<a:tr>` must carry N `<a:tc>`. Something has\n * to translate, and that is a walk of the standard HTML table model — cells pack left to right,\n * skipping columns still held by a rowspan above.\n *\n * Returns the grid width and, per row, how many columns that row reaches. The difference between\n * the two is exactly the padding a ragged row needs; the merge cells for `colspan`/`rowspan` are\n * *not* padding — the table emitter synthesizes those itself, so they are counted as filled here.\n *\n * Spans are read through {@link gridSpan}, so a bad attribute cannot shift the whole grid.\n * @param {readonly (readonly GridCellSpans[])[]} rows - per-row cell spans, in emission order\n * @returns {{ columns: number, filled: number[] }} grid width, and columns reached per row\n */\nexport function measureGridColumns(rows: readonly (readonly GridCellSpans[])[]): { columns: number; filled: number[] } {\n\t// carry[c] = how many further rows column c is still held by a rowspan started above.\n\tconst carry: number[] = []\n\tconst filled: number[] = []\n\n\tfor (const row of rows) {\n\t\tlet col = 0\n\t\tfor (const cell of row) {\n\t\t\twhile ((carry[col] ?? 0) > 0) col++\n\t\t\tconst colspan = gridSpan(cell?.colspan)\n\t\t\t// Written now, decremented at the end of this row, so it leaves `rowspan - 1` behind.\n\t\t\tfor (let idx = 0; idx < colspan; idx++) carry[col + idx] = gridSpan(cell?.rowspan)\n\t\t\tcol += colspan\n\t\t}\n\t\t// Trailing columns held from above count too: a row whose last cells are all rowspan\n\t\t// continuations reaches past its own final cell.\n\t\twhile ((carry[col] ?? 0) > 0) col++\n\t\tfilled.push(col)\n\t\tfor (let idx = 0; idx < carry.length; idx++) {\n\t\t\tconst held = carry[idx] ?? 0\n\t\t\tif (held > 0) carry[idx] = held - 1\n\t\t}\n\t}\n\n\treturn { columns: filled.reduce((max, reached) => (reached > max ? reached : max), 0), filled }\n}\n\n/**\n * Widen a column-width basis to cover a grid wider than the row it was derived from.\n *\n * The basis comes from one row — the first with cells — but the grid is as wide as the *widest*\n * row, and those need not agree (a single spanning header over a wider body is the common shape).\n * The columns the source row never described get the average of the ones it did, so they read as\n * ordinary columns rather than as a zero-width sliver; with no usable basis at all they get `1`,\n * which the proportional calc downstream turns into an equal split.\n * @param {readonly number[]} basis - per-column basis derived from the width-source row\n * @param {number} columns - the full grid width\n * @returns {number[]} basis covering every grid column\n */\nexport function extendColBasis(basis: readonly number[], columns: number): number[] {\n\tconst extended = [...basis]\n\tconst total = extended.reduce((acc, width) => acc + (isFinite(width) ? width : 0), 0)\n\tconst share = extended.length > 0 && total > 0 ? total / extended.length : 1\n\twhile (extended.length < columns) extended.push(share)\n\treturn extended\n}\n\n/**\n * The minimum a cell has to look like for {@link readCellText}. Any DOM's element satisfies it;\n * stating it structurally is what lets the fallback walk be unit-tested without a DOM at all.\n */\ntype TextCell = {\n\tinnerText?: string\n\tnodeType?: number\n\tnodeValue?: string | null\n\tnodeName?: string\n\tchildNodes?: ArrayLike<TextCell>\n}\n\n/**\n * Read a cell's text, with `<br>` surviving as a newline.\n *\n * `innerText` is the right answer in a browser — it is the *rendered* text, so it already\n * collapses whitespace, honors `display: none`, and turns `<br>` into `\"\\n\"`. But it is an\n * HTML-spec extra tied to rendering, and outside a browser it is either absent (jsdom does not\n * implement it, so every cell would come out empty) or present but not actually rendered\n * (happy-dom returns `\"ab\"` for `a<br>b`, so every cell would come out on one line).\n *\n * So both are computed and the better one wins: a `childNodes` walk that maps `<br>` to a line\n * break and collapses whitespace per line, and `innerText`. `innerText` is preferred unless it\n * dropped a line break the walk found — the one thing that provably makes it not the rendered\n * text. Neither can know about `text-transform` without a browser.\n * @param {TextCell} cell - the table cell element\n * @returns {string} cell text, `<br>`-separated lines joined by `\"\\n\"`\n */\nexport function readCellText(cell: TextCell): string {\n\t// Accumulate one bucket per line rather than one string with \"\\n\" separators: the source's\n\t// own indentation contains newlines, and only a `<br>` may actually start a new line. A\n\t// separator character could not tell those two apart; separate buckets never have to.\n\tconst lines: string[] = ['']\n\tconst append = (text: string): void => {\n\t\tlines[lines.length - 1] = (lines[lines.length - 1] ?? '') + text\n\t}\n\tconst walk = (node: TextCell): void => {\n\t\tif (node.nodeType === 3) {\n\t\t\tappend(node.nodeValue ?? '')\n\t\t\treturn\n\t\t}\n\t\tif (node.nodeType !== 1) return\n\t\tif ((node.nodeName ?? '').toUpperCase() === 'BR') {\n\t\t\tlines.push('')\n\t\t\treturn\n\t\t}\n\t\tconst children = node.childNodes\n\t\tfor (let idx = 0; idx < (children?.length ?? 0); idx++) {\n\t\t\tconst child = children?.[idx]\n\t\t\tif (child) walk(child)\n\t\t}\n\t}\n\n\t// Walk from the cell's children: the cell itself is an element, and can never be a BR.\n\tconst children = cell.childNodes\n\tfor (let idx = 0; idx < (children?.length ?? 0); idx++) {\n\t\tconst child = children?.[idx]\n\t\tif (child) walk(child)\n\t}\n\tconst walked = lines.map((line) => line.replace(/\\s+/g, ' ').trim()).join('\\n')\n\n\t// Prefer `innerText` — except when the walk found line breaks it dropped. A DOM that does\n\t// not render can still expose an `innerText` property that is really just `textContent`\n\t// (happy-dom returns `\"ab\"` for `a<br>b`), and that one is not the rendered text this\n\t// wants: it has silently lost the cell's line structure. Where it kept the breaks, it is\n\t// the better answer, because it also knows about `display:none` and `text-transform`.\n\tconst rendered = cell.innerText\n\tif (typeof rendered !== 'string') return walked\n\treturn walked.includes('\\n') && !rendered.includes('\\n') ? walked : rendered\n}\n\n// ===== Live-DOM tableToSlides() flow =====\n// Browser-only entry (reads a rendered table via getComputedStyle/offsetWidth);\n// out of active scope — see AGENTS.md. Internally signposted by `// STEP 1..5`.\n\n/**\n * Resolve `options.masterTitle` to the slide layout it names, so the auto-pager can take that\n * master's margins.\n *\n * The layout registry is a presentation *internal* — it is not on {@link TableToSlidesHost},\n * and the public `slideLayouts` getter deliberately hides the `_name` this matches on. Rather\n * than widen either, read it defensively: a host that has no registry simply resolves no\n * master, which is what a caller passing a bare `{ addSlide, presLayout }` object should get.\n * The alternative — dropping the lookup on the free-function path — would make `masterTitle`\n * silently do nothing there, which is a trap.\n * @param {TableToSlidesHost} pptx - the presentation the slides are being added to\n * @param {string} masterTitle - the `title` passed to `defineSlideMaster`\n * @returns {SlideLayoutInternal | undefined} the named layout, if this host has one\n */\nfunction resolveMasterSlide(pptx: TableToSlidesHost, masterTitle?: string): SlideLayoutInternal | undefined {\n\tif (!masterTitle) return undefined\n\tconst layouts = (pptx as { _slideLayouts?: SlideLayoutInternal[] })._slideLayouts\n\tif (!Array.isArray(layouts)) return undefined\n\treturn layouts.find((layout) => layout._name === masterTitle)\n}\n\n/** Which of the three logical sections a row belongs to. A section-less row counts as body. */\ntype TablePart = 'thead' | 'tbody' | 'tfoot'\n\n/**\n * A row's cells, via `HTMLTableRowElement.cells`.\n *\n * Read off the structural shape rather than the `lib.dom` type so a DOM that does not implement\n * the collection degrades to \"this row has no cells\" instead of throwing — the same tolerance\n * every other DOM read in this file has.\n * @param {Element} row - a `<tr>`\n * @returns {HTMLTableCellElement[]} the row's cells, in document order\n */\nfunction rowCells(row: Element): HTMLTableCellElement[] {\n\tconst cells = (row as { cells?: ArrayLike<Element> }).cells\n\treturn cells ? (Array.from(cells) as HTMLTableCellElement[]) : []\n}\n\n/**\n * Collect every row of the table, bucketed head → body → foot.\n *\n * `HTMLTableElement.rows` is the right source and a `thead tr`/`tbody tr`/`tfoot tr` query is not,\n * for two reasons the query cannot fix:\n *\n * - **A row need not be in a section.** `<table><tr>…` is valid authored markup, and a table built\n * with `createElement`/`appendChild` has no `<tbody>` at all — the HTML *parser* inserts one, the\n * DOM API does not. Those rows matched none of the three selectors and were silently dropped,\n * which is how a perfectly good table reached `addTable` with zero rows and threw\n * `addTable: Array expected!` (upstream gitbrent/PptxGenJS#1005).\n * - **A descendant query reaches into nested tables.** `tbody tr` matches the rows of a table\n * inside a cell of this one, folding them into the outer table as extra rows.\n *\n * Each row's own parentage settles both questions: it names the section the row belongs to (the\n * head/body/foot split still matters downstream, for repeating header rows on auto-paged slides),\n * and it says whether the row is this table's at all. The ownership check is not redundant with\n * using `rows` — happy-dom's `rows` is itself a descendant walk, so a nested table's rows arrive\n * there too. Checking is what makes the answer the same on every DOM.\n * @param {Element} table - the `<table>` being converted\n * @returns {Array<{ row: Element, part: TablePart }>} rows in emission order\n */\nfunction collectTableRows(table: Element): Array<{ row: Element; part: TablePart }> {\n\tconst head: Array<{ row: Element; part: TablePart }> = []\n\tconst body: Array<{ row: Element; part: TablePart }> = []\n\tconst foot: Array<{ row: Element; part: TablePart }> = []\n\tconst place = (row: Element): void => {\n\t\tconst parent = row.parentElement\n\t\tconst section = (parent?.nodeName ?? '').toUpperCase()\n\t\tconst sectioned = section === 'THEAD' || section === 'TBODY' || section === 'TFOOT'\n\t\tif ((sectioned ? parent?.parentElement : parent) !== table) return\n\t\tif (section === 'THEAD') head.push({ row, part: 'thead' })\n\t\telse if (section === 'TFOOT') foot.push({ row, part: 'tfoot' })\n\t\telse body.push({ row, part: 'tbody' })\n\t}\n\n\tconst rows = (table as { rows?: ArrayLike<Element> }).rows\n\tif (rows) {\n\t\tfor (let idx = 0; idx < rows.length; idx++) {\n\t\t\tconst row = rows[idx]\n\t\t\tif (row) place(row)\n\t\t}\n\t} else {\n\t\t// A DOM without `rows` is not one this library has ever run on, but the section query is\n\t\t// still a truthful fallback for the sectioned tables it can see.\n\t\tfor (const part of ['thead', 'tbody', 'tfoot']) {\n\t\t\ttable.querySelectorAll(`${part} tr`).forEach(place)\n\t\t}\n\t}\n\n\treturn [...head, ...body, ...foot]\n}\n\n/**\n * Reproduces an HTML table as a PowerPoint table - including column widths, style, etc. - creates 1 or more slides as needed\n * @param {TableToSlidesHost} pptx - ts-pptx instance\n * @param {TableToSlidesElement | string} target - the table element, or the HTMLElementID of the table\n * @param {TableToSlidesProps} options - array of options (e.g.: tabsize)\n */\nexport function genTableToSlides(\n\tpptx: TableToSlidesHost,\n\ttarget: TableToSlidesElement | string,\n\toptions: TableToSlidesProps = {}\n): void {\n\tconst opts = options || {}\n\tconst masterSlide = resolveMasterSlide(pptx, opts.masterTitle)\n\topts.slideMargin = opts.slideMargin || opts.slideMargin === 0 ? opts.slideMargin : 0.5\n\tlet emuSlideTabW = opts.w || pptx.presLayout.width\n\tconst arrObjTabHeadRows: TableCell[][] = []\n\tconst arrObjTabBodyRows: TableCell[][] = []\n\tconst arrObjTabFootRows: TableCell[][] = []\n\tconst arrColW: number[] = []\n\tconst arrTabColW: number[] = []\n\tconst arrTabColCssW: string[] = []\n\tlet arrInchMargins: [number, number, number, number] = [0.5, 0.5, 0.5, 0.5] // TRBL-style\n\tlet intTabW = 0\n\n\t// REALITY-CHECK: resolve the table (and its style reader) before anything else — this is\n\t// also where a missing/unresolvable table id fails.\n\tconst ctx = resolveDomContext(target, opts)\n\n\t// STEP 1: Set margins\n\tif (masterSlide?._margin) {\n\t\tif (Array.isArray(masterSlide._margin)) arrInchMargins = masterSlide._margin\n\t\telse if (!isNaN(masterSlide._margin))\n\t\t\tarrInchMargins = [masterSlide._margin, masterSlide._margin, masterSlide._margin, masterSlide._margin]\n\t\topts.slideMargin = arrInchMargins\n\t} else if (opts?.slideMargin) {\n\t\tif (Array.isArray(opts.slideMargin)) arrInchMargins = opts.slideMargin\n\t\telse if (!isNaN(opts.slideMargin))\n\t\t\tarrInchMargins = [opts.slideMargin, opts.slideMargin, opts.slideMargin, opts.slideMargin]\n\t}\n\temuSlideTabW = (opts.w ? inch2Emu(opts.w) : pptx.presLayout.width) - inch2Emu(arrInchMargins[1] + arrInchMargins[3])\n\n\tif (opts.verbose) {\n\t\tconsole.log('[[VERBOSE MODE]]')\n\t\tconsole.log('|-- `tableToSlides` ----------------------------------------------------|')\n\t\tconsole.log(`| tableProps.h .................................... = ${opts.h}`)\n\t\tconsole.log(`| tableProps.w .................................... = ${opts.w}`)\n\t\tconsole.log(\n\t\t\t`| pptx.presLayout.width ........................... = ${(pptx.presLayout.width / EMU_PER_INCH).toFixed(1)}`\n\t\t)\n\t\tconsole.log(\n\t\t\t`| pptx.presLayout.height .......................... = ${(pptx.presLayout.height / EMU_PER_INCH).toFixed(1)}`\n\t\t)\n\t\tconsole.log(`| emuSlideTabW .................................... = ${(emuSlideTabW / EMU_PER_INCH).toFixed(1)}`)\n\t}\n\n\t// STEP 2: Resolve the rows and the grid they occupy, then take the column widths from the\n\t// first row that has any cells (others may have colspans, who cares, we only need col widths from 1).\n\t// Two bases are collected in the same pass: the rendered `offsetWidth` (what a browser\n\t// reports) and the computed CSS `width` (the only width statement available where nothing\n\t// laid the table out). `pickColWidthBasis` decides which one STEP 3 runs on.\n\tconst domRows = collectTableRows(ctx.table)\n\tconst { columns: intColCnt, filled: arrRowFilled } = measureGridColumns(\n\t\tdomRows.map(({ row }) =>\n\t\t\trowCells(row).map((cell) => ({\n\t\t\t\tcolspan: Number(cell.getAttribute('colspan')),\n\t\t\t\trowspan: Number(cell.getAttribute('rowspan')),\n\t\t\t}))\n\t\t)\n\t)\n\t// A table with no rows — or only empty ones — has nothing to convert. Say so here: the failure\n\t// used to surface far downstream as `Reduce of empty array with no initial value` out of the\n\t// auto-pager, or as `addTable: Array expected!`, neither of which names the table.\n\tconst srcRow = domRows.find(({ row }) => rowCells(row).length > 0)\n\tif (!srcRow) {\n\t\tthrow new InvalidOptionError(\n\t\t\t'html/table-has-no-cells',\n\t\t\t'tableToSlides: the table has no cells to convert - expected at least one <tr> with a <td>/<th>.'\n\t\t)\n\t}\n\n\t// Per grid column, the width-source cell it came from and that cell's colspan. Built here so\n\t// STEP 3 can read a column's overrides off the *right* cell: with a colspan in play, column\n\t// index and cell index part ways, and indexing the row by column silently applied one cell's\n\t// `data-pptx-width` to the next column along (upstream gitbrent/PptxGenJS#1244).\n\tconst arrColSrc: Array<{ cell: HTMLTableCellElement; span: number }> = []\n\tconst arrCellSpans: number[] = []\n\trowCells(srcRow.row).forEach((cell) => {\n\t\tconst offsetW = Number(cell.offsetWidth)\n\t\tconst measured = isFinite(offsetW) ? offsetW : 0\n\t\tarrTabColCssW.push(ctx.getComputedStyle(cell).getPropertyValue('width'))\n\t\t// Guesstimate (divide evenly) col widths across a spanned cell.\n\t\t// NOTE: both j$query and vanilla selectors return {0} when table is not visible)\n\t\tconst span = gridSpan(cell.getAttribute('colspan'))\n\t\tarrCellSpans.push(span)\n\t\tfor (let idxc = 0; idxc < span; idxc++) {\n\t\t\tarrTabColW.push(Math.round(measured / span))\n\t\t\tarrColSrc.push({ cell, span })\n\t\t}\n\t})\n\n\t// The CSS basis is parsed per *cell* (unit uniformity is a property of the row as authored),\n\t// then expanded across each cell's colspan the same way `offsetWidth` is.\n\tconst parsedCellCssW = parseCssWidthBasis(arrTabColCssW)\n\tconst arrCssColW: number[] = []\n\tif (parsedCellCssW.length === arrCellSpans.length) {\n\t\tparsedCellCssW.forEach((cssW, idxC) => {\n\t\t\tconst span = arrCellSpans[idxC] ?? 1\n\t\t\tfor (let idxc = 0; idxc < span; idxc++) arrCssColW.push(cssW / span)\n\t\t})\n\t}\n\n\t// The width-source row can be narrower than the grid (one spanning header over a wider body),\n\t// so widen the basis to the full grid before the proportional calc — that way the calc still\n\t// divides the slide across *every* column instead of overflowing it by the missing ones.\n\tconst arrBasisColW = extendColBasis(pickColWidthBasis(arrTabColW, arrCssColW), intColCnt)\n\tarrBasisColW.forEach((colW) => {\n\t\tintTabW += colW\n\t})\n\n\t// STEP 3: Calc/Set column widths by using same column width percent from HTML table\n\tarrBasisColW.forEach((colW, idxW) => {\n\t\tconst intCalcWidth = Number(((Number(emuSlideTabW) * ((colW / intTabW) * 100)) / 100 / EMU_PER_INCH).toFixed(2))\n\t\t// A `data-pptx-width` on a spanning cell states that *cell's* width, so it divides across\n\t\t// the columns the cell covers — exactly as its `offsetWidth` and its CSS width do above.\n\t\t// A column past the source row's reach has no cell to be overridden by.\n\t\tconst src = arrColSrc[idxW]\n\t\tconst intSetWidth = src ? Number(src.cell.getAttribute('data-pptx-width')) / src.span : 0\n\t\tconst intMinWidth = src ? Number(src.cell.getAttribute('data-pptx-min-width')) / src.span : 0\n\t\tarrColW.push(resolveHtmlColWidth(intCalcWidth, intSetWidth, intMinWidth))\n\t})\n\tif (opts.verbose) {\n\t\tconsole.log(`| arrColW ......................................... = [${arrColW.join(', ')}]`)\n\t}\n\n\t// STEP 4: Iterate over each table element and create data arrays (text and opts)\n\t// NOTE: We create 3 arrays instead of one so we can loop over body then show header/footer rows on first and last page\n\tdomRows.forEach(({ row, part }, idxRow) => {\n\t\tconst arrObjTabCells: TableCell[] = []\n\t\trowCells(row).forEach((cell) => {\n\t\t\t// The computed style is read a dozen times below; resolve it once per cell.\n\t\t\tconst style = ctx.getComputedStyle(cell)\n\n\t\t\t// A: Get text/bkgd colors\n\t\t\t// NOTE: an unparseable or fully transparent background is the default for an\n\t\t\t// unstyled table; pptx has no \"transparent\" solid fill, so use white instead.\n\t\t\tconst textColor = cssColorToHex(style.getPropertyValue('color')) ?? '000000'\n\t\t\tconst fillColor = cssColorToHex(style.getPropertyValue('background-color')) ?? 'FFFFFF'\n\n\t\t\t// B: Create option object\n\t\t\tconst cellOpts: TableCellProps = {\n\t\t\t\tbold: !!(\n\t\t\t\t\tstyle.getPropertyValue('font-weight') === 'bold' || Number(style.getPropertyValue('font-weight')) >= 500\n\t\t\t\t),\n\t\t\t\tcolor: textColor,\n\t\t\t\tfill: { color: fillColor },\n\t\t\t\tfontSize: Number(style.getPropertyValue('font-size').replace(/[a-z]/gi, '')),\n\t\t\t}\n\t\t\tconst fontFace = ((style.getPropertyValue('font-family') || '').split(',')[0] ?? '')\n\t\t\t\t.replace(/\"/g, '')\n\t\t\t\t.replace('inherit', '')\n\t\t\t\t.replace('initial', '')\n\t\t\t// Read through the same `gridSpan` the grid walk used, so what is emitted and what\n\t\t\t// was measured cannot disagree: a `colspan=\"-2\"` counted as one column above must\n\t\t\t// not reach the table definition as `-2` and corrupt its own column count.\n\t\t\tconst colspan = gridSpan(cell.getAttribute('colspan'))\n\t\t\tconst rowspan = gridSpan(cell.getAttribute('rowspan'))\n\t\t\tif (fontFace) cellOpts.fontFace = fontFace\n\t\t\tif (colspan > 1) cellOpts.colspan = colspan\n\t\t\tif (rowspan > 1) cellOpts.rowspan = rowspan\n\n\t\t\tif (['left', 'center', 'right', 'start', 'end'].includes(style.getPropertyValue('text-align'))) {\n\t\t\t\tconst align = style.getPropertyValue('text-align').replace('start', 'left').replace('end', 'right')\n\t\t\t\tcellOpts.align =\n\t\t\t\t\talign === 'center' ? 'center' : align === 'left' ? 'left' : align === 'right' ? 'right' : undefined\n\t\t\t}\n\t\t\tif (['top', 'middle', 'bottom'].includes(style.getPropertyValue('vertical-align'))) {\n\t\t\t\tconst valign = style.getPropertyValue('vertical-align')\n\t\t\t\tcellOpts.valign =\n\t\t\t\t\tvalign === 'top' ? 'top' : valign === 'middle' ? 'middle' : valign === 'bottom' ? 'bottom' : undefined\n\t\t\t}\n\n\t\t\t// C: Add padding [margin] (if any)\n\t\t\t// NOTE: Margins translate: px->pt 1:1 (e.g.: a 20px padded cell looks the same in PPTX as 20pt Text Inset/Padding)\n\t\t\tif (style.getPropertyValue('padding-left')) {\n\t\t\t\tconst cellMargin: MarginTuple = [0, 0, 0, 0]\n\t\t\t\tconst sidesPad = ['padding-top', 'padding-right', 'padding-bottom', 'padding-left']\n\t\t\t\tsidesPad.forEach((val, idxs) => {\n\t\t\t\t\t// Anything that is not an absolute px length (a `%` padding, a keyword) has no\n\t\t\t\t\t// meaning as a point inset, so it insets by nothing rather than by its digits.\n\t\t\t\t\tconst pad = parseCssPx(style.getPropertyValue(val))\n\t\t\t\t\tcellMargin[idxs] = isFinite(pad) ? Math.round(pad) : 0\n\t\t\t\t})\n\t\t\t\tcellOpts.margin = cellMargin\n\t\t\t}\n\n\t\t\t// D: Add border (if any)\n\t\t\tif (\n\t\t\t\tstyle.getPropertyValue('border-top-width') ||\n\t\t\t\tstyle.getPropertyValue('border-right-width') ||\n\t\t\t\tstyle.getPropertyValue('border-bottom-width') ||\n\t\t\t\tstyle.getPropertyValue('border-left-width')\n\t\t\t) {\n\t\t\t\tconst cellBorder: BorderTuple = [{ type: 'none' }, { type: 'none' }, { type: 'none' }, { type: 'none' }]\n\t\t\t\tconst sidesBor = ['top', 'right', 'bottom', 'left']\n\t\t\t\tsidesBor.forEach((val, idxb) => {\n\t\t\t\t\tcellBorder[idxb] = htmlBorderToProps(\n\t\t\t\t\t\tstyle.getPropertyValue('border-' + val + '-width'),\n\t\t\t\t\t\tstyle.getPropertyValue('border-' + val + '-color')\n\t\t\t\t\t)\n\t\t\t\t})\n\t\t\t\tcellOpts.border = cellBorder\n\t\t\t}\n\n\t\t\t// LAST: Add cell\n\t\t\tarrObjTabCells.push({\n\t\t\t\t_type: SlideObjectType.tablecell,\n\t\t\t\ttext: readCellText(cell), // <br> must survive as \"\\n\", so linebreak etc. work later!\n\t\t\t\toptions: cellOpts,\n\t\t\t})\n\t\t})\n\n\t\t// Normalize a ragged row up to the grid width. HTML tolerates a short row and just leaves\n\t\t// the tail of the grid empty; pptx does not — `<a:tblGrid>` declares the column count and a\n\t\t// row with fewer `<a:tc>` is a malformed table PowerPoint has to repair. The missing cells\n\t\t// are blank rather than a copy of a neighbour: the source table never stated them, so there\n\t\t// is nothing to carry over. Columns held by a `rowspan` from above are already counted as\n\t\t// filled — the table emitter synthesizes those merge cells itself.\n\t\tfor (let idxPad = arrRowFilled[idxRow] ?? 0; idxPad < intColCnt; idxPad++) {\n\t\t\tarrObjTabCells.push({ _type: SlideObjectType.tablecell, text: '', options: {} })\n\t\t}\n\n\t\tif (part === 'thead') arrObjTabHeadRows.push(arrObjTabCells)\n\t\telse if (part === 'tfoot') arrObjTabFootRows.push(arrObjTabCells)\n\t\telse arrObjTabBodyRows.push(arrObjTabCells)\n\t})\n\n\t// STEP 5: Break table into Slides as needed\n\t// Pass head-rows as there is an option to add to each table and the parse func needs this data to fulfill that option\n\topts._arrObjTabHeadRows = arrObjTabHeadRows\n\topts.colW = arrColW\n\tgetSlidesForTableRows(\n\t\t[...arrObjTabHeadRows, ...arrObjTabBodyRows, ...arrObjTabFootRows],\n\t\topts,\n\t\tpptx.presLayout,\n\t\tmasterSlide\n\t).forEach((slide, idxTr) => {\n\t\t// A: Create new Slide\n\t\tconst newSlide = pptx.addSlide({ masterTitle: opts.masterTitle || undefined })\n\n\t\t// B: DESIGN: Reset `y` to startY or margin after first Slide\n\t\tif (idxTr === 0) opts.y = opts.y || arrInchMargins[0]\n\t\tif (idxTr > 0) opts.y = opts.autoPageSlideStartY || arrInchMargins[0]\n\t\tif (opts.verbose)\n\t\t\tconsole.log(\n\t\t\t\t`| opts.autoPageSlideStartY: ${opts.autoPageSlideStartY} / arrInchMargins[0]: ${arrInchMargins[0]} => opts.y = ${opts.y}`\n\t\t\t)\n\n\t\t// C: Add table to Slide\n\t\tnewSlide.addTable(slide.rows, {\n\t\t\tx: opts.x || arrInchMargins[3],\n\t\t\ty: opts.y,\n\t\t\tw: Number(emuSlideTabW) / EMU_PER_INCH,\n\t\t\tcolW: arrColW,\n\t\t\tautoPage: false,\n\t\t})\n\n\t\t// D: Add any additional objects\n\t\tif (opts.addImage) {\n\t\t\topts.addImage.options = opts.addImage.options || {}\n\t\t\tif (!opts.addImage.image || (!opts.addImage.image.path && !opts.addImage.image.data)) {\n\t\t\t\twarn('html/image-missing-source', 'tableToSlides.addImage requires either `path` or `data`')\n\t\t\t} else {\n\t\t\t\tconst imageProps = opts.addImage.image.path\n\t\t\t\t\t? { path: opts.addImage.image.path }\n\t\t\t\t\t: { data: opts.addImage.image.data as string }\n\t\t\t\tnewSlide.addImage({\n\t\t\t\t\t...imageProps,\n\t\t\t\t\tx: opts.addImage.options.x,\n\t\t\t\t\ty: opts.addImage.options.y,\n\t\t\t\t\tw: opts.addImage.options.w,\n\t\t\t\t\th: opts.addImage.options.h,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\tif (opts.addShape) newSlide.addShape(opts.addShape.shapeName, opts.addShape.options || {})\n\t\tif (opts.addTable) newSlide.addTable(opts.addTable.rows, opts.addTable.options || {})\n\t\tif (opts.addText) newSlide.addText(opts.addText.text, opts.addText.options || {})\n\t})\n}\n"],"mappings":";;;;;;;;;;;;AAkEA,MAAM,oBAAoB,EACzB,wBAAwB,GACzB;;;;;;AAOA,SAAS,mBAAmB,KAA4D;CACvF,MAAM,OAAO,KAAK;CAClB,OAAO,OAAO,KAAK,iBAAiB,KAAK,IAAI,UAAU;AACxD;;;;;;;;;;;;;;;;;;AAmBA,SAAS,kBAAkB,QAAuC,SAAyC;CAC1G,MAAM,aAAa,YAA2C;CAE9D,IAAI,OAAO,WAAW,UAAU;EAC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eAAe,GAAG,eAAe,KAAK,GACvH;EAGD,SAAS,SAAS,MAAM,MAAM;GAC7B,GAAG,KAAK,KAAK,eAAe;GAC5B,GAAG,KAAK;GACR,GAAG,OAAO,YAAY,IAAI;GAC1B,MAAM;GACN,UAAU;EACX,CAAC;EAGD,IAAI,KAAK,UAAU;GAClB,KAAK,SAAS,UAAU,KAAK,SAAS,WAAW,CAAC;GAClD,IAAI,CAAC,KAAK,SAAS,SAAU,CAAC,KAAK,SAAS,MAAM,QAAQ,CAAC,KAAK,SAAS,MAAM,MAC9E,KAAK,6BAA6B,yDAAyD;QACrF;IACN,MAAM,aAAa,KAAK,SAAS,MAAM,OACpC,EAAE,MAAM,KAAK,SAAS,MAAM,KAAK,IACjC,EAAE,MAAM,KAAK,SAAS,MAAM,KAAe;IAC9C,SAAS,SAAS;KACjB,GAAG;KACH,GAAG,KAAK,SAAS,QAAQ;KACzB,GAAG,KAAK,SAAS,QAAQ;KACzB,GAAG,KAAK,SAAS,QAAQ;KACzB,GAAG,KAAK,SAAS,QAAQ;IAC1B,CAAC;GACF;EACD;EACA,IAAI,KAAK,UAAU,SAAS,SAAS,KAAK,SAAS,WAAW,KAAK,SAAS,WAAW,CAAC,CAAC;EACzF,IAAI,KAAK,UAAU,SAAS,SAAS,KAAK,SAAS,MAAM,KAAK,SAAS,WAAW,CAAC,CAAC;EACpF,IAAI,KAAK,SAAS,SAAS,QAAQ,KAAK,QAAQ,MAAM,KAAK,QAAQ,WAAW,CAAC,CAAC;CACjF,CAAC;AACF"}
|
package/dist/html.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { D as TableToSlidesDocument, O as TableToSlidesElement, a as Slide, k as TableToSlidesProps, t as AddSlideProps } from "./slide-B6mDaM-P.js";
|
|
2
|
+
import { i as PresLayout } from "./pres-5x1bjCzk.js";
|
|
3
|
+
import { a as TsPptxError, d as InvalidOptionErrorCode, f as MediaErrorCode, h as UnsupportedFeatureErrorCode, i as PackageReadError, l as ErrorCode, m as TsPptxCode, n as InvalidOptionError, o as TsPptxErrorOptions, p as PackageReadErrorCode, r as MediaError, s as UnsupportedFeatureError, t as InternalError, u as InternalErrorCode } from "./errors-DRLpOpgQ.js";
|
|
4
|
+
//#region src/gen/table/html-dom.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* What `tableToSlides` needs a presentation to be: somewhere to put slides, and a layout to
|
|
7
|
+
* size them against. Structural on purpose — stating the two members rather than naming the
|
|
8
|
+
* class is what lets the free function on `ts-pptx/html` take any presentation instance
|
|
9
|
+
* (Node, browser, or standalone) without the entry importing one.
|
|
10
|
+
*/
|
|
11
|
+
type TableToSlidesHost = {
|
|
12
|
+
addSlide: (options?: AddSlideProps) => Slide;
|
|
13
|
+
presLayout: PresLayout;
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/html.d.ts
|
|
17
|
+
/**
|
|
18
|
+
* Reproduce an HTML `<table>` as a PowerPoint table, adding as many slides as its rows need.
|
|
19
|
+
* @param {TableToSlidesHost} pptx - the presentation to add slides to
|
|
20
|
+
* @param {TableToSlidesElement | string} table - the `<table>` element, or its id (see `options.document`)
|
|
21
|
+
* @param {TableToSlidesProps} options - generation options
|
|
22
|
+
*/
|
|
23
|
+
declare function tableToSlides(pptx: TableToSlidesHost, table: TableToSlidesElement | string, options?: TableToSlidesProps): void;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { type ErrorCode, InternalError, type InternalErrorCode, InvalidOptionError, type InvalidOptionErrorCode, MediaError, type MediaErrorCode, PackageReadError, type PackageReadErrorCode, type TableToSlidesDocument, type TableToSlidesElement, type TableToSlidesHost, type TableToSlidesProps, type TsPptxCode, TsPptxError, type TsPptxErrorOptions, UnsupportedFeatureError, type UnsupportedFeatureErrorCode, tableToSlides };
|
|
26
|
+
//# sourceMappingURL=html.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.d.ts","names":[],"sources":["../src/gen/table/html-dom.ts","../src/html.ts"],"mappings":";;;;;;;;;;KA0CY;EACX,WAAW,UAAU,kBAAkB;EACvC,YAAY;;;;;;;;;;iBCUG,cACf,MAAM,mBACN,OAAO,+BACP,UAAS"}
|
package/dist/html.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { a as TsPptxError, i as PackageReadError, n as InvalidOptionError, o as UnsupportedFeatureError, r as MediaError, t as InternalError } from "./errors-DGE9zh3U.js";
|
|
2
|
+
import { t as genTableToSlides } from "./html-dom-wVa3TiG7.js";
|
|
3
|
+
//#region src/html.ts
|
|
4
|
+
/**
|
|
5
|
+
* `ts-pptx/html` — reproduce an existing HTML `<table>` as a PowerPoint table, as a free
|
|
6
|
+
* function that works anywhere there is a DOM.
|
|
7
|
+
*
|
|
8
|
+
* The same conversion is available as `TsPptx.prototype.tableToSlides(id, options)` on the
|
|
9
|
+
* browser build. Reach for *that* when you are in a browser and have a table id; reach for
|
|
10
|
+
* *this* when either of those is not true:
|
|
11
|
+
*
|
|
12
|
+
* - **You are not in a browser.** Node has no global `document`, so the method's entry point
|
|
13
|
+
* does not exist. Pass the element itself (from any DOM implementation) and no global is
|
|
14
|
+
* consulted at all; pass an id together with `options.document` and the id resolves against
|
|
15
|
+
* that document.
|
|
16
|
+
* - **You already have the element.** Passing it skips the id lookup, and skips the class of
|
|
17
|
+
* bug where an id that is not a valid CSS identifier resolves to nothing.
|
|
18
|
+
* - **Your presentation is not a `TsPptx`.** The `pptx` parameter is structural
|
|
19
|
+
* ({@link TableToSlidesHost}: `addSlide` + `presLayout`), so anything shaped like a
|
|
20
|
+
* presentation works, including the Node build.
|
|
21
|
+
*
|
|
22
|
+
* **Column widths need a layout engine.** In a browser the columns are sized from each cell's
|
|
23
|
+
* rendered `offsetWidth`, which reproduces the table's real proportions. Nothing outside a
|
|
24
|
+
* browser lays a table out, so `offsetWidth` is `0` there and the conversion degrades: it uses
|
|
25
|
+
* the computed CSS `width`s when the stylesheet states them for every column in one unit, and
|
|
26
|
+
* an equal split when it does not. To pin widths regardless, put `data-pptx-width` (exact
|
|
27
|
+
* inches) or `data-pptx-min-width` (a floor) on the cells of the table's first row — those win
|
|
28
|
+
* outright on every path. On a cell that spans, the value is the *cell's* width and divides
|
|
29
|
+
* across the columns it covers, the same way a measured or CSS width does.
|
|
30
|
+
*
|
|
31
|
+
* Everything else — cell text (with `<br>` preserved as a line break), colspan/rowspan,
|
|
32
|
+
* computed colors, weight, alignment, padding, borders, and auto-paging across as many slides
|
|
33
|
+
* as the rows need — works the same wherever it runs.
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* import { TsPptx } from '@shbernal/ts-pptx'
|
|
37
|
+
* import { tableToSlides } from '@shbernal/ts-pptx/html'
|
|
38
|
+
* import { Window } from 'happy-dom'
|
|
39
|
+
*
|
|
40
|
+
* const win = new Window()
|
|
41
|
+
* win.document.body.innerHTML = '<table id="report">…</table>'
|
|
42
|
+
*
|
|
43
|
+
* const pptx = new TsPptx()
|
|
44
|
+
* tableToSlides(pptx, win.document.getElementById('report'), { autoPage: true })
|
|
45
|
+
* await pptx.writeFile({ fileName: 'report.pptx' })
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
/**
|
|
49
|
+
* Reproduce an HTML `<table>` as a PowerPoint table, adding as many slides as its rows need.
|
|
50
|
+
* @param {TableToSlidesHost} pptx - the presentation to add slides to
|
|
51
|
+
* @param {TableToSlidesElement | string} table - the `<table>` element, or its id (see `options.document`)
|
|
52
|
+
* @param {TableToSlidesProps} options - generation options
|
|
53
|
+
*/
|
|
54
|
+
function tableToSlides(pptx, table, options = {}) {
|
|
55
|
+
genTableToSlides(pptx, table, options);
|
|
56
|
+
}
|
|
57
|
+
//#endregion
|
|
58
|
+
export { InternalError, InvalidOptionError, MediaError, PackageReadError, TsPptxError, UnsupportedFeatureError, tableToSlides };
|
|
59
|
+
|
|
60
|
+
//# sourceMappingURL=html.js.map
|
package/dist/html.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"html.js","names":[],"sources":["../src/html.ts"],"sourcesContent":["/**\n * `ts-pptx/html` — reproduce an existing HTML `<table>` as a PowerPoint table, as a free\n * function that works anywhere there is a DOM.\n *\n * The same conversion is available as `TsPptx.prototype.tableToSlides(id, options)` on the\n * browser build. Reach for *that* when you are in a browser and have a table id; reach for\n * *this* when either of those is not true:\n *\n * - **You are not in a browser.** Node has no global `document`, so the method's entry point\n * does not exist. Pass the element itself (from any DOM implementation) and no global is\n * consulted at all; pass an id together with `options.document` and the id resolves against\n * that document.\n * - **You already have the element.** Passing it skips the id lookup, and skips the class of\n * bug where an id that is not a valid CSS identifier resolves to nothing.\n * - **Your presentation is not a `TsPptx`.** The `pptx` parameter is structural\n * ({@link TableToSlidesHost}: `addSlide` + `presLayout`), so anything shaped like a\n * presentation works, including the Node build.\n *\n * **Column widths need a layout engine.** In a browser the columns are sized from each cell's\n * rendered `offsetWidth`, which reproduces the table's real proportions. Nothing outside a\n * browser lays a table out, so `offsetWidth` is `0` there and the conversion degrades: it uses\n * the computed CSS `width`s when the stylesheet states them for every column in one unit, and\n * an equal split when it does not. To pin widths regardless, put `data-pptx-width` (exact\n * inches) or `data-pptx-min-width` (a floor) on the cells of the table's first row — those win\n * outright on every path. On a cell that spans, the value is the *cell's* width and divides\n * across the columns it covers, the same way a measured or CSS width does.\n *\n * Everything else — cell text (with `<br>` preserved as a line break), colspan/rowspan,\n * computed colors, weight, alignment, padding, borders, and auto-paging across as many slides\n * as the rows need — works the same wherever it runs.\n * @example\n * ```ts\n * import { TsPptx } from '@shbernal/ts-pptx'\n * import { tableToSlides } from '@shbernal/ts-pptx/html'\n * import { Window } from 'happy-dom'\n *\n * const win = new Window()\n * win.document.body.innerHTML = '<table id=\"report\">…</table>'\n *\n * const pptx = new TsPptx()\n * tableToSlides(pptx, win.document.getElementById('report'), { autoPage: true })\n * await pptx.writeFile({ fileName: 'report.pptx' })\n * ```\n */\n\nimport { genTableToSlides, type TableToSlidesHost } from './gen/table/html-dom.js'\nimport type { TableToSlidesElement, TableToSlidesProps } from './types/index.js'\n\n/**\n * Reproduce an HTML `<table>` as a PowerPoint table, adding as many slides as its rows need.\n * @param {TableToSlidesHost} pptx - the presentation to add slides to\n * @param {TableToSlidesElement | string} table - the `<table>` element, or its id (see `options.document`)\n * @param {TableToSlidesProps} options - generation options\n */\nexport function tableToSlides(\n\tpptx: TableToSlidesHost,\n\ttable: TableToSlidesElement | string,\n\toptions: TableToSlidesProps = {}\n): void {\n\tgenTableToSlides(pptx, table, options)\n}\n\nexport type { TableToSlidesHost }\nexport type { TableToSlidesDocument, TableToSlidesElement, TableToSlidesProps } from './types/index.js'\n\n// Error taxonomy — every failure the library throws. The classes and their `code` are API;\n// the message is not. Re-exported from every entry so `instanceof` works whichever subpath a\n// consumer imports — they all resolve to one shared module, so the classes are identical.\nexport {\n\tTsPptxError,\n\tInvalidOptionError,\n\tUnsupportedFeatureError,\n\tPackageReadError,\n\tMediaError,\n\tInternalError,\n\ttype TsPptxErrorOptions,\n} from './errors.js'\nexport type {\n\tErrorCode,\n\tTsPptxCode,\n\tInvalidOptionErrorCode,\n\tUnsupportedFeatureErrorCode,\n\tPackageReadErrorCode,\n\tMediaErrorCode,\n\tInternalErrorCode,\n} from './codes.js'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDA,SAAgB,cACf,MACA,OACA,UAA8B,CAAC,GACxB;CACP,iBAAiB,MAAM,OAAO,OAAO;AACtC"}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
//#region src/media/base64.ts
|
|
2
|
+
/**
|
|
3
|
+
* Base64 payload handling for media parts — isomorphic across Node and browsers
|
|
4
|
+
* (`TextEncoder`/`atob`/`btoa` only, no `Buffer`).
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Encode raw SVG markup as a base64 `image/svg+xml` data URI.
|
|
8
|
+
* - lets callers pass inline SVG to `addImage({ svg })` without hand-rolling base64
|
|
9
|
+
* - isomorphic and UTF-8 safe: uses the global `TextEncoder`/`btoa` (Node and browsers)
|
|
10
|
+
* @param {string} svg - SVG markup, e.g. `'<svg ...>...</svg>'`
|
|
11
|
+
* @returns {string} a `data:image/svg+xml;base64,...` URI
|
|
12
|
+
*/
|
|
13
|
+
function svgMarkupToDataUri(svg) {
|
|
14
|
+
return `data:image/svg+xml;base64,${bytesToBase64(new TextEncoder().encode(svg))}`;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Encode raw bytes as base64 (no `data:` prefix) using only `btoa`, so the result is the same
|
|
18
|
+
* on Node, in a browser, and in a runtime that has neither `Buffer` nor `FileReader`.
|
|
19
|
+
*
|
|
20
|
+
* Chunked because `String.fromCharCode(...spread)` blows the argument-count limit on a payload
|
|
21
|
+
* of any real size — a multi-megabyte video rel would throw rather than encode.
|
|
22
|
+
* @param {Uint8Array} bytes - the payload
|
|
23
|
+
* @returns {string} base64 text
|
|
24
|
+
*/
|
|
25
|
+
function bytesToBase64(bytes) {
|
|
26
|
+
const CHUNK = 32768;
|
|
27
|
+
let binary = "";
|
|
28
|
+
for (let i = 0; i < bytes.length; i += CHUNK) binary += String.fromCharCode(...bytes.subarray(i, i + CHUNK));
|
|
29
|
+
return btoa(binary);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Decode a base64 image payload (raw base64 or a `data:` URI) to bytes.
|
|
33
|
+
* - tolerant of the `data:[mime];base64,` prefix and of whitespace in the payload
|
|
34
|
+
* @param {string} b64 - base64 string or data URI
|
|
35
|
+
* @returns {Uint8Array | null} decoded bytes, or `null` when the payload is empty/undecodable
|
|
36
|
+
*/
|
|
37
|
+
function decodeBase64ToBytes(b64) {
|
|
38
|
+
if (!b64) return null;
|
|
39
|
+
const comma = b64.indexOf("base64,");
|
|
40
|
+
const payload = (comma >= 0 ? b64.slice(comma + 7) : b64).replace(/\s/g, "");
|
|
41
|
+
if (!payload) return null;
|
|
42
|
+
try {
|
|
43
|
+
const binary = atob(payload);
|
|
44
|
+
const bytes = new Uint8Array(binary.length);
|
|
45
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
46
|
+
return bytes;
|
|
47
|
+
} catch {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/media/image-size.ts
|
|
53
|
+
/**
|
|
54
|
+
* Intrinsic image geometry: reading a natural pixel size out of header bytes, and the
|
|
55
|
+
* `<a:srcRect>` crop math that fits that natural size into a display box.
|
|
56
|
+
*
|
|
57
|
+
* Shared by both sides of the library — the write path (`addImage({ sizing })`) and the read
|
|
58
|
+
* API's `Picture.setImage({ fit })` — which is why it lives outside `gen/` and `read/`.
|
|
59
|
+
* Everything here is synchronous and pure: headers only, never pixel decoding.
|
|
60
|
+
*/
|
|
61
|
+
/**
|
|
62
|
+
* Read the intrinsic dimensions of an image from its header bytes.
|
|
63
|
+
* - synchronous: parses only file-format headers, never decodes pixels
|
|
64
|
+
* - raster: PNG, JPEG, GIF, BMP, and WebP (VP8 / VP8L / VP8X) — natural pixels
|
|
65
|
+
* - vector: SVG — intrinsic size from the root `<svg>` width/height or viewBox
|
|
66
|
+
* - unrecognized formats return `null` (no measurable intrinsic size)
|
|
67
|
+
*
|
|
68
|
+
* Used by image `sizing: 'cover' | 'contain'` to compute an aspect-correct
|
|
69
|
+
* `<a:srcRect>` crop from the *natural* image ratio rather than the displayed box.
|
|
70
|
+
* @param {string} dataB64 - base64 image payload or `data:` URI
|
|
71
|
+
* @returns {{ w: number, h: number } | null} natural size, or `null` when unmeasurable
|
|
72
|
+
*/
|
|
73
|
+
function getImageSizeFromBase64(dataB64) {
|
|
74
|
+
const b = decodeBase64ToBytes(dataB64);
|
|
75
|
+
return b ? getImageSizeFromBytes(b) : null;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Read the intrinsic dimensions of an image from raw header bytes — the
|
|
79
|
+
* byte-level core shared by {@link getImageSizeFromBase64} and the read API's
|
|
80
|
+
* `Picture.setImage({ fit })`, which already holds the media bytes.
|
|
81
|
+
* @param {Uint8Array} b - image bytes
|
|
82
|
+
* @returns {{ w: number, h: number } | null} natural size, or `null` when unmeasurable
|
|
83
|
+
*/
|
|
84
|
+
function getImageSizeFromBytes(b) {
|
|
85
|
+
if (!b || b.length < 24) return null;
|
|
86
|
+
const u = (n) => b[n] ?? 0;
|
|
87
|
+
if (b[0] === 137 && b[1] === 80 && b[2] === 78 && b[3] === 71) {
|
|
88
|
+
const w = u(16) << 24 | u(17) << 16 | u(18) << 8 | u(19);
|
|
89
|
+
const h = u(20) << 24 | u(21) << 16 | u(22) << 8 | u(23);
|
|
90
|
+
return w > 0 && h > 0 ? {
|
|
91
|
+
w,
|
|
92
|
+
h
|
|
93
|
+
} : null;
|
|
94
|
+
}
|
|
95
|
+
if (b[0] === 71 && b[1] === 73 && b[2] === 70) {
|
|
96
|
+
const w = u(6) | u(7) << 8;
|
|
97
|
+
const h = u(8) | u(9) << 8;
|
|
98
|
+
return w > 0 && h > 0 ? {
|
|
99
|
+
w,
|
|
100
|
+
h
|
|
101
|
+
} : null;
|
|
102
|
+
}
|
|
103
|
+
if (b[0] === 66 && b[1] === 77) {
|
|
104
|
+
const w = u(18) | u(19) << 8 | u(20) << 16 | u(21) << 24;
|
|
105
|
+
const h = u(22) | u(23) << 8 | u(24) << 16 | u(25) << 24;
|
|
106
|
+
const aw = Math.abs(w);
|
|
107
|
+
const ah = Math.abs(h);
|
|
108
|
+
return aw > 0 && ah > 0 ? {
|
|
109
|
+
w: aw,
|
|
110
|
+
h: ah
|
|
111
|
+
} : null;
|
|
112
|
+
}
|
|
113
|
+
if (b[0] === 82 && b[1] === 73 && b[2] === 70 && b[3] === 70 && b[8] === 87 && b[9] === 69 && b[10] === 66 && b[11] === 80) {
|
|
114
|
+
const fourCC = String.fromCharCode(u(12), u(13), u(14), u(15));
|
|
115
|
+
if (fourCC === "VP8 " && b.length >= 30) {
|
|
116
|
+
const w = (u(26) | u(27) << 8) & 16383;
|
|
117
|
+
const h = (u(28) | u(29) << 8) & 16383;
|
|
118
|
+
return w > 0 && h > 0 ? {
|
|
119
|
+
w,
|
|
120
|
+
h
|
|
121
|
+
} : null;
|
|
122
|
+
}
|
|
123
|
+
if (fourCC === "VP8L" && b.length >= 25) {
|
|
124
|
+
const bits = u(21) | u(22) << 8 | u(23) << 16 | u(24) << 24;
|
|
125
|
+
const w = (bits & 16383) + 1;
|
|
126
|
+
const h = (bits >> 14 & 16383) + 1;
|
|
127
|
+
return w > 0 && h > 0 ? {
|
|
128
|
+
w,
|
|
129
|
+
h
|
|
130
|
+
} : null;
|
|
131
|
+
}
|
|
132
|
+
if (fourCC === "VP8X" && b.length >= 30) {
|
|
133
|
+
const w = (u(24) | u(25) << 8 | u(26) << 16) + 1;
|
|
134
|
+
const h = (u(27) | u(28) << 8 | u(29) << 16) + 1;
|
|
135
|
+
return w > 0 && h > 0 ? {
|
|
136
|
+
w,
|
|
137
|
+
h
|
|
138
|
+
} : null;
|
|
139
|
+
}
|
|
140
|
+
return null;
|
|
141
|
+
}
|
|
142
|
+
if (b[0] === 255 && b[1] === 216) {
|
|
143
|
+
let i = 2;
|
|
144
|
+
while (i + 9 < b.length) {
|
|
145
|
+
if (b[i] !== 255) {
|
|
146
|
+
i++;
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const marker = u(i + 1);
|
|
150
|
+
if (marker >= 192 && marker <= 207 && marker !== 196 && marker !== 200 && marker !== 204) {
|
|
151
|
+
const h = u(i + 5) << 8 | u(i + 6);
|
|
152
|
+
const w = u(i + 7) << 8 | u(i + 8);
|
|
153
|
+
return w > 0 && h > 0 ? {
|
|
154
|
+
w,
|
|
155
|
+
h
|
|
156
|
+
} : null;
|
|
157
|
+
}
|
|
158
|
+
if (marker >= 208 && marker <= 217 || marker === 1) {
|
|
159
|
+
i += 2;
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
const segLen = u(i + 2) << 8 | u(i + 3);
|
|
163
|
+
if (segLen < 2) break;
|
|
164
|
+
i += 2 + segLen;
|
|
165
|
+
}
|
|
166
|
+
return null;
|
|
167
|
+
}
|
|
168
|
+
const text = utf8Decode(b);
|
|
169
|
+
if (/<svg[\s>]/i.test(text)) return getSvgSizeFromMarkup(text);
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Compute the `<a:srcRect>` crop percentages (each in 1/1000 of a percent, the
|
|
174
|
+
* OOXML unit) for fitting an image of natural size `img` into a display `box`,
|
|
175
|
+
* assuming the cropped region is then stretched to fill the box (`<a:stretch>`).
|
|
176
|
+
*
|
|
177
|
+
* - `cover`: fill the box, cropping the overflowing axis (positive l/r or t/b)
|
|
178
|
+
* - `contain`: fit inside the box, letterboxing the short axis (negative l/r or t/b)
|
|
179
|
+
*
|
|
180
|
+
* Single source of truth for the crop math shared by the write side
|
|
181
|
+
* (`ImageSizingXml`) and the read API's `Picture.setImage({ fit })`. `l`/`r` and
|
|
182
|
+
* `t`/`b` are symmetric (centered crop).
|
|
183
|
+
* @param {'cover' | 'contain'} type - fit mode
|
|
184
|
+
* @param {{ w: number, h: number }} img - natural image pixel size
|
|
185
|
+
* @param {{ w: number, h: number }} box - displayed frame size (any consistent unit)
|
|
186
|
+
* @returns {{ l: number, r: number, t: number, b: number }} srcRect percentages
|
|
187
|
+
*/
|
|
188
|
+
function fitSrcRectPercents(type, img, box) {
|
|
189
|
+
const imgRatio = img.h / img.w;
|
|
190
|
+
const boxRatio = box.h / box.w;
|
|
191
|
+
let width;
|
|
192
|
+
let height;
|
|
193
|
+
if (type === "cover") {
|
|
194
|
+
const isBoxBased = boxRatio > imgRatio;
|
|
195
|
+
width = isBoxBased ? box.h / imgRatio : box.w;
|
|
196
|
+
height = isBoxBased ? box.h : box.w * imgRatio;
|
|
197
|
+
} else {
|
|
198
|
+
const widthBased = boxRatio > imgRatio;
|
|
199
|
+
width = widthBased ? box.w : box.h / imgRatio;
|
|
200
|
+
height = widthBased ? box.w * imgRatio : box.h;
|
|
201
|
+
}
|
|
202
|
+
const hz = Math.round(1e5 * .5 * (1 - box.w / width));
|
|
203
|
+
const vz = Math.round(1e5 * .5 * (1 - box.h / height));
|
|
204
|
+
return {
|
|
205
|
+
l: hz,
|
|
206
|
+
r: hz,
|
|
207
|
+
t: vz,
|
|
208
|
+
b: vz
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Read the intrinsic size of an SVG document from its root `<svg>` element.
|
|
213
|
+
* Follows the SVG sizing model: an explicit absolute `width`/`height` pair wins;
|
|
214
|
+
* otherwise the `viewBox` width/height defines the size (and thus aspect ratio).
|
|
215
|
+
* Percentage or missing `width`/`height` fall through to `viewBox`.
|
|
216
|
+
* @param {string} svg - SVG markup
|
|
217
|
+
* @returns {{ w: number, h: number } | null} intrinsic size, or `null` when undeterminable
|
|
218
|
+
*/
|
|
219
|
+
function getSvgSizeFromMarkup(svg) {
|
|
220
|
+
const openTag = /<svg\b[^>]*>/i.exec(svg)?.[0];
|
|
221
|
+
if (!openTag) return null;
|
|
222
|
+
const attr = (name) => new RegExp(`\\b${name}\\s*=\\s*["']([^"']*)["']`, "i").exec(openTag)?.[1] ?? null;
|
|
223
|
+
const absLength = (val) => {
|
|
224
|
+
if (val == null || /%\s*$/.test(val)) return NaN;
|
|
225
|
+
const m = /^\s*\+?(\d*\.?\d+)/.exec(val);
|
|
226
|
+
return m ? parseFloat(m[1] ?? "") : NaN;
|
|
227
|
+
};
|
|
228
|
+
let w = absLength(attr("width"));
|
|
229
|
+
let h = absLength(attr("height"));
|
|
230
|
+
if (!(w > 0 && h > 0)) {
|
|
231
|
+
const vb = attr("viewBox");
|
|
232
|
+
const p = vb ? vb.trim().split(/[\s,]+/).map(Number) : [];
|
|
233
|
+
const vw = p[2];
|
|
234
|
+
const vh = p[3];
|
|
235
|
+
if (p.length === 4 && vw != null && vh != null && vw > 0 && vh > 0) {
|
|
236
|
+
w = vw;
|
|
237
|
+
h = vh;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return w > 0 && h > 0 ? {
|
|
241
|
+
w,
|
|
242
|
+
h
|
|
243
|
+
} : null;
|
|
244
|
+
}
|
|
245
|
+
/** Decode UTF-8 bytes to a string, isomorphic across Node and browsers. */
|
|
246
|
+
function utf8Decode(bytes) {
|
|
247
|
+
return new TextDecoder().decode(bytes);
|
|
248
|
+
}
|
|
249
|
+
//#endregion
|
|
250
|
+
export { decodeBase64ToBytes as a, bytesToBase64 as i, getImageSizeFromBase64 as n, svgMarkupToDataUri as o, getImageSizeFromBytes as r, fitSrcRectPercents as t };
|
|
251
|
+
|
|
252
|
+
//# sourceMappingURL=image-size-C5Z1sKof.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"image-size-C5Z1sKof.js","names":[],"sources":["../src/media/base64.ts","../src/media/image-size.ts"],"sourcesContent":["/**\n * Base64 payload handling for media parts — isomorphic across Node and browsers\n * (`TextEncoder`/`atob`/`btoa` only, no `Buffer`).\n */\n\n/**\n * Encode raw SVG markup as a base64 `image/svg+xml` data URI.\n * - lets callers pass inline SVG to `addImage({ svg })` without hand-rolling base64\n * - isomorphic and UTF-8 safe: uses the global `TextEncoder`/`btoa` (Node and browsers)\n * @param {string} svg - SVG markup, e.g. `'<svg ...>...</svg>'`\n * @returns {string} a `data:image/svg+xml;base64,...` URI\n */\nexport function svgMarkupToDataUri(svg: string): string {\n\treturn `data:image/svg+xml;base64,${bytesToBase64(new TextEncoder().encode(svg))}`\n}\n\n/**\n * Encode raw bytes as base64 (no `data:` prefix) using only `btoa`, so the result is the same\n * on Node, in a browser, and in a runtime that has neither `Buffer` nor `FileReader`.\n *\n * Chunked because `String.fromCharCode(...spread)` blows the argument-count limit on a payload\n * of any real size — a multi-megabyte video rel would throw rather than encode.\n * @param {Uint8Array} bytes - the payload\n * @returns {string} base64 text\n */\nexport function bytesToBase64(bytes: Uint8Array): string {\n\tconst CHUNK = 0x8000\n\tlet binary = ''\n\tfor (let i = 0; i < bytes.length; i += CHUNK) binary += String.fromCharCode(...bytes.subarray(i, i + CHUNK))\n\treturn btoa(binary)\n}\n\n/**\n * Decode a base64 image payload (raw base64 or a `data:` URI) to bytes.\n * - tolerant of the `data:[mime];base64,` prefix and of whitespace in the payload\n * @param {string} b64 - base64 string or data URI\n * @returns {Uint8Array | null} decoded bytes, or `null` when the payload is empty/undecodable\n */\nexport function decodeBase64ToBytes(b64: string): Uint8Array | null {\n\tif (!b64) return null\n\t// Strip any `data:...;base64,` prefix and surrounding whitespace\n\tconst comma = b64.indexOf('base64,')\n\tconst payload = (comma >= 0 ? b64.slice(comma + 'base64,'.length) : b64).replace(/\\s/g, '')\n\tif (!payload) return null\n\ttry {\n\t\tconst binary = atob(payload)\n\t\tconst bytes = new Uint8Array(binary.length)\n\t\tfor (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i)\n\t\treturn bytes\n\t} catch {\n\t\treturn null\n\t}\n}\n","/**\n * Intrinsic image geometry: reading a natural pixel size out of header bytes, and the\n * `<a:srcRect>` crop math that fits that natural size into a display box.\n *\n * Shared by both sides of the library — the write path (`addImage({ sizing })`) and the read\n * API's `Picture.setImage({ fit })` — which is why it lives outside `gen/` and `read/`.\n * Everything here is synchronous and pure: headers only, never pixel decoding.\n */\n\nimport { decodeBase64ToBytes } from './base64.js'\n\n/**\n * Read the intrinsic dimensions of an image from its header bytes.\n * - synchronous: parses only file-format headers, never decodes pixels\n * - raster: PNG, JPEG, GIF, BMP, and WebP (VP8 / VP8L / VP8X) — natural pixels\n * - vector: SVG — intrinsic size from the root `<svg>` width/height or viewBox\n * - unrecognized formats return `null` (no measurable intrinsic size)\n *\n * Used by image `sizing: 'cover' | 'contain'` to compute an aspect-correct\n * `<a:srcRect>` crop from the *natural* image ratio rather than the displayed box.\n * @param {string} dataB64 - base64 image payload or `data:` URI\n * @returns {{ w: number, h: number } | null} natural size, or `null` when unmeasurable\n */\nexport function getImageSizeFromBase64(dataB64: string): { w: number; h: number } | null {\n\tconst b = decodeBase64ToBytes(dataB64)\n\treturn b ? getImageSizeFromBytes(b) : null\n}\n\n/**\n * Read the intrinsic dimensions of an image from raw header bytes — the\n * byte-level core shared by {@link getImageSizeFromBase64} and the read API's\n * `Picture.setImage({ fit })`, which already holds the media bytes.\n * @param {Uint8Array} b - image bytes\n * @returns {{ w: number, h: number } | null} natural size, or `null` when unmeasurable\n */\nexport function getImageSizeFromBytes(b: Uint8Array): { w: number; h: number } | null {\n\tif (!b || b.length < 24) return null\n\n\t// Bounds-checked byte read: every access below is already guarded by an\n\t// explicit length check, so the `?? 0` fallback is unreachable in practice.\n\tconst u = (n: number): number => b[n] ?? 0\n\n\t// PNG: 8-byte signature, then IHDR with width@16 / height@20 (big-endian uint32)\n\tif (b[0] === 0x89 && b[1] === 0x50 && b[2] === 0x4e && b[3] === 0x47) {\n\t\tconst w = (u(16) << 24) | (u(17) << 16) | (u(18) << 8) | u(19)\n\t\tconst h = (u(20) << 24) | (u(21) << 16) | (u(22) << 8) | u(23)\n\t\treturn w > 0 && h > 0 ? { w, h } : null\n\t}\n\n\t// GIF: \"GIF87a\"/\"GIF89a\", width@6 / height@8 (little-endian uint16)\n\tif (b[0] === 0x47 && b[1] === 0x49 && b[2] === 0x46) {\n\t\tconst w = u(6) | (u(7) << 8)\n\t\tconst h = u(8) | (u(9) << 8)\n\t\treturn w > 0 && h > 0 ? { w, h } : null\n\t}\n\n\t// BMP: \"BM\", width@18 / height@22 (little-endian int32; height may be negative for top-down)\n\tif (b[0] === 0x42 && b[1] === 0x4d) {\n\t\tconst w = u(18) | (u(19) << 8) | (u(20) << 16) | (u(21) << 24)\n\t\tconst h = u(22) | (u(23) << 8) | (u(24) << 16) | (u(25) << 24)\n\t\tconst aw = Math.abs(w)\n\t\tconst ah = Math.abs(h)\n\t\treturn aw > 0 && ah > 0 ? { w: aw, h: ah } : null\n\t}\n\n\t// WebP: \"RIFF\"....\"WEBP\" then a VP8 / VP8L / VP8X chunk\n\tif (\n\t\tb[0] === 0x52 &&\n\t\tb[1] === 0x49 &&\n\t\tb[2] === 0x46 &&\n\t\tb[3] === 0x46 &&\n\t\tb[8] === 0x57 &&\n\t\tb[9] === 0x45 &&\n\t\tb[10] === 0x42 &&\n\t\tb[11] === 0x50\n\t) {\n\t\tconst fourCC = String.fromCharCode(u(12), u(13), u(14), u(15))\n\t\tif (fourCC === 'VP8 ' && b.length >= 30) {\n\t\t\t// Lossy: 14-bit width/height at offset 26/28 (little-endian, mask off scale bits)\n\t\t\tconst w = (u(26) | (u(27) << 8)) & 0x3fff\n\t\t\tconst h = (u(28) | (u(29) << 8)) & 0x3fff\n\t\t\treturn w > 0 && h > 0 ? { w, h } : null\n\t\t}\n\t\tif (fourCC === 'VP8L' && b.length >= 25) {\n\t\t\t// Lossless: 14-bit width/height packed starting at bit 0 of offset 21\n\t\t\tconst bits = u(21) | (u(22) << 8) | (u(23) << 16) | (u(24) << 24)\n\t\t\tconst w = (bits & 0x3fff) + 1\n\t\t\tconst h = ((bits >> 14) & 0x3fff) + 1\n\t\t\treturn w > 0 && h > 0 ? { w, h } : null\n\t\t}\n\t\tif (fourCC === 'VP8X' && b.length >= 30) {\n\t\t\t// Extended: 24-bit canvas width/height minus one at offset 24/27 (little-endian)\n\t\t\tconst w = (u(24) | (u(25) << 8) | (u(26) << 16)) + 1\n\t\t\tconst h = (u(27) | (u(28) << 8) | (u(29) << 16)) + 1\n\t\t\treturn w > 0 && h > 0 ? { w, h } : null\n\t\t}\n\t\treturn null\n\t}\n\n\t// JPEG: \"FFD8\", scan segment markers for a Start-Of-Frame (SOFn) and read height@5 / width@7\n\tif (b[0] === 0xff && b[1] === 0xd8) {\n\t\tlet i = 2\n\t\twhile (i + 9 < b.length) {\n\t\t\tif (b[i] !== 0xff) {\n\t\t\t\ti++\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tconst marker = u(i + 1)\n\t\t\t// SOF0..SOF15 carry frame dimensions, excluding DHT(C4)/JPG(C8)/DAC(CC)\n\t\t\tif (marker >= 0xc0 && marker <= 0xcf && marker !== 0xc4 && marker !== 0xc8 && marker !== 0xcc) {\n\t\t\t\tconst h = (u(i + 5) << 8) | u(i + 6)\n\t\t\t\tconst w = (u(i + 7) << 8) | u(i + 8)\n\t\t\t\treturn w > 0 && h > 0 ? { w, h } : null\n\t\t\t}\n\t\t\t// Standalone markers (RSTn / SOI / EOI / TEM) have no length payload\n\t\t\tif ((marker >= 0xd0 && marker <= 0xd9) || marker === 0x01) {\n\t\t\t\ti += 2\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Otherwise skip this segment using its 2-byte big-endian length\n\t\t\tconst segLen = (u(i + 2) << 8) | u(i + 3)\n\t\t\tif (segLen < 2) break\n\t\t\ti += 2 + segLen\n\t\t}\n\t\treturn null\n\t}\n\n\t// SVG: text-based vector with no binary signature. When the payload is an\n\t// `<svg>` document, read its intrinsic size from the root element so that\n\t// `sizing: 'cover' | 'contain'` is aspect-correct for SVG, not just rasters.\n\tconst text = utf8Decode(b)\n\tif (/<svg[\\s>]/i.test(text)) return getSvgSizeFromMarkup(text)\n\n\treturn null\n}\n\n/**\n * Compute the `<a:srcRect>` crop percentages (each in 1/1000 of a percent, the\n * OOXML unit) for fitting an image of natural size `img` into a display `box`,\n * assuming the cropped region is then stretched to fill the box (`<a:stretch>`).\n *\n * - `cover`: fill the box, cropping the overflowing axis (positive l/r or t/b)\n * - `contain`: fit inside the box, letterboxing the short axis (negative l/r or t/b)\n *\n * Single source of truth for the crop math shared by the write side\n * (`ImageSizingXml`) and the read API's `Picture.setImage({ fit })`. `l`/`r` and\n * `t`/`b` are symmetric (centered crop).\n * @param {'cover' | 'contain'} type - fit mode\n * @param {{ w: number, h: number }} img - natural image pixel size\n * @param {{ w: number, h: number }} box - displayed frame size (any consistent unit)\n * @returns {{ l: number, r: number, t: number, b: number }} srcRect percentages\n */\nexport function fitSrcRectPercents(\n\ttype: 'cover' | 'contain',\n\timg: { w: number; h: number },\n\tbox: { w: number; h: number }\n): { l: number; r: number; t: number; b: number } {\n\tconst imgRatio = img.h / img.w\n\tconst boxRatio = box.h / box.w\n\tlet width: number\n\tlet height: number\n\tif (type === 'cover') {\n\t\tconst isBoxBased = boxRatio > imgRatio\n\t\twidth = isBoxBased ? box.h / imgRatio : box.w\n\t\theight = isBoxBased ? box.h : box.w * imgRatio\n\t} else {\n\t\tconst widthBased = boxRatio > imgRatio\n\t\twidth = widthBased ? box.w : box.h / imgRatio\n\t\theight = widthBased ? box.w * imgRatio : box.h\n\t}\n\tconst hz = Math.round(1e5 * 0.5 * (1 - box.w / width))\n\tconst vz = Math.round(1e5 * 0.5 * (1 - box.h / height))\n\treturn { l: hz, r: hz, t: vz, b: vz }\n}\n\n/**\n * Read the intrinsic size of an SVG document from its root `<svg>` element.\n * Follows the SVG sizing model: an explicit absolute `width`/`height` pair wins;\n * otherwise the `viewBox` width/height defines the size (and thus aspect ratio).\n * Percentage or missing `width`/`height` fall through to `viewBox`.\n * @param {string} svg - SVG markup\n * @returns {{ w: number, h: number } | null} intrinsic size, or `null` when undeterminable\n */\nfunction getSvgSizeFromMarkup(svg: string): { w: number; h: number } | null {\n\tconst openTag = /<svg\\b[^>]*>/i.exec(svg)?.[0]\n\tif (!openTag) return null\n\tconst attr = (name: string): string | null =>\n\t\tnew RegExp(`\\\\b${name}\\\\s*=\\\\s*[\"']([^\"']*)[\"']`, 'i').exec(openTag)?.[1] ?? null\n\t// Leading number with an optional absolute unit; a percentage is not an intrinsic length.\n\tconst absLength = (val: string | null): number => {\n\t\tif (val == null || /%\\s*$/.test(val)) return NaN\n\t\tconst m = /^\\s*\\+?(\\d*\\.?\\d+)/.exec(val)\n\t\treturn m ? parseFloat(m[1] ?? '') : NaN\n\t}\n\tlet w = absLength(attr('width'))\n\tlet h = absLength(attr('height'))\n\tif (!(w > 0 && h > 0)) {\n\t\tconst vb = attr('viewBox')\n\t\tconst p = vb\n\t\t\t? vb\n\t\t\t\t\t.trim()\n\t\t\t\t\t.split(/[\\s,]+/)\n\t\t\t\t\t.map(Number)\n\t\t\t: []\n\t\tconst vw = p[2]\n\t\tconst vh = p[3]\n\t\tif (p.length === 4 && vw != null && vh != null && vw > 0 && vh > 0) {\n\t\t\tw = vw\n\t\t\th = vh\n\t\t}\n\t}\n\treturn w > 0 && h > 0 ? { w, h } : null\n}\n\n/** Decode UTF-8 bytes to a string, isomorphic across Node and browsers. */\nfunction utf8Decode(bytes: Uint8Array): string {\n\treturn new TextDecoder().decode(bytes)\n}\n"],"mappings":";;;;;;;;;;;;AAYA,SAAgB,mBAAmB,KAAqB;CACvD,OAAO,6BAA6B,cAAc,IAAI,YAAY,CAAC,CAAC,OAAO,GAAG,CAAC;AAChF;;;;;;;;;;AAWA,SAAgB,cAAc,OAA2B;CACxD,MAAM,QAAQ;CACd,IAAI,SAAS;CACb,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,OAAO,UAAU,OAAO,aAAa,GAAG,MAAM,SAAS,GAAG,IAAI,KAAK,CAAC;CAC3G,OAAO,KAAK,MAAM;AACnB;;;;;;;AAQA,SAAgB,oBAAoB,KAAgC;CACnE,IAAI,CAAC,KAAK,OAAO;CAEjB,MAAM,QAAQ,IAAI,QAAQ,SAAS;CACnC,MAAM,WAAW,SAAS,IAAI,IAAI,MAAM,QAAQ,CAAgB,IAAI,IAAA,CAAK,QAAQ,OAAO,EAAE;CAC1F,IAAI,CAAC,SAAS,OAAO;CACrB,IAAI;EACH,MAAM,SAAS,KAAK,OAAO;EAC3B,MAAM,QAAQ,IAAI,WAAW,OAAO,MAAM;EAC1C,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK,MAAM,KAAK,OAAO,WAAW,CAAC;EACtE,OAAO;CACR,QAAQ;EACP,OAAO;CACR;AACD;;;;;;;;;;;;;;;;;;;;;;;AC7BA,SAAgB,uBAAuB,SAAkD;CACxF,MAAM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AU,gBAAgB,KAAK,GAAG,CAAC,GAAG;CAC5C,IAAI,CAAC,SAAS,OAAO;CACrB,MAAM,QAAQ,SACb,IAAI,OAAO,MAAM,KAAK,4BAA4B,GAAG,CAAC,CAAC,KAAK,OAAO,CAAC,GAAG,MAAM;CAE9E,MAAM,aAAa,QAA+B;EACjD,IAAI,OAAO,QAAQ,QAAQ,KAAK,GAAG,GAAG,OAAO;EAC7C,MAAM,IAAI,qBAAqB,KAAK,GAAG;EACvC,OAAO,IAAI,WAAW,EAAE,MAAM,EAAE,IAAI;CACrC;CACA,IAAI,IAAI,UAAU,KAAK,OAAO,CAAC;CAC/B,IAAI,IAAI,UAAU,KAAK,QAAQ,CAAC;CAChC,IAAI,EAAE,IAAI,KAAK,IAAI,IAAI;EACtB,MAAM,KAAK,KAAK,SAAS;EACzB,MAAM,IAAI,KACP,GACC,KAAK,CAAC,CACN,MAAM,QAAQ,CAAC,CACf,IAAI,MAAM,IACX,CAAC;EACJ,MAAM,KAAK,EAAE;EACb,MAAM,KAAK,EAAE;EACb,IAAI,EAAE,WAAW,KAAK,MAAM,QAAQ,MAAM,QAAQ,KAAK,KAAK,KAAK,GAAG;GACnE,IAAI;GACJ,IAAI;EACL;CACD;CACA,OAAO,IAAI,KAAK,IAAI,IAAI;EAAE;EAAG;CAAE,IAAI;AACpC;;AAGA,SAAS,WAAW,OAA2B;CAC9C,OAAO,IAAI,YAAY,CAAC,CAAC,OAAO,KAAK;AACtC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { C as isChartExType, S as connectorPresetFor, _ as TextAnchor, a as CONNECTOR_PRESETS, b as ZIP_OUTPUT_TYPE, c as OutputType, d as SCHEME_COLORS, f as SHAPE_NAME, g as TableStyle, h as SlideObjectType, i as CHART_NAME, l as PLACEHOLDER_TYPE, m as ShapeType, n as AlignV, o as CONNECTOR_PRESET_NAME, p as SchemeColor, r as BulletType, s as ChartType, t as AlignH, u as PlaceholderType, v as VALID_SHAPE_PRESETS, x as asChartType, y as WRITE_OUTPUT_TYPE } from "./enums-D3aF4QGb.js";
|
|
2
|
+
import { $ as LinearGradientFillProps, $t as CommentProps, A as ImageBaseProps, At as ChartPropsChartBar, B as ShapeGuide, Bt as ChartPropsChartWaterfall, C as TableRow, Ct as ChartLineDash, D as TableToSlidesDocument, Dt as ChartPropsAxisSer, E as TableStyleRegionProps, Et as ChartPropsAxisCat, F as ShapeAdjustHandle, Ft as ChartPropsChartPie, G as DataOrPathProps, Gt as ChartPropsTitle, H as BackgroundProps, Ht as ChartPropsDataTable, I as ShapeAdjustHandlePolar, It as ChartPropsChartRadar, J as GradientFillProps, Jt as OptsChartData, K as DataOrPathRequiredProps, Kt as ChartSeriesOpts, L as ShapeAdjustHandleXY, Lt as ChartPropsChartRegionMap, M as MediaProps, Mt as ChartPropsChartDoughnut, N as MediaType, Nt as ChartPropsChartHistogram, O as TableToSlidesElement, Ot as ChartPropsAxisVal, P as OleObjectProps, Pt as ChartPropsChartLine, Q as ImageFillProps, Qt as PlaceholderProps, R as ShapeAdjustValue, Rt as ChartPropsChartStock, S as TableProps, St as ChartExStatistics, T as TableStyleProps, Tt as ChartOpts, U as Color, Ut as ChartPropsFillLine, V as ShapeProps, Vt as ChartPropsDataLabel, W as Coord, Wt as ChartPropsLegend, X as HAlign, Xt as ObjectLockProps, Y as GradientStopProps, Yt as OptsChartGridLine, Z as HexColor, Zt as ObjectNameProps, _ as TransitionProps, _t as ChartAxisTickMark, a as Slide, an as SlideComment, at as TextVertType, b as TableCell, bt as ChartExBinning, c as MasterTextStyleLevel, cn as TextBaseProps, ct as BorderProps, d as SlideMasterObject, dn as TextMeasurement, dt as HyperlinkActionJump, en as MeasureTextOptions, et as Margin, f as SlideMasterProps, fn as TextProps, ft as HyperlinkProps, g as PresetEffect, gt as ChartAreaProps, h as AnimationTrigger, hn as textRuns, ht as ShapeLineProps, i as ObjectOptions, in as ResolvedCommentAuthor, it as RadialGradientFillProps, j as ImageProps, jt as ChartPropsChartBoxWhisker, k as TableToSlidesProps, kt as ChartPropsBase, l as MasterTextStyleProps, ln as TextFitShrinkProps, lt as ConnectorProps, m as AnimationProps, mn as textRun, mt as ShapeFillProps, n as GroupChildProps, nn as NotesTextOptions, nt as PatternPreset, o as SlideLayout, on as TableCellLayout, ot as ThemeColor, p as SlideNumberProps, pn as TextPropsOptions, pt as ShadowProps, q as GeometryPoint, qt as LineCap, r as GroupProps, rn as OverflowBoxOptions, rt as PositionProps, s as MasterBulletProps, sn as TableLayoutResult, st as VAlign, t as AddSlideProps, tn as NotesProps, tt as PatternFillProps, u as SlideMasterChartProps, un as TextGlowProps, ut as ConnectorType, v as TransitionSoundProps, vt as ChartDataPointStyle, w as TableRowSlide, wt as ChartMulti, x as TableCellProps, xt as ChartExGeography, y as TransitionType, yt as ChartErrorBarOptions, z as ShapeConnectionSite, zt as ChartPropsChartSurface } from "./slide-B6mDaM-P.js";
|
|
3
|
+
import { a as PresentationProps, c as WriteFileProps, d as ThemeProps, i as PresLayout, l as WriteProps, n as PackagePart, o as SectionProps, r as PartsProps, s as WriteBaseProps, t as CustomPropertyValue, u as ThemeColorScheme } from "./pres-5x1bjCzk.js";
|
|
4
|
+
import { C as pixelsToEmu, D as SlideZoomProps, E as SectionZoomProps, O as SummaryZoomProps, S as percentToEmu, T as ptToHundredths, _ as coordToEmu, a as ANGLE_UNITS_PER_DEGREE, b as emuToPoints, c as EMU_PER_POINT, d as HUNDREDTHS_PER_POINT, f as PERCENT_SCALE, g as StandardLayoutName, h as StandardLayout, i as PresentationCore, k as ZoomBaseProps, l as Emu, m as STANDARD_LAYOUTS, n as DiagnosticHandler, o as DEFAULT_PX_PER_INCH, p as POINTS_PER_INCH, r as setDiagnosticHandler, s as EMU_PER_INCH, t as Diagnostic, u as FIXED_PCT_PER_PERCENT, v as emuToInches, w as pointsToEmu, x as inchesToEmu, y as emuToPixels } from "./diagnostics-DzY9Tyfm.js";
|
|
5
|
+
import { a as TsPptxError, c as DiagnosticCode, d as InvalidOptionErrorCode, f as MediaErrorCode, h as UnsupportedFeatureErrorCode, i as PackageReadError, l as ErrorCode, m as TsPptxCode, n as InvalidOptionError, o as TsPptxErrorOptions, p as PackageReadErrorCode, r as MediaError, s as UnsupportedFeatureError, t as InternalError, u as InternalErrorCode } from "./errors-DRLpOpgQ.js";
|
|
6
|
+
//#region src/index.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* The runtime-agnostic entry: what a consumer gets from the bare `@shbernal/ts-pptx` specifier
|
|
9
|
+
* when neither the `node` nor the `browser` export condition resolves — Deno, Bun, edge workers.
|
|
10
|
+
* Node and browser consumers reach `ts-pptx/node` and `ts-pptx/browser` through those conditions
|
|
11
|
+
* without naming them, and get the same class backed by an adapter that can reach their host.
|
|
12
|
+
*
|
|
13
|
+
* Authoring is identical on all three. The difference is only where the finished deck can go:
|
|
14
|
+
* `write`, `stream` and `toParts` hand the bytes back here as everywhere, while `writeFile`
|
|
15
|
+
* throws `runtime/file-output-unavailable` because there is no filesystem and no DOM to write
|
|
16
|
+
* to. Live-DOM `tableToSlides` is likewise absent — it is defined on the browser entry, and the
|
|
17
|
+
* DOM-agnostic form is the free `tableToSlides` on `ts-pptx/html`.
|
|
18
|
+
*/
|
|
19
|
+
declare class TsPptx extends PresentationCore {
|
|
20
|
+
constructor();
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { ANGLE_UNITS_PER_DEGREE, AddSlideProps, AlignH, AlignV, AnimationProps, AnimationTrigger, BackgroundProps, BorderProps, BulletType, CHART_NAME, CONNECTOR_PRESETS, CONNECTOR_PRESET_NAME, ChartAreaProps, ChartAxisTickMark, ChartDataPointStyle, ChartErrorBarOptions, ChartExBinning, ChartExGeography, ChartExStatistics, ChartLineDash, ChartMulti, ChartOpts, ChartPropsAxisCat, ChartPropsAxisSer, ChartPropsAxisVal, ChartPropsBase, ChartPropsChartBar, ChartPropsChartBoxWhisker, ChartPropsChartDoughnut, ChartPropsChartHistogram, ChartPropsChartLine, ChartPropsChartPie, ChartPropsChartRadar, ChartPropsChartRegionMap, ChartPropsChartStock, ChartPropsChartSurface, ChartPropsChartWaterfall, ChartPropsDataLabel, ChartPropsDataTable, ChartPropsFillLine, ChartPropsLegend, ChartPropsTitle, ChartSeriesOpts, ChartType, Color, CommentProps, ConnectorProps, ConnectorType, Coord, CustomPropertyValue, DEFAULT_PX_PER_INCH, DataOrPathProps, DataOrPathRequiredProps, type Diagnostic, type DiagnosticCode, type DiagnosticHandler, EMU_PER_INCH, EMU_PER_POINT, Emu, type ErrorCode, FIXED_PCT_PER_PERCENT, GeometryPoint, GradientFillProps, GradientStopProps, GroupChildProps, GroupProps, HAlign, HUNDREDTHS_PER_POINT, HexColor, HyperlinkActionJump, HyperlinkProps, ImageBaseProps, ImageFillProps, ImageProps, InternalError, type InternalErrorCode, InvalidOptionError, type InvalidOptionErrorCode, LineCap, LinearGradientFillProps, Margin, MasterBulletProps, MasterTextStyleLevel, MasterTextStyleProps, MeasureTextOptions, MediaError, type MediaErrorCode, MediaProps, MediaType, NotesProps, NotesTextOptions, ObjectLockProps, ObjectNameProps, ObjectOptions, OleObjectProps, OptsChartData, OptsChartGridLine, OutputType, OverflowBoxOptions, PERCENT_SCALE, PLACEHOLDER_TYPE, POINTS_PER_INCH, PackagePart, PackageReadError, type PackageReadErrorCode, PartsProps, PatternFillProps, PatternPreset, PlaceholderProps, PlaceholderType, PositionProps, PresLayout, PresentationProps, PresetEffect, RadialGradientFillProps, ResolvedCommentAuthor, SCHEME_COLORS, SHAPE_NAME, STANDARD_LAYOUTS, SchemeColor, SectionProps, SectionZoomProps, ShadowProps, ShapeAdjustHandle, ShapeAdjustHandlePolar, ShapeAdjustHandleXY, ShapeAdjustValue, ShapeConnectionSite, ShapeFillProps, ShapeGuide, ShapeLineProps, ShapeProps, ShapeType, Slide, SlideComment, SlideLayout, SlideMasterChartProps, SlideMasterObject, SlideMasterProps, SlideNumberProps, SlideObjectType, SlideZoomProps, StandardLayout, StandardLayoutName, SummaryZoomProps, TableCell, TableCellLayout, TableCellProps, TableLayoutResult, TableProps, TableRow, TableRowSlide, TableStyle, TableStyleProps, TableStyleRegionProps, TableToSlidesDocument, TableToSlidesElement, TableToSlidesProps, TextAnchor, TextBaseProps, TextFitShrinkProps, TextGlowProps, TextMeasurement, TextProps, TextPropsOptions, TextVertType, ThemeColor, ThemeColorScheme, ThemeProps, TransitionProps, TransitionSoundProps, TransitionType, TsPptx, TsPptx as default, type TsPptxCode, TsPptxError, type TsPptxErrorOptions, UnsupportedFeatureError, type UnsupportedFeatureErrorCode, VALID_SHAPE_PRESETS, VAlign, WRITE_OUTPUT_TYPE, WriteBaseProps, WriteFileProps, WriteProps, ZIP_OUTPUT_TYPE, ZoomBaseProps, asChartType, connectorPresetFor, coordToEmu, emuToInches, emuToPixels, emuToPoints, inchesToEmu, isChartExType, percentToEmu, pixelsToEmu, pointsToEmu, ptToHundredths, setDiagnosticHandler, textRun, textRuns };
|
|
24
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;cAea,eAAe;EAAA"}
|