logisheets 0.7.0 → 1.0.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 (461) hide show
  1. package/dist/src/api/block_manager.d.ts +21 -0
  2. package/dist/src/api/block_manager.js +35 -0
  3. package/dist/src/api/calculator.d.ts +19 -0
  4. package/dist/src/api/calculator.js +46 -0
  5. package/dist/src/api/cell.d.ts +29 -0
  6. package/dist/src/api/cell.js +55 -0
  7. package/dist/src/api/craft-calc.d.ts +83 -0
  8. package/dist/src/api/craft-calc.js +223 -0
  9. package/dist/src/api/index.d.ts +6 -0
  10. package/dist/src/api/index.js +4 -0
  11. package/dist/src/api/utils.d.ts +3 -1
  12. package/dist/src/api/utils.js +7 -0
  13. package/dist/src/api/workbook.d.ts +82 -10
  14. package/dist/src/api/workbook.js +285 -64
  15. package/dist/src/api/worksheet.d.ts +32 -11
  16. package/dist/src/api/worksheet.js +146 -19
  17. package/dist/src/bindings/action_effect.d.ts +56 -0
  18. package/dist/src/bindings/action_effect.js +96 -1
  19. package/dist/src/bindings/alignment.d.ts +7 -0
  20. package/dist/src/bindings/app_data.d.ts +4 -0
  21. package/dist/src/bindings/appendix.d.ts +5 -0
  22. package/dist/src/bindings/appendix_with_cell.d.ts +8 -0
  23. package/dist/src/bindings/async_func_result.d.ts +10 -0
  24. package/dist/src/bindings/async_func_result.js +19 -1
  25. package/dist/src/bindings/bind_form_schema.d.ts +42 -0
  26. package/dist/src/bindings/bind_form_schema.js +68 -0
  27. package/dist/src/bindings/bind_random_schema.d.ts +23 -0
  28. package/dist/src/bindings/bind_random_schema.js +33 -0
  29. package/dist/src/bindings/block_cell_id.d.ts +1 -1
  30. package/dist/src/bindings/block_cell_id.js +0 -1
  31. package/dist/src/bindings/block_cell_info.d.ts +5 -0
  32. package/dist/src/bindings/block_display_info.d.ts +7 -0
  33. package/dist/src/bindings/block_field.d.ts +5 -0
  34. package/dist/src/bindings/block_info.d.ts +8 -0
  35. package/dist/src/bindings/block_info.js +0 -1
  36. package/dist/src/bindings/block_input.d.ts +19 -0
  37. package/dist/src/bindings/block_input.js +40 -2
  38. package/dist/src/bindings/block_line_name_field_update.d.ts +34 -0
  39. package/dist/src/bindings/block_line_name_field_update.js +50 -0
  40. package/dist/src/bindings/block_line_style_update.d.ts +31 -0
  41. package/dist/src/bindings/block_line_style_update.js +47 -0
  42. package/dist/src/bindings/block_schema.d.ts +11 -0
  43. package/dist/src/bindings/block_schema_field_entry.d.ts +5 -0
  44. package/dist/src/bindings/block_schema_key_entry.d.ts +4 -0
  45. package/dist/src/bindings/block_schema_random_entry.d.ts +6 -0
  46. package/dist/src/bindings/block_schema_type.d.ts +1 -0
  47. package/dist/src/bindings/block_style_update.d.ts +19 -0
  48. package/dist/src/bindings/block_style_update.js +40 -1
  49. package/dist/src/bindings/cell_alignment.d.ts +6 -6
  50. package/dist/src/bindings/cell_clear.d.ts +18 -0
  51. package/dist/src/bindings/cell_clear.js +26 -0
  52. package/dist/src/bindings/cell_coordinate.d.ts +4 -0
  53. package/dist/src/bindings/cell_coordinate.js +1 -0
  54. package/dist/src/bindings/cell_coordinate_with_sheet.d.ts +5 -0
  55. package/dist/src/bindings/cell_coordinate_with_sheet.js +1 -0
  56. package/dist/src/bindings/cell_format_brush.d.ts +38 -0
  57. package/dist/src/bindings/cell_format_brush.js +61 -0
  58. package/dist/src/bindings/cell_id.d.ts +8 -3
  59. package/dist/src/bindings/cell_info.d.ts +2 -0
  60. package/dist/src/bindings/cell_input.d.ts +16 -0
  61. package/dist/src/bindings/cell_input.js +33 -2
  62. package/dist/src/bindings/cell_position.d.ts +4 -0
  63. package/dist/src/bindings/cell_position.js +1 -0
  64. package/dist/src/bindings/cell_protection.js +0 -1
  65. package/dist/src/bindings/cell_ref.d.ts +9 -0
  66. package/dist/src/bindings/cell_ref.js +1 -0
  67. package/dist/src/bindings/cell_style_update.d.ts +23 -0
  68. package/dist/src/bindings/cell_style_update.js +33 -0
  69. package/dist/src/bindings/col_info.js +0 -1
  70. package/dist/src/bindings/color.js +0 -1
  71. package/dist/src/bindings/comment.js +0 -1
  72. package/dist/src/bindings/convert_block.d.ts +30 -0
  73. package/dist/src/bindings/convert_block.js +47 -0
  74. package/dist/src/bindings/create_appendix.d.ts +38 -0
  75. package/dist/src/bindings/create_appendix.js +57 -0
  76. package/dist/src/bindings/create_block.d.ts +31 -0
  77. package/dist/src/bindings/create_block.js +57 -2
  78. package/dist/src/bindings/create_diy_cell.d.ts +18 -0
  79. package/dist/src/bindings/create_diy_cell.js +26 -0
  80. package/dist/src/bindings/create_diy_cell_by_id.d.ts +22 -0
  81. package/dist/src/bindings/create_diy_cell_by_id.js +33 -0
  82. package/dist/src/bindings/create_sheet.d.ts +10 -0
  83. package/dist/src/bindings/create_sheet.js +19 -2
  84. package/dist/src/bindings/ct_border.d.ts +13 -0
  85. package/dist/src/bindings/ct_border.js +1 -0
  86. package/dist/src/bindings/ct_border_pr.d.ts +6 -0
  87. package/dist/src/bindings/ct_border_pr.js +1 -0
  88. package/dist/src/bindings/ct_color.d.ts +7 -0
  89. package/dist/src/bindings/ct_color.js +1 -0
  90. package/dist/src/bindings/ct_fill.d.ts +9 -0
  91. package/dist/src/bindings/ct_fill.js +1 -0
  92. package/dist/src/bindings/ct_font.d.ts +25 -0
  93. package/dist/src/bindings/ct_font.js +1 -0
  94. package/dist/src/bindings/ct_gradient_fill.d.ts +11 -0
  95. package/dist/src/bindings/ct_gradient_fill.js +1 -0
  96. package/dist/src/bindings/ct_gradient_stop.d.ts +5 -0
  97. package/dist/src/bindings/ct_gradient_stop.js +1 -0
  98. package/dist/src/bindings/ct_pattern_fill.d.ts +7 -0
  99. package/dist/src/bindings/ct_pattern_fill.js +1 -0
  100. package/dist/src/bindings/delete_cols.d.ts +13 -0
  101. package/dist/src/bindings/delete_cols.js +26 -2
  102. package/dist/src/bindings/delete_cols_in_block.d.ts +16 -0
  103. package/dist/src/bindings/delete_cols_in_block.js +33 -2
  104. package/dist/src/bindings/delete_rows.d.ts +13 -0
  105. package/dist/src/bindings/delete_rows.js +26 -2
  106. package/dist/src/bindings/delete_rows_in_block.d.ts +16 -0
  107. package/dist/src/bindings/delete_rows_in_block.js +33 -2
  108. package/dist/src/bindings/delete_sheet.d.ts +7 -0
  109. package/dist/src/bindings/delete_sheet.js +12 -2
  110. package/dist/src/bindings/display_window.d.ts +14 -0
  111. package/dist/src/bindings/display_window.js +1 -0
  112. package/dist/src/bindings/display_window_request.d.ts +7 -0
  113. package/dist/src/bindings/display_window_request.js +1 -0
  114. package/dist/src/bindings/display_window_with_start_point.d.ts +6 -0
  115. package/dist/src/bindings/display_window_with_start_point.js +1 -0
  116. package/dist/src/bindings/edit_action.d.ts +5 -3
  117. package/dist/src/bindings/edit_payload.d.ts +160 -27
  118. package/dist/src/bindings/ephemeral_cell_input.d.ts +18 -0
  119. package/dist/src/bindings/ephemeral_cell_input.js +26 -0
  120. package/dist/src/bindings/ephemeral_cell_remove.d.ts +14 -0
  121. package/dist/src/bindings/ephemeral_cell_remove.js +19 -0
  122. package/dist/src/bindings/ephemeral_cell_style_update.d.ts +19 -0
  123. package/dist/src/bindings/ephemeral_cell_style_update.js +26 -0
  124. package/dist/src/bindings/error_message.js +0 -1
  125. package/dist/src/bindings/field_render_entry.d.ts +6 -0
  126. package/dist/src/bindings/field_render_entry.js +1 -0
  127. package/dist/src/bindings/fill.d.ts +5 -3
  128. package/dist/src/bindings/font_family.js +0 -1
  129. package/dist/src/bindings/font_name.js +0 -1
  130. package/dist/src/bindings/font_size.d.ts +3 -0
  131. package/dist/src/bindings/font_size.js +1 -0
  132. package/dist/src/bindings/formula_display_info.d.ts +6 -0
  133. package/dist/src/bindings/formula_display_info.js +1 -0
  134. package/dist/src/bindings/horizontal_alignment.d.ts +1 -0
  135. package/dist/src/bindings/horizontal_alignment.js +1 -0
  136. package/dist/src/bindings/index.d.ts +123 -14
  137. package/dist/src/bindings/index.js +123 -14
  138. package/dist/src/bindings/insert_cols.d.ts +13 -0
  139. package/dist/src/bindings/insert_cols.js +26 -2
  140. package/dist/src/bindings/insert_cols_in_block.d.ts +16 -0
  141. package/dist/src/bindings/insert_cols_in_block.js +33 -2
  142. package/dist/src/bindings/insert_rows.d.ts +13 -0
  143. package/dist/src/bindings/insert_rows.js +26 -2
  144. package/dist/src/bindings/insert_rows_in_block.d.ts +16 -0
  145. package/dist/src/bindings/insert_rows_in_block.js +33 -2
  146. package/dist/src/bindings/int_property.d.ts +3 -0
  147. package/dist/src/bindings/int_property.js +1 -0
  148. package/dist/src/bindings/line_format_brush.d.ts +34 -0
  149. package/dist/src/bindings/line_format_brush.js +54 -0
  150. package/dist/src/bindings/line_style_update.d.ts +27 -0
  151. package/dist/src/bindings/line_style_update.js +40 -0
  152. package/dist/src/bindings/merge_cell.d.ts +4 -4
  153. package/dist/src/bindings/merge_cell.js +0 -1
  154. package/dist/src/bindings/merge_cells.d.ts +26 -0
  155. package/dist/src/bindings/merge_cells.js +40 -0
  156. package/dist/src/bindings/modify_policy.d.ts +1 -0
  157. package/dist/src/bindings/modify_policy.js +1 -0
  158. package/dist/src/bindings/move_block.d.ts +16 -0
  159. package/dist/src/bindings/move_block.js +33 -2
  160. package/dist/src/bindings/move_block_line.d.ts +26 -0
  161. package/dist/src/bindings/move_block_line.js +40 -0
  162. package/dist/src/bindings/msg_sequencer_action_invalid_message.js +0 -1
  163. package/dist/src/bindings/msg_sequencer_init_workbook.js +0 -1
  164. package/dist/src/bindings/msg_sequencer_message.d.ts +7 -4
  165. package/dist/src/bindings/msg_user_message.d.ts +5 -3
  166. package/dist/src/bindings/normal_cell_id.js +0 -1
  167. package/dist/src/bindings/payloads_action.d.ts +1 -0
  168. package/dist/src/bindings/random_schema_unit.d.ts +22 -0
  169. package/dist/src/bindings/random_schema_unit.js +33 -0
  170. package/dist/src/bindings/raw_style.d.ts +13 -0
  171. package/dist/src/bindings/raw_style.js +1 -0
  172. package/dist/src/bindings/remove_appendix.d.ts +26 -0
  173. package/dist/src/bindings/remove_appendix.js +36 -0
  174. package/dist/src/bindings/remove_block.d.ts +10 -0
  175. package/dist/src/bindings/remove_block.js +19 -2
  176. package/dist/src/bindings/remove_diy_cell.d.ts +18 -0
  177. package/dist/src/bindings/remove_diy_cell.js +26 -0
  178. package/dist/src/bindings/remove_diy_cell_by_id.d.ts +22 -0
  179. package/dist/src/bindings/remove_diy_cell_by_id.js +33 -0
  180. package/dist/src/bindings/reorder_block_lines.d.ts +6 -0
  181. package/dist/src/bindings/reorder_block_lines.js +1 -0
  182. package/dist/src/bindings/reproduce_cells.d.ts +23 -0
  183. package/dist/src/bindings/reproduce_cells.js +33 -0
  184. package/dist/src/bindings/reproducible_cell.d.ts +10 -0
  185. package/dist/src/bindings/reproducible_cell.js +1 -0
  186. package/dist/src/bindings/resize_block.d.ts +22 -0
  187. package/dist/src/bindings/resize_block.js +29 -0
  188. package/dist/src/bindings/row_info.js +0 -1
  189. package/dist/src/bindings/rpc_batch_get_cell_coordinate_with_sheet_by_id_params.d.ts +4 -0
  190. package/dist/src/bindings/rpc_batch_get_cell_coordinate_with_sheet_by_id_params.js +1 -0
  191. package/dist/src/bindings/rpc_batch_get_cell_info_by_id_params.d.ts +4 -0
  192. package/dist/src/bindings/rpc_batch_get_cell_info_by_id_params.js +1 -0
  193. package/dist/src/bindings/rpc_calc_condition_params.d.ts +4 -0
  194. package/dist/src/bindings/rpc_calc_condition_params.js +1 -0
  195. package/dist/src/bindings/rpc_check_formula_params.d.ts +3 -0
  196. package/dist/src/bindings/rpc_check_formula_params.js +1 -0
  197. package/dist/src/bindings/rpc_direction.d.ts +1 -0
  198. package/dist/src/bindings/rpc_direction.js +1 -0
  199. package/dist/src/bindings/rpc_get_available_block_id_params.d.ts +3 -0
  200. package/dist/src/bindings/rpc_get_available_block_id_params.js +1 -0
  201. package/dist/src/bindings/rpc_get_block_col_id_params.d.ts +5 -0
  202. package/dist/src/bindings/rpc_get_block_col_id_params.js +1 -0
  203. package/dist/src/bindings/rpc_get_block_display_window_params.d.ts +4 -0
  204. package/dist/src/bindings/rpc_get_block_display_window_params.js +1 -0
  205. package/dist/src/bindings/rpc_get_block_info_params.d.ts +4 -0
  206. package/dist/src/bindings/rpc_get_block_info_params.js +1 -0
  207. package/dist/src/bindings/rpc_get_block_row_id_params.d.ts +5 -0
  208. package/dist/src/bindings/rpc_get_block_row_id_params.js +1 -0
  209. package/dist/src/bindings/rpc_get_block_values_params.d.ts +6 -0
  210. package/dist/src/bindings/rpc_get_block_values_params.js +1 -0
  211. package/dist/src/bindings/rpc_get_cell_id_by_block_ref_params.d.ts +5 -0
  212. package/dist/src/bindings/rpc_get_cell_id_by_block_ref_params.js +1 -0
  213. package/dist/src/bindings/rpc_get_cell_id_params.d.ts +5 -0
  214. package/dist/src/bindings/rpc_get_cell_id_params.js +1 -0
  215. package/dist/src/bindings/rpc_get_cell_infos_params.d.ts +7 -0
  216. package/dist/src/bindings/rpc_get_cell_infos_params.js +1 -0
  217. package/dist/src/bindings/rpc_get_cell_params.d.ts +5 -0
  218. package/dist/src/bindings/rpc_get_cell_params.js +1 -0
  219. package/dist/src/bindings/rpc_get_cell_position_params.d.ts +5 -0
  220. package/dist/src/bindings/rpc_get_cell_position_params.js +1 -0
  221. package/dist/src/bindings/rpc_get_cells_except_window_params.d.ts +11 -0
  222. package/dist/src/bindings/rpc_get_cells_except_window_params.js +1 -0
  223. package/dist/src/bindings/rpc_get_cells_params.d.ts +7 -0
  224. package/dist/src/bindings/rpc_get_cells_params.js +1 -0
  225. package/dist/src/bindings/rpc_get_col_width_params.d.ts +4 -0
  226. package/dist/src/bindings/rpc_get_col_width_params.js +1 -0
  227. package/dist/src/bindings/rpc_get_display_units_of_formula_params.d.ts +3 -0
  228. package/dist/src/bindings/rpc_get_display_units_of_formula_params.js +1 -0
  229. package/dist/src/bindings/rpc_get_display_window_params.d.ts +7 -0
  230. package/dist/src/bindings/rpc_get_display_window_params.js +1 -0
  231. package/dist/src/bindings/rpc_get_display_window_with_start_point_params.d.ts +7 -0
  232. package/dist/src/bindings/rpc_get_display_window_with_start_point_params.js +1 -0
  233. package/dist/src/bindings/rpc_get_display_window_within_cell_params.d.ts +7 -0
  234. package/dist/src/bindings/rpc_get_display_window_within_cell_params.js +1 -0
  235. package/dist/src/bindings/rpc_get_diy_cell_id_with_block_id_params.d.ts +6 -0
  236. package/dist/src/bindings/rpc_get_diy_cell_id_with_block_id_params.js +1 -0
  237. package/dist/src/bindings/rpc_get_merged_cells_params.d.ts +7 -0
  238. package/dist/src/bindings/rpc_get_merged_cells_params.js +1 -0
  239. package/dist/src/bindings/rpc_get_next_visible_cell_params.d.ts +7 -0
  240. package/dist/src/bindings/rpc_get_next_visible_cell_params.js +1 -0
  241. package/dist/src/bindings/rpc_get_reproducible_cell_params.d.ts +5 -0
  242. package/dist/src/bindings/rpc_get_reproducible_cell_params.js +1 -0
  243. package/dist/src/bindings/rpc_get_reproducible_cells_params.d.ts +5 -0
  244. package/dist/src/bindings/rpc_get_reproducible_cells_params.js +1 -0
  245. package/dist/src/bindings/rpc_get_row_height_params.d.ts +4 -0
  246. package/dist/src/bindings/rpc_get_row_height_params.js +1 -0
  247. package/dist/src/bindings/rpc_get_row_info_params.d.ts +4 -0
  248. package/dist/src/bindings/rpc_get_row_info_params.js +1 -0
  249. package/dist/src/bindings/rpc_get_shadow_cell_id_params.d.ts +7 -0
  250. package/dist/src/bindings/rpc_get_shadow_cell_id_params.js +1 -0
  251. package/dist/src/bindings/rpc_get_shadow_cell_ids_params.d.ts +7 -0
  252. package/dist/src/bindings/rpc_get_shadow_cell_ids_params.js +1 -0
  253. package/dist/src/bindings/rpc_get_shadow_info_by_id_params.d.ts +3 -0
  254. package/dist/src/bindings/rpc_get_shadow_info_by_id_params.js +1 -0
  255. package/dist/src/bindings/rpc_get_sheet_dimension_params.d.ts +3 -0
  256. package/dist/src/bindings/rpc_get_sheet_dimension_params.js +1 -0
  257. package/dist/src/bindings/rpc_get_sheet_id_params.d.ts +3 -0
  258. package/dist/src/bindings/rpc_get_sheet_id_params.js +1 -0
  259. package/dist/src/bindings/rpc_get_sheet_idx_params.d.ts +3 -0
  260. package/dist/src/bindings/rpc_get_sheet_idx_params.js +1 -0
  261. package/dist/src/bindings/rpc_get_sheet_name_by_idx_params.d.ts +3 -0
  262. package/dist/src/bindings/rpc_get_sheet_name_by_idx_params.js +1 -0
  263. package/dist/src/bindings/rpc_handle_transaction_params.d.ts +4 -0
  264. package/dist/src/bindings/rpc_handle_transaction_params.js +1 -0
  265. package/dist/src/bindings/rpc_load_workbook_params.d.ts +4 -0
  266. package/dist/src/bindings/rpc_load_workbook_params.js +1 -0
  267. package/dist/src/bindings/rpc_lookup_appendix_upward_params.d.ts +8 -0
  268. package/dist/src/bindings/rpc_lookup_appendix_upward_params.js +1 -0
  269. package/dist/src/bindings/rpc_save_params.d.ts +3 -0
  270. package/dist/src/bindings/rpc_save_params.js +1 -0
  271. package/dist/src/bindings/rpc_toggle_status_params.d.ts +3 -0
  272. package/dist/src/bindings/rpc_toggle_status_params.js +1 -0
  273. package/dist/src/bindings/rpc_transaction.d.ts +6 -0
  274. package/dist/src/bindings/rpc_transaction.js +1 -0
  275. package/dist/src/bindings/rpc_workbook_methods.d.ts +116 -0
  276. package/dist/src/bindings/rpc_workbook_methods.js +1 -0
  277. package/dist/src/bindings/save_file_result.d.ts +4 -0
  278. package/dist/src/bindings/save_file_result.js +1 -0
  279. package/dist/src/bindings/set_col_width.d.ts +13 -0
  280. package/dist/src/bindings/set_col_width.js +26 -2
  281. package/dist/src/bindings/set_row_height.d.ts +13 -0
  282. package/dist/src/bindings/set_row_height.js +26 -2
  283. package/dist/src/bindings/set_sheet_color.d.ts +14 -0
  284. package/dist/src/bindings/set_sheet_color.js +19 -0
  285. package/dist/src/bindings/set_sheet_visible.d.ts +14 -0
  286. package/dist/src/bindings/set_sheet_visible.js +19 -0
  287. package/dist/src/bindings/set_visible.d.ts +16 -0
  288. package/dist/src/bindings/set_visible.js +33 -2
  289. package/dist/src/bindings/shadow_cell_info.d.ts +7 -0
  290. package/dist/src/bindings/shadow_cell_info.js +1 -0
  291. package/dist/src/bindings/shadow_kind.d.ts +1 -0
  292. package/dist/src/bindings/shadow_kind.js +1 -0
  293. package/dist/src/bindings/sheet_cell_id.d.ts +15 -0
  294. package/dist/src/bindings/sheet_cell_id.js +19 -0
  295. package/dist/src/bindings/sheet_col_id.d.ts +14 -0
  296. package/dist/src/bindings/sheet_col_id.js +19 -0
  297. package/dist/src/bindings/sheet_coordinate.d.ts +4 -0
  298. package/dist/src/bindings/sheet_coordinate.js +1 -0
  299. package/dist/src/bindings/sheet_dimension.d.ts +6 -0
  300. package/dist/src/bindings/sheet_dimension.js +1 -0
  301. package/dist/src/bindings/sheet_info.d.ts +6 -0
  302. package/dist/src/bindings/sheet_info.js +1 -0
  303. package/dist/src/bindings/sheet_rename.d.ts +13 -0
  304. package/dist/src/bindings/sheet_rename.js +22 -2
  305. package/dist/src/bindings/sheet_row_id.d.ts +14 -0
  306. package/dist/src/bindings/sheet_row_id.js +19 -0
  307. package/dist/src/bindings/split_merged_cells.d.ts +18 -0
  308. package/dist/src/bindings/split_merged_cells.js +26 -0
  309. package/dist/src/bindings/st_border_style.d.ts +1 -1
  310. package/dist/src/bindings/st_border_style.js +0 -1
  311. package/dist/src/bindings/st_font_scheme.d.ts +1 -1
  312. package/dist/src/bindings/st_font_scheme.js +0 -1
  313. package/dist/src/bindings/st_gradient_type.d.ts +1 -1
  314. package/dist/src/bindings/st_gradient_type.js +0 -1
  315. package/dist/src/bindings/st_horizontal_alignment.d.ts +1 -1
  316. package/dist/src/bindings/st_horizontal_alignment.js +0 -1
  317. package/dist/src/bindings/st_pattern_type.d.ts +1 -1
  318. package/dist/src/bindings/st_pattern_type.js +0 -1
  319. package/dist/src/bindings/st_underline_values.d.ts +1 -1
  320. package/dist/src/bindings/st_underline_values.js +0 -1
  321. package/dist/src/bindings/st_vertical_align_run.d.ts +1 -1
  322. package/dist/src/bindings/st_vertical_align_run.js +0 -1
  323. package/dist/src/bindings/st_vertical_alignment.d.ts +1 -1
  324. package/dist/src/bindings/st_vertical_alignment.js +0 -1
  325. package/dist/src/bindings/status_code.d.ts +6 -3
  326. package/dist/src/bindings/status_code.js +0 -1
  327. package/dist/src/bindings/style.d.ts +2 -2
  328. package/dist/src/bindings/style_update_type.d.ts +79 -0
  329. package/dist/src/bindings/style_update_type.js +125 -1
  330. package/dist/src/bindings/task.js +0 -1
  331. package/dist/src/bindings/temp_cell_change.d.ts +8 -0
  332. package/dist/src/bindings/temp_cell_change.js +1 -0
  333. package/dist/src/bindings/temp_status_diff.d.ts +4 -0
  334. package/dist/src/bindings/temp_status_diff.js +1 -0
  335. package/dist/src/bindings/token_type.d.ts +1 -0
  336. package/dist/src/bindings/token_type.js +1 -0
  337. package/dist/src/bindings/token_unit.d.ts +6 -0
  338. package/dist/src/bindings/token_unit.js +1 -0
  339. package/dist/src/bindings/upsert_field_formulas.d.ts +18 -0
  340. package/dist/src/bindings/upsert_field_formulas.js +26 -0
  341. package/dist/src/bindings/upsert_field_render_info.d.ts +19 -0
  342. package/dist/src/bindings/upsert_field_render_info.js +26 -0
  343. package/dist/src/bindings/value.d.ts +9 -5
  344. package/dist/src/bindings/value.js +0 -1
  345. package/dist/src/bindings/vertical_alignment.d.ts +1 -0
  346. package/dist/src/bindings/vertical_alignment.js +1 -0
  347. package/dist/src/bindings/workbook_file.js +0 -1
  348. package/dist/src/bindings/workbook_update_type.d.ts +1 -0
  349. package/dist/src/bindings/workbook_update_type.js +1 -0
  350. package/dist/src/client.d.ts +25 -0
  351. package/dist/src/client.js +1 -0
  352. package/dist/src/index.d.ts +5 -2
  353. package/dist/src/index.js +5 -1
  354. package/dist/src/layout.d.ts +7 -0
  355. package/dist/src/layout.js +1 -0
  356. package/dist/src/payloads/index.d.ts +1 -43
  357. package/dist/src/payloads/index.js +1 -21
  358. package/dist/src/payloads/set_block_line_name_field.d.ts +34 -0
  359. package/dist/src/payloads/set_block_line_name_field.js +62 -0
  360. package/dist/src/payloads/set_block_line_num_fmt.d.ts +23 -0
  361. package/dist/src/payloads/set_block_line_num_fmt.js +54 -0
  362. package/dist/src/payloads/set_cell_alignment.d.ts +18 -0
  363. package/dist/src/payloads/{set_col_width.js → set_cell_alignment.js} +15 -8
  364. package/dist/src/payloads/{set_border.d.ts → set_cell_border.d.ts} +3 -4
  365. package/dist/src/payloads/{set_border.js → set_cell_border.js} +1 -2
  366. package/dist/src/payloads/{set_font.d.ts → set_cell_font.d.ts} +3 -4
  367. package/dist/src/payloads/{set_font.js → set_cell_font.js} +1 -2
  368. package/dist/src/payloads/{cell_input.d.ts → set_cell_num_fmt.d.ts} +6 -7
  369. package/dist/src/payloads/{cell_input.js → set_cell_num_fmt.js} +7 -8
  370. package/dist/src/payloads/set_cell_pattern_fill.d.ts +24 -0
  371. package/dist/src/payloads/{block_input.js → set_cell_pattern_fill.js} +15 -14
  372. package/dist/src/payloads/set_cell_wrap_text.d.ts +17 -0
  373. package/dist/src/payloads/{set_col_visible.js → set_cell_wrap_text.js} +15 -8
  374. package/dist/src/payloads/set_field_num_fmt.d.ts +14 -0
  375. package/dist/src/payloads/set_field_num_fmt.js +30 -0
  376. package/dist/src/payloads/set_line_alignment.d.ts +21 -0
  377. package/dist/src/payloads/set_line_alignment.js +46 -0
  378. package/dist/src/payloads/set_line_border.d.ts +48 -0
  379. package/dist/src/payloads/set_line_border.js +96 -0
  380. package/dist/src/payloads/set_line_font.d.ts +48 -0
  381. package/dist/src/payloads/set_line_font.js +98 -0
  382. package/dist/src/payloads/set_line_num_fmt.d.ts +20 -0
  383. package/dist/src/payloads/set_line_num_fmt.js +46 -0
  384. package/dist/src/payloads/set_line_pattern_fill.d.ts +27 -0
  385. package/dist/src/payloads/set_line_pattern_fill.js +56 -0
  386. package/dist/src/payloads/set_line_wrap_text.d.ts +20 -0
  387. package/dist/src/payloads/set_line_wrap_text.js +46 -0
  388. package/dist/src/types.d.ts +31 -0
  389. package/dist/src/types.js +21 -0
  390. package/dist/src/utils.d.ts +1 -0
  391. package/dist/src/utils.js +22 -0
  392. package/package.json +4 -3
  393. package/dist/src/bindings/cell_formula_value.d.ts +0 -7
  394. package/dist/src/bindings/cell_style.d.ts +0 -6
  395. package/dist/src/bindings/display_patch.d.ts +0 -25
  396. package/dist/src/bindings/display_request.d.ts +0 -4
  397. package/dist/src/bindings/display_request.js +0 -2
  398. package/dist/src/bindings/display_response.d.ts +0 -5
  399. package/dist/src/bindings/sheet_blocks.d.ts +0 -5
  400. package/dist/src/bindings/sheet_col_info.d.ts +0 -6
  401. package/dist/src/bindings/sheet_comments.d.ts +0 -5
  402. package/dist/src/bindings/sheet_merge_cells.d.ts +0 -5
  403. package/dist/src/bindings/sheet_names.d.ts +0 -3
  404. package/dist/src/bindings/sheet_names.js +0 -2
  405. package/dist/src/bindings/sheet_row_info.d.ts +0 -6
  406. package/dist/src/bindings/sheet_styles.d.ts +0 -5
  407. package/dist/src/bindings/sheet_values.d.ts +0 -5
  408. package/dist/src/bindings/style_update.d.ts +0 -7
  409. package/dist/src/payloads/block_input.d.ts +0 -21
  410. package/dist/src/payloads/create_block.d.ts +0 -24
  411. package/dist/src/payloads/create_block.js +0 -61
  412. package/dist/src/payloads/delete_block_cols.d.ts +0 -18
  413. package/dist/src/payloads/delete_block_cols.js +0 -39
  414. package/dist/src/payloads/delete_block_rows.d.ts +0 -18
  415. package/dist/src/payloads/delete_block_rows.js +0 -39
  416. package/dist/src/payloads/delete_cols.d.ts +0 -15
  417. package/dist/src/payloads/delete_cols.js +0 -31
  418. package/dist/src/payloads/delete_rows.d.ts +0 -15
  419. package/dist/src/payloads/delete_rows.js +0 -31
  420. package/dist/src/payloads/delete_sheet.d.ts +0 -9
  421. package/dist/src/payloads/delete_sheet.js +0 -15
  422. package/dist/src/payloads/insert_block_cols.d.ts +0 -18
  423. package/dist/src/payloads/insert_block_cols.js +0 -39
  424. package/dist/src/payloads/insert_block_rows.d.ts +0 -18
  425. package/dist/src/payloads/insert_block_rows.js +0 -39
  426. package/dist/src/payloads/insert_cols.d.ts +0 -15
  427. package/dist/src/payloads/insert_cols.js +0 -31
  428. package/dist/src/payloads/insert_rows.d.ts +0 -15
  429. package/dist/src/payloads/insert_rows.js +0 -31
  430. package/dist/src/payloads/insert_sheet.d.ts +0 -12
  431. package/dist/src/payloads/insert_sheet.js +0 -23
  432. package/dist/src/payloads/move_block.d.ts +0 -18
  433. package/dist/src/payloads/move_block.js +0 -39
  434. package/dist/src/payloads/set_col_visible.d.ts +0 -15
  435. package/dist/src/payloads/set_col_width.d.ts +0 -15
  436. package/dist/src/payloads/set_row_height.d.ts +0 -15
  437. package/dist/src/payloads/set_row_height.js +0 -31
  438. package/dist/src/payloads/set_row_visible.d.ts +0 -15
  439. package/dist/src/payloads/set_row_visible.js +0 -31
  440. package/dist/src/payloads/sheet_rename.d.ts +0 -15
  441. package/dist/src/payloads/sheet_rename.js +0 -29
  442. package/dist/src/transactions.d.ts +0 -7
  443. package/dist/src/transactions.js +0 -12
  444. package/wasm/.gitignore +0 -1
  445. package/wasm/logisheets_wasm_server.d.ts +0 -255
  446. package/wasm/logisheets_wasm_server.js +0 -946
  447. package/wasm/logisheets_wasm_server_bg.wasm +0 -0
  448. package/wasm/logisheets_wasm_server_bg.wasm.d.ts +0 -40
  449. package/wasm/package.json +0 -14
  450. /package/dist/src/bindings/{cell_formula_value.js → alignment.js} +0 -0
  451. /package/dist/src/bindings/{cell_style.js → app_data.js} +0 -0
  452. /package/dist/src/bindings/{display_patch.js → appendix.js} +0 -0
  453. /package/dist/src/bindings/{display_response.js → appendix_with_cell.js} +0 -0
  454. /package/dist/src/bindings/{sheet_blocks.js → block_cell_info.js} +0 -0
  455. /package/dist/src/bindings/{sheet_col_info.js → block_display_info.js} +0 -0
  456. /package/dist/src/bindings/{sheet_comments.js → block_field.js} +0 -0
  457. /package/dist/src/bindings/{sheet_merge_cells.js → block_schema.js} +0 -0
  458. /package/dist/src/bindings/{sheet_row_info.js → block_schema_field_entry.js} +0 -0
  459. /package/dist/src/bindings/{sheet_styles.js → block_schema_key_entry.js} +0 -0
  460. /package/dist/src/bindings/{sheet_values.js → block_schema_random_entry.js} +0 -0
  461. /package/dist/src/bindings/{style_update.js → block_schema_type.js} +0 -0
@@ -0,0 +1,21 @@
1
+ export declare class BlockManager {
2
+ constructor(checkBindBlock: (sheetIdx: number, blockId: number, rowCount: number, colCount: number) => boolean, getAvailableBlockId: (sheetIdx: number) => number);
3
+ /**
4
+ * Todo: make sure that the block/craft will never be changed by other
5
+ * crafts.
6
+ */
7
+ bindBlock(sheetIdx: number, blockId: number, rowCount: number, colCount: number): boolean;
8
+ /**
9
+ * This function should only find the greatest block id when the available block id
10
+ * has been set. After that, it will always use the cached value.
11
+ * This means that every time you call this function after initialization,
12
+ * it will return a new block id. It will lead to the waste of block ids if you don't create
13
+ * a block with this id.
14
+ *
15
+ * Block id is `usize` in `WASM` side. It should be enough for most cases even we waste some of the ids.
16
+ */
17
+ getAvailableBlockId(sheetIdx: number): number;
18
+ private sheetAvailableBlockIds;
19
+ private _checkBindBlock;
20
+ private _getAvailableBlockId;
21
+ }
@@ -0,0 +1,35 @@
1
+ export class BlockManager {
2
+ constructor(checkBindBlock, getAvailableBlockId) {
3
+ this._checkBindBlock = checkBindBlock;
4
+ this._getAvailableBlockId = getAvailableBlockId;
5
+ }
6
+ /**
7
+ * Todo: make sure that the block/craft will never be changed by other
8
+ * crafts.
9
+ */
10
+ bindBlock(sheetIdx, blockId, rowCount, colCount) {
11
+ return this._checkBindBlock(sheetIdx, blockId, rowCount, colCount);
12
+ }
13
+ /**
14
+ * This function should only find the greatest block id when the available block id
15
+ * has been set. After that, it will always use the cached value.
16
+ * This means that every time you call this function after initialization,
17
+ * it will return a new block id. It will lead to the waste of block ids if you don't create
18
+ * a block with this id.
19
+ *
20
+ * Block id is `usize` in `WASM` side. It should be enough for most cases even we waste some of the ids.
21
+ */
22
+ getAvailableBlockId(sheetIdx) {
23
+ if (this.sheetAvailableBlockIds.has(sheetIdx)) {
24
+ const result = this.sheetAvailableBlockIds.get(sheetIdx);
25
+ this.sheetAvailableBlockIds.set(sheetIdx, result + 1);
26
+ return result;
27
+ }
28
+ const id = this._getAvailableBlockId(sheetIdx);
29
+ this.sheetAvailableBlockIds.set(sheetIdx, id);
30
+ return id;
31
+ }
32
+ sheetAvailableBlockIds = new Map();
33
+ _checkBindBlock;
34
+ _getAvailableBlockId;
35
+ }
@@ -0,0 +1,19 @@
1
+ import { AsyncFuncResult, Task } from '../bindings';
2
+ export declare const enum CalcException {
3
+ Unspecified = 0,
4
+ ArgErr = 1,
5
+ TimeOut = 2,
6
+ NotFound = 3
7
+ }
8
+ export type Executor = (args: readonly string[]) => Promise<string | CalcException>;
9
+ export declare class CustomFunc {
10
+ readonly funcName: string;
11
+ executor: Executor;
12
+ constructor(funcName: string, executor: Executor);
13
+ }
14
+ export declare class Calculator {
15
+ calc(tasks: readonly Task[]): Promise<AsyncFuncResult>;
16
+ registry(f: CustomFunc): void;
17
+ private _exec;
18
+ private _registry;
19
+ }
@@ -0,0 +1,46 @@
1
+ export class CustomFunc {
2
+ funcName;
3
+ executor;
4
+ constructor(funcName, executor) {
5
+ this.funcName = funcName;
6
+ this.executor = executor;
7
+ }
8
+ }
9
+ export class Calculator {
10
+ async calc(tasks) {
11
+ const promises = tasks.map((t) => this._exec(t.asyncFunc, t.args));
12
+ return Promise.all(promises).then((values) => {
13
+ const res = values.map((v) => {
14
+ if (typeof v === 'string') {
15
+ return v;
16
+ }
17
+ switch (v) {
18
+ case 1 /* CalcException.ArgErr */:
19
+ return '#ARGERR!';
20
+ case 2 /* CalcException.TimeOut */:
21
+ return '#TIMEOUT!';
22
+ case 3 /* CalcException.NotFound */:
23
+ return '#NOTFOUND!';
24
+ default:
25
+ return '#UNKNOWN!';
26
+ }
27
+ });
28
+ const asyncFuncResult = {
29
+ tasks,
30
+ values: res,
31
+ };
32
+ return asyncFuncResult;
33
+ });
34
+ }
35
+ registry(f) {
36
+ this._registry.set(f.funcName, f.executor);
37
+ }
38
+ async _exec(func, args) {
39
+ const executor = this._registry.get(func);
40
+ if (executor === undefined) {
41
+ return 3 /* CalcException.NotFound */;
42
+ }
43
+ return executor(args);
44
+ }
45
+ _registry = new Map();
46
+ }
@@ -0,0 +1,29 @@
1
+ import { CellInfo, Value, Style } from '../bindings';
2
+ export declare class Cell {
3
+ constructor(cellInfo: CellInfo);
4
+ getText(): string;
5
+ getStyle(): Style;
6
+ getFormula(): string;
7
+ getBlockId(): number | undefined;
8
+ toCellInfo(): CellInfo;
9
+ private _value;
10
+ private _info;
11
+ }
12
+ export declare class CellValue {
13
+ cellValueOneof?: {
14
+ $case: 'str';
15
+ str: string;
16
+ } | {
17
+ $case: 'number';
18
+ number: number;
19
+ } | {
20
+ $case: 'bool';
21
+ bool: boolean;
22
+ } | {
23
+ $case: 'error';
24
+ error: string;
25
+ };
26
+ get value(): string | number | boolean;
27
+ get valueStr(): string;
28
+ static from(value: Value): CellValue;
29
+ }
@@ -0,0 +1,55 @@
1
+ export class Cell {
2
+ constructor(cellInfo) {
3
+ this._value = CellValue.from(cellInfo.value);
4
+ this._info = cellInfo;
5
+ }
6
+ getText() {
7
+ return this._value.valueStr ?? '';
8
+ }
9
+ getStyle() {
10
+ return this._info.style;
11
+ }
12
+ getFormula() {
13
+ return this._info.formula;
14
+ }
15
+ getBlockId() {
16
+ return this._info.blockId;
17
+ }
18
+ toCellInfo() {
19
+ return this._info;
20
+ }
21
+ _value;
22
+ _info;
23
+ }
24
+ export class CellValue {
25
+ cellValueOneof;
26
+ get value() {
27
+ if (this.cellValueOneof?.$case === 'str')
28
+ return this.cellValueOneof.str;
29
+ else if (this.cellValueOneof?.$case === 'bool')
30
+ return this.cellValueOneof.bool;
31
+ else if (this.cellValueOneof?.$case === 'error')
32
+ return this.cellValueOneof.error;
33
+ else if (this.cellValueOneof?.$case === 'number')
34
+ return this.cellValueOneof.number;
35
+ else
36
+ return '';
37
+ }
38
+ get valueStr() {
39
+ return this.value.toString();
40
+ }
41
+ static from(value) {
42
+ const v = new CellValue();
43
+ if (value === 'empty')
44
+ return v;
45
+ if (value.type === 'str')
46
+ v.cellValueOneof = { $case: 'str', str: value.value };
47
+ else if (value.type === 'bool')
48
+ v.cellValueOneof = { $case: 'bool', bool: value.value };
49
+ else if (value.type === 'number')
50
+ v.cellValueOneof = { $case: 'number', number: value.value };
51
+ else if (value.type === 'error')
52
+ v.cellValueOneof = { $case: 'error', error: value.value };
53
+ return v;
54
+ }
55
+ }
@@ -0,0 +1,83 @@
1
+ import type { Value } from '../bindings/value';
2
+ import type { Client } from '../client';
3
+ /**
4
+ * Per-craft temporary-calculation handle.
5
+ *
6
+ * Each craft (or the host UI, treated identically) acquires one of these
7
+ * via {@link acquireCraftCalc}. The handle scopes a private range of
8
+ * ephemeral cell ids; the craft picks small `localId` numbers and never
9
+ * sees engine-wide ids.
10
+ *
11
+ * Two flavours:
12
+ * - {@link calcOnce} — fire-and-forget. Uses one reserved slot inside
13
+ * the craft's range; each call overwrites the previous result.
14
+ * - {@link setCalc} / {@link getCalc} / {@link dropCalc} — caller-owned
15
+ * `localId`. The slot persists (and auto-recomputes on dep changes)
16
+ * until dropped.
17
+ *
18
+ * Slot 0 inside each craft range is reserved for `calcOnce`; user
19
+ * `localId`s are transparently offset by 1 so they cannot collide.
20
+ *
21
+ * Lifetime notes:
22
+ * - Ephemeral cells are wiped on file save/load (that's what "ephemeral"
23
+ * means). No reload-survival design is needed.
24
+ * - `dropCalc` removes one slot; `dropAll` removes every slot the craft
25
+ * has touched in this session — both emit `ephemeralCellRemove`
26
+ * payloads which free the container slot and detach the cell from the
27
+ * dependency graph.
28
+ */
29
+ export declare class CraftCalc {
30
+ private readonly _workbook;
31
+ private static readonly HOST_SHEET_IDX;
32
+ private readonly _base;
33
+ private _sheetId;
34
+ private readonly _live;
35
+ constructor(_workbook: Client, base: number);
36
+ /**
37
+ * Evaluate `formula` once and return the result. Internally uses the
38
+ * craft's reserved one-shot slot; consecutive calls overwrite each
39
+ * other. Safe across calls within the same craft (the slot is
40
+ * craft-private); concurrent in-flight calls within one craft race
41
+ * for the slot — caller should await one before issuing the next.
42
+ *
43
+ * `formula` may be passed with or without a leading `=`.
44
+ */
45
+ calcOnce(formula: string): Promise<Value>;
46
+ /**
47
+ * Set (or replace) the formula in a caller-owned slot and return the
48
+ * freshly computed value. `localId` is craft-local — pick any
49
+ * non-negative integer; collisions between crafts are impossible.
50
+ */
51
+ setCalc(localId: number, formula: string): Promise<Value>;
52
+ /**
53
+ * Read the current value of a previously-set slot. The value
54
+ * auto-tracks dependency changes (same depgraph the workbook uses
55
+ * for normal cells), so repeated `getCalc` calls reflect the latest
56
+ * state without re-issuing the formula.
57
+ *
58
+ * Throws if `localId` was never `setCalc`-ed (or has been dropped).
59
+ */
60
+ getCalc(localId: number): Promise<Value>;
61
+ /**
62
+ * Release a caller-owned slot. Emits one `ephemeralCellRemove`
63
+ * payload — frees the container slot and removes the cell from the
64
+ * dependency graph. Safe to call on a slot that was never written
65
+ * (the engine treats it as a no-op).
66
+ */
67
+ dropCalc(localId: number): Promise<void>;
68
+ /**
69
+ * Release every slot this handle has touched this session in one
70
+ * transaction. Call on craft unmount.
71
+ */
72
+ dropAll(): Promise<void>;
73
+ private _oneShotEngineId;
74
+ private _userEngineId;
75
+ private _resolveSheetId;
76
+ private _remove;
77
+ private _evaluate;
78
+ }
79
+ /**
80
+ * Allocate a fresh ephemeral-id range and return a {@link CraftCalc}
81
+ * handle scoped to it. Call once per craft (or per host-UI context).
82
+ */
83
+ export declare function acquireCraftCalc(workbook: Client): CraftCalc;
@@ -0,0 +1,223 @@
1
+ import { EphemeralCellInputBuilder } from '../bindings/ephemeral_cell_input';
2
+ import { EphemeralCellRemoveBuilder } from '../bindings/ephemeral_cell_remove';
3
+ import { isErrorMessage } from './utils';
4
+ // Ephemeral-cell-id partitioning:
5
+ //
6
+ // 0x0000_0000_0000_0000 .. 0x0000_0000_FFFF_FFFF engine-reserved
7
+ // 0x0000_0001_0000_0000 .. ... per-craft ranges
8
+ //
9
+ // Each craft gets a fresh range of CRAFT_RANGE_SIZE ids on acquire.
10
+ // JS Number is safe to 2^53, the bindings take id as `number`, so we
11
+ // keep both base and offset in plain Number. With 2^32 reserved for the
12
+ // engine and 2^20 per craft, we can hand out ~2^21 craft ranges before
13
+ // running into precision concerns — plenty.
14
+ const ENGINE_RESERVED_END = 0x1_0000_0000; // 2^32
15
+ const CRAFT_RANGE_SIZE = 1 << 20; // 2^20 ids per craft
16
+ // Bumped on every acquire. Lives for the JS session only; on reload
17
+ // crafts re-acquire and get fresh ranges. Since crafts hold no state of
18
+ // their own and rebuild from blocks, the id range identity does not need
19
+ // to survive reloads.
20
+ let nextCraftBase = ENGINE_RESERVED_END;
21
+ /**
22
+ * Per-craft temporary-calculation handle.
23
+ *
24
+ * Each craft (or the host UI, treated identically) acquires one of these
25
+ * via {@link acquireCraftCalc}. The handle scopes a private range of
26
+ * ephemeral cell ids; the craft picks small `localId` numbers and never
27
+ * sees engine-wide ids.
28
+ *
29
+ * Two flavours:
30
+ * - {@link calcOnce} — fire-and-forget. Uses one reserved slot inside
31
+ * the craft's range; each call overwrites the previous result.
32
+ * - {@link setCalc} / {@link getCalc} / {@link dropCalc} — caller-owned
33
+ * `localId`. The slot persists (and auto-recomputes on dep changes)
34
+ * until dropped.
35
+ *
36
+ * Slot 0 inside each craft range is reserved for `calcOnce`; user
37
+ * `localId`s are transparently offset by 1 so they cannot collide.
38
+ *
39
+ * Lifetime notes:
40
+ * - Ephemeral cells are wiped on file save/load (that's what "ephemeral"
41
+ * means). No reload-survival design is needed.
42
+ * - `dropCalc` removes one slot; `dropAll` removes every slot the craft
43
+ * has touched in this session — both emit `ephemeralCellRemove`
44
+ * payloads which free the container slot and detach the cell from the
45
+ * dependency graph.
46
+ */
47
+ export class CraftCalc {
48
+ _workbook;
49
+ // Host scratch sheet hosting all ephemeral calc cells. Sheet 0 is
50
+ // always present in any workbook this API targets. BLOCKREF and
51
+ // other ref-name lookups don't care which sheet hosts the cell.
52
+ static HOST_SHEET_IDX = 0;
53
+ _base;
54
+ // Cached resolved sheetId for HOST_SHEET_IDX.
55
+ _sheetId;
56
+ // Engine ids of every slot we've written this session, so dropAll
57
+ // can flush them all. `_oneShotEngineId()` lazily lands here too the
58
+ // first time calcOnce runs.
59
+ _live = new Set();
60
+ constructor(_workbook, base) {
61
+ this._workbook = _workbook;
62
+ this._base = base;
63
+ }
64
+ /**
65
+ * Evaluate `formula` once and return the result. Internally uses the
66
+ * craft's reserved one-shot slot; consecutive calls overwrite each
67
+ * other. Safe across calls within the same craft (the slot is
68
+ * craft-private); concurrent in-flight calls within one craft race
69
+ * for the slot — caller should await one before issuing the next.
70
+ *
71
+ * `formula` may be passed with or without a leading `=`.
72
+ */
73
+ async calcOnce(formula) {
74
+ return this._evaluate(this._oneShotEngineId(), formula);
75
+ }
76
+ /**
77
+ * Set (or replace) the formula in a caller-owned slot and return the
78
+ * freshly computed value. `localId` is craft-local — pick any
79
+ * non-negative integer; collisions between crafts are impossible.
80
+ */
81
+ async setCalc(localId, formula) {
82
+ return this._evaluate(this._userEngineId(localId), formula);
83
+ }
84
+ /**
85
+ * Read the current value of a previously-set slot. The value
86
+ * auto-tracks dependency changes (same depgraph the workbook uses
87
+ * for normal cells), so repeated `getCalc` calls reflect the latest
88
+ * state without re-issuing the formula.
89
+ *
90
+ * Throws if `localId` was never `setCalc`-ed (or has been dropped).
91
+ */
92
+ async getCalc(localId) {
93
+ const sheetId = await this._resolveSheetId();
94
+ const engineId = this._userEngineId(localId);
95
+ const infos = await this._workbook.batchGetCellInfoById({
96
+ ids: [
97
+ {
98
+ sheetId,
99
+ cellId: { type: 'ephemeralCell', value: engineId },
100
+ },
101
+ ],
102
+ });
103
+ if (isErrorMessage(infos))
104
+ throw new Error(`getCalc(${localId}) failed: ${JSON.stringify(infos)}`);
105
+ return infos[0].value;
106
+ }
107
+ /**
108
+ * Release a caller-owned slot. Emits one `ephemeralCellRemove`
109
+ * payload — frees the container slot and removes the cell from the
110
+ * dependency graph. Safe to call on a slot that was never written
111
+ * (the engine treats it as a no-op).
112
+ */
113
+ async dropCalc(localId) {
114
+ await this._remove(this._userEngineId(localId));
115
+ }
116
+ /**
117
+ * Release every slot this handle has touched this session in one
118
+ * transaction. Call on craft unmount.
119
+ */
120
+ async dropAll() {
121
+ if (this._live.size === 0)
122
+ return;
123
+ const payloads = Array.from(this._live).map((engineId) => ({
124
+ type: 'ephemeralCellRemove',
125
+ value: new EphemeralCellRemoveBuilder()
126
+ .sheetIdx(CraftCalc.HOST_SHEET_IDX)
127
+ .id(engineId)
128
+ .build(),
129
+ }));
130
+ this._live.clear();
131
+ const res = await this._workbook.handleTransaction({
132
+ transaction: { payloads, undoable: false, temp: false },
133
+ });
134
+ if (isErrorMessage(res))
135
+ throw new Error(`dropAll failed: ${JSON.stringify(res)}`);
136
+ }
137
+ // -- internals ------------------------------------------------------
138
+ _oneShotEngineId() {
139
+ return this._base; // slot 0 inside the range
140
+ }
141
+ _userEngineId(localId) {
142
+ if (!Number.isInteger(localId) || localId < 0)
143
+ throw new Error(`localId must be a non-negative integer: ${localId}`);
144
+ const offset = localId + 1; // reserve slot 0 for calcOnce
145
+ if (offset >= CRAFT_RANGE_SIZE)
146
+ throw new Error(`localId ${localId} exceeds craft range size ${CRAFT_RANGE_SIZE}`);
147
+ return this._base + offset;
148
+ }
149
+ async _resolveSheetId() {
150
+ if (this._sheetId !== undefined)
151
+ return this._sheetId;
152
+ const r = await this._workbook.getSheetId({
153
+ sheetIdx: CraftCalc.HOST_SHEET_IDX,
154
+ });
155
+ if (isErrorMessage(r))
156
+ throw new Error(`CraftCalc: getSheetId(0) failed: ${JSON.stringify(r)}`);
157
+ this._sheetId = r;
158
+ return r;
159
+ }
160
+ async _remove(engineId) {
161
+ this._live.delete(engineId);
162
+ const res = await this._workbook.handleTransaction({
163
+ transaction: {
164
+ payloads: [
165
+ {
166
+ type: 'ephemeralCellRemove',
167
+ value: new EphemeralCellRemoveBuilder()
168
+ .sheetIdx(CraftCalc.HOST_SHEET_IDX)
169
+ .id(engineId)
170
+ .build(),
171
+ },
172
+ ],
173
+ undoable: false,
174
+ temp: false,
175
+ },
176
+ });
177
+ if (isErrorMessage(res))
178
+ throw new Error(`CraftCalc: drop failed: ${JSON.stringify(res)}`);
179
+ }
180
+ async _evaluate(engineId, formula) {
181
+ this._live.add(engineId);
182
+ const expr = formula.startsWith('=') ? formula : `=${formula}`;
183
+ const writeResult = await this._workbook.handleTransaction({
184
+ transaction: {
185
+ payloads: [
186
+ {
187
+ type: 'ephemeralCellInput',
188
+ value: new EphemeralCellInputBuilder()
189
+ .sheetIdx(CraftCalc.HOST_SHEET_IDX)
190
+ .id(engineId)
191
+ .content(expr)
192
+ .build(),
193
+ },
194
+ ],
195
+ undoable: false,
196
+ temp: false,
197
+ },
198
+ });
199
+ if (isErrorMessage(writeResult))
200
+ throw new Error(`CraftCalc: formula evaluation failed: ${JSON.stringify(writeResult)}`);
201
+ const sheetId = await this._resolveSheetId();
202
+ const infos = await this._workbook.batchGetCellInfoById({
203
+ ids: [
204
+ {
205
+ sheetId,
206
+ cellId: { type: 'ephemeralCell', value: engineId },
207
+ },
208
+ ],
209
+ });
210
+ if (isErrorMessage(infos))
211
+ throw new Error(`CraftCalc: read-back failed: ${JSON.stringify(infos)}`);
212
+ return infos[0].value;
213
+ }
214
+ }
215
+ /**
216
+ * Allocate a fresh ephemeral-id range and return a {@link CraftCalc}
217
+ * handle scoped to it. Call once per craft (or per host-UI context).
218
+ */
219
+ export function acquireCraftCalc(workbook) {
220
+ const base = nextCraftBase;
221
+ nextCraftBase += CRAFT_RANGE_SIZE;
222
+ return new CraftCalc(workbook, base);
223
+ }
@@ -1,2 +1,8 @@
1
1
  export * from './workbook';
2
2
  export * from './worksheet';
3
+ export { CalcException, CustomFunc, Calculator } from './calculator';
4
+ export type { Executor } from './calculator';
5
+ export * from './cell';
6
+ export { CraftCalc, acquireCraftCalc } from './craft-calc';
7
+ export { isErrorMessage, getPatternFill } from './utils';
8
+ export type { Result } from './utils';
@@ -1,2 +1,6 @@
1
1
  export * from './workbook';
2
2
  export * from './worksheet';
3
+ export { CustomFunc, Calculator } from './calculator';
4
+ export * from './cell';
5
+ export { CraftCalc, acquireCraftCalc } from './craft-calc';
6
+ export { isErrorMessage, getPatternFill } from './utils';
@@ -1,3 +1,5 @@
1
+ import { Fill, PatternFill } from '../bindings';
1
2
  import { ErrorMessage } from '../bindings/error_message';
2
3
  export declare function isErrorMessage(v: any): v is ErrorMessage;
3
- export declare type Result<V> = V | ErrorMessage;
4
+ export type Result<V> = V | ErrorMessage;
5
+ export declare function getPatternFill(v: Fill): PatternFill | null;
@@ -1,4 +1,11 @@
1
1
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
2
2
  export function isErrorMessage(v) {
3
+ if (typeof v !== 'object' || v === null)
4
+ return false;
3
5
  return 'msg' in v && 'ty' in v;
4
6
  }
7
+ export function getPatternFill(v) {
8
+ if (v.type === 'patternFill')
9
+ return v.value;
10
+ return null;
11
+ }
@@ -1,18 +1,90 @@
1
- import { ActionEffect, AsyncFuncResult, DisplayResponse } from '../bindings';
2
- import { Transaction } from '../transactions';
1
+ import { ActionEffect, BlockField, FormulaDisplayInfo, ShadowCellInfo, SheetCellId, SheetInfo, SaveFileResult, AppData, CellInfo, CellCoordinateWithSheet, Transaction, GetBlockValuesParams, GetCellIdParams, GetShadowCellIdParams, GetShadowCellIdsParams, GetAvailableBlockIdParams, TempStatusDiff } from '../bindings';
2
+ import { ColId, RowId } from '../types';
3
3
  import { Worksheet } from './worksheet';
4
- export declare type ReturnCode = number;
4
+ import { CustomFunc } from './calculator';
5
+ import { Result } from './utils';
6
+ export type ReturnCode = number;
7
+ export type Callback = () => void;
8
+ export type CellIdCallback = (cellId: SheetCellId) => void;
5
9
  export declare class Workbook {
6
10
  constructor();
11
+ getSheetIdx(sheetId: number): Result<number>;
12
+ getBlockValues(params: GetBlockValuesParams): Result<readonly string[]>;
13
+ getAvailableBlockId(params: GetAvailableBlockIdParams): Result<number>;
14
+ /**
15
+ * @returns the block id if success, otherwise the error message
16
+ *
17
+ * It is caller's responsibility to store the block id.
18
+ */
19
+ createBlockForNewCraft(sheetIdx: number, masterRow: number, masterCol: number, rowCnt: number, colCnt: number): Result<number>;
7
20
  undo(): boolean;
8
21
  redo(): boolean;
9
- execTransaction(tx: Transaction, undoable: boolean): ActionEffect;
10
- load(buf: Uint8Array, book_name: string): ReturnCode;
22
+ registerCellUpdatedCallback(callback: Callback): void;
23
+ registerSheetInfoUpdateCallback(callback: Callback): void;
24
+ /**
25
+ * Fires after a transaction with sheet indices whose row/column headers
26
+ * changed (i.e. SetRowHeight / SetColWidth payloads). Useful for the UI
27
+ * to know which sheets need their header strip re-rendered.
28
+ */
29
+ registerHeaderUpdatedCallback(callback: (sheetIdxes: readonly number[]) => void): void;
30
+ getSheetNameByIdx(idx: number): Result<string>;
31
+ getAllSheetInfo(): Array<SheetInfo>;
32
+ checkFormula(f: string): boolean;
33
+ calcCondition(sheetIdx: number, f: string): Result<boolean>;
34
+ /**
35
+ * Resolve a (refName, key, field) triple to a concrete cell, the same
36
+ * way the BLOCKREF formula resolves at evaluation time. Useful for
37
+ * subscribing to block cells without threading sheet/block/row/col
38
+ * coordinates.
39
+ */
40
+ getCellIdByBlockRef(refName: string, key: string, field: string): Result<SheetCellId>;
41
+ /**
42
+ * Snapshot of all cell-value differences between the active temp
43
+ * branch and the committed (fork) status. Returns an empty diff
44
+ * when no temp branch is active. Used by the host's diff layer to
45
+ * drive its overlay without needing JS-side snapshot/compare.
46
+ */
47
+ getTempStatusChanges(): Result<TempStatusDiff>;
48
+ getSheetId(sheetIdx: number): Result<number>;
49
+ getBlockRowId(sheetId: number, blockId: number, rowIdx: number): Result<RowId>;
50
+ getBlockColId(sheetId: number, blockId: number, colIdx: number): Result<ColId>;
51
+ getDisplayUnitsOfFormula(f: string): Result<FormulaDisplayInfo>;
52
+ onCellValueChanged(sheetIdx: number, rowIdx: number, colIdx: number, callback: Callback): Result<void>;
53
+ onCellRemoved(sheetIdx: number, rowIdx: number, colIdx: number, callback: Callback): Result<void>;
54
+ onShadowCellValueChanged(sheetIdx: number, rowIdx: number, colIdx: number, callback: Callback): Result<void>;
55
+ private _registerCellRemovedCallback;
56
+ private _registerCellValueChangedCallback;
57
+ registerCellValueChangedByCellId(cellId: SheetCellId, callback: Callback): void;
58
+ commitTempStatus(): void;
59
+ cleanupTempStatus(): void;
60
+ toggleStatus(useTemp: boolean): void;
61
+ batchGetCellInfoById(ids: readonly SheetCellId[]): Result<readonly CellInfo[]>;
62
+ batchGetCellCoordinateWithSheetById(ids: readonly SheetCellId[]): Result<readonly CellCoordinateWithSheet[]>;
63
+ execTransaction(tx: Transaction): ActionEffect;
64
+ load(buf: Uint8Array, bookName: string): ReturnCode;
65
+ save(data: string): SaveFileResult;
66
+ getAppData(): readonly AppData[];
11
67
  release(): void;
12
- inputAsyncResult(r: AsyncFuncResult): ActionEffect;
13
- getPatches(sheet_idx: number, version: number): DisplayResponse;
14
- get_sheet_count(): number;
15
- get_worksheet(idx: number): Worksheet;
16
- private _addPayload;
68
+ getSheetCount(): number;
69
+ getWorksheet(idx: number): Worksheet;
70
+ getWorksheetById(id: number): Worksheet;
71
+ registryCustomFunc(customFunc: CustomFunc): void;
72
+ getShadowCellId(params: GetShadowCellIdParams): Result<number>;
73
+ getShadowCellIds(params: GetShadowCellIdsParams): Result<readonly number[]>;
74
+ getShadowInfoById(params: {
75
+ shadowId: number;
76
+ }): Result<ShadowCellInfo>;
77
+ getCellId(params: GetCellIdParams): Result<SheetCellId>;
78
+ getAllBlockFields(): Result<readonly BlockField[]>;
79
+ private _inputAsyncResult;
80
+ private _onCellUpdate;
81
+ private _onSheetUpdate;
82
+ private _cellUpdatedCallbacks;
83
+ private _sheetInfoUpdatedCallbacks;
84
+ private _headerUpdatedCallbacks;
85
+ private _cellValueChangedCallbacks;
86
+ private _cellRemovedCallbacks;
17
87
  private _id;
88
+ private _blockManager;
89
+ private _calculator;
18
90
  }