xls-codec 2.0.2 → 4.0.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.
Files changed (50) hide show
  1. package/README.md +12 -10
  2. package/dist/biff/ptg.cjs +160 -7
  3. package/dist/biff/ptg.d.cts +2 -2
  4. package/dist/biff/ptg.d.ts +2 -2
  5. package/dist/biff/ptg.js +161 -9
  6. package/dist/biff/strings.cjs +6 -0
  7. package/dist/biff/strings.d.cts +3 -1
  8. package/dist/biff/strings.d.ts +3 -1
  9. package/dist/biff/strings.js +6 -1
  10. package/dist/biff/substreams.cjs +5 -0
  11. package/dist/biff/substreams.d.cts +2 -2
  12. package/dist/biff/substreams.d.ts +2 -2
  13. package/dist/biff/substreams.js +5 -1
  14. package/dist/biff/xf-colors.cjs +59 -8
  15. package/dist/biff/xf-colors.d.cts +2 -2
  16. package/dist/biff/xf-colors.d.ts +2 -2
  17. package/dist/biff/xf-colors.js +59 -9
  18. package/dist/biff/xf-writer.d.cts +1 -1
  19. package/dist/biff/xf-writer.d.ts +1 -1
  20. package/dist/content.cjs +3 -3
  21. package/dist/content.js +3 -3
  22. package/dist/index.cjs +2 -0
  23. package/dist/index.d.cts +3 -3
  24. package/dist/index.d.ts +3 -3
  25. package/dist/index.js +3 -3
  26. package/dist/{print-names-DUlpVE00.d.ts → print-names-C-PQ2vAy.d.ts} +1 -1
  27. package/dist/{print-names-D-njuzVw.d.cts → print-names-DyYloloV.d.cts} +1 -1
  28. package/dist/ptg-CCBbJLZJ.d.cts +49 -0
  29. package/dist/ptg-CCBbJLZJ.d.ts +49 -0
  30. package/dist/{substreams-D7dQiJbp.d.ts → substreams-CmyZMtuM.d.ts} +3 -1
  31. package/dist/{substreams-Ddtvn_Vr.d.cts → substreams-Cpy5Fi3d.d.cts} +3 -1
  32. package/dist/workbook/globals-writer.d.cts +2 -2
  33. package/dist/workbook/globals-writer.d.ts +2 -2
  34. package/dist/workbook/globals.cjs +137 -14
  35. package/dist/workbook/globals.d.cts +7 -7
  36. package/dist/workbook/globals.d.ts +7 -7
  37. package/dist/workbook/globals.js +138 -15
  38. package/dist/workbook/print-names.d.cts +1 -1
  39. package/dist/workbook/print-names.d.ts +1 -1
  40. package/dist/workbook/sheet.cjs +109 -6
  41. package/dist/workbook/sheet.d.cts +3 -3
  42. package/dist/workbook/sheet.d.ts +3 -3
  43. package/dist/workbook/sheet.js +110 -7
  44. package/dist/write.cjs +37 -4
  45. package/dist/write.js +39 -6
  46. package/dist/{xf-colors-CpykR3B9.d.ts → xf-colors--5oxSeI1.d.ts} +13 -6
  47. package/dist/{xf-colors-CehHZtBy.d.cts → xf-colors-BB5MKq6R.d.cts} +13 -6
  48. package/package.json +4 -4
  49. package/dist/ptg-B2K8t3js.d.cts +0 -21
  50. package/dist/ptg-B2K8t3js.d.ts +0 -21
@@ -1,10 +1,12 @@
1
1
  import { t as BlockCursor } from "./cursor-VMtw9uVP.cjs";
2
- import { Alignment, Color, ContentBorder } from "document-schema.js";
2
+ import { Alignment, Color, ContentBorder, ContentCellFill, ContentCellPatternType } from "document-schema.js";
3
3
  //#region src/biff/xf-colors.d.ts
4
4
  /** FLSNULL: no fill pattern -- the cell's fill colour fields carry no meaning. */
5
5
  declare const FILL_PATTERN_NONE = 0;
6
- /** FLSSOLID: a solid fill, the only pattern this package maps onto ContentSheetCell.background -- "If this value is 1 ... then only icvFore is rendered" ([MS-XLS] CellXF). Every other pattern (50%/75%/25% gray, the stripe and crosshatch families, ...) is a real information-loss case this reader does not approximate: see resolveFillBackground below. */
6
+ /** FLSSOLID: a solid fill -- "If this value is 1 ... then only icvFore is rendered" ([MS-XLS] CellXF). */
7
7
  declare const FILL_PATTERN_SOLID = 1;
8
+ /** The inverse of FILL_PATTERN_TO_PATTERN_TYPE, built from it rather than restated by hand so the two can never drift apart. Every ContentCellPatternType this package's own writer is ever asked to state has an entry, since the SpreadsheetML half of the shared vocabulary is exactly FILL_PATTERN_TO_PATTERN_TYPE's own value set -- the WordprocessingML-only members (the percentN family and the stripe/cross families ST_Shd names) are absent, FillPattern having no equivalent for them at all. */
9
+ declare const PATTERN_TYPE_TO_FILL_PATTERN: ReadonlyMap<ContentCellPatternType, number>;
8
10
  /** alc (a CellXF/StyleXF payload's word1, bits 0-2) -> ContentSheetCell.alignment, or undefined for ALCGEN (the value-kind default this field being absent already requests) and for the three HorizAlign members (ALCFILL/ALCCONTCTR/ALCDIST) Alignment has no member for -- matching ooxml.js's readHorizontalAlignment policy of only the four direct members surviving. */
9
11
  declare function resolveHorizontalAlignment(alc: number): Alignment | undefined;
10
12
  /** ContentSheetCell.alignment -> the alc token to pack into word1 -- undefined maps to ALCGEN, the "use the value-kind default" token every genuinely unaligned cell already carried before this module modelled alignment at all. */
@@ -56,12 +58,17 @@ interface XfBorderEdge {
56
58
  declare function resolveBorderEdge(edge: XfBorderEdge, palette: readonly Color[] | undefined): ContentBorder | undefined;
57
59
  /** The inverse of resolveBorderEdge's style resolution: picks the BorderStyle token carrying a ContentBorder's own pattern at the closest named weight, bucketing a solid/dashed border's widthPt back to a weight through document-schema.js's own shared quantisation -- the same one resolveBorderEdge's widths came out of, and the same one ooxml.js's borderToXlsxStyle buckets xlsx's string tokens through. */
58
60
  declare function borderStyleTokenFor(border: ContentBorder): number;
59
- /** A solid fill's own foreground colour resolved to a real background, or undefined for every other FillPattern value -- FLSNULL (no fill at all) and every pattern beyond solid (50%/75%/25% gray, the stripe and crosshatch family) alike. A non-solid pattern is a real information-loss case rather than an oversight: ContentSheetCell.background models one flat colour, and approximating a striped or crosshatched fill as its foreground colour alone would misrepresent what the cell actually shows -- see xls-codec's README for this package's own stated judgment call. */
60
- declare function resolveFillBackground(fillPattern: number, foregroundIcv: number, palette: readonly Color[] | undefined): Color | undefined;
61
- /** Every decoration field the trailing payload's word2/word3/word4 carry ([MS-XLS] 2.4.353's own CellXF/StyleXF "Data" field), read or write side alike: which fill pattern (if any) and its foreground colour, and each of the four sides' own border style plus colour. Diagonal borders (dgDiag/grbitDiag/icvDiag) are out of this package's scope -- ContentCellBordersSchema has no diagonal member -- and are always read as absent / always written as none. */
61
+ /**
62
+ * Resolves a cell's own FillPattern/icvFore/icvBack triple to a real ContentCellFill (ExaDev/documents.js#951), or undefined for FLSNULL (no fill at all), for a reserved/unrecognised FillPattern value, or for FLSSOLID when its own icvFore does not resolve to a fixed RGB value (an "Automatic" or otherwise unmapped icv, which leaves nothing to state a solid fill's colour as).
63
+ *
64
+ * FLSSOLID resolves to a 'solid' fill of icvFore alone -- "If this value is 1 ... then only icvFore is rendered" ([MS-XLS] CellXF), so icvBack carries no meaning for it and is never consulted. Every other named FillPattern resolves to a real 'pattern' fill via FILL_PATTERN_TO_PATTERN_TYPE, carrying whichever of icvFore/icvBack resolves to a real colour (either may be an "Automatic" icv this package cannot express as a fixed RGB value, matching ContentCellFillSchema's own "a colour can defer instead of asserting" convention).
65
+ */
66
+ declare function resolveFillBackground(fillPattern: number, foregroundIcv: number, backgroundIcv: number, palette: readonly Color[] | undefined): ContentCellFill | undefined;
67
+ /** Every decoration field the trailing payload's word2/word3/word4 carry ([MS-XLS] 2.4.353's own CellXF/StyleXF "Data" field), read or write side alike: which fill pattern (if any) and its foreground/background colours, and each of the four sides' own border style plus colour. fillBackgroundIcv carries no meaning for a solid fill (icvFore alone is rendered) but is real for every other named pattern, where it is the colour the pattern's gaps show through. Diagonal borders (dgDiag/grbitDiag/icvDiag) are out of this package's scope -- ContentCellBordersSchema has no diagonal member -- and are always read as absent / always written as none. */
62
68
  interface XfDecorationFields {
63
69
  readonly fillPattern: number;
64
70
  readonly fillForegroundIcv: number;
71
+ readonly fillBackgroundIcv: number;
65
72
  readonly left: XfBorderEdge;
66
73
  readonly right: XfBorderEdge;
67
74
  readonly top: XfBorderEdge;
@@ -88,4 +95,4 @@ declare function readLongRgbColor(cursor: BlockCursor): Color;
88
95
  /** The inverse of readLongRgbColor: a colour's own red/green/blue/reserved bytes, rounded to the nearest byte (the same rounding colorToRgbHex applies) -- exact for any colour this package itself constructed via rgbHexToColor, which is what write.ts's own palette-colour interning does. */
89
96
  declare function longRgbBytesOf(color: Color): readonly [number, number, number, number];
90
97
  //#endregion
91
- export { readLongRgbColor as A, XfAlignmentFields as C, horizAlignTokenFor as D, borderStyleTokenFor as E, resolveVerticalAlignment as F, unpackXfAlignment as I, unpackXfDecoration as L, resolveFillBackground as M, resolveHorizontalAlignment as N, longRgbBytesOf as O, resolveIcvColor as P, vertAlignTokenFor as R, UNDECORATED_XF_FIELDS as S, XfDecorationFields as T, FILL_PATTERN_SOLID as _, BORDER_STYLE_DOUBLE as a, PALETTE_BASE_ICV as b, BORDER_STYLE_MEDIUM_DASHDOT as c, BORDER_STYLE_NONE as d, BORDER_STYLE_SLANT_DASHDOT as f, FILL_PATTERN_NONE as g, DEFAULT_PALETTE_HEX_TO_ICV as h, BORDER_STYLE_DOTTED as i, resolveBorderEdge as j, packXfDecorationWords as k, BORDER_STYLE_MEDIUM_DASHDOTDOT as l, BORDER_STYLE_THIN as m, BORDER_STYLE_DASHDOTDOT as n, BORDER_STYLE_HAIR as o, BORDER_STYLE_THICK as p, BORDER_STYLE_DASHED as r, BORDER_STYLE_MEDIUM as s, BORDER_STYLE_DASHDOT as t, BORDER_STYLE_MEDIUM_DASHED as u, ICV_AUTOMATIC_BACKGROUND as v, XfBorderEdge as w, PALETTE_ENTRY_COUNT as x, ICV_AUTOMATIC_FOREGROUND as y };
98
+ export { packXfDecorationWords as A, UNDECORATED_XF_FIELDS as C, borderStyleTokenFor as D, XfDecorationFields as E, resolveIcvColor as F, resolveVerticalAlignment as I, unpackXfAlignment as L, resolveBorderEdge as M, resolveFillBackground as N, horizAlignTokenFor as O, resolveHorizontalAlignment as P, unpackXfDecoration as R, PATTERN_TYPE_TO_FILL_PATTERN as S, XfBorderEdge as T, FILL_PATTERN_SOLID as _, BORDER_STYLE_DOUBLE as a, PALETTE_BASE_ICV as b, BORDER_STYLE_MEDIUM_DASHDOT as c, BORDER_STYLE_NONE as d, BORDER_STYLE_SLANT_DASHDOT as f, FILL_PATTERN_NONE as g, DEFAULT_PALETTE_HEX_TO_ICV as h, BORDER_STYLE_DOTTED as i, readLongRgbColor as j, longRgbBytesOf as k, BORDER_STYLE_MEDIUM_DASHDOTDOT as l, BORDER_STYLE_THIN as m, BORDER_STYLE_DASHDOTDOT as n, BORDER_STYLE_HAIR as o, BORDER_STYLE_THICK as p, BORDER_STYLE_DASHED as r, BORDER_STYLE_MEDIUM as s, BORDER_STYLE_DASHDOT as t, BORDER_STYLE_MEDIUM_DASHED as u, ICV_AUTOMATIC_BACKGROUND as v, XfAlignmentFields as w, PALETTE_ENTRY_COUNT as x, ICV_AUTOMATIC_FOREGROUND as y, vertAlignTokenFor as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xls-codec",
3
- "version": "2.0.2",
3
+ "version": "4.0.0",
4
4
  "description": "Hand-written reader for the legacy Excel Binary File Format (.xls, BIFF8) as specified by [MS-XLS], mapping a workbook's record stream onto the shared document-schema.js spreadsheet model - the .xls codec for the documents.js family.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -68,9 +68,9 @@
68
68
  },
69
69
  "packageManager": "pnpm@11.6.0",
70
70
  "dependencies": {
71
- "archive-codec": "^1.4.2",
72
- "document-schema.js": "^5.6.0",
73
- "excel-number-format": "^1.0.1"
71
+ "archive-codec": "^1.4.3",
72
+ "document-schema.js": "^6.0.0",
73
+ "excel-number-format": "^1.0.2"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@arethetypeswrong/cli": "^0.18.5",
@@ -1,21 +0,0 @@
1
- //#region src/biff/ptg.d.ts
2
- /** A 3D reference's sheet scope, resolved from its ixti through EXTERNSHEET and a self-referencing SupBook ([MS-XLS] 2.4.271, 2.4.106, 2.5.344): the first and last sheet of the reference, both direct BoundSheet8 indices into FormulaSheetContext.sheets. A single-sheet 3D reference has `firstSheetIndex === lastSheetIndex`. Defined here rather than alongside the globals reader that produces it, since resolving it into reference text is what this module exists to do. */
3
- interface SheetRange {
4
- readonly firstSheetIndex: number;
5
- readonly lastSheetIndex: number;
6
- }
7
- /** What a 3D reference's own ixti resolves against: the workbook's sheets in BoundSheet8 order (only the name is needed here), and each ixti's own resolved sheet range (undefined where this reader does not resolve it -- see WorkbookGlobals.sheetRanges, which this type's own sheetRanges field matches field-for-field). */
8
- interface FormulaSheetContext {
9
- readonly sheets: readonly {
10
- readonly name: string;
11
- }[];
12
- readonly sheetRanges: readonly (SheetRange | undefined)[];
13
- }
14
- /**
15
- * Parses a Formula record's compiled expression into the text a spreadsheet application would show, or returns undefined for a token this reader does not resolve -- a shared formula's PtgExp, an array constant's PtgArray, a defined name, a natural-language reference, or a 3D reference into a genuinely external workbook (see the module comment for the full list). The caller leaves ContentSheetCell.formula absent in that case, exactly as for any other unsupported construct.
16
- *
17
- * `rgce` is the formula's own token bytes, already sliced to their declared length (CellParsedFormula.cce) by the caller -- this function reads exactly that many bytes and nothing past them.
18
- */
19
- declare function parseFormulaText(rgce: Uint8Array<ArrayBuffer>, context: FormulaSheetContext): string | undefined;
20
- //#endregion
21
- export { SheetRange as n, parseFormulaText as r, FormulaSheetContext as t };
@@ -1,21 +0,0 @@
1
- //#region src/biff/ptg.d.ts
2
- /** A 3D reference's sheet scope, resolved from its ixti through EXTERNSHEET and a self-referencing SupBook ([MS-XLS] 2.4.271, 2.4.106, 2.5.344): the first and last sheet of the reference, both direct BoundSheet8 indices into FormulaSheetContext.sheets. A single-sheet 3D reference has `firstSheetIndex === lastSheetIndex`. Defined here rather than alongside the globals reader that produces it, since resolving it into reference text is what this module exists to do. */
3
- interface SheetRange {
4
- readonly firstSheetIndex: number;
5
- readonly lastSheetIndex: number;
6
- }
7
- /** What a 3D reference's own ixti resolves against: the workbook's sheets in BoundSheet8 order (only the name is needed here), and each ixti's own resolved sheet range (undefined where this reader does not resolve it -- see WorkbookGlobals.sheetRanges, which this type's own sheetRanges field matches field-for-field). */
8
- interface FormulaSheetContext {
9
- readonly sheets: readonly {
10
- readonly name: string;
11
- }[];
12
- readonly sheetRanges: readonly (SheetRange | undefined)[];
13
- }
14
- /**
15
- * Parses a Formula record's compiled expression into the text a spreadsheet application would show, or returns undefined for a token this reader does not resolve -- a shared formula's PtgExp, an array constant's PtgArray, a defined name, a natural-language reference, or a 3D reference into a genuinely external workbook (see the module comment for the full list). The caller leaves ContentSheetCell.formula absent in that case, exactly as for any other unsupported construct.
16
- *
17
- * `rgce` is the formula's own token bytes, already sliced to their declared length (CellParsedFormula.cce) by the caller -- this function reads exactly that many bytes and nothing past them.
18
- */
19
- declare function parseFormulaText(rgce: Uint8Array<ArrayBuffer>, context: FormulaSheetContext): string | undefined;
20
- //#endregion
21
- export { SheetRange as n, parseFormulaText as r, FormulaSheetContext as t };