@shbernal/ts-pptx 4.1.0 → 5.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 (139) hide show
  1. package/README.md +11 -11
  2. package/dist/anim-presets-Qbgh8uut.js +55 -0
  3. package/dist/anim-presets-Qbgh8uut.js.map +1 -0
  4. package/dist/{autopage-D4kyVp11.js → autopage-DqZ37VpL.js} +11 -12
  5. package/dist/autopage-DqZ37VpL.js.map +1 -0
  6. package/dist/{binary-string-CKVAYI3M.js → binary-string-Ba8VM3b9.js} +3 -4
  7. package/dist/binary-string-Ba8VM3b9.js.map +1 -0
  8. package/dist/{body-insets-kVHmjGc6.js → body-insets-BDHymJvz.js} +7 -9
  9. package/dist/body-insets-BDHymJvz.js.map +1 -0
  10. package/dist/browser.d.ts +24 -16
  11. package/dist/browser.d.ts.map +1 -1
  12. package/dist/browser.js +19 -19
  13. package/dist/browser.js.map +1 -1
  14. package/dist/{image-size-DwDbakcl.js → chart-metadata-CwiTTcJq.js} +576 -538
  15. package/dist/chart-metadata-CwiTTcJq.js.map +1 -0
  16. package/dist/{clip-DHDlnHUq.d.ts → clip-ISfCMtWA.d.ts} +6 -10
  17. package/dist/clip-ISfCMtWA.d.ts.map +1 -0
  18. package/dist/{notes-BcT571R4.js → comments-CKIZYRbZ.js} +517 -389
  19. package/dist/comments-CKIZYRbZ.js.map +1 -0
  20. package/dist/{diagnostics-DiMmBU8P.d.ts → diagnostics-MoA4MBq5.d.ts} +52 -50
  21. package/dist/diagnostics-MoA4MBq5.d.ts.map +1 -0
  22. package/dist/{embedded-fonts-CI_YGW2d.d.ts → embedded-fonts-U7HIIhPO.d.ts} +4 -6
  23. package/dist/embedded-fonts-U7HIIhPO.d.ts.map +1 -0
  24. package/dist/{entry-compose-6hF9aTmT.d.ts → entry-compose-CiakSt-f.d.ts} +53 -74
  25. package/dist/entry-compose-CiakSt-f.d.ts.map +1 -0
  26. package/dist/{errors-Da2nXCJm.js → entry-errors-JMthgJ2g.js} +41 -25
  27. package/dist/entry-errors-JMthgJ2g.js.map +1 -0
  28. package/dist/{table-cell-margins-PDshga8T.js → enums-BP9wsb9Q.js} +42 -45
  29. package/dist/enums-BP9wsb9Q.js.map +1 -0
  30. package/dist/{enums-DQRpVOLh.d.ts → enums-PcXr3o3J.d.ts} +11 -12
  31. package/dist/{enums-DQRpVOLh.d.ts.map → enums-PcXr3o3J.d.ts.map} +1 -1
  32. package/dist/families.d.ts +24 -26
  33. package/dist/families.d.ts.map +1 -1
  34. package/dist/families.js +3 -4
  35. package/dist/{fit-CcXbg__l.js → fit-Bpmzep6O.js} +60 -52
  36. package/dist/fit-Bpmzep6O.js.map +1 -0
  37. package/dist/{font-metrics-CBGmhLo0.d.ts → font-metrics-DTppw4t3.d.ts} +61 -37
  38. package/dist/font-metrics-DTppw4t3.d.ts.map +1 -0
  39. package/dist/{grid-9B2w5EaY.js → grid-DUIMxjfl.js} +23 -26
  40. package/dist/grid-DUIMxjfl.js.map +1 -0
  41. package/dist/{html-dom-DvJmuHt2.js → html-dom-LZCgntnJ.js} +42 -43
  42. package/dist/html-dom-LZCgntnJ.js.map +1 -0
  43. package/dist/html.d.ts +53 -9
  44. package/dist/html.d.ts.map +1 -1
  45. package/dist/html.js +12 -13
  46. package/dist/html.js.map +1 -1
  47. package/dist/index.d.ts +21 -13
  48. package/dist/index.d.ts.map +1 -1
  49. package/dist/index.js +15 -15
  50. package/dist/index.js.map +1 -1
  51. package/dist/inspect.d.ts +14 -16
  52. package/dist/inspect.d.ts.map +1 -1
  53. package/dist/inspect.js +18 -19
  54. package/dist/inspect.js.map +1 -1
  55. package/dist/{text-anchor-BgLPbwbL.js → lock-attrs-CSQnFDHP.js} +62 -12
  56. package/dist/lock-attrs-CSQnFDHP.js.map +1 -0
  57. package/dist/math.d.ts +2 -4
  58. package/dist/math.d.ts.map +1 -1
  59. package/dist/math.js +12 -13
  60. package/dist/math.js.map +1 -1
  61. package/dist/measure.d.ts +23 -12
  62. package/dist/measure.d.ts.map +1 -1
  63. package/dist/measure.js +3 -3
  64. package/dist/node.d.ts +21 -13
  65. package/dist/node.d.ts.map +1 -1
  66. package/dist/node.js +12 -12
  67. package/dist/node.js.map +1 -1
  68. package/dist/{options-internal-WqgMf720.js → options-internal-BWgmLPdx.js} +4 -5
  69. package/dist/options-internal-BWgmLPdx.js.map +1 -0
  70. package/dist/{package-KoEgVwII.d.ts → package-CANBWuSm.d.ts} +4 -12
  71. package/dist/package-CANBWuSm.d.ts.map +1 -0
  72. package/dist/{playbtn-CUqQdoDf.js → playbtn-BQZFJir9.js} +4 -5
  73. package/dist/playbtn-BQZFJir9.js.map +1 -0
  74. package/dist/{pres-BA9_lJbY.d.ts → pres-BkEkUAEM.d.ts} +383 -230
  75. package/dist/pres-BkEkUAEM.d.ts.map +1 -0
  76. package/dist/{presentation-Cyl74rq2.js → presentation-4Ggq0_Xa.js} +408 -288
  77. package/dist/presentation-4Ggq0_Xa.js.map +1 -0
  78. package/dist/{presentation-types-B3VQH4Bz.d.ts → presentation-types-BgnZR-0a.d.ts} +1104 -457
  79. package/dist/presentation-types-BgnZR-0a.d.ts.map +1 -0
  80. package/dist/read.d.ts +18 -13
  81. package/dist/read.d.ts.map +1 -1
  82. package/dist/read.js +4 -4
  83. package/dist/script.d.ts +116 -65
  84. package/dist/script.d.ts.map +1 -1
  85. package/dist/script.js +2697 -777
  86. package/dist/script.js.map +1 -1
  87. package/dist/{shapes-BcyFdZpp.js → shapes-CAPOjU0Q.js} +1556 -487
  88. package/dist/shapes-CAPOjU0Q.js.map +1 -0
  89. package/dist/{slide-BqPtyKmb.d.ts → slide-BmT4kMoO.d.ts} +94 -86
  90. package/dist/slide-BmT4kMoO.d.ts.map +1 -0
  91. package/dist/{slide-size-BalTjFuv.js → slide-size-SkScz1ig.js} +2 -3
  92. package/dist/{slide-size-BalTjFuv.js.map → slide-size-SkScz1ig.js.map} +1 -1
  93. package/dist/{table-dom-CVbvUfgh.js → table-dom-BYga4FYY.js} +3 -4
  94. package/dist/{table-dom-CVbvUfgh.js.map → table-dom-BYga4FYY.js.map} +1 -1
  95. package/dist/{text-BvFFMMFQ.js → text-Dz0ArGIp.js} +365 -318
  96. package/dist/text-Dz0ArGIp.js.map +1 -0
  97. package/dist/{transition-speed-kUEWDWTx.js → transition-speed-CNJ0fSpQ.js} +2 -3
  98. package/dist/{transition-speed-kUEWDWTx.js.map → transition-speed-CNJ0fSpQ.js.map} +1 -1
  99. package/dist/{units-internal-DFcUYjh3.js → units-internal-BR3a4cIi.js} +26 -29
  100. package/dist/units-internal-BR3a4cIi.js.map +1 -0
  101. package/dist/{zip-CYZ0F6BV.js → zip-7JTh61LX.js} +8 -10
  102. package/dist/zip-7JTh61LX.js.map +1 -0
  103. package/dist/{zip-CTll_dr0.d.ts → zip-uUjs9Cqx.d.ts} +4 -6
  104. package/dist/zip-uUjs9Cqx.d.ts.map +1 -0
  105. package/dist/zip.d.ts +3 -3
  106. package/dist/zip.js +3 -3
  107. package/dist/{zoom-BoNyOlPm.js → zoom-CSSeOwM8.js} +1153 -583
  108. package/dist/zoom-CSSeOwM8.js.map +1 -0
  109. package/package.json +20 -21
  110. package/skills/{ts-pptx-upstream → pptx-ts-upstream}/SKILL.md +27 -74
  111. package/dist/autopage-D4kyVp11.js.map +0 -1
  112. package/dist/binary-string-CKVAYI3M.js.map +0 -1
  113. package/dist/body-insets-kVHmjGc6.js.map +0 -1
  114. package/dist/clip-DHDlnHUq.d.ts.map +0 -1
  115. package/dist/diagnostics-DiMmBU8P.d.ts.map +0 -1
  116. package/dist/embedded-fonts-CI_YGW2d.d.ts.map +0 -1
  117. package/dist/entry-compose-6hF9aTmT.d.ts.map +0 -1
  118. package/dist/errors-Da2nXCJm.js.map +0 -1
  119. package/dist/fit-CcXbg__l.js.map +0 -1
  120. package/dist/font-metrics-CBGmhLo0.d.ts.map +0 -1
  121. package/dist/grid-9B2w5EaY.js.map +0 -1
  122. package/dist/html-dom-DvJmuHt2.js.map +0 -1
  123. package/dist/image-size-DwDbakcl.js.map +0 -1
  124. package/dist/notes-BcT571R4.js.map +0 -1
  125. package/dist/options-internal-WqgMf720.js.map +0 -1
  126. package/dist/package-KoEgVwII.d.ts.map +0 -1
  127. package/dist/playbtn-CUqQdoDf.js.map +0 -1
  128. package/dist/pres-BA9_lJbY.d.ts.map +0 -1
  129. package/dist/presentation-Cyl74rq2.js.map +0 -1
  130. package/dist/presentation-types-B3VQH4Bz.d.ts.map +0 -1
  131. package/dist/shapes-BcyFdZpp.js.map +0 -1
  132. package/dist/slide-BqPtyKmb.d.ts.map +0 -1
  133. package/dist/table-cell-margins-PDshga8T.js.map +0 -1
  134. package/dist/text-BvFFMMFQ.js.map +0 -1
  135. package/dist/text-anchor-BgLPbwbL.js.map +0 -1
  136. package/dist/units-internal-DFcUYjh3.js.map +0 -1
  137. package/dist/zip-CTll_dr0.d.ts.map +0 -1
  138. package/dist/zip-CYZ0F6BV.js.map +0 -1
  139. package/dist/zoom-BoNyOlPm.js.map +0 -1
package/dist/browser.js CHANGED
@@ -1,9 +1,9 @@
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-Da2nXCJm.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-PDshga8T.js";
3
- import { c as ALL_CONSTRUCT_FAMILIES, d as IMG_SVG_PLACEHOLDER, i as fetchFontBytes, l as composePresentation, n as textRuns, r as clipPath, t as textRun, u as PresentationCore } from "./text-BvFFMMFQ.js";
4
- import { r as PPTX_CONTENT_TYPE } from "./zip-CYZ0F6BV.js";
5
- import { t as tableDomFamily } from "./table-dom-CVbvUfgh.js";
6
- //#region src/runtime/browser.ts
1
+ import { c as ALL_CONSTRUCT_FAMILIES, d as IMG_SVG_PLACEHOLDER, i as fetchFontBytes, l as composePresentation, n as textRuns, r as clipPath, t as textRun, u as PresentationCore } from "./text-Dz0ArGIp.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, a as OutputType, b as FIXED_PCT_PER_PERCENT, c as ShapeType, d as TextAnchor, f as VALID_SHAPE_PRESETS, g as isChartType, h as isChartExType, i as ChartType, j as percentToEmu, k as emuToPoints, l as SlideObjectType, m as connectorPresetFor, n as AlignV, o as PlaceholderType, p as asChartType, r as BulletType, s as SchemeColor, t as AlignH, u as TableStyle, v as ANGLE_UNITS_PER_DEGREE, w as PERCENT_SCALE, x as HUNDREDTHS_PER_POINT, y as DEFAULT_PX_PER_INCH } from "./enums-BP9wsb9Q.js";
3
+ import { a as PackageReadError, c as resetDiagnosticState, i as MediaError, l as setDiagnosticHandler, n as InternalError, o as PptxTsError, r as InvalidOptionError, s as UnsupportedFeatureError, t as TsPptxError } from "./entry-errors-JMthgJ2g.js";
4
+ import { r as PPTX_CONTENT_TYPE } from "./zip-7JTh61LX.js";
5
+ import { t as tableDomFamily } from "./table-dom-BYga4FYY.js";
6
+ // src/runtime/browser.ts
7
7
  function createBrowserRuntime() {
8
8
  return {
9
9
  writeFileOutputType: null,
@@ -14,7 +14,7 @@ function createBrowserRuntime() {
14
14
  };
15
15
  }
16
16
  /**
17
- * Returns a `data:` URI, not raw base64 — see {@link RuntimeAdapter.loadMedia}. The `FileReader`
17
+ * Returns a `data:` URI, not raw base64; see {@link RuntimeAdapter.loadMedia}. The `FileReader`
18
18
  * is what makes this adapter's own implementation worth keeping: it decodes the blob off the main
19
19
  * thread, where the shared `fetchMediaBase64` would encode the whole payload synchronously.
20
20
  */
@@ -58,7 +58,7 @@ async function createSvgPngPreview(rel) {
58
58
  }
59
59
  };
60
60
  image.onerror = () => fail();
61
- image.src = typeof rel.data === "string" ? rel.data : IMG_SVG_PLACEHOLDER;
61
+ image.src = rel.data;
62
62
  });
63
63
  }
64
64
  async function writeFile(fileName, data) {
@@ -76,8 +76,7 @@ async function writeFile(fileName, data) {
76
76
  }, 100);
77
77
  return fileName;
78
78
  }
79
- //#endregion
80
- //#region src/browser.ts
79
+ // src/browser.ts
81
80
  /**
82
81
  * The browser authoring entry, which the bare `pptx-ts` specifier resolves to under the
83
82
  * `browser` export condition.
@@ -85,20 +84,20 @@ async function writeFile(fileName, data) {
85
84
  * @module
86
85
  */
87
86
  /**
88
- * The browser entry, reached through the `browser` export condition — a bundler resolving the
87
+ * The browser entry, reached through the `browser` export condition. A bundler resolving the
89
88
  * bare `pptx-ts` specifier for the web lands here without naming this subpath.
90
89
  *
91
90
  * Same authoring API as every other entry (see `entry-surface.ts`), plus one method that only
92
- * makes sense with a live DOM: {@link TsPptx.tableToSlides}. `writeFile` triggers a download
91
+ * makes sense with a live DOM: {@link PptxTs.tableToSlides}. `writeFile` triggers a download
93
92
  * rather than touching a filesystem.
94
93
  */
95
- var TsPptx = class extends PresentationCore {
94
+ var PptxTs = class extends PresentationCore {
96
95
  constructor() {
97
96
  super(createBrowserRuntime(), [...ALL_CONSTRUCT_FAMILIES, tableDomFamily]);
98
97
  }
99
98
  /**
100
- * Reproduces a rendered HTML `<table>` as a PowerPoint table — including column widths,
101
- * style, etc. — creating one or more slides as needed. Resolves `eleId` against the global
99
+ * Reproduces a rendered HTML `<table>` as a PowerPoint table (including column widths,
100
+ * style, etc.), creating one or more slides as needed. Resolves `eleId` against the global
102
101
  * `document`, so it exists only on the browser/standalone build; the same conversion is
103
102
  * available anywhere there is a DOM as the free `tableToSlides` on `pptx-ts/html`, which
104
103
  * also takes the element directly. The in-memory `slide.addTable(rows, opts)` path remains
@@ -107,7 +106,7 @@ var TsPptx = class extends PresentationCore {
107
106
  * That global lookup is why this stays rather than folding into the free function: reaching
108
107
  * `document` without being handed one is the affordance the browser entry exists to give, and
109
108
  * it is the one thing the platform-agnostic form deliberately will not do. The conversion
110
- * itself lives in one place either way — both spellings call `genTableToSlides`.
109
+ * itself lives in one place either way: both spellings call `genTableToSlides`.
111
110
  * @param {string} eleId - table HTML element ID
112
111
  * @param {TableToSlidesProps} options - generation options
113
112
  */
@@ -118,7 +117,7 @@ var TsPptx = class extends PresentationCore {
118
117
  /**
119
118
  * Compose a presentation from the construct families it needs, on the browser adapter.
120
119
  *
121
- * The counterpart to {@link TsPptx}, which is composed with every family there is. This one costs
120
+ * The counterpart to {@link PptxTs}, which is composed with every family there is. This one costs
122
121
  * what it carries: the core tier (text, shapes, images, groups, speaker notes) plus whatever
123
122
  * `use` names, and nothing else reaches the bundle. `tableToSlides` is one of those families
124
123
  * (`domTables`), so a deck that wants it composes it.
@@ -131,7 +130,8 @@ var TsPptx = class extends PresentationCore {
131
130
  function createPresentation(opts) {
132
131
  return composePresentation(createBrowserRuntime(), opts);
133
132
  }
134
- //#endregion
135
- 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 };
133
+ /** @deprecated Renamed to {@link PptxTs}. This alias is removed in v5. */
134
+ const TsPptx = PptxTs;
135
+ 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, PptxTs, PptxTs as default, PptxTsError, STANDARD_LAYOUTS, SchemeColor, ShapeType, SlideObjectType, TableStyle, TextAnchor, TsPptx, TsPptxError, UnsupportedFeatureError, VALID_SHAPE_PRESETS, asChartType, clipPath, connectorPresetFor, coordToEmu, createPresentation, emuToInches, emuToPixels, emuToPoints, inchesToEmu, isChartExType, isChartType, percentToEmu, pixelsToEmu, pointsToEmu, ptToHundredths, resetDiagnosticState, setDiagnosticHandler, textRun, textRuns };
136
136
 
137
137
  //# sourceMappingURL=browser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.js","names":[],"sources":["../src/runtime/browser.ts","../src/browser.ts"],"sourcesContent":["import { IMG_SVG_PLACEHOLDER } from '../media/placeholders.js'\nimport { MediaError } from '../errors.js'\nimport type { SlideRelMedia } from '../types/internal.js'\nimport type { RuntimeAdapter } from './types.js'\nimport { fetchFontBytes } from './fetch-media.js'\nimport { PPTX_CONTENT_TYPE } from '../ooxml/pptx-content-type.js'\n\nexport function createBrowserRuntime(): RuntimeAdapter {\n\treturn {\n\t\twriteFileOutputType: null,\n\t\tloadMedia,\n\t\tcreateSvgPngPreview,\n\t\twriteFile,\n\t\tloadFontData: fetchFontBytes,\n\t}\n}\n\n/**\n * Returns a `data:` URI, not raw base64 — see {@link RuntimeAdapter.loadMedia}. The `FileReader`\n * is what makes this adapter's own implementation worth keeping: it decodes the blob off the main\n * thread, where the shared `fetchMediaBase64` would encode the whole payload synchronously.\n */\nasync function loadMedia(rel: SlideRelMedia & { path: string }): Promise<string> {\n\tconst response = await fetch(rel.path)\n\tif (!response.ok) throw new MediaError('media/fetch-failed', `Unable to load image (fetch): ${rel.path}`)\n\tconst blob = await response.blob()\n\n\treturn await new Promise<string>((resolve, reject) => {\n\t\tconst reader = new FileReader()\n\t\treader.onloadend = () => resolve(reader.result as string)\n\t\treader.onerror = () =>\n\t\t\treject(new MediaError('media/decode-failed', `Unable to load image (FileReader): ${rel.path}`))\n\t\treader.readAsDataURL(blob)\n\t})\n}\n\nasync function createSvgPngPreview(rel: SlideRelMedia): Promise<MediaError | null> {\n\treturn await new Promise((resolve) => {\n\t\tconst image = new Image()\n\t\t// Resolves, as the Node and neutral adapters do. It used to reject, so the same failure\n\t\t// reached the caller three ways depending on runtime and on how the SVG arrived.\n\t\tconst fail = (reason?: unknown) => {\n\t\t\trel.data = IMG_SVG_PLACEHOLDER\n\t\t\tresolve(\n\t\t\t\tnew MediaError(\n\t\t\t\t\t'media/svg-preview-failed',\n\t\t\t\t\t`Unable to load image (image.onerror): ${rel.path}${reason ? ` - ${String(reason)}` : ''}`\n\t\t\t\t)\n\t\t\t)\n\t\t}\n\n\t\timage.onload = () => {\n\t\t\tif (image.width + image.height === 0) {\n\t\t\t\tfail('h/w=0')\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst canvas = document.createElement('CANVAS') as HTMLCanvasElement\n\t\t\tconst ctx = canvas.getContext('2d')\n\t\t\tif (!ctx) {\n\t\t\t\tfail('canvas 2d context unavailable')\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcanvas.width = image.width\n\t\t\tcanvas.height = image.height\n\t\t\tctx.drawImage(image, 0, 0)\n\t\t\ttry {\n\t\t\t\t// `rel.type` is `image/png`, not the SVG's type, so this is a valid canvas output\n\t\t\t\t// type and not an `image/svg+xml` that silently falls back to PNG.\n\t\t\t\t// `createSvgPngPreview` is only called on a rel flagged `isSvgPng` — all three\n\t\t\t\t// call sites in `gen/media.ts` filter on it — and the only two places that\n\t\t\t\t// create such a rel (`gen/define/image.ts`, `gen/define/text.ts`) set the\n\t\t\t\t// *fallback's* type, since that is the part this writes. The SVG keeps its own\n\t\t\t\t// rel beside it.\n\t\t\t\trel.data = canvas.toDataURL(rel.type)\n\t\t\t\tresolve(null)\n\t\t\t} catch (ex) {\n\t\t\t\tfail(ex)\n\t\t\t}\n\t\t}\n\t\timage.onerror = () => fail()\n\t\timage.src = typeof rel.data === 'string' ? rel.data : IMG_SVG_PLACEHOLDER\n\t})\n}\n\nasync function writeFile(fileName: string, data: string | ArrayBuffer | Blob | Uint8Array): Promise<string> {\n\tconst eleLink = document.createElement('a')\n\teleLink.setAttribute('style', 'display:none;')\n\teleLink.dataset['interception'] = 'off'\n\tdocument.body.appendChild(eleLink)\n\n\tconst url = window.URL.createObjectURL(new Blob([data as Blob], { type: PPTX_CONTENT_TYPE }))\n\teleLink.href = url\n\teleLink.download = fileName\n\teleLink.click()\n\n\tsetTimeout(() => {\n\t\twindow.URL.revokeObjectURL(url)\n\t\tdocument.body.removeChild(eleLink)\n\t}, 100)\n\n\treturn fileName\n}\n","/**\n * The browser authoring entry, which the bare `pptx-ts` specifier resolves to under the\n * `browser` 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 { createBrowserRuntime } from './runtime/browser.js'\nimport { tableDomFamily } from './families/table-dom.js'\nimport type { TableToSlidesProps } from './types/index.js'\n\n/**\n * The browser entry, reached through the `browser` export condition — a bundler resolving the\n * bare `pptx-ts` specifier for the web lands here without naming this subpath.\n *\n * Same authoring API as every other entry (see `entry-surface.ts`), plus one method that only\n * makes sense with a live DOM: {@link TsPptx.tableToSlides}. `writeFile` triggers a download\n * rather than touching a filesystem.\n */\nexport class TsPptx extends PresentationCore {\n\tconstructor() {\n\t\t// The table family's live-DOM half is composed here and nowhere else: it is the one part of\n\t\t// the authoring surface that needs a `document`.\n\t\tsuper(createBrowserRuntime(), [...ALL_CONSTRUCT_FAMILIES, tableDomFamily])\n\t}\n\n\t/**\n\t * Reproduces a rendered HTML `<table>` as a PowerPoint table — including column widths,\n\t * style, etc. — creating one or more slides as needed. Resolves `eleId` against the global\n\t * `document`, so it exists only on the browser/standalone build; the same conversion is\n\t * available anywhere there is a DOM as the free `tableToSlides` on `pptx-ts/html`, which\n\t * also takes the element directly. The in-memory `slide.addTable(rows, opts)` path remains\n\t * the platform-agnostic way to build a table from data you already hold.\n\t *\n\t * That global lookup is why this stays rather than folding into the free function: reaching\n\t * `document` without being handed one is the affordance the browser entry exists to give, and\n\t * it is the one thing the platform-agnostic form deliberately will not do. The conversion\n\t * itself lives in one place either way — both spellings call `genTableToSlides`.\n\t * @param {string} eleId - table HTML element ID\n\t * @param {TableToSlidesProps} options - generation options\n\t */\n\ttableToSlides(eleId: string, options: TableToSlidesProps = {}): void {\n\t\tthis.familyAuthor('tableToSlides')(eleId, options)\n\t}\n}\n\n/**\n * Compose a presentation from the construct families it needs, on the browser 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. `tableToSlides` is one of those families\n * (`domTables`), so a deck that wants it composes it.\n * @param {ComposeOptions} opts - the families to compose in, from `pptx-ts/families`\n * @example\n * import { createPresentation } from 'pptx-ts/browser'\n * import { charts, domTables } from 'pptx-ts/families'\n * const pres = createPresentation({ use: [charts, domTables] })\n */\nexport function createPresentation<const Fs extends readonly ConstructFamily[] = []>(\n\topts?: ComposeOptions<Fs>\n): Composed<Fs> {\n\treturn composePresentation(createBrowserRuntime(), opts)\n}\n\nexport { TsPptx as default }\nexport * from './entry-surface.js'\n"],"mappings":";;;;;;AAOA,SAAgB,uBAAuC;CACtD,OAAO;EACN,qBAAqB;EACrB;EACA;EACA;EACA,cAAc;CACf;AACD;;;;;;AAOA,eAAe,UAAU,KAAwD;CAChF,MAAM,WAAW,MAAM,MAAM,IAAI,IAAI;CACrC,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,WAAW,sBAAsB,iCAAiC,IAAI,MAAM;CACxG,MAAM,OAAO,MAAM,SAAS,KAAK;CAEjC,OAAO,MAAM,IAAI,SAAiB,SAAS,WAAW;EACrD,MAAM,SAAS,IAAI,WAAW;EAC9B,OAAO,kBAAkB,QAAQ,OAAO,MAAgB;EACxD,OAAO,gBACN,OAAO,IAAI,WAAW,uBAAuB,sCAAsC,IAAI,MAAM,CAAC;EAC/F,OAAO,cAAc,IAAI;CAC1B,CAAC;AACF;AAEA,eAAe,oBAAoB,KAAgD;CAClF,OAAO,MAAM,IAAI,SAAS,YAAY;EACrC,MAAM,QAAQ,IAAI,MAAM;EAGxB,MAAM,QAAQ,WAAqB;GAClC,IAAI,OAAO;GACX,QACC,IAAI,WACH,4BACA,yCAAyC,IAAI,OAAO,SAAS,MAAM,OAAO,MAAM,MAAM,IACvF,CACD;EACD;EAEA,MAAM,eAAe;GACpB,IAAI,MAAM,QAAQ,MAAM,WAAW,GAAG;IACrC,KAAK,OAAO;IACZ;GACD;GACA,MAAM,SAAS,SAAS,cAAc,QAAQ;GAC9C,MAAM,MAAM,OAAO,WAAW,IAAI;GAClC,IAAI,CAAC,KAAK;IACT,KAAK,+BAA+B;IACpC;GACD;GACA,OAAO,QAAQ,MAAM;GACrB,OAAO,SAAS,MAAM;GACtB,IAAI,UAAU,OAAO,GAAG,CAAC;GACzB,IAAI;IAQH,IAAI,OAAO,OAAO,UAAU,IAAI,IAAI;IACpC,QAAQ,IAAI;GACb,SAAS,IAAI;IACZ,KAAK,EAAE;GACR;EACD;EACA,MAAM,gBAAgB,KAAK;EAC3B,MAAM,MAAM,OAAO,IAAI,SAAS,WAAW,IAAI,OAAO;CACvD,CAAC;AACF;AAEA,eAAe,UAAU,UAAkB,MAAiE;CAC3G,MAAM,UAAU,SAAS,cAAc,GAAG;CAC1C,QAAQ,aAAa,SAAS,eAAe;CAC7C,QAAQ,QAAQ,kBAAkB;CAClC,SAAS,KAAK,YAAY,OAAO;CAEjC,MAAM,MAAM,OAAO,IAAI,gBAAgB,IAAI,KAAK,CAAC,IAAY,GAAG,EAAE,MAAM,kBAAkB,CAAC,CAAC;CAC5F,QAAQ,OAAO;CACf,QAAQ,WAAW;CACnB,QAAQ,MAAM;CAEd,iBAAiB;EAChB,OAAO,IAAI,gBAAgB,GAAG;EAC9B,SAAS,KAAK,YAAY,OAAO;CAClC,GAAG,GAAG;CAEN,OAAO;AACR;;;;;;;;;;;;;;;;;AC/EA,IAAa,SAAb,cAA4B,iBAAiB;CAC5C,cAAc;EAGb,MAAM,qBAAqB,GAAG,CAAC,GAAG,wBAAwB,cAAc,CAAC;CAC1E;;;;;;;;;;;;;;;;CAiBA,cAAc,OAAe,UAA8B,CAAC,GAAS;EACpE,KAAK,aAAa,eAAe,CAAC,CAAC,OAAO,OAAO;CAClD;AACD;;;;;;;;;;;;;;AAeA,SAAgB,mBACf,MACe;CACf,OAAO,oBAAoB,qBAAqB,GAAG,IAAI;AACxD"}
1
+ {"version":3,"file":"browser.js","names":[],"sources":["../src/runtime/browser.ts","../src/browser.ts"],"sourcesContent":["import { IMG_SVG_PLACEHOLDER } from '../media/placeholders.js'\nimport { MediaError } from '../errors.js'\nimport type { SlideRelMedia } from '../types/internal.js'\nimport type { RuntimeAdapter } from './types.js'\nimport { fetchFontBytes } from './fetch-media.js'\nimport { PPTX_CONTENT_TYPE } from '../ooxml/pptx-content-type.js'\n\nexport function createBrowserRuntime(): RuntimeAdapter {\n\treturn {\n\t\twriteFileOutputType: null,\n\t\tloadMedia,\n\t\tcreateSvgPngPreview,\n\t\twriteFile,\n\t\tloadFontData: fetchFontBytes,\n\t}\n}\n\n/**\n * Returns a `data:` URI, not raw base64; see {@link RuntimeAdapter.loadMedia}. The `FileReader`\n * is what makes this adapter's own implementation worth keeping: it decodes the blob off the main\n * thread, where the shared `fetchMediaBase64` would encode the whole payload synchronously.\n */\nasync function loadMedia(rel: SlideRelMedia & { path: string }): Promise<string> {\n\tconst response = await fetch(rel.path)\n\tif (!response.ok) throw new MediaError('media/fetch-failed', `Unable to load image (fetch): ${rel.path}`)\n\tconst blob = await response.blob()\n\n\treturn await new Promise<string>((resolve, reject) => {\n\t\tconst reader = new FileReader()\n\t\treader.onloadend = () => resolve(reader.result as string)\n\t\treader.onerror = () =>\n\t\t\treject(new MediaError('media/decode-failed', `Unable to load image (FileReader): ${rel.path}`))\n\t\treader.readAsDataURL(blob)\n\t})\n}\n\nasync function createSvgPngPreview(rel: SlideRelMedia): Promise<MediaError | null> {\n\treturn await new Promise((resolve) => {\n\t\tconst image = new Image()\n\t\t// Resolves, as the Node and neutral adapters do. It used to reject, so the same failure\n\t\t// reached the caller three ways depending on runtime and on how the SVG arrived.\n\t\tconst fail = (reason?: unknown) => {\n\t\t\trel.data = IMG_SVG_PLACEHOLDER\n\t\t\tresolve(\n\t\t\t\tnew MediaError(\n\t\t\t\t\t'media/svg-preview-failed',\n\t\t\t\t\t`Unable to load image (image.onerror): ${rel.path}${reason ? ` - ${String(reason)}` : ''}`\n\t\t\t\t)\n\t\t\t)\n\t\t}\n\n\t\timage.onload = () => {\n\t\t\tif (image.width + image.height === 0) {\n\t\t\t\tfail('h/w=0')\n\t\t\t\treturn\n\t\t\t}\n\t\t\tconst canvas = document.createElement('CANVAS') as HTMLCanvasElement\n\t\t\tconst ctx = canvas.getContext('2d')\n\t\t\tif (!ctx) {\n\t\t\t\tfail('canvas 2d context unavailable')\n\t\t\t\treturn\n\t\t\t}\n\t\t\tcanvas.width = image.width\n\t\t\tcanvas.height = image.height\n\t\t\tctx.drawImage(image, 0, 0)\n\t\t\ttry {\n\t\t\t\t// `rel.type` is `image/png`, not the SVG's type, so this is a valid canvas output\n\t\t\t\t// type and not an `image/svg+xml` that silently falls back to PNG.\n\t\t\t\t// `createSvgPngPreview` is only called on a rel flagged `isSvgPng` (all three\n\t\t\t\t// call sites in `gen/media.ts` filter on it), and the only two places that\n\t\t\t\t// create such a rel (`gen/define/image.ts`, `gen/define/text.ts`) set the\n\t\t\t\t// *fallback's* type, since that is the part this writes. The SVG keeps its own\n\t\t\t\t// rel beside it.\n\t\t\t\trel.data = canvas.toDataURL(rel.type)\n\t\t\t\tresolve(null)\n\t\t\t} catch (ex) {\n\t\t\t\tfail(ex)\n\t\t\t}\n\t\t}\n\t\timage.onerror = () => fail()\n\t\timage.src = rel.data\n\t})\n}\n\nasync function writeFile(fileName: string, data: string | ArrayBuffer | Blob | Uint8Array): Promise<string> {\n\tconst eleLink = document.createElement('a')\n\teleLink.setAttribute('style', 'display:none;')\n\teleLink.dataset['interception'] = 'off'\n\tdocument.body.appendChild(eleLink)\n\n\tconst url = window.URL.createObjectURL(new Blob([data as Blob], { type: PPTX_CONTENT_TYPE }))\n\teleLink.href = url\n\teleLink.download = fileName\n\teleLink.click()\n\n\tsetTimeout(() => {\n\t\twindow.URL.revokeObjectURL(url)\n\t\tdocument.body.removeChild(eleLink)\n\t}, 100)\n\n\treturn fileName\n}\n","/**\n * The browser authoring entry, which the bare `pptx-ts` specifier resolves to under the\n * `browser` 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 { createBrowserRuntime } from './runtime/browser.js'\nimport { tableDomFamily } from './families/table-dom.js'\nimport type { TableToSlidesProps } from './types/index.js'\n\n/**\n * The browser entry, reached through the `browser` export condition. A bundler resolving the\n * bare `pptx-ts` specifier for the web lands here without naming this subpath.\n *\n * Same authoring API as every other entry (see `entry-surface.ts`), plus one method that only\n * makes sense with a live DOM: {@link PptxTs.tableToSlides}. `writeFile` triggers a download\n * rather than touching a filesystem.\n */\nexport class PptxTs extends PresentationCore {\n\tconstructor() {\n\t\t// The table family's live-DOM half is composed here and nowhere else: it is the one part of\n\t\t// the authoring surface that needs a `document`.\n\t\tsuper(createBrowserRuntime(), [...ALL_CONSTRUCT_FAMILIES, tableDomFamily])\n\t}\n\n\t/**\n\t * Reproduces a rendered HTML `<table>` as a PowerPoint table (including column widths,\n\t * style, etc.), creating one or more slides as needed. Resolves `eleId` against the global\n\t * `document`, so it exists only on the browser/standalone build; the same conversion is\n\t * available anywhere there is a DOM as the free `tableToSlides` on `pptx-ts/html`, which\n\t * also takes the element directly. The in-memory `slide.addTable(rows, opts)` path remains\n\t * the platform-agnostic way to build a table from data you already hold.\n\t *\n\t * That global lookup is why this stays rather than folding into the free function: reaching\n\t * `document` without being handed one is the affordance the browser entry exists to give, and\n\t * it is the one thing the platform-agnostic form deliberately will not do. The conversion\n\t * itself lives in one place either way: both spellings call `genTableToSlides`.\n\t * @param {string} eleId - table HTML element ID\n\t * @param {TableToSlidesProps} options - generation options\n\t */\n\ttableToSlides(eleId: string, options: TableToSlidesProps = {}): void {\n\t\tthis.familyAuthor('tableToSlides')(eleId, options)\n\t}\n}\n\n/**\n * Compose a presentation from the construct families it needs, on the browser adapter.\n *\n * The counterpart to {@link PptxTs}, 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. `tableToSlides` is one of those families\n * (`domTables`), so a deck that wants it composes it.\n * @param {ComposeOptions} opts - the families to compose in, from `pptx-ts/families`\n * @example\n * import { createPresentation } from 'pptx-ts/browser'\n * import { charts, domTables } from 'pptx-ts/families'\n * const pres = createPresentation({ use: [charts, domTables] })\n */\nexport function createPresentation<const Fs extends readonly ConstructFamily[] = []>(\n\topts?: ComposeOptions<Fs>\n): Composed<Fs> {\n\treturn composePresentation(createBrowserRuntime(), opts)\n}\n\nexport { PptxTs as default }\n\n/** @deprecated Renamed to {@link PptxTs}. This alias is removed in v5. */\nexport const TsPptx = PptxTs\n/** @deprecated Renamed to {@link PptxTs}. This alias is removed in v5. */\nexport type TsPptx = PptxTs\n\nexport * from './entry-surface.js'\n"],"mappings":";;;;;;AAOA,SAAgB,uBAAuC;CACtD,OAAO;EACN,qBAAqB;EACrB;EACA;EACA;EACA,cAAc;CACf;AACD;;;;;;AAOA,eAAe,UAAU,KAAwD;CAChF,MAAM,WAAW,MAAM,MAAM,IAAI,IAAI;CACrC,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,WAAW,sBAAsB,iCAAiC,IAAI,MAAM;CACxG,MAAM,OAAO,MAAM,SAAS,KAAK;CAEjC,OAAO,MAAM,IAAI,SAAiB,SAAS,WAAW;EACrD,MAAM,SAAS,IAAI,WAAW;EAC9B,OAAO,kBAAkB,QAAQ,OAAO,MAAgB;EACxD,OAAO,gBACN,OAAO,IAAI,WAAW,uBAAuB,sCAAsC,IAAI,MAAM,CAAC;EAC/F,OAAO,cAAc,IAAI;CAC1B,CAAC;AACF;AAEA,eAAe,oBAAoB,KAAgD;CAClF,OAAO,MAAM,IAAI,SAAS,YAAY;EACrC,MAAM,QAAQ,IAAI,MAAM;EAGxB,MAAM,QAAQ,WAAqB;GAClC,IAAI,OAAO;GACX,QACC,IAAI,WACH,4BACA,yCAAyC,IAAI,OAAO,SAAS,MAAM,OAAO,MAAM,MAAM,IACvF,CACD;EACD;EAEA,MAAM,eAAe;GACpB,IAAI,MAAM,QAAQ,MAAM,WAAW,GAAG;IACrC,KAAK,OAAO;IACZ;GACD;GACA,MAAM,SAAS,SAAS,cAAc,QAAQ;GAC9C,MAAM,MAAM,OAAO,WAAW,IAAI;GAClC,IAAI,CAAC,KAAK;IACT,KAAK,+BAA+B;IACpC;GACD;GACA,OAAO,QAAQ,MAAM;GACrB,OAAO,SAAS,MAAM;GACtB,IAAI,UAAU,OAAO,GAAG,CAAC;GACzB,IAAI;IAQH,IAAI,OAAO,OAAO,UAAU,IAAI,IAAI;IACpC,QAAQ,IAAI;GACb,SAAS,IAAI;IACZ,KAAK,EAAE;GACR;EACD;EACA,MAAM,gBAAgB,KAAK;EAC3B,MAAM,MAAM,IAAI;CACjB,CAAC;AACF;AAEA,eAAe,UAAU,UAAkB,MAAiE;CAC3G,MAAM,UAAU,SAAS,cAAc,GAAG;CAC1C,QAAQ,aAAa,SAAS,eAAe;CAC7C,QAAQ,QAAQ,kBAAkB;CAClC,SAAS,KAAK,YAAY,OAAO;CAEjC,MAAM,MAAM,OAAO,IAAI,gBAAgB,IAAI,KAAK,CAAC,IAAY,GAAG,EAAE,MAAM,kBAAkB,CAAC,CAAC;CAC5F,QAAQ,OAAO;CACf,QAAQ,WAAW;CACnB,QAAQ,MAAM;CAEd,iBAAiB;EAChB,OAAO,IAAI,gBAAgB,GAAG;EAC9B,SAAS,KAAK,YAAY,OAAO;CAClC,GAAG,GAAG;CAEN,OAAO;AACR;;;;;;;;;;;;;;;;AC/EA,IAAa,SAAb,cAA4B,iBAAiB;CAC5C,cAAc;EAGb,MAAM,qBAAqB,GAAG,CAAC,GAAG,wBAAwB,cAAc,CAAC;CAC1E;;;;;;;;;;;;;;;;CAiBA,cAAc,OAAe,UAA8B,CAAC,GAAS;EACpE,KAAK,aAAa,eAAe,CAAC,CAAC,OAAO,OAAO;CAClD;AACD;;;;;;;;;;;;;;AAeA,SAAgB,mBACf,MACe;CACf,OAAO,oBAAoB,qBAAqB,GAAG,IAAI;AACxD;;AAKA,MAAa,SAAS"}