@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.
Files changed (81) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +238 -0
  3. package/dist/autopage-tmfjRzL4.js +420 -0
  4. package/dist/autopage-tmfjRzL4.js.map +1 -0
  5. package/dist/browser.d.ts +23 -0
  6. package/dist/browser.d.ts.map +1 -0
  7. package/dist/browser.js +103 -0
  8. package/dist/browser.js.map +1 -0
  9. package/dist/diagnostics-DYQC7xLV.js +0 -0
  10. package/dist/diagnostics-DYQC7xLV.js.map +1 -0
  11. package/dist/diagnostics-DzY9Tyfm.d.ts +693 -0
  12. package/dist/diagnostics-DzY9Tyfm.d.ts.map +1 -0
  13. package/dist/embedded-fonts-MaynAHa9.js +94 -0
  14. package/dist/embedded-fonts-MaynAHa9.js.map +1 -0
  15. package/dist/enums-D3aF4QGb.d.ts +452 -0
  16. package/dist/enums-D3aF4QGb.d.ts.map +1 -0
  17. package/dist/errors-DGE9zh3U.js +93 -0
  18. package/dist/errors-DGE9zh3U.js.map +1 -0
  19. package/dist/errors-DRLpOpgQ.d.ts +160 -0
  20. package/dist/errors-DRLpOpgQ.d.ts.map +1 -0
  21. package/dist/fit-CbxyHN69.js +0 -0
  22. package/dist/fit-CbxyHN69.js.map +1 -0
  23. package/dist/html-dom-wVa3TiG7.js +666 -0
  24. package/dist/html-dom-wVa3TiG7.js.map +1 -0
  25. package/dist/html.d.ts +26 -0
  26. package/dist/html.d.ts.map +1 -0
  27. package/dist/html.js +60 -0
  28. package/dist/html.js.map +1 -0
  29. package/dist/image-size-C5Z1sKof.js +252 -0
  30. package/dist/image-size-C5Z1sKof.js.map +1 -0
  31. package/dist/index.d.ts +24 -0
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +75 -0
  34. package/dist/index.js.map +1 -0
  35. package/dist/inspect.d.ts +173 -0
  36. package/dist/inspect.d.ts.map +1 -0
  37. package/dist/inspect.js +285 -0
  38. package/dist/inspect.js.map +1 -0
  39. package/dist/math.d.ts +37 -0
  40. package/dist/math.d.ts.map +1 -0
  41. package/dist/math.js +106 -0
  42. package/dist/math.js.map +1 -0
  43. package/dist/measure.d.ts +223 -0
  44. package/dist/measure.d.ts.map +1 -0
  45. package/dist/measure.js +3 -0
  46. package/dist/node.d.ts +12 -0
  47. package/dist/node.d.ts.map +1 -0
  48. package/dist/node.js +60 -0
  49. package/dist/node.js.map +1 -0
  50. package/dist/package-CaOLXSNi.d.ts +193 -0
  51. package/dist/package-CaOLXSNi.d.ts.map +1 -0
  52. package/dist/pres-5x1bjCzk.d.ts +202 -0
  53. package/dist/pres-5x1bjCzk.d.ts.map +1 -0
  54. package/dist/presentation-B0JWdTN1.js +4286 -0
  55. package/dist/presentation-B0JWdTN1.js.map +1 -0
  56. package/dist/presentation-RGOiun5P.d.ts +3249 -0
  57. package/dist/presentation-RGOiun5P.d.ts.map +1 -0
  58. package/dist/presentation-types-BVw0EknS.d.ts +538 -0
  59. package/dist/presentation-types-BVw0EknS.d.ts.map +1 -0
  60. package/dist/read.d.ts +73 -0
  61. package/dist/read.d.ts.map +1 -0
  62. package/dist/read.js +4 -0
  63. package/dist/script.d.ts +553 -0
  64. package/dist/script.d.ts.map +1 -0
  65. package/dist/script.js +0 -0
  66. package/dist/script.js.map +1 -0
  67. package/dist/shapes-BZU8UTW2.js +5365 -0
  68. package/dist/shapes-BZU8UTW2.js.map +1 -0
  69. package/dist/slide-B6mDaM-P.d.ts +3396 -0
  70. package/dist/slide-B6mDaM-P.d.ts.map +1 -0
  71. package/dist/text-WRUbOy2r.js +11238 -0
  72. package/dist/text-WRUbOy2r.js.map +1 -0
  73. package/dist/units-B-JUKwCS.js +144 -0
  74. package/dist/units-B-JUKwCS.js.map +1 -0
  75. package/dist/units-internal-7JcMfYti.js +723 -0
  76. package/dist/units-internal-7JcMfYti.js.map +1 -0
  77. package/dist/zip.d.ts +68 -0
  78. package/dist/zip.d.ts.map +1 -0
  79. package/dist/zip.js +163 -0
  80. package/dist/zip.js.map +1 -0
  81. package/package.json +214 -0
package/dist/math.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ 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";
2
+ //#region src/math.d.ts
3
+ /**
4
+ * Convert a MathML string to OMML for the `math:` option on `addText`.
5
+ *
6
+ * Canonical output form: a bare `<m:oMath>…</m:oMath>` in the `m:` namespace, with no
7
+ * namespace declarations (the `math:` option's envelope supplies the `m` prefix).
8
+ *
9
+ * @param mathml - a MathML string (e.g. `<math>…</math>`)
10
+ * @returns OMML `<m:oMath>…</m:oMath>`
11
+ */
12
+ declare function mathmlToOmml(mathml: string): string;
13
+ interface LatexToOmmlOptions {
14
+ /**
15
+ * Display (block) math: render in `displayMode` and wrap the result in
16
+ * `<m:oMathPara>` (a centered display-math paragraph). Default `true`. When `false`,
17
+ * temml renders in inline mode and the result is a bare `<m:oMath>`.
18
+ */
19
+ display?: boolean;
20
+ }
21
+ /**
22
+ * Convert a LaTeX string to OMML for the `math:` option on `addText`.
23
+ *
24
+ * Display math (the default) is returned as a full `<m:oMathPara>` centered display
25
+ * paragraph; with `{ display: false }` a bare `<m:oMath>` is returned (both forms are
26
+ * accepted by the `math:` option). Throws on invalid LaTeX, surfacing temml's parse
27
+ * position.
28
+ *
29
+ * @param latex - a LaTeX math expression, e.g. `x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}`
30
+ * @param opts - see {@link LatexToOmmlOptions}
31
+ * @returns OMML `<m:oMathPara>…</m:oMathPara>` (display) or `<m:oMath>…</m:oMath>` (inline)
32
+ * @throws {Error} if the LaTeX cannot be parsed
33
+ */
34
+ declare function latexToOmml(latex: string, opts?: LatexToOmmlOptions): string;
35
+ //#endregion
36
+ export { type ErrorCode, InternalError, type InternalErrorCode, InvalidOptionError, type InvalidOptionErrorCode, LatexToOmmlOptions, MediaError, type MediaErrorCode, PackageReadError, type PackageReadErrorCode, type TsPptxCode, TsPptxError, type TsPptxErrorOptions, UnsupportedFeatureError, type UnsupportedFeatureErrorCode, latexToOmml, mathmlToOmml };
37
+ //# sourceMappingURL=math.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"math.d.ts","names":[],"sources":["../src/math.ts"],"mappings":";;;;;;;;;;;iBA8FgB,aAAa;UAKZ;;;;;;EAMhB;;;;;;;;;;;;;;;iBAgBe,YAAY,eAAe,OAAM"}
package/dist/math.js ADDED
@@ -0,0 +1,106 @@
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 { createRequire } from "node:module";
3
+ //#region src/math.ts
4
+ /**
5
+ * `@shbernal/ts-pptx/math` — author display equations in LaTeX or MathML and get
6
+ * OMML for the `math:` option on `addText` (see {@link TextProps.math}).
7
+ *
8
+ * Pipeline: LaTeX --temml--> MathML --mathml2omml--> OMML.
9
+ *
10
+ * Both converters are **optional peer dependencies** (temml is MIT, mathml2omml is
11
+ * LGPL-3.0-or-later); install them to use this subpath:
12
+ *
13
+ * ```sh
14
+ * npm install temml mathml2omml
15
+ * ```
16
+ *
17
+ * This subpath is **Node-only**: it loads the converters synchronously via
18
+ * `node:module`'s `createRequire`, so `latexToOmml()` / `mathmlToOmml()` stay
19
+ * synchronous. Both display and inline (in-sentence) equations are supported: a
20
+ * default `latexToOmml()` returns a centered display `<m:oMathPara>`, while
21
+ * `latexToOmml(tex, { display: false })` (and `mathmlToOmml()`) return the bare
22
+ * `<m:oMath>` form you pass to a text item with `inline: true` to flow it
23
+ * mid-paragraph (see {@link TextProps.inline}).
24
+ *
25
+ * @module
26
+ */
27
+ const nodeRequire = createRequire(import.meta.url);
28
+ const MISSING_DEPS_MESSAGE = "@shbernal/ts-pptx/math requires the optional peer dependencies 'temml' and 'mathml2omml'. Install them with: npm install temml mathml2omml";
29
+ /** Require an optional peer, remapping a not-found error to the install hint. */
30
+ function requirePeer(id) {
31
+ try {
32
+ return nodeRequire(id);
33
+ } catch (err) {
34
+ if (err?.code === "MODULE_NOT_FOUND") throw new UnsupportedFeatureError("math/missing-optional-peer", MISSING_DEPS_MESSAGE, { cause: err });
35
+ throw err;
36
+ }
37
+ }
38
+ let temmlModule;
39
+ let mml2ommlFn;
40
+ function loadTemml() {
41
+ if (!temmlModule) {
42
+ const mod = requirePeer("temml");
43
+ temmlModule = "renderToString" in mod ? mod : mod.default;
44
+ }
45
+ return temmlModule;
46
+ }
47
+ function loadMml2omml() {
48
+ if (!mml2ommlFn) mml2ommlFn = requirePeer("mathml2omml").mml2omml;
49
+ return mml2ommlFn;
50
+ }
51
+ /**
52
+ * mathml2omml puts namespace declarations on the `<m:oMath>` opening tag: `xmlns:m`
53
+ * (redundant — the `<a14:m>` envelope the `math:` option authors already declares it)
54
+ * and `xmlns:w` (unused in the output it produces). Strip them so the result is a bare
55
+ * `<m:oMath>` that drops into the `math:` option cleanly.
56
+ */
57
+ function stripOMathNamespaces(omml) {
58
+ return omml.replace(/^(\s*<m:oMath)\b[^>]*>/, "$1>");
59
+ }
60
+ /** Centered-display paragraph props, matching what the `math:` emitter/oracle author. */
61
+ const DISPLAY_PARA_PR = "<m:oMathParaPr><m:jc m:val=\"centerGroup\"/></m:oMathParaPr>";
62
+ /**
63
+ * Convert a MathML string to OMML for the `math:` option on `addText`.
64
+ *
65
+ * Canonical output form: a bare `<m:oMath>…</m:oMath>` in the `m:` namespace, with no
66
+ * namespace declarations (the `math:` option's envelope supplies the `m` prefix).
67
+ *
68
+ * @param mathml - a MathML string (e.g. `<math>…</math>`)
69
+ * @returns OMML `<m:oMath>…</m:oMath>`
70
+ */
71
+ function mathmlToOmml(mathml) {
72
+ return stripOMathNamespaces(loadMml2omml()(mathml).trim());
73
+ }
74
+ /**
75
+ * Convert a LaTeX string to OMML for the `math:` option on `addText`.
76
+ *
77
+ * Display math (the default) is returned as a full `<m:oMathPara>` centered display
78
+ * paragraph; with `{ display: false }` a bare `<m:oMath>` is returned (both forms are
79
+ * accepted by the `math:` option). Throws on invalid LaTeX, surfacing temml's parse
80
+ * position.
81
+ *
82
+ * @param latex - a LaTeX math expression, e.g. `x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}`
83
+ * @param opts - see {@link LatexToOmmlOptions}
84
+ * @returns OMML `<m:oMathPara>…</m:oMathPara>` (display) or `<m:oMath>…</m:oMath>` (inline)
85
+ * @throws {Error} if the LaTeX cannot be parsed
86
+ */
87
+ function latexToOmml(latex, opts = {}) {
88
+ const display = opts.display ?? true;
89
+ const temml = loadTemml();
90
+ let mathml;
91
+ try {
92
+ mathml = temml.renderToString(latex, {
93
+ displayMode: display,
94
+ throwOnError: true
95
+ });
96
+ } catch (err) {
97
+ const pe = err;
98
+ throw new InvalidOptionError("math/invalid-latex", `Invalid LaTeX${typeof pe.position === "number" ? ` (position ${pe.position})` : ""}: ${pe.message}`, { cause: err });
99
+ }
100
+ const oMath = mathmlToOmml(mathml);
101
+ return display ? `<m:oMathPara>${DISPLAY_PARA_PR}${oMath}</m:oMathPara>` : oMath;
102
+ }
103
+ //#endregion
104
+ export { InternalError, InvalidOptionError, MediaError, PackageReadError, TsPptxError, UnsupportedFeatureError, latexToOmml, mathmlToOmml };
105
+
106
+ //# sourceMappingURL=math.js.map
@@ -0,0 +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 * 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\tconst oMath = mathmlToOmml(mathml)\n\treturn display ? `<m:oMathPara>${DISPLAY_PARA_PR}${oMath}</m:oMathPara>` : oMath\n}\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":";;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAM,cAAc,cAAc,OAAO,KAAK,GAAG;AAWjD,MAAM,uBACL;;AAID,SAAS,YAAe,IAAe;CACtC,IAAI;EACH,OAAO,YAAY,EAAE;CACtB,SAAS,KAAK;EACb,IAAK,KAA2C,SAAS,oBACxD,MAAM,IAAI,wBAAwB,8BAA8B,sBAAsB,EAAE,OAAO,IAAI,CAAC;EAErG,MAAM;CACP;AACD;AAEA,IAAI;AACJ,IAAI;AAEJ,SAAS,YAAyB;CACjC,IAAI,CAAC,aAAa;EACjB,MAAM,MAAM,YAAoD,OAAO;EACvE,cAAc,oBAAoB,MAAM,MAAM,IAAI;CACnD;CACA,OAAO;AACR;AAEA,SAAS,eAA2C;CACnD,IAAI,CAAC,YAEJ,aADY,YAAsD,aACnD,CAAC,CAAC;CAElB,OAAO;AACR;;;;;;;AAQA,SAAS,qBAAqB,MAAsB;CACnD,OAAO,KAAK,QAAQ,0BAA0B,KAAK;AACpD;;AAGA,MAAM,kBAAkB;;;;;;;;;;AAWxB,SAAgB,aAAa,QAAwB;CAEpD,OAAO,qBADU,aACkB,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC;AACpD;;;;;;;;;;;;;;AAwBA,SAAgB,YAAY,OAAe,OAA2B,CAAC,GAAW;CACjF,MAAM,UAAU,KAAK,WAAW;CAChC,MAAM,QAAQ,UAAU;CACxB,IAAI;CACJ,IAAI;EACH,SAAS,MAAM,eAAe,OAAO;GAAE,aAAa;GAAS,cAAc;EAAK,CAAC;CAClF,SAAS,KAAK;EACb,MAAM,KAAK;EAEX,MAAM,IAAI,mBAAmB,sBAAsB,gBADvC,OAAO,GAAG,aAAa,WAAW,cAAc,GAAG,SAAS,KAAK,GACN,IAAI,GAAG,WAAW,EAAE,OAAO,IAAI,CAAC;CACxG;CACA,MAAM,QAAQ,aAAa,MAAM;CACjC,OAAO,UAAU,gBAAgB,kBAAkB,MAAM,kBAAkB;AAC5E"}
@@ -0,0 +1,223 @@
1
+ import { dn as TextMeasurement, en as MeasureTextOptions, fn as TextProps, i as ObjectOptions, pn as TextPropsOptions, rn as OverflowBoxOptions } from "./slide-B6mDaM-P.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-DRLpOpgQ.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
+ /** Parse a font file (TTF/OTF) into a `FontMetrics`. Lazily imports opentype.js. */
30
+ declare function parseFontMetrics(data: Uint8Array): Promise<FontMetrics>;
31
+ /**
32
+ * Registry of `FontMetrics` keyed by `(face, bold, italic)`. Variant advances
33
+ * differ, so bold/italic are stored separately; lookup falls back to the regular
34
+ * variant (then any registered variant of the face) so a deck that only registers
35
+ * the regular weight still measures bold runs approximately rather than not at all.
36
+ */
37
+ declare class FontMetricsRegistry {
38
+ private readonly map;
39
+ private key;
40
+ set(face: string, metrics: FontMetrics, opts?: {
41
+ bold?: boolean;
42
+ italic?: boolean;
43
+ }): void;
44
+ /** True if any variant of `face` has registered metrics. */
45
+ hasFace(face: string): boolean;
46
+ /**
47
+ * Coverage of code point `cp` for `face`, read from the registered font's cmap:
48
+ * `true`/`false` when a variant of `face` is registered (see {@link get} for the
49
+ * exact→regular→any-variant fallback), or `undefined` when the face has **no**
50
+ * registered metrics — "unknown", deliberately distinct from a `false`
51
+ * "registered but not covered". A coverage audit must not treat an unregistered
52
+ * face as fully covered, so callers get `undefined` here rather than the per-face
53
+ * {@link FontMetrics.hasCodepoint} boolean (which, for the heuristic fallback,
54
+ * always reports covered). Register the face via {@link parseFontMetrics} +
55
+ * {@link set} first.
56
+ */
57
+ hasCodepoint(face: string | undefined | null, cp: number, opts?: {
58
+ bold?: boolean;
59
+ italic?: boolean;
60
+ }): boolean | undefined;
61
+ /** Resolve metrics for a run, falling back from exact variant → regular → any variant. */
62
+ get(face: string | undefined | null, bold?: boolean, italic?: boolean): FontMetrics | undefined;
63
+ get size(): number;
64
+ }
65
+ /**
66
+ * A {@link MetricsResolver} backed by a registry: exact metrics for a registered face, otherwise
67
+ * the shared heuristic fallback (with `onHeuristic` told which face it stood in for). A run with
68
+ * no `fontFace` at all resolves to `undefined`, which the callers treat as unmeasurable.
69
+ */
70
+ declare function makeRegistryResolver(registry: FontMetricsRegistry, onHeuristic?: (face: string) => void): MetricsResolver;
71
+ //#endregion
72
+ //#region src/measure/text-fit.d.ts
73
+ /**
74
+ * PowerPoint single-spacing line pitch as a multiple of font size.
75
+ *
76
+ * Calibrated from `autofit-calibration.json` (Deck 1, `autofit-line-metrics`):
77
+ * the per-line `cy` delta is a **font-independent** 1.2117× at 12/18/32 pt across
78
+ * {Aptos, Aptos SemiBold, Calibri, Tahoma, Arial}, and PowerPoint vs LibreOffice
79
+ * agree to ≤ 0.041 pt. See `test/read/fixtures/README.md` → "Findings" #1–#2.
80
+ */
81
+ declare const SINGLE_LINE_PITCH = 1.2117;
82
+ /** PowerPoint's `fontScale` search grid: discrete 2.5% steps (Findings #3). */
83
+ declare const FONT_SCALE_STEP_PCT = 2.5;
84
+ /** Floor for the shrink search (see `docs/measured-text-fit.md` → Solvers). */
85
+ declare const MIN_FONT_SCALE_PCT = 25;
86
+ /**
87
+ * Conservative safety factors applied by the shrink solver (not by the pure
88
+ * `measureHeightPt`). Raw `hmtx` advances summed without shaping still pack a line
89
+ * a little tighter than PowerPoint, which lays text out at a device DPI and rounds
90
+ * each glyph advance up — so PowerPoint wraps marginally earlier and its fitted
91
+ * box is marginally taller. Inflating measured width and height by these factors
92
+ * makes the computed `fontScale` ≤ PowerPoint's across the calibration oracle
93
+ * (`test/read/autofit-calibration-oracle.test.mjs`: 0 violations over the Aptos
94
+ * cases). They err on the side of shrinking slightly too much, never overflowing.
95
+ */
96
+ declare const WIDTH_SAFETY_FACTOR = 1.03;
97
+ declare const HEIGHT_SAFETY_FACTOR = 1.04;
98
+ /** One text run with the inputs measurement needs. */
99
+ interface FitRun {
100
+ text: string;
101
+ sizePt: number;
102
+ bold?: boolean;
103
+ italic?: boolean;
104
+ fontFace?: string;
105
+ /** Character spacing in points (PowerPoint `spc`/1200). */
106
+ charSpacingPt?: number;
107
+ }
108
+ /** One paragraph: its runs plus vertical-rhythm options. */
109
+ interface FitParagraph {
110
+ runs: FitRun[];
111
+ /** Line spacing as a percent of single (100 = single). Ignored if `lineSpacingPts` set. */
112
+ lineSpacingPct?: number;
113
+ /** Exact line spacing in points (overrides `lineSpacingPct`). */
114
+ lineSpacingPts?: number;
115
+ spaceBeforePts?: number;
116
+ spaceAfterPts?: number;
117
+ }
118
+ /** Inner box (shape minus insets) the text must fit, in points. */
119
+ interface FitBox {
120
+ innerWidthPt: number;
121
+ innerHeightPt: number;
122
+ /**
123
+ * `false` when the frame does not wrap (`wrap:false` / `wrap="none"`): text lays
124
+ * out as one line per paragraph (no width-wrapping), and the shrink solver must
125
+ * additionally keep the widest line within `innerWidthPt`. A too-wide line
126
+ * overflows HORIZONTALLY — `normAutofit`'s vertical shrink never catches it, so
127
+ * without this check a non-wrapping line is never shrunk and spills out of the box
128
+ * in PowerPoint. Defaults to wrapping (`true`), so table cells and `measureText`
129
+ * are unaffected.
130
+ */
131
+ wrap?: boolean;
132
+ }
133
+ /** Resolve the metrics for a run, or `undefined` if the face is not registered. */
134
+ type MetricsResolver = (run: FitRun) => FontMetrics | undefined;
135
+ interface ShrinkResult {
136
+ fontScalePct: number;
137
+ lnSpcReductionPct: number;
138
+ }
139
+ type ShrinkOutcome = {
140
+ kind: 'fits';
141
+ } | {
142
+ kind: 'unmeasurable';
143
+ } | {
144
+ kind: 'shrink';
145
+ result: ShrinkResult;
146
+ };
147
+ /** Laid-out result of {@link measureLayout}: total height (points) + wrapped line count. */
148
+ interface LayoutResult {
149
+ heightPt: number;
150
+ lineCount: number;
151
+ /**
152
+ * Width (points) of the widest laid-out line across all paragraphs. Useful for
153
+ * tightening a box to the actual text extent or measuring a natural (single-line)
154
+ * width. Carries the same `widthSafety` inflation as the wrap decision, so a box
155
+ * set to this width will not re-wrap. Conservative (slightly wide).
156
+ */
157
+ widestLineWidthPt: number;
158
+ }
159
+ /**
160
+ * Lay out `paragraphs` at a given scale/reduction and return the total height
161
+ * (points) and wrapped line count, or `null` if any paragraph is unmeasurable.
162
+ * Errs tall (conservative): includes space-before/after and the calibrated line
163
+ * pitch. The single source of truth for both {@link measureHeightPt} (the solvers)
164
+ * and the public layout-time measure API.
165
+ */
166
+ declare function measureLayout(paragraphs: FitParagraph[], innerWidthPt: number, resolve: MetricsResolver, fontScalePct: number, lnSpcReductionPct: number, widthSafety?: number): LayoutResult | null;
167
+ /**
168
+ * Total laid-out height (points) at a given scale/reduction, or `null` if any
169
+ * paragraph is unmeasurable. Thin wrapper over {@link measureLayout}.
170
+ */
171
+ declare function measureHeightPt(paragraphs: FitParagraph[], innerWidthPt: number, resolve: MetricsResolver, fontScalePct: number, lnSpcReductionPct: number, widthSafety?: number): number | null;
172
+ /**
173
+ * Largest `fontScale` (on PowerPoint's 2.5% grid) at which the text fits the box.
174
+ * Width and height both re-measured per scale. Conservative: because the model
175
+ * over-estimates, the returned scale is ≤ PowerPoint's and the text never overflows.
176
+ *
177
+ * `lnSpcReduction` is left at 0 in P1 — dropping `fontScale` alone is provably
178
+ * conservative (PowerPoint trades line-spacing reduction to keep the font *larger*,
179
+ * so a reduction-free fit is always ≤ PowerPoint's scale). The calibration data for
180
+ * the reduction ramp (Findings #4) is recorded for a future refinement.
181
+ */
182
+ type ResizeOutcome = {
183
+ kind: 'unmeasurable';
184
+ } | {
185
+ kind: 'resize';
186
+ neededInnerHeightPt: number;
187
+ };
188
+ declare function solveResize(paragraphs: FitParagraph[], box: FitBox, resolve: MetricsResolver): ResizeOutcome;
189
+ declare function solveShrink(paragraphs: FitParagraph[], box: FitBox, resolve: MetricsResolver): ShrinkOutcome;
190
+ //#endregion
191
+ //#region src/measure/fit.d.ts
192
+ /**
193
+ * Layout-time text measurement against registered metrics — the public engine
194
+ * behind `pptx.measureText()`. Uses the **same** calibrated wrap model, resolver
195
+ * semantics, and conservative safety factors as the export-time bake
196
+ * ({@link applyMeasuredFit} / {@link solveResize} / {@link solveShrink}), so a
197
+ * layout-time prediction matches the value the export would bake **for any deck
198
+ * that opted into measured fit (i.e. registered at least one face)**.
199
+ *
200
+ * With an **empty** registry the two intentionally diverge: {@link applyMeasuredFit}
201
+ * treats "no metrics" as "not opted in" and bakes nothing, while this returns
202
+ * heuristic numbers so the API is useful with zero setup. Check
203
+ * `approximatedFaces` if that distinction matters.
204
+ *
205
+ * Synchronous: assumes metrics are pre-registered (lookup is sync). A named face
206
+ * with no exact metrics silently uses the conservative heuristic (same as export)
207
+ * and is reported in `approximatedFaces`; an unnamed theme-default face returns
208
+ * `measurable: false`.
209
+ */
210
+ declare function measureText(registry: FontMetricsRegistry, text: string | TextProps[], opts: MeasureTextOptions): TextMeasurement;
211
+ //#endregion
212
+ //#region src/measure/paragraphs.d.ts
213
+ type RunOpts = TextPropsOptions & ObjectOptions;
214
+ /**
215
+ * Convert a run list (+ box-level default options) into a measurable
216
+ * `FitParagraph[]`, or null if empty. The single converter shared by the
217
+ * export-time pass ({@link extractParagraphs}) and the public layout-time
218
+ * `measureText` API, so a layout-time prediction and the baked export never drift.
219
+ */
220
+ declare function buildFitParagraphs(runs: TextProps[], opts: RunOpts): FitParagraph[] | null;
221
+ //#endregion
222
+ export { type ErrorCode, FONT_SCALE_STEP_PCT, type FitBox, type FitParagraph, type FitRun, 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 ResizeOutcome, SINGLE_LINE_PITCH, type ShrinkOutcome, type ShrinkResult, type TextMeasurement, type TsPptxCode, TsPptxError, type TsPptxErrorOptions, UnsupportedFeatureError, type UnsupportedFeatureErrorCode, WIDTH_SAFETY_FACTOR, buildFitParagraphs, getHeuristicFontMetrics, makeRegistryResolver, measureHeightPt, measureLayout, measureText, parseFontMetrics, solveResize, solveShrink };
223
+ //# sourceMappingURL=measure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"measure.d.ts","names":[],"sources":["../src/measure/font-metrics.ts","../src/measure/text-fit.ts","../src/measure/fit.ts","../src/measure/paragraphs.ts"],"mappings":";;;;UAkBiB;;WAEP;;;;;;EAMT,iBAAiB,cAAc,gBAAgB;;;;;;;EAO/C,eAAe;;;;;;;;iBAgGA,2BAA2B;;iBAMrB,iBAAiB,MAAM,aAAa,QAAQ;;;;;;;cAqBrD;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;;;;;;;;;;;cCpMU;;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;;;UAmIZ;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;;;;;;;;;;;;;;;;;;;;;iBC/OhF,YACf,UAAU,qBACV,eAAe,aACf,MAAM,qBACJ;;;KCrES,UAAU,mBAAmB;;;;;;;iBA8BzB,mBAAmB,MAAM,aAAa,MAAM,UAAU"}
@@ -0,0 +1,3 @@
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 { _ 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 } from "./fit-CbxyHN69.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, makeRegistryResolver, measureHeightPt, measureLayout, measureText, parseFontMetrics, solveResize, solveShrink };
package/dist/node.d.ts ADDED
@@ -0,0 +1,12 @@
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/node.d.ts
7
+ declare class TsPptx extends PresentationCore {
8
+ constructor();
9
+ }
10
+ //#endregion
11
+ 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 };
12
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","names":[],"sources":["../src/node.ts"],"mappings":";;;;;;cAGa,eAAe;EAAA"}
package/dist/node.js ADDED
@@ -0,0 +1,60 @@
1
+ import { t as setDiagnosticHandler } from "./diagnostics-DYQC7xLV.js";
2
+ import { a as TsPptxError, i as PackageReadError, n as InvalidOptionError, o as UnsupportedFeatureError, r as MediaError, t as InternalError } from "./errors-DGE9zh3U.js";
3
+ import { _ as pointsToEmu, a as FIXED_PCT_PER_PERCENT, 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 } from "./units-B-JUKwCS.js";
4
+ import { n as textRuns, r as PresentationCore, t as textRun } from "./text-WRUbOy2r.js";
5
+ import { $ as connectorPresetFor, B as AlignV, G as PlaceholderType, H as CONNECTOR_PRESETS, J as SlideObjectType, K as SchemeColor, Q as asChartType, U as ChartType, V as BulletType, W as OutputType, X as TextAnchor, Y as TableStyle, Z as VALID_SHAPE_PRESETS, et as isChartExType, j as IMG_SVG_PLACEHOLDER, q as ShapeType, z as AlignH } from "./units-internal-7JcMfYti.js";
6
+ import { Buffer } from "node:buffer";
7
+ import fs from "node:fs/promises";
8
+ //#region src/runtime/node.ts
9
+ function createNodeRuntime() {
10
+ return {
11
+ writeFileOutputType: "nodebuffer",
12
+ loadMedia,
13
+ createSvgPngPreview,
14
+ writeFile,
15
+ loadFontData
16
+ };
17
+ }
18
+ async function loadFontData(source) {
19
+ if (source.startsWith("http")) {
20
+ const response = await fetch(source);
21
+ if (!response.ok) throw new MediaError("font/fetch-failed", `Unable to load font (fetch): ${source}`);
22
+ return new Uint8Array(await response.arrayBuffer());
23
+ }
24
+ try {
25
+ return new Uint8Array(await fs.readFile(source));
26
+ } catch (ex) {
27
+ throw new MediaError("font/read-failed", `Unable to read font file: "${source}"\n${String(ex)}`, { cause: ex });
28
+ }
29
+ }
30
+ async function loadMedia(rel) {
31
+ if (rel.path.startsWith("http")) {
32
+ const response = await fetch(rel.path);
33
+ if (!response.ok) throw new MediaError("media/fetch-failed", `Unable to load image (fetch): ${rel.path}`);
34
+ return Buffer.from(await response.arrayBuffer()).toString("base64");
35
+ }
36
+ try {
37
+ return Buffer.from(await fs.readFile(rel.path)).toString("base64");
38
+ } catch (ex) {
39
+ throw new MediaError("media/read-failed", `Unable to read media: "${rel.path}"\n${String(ex)}`, { cause: ex });
40
+ }
41
+ }
42
+ async function createSvgPngPreview(rel) {
43
+ rel.data = IMG_SVG_PLACEHOLDER;
44
+ return "done";
45
+ }
46
+ async function writeFile(fileName, data) {
47
+ await fs.writeFile(fileName, data);
48
+ return fileName;
49
+ }
50
+ //#endregion
51
+ //#region src/node.ts
52
+ var TsPptx = class extends PresentationCore {
53
+ constructor() {
54
+ super(createNodeRuntime());
55
+ }
56
+ };
57
+ //#endregion
58
+ 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, connectorPresetFor, coordToEmu, emuToInches, emuToPixels, emuToPoints, inchesToEmu, isChartExType, percentToEmu, pixelsToEmu, pointsToEmu, ptToHundredths, setDiagnosticHandler, textRun, textRuns };
59
+
60
+ //# sourceMappingURL=node.js.map
@@ -0,0 +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 { IMG_SVG_PLACEHOLDER } from '../constants-internal.js'\nimport { MediaError } from '../errors.js'\nimport type { SlideRelMedia } from '../types/internal.js'\nimport type { RuntimeAdapter } from './types.js'\n\nexport function createNodeRuntime(): RuntimeAdapter {\n\treturn {\n\t\twriteFileOutputType: 'nodebuffer',\n\t\tloadMedia,\n\t\tcreateSvgPngPreview,\n\t\twriteFile,\n\t\tloadFontData,\n\t}\n}\n\nasync function loadFontData(source: string): Promise<Uint8Array> {\n\tif (source.startsWith('http')) {\n\t\tconst response = await fetch(source)\n\t\tif (!response.ok) throw new MediaError('font/fetch-failed', `Unable to load font (fetch): ${source}`)\n\t\treturn new Uint8Array(await response.arrayBuffer())\n\t}\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 (rel.path.startsWith('http')) {\n\t\tconst response = await fetch(rel.path)\n\t\tif (!response.ok) throw new MediaError('media/fetch-failed', `Unable to load image (fetch): ${rel.path}`)\n\t\treturn Buffer.from(await response.arrayBuffer()).toString('base64')\n\t}\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 createSvgPngPreview(rel: SlideRelMedia): Promise<string> {\n\trel.data = IMG_SVG_PLACEHOLDER\n\treturn 'done'\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\nexport class TsPptx extends PresentationCore {\n\tconstructor() {\n\t\tsuper(createNodeRuntime())\n\t}\n}\n\nexport { TsPptx as default }\nexport * from './enums.js'\nexport * from './units.js'\n// Use `export *` (not `export type *`) so the value exports `textRun`/`textRuns`\n// reach this entry; `export type *` would drop them and crash any Node consumer\n// that imports them, while TypeScript (reading index.d.ts) stays green.\nexport * from './types/index.js'\nexport { setDiagnosticHandler, type Diagnostic, type DiagnosticCode, type DiagnosticHandler } from './diagnostics.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":";;;;;;;;AAOA,SAAgB,oBAAoC;CACnD,OAAO;EACN,qBAAqB;EACrB;EACA;EACA;EACA;CACD;AACD;AAEA,eAAe,aAAa,QAAqC;CAChE,IAAI,OAAO,WAAW,MAAM,GAAG;EAC9B,MAAM,WAAW,MAAM,MAAM,MAAM;EACnC,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,WAAW,qBAAqB,gCAAgC,QAAQ;EACpG,OAAO,IAAI,WAAW,MAAM,SAAS,YAAY,CAAC;CACnD;CACA,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,IAAI,KAAK,WAAW,MAAM,GAAG;EAChC,MAAM,WAAW,MAAM,MAAM,IAAI,IAAI;EACrC,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,WAAW,sBAAsB,iCAAiC,IAAI,MAAM;EACxG,OAAO,OAAO,KAAK,MAAM,SAAS,YAAY,CAAC,CAAC,CAAC,SAAS,QAAQ;CACnE;CAEA,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,oBAAoB,KAAqC;CACvE,IAAI,OAAO;CACX,OAAO;AACR;AAEA,eAAe,UAAU,UAAkB,MAAiE;CAC3G,MAAM,GAAG,UAAU,UAAU,IAA2B;CACxD,OAAO;AACR;;;ACrDA,IAAa,SAAb,cAA4B,iBAAiB;CAC5C,cAAc;EACb,MAAM,kBAAkB,CAAC;CAC1B;AACD"}