@stll/docx-core 0.44.0 → 0.45.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.
@@ -1,4 +1,4 @@
1
- import { _ as ZipError, a as UINT16_SENTINEL, d as encodeEndOfCentralDirectory, f as encodeEntryName, g as toDosDateTime, h as isSafeZipPath, l as encodeCentralHeader, m as fromDosDateTime, p as encodeLocalHeader, r as FIXED_DOS_DATE_TIME, v as copyBytes, y as platformZipCodec } from "./format-DXPXB02u.js";
1
+ import { _ as ZipError, a as UINT16_SENTINEL, d as encodeEndOfCentralDirectory, f as encodeEntryName, g as toDosDateTime, h as isSafeZipPath, l as encodeCentralHeader, m as fromDosDateTime, p as encodeLocalHeader, r as FIXED_DOS_DATE_TIME, v as copyBytes, y as platformZipCodec } from "./format-DKTCMfac.js";
2
2
  import { Result } from "better-result";
3
3
  import { decodeText, encodeUtf8 } from "@stll/utf8-boundaries";
4
4
  // src/zip/read.ts
@@ -1748,20 +1748,29 @@ type MarkupRangeMarker = WritableRecord & {
1748
1748
  };
1749
1749
  /**
1750
1750
  * The cut a kept range marker stands in: the date of the revision it was kept
1751
- * from, and, where only one side of it is a piece of that cut (`piece`), that
1752
- * side: its record, or the pending change beside the marker once resolved,
1753
- * takes the marker with no alike record across from it.
1751
+ * from, and the pending changes beside the marker that took its seam and hold
1752
+ * a piece of that cut (`holders`): resolved, such a change takes the marker
1753
+ * with no alike record across from it.
1754
1754
  */
1755
1755
  type KeptCut = WritableRecord & {
1756
1756
  keptFrom: string;
1757
- piece?: KeptCutPiece;
1757
+ holders?: KeptCutHolders;
1758
1758
  };
1759
1759
  /**
1760
- * The side of a kept marker whose record, or the pending change that took
1761
- * its seam, is a piece of its cut; `both` where pending changes either side
1762
- * took it.
1760
+ * The revision ids of the pending changes either side of a kept marker that
1761
+ * hold a piece of its cut: the one before it, the one after it, or both. A
1762
+ * holder no longer standing beside the marker holds nothing. A seam-scoped
1763
+ * marker waits on the whole cut, even where it has a holder on one side.
1763
1764
  */
1764
- type KeptCutPiece = "before" | "after" | "both";
1765
+ type KeptCutHolders = WritableRecord & {
1766
+ scope?: "seam";
1767
+ } & ({
1768
+ before: number;
1769
+ after?: number;
1770
+ } | {
1771
+ before?: number;
1772
+ after: number;
1773
+ });
1765
1774
  /** Added-revision ancestors that own a copied bookmark or move boundary. */
1766
1775
  type CopyOriginAncestorOrdinals = readonly [number, ...number[]];
1767
1776
  type CopyOriginMarker = WritableRecord & {
@@ -3396,6 +3405,20 @@ type ParagraphMarkChange = WritableRecord & {
3396
3405
  * reader that does not know it joins as any rejected mark does.
3397
3406
  */
3398
3407
  survivor?: "first" | undefined;
3408
+ /**
3409
+ * With `survivor: "first"`: the revision id of the tracked mark the
3410
+ * paragraph after took over (at the end of a chain of such marks), which
3411
+ * that paragraph holds. When the paragraph holding it goes (rejected, joined
3412
+ * on or deleted), the mark keeps the paragraph after on rejection, the one
3413
+ * that was there before both; when the mark is accepted, the paragraph
3414
+ * stays and the id goes. Absent when the taken-over mark was no tracked
3415
+ * change. Saved as folio's own ignorable review provenance.
3416
+ *
3417
+ * Compatibility: a file saved before folio recorded it carries
3418
+ * `survivor: "first"` alone, read as that same positional flag. Remove that
3419
+ * reading when no supported document can still carry the flag alone.
3420
+ */
3421
+ takenOverMark?: number | undefined;
3399
3422
  /**
3400
3423
  * A later pending deletion of this added mark, `w:del` written beside its
3401
3424
  * `w:ins` or `w:moveTo`: another author deleted the break an insertion
@@ -4571,4 +4594,4 @@ declare const COMMENT_PART_RELATIONSHIPS: {
4571
4594
  readonly target: "commentsExtended.xml";
4572
4595
  };
4573
4596
  };
4574
- export { lockedControlViolation as $, ParagraphAlignment as $i, Shape as $n, LevelSuffix as $r, ImageWrap as $t, ThemeColorScheme as A, isBorderNil as Aa, ParagraphNumberingReference as Ai, ParagraphMarkDeletion as An, Watermark as Ar, EndnotePosition as At, finalizeParagraphFormatting as B, resolveParagraphNumbering as Bi, PropertyRevisionKind as Bn, PreviewShape as Br, HeaderFooter as Bt, Relationship as C, SchemeColorValue as Ca, TableWidthType as Ci, PARAGRAPH_MARK_CHANGE_KINDS as Cn, TextBox as Cr, DocumentBody as Ct, StyleDefinitions as D, UnrecognisedBorderStyle as Da, NO_NUMBERING_NUM_ID as Di, ParagraphContent as Dn, TrackedRunChange as Dr, DrawingRawXmlMode as Dt, Style as E, BorderStyleValue as Ea, UnderlineStyle as Ei, Paragraph as En, TrackedChangeInfo as Er, DrawingGroupChild as Et, MAX_RETAINED_PARSE_WARNINGS_PER_CODE as F, BorderStyle as Fa, paragraphNumberingFromSlots as Fi, PreservedBlock as Fn, normalizeRevisionId as Fr, FoldedListNumber as Ft, ContentControlChange as G, OutlineLevel as Gi, RunPropertyChange as Gn, presetLineDashToken as Gr, Image as Gt, paragraphSpacingExplicit as H, sameStatedParagraphNumbering as Hi, ReviewCarrier as Hn, UnrecognisedPresetLineDash as Hr, HeaderReference as Ht, PARSE_WARNING_CODES as I, paragraphNumberingLevel as Ii, PreservedInline as In, RelationshipId as Ir, FooterReference as It, LockedControlTouch as J, outlineLevelFromStatedValue as Ji, SdtType as Jn, AbstractNumbering as Jr, ImageFrameLocks as Jt, ContentControlLock as K, headingLevelOf as Ki, SdtEndProperties as Kn, PRESET_LINE_DASH_VALS as Kr, ImageCrop as Kt, ParseWarning as L, paragraphNumberingReference as Li, PreservedXmlContent as Ln, mintRelationshipId as Lr, Footnote as Lt, ThemeFontScheme as M, isBorderStyle as Ma, ResolvedParagraphNumbering as Mi, PictureWatermark as Mn, WrapDistances as Mr, Field as Mt, IMPORTED_ID_COLLISION_KINDS as N, statesNoBorder as Na, isNumberingReference as Ni, PositionalTab as Nn, WrapPolygonPoint as Nr, FieldCharContent as Nt, StyleType as O, borderStyleFrom as Oa, NO_PARAGRAPH_NUMBERING as Oi, ParagraphMarkChange as On, TrackedRunContent as Or, EffectExtentSlots as Ot, ImportedIdCollisionKind as P, BORDER_STYLES as Pa, mergeParagraphNumbering as Pi, PositionedBookmarkMarker as Pn, isOoxmlSymbolCharacter as Pr, FieldType as Pt, lockedControlMessage as Q, PARAGRAPH_ALIGNMENTS as Qi, SectionStart as Qn, LevelOverride as Qr, ImageTransform as Qt, ParseWarningCode as R, paragraphNumberingReferenceId as Ri, PropertyChange as Rn, relationshipIdOf as Rr, FootnotePosition as Rt, MediaFile as S, SchemeColorSlot as Sa, TableRowFormatting as Si, NoteReferenceContent as Sn, TableStructuralChangeInfo as Sr, DocumentBackgroundDrawing as St, RelationshipType as T, ThemeColor as Ta, TextFormatting as Ti, PageOrientation as Tn, TextWatermark as Tr, DrawingContent as Tt, setDocumentBodyComments as U, BODY_TEXT_OUTLINE_LEVEL as Ui, Run as Un, isPresetLineDashVal as Ur, Hyperlink as Ut, isCanonicallyEmptyParagraphFormatting as V, sameEffectiveParagraphNumbering as Vi, REVIEW_CARRIERS as Vn, PresetLineDashValue as Vr, HeaderFooterType as Vt, CONTENT_CONTROL_LOCK as W, HeadingOutlineLevel as Wi, RunContent as Wn, presetLineDashFrom as Wr, INSERTION_SEAM_POLICIES as Wt, contentControlLockAllows as X, NUMBER_FORMATS as Xi, SectionProperties as Xn, CounterFormat as Xr, ImagePosition as Xt, LockedControlViolation as Y, outlineLevelStatedValue as Yi, Section as Yn, COUNTER_FORMATS as Yr, ImagePadding as Yt, firstLockedControlViolation as Z, NumberFormat as Zi, SectionPropertyChange as Zn, LevelLegacy as Zr, ImageSize as Zt, DocDefaults as _, isThemeColor as _a, TableFormatting as _i, MoveToRangeStart as _n, TablePreservedMarkup as _r, ComplexField as _t, DocumentSettings as a, TabStopAlignment as aa, CellMargins as ai, KeptCut as an, ShapeTextBody as ar, BlockContent as at, FontInfo as b, themeColorSlot as ba, TableMeasurement as bi, NoteMarkerContent as bn, TableRow as br, DisplacedByCustomXml as bt, NumberingLevelEntry as c, TextDirectionFlow as ca, FloatingTableProperties as ci, MAX_REVISION_ID as cn, SoftHyphenContent as cr, BookmarkEnd as ct, numberingInstanceResolves as d, ShadingProperties as da, SpacingExplicit as di, MoveBookmarkMarker as dn, Table as dr, BreakContent as dt, TABLE_ALIGNMENTS as ea, ListLevel as ei, ImageWrapPolygon as en, ShapeAlternateContent as er, locksContent as et, numberingLevelEntries as f, SCHEME_COLOR_VALUE_BY_THEME_COLOR as fa, TabLeader as fi, MoveFrom as fn, TableCell as fr, Column as ft, ExhaustiveFields as g, isSchemeColorValue as ga, TableCellFormatting as gi, MoveToRangeEnd as gn, TableCustomXmlWrapper as gr, CommentReference as gt, isNumberingLevel as h, UnrecognisedThemeColor as ha, TableCellBorders as hi, MoveTo as hn, TableContentCarrier as hr, CommentRangeStart as ht, Document as i, TEXT_DIRECTION_FLOW_BY_TOKEN as ia, NumberingInstance as ii, InstrTextContent as in, ShapeOutline as ir, BidiControl as it, ThemeFont as j, isBorderNone as ja, ParagraphNumberingSlots as ji, ParagraphPropertyChange as jn, WrapDistanceSlots as jr, EndnoteProperties as jt, Theme as k, borderStyleToken as ka, ParagraphNumberingOverride as ki, ParagraphMarkChangeKind as kn, VerticalAlign as kr, Endnote as kt, NumberingLevelResolution as l, BorderSpec as la, LineSpacingRule as li, MarkupRangeMarker as ln, SymbolContent as lr, BookmarkRangeMarker as lt, resolveNumberingLevel as m, ThemeColorValue as ma, TableBorders as mi, MoveFromRangeStart as mn, TableCellPropertyChange as mr, CommentRangeEnd as mt, DEFAULT_TAB_STOP_TWIPS as n, TEXT_DIRECTIONS as na, ListRendering as ni, InlineWrapper as nn, ShapeFill as nr, getSingularRunPropertyChange as nt, DocxConformanceClass as o, TableAlignment as oa, ConditionalFormatStyle as oi, KeptCutPiece as on, ShapeType as or, BlockCustomXml as ot, numberingLevelHasMarkerSlot as p, THEME_COLOR_BY_SCHEME_COLOR_VALUE as pa, TabStop as pi, MoveFromRangeEnd as pn, TableCellBlock as pr, Comment as pt, LockedControlSpan as q, headingOutlineLevel as qi, SdtProperties as qn, PresetLineDashVal as qr, ImageDocPrLink as qt, DOCX_CONFORMANCE_CLASSES as r, TEXT_DIRECTION_FLOWS as ra, NumberingDefinitions as ri, Insertion as rn, ShapeGeometryAdjustment as rr, BIDI_CONTROLS as rt, DocxPackage as s, TextDirection as sa, EmphasisMark as si, LineNumberRestart as sn, SimpleField as sr, BlockSdt as st, COMMENT_PART_RELATIONSHIPS as t, TAB_STOP_ALIGNMENTS as ta, ListMarkerFormatting as ti, InlineSdt as tn, ShapeContent as tr, locksControl as tt, levelShowsMarker as u, ColorValue as ua, ParagraphFormatting as ui, MathEquation as un, TabContent as ur, BookmarkStart as ut, EmbeddedFontRef as v, knownThemeColor as va, TableGridChange as vi, NoBreakHyphenContent as vn, TablePropertyChange as vr, DRAWING_RAW_XML_MODES as vt, RelationshipMap as w, THEME_COLORS as wa, TextEffect as wi, PROPERTY_REVISION_KINDS as wn, TextContent as wr, DrawingAnchor as wt, FontTable as x, themeColorToken as xa, TablePropertyExceptionFormatting as xi, NoteNumberRestart as xn, TableRowPropertyChange as xr, DocumentBackground as xt, FontCharset as y, readThemeColor as ya, TableLook as yi, NonVisualDrawingNames as yn, TablePropertyExceptionChange as yr, Deletion as yt, ParseWarningLocation as z, paragraphNumberingSlots as zi, PropertyChangeInfo as zn, PreviewDescriptor as zr, FootnoteProperties as zt };
4597
+ export { lockedControlViolation as $, ParagraphAlignment as $i, Shape as $n, LevelSuffix as $r, ImageWrap as $t, ThemeColorScheme as A, isBorderNil as Aa, ParagraphNumberingReference as Ai, ParagraphMarkDeletion as An, Watermark as Ar, EndnotePosition as At, finalizeParagraphFormatting as B, resolveParagraphNumbering as Bi, PropertyRevisionKind as Bn, PreviewShape as Br, HeaderFooter as Bt, Relationship as C, SchemeColorValue as Ca, TableWidthType as Ci, PARAGRAPH_MARK_CHANGE_KINDS as Cn, TextBox as Cr, DocumentBody as Ct, StyleDefinitions as D, UnrecognisedBorderStyle as Da, NO_NUMBERING_NUM_ID as Di, ParagraphContent as Dn, TrackedRunChange as Dr, DrawingRawXmlMode as Dt, Style as E, BorderStyleValue as Ea, UnderlineStyle as Ei, Paragraph as En, TrackedChangeInfo as Er, DrawingGroupChild as Et, MAX_RETAINED_PARSE_WARNINGS_PER_CODE as F, BorderStyle as Fa, paragraphNumberingFromSlots as Fi, PreservedBlock as Fn, normalizeRevisionId as Fr, FoldedListNumber as Ft, ContentControlChange as G, OutlineLevel as Gi, RunPropertyChange as Gn, presetLineDashToken as Gr, Image as Gt, paragraphSpacingExplicit as H, sameStatedParagraphNumbering as Hi, ReviewCarrier as Hn, UnrecognisedPresetLineDash as Hr, HeaderReference as Ht, PARSE_WARNING_CODES as I, paragraphNumberingLevel as Ii, PreservedInline as In, RelationshipId as Ir, FooterReference as It, LockedControlTouch as J, outlineLevelFromStatedValue as Ji, SdtType as Jn, AbstractNumbering as Jr, ImageFrameLocks as Jt, ContentControlLock as K, headingLevelOf as Ki, SdtEndProperties as Kn, PRESET_LINE_DASH_VALS as Kr, ImageCrop as Kt, ParseWarning as L, paragraphNumberingReference as Li, PreservedXmlContent as Ln, mintRelationshipId as Lr, Footnote as Lt, ThemeFontScheme as M, isBorderStyle as Ma, ResolvedParagraphNumbering as Mi, PictureWatermark as Mn, WrapDistances as Mr, Field as Mt, IMPORTED_ID_COLLISION_KINDS as N, statesNoBorder as Na, isNumberingReference as Ni, PositionalTab as Nn, WrapPolygonPoint as Nr, FieldCharContent as Nt, StyleType as O, borderStyleFrom as Oa, NO_PARAGRAPH_NUMBERING as Oi, ParagraphMarkChange as On, TrackedRunContent as Or, EffectExtentSlots as Ot, ImportedIdCollisionKind as P, BORDER_STYLES as Pa, mergeParagraphNumbering as Pi, PositionedBookmarkMarker as Pn, isOoxmlSymbolCharacter as Pr, FieldType as Pt, lockedControlMessage as Q, PARAGRAPH_ALIGNMENTS as Qi, SectionStart as Qn, LevelOverride as Qr, ImageTransform as Qt, ParseWarningCode as R, paragraphNumberingReferenceId as Ri, PropertyChange as Rn, relationshipIdOf as Rr, FootnotePosition as Rt, MediaFile as S, SchemeColorSlot as Sa, TableRowFormatting as Si, NoteReferenceContent as Sn, TableStructuralChangeInfo as Sr, DocumentBackgroundDrawing as St, RelationshipType as T, ThemeColor as Ta, TextFormatting as Ti, PageOrientation as Tn, TextWatermark as Tr, DrawingContent as Tt, setDocumentBodyComments as U, BODY_TEXT_OUTLINE_LEVEL as Ui, Run as Un, isPresetLineDashVal as Ur, Hyperlink as Ut, isCanonicallyEmptyParagraphFormatting as V, sameEffectiveParagraphNumbering as Vi, REVIEW_CARRIERS as Vn, PresetLineDashValue as Vr, HeaderFooterType as Vt, CONTENT_CONTROL_LOCK as W, HeadingOutlineLevel as Wi, RunContent as Wn, presetLineDashFrom as Wr, INSERTION_SEAM_POLICIES as Wt, contentControlLockAllows as X, NUMBER_FORMATS as Xi, SectionProperties as Xn, CounterFormat as Xr, ImagePosition as Xt, LockedControlViolation as Y, outlineLevelStatedValue as Yi, Section as Yn, COUNTER_FORMATS as Yr, ImagePadding as Yt, firstLockedControlViolation as Z, NumberFormat as Zi, SectionPropertyChange as Zn, LevelLegacy as Zr, ImageSize as Zt, DocDefaults as _, isThemeColor as _a, TableFormatting as _i, MoveToRangeStart as _n, TablePreservedMarkup as _r, ComplexField as _t, DocumentSettings as a, TabStopAlignment as aa, CellMargins as ai, KeptCut as an, ShapeTextBody as ar, BlockContent as at, FontInfo as b, themeColorSlot as ba, TableMeasurement as bi, NoteMarkerContent as bn, TableRow as br, DisplacedByCustomXml as bt, NumberingLevelEntry as c, TextDirectionFlow as ca, FloatingTableProperties as ci, MAX_REVISION_ID as cn, SoftHyphenContent as cr, BookmarkEnd as ct, numberingInstanceResolves as d, ShadingProperties as da, SpacingExplicit as di, MoveBookmarkMarker as dn, Table as dr, BreakContent as dt, TABLE_ALIGNMENTS as ea, ListLevel as ei, ImageWrapPolygon as en, ShapeAlternateContent as er, locksContent as et, numberingLevelEntries as f, SCHEME_COLOR_VALUE_BY_THEME_COLOR as fa, TabLeader as fi, MoveFrom as fn, TableCell as fr, Column as ft, ExhaustiveFields as g, isSchemeColorValue as ga, TableCellFormatting as gi, MoveToRangeEnd as gn, TableCustomXmlWrapper as gr, CommentReference as gt, isNumberingLevel as h, UnrecognisedThemeColor as ha, TableCellBorders as hi, MoveTo as hn, TableContentCarrier as hr, CommentRangeStart as ht, Document as i, TEXT_DIRECTION_FLOW_BY_TOKEN as ia, NumberingInstance as ii, InstrTextContent as in, ShapeOutline as ir, BidiControl as it, ThemeFont as j, isBorderNone as ja, ParagraphNumberingSlots as ji, ParagraphPropertyChange as jn, WrapDistanceSlots as jr, EndnoteProperties as jt, Theme as k, borderStyleToken as ka, ParagraphNumberingOverride as ki, ParagraphMarkChangeKind as kn, VerticalAlign as kr, Endnote as kt, NumberingLevelResolution as l, BorderSpec as la, LineSpacingRule as li, MarkupRangeMarker as ln, SymbolContent as lr, BookmarkRangeMarker as lt, resolveNumberingLevel as m, ThemeColorValue as ma, TableBorders as mi, MoveFromRangeStart as mn, TableCellPropertyChange as mr, CommentRangeEnd as mt, DEFAULT_TAB_STOP_TWIPS as n, TEXT_DIRECTIONS as na, ListRendering as ni, InlineWrapper as nn, ShapeFill as nr, getSingularRunPropertyChange as nt, DocxConformanceClass as o, TableAlignment as oa, ConditionalFormatStyle as oi, KeptCutHolders as on, ShapeType as or, BlockCustomXml as ot, numberingLevelHasMarkerSlot as p, THEME_COLOR_BY_SCHEME_COLOR_VALUE as pa, TabStop as pi, MoveFromRangeEnd as pn, TableCellBlock as pr, Comment as pt, LockedControlSpan as q, headingOutlineLevel as qi, SdtProperties as qn, PresetLineDashVal as qr, ImageDocPrLink as qt, DOCX_CONFORMANCE_CLASSES as r, TEXT_DIRECTION_FLOWS as ra, NumberingDefinitions as ri, Insertion as rn, ShapeGeometryAdjustment as rr, BIDI_CONTROLS as rt, DocxPackage as s, TextDirection as sa, EmphasisMark as si, LineNumberRestart as sn, SimpleField as sr, BlockSdt as st, COMMENT_PART_RELATIONSHIPS as t, TAB_STOP_ALIGNMENTS as ta, ListMarkerFormatting as ti, InlineSdt as tn, ShapeContent as tr, locksControl as tt, levelShowsMarker as u, ColorValue as ua, ParagraphFormatting as ui, MathEquation as un, TabContent as ur, BookmarkStart as ut, EmbeddedFontRef as v, knownThemeColor as va, TableGridChange as vi, NoBreakHyphenContent as vn, TablePropertyChange as vr, DRAWING_RAW_XML_MODES as vt, RelationshipMap as w, THEME_COLORS as wa, TextEffect as wi, PROPERTY_REVISION_KINDS as wn, TextContent as wr, DrawingAnchor as wt, FontTable as x, themeColorToken as xa, TablePropertyExceptionFormatting as xi, NoteNumberRestart as xn, TableRowPropertyChange as xr, DocumentBackground as xt, FontCharset as y, readThemeColor as ya, TableLook as yi, NonVisualDrawingNames as yn, TablePropertyExceptionChange as yr, Deletion as yt, ParseWarningLocation as z, paragraphNumberingSlots as zi, PropertyChangeInfo as zn, PreviewDescriptor as zr, FootnoteProperties as zt };
Binary file
@@ -43,19 +43,45 @@ const exactBytes = (bytes) => {
43
43
  const { buffer } = bytes;
44
44
  return buffer instanceof ArrayBuffer && bytes.byteOffset === 0 && bytes.byteLength === buffer.byteLength ? new Uint8Array(buffer) : copyBytes(bytes);
45
45
  };
46
- let crcTable = null;
47
- const tableCrc32 = (data, previous = 0) => {
48
- if (crcTable === null) {
49
- crcTable = /* @__PURE__ */ new Uint32Array(256);
50
- for (let index = 0; index < 256; index++) {
51
- let value = index;
52
- for (let bit = 0; bit < 8; bit++) value = value & 1 ? 3988292384 ^ value >>> 1 : value >>> 1;
53
- crcTable[index] = value >>> 0;
46
+ /**
47
+ * Eight 256-entry CRC-32 tables, one after another: table 0 is the classic
48
+ * byte table, and table `k` advances a byte's contribution by `k` more bytes.
49
+ */
50
+ let crcTables = null;
51
+ const buildCrcTables = () => {
52
+ const tables = /* @__PURE__ */ new Uint32Array(2048);
53
+ for (let index = 0; index < 256; index++) {
54
+ let value = index;
55
+ for (let bit = 0; bit < 8; bit++) value = value & 1 ? 3988292384 ^ value >>> 1 : value >>> 1;
56
+ tables[index] = value >>> 0;
57
+ }
58
+ for (let index = 0; index < 256; index++) {
59
+ let value = tables[index];
60
+ for (let table = 1; table < 8; table++) {
61
+ value = tables[value & 255] ^ value >>> 8;
62
+ tables[table * 256 + index] = value >>> 0;
54
63
  }
55
64
  }
56
- const table = crcTable;
65
+ return tables;
66
+ };
67
+ /**
68
+ * CRC-32 where the runtime offers none (browsers): eight bytes per step over
69
+ * eight tables, then byte by byte. The loops index the array; iterating a
70
+ * typed array with `for…of` runs an order of magnitude slower, and every
71
+ * entry an archive inflates is checked through here.
72
+ */
73
+ const tableCrc32 = (data, previous = 0) => {
74
+ crcTables ??= buildCrcTables();
75
+ const t = crcTables;
57
76
  let crc = ~previous >>> 0;
58
- for (const byte of data) crc = table[(crc ^ byte) & 255] ^ crc >>> 8;
77
+ const length = data.length;
78
+ const whole = length - length % 8;
79
+ let index = 0;
80
+ for (; index < whole; index += 8) {
81
+ const low = (crc ^ (data[index] | data[index + 1] << 8 | data[index + 2] << 16 | data[index + 3] << 24)) >>> 0;
82
+ crc = t[1792 + (low & 255)] ^ t[1536 + (low >>> 8 & 255)] ^ t[1280 + (low >>> 16 & 255)] ^ t[1024 + (low >>> 24)] ^ t[768 + data[index + 4]] ^ t[512 + data[index + 5]] ^ t[256 + data[index + 6]] ^ t[data[index + 7]];
83
+ }
84
+ for (; index < length; index++) crc = t[(crc ^ data[index]) & 255] ^ crc >>> 8;
59
85
  return ~crc >>> 0;
60
86
  };
61
87
  const BUFFER_TOO_LARGE = "ERR_BUFFER_TOO_LARGE";
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { B as finalizeParagraphFormatting, Ct as DocumentBody, Dn as ParagraphContent, E as Style, En as Paragraph, Nn as PositionalTab, St as DocumentBackgroundDrawing, U as setDocumentBodyComments, Un as Run, V as isCanonicallyEmptyParagraphFormatting, Wn as RunContent, Xn as SectionProperties, at as BlockContent, br as TableRow, dr as Table, dt as BreakContent, fr as TableCell, i as Document, o as DocxConformanceClass, r as DOCX_CONFORMANCE_CLASSES, ri as NumberingDefinitions, s as DocxPackage, wr as TextContent, xt as DocumentBackground } from "./document-f4_h6JMT.js";
1
+ import { B as finalizeParagraphFormatting, Ct as DocumentBody, Dn as ParagraphContent, E as Style, En as Paragraph, Nn as PositionalTab, St as DocumentBackgroundDrawing, U as setDocumentBodyComments, Un as Run, V as isCanonicallyEmptyParagraphFormatting, Wn as RunContent, Xn as SectionProperties, at as BlockContent, br as TableRow, dr as Table, dt as BreakContent, fr as TableCell, i as Document, o as DocxConformanceClass, r as DOCX_CONFORMANCE_CLASSES, ri as NumberingDefinitions, s as DocxPackage, wr as TextContent, xt as DocumentBackground } from "./document-BKejiFuk.js";
2
2
  import { TaggedErrorClass } from "better-result";
3
3
  import { Buffer } from "node:buffer";
4
4
  type LegalDocumentKind = "agreement" | "letter" | "memo" | "checklist" | "pleading" | "other";