ooxml-ui 1.23.0 → 1.23.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.
@@ -65151,6 +65151,168 @@ function calculateViewportFit(input, defaults = DEFAULTS) {
65151
65151
  };
65152
65152
  }
65153
65153
 
65154
+ // src/pptx/render/viewport-size.ts
65155
+ var LAYOUT_UNIT = 1 / 64;
65156
+ var PADDING_SNAP = LAYOUT_UNIT / 0.25;
65157
+ function finiteOrZero(value) {
65158
+ return Number.isFinite(value) && value > 0 ? value : 0;
65159
+ }
65160
+ function isFiniteNumber(value) {
65161
+ return value !== void 0 && Number.isFinite(value);
65162
+ }
65163
+ function serializationError(value) {
65164
+ const magnitude = Math.abs(value);
65165
+ return magnitude === 0 ? 0 : 0.5 * 10 ** (Math.floor(Math.log10(magnitude)) - 5);
65166
+ }
65167
+ function localBorderBox(cssSize, boxSizing, borders, paddingStart, paddingEnd) {
65168
+ if (!isFiniteNumber(cssSize) || cssSize < 0) {
65169
+ return void 0;
65170
+ }
65171
+ if (boxSizing === "border-box") {
65172
+ const error2 = serializationError(cssSize);
65173
+ return {
65174
+ size: cssSize,
65175
+ low: cssSize - error2,
65176
+ high: cssSize + error2,
65177
+ floor: cssSize - error2,
65178
+ exact: true
65179
+ };
65180
+ }
65181
+ if (boxSizing !== "content-box" || !isFiniteNumber(paddingStart) || !isFiniteNumber(paddingEnd)) {
65182
+ return void 0;
65183
+ }
65184
+ const start = Math.max(0, paddingStart);
65185
+ const end = Math.max(0, paddingEnd);
65186
+ const size2 = cssSize + start + end + borders;
65187
+ const error = serializationError(cssSize) + serializationError(start) + serializationError(end) + serializationError(borders);
65188
+ const snap = (start > 0 ? PADDING_SNAP : 0) + (end > 0 ? PADDING_SNAP : 0);
65189
+ return {
65190
+ size: size2,
65191
+ low: size2 - error - snap,
65192
+ high: size2 + error,
65193
+ floor: size2 - error - snap,
65194
+ exact: snap === 0
65195
+ };
65196
+ }
65197
+ function fractionalAxis(client, offset, rect3, borderStart, borderEnd, cssSize, boxSizing, paddingStart, paddingEnd, zoomed) {
65198
+ const snapped = finiteOrZero(client);
65199
+ if (snapped === 0 || !(finiteOrZero(offset) > 0)) {
65200
+ return snapped;
65201
+ }
65202
+ const bordersKnown = isFiniteNumber(borderStart) && isFiniteNumber(borderEnd);
65203
+ const borders = bordersKnown ? Math.max(0, borderStart) + Math.max(0, borderEnd) : 0;
65204
+ if (bordersKnown && offset - snapped - borders >= 1) {
65205
+ return Math.max(0, snapped - 1);
65206
+ }
65207
+ const local = bordersKnown ? localBorderBox(cssSize, boxSizing, borders, paddingStart, paddingEnd) : void 0;
65208
+ if (local) {
65209
+ const plain = !zoomed && Number.isFinite(rect3) && rect3 >= local.low && rect3 <= local.high;
65210
+ if (plain) {
65211
+ const size2 = local.exact ? Math.min(rect3, local.floor + LAYOUT_UNIT) : local.floor;
65212
+ return Math.max(0, size2 - borders);
65213
+ }
65214
+ return Math.max(0, Math.min(snapped, local.size - borders) - 1);
65215
+ }
65216
+ if (!Number.isFinite(rect3)) {
65217
+ return snapped;
65218
+ }
65219
+ const error = rect3 - offset;
65220
+ if (zoomed || Math.abs(error) >= 1) {
65221
+ return Math.max(0, snapped - 1);
65222
+ }
65223
+ if (!bordersKnown) {
65224
+ return Math.max(0, snapped + error);
65225
+ }
65226
+ return Math.max(0, rect3 - borders);
65227
+ }
65228
+ function isZoomed(cssZoom) {
65229
+ return isFiniteNumber(cssZoom) && Math.abs(cssZoom - 1) > 1e-6;
65230
+ }
65231
+ function fractionalClientSize(metrics) {
65232
+ const zoomed = isZoomed(metrics.cssZoom);
65233
+ return {
65234
+ width: fractionalAxis(
65235
+ metrics.clientWidth,
65236
+ metrics.offsetWidth,
65237
+ metrics.rectWidth,
65238
+ metrics.borderLeft,
65239
+ metrics.borderRight,
65240
+ metrics.cssWidth,
65241
+ metrics.boxSizing,
65242
+ metrics.paddingLeft,
65243
+ metrics.paddingRight,
65244
+ zoomed
65245
+ ),
65246
+ height: fractionalAxis(
65247
+ metrics.clientHeight,
65248
+ metrics.offsetHeight,
65249
+ metrics.rectHeight,
65250
+ metrics.borderTop,
65251
+ metrics.borderBottom,
65252
+ metrics.cssHeight,
65253
+ metrics.boxSizing,
65254
+ metrics.paddingTop,
65255
+ metrics.paddingBottom,
65256
+ zoomed
65257
+ )
65258
+ };
65259
+ }
65260
+ function pixels(value) {
65261
+ const parsed = value === void 0 || !value.endsWith("px") ? Number.NaN : Number.parseFloat(value);
65262
+ return Number.isFinite(parsed) ? parsed : void 0;
65263
+ }
65264
+ function measureViewportClientSize(element) {
65265
+ const rect3 = element.getBoundingClientRect();
65266
+ const view2 = element.ownerDocument?.defaultView;
65267
+ const style = view2?.getComputedStyle ? view2.getComputedStyle(element) : void 0;
65268
+ const { currentCSSZoom } = element;
65269
+ return fractionalClientSize({
65270
+ clientWidth: element.clientWidth,
65271
+ clientHeight: element.clientHeight,
65272
+ offsetWidth: element.offsetWidth,
65273
+ offsetHeight: element.offsetHeight,
65274
+ rectWidth: rect3.width,
65275
+ rectHeight: rect3.height,
65276
+ borderLeft: pixels(style?.borderLeftWidth),
65277
+ borderRight: pixels(style?.borderRightWidth),
65278
+ borderTop: pixels(style?.borderTopWidth),
65279
+ borderBottom: pixels(style?.borderBottomWidth),
65280
+ cssWidth: pixels(style?.width),
65281
+ cssHeight: pixels(style?.height),
65282
+ boxSizing: style?.boxSizing,
65283
+ paddingLeft: pixels(style?.paddingLeft),
65284
+ paddingRight: pixels(style?.paddingRight),
65285
+ paddingTop: pixels(style?.paddingTop),
65286
+ paddingBottom: pixels(style?.paddingBottom),
65287
+ cssZoom: typeof currentCSSZoom === "number" ? currentCSSZoom : void 0
65288
+ });
65289
+ }
65290
+ function observeViewportClientSize(element, onSize) {
65291
+ let last = measureViewportClientSize(element);
65292
+ onSize(last);
65293
+ if (typeof ResizeObserver === "undefined") {
65294
+ return () => void 0;
65295
+ }
65296
+ const remeasure = () => {
65297
+ const next = measureViewportClientSize(element);
65298
+ if (next.width === last.width && next.height === last.height) {
65299
+ return;
65300
+ }
65301
+ last = next;
65302
+ onSize(next);
65303
+ };
65304
+ const observers = ["content-box", "border-box"].map((box) => {
65305
+ const observer = new ResizeObserver(remeasure);
65306
+ observer.observe(element, { box });
65307
+ return observer;
65308
+ });
65309
+ return () => {
65310
+ for (const observer of observers) {
65311
+ observer.disconnect();
65312
+ }
65313
+ };
65314
+ }
65315
+
65154
65316
  // src/pptx/render/inline-list-activation.ts
65155
65317
  function readListActivationSelection(root, body) {
65156
65318
  if (readEditableText(root) !== body) {
@@ -82741,13 +82903,13 @@ function writeStr(out, str) {
82741
82903
  }
82742
82904
  }
82743
82905
  function quantizeFrame(imageData) {
82744
- const pixels = imageData.data;
82906
+ const pixels2 = imageData.data;
82745
82907
  const numPixels = imageData.width * imageData.height;
82746
82908
  const sampleStep = Math.max(1, Math.floor(numPixels / 1e4));
82747
82909
  const samples = [];
82748
82910
  for (let i = 0; i < numPixels; i += sampleStep) {
82749
82911
  const off = i * 4;
82750
- samples.push([pixels[off], pixels[off + 1], pixels[off + 2]]);
82912
+ samples.push([pixels2[off], pixels2[off + 1], pixels2[off + 2]]);
82751
82913
  }
82752
82914
  const buckets = medianCut(samples, 8);
82753
82915
  const palette = new Uint8Array(768);
@@ -82775,7 +82937,7 @@ function quantizeFrame(imageData) {
82775
82937
  const indexed = new Uint8Array(numPixels);
82776
82938
  for (let i = 0; i < numPixels; i++) {
82777
82939
  const off = i * 4;
82778
- indexed[i] = findNearest(centroids, pixels[off], pixels[off + 1], pixels[off + 2]);
82940
+ indexed[i] = findNearest(centroids, pixels2[off], pixels2[off + 1], pixels2[off + 2]);
82779
82941
  }
82780
82942
  return { palette, indexed };
82781
82943
  }
@@ -83672,18 +83834,18 @@ function filterRowNone(rowRgba) {
83672
83834
  out.set(rowRgba, 1);
83673
83835
  return out;
83674
83836
  }
83675
- function filterPixelBlock(pixels, width, height) {
83837
+ function filterPixelBlock(pixels2, width, height) {
83676
83838
  const rowBytes = width * RGBA_BYTES_PER_PIXEL;
83677
- if (pixels.length !== rowBytes * height) {
83839
+ if (pixels2.length !== rowBytes * height) {
83678
83840
  throw new Error(
83679
- `filterPixelBlock: expected ${rowBytes * height} bytes for ${width}x${height} RGBA, got ${pixels.length}`
83841
+ `filterPixelBlock: expected ${rowBytes * height} bytes for ${width}x${height} RGBA, got ${pixels2.length}`
83680
83842
  );
83681
83843
  }
83682
83844
  const out = new Uint8Array((rowBytes + 1) * height);
83683
83845
  for (let row = 0; row < height; row++) {
83684
83846
  const srcStart = row * rowBytes;
83685
83847
  out[row * (rowBytes + 1)] = 0;
83686
- out.set(pixels.subarray(srcStart, srcStart + rowBytes), row * (rowBytes + 1) + 1);
83848
+ out.set(pixels2.subarray(srcStart, srcStart + rowBytes), row * (rowBytes + 1) + 1);
83687
83849
  }
83688
83850
  return out;
83689
83851
  }
@@ -83736,9 +83898,9 @@ async function encodePngFromRowBands(width, height, rowBands) {
83736
83898
  }
83737
83899
  return assemblePng(width, height, [buildIdatChunk(zlibBytes)]);
83738
83900
  }
83739
- async function encodePngFromPixels(width, height, pixels) {
83901
+ async function encodePngFromPixels(width, height, pixels2) {
83740
83902
  async function* single() {
83741
- yield { pixels, bandHeight: height };
83903
+ yield { pixels: pixels2, bandHeight: height };
83742
83904
  }
83743
83905
  return encodePngFromRowBands(width, height, single());
83744
83906
  }
@@ -87012,6 +87174,7 @@ exports.formatSlideCounter = formatSlideCounter;
87012
87174
  exports.formatSnapshotSize = formatSnapshotSize;
87013
87175
  exports.formatTime = formatTime;
87014
87176
  exports.formatVersionTimestamp = formatVersionTimestamp;
87177
+ exports.fractionalClientSize = fractionalClientSize;
87015
87178
  exports.freeformCloseTolerance = freeformCloseTolerance;
87016
87179
  exports.galleryDeckView = galleryDeckView;
87017
87180
  exports.galleryHasItems = galleryHasItems;
@@ -87432,6 +87595,7 @@ exports.measureNormAutofitStepHeightPx = measureNormAutofitStepHeightPx;
87432
87595
  exports.measurePreviewGeometry = measurePreviewGeometry;
87433
87596
  exports.measureSvgViewportRect = measureSvgViewportRect;
87434
87597
  exports.measureTextWidth = measureTextWidth;
87598
+ exports.measureViewportClientSize = measureViewportClientSize;
87435
87599
  exports.mediaFallbackIcon = mediaFallbackIcon;
87436
87600
  exports.mediaFallbackLabelKey = mediaFallbackLabelKey;
87437
87601
  exports.mediaFallbackVisual = mediaFallbackVisual;
@@ -87515,6 +87679,7 @@ exports.numberControl = numberControl;
87515
87679
  exports.observeElementHeight = observeElementHeight;
87516
87680
  exports.observeExternalCollaborationReadiness = observeExternalCollaborationReadiness;
87517
87681
  exports.observeExternalCollaborationSession = observeExternalCollaborationSession;
87682
+ exports.observeViewportClientSize = observeViewportClientSize;
87518
87683
  exports.officeColorSwatchLabel = officeColorSwatchLabel;
87519
87684
  exports.oleActionsVisible = oleActionsVisible;
87520
87685
  exports.ooxmlDashToCssBorderStyle = ooxmlDashToCssBorderStyle;