@shbernal/ts-xlsx 3.2.2-next.31.ga6df6f9 → 3.2.2-next.32.g433defc
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/core/autofilter.js +4 -3
- package/dist/customui/ribbon.js +3 -5
- package/dist/io/csv/read.js +1 -2
- package/dist/io/style/xf-style.js +1 -1
- package/dist/io/xlsb/primitives.d.ts +1 -1
- package/dist/io/xlsb/primitives.js +1 -3
- package/dist/io/xlsb/read.d.ts +2 -3
- package/dist/io/xlsb/read.js +1 -1
- package/dist/io/xlsx/comments.js +2 -3
- package/dist/io/xlsx/pivot.js +6 -2
- package/dist/vba/project-editor.js +2 -2
- package/dist/xml/xml-scan.js +2 -6
- package/package.json +2 -3
package/dist/core/autofilter.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AuthoringError, quoted } from '../errors.js';
|
|
1
|
+
import { AuthoringError, InternalError, quoted } from '../errors.js';
|
|
2
2
|
import { tokenSet } from '../token-set.js';
|
|
3
3
|
import { boundedRect, decodeRange, encodeRect } from './address.js';
|
|
4
4
|
import { isDeletedSpan, shiftIndex, shiftRect } from './grid-shift.js';
|
|
@@ -44,8 +44,9 @@ function canonicalizeColumn(column, width) {
|
|
|
44
44
|
}
|
|
45
45
|
export function shiftAutoFilter(filter, splice) {
|
|
46
46
|
const rect = boundedRect(decodeRange(filter.ref));
|
|
47
|
-
if (rect === undefined)
|
|
48
|
-
|
|
47
|
+
if (rect === undefined) {
|
|
48
|
+
throw new InternalError(`stored autofilter range ${quoted(filter.ref)} is not a bounded rectangle`);
|
|
49
|
+
}
|
|
49
50
|
const moved = shiftRect(rect, splice);
|
|
50
51
|
if (moved === undefined)
|
|
51
52
|
return undefined;
|
package/dist/customui/ribbon.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { strFromU8 } from 'fflate';
|
|
2
2
|
import { isRelType } from '../rel-type.js';
|
|
3
3
|
import { tokenSet } from '../token-set.js';
|
|
4
|
+
import { XmlParseError } from '../xml/errors.js';
|
|
4
5
|
import { boolStrict, localName, xmlEvents } from '../xml/xml-scan.js';
|
|
5
6
|
import { CustomUiParseError } from './errors.js';
|
|
6
7
|
export const CUSTOMUI_2006_NAMESPACE = 'http://schemas.microsoft.com/office/2006/01/customui';
|
|
@@ -38,10 +39,9 @@ export function parseCustomUi(input) {
|
|
|
38
39
|
root = buildTree(xml);
|
|
39
40
|
}
|
|
40
41
|
catch (error) {
|
|
41
|
-
if (error instanceof
|
|
42
|
+
if (!(error instanceof XmlParseError))
|
|
42
43
|
throw error;
|
|
43
|
-
|
|
44
|
-
throw new CustomUiParseError(`malformed customUI XML: ${detail}`, { cause: error });
|
|
44
|
+
throw new CustomUiParseError(`malformed customUI XML: ${error.message}`, { cause: error });
|
|
45
45
|
}
|
|
46
46
|
const customUi = findChild(root, 'customUI');
|
|
47
47
|
if (customUi === undefined) {
|
|
@@ -104,8 +104,6 @@ function buildTree(xml) {
|
|
|
104
104
|
for (const event of xmlEvents(xml)) {
|
|
105
105
|
if (event.kind === 'open') {
|
|
106
106
|
const parent = stack[stack.length - 1];
|
|
107
|
-
if (parent === undefined)
|
|
108
|
-
throw new CustomUiParseError('unbalanced customUI markup');
|
|
109
107
|
const el = {
|
|
110
108
|
name: event.name,
|
|
111
109
|
local: localName(event.name),
|
package/dist/io/csv/read.js
CHANGED
|
@@ -90,8 +90,7 @@ function defaultCsvCoerce(field) {
|
|
|
90
90
|
const numeric = NUMERIC.exec(field);
|
|
91
91
|
if (numeric) {
|
|
92
92
|
const value = Number(field);
|
|
93
|
-
const exact =
|
|
94
|
-
Math.abs(value) <= Number.MAX_SAFE_INTEGER &&
|
|
93
|
+
const exact = Math.abs(value) <= Number.MAX_SAFE_INTEGER &&
|
|
95
94
|
significantDigits(numeric[1] ?? '') <= MAX_EXACT_SIGNIFICANT_DIGITS;
|
|
96
95
|
return exact ? value : field;
|
|
97
96
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Color } from '../../core/style.ts';
|
|
2
|
-
import {
|
|
2
|
+
import type { ErrorCode } from '../../core/value.ts';
|
|
3
3
|
/** The `Cell` structure ([MS-XLSB] 2.5.10) every cell record opens with. */
|
|
4
4
|
export interface CellHeader {
|
|
5
5
|
/** Zero-based column index. */
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { decodeUtf16le } from '../../bytes.js';
|
|
2
|
-
import { isErrorCode } from '../../core/value.js';
|
|
3
2
|
import { hex } from '../../hex.js';
|
|
4
3
|
import { XlsbParseError } from './errors.js';
|
|
5
4
|
const NULL_STRING_LENGTH = 0xffffffff;
|
|
@@ -104,8 +103,7 @@ export class RecordReader {
|
|
|
104
103
|
}
|
|
105
104
|
}
|
|
106
105
|
export function errorCodeFor(code) {
|
|
107
|
-
|
|
108
|
-
return text !== undefined && isErrorCode(text) ? text : undefined;
|
|
106
|
+
return BERR_CODES.get(code);
|
|
109
107
|
}
|
|
110
108
|
const BERR_CODES = new Map([
|
|
111
109
|
[0x00, '#NULL!'],
|
package/dist/io/xlsb/read.d.ts
CHANGED
|
@@ -17,7 +17,6 @@ export declare function readXlsb(data: Uint8Array, options?: ReadPackageOptions)
|
|
|
17
17
|
* `.xlsx` reader can hand over a package it has already inflated and classified, rather than
|
|
18
18
|
* inflating the same bytes twice.
|
|
19
19
|
*
|
|
20
|
-
* `documentPath` is where the package's own `_rels/.rels` says its workbook lives
|
|
21
|
-
* conventional path for a caller holding nothing but the parts.
|
|
20
|
+
* `documentPath` is where the package's own `_rels/.rels` says its workbook lives.
|
|
22
21
|
*/
|
|
23
|
-
export declare function readXlsbPackage(files: Record<string, Uint8Array>, documentPath
|
|
22
|
+
export declare function readXlsbPackage(files: Record<string, Uint8Array>, documentPath: string): Workbook;
|
package/dist/io/xlsb/read.js
CHANGED
|
@@ -24,7 +24,7 @@ export function readXlsb(data, options = {}) {
|
|
|
24
24
|
}
|
|
25
25
|
return readXlsbPackage(files, documentPath);
|
|
26
26
|
}
|
|
27
|
-
export function readXlsbPackage(files, documentPath
|
|
27
|
+
export function readXlsbPackage(files, documentPath) {
|
|
28
28
|
const { partText, partBytes } = packageAccessors(files);
|
|
29
29
|
const workbookPart = partBytes(documentPath);
|
|
30
30
|
if (workbookPart === undefined) {
|
package/dist/io/xlsx/comments.js
CHANGED
|
@@ -6,9 +6,8 @@ export function collectComments(cells, threads, alreadyCollected = []) {
|
|
|
6
6
|
const anchored = new Set(fallbacks.map((fallback) => fallback.ref));
|
|
7
7
|
const comments = [...fallbacks, ...alreadyCollected];
|
|
8
8
|
for (const cell of cells) {
|
|
9
|
-
if (cell.note
|
|
10
|
-
|
|
11
|
-
comments.push(noteOn(cell, cell.note));
|
|
9
|
+
if (cell.note !== undefined)
|
|
10
|
+
comments.push(noteOn(cell, cell.note));
|
|
12
11
|
}
|
|
13
12
|
return comments
|
|
14
13
|
.filter((comment) => comment.threadId !== undefined || !anchored.has(comment.ref))
|
package/dist/io/xlsx/pivot.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { encodeAddress } from '../../core/address.js';
|
|
2
|
+
import { InternalError } from '../../errors.js';
|
|
2
3
|
import { escapeAttr, numberText, XML_DECLARATION } from '../../xml/xml.js';
|
|
3
4
|
import { RELATIONSHIPS_NS } from '../opc/namespaces.js';
|
|
4
5
|
import { SPREADSHEETML_NS } from './namespaces.js';
|
|
@@ -46,8 +47,11 @@ export function pivotCacheRecordsXml(table) {
|
|
|
46
47
|
`</pivotCacheRecords>`);
|
|
47
48
|
}
|
|
48
49
|
export function pivotTableXml(table, name, cacheId) {
|
|
49
|
-
const rowField = table.rowFields
|
|
50
|
-
const columnField = table.columnFields
|
|
50
|
+
const [rowField] = table.rowFields;
|
|
51
|
+
const [columnField] = table.columnFields;
|
|
52
|
+
if (rowField === undefined || columnField === undefined) {
|
|
53
|
+
throw new InternalError('a pivot table reached the writer with no row or column field');
|
|
54
|
+
}
|
|
51
55
|
const rowGroups = table.cacheFields[rowField]?.sharedItems?.length ?? 1;
|
|
52
56
|
const columnGroups = table.cacheFields[columnField]?.sharedItems?.length ?? 1;
|
|
53
57
|
const location = `A1:${encodeAddress(2 + columnGroups, 3 + rowGroups)}`;
|
|
@@ -146,7 +146,7 @@ function removeModuleDirRecord(dir, streamName, decoder) {
|
|
|
146
146
|
}
|
|
147
147
|
if (countAt < 0)
|
|
148
148
|
throw new VbaParseError('dir stream is missing MODULES_COUNT');
|
|
149
|
-
if (removeStart < 0
|
|
149
|
+
if (removeStart < 0) {
|
|
150
150
|
throw new VbaParseError(`module stream ${quoted(streamName)} not found in the dir stream`);
|
|
151
151
|
}
|
|
152
152
|
if (countAt >= removeStart) {
|
|
@@ -214,7 +214,7 @@ function removeProjectwmRecord(wm, existingModuleCount, name, decoder) {
|
|
|
214
214
|
removeEnd = pos;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
if (removeStart < 0
|
|
217
|
+
if (removeStart < 0) {
|
|
218
218
|
throw new VbaParseError(`module ${quoted(name)} not found in the PROJECTwm stream`);
|
|
219
219
|
}
|
|
220
220
|
return spliceBytes(wm, removeStart, removeEnd);
|
package/dist/xml/xml-scan.js
CHANGED
|
@@ -166,15 +166,11 @@ export function* xmlEvents(source) {
|
|
|
166
166
|
while (i < length) {
|
|
167
167
|
const lt = source.indexOf('<', i);
|
|
168
168
|
if (lt === -1) {
|
|
169
|
-
|
|
170
|
-
if (chunk.length > 0)
|
|
171
|
-
yield { kind: 'text', text: admitText(normalizeLineEndings(chunk)) };
|
|
169
|
+
yield { kind: 'text', text: admitText(normalizeLineEndings(source.slice(i))) };
|
|
172
170
|
return;
|
|
173
171
|
}
|
|
174
172
|
if (lt > i) {
|
|
175
|
-
|
|
176
|
-
if (chunk.length > 0)
|
|
177
|
-
yield { kind: 'text', text: admitText(normalizeLineEndings(chunk)) };
|
|
173
|
+
yield { kind: 'text', text: admitText(normalizeLineEndings(source.slice(i, lt))) };
|
|
178
174
|
}
|
|
179
175
|
const markup = markupAt(source, lt);
|
|
180
176
|
if (markup !== undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shbernal/ts-xlsx",
|
|
3
|
-
"version": "3.2.2-next.
|
|
3
|
+
"version": "3.2.2-next.32.g433defc",
|
|
4
4
|
"description": "A TypeScript-first library for reading and writing xlsx (OOXML) spreadsheets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"csv",
|
|
@@ -92,7 +92,6 @@
|
|
|
92
92
|
"corpus-blind:check": "node scripts/check-corpus-blind.ts",
|
|
93
93
|
"entries:check": "node scripts/check-entries.ts",
|
|
94
94
|
"public-types:check": "node scripts/check-public-types.ts",
|
|
95
|
-
"facet-register:check": "node scripts/check-facet-register.ts",
|
|
96
95
|
"tsconfig-coverage:check": "node scripts/check-tsconfig-coverage.ts",
|
|
97
96
|
"browser:check": "node scripts/check-browser-safe.ts",
|
|
98
97
|
"source-text:check": "node scripts/check-source-text.ts",
|
|
@@ -117,7 +116,7 @@
|
|
|
117
116
|
"verify": "node scripts/verify.ts --full",
|
|
118
117
|
"verify:quick": "node scripts/verify.ts --quick",
|
|
119
118
|
"test": "node scripts/verify.ts --full",
|
|
120
|
-
"prepublishOnly": "pnpm run
|
|
119
|
+
"prepublishOnly": "pnpm run test && pnpm run smoke:dist",
|
|
121
120
|
"validate:ooxml": "ooxml-validate",
|
|
122
121
|
"test:ooxml": "node test/ooxml-validation/run.ts"
|
|
123
122
|
},
|