ooxml-core 0.21.2 → 0.22.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 (85) hide show
  1. package/README.md +3 -4
  2. package/dist/automation/index.cjs +86 -22
  3. package/dist/automation/index.mjs +86 -22
  4. package/dist/chart/index.cjs +242 -0
  5. package/dist/chart/index.d.ts +5 -0
  6. package/dist/chart/index.d.ts.map +1 -1
  7. package/dist/chart/index.mjs +227 -1
  8. package/dist/chart/pie-best-fit.d.ts +51 -0
  9. package/dist/chart/pie-best-fit.d.ts.map +1 -0
  10. package/dist/chart/pie-label-collision.d.ts +48 -0
  11. package/dist/chart/pie-label-collision.d.ts.map +1 -0
  12. package/dist/chart/radar-geometry.d.ts +19 -0
  13. package/dist/chart/radar-geometry.d.ts.map +1 -0
  14. package/dist/chart/treemap-squarify.d.ts +31 -0
  15. package/dist/chart/treemap-squarify.d.ts.map +1 -0
  16. package/dist/chart/trendline-equation.d.ts +39 -0
  17. package/dist/chart/trendline-equation.d.ts.map +1 -0
  18. package/dist/collab/index.cjs +6 -1
  19. package/dist/collab/index.mjs +6 -1
  20. package/dist/color/contrast.d.ts +18 -0
  21. package/dist/color/contrast.d.ts.map +1 -0
  22. package/dist/color/index.cjs +33 -0
  23. package/dist/color/index.d.ts +2 -0
  24. package/dist/color/index.d.ts.map +1 -1
  25. package/dist/color/index.mjs +31 -1
  26. package/dist/color/unit-rgb.d.ts +21 -0
  27. package/dist/color/unit-rgb.d.ts.map +1 -0
  28. package/dist/docx/embedded.cjs +1 -1
  29. package/dist/docx/embedded.mjs +1 -1
  30. package/dist/docx/index.cjs +1 -1
  31. package/dist/docx/index.mjs +1 -1
  32. package/dist/docx/load/index.cjs +1 -1
  33. package/dist/docx/load/index.mjs +1 -1
  34. package/dist/geometry/align-distribute.d.ts +145 -0
  35. package/dist/geometry/align-distribute.d.ts.map +1 -0
  36. package/dist/geometry/index.cjs +318 -0
  37. package/dist/geometry/index.d.ts +2 -0
  38. package/dist/geometry/index.d.ts.map +1 -1
  39. package/dist/geometry/index.mjs +307 -1
  40. package/dist/geometry/snap-guides.d.ts +125 -0
  41. package/dist/geometry/snap-guides.d.ts.map +1 -0
  42. package/dist/index.cjs +665 -0
  43. package/dist/index.mjs +665 -0
  44. package/dist/pptx/automation/index.cjs +24 -1
  45. package/dist/pptx/automation/index.d.ts +3 -3
  46. package/dist/pptx/automation/index.mjs +24 -1
  47. package/dist/pptx/chunks/{index-JaNVJ6Tf.d.ts → index-D2y7ehZ5.d.ts} +3 -3
  48. package/dist/pptx/chunks/{index-JaNVJ6Tf.d.ts.map → index-D2y7ehZ5.d.ts.map} +1 -1
  49. package/dist/pptx/chunks/{index-DHdHU9Qr.d.ts → index-ucqKcqvI.d.ts} +10 -2
  50. package/dist/pptx/chunks/{index-DHdHU9Qr.d.ts.map → index-ucqKcqvI.d.ts.map} +1 -1
  51. package/dist/pptx/chunks/{text-operations-DUEhSW5Z.d.ts → text-operations-CR3pUJi-.d.ts} +14 -2
  52. package/dist/pptx/chunks/text-operations-CR3pUJi-.d.ts.map +1 -0
  53. package/dist/pptx/cli/index.cjs +23 -0
  54. package/dist/pptx/cli/index.d.ts +1 -1
  55. package/dist/pptx/cli/index.mjs +23 -0
  56. package/dist/pptx/converter/index.d.ts +1 -1
  57. package/dist/pptx/index.cjs +33 -3
  58. package/dist/pptx/index.d.ts +3 -3
  59. package/dist/pptx/index.mjs +33 -3
  60. package/dist/teams/index.cjs +7 -2
  61. package/dist/teams/index.mjs +7 -2
  62. package/dist/text/decimal-tab.d.ts +24 -0
  63. package/dist/text/decimal-tab.d.ts.map +1 -0
  64. package/dist/text/index.cjs +72 -0
  65. package/dist/text/index.d.ts +2 -0
  66. package/dist/text/index.d.ts.map +1 -1
  67. package/dist/text/index.mjs +68 -1
  68. package/dist/text/tab-leader.d.ts +36 -0
  69. package/dist/text/tab-leader.d.ts.map +1 -0
  70. package/dist/xlsx/edit/charts.d.ts.map +1 -1
  71. package/dist/xlsx/edit/clipboard-html-parse.d.ts.map +1 -1
  72. package/dist/xlsx/edit/fill-series.d.ts.map +1 -1
  73. package/dist/xlsx/index.cjs +85 -21
  74. package/dist/xlsx/index.mjs +85 -21
  75. package/dist/xlsx/load/csv.d.ts.map +1 -1
  76. package/dist/xlsx/load/index.cjs +17 -8
  77. package/dist/xlsx/load/index.mjs +17 -8
  78. package/dist/xlsx/numfmt/input-date.d.ts.map +1 -1
  79. package/dist/xlsx/ui/grid/cell-paint.d.ts.map +1 -1
  80. package/dist/xlsx/ui/index.cjs +86 -25
  81. package/dist/xlsx/ui/index.mjs +86 -25
  82. package/dist/xlsx/ui/selection.d.ts.map +1 -1
  83. package/dist/xlsx/write/drawing.d.ts.map +1 -1
  84. package/package.json +2 -2
  85. package/dist/pptx/chunks/text-operations-DUEhSW5Z.d.ts.map +0 -1
@@ -0,0 +1,39 @@
1
+ /**
2
+ * chart-trendline-equation-format.ts: Excel-style trendline equation text
3
+ * formatting.
4
+ *
5
+ * Excel's own trendline equation display (`c:trendlineLbl` with
6
+ * `c:dispEq val="1"`) rounds every coefficient to a handful of SIGNIFICANT
7
+ * digits in plain decimal notation, not a fixed number of decimal places: a
8
+ * small slope like 0.003742 stays "0.003742"-ish (four significant figures),
9
+ * where `.toFixed(2)` would flatten it to "0.00" and silently erase the fit.
10
+ * It also lays out each trendline family in its own fixed shape (exponential
11
+ * as `y = a e^(bx)`, a polynomial in DESCENDING powers), which this module
12
+ * is the single source of truth for so it cannot drift between the fit types.
13
+ *
14
+ * @module chart/trendline-equation
15
+ */
16
+ /**
17
+ * Format one coefficient to `SIGNIFICANT_DIGITS` significant figures in plain
18
+ * decimal notation (falls back to exponential only where `Number#toString`
19
+ * itself would, i.e. extreme magnitudes), with insignificant trailing zeros
20
+ * dropped. `-0` normalises to `"0"`.
21
+ */
22
+ export declare function formatTrendlineCoefficient(value: number): string;
23
+ /** `y = mx + b` (linear) or `y = mx - b` when the intercept is negative. */
24
+ export declare function formatLinearEquation(slope: number, intercept: number): string;
25
+ /** `y = a e^(bx)`: Excel's own exponential trendline layout. */
26
+ export declare function formatExponentialEquation(a: number, b: number): string;
27
+ /** `y = a ln(x) + b` (logarithmic), `-` glue when the intercept is negative. */
28
+ export declare function formatLogarithmicEquation(slope: number, intercept: number): string;
29
+ /** `y = a x^b` (power). */
30
+ export declare function formatPowerEquation(a: number, b: number): string;
31
+ /**
32
+ * `y = a_n x^n + ... + a_1 x + a_0`: a polynomial in DESCENDING powers of x
33
+ * (Excel's own layout), from `coeffsAscending` ([a0, a1, ..., an], the order
34
+ * `fitPolynomial` returns them in). The highest-order term never shows a
35
+ * redundant leading `+`; `x^1` drops its exponent; the constant term (`x^0`)
36
+ * drops the variable entirely.
37
+ */
38
+ export declare function formatPolynomialEquation(coeffsAscending: readonly number[]): string;
39
+ //# sourceMappingURL=trendline-equation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trendline-equation.d.ts","sourceRoot":"","sources":["../../chart/trendline-equation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAWhE;AAOD,4EAA4E;AAC5E,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAG7E;AAED,gEAAgE;AAChE,wBAAgB,yBAAyB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,gFAAgF;AAChF,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAGlF;AAED,2BAA2B;AAC3B,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CAanF"}
@@ -1274,7 +1274,7 @@ function createTransportProvider({ doc, awareness }, { transport, maxMessageByte
1274
1274
  // collab/websocket-transport.ts
1275
1275
  var OPEN = 1;
1276
1276
  function roomUrl(server, roomId) {
1277
- return `${server.replace(/\/+$/u, "")}/${encodeURIComponent(roomId)}`;
1277
+ return `${trimTrailingSlashes(server)}/${encodeURIComponent(roomId)}`;
1278
1278
  }
1279
1279
  function createWebSocketTransport(options) {
1280
1280
  const { baseDelayMs = 250, maxDelayMs = 1e4, maxRetries = Infinity } = options;
@@ -1345,6 +1345,11 @@ function createWebSocketTransport(options) {
1345
1345
  }
1346
1346
  };
1347
1347
  }
1348
+ function trimTrailingSlashes(value) {
1349
+ let end = value.length;
1350
+ while (end > 0 && value.charCodeAt(end - 1) === 47) end--;
1351
+ return value.slice(0, end);
1352
+ }
1348
1353
 
1349
1354
  exports.BROADCAST_THROTTLE_MS = BROADCAST_THROTTLE_MS;
1350
1355
  exports.BoundedMap = BoundedMap;
@@ -1250,7 +1250,7 @@ function createTransportProvider({ doc, awareness }, { transport, maxMessageByte
1250
1250
  // collab/websocket-transport.ts
1251
1251
  var OPEN = 1;
1252
1252
  function roomUrl(server, roomId) {
1253
- return `${server.replace(/\/+$/u, "")}/${encodeURIComponent(roomId)}`;
1253
+ return `${trimTrailingSlashes(server)}/${encodeURIComponent(roomId)}`;
1254
1254
  }
1255
1255
  function createWebSocketTransport(options) {
1256
1256
  const { baseDelayMs = 250, maxDelayMs = 1e4, maxRetries = Infinity } = options;
@@ -1321,5 +1321,10 @@ function createWebSocketTransport(options) {
1321
1321
  }
1322
1322
  };
1323
1323
  }
1324
+ function trimTrailingSlashes(value) {
1325
+ let end = value.length;
1326
+ while (end > 0 && value.charCodeAt(end - 1) === 47) end--;
1327
+ return value.slice(0, end);
1328
+ }
1324
1329
 
1325
1330
  export { BROADCAST_THROTTLE_MS, BoundedMap, COLLABORATION_ROLES, COLLAB_LEAVE_MESSAGE, CONNECTION_TIMEOUT_MS, CURSOR_PALETTE, DEFAULT_COLOR, DEFAULT_MAX_PACKAGE_BYTES, DEPARTURE_CHANNEL, Emitter, INITIAL_SYNC_GRACE_MS, IdempotencyCache, LEGACY_PPTX_DEPARTURE_CHANNEL, LEGACY_PPTX_LEAVE_MESSAGE, LOCAL_ORIGIN, MAX_LABEL_CHARS, MAX_UPDATE_BYTES, MESSAGE_AWARENESS, MESSAGE_QUERY_AWARENESS, MESSAGE_SYNC, PRESENCE_FIELD, PRESENCE_HEARTBEAT_MS, STALE_PRESENCE_MS, SequenceTracker, adaptYjsProvider, applyUpdateSafe, asSelectionIds, assignUserColor, bindDocument, borrowAwareness, buildRoster, canBroadcast, canWrite, clampCoordinate, classifyVersion, clearLocalAwareness, createAssetSync, createBroadcastTransport, createClientId, createCollabSession, createDepartureChannel, createIdGenerator, createMemoryHub, createPresencePublisher, createSyncGate, createTransportProvider, createWebSocketTransport, deriveCanvasPresence, derivePresence, encodeDiff, encodeSnapshot, encodeStateVector2 as encodeStateVector, formatCursorLabel, freezeDeep, fromBase64, getUserInitials, isMixedContentBlocked, isNonNegativeSafeInteger, isPresenceFresh, isValidId, isValidRoomId, mergeUpdates2 as mergeUpdates, observeExternalSession, packageAdapter, presenceToCursors, registerTeardown, removeAwarenessStatesLocally, restoreSnapshot, roomUrl, sanitizeAvatarUrl, sanitizeCanvasPayload, sanitizeColor, sanitizeIdentity, sanitizeIndex, sanitizeRole, sanitizeUserName, shouldAutoFollowBroadcaster, shouldRoomReplaceLoad, stripHtmlTags, toBase64, transportProvider, validateDisplayName, validateRoomId, validateUpdate };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Readable-text-colour selection for fills whose text colour was left implicit.
3
+ *
4
+ * PowerPoint stores no colour for a great many runs and resolves one at paint
5
+ * time from what is behind them. Renderers that instead pick a fixed colour get
6
+ * white text on white panels, so both the 2D and 3D SmartArt paths need the same
7
+ * decision, made the same way.
8
+ *
9
+ * @module color/contrast
10
+ */
11
+ /** Parse `#rgb`/`#rrggbb` into `[r, g, b]` (0..255); falls back to mid-grey. */
12
+ export declare function parseHex(hex: string): [number, number, number];
13
+ /**
14
+ * Pick a readable text colour (near-black or near-white) for a given fill,
15
+ * using the WCAG relative-luminance threshold.
16
+ */
17
+ export declare function contrastTextColor(fill: string): string;
18
+ //# sourceMappingURL=contrast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contrast.d.ts","sourceRoot":"","sources":["../../color/contrast.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,gFAAgF;AAChF,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAY9D;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAItD"}
@@ -160,16 +160,49 @@ function linearToSrgb255(linear) {
160
160
  return 255 * (c <= 31308e-7 ? c * 12.92 : 1.055 * c ** (1 / 2.4) - 0.055);
161
161
  }
162
162
 
163
+ // color/contrast.ts
164
+ function parseHex(hex) {
165
+ let h = hex.trim().replace(/^#/u, "");
166
+ if (h.length === 3) {
167
+ h = h.split("").map((c) => c + c).join("");
168
+ }
169
+ if (h.length !== 6 || /[^0-9a-fA-F]/u.test(h)) {
170
+ return [128, 128, 128];
171
+ }
172
+ return [parseInt(h.slice(0, 2), 16), parseInt(h.slice(2, 4), 16), parseInt(h.slice(4, 6), 16)];
173
+ }
174
+ function contrastTextColor(fill) {
175
+ const [r, g, b] = parseHex(fill);
176
+ const lum = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
177
+ return lum > 0.6 ? "#1a1a1a" : "#ffffff";
178
+ }
179
+
180
+ // color/unit-rgb.ts
181
+ function hexToRgbUnit(hex) {
182
+ const clean = hex.replace(/^#/u, "");
183
+ const r = Number.parseInt(clean.substring(0, 2), 16) / 255;
184
+ const g = Number.parseInt(clean.substring(2, 4), 16) / 255;
185
+ const b = Number.parseInt(clean.substring(4, 6), 16) / 255;
186
+ return {
187
+ r: Number.isFinite(r) ? r : 0,
188
+ g: Number.isFinite(g) ? g : 0,
189
+ b: Number.isFinite(b) ? b : 0
190
+ };
191
+ }
192
+
163
193
  exports.blendColorOntoWhite = blendColorOntoWhite;
164
194
  exports.clampUnitInterval = clampUnitInterval;
165
195
  exports.colorWithOpacity = colorWithOpacity;
196
+ exports.contrastTextColor = contrastTextColor;
166
197
  exports.hexToRgbChannels = hexToRgbChannels;
198
+ exports.hexToRgbUnit = hexToRgbUnit;
167
199
  exports.hslToRgb = hslToRgb;
168
200
  exports.linearToSrgb255 = linearToSrgb255;
169
201
  exports.normalizeHexColor = normalizeHexColor;
170
202
  exports.parseDrawingFraction = parseDrawingFraction;
171
203
  exports.parseDrawingHueDegrees = parseDrawingHueDegrees;
172
204
  exports.parseDrawingPercent = parseDrawingPercent;
205
+ exports.parseHex = parseHex;
173
206
  exports.parseOoxmlPercent = parseOoxmlPercent;
174
207
  exports.rgbToHsl = rgbToHsl;
175
208
  exports.scrgbLinearToSrgb8 = scrgbLinearToSrgb8;
@@ -1,3 +1,5 @@
1
1
  export * from './color-primitives.js';
2
2
  export * from './color-linear.js';
3
+ export * from './contrast.js';
4
+ export * from './unit-rgb.js';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../color/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../color/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC"}
@@ -158,4 +158,34 @@ function linearToSrgb255(linear) {
158
158
  return 255 * (c <= 31308e-7 ? c * 12.92 : 1.055 * c ** (1 / 2.4) - 0.055);
159
159
  }
160
160
 
161
- export { blendColorOntoWhite, clampUnitInterval, colorWithOpacity, hexToRgbChannels, hslToRgb, linearToSrgb255, normalizeHexColor, parseDrawingFraction, parseDrawingHueDegrees, parseDrawingPercent, parseOoxmlPercent, rgbToHsl, scrgbLinearToSrgb8, srgb255ToLinear, toHex };
161
+ // color/contrast.ts
162
+ function parseHex(hex) {
163
+ let h = hex.trim().replace(/^#/u, "");
164
+ if (h.length === 3) {
165
+ h = h.split("").map((c) => c + c).join("");
166
+ }
167
+ if (h.length !== 6 || /[^0-9a-fA-F]/u.test(h)) {
168
+ return [128, 128, 128];
169
+ }
170
+ return [parseInt(h.slice(0, 2), 16), parseInt(h.slice(2, 4), 16), parseInt(h.slice(4, 6), 16)];
171
+ }
172
+ function contrastTextColor(fill) {
173
+ const [r, g, b] = parseHex(fill);
174
+ const lum = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
175
+ return lum > 0.6 ? "#1a1a1a" : "#ffffff";
176
+ }
177
+
178
+ // color/unit-rgb.ts
179
+ function hexToRgbUnit(hex) {
180
+ const clean = hex.replace(/^#/u, "");
181
+ const r = Number.parseInt(clean.substring(0, 2), 16) / 255;
182
+ const g = Number.parseInt(clean.substring(2, 4), 16) / 255;
183
+ const b = Number.parseInt(clean.substring(4, 6), 16) / 255;
184
+ return {
185
+ r: Number.isFinite(r) ? r : 0,
186
+ g: Number.isFinite(g) ? g : 0,
187
+ b: Number.isFinite(b) ? b : 0
188
+ };
189
+ }
190
+
191
+ export { blendColorOntoWhite, clampUnitInterval, colorWithOpacity, contrastTextColor, hexToRgbChannels, hexToRgbUnit, hslToRgb, linearToSrgb255, normalizeHexColor, parseDrawingFraction, parseDrawingHueDegrees, parseDrawingPercent, parseHex, parseOoxmlPercent, rgbToHsl, scrgbLinearToSrgb8, srgb255ToLinear, toHex };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Colour-unit conversion helpers shared across the SVG `<filter>` builders in
3
+ * `render/`.
4
+ *
5
+ * `hexToRgbUnit` used to exist as three private, byte-identical copies:
6
+ * `visual-effects.ts` (DAG duotone filter), `image-effects.ts` (image duotone
7
+ * filter), and Angular's `duotone-filter.ts`. This is the one canonical copy;
8
+ * the other two shared modules now import it instead of redefining it.
9
+ */
10
+ /**
11
+ * Parse a hex colour (`#RRGGBB`/`RRGGBB`, `#` optional) to normalised 0-1 RGB
12
+ * components. Any channel that fails to parse (missing/invalid hex digits,
13
+ * including a short 3-digit `#RGB` shorthand, which this does NOT expand)
14
+ * produces `0`, matching every prior copy's behaviour exactly.
15
+ */
16
+ export declare function hexToRgbUnit(hex: string): {
17
+ r: number;
18
+ g: number;
19
+ b: number;
20
+ };
21
+ //# sourceMappingURL=unit-rgb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unit-rgb.d.ts","sourceRoot":"","sources":["../../color/unit-rgb.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAU7E"}
@@ -1149,7 +1149,7 @@ async function applyCoreProperties(zip, next, prior) {
1149
1149
  await ensureContentTypeOverride(zip, CORE_PATH, CORE_TYPE);
1150
1150
  const rels = zip.file("_rels/.rels");
1151
1151
  const relsXml = await rels?.async("string") ?? '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>';
1152
- if (!relsXml.includes(CORE_REL)) {
1152
+ if (!relsXml.includes(`Type="${CORE_REL}"`)) {
1153
1153
  const ids = [...relsXml.matchAll(/Id="rId(\d+)"/g)].map((match) => Number(match[1]));
1154
1154
  const id = `rId${Math.max(0, ...ids) + 1}`;
1155
1155
  zip.file(
@@ -1143,7 +1143,7 @@ async function applyCoreProperties(zip, next, prior) {
1143
1143
  await ensureContentTypeOverride(zip, CORE_PATH, CORE_TYPE);
1144
1144
  const rels = zip.file("_rels/.rels");
1145
1145
  const relsXml = await rels?.async("string") ?? '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>';
1146
- if (!relsXml.includes(CORE_REL)) {
1146
+ if (!relsXml.includes(`Type="${CORE_REL}"`)) {
1147
1147
  const ids = [...relsXml.matchAll(/Id="rId(\d+)"/g)].map((match) => Number(match[1]));
1148
1148
  const id = `rId${Math.max(0, ...ids) + 1}`;
1149
1149
  zip.file(
@@ -1787,7 +1787,7 @@ async function applyCoreProperties(zip, next, prior) {
1787
1787
  await ensureContentTypeOverride(zip, CORE_PATH, CORE_TYPE);
1788
1788
  const rels = zip.file("_rels/.rels");
1789
1789
  const relsXml = await rels?.async("string") ?? '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>';
1790
- if (!relsXml.includes(CORE_REL)) {
1790
+ if (!relsXml.includes(`Type="${CORE_REL}"`)) {
1791
1791
  const ids = [...relsXml.matchAll(/Id="rId(\d+)"/g)].map((match) => Number(match[1]));
1792
1792
  const id = `rId${Math.max(0, ...ids) + 1}`;
1793
1793
  zip.file(
@@ -1781,7 +1781,7 @@ async function applyCoreProperties(zip, next, prior) {
1781
1781
  await ensureContentTypeOverride(zip, CORE_PATH, CORE_TYPE);
1782
1782
  const rels = zip.file("_rels/.rels");
1783
1783
  const relsXml = await rels?.async("string") ?? '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>';
1784
- if (!relsXml.includes(CORE_REL)) {
1784
+ if (!relsXml.includes(`Type="${CORE_REL}"`)) {
1785
1785
  const ids = [...relsXml.matchAll(/Id="rId(\d+)"/g)].map((match) => Number(match[1]));
1786
1786
  const id = `rId${Math.max(0, ...ids) + 1}`;
1787
1787
  zip.file(
@@ -2110,7 +2110,7 @@ async function applyCoreProperties(zip, next, prior) {
2110
2110
  await ensureContentTypeOverride(zip, CORE_PATH, CORE_TYPE);
2111
2111
  const rels = zip.file("_rels/.rels");
2112
2112
  const relsXml = await rels?.async("string") ?? '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>';
2113
- if (!relsXml.includes(CORE_REL)) {
2113
+ if (!relsXml.includes(`Type="${CORE_REL}"`)) {
2114
2114
  const ids = [...relsXml.matchAll(/Id="rId(\d+)"/g)].map((match) => Number(match[1]));
2115
2115
  const id = `rId${Math.max(0, ...ids) + 1}`;
2116
2116
  zip.file(
@@ -2104,7 +2104,7 @@ async function applyCoreProperties(zip, next, prior) {
2104
2104
  await ensureContentTypeOverride(zip, CORE_PATH, CORE_TYPE);
2105
2105
  const rels = zip.file("_rels/.rels");
2106
2106
  const relsXml = await rels?.async("string") ?? '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"></Relationships>';
2107
- if (!relsXml.includes(CORE_REL)) {
2107
+ if (!relsXml.includes(`Type="${CORE_REL}"`)) {
2108
2108
  const ids = [...relsXml.matchAll(/Id="rId(\d+)"/g)].map((match) => Number(match[1]));
2109
2109
  const id = `rId${Math.max(0, ...ids) + 1}`;
2110
2110
  zip.file(
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Pure geometry helpers for the align / distribute editor operations.
3
+ *
4
+ * These functions operate over a list of slide elements (anything carrying the
5
+ * `{ id, x, y, width, height }` bounding-box fields of {@link PptxElement}) and
6
+ * return a `Map` keyed by element `id` describing the *new* position(s) for the
7
+ * elements that need to move. Elements that already sit on the target edge (or
8
+ * the two outer-most elements during distribution) are still included with
9
+ * their unchanged coordinate so callers can apply the whole map uniformly; the
10
+ * map only ever contains the axis that the operation touches.
11
+ *
12
+ * The reference box the selection is aligned against is either the union of
13
+ * the selected boxes (PowerPoint's "Align Selected Objects") or the slide
14
+ * itself ("Align to Slide"). PowerPoint defaults to the slide whenever a
15
+ * single object is selected, which is why a one-element selection is not a
16
+ * no-op once a `slideSize` is supplied: Align Center on a lone title is one
17
+ * of the commonest arrange gestures there is.
18
+ *
19
+ * The helpers are deliberately framework-agnostic: no DOM, no Vue reactivity,
20
+ * no side effects. The host wires them into the editor by feeding the current
21
+ * selection in and applying the returned `Map` via its element-transform
22
+ * operation (one batched history entry per call).
23
+ */
24
+ /** Edge / centre that {@link alignElements} can snap a selection to. */
25
+ export type AlignEdge = 'left' | 'centerH' | 'right' | 'top' | 'middle' | 'bottom';
26
+ /** Axis along which {@link distributeElements} evenly spaces a selection. */
27
+ export type DistributeAxis = 'horizontal' | 'vertical';
28
+ /**
29
+ * What a selection is aligned / distributed against.
30
+ *
31
+ * - `'selection'`: the union bounding box of the selected elements
32
+ * (PowerPoint's "Align Selected Objects"). Needs at least two elements.
33
+ * - `'slide'`: the slide bounds (`0, 0, slideSize.width, slideSize.height`),
34
+ * PowerPoint's "Align to Slide". Works for any non-empty selection.
35
+ */
36
+ export type AlignReference = 'selection' | 'slide';
37
+ /** Slide dimensions in the same (pixel) units as the element boxes. */
38
+ export interface AlignSlideSize {
39
+ width: number;
40
+ height: number;
41
+ }
42
+ /** Optional reference selection for {@link alignElements} and friends. */
43
+ export interface AlignOptions {
44
+ /**
45
+ * Explicit reference. When omitted, `'slide'` is assumed for a single
46
+ * element (PowerPoint's default) and `'selection'` otherwise. Either way
47
+ * the slide is only used when `slideSize` is supplied.
48
+ */
49
+ reference?: AlignReference;
50
+ /** Slide bounds; required for the slide to act as the reference. */
51
+ slideSize?: AlignSlideSize;
52
+ }
53
+ /** New position for a single element. Only the affected axis is populated. */
54
+ export interface ElementPosition {
55
+ x?: number;
56
+ y?: number;
57
+ }
58
+ /**
59
+ * The minimal bounding-box shape the helpers need. {@link PptxElement} already
60
+ * satisfies this, but accepting the structural subset keeps the helpers usable
61
+ * (and testable) with plain geometry objects too.
62
+ */
63
+ export interface BoundingBoxElement {
64
+ id: string;
65
+ x: number;
66
+ y: number;
67
+ width: number;
68
+ height: number;
69
+ }
70
+ /** An axis-aligned reference rectangle. */
71
+ export interface AlignReferenceBox {
72
+ minX: number;
73
+ minY: number;
74
+ maxX: number;
75
+ maxY: number;
76
+ }
77
+ /**
78
+ * Decide whether the slide (rather than the selection) is the reference for a
79
+ * given selection + options. The slide is chosen when asked for explicitly or
80
+ * when only one element is selected, but only when its size is known.
81
+ */
82
+ export declare function usesSlideReference(elementCount: number, options: AlignOptions | undefined): options is AlignOptions & {
83
+ slideSize: AlignSlideSize;
84
+ };
85
+ /**
86
+ * The rectangle a selection is aligned against, or `null` when there is
87
+ * nothing to align to (an empty selection, or a lone element with no slide
88
+ * size to fall back on).
89
+ */
90
+ export declare function resolveAlignReferenceBox(elements: readonly BoundingBoxElement[], options?: AlignOptions): AlignReferenceBox | null;
91
+ /**
92
+ * Align every element in the selection to a shared edge (or centre line) of
93
+ * the reference box (see {@link resolveAlignReferenceBox}).
94
+ *
95
+ * - `left` / `right` / `centerH` move elements horizontally (set `x`).
96
+ * - `top` / `bottom` / `middle` move elements vertically (set `y`).
97
+ *
98
+ * Without a `slideSize` the behaviour is unchanged from before the option
99
+ * existed: the reference is the selection's union box and fewer than two
100
+ * elements yields an empty map.
101
+ *
102
+ * @param elements - The selected elements.
103
+ * @param edge - The edge / centre line to align to.
104
+ * @param options - Reference selection; see {@link AlignOptions}.
105
+ * @returns A `Map<id, {x?, y?}>` of new positions (only the touched axis set).
106
+ */
107
+ export declare function alignElements(elements: readonly BoundingBoxElement[], edge: AlignEdge, options?: AlignOptions): Map<string, ElementPosition>;
108
+ /**
109
+ * Distribute a selection so the gaps between adjacent elements are equal.
110
+ *
111
+ * Elements are ordered by their leading edge on the chosen axis. Against the
112
+ * selection, the two outer-most elements are pinned and the free space (span
113
+ * minus the sum of element sizes) is divided evenly into the gaps between
114
+ * consecutive elements; this needs at least three elements (two outer + one
115
+ * interior to move). Against the slide (`'slide'` reference, or a single
116
+ * element with a `slideSize`), the span is the whole slide and the free space
117
+ * is divided into `n + 1` equal gaps so the margins to both slide edges match
118
+ * the gaps between elements, as PowerPoint's "Align to Slide" distribution
119
+ * does; any non-empty selection qualifies.
120
+ *
121
+ * @param elements - The selected elements.
122
+ * @param axis - `'horizontal'` distributes along `x`; `'vertical'` along `y`.
123
+ * @param options - Reference selection; see {@link AlignOptions}.
124
+ * @returns A `Map<id, {x?, y?}>` of new positions (only the touched axis set).
125
+ */
126
+ export declare function distributeElements(elements: readonly BoundingBoxElement[], axis: DistributeAxis, options?: AlignOptions): Map<string, ElementPosition>;
127
+ /** Alias of {@link AlignEdge}. */
128
+ export type AlignMode = AlignEdge;
129
+ /** Alias of {@link DistributeAxis}. */
130
+ export type DistributeMode = DistributeAxis;
131
+ /** Alias of {@link BoundingBoxElement}. */
132
+ export type AlignBox = BoundingBoxElement;
133
+ /** Alias of {@link ElementPosition}. */
134
+ export type PositionUpdate = ElementPosition;
135
+ /**
136
+ * {@link alignElements} (slide reference included) filtered to the boxes that
137
+ * actually move.
138
+ */
139
+ export declare function computeAlign(boxes: readonly AlignBox[], mode: AlignMode, options?: AlignOptions): Map<string, PositionUpdate>;
140
+ /**
141
+ * {@link distributeElements} (slide reference included) filtered to the boxes
142
+ * that actually move.
143
+ */
144
+ export declare function computeDistribute(boxes: readonly AlignBox[], mode: DistributeMode, options?: AlignOptions): Map<string, PositionUpdate>;
145
+ //# sourceMappingURL=align-distribute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"align-distribute.d.ts","sourceRoot":"","sources":["../../geometry/align-distribute.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,wEAAwE;AACxE,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEnF,6EAA6E;AAC7E,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,UAAU,CA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