pptx-ts 0.0.1 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/README.md +116 -269
  2. package/dist/autopage-odPz7zZO.js +536 -0
  3. package/dist/autopage-odPz7zZO.js.map +1 -0
  4. package/dist/binary-string-CKVAYI3M.js +24 -0
  5. package/dist/binary-string-CKVAYI3M.js.map +1 -0
  6. package/dist/body-insets-Dw_BeWD_.js +54 -0
  7. package/dist/body-insets-Dw_BeWD_.js.map +1 -0
  8. package/dist/browser.d.ts +29 -9
  9. package/dist/browser.d.ts.map +1 -1
  10. package/dist/browser.js +41 -14
  11. package/dist/browser.js.map +1 -1
  12. package/dist/clip-Bl01BPcN.d.ts +67 -0
  13. package/dist/clip-Bl01BPcN.d.ts.map +1 -0
  14. package/dist/diagnostics-D8ot4Ei7.d.ts +244 -0
  15. package/dist/diagnostics-D8ot4Ei7.d.ts.map +1 -0
  16. package/dist/embedded-fonts-DarT9aoa.d.ts +20 -0
  17. package/dist/embedded-fonts-DarT9aoa.d.ts.map +1 -0
  18. package/dist/entry-compose-DCnvBZz2.d.ts +1046 -0
  19. package/dist/entry-compose-DCnvBZz2.d.ts.map +1 -0
  20. package/dist/{enums-CvRYniUA.d.ts → enums-BUKTUB6V.d.ts} +21 -13
  21. package/dist/{enums-CvRYniUA.d.ts.map → enums-BUKTUB6V.d.ts.map} +1 -1
  22. package/dist/{errors-Bvln0H-7.js → errors-C4oENPcu.js} +92 -2
  23. package/dist/errors-C4oENPcu.js.map +1 -0
  24. package/dist/families.d.ts +260 -0
  25. package/dist/families.d.ts.map +1 -0
  26. package/dist/families.js +57 -0
  27. package/dist/families.js.map +1 -0
  28. package/dist/{fit-BKs0zxMI.js → fit-Cb7naFj6.js} +249 -167
  29. package/dist/fit-Cb7naFj6.js.map +1 -0
  30. package/dist/font-metrics-v5fn7s7e.d.ts +613 -0
  31. package/dist/font-metrics-v5fn7s7e.d.ts.map +1 -0
  32. package/dist/grid-DikTjFey.js +187 -0
  33. package/dist/grid-DikTjFey.js.map +1 -0
  34. package/dist/{html-dom-B0I0QSbU.js → html-dom-Iuog2wdK.js} +121 -91
  35. package/dist/html-dom-Iuog2wdK.js.map +1 -0
  36. package/dist/html.d.ts +6 -6
  37. package/dist/html.d.ts.map +1 -1
  38. package/dist/html.js +7 -6
  39. package/dist/html.js.map +1 -1
  40. package/dist/image-size-CvN2iCA4.js +1611 -0
  41. package/dist/image-size-CvN2iCA4.js.map +1 -0
  42. package/dist/index.d.ts +24 -10
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +31 -11
  45. package/dist/index.js.map +1 -1
  46. package/dist/inspect.d.ts +40 -31
  47. package/dist/inspect.d.ts.map +1 -1
  48. package/dist/inspect.js +40 -48
  49. package/dist/inspect.js.map +1 -1
  50. package/dist/math.d.ts +7 -5
  51. package/dist/math.d.ts.map +1 -1
  52. package/dist/math.js +16 -7
  53. package/dist/math.js.map +1 -1
  54. package/dist/measure.d.ts +12 -225
  55. package/dist/measure.d.ts.map +1 -1
  56. package/dist/measure.js +3 -3
  57. package/dist/node.d.ts +22 -8
  58. package/dist/node.d.ts.map +1 -1
  59. package/dist/node.js +27 -7
  60. package/dist/node.js.map +1 -1
  61. package/dist/notes-Dh12JAbn.js +3264 -0
  62. package/dist/notes-Dh12JAbn.js.map +1 -0
  63. package/dist/options-internal-WqgMf720.js +43 -0
  64. package/dist/options-internal-WqgMf720.js.map +1 -0
  65. package/dist/{package-CaOLXSNi.d.ts → package-J49Ck6S2.d.ts} +27 -12
  66. package/dist/package-J49Ck6S2.d.ts.map +1 -0
  67. package/dist/playbtn-CUqQdoDf.js +22 -0
  68. package/dist/playbtn-CUqQdoDf.js.map +1 -0
  69. package/dist/{slide-js0QpRV-.d.ts → pres-C6qgOFAa.d.ts} +1021 -1370
  70. package/dist/pres-C6qgOFAa.d.ts.map +1 -0
  71. package/dist/{presentation-Cp7vzlAw.js → presentation-DGYlAWhl.js} +3208 -2727
  72. package/dist/presentation-DGYlAWhl.js.map +1 -0
  73. package/dist/{presentation-types-DP_8jog7.d.ts → presentation-types-8jLQHI4M.d.ts} +1070 -683
  74. package/dist/presentation-types-8jLQHI4M.d.ts.map +1 -0
  75. package/dist/read.d.ts +9 -9
  76. package/dist/read.d.ts.map +1 -1
  77. package/dist/read.js +4 -4
  78. package/dist/script.d.ts +80 -66
  79. package/dist/script.d.ts.map +1 -1
  80. package/dist/script.js +2399 -1139
  81. package/dist/script.js.map +1 -1
  82. package/dist/{shapes-BemroU-z.js → shapes-re0KyQk_.js} +2807 -1609
  83. package/dist/shapes-re0KyQk_.js.map +1 -0
  84. package/dist/slide-Dx2ZeVZ6.d.ts +1256 -0
  85. package/dist/slide-Dx2ZeVZ6.d.ts.map +1 -0
  86. package/dist/slide-size-BalTjFuv.js +88 -0
  87. package/dist/slide-size-BalTjFuv.js.map +1 -0
  88. package/dist/{units-internal-Dg95w_YD.js → table-cell-margins-EVg0EwxT.js} +235 -273
  89. package/dist/table-cell-margins-EVg0EwxT.js.map +1 -0
  90. package/dist/table-dom-BTDP3lEP.js +21 -0
  91. package/dist/table-dom-BTDP3lEP.js.map +1 -0
  92. package/dist/text-KnLOtEEu.js +3980 -0
  93. package/dist/text-KnLOtEEu.js.map +1 -0
  94. package/dist/text-anchor-CrYXAfUu.js +176 -0
  95. package/dist/text-anchor-CrYXAfUu.js.map +1 -0
  96. package/dist/transition-speed-kUEWDWTx.js +14 -0
  97. package/dist/transition-speed-kUEWDWTx.js.map +1 -0
  98. package/dist/units-internal-XJlf-hOl.js +649 -0
  99. package/dist/units-internal-XJlf-hOl.js.map +1 -0
  100. package/dist/zip-C0leZZMj.d.ts +67 -0
  101. package/dist/zip-C0leZZMj.d.ts.map +1 -0
  102. package/dist/zip-CKd8ihcf.js +177 -0
  103. package/dist/zip-CKd8ihcf.js.map +1 -0
  104. package/dist/zip.d.ts +3 -68
  105. package/dist/zip.js +3 -163
  106. package/dist/zoom-cX9sllpH.js +8865 -0
  107. package/dist/zoom-cX9sllpH.js.map +1 -0
  108. package/package.json +106 -19
  109. package/skills/ts-pptx-upstream/SKILL.md +58 -57
  110. package/dist/autopage-DkjYZUFD.js +0 -423
  111. package/dist/autopage-DkjYZUFD.js.map +0 -1
  112. package/dist/diagnostics-Du_s75MT.d.ts +0 -829
  113. package/dist/diagnostics-Du_s75MT.d.ts.map +0 -1
  114. package/dist/errors-Bvln0H-7.js.map +0 -1
  115. package/dist/errors-PflMPWBn.d.ts +0 -182
  116. package/dist/errors-PflMPWBn.d.ts.map +0 -1
  117. package/dist/fit-BKs0zxMI.js.map +0 -1
  118. package/dist/html-dom-B0I0QSbU.js.map +0 -1
  119. package/dist/namespaces-BVnNu7sg.js +0 -666
  120. package/dist/namespaces-BVnNu7sg.js.map +0 -1
  121. package/dist/notes-RLCwdlTE.js +0 -1703
  122. package/dist/notes-RLCwdlTE.js.map +0 -1
  123. package/dist/package-CaOLXSNi.d.ts.map +0 -1
  124. package/dist/pres-C5__xkDh.d.ts +0 -202
  125. package/dist/pres-C5__xkDh.d.ts.map +0 -1
  126. package/dist/presentation-Cp7vzlAw.js.map +0 -1
  127. package/dist/presentation-types-DP_8jog7.d.ts.map +0 -1
  128. package/dist/shapes-BemroU-z.js.map +0 -1
  129. package/dist/slide-js0QpRV-.d.ts.map +0 -1
  130. package/dist/text-CyetbF6p.js +0 -11278
  131. package/dist/text-CyetbF6p.js.map +0 -1
  132. package/dist/units-1kRzYShk.js +0 -231
  133. package/dist/units-1kRzYShk.js.map +0 -1
  134. package/dist/units-internal-Dg95w_YD.js.map +0 -1
  135. package/dist/zip.d.ts.map +0 -1
  136. package/dist/zip.js.map +0 -1
package/dist/math.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"math.js","names":[],"sources":["../src/math.ts"],"sourcesContent":["/**\n * `@shbernal/ts-pptx/math` — author display equations in LaTeX or MathML and get\n * OMML for the `math:` option on `addText` (see {@link TextProps.math}).\n *\n * Pipeline: LaTeX --temml--> MathML --mathml2omml--> OMML.\n *\n * Both converters are **optional peer dependencies** (temml is MIT, mathml2omml is\n * LGPL-3.0-or-later); install them to use this subpath:\n *\n * ```sh\n * npm install temml mathml2omml\n * ```\n *\n * This subpath is **Node-only**: it loads the converters synchronously via\n * `node:module`'s `createRequire`, so `latexToOmml()` / `mathmlToOmml()` stay\n * synchronous. Both display and inline (in-sentence) equations are supported: a\n * default `latexToOmml()` returns a centered display `<m:oMathPara>`, while\n * `latexToOmml(tex, { display: false })` (and `mathmlToOmml()`) return the bare\n * `<m:oMath>` form you pass to a text item with `inline: true` to flow it\n * mid-paragraph (see {@link TextProps.inline}).\n *\n * @module\n */\nimport { createRequire } from 'node:module'\nimport { InvalidOptionError, UnsupportedFeatureError } from './errors.js'\n\nconst nodeRequire = createRequire(import.meta.url)\n\n/** Minimal shape of the temml API we depend on. */\ninterface TemmlModule {\n\trenderToString(latex: string, options?: { displayMode?: boolean; throwOnError?: boolean }): string\n}\n/** temml's `ParseError` carries a `position` (character offset into the source). */\ninterface TemmlParseError extends Error {\n\tposition?: number\n}\n\nconst MISSING_DEPS_MESSAGE =\n\t\"@shbernal/ts-pptx/math requires the optional peer dependencies 'temml' and \" +\n\t\"'mathml2omml'. Install them with: npm install temml mathml2omml\"\n\n/** Require an optional peer, remapping a not-found error to the install hint. */\nfunction requirePeer<T>(id: string): T {\n\ttry {\n\t\treturn nodeRequire(id) as T\n\t} catch (err) {\n\t\tif ((err as NodeJS.ErrnoException | undefined)?.code === 'MODULE_NOT_FOUND') {\n\t\t\tthrow new UnsupportedFeatureError('math/missing-optional-peer', MISSING_DEPS_MESSAGE, { cause: err })\n\t\t}\n\t\tthrow err\n\t}\n}\n\nlet temmlModule: TemmlModule | undefined\nlet mml2ommlFn: ((mathml: string) => string) | undefined\n\nfunction loadTemml(): TemmlModule {\n\tif (!temmlModule) {\n\t\tconst mod = requirePeer<TemmlModule | { default: TemmlModule }>('temml')\n\t\ttemmlModule = 'renderToString' in mod ? mod : mod.default\n\t}\n\treturn temmlModule\n}\n\nfunction loadMml2omml(): (mathml: string) => string {\n\tif (!mml2ommlFn) {\n\t\tconst mod = requirePeer<{ mml2omml: (mathml: string) => string }>('mathml2omml')\n\t\tmml2ommlFn = mod.mml2omml\n\t}\n\treturn mml2ommlFn\n}\n\n/**\n * mathml2omml puts namespace declarations on the `<m:oMath>` opening tag: `xmlns:m`\n * (redundant — the `<a14:m>` envelope the `math:` option authors already declares it)\n * and `xmlns:w` (unused in the output it produces). Strip them so the result is a bare\n * `<m:oMath>` that drops into the `math:` option cleanly.\n */\nfunction stripOMathNamespaces(omml: string): string {\n\treturn omml.replace(/^(\\s*<m:oMath)\\b[^>]*>/, '$1>')\n}\n\n/** Centered-display paragraph props, matching what the `math:` emitter/oracle author. */\nconst DISPLAY_PARA_PR = '<m:oMathParaPr><m:jc m:val=\"centerGroup\"/></m:oMathParaPr>'\n\n/**\n * The operator-dictionary subset this module has to carry, keyed by the character temml\n * puts in the `<mo>` of an accent and valued by the combining mark OMML wants in `m:chr`.\n *\n * Two halves of one problem. **Which** `<mover>`s are accents: temml renders every accent\n * command as a bare `<mover>` with no `accent=\"true\"`, which is correct for a browser —\n * MathML renderers derive accent positioning from the operator dictionary, so the attribute\n * is redundant there — but mathml2omml has no dictionary and keys strictly off the\n * attribute, mapping a bare `<mover>` to `<m:limUpp>` (an over-*limit*, with limit spacing)\n * instead of `<m:acc>`. Membership in this table is the dictionary lookup that is otherwise\n * missing. **Which character** to attach: mathml2omml passes the `<mo>` text straight\n * through to `m:chr`, and temml emits the *spacing* modifiers (U+02C6 MODIFIER LETTER\n * CIRCUMFLEX, U+2192 RIGHTWARDS ARROW) while ECMA-376 §22.1.2.20 says an `accPr` character\n * \"should be within the range of (U+0300–U+036F) or (U+20D0–U+20EF)\" — the combining marks,\n * which is also what Word itself writes. Left alone, `\\vec{v}` would hang a full-size arrow\n * over the base instead of an arrow accent.\n *\n * Keyed by character rather than by LaTeX command because that is all that survives into\n * the MathML. Derived by rendering every accent command temml documents and reading back\n * the `<mo>` it produced; the commands each entry serves are named in the comments.\n */\nconst ACCENT_CHARS = new Map<string, string>([\n\t['ˆ', '̂'], // ˆ \\hat, \\^ → COMBINING CIRCUMFLEX ACCENT\n\t['~', '̃'], // ~ \\tilde, \\~ → COMBINING TILDE\n\t['´', '́'], // ´ \\acute → COMBINING ACUTE ACCENT\n\t['ˊ', '́'], // ˊ \\' → COMBINING ACUTE ACCENT\n\t['`', '̀'], // ` \\grave → COMBINING GRAVE ACCENT\n\t['ˋ', '̀'], // ˋ \\` → COMBINING GRAVE ACCENT\n\t['¨', '̈'], // ¨ \\ddot, \\\" → COMBINING DIAERESIS\n\t['˙', '̇'], // ˙ \\dot, \\. → COMBINING DOT ABOVE\n\t['‾', '̄'], // ‾ \\bar → COMBINING MACRON\n\t['ˉ', '̄'], // ˉ \\= → COMBINING MACRON\n\t['˘', '̆'], // ˘ \\breve, \\u → COMBINING BREVE\n\t['ˇ', '̌'], // ˇ \\check, \\v → COMBINING CARON\n\t['˚', '̊'], // ˚ \\mathring, \\r → COMBINING RING ABOVE\n\t['˝', '̋'], // ˝ \\H → COMBINING DOUBLE ACUTE ACCENT\n\t['→', '⃗'], // → \\vec → COMBINING RIGHT ARROW ABOVE\n\t['…', '⃛'], // … \\dddot → COMBINING THREE DOTS ABOVE\n])\n\n/** An `<mover>`'s last child, when that child is an `<mo>`: `[, attributes, text]`. */\nconst TRAILING_MO = /<mo\\b([^>]*)>([^<]*)<\\/mo>\\s*$/\n\n/**\n * Stamp `accent=\"true\"` on the `<mover>`s that are accents, and swap their operator for the\n * combining mark OMML wants. See {@link ACCENT_CHARS} for why both are needed.\n *\n * Scoped as narrowly as the defect. Only `<mo stretchy=\"false\">` qualifies, which is how\n * temml distinguishes a true accent from a *wide* one (`\\widehat`, `\\overrightarrow`) or a\n * group character (`\\overbrace`, `\\overgroup`) — those already reach `m:groupChr`, which is\n * a reasonable rendering, so they are left alone rather than churned. `\\stackrel` is an\n * over-relation whose character comes from the caller, so it stays `m:limUpp` unless the\n * caller happened to stack a diacritic. An `<mover>` that already states `accent` is the\n * author's call and is never rewritten.\n *\n * `<munder>` is deliberately **not** touched. The symmetric-looking fix — stamping\n * `accentunder=\"true\"` — makes mathml2omml emit `<m:acc>`, which is an *over*-accent: it\n * would move `\\utilde`'s tilde above the base. OMML has no under-accent object, so the\n * `m:limLow` an under-accent already produces is the closest thing available.\n *\n * Implemented against the tag text rather than through a DOM. temml's output is\n * machine-generated and well-formed, so pairing `<mover>` with `</mover>` on a stack is\n * exact, and this subpath otherwise carries no XML parser — the read path's is a different\n * dependency and pulling it in here would grow the module for one rewrite.\n */\nfunction markAccentedMovers(mathml: string): string {\n\tconst edits: { at: number; length: number; text: string }[] = []\n\tconst open: number[] = []\n\tconst tags = /<(\\/?)mover\\b[^>]*>/g\n\tfor (let tag = tags.exec(mathml); tag !== null; tag = tags.exec(mathml)) {\n\t\tif (tag[1] === '') {\n\t\t\t// `accent` already stated: the author has answered the question this asks.\n\t\t\topen.push(tag[0].includes('accent=') ? -1 : tag.index)\n\t\t\tcontinue\n\t\t}\n\t\tconst openAt = open.pop()\n\t\tif (openAt === undefined || openAt === -1) continue\n\n\t\tconst openEnd = mathml.indexOf('>', openAt) + 1\n\t\tconst mo = TRAILING_MO.exec(mathml.slice(openEnd, tag.index))\n\t\tif (!mo) continue\n\t\tconst [whole, attrs = '', operator = ''] = mo\n\t\t// `stretchy=\"false\"` is how temml separates a true accent from a wide one\n\t\t// (`\\widehat`) or a group character (`\\overbrace`); those already map well.\n\t\tif (!attrs.includes('stretchy=\"false\"')) continue\n\t\tconst combining = ACCENT_CHARS.get(operator)\n\t\t// A multi-character operator (`\\ddddot` renders as \"….\") has no single `m:chr`, so it\n\t\t// is not in the table and keeps the limit form rather than producing an invalid one.\n\t\tif (combining === undefined) continue\n\n\t\t// Applied right-to-left below, so earlier offsets stay valid.\n\t\tedits.push({\n\t\t\tat: openEnd + mo.index + whole.length - `${operator}</mo>`.length,\n\t\t\tlength: operator.length,\n\t\t\ttext: combining,\n\t\t})\n\t\tedits.push({ at: openAt + '<mover'.length, length: 0, text: ' accent=\"true\"' })\n\t}\n\n\tlet out = mathml\n\tfor (const edit of edits.sort((a, b) => b.at - a.at)) {\n\t\tout = out.slice(0, edit.at) + edit.text + out.slice(edit.at + edit.length)\n\t}\n\treturn out\n}\n\n/**\n * Convert a MathML string to OMML for the `math:` option on `addText`.\n *\n * Canonical output form: a bare `<m:oMath>…</m:oMath>` in the `m:` namespace, with no\n * namespace declarations (the `math:` option's envelope supplies the `m` prefix).\n *\n * @param mathml - a MathML string (e.g. `<math>…</math>`)\n * @returns OMML `<m:oMath>…</m:oMath>`\n */\nexport function mathmlToOmml(mathml: string): string {\n\tconst mml2omml = loadMml2omml()\n\treturn stripOMathNamespaces(mml2omml(mathml).trim())\n}\n\nexport interface LatexToOmmlOptions {\n\t/**\n\t * Display (block) math: render in `displayMode` and wrap the result in\n\t * `<m:oMathPara>` (a centered display-math paragraph). Default `true`. When `false`,\n\t * temml renders in inline mode and the result is a bare `<m:oMath>`.\n\t */\n\tdisplay?: boolean\n}\n\n/**\n * Convert a LaTeX string to OMML for the `math:` option on `addText`.\n *\n * Display math (the default) is returned as a full `<m:oMathPara>` centered display\n * paragraph; with `{ display: false }` a bare `<m:oMath>` is returned (both forms are\n * accepted by the `math:` option). Throws on invalid LaTeX, surfacing temml's parse\n * position.\n *\n * @param latex - a LaTeX math expression, e.g. `x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}`\n * @param opts - see {@link LatexToOmmlOptions}\n * @returns OMML `<m:oMathPara>…</m:oMathPara>` (display) or `<m:oMath>…</m:oMath>` (inline)\n * @throws {Error} if the LaTeX cannot be parsed\n */\nexport function latexToOmml(latex: string, opts: LatexToOmmlOptions = {}): string {\n\tconst display = opts.display ?? true\n\tconst temml = loadTemml()\n\tlet mathml: string\n\ttry {\n\t\tmathml = temml.renderToString(latex, { displayMode: display, throwOnError: true })\n\t} catch (err) {\n\t\tconst pe = err as TemmlParseError\n\t\tconst pos = typeof pe.position === 'number' ? ` (position ${pe.position})` : ''\n\t\tthrow new InvalidOptionError('math/invalid-latex', `Invalid LaTeX${pos}: ${pe.message}`, { cause: err })\n\t}\n\t// Applied here rather than in `mathmlToOmml`, because it compensates for something temml\n\t// does: a caller handing in their own MathML states `accent` themselves, and rewriting it\n\t// under them would be the module second-guessing an attribute the MathML spec gives them.\n\tconst oMath = mathmlToOmml(markAccentedMovers(mathml))\n\treturn display ? `<m:oMathPara>${DISPLAY_PARA_PR}${oMath}</m:oMathPara>` : oMath\n}\n\n// Error taxonomy — see `entry-errors.ts`. Re-exported from every entry so `instanceof`\n// works whichever subpath a consumer imports.\nexport * from './entry-errors.js'\n"],"mappings":"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"}
1
+ {"version":3,"file":"math.js","names":[],"sources":["../src/math.ts"],"sourcesContent":["/**\n * Author display equations in LaTeX or MathML and get\n * OMML for the `math:` option on `addText` (see `TextProps.math`).\n *\n * Pipeline: LaTeX --temml--> MathML --mathml2omml--> OMML.\n *\n * Both converters are **optional peer dependencies** (temml is MIT, mathml2omml is\n * LGPL-3.0-or-later); install them to use this subpath:\n *\n * ```sh\n * npm install temml mathml2omml\n * ```\n *\n * This subpath is **Node-only**: it loads the converters synchronously via\n * `node:module`'s `createRequire`, so `latexToOmml()` / `mathmlToOmml()` stay\n * synchronous. Both display and inline (in-sentence) equations are supported: a\n * default `latexToOmml()` returns a centered display `<m:oMathPara>`, while\n * `latexToOmml(tex, { display: false })` (and `mathmlToOmml()`) return the bare\n * `<m:oMath>` form you pass to a text item with `inline: true` to flow it\n * mid-paragraph (see `TextProps.inline`).\n *\n * @module\n */\nimport { createRequire } from 'node:module'\nimport { InvalidOptionError, UnsupportedFeatureError } from './errors.js'\n\nconst nodeRequire = createRequire(import.meta.url)\n\n/** Minimal shape of the temml API we depend on. */\ninterface TemmlModule {\n\trenderToString(latex: string, options?: { displayMode?: boolean; throwOnError?: boolean }): string\n}\n/** temml's `ParseError` carries a `position` (character offset into the source). */\ninterface TemmlParseError extends Error {\n\tposition?: number\n}\n\nconst MISSING_DEPS_MESSAGE =\n\t\"pptx-ts/math requires the optional peer dependencies 'temml' and \" +\n\t\"'mathml2omml'. Install them with: npm install temml mathml2omml\"\n\n/** Require an optional peer, remapping a not-found error to the install hint. */\nfunction requirePeer<T>(id: string): T {\n\ttry {\n\t\treturn nodeRequire(id) as T\n\t} catch (err) {\n\t\tif ((err as NodeJS.ErrnoException | undefined)?.code === 'MODULE_NOT_FOUND') {\n\t\t\tthrow new UnsupportedFeatureError('math/missing-optional-peer', MISSING_DEPS_MESSAGE, { cause: err })\n\t\t}\n\t\tthrow err\n\t}\n}\n\nlet temmlModule: TemmlModule | undefined\nlet mml2ommlFn: ((mathml: string) => string) | undefined\n\nfunction loadTemml(): TemmlModule {\n\tif (!temmlModule) {\n\t\tconst mod = requirePeer<TemmlModule | { default: TemmlModule }>('temml')\n\t\ttemmlModule = 'renderToString' in mod ? mod : mod.default\n\t}\n\treturn temmlModule\n}\n\nfunction loadMml2omml(): (mathml: string) => string {\n\tif (!mml2ommlFn) {\n\t\tconst mod = requirePeer<{ mml2omml: (mathml: string) => string }>('mathml2omml')\n\t\tmml2ommlFn = mod.mml2omml\n\t}\n\treturn mml2ommlFn\n}\n\n/**\n * mathml2omml puts namespace declarations on the `<m:oMath>` opening tag: `xmlns:m`\n * (redundant — the `<a14:m>` envelope the `math:` option authors already declares it)\n * and `xmlns:w` (unused in the output it produces). Strip them so the result is a bare\n * `<m:oMath>` that drops into the `math:` option cleanly.\n */\nfunction stripOMathNamespaces(omml: string): string {\n\treturn omml.replace(/^(\\s*<m:oMath)\\b[^>]*>/, '$1>')\n}\n\n/** Centered-display paragraph props, matching what the `math:` emitter/oracle author. */\nconst DISPLAY_PARA_PR = '<m:oMathParaPr><m:jc m:val=\"centerGroup\"/></m:oMathParaPr>'\n\n/**\n * The operator-dictionary subset this module has to carry, keyed by the character temml\n * puts in the `<mo>` of an accent and valued by the combining mark OMML wants in `m:chr`.\n *\n * Two halves of one problem. **Which** `<mover>`s are accents: temml renders every accent\n * command as a bare `<mover>` with no `accent=\"true\"`, which is correct for a browser —\n * MathML renderers derive accent positioning from the operator dictionary, so the attribute\n * is redundant there — but mathml2omml has no dictionary and keys strictly off the\n * attribute, mapping a bare `<mover>` to `<m:limUpp>` (an over-*limit*, with limit spacing)\n * instead of `<m:acc>`. Membership in this table is the dictionary lookup that is otherwise\n * missing. **Which character** to attach: mathml2omml passes the `<mo>` text straight\n * through to `m:chr`, and temml emits the *spacing* modifiers (U+02C6 MODIFIER LETTER\n * CIRCUMFLEX, U+2192 RIGHTWARDS ARROW) while ECMA-376 §22.1.2.20 says an `accPr` character\n * \"should be within the range of (U+0300–U+036F) or (U+20D0–U+20EF)\" — the combining marks,\n * which is also what Word itself writes. Left alone, `\\vec{v}` would hang a full-size arrow\n * over the base instead of an arrow accent.\n *\n * Keyed by character rather than by LaTeX command because that is all that survives into\n * the MathML. Derived by rendering every accent command temml documents and reading back\n * the `<mo>` it produced; the commands each entry serves are named in the comments.\n */\nconst ACCENT_CHARS = new Map<string, string>([\n\t['ˆ', '̂'], // ˆ \\hat, \\^ → COMBINING CIRCUMFLEX ACCENT\n\t['~', '̃'], // ~ \\tilde, \\~ → COMBINING TILDE\n\t['´', '́'], // ´ \\acute → COMBINING ACUTE ACCENT\n\t['ˊ', '́'], // ˊ \\' → COMBINING ACUTE ACCENT\n\t['`', '̀'], // ` \\grave → COMBINING GRAVE ACCENT\n\t['ˋ', '̀'], // ˋ \\` → COMBINING GRAVE ACCENT\n\t['¨', '̈'], // ¨ \\ddot, \\\" → COMBINING DIAERESIS\n\t['˙', '̇'], // ˙ \\dot, \\. → COMBINING DOT ABOVE\n\t['‾', '̄'], // ‾ \\bar → COMBINING MACRON\n\t['ˉ', '̄'], // ˉ \\= → COMBINING MACRON\n\t['˘', '̆'], // ˘ \\breve, \\u → COMBINING BREVE\n\t['ˇ', '̌'], // ˇ \\check, \\v → COMBINING CARON\n\t['˚', '̊'], // ˚ \\mathring, \\r → COMBINING RING ABOVE\n\t['˝', '̋'], // ˝ \\H → COMBINING DOUBLE ACUTE ACCENT\n\t['→', '⃗'], // → \\vec → COMBINING RIGHT ARROW ABOVE\n\t['…', '⃛'], // … \\dddot → COMBINING THREE DOTS ABOVE\n])\n\n/** An `<mover>`'s last child, when that child is an `<mo>`: `[, attributes, text]`. */\nconst TRAILING_MO = /<mo\\b([^>]*)>([^<]*)<\\/mo>\\s*$/\n\n/**\n * Stamp `accent=\"true\"` on the `<mover>`s that are accents, and swap their operator for the\n * combining mark OMML wants. See {@link ACCENT_CHARS} for why both are needed.\n *\n * Scoped as narrowly as the defect. Only `<mo stretchy=\"false\">` qualifies, which is how\n * temml distinguishes a true accent from a *wide* one (`\\widehat`, `\\overrightarrow`) or a\n * group character (`\\overbrace`, `\\overgroup`) — those already reach `m:groupChr`, which is\n * a reasonable rendering, so they are left alone rather than churned. `\\stackrel` is an\n * over-relation whose character comes from the caller, so it stays `m:limUpp` unless the\n * caller happened to stack a diacritic. An `<mover>` that already states `accent` is the\n * author's call and is never rewritten.\n *\n * `<munder>` is deliberately **not** touched. The symmetric-looking fix — stamping\n * `accentunder=\"true\"` — makes mathml2omml emit `<m:acc>`, which is an *over*-accent: it\n * would move `\\utilde`'s tilde above the base. OMML has no under-accent object, so the\n * `m:limLow` an under-accent already produces is the closest thing available.\n *\n * Implemented against the tag text rather than through a DOM. temml's output is\n * machine-generated and well-formed, so pairing `<mover>` with `</mover>` on a stack is\n * exact, and this subpath otherwise carries no XML parser — the read path's is a different\n * dependency and pulling it in here would grow the module for one rewrite.\n */\nfunction markAccentedMovers(mathml: string): string {\n\tconst edits: { at: number; length: number; text: string }[] = []\n\tconst open: number[] = []\n\tconst tags = /<(\\/?)mover\\b[^>]*>/g\n\tfor (let tag = tags.exec(mathml); tag !== null; tag = tags.exec(mathml)) {\n\t\tif (tag[1] === '') {\n\t\t\t// `accent` already stated: the author has answered the question this asks.\n\t\t\topen.push(tag[0].includes('accent=') ? -1 : tag.index)\n\t\t\tcontinue\n\t\t}\n\t\tconst openAt = open.pop()\n\t\tif (openAt === undefined || openAt === -1) continue\n\n\t\tconst openEnd = mathml.indexOf('>', openAt) + 1\n\t\tconst mo = TRAILING_MO.exec(mathml.slice(openEnd, tag.index))\n\t\tif (!mo) continue\n\t\tconst [whole, attrs = '', operator = ''] = mo\n\t\t// `stretchy=\"false\"` is how temml separates a true accent from a wide one\n\t\t// (`\\widehat`) or a group character (`\\overbrace`); those already map well.\n\t\tif (!attrs.includes('stretchy=\"false\"')) continue\n\t\tconst combining = ACCENT_CHARS.get(operator)\n\t\t// A multi-character operator (`\\ddddot` renders as \"….\") has no single `m:chr`, so it\n\t\t// is not in the table and keeps the limit form rather than producing an invalid one.\n\t\tif (combining === undefined) continue\n\n\t\t// Applied right-to-left below, so earlier offsets stay valid.\n\t\tedits.push({\n\t\t\tat: openEnd + mo.index + whole.length - `${operator}</mo>`.length,\n\t\t\tlength: operator.length,\n\t\t\ttext: combining,\n\t\t})\n\t\tedits.push({ at: openAt + '<mover'.length, length: 0, text: ' accent=\"true\"' })\n\t}\n\n\tlet out = mathml\n\tfor (const edit of edits.sort((a, b) => b.at - a.at)) {\n\t\tout = out.slice(0, edit.at) + edit.text + out.slice(edit.at + edit.length)\n\t}\n\treturn out\n}\n\n/**\n * Convert a MathML string to OMML for the `math:` option on `addText`.\n *\n * Canonical output form: a bare `<m:oMath>…</m:oMath>` in the `m:` namespace, with no\n * namespace declarations (the `math:` option's envelope supplies the `m` prefix).\n *\n * @param mathml - a MathML string (e.g. `<math>…</math>`)\n * @returns OMML `<m:oMath>…</m:oMath>`\n * @throws {InvalidOptionError} `math/invalid-mathml` when the input has no `<math>` element, or\n * does not convert to an equation. The converter returns the string `'undefined'` for such input.\n */\nexport function mathmlToOmml(mathml: string): string {\n\tconst mml2omml = loadMml2omml()\n\tif (typeof mathml !== 'string' || !/<(?:[\\w-]+:)?math[\\s>]/.test(mathml)) {\n\t\tconst got = typeof mathml === 'string' ? JSON.stringify(mathml.slice(0, 40)) : typeof mathml\n\t\tthrow new InvalidOptionError(\n\t\t\t'math/invalid-mathml',\n\t\t\t`mathmlToOmml: expected MathML with a <math> element, got ${got}`\n\t\t)\n\t}\n\tconst omml = stripOMathNamespaces(String(mml2omml(mathml)).trim())\n\t// The root element's name, read rather than matched as a tag: this checks the converter's output\n\t// and builds nothing.\n\tif (/^<([\\w:]+)/.exec(omml)?.[1] !== 'm:oMath') {\n\t\tthrow new InvalidOptionError('math/invalid-mathml', 'mathmlToOmml: the MathML did not convert to an OMML equation')\n\t}\n\treturn omml\n}\n\nexport interface LatexToOmmlOptions {\n\t/**\n\t * Display (block) math: render in `displayMode` and wrap the result in\n\t * `<m:oMathPara>` (a centered display-math paragraph). Default `true`. When `false`,\n\t * temml renders in inline mode and the result is a bare `<m:oMath>`.\n\t */\n\tdisplay?: boolean\n}\n\n/**\n * Convert a LaTeX string to OMML for the `math:` option on `addText`.\n *\n * Display math (the default) is returned as a full `<m:oMathPara>` centered display\n * paragraph; with `{ display: false }` a bare `<m:oMath>` is returned (both forms are\n * accepted by the `math:` option). Throws on invalid LaTeX, surfacing temml's parse\n * position.\n *\n * @param latex - a LaTeX math expression, e.g. `x = \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a}`\n * @param opts - see {@link LatexToOmmlOptions}\n * @returns OMML `<m:oMathPara>…</m:oMathPara>` (display) or `<m:oMath>…</m:oMath>` (inline)\n * @throws {Error} if the LaTeX cannot be parsed\n */\nexport function latexToOmml(latex: string, opts: LatexToOmmlOptions = {}): string {\n\tconst display = opts.display ?? true\n\tconst temml = loadTemml()\n\tlet mathml: string\n\ttry {\n\t\tmathml = temml.renderToString(latex, { displayMode: display, throwOnError: true })\n\t} catch (err) {\n\t\tconst pe = err as TemmlParseError\n\t\tconst pos = typeof pe.position === 'number' ? ` (position ${pe.position})` : ''\n\t\tthrow new InvalidOptionError('math/invalid-latex', `Invalid LaTeX${pos}: ${pe.message}`, { cause: err })\n\t}\n\t// Applied here rather than in `mathmlToOmml`, because it compensates for something temml\n\t// does: a caller handing in their own MathML states `accent` themselves, and rewriting it\n\t// under them would be the module second-guessing an attribute the MathML spec gives them.\n\tconst oMath = mathmlToOmml(markAccentedMovers(mathml))\n\treturn display ? `<m:oMathPara>${DISPLAY_PARA_PR}${oMath}</m:oMathPara>` : oMath\n}\n\n// Error taxonomy — see `entry-errors.ts`. Re-exported from every entry so `instanceof`\n// works whichever subpath a consumer imports.\nexport * from './entry-errors.js'\n\n// Diagnostics — see `entry-diagnostics.ts`. Re-exported from every entry so a consumer of any\n// subpath can install a handler for the warnings that subpath emits.\nexport * from './entry-diagnostics.js'\n"],"mappings":"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"}
package/dist/measure.d.ts CHANGED
@@ -1,219 +1,6 @@
1
- import { Qt as MeasureTextOptions, dn as TextPropsOptions, i as ObjectOptions, ln as TextMeasurement, tn as OverflowBoxOptions, un as TextProps } from "./slide-js0QpRV-.js";
2
- 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-PflMPWBn.js";
3
- //#region src/measure/font-metrics.d.ts
4
- /** Per-(face,bold,italic) advance-width source backed by a parsed font file. */
5
- interface FontMetrics {
6
- /** Font design units per em (advances are in these units). */
7
- readonly unitsPerEm: number;
8
- /**
9
- * Advance width of `text` at `sizePt`, in points. Sums raw glyph advances
10
- * (no kerning) and adds `charSpacingPt` after every character, matching how
11
- * PowerPoint widens runs with character spacing.
12
- */
13
- advanceWidthPt: (text: string, sizePt: number, charSpacingPt?: number) => number;
14
- /**
15
- * True if this face's cmap maps code point `cp` to a real glyph (not the
16
- * `.notdef` fallback). Use it to flag source code points the face cannot
17
- * render. Authoritative only for file-backed metrics; the unregistered-font
18
- * heuristic has no cmap and reports every code point as covered.
19
- */
20
- hasCodepoint: (cp: number) => boolean;
21
- }
22
- /**
23
- * Shared, font-independent `FontMetrics` used when a named face has no registered
24
- * metrics but the deck has opted into measured fit (some other face is registered).
25
- * Approximate but conservative — see {@link heuristicCharRatio}. A deck with no
26
- * registered metrics at all does not engage measured fit, so this never fires there.
27
- */
28
- declare function getHeuristicFontMetrics(): FontMetrics;
29
- /** Options for {@link parseFontMetrics}. */
30
- interface ParseFontMetricsOptions {
31
- /**
32
- * Which font to read out of a file that holds several: a 0-based index, or a name
33
- * matched case-insensitively against the family, full, and PostScript names
34
- * (`listFontFaces` lists them). Omitted selects the first.
35
- *
36
- * Collections (`.ttc`/`.otc`) are why this exists: `msgothic.ttc` is three fonts and
37
- * `cambria.ttc` is two. The selector means the same thing for a plain TTF/OTF, which
38
- * is a one-entry list, so a wrong index or an unmatched name is an error there rather
39
- * than being ignored.
40
- */
41
- readonly font?: number | string;
42
- }
43
- /**
44
- * Parse a font file into a `FontMetrics`. Lazily imports opentype.js.
45
- *
46
- * Reads plain TTF/OTF and **font collections** (`.ttc`/`.otc`); for a collection, pass
47
- * `font` to say which member, since a collection has no single answer. The underlying
48
- * parser does not read the `ttcf` wrapper, so the selected member is unwrapped into a
49
- * standalone sfnt first (see `measure/font-collection.ts`).
50
- * @param {Uint8Array} data - the font file's bytes
51
- * @param {ParseFontMetricsOptions} [opts] - which font, for a file holding several
52
- * @returns {Promise<FontMetrics>} advance widths and cmap coverage for that font
53
- * @example await parseFontMetrics(bytes) // a plain .ttf
54
- * @example await parseFontMetrics(ttcBytes, { font: 'MS PGothic' })
55
- */
56
- declare function parseFontMetrics(data: Uint8Array, opts?: ParseFontMetricsOptions): Promise<FontMetrics>;
57
- /**
58
- * Registry of `FontMetrics` keyed by `(face, bold, italic)`. Variant advances
59
- * differ, so bold/italic are stored separately; lookup falls back to the regular
60
- * variant (then any registered variant of the face) so a deck that only registers
61
- * the regular weight still measures bold runs approximately rather than not at all.
62
- */
63
- declare class FontMetricsRegistry {
64
- private readonly map;
65
- private key;
66
- set(face: string, metrics: FontMetrics, opts?: {
67
- bold?: boolean;
68
- italic?: boolean;
69
- }): void;
70
- /** True if any variant of `face` has registered metrics. */
71
- hasFace(face: string): boolean;
72
- /**
73
- * Coverage of code point `cp` for `face`, read from the registered font's cmap:
74
- * `true`/`false` when a variant of `face` is registered (see {@link get} for the
75
- * exact→regular→any-variant fallback), or `undefined` when the face has **no**
76
- * registered metrics — "unknown", deliberately distinct from a `false`
77
- * "registered but not covered". A coverage audit must not treat an unregistered
78
- * face as fully covered, so callers get `undefined` here rather than the per-face
79
- * {@link FontMetrics.hasCodepoint} boolean (which, for the heuristic fallback,
80
- * always reports covered). Register the face via {@link parseFontMetrics} +
81
- * {@link set} first.
82
- */
83
- hasCodepoint(face: string | undefined | null, cp: number, opts?: {
84
- bold?: boolean;
85
- italic?: boolean;
86
- }): boolean | undefined;
87
- /** Resolve metrics for a run, falling back from exact variant → regular → any variant. */
88
- get(face: string | undefined | null, bold?: boolean, italic?: boolean): FontMetrics | undefined;
89
- get size(): number;
90
- }
91
- /**
92
- * A {@link MetricsResolver} backed by a registry: exact metrics for a registered face, otherwise
93
- * the shared heuristic fallback (with `onHeuristic` told which face it stood in for). A run with
94
- * no `fontFace` at all resolves to `undefined`, which the callers treat as unmeasurable.
95
- */
96
- declare function makeRegistryResolver(registry: FontMetricsRegistry, onHeuristic?: (face: string) => void): MetricsResolver;
97
- //#endregion
98
- //#region src/measure/text-fit.d.ts
99
- /**
100
- * PowerPoint single-spacing line pitch as a multiple of font size.
101
- *
102
- * Calibrated from `autofit-calibration.json` (Deck 1, `autofit-line-metrics`):
103
- * the per-line `cy` delta is a **font-independent** 1.2117× at 12/18/32 pt across
104
- * {Aptos, Aptos SemiBold, Calibri, Tahoma, Arial}, and PowerPoint vs LibreOffice
105
- * agree to ≤ 0.041 pt. See `test/read/fixtures/README.md` → "Findings" #1–#2.
106
- */
107
- declare const SINGLE_LINE_PITCH = 1.2117;
108
- /** PowerPoint's `fontScale` search grid: discrete 2.5% steps (Findings #3). */
109
- declare const FONT_SCALE_STEP_PCT = 2.5;
110
- /** Floor for the shrink search (see `docs/measured-text-fit.md` → Solvers). */
111
- declare const MIN_FONT_SCALE_PCT = 25;
112
- /**
113
- * Conservative safety factors applied by the shrink solver (not by the pure
114
- * `measureHeightPt`). Raw `hmtx` advances summed without shaping still pack a line
115
- * a little tighter than PowerPoint, which lays text out at a device DPI and rounds
116
- * each glyph advance up — so PowerPoint wraps marginally earlier and its fitted
117
- * box is marginally taller. Inflating measured width and height by these factors
118
- * makes the computed `fontScale` ≤ PowerPoint's across the calibration oracle
119
- * (`test/read/autofit-calibration-oracle.test.js`: 0 violations over the Aptos
120
- * cases). They err on the side of shrinking slightly too much, never overflowing.
121
- */
122
- declare const WIDTH_SAFETY_FACTOR = 1.03;
123
- declare const HEIGHT_SAFETY_FACTOR = 1.04;
124
- /** One text run with the inputs measurement needs. */
125
- interface FitRun {
126
- text: string;
127
- sizePt: number;
128
- bold?: boolean;
129
- italic?: boolean;
130
- fontFace?: string;
131
- /** Character spacing in points (PowerPoint `spc`/1200). */
132
- charSpacingPt?: number;
133
- }
134
- /** One paragraph: its runs plus vertical-rhythm options. */
135
- interface FitParagraph {
136
- runs: FitRun[];
137
- /** Line spacing as a percent of single (100 = single). Ignored if `lineSpacingPts` set. */
138
- lineSpacingPct?: number;
139
- /** Exact line spacing in points (overrides `lineSpacingPct`). */
140
- lineSpacingPts?: number;
141
- spaceBeforePts?: number;
142
- spaceAfterPts?: number;
143
- }
144
- /** Inner box (shape minus insets) the text must fit, in points. */
145
- interface FitBox {
146
- innerWidthPt: number;
147
- innerHeightPt: number;
148
- /**
149
- * `false` when the frame does not wrap (`wrap:false` / `wrap="none"`): text lays
150
- * out as one line per paragraph (no width-wrapping), and the shrink solver must
151
- * additionally keep the widest line within `innerWidthPt`. A too-wide line
152
- * overflows HORIZONTALLY — `normAutofit`'s vertical shrink never catches it, so
153
- * without this check a non-wrapping line is never shrunk and spills out of the box
154
- * in PowerPoint. Defaults to wrapping (`true`), so table cells and `measureText`
155
- * are unaffected.
156
- */
157
- wrap?: boolean;
158
- }
159
- /** Resolve the metrics for a run, or `undefined` if the face is not registered. */
160
- type MetricsResolver = (run: FitRun) => FontMetrics | undefined;
161
- interface ShrinkResult {
162
- fontScalePct: number;
163
- lnSpcReductionPct: number;
164
- }
165
- type ShrinkOutcome = {
166
- kind: 'fits';
167
- } | {
168
- kind: 'unmeasurable';
169
- } | {
170
- kind: 'shrink';
171
- result: ShrinkResult;
172
- };
173
- /** Laid-out result of {@link measureLayout}: total height (points) + wrapped line count. */
174
- interface LayoutResult {
175
- heightPt: number;
176
- lineCount: number;
177
- /**
178
- * Width (points) of the widest laid-out line across all paragraphs. Useful for
179
- * tightening a box to the actual text extent or measuring a natural (single-line)
180
- * width. Carries the same `widthSafety` inflation as the wrap decision, so a box
181
- * set to this width will not re-wrap. Conservative (slightly wide).
182
- */
183
- widestLineWidthPt: number;
184
- }
185
- /**
186
- * Lay out `paragraphs` at a given scale/reduction and return the total height
187
- * (points) and wrapped line count, or `null` if any paragraph is unmeasurable.
188
- * Errs tall (conservative): includes space-before/after and the calibrated line
189
- * pitch. The single source of truth for both {@link measureHeightPt} (the solvers)
190
- * and the public layout-time measure API.
191
- */
192
- declare function measureLayout(paragraphs: FitParagraph[], innerWidthPt: number, resolve: MetricsResolver, fontScalePct: number, lnSpcReductionPct: number, widthSafety?: number): LayoutResult | null;
193
- /**
194
- * Total laid-out height (points) at a given scale/reduction, or `null` if any
195
- * paragraph is unmeasurable. Thin wrapper over {@link measureLayout}.
196
- */
197
- declare function measureHeightPt(paragraphs: FitParagraph[], innerWidthPt: number, resolve: MetricsResolver, fontScalePct: number, lnSpcReductionPct: number, widthSafety?: number): number | null;
198
- /**
199
- * Largest `fontScale` (on PowerPoint's 2.5% grid) at which the text fits the box.
200
- * Width and height both re-measured per scale. Conservative: because the model
201
- * over-estimates, the returned scale is ≤ PowerPoint's and the text never overflows.
202
- *
203
- * `lnSpcReduction` is left at 0 in P1 — dropping `fontScale` alone is provably
204
- * conservative (PowerPoint trades line-spacing reduction to keep the font *larger*,
205
- * so a reduction-free fit is always ≤ PowerPoint's scale). The calibration data for
206
- * the reduction ramp (Findings #4) is recorded for a future refinement.
207
- */
208
- type ResizeOutcome = {
209
- kind: 'unmeasurable';
210
- } | {
211
- kind: 'resize';
212
- neededInnerHeightPt: number;
213
- };
214
- declare function solveResize(paragraphs: FitParagraph[], box: FitBox, resolve: MetricsResolver): ResizeOutcome;
215
- declare function solveShrink(paragraphs: FitParagraph[], box: FitBox, resolve: MetricsResolver): ShrinkOutcome;
216
- //#endregion
1
+ import { Bt as TextMeasurement, Ht as TextPropsOptions, Ot as MeasureTextOptions, Vt as TextProps, jt as OverflowBoxOptions } from "./pres-C6qgOFAa.js";
2
+ import { C as solveShrink, S as solveResize, _ as ShrinkOutcome, a as makeRegistryResolver, b as measureHeightPt, c as FitBox, d as HEIGHT_SAFETY_FACTOR, f as LayoutResult, g as SINGLE_LINE_PITCH, h as ResizeOutcome, i as getHeuristicFontMetrics, l as FitParagraph, m as MetricsResolver, n as FontMetricsRegistry, o as parseFontMetrics, p as MIN_FONT_SCALE_PCT, r as ParseFontMetricsOptions, s as FONT_SCALE_STEP_PCT, t as FontMetrics, u as FitRun, v as ShrinkResult, w as ObjectOptionsInternal, x as measureLayout, y as WIDTH_SAFETY_FACTOR } from "./font-metrics-v5fn7s7e.js";
3
+ import { _ as PackageReadErrorCode, a as InternalError, c as PackageReadError, d as UnsupportedFeatureError, f as DiagnosticCode, g as MediaErrorCode, h as InvalidOptionErrorCode, i as setDiagnosticHandler, l as TsPptxError, m as InternalErrorCode, n as DiagnosticHandler, o as InvalidOptionError, p as ErrorCode, r as resetDiagnosticState, s as MediaError, t as Diagnostic, u as TsPptxErrorOptions, v as TsPptxCode, y as UnsupportedFeatureErrorCode } from "./diagnostics-D8ot4Ei7.js";
217
4
  //#region src/measure/font-collection.d.ts
218
5
  /**
219
6
  * Font **collection** (`.ttc` / `.otc`) support for the write-side metrics.
@@ -261,7 +48,7 @@ interface FontFaceInfo {
261
48
  readonly postScriptName?: string;
262
49
  }
263
50
  /** True when `data` starts with the `ttcf` tag, i.e. holds more than one font. */
264
- declare function isFontCollection(data: Uint8Array): boolean;
51
+ export declare function isFontCollection(data: Uint8Array): boolean;
265
52
  /**
266
53
  * The fonts inside `data`, in file order. A plain TTF/OTF yields exactly one entry, so a
267
54
  * caller never has to branch on the container format.
@@ -274,18 +61,18 @@ declare function isFontCollection(data: Uint8Array): boolean;
274
61
  * @returns {FontFaceInfo[]} one entry per font, index-ordered
275
62
  * @example listFontFaces(readFileSync('C:/Windows/Fonts/msgothic.ttc')).map((f) => f.family)
276
63
  */
277
- declare function listFontFaces(data: Uint8Array): FontFaceInfo[];
64
+ export declare function listFontFaces(data: Uint8Array): FontFaceInfo[];
278
65
  //#endregion
279
66
  //#region src/measure/fit.d.ts
280
67
  /**
281
68
  * Layout-time text measurement against registered metrics — the public engine
282
69
  * behind `pptx.measureText()`. Uses the **same** calibrated wrap model, resolver
283
70
  * semantics, and conservative safety factors as the export-time bake
284
- * ({@link applyMeasuredFit} / {@link solveResize} / {@link solveShrink}), so a
71
+ * (`applyMeasuredFit` / {@link solveResize} / {@link solveShrink}), so a
285
72
  * layout-time prediction matches the value the export would bake **for any deck
286
73
  * that opted into measured fit (i.e. registered at least one face)**.
287
74
  *
288
- * With an **empty** registry the two intentionally diverge: {@link applyMeasuredFit}
75
+ * With an **empty** registry the two intentionally diverge: `applyMeasuredFit`
289
76
  * treats "no metrics" as "not opted in" and bakes nothing, while this returns
290
77
  * heuristic numbers so the API is useful with zero setup. Check
291
78
  * `approximatedFaces` if that distinction matters.
@@ -297,17 +84,17 @@ declare function listFontFaces(data: Uint8Array): FontFaceInfo[];
297
84
  * in `uncoveredCodepoints`, and are the one case where the height may come back short
298
85
  * rather than tall — there is no font fallback here, only the font's `.notdef` advance.
299
86
  */
300
- declare function measureText(registry: FontMetricsRegistry, text: string | TextProps[], opts: MeasureTextOptions): TextMeasurement;
87
+ export declare function measureText(registry: FontMetricsRegistry, text: string | TextProps[], opts: MeasureTextOptions): TextMeasurement;
301
88
  //#endregion
302
89
  //#region src/measure/paragraphs.d.ts
303
- type RunOpts = TextPropsOptions & ObjectOptions;
90
+ type RunOpts = TextPropsOptions & ObjectOptionsInternal;
304
91
  /**
305
92
  * Convert a run list (+ box-level default options) into a measurable
306
93
  * `FitParagraph[]`, or null if empty. The single converter shared by the
307
- * export-time pass ({@link extractParagraphs}) and the public layout-time
94
+ * export-time pass (`extractParagraphs`) and the public layout-time
308
95
  * `measureText` API, so a layout-time prediction and the baked export never drift.
309
96
  */
310
- declare function buildFitParagraphs(runs: TextProps[], opts: RunOpts): FitParagraph[] | null;
97
+ export declare function buildFitParagraphs(runs: TextProps[], opts: RunOpts): FitParagraph[] | null;
311
98
  //#endregion
312
- export { type ErrorCode, FONT_SCALE_STEP_PCT, type FitBox, type FitParagraph, type FitRun, type FontFaceInfo, type FontMetrics, FontMetricsRegistry, HEIGHT_SAFETY_FACTOR, InternalError, type InternalErrorCode, InvalidOptionError, type InvalidOptionErrorCode, type LayoutResult, MIN_FONT_SCALE_PCT, type MeasureTextOptions, MediaError, type MediaErrorCode, type MetricsResolver, type OverflowBoxOptions, PackageReadError, type PackageReadErrorCode, type ParseFontMetricsOptions, type ResizeOutcome, SINGLE_LINE_PITCH, type ShrinkOutcome, type ShrinkResult, type TextMeasurement, type TsPptxCode, TsPptxError, type TsPptxErrorOptions, UnsupportedFeatureError, type UnsupportedFeatureErrorCode, WIDTH_SAFETY_FACTOR, buildFitParagraphs, getHeuristicFontMetrics, isFontCollection, listFontFaces, makeRegistryResolver, measureHeightPt, measureLayout, measureText, parseFontMetrics, solveResize, solveShrink };
99
+ export { type Diagnostic, type DiagnosticCode, type DiagnosticHandler, type ErrorCode, FONT_SCALE_STEP_PCT, type FitBox, type FitParagraph, type FitRun, type FontFaceInfo, type FontMetrics, FontMetricsRegistry, HEIGHT_SAFETY_FACTOR, InternalError, type InternalErrorCode, InvalidOptionError, type InvalidOptionErrorCode, type LayoutResult, MIN_FONT_SCALE_PCT, type MeasureTextOptions, MediaError, type MediaErrorCode, type MetricsResolver, type OverflowBoxOptions, PackageReadError, type PackageReadErrorCode, type ParseFontMetricsOptions, type ResizeOutcome, SINGLE_LINE_PITCH, type ShrinkOutcome, type ShrinkResult, type TextMeasurement, type TsPptxCode, TsPptxError, type TsPptxErrorOptions, UnsupportedFeatureError, type UnsupportedFeatureErrorCode, WIDTH_SAFETY_FACTOR, getHeuristicFontMetrics, makeRegistryResolver, measureHeightPt, measureLayout, parseFontMetrics, resetDiagnosticState, setDiagnosticHandler, solveResize, solveShrink };
313
100
  //# sourceMappingURL=measure.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"measure.d.ts","names":[],"sources":["../src/measure/font-metrics.ts","../src/measure/text-fit.ts","../src/measure/font-collection.ts","../src/measure/fit.ts","../src/measure/paragraphs.ts"],"mappings":";;;;UAmBiB;;WAEP;;;;;;EAMT,iBAAiB,cAAc,gBAAgB;;;;;;;EAO/C,eAAe;;;;;;;;iBAgGA,2BAA2B;;UAM1B;;;;;;;;;;;WAWP;;;;;;;;;;;;;;;iBAgBY,iBAAiB,MAAM,YAAY,OAAO,0BAA0B,QAAQ;;;;;;;cA4BrF;mBACK;UAET;EAIR,IAAI,cAAc,SAAS,aAAa;IAAS;IAAgB;;;EAKjE,QAAQ;;;;;;;;;;;;EAiBR,aACC,iCACA,YACA;IAAS;IAAgB;;;EAM1B,IAAI,iCAAiC,gBAAc,mBAAiB;MAahE;;;;;;;iBAUW,qBACf,UAAU,qBACV,eAAe,wBACb;;;;;;;;;;;cCvOU;;cAGA;;cAGA;;;;;;;;;;;cAYA;cACA;;UAGI;EAChB;EACA;EACA;EACA;EACA;;EAEA;;;UAIgB;EAChB,MAAM;;EAEN;;EAEA;EACA;EACA;;;UAIgB;EAChB;EACA;;;;;;;;;;EAUA;;;KAIW,mBAAmB,KAAK,WAAW;UAE9B;EAChB;EACA;;KAGW;EACP;;EACA;;EACA;EAAgB,QAAQ;;;UAiMZ;EAChB;EACA;;;;;;;EAOA;;;;;;;;;iBAUe,cACf,YAAY,gBACZ,sBACA,SAAS,iBACT,sBACA,2BACA,uBACE;;;;;iBA0Ba,gBACf,YAAY,gBACZ,sBACA,SAAS,iBACT,sBACA,2BACA;;;;;;;;;;;KAgBW;EACP;;EACA;EAAgB;;iBAoBL,YAAY,YAAY,gBAAgB,KAAK,QAAQ,SAAS,kBAAkB;iBAMhF,YAAY,YAAY,gBAAgB,KAAK,QAAQ,SAAS,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UClV/E;;WAEP;;WAEA;;WAEA;;WAEA;;WAEA;;;iBA+BM,iBAAiB,MAAM;;;;;;;;;;;;;iBA0HvB,cAAc,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;iBC1GjC,YACf,UAAU,qBACV,eAAe,aACf,MAAM,qBACJ;;;KCzFS,UAAU,mBAAmB;;;;;;;iBA8BzB,mBAAmB,MAAM,aAAa,MAAM,UAAU"}
1
+ {"version":3,"file":"measure.d.ts","names":[],"sources":["../src/measure/font-collection.ts","../src/measure/fit.ts","../src/measure/paragraphs.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAmDiB;;WAEP;;WAEA;;WAEA;;WAEA;;WAEA;;;wBA+BM,iBAAiB,MAAM;;;;;;;;;;;;;wBA0HvB,cAAc,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;wBC5GjC,YACf,UAAU,qBACV,eAAe,aACf,MAAM,qBACJ;;;KCzFS,UAAU,mBAAmB;;;;;;;wBAoDzB,mBAAmB,MAAM,aAAa,MAAM,UAAU"}
package/dist/measure.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as TsPptxError, i as PackageReadError, n as InvalidOptionError, o as UnsupportedFeatureError, r as MediaError, t as InternalError } from "./errors-Bvln0H-7.js";
2
- import { _ as parseFontMetrics, a as FONT_SCALE_STEP_PCT, c as SINGLE_LINE_PITCH, d as measureLayout, f as solveResize, g as makeRegistryResolver, h as getHeuristicFontMetrics, i as buildFitParagraphs, l as WIDTH_SAFETY_FACTOR, m as FontMetricsRegistry, n as measureText, o as HEIGHT_SAFETY_FACTOR, p as solveShrink, s as MIN_FONT_SCALE_PCT, u as measureHeightPt, v as isFontCollection, y as listFontFaces } from "./fit-BKs0zxMI.js";
3
- export { FONT_SCALE_STEP_PCT, FontMetricsRegistry, HEIGHT_SAFETY_FACTOR, InternalError, InvalidOptionError, MIN_FONT_SCALE_PCT, MediaError, PackageReadError, SINGLE_LINE_PITCH, TsPptxError, UnsupportedFeatureError, WIDTH_SAFETY_FACTOR, buildFitParagraphs, getHeuristicFontMetrics, isFontCollection, listFontFaces, makeRegistryResolver, measureHeightPt, measureLayout, measureText, parseFontMetrics, solveResize, solveShrink };
1
+ import { a as TsPptxError, c as setDiagnosticHandler, i as PackageReadError, n as InvalidOptionError, o as UnsupportedFeatureError, r as MediaError, s as resetDiagnosticState, t as InternalError } from "./errors-C4oENPcu.js";
2
+ import { _ as getHeuristicFontMetrics, b as isFontCollection, c as HEIGHT_SAFETY_FACTOR, d as WIDTH_SAFETY_FACTOR, f as measureHeightPt, g as FontMetricsRegistry, h as solveShrink, l as MIN_FONT_SCALE_PCT, m as solveResize, n as measureText, o as buildFitParagraphs, p as measureLayout, s as FONT_SCALE_STEP_PCT, u as SINGLE_LINE_PITCH, v as makeRegistryResolver, x as listFontFaces, y as parseFontMetrics } from "./fit-Cb7naFj6.js";
3
+ export { FONT_SCALE_STEP_PCT, FontMetricsRegistry, HEIGHT_SAFETY_FACTOR, InternalError, InvalidOptionError, MIN_FONT_SCALE_PCT, MediaError, PackageReadError, SINGLE_LINE_PITCH, TsPptxError, UnsupportedFeatureError, WIDTH_SAFETY_FACTOR, buildFitParagraphs, getHeuristicFontMetrics, isFontCollection, listFontFaces, makeRegistryResolver, measureHeightPt, measureLayout, measureText, parseFontMetrics, resetDiagnosticState, setDiagnosticHandler, solveResize, solveShrink };
package/dist/node.d.ts CHANGED
@@ -1,20 +1,34 @@
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, w as isChartType, x as asChartType, y as WRITE_OUTPUT_TYPE } from "./enums-CvRYniUA.js";
2
- import { $ as BorderProps, $t as NotesProps, A as TableToSlidesDocument, At as ChartPropsChartHistogram, B as GradientStopProps, Bt as ChartPropsFillLine, C as TableCell, Cn as ShapeConnectionSite, Ct as ChartPropsAxisCat, D as TableProps, Dt as ChartPropsChartBar, E as TableCellProps, Et as ChartPropsBase, F as Coord, Ft as ChartPropsChartStock, G as Margin, Gt as OptsChartData, H as HexColor, Ht as ChartPropsTitle, I as DataOrPathProps, It as ChartPropsChartSurface, J as PositionProps, Jt as ObjectLockProps, K as PatternFillProps, Kt as OptsChartGridLine, L as DataOrPathRequiredProps, Lt as ChartPropsChartWaterfall, M as TableToSlidesProps, Mt as ChartPropsChartPie, N as BackgroundProps, Nt as ChartPropsChartRadar, O as TableRow, Ot as ChartPropsChartBoxWhisker, P as Color, Pt as ChartPropsChartRegionMap, Q as VAlign, Qt as MeasureTextOptions, R as GeometryPoint, Rt as ChartPropsDataLabel, S as TransitionType, Sn as ShapeAdjustValue, St as ChartOpts, T as TableCellDiagonals, Tn as ShapeProps, Tt as ChartPropsAxisVal, U as ImageFillProps, Ut as ChartSeriesOpts, V as HAlign, Vt as ChartPropsLegend, W as LinearGradientFillProps, Wt as LineCap, X as TextVertType, Xt as PlaceholderProps, Y as RadialGradientFillProps, Yt as ObjectNameProps, Z as ThemeColor, Zt as CommentProps, _ as AnimationProps, _n as MediaType, _t as ChartExBinning, a as Slide, an as TableLayoutResult, at as ShapeFillProps, b as TransitionProps, bn as ShapeAdjustHandlePolar, bt as ChartLineDash, c as Model3dPoint, cn as TextGlowProps, d as MasterTextStyleLevel, dn as TextPropsOptions, dt as PresetMaterialType, en as NotesTextOptions, et as ConnectorProps, f as MasterTextStyleProps, fn as textRun, g as SlideNumberProps, gn as MediaProps, gt as ChartErrorBarOptions, h as SlideMasterProps, hn as ImageProps, ht as ChartDataPointStyle, i as ObjectOptions, in as TableCellLayout, it as ShadowProps, j as TableToSlidesElement, jt as ChartPropsChartLine, k as TableRowSlide, kt as ChartPropsChartDoughnut, l as Model3dProps, ln as TextMeasurement, lt as LightRigDirection, m as SlideMasterObject, mn as ImageBaseProps, mt as ChartAxisTickMark, n as GroupChildProps, nn as ResolvedCommentAuthor, nt as HyperlinkActionJump, o as SlideLayout, on as TextBaseProps, ot as ShapeLineProps, p as SlideMasterChartProps, pn as textRuns, pt as ChartAreaProps, q as PatternPreset, qt as CommonObjectDescriptor, r as GroupProps, rn as SlideComment, rt as HyperlinkProps, s as Model3dCameraProps, sn as TextFitShrinkProps, st as BevelPresetType, t as AddSlideProps, tn as OverflowBoxOptions, tt as ConnectorType, u as MasterBulletProps, un as TextProps, ut as LightRigType, v as AnimationTrigger, vn as OleObjectProps, vt as ChartExGeography, w as TableCell3DProps, wn as ShapeGuide, wt as ChartPropsAxisSer, x as TransitionSoundProps, xn as ShapeAdjustHandleXY, xt as ChartMulti, y as PresetEffect, yn as ShapeAdjustHandle, yt as ChartExStatistics, z as GradientFillProps, zt as ChartPropsDataTable } from "./slide-js0QpRV-.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-C5__xkDh.js";
4
- import { A as ptToHundredths, C as emuToInches, D as percentToEmu, E as inchesToEmu, M as SlideZoomProps, N as SummaryZoomProps, O as pixelsToEmu, P as ZoomBaseProps, S as coordToEmu, T as emuToPoints, _ as PERCENT_SCALE, a as ClipShape, b as StandardLayout, c as clipPath, d as DEFAULT_PX_PER_INCH, f as EMU_PER_INCH, g as HUNDREDTHS_PER_POINT, h as FIXED_PCT_PER_PERCENT, i as setDiagnosticHandler, j as SectionZoomProps, k as pointsToEmu, l as PresentationCore, m as Emu, n as DiagnosticHandler, o as FlatSide, p as EMU_PER_POINT, r as resetDiagnosticState, s as HalfDiscPreset, t as Diagnostic, u as ANGLE_UNITS_PER_DEGREE, v as POINTS_PER_INCH, w as emuToPixels, x as StandardLayoutName, y as STANDARD_LAYOUTS } from "./diagnostics-Du_s75MT.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-PflMPWBn.js";
1
+ import { C as isChartType, S as isChartExType, _ as VALID_SHAPE_PRESETS, a as CONNECTOR_PRESET_NAME, b as asChartType, c as PLACEHOLDER_TYPE, d as SHAPE_NAME, f as SchemeColor, g as TextAnchor, h as TableStyle, i as CHART_NAME, l as PlaceholderType, m as SlideObjectType, n as AlignV, o as ChartType, p as ShapeType, r as BulletType, s as OutputType, t as AlignH, u as SCHEME_COLORS, v as WRITE_OUTPUT_TYPE, x as connectorPresetFor, y as ZIP_OUTPUT_TYPE } from "./enums-BUKTUB6V.js";
2
+ import { $ as ChartPropsAxisCat, $t as ShapeAdjustValue, A as TextVertType, At as NotesTextOptions, B as ShapeFillProps, Bt as TextMeasurement, C as ImageFillProps, Cn as TimeUnit, Ct as CommonObjectDescriptor, D as PatternPreset, Dt as CommentProps, E as PatternFillProps, Et as PlaceholderProps, F as ConnectorType, Ft as TableLayoutResult, G as ChartDataPointStyle, Gt as ImageBaseProps, H as StrokeProps, Ht as TextPropsOptions, I as FillOption, It as TextBaseProps, J as ChartExGeography, Jt as MediaType, K as ChartErrorBarOptions, Kt as ImageProps, L as HyperlinkActionJump, Lt as TextBulletProps, M as VAlign, Mt as ResolvedCommentAuthor, N as BorderProps, Nt as SlideComment, O as PositionProps, Ot as MeasureTextOptions, P as ConnectorProps, Pt as TableCellLayout, Q as ChartOpts, Qt as ShapeAdjustHandleXY, R as HyperlinkProps, Rt as TextFitShrinkProps, S as HexColor, St as OptsChartGridLine, T as Margin, Tt as ObjectNameProps, U as ChartAreaProps, Ut as textRun, V as ShapeLineProps, Vt as TextProps, W as ChartAxisTickMark, Wt as textRuns, X as ChartLineDash, Xt as ShapeAdjustHandle, Y as ChartExStatistics, Yt as OleObjectProps, Z as ChartMulti, Zt as ShapeAdjustHandlePolar, _ as DataOrPathRequiredProps, _n as RadarStyleAlias, _t as ChartPropsLegend, a as PresentationProps, an as BarGrouping, at as ChartPropsChartDoughnut, b as GradientStopProps, bt as LineCap, c as WriteFileProps, cn as DataLabelPosition, ct as ChartPropsChartPie, d as ThemeProps, dn as LegendPosition, dt as ChartPropsChartStock, en as ShapeConnectionSite, et as ChartPropsAxisSer, f as BackgroundOption, fn as LightRigDirection, ft as ChartPropsChartSurface, g as DataOrPathProps, gn as RadarStyle, gt as ChartPropsFillLine, h as Coord, hn as PresetMaterialType, ht as ChartPropsDataTable, i as PresLayout, in as BarDirection, it as ChartPropsChartBoxWhisker, j as ThemeColor, jt as OverflowBoxOptions, k as RadialGradientFillProps, kt as NotesProps, l as WriteProps, ln as DisplayBlanksAs, lt as ChartPropsChartRadar, m as Color, mn as LineDataSymbol, mt as ChartPropsDataLabel, n as PackagePart, nn as ShapeProps, nt as ChartPropsBase, o as SectionProps, on as BevelPresetType, ot as ChartPropsChartHistogram, p as BackgroundProps, pn as LightRigType, pt as ChartPropsChartWaterfall, q as ChartExBinning, qt as MediaProps, r as PartsProps, rn as Bar3DShape, rt as ChartPropsChartBar, s as WriteBaseProps, st as ChartPropsChartLine, t as CustomPropertyValue, tn as ShapeGuide, tt as ChartPropsAxisVal, u as ThemeColorScheme, ut as ChartPropsChartRegionMap, v as GeometryPoint, vt as ChartPropsTitle, w as LinearGradientFillProps, wt as ObjectLockProps, x as HAlign, xt as OptsChartData, y as GradientFillProps, yt as ChartSeriesOpts, z as ShadowProps, zt as TextGlowProps } from "./pres-C6qgOFAa.js";
3
+ import { A as TableCellDiagonals, C as AnimationTrigger, D as TransitionType, E as TransitionSoundProps, F as TableToSlidesDocument, I as TableToSlidesElement, L as TableToSlidesProps, M as TableProps, N as TableRow, O as TableCell, P as TableRowSlide, S as AnimationProps, T as TransitionProps, _ as MasterTextStyleProps, a as Slide, b as SlideMasterProps, c as SectionZoomProps, d as ZoomBaseProps, f as Model3dCameraProps, g as MasterTextStyleLevel, h as MasterBulletProps, i as ObjectOptions, j as TableCellProps, k as TableCell3DProps, l as SlideZoomProps, m as Model3dProps, n as GroupChildProps, o as SlideLayout, p as Model3dPoint, r as GroupProps, s as SlideObjectInfo, t as AddSlideProps, u as SummaryZoomProps, v as SlideMasterChartProps, w as PresetEffect, x as SlideNumberProps, y as SlideMasterObject } from "./slide-Dx2ZeVZ6.js";
4
+ import { _ as PackageReadErrorCode, a as InternalError, c as PackageReadError, d as UnsupportedFeatureError, f as DiagnosticCode, g as MediaErrorCode, h as InvalidOptionErrorCode, i as setDiagnosticHandler, l as TsPptxError, m as InternalErrorCode, n as DiagnosticHandler, o as InvalidOptionError, p as ErrorCode, r as resetDiagnosticState, s as MediaError, t as Diagnostic, u as TsPptxErrorOptions, v as TsPptxCode, y as UnsupportedFeatureErrorCode } from "./diagnostics-D8ot4Ei7.js";
5
+ import { A as pixelsToEmu, C as StandardLayoutName, D as emuToPoints, E as emuToPixels, M as ptToHundredths, O as inchesToEmu, S as StandardLayout, T as emuToInches, _ as HUNDREDTHS_PER_POINT, b as PERCENT_SCALE, c as ConstructFamily, g as FIXED_PCT_PER_PERCENT, h as Emu, i as ComposedSlide, j as pointsToEmu, k as percentToEmu, m as DEFAULT_PX_PER_INCH, n as Composed, p as ANGLE_UNITS_PER_DEGREE, r as ComposedPresentation, s as PresentationCore, t as ComposeOptions, v as MAX_COORDINATE_EMU, w as coordToEmu, x as STANDARD_LAYOUTS, y as MIN_COORDINATE_EMU } from "./entry-compose-DCnvBZz2.js";
6
+ import { a as EMU_PER_INCH, i as clipPath, n as FlatSide, o as EMU_PER_POINT, r as HalfDiscPreset, s as POINTS_PER_INCH, t as ClipShape } from "./clip-Bl01BPcN.js";
6
7
  //#region src/node.d.ts
7
8
  /**
8
9
  * The Node entry, reached through the `node` export condition — a consumer importing the bare
9
- * `@shbernal/ts-pptx` specifier under Node lands here without naming this subpath.
10
+ * `pptx-ts` specifier under Node lands here without naming this subpath.
10
11
  *
11
12
  * Same authoring API as every other entry (see `entry-surface.ts`); the runtime adapter is what
12
13
  * differs. This one can reach the filesystem, so `writeFile` writes a real file and media may be
13
14
  * loaded from a path — both of which throw on the runtime-agnostic entry.
14
15
  */
15
- declare class TsPptx extends PresentationCore {
16
+ export declare class TsPptx extends PresentationCore {
16
17
  constructor();
17
18
  }
19
+ /**
20
+ * Compose a presentation from the construct families it needs, on the Node adapter.
21
+ *
22
+ * The counterpart to {@link TsPptx}, which is composed with every family there is. This one costs
23
+ * what it carries: the core tier (text, shapes, images, groups, speaker notes) plus whatever
24
+ * `use` names, and nothing else reaches the bundle.
25
+ * @param {ComposeOptions} opts - the families to compose in, from `pptx-ts/families`
26
+ * @example
27
+ * import { createPresentation } from 'pptx-ts/node'
28
+ * import { charts } from 'pptx-ts/families'
29
+ * const pres = createPresentation({ use: [charts] })
30
+ */
31
+ export declare function createPresentation<const Fs extends readonly ConstructFamily[] = []>(opts?: ComposeOptions<Fs>): Composed<Fs>;
18
32
  //#endregion
19
- export { ANGLE_UNITS_PER_DEGREE, AddSlideProps, AlignH, AlignV, AnimationProps, AnimationTrigger, BackgroundProps, type BevelPresetType, 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, ClipShape, Color, CommentProps, CommonObjectDescriptor, 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, FlatSide, GeometryPoint, GradientFillProps, GradientStopProps, GroupChildProps, GroupProps, HAlign, HUNDREDTHS_PER_POINT, HalfDiscPreset, HexColor, HyperlinkActionJump, HyperlinkProps, ImageBaseProps, ImageFillProps, ImageProps, InternalError, type InternalErrorCode, InvalidOptionError, type InvalidOptionErrorCode, type LightRigDirection, type LightRigType, LineCap, LinearGradientFillProps, Margin, MasterBulletProps, MasterTextStyleLevel, MasterTextStyleProps, MeasureTextOptions, MediaError, type MediaErrorCode, MediaProps, MediaType, Model3dCameraProps, Model3dPoint, Model3dProps, 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, type PresetMaterialType, 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, TableCell3DProps, TableCellDiagonals, TableCellLayout, TableCellProps, TableLayoutResult, TableProps, TableRow, TableRowSlide, TableStyle, 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, clipPath, connectorPresetFor, coordToEmu, emuToInches, emuToPixels, emuToPoints, inchesToEmu, isChartExType, isChartType, percentToEmu, pixelsToEmu, pointsToEmu, ptToHundredths, resetDiagnosticState, setDiagnosticHandler, textRun, textRuns };
33
+ export { ANGLE_UNITS_PER_DEGREE, AddSlideProps, AlignH, AlignV, AnimationProps, AnimationTrigger, BackgroundOption, BackgroundProps, type Bar3DShape, type BarDirection, type BarGrouping, type BevelPresetType, BorderProps, BulletType, CHART_NAME, 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, ClipShape, Color, CommentProps, CommonObjectDescriptor, type ComposeOptions, type Composed, type ComposedPresentation, type ComposedSlide, ConnectorProps, ConnectorType, type ConstructFamily, Coord, CustomPropertyValue, DEFAULT_PX_PER_INCH, type DataLabelPosition, DataOrPathProps, DataOrPathRequiredProps, type Diagnostic, type DiagnosticCode, type DiagnosticHandler, type DisplayBlanksAs, EMU_PER_INCH, EMU_PER_POINT, Emu, type ErrorCode, FIXED_PCT_PER_PERCENT, FillOption, FlatSide, GeometryPoint, GradientFillProps, GradientStopProps, GroupChildProps, GroupProps, HAlign, HUNDREDTHS_PER_POINT, HalfDiscPreset, HexColor, HyperlinkActionJump, HyperlinkProps, ImageBaseProps, ImageFillProps, ImageProps, InternalError, type InternalErrorCode, InvalidOptionError, type InvalidOptionErrorCode, type LegendPosition, type LightRigDirection, type LightRigType, LineCap, type LineDataSymbol, LinearGradientFillProps, MAX_COORDINATE_EMU, MIN_COORDINATE_EMU, Margin, MasterBulletProps, MasterTextStyleLevel, MasterTextStyleProps, MeasureTextOptions, MediaError, type MediaErrorCode, MediaProps, MediaType, Model3dCameraProps, Model3dPoint, Model3dProps, 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, type PresetMaterialType, type RadarStyle, type RadarStyleAlias, 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, SlideObjectInfo, SlideObjectType, SlideZoomProps, StandardLayout, StandardLayoutName, StrokeProps, SummaryZoomProps, TableCell, TableCell3DProps, TableCellDiagonals, TableCellLayout, TableCellProps, TableLayoutResult, TableProps, TableRow, TableRowSlide, TableStyle, TableToSlidesDocument, TableToSlidesElement, TableToSlidesProps, TextAnchor, TextBaseProps, TextBulletProps, TextFitShrinkProps, TextGlowProps, TextMeasurement, TextProps, TextPropsOptions, TextVertType, ThemeColor, ThemeColorScheme, ThemeProps, type TimeUnit, TransitionProps, TransitionSoundProps, TransitionType, 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, clipPath, connectorPresetFor, coordToEmu, emuToInches, emuToPixels, emuToPoints, inchesToEmu, isChartExType, isChartType, percentToEmu, pixelsToEmu, pointsToEmu, ptToHundredths, resetDiagnosticState, setDiagnosticHandler, textRun, textRuns };
20
34
  //# sourceMappingURL=node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","names":[],"sources":["../src/node.ts"],"mappings":";;;;;;;;;;;;;;cAWa,eAAe;EAC3B"}
1
+ {"version":3,"file":"node.d.ts","names":[],"sources":["../src/node.ts"],"mappings":";;;;;;;;;;;;;;;qBAoBa,eAAe;EAC3B;;;;;;;;;;;;;;wBAiBe,yBAAyB,oBAAoB,wBAC5D,OAAO,eAAe,MACpB,SAAS"}
package/dist/node.js CHANGED
@@ -1,7 +1,6 @@
1
- import { _ as pointsToEmu, a as FIXED_PCT_PER_PERCENT, b as setDiagnosticHandler, c as POINTS_PER_INCH, d as emuToInches, f as emuToPixels, g as pixelsToEmu, h as percentToEmu, i as EMU_PER_POINT, l as STANDARD_LAYOUTS, m as inchesToEmu, n as DEFAULT_PX_PER_INCH, o as HUNDREDTHS_PER_POINT, p as emuToPoints, r as EMU_PER_INCH, s as PERCENT_SCALE, t as ANGLE_UNITS_PER_DEGREE, u as coordToEmu, v as ptToHundredths, y as resetDiagnosticState } from "./units-1kRzYShk.js";
2
- import { a as TsPptxError, i as PackageReadError, n as InvalidOptionError, o as UnsupportedFeatureError, r as MediaError, t as InternalError } from "./errors-Bvln0H-7.js";
3
- import { a as fetchMediaBase64, c as PresentationCore, i as fetchFontBytes, n as textRuns, o as isRemote, r as clipPath, s as placeholderSvgPreview, t as textRun } from "./text-CyetbF6p.js";
4
- import { $ as isChartExType, B as BulletType, G as SchemeColor, H as ChartType, J as TableStyle, K as ShapeType, Q as connectorPresetFor, R as AlignH, U as OutputType, V as CONNECTOR_PRESETS, W as PlaceholderType, X as VALID_SHAPE_PRESETS, Y as TextAnchor, Z as asChartType, et as isChartType, q as SlideObjectType, z as AlignV } from "./units-internal-Dg95w_YD.js";
1
+ import { a as TsPptxError, c as setDiagnosticHandler, i as PackageReadError, n as InvalidOptionError, o as UnsupportedFeatureError, r as MediaError, s as resetDiagnosticState, t as InternalError } from "./errors-C4oENPcu.js";
2
+ import { A as inchesToEmu, C as MIN_COORDINATE_EMU, D as emuToInches, E as coordToEmu, F as EMU_PER_INCH, I as EMU_PER_POINT, L as POINTS_PER_INCH, M as pixelsToEmu, N as pointsToEmu, O as emuToPixels, P as ptToHundredths, S as MAX_COORDINATE_EMU, T as STANDARD_LAYOUTS, _ as isChartType, a as ChartType, b as FIXED_PCT_PER_PERCENT, c as SchemeColor, d as TableStyle, f as TextAnchor, g as isChartExType, h as connectorPresetFor, i as BulletType, j as percentToEmu, k as emuToPoints, l as ShapeType, m as asChartType, n as AlignH, o as OutputType, p as VALID_SHAPE_PRESETS, r as AlignV, s as PlaceholderType, u as SlideObjectType, v as ANGLE_UNITS_PER_DEGREE, w as PERCENT_SCALE, x as HUNDREDTHS_PER_POINT, y as DEFAULT_PX_PER_INCH } from "./table-cell-margins-EVg0EwxT.js";
3
+ import { a as fetchMediaBase64, c as ALL_CONSTRUCT_FAMILIES, i as fetchFontBytes, l as composePresentation, n as textRuns, o as isRemote, r as clipPath, s as placeholderSvgPreview, t as textRun, u as PresentationCore } from "./text-KnLOtEEu.js";
5
4
  import { Buffer } from "node:buffer";
6
5
  import fs from "node:fs/promises";
7
6
  //#region src/runtime/node.ts
@@ -37,8 +36,14 @@ async function writeFile(fileName, data) {
37
36
  //#endregion
38
37
  //#region src/node.ts
39
38
  /**
39
+ * The Node authoring entry, which the bare `pptx-ts` specifier resolves to under the `node`
40
+ * export condition.
41
+ *
42
+ * @module
43
+ */
44
+ /**
40
45
  * The Node entry, reached through the `node` export condition — a consumer importing the bare
41
- * `@shbernal/ts-pptx` specifier under Node lands here without naming this subpath.
46
+ * `pptx-ts` specifier under Node lands here without naming this subpath.
42
47
  *
43
48
  * Same authoring API as every other entry (see `entry-surface.ts`); the runtime adapter is what
44
49
  * differs. This one can reach the filesystem, so `writeFile` writes a real file and media may be
@@ -46,10 +51,25 @@ async function writeFile(fileName, data) {
46
51
  */
47
52
  var TsPptx = class extends PresentationCore {
48
53
  constructor() {
49
- super(createNodeRuntime());
54
+ super(createNodeRuntime(), ALL_CONSTRUCT_FAMILIES);
50
55
  }
51
56
  };
57
+ /**
58
+ * Compose a presentation from the construct families it needs, on the Node adapter.
59
+ *
60
+ * The counterpart to {@link TsPptx}, which is composed with every family there is. This one costs
61
+ * what it carries: the core tier (text, shapes, images, groups, speaker notes) plus whatever
62
+ * `use` names, and nothing else reaches the bundle.
63
+ * @param {ComposeOptions} opts - the families to compose in, from `pptx-ts/families`
64
+ * @example
65
+ * import { createPresentation } from 'pptx-ts/node'
66
+ * import { charts } from 'pptx-ts/families'
67
+ * const pres = createPresentation({ use: [charts] })
68
+ */
69
+ function createPresentation(opts) {
70
+ return composePresentation(createNodeRuntime(), opts);
71
+ }
52
72
  //#endregion
53
- export { ANGLE_UNITS_PER_DEGREE, AlignH, AlignV, BulletType, CONNECTOR_PRESETS, ChartType, DEFAULT_PX_PER_INCH, EMU_PER_INCH, EMU_PER_POINT, FIXED_PCT_PER_PERCENT, HUNDREDTHS_PER_POINT, InternalError, InvalidOptionError, MediaError, OutputType, PERCENT_SCALE, POINTS_PER_INCH, PackageReadError, PlaceholderType, STANDARD_LAYOUTS, SchemeColor, ShapeType, SlideObjectType, TableStyle, TextAnchor, TsPptx, TsPptx as default, TsPptxError, UnsupportedFeatureError, VALID_SHAPE_PRESETS, asChartType, clipPath, connectorPresetFor, coordToEmu, emuToInches, emuToPixels, emuToPoints, inchesToEmu, isChartExType, isChartType, percentToEmu, pixelsToEmu, pointsToEmu, ptToHundredths, resetDiagnosticState, setDiagnosticHandler, textRun, textRuns };
73
+ export { ANGLE_UNITS_PER_DEGREE, AlignH, AlignV, BulletType, ChartType, DEFAULT_PX_PER_INCH, EMU_PER_INCH, EMU_PER_POINT, FIXED_PCT_PER_PERCENT, HUNDREDTHS_PER_POINT, InternalError, InvalidOptionError, MAX_COORDINATE_EMU, MIN_COORDINATE_EMU, MediaError, OutputType, PERCENT_SCALE, POINTS_PER_INCH, PackageReadError, PlaceholderType, STANDARD_LAYOUTS, SchemeColor, ShapeType, SlideObjectType, TableStyle, TextAnchor, TsPptx, TsPptx as default, TsPptxError, UnsupportedFeatureError, VALID_SHAPE_PRESETS, asChartType, clipPath, connectorPresetFor, coordToEmu, createPresentation, emuToInches, emuToPixels, emuToPoints, inchesToEmu, isChartExType, isChartType, percentToEmu, pixelsToEmu, pointsToEmu, ptToHundredths, resetDiagnosticState, setDiagnosticHandler, textRun, textRuns };
54
74
 
55
75
  //# sourceMappingURL=node.js.map
package/dist/node.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","names":[],"sources":["../src/runtime/node.ts","../src/node.ts"],"sourcesContent":["import { Buffer } from 'node:buffer'\nimport fs from 'node:fs/promises'\nimport { MediaError } from '../errors.js'\nimport type { SlideRelMedia } from '../types/internal.js'\nimport type { RuntimeAdapter } from './types.js'\nimport { fetchFontBytes, fetchMediaBase64, isRemote, placeholderSvgPreview } from './fetch-media.js'\n\nexport function createNodeRuntime(): RuntimeAdapter {\n\treturn {\n\t\twriteFileOutputType: 'nodebuffer',\n\t\tloadMedia,\n\t\tcreateSvgPngPreview: placeholderSvgPreview,\n\t\twriteFile,\n\t\tloadFontData,\n\t}\n}\n\nasync function loadFontData(source: string): Promise<Uint8Array> {\n\tif (isRemote(source)) return await fetchFontBytes(source)\n\ttry {\n\t\treturn new Uint8Array(await fs.readFile(source))\n\t} catch (ex) {\n\t\tthrow new MediaError('font/read-failed', `Unable to read font file: \"${source}\"\\n${String(ex)}`, {\n\t\t\tcause: ex,\n\t\t})\n\t}\n}\n\nasync function loadMedia(rel: SlideRelMedia & { path: string }): Promise<string> {\n\tif (isRemote(rel.path)) return await fetchMediaBase64(rel.path)\n\n\ttry {\n\t\treturn Buffer.from(await fs.readFile(rel.path)).toString('base64')\n\t} catch (ex) {\n\t\tthrow new MediaError('media/read-failed', `Unable to read media: \"${rel.path}\"\\n${String(ex)}`, {\n\t\t\tcause: ex,\n\t\t})\n\t}\n}\n\nasync function writeFile(fileName: string, data: string | ArrayBuffer | Blob | Uint8Array): Promise<string> {\n\tawait fs.writeFile(fileName, data as string | Uint8Array)\n\treturn fileName\n}\n","import PresentationCore from './presentation.js'\nimport { createNodeRuntime } from './runtime/node.js'\n\n/**\n * The Node entry, reached through the `node` export condition — a consumer importing the bare\n * `@shbernal/ts-pptx` specifier under Node lands here without naming this subpath.\n *\n * Same authoring API as every other entry (see `entry-surface.ts`); the runtime adapter is what\n * differs. This one can reach the filesystem, so `writeFile` writes a real file and media may be\n * loaded from a path — both of which throw on the runtime-agnostic entry.\n */\nexport class TsPptx extends PresentationCore {\n\tconstructor() {\n\t\tsuper(createNodeRuntime())\n\t}\n}\n\nexport { TsPptx as default }\nexport * from './entry-surface.js'\n"],"mappings":";;;;;;;AAOA,SAAgB,oBAAoC;CACnD,OAAO;EACN,qBAAqB;EACrB;EACA,qBAAqB;EACrB;EACA;CACD;AACD;AAEA,eAAe,aAAa,QAAqC;CAChE,IAAI,SAAS,MAAM,GAAG,OAAO,MAAM,eAAe,MAAM;CACxD,IAAI;EACH,OAAO,IAAI,WAAW,MAAM,GAAG,SAAS,MAAM,CAAC;CAChD,SAAS,IAAI;EACZ,MAAM,IAAI,WAAW,oBAAoB,8BAA8B,OAAO,KAAK,OAAO,EAAE,KAAK,EAChG,OAAO,GACR,CAAC;CACF;AACD;AAEA,eAAe,UAAU,KAAwD;CAChF,IAAI,SAAS,IAAI,IAAI,GAAG,OAAO,MAAM,iBAAiB,IAAI,IAAI;CAE9D,IAAI;EACH,OAAO,OAAO,KAAK,MAAM,GAAG,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,QAAQ;CAClE,SAAS,IAAI;EACZ,MAAM,IAAI,WAAW,qBAAqB,0BAA0B,IAAI,KAAK,KAAK,OAAO,EAAE,KAAK,EAC/F,OAAO,GACR,CAAC;CACF;AACD;AAEA,eAAe,UAAU,UAAkB,MAAiE;CAC3G,MAAM,GAAG,UAAU,UAAU,IAA2B;CACxD,OAAO;AACR;;;;;;;;;;;AChCA,IAAa,SAAb,cAA4B,iBAAiB;CAC5C,cAAc;EACb,MAAM,kBAAkB,CAAC;CAC1B;AACD"}
1
+ {"version":3,"file":"node.js","names":[],"sources":["../src/runtime/node.ts","../src/node.ts"],"sourcesContent":["import { Buffer } from 'node:buffer'\nimport fs from 'node:fs/promises'\nimport { MediaError } from '../errors.js'\nimport type { SlideRelMedia } from '../types/internal.js'\nimport type { RuntimeAdapter } from './types.js'\nimport { fetchFontBytes, fetchMediaBase64, isRemote, placeholderSvgPreview } from './fetch-media.js'\n\nexport function createNodeRuntime(): RuntimeAdapter {\n\treturn {\n\t\twriteFileOutputType: 'nodebuffer',\n\t\tloadMedia,\n\t\tcreateSvgPngPreview: placeholderSvgPreview,\n\t\twriteFile,\n\t\tloadFontData,\n\t}\n}\n\nasync function loadFontData(source: string): Promise<Uint8Array> {\n\tif (isRemote(source)) return await fetchFontBytes(source)\n\ttry {\n\t\treturn new Uint8Array(await fs.readFile(source))\n\t} catch (ex) {\n\t\tthrow new MediaError('font/read-failed', `Unable to read font file: \"${source}\"\\n${String(ex)}`, {\n\t\t\tcause: ex,\n\t\t})\n\t}\n}\n\nasync function loadMedia(rel: SlideRelMedia & { path: string }): Promise<string> {\n\tif (isRemote(rel.path)) return await fetchMediaBase64(rel.path)\n\n\ttry {\n\t\treturn Buffer.from(await fs.readFile(rel.path)).toString('base64')\n\t} catch (ex) {\n\t\tthrow new MediaError('media/read-failed', `Unable to read media: \"${rel.path}\"\\n${String(ex)}`, {\n\t\t\tcause: ex,\n\t\t})\n\t}\n}\n\nasync function writeFile(fileName: string, data: string | ArrayBuffer | Blob | Uint8Array): Promise<string> {\n\tawait fs.writeFile(fileName, data as string | Uint8Array)\n\treturn fileName\n}\n","/**\n * The Node authoring entry, which the bare `pptx-ts` specifier resolves to under the `node`\n * export condition.\n *\n * @module\n */\nimport PresentationCore from './presentation.js'\nimport { composePresentation, type ComposeOptions, type Composed } from './entry-compose.js'\nimport type { ConstructFamily } from './families/shared.js'\nimport { ALL_CONSTRUCT_FAMILIES } from './entry-families.js'\nimport { createNodeRuntime } from './runtime/node.js'\n\n/**\n * The Node entry, reached through the `node` export condition — a consumer importing the bare\n * `pptx-ts` specifier under Node lands here without naming this subpath.\n *\n * Same authoring API as every other entry (see `entry-surface.ts`); the runtime adapter is what\n * differs. This one can reach the filesystem, so `writeFile` writes a real file and media may be\n * loaded from a path — both of which throw on the runtime-agnostic entry.\n */\nexport class TsPptx extends PresentationCore {\n\tconstructor() {\n\t\tsuper(createNodeRuntime(), ALL_CONSTRUCT_FAMILIES)\n\t}\n}\n\n/**\n * Compose a presentation from the construct families it needs, on the Node adapter.\n *\n * The counterpart to {@link TsPptx}, which is composed with every family there is. This one costs\n * what it carries: the core tier (text, shapes, images, groups, speaker notes) plus whatever\n * `use` names, and nothing else reaches the bundle.\n * @param {ComposeOptions} opts - the families to compose in, from `pptx-ts/families`\n * @example\n * import { createPresentation } from 'pptx-ts/node'\n * import { charts } from 'pptx-ts/families'\n * const pres = createPresentation({ use: [charts] })\n */\nexport function createPresentation<const Fs extends readonly ConstructFamily[] = []>(\n\topts?: ComposeOptions<Fs>\n): Composed<Fs> {\n\treturn composePresentation(createNodeRuntime(), opts)\n}\n\nexport { TsPptx as default }\nexport * from './entry-surface.js'\n"],"mappings":";;;;;;AAOA,SAAgB,oBAAoC;CACnD,OAAO;EACN,qBAAqB;EACrB;EACA,qBAAqB;EACrB;EACA;CACD;AACD;AAEA,eAAe,aAAa,QAAqC;CAChE,IAAI,SAAS,MAAM,GAAG,OAAO,MAAM,eAAe,MAAM;CACxD,IAAI;EACH,OAAO,IAAI,WAAW,MAAM,GAAG,SAAS,MAAM,CAAC;CAChD,SAAS,IAAI;EACZ,MAAM,IAAI,WAAW,oBAAoB,8BAA8B,OAAO,KAAK,OAAO,EAAE,KAAK,EAChG,OAAO,GACR,CAAC;CACF;AACD;AAEA,eAAe,UAAU,KAAwD;CAChF,IAAI,SAAS,IAAI,IAAI,GAAG,OAAO,MAAM,iBAAiB,IAAI,IAAI;CAE9D,IAAI;EACH,OAAO,OAAO,KAAK,MAAM,GAAG,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,QAAQ;CAClE,SAAS,IAAI;EACZ,MAAM,IAAI,WAAW,qBAAqB,0BAA0B,IAAI,KAAK,KAAK,OAAO,EAAE,KAAK,EAC/F,OAAO,GACR,CAAC;CACF;AACD;AAEA,eAAe,UAAU,UAAkB,MAAiE;CAC3G,MAAM,GAAG,UAAU,UAAU,IAA2B;CACxD,OAAO;AACR;;;;;;;;;;;;;;;;;ACvBA,IAAa,SAAb,cAA4B,iBAAiB;CAC5C,cAAc;EACb,MAAM,kBAAkB,GAAG,sBAAsB;CAClD;AACD;;;;;;;;;;;;;AAcA,SAAgB,mBACf,MACe;CACf,OAAO,oBAAoB,kBAAkB,GAAG,IAAI;AACrD"}