@trebco/treb 32.14.0 → 36.1.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 (267) hide show
  1. package/api-generator/api-generator-types.ts +3 -0
  2. package/api-generator/api-generator.ts +15 -1
  3. package/bun.lock +145 -99
  4. package/dist/chunk-43DLP2OX.mjs +11 -0
  5. package/dist/chunk-4CKS56PE.mjs +11 -0
  6. package/dist/chunk-75PARUQE.mjs +11 -0
  7. package/dist/chunk-7QD63AZS.mjs +24601 -0
  8. package/dist/chunk-A55ARVRD.mjs +11 -0
  9. package/dist/chunk-DESAKYW4.mjs +11 -0
  10. package/dist/chunk-EQ2R5W6P.mjs +24565 -0
  11. package/dist/chunk-IYJU2J6D.mjs +24601 -0
  12. package/dist/chunk-KSJFPGXT.mjs +11 -0
  13. package/dist/chunk-ORQFKLXM.mjs +24601 -0
  14. package/dist/chunk-SFDNNDHY.mjs +11 -0
  15. package/dist/chunk-T47DX5MI.mjs +11 -0
  16. package/dist/chunk-T6ILBVEX.mjs +11 -0
  17. package/dist/chunk-TPRCDYYG.mjs +11 -0
  18. package/dist/chunk-YAHNOOHO.mjs +11 -0
  19. package/dist/chunk-YLCFKX2G.mjs +24601 -0
  20. package/dist/treb-export-worker.mjs +9 -2
  21. package/dist/treb-spreadsheet.mjs +7 -19
  22. package/dist/treb.d.ts +144 -117
  23. package/esbuild-composite.mjs +18 -6
  24. package/esbuild-utils.mjs +62 -3
  25. package/i18n/languages/treb-i18n-da.mjs +1 -1
  26. package/i18n/languages/treb-i18n-de.mjs +1 -1
  27. package/i18n/languages/treb-i18n-es.mjs +1 -1
  28. package/i18n/languages/treb-i18n-fr.mjs +1 -1
  29. package/i18n/languages/treb-i18n-it.mjs +1 -1
  30. package/i18n/languages/treb-i18n-nl.mjs +1 -1
  31. package/i18n/languages/treb-i18n-no.mjs +1 -1
  32. package/i18n/languages/treb-i18n-pl.mjs +1 -1
  33. package/i18n/languages/treb-i18n-pt.mjs +1 -1
  34. package/i18n/languages/treb-i18n-sv.mjs +1 -1
  35. package/ooxml-types/README.md +141 -0
  36. package/ooxml-types/package.json +5 -0
  37. package/ooxml-types/src/types/drawingml/chart.ts +327 -0
  38. package/ooxml-types/src/types/drawingml/index.ts +63 -0
  39. package/ooxml-types/src/types/drawingml/spreadsheetDrawing.ts +105 -0
  40. package/ooxml-types/src/types/drawingml/theme.ts +104 -0
  41. package/ooxml-types/src/types/index.ts +3 -0
  42. package/ooxml-types/src/types/package/contentTypes.ts +49 -0
  43. package/ooxml-types/src/types/package/docProps.ts +46 -0
  44. package/ooxml-types/src/types/package/index.ts +17 -0
  45. package/ooxml-types/src/types/package/relationships.ts +37 -0
  46. package/ooxml-types/src/types/spreadsheetml/columns.ts +20 -0
  47. package/ooxml-types/src/types/spreadsheetml/comments.ts +30 -0
  48. package/ooxml-types/src/types/spreadsheetml/dataFeatures.ts +261 -0
  49. package/ooxml-types/src/types/spreadsheetml/enums.ts +175 -0
  50. package/ooxml-types/src/types/spreadsheetml/index.ts +186 -0
  51. package/ooxml-types/src/types/spreadsheetml/metadata.ts +90 -0
  52. package/ooxml-types/src/types/spreadsheetml/misc.ts +35 -0
  53. package/ooxml-types/src/types/spreadsheetml/pageLayout.ts +83 -0
  54. package/ooxml-types/src/types/spreadsheetml/sharedStrings.ts +33 -0
  55. package/ooxml-types/src/types/spreadsheetml/sheetData.ts +70 -0
  56. package/ooxml-types/src/types/spreadsheetml/sheetProperties.ts +86 -0
  57. package/ooxml-types/src/types/spreadsheetml/sheetViews.ts +51 -0
  58. package/ooxml-types/src/types/spreadsheetml/sparkline.ts +46 -0
  59. package/ooxml-types/src/types/spreadsheetml/styles.ts +274 -0
  60. package/ooxml-types/src/types/spreadsheetml/table.ts +106 -0
  61. package/ooxml-types/src/types/spreadsheetml/util.ts +15 -0
  62. package/ooxml-types/src/types/spreadsheetml/workbook.ts +165 -0
  63. package/ooxml-types/src/types/spreadsheetml/worksheet.ts +60 -0
  64. package/package.json +13 -11
  65. package/treb-base-types/src/api_types.ts +1 -1
  66. package/treb-base-types/src/area-utils.ts +1 -1
  67. package/treb-base-types/src/area.ts +1 -1
  68. package/treb-base-types/src/basic_types.ts +1 -1
  69. package/treb-base-types/src/cell.ts +1 -1
  70. package/treb-base-types/src/cells.ts +1 -1
  71. package/treb-base-types/src/color.ts +1 -1
  72. package/treb-base-types/src/dom-utilities.ts +1 -1
  73. package/treb-base-types/src/evaluate-options.ts +1 -1
  74. package/treb-base-types/src/font-stack.ts +1 -1
  75. package/treb-base-types/src/gradient.ts +1 -1
  76. package/treb-base-types/src/import.ts +1 -1
  77. package/treb-base-types/src/index-standalone.ts +1 -1
  78. package/treb-base-types/src/index.ts +2 -1
  79. package/treb-base-types/src/layout.ts +1 -1
  80. package/treb-base-types/src/localization.ts +1 -1
  81. package/treb-base-types/src/rectangle.ts +1 -1
  82. package/treb-base-types/src/render_text.ts +7 -1
  83. package/treb-base-types/src/style.ts +1 -1
  84. package/treb-base-types/src/table.ts +1 -1
  85. package/treb-base-types/src/text_part.ts +1 -1
  86. package/treb-base-types/src/theme.ts +1 -1
  87. package/treb-base-types/src/union.ts +4 -1
  88. package/treb-base-types/src/value-type.ts +1 -1
  89. package/treb-base-types/src/worker-proxy.ts +294 -0
  90. package/treb-base-types/style/resizable.css +1 -1
  91. package/treb-calculator/src/calculator.ts +133 -14
  92. package/treb-calculator/src/complex-math.ts +1 -1
  93. package/treb-calculator/src/dag/array-vertex.ts +1 -1
  94. package/treb-calculator/src/dag/calculation_leaf_vertex.ts +1 -1
  95. package/treb-calculator/src/dag/graph.ts +1 -1
  96. package/treb-calculator/src/dag/spreadsheet_vertex.ts +1 -1
  97. package/treb-calculator/src/dag/spreadsheet_vertex_base.ts +1 -1
  98. package/treb-calculator/src/dag/state_leaf_vertex.ts +1 -1
  99. package/treb-calculator/src/dag/vertex.ts +1 -1
  100. package/treb-calculator/src/descriptors.ts +9 -1
  101. package/treb-calculator/src/expression-calculator.ts +1 -1
  102. package/treb-calculator/src/function-error.ts +1 -1
  103. package/treb-calculator/src/function-library.ts +1 -1
  104. package/treb-calculator/src/functions/base-functions.ts +8 -4
  105. package/treb-calculator/src/functions/beta.ts +1 -1
  106. package/treb-calculator/src/functions/checkbox.ts +1 -1
  107. package/treb-calculator/src/functions/complex-functions.ts +1 -1
  108. package/treb-calculator/src/functions/date-utils.ts +1 -1
  109. package/treb-calculator/src/functions/finance-functions.ts +2 -4
  110. package/treb-calculator/src/functions/fp.ts +1 -1
  111. package/treb-calculator/src/functions/function-utilities.ts +1 -1
  112. package/treb-calculator/src/functions/gamma.ts +1 -1
  113. package/treb-calculator/src/functions/information-functions.ts +1 -1
  114. package/treb-calculator/src/functions/lambda-functions.ts +4 -1
  115. package/treb-calculator/src/functions/matrix-functions.ts +1 -1
  116. package/treb-calculator/src/functions/normal.ts +1 -1
  117. package/treb-calculator/src/functions/regex-functions.ts +13 -4
  118. package/treb-calculator/src/functions/sparkline.ts +1 -1
  119. package/treb-calculator/src/functions/statistics-functions.ts +1 -1
  120. package/treb-calculator/src/functions/students-t.ts +1 -1
  121. package/treb-calculator/src/functions/text-functions.ts +5 -1
  122. package/treb-calculator/src/index.ts +1 -1
  123. package/treb-calculator/src/notifier-types.ts +1 -1
  124. package/treb-calculator/src/primitives.ts +1 -1
  125. package/treb-calculator/src/utilities.ts +1 -1
  126. package/treb-charts/src/chart-functions.ts +1 -1
  127. package/treb-charts/src/chart-types.ts +1 -1
  128. package/treb-charts/src/chart-utils.ts +1 -1
  129. package/treb-charts/src/chart.ts +1 -1
  130. package/treb-charts/src/default-chart-renderer.ts +1 -1
  131. package/treb-charts/src/index.ts +1 -1
  132. package/treb-charts/src/main.ts +1 -1
  133. package/treb-charts/src/quicksort.ts +1 -1
  134. package/treb-charts/src/rectangle.ts +1 -1
  135. package/treb-charts/src/renderer-type.ts +1 -1
  136. package/treb-charts/src/renderer.ts +1 -1
  137. package/treb-charts/src/util.ts +1 -1
  138. package/treb-charts/style/charts.scss +1 -1
  139. package/treb-data-model/src/annotation.ts +1 -1
  140. package/treb-data-model/src/conditional_format.ts +1 -1
  141. package/treb-data-model/src/data-validation.ts +1 -1
  142. package/treb-data-model/src/data_model.ts +32 -5
  143. package/treb-data-model/src/index.ts +1 -1
  144. package/treb-data-model/src/language-model.ts +1 -1
  145. package/treb-data-model/src/named.ts +1 -1
  146. package/treb-data-model/src/serialize_options.ts +1 -1
  147. package/treb-data-model/src/sheet.ts +1 -1
  148. package/treb-data-model/src/sheet_collection.ts +1 -1
  149. package/treb-data-model/src/sheet_selection.ts +1 -1
  150. package/treb-data-model/src/sheet_types.ts +1 -1
  151. package/treb-data-model/src/types.ts +1 -1
  152. package/treb-embed/src/content-types.d.ts +1 -1
  153. package/treb-embed/src/custom-element/global.d.ts +1 -1
  154. package/treb-embed/src/custom-element/spreadsheet-constructor.ts +1 -1
  155. package/treb-embed/src/custom-element/treb-global.ts +1 -1
  156. package/treb-embed/src/custom-element/treb-spreadsheet-element.ts +1 -1
  157. package/treb-embed/src/embedded-spreadsheet.ts +357 -154
  158. package/treb-embed/src/index.ts +1 -1
  159. package/treb-embed/src/options.ts +4 -2
  160. package/treb-embed/src/plugin.ts +1 -1
  161. package/treb-embed/src/progress-dialog.ts +1 -1
  162. package/treb-embed/src/selection-state.ts +1 -1
  163. package/treb-embed/src/spinner.ts +1 -1
  164. package/treb-embed/src/toolbar-message.ts +6 -1
  165. package/treb-embed/src/types.ts +13 -1
  166. package/treb-embed/style/autocomplete.scss +1 -1
  167. package/treb-embed/style/dark-theme.scss +1 -1
  168. package/treb-embed/style/defaults.scss +1 -1
  169. package/treb-embed/style/dialog.scss +1 -1
  170. package/treb-embed/style/dropdown-select.scss +1 -1
  171. package/treb-embed/style/font-stacks.scss +1 -1
  172. package/treb-embed/style/formula-bar.scss +1 -1
  173. package/treb-embed/style/grid.scss +1 -1
  174. package/treb-embed/style/layout.scss +1 -1
  175. package/treb-embed/style/mouse-mask.scss +1 -1
  176. package/treb-embed/style/note.scss +1 -1
  177. package/treb-embed/style/overlay-editor.scss +1 -1
  178. package/treb-embed/style/spinner.scss +1 -1
  179. package/treb-embed/style/tab-bar.scss +1 -1
  180. package/treb-embed/style/table.scss +1 -1
  181. package/treb-embed/style/theme-defaults.scss +1 -1
  182. package/treb-embed/style/toolbar.scss +1 -1
  183. package/treb-embed/style/tooltip.scss +1 -1
  184. package/treb-embed/style/treb-icons.scss +1 -1
  185. package/treb-embed/style/treb-spreadsheet-element.scss +1 -1
  186. package/treb-embed/style/z-index.scss +1 -1
  187. package/treb-export/src/address-type.ts +1 -1
  188. package/treb-export/src/base-template.ts +1 -1
  189. package/treb-export/src/column-width.ts +1 -1
  190. package/treb-export/src/drawing/bubble-chart-template.ts +1 -1
  191. package/treb-export/src/drawing/chart-template-components2.ts +1 -1
  192. package/treb-export/src/drawing/chart.ts +1 -1
  193. package/treb-export/src/drawing/column-chart-template2.ts +1 -1
  194. package/treb-export/src/drawing/donut-chart-template2.ts +1 -1
  195. package/treb-export/src/drawing/drawing.ts +1 -1
  196. package/treb-export/src/drawing/embedded-image.ts +1 -1
  197. package/treb-export/src/drawing/scatter-chart-template2.ts +1 -1
  198. package/treb-export/src/export.ts +10 -6
  199. package/treb-export/src/import-export-messages.ts +61 -0
  200. package/treb-export/src/import.ts +318 -301
  201. package/treb-export/src/index.worker.ts +85 -53
  202. package/treb-export/src/metadata.ts +71 -3
  203. package/treb-export/src/ooxml.ts +47 -0
  204. package/treb-export/src/relationship.ts +1 -1
  205. package/treb-export/src/shared-strings.ts +19 -15
  206. package/treb-export/src/template-2.ts +1 -1
  207. package/treb-export/src/unescape_xml.ts +1 -1
  208. package/treb-export/src/workbook-sheet.ts +11 -6
  209. package/treb-export/src/workbook-style.ts +137 -25
  210. package/treb-export/src/workbook-theme.ts +20 -4
  211. package/treb-export/src/workbook.ts +85 -88
  212. package/treb-export/src/xml-test.ts +1 -1
  213. package/treb-export/src/xml-utils.ts +1 -1
  214. package/treb-export/src/zip-wrapper.ts +1 -1
  215. package/treb-export/tsconfig.json +2 -1
  216. package/treb-format/src/format.test.ts +1 -1
  217. package/treb-format/src/format.ts +12 -5
  218. package/treb-format/src/format_cache.ts +3 -3
  219. package/treb-format/src/format_parser.ts +1 -1
  220. package/treb-format/src/index.ts +1 -1
  221. package/treb-format/src/number_format_section.ts +1 -1
  222. package/treb-format/src/value_parser.ts +1 -1
  223. package/treb-grid/src/editors/autocomplete.ts +1 -1
  224. package/treb-grid/src/editors/autocomplete_matcher.ts +1 -1
  225. package/treb-grid/src/editors/editor.ts +15 -6
  226. package/treb-grid/src/editors/external_editor.ts +33 -8
  227. package/treb-grid/src/editors/formula_bar.ts +12 -1
  228. package/treb-grid/src/editors/overlay_editor.ts +4 -1
  229. package/treb-grid/src/index.ts +1 -1
  230. package/treb-grid/src/layout/base_layout.ts +1 -1
  231. package/treb-grid/src/layout/grid_layout.ts +1 -1
  232. package/treb-grid/src/layout/mock-layout.ts +1 -1
  233. package/treb-grid/src/render/selection-renderer.ts +1 -1
  234. package/treb-grid/src/render/svg_header_overlay.ts +1 -1
  235. package/treb-grid/src/render/svg_selection_block.ts +1 -1
  236. package/treb-grid/src/render/tile_renderer.ts +36 -7
  237. package/treb-grid/src/types/border_constants.ts +1 -1
  238. package/treb-grid/src/types/clipboard_data.ts +1 -1
  239. package/treb-grid/src/types/clipboard_data2.ts +1 -1
  240. package/treb-grid/src/types/drag_mask.ts +1 -1
  241. package/treb-grid/src/types/external_editor_config.ts +1 -1
  242. package/treb-grid/src/types/grid.ts +181 -40
  243. package/treb-grid/src/types/grid_base.ts +7 -4
  244. package/treb-grid/src/types/grid_command.ts +7 -1
  245. package/treb-grid/src/types/grid_events.ts +2 -1
  246. package/treb-grid/src/types/grid_options.ts +1 -1
  247. package/treb-grid/src/types/scale-control.ts +1 -1
  248. package/treb-grid/src/types/set_range_options.ts +1 -1
  249. package/treb-grid/src/types/tab_bar.ts +1 -1
  250. package/treb-grid/src/types/tile.ts +1 -1
  251. package/treb-grid/src/types/update_flags.ts +1 -1
  252. package/treb-grid/src/util/fontmetrics.ts +1 -1
  253. package/treb-grid/src/util/ua.ts +1 -1
  254. package/treb-parser/src/csv-parser.ts +1 -1
  255. package/treb-parser/src/index.ts +1 -1
  256. package/treb-parser/src/md-parser.ts +1 -1
  257. package/treb-parser/src/parser-types.ts +1 -1
  258. package/treb-parser/src/parser.ts +1 -1
  259. package/treb-utils/src/event_source.ts +1 -1
  260. package/treb-utils/src/ievent_source.ts +1 -1
  261. package/treb-utils/src/index.ts +1 -1
  262. package/treb-utils/src/measurement.ts +1 -1
  263. package/treb-utils/src/scale.ts +1 -1
  264. package/treb-utils/src/serialize_html.ts +1 -1
  265. package/treb-utils/src/validate_uri.ts +1 -1
  266. package/tsproject.json +2 -3
  267. package/treb-embed/src/export-worker.ts +0 -44
@@ -14,7 +14,7 @@
14
14
  * You should have received a copy of the GNU General Public License along
15
15
  * with TREB. If not, see <https://www.gnu.org/licenses/>.
16
16
  *
17
- * Copyright 2022-2025 trebco, llc.
17
+ * Copyright 2022-2026 trebco, llc.
18
18
  * info@treb.app
19
19
  *
20
20
  */
@@ -26,6 +26,7 @@ import type {
26
26
  SheetChangeEvent, GridOptions,
27
27
  CellEvent, FunctionDescriptor,
28
28
  ExternalEditorConfig,
29
+ GridSelectionEvent,
29
30
  } from 'treb-grid';
30
31
 
31
32
  import { DataModel, Sheet, StandardGradientsList } from 'treb-data-model';
@@ -74,6 +75,7 @@ import type {
74
75
  IArea, CellValue, Point,
75
76
  Complex, ExtendedUnion, IRectangle,
76
77
  AddressReference, RangeReference, TableSortOptions, Table, TableTheme,
78
+ Theme,
77
79
  } from 'treb-base-types';
78
80
 
79
81
  import {
@@ -92,7 +94,7 @@ import { NumberFormatCache, ValueParser, NumberFormat, LotusDate, UnlotusDate }
92
94
  import { Dialog, DialogType } from './progress-dialog';
93
95
  import { Spinner } from './spinner';
94
96
  import { type EmbeddedSpreadsheetOptions, DefaultOptions, type ExportOptions } from './options';
95
- import { type TREBDocument, SaveFileType, LoadSource, type EmbeddedSheetEvent, type InsertTableOptions } from './types';
97
+ import { type TREBDocument, SaveFileType, LoadSource, type EmbeddedSheetEvent, type InsertTableOptions, type SelectionEvent } from './types';
96
98
 
97
99
  import type { SelectionState } from './selection-state';
98
100
  import type { BorderToolbarMessage, ToolbarMessage } from './toolbar-message';
@@ -102,6 +104,7 @@ import type { SetRangeOptions, ClipboardData, PasteOptions } from 'treb-grid';
102
104
 
103
105
  import type { StateLeafVertex } from 'treb-calculator';
104
106
 
107
+ import * as ImportExportMessages from 'treb-export/src/import-export-messages';
105
108
 
106
109
  // --- worker ------------------------------------------------------------------
107
110
 
@@ -109,9 +112,20 @@ import type { StateLeafVertex } from 'treb-calculator';
109
112
  * import type for our worker, plus markup files
110
113
  */
111
114
  import './content-types.d.ts';
115
+ import { CreateWorker, type WorkerProxy } from 'treb-base-types';
112
116
 
113
117
  // --- types -------------------------------------------------------------------
114
118
 
119
+ /** new, intended for tui support but keeping it as generic as possible */
120
+ export type CustomGridFactory = (
121
+ options: GridOptions,
122
+ model: DataModel,
123
+ theme: Theme|undefined,
124
+ initialze_dom: boolean,
125
+ DOM: DOMContext,
126
+ ) => Grid;
127
+
128
+
115
129
  /**
116
130
  * options for saving files. we add the option for JSON formatting.
117
131
  */
@@ -164,8 +178,11 @@ export interface LoadDocumentOptions {
164
178
  /** @internal */
165
179
  override_selection?: GridSelection,
166
180
 
167
- /** @internal */
168
181
  source?: LoadSource,
182
+
183
+ /** opaque data for reference */
184
+ path?: string;
185
+
169
186
  }
170
187
 
171
188
  /**
@@ -243,6 +260,18 @@ export type TableFilterFunction = (value: CellValue, calculated_value: CellValue
243
260
  */
244
261
  export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
245
262
 
263
+ /**
264
+ * this is temporary. we need a better way to handle this, perhaps
265
+ * making the factory method (createSpreadsheet) async.
266
+ *
267
+ * for now, you can test on this set of promises to see when the
268
+ * app is ready
269
+ */
270
+ protected _ready_state: Promise<void>[] = [];
271
+ public get ready () {
272
+ return Promise.all(this._ready_state);
273
+ }
274
+
246
275
  /** @internal */
247
276
  public static treb_base_path = '';
248
277
 
@@ -463,8 +492,10 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
463
492
  /**
464
493
  * export worker (no longer using worker-loader).
465
494
  * export worker is loaded on demand, not by default.
495
+ *
496
+ * FIXME: type
466
497
  */
467
- protected export_worker?: Worker;
498
+ protected export_worker?: WorkerProxy<ImportExportMessages.RXMessages, ImportExportMessages.TXMessages>;
468
499
 
469
500
  /**
470
501
  * undo pointer points to the next insert spot. that means that when
@@ -651,7 +682,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
651
682
  *
652
683
  * @internal
653
684
  */
654
- constructor(options: EmbeddedSpreadsheetOptions & { model?: EmbeddedSpreadsheet }) {
685
+ constructor(options: EmbeddedSpreadsheetOptions & { model?: EmbeddedSpreadsheet, custom_grid?: CustomGridFactory }) {
655
686
 
656
687
  // we renamed this option, default to the new name
657
688
 
@@ -832,8 +863,12 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
832
863
 
833
864
  }
834
865
 
835
- //this.extra_calculator = //new Calculator(this.model);
836
- // this.CreateCalculator(this.model);
866
+ // FIXME: we should start figuring out what can happen before
867
+ // this async init, and what has to wait. then we can split the
868
+ // ctor into two parts, and move stuff that has to wait to part 2
869
+
870
+ const calculator_init = this.calculator.InitResources();
871
+ this._ready_state.push(calculator_init);
837
872
 
838
873
  if (container) {
839
874
  this.DOM = DOMContext.GetInstance(container.ownerDocument);
@@ -847,12 +882,30 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
847
882
  // it when we don't have a container? or was it built for something
848
883
  // else? (A: it was)
849
884
 
850
- this.grid = new Grid(
851
- grid_options,
852
- this.model,
853
- undefined,
854
- !!container,
855
- this.DOM);
885
+ if (options.custom_grid) {
886
+ this.grid = options.custom_grid(
887
+ grid_options,
888
+ this.model,
889
+ undefined,
890
+ !!container,
891
+ this.DOM);
892
+
893
+ // we're going to need to create some sort of capabilities map
894
+ // for custom grids. for the time being, let's subscribe to events
895
+ // and see what happens.
896
+
897
+ // UPDATE: do that a little later...
898
+
899
+
900
+ }
901
+ else {
902
+ this.grid = new Grid(
903
+ grid_options,
904
+ this.model,
905
+ undefined,
906
+ !!container,
907
+ this.DOM);
908
+ }
856
909
 
857
910
  if (this.options.headless) {
858
911
  this.grid.headless = true; // FIXME: move into grid options
@@ -970,7 +1023,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
970
1023
 
971
1024
  case 'selection':
972
1025
  // console.info('selection event');
973
- this.UpdateSelection(event.selection);
1026
+ this.UpdateSelection(event.selection, event.reason);
974
1027
  this.UpdateSelectionStyle(event.selection);
975
1028
  break;
976
1029
 
@@ -1133,11 +1186,204 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
1133
1186
 
1134
1187
  }
1135
1188
  else {
1189
+
1190
+ if (options.custom_grid) {
1191
+ console.info("creating subscription for custom grid (TODO: capabilities)")
1192
+
1193
+ ////
1194
+
1195
+
1196
+ this.grid.grid_events.Subscribe((event) => {
1197
+
1198
+ // console.info({event});
1199
+
1200
+ switch (event.type) {
1201
+
1202
+ // these messages can stack, they don't have undo effect
1203
+
1204
+ case 'error':
1205
+ /*
1206
+ this.dialog?.ShowDialog({
1207
+ type: DialogType.error,
1208
+ ...this.TranslateGridError(event.code),
1209
+ timeout: 3000,
1210
+ close_box: true,
1211
+ });
1212
+ */
1213
+
1214
+ // ??
1215
+
1216
+ break;
1217
+
1218
+ case 'selection':
1219
+ // console.info('selection event');
1220
+ this.UpdateSelection(event.selection, event.reason);
1221
+ this.UpdateSelectionStyle(event.selection);
1222
+ break;
1223
+
1224
+ case 'sheet-change':
1225
+ this.OnSheetChange(event);
1226
+ this.UpdateSelectionStyle();
1227
+ break;
1228
+
1229
+ case 'scale':
1230
+ this.RebuildAllAnnotations();
1231
+ this.Publish({ type: 'view-change' });
1232
+ break;
1233
+
1234
+ case 'cell-event':
1235
+ this.HandleCellEvent(event);
1236
+ break;
1237
+
1238
+ // messages that trigger undo need some special handling,
1239
+ // because we don't want to stack a sequence of messages
1240
+ // and push multiple undo events. that applies to data,
1241
+ // style, structure, and (maybe?) annotations
1242
+
1243
+ // OK, temp we have a composite event for data+style
1244
+
1245
+ case 'composite':
1246
+ {
1247
+ const cached_selection = this.last_selection;
1248
+ if (this.calculation === CalculationOptions.automatic) {
1249
+ this.Recalculate(event);
1250
+ }
1251
+ this.DocumentChange(cached_selection);
1252
+ this.UpdateDocumentStyles();
1253
+ this.UpdateSelectionStyle();
1254
+ }
1255
+ break;
1256
+
1257
+ case 'data':
1258
+ {
1259
+ // because this is async (more than once), we can't expect the
1260
+ // selection event to happen after the PushUndo call. we need
1261
+ // to preserve the current selection and pass it through.
1262
+
1263
+ const cached_selection = this.last_selection;
1264
+
1265
+ // recalc is no longer async
1266
+
1267
+ if (this.calculation === CalculationOptions.automatic) {
1268
+ this.Recalculate(event);
1269
+ }
1270
+
1271
+ this.DocumentChange(cached_selection);
1272
+
1273
+ }
1274
+ break;
1275
+
1276
+ case 'style':
1277
+ this.DocumentChange();
1278
+ this.UpdateDocumentStyles();
1279
+ this.UpdateSelectionStyle();
1280
+ break;
1281
+
1282
+ case 'annotation':
1283
+
1284
+ /*
1285
+ // FIXME: maybe need to update vertices (on create, update, delete,
1286
+ // not on move or resize)
1287
+
1288
+ if (event.annotation) {
1289
+ const view: AnnotationViewData = event.annotation.view[this.grid.view_index] || {};
1290
+
1291
+ let update_toolbar = false;
1292
+
1293
+ if (event.event === 'select') {
1294
+ update_toolbar = true;
1295
+ }
1296
+ else {
1297
+ this.DocumentChange();
1298
+ switch (event.event) {
1299
+ case 'create':
1300
+ this.InflateAnnotation(event.annotation);
1301
+ this.calculator.UpdateAnnotations(event.annotation, this.grid.active_sheet);
1302
+ this.grid.AnnotationUpdated(event.annotation);
1303
+ update_toolbar = (event.annotation === this.grid.selected_annotation);
1304
+ break;
1305
+ case 'delete':
1306
+ this.calculator.RemoveAnnotation(event.annotation); // clean up vertex
1307
+ break;
1308
+ case 'update':
1309
+ if (view.update_callback) {
1310
+ view.update_callback();
1311
+ this.grid.AnnotationUpdated(event.annotation);
1312
+ }
1313
+ else {
1314
+ console.info('annotation update event without update callback');
1315
+ }
1316
+ this.calculator.UpdateAnnotations(event.annotation, this.grid.active_sheet);
1317
+ update_toolbar = (event.annotation === this.grid.selected_annotation);
1318
+ break;
1319
+ case 'resize':
1320
+ if (view.resize_callback) {
1321
+ view.resize_callback();
1322
+ this.grid.AnnotationUpdated(event.annotation);
1323
+ }
1324
+ break;
1325
+ }
1326
+
1327
+ }
1328
+
1329
+ if (update_toolbar) {
1330
+ this.UpdateSelectionStyleAnnotation(event.annotation);
1331
+ this.Publish({ type: 'annotation-selection' });
1332
+ break;
1333
+ }
1334
+
1335
+ }
1336
+ else {
1337
+ console.info('annotation event without annotation');
1338
+ }
1339
+ */
1340
+ break;
1341
+
1342
+ case 'structure':
1343
+ {
1344
+ // console.info("S event", event);
1345
+
1346
+ const cached_selection = this.last_selection;
1347
+ if (event.conditional_format) {
1348
+ this.calculator.UpdateConditionals();
1349
+ this.ApplyConditionalFormats(this.grid.active_sheet, false);
1350
+ }
1351
+
1352
+ if (event.rebuild_required) {
1353
+ this.calculator.Reset();
1354
+
1355
+ // recalculate is no longer async
1356
+
1357
+ if (this.calculation === CalculationOptions.automatic) {
1358
+ this.Recalculate(event);
1359
+ }
1360
+ this.DocumentChange(cached_selection);
1361
+
1362
+ }
1363
+ else {
1364
+ this.DocumentChange(cached_selection);
1365
+ }
1366
+ }
1367
+ this.UpdateSelectionStyle();
1368
+ break;
1369
+
1370
+ }
1371
+ });
1372
+
1373
+ ////
1374
+
1375
+
1376
+ }
1377
+
1136
1378
  if (!EmbeddedSpreadsheet.one_time_warnings.headless) {
1137
- EmbeddedSpreadsheet.one_time_warnings.headless = true;
1138
- console.info('not initializing layout; don\'t call UI functions');
1379
+
1380
+ // suppress this warning if you explicitly set headless mode
1381
+
1382
+ if (!options.headless) {
1383
+ EmbeddedSpreadsheet.one_time_warnings.headless = true;
1384
+ console.info('not initializing layout; don\'t call UI functions');
1385
+ }
1139
1386
  }
1140
- // this.grid.headless = true; // ensure
1141
1387
  }
1142
1388
 
1143
1389
  if (options.preload) {
@@ -1151,7 +1397,9 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
1151
1397
  data = JSON.parse(data);
1152
1398
  }
1153
1399
  if (data) {
1154
- this.LoadDocument(data as TREBDocument, { recalculate: !!this.options.recalculate, source});
1400
+ calculator_init.then(() => {
1401
+ this.LoadDocument(data as TREBDocument, { recalculate: !!this.options.recalculate, source});
1402
+ });
1155
1403
  }
1156
1404
  else {
1157
1405
  this.UpdateDocumentStyles();
@@ -1206,13 +1454,16 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
1206
1454
  this.spinner = new Spinner(container);
1207
1455
  }
1208
1456
 
1457
+
1209
1458
  // don't load if we are a split view
1210
1459
  // UPDATE: don't load if we have a local_storage document. this is taking
1211
1460
  // over the old alternate_document flow, because it doesn't make any sense
1212
1461
  // otherwise. what would local_storage with document_name mean otherwise?
1213
1462
 
1214
1463
  if (network_document && !options.model && !data) {
1215
- this.LoadNetworkDocument(network_document, this.options);
1464
+ calculator_init.then(() => {
1465
+ this.LoadNetworkDocument(network_document, this.options);
1466
+ });
1216
1467
  }
1217
1468
 
1218
1469
  // create mask dialog
@@ -1286,6 +1537,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
1286
1537
  return new Calculator(model, {
1287
1538
  complex_numbers: options.complex,
1288
1539
  spill: options.spill,
1540
+ headless: options.headless,
1289
1541
  });
1290
1542
  }
1291
1543
 
@@ -1881,6 +2133,17 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
1881
2133
  case 'insert-scatter-plot': insert_annotation('Scatter.Plot'); break;
1882
2134
  case 'insert-box-plot': insert_annotation('Box.Plot'); break;
1883
2135
 
2136
+ case 'toggle-grouping':
2137
+ if (this.selection_state?.style) {
2138
+ const format = NumberFormatCache.Get(this.selection_state.style.number_format || 'General');
2139
+ if (format.date_format) { break; }
2140
+ const clone = new NumberFormat(format.pattern);
2141
+ clone.ToggleGrouping();
2142
+ const rendered = clone.toString();
2143
+ updated_style.number_format = NumberFormatCache.SymbolicName(rendered) || rendered;
2144
+ }
2145
+ break;
2146
+
1884
2147
  case 'increase-precision':
1885
2148
  case 'decrease-precision':
1886
2149
  if (this.selection_state?.style) {
@@ -1890,78 +2153,18 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
1890
2153
 
1891
2154
  const clone = new NumberFormat(format.pattern);
1892
2155
 
1893
- // special case: from general, we want to go to a relative number...
1894
- // for that to work, we need a (the first) value... then go from there.
1895
-
1896
- // NOTE: this isn't really the way to identify this, we only want
1897
- // to do this if the style === 'General'.
1898
-
1899
- if (format.magic_decimal) {
1900
-
1901
- // but what we're doing here, if there's a magic decimal, is
1902
- // measuring the decimal part of the first number we find. then
1903
- // we increase/decrease from that.
1904
-
1905
- let len = 0;
1906
- let rng = this.GetRange();
1907
-
1908
- // find the first number...
1909
-
1910
- if (!Array.isArray(rng)) {
1911
- rng = [[rng]];
1912
- }
1913
-
1914
- find_number:
1915
- for (let i = 0; i < rng.length; i++) {
1916
- for (let j = 0; j < rng[i].length; j++) {
1917
- const value = rng[i][j];
1918
-
1919
- if (typeof value !== 'undefined' && IsComplex(value)) {
1920
-
1921
- // find the longer of the two, use that as base
1922
-
1923
- //const f2 = NumberFormatCache.Get(this.active_selection_style.number_format || 'General', true);
1924
- const f2 = NumberFormatCache.Get(this.selection_state.style.number_format || 'General', true);
1925
- const real_parts = f2.BaseFormat(value.real);
1926
- const imaginary_parts = f2.BaseFormat(value.imaginary);
1927
-
1928
- if (real_parts.parts && typeof real_parts.parts[1] === 'string') {
1929
- len = real_parts.parts[1].length;
1930
- }
1931
- if (imaginary_parts.parts && typeof imaginary_parts.parts[1] === 'string') {
1932
- len = Math.max(len, imaginary_parts.parts[1].length);
1933
- }
1934
-
1935
- break find_number;
1936
-
1937
- }
1938
- else if (typeof value === 'number') {
1939
- const parts = format.BaseFormat(value);
1940
- if (parts.parts && typeof parts.parts[1] === 'string') {
1941
- len = parts.parts[1].length;
1942
- }
1943
- break find_number;
1944
- }
1945
- }
1946
- }
1947
-
1948
- if (event.command === 'increase-precision') {
1949
- clone.SetDecimal(len + 1);
1950
- }
1951
- else {
1952
- clone.SetDecimal(Math.max(0, len - 1));
1953
- }
1954
-
2156
+ if (event.command === 'increase-precision' ) {
2157
+ clone.IncreaseDecimal();
1955
2158
  }
1956
2159
  else {
1957
- if (event.command === 'increase-precision' ) {
1958
- clone.IncreaseDecimal();
1959
- }
1960
- else {
1961
- clone.DecreaseDecimal();
1962
- }
2160
+ clone.DecreaseDecimal();
1963
2161
  }
1964
- updated_style.number_format = clone.toString();
2162
+
2163
+ // try to resolve this to a standard format, if possible
2164
+
2165
+ const rendered = clone.toString();
2166
+ updated_style.number_format = NumberFormatCache.SymbolicName(rendered) || rendered;
2167
+
1965
2168
  }
1966
2169
  break;
1967
2170
 
@@ -2203,7 +2406,8 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
2203
2406
  // comments
2204
2407
 
2205
2408
  try {
2206
- mod = await import(`esbuild-ignore-import:./languages/treb-i18n-${language}.mjs`);
2409
+ const path = `./languages/treb-i18n-${language}.mjs`;
2410
+ mod = await import(path);
2207
2411
  }
2208
2412
  catch (err) {
2209
2413
  console.error(err);
@@ -2222,6 +2426,10 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
2222
2426
  this.grid.Update(true);
2223
2427
  this.UpdateAC();
2224
2428
 
2429
+ this.Publish({
2430
+ type: 'language-change',
2431
+ });
2432
+
2225
2433
  }
2226
2434
 
2227
2435
  /**
@@ -2870,6 +3078,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
2870
3078
  *
2871
3079
  * @param column - column, or columns (array), or undefined means all columns
2872
3080
  * @param width - desired width (can be 0) or undefined means 'auto-size'
3081
+ * @param allow_shrinking - for auto-size, allow shrinking. defaults to true.
2873
3082
  *
2874
3083
  * @privateRemarks
2875
3084
  *
@@ -2878,9 +3087,8 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
2878
3087
  *
2879
3088
  * @public
2880
3089
  */
2881
- public SetColumnWidth(column?: number | number[], width?: number): void {
2882
-
2883
- this.grid.SetColumnWidth(column, width);
3090
+ public SetColumnWidth(column?: number | number[], width?: number, allow_shrinking?: boolean): void {
3091
+ this.grid.SetColumnWidth(column, width, allow_shrinking);
2884
3092
  }
2885
3093
 
2886
3094
  /**
@@ -3084,14 +3292,16 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
3084
3292
  return new Promise<Blob>((resolve, reject) => {
3085
3293
 
3086
3294
  if (this.export_worker) {
3087
- this.export_worker.onmessage = (event) => {
3088
- resolve(event.data ? event.data.blob : undefined);
3089
- };
3090
- this.export_worker.onerror = (event) => {
3295
+ this.export_worker.OnMessage((event) => {
3296
+ if (event.data.type === 'export-complete') {
3297
+ resolve(event.data.blob);
3298
+ }
3299
+ });
3300
+ this.export_worker.OnError((event) => {
3091
3301
  console.error('export worker error');
3092
3302
  console.info(event);
3093
3303
  reject(event);
3094
- };
3304
+ });
3095
3305
 
3096
3306
  if (!serialized) {
3097
3307
  serialized = this.Serialize({
@@ -3109,8 +3319,8 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
3109
3319
  // why do _we_ put this in, instead of the grid method?
3110
3320
  serialized.decimal_mark = Localization.decimal_separator;
3111
3321
 
3112
- this.export_worker.postMessage({
3113
- command: 'export',
3322
+ this.export_worker.PostMessage({
3323
+ type: 'export',
3114
3324
  sheet: serialized,
3115
3325
  decorated: this.calculator.DecoratedFunctionList(),
3116
3326
  });
@@ -3750,7 +3960,11 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
3750
3960
 
3751
3961
  }
3752
3962
 
3753
- this.Publish({ type: 'load', source: options.source }); // FIXME: should not happen on undo...
3963
+ this.Publish({
3964
+ type: 'load',
3965
+ source: options.source,
3966
+ path: options.path,
3967
+ }); // FIXME: should not happen on undo...
3754
3968
  this.UpdateDocumentStyles();
3755
3969
  this.loaded = true;
3756
3970
 
@@ -4041,7 +4255,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
4041
4255
 
4042
4256
  this.calculator.Calculate(area);
4043
4257
 
4044
- if (this.calculator.grid_expanded) {
4258
+ if (this.calculator.grid_expanded && !this.grid.headless) {
4045
4259
  // console.info("GRID EXPANDED");
4046
4260
  this.grid.UpdateLayout();
4047
4261
  }
@@ -4090,8 +4304,9 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
4090
4304
  * Revert state one level from the undo stack.
4091
4305
  *
4092
4306
  * @public
4307
+ * @returns true if undo succeeded, false if the undo stack was empty
4093
4308
  */
4094
- public Undo(): void {
4309
+ public Undo(): boolean {
4095
4310
 
4096
4311
  // this is half of the problem, we also need to manage views when
4097
4312
  // we set undo states
@@ -4104,7 +4319,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
4104
4319
 
4105
4320
  if (this.undo_pointer <= 1) {
4106
4321
  console.warn('nothing to undo');
4107
- return;
4322
+ return false;
4108
4323
  }
4109
4324
 
4110
4325
  const undo_entry = this.undo_stack[(--this.undo_pointer) - 1];
@@ -4134,6 +4349,8 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
4134
4349
 
4135
4350
  // this.file_version--; // decrement
4136
4351
 
4352
+ return true;
4353
+
4137
4354
  }
4138
4355
 
4139
4356
 
@@ -5060,8 +5277,8 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
5060
5277
  /**
5061
5278
  *
5062
5279
  */
5063
- protected async ImportXLSX( // data: string, source: LoadSource): Promise<Blob | void> {
5064
- data: ArrayBuffer, source: LoadSource): Promise<Blob | void> {
5280
+ public async ImportXLSX( // data: string, source: LoadSource): Promise<Blob | void> {
5281
+ data: ArrayBuffer, source: LoadSource, path?: string): Promise<Blob | void> {
5065
5282
 
5066
5283
  // this is inlined to ensure the code will be tree-shaken properly
5067
5284
  if (!process.env.XLSX_SUPPORT) {
@@ -5089,12 +5306,15 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
5089
5306
  message: 'Importing XLSX...'
5090
5307
  });
5091
5308
 
5092
- this.export_worker.onmessage = (event) => {
5309
+ this.export_worker.OnMessage((event) => {
5093
5310
  if (event.data) {
5094
5311
 
5095
- if (event.data.status === 'error') {
5312
+ if (event.data.type === 'import-error') {
5096
5313
  return reject(event.data.error || 'unknown error');
5097
5314
  }
5315
+ if (event.data.type !== 'import-complete') {
5316
+ return reject('unknown error (invalid message)');
5317
+ }
5098
5318
 
5099
5319
  if (this.parser.decimal_mark !== DecimalMarkType.Period) {
5100
5320
 
@@ -5118,15 +5338,15 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
5118
5338
  });
5119
5339
  };
5120
5340
 
5121
- for (const named of event.data.results) {
5122
- named.expression = translate(named.expression);
5341
+ for (const named of event.data.results.named || []) {
5342
+ named.expression = translate(named.expression) || '';
5123
5343
  }
5124
5344
 
5125
5345
  for (const sheet of event.data.results.sheets || []) {
5126
5346
 
5127
5347
  for (const cell of sheet.cells || []) {
5128
5348
  if (cell.type === 'formula' && cell.value) {
5129
- cell.value = translate(cell.value);
5349
+ cell.value = translate(cell.value as string);
5130
5350
  }
5131
5351
  }
5132
5352
 
@@ -5152,7 +5372,7 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
5152
5372
  // this one _is_ the grid cells
5153
5373
 
5154
5374
  // this.calculator.AttachModel();
5155
- this.Publish({ type: 'load', source, });
5375
+ this.Publish({ type: 'load', source, path });
5156
5376
  this.UpdateDocumentStyles();
5157
5377
 
5158
5378
  // add to support import charts
@@ -5171,15 +5391,18 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
5171
5391
 
5172
5392
  this.dialog?.HideDialog();
5173
5393
  resolve();
5174
- };
5175
- this.export_worker.onerror = (event) => {
5394
+ });
5395
+
5396
+ this.export_worker.OnError((event) => {
5176
5397
  console.error('import worker error');
5177
5398
  console.info(event);
5178
5399
  reject(event);
5179
- };
5180
- this.export_worker.postMessage({
5181
- command: 'import', data,
5182
5400
  });
5401
+
5402
+ this.export_worker.PostMessage({
5403
+ type: 'import', data,
5404
+ });
5405
+
5183
5406
  }
5184
5407
  else {
5185
5408
  reject('worker failed');
@@ -5630,21 +5853,6 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
5630
5853
  }
5631
5854
  }
5632
5855
 
5633
- /*
5634
- public SetHeadless(headless = true): void {
5635
- if (this.grid.headless === headless) {
5636
- return;
5637
- }
5638
-
5639
- this.grid.headless = headless;
5640
- if (!headless) {
5641
- this.grid.Update(true);
5642
- this.RebuildAllAnnotations();
5643
- // this.InflateAnnotations();
5644
- }
5645
- }
5646
- */
5647
-
5648
5856
  /**
5649
5857
  * this method should be called after changing the headless flag
5650
5858
  */
@@ -6119,14 +6327,19 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
6119
6327
  * we can also use this to better manage selection in the undo system...
6120
6328
  *
6121
6329
  */
6122
- protected UpdateSelection(selection: GridSelection): void {
6330
+ protected UpdateSelection(selection: GridSelection, reason?: GridSelectionEvent['reason']): void {
6123
6331
 
6124
6332
  // console.info("US", JSON.stringify(selection));
6125
6333
 
6126
6334
  // cache for undo
6127
6335
  this.last_selection = JSON.stringify(selection);
6128
6336
 
6129
- this.Publish({ type: 'selection' });
6337
+ const event: SelectionEvent = { type: 'selection' };
6338
+ if (reason === 'sheet-change') {
6339
+ event.reason = reason;
6340
+ }
6341
+
6342
+ this.Publish(event);
6130
6343
  }
6131
6344
 
6132
6345
  /** update selection style for the toolbar, when an annotation is selected. */
@@ -6240,12 +6453,6 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
6240
6453
 
6241
6454
  }
6242
6455
 
6243
- /* * overloadable for subclasses * /
6244
- protected InitCalculator(): CalcType {
6245
- return new Calculator();
6246
- }
6247
- */
6248
-
6249
6456
  /**
6250
6457
  * this function is called when the file locale (as indicated by the
6251
6458
  * decimal separator) is different than the current active locale.
@@ -6577,21 +6784,17 @@ export class EmbeddedSpreadsheet<USER_DATA_TYPE = unknown> {
6577
6784
  }
6578
6785
 
6579
6786
  /**
6580
- * worker now uses a dynamic import with a module built separately.
6581
- * see `export-worker.ts` (in this directory) for more detail.
6582
- */
6583
- protected async LoadWorker(): Promise<Worker> {
6584
- try {
6585
- const worker = `export`;
6586
- const mod = await import(`esbuild-ignore-import:./treb-${worker}-worker.mjs`) as {
6587
- CreateWorker: () => Promise<Worker>;
6588
- };
6589
- return await mod.CreateWorker();
6590
- }
6591
- catch (err) {
6592
- console.error(err);
6593
- throw(err);
6594
- }
6787
+ * switching to worker proxy so we can support node
6788
+ * FIXME: type
6789
+ */
6790
+ protected async LoadWorker(): Promise<WorkerProxy<ImportExportMessages.RXMessages, ImportExportMessages.TXMessages>> {
6791
+ const worker = CreateWorker<ImportExportMessages.RXMessages, ImportExportMessages.TXMessages>(!!this.options.in_process_workers);
6792
+ await worker.Init('./treb-export-worker.mjs', () => {
6793
+ return new Worker(new URL('./treb-export-worker.mjs', import.meta.url), {
6794
+ type: 'module'
6795
+ }) as Worker;
6796
+ });
6797
+ return worker;
6595
6798
  }
6596
6799
 
6597
6800
  /**