@extend-ai/react-docx 0.3.0 → 0.4.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.
- package/dist/index.cjs +5 -78
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -78
- package/dist/index.js.map +1 -1
- package/package.json +4 -5
package/dist/index.js
CHANGED
|
@@ -6498,7 +6498,6 @@ function resolveDocumentLayout(model) {
|
|
|
6498
6498
|
}
|
|
6499
6499
|
|
|
6500
6500
|
// src/image-render.ts
|
|
6501
|
-
import { convertEmfToDataUrl, convertWmfToDataUrl } from "emf-converter";
|
|
6502
6501
|
import { encode as encodePng } from "fast-png";
|
|
6503
6502
|
import UTIFModule from "utif";
|
|
6504
6503
|
var TIFF_CONTENT_TYPES = /* @__PURE__ */ new Set(["image/tiff", "image/tif"]);
|
|
@@ -6513,9 +6512,6 @@ var EMF_DATA_URI_PREFIXES = ["data:image/emf", "data:image/x-emf"];
|
|
|
6513
6512
|
var WMF_DATA_URI_PREFIXES = ["data:image/wmf", "data:image/x-wmf"];
|
|
6514
6513
|
var UTIF = UTIFModule;
|
|
6515
6514
|
var convertedTiffSrcCache = /* @__PURE__ */ new Map();
|
|
6516
|
-
var convertedMetafileSrcCache = /* @__PURE__ */ new Map();
|
|
6517
|
-
var pendingMetafileConversions = /* @__PURE__ */ new Map();
|
|
6518
|
-
var renderableImageSourceListeners = /* @__PURE__ */ new Set();
|
|
6519
6515
|
function normalizeImageContentType(image) {
|
|
6520
6516
|
return image.contentType?.trim().toLowerCase();
|
|
6521
6517
|
}
|
|
@@ -6556,45 +6552,15 @@ function imageUsesWmfContent(image) {
|
|
|
6556
6552
|
const src = normalizeImageSrc(image)?.toLowerCase();
|
|
6557
6553
|
return Boolean(src && WMF_DATA_URI_PREFIXES.some((prefix) => src.startsWith(prefix)));
|
|
6558
6554
|
}
|
|
6559
|
-
function metafileCacheKey(image) {
|
|
6560
|
-
const src = normalizeImageSrc(image);
|
|
6561
|
-
if (src) {
|
|
6562
|
-
return src;
|
|
6563
|
-
}
|
|
6564
|
-
const bytes = image.data;
|
|
6565
|
-
if (!bytes?.byteLength) {
|
|
6566
|
-
return void 0;
|
|
6567
|
-
}
|
|
6568
|
-
const base64 = bytesToBase642(bytes);
|
|
6569
|
-
const contentType = normalizeImageContentType(image) ?? "application/octet-stream";
|
|
6570
|
-
return base64 ? `data:${contentType};base64,${base64}` : void 0;
|
|
6571
|
-
}
|
|
6572
|
-
function notifyRenderableImageSourceListeners() {
|
|
6573
|
-
renderableImageSourceListeners.forEach((listener) => {
|
|
6574
|
-
try {
|
|
6575
|
-
listener();
|
|
6576
|
-
} catch {
|
|
6577
|
-
}
|
|
6578
|
-
});
|
|
6579
|
-
}
|
|
6580
6555
|
function imageUsesPlaceholderFallback(image) {
|
|
6581
|
-
|
|
6582
|
-
if (!contentType || !PLACEHOLDER_FALLBACK_CONTENT_TYPES.has(contentType)) {
|
|
6583
|
-
return false;
|
|
6584
|
-
}
|
|
6585
|
-
const cacheKey = metafileCacheKey(image);
|
|
6586
|
-
if (!cacheKey) {
|
|
6587
|
-
return true;
|
|
6588
|
-
}
|
|
6589
|
-
return convertedMetafileSrcCache.get(cacheKey) == null;
|
|
6556
|
+
return imageHasMetafileContent(image);
|
|
6590
6557
|
}
|
|
6591
6558
|
function unsupportedImageFallbackLabel(image, widthPx, heightPx) {
|
|
6592
6559
|
const isSmallIcon = (widthPx ?? 0) <= 56 && (heightPx ?? 0) <= 56;
|
|
6593
|
-
|
|
6594
|
-
if (contentType === "image/x-emf" || contentType === "image/emf") {
|
|
6560
|
+
if (imageUsesEmfContent(image)) {
|
|
6595
6561
|
return isSmallIcon ? "e" : "EMF";
|
|
6596
6562
|
}
|
|
6597
|
-
if (
|
|
6563
|
+
if (imageUsesWmfContent(image)) {
|
|
6598
6564
|
return isSmallIcon ? "w" : "WMF";
|
|
6599
6565
|
}
|
|
6600
6566
|
return isSmallIcon ? "e" : "TIFF";
|
|
@@ -6640,13 +6606,6 @@ function toArrayBuffer(bytes) {
|
|
|
6640
6606
|
}
|
|
6641
6607
|
return buffer.slice(byteOffset, byteOffset + byteLength);
|
|
6642
6608
|
}
|
|
6643
|
-
function toStrictArrayBuffer(bytes) {
|
|
6644
|
-
const arrayBuffer = toArrayBuffer(bytes);
|
|
6645
|
-
if (arrayBuffer instanceof ArrayBuffer) {
|
|
6646
|
-
return arrayBuffer;
|
|
6647
|
-
}
|
|
6648
|
-
return Uint8Array.from(bytes).buffer;
|
|
6649
|
-
}
|
|
6650
6609
|
function resolveTiffBytes(image) {
|
|
6651
6610
|
if (image.data?.byteLength) {
|
|
6652
6611
|
return image.data;
|
|
@@ -6708,37 +6667,6 @@ function resolveRenderableImageSource(image) {
|
|
|
6708
6667
|
return void 0;
|
|
6709
6668
|
}
|
|
6710
6669
|
if (imageHasMetafileContent(image)) {
|
|
6711
|
-
const cacheKey = metafileCacheKey(image);
|
|
6712
|
-
if (!cacheKey) {
|
|
6713
|
-
return void 0;
|
|
6714
|
-
}
|
|
6715
|
-
if (convertedMetafileSrcCache.has(cacheKey)) {
|
|
6716
|
-
return convertedMetafileSrcCache.get(cacheKey) ?? void 0;
|
|
6717
|
-
}
|
|
6718
|
-
if (!pendingMetafileConversions.has(cacheKey)) {
|
|
6719
|
-
const bytes = resolveTiffBytes(image);
|
|
6720
|
-
if (bytes) {
|
|
6721
|
-
const conversionPromise = (async () => {
|
|
6722
|
-
try {
|
|
6723
|
-
const arrayBuffer = toStrictArrayBuffer(bytes);
|
|
6724
|
-
const converted2 = imageUsesEmfContent(image) ? await convertEmfToDataUrl(arrayBuffer, void 0, void 0, { dpiScale: 1 }) : imageUsesWmfContent(image) ? await convertWmfToDataUrl(arrayBuffer, void 0, void 0, { dpiScale: 1 }) : null;
|
|
6725
|
-
const normalized = converted2 ?? void 0;
|
|
6726
|
-
convertedMetafileSrcCache.set(cacheKey, normalized ?? null);
|
|
6727
|
-
notifyRenderableImageSourceListeners();
|
|
6728
|
-
return normalized;
|
|
6729
|
-
} catch {
|
|
6730
|
-
convertedMetafileSrcCache.set(cacheKey, null);
|
|
6731
|
-
notifyRenderableImageSourceListeners();
|
|
6732
|
-
return void 0;
|
|
6733
|
-
} finally {
|
|
6734
|
-
pendingMetafileConversions.delete(cacheKey);
|
|
6735
|
-
}
|
|
6736
|
-
})();
|
|
6737
|
-
pendingMetafileConversions.set(cacheKey, conversionPromise);
|
|
6738
|
-
} else {
|
|
6739
|
-
convertedMetafileSrcCache.set(cacheKey, null);
|
|
6740
|
-
}
|
|
6741
|
-
}
|
|
6742
6670
|
return void 0;
|
|
6743
6671
|
}
|
|
6744
6672
|
if (!imageHasTiffContent(image)) {
|
|
@@ -6761,9 +6689,8 @@ function resolveRenderableImageSource(image) {
|
|
|
6761
6689
|
return converted;
|
|
6762
6690
|
}
|
|
6763
6691
|
function subscribeRenderableImageSourceUpdates(listener) {
|
|
6764
|
-
|
|
6692
|
+
void listener;
|
|
6765
6693
|
return () => {
|
|
6766
|
-
renderableImageSourceListeners.delete(listener);
|
|
6767
6694
|
};
|
|
6768
6695
|
}
|
|
6769
6696
|
|
|
@@ -10544,7 +10471,7 @@ var DOC_SURFACE_STYLE_BY_THEME = {
|
|
|
10544
10471
|
boxShadow: "0 2px 10px rgba(2, 6, 23, 0.55), 0 1px 2px rgba(2, 6, 23, 0.45)"
|
|
10545
10472
|
}
|
|
10546
10473
|
};
|
|
10547
|
-
var NIGHT_READER_INVERSION_FILTER = "invert(
|
|
10474
|
+
var NIGHT_READER_INVERSION_FILTER = "invert(0.95) hue-rotate(180deg) saturate(0.9) brightness(0.9) contrast(0.94)";
|
|
10548
10475
|
function appendCssFilters(...filters) {
|
|
10549
10476
|
const resolvedFilters = filters.map((filter) => filter?.trim()).filter((filter) => Boolean(filter));
|
|
10550
10477
|
return resolvedFilters.length > 0 ? resolvedFilters.join(" ") : void 0;
|