@xlsx-editor.dev/core 0.0.0-placeholder.0 → 0.1.0-beta.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 (55) hide show
  1. package/LICENSE +217 -0
  2. package/README.md +254 -2
  3. package/THIRD_PARTY_NOTICES.md +78 -0
  4. package/dist/automation.d.ts +299 -0
  5. package/dist/automation.js +42 -0
  6. package/dist/builtins-nmHrq2Et.d.ts +37 -0
  7. package/dist/cascade.d.ts +196 -0
  8. package/dist/cascade.js +60 -0
  9. package/dist/cell-format-DW8yF-c-.d.ts +226 -0
  10. package/dist/chunk-2DLJYRJC.js +3171 -0
  11. package/dist/chunk-2ZU4337U.js +204 -0
  12. package/dist/chunk-44L37ENZ.js +8219 -0
  13. package/dist/chunk-77N55BLP.js +911 -0
  14. package/dist/chunk-7PV5HQPE.js +84 -0
  15. package/dist/chunk-E4VJJ556.js +756 -0
  16. package/dist/chunk-KG4IL4JI.js +436 -0
  17. package/dist/chunk-PLDK4XO6.js +9125 -0
  18. package/dist/chunk-PRHLYXHL.js +1699 -0
  19. package/dist/chunk-TE4FXG5T.js +3156 -0
  20. package/dist/contracts.d.ts +32 -0
  21. package/dist/contracts.js +0 -0
  22. package/dist/dist-C7NLNUMD.js +2850 -0
  23. package/dist/editor.d.ts +3167 -0
  24. package/dist/editor.js +309 -0
  25. package/dist/harfbuzz-measurer-CkKfsEyu.d.ts +128 -0
  26. package/dist/harfbuzz.wasm +0 -0
  27. package/dist/index.d.ts +11 -0
  28. package/dist/index.js +309 -0
  29. package/dist/layout.d.ts +111 -0
  30. package/dist/layout.js +104 -0
  31. package/dist/merge-commands-DthcNpfw.d.ts +53 -0
  32. package/dist/node-module-shim-LQXGL47O.js +18 -0
  33. package/dist/ops-CfUCjyph.d.ts +629 -0
  34. package/dist/output.d.ts +177 -0
  35. package/dist/output.js +29 -0
  36. package/dist/sheet-index-P5vevMWX.d.ts +52 -0
  37. package/dist/sheet-layout-D9M_4EBn.d.ts +494 -0
  38. package/dist/sheet-protection-D8goxm58.d.ts +209 -0
  39. package/dist/store.d.ts +615 -0
  40. package/dist/store.js +272 -0
  41. package/dist/theme-BprDji6x.d.ts +16 -0
  42. package/dist/units-D6CD_A5I.d.ts +13 -0
  43. package/dist/workbook-index-DsbeR8Kb.d.ts +294 -0
  44. package/licenses/Emscripten-LICENSE.txt +102 -0
  45. package/licenses/HarfBuzz-COPYING.txt +42 -0
  46. package/licenses/HarfBuzz-USE-MIT.txt +21 -0
  47. package/licenses/HarfBuzz-source-notices.txt +4508 -0
  48. package/licenses/README.md +19 -0
  49. package/licenses/Unicode-LICENSE.txt +39 -0
  50. package/licenses/compiler-rt-LICENSE.txt +311 -0
  51. package/licenses/harfbuzz-manifest.json +84 -0
  52. package/licenses/musl-COPYRIGHT.txt +193 -0
  53. package/package.json +79 -6
  54. package/src/styles/editor.css +1933 -0
  55. package/src/styles/editor.css.d.ts +2 -0
@@ -0,0 +1,629 @@
1
+ import { P as PackagePart, X as XlsxPackage, E as Element, a as XmlPart } from './workbook-index-DsbeR8Kb.js';
2
+
3
+ /** The border lines that a patch draws (`ST_BorderStyle`, Part 1, 18.18.3). */
4
+ declare const PATCH_BORDER_STYLES: readonly ['thin', 'medium', 'thick', 'dashed', 'dotted', 'double'];
5
+ type PatchBorderStyle = (typeof PATCH_BORDER_STYLES)[number];
6
+ /** `ST_HorizontalAlignment` (Part 1, 18.18.40). */
7
+ declare const PATCH_HORIZONTAL: readonly ['general', 'left', 'center', 'right', 'fill', 'justify', 'centerContinuous', 'distributed'];
8
+ type PatchHorizontal = (typeof PATCH_HORIZONTAL)[number];
9
+ /** `ST_VerticalAlignment` (Part 1, 18.18.88). */
10
+ declare const PATCH_VERTICAL: readonly ['top', 'center', 'bottom', 'justify', 'distributed'];
11
+ type PatchVertical = (typeof PATCH_VERTICAL)[number];
12
+ /**
13
+ * The cell format properties that one command sets. An absent property keeps each cell's own
14
+ * value. Colors are `RRGGBB` hex digits.
15
+ */
16
+ interface FormatPatch {
17
+ readonly bold?: boolean;
18
+ readonly italic?: boolean;
19
+ /** A single underline, or none. */
20
+ readonly underline?: boolean;
21
+ /** The font family. Setting it drops the theme font scheme of the cell's font. */
22
+ readonly fontName?: string;
23
+ /**
24
+ * The font size in points, 1 to 409. The range is an engine limit: `x:sz/@val` (`CT_FontSize`,
25
+ * sml.xsd) is an `xsd:double` with no bound.
26
+ */
27
+ readonly fontSize?: number;
28
+ readonly fontColor?: string;
29
+ /** A solid fill of one color, or no fill. */
30
+ readonly fill?: {
31
+ readonly type: 'solid';
32
+ readonly color: string;
33
+ } | {
34
+ readonly type: 'none';
35
+ };
36
+ /**
37
+ * Borders: `outline` draws the edges of the range, `all` draws every edge of every cell, and
38
+ * `none` removes every edge and the diagonal. `style` is `thin` when absent; `color` is the
39
+ * automatic color when absent.
40
+ */
41
+ readonly borders?: {
42
+ readonly edges: 'outline' | 'all' | 'none';
43
+ readonly style?: PatchBorderStyle;
44
+ readonly color?: string;
45
+ };
46
+ readonly horizontal?: PatchHorizontal;
47
+ readonly vertical?: PatchVertical;
48
+ readonly wrapText?: boolean;
49
+ /**
50
+ * A built-in number format by id (0 to 163), or a custom format code. A custom code that a
51
+ * number format of the styles part already holds reuses its id; a new code gets the lowest
52
+ * unused id from 164 up. Give one of `id` and `code`. A patch that gives both is refused
53
+ * with `bad-format`.
54
+ */
55
+ readonly numberFormat?: {
56
+ readonly id: number;
57
+ readonly code?: never;
58
+ } | {
59
+ readonly code: string;
60
+ readonly id?: never;
61
+ };
62
+ }
63
+ /**
64
+ * The longest font name that a patch sets. Longer names are refused, not cut: 31 characters is
65
+ * the longest face name that the font tables of common systems hold. This is an engine limit:
66
+ * `x:name/@val` (`CT_FontName`, sml.xsd) is an `ST_Xstring` with no length limit.
67
+ */
68
+ declare const MAX_FONT_NAME_LENGTH = 31;
69
+ /**
70
+ * The longest custom number format code that the number format parser reads. This is an engine
71
+ * limit: `x:numFmt/@formatCode` is an `ST_Xstring` with no length limit.
72
+ *
73
+ * @public
74
+ */
75
+ declare const MAX_FORMAT_CODE_LENGTH = 255;
76
+ /** The custom number format ids start here (Part 1, 18.8.30). */
77
+ declare const FIRST_CUSTOM_NUMFMT_ID = 164;
78
+ /**
79
+ * Why a patch cannot be applied, or undefined. A patch that sets nothing is refused, so a
80
+ * command never writes an empty transaction that looks like an edit.
81
+ */
82
+ declare function patchProblem(patch: FormatPatch): string | undefined;
83
+ /** Which records of a cell format a patch changes. */
84
+ interface PatchGroups {
85
+ readonly font: boolean;
86
+ readonly fill: boolean;
87
+ readonly border: boolean;
88
+ readonly alignment: boolean;
89
+ readonly numFmt: boolean;
90
+ }
91
+ declare function patchGroups(patch: FormatPatch): PatchGroups;
92
+ /**
93
+ * The patch with its custom number format code lowered: a code that equals a built-in code
94
+ * becomes that built-in id, so the styles part gets no custom format for it. `defined` holds the
95
+ * `x:numFmt` codes of the workbook by id: when it gives the built-in id another code, the code
96
+ * stays a code, because the id would show that other code. A code that the number format
97
+ * parser cannot read is a problem (`unreadable-number-format`). Other values of the patch pass
98
+ * unchecked: `patchProblem` checks them.
99
+ */
100
+ declare function lowerNumberFormat(patch: FormatPatch, defined?: ReadonlyMap<number, string>): {
101
+ readonly patch: FormatPatch;
102
+ } | {
103
+ readonly problem: string;
104
+ };
105
+
106
+ /** One part to put back: an earlier revision of it, or `null` to remove it. */
107
+ interface PartRestore {
108
+ readonly partName: string;
109
+ readonly part: PackagePart | null;
110
+ }
111
+ /**
112
+ * Why every structural edit of the worksheet `sheet` is refused, whatever rows or columns it
113
+ * names, or undefined: the sheet is not a worksheet, a sheet has cells that the editor cannot
114
+ * read, or a blocker holds a reference that the edit would move (`blockers.ts`).
115
+ * The blockers do not depend on the edited rows or columns, so the editor reads this as the
116
+ * state of its structural commands. An edit that passes can still be refused by its own rows
117
+ * or columns, for example with `grid-full`. The drawing of the edited sheet refuses every edit
118
+ * when it cannot be read or relates to a part that can refer to cells (`drawingBlocker`). A
119
+ * hyperlink target that the edit moves can also
120
+ * refuse it (`moveHyperlinkTargets`): a fragment target with a `%` escape, or a hyperlink with
121
+ * both `@r:id` and `@location`, refuses only an edit that changes the place it names, so it
122
+ * depends on the rows or columns and is not part of this check. `applyStructure` runs the same
123
+ * check first.
124
+ */
125
+ declare function structureBlocker(pkg: XlsxPackage, sheet: string): OpRejection | undefined;
126
+
127
+ /** A value to store in a cell. `empty` clears the value and keeps the cell format. */
128
+ type CellInput = {
129
+ readonly type: 'number';
130
+ readonly value: number;
131
+ } | {
132
+ readonly type: 'string';
133
+ readonly value: string;
134
+ } | {
135
+ readonly type: 'boolean';
136
+ readonly value: boolean;
137
+ }
138
+ /**
139
+ * Formula text without the leading `=`. The store writes it as `x:f` with no cached value,
140
+ * in the form the tokenizer writes back (`normalizeFormula`), and refuses text that the
141
+ * tokenizer cannot read.
142
+ */
143
+ | {
144
+ readonly type: 'formula';
145
+ readonly text: string;
146
+ }
147
+ /**
148
+ * An ISO 8601 date or date-time (`2024-03-01`, `2024-03-01T12:30:00`), written as `t="d"`
149
+ * with the text as `x:v`. The cell keeps its format, which converts the date to a serial for
150
+ * display. Text that is not an ISO 8601 date is refused. The Transitional
151
+ * schema has no `d` value in `ST_CellType` (sml.xsd; ECMA-376 Part 1, 18.18.11).
152
+ */
153
+ | {
154
+ readonly type: 'date';
155
+ readonly iso: string;
156
+ } | {
157
+ readonly type: 'empty';
158
+ };
159
+ /** The names of the structural ops. */
160
+ type StructuralOpName = 'insertRows' | 'deleteRows' | 'insertColumns' | 'deleteColumns';
161
+ /** One structural op for each name, so that a check of `op` narrows the union. */
162
+ type StructuralOps = {
163
+ [K in StructuralOpName]: {
164
+ readonly op: K;
165
+ readonly sheet: string;
166
+ readonly start: number;
167
+ readonly count: number;
168
+ };
169
+ }[StructuralOpName];
170
+ /** One typed op. */
171
+ type WorkbookOp = {
172
+ readonly op: 'setCellValue';
173
+ readonly sheet: string;
174
+ readonly ref: string;
175
+ readonly value: CellInput;
176
+ }
177
+ /** Set `x:calcPr/@fullCalcOnLoad`. No inverse: undo never clears it. */
178
+ | {
179
+ readonly op: 'setFullCalcOnLoad';
180
+ }
181
+ /** Drop the calculation chain. No inverse: the chain is optional. */
182
+ | {
183
+ readonly op: 'dropCalcChain';
184
+ }
185
+ /**
186
+ * Set `x:dimension/@ref` of a worksheet that has an `x:dimension`. A write that creates a
187
+ * cell outside it widens it in the same op; this op is its inverse.
188
+ */
189
+ | {
190
+ readonly op: 'setDimension';
191
+ readonly sheet: string;
192
+ readonly ref: string;
193
+ }
194
+ /**
195
+ * Clear the values and formulas of the cells that exist in a range (`A1` or `A1:C3`), and keep
196
+ * their cell formats. Cells inside an array formula range refuse it; shared formula masters
197
+ * inside it are unshared first. The other refusals are the `shared-formula` cases
198
+ * of {@link OpRejection}.
199
+ */
200
+ | {
201
+ readonly op: 'clearValues';
202
+ readonly sheet: string;
203
+ readonly ref: string;
204
+ }
205
+ /**
206
+ * Apply a format patch to every cell of a range (`A1` or `A1:C3`): each cell gets its own cell
207
+ * format with the patch applied. The store reuses or appends the style records; cells that do
208
+ * not exist are created, at most `MAX_FORMAT_NEW_CELLS` of them (`format-range.ts`).
209
+ */
210
+ | {
211
+ readonly op: 'applyFormat';
212
+ readonly sheet: string;
213
+ readonly ref: string;
214
+ readonly patch: FormatPatch;
215
+ }
216
+ /**
217
+ * Remove the cell format (`@s`) of the cells that exist in a range, and keep their values. On a
218
+ * protected sheet, a cell keeps its protection: it gets format 0 with that protection. When a
219
+ * formula or a defined name calls `CELL` or a `GET.*` macro, the cached values become stale.
220
+ * When the record of that protection would pass the record limit of `x:cellXfs`, the op is
221
+ * refused with `style-limit`. When the styles part cannot be read, such as a part past a read
222
+ * limit that stays as bytes, the op still gives the default format 0. On a protected sheet, it
223
+ * is then refused with `unsupported-package`, because the protection of a cell is in the
224
+ * unread part.
225
+ */
226
+ | {
227
+ readonly op: 'clearFormats';
228
+ readonly sheet: string;
229
+ readonly ref: string;
230
+ }
231
+ /**
232
+ * Give one cell (`A1`) the cell format at `index` of `x:cellXfs`, and keep its value (design
233
+ * D2 of the change `workbook-structure-editing`): the format that an internal paste copies.
234
+ * An index that the workbook does not have is refused with `bad-format`. A cell with no
235
+ * `x:c` that already shows the format (from its row or column) stays absent, and an emptied
236
+ * cell that shows the format of its row or column goes away (`cell-format-index.ts`). On a
237
+ * protected sheet that does not allow formatting cells, a new format is refused with
238
+ * `locked` (`sheet-protection.ts`). On any protected sheet, a new format that changes the
239
+ * `@locked` or `@hidden` protection of the cell is refused with `locked` and the rule `cell`.
240
+ * When a formula or a defined name calls `CELL` or a `GET.*` macro, a changed cell format
241
+ * makes the cached values stale (`CELL("format")` reads it). When the styles part cannot be
242
+ * read, the op gives format 0 only, and any other index is refused with `unsupported-package`.
243
+ */
244
+ | {
245
+ readonly op: 'setCellFormatIndex';
246
+ readonly sheet: string;
247
+ readonly ref: string;
248
+ readonly index: number;
249
+ }
250
+ /**
251
+ * Insert or delete whole rows or columns of a worksheet: `start` is the 1-based
252
+ * number of the first row or column (`A` is 1), and `count` how many, at most the size of the
253
+ * grid. Every reference of the workbook moves with them, or the op is refused with a reason
254
+ * that names what holds the reference (`structure-blocked`) or the content that would leave
255
+ * the grid (`grid-full`). It is refused with `sheet-name-ambiguous`, with the other sheet as
256
+ * the subject, when a file gives the name of the sheet to another sheet too, in any case,
257
+ * and with `sheet-name-too-long`, with that name as the subject, when a stored sheet name has
258
+ * more than 31 characters. A hyperlink relationship target that is a fragment (`#Data!A5`)
259
+ * moves with the cells that it names. A formula or a defined name inside
260
+ * `mc:AlternateContent` whose text the edit would change refuses it with `structure-blocked`,
261
+ * because the editor does not rewrite each branch.
262
+ */
263
+ | StructuralOps
264
+ /**
265
+ * Add an empty worksheet named `name` at position `index` of the sheet list (0 is the first
266
+ * tab; the sheet count adds it at the end). A name that breaks the rules of a sheet name is
267
+ * refused with `sheet-name-invalid` or `sheet-name-taken`, and a position outside 0 to the sheet
268
+ * count with `bad-position`. Each sheet op is refused with `locked` (rule `workbook`) when
269
+ * `x:workbookProtection/@lockStructure` is true. Refused with `structure-blocked` when the add
270
+ * changes the position of the sheet that the `@localSheetId` of a defined name inside
271
+ * `mc:AlternateContent` names, because the editor does not rewrite each branch.
272
+ */
273
+ | {
274
+ readonly op: 'addSheet';
275
+ readonly name: string;
276
+ readonly index: number;
277
+ }
278
+ /**
279
+ * Rename a sheet, and rewrite each reference to it in every formula, defined name, and
280
+ * internal hyperlink location. Refused with `unknown-sheet` when no sheet has the name, with
281
+ * `sheet-name-invalid` or `sheet-name-taken` for the new name, with `structure-blocked`
282
+ * when other content names the sheet and the store does not rewrite it, and with
283
+ * `sheet-name-ambiguous` when another sheet has the same name without case and a reference
284
+ * names one of the two, and with `locked` when the workbook protection locks its structure.
285
+ * A formula or a defined name inside `mc:AlternateContent` that names the sheet is content
286
+ * that the store does not rewrite, so it refuses the rename with `structure-blocked`.
287
+ */
288
+ | {
289
+ readonly op: 'renameSheet';
290
+ readonly sheet: string;
291
+ readonly name: string;
292
+ }
293
+ /**
294
+ * Delete a sheet with its part, relationships, and override. Each reference to it becomes
295
+ * `#REF!`, and its sheet-scoped defined names go. Refused with `unknown-sheet` when no sheet
296
+ * has the name, with `last-sheet` when no visible sheet would be left, with
297
+ * `sheet-range-blocked` for a sheet range that starts or ends at the sheet, with
298
+ * `structure-blocked` for a related part, with `sheet-name-ambiguous` when another sheet
299
+ * has the same name without case, and with `locked` when the workbook protection locks its
300
+ * structure. Refused with `structure-blocked` when the delete would change a formula or a
301
+ * defined name inside `mc:AlternateContent`, or when it changes the position of the sheet that
302
+ * the `@localSheetId` of a defined name inside `mc:AlternateContent` names.
303
+ */
304
+ | {
305
+ readonly op: 'deleteSheet';
306
+ readonly sheet: string;
307
+ }
308
+ /**
309
+ * Move a sheet to position `index` of the sheet list. Sheet-scoped defined names and the
310
+ * active tab follow their sheets. A move to the same place changes nothing. Refused with
311
+ * `unknown-sheet` when no sheet has the name, with `bad-position` for a position outside
312
+ * the sheet list, with `sheet-range-blocked` for a sheet range whose span the move
313
+ * changes, and with `locked` when the workbook protection locks its structure. Refused with
314
+ * `structure-blocked` when the move changes the position of the sheet that the `@localSheetId`
315
+ * of a defined name inside `mc:AlternateContent` names.
316
+ */
317
+ | {
318
+ readonly op: 'moveSheet';
319
+ readonly sheet: string;
320
+ readonly index: number;
321
+ }
322
+ /**
323
+ * Set the width of the columns `first` to `last` (1-based, `A` is 1) to `width` characters,
324
+ * from 0 to 255, with `@customWidth`.
325
+ * The `x:col` elements that the range crosses split, and keep their other attributes. A
326
+ * width outside 0 to 255 is refused with `bad-size`, a range outside the grid with
327
+ * `bad-reference`, an unknown sheet with `unknown-sheet`, a resize that would change a drawing,
328
+ * control, or object anchor that keeps its size or position, or a resize of a sheet whose
329
+ * drawing part cannot be read, with `resize-anchor`, and a cell structure that the editor
330
+ * cannot change with `invalid-sheet` (`axis-size.ts`). On a protected sheet, it is refused
331
+ * with `locked` unless the protection allows formatting columns (`@formatColumns` is false).
332
+ */
333
+ | {
334
+ readonly op: 'setColumnWidth';
335
+ readonly sheet: string;
336
+ readonly first: number;
337
+ readonly last: number;
338
+ readonly width: number;
339
+ }
340
+ /**
341
+ * Set the height of the rows `first` to `last` (1-based) to `height` points, from 0 to 409,
342
+ * with `@customHeight`. A row with no `x:row` gets an empty one. A height outside 0 to 409 is
343
+ * refused with `bad-size`, a range outside the grid with `bad-reference`, an unknown sheet
344
+ * with `unknown-sheet`, a range that would create more than `MAX_RESIZE_NEW_ROWS` rows with
345
+ * `too-many-rows`, a resize that would change an anchor that keeps its size or position, or a
346
+ * resize of a sheet whose drawing part cannot be read, with `resize-anchor`, and rows out of
347
+ * order in `x:sheetData` with `invalid-sheet`. On a protected sheet, it is refused with
348
+ * `locked` unless the protection allows formatting rows (`@formatRows` is false).
349
+ */
350
+ | {
351
+ readonly op: 'setRowHeight';
352
+ readonly sheet: string;
353
+ readonly first: number;
354
+ readonly last: number;
355
+ readonly height: number;
356
+ }
357
+ /**
358
+ * Merge the range `ref` of a sheet into one cell (`x:mergeCell`, ECMA-376 Part 1, 18.3.1.54).
359
+ * The top-left cell keeps its value. A range where another cell holds a value or a formula is
360
+ * refused with `merge-drops-values`, so a caller clears those cells first in the same
361
+ * transaction; a range of one cell with `merge-one-cell`; and a range that meets a merged
362
+ * range with `merge-overlap` (`merge-cells.ts`). On a protected sheet, it is refused with
363
+ * `locked`.
364
+ */
365
+ | {
366
+ readonly op: 'mergeCells';
367
+ readonly sheet: string;
368
+ readonly ref: string;
369
+ }
370
+ /**
371
+ * Unmerge each merged range of a sheet that meets the range `ref`. A range that meets no
372
+ * merged range changes nothing. On a protected sheet, it is refused with `locked`.
373
+ */
374
+ | {
375
+ readonly op: 'unmergeCells';
376
+ readonly sheet: string;
377
+ readonly ref: string;
378
+ }
379
+ /**
380
+ * Set the width of each listed column (1-based `column`, ascending) to `width` characters, in
381
+ * one pass over `x:cols`, as `setColumnWidth` sets one range. An empty list, columns out of
382
+ * ascending order, or a column outside the grid is refused with `bad-reference`, a width
383
+ * outside 0 to 255 with `bad-size`, an unknown sheet with `unknown-sheet`, an `x:col` without
384
+ * a valid range with `invalid-sheet`, and a width change that meets an anchor that keeps its
385
+ * size or position with `resize-anchor`. Protection and stale values follow `setColumnWidth`.
386
+ * A fit to content uses it: the file stores a fitted width as a custom width (`@customWidth`),
387
+ * so no fitted form exists, unlike `setFittedRowHeights`. A list that changes no `x:col`
388
+ * attribute is no change. A column at its width that gains `@customWidth` or loses `@bestFit`
389
+ * changes the file, and no anchor refuses it.
390
+ */
391
+ | {
392
+ readonly op: 'setColumnWidths';
393
+ readonly sheet: string;
394
+ readonly columns: readonly {
395
+ readonly column: number;
396
+ readonly width: number;
397
+ }[];
398
+ }
399
+ /**
400
+ * Set each listed row (1-based `row`, ascending, each with an `x:row`) to the given height as
401
+ * a fitted height: `@ht` without `@customHeight`. An existing `@customHeight` goes, because a
402
+ * fitted height is not a height set by hand (18.3.1.73). One pass over `x:sheetData` sets every
403
+ * row. A row with no `x:row`, a row outside the grid, listed rows out of ascending order, or an
404
+ * empty list is refused with `bad-reference`, a height outside 0 to 409 with `bad-size`, an
405
+ * unknown sheet with `unknown-sheet`, rows out of order in `x:sheetData` with `invalid-sheet`,
406
+ * and a change that meets an anchor that keeps its size or position with `resize-anchor`: a new
407
+ * height, or the loss of a true `@customHeight` (`1` or `true`), after which a value edit gives
408
+ * the row its automatic height. Protection and stale values follow `setRowHeight`. A list that
409
+ * changes no `x:row` attribute is no change. A row at its height that loses a true
410
+ * `@customHeight` changes the file, and an anchor can refuse it.
411
+ */
412
+ | {
413
+ readonly op: 'setFittedRowHeights';
414
+ readonly sheet: string;
415
+ readonly rows: readonly {
416
+ readonly row: number;
417
+ readonly height: number;
418
+ }[];
419
+ };
420
+ /**
421
+ * The inverse ops: only undo and redo apply them, because they put back content of an earlier
422
+ * revision as it was, with no check of what it holds. `transact` refuses them, so no caller can
423
+ * write a part, a style list, or a row through them.
424
+ */
425
+ type InverseOp = {
426
+ /**
427
+ * Put back one row as it was: the inverse of an op that changed cells in it. `node` is a
428
+ * row element of an earlier revision, or `null` to remove the row.
429
+ */
430
+ readonly op: 'restoreRow';
431
+ readonly sheet: string;
432
+ /** 1-based row number. */
433
+ readonly row: number;
434
+ readonly node: Element | null;
435
+ }
436
+ /**
437
+ * Put back the styles part of an earlier revision, or remove the styles part that a later edit
438
+ * created (`null`): the inverse of a format edit that appended style records.
439
+ */
440
+ | {
441
+ readonly op: 'restoreStyles';
442
+ readonly part: XmlPart | null;
443
+ }
444
+ /**
445
+ * Put back parts of an earlier revision, or remove a part (`null`): the inverse of a
446
+ * structural edit, which rewrites references across the workbook.
447
+ */
448
+ | {
449
+ readonly op: 'restoreParts';
450
+ readonly parts: readonly PartRestore[];
451
+ };
452
+ /** An op that a history entry holds: a typed op or an inverse op. */
453
+ type HistoryOp = WorkbookOp | InverseOp;
454
+ /** Why an op or a transaction was refused. */
455
+ interface OpRejection {
456
+ readonly code: 'unknown-sheet' | 'bad-reference' | 'bad-value'
457
+ /** A text longer than a cell holds (`MAX_CELL_TEXT`). */
458
+ | 'text-too-long'
459
+ /** A column width or a row height outside its allowed values. */
460
+ | 'bad-size'
461
+ /** A merge of one cell: there is nothing to merge. */
462
+ | 'merge-one-cell'
463
+ /** A merge that meets a merged range. */
464
+ | 'merge-overlap'
465
+ /** A merge would drop a value or a formula outside the top-left cell of its range. */
466
+ | 'merge-drops-values'
467
+ /** A sheet position outside the sheet list. */
468
+ | 'bad-position' | 'invalid-sheet'
469
+ /**
470
+ * The edit would change a formula range that the store keeps whole: the cell is the master of,
471
+ * or inside, an array or data table formula range (its master can be inside
472
+ * `mc:AlternateContent`); or it is a shared formula master whose text cannot be read; or it is
473
+ * a shared master with a child whose `x:f` is inside `mc:AlternateContent` in its cell, which
474
+ * the unshare cannot rewrite; or the edit would move the formula of a shared child out of the
475
+ * grid. An edit to any other shared master unshares its children. The `subject` names the
476
+ * formula range that blocks the edit (`Sheet1!A2:A3`), or the cell when the range cannot be
477
+ * read; `causeCell` names the cell whose formula the editor cannot rewrite, for a shared
478
+ * master. A batch writes its cells in order, so a batch that writes a shared master before its
479
+ * wrapped child is refused. A cell with a formula inside `mc:AlternateContent` refuses its own
480
+ * edit or clear with `cell-alternate-content` first (`cellChildBlocker`).
481
+ */
482
+ | 'shared-formula'
483
+ /** Formula text that the reference tokenizer cannot read. */
484
+ | 'unreadable-formula'
485
+ /** Formula text with an operator, an operand, or a separator out of place. */
486
+ | 'formula-syntax'
487
+ /** Formula text in R1C1 notation: `x:f` holds A1 text only. */
488
+ | 'r1c1-formula'
489
+ /**
490
+ * Typed formula text that calls a function outside the predefined functions of ECMA-376
491
+ * Part 1, 18.17.7, such as a future function or a name with a stored-name prefix.
492
+ */
493
+ | 'unsupported-function'
494
+ /**
495
+ * Formula text that names a sheet, an external workbook index `[n]`, or a table that the
496
+ * workbook does not hold, or a sheet name with a space that is not quoted.
497
+ */
498
+ | 'unknown-formula-reference'
499
+ /** Text with a character that XML 1.0 cannot hold, such as a control character. */
500
+ | 'invalid-character' | 'unsupported-package'
501
+ /**
502
+ * A value edit, a paste, a clear, or a cut of a cell that holds another form of its value,
503
+ * which the edit can neither keep nor replace (`cellChildBlocker`): non-empty markup
504
+ * compatibility content that is not a stored value (`x:v` or `x:is`), a formula in it
505
+ * included, or an element in another namespace with `x:f`, `x:v`, or `x:is` in it. The
506
+ * subject is the cell with its sheet, such as `Data!B5`.
507
+ */
508
+ | 'cell-alternate-content'
509
+ /** A format patch value outside its allowed values. */
510
+ | 'bad-format'
511
+ /** A custom number format code that the number format parser cannot read. */
512
+ | 'unreadable-number-format'
513
+ /** A format command that would create more cells than one command may. */
514
+ | 'range-too-large'
515
+ /** A row height edit that would create more row records than one edit may. */
516
+ | 'too-many-rows'
517
+ /**
518
+ * A resize would change an anchor that keeps its size or position in points: a drawing
519
+ * anchor, or the anchor of an embedded control or object (`resizeBlocker`). Also a resize of
520
+ * a sheet whose drawing part cannot be read, so its anchors cannot be checked; that refusal
521
+ * has `causeUnreadable`.
522
+ */
523
+ | 'resize-anchor'
524
+ /** A clear of formats that would create more `s="0"` cells than one command may. */
525
+ | 'clear-too-large'
526
+ /** A style list that would hold more records than the store allows. */
527
+ | 'style-limit'
528
+ /** The transaction would leave a part that breaks a structural rule. */
529
+ | 'invalid-part'
530
+ /**
531
+ * The sheet is protected (`x:sheetProtection/@sheet`), and the op changes a locked cell, or
532
+ * an action that the protection does not allow; or the workbook protection locks the sheet
533
+ * list (`x:workbookProtection/@lockStructure`) and the op is a sheet op
534
+ * (`sheet-protection.ts`).
535
+ */
536
+ | 'locked'
537
+ /** `undo` or `redo` with an empty history stack. */
538
+ | 'nothing-to-undo' | 'nothing-to-redo'
539
+ /**
540
+ * A structural edit would change a position that an element, a part, or a formula refers
541
+ * to, and the store cannot move that reference with certainty.
542
+ */
543
+ | 'structure-blocked'
544
+ /**
545
+ * A sheet move or delete would change the sheets that a sheet range (`Sheet1:Sheet3!A1`)
546
+ * spans, and the store does not rewrite sheet ranges.
547
+ */
548
+ | 'sheet-range-blocked'
549
+ /**
550
+ * A stored sheet name holds more than 31 characters, so an op that searches the sheet ranges
551
+ * of the workbook is refused (`longSheetNameBlocker`). The subject is the full name.
552
+ */
553
+ | 'sheet-name-too-long'
554
+ /** A structural edit would push content past the last row or column of the grid. */
555
+ | 'grid-full'
556
+ /** The ops were prepared against a revision that is no longer the current one. */
557
+ | 'stale-revision'
558
+ /** A sheet name that is empty, too long, or holds a character that a sheet name cannot. */
559
+ | 'sheet-name-invalid'
560
+ /** A sheet name that another sheet has, compared without case. */
561
+ | 'sheet-name-taken'
562
+ /**
563
+ * Two sheets of a file have the same name without case, so a reference cannot tell them
564
+ * apart: an edit that rewrites or moves references of one of them is refused.
565
+ */
566
+ | 'sheet-name-ambiguous'
567
+ /** A sheet delete that would leave the workbook with no visible sheet. */
568
+ | 'last-sheet';
569
+ readonly detail: string;
570
+ /**
571
+ * What the refusal names, as the file names it: an element and its part
572
+ * (`x:conditionalFormatting (/xl/worksheets/sheet1.xml)`), a part, a cell (`Data!B5`), or a
573
+ * range (`B2:C3`). A merge names a cell or a range of its sheet, with no sheet name.
574
+ */
575
+ readonly subject?: string;
576
+ /**
577
+ * The cell, with its sheet (`Data!A2`), whose formula the editor cannot rewrite, on a
578
+ * `shared-formula` refusal of a shared formula master: a child inside `mc:AlternateContent`, a
579
+ * child whose formula would move out of the grid, or a master whose text cannot be read.
580
+ */
581
+ readonly causeCell?: string;
582
+ /**
583
+ * True when the formula of `causeCell` cannot be read, not only not rewritten. On a
584
+ * `resize-anchor` refusal, true when the drawing part of the sheet cannot be read (the reader
585
+ * keeps it as bytes, or it is not a `xdr:wsDr`), so the resize cannot be checked.
586
+ */
587
+ readonly causeUnreadable?: true;
588
+ /**
589
+ * The shared formula master, with its sheet (`Data!A1`), that the edit would change, beside
590
+ * `causeCell`. It is inside the edited or cleared cells, so a message names it to leave out.
591
+ */
592
+ readonly masterCell?: string;
593
+ /**
594
+ * What a `structure-blocked` or `grid-full` refusal names, as a kind and a display name. A
595
+ * `sheet-range-blocked` refusal has it for content that the op does not rewrite, such as
596
+ * conditional formatting, and for a formula inside `mc:AlternateContent` (kind
597
+ * `wrapped-formula`), which the user cannot edit. A formula, a defined name, or a hyperlink
598
+ * that the op rewrites gives a `sheet-range-blocked` refusal with no `about`.
599
+ */
600
+ readonly about?: StructureSubject;
601
+ /**
602
+ * The protection rule of a `locked` refusal: a locked `cell` that a value edit changes, or a
603
+ * cell whose `@locked` or `@hidden` protection a new cell format index changes; `format` when
604
+ * the protection does not allow formatting cells; `structure` when it does not allow an
605
+ * insert or a delete of rows or columns; `size` when it does not allow a column width or a
606
+ * row height (`@formatColumns`, `@formatRows`); `merge` on a protected sheet, which allows no
607
+ * merge or unmerge; or `workbook` when the workbook protection locks the sheet list
608
+ * (`x:workbookProtection/@lockStructure`).
609
+ */
610
+ readonly lock?: 'cell' | 'format' | 'structure' | 'size' | 'workbook' | 'merge';
611
+ }
612
+ /**
613
+ * The kinds of content that refuse a structural edit, or that a `grid-full`
614
+ * refusal names, for user text. The part path stays in the rejection's `subject` and `detail`.
615
+ */
616
+ declare const STRUCTURE_SUBJECT_KINDS: readonly ['cell', 'wrapped-formula', 'cell-content', 'row', 'merged-range', 'columns', 'hyperlink', 'sheet-view', 'conditional-formatting', 'data-validation', 'filter', 'table', 'comment', 'drawing', 'linked-drawing', 'control', 'chart', 'pivot-table', 'other-sheet', 'not-worksheet', 'defined-name', 'sheet-content', 'workbook-content'];
617
+ /** One of {@link STRUCTURE_SUBJECT_KINDS}. A test keeps them equal to the catalog nouns. */
618
+ type StructureSubjectKind = (typeof STRUCTURE_SUBJECT_KINDS)[number];
619
+ /**
620
+ * What refuses a structural edit: its kind, and a display name where the kind has one: the
621
+ * sheet name, the defined name, or a reference such as `Data!B5`.
622
+ */
623
+ interface StructureSubject {
624
+ readonly kind: StructureSubjectKind;
625
+ readonly name?: string;
626
+ }
627
+
628
+ export { MAX_FONT_NAME_LENGTH as M, PATCH_BORDER_STYLES as P, FIRST_CUSTOM_NUMFMT_ID as a, MAX_FORMAT_CODE_LENGTH as b, PATCH_HORIZONTAL as c, PATCH_VERTICAL as d, STRUCTURE_SUBJECT_KINDS as i, lowerNumberFormat as l, patchProblem as m, patchGroups as p, structureBlocker as s };
629
+ export type { CellInput as C, FormatPatch as F, HistoryOp as H, InverseOp as I, OpRejection as O, StructuralOpName as S, WorkbookOp as W, PatchBorderStyle as e, PatchGroups as f, PatchHorizontal as g, PatchVertical as h, StructureSubject as j, StructureSubjectKind as k };