@perspective-dev/viewer 5.6.0 → 5.7.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 (595) hide show
  1. package/README.md +4 -4
  2. package/dist/cdn/perspective-viewer.js +10 -9
  3. package/dist/cdn/perspective-viewer.js.map +4 -4
  4. package/dist/css/blueprint.css +1 -1
  5. package/dist/css/botanical.css +1 -1
  6. package/dist/css/dracula.css +1 -1
  7. package/dist/css/eggplant.css +1 -1
  8. package/dist/css/gruvbox-dark.css +1 -1
  9. package/dist/css/gruvbox.css +1 -1
  10. package/dist/css/intl/ar.css +1 -1
  11. package/dist/css/intl/de.css +1 -1
  12. package/dist/css/intl/es.css +1 -1
  13. package/dist/css/intl/fr.css +1 -1
  14. package/dist/css/intl/ja.css +1 -1
  15. package/dist/css/intl/pt.css +1 -1
  16. package/dist/css/intl/zh.css +1 -1
  17. package/dist/css/intl.css +1 -1
  18. package/dist/css/ledger.css +1 -1
  19. package/dist/css/monokai.css +1 -1
  20. package/dist/css/nord.css +1 -1
  21. package/dist/css/phosphor.css +1 -1
  22. package/dist/css/pro-dark.css +1 -1
  23. package/dist/css/pro.css +1 -1
  24. package/dist/css/solarized-dark.css +1 -1
  25. package/dist/css/solarized.css +1 -1
  26. package/dist/css/themes.css +1 -1
  27. package/dist/css/vaporwave.css +1 -1
  28. package/dist/css/velvet.css +1 -1
  29. package/dist/custom-elements.json +3955 -0
  30. package/dist/docs/perspective-docs.json +1 -1
  31. package/dist/esm/bootstrap.d.ts +48 -1
  32. package/dist/esm/column-format.d.ts +27 -18
  33. package/dist/esm/column-format.js +1 -1
  34. package/dist/esm/column-format.js.map +3 -3
  35. package/dist/esm/extensions.d.ts +127 -10
  36. package/dist/esm/perspective-viewer.d.ts +30 -25
  37. package/dist/esm/perspective-viewer.js +869 -9
  38. package/dist/esm/perspective-viewer.js.map +4 -4
  39. package/dist/esm/plugin.d.ts +1 -1
  40. package/dist/ts-rs/ColumnConfigDefaultsOptions.d.ts +15 -0
  41. package/dist/ts-rs/ColumnType.d.ts +6 -0
  42. package/dist/ts-rs/ConfigDefaultsOptions.d.ts +10 -0
  43. package/{src/ts/ts-rs/CurrencyNumberFormatStyle.ts → dist/ts-rs/CurrencyNumberFormatStyle.d.ts} +3 -3
  44. package/{src/ts/ts-rs/CustomNumberFormatConfig.ts → dist/ts-rs/CustomNumberFormatConfig.d.ts} +5 -5
  45. package/dist/ts-rs/DatetimeFormat.d.ts +61 -0
  46. package/dist/ts-rs/DatetimeMonthPart.d.ts +6 -0
  47. package/dist/ts-rs/DatetimeNumericPart.d.ts +6 -0
  48. package/{src/ts/ts-rs/Orientation.ts → dist/ts-rs/DatetimeTextPart.d.ts} +2 -2
  49. package/{src/ts/ts-rs/DerivedTableConfig.ts → dist/ts-rs/DerivedTableConfig.d.ts} +8 -8
  50. package/{src/ts/ts-rs/ExportOptions.ts → dist/ts-rs/ExportOptions.d.ts} +1 -1
  51. package/{src/ts/ts-rs/Filter.ts → dist/ts-rs/Filter.d.ts} +1 -1
  52. package/{src/ts/ts-rs/FilterTerm.ts → dist/ts-rs/FilterTerm.d.ts} +1 -1
  53. package/dist/ts-rs/FractionalSecondDigits.d.ts +6 -0
  54. package/{src/ts/ts-rs/GetViewOptions.ts → dist/ts-rs/GetViewOptions.d.ts} +1 -1
  55. package/dist/ts-rs/Layout.d.ts +9 -0
  56. package/{src/ts/ts-rs/Notation.ts → dist/ts-rs/Notation.d.ts} +1 -1
  57. package/{src/ts/ts-rs/NumberFormatStyle.ts → dist/ts-rs/NumberFormatStyle.d.ts} +2 -2
  58. package/{src/ts/ts-rs/OnUpdateData.ts → dist/ts-rs/OnUpdateData.d.ts} +1 -1
  59. package/dist/ts-rs/Orientation.d.ts +7 -0
  60. package/{src/ts/ts-rs/PanelViewerConfig.ts → dist/ts-rs/PanelViewerConfig.d.ts} +12 -12
  61. package/{src/ts/ts-rs/PluginStaticConfig.ts → dist/ts-rs/PluginStaticConfig.d.ts} +3 -3
  62. package/{src/ts/ts-rs/SimpleDatetimeFormat.ts → dist/ts-rs/SimpleDatetimeFormat.d.ts} +4 -1
  63. package/{src/ts/ts-rs/Sort.ts → dist/ts-rs/Sort.d.ts} +1 -1
  64. package/dist/ts-rs/SplitLayout.d.ts +21 -0
  65. package/{src/ts/ts-rs/TabLayout.ts → dist/ts-rs/TabLayout.d.ts} +3 -0
  66. package/{src/ts/ts-rs/TableRef.ts → dist/ts-rs/TableRef.d.ts} +1 -1
  67. package/{src/ts/ts-rs/Unit.ts → dist/ts-rs/Unit.d.ts} +1 -1
  68. package/{src/ts/ts-rs/UnitNumberFormatStyle.ts → dist/ts-rs/UnitNumberFormatStyle.d.ts} +2 -2
  69. package/{src/ts/ts-rs/ViewerConfig.ts → dist/ts-rs/ViewerConfig.d.ts} +12 -12
  70. package/{src/ts/ts-rs/ViewerConfigInitial.ts → dist/ts-rs/ViewerConfigInitial.d.ts} +9 -9
  71. package/{src/ts/ts-rs/ViewerConfigUpdate.ts → dist/ts-rs/ViewerConfigUpdate.d.ts} +13 -13
  72. package/{src/ts/ts-rs/WindowSort.ts → dist/ts-rs/WindowSort.d.ts} +1 -1
  73. package/{src/ts/ts-rs/WindowSpec.ts → dist/ts-rs/WindowSpec.d.ts} +1 -1
  74. package/{src/ts/ts-rs/Windows.ts → dist/ts-rs/Windows.d.ts} +1 -1
  75. package/{src/ts/ts-rs/WorkspaceConfig.ts → dist/ts-rs/WorkspaceConfig.d.ts} +5 -5
  76. package/{src/ts/ts-rs/WorkspaceConfigUpdate.ts → dist/ts-rs/WorkspaceConfigUpdate.d.ts} +12 -6
  77. package/dist/wasm/perspective-viewer.d.ts +192 -65
  78. package/dist/wasm/perspective-viewer.js +329 -116
  79. package/dist/wasm/perspective-viewer.wasm +0 -0
  80. package/dist/wasm/perspective-viewer.wasm.d.ts +24 -16
  81. package/dist/wasm/snippets/{perspective-viewer-d0d525977a1acba2 → perspective-viewer-c26bfdc60d367a99}/inline4.js +0 -6
  82. package/package.json +12 -16
  83. package/dist/esm/ts-rs/AddPanelOptions.d.ts +0 -9
  84. package/dist/esm/ts-rs/Aggregate.d.ts +0 -1
  85. package/dist/esm/ts-rs/ClientOptions.d.ts +0 -7
  86. package/dist/esm/ts-rs/ColumnSelectMode.d.ts +0 -1
  87. package/dist/esm/ts-rs/CompactDisplay.d.ts +0 -5
  88. package/dist/esm/ts-rs/CurrencyCode.d.ts +0 -1
  89. package/dist/esm/ts-rs/CurrencyDisplay.d.ts +0 -1
  90. package/dist/esm/ts-rs/CurrencyNumberFormatStyle.d.ts +0 -8
  91. package/dist/esm/ts-rs/CurrencySign.d.ts +0 -1
  92. package/dist/esm/ts-rs/CustomDatetimeFormat.d.ts +0 -1
  93. package/dist/esm/ts-rs/CustomDatetimeStyleConfig.d.ts +0 -54
  94. package/dist/esm/ts-rs/CustomNumberFormatConfig.d.ts +0 -34
  95. package/dist/esm/ts-rs/DatetimeFormatType.d.ts +0 -6
  96. package/dist/esm/ts-rs/DerivedTableConfig.d.ts +0 -35
  97. package/dist/esm/ts-rs/ExportMethod.d.ts +0 -1
  98. package/dist/esm/ts-rs/ExportOptions.d.ts +0 -9
  99. package/dist/esm/ts-rs/Expressions.d.ts +0 -3
  100. package/dist/esm/ts-rs/Filter.d.ts +0 -2
  101. package/dist/esm/ts-rs/FilterReducer.d.ts +0 -1
  102. package/dist/esm/ts-rs/FilterTerm.d.ts +0 -2
  103. package/dist/esm/ts-rs/FormatUnit.d.ts +0 -1
  104. package/dist/esm/ts-rs/GetClientOptions.d.ts +0 -8
  105. package/dist/esm/ts-rs/GetTableOptions.d.ts +0 -8
  106. package/dist/esm/ts-rs/GetViewMode.d.ts +0 -4
  107. package/dist/esm/ts-rs/GetViewOptions.d.ts +0 -8
  108. package/dist/esm/ts-rs/GroupRollupMode.d.ts +0 -1
  109. package/dist/esm/ts-rs/Layout.d.ts +0 -11
  110. package/dist/esm/ts-rs/Notation.d.ts +0 -17
  111. package/dist/esm/ts-rs/NumberFormatStyle.d.ts +0 -18
  112. package/dist/esm/ts-rs/OnUpdateData.d.ts +0 -6
  113. package/dist/esm/ts-rs/OptionalUpdate.d.ts +0 -1
  114. package/dist/esm/ts-rs/Orientation.d.ts +0 -4
  115. package/dist/esm/ts-rs/PanelOptions.d.ts +0 -7
  116. package/dist/esm/ts-rs/PanelViewerConfig.d.ts +0 -82
  117. package/dist/esm/ts-rs/PluginStaticConfig.d.ts +0 -112
  118. package/dist/esm/ts-rs/RestoreOptions.d.ts +0 -21
  119. package/dist/esm/ts-rs/RestoreWorkspaceOptions.d.ts +0 -9
  120. package/dist/esm/ts-rs/RoundingMode.d.ts +0 -1
  121. package/dist/esm/ts-rs/RoundingPriority.d.ts +0 -1
  122. package/dist/esm/ts-rs/SaveWorkspaceOptions.d.ts +0 -10
  123. package/dist/esm/ts-rs/Scalar.d.ts +0 -5
  124. package/dist/esm/ts-rs/SignDisplay.d.ts +0 -1
  125. package/dist/esm/ts-rs/SimpleDatetimeFormat.d.ts +0 -1
  126. package/dist/esm/ts-rs/SimpleDatetimeStyleConfig.d.ts +0 -24
  127. package/dist/esm/ts-rs/Sort.d.ts +0 -2
  128. package/dist/esm/ts-rs/SortDir.d.ts +0 -1
  129. package/dist/esm/ts-rs/SplitLayout.d.ts +0 -7
  130. package/dist/esm/ts-rs/SplitRollupMode.d.ts +0 -9
  131. package/dist/esm/ts-rs/TabLayout.d.ts +0 -10
  132. package/dist/esm/ts-rs/TableRef.d.ts +0 -9
  133. package/dist/esm/ts-rs/TrailingZeroDisplay.d.ts +0 -1
  134. package/dist/esm/ts-rs/Unit.d.ts +0 -1
  135. package/dist/esm/ts-rs/UnitDisplay.d.ts +0 -1
  136. package/dist/esm/ts-rs/UnitNumberFormatStyle.d.ts +0 -6
  137. package/dist/esm/ts-rs/UseGrouping.d.ts +0 -1
  138. package/dist/esm/ts-rs/ViewOnUpdateResp.d.ts +0 -4
  139. package/dist/esm/ts-rs/ViewerConfig.d.ts +0 -86
  140. package/dist/esm/ts-rs/ViewerConfigInitial.d.ts +0 -175
  141. package/dist/esm/ts-rs/ViewerConfigUpdate.d.ts +0 -182
  142. package/dist/esm/ts-rs/WindowSort.d.ts +0 -7
  143. package/dist/esm/ts-rs/WindowSortDir.d.ts +0 -6
  144. package/dist/esm/ts-rs/WindowSpec.d.ts +0 -47
  145. package/dist/esm/ts-rs/Windows.d.ts +0 -10
  146. package/dist/esm/ts-rs/WorkspaceConfig.d.ts +0 -56
  147. package/dist/esm/ts-rs/WorkspaceConfigUpdate.d.ts +0 -56
  148. package/dist/esm/ts-rs/serde_json/JsonValue.d.ts +0 -3
  149. package/src/css/_column_dropdown.css +0 -14
  150. package/src/css/_context_menu.css +0 -14
  151. package/src/css/_dropdown_menu.css +0 -14
  152. package/src/css/_filter_dropdown.css +0 -14
  153. package/src/css/_function_dropdown.css +0 -14
  154. package/src/css/_viewer_bundle.css +0 -41
  155. package/src/css/aggregate-selector.css +0 -75
  156. package/src/css/column-dropdown.css +0 -106
  157. package/src/css/column-selector.css +0 -729
  158. package/src/css/column-settings-panel.css +0 -164
  159. package/src/css/column-style.css +0 -774
  160. package/src/css/column-symbol-attributes.css +0 -74
  161. package/src/css/config-selector.css +0 -505
  162. package/src/css/containers/pairs-list.css +0 -47
  163. package/src/css/empty-column.css +0 -73
  164. package/src/css/expression-editor.css +0 -153
  165. package/src/css/filter-dropdown.css +0 -54
  166. package/src/css/filter-item.css +0 -127
  167. package/src/css/form/code-editor.css +0 -133
  168. package/src/css/form/debug.css +0 -115
  169. package/src/css/function-dropdown.css +0 -46
  170. package/src/css/panel-tab.css +0 -216
  171. package/src/css/plugin-selector.css +0 -292
  172. package/src/css/render-warning.css +0 -82
  173. package/src/css/status-bar.css +0 -647
  174. package/src/css/type-icon.css +0 -114
  175. package/src/css/ui/containers/context-menu.css +0 -124
  176. package/src/css/ui/containers/dropdown-menu-items.css +0 -95
  177. package/src/css/ui/containers/dropdown-menu.css +0 -50
  178. package/src/css/ui/containers/scroll-panel.css +0 -31
  179. package/src/css/ui/containers/split-panel.css +0 -81
  180. package/src/css/ui/containers/tabs.css +0 -55
  181. package/src/css/ui/dom/checkbox.css +0 -98
  182. package/src/css/ui/dom/scrollbar.css +0 -35
  183. package/src/css/ui/dom/select.css +0 -74
  184. package/src/css/ui/form/mirrored-textarea.css +0 -81
  185. package/src/css/viewer.css +0 -1003
  186. package/src/rust/agent/client/mod.rs +0 -19
  187. package/src/rust/agent/client/protocol.rs +0 -231
  188. package/src/rust/agent/client/transport.rs +0 -287
  189. package/src/rust/agent/client/turn.rs +0 -174
  190. package/src/rust/agent/config.rs +0 -159
  191. package/src/rust/agent/docs.rs +0 -293
  192. package/src/rust/agent/markdown/block.rs +0 -509
  193. package/src/rust/agent/markdown/entity.rs +0 -52
  194. package/src/rust/agent/markdown/events.rs +0 -71
  195. package/src/rust/agent/markdown/inline.rs +0 -497
  196. package/src/rust/agent/markdown/mod.rs +0 -228
  197. package/src/rust/agent/mod.rs +0 -23
  198. package/src/rust/agent/preamble.md +0 -17
  199. package/src/rust/agent/runtime.rs +0 -201
  200. package/src/rust/agent/slot.rs +0 -236
  201. package/src/rust/agent/tools.rs +0 -1203
  202. package/src/rust/components/chat_panel.rs +0 -289
  203. package/src/rust/components/code_editor/highlight.rs +0 -52
  204. package/src/rust/components/code_editor.rs +0 -302
  205. package/src/rust/components/column_dropdown.rs +0 -284
  206. package/src/rust/components/column_selector/active_column.rs +0 -497
  207. package/src/rust/components/column_selector/add_expression_button.rs +0 -48
  208. package/src/rust/components/column_selector/aggregate_selector.rs +0 -193
  209. package/src/rust/components/column_selector/column_selector_column_row.rs +0 -73
  210. package/src/rust/components/column_selector/config_selector.rs +0 -932
  211. package/src/rust/components/column_selector/derived_control.rs +0 -229
  212. package/src/rust/components/column_selector/empty_column.rs +0 -136
  213. package/src/rust/components/column_selector/expr_edit_button.rs +0 -59
  214. package/src/rust/components/column_selector/filter_column.rs +0 -530
  215. package/src/rust/components/column_selector/inactive_column.rs +0 -246
  216. package/src/rust/components/column_selector/invalid_column.rs +0 -22
  217. package/src/rust/components/column_selector/pivot_column.rs +0 -130
  218. package/src/rust/components/column_selector/sort_column.rs +0 -148
  219. package/src/rust/components/column_selector.rs +0 -628
  220. package/src/rust/components/column_settings_sidebar/attributes_tab.rs +0 -34
  221. package/src/rust/components/column_settings_sidebar/save_settings.rs +0 -72
  222. package/src/rust/components/column_settings_sidebar/style_tab/agg_depth_selector.rs +0 -66
  223. package/src/rust/components/column_settings_sidebar/style_tab/alignment_field.rs +0 -90
  224. package/src/rust/components/column_settings_sidebar/style_tab/font_field.rs +0 -267
  225. package/src/rust/components/column_settings_sidebar/style_tab/primitive_field.rs +0 -560
  226. package/src/rust/components/column_settings_sidebar/style_tab/symbol/row_selector.rs +0 -101
  227. package/src/rust/components/column_settings_sidebar/style_tab/symbol/symbol_pairs.rs +0 -91
  228. package/src/rust/components/column_settings_sidebar/style_tab/symbol/symbol_pairs_item.rs +0 -112
  229. package/src/rust/components/column_settings_sidebar/style_tab/symbol/symbol_selector.rs +0 -54
  230. package/src/rust/components/column_settings_sidebar/style_tab/symbol.rs +0 -143
  231. package/src/rust/components/column_settings_sidebar/style_tab.rs +0 -499
  232. package/src/rust/components/column_settings_sidebar/window_tab.rs +0 -34
  233. package/src/rust/components/column_settings_sidebar.rs +0 -622
  234. package/src/rust/components/copy_dropdown.rs +0 -111
  235. package/src/rust/components/datetime_column_style/custom.rs +0 -220
  236. package/src/rust/components/datetime_column_style/simple.rs +0 -131
  237. package/src/rust/components/datetime_column_style.rs +0 -259
  238. package/src/rust/components/debug_panel.rs +0 -350
  239. package/src/rust/components/dragdrop_list.rs +0 -473
  240. package/src/rust/components/editable_header.rs +0 -147
  241. package/src/rust/components/empty_row.rs +0 -166
  242. package/src/rust/components/export_dropdown.rs +0 -132
  243. package/src/rust/components/expression_editor.rs +0 -172
  244. package/src/rust/components/filter_dropdown.rs +0 -289
  245. package/src/rust/components/function_dropdown.rs +0 -224
  246. package/src/rust/components/global_filter_bar.rs +0 -76
  247. package/src/rust/components/main_panel/frame_theme.rs +0 -130
  248. package/src/rust/components/main_panel/msg.rs +0 -68
  249. package/src/rust/components/main_panel/presize.rs +0 -220
  250. package/src/rust/components/main_panel/reconcile.rs +0 -234
  251. package/src/rust/components/main_panel/render.rs +0 -455
  252. package/src/rust/components/main_panel/update.rs +0 -251
  253. package/src/rust/components/main_panel.rs +0 -481
  254. package/src/rust/components/mod.rs +0 -50
  255. package/src/rust/components/new_panel_menu.rs +0 -165
  256. package/src/rust/components/number_series_style.rs +0 -157
  257. package/src/rust/components/panel_menu.rs +0 -518
  258. package/src/rust/components/panel_tab.rs +0 -567
  259. package/src/rust/components/plugin_selector.rs +0 -132
  260. package/src/rust/components/plugin_tab.rs +0 -285
  261. package/src/rust/components/render_warning.rs +0 -128
  262. package/src/rust/components/rows_counter.rs +0 -124
  263. package/src/rust/components/settings_panel.rs +0 -406
  264. package/src/rust/components/status_bar.rs +0 -595
  265. package/src/rust/components/status_indicator.rs +0 -125
  266. package/src/rust/components/style.rs +0 -107
  267. package/src/rust/components/style_controls/mod.rs +0 -15
  268. package/src/rust/components/style_controls/number_string_format/digits_section.rs +0 -150
  269. package/src/rust/components/style_controls/number_string_format/misc_section.rs +0 -60
  270. package/src/rust/components/style_controls/number_string_format/style_section.rs +0 -70
  271. package/src/rust/components/style_controls/number_string_format/types.rs +0 -55
  272. package/src/rust/components/style_controls/number_string_format.rs +0 -258
  273. package/src/rust/components/type_icon.rs +0 -53
  274. package/src/rust/components/viewer/filters.rs +0 -145
  275. package/src/rust/components/viewer/msg.rs +0 -242
  276. package/src/rust/components/viewer/panels.rs +0 -397
  277. package/src/rust/components/viewer/render.rs +0 -266
  278. package/src/rust/components/viewer/settings.rs +0 -621
  279. package/src/rust/components/viewer/snapshots.rs +0 -154
  280. package/src/rust/components/viewer/wiring.rs +0 -500
  281. package/src/rust/components/viewer.rs +0 -429
  282. package/src/rust/components/window_editor.rs +0 -985
  283. package/src/rust/config/column_config_schema.rs +0 -525
  284. package/src/rust/config/columns_config.rs +0 -39
  285. package/src/rust/config/datetime_column_style/custom.rs +0 -138
  286. package/src/rust/config/datetime_column_style/custom_format.rs +0 -90
  287. package/src/rust/config/datetime_column_style/simple.rs +0 -65
  288. package/src/rust/config/datetime_column_style/simple_format.rs +0 -86
  289. package/src/rust/config/datetime_column_style.rs +0 -66
  290. package/src/rust/config/export_method.rs +0 -175
  291. package/src/rust/config/kvpair.rs +0 -47
  292. package/src/rust/config/mod.rs +0 -39
  293. package/src/rust/config/number_series_style.rs +0 -79
  294. package/src/rust/config/number_string_format/enums.rs +0 -298
  295. package/src/rust/config/number_string_format.rs +0 -424
  296. package/src/rust/config/options.rs +0 -145
  297. package/src/rust/config/plugin_static_config.rs +0 -217
  298. package/src/rust/config/view_config.rs +0 -24
  299. package/src/rust/config/viewer_config.rs +0 -461
  300. package/src/rust/config/workspace_config.rs +0 -296
  301. package/src/rust/custom_elements/debug_plugin.rs +0 -122
  302. package/src/rust/custom_elements/mod.rs +0 -17
  303. package/src/rust/custom_elements/viewer.rs +0 -2255
  304. package/src/rust/custom_events.rs +0 -423
  305. package/src/rust/derived.rs +0 -266
  306. package/src/rust/exprtk/cursor.rs +0 -90
  307. package/src/rust/exprtk/mod.rs +0 -19
  308. package/src/rust/exprtk/tokenize/comment.rs +0 -21
  309. package/src/rust/exprtk/tokenize/number.rs +0 -44
  310. package/src/rust/exprtk/tokenize/string.rs +0 -98
  311. package/src/rust/exprtk/tokenize/symbol.rs +0 -26
  312. package/src/rust/exprtk/tokenize.rs +0 -153
  313. package/src/rust/js/clipboard.rs +0 -77
  314. package/src/rust/js/clipboard_item.rs +0 -21
  315. package/src/rust/js/intersection_observer.rs +0 -32
  316. package/src/rust/js/mimetype.rs +0 -37
  317. package/src/rust/js/mod.rs +0 -30
  318. package/src/rust/js/plugin.rs +0 -324
  319. package/src/rust/js/regular_layout.rs +0 -258
  320. package/src/rust/js/resize_observer.rs +0 -37
  321. package/src/rust/lib.rs +0 -204
  322. package/src/rust/presentation/column_locator.rs +0 -115
  323. package/src/rust/presentation/props.rs +0 -47
  324. package/src/rust/presentation/sheets.rs +0 -78
  325. package/src/rust/presentation.rs +0 -825
  326. package/src/rust/queries/column_locator.rs +0 -114
  327. package/src/rust/queries/column_values.rs +0 -59
  328. package/src/rust/queries/columns_iter_set.rs +0 -331
  329. package/src/rust/queries/export_app.rs +0 -59
  330. package/src/rust/queries/exports.rs +0 -96
  331. package/src/rust/queries/fetch_column_stats.rs +0 -94
  332. package/src/rust/queries/get_viewer_config.rs +0 -73
  333. package/src/rust/queries/hosted_tables.rs +0 -38
  334. package/src/rust/queries/is_invalid_drop.rs +0 -36
  335. package/src/rust/queries/mod.rs +0 -48
  336. package/src/rust/queries/palette_set.rs +0 -82
  337. package/src/rust/queries/plugin_column_styles.rs +0 -105
  338. package/src/rust/queries/validate_expression.rs +0 -39
  339. package/src/rust/renderer/activate.rs +0 -90
  340. package/src/rust/renderer/dispatch.rs +0 -564
  341. package/src/rust/renderer/limits.rs +0 -104
  342. package/src/rust/renderer/plugin_config.rs +0 -1129
  343. package/src/rust/renderer/plugin_store.rs +0 -58
  344. package/src/rust/renderer/props.rs +0 -69
  345. package/src/rust/renderer/registry.rs +0 -175
  346. package/src/rust/renderer/render_timer.rs +0 -204
  347. package/src/rust/renderer/state.rs +0 -205
  348. package/src/rust/renderer.rs +0 -868
  349. package/src/rust/root.rs +0 -50
  350. package/src/rust/session/column_defaults_update.rs +0 -194
  351. package/src/rust/session/drag_drop_update.rs +0 -197
  352. package/src/rust/session/metadata.rs +0 -415
  353. package/src/rust/session/op_queue.rs +0 -430
  354. package/src/rust/session/panel_state.rs +0 -327
  355. package/src/rust/session/props.rs +0 -193
  356. package/src/rust/session/replace_expression_update.rs +0 -133
  357. package/src/rust/session/view_subscription.rs +0 -266
  358. package/src/rust/session.rs +0 -1901
  359. package/src/rust/tasks/apply_global_filters.rs +0 -103
  360. package/src/rust/tasks/auto_pause.rs +0 -181
  361. package/src/rust/tasks/copy_export.rs +0 -296
  362. package/src/rust/tasks/create_panel.rs +0 -268
  363. package/src/rust/tasks/derive.rs +0 -312
  364. package/src/rust/tasks/dismiss_render_warning.rs +0 -35
  365. package/src/rust/tasks/edit_expression.rs +0 -92
  366. package/src/rust/tasks/edit_window.rs +0 -153
  367. package/src/rust/tasks/eject.rs +0 -89
  368. package/src/rust/tasks/mod.rs +0 -80
  369. package/src/rust/tasks/pipeline.rs +0 -425
  370. package/src/rust/tasks/presize_panels.rs +0 -386
  371. package/src/rust/tasks/reset_all.rs +0 -119
  372. package/src/rust/tasks/resize_observer.rs +0 -173
  373. package/src/rust/tasks/restore_derived.rs +0 -200
  374. package/src/rust/tasks/restore_panel.rs +0 -271
  375. package/src/rust/tasks/send_column_config.rs +0 -87
  376. package/src/rust/tasks/send_plugin_config.rs +0 -83
  377. package/src/rust/tasks/set_edit_mode.rs +0 -69
  378. package/src/rust/tasks/sync_update_panels.rs +0 -253
  379. package/src/rust/tasks/table_lifecycle.rs +0 -200
  380. package/src/rust/tasks/transactional_restore.rs +0 -387
  381. package/src/rust/tasks/update_theme.rs +0 -139
  382. package/src/rust/tasks/validate_expression.rs +0 -61
  383. package/src/rust/ui/containers/control_group.rs +0 -113
  384. package/src/rust/ui/containers/dropdown_menu.rs +0 -103
  385. package/src/rust/ui/containers/mod.rs +0 -21
  386. package/src/rust/ui/containers/scroll_panel.rs +0 -315
  387. package/src/rust/ui/containers/scroll_panel_item.rs +0 -98
  388. package/src/rust/ui/containers/select.rs +0 -271
  389. package/src/rust/ui/containers/sidebar.rs +0 -125
  390. package/src/rust/ui/containers/sidebar_close_button.rs +0 -30
  391. package/src/rust/ui/containers/split_panel.rs +0 -498
  392. package/src/rust/ui/containers/tab_list.rs +0 -101
  393. package/src/rust/ui/context_menu.rs +0 -264
  394. package/src/rust/ui/dragdrop.rs +0 -201
  395. package/src/rust/ui/font_loader.rs +0 -201
  396. package/src/rust/ui/form/color_selector.rs +0 -58
  397. package/src/rust/ui/form/intl_label.rs +0 -62
  398. package/src/rust/ui/form/mirrored_textarea.rs +0 -100
  399. package/src/rust/ui/form/mod.rs +0 -24
  400. package/src/rust/ui/form/multi_stop_gradient_selector.rs +0 -386
  401. package/src/rust/ui/form/named_value_picker.rs +0 -81
  402. package/src/rust/ui/form/number_field.rs +0 -72
  403. package/src/rust/ui/form/number_input.rs +0 -45
  404. package/src/rust/ui/form/number_range_field.rs +0 -77
  405. package/src/rust/ui/form/optional_field.rs +0 -55
  406. package/src/rust/ui/form/palette_selector.rs +0 -388
  407. package/src/rust/ui/form/select_enum_field.rs +0 -59
  408. package/src/rust/ui/form/select_value_field.rs +0 -64
  409. package/src/rust/ui/mod.rs +0 -56
  410. package/src/rust/ui/modal.rs +0 -61
  411. package/src/rust/ui/portal.rs +0 -374
  412. package/src/rust/ui/style.rs +0 -56
  413. package/src/rust/utils/browser/blob.rs +0 -63
  414. package/src/rust/utils/browser/download.rs +0 -27
  415. package/src/rust/utils/browser/dragdrop.rs +0 -38
  416. package/src/rust/utils/browser/mod.rs +0 -27
  417. package/src/rust/utils/browser/mouse.rs +0 -24
  418. package/src/rust/utils/browser/request_animation_frame.rs +0 -95
  419. package/src/rust/utils/browser/selection.rs +0 -84
  420. package/src/rust/utils/completion.rs +0 -50
  421. package/src/rust/utils/css.rs +0 -525
  422. package/src/rust/utils/css_vars.rs +0 -39
  423. package/src/rust/utils/custom_element.rs +0 -105
  424. package/src/rust/utils/datetime.rs +0 -54
  425. package/src/rust/utils/debounce.rs +0 -232
  426. package/src/rust/utils/hooks/mod.rs +0 -15
  427. package/src/rust/utils/hooks/use_async_callback.rs +0 -43
  428. package/src/rust/utils/in_flight.rs +0 -74
  429. package/src/rust/utils/local_fonts.rs +0 -359
  430. package/src/rust/utils/mod.rs +0 -56
  431. package/src/rust/utils/modal_position.rs +0 -104
  432. package/src/rust/utils/number_format.rs +0 -49
  433. package/src/rust/utils/pending_effects.rs +0 -38
  434. package/src/rust/utils/plugin_host_state.rs +0 -43
  435. package/src/rust/utils/ptr_eq_rc.rs +0 -74
  436. package/src/rust/utils/pubsub.rs +0 -236
  437. package/src/rust/utils/spawn.rs +0 -33
  438. package/src/rust/utils/weak_scope.rs +0 -39
  439. package/src/rust/workspace.rs +0 -1195
  440. package/src/svg/active-indicator.svg +0 -3
  441. package/src/svg/align-scroll-icon.svg +0 -7
  442. package/src/svg/bg-pattern.png +0 -0
  443. package/src/svg/bookmark-icon.svg +0 -4
  444. package/src/svg/boolean-type.svg +0 -4
  445. package/src/svg/checkbox-checked-icon.svg +0 -4
  446. package/src/svg/checkbox-hover.svg +0 -4
  447. package/src/svg/checkbox-off.svg +0 -3
  448. package/src/svg/checkbox-on.svg +0 -4
  449. package/src/svg/checkbox-unchecked-icon.svg +0 -3
  450. package/src/svg/close-icon.svg +0 -6
  451. package/src/svg/column-settings-icon.svg +0 -6
  452. package/src/svg/datagrid-select-column.svg +0 -8
  453. package/src/svg/datagrid-select-region.svg +0 -8
  454. package/src/svg/datagrid-select-row-tree.svg +0 -8
  455. package/src/svg/datagrid-select-row.svg +0 -8
  456. package/src/svg/datagrid.svg +0 -13
  457. package/src/svg/date-type.svg +0 -4
  458. package/src/svg/derived.svg +0 -6
  459. package/src/svg/downloading.gif +0 -0
  460. package/src/svg/drag-handle copy.svg +0 -10
  461. package/src/svg/drag-handle.svg +0 -10
  462. package/src/svg/drawer-bg-pattern-hidpi.png +0 -0
  463. package/src/svg/drawer-tab-hover.svg +0 -4
  464. package/src/svg/drawer-tab-invert-hover.svg +0 -5
  465. package/src/svg/drawer-tab-invert.svg +0 -3
  466. package/src/svg/drawer-tab.svg +0 -5
  467. package/src/svg/dropdown-selector.svg +0 -3
  468. package/src/svg/duplicate-icon.svg +0 -4
  469. package/src/svg/editable-icon.svg +0 -5
  470. package/src/svg/export-icon.svg +0 -4
  471. package/src/svg/expression.svg +0 -10
  472. package/src/svg/free-scroll-icon.svg +0 -5
  473. package/src/svg/inactive-mouseover.svg +0 -4
  474. package/src/svg/lock.svg +0 -7
  475. package/src/svg/mega-menu-icons-candlestick.svg +0 -6
  476. package/src/svg/mega-menu-icons-datagrid.svg +0 -37
  477. package/src/svg/mega-menu-icons-density.svg +0 -23
  478. package/src/svg/mega-menu-icons-heatmap.svg +0 -60
  479. package/src/svg/mega-menu-icons-map-density.svg +0 -24
  480. package/src/svg/mega-menu-icons-map-line.svg +0 -19
  481. package/src/svg/mega-menu-icons-map-scatter.svg +0 -43
  482. package/src/svg/mega-menu-icons-ohlc.svg +0 -5
  483. package/src/svg/mega-menu-icons-sunburst.svg +0 -5
  484. package/src/svg/mega-menu-icons-treemap.svg +0 -4
  485. package/src/svg/mega-menu-icons-x-bar.svg +0 -36
  486. package/src/svg/mega-menu-icons-x-y-line.svg +0 -38
  487. package/src/svg/mega-menu-icons-x-y-scatter.svg +0 -72
  488. package/src/svg/mega-menu-icons-y-area.svg +0 -73
  489. package/src/svg/mega-menu-icons-y-bar.svg +0 -36
  490. package/src/svg/mega-menu-icons-y-line.svg +0 -36
  491. package/src/svg/mega-menu-icons-y-scatter.svg +0 -12
  492. package/src/svg/new-panel-icon.svg +0 -4
  493. package/src/svg/number-type.svg +0 -4
  494. package/src/svg/pin-icon.svg +0 -5
  495. package/src/svg/radio-hover.svg +0 -4
  496. package/src/svg/radio-off.svg +0 -3
  497. package/src/svg/radio-on.svg +0 -4
  498. package/src/svg/read-only-icon.svg +0 -6
  499. package/src/svg/revert-icon.svg +0 -4
  500. package/src/svg/sort-abs-asc-icon.svg +0 -3
  501. package/src/svg/sort-abs-col-asc-icon.svg +0 -3
  502. package/src/svg/sort-abs-col-desc-icon.svg +0 -3
  503. package/src/svg/sort-abs-desc-icon.svg +0 -3
  504. package/src/svg/sort-asc-icon.svg +0 -4
  505. package/src/svg/sort-col-asc-icon.svg +0 -4
  506. package/src/svg/sort-col-desc-icon.svg +0 -4
  507. package/src/svg/sort-desc-icon.svg +0 -4
  508. package/src/svg/sort-none-icon.svg +0 -3
  509. package/src/svg/status_error.svg +0 -70
  510. package/src/svg/status_ok.svg +0 -3
  511. package/src/svg/status_pending.svg +0 -3
  512. package/src/svg/string-type.svg +0 -4
  513. package/src/svg/theme-icon.svg +0 -5
  514. package/src/svg/updating.gif +0 -0
  515. package/src/themes/blueprint.css +0 -133
  516. package/src/themes/botanical.css +0 -97
  517. package/src/themes/defaults.css +0 -68
  518. package/src/themes/dracula.css +0 -167
  519. package/src/themes/eggplant.css +0 -131
  520. package/src/themes/gruvbox-dark.css +0 -183
  521. package/src/themes/gruvbox.css +0 -97
  522. package/src/themes/icons.css +0 -110
  523. package/src/themes/intl/ar.css +0 -208
  524. package/src/themes/intl/de.css +0 -217
  525. package/src/themes/intl/es.css +0 -217
  526. package/src/themes/intl/fr.css +0 -217
  527. package/src/themes/intl/ja.css +0 -217
  528. package/src/themes/intl/pt.css +0 -217
  529. package/src/themes/intl/zh.css +0 -217
  530. package/src/themes/intl.css +0 -219
  531. package/src/themes/ledger.css +0 -137
  532. package/src/themes/monokai.css +0 -181
  533. package/src/themes/nord.css +0 -131
  534. package/src/themes/phosphor.css +0 -125
  535. package/src/themes/pro-dark.css +0 -113
  536. package/src/themes/pro.css +0 -117
  537. package/src/themes/solarized-dark.css +0 -85
  538. package/src/themes/solarized.css +0 -72
  539. package/src/themes/themes.css +0 -28
  540. package/src/themes/vaporwave.css +0 -191
  541. package/src/themes/velvet.css +0 -132
  542. package/src/ts/bootstrap.ts +0 -38
  543. package/src/ts/column-format.ts +0 -233
  544. package/src/ts/extensions.ts +0 -236
  545. package/src/ts/perspective-viewer.cdn.ts +0 -19
  546. package/src/ts/perspective-viewer.ts +0 -72
  547. package/src/ts/perspective-viewer.worker.ts +0 -14
  548. package/src/ts/plugin.ts +0 -296
  549. package/src/ts/providers.ts +0 -96
  550. package/src/ts/select-detail.ts +0 -48
  551. package/src/ts/ts-rs/CustomDatetimeFormat.ts +0 -3
  552. package/src/ts/ts-rs/CustomDatetimeStyleConfig.ts +0 -54
  553. package/src/ts/ts-rs/DatetimeFormatType.ts +0 -8
  554. package/src/ts/ts-rs/FormatUnit.ts +0 -3
  555. package/src/ts/ts-rs/Layout.ts +0 -9
  556. package/src/ts/ts-rs/SimpleDatetimeStyleConfig.ts +0 -25
  557. package/src/ts/ts-rs/SplitLayout.ts +0 -5
  558. package/tsconfig.json +0 -16
  559. /package/{src/ts/ts-rs/AddPanelOptions.ts → dist/ts-rs/AddPanelOptions.d.ts} +0 -0
  560. /package/{src/ts/ts-rs/Aggregate.ts → dist/ts-rs/Aggregate.d.ts} +0 -0
  561. /package/{src/ts/ts-rs/ClientOptions.ts → dist/ts-rs/ClientOptions.d.ts} +0 -0
  562. /package/{src/ts/ts-rs/ColumnSelectMode.ts → dist/ts-rs/ColumnSelectMode.d.ts} +0 -0
  563. /package/{src/ts/ts-rs/CompactDisplay.ts → dist/ts-rs/CompactDisplay.d.ts} +0 -0
  564. /package/{src/ts/ts-rs/CurrencyCode.ts → dist/ts-rs/CurrencyCode.d.ts} +0 -0
  565. /package/{src/ts/ts-rs/CurrencyDisplay.ts → dist/ts-rs/CurrencyDisplay.d.ts} +0 -0
  566. /package/{src/ts/ts-rs/CurrencySign.ts → dist/ts-rs/CurrencySign.d.ts} +0 -0
  567. /package/{src/ts/ts-rs/ExportMethod.ts → dist/ts-rs/ExportMethod.d.ts} +0 -0
  568. /package/{src/ts/ts-rs/Expressions.ts → dist/ts-rs/Expressions.d.ts} +0 -0
  569. /package/{src/ts/ts-rs/FilterReducer.ts → dist/ts-rs/FilterReducer.d.ts} +0 -0
  570. /package/{src/ts/ts-rs/GetClientOptions.ts → dist/ts-rs/GetClientOptions.d.ts} +0 -0
  571. /package/{src/ts/ts-rs/GetTableOptions.ts → dist/ts-rs/GetTableOptions.d.ts} +0 -0
  572. /package/{src/ts/ts-rs/GetViewMode.ts → dist/ts-rs/GetViewMode.d.ts} +0 -0
  573. /package/{src/ts/ts-rs/GroupRollupMode.ts → dist/ts-rs/GroupRollupMode.d.ts} +0 -0
  574. /package/{src/ts/ts-rs/OptionalUpdate.ts → dist/ts-rs/OptionalUpdate.d.ts} +0 -0
  575. /package/{src/ts/ts-rs/PanelOptions.ts → dist/ts-rs/PanelOptions.d.ts} +0 -0
  576. /package/{src/ts/ts-rs/RestoreOptions.ts → dist/ts-rs/RestoreOptions.d.ts} +0 -0
  577. /package/{src/ts/ts-rs/RestoreWorkspaceOptions.ts → dist/ts-rs/RestoreWorkspaceOptions.d.ts} +0 -0
  578. /package/{src/ts/ts-rs/RoundingMode.ts → dist/ts-rs/RoundingMode.d.ts} +0 -0
  579. /package/{src/ts/ts-rs/RoundingPriority.ts → dist/ts-rs/RoundingPriority.d.ts} +0 -0
  580. /package/{src/ts/ts-rs/SaveWorkspaceOptions.ts → dist/ts-rs/SaveWorkspaceOptions.d.ts} +0 -0
  581. /package/{src/ts/ts-rs/Scalar.ts → dist/ts-rs/Scalar.d.ts} +0 -0
  582. /package/{src/ts/ts-rs/SignDisplay.ts → dist/ts-rs/SignDisplay.d.ts} +0 -0
  583. /package/{src/ts/ts-rs/SortDir.ts → dist/ts-rs/SortDir.d.ts} +0 -0
  584. /package/{src/ts/ts-rs/SplitRollupMode.ts → dist/ts-rs/SplitRollupMode.d.ts} +0 -0
  585. /package/{src/ts/ts-rs/TrailingZeroDisplay.ts → dist/ts-rs/TrailingZeroDisplay.d.ts} +0 -0
  586. /package/{src/ts/ts-rs/UnitDisplay.ts → dist/ts-rs/UnitDisplay.d.ts} +0 -0
  587. /package/{src/ts/ts-rs/UseGrouping.ts → dist/ts-rs/UseGrouping.d.ts} +0 -0
  588. /package/{src/ts/ts-rs/ViewOnUpdateResp.ts → dist/ts-rs/ViewOnUpdateResp.d.ts} +0 -0
  589. /package/{src/ts/ts-rs/WindowSortDir.ts → dist/ts-rs/WindowSortDir.d.ts} +0 -0
  590. /package/{src/ts/ts-rs/serde_json/JsonValue.ts → dist/ts-rs/serde_json/JsonValue.d.ts} +0 -0
  591. /package/dist/wasm/snippets/{perspective-viewer-d0d525977a1acba2 → perspective-viewer-c26bfdc60d367a99}/inline0.js +0 -0
  592. /package/dist/wasm/snippets/{perspective-viewer-d0d525977a1acba2 → perspective-viewer-c26bfdc60d367a99}/inline1.js +0 -0
  593. /package/dist/wasm/snippets/{perspective-viewer-d0d525977a1acba2 → perspective-viewer-c26bfdc60d367a99}/inline2.js +0 -0
  594. /package/dist/wasm/snippets/{perspective-viewer-d0d525977a1acba2 → perspective-viewer-c26bfdc60d367a99}/inline3.js +0 -0
  595. /package/dist/wasm/snippets/{perspective-viewer-d0d525977a1acba2 → perspective-viewer-c26bfdc60d367a99}/inline5.js +0 -0
@@ -1,1901 +0,0 @@
1
- // ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
2
- // ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃
3
- // ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃
4
- // ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃
5
- // ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃
6
- // ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫
7
- // ┃ Copyright (c) 2017, the Perspective Authors. ┃
8
- // ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃
9
- // ┃ This file is part of the Perspective library, distributed under the terms ┃
10
- // ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11
- // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
-
13
- pub(crate) mod column_defaults_update;
14
- pub(crate) mod drag_drop_update;
15
- mod metadata;
16
- mod op_queue;
17
- mod panel_state;
18
- mod props;
19
- pub(crate) mod replace_expression_update;
20
- mod view_subscription;
21
-
22
- use std::cell::{Cell, RefCell};
23
- use std::collections::{HashMap, HashSet};
24
- use std::future::Future;
25
- use std::ops::Deref;
26
- use std::rc::Rc;
27
-
28
- use perspective_client::config::*;
29
- use perspective_client::proto::ViewDimensionsResp;
30
- use perspective_client::{
31
- Client, ClientError, DescribeError, Description, ExprValidationResult, ReconnectCallback, View,
32
- };
33
- use perspective_js::apierror;
34
- use perspective_js::utils::*;
35
- use wasm_bindgen::prelude::*;
36
- use yew::html::ImplicitClone;
37
- use yew::prelude::*;
38
-
39
- use self::metadata::*;
40
- pub use self::metadata::{MetadataRef, SessionMetadata, SessionMetadataRc};
41
- use self::op_queue::OpQueue;
42
- pub use self::op_queue::{EditDelta, OpCtx, OpKind, StepFuture, Ticket};
43
- use self::panel_state::effective;
44
- pub use self::panel_state::{Binding, OverlayClause, PanelState};
45
- pub use self::props::{SessionProps, TableLoadState};
46
- use self::view_subscription::*;
47
- pub use self::view_subscription::{ViewStats, ViewSubscription};
48
- use crate::config::PluginStaticConfig;
49
- use crate::utils::*;
50
-
51
- /// Per-column numeric stats sourced from `View::get_min_max`. Keyed by
52
- /// column name in [`SessionHandle::column_stats`]; populated lazily by
53
- /// the `fetch_column_abs_max` task; cleared on every
54
- /// `view_config_changed`.
55
- #[derive(Clone, Copy, Debug, Default, PartialEq)]
56
- pub struct ColumnStats {
57
- pub abs_max: Option<f64>,
58
- }
59
-
60
- /// Immutable state for `Session`.
61
- #[derive(Default)]
62
- pub struct SessionHandle {
63
- session_data: RefCell<SessionData>,
64
- pub table_updated: PubSub<()>,
65
- pub table_loaded: PubSub<()>,
66
- pub table_unloaded: PubSub<bool>,
67
-
68
- /// Fires when a `View` was CREATED — literally.
69
- pub view_created: PubSub<()>,
70
-
71
- /// Fires exactly once per locked run that RECONCILED the committed
72
- /// config against the bound render state — on every `bind_view` exit
73
- /// (SKIP / REUSE / auto-PAUSED / REBUILD). This is the "a commit was
74
- /// applied; a `perspective-config-update` may need dispatching" signal;
75
- /// it does NOT imply a `View` was constructed (that is
76
- /// [`Self::view_created`]).
77
- pub commit_reconciled: PubSub<()>,
78
-
79
- pub view_config_changed: PubSub<()>,
80
- pub title_changed: PubSub<Option<String>>,
81
-
82
- /// Account of in-flight CONFIG-DRIVEN pipeline runs.
83
- pub config_runs: InFlight,
84
-
85
- /// Fires when the user clicks the status indicator while in
86
- /// [`StatusIconState::Normal`].
87
- pub status_indicator_clicked: PubSub<()>,
88
-
89
- /// Per-column numeric stats cache.
90
- column_stats: RefCell<HashMap<String, ColumnStats>>,
91
-
92
- /// Memoized snapshots used by [`Session::to_props`] to keep
93
- /// `PtrEqRc` identity stable across repeated `to_props()` calls
94
- /// when the underlying value hasn't changed.
95
- cached_config: RefCell<Option<PtrEqRc<ViewConfig>>>,
96
- cached_metadata: RefCell<Option<SessionMetadataRc>>,
97
-
98
- /// Dedup cell for `perspective-config-update`: the last [`ViewerConfig`]
99
- /// this session dispatched, so an unchanged re-fire is suppressed. Held
100
- /// per-`Session` (i.e. per panel) — was element-level on `Presentation`,
101
- /// which cross-suppressed when N panels shared one cell — so each panel
102
- /// dedups only against its own last dispatch. `Rc`-wrapped so the same
103
- /// allocation is shared with the event's lazy `getConfig()` closure without
104
- /// copying the config.
105
- pub last_dispatched_config: RefCell<Option<std::rc::Rc<crate::config::ViewerConfig>>>,
106
-
107
- /// Every writer of this panel's committed state, run one at a time in
108
- /// submit order (see [`op_queue`]).
109
- queue: Rc<OpQueue>,
110
-
111
- /// Coalesces `view_config_changed`: multiple synchronous commits in one
112
- /// task emit ONE event on the next microtask — the cadence the deleted
113
- /// `is_clean` flag provided by accident, now deliberate.
114
- config_event_scheduled: Cell<bool>,
115
-
116
- /// Account of in-flight `perspective-config-update` dispatch tasks for
117
- /// this panel (see [`Session::track_dispatch`]). `flush()` joins these via
118
- /// [`Session::settle_dispatches`], so the "config-update fires before
119
- /// `flush()` resolves" contract holds by construction instead of by
120
- /// microtask luck.
121
- dispatches: InFlight,
122
-
123
- /// Fires when [`SessionHandle::column_stats`] is updated (insert or
124
- /// clear). Subscribers re-render and re-query the schema with the
125
- /// new value.
126
- pub column_stats_changed: PubSub<()>,
127
-
128
- /// Fires when view stats are updated.
129
- pub stats_changed: PubSub<()>,
130
-
131
- /// Injected callback from the root component, driving
132
- /// `session_props.has_table_cells` for the active panel.
133
- pub on_stats_changed: RefCell<Option<Callback<()>>>,
134
-
135
- /// Injected callback from the root component, replacing the former
136
- /// `table_errored: PubSub` field. Fires when an error is set on the
137
- /// session (table load failure, client disconnect, invalid config, etc.).
138
- pub on_table_errored: RefCell<Option<Callback<()>>>,
139
- }
140
-
141
- impl Deref for SessionHandle {
142
- type Target = RefCell<SessionData>;
143
-
144
- fn deref(&self) -> &Self::Target {
145
- &self.session_data
146
- }
147
- }
148
-
149
- /// What an un-hosted `table` name means to a bind, per the `wait_for_table`
150
- /// option.
151
- #[derive(Clone, Copy, Debug, PartialEq, Eq)]
152
- pub enum MissingTable {
153
- /// A hard error that leaves the panel as it was.
154
- Error,
155
-
156
- /// The panel waits unbound and binds when the name is hosted.
157
- Pend,
158
- }
159
-
160
- impl MissingTable {
161
- /// Decode the `wait_for_table` option (absent = `false` = `Error`).
162
- pub fn from_wait(wait_for_table: Option<bool>) -> Self {
163
- if wait_for_table.unwrap_or_default() {
164
- Self::Pend
165
- } else {
166
- Self::Error
167
- }
168
- }
169
- }
170
-
171
- /// Open `name` on `client`, returning `Ok(None)` when the name is not hosted
172
- /// and `missing` is [`MissingTable::Pend`].
173
- pub(crate) async fn probe_table(
174
- client: &Client,
175
- name: &str,
176
- missing: MissingTable,
177
- ) -> ApiResult<Option<perspective_client::Table>> {
178
- match client.open_table(name.to_owned()).await {
179
- Ok(table) => Ok(Some(table)),
180
- Err(e) => {
181
- let hosted = client.get_hosted_table_names().await.unwrap_or_default();
182
- if hosted.iter().any(|n| n == name) {
183
- return Err(e.into());
184
- }
185
-
186
- match missing {
187
- MissingTable::Pend => Ok(None),
188
- MissingTable::Error => Err(ApiError::new(format!("Unknown table \"{name}\""))),
189
- }
190
- },
191
- }
192
- }
193
-
194
- /// Mutable state for `Session`.
195
- #[derive(Default)]
196
- pub struct SessionData {
197
- /// This panel's committed state: ONE immutable value, replaced whole by
198
- /// [`SessionData::swap`].
199
- state: Lifecycle,
200
-
201
- /// What [`Session::metadata`] answers while nothing is bound, and what
202
- /// [`Session::metadata_mut`] scribbles on (every write is a no-op then).
203
- unbound_metadata: Rc<SessionMetadata>,
204
- view_sub: Option<ViewSubscription>,
205
- stats: Option<ViewStats>,
206
- is_paused: bool,
207
- }
208
-
209
- /// A panel's state and whether it can still be written.
210
- enum Lifecycle {
211
- Live(Rc<PanelState>),
212
-
213
- /// Terminal: the owning panel was ejected ([`Session::dispose`]).
214
- Disposed {
215
- last: Rc<PanelState>,
216
- disposal: Disposal,
217
- },
218
- }
219
-
220
- impl Default for Lifecycle {
221
- fn default() -> Self {
222
- Self::Live(Rc::default())
223
- }
224
- }
225
-
226
- impl Deref for Lifecycle {
227
- type Target = Rc<PanelState>;
228
-
229
- fn deref(&self) -> &Self::Target {
230
- match self {
231
- Lifecycle::Live(state) | Lifecycle::Disposed { last: state, .. } => state,
232
- }
233
- }
234
- }
235
-
236
- impl Lifecycle {
237
- fn live_mut(&mut self) -> Option<&mut Rc<PanelState>> {
238
- match self {
239
- Lifecycle::Live(state) => Some(state),
240
- Lifecycle::Disposed { .. } => None,
241
- }
242
- }
243
-
244
- fn disposal(&self) -> Option<Disposal> {
245
- match self {
246
- Lifecycle::Live(_) => None,
247
- Lifecycle::Disposed { disposal, .. } => Some(*disposal),
248
- }
249
- }
250
- }
251
-
252
- /// An OWNED read guard over the committed [`ViewConfig`]: a snapshot that
253
- /// borrows nothing.
254
- pub struct ViewConfigRef(Rc<ViewConfig>);
255
-
256
- impl Deref for ViewConfigRef {
257
- type Target = ViewConfig;
258
-
259
- fn deref(&self) -> &Self::Target {
260
- &self.0
261
- }
262
- }
263
-
264
- impl SessionData {
265
- fn error(&self) -> Option<&TableErrorState> {
266
- self.state.lost()
267
- }
268
-
269
- fn clear_errors(&mut self) {
270
- if self.state.lost().is_some() {
271
- self.swap(self.state.recovered());
272
- }
273
- }
274
-
275
- fn swap(&mut self, next: PanelState) {
276
- if let Some(state) = self.state.live_mut() {
277
- *state = Rc::new(next);
278
- }
279
- }
280
-
281
- fn table(&self) -> Option<&perspective_client::Table> {
282
- self.state.bound().map(|bound| &bound.table)
283
- }
284
-
285
- fn pending_table(&self) -> Option<&str> {
286
- self.state.awaiting()
287
- }
288
-
289
- fn metadata(&self) -> &Rc<SessionMetadata> {
290
- match self.state.bound() {
291
- Some(bound) => &bound.metadata,
292
- None => &self.unbound_metadata,
293
- }
294
- }
295
-
296
- /// Copy-on-write: a snapshot held elsewhere never observes the mutation.
297
- fn metadata_mut(&mut self) -> &mut SessionMetadata {
298
- let Some(state) = self.state.live_mut() else {
299
- return Rc::make_mut(&mut self.unbound_metadata);
300
- };
301
-
302
- let binding = match &mut Rc::make_mut(state).binding {
303
- Binding::Lost { prior, .. } => Rc::make_mut(prior),
304
- binding => binding,
305
- };
306
-
307
- match binding {
308
- Binding::Bound(bound) => Rc::make_mut(&mut Rc::make_mut(bound).metadata),
309
- _ => Rc::make_mut(&mut self.unbound_metadata),
310
- }
311
- }
312
-
313
- fn config(&self) -> &ViewConfig {
314
- self.state.config()
315
- }
316
-
317
- fn set_config(&mut self, config: ViewConfig) {
318
- self.swap(self.state.with_config(Rc::new(config)));
319
- }
320
-
321
- /// Memo for [`Session::validate_snapshot`]: the [`Description`] the server
322
- /// gave for the last validated effective config; an equal snapshot skips
323
- /// the round trip.
324
- fn description(&self) -> Option<&(Rc<ViewConfig>, Rc<Description>)> {
325
- self.state.bound()?.description.as_ref()
326
- }
327
-
328
- fn set_description(&mut self, description: Option<(Rc<ViewConfig>, Rc<Description>)>) {
329
- self.swap(self.state.with_description(description));
330
- }
331
-
332
- fn unbind(&mut self) {
333
- self.swap(self.state.unbound());
334
- }
335
- }
336
-
337
- #[derive(Clone)]
338
- pub struct TableErrorState(ApiError, Option<ReconnectCallback>);
339
-
340
- impl PartialEq for TableErrorState {
341
- fn eq(&self, other: &Self) -> bool {
342
- self.0.to_string() == other.0.to_string()
343
- }
344
- }
345
-
346
- impl std::fmt::Debug for TableErrorState {
347
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
348
- f.debug_tuple("TableErrorState")
349
- .field(&self.0.to_string())
350
- .finish()
351
- }
352
- }
353
-
354
- impl TableErrorState {
355
- pub fn message(&self) -> String {
356
- self.0.message()
357
- }
358
-
359
- pub fn stacktrace(&self) -> String {
360
- self.0.stacktrace()
361
- }
362
-
363
- pub fn kind(&self) -> &'static str {
364
- self.0.kind()
365
- }
366
-
367
- pub fn is_reconnect(&self) -> bool {
368
- self.1.is_some()
369
- }
370
- }
371
-
372
- /// How a terminal disposal reports itself to a public run still in flight on
373
- /// the ejected panel.
374
- #[derive(Clone, Copy, PartialEq, Eq)]
375
- pub enum Disposal {
376
- /// A separate call destroyed the panel, so a racing public run rejects
377
- /// rather than reporting a success it never achieved.
378
- Reject,
379
-
380
- /// The ejecting call reports the eviction on its own promise, so a racing
381
- /// public run resolves rather than surfacing it twice.
382
- Resolve,
383
- }
384
-
385
- impl From<Disposal> for ApiResult<()> {
386
- fn from(disposal: Disposal) -> Self {
387
- match disposal {
388
- Disposal::Reject => Err(ApiError::new("Panel disposed")),
389
- Disposal::Resolve => Ok(()),
390
- }
391
- }
392
- }
393
-
394
- #[derive(Debug, Default)]
395
- pub enum TableIntermediateState {
396
- #[default]
397
- Ejected,
398
- }
399
-
400
- /// Options for [`Session::reset`]
401
- #[derive(Default)]
402
- pub struct ResetOptions {
403
- /// Reset user defined expressions
404
- pub expressions: bool,
405
-
406
- /// Reset the [`Table`]
407
- pub table: Option<TableIntermediateState>,
408
-
409
- /// Reset the [`ViewConfig`]
410
- pub config: bool,
411
-
412
- /// Manually reset the [`ViewStats`]
413
- pub stats: bool,
414
- }
415
-
416
- /// The `Session` struct is the principal interface to the Perspective engine,
417
- /// the `Table` and `View` objects for this viewer, and all associated state
418
- /// including the `ViewConfig`.
419
- #[derive(Clone)]
420
- pub struct Session(Rc<SessionHandle>);
421
-
422
- impl ImplicitClone for Session {}
423
-
424
- impl Deref for Session {
425
- type Target = SessionHandle;
426
-
427
- fn deref(&self) -> &Self::Target {
428
- &self.0
429
- }
430
- }
431
-
432
- impl PartialEq for Session {
433
- fn eq(&self, other: &Self) -> bool {
434
- Rc::ptr_eq(&self.0, &other.0)
435
- }
436
- }
437
-
438
- impl Session {
439
- /// Uses [`Self::new`] instead of [`Default`] to prevent accidental
440
- /// instantiation in props/etc.
441
- #[allow(clippy::new_without_default)]
442
- pub fn new() -> Self {
443
- Self(Rc::default())
444
- }
445
-
446
- pub(crate) fn metadata(&self) -> MetadataRef {
447
- MetadataRef(self.borrow().metadata().clone())
448
- }
449
-
450
- pub(crate) fn metadata_mut(&self) -> MetadataMutRef<'_> {
451
- std::cell::RefMut::map(self.borrow_mut(), |x| x.metadata_mut())
452
- }
453
-
454
- /// The title as the UI and `save()` see it: the committed title, or the
455
- /// latest pending rename.
456
- pub(crate) fn get_title(&self) -> Option<String> {
457
- let pending = self
458
- .0
459
- .queue
460
- .pending_edits()
461
- .into_iter()
462
- .filter_map(|delta| match delta {
463
- EditDelta::Title(title) => Some(title),
464
- _ => None,
465
- })
466
- .next_back();
467
-
468
- pending.unwrap_or_else(|| self.borrow().state.chrome.title.clone())
469
- }
470
-
471
- /// Rename this panel — a UI edit, committed by the drain in its turn.
472
- pub fn set_title(&self, title: Option<String>) {
473
- let title = title.filter(|x| !x.is_empty());
474
- let session = self.clone();
475
- let _ticket = self.submit(
476
- OpKind::Edit {
477
- delta: EditDelta::Title(title.clone()),
478
- swaps_plugin: false,
479
- },
480
- move |_ctx| {
481
- Box::pin(async move {
482
- session.commit_title(title);
483
- Ok(None)
484
- })
485
- },
486
- );
487
-
488
- self.title_changed.emit(self.get_title());
489
- }
490
-
491
- /// Write the title NOW.
492
- pub(crate) fn commit_title(&self, title: Option<String>) {
493
- let new_title = title.filter(|x| !x.is_empty());
494
- let next = self.borrow().state.with_title(new_title.clone());
495
- self.borrow_mut().swap(next);
496
- self.title_changed.emit(new_title);
497
- }
498
-
499
- /// Reset this (presumably shared) `Session` to its initial state, returning
500
- /// a bool indicating whether this `Session` had a table which was
501
- /// deleted. TODO Table should be an immutable constructor parameter to
502
- /// `Session`.
503
- pub fn reset(&self, options: ResetOptions) -> impl Future<Output = ApiResult<()>> + use<> {
504
- let view = self.0.borrow_mut().view_sub.take();
505
- let had_table = self.borrow().table().is_some();
506
- let err = self.get_error();
507
- self.borrow_mut().clear_errors();
508
- if options.stats {
509
- self.update_stats(ViewStats::default());
510
- }
511
-
512
- if options.config {
513
- let mut config = self.borrow().config().clone();
514
- config.reset(options.expressions);
515
- self.borrow_mut().set_config(config);
516
- }
517
-
518
- if options.expressions {
519
- self.borrow_mut().set_description(None);
520
- }
521
-
522
- match options.table {
523
- Some(TableIntermediateState::Ejected) => self.borrow_mut().unbind(),
524
- None => {},
525
- };
526
-
527
- // A config reset that KEEPS its `Table` is itself a commit, and every
528
- // commit normalizes (I1/I4): re-fill the emptied `columns` from the
529
- // table's defaults NOW, synchronously — previously this fill lived in
530
- // the async validate write-back and ran on the next draw, so skipping
531
- // it here left `save()` reporting `columns: []` after `reset()`. An
532
- // ejecting/reloading reset skips it (no table to fill from — `load()`
533
- // runs its own table-bind commit).
534
- if options.config && options.table.is_none() {
535
- self.commit_table_defaults();
536
- }
537
-
538
- let session = self.clone();
539
- async move {
540
- let res = view.delete().await;
541
- if options.table.is_some() && had_table {
542
- session.table_unloaded.emit(true)
543
- }
544
-
545
- if let Some(err) = err { Err(err) } else { res }
546
- }
547
- }
548
-
549
- /// Submit a writer of this panel's state.
550
- pub fn submit(&self, kind: OpKind, step: impl FnOnce(OpCtx) -> StepFuture + 'static) -> Ticket {
551
- if let Some(disposal) = self.disposal() {
552
- return Ticket::settled(disposal.into());
553
- }
554
-
555
- let is_edit = matches!(kind, OpKind::Edit {
556
- delta: EditDelta::View(_),
557
- ..
558
- });
559
-
560
- let guard = self.begin_config_run();
561
- let (ticket, start) = self.0.queue.push(kind, guard, step);
562
- if is_edit {
563
- self.notify_view_config_changed();
564
- }
565
-
566
- if start {
567
- let queue = self.0.queue.clone();
568
- let session = self.clone();
569
- ApiFuture::spawn_named("op-queue-drain", async move {
570
- queue
571
- .drain(move |_exit| session.notify_view_config_changed())
572
- .await;
573
-
574
- Ok(())
575
- });
576
- }
577
-
578
- ticket
579
- }
580
-
581
- /// Resolves once every op submitted to this panel has settled — its write
582
- /// made (or rejected) AND its render landed.
583
- pub async fn settle_ops(&self) {
584
- self.0.queue.idle().await
585
- }
586
-
587
- /// Whether a `load()` is queued or running.
588
- pub fn has_pending_load(&self) -> bool {
589
- self.0.queue.has_load()
590
- }
591
-
592
- /// The ONE `Live → Disposed` transition (this session's panel was ejected):
593
- /// the state is frozen as its last value, everything queued settles per
594
- /// `disposal`, and every later `submit` settles at once.
595
- pub(crate) fn dispose(&self, disposal: Disposal) {
596
- {
597
- let mut data = self.borrow_mut();
598
- if let Lifecycle::Live(last) = &data.state {
599
- data.state = Lifecycle::Disposed {
600
- last: last.clone(),
601
- disposal,
602
- };
603
- }
604
- }
605
-
606
- self.0.queue.reject_all(disposal.into());
607
- }
608
-
609
- /// Take the bound `View` out WITHOUT deleting it, so it can feed a derived
610
- /// `Table`, leaving the next bind nothing to dispose of.
611
- pub fn take_view_sub(&self) -> Option<ViewSubscription> {
612
- self.borrow_mut().view_sub.take()
613
- }
614
-
615
- /// Put a subscription taken by [`Self::take_view_sub`] back, for a
616
- /// derivation which could not complete.
617
- pub fn put_view_sub(&self, sub: ViewSubscription) {
618
- self.borrow_mut().view_sub = Some(sub);
619
- }
620
-
621
- pub(crate) fn is_disposed(&self) -> bool {
622
- self.disposal().is_some()
623
- }
624
-
625
- /// This session's disposal, if its panel was ejected.
626
- pub(crate) fn disposal(&self) -> Option<Disposal> {
627
- self.borrow().state.disposal()
628
- }
629
-
630
- pub(crate) fn has_table(&self) -> Option<TableLoadState> {
631
- let data = self.borrow();
632
- if data.table().is_some() {
633
- Some(TableLoadState::Loaded)
634
- } else if self.0.queue.has_load() {
635
- Some(TableLoadState::Loading)
636
- } else if data.pending_table().is_some() {
637
- Some(TableLoadState::Pending)
638
- } else {
639
- None
640
- }
641
- }
642
-
643
- pub fn get_table(&self) -> Option<perspective_client::Table> {
644
- self.borrow().table().cloned()
645
- }
646
-
647
- /// Look this panel's tables up on `client` — unbinding it from a table of
648
- /// any other client's.
649
- pub fn set_client(&self, client: Client) -> bool {
650
- if Some(&client) != self.get_client().as_ref() {
651
- let next = self.borrow().state.unbound_on(Some(client));
652
- self.borrow_mut().swap(next);
653
- true
654
- } else {
655
- false
656
- }
657
- }
658
-
659
- pub fn get_client(&self) -> Option<Client> {
660
- self.borrow().state.client()
661
- }
662
-
663
- /// The configured table name awaiting a host, if any (see
664
- /// [`SessionData::pending_table`]).
665
- pub fn pending_table(&self) -> Option<String> {
666
- self.borrow().pending_table().map(str::to_owned)
667
- }
668
-
669
- /// Suspend a BOUND table to PENDING: delete the `View`, drop the `Table`
670
- /// handle (freeing the engine name for a lazy `Table::delete` to
671
- /// complete), and record the name as pending — the view config is KEPT,
672
- /// so the reactive rebind (`tasks::table_lifecycle`) restores this panel
673
- /// as it was when the name is hosted again. `None` when no table is
674
- /// bound.
675
- pub fn suspend_table(&self) -> Option<impl Future<Output = ApiResult<()>> + use<>> {
676
- let name = self.borrow().table()?.get_name().to_owned();
677
- let client = self.get_client()?;
678
- let fut = self.reset(ResetOptions {
679
- table: Some(TableIntermediateState::Ejected),
680
- stats: true,
681
- ..ResetOptions::default()
682
- });
683
-
684
- let next = self.borrow().state.awaiting_table(client, name);
685
- self.borrow_mut().swap(next);
686
- Some(fut)
687
- }
688
-
689
- /// Record a connection error on `client` as this panel's lost binding — for
690
- /// as long as `client` is the one the panel is bound through.
691
- async fn watch_client(&self, client: &Client) -> ApiResult<()> {
692
- let on_error = self.on_table_errored.borrow().clone();
693
- let session = self.clone();
694
- let watched = client.clone();
695
- let poll_loop = LocalPollLoop::new(move |(message, reconnect): (ApiError, _)| {
696
- if session.get_client().as_ref() != Some(&watched) {
697
- return Ok(JsValue::UNDEFINED);
698
- }
699
-
700
- let next = session
701
- .borrow()
702
- .state
703
- .with_lost(TableErrorState(message, reconnect));
704
- session.borrow_mut().swap(next);
705
- if let Some(cb) = &on_error {
706
- cb.emit(());
707
- }
708
- if let Some(sub) = session.borrow_mut().view_sub.take() {
709
- sub.dismiss();
710
- }
711
-
712
- Ok(JsValue::UNDEFINED)
713
- });
714
-
715
- let _callback_id = client
716
- .on_error(Box::new(move |message: ClientError, reconnect| {
717
- let poll_loop = poll_loop.clone();
718
- async move {
719
- poll_loop.poll((message.into(), reconnect)).await;
720
- Ok(())
721
- }
722
- }))
723
- .await?;
724
-
725
- Ok(())
726
- }
727
-
728
- pub async fn set_error(&self, reset_table: bool, err: ApiError) -> ApiResult<()> {
729
- let session = self.clone();
730
- let poll_loop = LocalPollLoop::new(move |()| {
731
- ApiFuture::spawn(session.reset(ResetOptions {
732
- config: true,
733
- expressions: true,
734
- ..ResetOptions::default()
735
- }));
736
- Ok(JsValue::UNDEFINED)
737
- });
738
-
739
- let error = TableErrorState(
740
- err.clone(),
741
- Some(ReconnectCallback::new(move || {
742
- clone!(poll_loop);
743
- Box::pin(async move {
744
- poll_loop.poll(()).await;
745
- Ok(())
746
- })
747
- })),
748
- );
749
-
750
- let next = self.borrow().state.with_lost(error);
751
- self.borrow_mut().swap(next);
752
-
753
- if let Some(cb) = self.on_table_errored.borrow().as_ref() {
754
- cb.emit(());
755
- }
756
-
757
- let sub = self.borrow_mut().view_sub.take();
758
- if reset_table {
759
- self.borrow_mut().unbind();
760
- }
761
-
762
- sub.delete().await?;
763
- Err(err)
764
- }
765
-
766
- pub fn set_pause(&self, pause: bool) -> bool {
767
- if pause == self.borrow().is_paused {
768
- false
769
- } else if pause {
770
- ApiFuture::spawn(self.borrow_mut().view_sub.take().delete());
771
- self.borrow_mut().is_paused = true;
772
- true
773
- } else {
774
- self.borrow_mut().is_paused = false;
775
- true
776
- }
777
- }
778
-
779
- pub async fn await_table(&self) -> ApiResult<()> {
780
- if self.js_get_table().is_none() {
781
- self.table_loaded.read_next().await?;
782
- let _ = self.js_get_table().ok_or("No table set")?;
783
- }
784
-
785
- Ok(())
786
- }
787
-
788
- pub fn js_get_table(&self) -> Option<JsValue> {
789
- Some(perspective_js::Table::from(self.borrow().table().cloned()?).into())
790
- }
791
-
792
- /// Whether the binding is lost.
793
- pub(crate) fn is_errored(&self) -> bool {
794
- self.borrow().error().is_some()
795
- }
796
-
797
- pub(crate) fn get_error(&self) -> Option<ApiError> {
798
- self.borrow().error().map(|x| x.0.clone())
799
- }
800
-
801
- /// Recover from an error state (the overlay's button) — a writer, so an op
802
- /// on the queue like any other.
803
- pub async fn reconnect(&self) -> ApiResult<()> {
804
- let session = self.clone();
805
- self.submit(OpKind::Restore { update: None }, move |_ctx| {
806
- Box::pin(async move {
807
- session.reconnect_step().await?;
808
- Ok(None)
809
- })
810
- })
811
- .settle()
812
- .await
813
- }
814
-
815
- async fn reconnect_step(&self) -> ApiResult<()> {
816
- let err = self.borrow().error().cloned();
817
- if let Some(TableErrorState(_, Some(reconnect))) = err {
818
- reconnect().await?;
819
- self.borrow_mut().clear_errors();
820
- self.borrow_mut().set_description(None);
821
- self.borrow_mut().view_sub = None;
822
- self.table_loaded.emit(());
823
- }
824
-
825
- Ok(())
826
- }
827
-
828
- pub fn get_view(&self) -> Option<View> {
829
- self.borrow()
830
- .view_sub
831
- .as_ref()
832
- .map(|sub| sub.get_view().clone())
833
- }
834
-
835
- /// The bound `View` together with its latest known dimensions, read under
836
- /// one borrow so they always belong together.
837
- pub fn get_view_with_dimensions(&self) -> Option<(View, Option<ViewDimensionsResp>)> {
838
- self.borrow()
839
- .view_sub
840
- .as_ref()
841
- .map(|sub| (sub.get_view().clone(), sub.dimensions()))
842
- }
843
-
844
- pub(crate) fn get_table_stats(&self) -> Option<ViewStats> {
845
- self.borrow().stats.clone()
846
- }
847
-
848
- /// Whether the stats snapshot carries table dimensions.
849
- pub(crate) fn has_table_cells(&self) -> bool {
850
- self.borrow()
851
- .stats
852
- .as_ref()
853
- .is_some_and(|s| s.num_table_cells.is_some())
854
- }
855
-
856
- /// The view config as the UI and `save()` see it: the committed config with
857
- /// every pending UI edit applied, in submit order.
858
- pub fn get_view_config(&self) -> ViewConfigRef {
859
- ViewConfigRef(self.projected())
860
- }
861
-
862
- /// The COMMITTED view config — what a running op must read, since the edits
863
- /// still queued behind it have not happened yet.
864
- pub fn committed_view_config(&self) -> ViewConfigRef {
865
- ViewConfigRef(self.borrow().state.config().clone())
866
- }
867
-
868
- fn projected(&self) -> Rc<ViewConfig> {
869
- let committed = self.borrow().state.config().clone();
870
- let edits = self
871
- .0
872
- .queue
873
- .pending_edits()
874
- .into_iter()
875
- .filter_map(|delta| match delta {
876
- EditDelta::View(delta) => Some(*delta),
877
- _ => None,
878
- })
879
- .collect::<Vec<_>>();
880
-
881
- if edits.is_empty() {
882
- return committed;
883
- }
884
-
885
- let mut config = (*committed).clone();
886
- for delta in edits {
887
- let mut candidate = config.clone();
888
- if candidate.apply_update(delta) && self.validate_names(&candidate).is_ok() {
889
- self.normalize_view_config(&mut candidate);
890
- config = candidate;
891
- }
892
- }
893
-
894
- Rc::new(config)
895
- }
896
-
897
- /// Whether `delta` is an edit the UI may submit: SYNCHRONOUS validation
898
- /// against the projection, so an invalid edit is refused at the control
899
- /// that made it.
900
- pub fn check_edit(&self, delta: &ViewConfigUpdate) -> ApiResult<()> {
901
- if let Some(x) = self.borrow().state.lost() {
902
- return Err(ApiError::new(x.0.clone()));
903
- }
904
-
905
- let mut candidate = (*self.projected()).clone();
906
- if candidate.apply_update(delta.clone()) {
907
- self.validate_names(&candidate)?;
908
- }
909
-
910
- Ok(())
911
- }
912
-
913
- /// The effective [`ViewConfig`] the `View` is built from — the one the
914
- /// committed description describes.
915
- fn effective_view_config(&self) -> Rc<ViewConfig> {
916
- let data = self.borrow();
917
- if let Some((effective, _)) = data.description() {
918
- return effective.clone();
919
- }
920
-
921
- let metadata = data.metadata().clone();
922
- let (config, _) = effective(data.config(), &data.state.overlay, &|name| {
923
- metadata.get_column_table_type(name)
924
- });
925
-
926
- Rc::new(config)
927
- }
928
-
929
- /// The overlay clauses this panel's table cannot honor, by index — a column
930
- /// it lacks, or has with another type.
931
- pub fn skipped_overlay(&self) -> Vec<usize> {
932
- let data = self.borrow();
933
- let metadata = data.metadata().clone();
934
- effective(data.config(), &data.state.overlay, &|name| {
935
- metadata.get_column_table_type(name)
936
- })
937
- .1
938
- }
939
-
940
- /// The element's global filter as last broadcast to this panel.
941
- pub(crate) fn committed_overlay(&self) -> Rc<Vec<OverlayClause>> {
942
- self.borrow().state.overlay.clone()
943
- }
944
-
945
- /// Snapshot of the [`ViewConfig`] the currently-bound `View` was
946
- /// constructed from. Returns `None` if no `View` has been created
947
- /// yet (e.g., the post-`load`/pre-render window, or after a reset).
948
- ///
949
- /// Prefer this over [`Self::get_view_config`] when you need a
950
- /// value consistent with what the active plugin is rendering.
951
- /// `get_view_config` returns the PROJECTED config — committed state plus
952
- /// pending edits — which runs ahead of the bound `View`.
953
- pub fn get_rendered_view_config(&self) -> Option<Rc<ViewConfig>> {
954
- self.borrow().view_sub.as_ref().map(|s| s.get_view_config())
955
- }
956
-
957
- pub fn set_update_column_defaults(
958
- &self,
959
- config_update: &mut ViewConfigUpdate,
960
- config_static: &PluginStaticConfig,
961
- ) {
962
- use self::column_defaults_update::*;
963
- let config = self.committed_view_config();
964
- config_update.set_update_column_defaults(
965
- &self.metadata(),
966
- &config,
967
- &config.columns,
968
- config_static,
969
- )
970
- }
971
-
972
- /// Rollup-mode-only subset of [`Self::set_update_column_defaults`], for
973
- /// restores that do NOT swap plugins: the plugin-advised
974
- /// `group_rollup_mode` must be (re-)enforced on every restore commit —
975
- /// a preceding `reset` may have wiped it — but the column-defaulting
976
- /// half must not run (it would rewrite a partial update's `columns`).
977
- pub fn set_update_rollup_defaults(
978
- &self,
979
- config_update: &mut ViewConfigUpdate,
980
- config_static: &PluginStaticConfig,
981
- ) {
982
- use self::column_defaults_update::*;
983
- config_update.set_update_rollup_defaults(
984
- &self.metadata(),
985
- &self.committed_view_config(),
986
- config_static,
987
- )
988
- }
989
-
990
- /// Re-normalize the config against the bound table's metadata — the
991
- /// default-view materialization after a config reset that keeps its table.
992
- fn commit_table_defaults(&self) {
993
- let mut candidate = self.borrow().config().clone();
994
- self.normalize_view_config(&mut candidate);
995
- if candidate != *self.borrow().config() {
996
- self.borrow_mut().set_config(candidate);
997
- self.notify_view_config_changed();
998
- }
999
- }
1000
-
1001
- /// SYNC name validation for a candidate config (I4): every referenced
1002
- /// column must be a table column, or an expression or window column
1003
- /// present in the candidate itself (syntactic presence — server-side
1004
- /// compilability is a run property, not a commit property). Skipped
1005
- /// when no table is bound yet: the config rides along until `load()`
1006
- /// binds one, and the engine surfaces any residual error on that run.
1007
- fn validate_names(&self, config: &ViewConfig) -> ApiResult<()> {
1008
- Self::validate_names_with(&self.metadata(), config)
1009
- }
1010
-
1011
- /// [`Self::validate_names`] against an explicit table's metadata — the
1012
- /// INCOMING table's, for a restore that binds one.
1013
- fn validate_names_with(metadata: &SessionMetadata, config: &ViewConfig) -> ApiResult<()> {
1014
- let table_columns = Self::columns_of(metadata);
1015
- if table_columns.is_empty() {
1016
- return Ok(());
1017
- }
1018
-
1019
- let mut allowed: HashSet<&str> = table_columns.iter().map(|x| x.as_str()).collect();
1020
- allowed.extend(config.expressions.0.keys().map(|x| x.as_str()));
1021
- allowed.extend(config.windows.keys().map(|x| x.as_str()));
1022
- let named = config
1023
- .columns
1024
- .iter()
1025
- .flatten()
1026
- .map(|x| ("columns", x))
1027
- .chain(config.group_by.iter().map(|x| ("group_by", x)))
1028
- .chain(config.split_by.iter().map(|x| ("split_by", x)))
1029
- .chain(config.sort.iter().map(|x| ("sort", &x.0)));
1030
-
1031
- for (field, column) in named {
1032
- if !allowed.contains(column.as_str()) {
1033
- return Err(apierror!(InvalidViewerConfigError(
1034
- field,
1035
- column.to_owned()
1036
- )));
1037
- }
1038
- }
1039
-
1040
- for filter in config.filter.iter() {
1041
- // TODO check filter op
1042
- if !allowed.contains(filter.column()) {
1043
- return Err(apierror!(InvalidViewerConfigError(
1044
- "filter",
1045
- filter.column().to_owned()
1046
- )));
1047
- }
1048
- }
1049
-
1050
- Ok(())
1051
- }
1052
-
1053
- /// SYNC normalization at commit time (previously the async validate's
1054
- /// write-back): fill empty `columns` from the table, prune `aggregates`
1055
- /// to referenced columns.
1056
- fn normalize_view_config(&self, config: &mut ViewConfig) {
1057
- Self::normalize_with(&self.metadata(), config)
1058
- }
1059
-
1060
- fn normalize_with(metadata: &SessionMetadata, config: &mut ViewConfig) {
1061
- let table_columns = Self::columns_of(metadata);
1062
- if table_columns.is_empty() {
1063
- return;
1064
- }
1065
-
1066
- if config.columns.is_empty() {
1067
- config.columns = table_columns.iter().cloned().map(Some).collect();
1068
- }
1069
-
1070
- let view_columns: HashSet<String> = config
1071
- .columns
1072
- .iter()
1073
- .flatten()
1074
- .cloned()
1075
- .chain(config.group_by.iter().cloned())
1076
- .chain(config.split_by.iter().cloned())
1077
- .chain(config.sort.iter().map(|x| x.0.clone()))
1078
- .chain(config.filter.iter().map(|x| x.column().to_owned()))
1079
- .collect();
1080
-
1081
- config
1082
- .aggregates
1083
- .retain(|column, _| view_columns.contains(column.as_str()));
1084
- }
1085
-
1086
- /// Run `fut` as a TRACKED dispatch task: its errors are owned (logged,
1087
- /// tagged) and its completion is joinable via
1088
- /// [`Self::settle_dispatches`]. Used by the `perspective-config-update`
1089
- /// dispatcher, whose landing `flush()` must be able to await.
1090
- pub fn track_dispatch(&self, fut: impl std::future::Future<Output = ApiResult<()>> + 'static) {
1091
- let guard = self.0.dispatches.guard();
1092
- ApiFuture::spawn_named("config-update-dispatch", async move {
1093
- let _guard = guard;
1094
- if let Err(e) = fut.await {
1095
- tracing::error!("[config-update dispatch] {}", e);
1096
- }
1097
-
1098
- Ok(())
1099
- });
1100
- }
1101
-
1102
- /// Resolve once every in-flight tracked dispatch for this panel has
1103
- /// landed. Immediate when none are pending.
1104
- pub async fn settle_dispatches(&self) -> ApiResult<()> {
1105
- self.0.dispatches.settle().await;
1106
- Ok(())
1107
- }
1108
-
1109
- /// Emit `view_config_changed` coalesced to one event per microtask batch.
1110
- /// Stats are cleared synchronously per commit (idempotent — an
1111
- /// already-empty cache no-ops, so rapid commit sequences fetch once).
1112
- fn notify_view_config_changed(&self) {
1113
- self.clear_column_stats();
1114
- if !self.0.config_event_scheduled.replace(true) {
1115
- let session = self.clone();
1116
- ApiFuture::spawn(async move {
1117
- session.0.config_event_scheduled.set(false);
1118
- session.view_config_changed.emit(());
1119
- Ok(())
1120
- });
1121
- }
1122
- }
1123
-
1124
- /// Begin spinner accounting for ONE config-driven pipeline run: call
1125
- /// immediately after the run's commit, and move the returned guard INTO
1126
- /// the run future.
1127
- pub fn begin_config_run(&self) -> InFlightGuard {
1128
- self.0.config_runs.guard()
1129
- }
1130
-
1131
- /// Read the cached `ColumnStats` for a column. Returns `None` if no
1132
- /// fetch has populated this column yet (or the cache was just
1133
- /// cleared by a view-config change).
1134
- pub fn get_column_stats(&self, column_name: &str) -> Option<ColumnStats> {
1135
- self.column_stats.borrow().get(column_name).copied()
1136
- }
1137
-
1138
- /// Insert a freshly-fetched `abs_max` for a column and notify
1139
- /// subscribers via [`SessionHandle::column_stats_changed`].
1140
- pub fn set_column_abs_max(&self, column_name: String, abs_max: f64) {
1141
- self.column_stats
1142
- .borrow_mut()
1143
- .entry(column_name)
1144
- .or_default()
1145
- .abs_max = Some(abs_max);
1146
- self.column_stats_changed.emit(());
1147
- }
1148
-
1149
- /// Drop the entire stats cache. Called when the view config changes
1150
- /// (filter / group_by / etc.) so stats are re-fetched on next
1151
- /// schema query.
1152
- pub fn clear_column_stats(&self) {
1153
- if !self.column_stats.borrow().is_empty() {
1154
- self.column_stats.borrow_mut().clear();
1155
- self.column_stats_changed.emit(());
1156
- }
1157
- }
1158
-
1159
- /// Immutable input for one pipeline run (invariant I2): the persisted
1160
- /// config and its EFFECTIVE companion (global-filter overlay appended),
1161
- /// captured at the same synchronous instant. Requires the
1162
- /// [`RenderGuard`] witness — snapshots exist only inside a locked run,
1163
- /// so run *N+1*'s snapshot is provably at least as fresh as every commit
1164
- /// that preceded run *N*'s completion (invariant I3).
1165
- pub fn snapshot(&self, _guard: &RenderGuard) -> ConfigSnapshot {
1166
- ConfigSnapshot {
1167
- config: self.borrow().state.config().clone(),
1168
- effective: self.effective_view_config(),
1169
- }
1170
- }
1171
-
1172
- /// Validate a snapshot against the server with `Table::describe`, failing
1173
- /// this run and never the committed config.
1174
- pub async fn validate_snapshot(
1175
- &self,
1176
- _guard: &RenderGuard,
1177
- snap: ConfigSnapshot,
1178
- ) -> ApiResult<ValidatedSnapshot> {
1179
- let (description, fresh) = self.describe_effective(&snap.effective).await?;
1180
- if fresh {
1181
- tracing::warn!("Rendering a commit that was not described");
1182
- Self::record_description(&mut self.metadata_mut(), &snap.effective, &description)?;
1183
- self.borrow_mut()
1184
- .set_description(Some((snap.effective.clone(), description.clone())));
1185
- }
1186
-
1187
- Ok(ValidatedSnapshot { snap })
1188
- }
1189
-
1190
- /// The server's [`Description`] of `effective`, and whether it took a round
1191
- /// trip (`false` when the memo already held it).
1192
- async fn describe_effective(
1193
- &self,
1194
- effective: &Rc<ViewConfig>,
1195
- ) -> ApiResult<(Rc<Description>, bool)> {
1196
- let memo = self
1197
- .borrow()
1198
- .description()
1199
- .cloned()
1200
- .filter(|(key, _)| **key == **effective)
1201
- .map(|(_, description)| description);
1202
-
1203
- if let Some(description) = memo {
1204
- return Ok((description, false));
1205
- }
1206
-
1207
- let table = self
1208
- .borrow()
1209
- .table()
1210
- .cloned()
1211
- .ok_or_else(|| apierror!(NoTableError))?;
1212
-
1213
- Self::describe_with(&table, &self.metadata(), effective)
1214
- .await
1215
- .map(|description| (description, true))
1216
- }
1217
-
1218
- /// `table`'s [`Description`] of `effective`, with validation failures as
1219
- /// the errors a `restore()` rejects with.
1220
- async fn describe_with(
1221
- table: &perspective_client::Table,
1222
- metadata: &SessionMetadata,
1223
- effective: &Rc<ViewConfig>,
1224
- ) -> ApiResult<Rc<Description>> {
1225
- let engine_config = Self::with_default_aggregates_of(metadata, effective);
1226
- match table.describe(engine_config.into()).await? {
1227
- Ok(description) => Ok(Rc::new(description)),
1228
- Err(DescribeError::Expressions {
1229
- expression_schema,
1230
- errors,
1231
- }) => Err(apierror!(InvalidViewerConfigExpressionsError(Rc::new(
1232
- ExprValidationResult {
1233
- expression_schema,
1234
- errors,
1235
- expression_alias: effective.expressions.0.clone(),
1236
- }
1237
- )))),
1238
- Err(DescribeError::Config(msg)) => Err(ApiError::new(msg)),
1239
- }
1240
- }
1241
-
1242
- /// The PREPARE half of a transactional restore's view of the panel: the
1243
- /// binding `plan` resolved, and the config it leaves — the committed one (a
1244
- /// default one, for a plan that resets) with `update` applied —
1245
- /// name-checked, normalized and DESCRIBED by the table it will be bound to.
1246
- pub(crate) async fn prepare_view(
1247
- &self,
1248
- plan: BindPlan,
1249
- mut update: ViewConfigUpdate,
1250
- defaults: ViewDefaults<'_>,
1251
- overlay: Option<Rc<Vec<OverlayClause>>>,
1252
- ) -> ApiResult<PreparedView> {
1253
- if self.is_disposed() {
1254
- return Err(ApiError::new("Panel disposed"));
1255
- }
1256
-
1257
- if matches!(plan, BindPlan::Keep)
1258
- && let Some(error) = self.borrow().state.lost()
1259
- {
1260
- return Err(error.0.clone());
1261
- }
1262
-
1263
- let committed = self.borrow().state.config().clone();
1264
- let base = match &plan {
1265
- BindPlan::Bind { reset: true, .. } | BindPlan::Pend { reset: true, .. } => {
1266
- Rc::new(ViewConfig::default())
1267
- },
1268
- _ => committed.clone(),
1269
- };
1270
-
1271
- let (binding, checked) = match plan {
1272
- BindPlan::Keep => {
1273
- let bound = self.borrow().state.bound().cloned();
1274
- (
1275
- PreparedBinding::Keep,
1276
- bound.map(|bound| (bound.table.clone(), bound.metadata.clone())),
1277
- )
1278
- },
1279
- BindPlan::Bind { table, client, .. } => {
1280
- let metadata = Rc::new(SessionMetadata::from_table(&table).await?);
1281
- let binding = PreparedBinding::Bind {
1282
- client: client.clone(),
1283
- table: table.clone(),
1284
- metadata: metadata.clone(),
1285
- };
1286
-
1287
- (binding, Some((*table, metadata)))
1288
- },
1289
- BindPlan::Pend { client, name, .. } => (PreparedBinding::Pend { client, name }, None),
1290
- };
1291
-
1292
- {
1293
- use self::column_defaults_update::*;
1294
- let metadata = match &checked {
1295
- Some((_, metadata)) => metadata.clone(),
1296
- None => self.borrow().metadata().clone(),
1297
- };
1298
-
1299
- match defaults {
1300
- ViewDefaults::Swap(plugin) => {
1301
- update.set_update_column_defaults(&metadata, &base, &base.columns, plugin)
1302
- },
1303
- ViewDefaults::Rollup(plugin) => {
1304
- update.set_update_rollup_defaults(&metadata, &base, plugin)
1305
- },
1306
- ViewDefaults::AsGiven => {},
1307
- }
1308
- }
1309
-
1310
- let mut candidate = (*base).clone();
1311
- candidate.apply_update(update);
1312
- if let Some((_, metadata)) = &checked {
1313
- Self::validate_names_with(metadata, &candidate)?;
1314
- Self::normalize_with(metadata, &mut candidate);
1315
- }
1316
-
1317
- let config = if candidate == *committed {
1318
- committed.clone()
1319
- } else {
1320
- Rc::new(candidate)
1321
- };
1322
-
1323
- let changed = !Rc::ptr_eq(&config, &committed);
1324
- let clauses = overlay
1325
- .clone()
1326
- .unwrap_or_else(|| self.borrow().state.overlay.clone());
1327
-
1328
- let (effective, description) = match &checked {
1329
- None => (config.clone(), None),
1330
- Some((table, metadata)) => {
1331
- let on_expression = clauses
1332
- .iter()
1333
- .any(|x| config.expressions.0.contains_key(x.filter.column()));
1334
-
1335
- let bare = if on_expression {
1336
- Some(Self::describe_with(table, metadata, &config).await?)
1337
- } else {
1338
- None
1339
- };
1340
-
1341
- let (effective, _) = effective(&config, &clauses, &|name| {
1342
- metadata.get_table_schema_type(name).or_else(|| {
1343
- bare.as_ref()
1344
- .and_then(|x| x.expression_schema.get(name).copied())
1345
- })
1346
- });
1347
-
1348
- let effective = if effective == *config {
1349
- config.clone()
1350
- } else {
1351
- Rc::new(effective)
1352
- };
1353
-
1354
- let description = match (&binding, bare) {
1355
- (_, Some(bare)) if Rc::ptr_eq(&effective, &config) => bare,
1356
- (PreparedBinding::Keep, _) => self.describe_effective(&effective).await?.0,
1357
- _ => Self::describe_with(table, metadata, &effective).await?,
1358
- };
1359
-
1360
- (effective, Some(description))
1361
- },
1362
- };
1363
-
1364
- Ok(PreparedView {
1365
- binding,
1366
- overlay,
1367
- config,
1368
- effective,
1369
- description,
1370
- changed,
1371
- announce: true,
1372
- })
1373
- }
1374
-
1375
- /// The COMMIT half of [`Self::prepare_view`], as one swap of this session's
1376
- /// state.
1377
- pub(crate) fn commit_view(
1378
- &self,
1379
- view: PreparedView,
1380
- title: Option<Option<String>>,
1381
- ) -> BindingEffects {
1382
- let state = self.borrow().state.clone();
1383
- let title_before = state.chrome.title.clone();
1384
- let had_table = state.bound().is_some();
1385
- let (rebound, watch) = match view.binding {
1386
- PreparedBinding::Keep => (None, None),
1387
- PreparedBinding::Bind {
1388
- client,
1389
- table,
1390
- metadata,
1391
- } => (
1392
- Some(state.bound_to(*table, (*metadata).clone())),
1393
- Some(client),
1394
- ),
1395
- PreparedBinding::Pend { client, name } => {
1396
- (Some(state.awaiting_table(client, name)), None)
1397
- },
1398
- };
1399
-
1400
- let rebinds = rebound.is_some();
1401
- let mut next = rebound.unwrap_or_else(|| (*state).clone());
1402
- next = next.with_config(view.config.clone());
1403
- if let Some(overlay) = view.overlay {
1404
- next = next.with_overlay(overlay);
1405
- }
1406
-
1407
- if let Some(description) = view.description {
1408
- if let Some(bound) = next.bound() {
1409
- let mut metadata = (*bound.metadata).clone();
1410
- if Self::record_description(&mut metadata, &view.effective, &description).is_ok() {
1411
- next = next.with_metadata(Rc::new(metadata));
1412
- }
1413
- }
1414
-
1415
- next = next.with_description(Some((view.effective, description)));
1416
- }
1417
-
1418
- let next = match title {
1419
- Some(title) => next.with_title(title),
1420
- None => next,
1421
- };
1422
-
1423
- let title_after = next.chrome.title.clone();
1424
- let bound = next.bound().is_some();
1425
- self.borrow_mut().swap(next);
1426
- let outgoing = if rebinds {
1427
- self.borrow_mut().view_sub.take()
1428
- } else {
1429
- None
1430
- };
1431
-
1432
- if rebinds {
1433
- self.update_stats(ViewStats::default());
1434
- }
1435
-
1436
- if (view.changed && view.announce) || rebinds {
1437
- self.notify_view_config_changed();
1438
- }
1439
-
1440
- if title_before != title_after {
1441
- self.title_changed.emit(title_after);
1442
- }
1443
-
1444
- BindingEffects {
1445
- rebinds,
1446
- outgoing,
1447
- unloaded: rebinds && had_table,
1448
- loaded: rebinds && bound,
1449
- watch,
1450
- }
1451
- }
1452
-
1453
- /// Everything the metadata derives from a [`Description`] of `effective`:
1454
- /// the expression types, the types the `View` will have, and the window
1455
- /// columns.
1456
- fn record_description(
1457
- metadata: &mut SessionMetadata,
1458
- effective: &ViewConfig,
1459
- description: &Description,
1460
- ) -> ApiResult<()> {
1461
- metadata.update_expressions(&ExprValidationResult {
1462
- expression_schema: description.expression_schema.clone(),
1463
- errors: HashMap::new(),
1464
- expression_alias: effective.expressions.0.clone(),
1465
- })?;
1466
-
1467
- metadata.update_view_schema(&description.view_schema)?;
1468
- metadata.update_windows(&effective.windows)?;
1469
- Ok(())
1470
- }
1471
-
1472
- /// Finish a committed rebind: dispose of the outgoing `View`, announce the
1473
- /// table change, and watch the incoming client for errors.
1474
- pub(crate) async fn finish_binding(&self, effects: BindingEffects) -> ApiResult<()> {
1475
- let BindingEffects {
1476
- outgoing,
1477
- unloaded,
1478
- loaded,
1479
- watch,
1480
- ..
1481
- } = effects;
1482
-
1483
- let deleted = outgoing.delete().await;
1484
- if unloaded {
1485
- self.table_unloaded.emit(true);
1486
- }
1487
-
1488
- if let Some(client) = watch {
1489
- self.watch_client(&client).await?;
1490
- }
1491
-
1492
- if loaded {
1493
- self.table_loaded.emit(());
1494
- }
1495
-
1496
- deleted
1497
- }
1498
-
1499
- /// Bind the engine `View` for a validated snapshot: SKIP
1500
- /// ([`BindDisposition::Unchanged`]) when the bound view was built from
1501
- /// an equal effective config, REUSE ([`BindDisposition::Adopted`],
1502
- /// in-place snapshot adoption) when engine-equivalent modulo
1503
- /// `None`-column placeholders, else REBUILD
1504
- /// ([`BindDisposition::Rebuilt`]) from the snapshot. The decision
1505
- /// compares two immutable values owned by this run — there are no
1506
- /// consumable flags for a concurrent run to steal — and the returned
1507
- /// disposition is the ONLY source of `plugin.draw` eligibility (its
1508
- /// `Rebuilt` arm mints the [`FreshView`] witness).
1509
- pub async fn bind_view(
1510
- &self,
1511
- _guard: &RenderGuard,
1512
- validated: ValidatedSnapshot,
1513
- ) -> ApiResult<BindDisposition> {
1514
- // Whichever way a bound `View` was reconciled without construction,
1515
- // classify it `Unchanged` (repaint-eligible, never full-draw); a
1516
- // session with nothing bound is `Deferred`.
1517
- fn unchanged_or_deferred(session: &Session) -> BindDisposition {
1518
- match session.get_view() {
1519
- Some(view) => BindDisposition::Unchanged(view),
1520
- None => BindDisposition::Deferred,
1521
- }
1522
- }
1523
-
1524
- let ValidatedSnapshot {
1525
- snap: ConfigSnapshot { config, effective },
1526
- } = validated;
1527
- if self.borrow().is_paused {
1528
- // A paused bind still RECONCILES the committed config (no `View`
1529
- // is constructed — `view_created` stays silent). Without this
1530
- // emit, a commit landing while auto-paused (e.g. `load()` on a
1531
- // disconnected element, once the IntersectionObserver's initial
1532
- // not-intersecting entry wins the race to this check) never
1533
- // announces its `config-update`: the dispatcher only ever runs
1534
- // from `commit_reconciled`, so the event — which `flush()` joins
1535
- // via the tracked-dispatch counter — would be deferred to the
1536
- // unpause render. The unpause render's own dispatch is deduped
1537
- // (`last_dispatched_config`), so this emit cannot double-fire.
1538
- self.commit_reconciled.emit(());
1539
- return Ok(unchanged_or_deferred(self));
1540
- }
1541
-
1542
- {
1543
- let bound = self.borrow().view_sub.as_ref().map(|x| x.build_config());
1544
- if let Some(bound) = bound {
1545
- if *bound == *effective {
1546
- // SKIP: the bound `View` already satisfies the commit.
1547
- self.commit_reconciled.emit(());
1548
- return Ok(unchanged_or_deferred(self));
1549
- } else if bound.is_equivalent(&effective) {
1550
- if let Some(sub) = self.borrow_mut().view_sub.as_mut() {
1551
- sub.set_configs(config.clone(), effective.clone());
1552
- }
1553
-
1554
- // REUSE: snapshot adoption, no `View` constructed.
1555
- self.commit_reconciled.emit(());
1556
- return match self.get_view() {
1557
- Some(view) => Ok(BindDisposition::Adopted(view)),
1558
- None => Ok(BindDisposition::Deferred),
1559
- };
1560
- }
1561
- }
1562
- }
1563
-
1564
- let table = self
1565
- .borrow()
1566
- .table()
1567
- .cloned()
1568
- .ok_or("`restore()` called before `load()`")?;
1569
-
1570
- let view_config = self.with_default_aggregates(&effective);
1571
- let view = table.view(Some(view_config.into())).await?;
1572
- let on_stats = Callback::from({
1573
- let this = self.clone();
1574
- move |stats| this.update_stats(stats)
1575
- });
1576
-
1577
- let sub = {
1578
- let on_update = self
1579
- .metadata()
1580
- .get_features()
1581
- .unwrap()
1582
- .on_update
1583
- .then(|| self.table_updated.callback());
1584
-
1585
- ViewSubscription::new(view, config, effective, on_stats, on_update).await?
1586
- };
1587
-
1588
- let old = self.borrow_mut().view_sub.take();
1589
- ApiFuture::spawn(old.delete());
1590
- self.borrow_mut().view_sub = Some(sub);
1591
- self.view_created.emit(());
1592
- self.commit_reconciled.emit(());
1593
- match self.get_view() {
1594
- Some(view) => Ok(BindDisposition::Rebuilt(FreshView::assert_fresh(view))),
1595
- None => Ok(BindDisposition::Deferred),
1596
- }
1597
- }
1598
-
1599
- /// The engine config for a `View` built from `effective`, per-column
1600
- /// default aggregates filled in as a courtesy to the virtual server API.
1601
- fn with_default_aggregates(&self, effective: &ViewConfig) -> ViewConfig {
1602
- Self::with_default_aggregates_of(&self.metadata(), effective)
1603
- }
1604
-
1605
- fn with_default_aggregates_of(
1606
- metadata: &SessionMetadata,
1607
- effective: &ViewConfig,
1608
- ) -> ViewConfig {
1609
- let mut view_config = effective.clone();
1610
- for col in view_config
1611
- .columns
1612
- .iter()
1613
- .flatten()
1614
- .chain(view_config.sort.iter().map(|x| &x.0))
1615
- {
1616
- if !view_config.aggregates.contains_key(col.as_str()) {
1617
- let agg = metadata
1618
- .get_column_aggregates(col.as_str())
1619
- .and_then(|mut aggs| aggs.next())
1620
- .into_apierror();
1621
-
1622
- match agg {
1623
- Err(_) => {
1624
- tracing::debug!("No default aggregate for column '{}' found, skipping", col)
1625
- },
1626
- Ok(agg) => _ = view_config.aggregates.insert(col.to_string(), agg),
1627
- };
1628
- }
1629
- }
1630
-
1631
- view_config
1632
- }
1633
-
1634
- /// Build a caller-owned `View` from the effective config outside the
1635
- /// render pipeline, with no subscription and no interaction with pause.
1636
- pub async fn create_detached_view(&self) -> ApiResult<View> {
1637
- let table = self.borrow().table().cloned().ok_or("No `Table` set")?;
1638
- let view_config = self.with_default_aggregates(&self.effective_view_config());
1639
- Ok(table.view(Some(view_config.into())).await?)
1640
- }
1641
-
1642
- /// Reset the config a failed draw could not render, as one queued op.
1643
- pub async fn reset_failed_config(&self) -> ApiResult<()> {
1644
- let session = self.clone();
1645
- self.submit(OpKind::Restore { update: None }, move |_ctx| {
1646
- Box::pin(async move {
1647
- session
1648
- .reset(ResetOptions {
1649
- config: true,
1650
- expressions: true,
1651
- ..ResetOptions::default()
1652
- })
1653
- .await?;
1654
-
1655
- Ok(None)
1656
- })
1657
- })
1658
- .settle()
1659
- .await
1660
- }
1661
-
1662
- fn update_stats(&self, stats: ViewStats) {
1663
- self.borrow_mut().stats = Some(stats);
1664
- if let Some(cb) = self.on_stats_changed.borrow().as_ref() {
1665
- cb.emit(());
1666
- }
1667
-
1668
- self.stats_changed.emit(());
1669
- }
1670
-
1671
- fn columns_of(metadata: &SessionMetadata) -> Vec<String> {
1672
- metadata
1673
- .get_table_columns()
1674
- .into_iter()
1675
- .flatten()
1676
- .cloned()
1677
- .collect()
1678
- }
1679
-
1680
- /// Snapshot the current session state as a [`SessionProps`] value suitable
1681
- /// for passing as a Yew prop. Called by the root component whenever a
1682
- /// session-related PubSub event fires.
1683
- pub fn to_props(&self) -> SessionProps {
1684
- let column_stats = PtrEqRc::new(self.column_stats.borrow().clone());
1685
- let projected = self.projected();
1686
- let title = self.get_title();
1687
- let data = self.borrow();
1688
-
1689
- // Reuse memoized snapshots when the underlying value hasn't
1690
- // changed. PtrEq identity must be stable across `to_props()`
1691
- // calls triggered by *unrelated* pubsubs (e.g. our own
1692
- // `column_stats_changed`), or downstream effects keyed on
1693
- // these `PtrEqRc`s will spuriously refire.
1694
- let config = {
1695
- let mut cached = self.cached_config.borrow_mut();
1696
- if !matches!(&*cached, Some(c) if **c == *projected) {
1697
- *cached = Some(PtrEqRc::new((*projected).clone()));
1698
- }
1699
- cached.clone().unwrap()
1700
- };
1701
- let metadata = {
1702
- let mut cached = self.cached_metadata.borrow_mut();
1703
- if !matches!(&*cached, Some(m) if **m == **data.metadata()) {
1704
- *cached = Some(PtrEqRc::new((**data.metadata()).clone()));
1705
- }
1706
- cached.clone().unwrap()
1707
- };
1708
-
1709
- SessionProps {
1710
- config,
1711
- has_table_cells: data
1712
- .stats
1713
- .as_ref()
1714
- .is_some_and(|s| s.num_table_cells.is_some()),
1715
- has_table: if data.table().is_some() {
1716
- Some(TableLoadState::Loaded)
1717
- } else if self.0.queue.has_load() {
1718
- Some(TableLoadState::Loading)
1719
- } else if data.pending_table().is_some() {
1720
- Some(TableLoadState::Pending)
1721
- } else {
1722
- None
1723
- },
1724
- error: data.error().cloned(),
1725
- title,
1726
- metadata,
1727
- column_stats,
1728
- }
1729
- }
1730
- }
1731
-
1732
- /// A view-config change that has passed every check — names, normalization and
1733
- /// the server's `describe` — and only awaits [`Session::commit_view`].
1734
- pub(crate) struct PreparedView {
1735
- binding: PreparedBinding,
1736
-
1737
- /// A new overlay to commit, when the op broadcasts one.
1738
- overlay: Option<Rc<Vec<OverlayClause>>>,
1739
- config: Rc<ViewConfig>,
1740
- effective: Rc<ViewConfig>,
1741
- description: Option<Rc<Description>>,
1742
- changed: bool,
1743
-
1744
- /// `false` for a projected UI edit, whose SUBMIT already announced it.
1745
- announce: bool,
1746
- }
1747
-
1748
- /// The plugin whose advice fills in what a restore's view config leaves unsaid
1749
- /// — computed against the table and config the restore LANDS on.
1750
- pub(crate) enum ViewDefaults<'a> {
1751
- /// The restore swaps to this plugin: default its columns and rollup mode.
1752
- Swap(&'a PluginStaticConfig),
1753
-
1754
- /// The restore stays on this plugin: re-enforce its rollup mode only.
1755
- Rollup(&'a PluginStaticConfig),
1756
-
1757
- /// The update is complete as given (a UI edit, whose control applied the
1758
- /// plugin's advice when it made it).
1759
- AsGiven,
1760
- }
1761
-
1762
- /// What a restore does to the panel's table binding — decided by its caller
1763
- /// from the restore's `table` and the panel it lands on, with the incoming
1764
- /// table already probed.
1765
- pub(crate) enum BindPlan {
1766
- /// The binding stands: bound, awaiting or unbound, as it is.
1767
- Keep,
1768
-
1769
- /// Bind `table`.
1770
- Bind {
1771
- client: Client,
1772
- table: Box<perspective_client::Table>,
1773
- reset: bool,
1774
- },
1775
-
1776
- /// Await a host for `name`.
1777
- Pend {
1778
- client: Client,
1779
- name: String,
1780
- reset: bool,
1781
- },
1782
- }
1783
-
1784
- enum PreparedBinding {
1785
- Keep,
1786
- Bind {
1787
- client: Client,
1788
- table: Box<perspective_client::Table>,
1789
- metadata: Rc<SessionMetadata>,
1790
- },
1791
- Pend {
1792
- client: Client,
1793
- name: String,
1794
- },
1795
- }
1796
-
1797
- /// What [`Session::commit_view`] leaves for [`Session::finish_binding`].
1798
- #[must_use]
1799
- pub(crate) struct BindingEffects {
1800
- rebinds: bool,
1801
- outgoing: Option<ViewSubscription>,
1802
- unloaded: bool,
1803
- loaded: bool,
1804
- watch: Option<Client>,
1805
- }
1806
-
1807
- impl BindingEffects {
1808
- /// Whether the commit replaced the panel's table binding.
1809
- pub fn rebound(&self) -> bool {
1810
- self.rebinds
1811
- }
1812
-
1813
- /// Discard the effects of a commit that kept its binding (there are none).
1814
- pub fn forget(self) {}
1815
- }
1816
-
1817
- impl PreparedView {
1818
- /// Mark this as a projected UI edit: the UI has shown it since it was
1819
- /// submitted, so committing it announces nothing.
1820
- pub fn projected(mut self) -> Self {
1821
- self.announce = false;
1822
- self
1823
- }
1824
-
1825
- pub fn config(&self) -> &ViewConfig {
1826
- &self.config
1827
- }
1828
-
1829
- /// The type each column will have in the `View` this config builds.
1830
- pub fn view_schema(&self) -> Option<&HashMap<String, perspective_client::proto::ColumnType>> {
1831
- self.description.as_ref().map(|x| &x.view_schema)
1832
- }
1833
- }
1834
-
1835
- /// One pipeline run's frozen input (invariant I2): the persisted
1836
- /// [`ViewConfig`] and its EFFECTIVE companion (global-filter overlay
1837
- /// appended), captured at the same synchronous instant inside the draw
1838
- /// lock by [`Session::snapshot`].
1839
- #[derive(Clone)]
1840
- pub struct ConfigSnapshot {
1841
- pub config: Rc<ViewConfig>,
1842
- pub effective: Rc<ViewConfig>,
1843
- }
1844
-
1845
- /// Type-state token: proof this snapshot was validated by
1846
- /// [`Session::validate_snapshot`], carrying the server's [`Description`] of it.
1847
- pub struct ValidatedSnapshot {
1848
- snap: ConfigSnapshot,
1849
- }
1850
-
1851
- /// Type-state witness that a `View` is NEW for the plugin about to render
1852
- /// it.
1853
- pub struct FreshView(View);
1854
-
1855
- impl FreshView {
1856
- /// See the type docs — two minting sites only.
1857
- pub(crate) fn assert_fresh(view: View) -> Self {
1858
- Self(view)
1859
- }
1860
-
1861
- pub fn view(&self) -> &View {
1862
- &self.0
1863
- }
1864
- }
1865
-
1866
- /// How [`Session::bind_view`] reconciled a validated snapshot against the
1867
- /// bound render state. Only the `Rebuilt` arm carries a [`FreshView`] — the
1868
- /// witness `Renderer::draw_fresh` (the sole `plugin.draw` dispatch)
1869
- /// requires — so which runs may FULL-draw is decided here, by type, not by
1870
- /// call-site convention.
1871
- pub enum BindDisposition {
1872
- /// A new engine `View` was constructed and bound (`view_created`).
1873
- Rebuilt(FreshView),
1874
-
1875
- /// REUSE: an engine-equivalent snapshot (placeholder-only diff) was
1876
- /// adopted in place — the plugin-visible config changed, the `View`
1877
- /// did not. Repaint via `plugin.update`.
1878
- Adopted(View),
1879
-
1880
- /// SKIP (or paused-with-a-bound-`View`): the bound `View` already
1881
- /// satisfies the commit. Repaint via `plugin.update` if the caller has
1882
- /// a reason to repaint (today: always, preserving the no-op-commit
1883
- /// repaint idioms — indicator click, toggle-debug, warning-dismiss).
1884
- Unchanged(View),
1885
-
1886
- /// Nothing to render: paused or deferred-draw (no table yet) with no
1887
- /// bound `View`.
1888
- Deferred,
1889
- }
1890
-
1891
- impl BindDisposition {
1892
- /// The bound `View`, whichever way it was reconciled (`None` for
1893
- /// [`Self::Deferred`]) — for building the run's `RenderContext`.
1894
- pub fn view(&self) -> Option<&View> {
1895
- match self {
1896
- Self::Rebuilt(fresh) => Some(fresh.view()),
1897
- Self::Adopted(view) | Self::Unchanged(view) => Some(view),
1898
- Self::Deferred => None,
1899
- }
1900
- }
1901
- }