@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.cjs
CHANGED
|
@@ -6611,7 +6611,6 @@ function resolveDocumentLayout(model) {
|
|
|
6611
6611
|
}
|
|
6612
6612
|
|
|
6613
6613
|
// src/image-render.ts
|
|
6614
|
-
var import_emf_converter = require("emf-converter");
|
|
6615
6614
|
var import_fast_png = require("fast-png");
|
|
6616
6615
|
var import_utif = __toESM(require("utif"), 1);
|
|
6617
6616
|
var TIFF_CONTENT_TYPES = /* @__PURE__ */ new Set(["image/tiff", "image/tif"]);
|
|
@@ -6626,9 +6625,6 @@ var EMF_DATA_URI_PREFIXES = ["data:image/emf", "data:image/x-emf"];
|
|
|
6626
6625
|
var WMF_DATA_URI_PREFIXES = ["data:image/wmf", "data:image/x-wmf"];
|
|
6627
6626
|
var UTIF = import_utif.default;
|
|
6628
6627
|
var convertedTiffSrcCache = /* @__PURE__ */ new Map();
|
|
6629
|
-
var convertedMetafileSrcCache = /* @__PURE__ */ new Map();
|
|
6630
|
-
var pendingMetafileConversions = /* @__PURE__ */ new Map();
|
|
6631
|
-
var renderableImageSourceListeners = /* @__PURE__ */ new Set();
|
|
6632
6628
|
function normalizeImageContentType(image) {
|
|
6633
6629
|
return image.contentType?.trim().toLowerCase();
|
|
6634
6630
|
}
|
|
@@ -6669,45 +6665,15 @@ function imageUsesWmfContent(image) {
|
|
|
6669
6665
|
const src = normalizeImageSrc(image)?.toLowerCase();
|
|
6670
6666
|
return Boolean(src && WMF_DATA_URI_PREFIXES.some((prefix) => src.startsWith(prefix)));
|
|
6671
6667
|
}
|
|
6672
|
-
function metafileCacheKey(image) {
|
|
6673
|
-
const src = normalizeImageSrc(image);
|
|
6674
|
-
if (src) {
|
|
6675
|
-
return src;
|
|
6676
|
-
}
|
|
6677
|
-
const bytes = image.data;
|
|
6678
|
-
if (!bytes?.byteLength) {
|
|
6679
|
-
return void 0;
|
|
6680
|
-
}
|
|
6681
|
-
const base64 = bytesToBase642(bytes);
|
|
6682
|
-
const contentType = normalizeImageContentType(image) ?? "application/octet-stream";
|
|
6683
|
-
return base64 ? `data:${contentType};base64,${base64}` : void 0;
|
|
6684
|
-
}
|
|
6685
|
-
function notifyRenderableImageSourceListeners() {
|
|
6686
|
-
renderableImageSourceListeners.forEach((listener) => {
|
|
6687
|
-
try {
|
|
6688
|
-
listener();
|
|
6689
|
-
} catch {
|
|
6690
|
-
}
|
|
6691
|
-
});
|
|
6692
|
-
}
|
|
6693
6668
|
function imageUsesPlaceholderFallback(image) {
|
|
6694
|
-
|
|
6695
|
-
if (!contentType || !PLACEHOLDER_FALLBACK_CONTENT_TYPES.has(contentType)) {
|
|
6696
|
-
return false;
|
|
6697
|
-
}
|
|
6698
|
-
const cacheKey = metafileCacheKey(image);
|
|
6699
|
-
if (!cacheKey) {
|
|
6700
|
-
return true;
|
|
6701
|
-
}
|
|
6702
|
-
return convertedMetafileSrcCache.get(cacheKey) == null;
|
|
6669
|
+
return imageHasMetafileContent(image);
|
|
6703
6670
|
}
|
|
6704
6671
|
function unsupportedImageFallbackLabel(image, widthPx, heightPx) {
|
|
6705
6672
|
const isSmallIcon = (widthPx ?? 0) <= 56 && (heightPx ?? 0) <= 56;
|
|
6706
|
-
|
|
6707
|
-
if (contentType === "image/x-emf" || contentType === "image/emf") {
|
|
6673
|
+
if (imageUsesEmfContent(image)) {
|
|
6708
6674
|
return isSmallIcon ? "e" : "EMF";
|
|
6709
6675
|
}
|
|
6710
|
-
if (
|
|
6676
|
+
if (imageUsesWmfContent(image)) {
|
|
6711
6677
|
return isSmallIcon ? "w" : "WMF";
|
|
6712
6678
|
}
|
|
6713
6679
|
return isSmallIcon ? "e" : "TIFF";
|
|
@@ -6753,13 +6719,6 @@ function toArrayBuffer(bytes) {
|
|
|
6753
6719
|
}
|
|
6754
6720
|
return buffer.slice(byteOffset, byteOffset + byteLength);
|
|
6755
6721
|
}
|
|
6756
|
-
function toStrictArrayBuffer(bytes) {
|
|
6757
|
-
const arrayBuffer = toArrayBuffer(bytes);
|
|
6758
|
-
if (arrayBuffer instanceof ArrayBuffer) {
|
|
6759
|
-
return arrayBuffer;
|
|
6760
|
-
}
|
|
6761
|
-
return Uint8Array.from(bytes).buffer;
|
|
6762
|
-
}
|
|
6763
6722
|
function resolveTiffBytes(image) {
|
|
6764
6723
|
if (image.data?.byteLength) {
|
|
6765
6724
|
return image.data;
|
|
@@ -6821,37 +6780,6 @@ function resolveRenderableImageSource(image) {
|
|
|
6821
6780
|
return void 0;
|
|
6822
6781
|
}
|
|
6823
6782
|
if (imageHasMetafileContent(image)) {
|
|
6824
|
-
const cacheKey = metafileCacheKey(image);
|
|
6825
|
-
if (!cacheKey) {
|
|
6826
|
-
return void 0;
|
|
6827
|
-
}
|
|
6828
|
-
if (convertedMetafileSrcCache.has(cacheKey)) {
|
|
6829
|
-
return convertedMetafileSrcCache.get(cacheKey) ?? void 0;
|
|
6830
|
-
}
|
|
6831
|
-
if (!pendingMetafileConversions.has(cacheKey)) {
|
|
6832
|
-
const bytes = resolveTiffBytes(image);
|
|
6833
|
-
if (bytes) {
|
|
6834
|
-
const conversionPromise = (async () => {
|
|
6835
|
-
try {
|
|
6836
|
-
const arrayBuffer = toStrictArrayBuffer(bytes);
|
|
6837
|
-
const converted2 = imageUsesEmfContent(image) ? await (0, import_emf_converter.convertEmfToDataUrl)(arrayBuffer, void 0, void 0, { dpiScale: 1 }) : imageUsesWmfContent(image) ? await (0, import_emf_converter.convertWmfToDataUrl)(arrayBuffer, void 0, void 0, { dpiScale: 1 }) : null;
|
|
6838
|
-
const normalized = converted2 ?? void 0;
|
|
6839
|
-
convertedMetafileSrcCache.set(cacheKey, normalized ?? null);
|
|
6840
|
-
notifyRenderableImageSourceListeners();
|
|
6841
|
-
return normalized;
|
|
6842
|
-
} catch {
|
|
6843
|
-
convertedMetafileSrcCache.set(cacheKey, null);
|
|
6844
|
-
notifyRenderableImageSourceListeners();
|
|
6845
|
-
return void 0;
|
|
6846
|
-
} finally {
|
|
6847
|
-
pendingMetafileConversions.delete(cacheKey);
|
|
6848
|
-
}
|
|
6849
|
-
})();
|
|
6850
|
-
pendingMetafileConversions.set(cacheKey, conversionPromise);
|
|
6851
|
-
} else {
|
|
6852
|
-
convertedMetafileSrcCache.set(cacheKey, null);
|
|
6853
|
-
}
|
|
6854
|
-
}
|
|
6855
6783
|
return void 0;
|
|
6856
6784
|
}
|
|
6857
6785
|
if (!imageHasTiffContent(image)) {
|
|
@@ -6874,9 +6802,8 @@ function resolveRenderableImageSource(image) {
|
|
|
6874
6802
|
return converted;
|
|
6875
6803
|
}
|
|
6876
6804
|
function subscribeRenderableImageSourceUpdates(listener) {
|
|
6877
|
-
|
|
6805
|
+
void listener;
|
|
6878
6806
|
return () => {
|
|
6879
|
-
renderableImageSourceListeners.delete(listener);
|
|
6880
6807
|
};
|
|
6881
6808
|
}
|
|
6882
6809
|
|
|
@@ -10654,7 +10581,7 @@ var DOC_SURFACE_STYLE_BY_THEME = {
|
|
|
10654
10581
|
boxShadow: "0 2px 10px rgba(2, 6, 23, 0.55), 0 1px 2px rgba(2, 6, 23, 0.45)"
|
|
10655
10582
|
}
|
|
10656
10583
|
};
|
|
10657
|
-
var NIGHT_READER_INVERSION_FILTER = "invert(
|
|
10584
|
+
var NIGHT_READER_INVERSION_FILTER = "invert(0.95) hue-rotate(180deg) saturate(0.9) brightness(0.9) contrast(0.94)";
|
|
10658
10585
|
function appendCssFilters(...filters) {
|
|
10659
10586
|
const resolvedFilters = filters.map((filter) => filter?.trim()).filter((filter) => Boolean(filter));
|
|
10660
10587
|
return resolvedFilters.length > 0 ? resolvedFilters.join(" ") : void 0;
|