@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
package/LICENSE ADDED
@@ -0,0 +1,217 @@
1
+ LICENSE SCOPE NOTICE
2
+
3
+ Except where a file expressly states different license terms, this package is
4
+ licensed under the Apache License, Version 2.0, reproduced below.
5
+
6
+ The ECMA-376 tables that this package bundles (the preset shape geometry, the
7
+ preset color names, the predefined function names, the built-in number formats,
8
+ and the default indexed color palette) are derived from ECMA-376 Part 1, 5th
9
+ edition (2016), published by Ecma International. They are used under the Ecma
10
+ copyright notice, not under the Apache License. The notice is in
11
+ THIRD_PARTY_NOTICES.md, and also in a legal comment in each dist/ file that
12
+ holds the preset shape geometry or the predefined function names.
13
+
14
+ The HarfBuzz binary, dist/harfbuzz.wasm, and its JavaScript glue keep their own
15
+ terms. THIRD_PARTY_NOTICES.md and the licenses/ directory hold them.
16
+
17
+ Apache License
18
+ Version 2.0, January 2004
19
+ http://www.apache.org/licenses/
20
+
21
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
22
+
23
+ 1. Definitions.
24
+
25
+ "License" shall mean the terms and conditions for use, reproduction,
26
+ and distribution as defined by Sections 1 through 9 of this document.
27
+
28
+ "Licensor" shall mean the copyright owner or entity authorized by
29
+ the copyright owner that is granting the License.
30
+
31
+ "Legal Entity" shall mean the union of the acting entity and all
32
+ other entities that control, are controlled by, or are under common
33
+ control with that entity. For the purposes of this definition,
34
+ "control" means (i) the power, direct or indirect, to cause the
35
+ direction or management of such entity, whether by contract or
36
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
37
+ outstanding shares, or (iii) beneficial ownership of such entity.
38
+
39
+ "You" (or "Your") shall mean an individual or Legal Entity
40
+ exercising permissions granted by this License.
41
+
42
+ "Source" form shall mean the preferred form for making modifications,
43
+ including but not limited to software source code, documentation
44
+ source, and configuration files.
45
+
46
+ "Object" form shall mean any form resulting from mechanical
47
+ transformation or translation of a Source form, including but
48
+ not limited to compiled object code, generated documentation,
49
+ and conversions to other media types.
50
+
51
+ "Work" shall mean the work of authorship, whether in Source or
52
+ Object form, made available under the License, as indicated by a
53
+ copyright notice that is included in or attached to the work
54
+ (an example is provided in the Appendix below).
55
+
56
+ "Derivative Works" shall mean any work, whether in Source or Object
57
+ form, that is based on (or derived from) the Work and for which the
58
+ editorial revisions, annotations, elaborations, or other modifications
59
+ represent, as a whole, an original work of authorship. For the purposes
60
+ of this License, Derivative Works shall not include works that remain
61
+ separable from, or merely link (or bind by name) to the interfaces of,
62
+ the Work and Derivative Works thereof.
63
+
64
+ "Contribution" shall mean any work of authorship, including
65
+ the original version of the Work and any modifications or additions
66
+ to that Work or Derivative Works thereof, that is intentionally
67
+ submitted to Licensor for inclusion in the Work by the copyright owner
68
+ or by an individual or Legal Entity authorized to submit on behalf of
69
+ the copyright owner. For the purposes of this definition, "submitted"
70
+ means any form of electronic, verbal, or written communication sent
71
+ to the Licensor or its representatives, including but not limited to
72
+ communication on electronic mailing lists, source code control systems,
73
+ and issue tracking systems that are managed by, or on behalf of, the
74
+ Licensor for the purpose of discussing and improving the Work, but
75
+ excluding communication that is conspicuously marked or otherwise
76
+ designated in writing by the copyright owner as "Not a Contribution."
77
+
78
+ "Contributor" shall mean Licensor and any individual or Legal Entity
79
+ on behalf of whom a Contribution has been received by Licensor and
80
+ subsequently incorporated within the Work.
81
+
82
+ 2. Grant of Copyright License. Subject to the terms and conditions of
83
+ this License, each Contributor hereby grants to You a perpetual,
84
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
85
+ copyright license to reproduce, prepare Derivative Works of,
86
+ publicly display, publicly perform, sublicense, and distribute the
87
+ Work and such Derivative Works in Source or Object form.
88
+
89
+ 3. Grant of Patent License. Subject to the terms and conditions of
90
+ this License, each Contributor hereby grants to You a perpetual,
91
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
92
+ (except as stated in this section) patent license to make, have made,
93
+ use, offer to sell, sell, import, and otherwise transfer the Work,
94
+ where such license applies only to those patent claims licensable
95
+ by such Contributor that are necessarily infringed by their
96
+ Contribution(s) alone or by combination of their Contribution(s)
97
+ with the Work to which such Contribution(s) was submitted. If You
98
+ institute patent litigation against any entity (including a
99
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
100
+ or a Contribution incorporated within the Work constitutes direct
101
+ or contributory patent infringement, then any patent licenses
102
+ granted to You under this License for that Work shall terminate
103
+ as of the date such litigation is filed.
104
+
105
+ 4. Redistribution. You may reproduce and distribute copies of the
106
+ Work or Derivative Works thereof in any medium, with or without
107
+ modifications, and in Source or Object form, provided that You
108
+ meet the following conditions:
109
+
110
+ (a) You must give any other recipients of the Work or
111
+ Derivative Works a copy of this License; and
112
+
113
+ (b) You must cause any modified files to carry prominent notices
114
+ stating that You changed the files; and
115
+
116
+ (c) You must retain, in the Source form of any Derivative Works
117
+ that You distribute, all copyright, patent, trademark, and
118
+ attribution notices from the Source form of the Work,
119
+ excluding those notices that do not pertain to any part of
120
+ the Derivative Works; and
121
+
122
+ (d) If the Work includes a "NOTICE" text file as part of its
123
+ distribution, then any Derivative Works that You distribute must
124
+ include a readable copy of the attribution notices contained
125
+ within such NOTICE file, excluding those notices that do not
126
+ pertain to any part of the Derivative Works, in at least one
127
+ of the following places: within a NOTICE text file distributed
128
+ as part of the Derivative Works; within the Source form or
129
+ documentation, if provided along with the Derivative Works; or,
130
+ within a display generated by the Derivative Works, if and
131
+ wherever such third-party notices normally appear. The contents
132
+ of the NOTICE file are for informational purposes only and
133
+ do not modify the License. You may add Your own attribution
134
+ notices within Derivative Works that You distribute, alongside
135
+ or as an addendum to the NOTICE text from the Work, provided
136
+ that such additional attribution notices cannot be construed
137
+ as modifying the License.
138
+
139
+ You may add Your own copyright statement to Your modifications and
140
+ may provide additional or different license terms and conditions
141
+ for use, reproduction, or distribution of Your modifications, or
142
+ for any such Derivative Works as a whole, provided Your use,
143
+ reproduction, and distribution of the Work otherwise complies with
144
+ the conditions stated in this License.
145
+
146
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
147
+ any Contribution intentionally submitted for inclusion in the Work
148
+ by You to the Licensor shall be under the terms and conditions of
149
+ this License, without any additional terms or conditions.
150
+ Notwithstanding the above, nothing herein shall supersede or modify
151
+ the terms of any separate license agreement you may have executed
152
+ with Licensor regarding such Contributions.
153
+
154
+ 6. Trademarks. This License does not grant permission to use the trade
155
+ names, trademarks, service marks, or product names of the Licensor,
156
+ except as required for reasonable and customary use in describing the
157
+ origin of the Work and reproducing the content of the NOTICE file.
158
+
159
+ 7. Disclaimer of Warranty. Unless required by applicable law or
160
+ agreed to in writing, Licensor provides the Work (and each
161
+ Contributor provides its Contributions) on an "AS IS" BASIS,
162
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
163
+ implied, including, without limitation, any warranties or conditions
164
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
165
+ PARTICULAR PURPOSE. You are solely responsible for determining the
166
+ appropriateness of using or redistributing the Work and assume any
167
+ risks associated with Your exercise of permissions under this License.
168
+
169
+ 8. Limitation of Liability. In no event and under no legal theory,
170
+ whether in tort (including negligence), contract, or otherwise,
171
+ unless required by applicable law (such as deliberate and grossly
172
+ negligent acts) or agreed to in writing, shall any Contributor be
173
+ liable to You for damages, including any direct, indirect, special,
174
+ incidental, or consequential damages of any character arising as a
175
+ result of this License or out of the use or inability to use the
176
+ Work (including but not limited to damages for loss of goodwill,
177
+ work stoppage, computer failure or malfunction, or any and all
178
+ other commercial damages or losses), even if such Contributor
179
+ has been advised of the possibility of such damages.
180
+
181
+ 9. Accepting Warranty or Additional Liability. While redistributing
182
+ the Work or Derivative Works thereof, You may choose to offer,
183
+ and charge a fee for, acceptance of support, warranty, indemnity,
184
+ or other liability obligations and/or rights consistent with this
185
+ License. However, in accepting such obligations, You may act only
186
+ on Your own behalf and on Your sole responsibility, not on behalf
187
+ of any other Contributor, and only if You agree to indemnify,
188
+ defend, and hold each Contributor harmless for any liability
189
+ incurred by, or claims asserted against, such Contributor by reason
190
+ of your accepting any such warranty or additional liability.
191
+
192
+ END OF TERMS AND CONDITIONS
193
+
194
+ APPENDIX: How to apply the Apache License to your work.
195
+
196
+ To apply the Apache License to your work, attach the following
197
+ boilerplate notice, with the fields enclosed by brackets "[]"
198
+ replaced with your own identifying information. (Don't include
199
+ the brackets!) The text should be enclosed in the appropriate
200
+ comment syntax for the file format. We also recommend that a
201
+ file or class name and description of purpose be included on the
202
+ same "printed page" as the copyright notice for easier
203
+ identification within third-party archives.
204
+
205
+ Copyright 2026 Eigenpal, Inc.
206
+
207
+ Licensed under the Apache License, Version 2.0 (the "License");
208
+ you may not use this file except in compliance with the License.
209
+ You may obtain a copy of the License at
210
+
211
+ http://www.apache.org/licenses/LICENSE-2.0
212
+
213
+ Unless required by applicable law or agreed to in writing, software
214
+ distributed under the License is distributed on an "AS IS" BASIS,
215
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
216
+ See the License for the specific language governing permissions and
217
+ limitations under the License.
package/README.md CHANGED
@@ -1,5 +1,257 @@
1
+ <p align="center">
2
+ <a href="https://www.xlsx-editor.dev/">
3
+ <picture>
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/eigenpal/xlsx-editor/main/.github/assets/readme-logo-dark.svg" />
5
+ <source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/eigenpal/xlsx-editor/main/.github/assets/readme-logo-light.svg" />
6
+ <img src="https://raw.githubusercontent.com/eigenpal/xlsx-editor/main/.github/assets/readme-logo-light.svg" alt="XLSX Editor by EigenPal" width="320" height="90" />
7
+ </picture>
8
+ </a>
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/package/@xlsx-editor.dev/core"><img src="https://img.shields.io/npm/v/@xlsx-editor.dev/core.svg?style=flat-square&color=107C41" alt="npm version" /></a>
13
+ <a href="https://www.npmjs.com/package/@xlsx-editor.dev/core"><img src="https://img.shields.io/npm/dm/@xlsx-editor.dev/core.svg?style=flat-square&color=107C41" alt="npm downloads" /></a>
14
+ <a href="https://github.com/eigenpal/xlsx-editor/blob/main/LICENSE"><img src="https://img.shields.io/badge/license-Apache_2.0-blue.svg?style=flat-square&color=107C41" alt="license" /></a>
15
+ </p>
16
+
1
17
  # @xlsx-editor.dev/core
2
18
 
3
- This version is a placeholder. It contains no code.
19
+ The XLSX Editor engine. It reads a SpreadsheetML package into one canonical tree for each part, and resolves cell formats. It lays out the grid without the DOM and paints it on a canvas. It applies edits as typed ops and saves the package. The React and Vue adapters render what this package computes and hold no editing state.
20
+
21
+ ## Install
22
+
23
+ ```bash
24
+ npm install @xlsx-editor.dev/core
25
+ ```
26
+
27
+ The adapters take this package as a peer, so one dependency tree loads one copy of the engine. Install one copy, at the same minor version as the other `@xlsx-editor.dev` packages. Each adapter accepts only the minor of `@xlsx-editor.dev/core` that it releases with, for example `~0.1.0`. The package is ESM only. On a server, it needs Node.js 20.16.0 or later in the 20.x release line, or Node.js 22.3.0 or later.
28
+
29
+ The type declarations need TypeScript 5.7 or later, with `moduleResolution` set to `bundler` or `node16`.
30
+
31
+ ## Entry points
32
+
33
+ | Entry | What it holds |
34
+ | --- | --- |
35
+ | `@xlsx-editor.dev/core` | The same exports as `@xlsx-editor.dev/core/editor` |
36
+ | `@xlsx-editor.dev/core/editor` | `createXlsxEditor`, the editor instance, the text helpers, and the chrome registry |
37
+ | `@xlsx-editor.dev/core/store` | Bounded package read and save, the canonical tree, the document store, and its ops |
38
+ | `@xlsx-editor.dev/core/cascade` | Cell formats, number formats, theme colors, and theme fonts |
39
+ | `@xlsx-editor.dev/core/layout` | DOM-free grid geometry and text layout |
40
+ | `@xlsx-editor.dev/core/automation` | The edits that lower to store ops |
41
+ | `@xlsx-editor.dev/core/output` | Canvas paint and pictures |
42
+ | `@xlsx-editor.dev/core/contracts` | Shared types |
43
+ | `@xlsx-editor.dev/core/styles/editor.css` | Chrome tokens and styles |
44
+ | `@xlsx-editor.dev/core/harfbuzz.wasm` | The text shaper binary, for a bundler that does not emit it |
45
+
46
+ ## Use
47
+
48
+ The editor adds no styles of its own, so import the stylesheet once in your app. The stylesheet applies inside an element with the `xlsx-editor` class. Without that class, the editor has no colors, so the selection and the active cell do not show. The grid also has no height, so it does not scroll.
49
+
50
+ The following element holds the editor. Give it the `xlsx-editor` and `xlsx-editor-viewport` classes, a width, and a height. The second class keeps the width of the editor from following its content, so the host must give the width: in a host that sizes its content, such as an inline block or a centered flex column, the editor is 0 pixels wide. A block element in normal flow takes the width of its container:
51
+
52
+ <!-- sample: core-host -->
53
+
54
+ ```html
55
+ <div id="grid" class="xlsx-editor xlsx-editor-viewport" style="height: 600px"></div>
56
+ ```
57
+
58
+ The following example opens a workbook in that element and enters a value:
59
+
60
+ <!-- sample: core-open -->
61
+
62
+ ```ts
63
+ import '@xlsx-editor.dev/core/styles/editor.css';
64
+ import { createXlsxEditor } from '@xlsx-editor.dev/core/editor';
65
+
66
+ const response = await fetch('/workbook.xlsx');
67
+ const bytes = new Uint8Array(await response.arrayBuffer());
68
+
69
+ const editor = createXlsxEditor();
70
+ editor.attach(document.getElementById('grid')!);
71
+ const opened = await editor.load(bytes);
72
+ if (opened.status === 'failed' && opened.failure) {
73
+ const { code, detail } = opened.failure;
74
+ throw new Error(`The workbook did not open: ${code}. ${detail ?? ''}`);
75
+ }
76
+ editor.select({ row: 1, col: 1 });
77
+ const result = editor.enterValue('42');
78
+ if (!result.ok) console.log(result.refusal.code);
79
+ ```
80
+
81
+ To save the result and release the editor, call `save()` and `destroy()`. `save()` returns bytes of the opened kind: `snapshot().workbookKind` is `workbook` or `template`.
82
+
83
+ ```ts
84
+ const saved = editor.save();
85
+ editor.destroy();
86
+ ```
87
+
88
+ Rows and columns are 0-based in the API: `{ row: 1, col: 1 }` is cell B2. The grid fills the element and scrolls inside it. For a React UI, use `@xlsx-editor.dev/react`.
89
+
90
+ ### Open a workbook
91
+
92
+ `load()` does not reject when a workbook does not open. It resolves with a snapshot whose `status` is `failed`, and `failure.code` gives the reason:
93
+
94
+ | Code | Reason |
95
+ | -------------- | --------------------------------------------------------------- |
96
+ | `package` | The file is not a workbook that the engine can read. |
97
+ | `fonts` | The text shaper or the fonts did not load. |
98
+ | `no-worksheet` | The workbook has no visible worksheet that the editor can show. |
99
+
100
+ `failure.detail` gives the engine's reason for your logs. For example, if the browser cannot fetch `harfbuzz.wasm`, the detail names the URL and `setHarfBuzzWasmUrl`. If the server answers with HTML, it also names the `optimizeDeps` setting of the Vite 7 dev server. Do not show the detail to users.
101
+
102
+ After a failed open, `editor.save()` returns `null`, and `editor.enterValue()` refuses the edit with the code `not-editable`.
103
+
104
+ ## Serve the text shaper
105
+
106
+ The engine measures text with HarfBuzz, which ships as `@xlsx-editor.dev/core/harfbuzz.wasm`. On disk, the file is `node_modules/@xlsx-editor.dev/core/dist/harfbuzz.wasm`. With Vite, use version 7.0.0 or later.
107
+
108
+ `vite build` and webpack 5.83.0 or later emit the file on their own, so they need no setup. The tests build a Vite app and a webpack app. Each output must hold the text shaper, the fonts, and the stylesheets. No test builds with Turbopack.
109
+
110
+ Some bundlers do not emit `new URL(..., import.meta.url)` assets. With such a bundler, serve the file yourself. Then call `setHarfBuzzWasmUrl` from `@xlsx-editor.dev/core/layout` before you create an editor:
111
+
112
+ ```ts
113
+ import { setHarfBuzzWasmUrl } from '@xlsx-editor.dev/core/layout';
114
+
115
+ setHarfBuzzWasmUrl('/static/harfbuzz.wasm');
116
+ ```
117
+
118
+ The Vite 8 dev server serves the text shaper and the fonts with no setup. The Vite 7 dev server answers these requests with HTML, so exclude both packages from dependency optimization:
119
+
120
+ <!-- sample: vite-7-dev -->
121
+
122
+ ```ts
123
+ // vite.config.ts
124
+ import { defineConfig } from 'vite';
125
+
126
+ export default defineConfig({
127
+ optimizeDeps: {
128
+ exclude: ['@xlsx-editor.dev/core', '@docx-editor.dev/fonts'],
129
+ },
130
+ });
131
+ ```
132
+
133
+ The default substitute faces of `@docx-editor.dev/fonts` load the same way, so these bundlers do not emit them either. With such a bundler, copy the files of `node_modules/@docx-editor.dev/fonts/assets/` to a static folder. Then pass the faces as the `fonts` option. Each face is a `FontSource`: a family, its style, and its bytes. Register each file under the name of its own family, as `loadSubstituteFonts()` of `@xlsx-editor.dev/core/editor` does. The engine maps each workbook family to its substitute, as the following table lists. It measures any other family with Liberation Sans.
134
+
135
+ | Files | Family | Stands in for |
136
+ | --- | --- | --- |
137
+ | `Carlito-*.ttf` | `Carlito` | Aptos, Aptos Display, Calibri, Calibri Light |
138
+ | `Caladea-*.ttf` | `Caladea` | Cambria |
139
+ | `LiberationSans-*.ttf` | `Liberation Sans` | Aptos Narrow, Arial, Arial Narrow, Helvetica, Helvetica Neue, Myriad Pro, Myriad Pro Light, Open Sans, Segoe UI |
140
+ | `LiberationSerif-*.ttf` | `Liberation Serif` | Times, Times New Roman |
141
+ | `LiberationMono-*.ttf` | `Liberation Mono` | Courier, Courier New |
142
+ | `TeXGyreAdventor-*.otf` | `TeX Gyre Adventor` | Century Gothic |
143
+
144
+ The following example serves the files from `/static/fonts/`:
145
+
146
+ ```ts
147
+ import { createXlsxEditor } from '@xlsx-editor.dev/core/editor';
148
+ import type { FontSource } from '@xlsx-editor.dev/core/layout';
149
+
150
+ async function face(
151
+ file: string,
152
+ family: string,
153
+ bold: boolean,
154
+ italic: boolean
155
+ ): Promise<FontSource> {
156
+ const response = await fetch(`/static/fonts/${file}`);
157
+ if (!response.ok) throw new Error(`${file}: HTTP ${response.status}`);
158
+ const bytes = new Uint8Array(await response.arrayBuffer());
159
+ return { family, bold, italic, bytes, origin: 'substitute' };
160
+ }
161
+
162
+ const editor = createXlsxEditor({
163
+ fonts: async () => [
164
+ await face('Carlito-Regular.ttf', 'Carlito', false, false),
165
+ await face('Carlito-Bold.ttf', 'Carlito', true, false),
166
+ await face('LiberationSans-Regular.ttf', 'Liberation Sans', false, false),
167
+ // Add one entry for each file that you serve.
168
+ ],
169
+ });
170
+ ```
171
+
172
+ The sample checks `response.ok` because the editor cannot identify an error page that you pass as face bytes. If the `fonts` function rejects or resolves to no faces, the workbook does not open: `editor.snapshot().status` is `failed`, and the failure code is `fonts`.
173
+
174
+ ## Fonts
175
+
176
+ `createXlsxEditor({ fonts })` takes font sources, or a function that resolves to them. Without `fonts`, the editor loads the packaged substitute faces of `@docx-editor.dev/fonts` (`loadSubstituteFonts` of `@xlsx-editor.dev/core/editor`). `editor.setFonts()` replaces the faces in place and resolves with the failure when the new faces do not load. `editor.fontReport()` lists the faces in force. The editor never fetches a font that a workbook names.
177
+
178
+ If no packaged substitute face loads, the workbook does not open. `editor.snapshot().status` is `failed`, the failure code is `fonts`, and `fontReport()` is empty. If only some packaged substitute faces load, the workbook opens. Its text then measures and paints with the faces that loaded. `fontReport().substituteFailures` then lists the faces that did not load.
179
+
180
+ ## Use on a server
181
+
182
+ The `store`, `cascade`, `layout`, and `automation` entries need no DOM, so they run on Node.js. The following example reads a workbook and saves it again:
183
+
184
+ <!-- sample: core-server-save -->
185
+
186
+ ```ts
187
+ import { readFileSync, writeFileSync } from 'node:fs';
188
+ import { readXlsx, saveXlsx } from '@xlsx-editor.dev/core/store';
189
+
190
+ const read = readXlsx(new Uint8Array(readFileSync('in.xlsx')));
191
+ if (!read.ok) throw new Error(`in.xlsx did not read: ${JSON.stringify(read.error)}`);
192
+ writeFileSync('out.xlsx', saveXlsx(read.pkg));
193
+ ```
194
+
195
+ If the bytes do not read, `read.error` is a `PackageRejection`. Its `reason` is one of these values:
196
+
197
+ - `zip`: the bytes are not a zip archive, or the archive is damaged or crosses a limit. `detail` gives the zip reader's reason, such as `inflate-error`.
198
+ - `no-content-types`: the archive has no `[Content_Types].xml` part.
199
+ - `not-a-workbook`: the package has no workbook part of a known content type.
200
+ - `xml`: the XML of the part `partName` is malformed or crosses a limit.
201
+
202
+ To measure text on a server, load the text shaper and give it the face bytes. `loadSubstituteFonts()` of `@xlsx-editor.dev/core/editor` reads the packaged faces with `fetch`. On Node.js, `fetch` cannot read local files, so this function works in a browser only. On a server, read the files of `@docx-editor.dev/fonts` yourself, under the families of [Serve the text shaper](#serve-the-text-shaper). If your package manager does not hoist `@docx-editor.dev/fonts`, install it too.
203
+
204
+ <!-- sample: core-server-measure -->
205
+
206
+ ```ts
207
+ import { readFileSync } from 'node:fs';
208
+ import { FONT_ASSET_ROOT } from '@docx-editor.dev/fonts';
209
+ import {
210
+ createHarfBuzzMeasurer,
211
+ type FontSource,
212
+ gridMetrics,
213
+ initializeHarfBuzz,
214
+ PRINT_PROFILE,
215
+ } from '@xlsx-editor.dev/core/layout';
216
+ import { readXlsx, workbookIndex } from '@xlsx-editor.dev/core/store';
217
+
218
+ await initializeHarfBuzz();
219
+ function face(file: string, family: string, bold: boolean, italic: boolean): FontSource {
220
+ const bytes = new Uint8Array(readFileSync(new URL(file, FONT_ASSET_ROOT)));
221
+ return { family, bold, italic, bytes, origin: 'substitute' };
222
+ }
223
+ const measurer = createHarfBuzzMeasurer([
224
+ face('Carlito-Regular.ttf', 'Carlito', false, false),
225
+ face('Carlito-Bold.ttf', 'Carlito', true, false),
226
+ face('LiberationSans-Regular.ttf', 'Liberation Sans', false, false),
227
+ ]);
228
+
229
+ const read = readXlsx(new Uint8Array(readFileSync('in.xlsx')));
230
+ if (!read.ok) throw new Error(`in.xlsx did not read: ${JSON.stringify(read.error)}`);
231
+ const index = workbookIndex(read.pkg);
232
+ if (!index) throw new Error('in.xlsx has no workbook part');
233
+ const metrics = gridMetrics(read.pkg, index, measurer, PRINT_PROFILE);
234
+ console.log(metrics.maxDigitWidth, metrics.defaultRowHeight);
235
+ ```
236
+
237
+ The sample passes the measurer to `gridMetrics` of `@xlsx-editor.dev/core/layout`. It gets the workbook index from `workbookIndex(pkg)` of `@xlsx-editor.dev/core/store`. That function returns `undefined` when the package has no workbook part, so check for that case first. The profile is `PRINT_PROFILE` or `SCREEN_PROFILE` of the layout entry. The result gives the maximum digit width and the default row height of the workbook. The column widths and row heights come from these values. The column width formulas are in ECMA-376 Part 1, 18.3.1.13 (`x:col/@width`, and `x:sheetFormatPr/@defaultColWidth` or `@baseColWidth` for a column with no `x:col`).
238
+
239
+ ## Untrusted input
240
+
241
+ Every value in a workbook is attacker-controlled. The engine treats the file that way:
242
+
243
+ - The package reader caps the decompressed size, the part count, the XML depth, and the element counts. It refuses paths with `..` or a leading `/`. XML has no DTD and no entity expansion.
244
+ - No value from a file reaches HTML: the grid paints into a canvas, and text goes through `textContent`.
245
+ - Hyperlink targets (`x:hyperlink`) go through an allowlist of URL schemes. External relationships (`TargetMode="External"`), external workbook links (`x:externalLink`), data connections (`x:connections`), and remote images never load on their own.
246
+ - Formulas (`x:f`) are never evaluated: a cell shows its cached `x:v`. Macros (`vbaProject.bin`), embedded objects (`x:oleObjects`), and controls (`x:controls`) are kept inert.
247
+ - File-supplied numbers, such as `x:dimension/@ref`, `x:row/@r`, and `x:row/@spans`, never size an allocation or a loop: the engine reads the cells that exist.
248
+
249
+ ## Lanes
250
+
251
+ Each entry point is a lane with a declared dependency edge. The `store`, `cascade`, `layout`, and `automation` lanes are DOM-free. For the lane graph, see [Core lanes](https://github.com/eigenpal/xlsx-editor/blob/main/CONTRIBUTING.md#core-lanes) in the contribution guide.
252
+
253
+ All chrome CSS and color tokens live in `@xlsx-editor.dev/core/styles/editor.css`. The adapters only import it. The painted grid is not themed.
254
+
255
+ ## License
4
256
 
5
- The real release is published from https://github.com/eigenpal/xlsx-editor.
257
+ Apache-2.0. See [LICENSE](LICENSE). The package bundles five ECMA-376 tables. The Ecma copyright notice covers them, not Apache-2.0. The tables are the preset shape geometry, the preset color names, and the predefined function names. They also include the built-in number formats and the default indexed color palette. Other third-party material keeps its own terms. See `THIRD_PARTY_NOTICES.md` in the package.
@@ -0,0 +1,78 @@
1
+ # Third-party notices for @xlsx-editor.dev/core
2
+
3
+ ## Material Symbols
4
+
5
+ `src/editor/icon-paths.ts` holds SVG path data from Material Symbols by Google, licensed under the Apache License, Version 2.0 (https://github.com/google/material-design-icons). The license text is in this package's `LICENSE` file.
6
+
7
+ ## ECMA-376 tables
8
+
9
+ These tables come from ECMA-376 Part 1, 5th edition (2016), published by Ecma International (https://ecma-international.org/publications-and-standards/standards/ecma-376/). They are used under the Ecma copyright notice below.
10
+
11
+ - The preset shape geometry table, which this package inlines from `@eigenpal/ooxml-core` (`drawingml-preset-geometry.generated.ts`) at build time. It is generated from `presetShapeDefinitions.xml`.
12
+ - The preset color names of `ST_PresetColorVal` (20.1.10.48), which this package inlines from `@eigenpal/ooxml-core` (`drawingml-preset-colors.ts`) at build time.
13
+ - The predefined function names of 18.17.7, in `src/store/formula/predefined-functions.generated.ts`.
14
+ - The built-in number format codes of 18.8.30, in `src/store/number-format/builtins.ts`.
15
+ - The default indexed color palette of 18.8.27, in `src/cascade/color.ts` and `src/store/number-format/parse.ts`.
16
+
17
+ ```
18
+ COPYRIGHT NOTICE
19
+
20
+ © Ecma International
21
+
22
+ By obtaining and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
23
+
24
+ This document may be copied, published and distributed to others, and certain derivative works of it may be prepared, copied, published, and distributed, in whole or in part, provided that the above copyright notice and this Copyright License and Disclaimer are included on all such copies and derivative works. The only derivative works that are permissible under this Copyright License and Disclaimer are:
25
+
26
+ (i) works which incorporate all or portion of this document for the purpose of providing commentary or explanation (such as an annotated version of the document),
27
+
28
+ (ii) works which incorporate all or portion of this document for the purpose of incorporating features that provide accessibility,
29
+
30
+ (iii) translations of this document into languages other than English and into different formats and
31
+
32
+ (iv) works by making use of this specification in standard conformant products by implementing (e.g. by copy and paste wholly or partly) the functionality therein.
33
+
34
+ However, the content of this document itself may not be modified in any way, including by removing the copyright notice or references to Ecma International, except as required to translate it into languages other than English or into a different format.
35
+
36
+ The official version of an Ecma International document is the English language version on the Ecma International website. In the event of discrepancies between a translated version and the official version, the official version shall govern.
37
+
38
+ The limited permissions granted above are perpetual and will not be revoked by Ecma International or its successors or assigns.
39
+
40
+ This document and the information contained herein is provided on an "AS IS" basis and ECMA INTERNATIONAL DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
41
+ ```
42
+
43
+ ## HarfBuzz
44
+
45
+ `dist/harfbuzz.wasm` contains HarfBuzz, distributed by `harfbuzzjs` (its license is below). The component versions, source URLs, and notice checksums are in `licenses/harfbuzz-manifest.json`. The following files contain the component copyright and permission notices. The source and runtime notices also cover optional upstream components.
46
+
47
+ - HarfBuzz source copyright and permission notices: `licenses/HarfBuzz-source-notices.txt`
48
+ - HarfBuzz primary license: `licenses/HarfBuzz-COPYING.txt`
49
+ - Universal Shaping Engine data: `licenses/HarfBuzz-USE-MIT.txt`
50
+ - Emscripten JavaScript runtime: `licenses/Emscripten-LICENSE.txt`
51
+ - Emscripten bundled C library: `licenses/musl-COPYRIGHT.txt`
52
+ - Emscripten bundled compiler runtime: `licenses/compiler-rt-LICENSE.txt`
53
+ - Unicode data tables: `licenses/Unicode-LICENSE.txt`
54
+
55
+ ## harfbuzzjs
56
+
57
+ ```
58
+ Copyright (c) 2019-2026 The harfbuzzjs project authors
59
+
60
+ Permission is hereby granted, free of charge, to any person obtaining a copy
61
+ of this software and associated documentation files (the "Software"), to deal
62
+ in the Software without restriction, including without limitation the rights
63
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
64
+ copies of the Software, and to permit persons to whom the Software is
65
+ furnished to do so, subject to the following conditions:
66
+
67
+ The above copyright notice and this permission notice shall be included in all
68
+ copies or substantial portions of the Software.
69
+
70
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
71
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
72
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
73
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
74
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
75
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
76
+ SOFTWARE.
77
+ ```
78
+