@shbernal/ts-xlsx 1.0.0 → 1.0.3

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 (105) hide show
  1. package/README.md +6 -0
  2. package/dist/core/autofilter.js +2 -2
  3. package/dist/core/cell.js +4 -4
  4. package/dist/core/color-resolution.js +1 -1
  5. package/dist/core/column.js +2 -2
  6. package/dist/core/conditional-formatting-overlay.js +1 -1
  7. package/dist/core/data-validation-overlay.js +2 -2
  8. package/dist/core/formula.js +2 -2
  9. package/dist/core/grid-edits.js +5 -5
  10. package/dist/core/merge.js +1 -1
  11. package/dist/core/pivot-table.js +3 -3
  12. package/dist/core/range.js +8 -4
  13. package/dist/core/row.js +2 -2
  14. package/dist/core/table-style.d.ts +2 -2
  15. package/dist/core/table-style.js +2 -2
  16. package/dist/core/table.js +2 -2
  17. package/dist/core/theme.d.ts +1 -1
  18. package/dist/core/theme.js +1 -1
  19. package/dist/core/value.d.ts +10 -10
  20. package/dist/core/workbook-protection.d.ts +1 -1
  21. package/dist/core/workbook.d.ts +11 -11
  22. package/dist/core/workbook.js +22 -22
  23. package/dist/core/worksheet-model.d.ts +1 -1
  24. package/dist/core/worksheet-model.js +5 -5
  25. package/dist/core/worksheet.d.ts +2 -2
  26. package/dist/core/worksheet.js +21 -21
  27. package/dist/customui/errors.js +1 -1
  28. package/dist/customui/index.js +2 -2
  29. package/dist/customui/ribbon.d.ts +1 -1
  30. package/dist/customui/ribbon.js +3 -3
  31. package/dist/entries/core.js +14 -14
  32. package/dist/entries/csv.js +2 -2
  33. package/dist/entries/customui.js +1 -1
  34. package/dist/entries/errors.js +7 -7
  35. package/dist/entries/vba.js +2 -2
  36. package/dist/entries/xlsb.js +1 -1
  37. package/dist/entries/xlsx.js +5 -5
  38. package/dist/index.js +7 -7
  39. package/dist/io/csv/read.js +2 -2
  40. package/dist/io/csv/write.js +2 -2
  41. package/dist/io/opc/errors.js +1 -1
  42. package/dist/io/opc/inflate.d.ts +1 -1
  43. package/dist/io/opc/inflate.js +2 -2
  44. package/dist/io/opc/read-opc.js +2 -2
  45. package/dist/io/opc/rels.js +2 -2
  46. package/dist/io/opc/sniff-format.js +2 -2
  47. package/dist/io/style/xf-style.js +2 -2
  48. package/dist/io/xlsb/errors.js +1 -1
  49. package/dist/io/xlsb/formula.js +4 -4
  50. package/dist/io/xlsb/primitives.js +2 -2
  51. package/dist/io/xlsb/read-shared-strings.js +3 -3
  52. package/dist/io/xlsb/read-styles.js +5 -5
  53. package/dist/io/xlsb/read-worksheet.js +9 -9
  54. package/dist/io/xlsb/read.d.ts +1 -1
  55. package/dist/io/xlsb/read.js +15 -15
  56. package/dist/io/xlsb/record-stream.js +1 -1
  57. package/dist/io/xlsx/cell-accumulator.js +6 -6
  58. package/dist/io/xlsx/cell-value.js +4 -4
  59. package/dist/io/xlsx/comments.js +4 -4
  60. package/dist/io/xlsx/conditional-formatting.js +5 -5
  61. package/dist/io/xlsx/data-validation.js +4 -4
  62. package/dist/io/xlsx/edit-vba.js +4 -4
  63. package/dist/io/xlsx/errors.js +1 -1
  64. package/dist/io/xlsx/hyperlinks.js +4 -4
  65. package/dist/io/xlsx/images.js +6 -6
  66. package/dist/io/xlsx/package-plan.js +3 -3
  67. package/dist/io/xlsx/pivot-read.js +2 -2
  68. package/dist/io/xlsx/pivot.js +4 -4
  69. package/dist/io/xlsx/read-rows.d.ts +3 -3
  70. package/dist/io/xlsx/read-rows.js +12 -12
  71. package/dist/io/xlsx/read-styles.js +4 -4
  72. package/dist/io/xlsx/read-worksheet.js +8 -8
  73. package/dist/io/xlsx/read.d.ts +1 -1
  74. package/dist/io/xlsx/read.js +28 -28
  75. package/dist/io/xlsx/relationships.d.ts +6 -6
  76. package/dist/io/xlsx/relationships.js +2 -2
  77. package/dist/io/xlsx/rich-runs.js +1 -1
  78. package/dist/io/xlsx/rich-text.js +2 -2
  79. package/dist/io/xlsx/shared-formulas.js +3 -3
  80. package/dist/io/xlsx/shared-strings-read.js +2 -2
  81. package/dist/io/xlsx/shared-strings.js +3 -3
  82. package/dist/io/xlsx/sheet-properties.js +4 -4
  83. package/dist/io/xlsx/styles.js +6 -6
  84. package/dist/io/xlsx/tables.js +5 -5
  85. package/dist/io/xlsx/threaded-comments.js +5 -5
  86. package/dist/io/xlsx/workbook-xml.js +9 -9
  87. package/dist/io/xlsx/worksheet-xml.js +18 -18
  88. package/dist/io/xlsx/write-stream.d.ts +1 -1
  89. package/dist/io/xlsx/write-stream.js +7 -7
  90. package/dist/io/xlsx/write.d.ts +3 -3
  91. package/dist/io/xlsx/write.js +20 -20
  92. package/dist/io/xlsx/x14-ext.js +1 -1
  93. package/dist/vba/cfb-writer.js +1 -1
  94. package/dist/vba/cfb.js +1 -1
  95. package/dist/vba/codepage.js +1 -1
  96. package/dist/vba/errors.js +1 -1
  97. package/dist/vba/index.js +5 -5
  98. package/dist/vba/ms-ovba.js +1 -1
  99. package/dist/vba/project-editor.js +7 -7
  100. package/dist/vba/project.js +4 -4
  101. package/dist/vba/vba-encoding.js +1 -1
  102. package/dist/xml/errors.js +1 -1
  103. package/dist/xml/xml-read.js +1 -1
  104. package/dist/xml/xml.js +1 -1
  105. package/package.json +3 -2
@@ -14,27 +14,27 @@
14
14
  // `worksheet-xml.ts` and are re-exported here so the streaming writer's import surface is
15
15
  // unchanged.
16
16
  import { strToU8, zip, zipSync } from 'fflate';
17
- import { DEFAULT_THEME_XML } from "../../core/theme.js";
18
- import { AuthoringError } from "../../errors.js";
19
- import { THEME_PART_PATH } from "../opc/part-paths.js";
20
- import { relsPartXml } from "../opc/rels.js";
21
- import { collectComments, commentsXml, vmlDrawingXml } from "./comments.js";
22
- import { collectHyperlinks, planHyperlinks } from "./hyperlinks.js";
23
- import { drawingRelsXml, drawingXml } from "./images.js";
24
- import { planMedia, planPreservedParts, SheetRelIds, } from "./package-plan.js";
25
- import { pivotCacheDefinitionXml, pivotCacheRecordsXml, pivotTableXml } from "./pivot.js";
26
- import { REL } from "./relationships.js";
27
- import { SharedStringTable } from "./shared-strings.js";
28
- import { StyleRegistry } from "./styles.js";
29
- import { tableXml } from "./tables.js";
30
- import { personsXml, threadedCommentsXml } from "./threaded-comments.js";
31
- import { appPropsXml, contentTypesXml, corePropsXml, FIXED_WORKBOOK_REL_COUNT, rootRelsXml, workbookRelsXml, workbookXml, } from "./workbook-xml.js";
32
- import { worksheetRelsXml, worksheetXml, } from "./worksheet-xml.js";
33
- export { buildColumnDefaults, Extent, renderRow, } from "./worksheet-xml.js";
17
+ import { DEFAULT_THEME_XML } from '../../core/theme.js';
18
+ import { AuthoringError } from '../../errors.js';
19
+ import { THEME_PART_PATH } from '../opc/part-paths.js';
20
+ import { relsPartXml } from '../opc/rels.js';
21
+ import { collectComments, commentsXml, vmlDrawingXml } from './comments.js';
22
+ import { collectHyperlinks, planHyperlinks } from './hyperlinks.js';
23
+ import { drawingRelsXml, drawingXml } from './images.js';
24
+ import { planMedia, planPreservedParts, SheetRelIds, } from './package-plan.js';
25
+ import { pivotCacheDefinitionXml, pivotCacheRecordsXml, pivotTableXml } from './pivot.js';
26
+ import { REL } from './relationships.js';
27
+ import { SharedStringTable } from './shared-strings.js';
28
+ import { StyleRegistry } from './styles.js';
29
+ import { tableXml } from './tables.js';
30
+ import { personsXml, threadedCommentsXml } from './threaded-comments.js';
31
+ import { appPropsXml, contentTypesXml, corePropsXml, FIXED_WORKBOOK_REL_COUNT, rootRelsXml, workbookRelsXml, workbookXml, } from './workbook-xml.js';
32
+ import { worksheetRelsXml, worksheetXml, } from './worksheet-xml.js';
33
+ export { buildColumnDefaults, Extent, renderRow, } from './worksheet-xml.js';
34
34
  /**
35
35
  * Serialise a workbook into an `.xlsx` package.
36
36
  *
37
- * @throws {@link AuthoringError} if the workbook has no worksheets (a zero-sheet package is corrupt),
37
+ * @throws {AuthoringError} if the workbook has no worksheets (a zero-sheet package is corrupt),
38
38
  * or holds a value the writer cannot yet represent.
39
39
  */
40
40
  export function writeXlsx(workbook, options = {}) {
@@ -55,7 +55,7 @@ export function writeXlsx(workbook, options = {}) {
55
55
  * no worker can take, and the reader's zip-bomb ceiling is enforced by counting output between
56
56
  * synchronous input slices. See ADR-0024.
57
57
  *
58
- * @throws {@link AuthoringError} — as a rejection — under the same conditions as {@link writeXlsx};
58
+ * @throws {AuthoringError} — as a rejection — under the same conditions as {@link writeXlsx};
59
59
  * the part-building it shares happens before any worker is involved. A failure raised by the zip
60
60
  * layer itself (including an environment that cannot spawn a worker) propagates unwrapped, exactly
61
61
  * as it does from {@link writeXlsx}.
@@ -135,7 +135,7 @@ function resolveSheetReferences(plan) {
135
135
  * streaming writer can drive the identical parts through a streamed zip container rather than
136
136
  * `zipSync`. Neither writer duplicates a byte of serialisation.
137
137
  *
138
- * @throws {@link AuthoringError} if the workbook has no worksheets, or holds a value the writer cannot represent.
138
+ * @throws {AuthoringError} if the workbook has no worksheets, or holds a value the writer cannot represent.
139
139
  */
140
140
  export function buildPackageParts(workbook, options = {}) {
141
141
  const sheets = workbook.worksheets;
@@ -1,4 +1,4 @@
1
- import { X14_NS } from "./namespaces.js";
1
+ import { X14_NS } from './namespaces.js';
2
2
  /**
3
3
  * Wrap an x14 extension body in the `<ext>` envelope every worksheet- and workbook-level x14
4
4
  * extension shares: a `uri` scoping the extension to its feature (a fixed GUID from
@@ -10,7 +10,7 @@
10
10
  // Unlike the reader, this is not a hostile-input path: we are the producer. It still validates its
11
11
  // contract (name length, sibling-name uniqueness, size bound) and fails closed with VbaAuthorError,
12
12
  // because a silently malformed container would surface far downstream as an unopenable workbook.
13
- import { VbaAuthorError } from "./errors.js";
13
+ import { VbaAuthorError } from './errors.js';
14
14
  const SECTOR = 512;
15
15
  const MINI_SECTOR = 64;
16
16
  const MINI_CUTOFF = 4096;
package/dist/vba/cfb.js CHANGED
@@ -9,7 +9,7 @@
9
9
  // It parses an untrusted blob, so every sector index, chain, and stream size is bounds-checked against
10
10
  // the file and every chain walk is cycle-guarded. A malformed container fails closed with a
11
11
  // VbaParseError instead of reading out of bounds, looping forever, or over-allocating.
12
- import { VbaParseError } from "./errors.js";
12
+ import { VbaParseError } from './errors.js';
13
13
  // Sector values 0xFFFFFFFA..0xFFFFFFFF are reserved markers (DIFSECT/FATSECT/ENDOFCHAIN/FREESECT), not
14
14
  // data-sector indices; any value at or above this is chain-terminal. Directory-tree links reuse the same
15
15
  // convention: NOSTREAM (0xFFFFFFFF) and any value at or above the ceiling mean "no such sibling/child".
@@ -1,7 +1,7 @@
1
1
  // The VBA project stores module names and source as MBCS bytes in the project code page
2
2
  // (`PROJECTCODEPAGE`, [MS-OVBA] 2.3.4.2). To recover text we decode those bytes with the matching
3
3
  // encoding rather than assuming latin1 — a CJK or Cyrillic project would otherwise mojibake.
4
- import { VbaAuthorError, VbaParseError } from "./errors.js";
4
+ import { VbaAuthorError, VbaParseError } from './errors.js';
5
5
  // Windows code-page numbers → the WHATWG encoding label `TextDecoder` understands. Node's built-in
6
6
  // ICU covers all of these. Only the code pages a VBA project realistically declares are listed; an
7
7
  // unlisted one falls back to windows-1252 (the overwhelmingly common Western-European default) so a
@@ -1,4 +1,4 @@
1
- import { XlsxError } from "../errors.js";
1
+ import { XlsxError } from '../errors.js';
2
2
  /**
3
3
  * Thrown when a VBA project (`vbaProject.bin`) is present but cannot be parsed — a malformed
4
4
  * compound file, a corrupt compressed stream, or a `dir` record that does not conform to [MS-OVBA].
package/dist/vba/index.js CHANGED
@@ -8,8 +8,8 @@
8
8
  // is a projection over bytes the model preserves opaquely on round-trip. For the design invariants and
9
9
  // the wider VBA feature map see the ADRs: read view (docs/decisions/0016), authoring (0017/0019), and
10
10
  // structural edits (0018/0019), plus docs/knowledge/specs/xlsm-macro-preservation.md.
11
- export { writeCompoundFile, } from "./cfb-writer.js";
12
- export { VbaAuthorError, VbaParseError } from "./errors.js";
13
- export { compressContainer, decompressContainer } from "./ms-ovba.js";
14
- export { parseVbaProject, VBA_PROJECT_CONTENT_TYPE, VBA_PROJECT_PART_PATH, VBA_PROJECT_REL_TYPE, vbaProjectSignatureKind, } from "./project.js";
15
- export { addVbaReference, removeVbaModule, } from "./project-editor.js";
11
+ export { writeCompoundFile, } from './cfb-writer.js';
12
+ export { VbaAuthorError, VbaParseError } from './errors.js';
13
+ export { compressContainer, decompressContainer } from './ms-ovba.js';
14
+ export { parseVbaProject, VBA_PROJECT_CONTENT_TYPE, VBA_PROJECT_PART_PATH, VBA_PROJECT_REL_TYPE, vbaProjectSignatureKind, } from './project.js';
15
+ export { addVbaReference, removeVbaModule, } from './project-editor.js';
@@ -11,7 +11,7 @@
11
11
  // fails closed with a VbaParseError rather than over-allocating, looping, or reading out of bounds. The
12
12
  // compressor is the authoring inverse — it is fed our own bytes, and its output re-expands to the input
13
13
  // byte-for-byte (the round-trip is the correctness contract).
14
- import { VbaParseError } from "./errors.js";
14
+ import { VbaParseError } from './errors.js';
15
15
  // A decompressed chunk covers at most 4096 bytes; both directions honour this window ([MS-OVBA]
16
16
  // 2.4.1.3.6). The chunk header's bits 12-14 carry a fixed 0b011 signature, bit 15 the compressed flag.
17
17
  const MAX_CHUNK_DECOMPRESSED = 4096;
@@ -9,13 +9,13 @@
9
9
  // p-code — so source authoring/editing lives in the offline `tools/vba-compiler` (VBIDE), not in this
10
10
  // pure-TS path (ADR 0019). These splices are safe precisely because they leave every module's p-code
11
11
  // exactly as its own compiler wrote it.
12
- import { CompoundFile } from "./cfb.js";
13
- import { writeCompoundFile } from "./cfb-writer.js";
14
- import { decoderForCodePage, encoderForCodePage } from "./codepage.js";
15
- import { VbaAuthorError, VbaParseError } from "./errors.js";
16
- import { compressContainer, decompressContainer } from "./ms-ovba.js";
17
- import { parseVbaProject } from "./project.js";
18
- import { push, u16, u32, utf16le, validateVbaName } from "./vba-encoding.js";
12
+ import { CompoundFile } from './cfb.js';
13
+ import { writeCompoundFile } from './cfb-writer.js';
14
+ import { decoderForCodePage, encoderForCodePage } from './codepage.js';
15
+ import { VbaAuthorError, VbaParseError } from './errors.js';
16
+ import { compressContainer, decompressContainer } from './ms-ovba.js';
17
+ import { parseVbaProject } from './project.js';
18
+ import { push, u16, u32, utf16le, validateVbaName } from './vba-encoding.js';
19
19
  const DIR_STREAM = 'dir';
20
20
  const PROJECT_STREAM = 'PROJECT';
21
21
  const PROJECTWM_STREAM = 'PROJECTwm';
@@ -5,10 +5,10 @@
5
5
  // where the compressed source text begins — past the p-code / PerformanceCache. We decompress `dir`,
6
6
  // read those facts, then decompress each module stream from its text offset and decode with the
7
7
  // project code page. The p-code is version-specific and deliberately not exposed; a reader wants source.
8
- import { CompoundFile } from "./cfb.js";
9
- import { decoderForCodePage } from "./codepage.js";
10
- import { VbaParseError } from "./errors.js";
11
- import { decompressContainer } from "./ms-ovba.js";
8
+ import { CompoundFile } from './cfb.js';
9
+ import { decoderForCodePage } from './codepage.js';
10
+ import { VbaParseError } from './errors.js';
11
+ import { decompressContainer } from './ms-ovba.js';
12
12
  // The OPC packaging identity of a workbook's VBA project — the relationship Type URI Excel wires it
13
13
  // under, the content type its `.bin` part declares, and the canonical package path. These are the
14
14
  // facts an authoring path needs to attach a macro blob so the writer emits a valid macro-enabled
@@ -5,7 +5,7 @@
5
5
  // on open — a module runs the compiled p-code it ships — so authoring/editing module SOURCE is done by
6
6
  // the offline `tools/vba-compiler` (VBIDE), which produces genuinely compiled p-code. This module holds
7
7
  // only what the pure-TS structural edits (remove module, add reference) still need (ADR 0019).
8
- import { VbaAuthorError } from "./errors.js";
8
+ import { VbaAuthorError } from './errors.js';
9
9
  const IDENTIFIER = /^[A-Za-z][A-Za-z0-9_]*$/;
10
10
  const MAX_NAME_CHARS = 31; // the CFB stream-name limit, and VBA's own module-name limit
11
11
  /**
@@ -1,4 +1,4 @@
1
- import { XlsxError } from "../errors.js";
1
+ import { XlsxError } from '../errors.js';
2
2
  /**
3
3
  * Thrown when XML text cannot be scanned into parse events — an unterminated tag, comment, CDATA
4
4
  * section, markup declaration or processing instruction.
@@ -10,7 +10,7 @@
10
10
  // entities and numeric character references are recognised; DTDs and `<!ENTITY>`
11
11
  // definitions are skipped, so entity-expansion (billion-laughs) and external-entity
12
12
  // (XXE) attacks are structurally impossible here, not merely mitigated.
13
- import { XmlParseError } from "./errors.js";
13
+ import { XmlParseError } from './errors.js';
14
14
  const PREDEFINED_ENTITIES = {
15
15
  amp: '&',
16
16
  lt: '<',
package/dist/xml/xml.js CHANGED
@@ -5,7 +5,7 @@
5
5
  // path. Escaping is the one hard, security-relevant requirement — an unescaped `<`,
6
6
  // `&`, or `"` produces a malformed package a consumer rejects — so it lives here,
7
7
  // audited once, rather than sprinkled through the part emitters.
8
- import { AuthoringError } from "../errors.js";
8
+ import { AuthoringError } from '../errors.js';
9
9
  const TEXT_ESCAPES = {
10
10
  '&': '&amp;',
11
11
  '<': '&lt;',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shbernal/ts-xlsx",
3
- "version": "1.0.0",
3
+ "version": "1.0.3",
4
4
  "description": "A TypeScript-first library for reading and writing xlsx (OOXML) spreadsheets.",
5
5
  "license": "MIT",
6
6
  "author": "shbernal",
@@ -74,6 +74,7 @@
74
74
  "constitution:check": "node scripts/check-constitution.ts",
75
75
  "layering:check": "node scripts/check-layering.ts",
76
76
  "entries:check": "node scripts/check-entries.ts",
77
+ "source-text:check": "node scripts/check-source-text.ts",
77
78
  "lint": "biome check --error-on-warnings src scripts test tools",
78
79
  "lint:fix": "biome check --write --error-on-warnings src scripts test tools",
79
80
  "format": "biome format --write src scripts test tools",
@@ -112,6 +113,6 @@
112
113
  "@types/node": "^24.13.3",
113
114
  "jszip": "^3.10.1",
114
115
  "lefthook": "^2.1.10",
115
- "typescript": "^6.0.3"
116
+ "typescript": "^7.0.2"
116
117
  }
117
118
  }