@stll/folio-core 0.26.0 → 0.27.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.
- package/dist/ai-edits/blockRange.d.ts +17 -2
- package/dist/ai-edits/blockRange.js +1 -1
- package/dist/ai-edits/table-cell-mutations.js +38 -3
- package/dist/compat/eigenpal.d.ts +2 -1
- package/dist/docx/paragraphParser.js +3 -2
- package/dist/docx/parser.js +28 -5
- package/dist/docx/rezip.d.ts +21 -1
- package/dist/docx/rezip.js +80 -2
- package/dist/docx/runParser.js +6 -5
- package/dist/docx/selectiveSave.d.ts +0 -8
- package/dist/docx/selectiveSave.js +16 -1
- package/dist/docx/serializer/runSerializer.js +4 -4
- package/dist/docx/serializer/sectionPropertiesSerializer.js +5 -5
- package/dist/docx/server/createBilingualDocument.js +73 -7
- package/dist/docx/server/extractDocxText.js +31 -12
- package/dist/docx/styleParser.js +6 -5
- package/dist/docx/unzip.js +17 -3
- package/dist/docx/xmlParser.js +34 -8
- package/dist/index.d.ts +2 -1
- package/dist/layout-painter/renderPage.js +6 -1
- package/dist/layout-painter/renderParagraph.js +36 -9
- package/dist/paged-layout/blockGeometry.d.ts +32 -0
- package/dist/paged-layout/blockGeometry.js +115 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +4 -3
- package/dist/utils/headerFooter.js +0 -12
- package/dist/utils/tiffConverter.d.ts +11 -2
- package/dist/utils/tiffConverter.js +12 -4
- package/package.json +1 -1
|
@@ -8,11 +8,20 @@
|
|
|
8
8
|
* back to the raw TIFF data URL, which won't render in browsers but is
|
|
9
9
|
* fine for headless round-trips.
|
|
10
10
|
*/
|
|
11
|
+
/**
|
|
12
|
+
* Budget shared by every TIFF in one package. The per-image cap bounds a single
|
|
13
|
+
* decode; without a running total a package of many large TIFFs still adds up.
|
|
14
|
+
* Callers pass what is left of the budget and subtract the pixels each
|
|
15
|
+
* conversion reports.
|
|
16
|
+
*/
|
|
17
|
+
declare const MAX_PACKAGE_TIFF_PIXELS = 256000000;
|
|
11
18
|
declare function isTiffMimeType(mimeType: string): boolean;
|
|
12
19
|
type ConvertedTiff = {
|
|
13
20
|
dataUrl: string;
|
|
14
21
|
data: ArrayBuffer;
|
|
22
|
+
/** Pixels decoded, so callers can draw down a package-wide budget. */
|
|
23
|
+
pixels: number;
|
|
15
24
|
};
|
|
16
|
-
declare function convertTiffToPngDataUrl(tiffData: ArrayBuffer): Promise<ConvertedTiff | null>;
|
|
25
|
+
declare function convertTiffToPngDataUrl(tiffData: ArrayBuffer, maxPixels?: number): Promise<ConvertedTiff | null>;
|
|
17
26
|
//#endregion
|
|
18
|
-
export { ConvertedTiff, convertTiffToPngDataUrl, isTiffMimeType };
|
|
27
|
+
export { ConvertedTiff, MAX_PACKAGE_TIFF_PIXELS, convertTiffToPngDataUrl, isTiffMimeType };
|
|
@@ -16,11 +16,18 @@
|
|
|
16
16
|
* RGBA buffer, which would otherwise hang or OOM the tab.
|
|
17
17
|
*/
|
|
18
18
|
const MAX_TIFF_PIXELS = 64e6;
|
|
19
|
+
/**
|
|
20
|
+
* Budget shared by every TIFF in one package. The per-image cap bounds a single
|
|
21
|
+
* decode; without a running total a package of many large TIFFs still adds up.
|
|
22
|
+
* Callers pass what is left of the budget and subtract the pixels each
|
|
23
|
+
* conversion reports.
|
|
24
|
+
*/
|
|
25
|
+
const MAX_PACKAGE_TIFF_PIXELS = 256e6;
|
|
19
26
|
function isTiffMimeType(mimeType) {
|
|
20
27
|
const lower = mimeType.toLowerCase();
|
|
21
28
|
return lower === "image/tiff" || lower === "image/tif";
|
|
22
29
|
}
|
|
23
|
-
async function convertTiffToPngDataUrl(tiffData) {
|
|
30
|
+
async function convertTiffToPngDataUrl(tiffData, maxPixels = MAX_TIFF_PIXELS) {
|
|
24
31
|
if (typeof document === "undefined" || typeof document.createElement !== "function") return null;
|
|
25
32
|
try {
|
|
26
33
|
const UTIF = await import("utif2");
|
|
@@ -29,7 +36,7 @@ async function convertTiffToPngDataUrl(tiffData) {
|
|
|
29
36
|
const declaredWidth = readTiffTagNumber(firstImage["t256"]);
|
|
30
37
|
const declaredHeight = readTiffTagNumber(firstImage["t257"]);
|
|
31
38
|
if (!declaredWidth || !declaredHeight) return null;
|
|
32
|
-
if (declaredWidth * declaredHeight > MAX_TIFF_PIXELS) return null;
|
|
39
|
+
if (declaredWidth * declaredHeight > Math.min(maxPixels, MAX_TIFF_PIXELS)) return null;
|
|
33
40
|
UTIF.decodeImage(tiffData, firstImage);
|
|
34
41
|
const rgba = UTIF.toRGBA8(firstImage);
|
|
35
42
|
if (rgba.length === 0) return null;
|
|
@@ -50,7 +57,8 @@ async function convertTiffToPngDataUrl(tiffData) {
|
|
|
50
57
|
if (!data) return null;
|
|
51
58
|
return {
|
|
52
59
|
dataUrl,
|
|
53
|
-
data
|
|
60
|
+
data,
|
|
61
|
+
pixels: width * height
|
|
54
62
|
};
|
|
55
63
|
} catch {
|
|
56
64
|
return null;
|
|
@@ -80,4 +88,4 @@ function dataUrlToArrayBuffer(dataUrl) {
|
|
|
80
88
|
}
|
|
81
89
|
}
|
|
82
90
|
//#endregion
|
|
83
|
-
export { convertTiffToPngDataUrl, isTiffMimeType };
|
|
91
|
+
export { MAX_PACKAGE_TIFF_PIXELS, convertTiffToPngDataUrl, isTiffMimeType };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/folio-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.1",
|
|
4
4
|
"description": "Headless, framework-neutral core of folio: the OOXML (.docx) parser, document model, ProseMirror integration, and page-layout engine. No React.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"document-model",
|