@perspective-dev/viewer 4.4.1 → 4.5.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 (225) hide show
  1. package/dist/cdn/perspective-viewer.js +1 -2
  2. package/dist/cdn/perspective-viewer.js.map +4 -4
  3. package/dist/css/botanical.css +1 -1
  4. package/dist/css/dracula.css +1 -1
  5. package/dist/css/gruvbox-dark.css +1 -1
  6. package/dist/css/gruvbox.css +1 -1
  7. package/dist/css/icons.css +1 -1
  8. package/dist/css/intl/de.css +1 -1
  9. package/dist/css/intl/es.css +1 -1
  10. package/dist/css/intl/fr.css +1 -1
  11. package/dist/css/intl/ja.css +1 -1
  12. package/dist/css/intl/pt.css +1 -1
  13. package/dist/css/intl/zh.css +1 -1
  14. package/dist/css/intl.css +1 -1
  15. package/dist/css/monokai.css +1 -1
  16. package/dist/css/phosphor.css +1 -1
  17. package/dist/css/pro-dark.css +1 -1
  18. package/dist/css/pro.css +1 -1
  19. package/dist/css/solarized-dark.css +1 -1
  20. package/dist/css/solarized.css +1 -1
  21. package/dist/css/themes.css +1 -1
  22. package/dist/css/vaporwave.css +1 -1
  23. package/dist/esm/bootstrap.d.ts +2 -1
  24. package/dist/esm/column-format.d.ts +51 -0
  25. package/dist/esm/extensions.d.ts +2 -0
  26. package/dist/esm/perspective-viewer.d.ts +3 -1
  27. package/dist/esm/perspective-viewer.inline.js +1 -2
  28. package/dist/esm/perspective-viewer.inline.js.map +4 -4
  29. package/dist/esm/perspective-viewer.js +1 -2
  30. package/dist/esm/perspective-viewer.js.map +4 -4
  31. package/dist/esm/perspective-viewer.worker.d.ts +2 -0
  32. package/dist/esm/plugin.d.ts +16 -72
  33. package/dist/esm/ts-rs/ColumnSelectMode.d.ts +1 -0
  34. package/dist/esm/ts-rs/PluginStaticConfig.d.ts +77 -0
  35. package/dist/esm/ts-rs/ViewerConfig.d.ts +6 -3
  36. package/dist/esm/ts-rs/ViewerConfigUpdate.d.ts +7 -4
  37. package/dist/wasm/perspective-viewer.d.ts +77 -18
  38. package/dist/wasm/perspective-viewer.js +293 -144
  39. package/dist/wasm/perspective-viewer.wasm +0 -0
  40. package/dist/wasm/perspective-viewer.wasm.d.ts +20 -15
  41. package/package.json +24 -2
  42. package/src/css/column-selector.css +3 -2
  43. package/src/css/column-settings-panel.css +35 -6
  44. package/src/css/column-style.css +27 -2
  45. package/src/css/containers/scroll-panel.css +2 -1
  46. package/src/css/containers/tabs.css +8 -52
  47. package/src/css/dom/checkbox.css +0 -4
  48. package/src/css/form/code-editor.css +1 -0
  49. package/src/css/form/debug.css +3 -10
  50. package/src/css/plugin-selector.css +33 -0
  51. package/src/css/plugin-settings-panel.css +99 -0
  52. package/src/css/viewer.css +65 -3
  53. package/src/rust/components/column_dropdown.rs +3 -1
  54. package/src/rust/components/column_selector/active_column.rs +13 -19
  55. package/src/rust/components/column_selector/config_selector.rs +20 -20
  56. package/src/rust/components/column_selector/filter_column.rs +14 -14
  57. package/src/rust/components/column_selector/inactive_column.rs +9 -15
  58. package/src/rust/components/column_selector/pivot_column.rs +7 -7
  59. package/src/rust/components/column_selector/sort_column.rs +7 -7
  60. package/src/rust/components/column_selector.rs +55 -37
  61. package/src/rust/components/column_settings_sidebar/style_tab/agg_depth_selector.rs +15 -7
  62. package/src/rust/components/column_settings_sidebar/style_tab/primitive_field.rs +394 -0
  63. package/src/rust/components/column_settings_sidebar/style_tab/symbol.rs +15 -6
  64. package/src/rust/components/column_settings_sidebar/style_tab.rs +267 -136
  65. package/src/rust/components/column_settings_sidebar.rs +43 -49
  66. package/src/rust/components/containers/dragdrop_list.rs +5 -5
  67. package/src/rust/components/containers/mod.rs +0 -1
  68. package/src/rust/components/containers/scroll_panel.rs +21 -7
  69. package/src/rust/components/containers/sidebar.rs +8 -6
  70. package/src/rust/components/containers/split_panel.rs +3 -3
  71. package/src/rust/components/containers/tab_list.rs +3 -9
  72. package/src/rust/components/copy_dropdown.rs +2 -3
  73. package/src/rust/components/datetime_column_style.rs +19 -81
  74. package/src/rust/components/editable_header.rs +2 -3
  75. package/src/rust/components/export_dropdown.rs +2 -3
  76. package/src/rust/components/expression_editor.rs +29 -17
  77. package/src/rust/components/filter_dropdown.rs +2 -1
  78. package/src/rust/components/form/color_range_selector.rs +14 -7
  79. package/src/rust/components/form/debug.rs +47 -37
  80. package/src/rust/components/main_panel.rs +24 -65
  81. package/src/rust/components/mod.rs +2 -1
  82. package/src/rust/components/number_series_style.rs +161 -0
  83. package/src/rust/components/plugin_tab.rs +221 -0
  84. package/src/rust/components/settings_panel.rs +181 -59
  85. package/src/rust/components/status_bar.rs +140 -173
  86. package/src/rust/components/status_indicator.rs +15 -22
  87. package/src/rust/components/string_column_style.rs +20 -82
  88. package/src/rust/components/style_controls/number_string_format.rs +14 -30
  89. package/src/rust/components/viewer.rs +92 -131
  90. package/src/rust/config/column_config_schema.rs +195 -0
  91. package/src/rust/config/columns_config.rs +4 -97
  92. package/src/rust/config/datetime_column_style.rs +0 -5
  93. package/src/rust/config/mod.rs +8 -2
  94. package/src/rust/config/number_series_style.rs +79 -0
  95. package/src/rust/config/plugin_static_config.rs +144 -0
  96. package/src/rust/config/string_column_style.rs +0 -5
  97. package/src/rust/config/viewer_config.rs +5 -6
  98. package/src/rust/custom_elements/copy_dropdown.rs +30 -18
  99. package/src/rust/custom_elements/debug_plugin.rs +1 -3
  100. package/src/rust/custom_elements/export_dropdown.rs +26 -18
  101. package/src/rust/custom_elements/viewer.rs +62 -73
  102. package/src/rust/custom_events.rs +181 -224
  103. package/src/rust/js/plugin.rs +45 -117
  104. package/src/rust/lib.rs +34 -5
  105. package/src/rust/presentation/drag_helpers.rs +206 -0
  106. package/src/rust/presentation/props.rs +8 -0
  107. package/src/rust/presentation.rs +256 -41
  108. package/src/rust/{tasks → queries}/column_locator.rs +17 -73
  109. package/src/rust/queries/column_values.rs +59 -0
  110. package/src/rust/{tasks → queries}/columns_iter_set.rs +11 -18
  111. package/src/rust/queries/exports.rs +96 -0
  112. package/src/rust/queries/fetch_column_stats.rs +94 -0
  113. package/src/rust/queries/get_viewer_config.rs +54 -0
  114. package/src/rust/queries/mod.rs +44 -0
  115. package/src/rust/queries/plugin_column_styles.rs +101 -0
  116. package/src/rust/{engines.rs → queries/validate_expression.rs} +26 -15
  117. package/src/rust/renderer/activate.rs +1 -0
  118. package/src/rust/renderer/limits.rs +9 -4
  119. package/src/rust/renderer/plugin_store.rs +12 -0
  120. package/src/rust/renderer/props.rs +28 -3
  121. package/src/rust/renderer/registry.rs +40 -15
  122. package/src/rust/renderer.rs +640 -51
  123. package/src/rust/session/column_defaults_update.rs +20 -28
  124. package/src/rust/session/drag_drop_update.rs +10 -10
  125. package/src/rust/session/metadata.rs +31 -16
  126. package/src/rust/session/props.rs +15 -6
  127. package/src/rust/session/view_subscription.rs +10 -0
  128. package/src/rust/session.rs +109 -147
  129. package/src/rust/tasks/copy_export.rs +178 -158
  130. package/src/rust/tasks/{structural.rs → dismiss_render_warning.rs} +20 -40
  131. package/src/rust/tasks/edit_expression.rs +68 -88
  132. package/src/rust/tasks/eject.rs +25 -22
  133. package/src/rust/tasks/intersection_observer.rs +8 -21
  134. package/src/rust/tasks/mod.rs +19 -21
  135. package/src/rust/tasks/reset_all.rs +78 -0
  136. package/src/rust/tasks/resize_observer.rs +11 -33
  137. package/src/rust/tasks/restore_and_render.rs +117 -90
  138. package/src/rust/tasks/{get_viewer_config.rs → send_column_config.rs} +38 -35
  139. package/src/rust/tasks/send_plugin_config.rs +32 -33
  140. package/src/rust/tasks/update_and_render.rs +66 -47
  141. package/src/rust/{components/containers/trap_door_panel.rs → tasks/update_theme.rs} +34 -33
  142. package/src/rust/tasks/validate_expression.rs +61 -0
  143. package/src/rust/utils/browser/selection.rs +4 -4
  144. package/src/rust/utils/mod.rs +0 -63
  145. package/src/svg/mega-menu-icons-density.svg +23 -0
  146. package/src/svg/mega-menu-icons-map-density.svg +24 -0
  147. package/src/svg/mega-menu-icons-map-line.svg +19 -0
  148. package/src/themes/botanical.css +27 -53
  149. package/src/themes/defaults.css +24 -36
  150. package/src/themes/dracula.css +36 -54
  151. package/src/themes/gruvbox-dark.css +39 -59
  152. package/src/themes/gruvbox.css +16 -28
  153. package/src/themes/icons.css +3 -0
  154. package/src/themes/intl/de.css +42 -6
  155. package/src/themes/intl/es.css +42 -6
  156. package/src/themes/intl/fr.css +42 -6
  157. package/src/themes/intl/ja.css +42 -6
  158. package/src/themes/intl/pt.css +42 -6
  159. package/src/themes/intl/zh.css +42 -6
  160. package/src/themes/intl.css +37 -4
  161. package/src/themes/monokai.css +45 -61
  162. package/src/themes/phosphor.css +20 -29
  163. package/src/themes/pro-dark.css +25 -34
  164. package/src/themes/solarized-dark.css +21 -36
  165. package/src/themes/solarized.css +13 -23
  166. package/src/themes/vaporwave.css +40 -74
  167. package/src/ts/bootstrap.ts +14 -3
  168. package/src/ts/column-format.ts +162 -0
  169. package/src/ts/extensions.ts +4 -0
  170. package/src/ts/perspective-viewer.ts +9 -1
  171. package/src/{rust/components/column_settings_sidebar/style_tab/stub.rs → ts/perspective-viewer.worker.ts} +2 -22
  172. package/src/ts/plugin.ts +25 -101
  173. package/src/ts/ts-rs/{FormatUnit.ts → ColumnSelectMode.ts} +1 -1
  174. package/src/ts/ts-rs/PluginStaticConfig.ts +78 -0
  175. package/src/ts/ts-rs/ViewerConfig.ts +1 -2
  176. package/src/ts/ts-rs/ViewerConfigUpdate.ts +2 -3
  177. package/dist/esm/ts-rs/ColumnConfigValues.d.ts +0 -31
  178. package/dist/esm/ts-rs/CustomDatetimeFormat.d.ts +0 -1
  179. package/dist/esm/ts-rs/CustomDatetimeStyleConfig.d.ts +0 -15
  180. package/dist/esm/ts-rs/CustomNumberFormatConfig.d.ts +0 -18
  181. package/dist/esm/ts-rs/DatetimeColorMode.d.ts +0 -1
  182. package/dist/esm/ts-rs/DatetimeFormatType.d.ts +0 -6
  183. package/dist/esm/ts-rs/FormatMode.d.ts +0 -1
  184. package/dist/esm/ts-rs/FormatUnit.d.ts +0 -1
  185. package/dist/esm/ts-rs/NumberBackgroundMode.d.ts +0 -1
  186. package/dist/esm/ts-rs/NumberForegroundMode.d.ts +0 -1
  187. package/dist/esm/ts-rs/PluginConfig.d.ts +0 -2
  188. package/dist/esm/ts-rs/RoundingMode.d.ts +0 -1
  189. package/dist/esm/ts-rs/RoundingPriority.d.ts +0 -1
  190. package/dist/esm/ts-rs/SignDisplay.d.ts +0 -1
  191. package/dist/esm/ts-rs/SimpleDatetimeFormat.d.ts +0 -1
  192. package/dist/esm/ts-rs/SimpleDatetimeStyleConfig.d.ts +0 -6
  193. package/dist/esm/ts-rs/StringColorMode.d.ts +0 -1
  194. package/dist/esm/ts-rs/TrailingZeroDisplay.d.ts +0 -1
  195. package/dist/esm/ts-rs/UseGrouping.d.ts +0 -1
  196. package/src/rust/components/number_column_style.rs +0 -491
  197. package/src/rust/config/number_column_style.rs +0 -136
  198. package/src/rust/dragdrop.rs +0 -481
  199. package/src/rust/tasks/plugin_column_styles.rs +0 -98
  200. package/src/ts/ts-rs/ColumnConfigValues.ts +0 -14
  201. package/src/ts/ts-rs/CustomDatetimeFormat.ts +0 -3
  202. package/src/ts/ts-rs/CustomDatetimeStyleConfig.ts +0 -5
  203. package/src/ts/ts-rs/CustomNumberFormatConfig.ts +0 -8
  204. package/src/ts/ts-rs/DatetimeColorMode.ts +0 -3
  205. package/src/ts/ts-rs/DatetimeFormatType.ts +0 -8
  206. package/src/ts/ts-rs/FormatMode.ts +0 -3
  207. package/src/ts/ts-rs/NumberBackgroundMode.ts +0 -3
  208. package/src/ts/ts-rs/NumberForegroundMode.ts +0 -3
  209. package/src/ts/ts-rs/PluginConfig.ts +0 -4
  210. package/src/ts/ts-rs/RoundingMode.ts +0 -3
  211. package/src/ts/ts-rs/RoundingPriority.ts +0 -3
  212. package/src/ts/ts-rs/SignDisplay.ts +0 -3
  213. package/src/ts/ts-rs/SimpleDatetimeFormat.ts +0 -3
  214. package/src/ts/ts-rs/SimpleDatetimeStyleConfig.ts +0 -4
  215. package/src/ts/ts-rs/StringColorMode.ts +0 -3
  216. package/src/ts/ts-rs/TrailingZeroDisplay.ts +0 -3
  217. package/src/ts/ts-rs/UseGrouping.ts +0 -3
  218. /package/dist/wasm/snippets/{perspective-viewer-d924246f0b4a3dce → perspective-viewer-39ab7da3ca157861}/inline0.js +0 -0
  219. /package/dist/wasm/snippets/{perspective-viewer-d924246f0b4a3dce → perspective-viewer-39ab7da3ca157861}/inline1.js +0 -0
  220. /package/dist/wasm/snippets/{perspective-viewer-d924246f0b4a3dce → perspective-viewer-39ab7da3ca157861}/inline2.js +0 -0
  221. /package/dist/wasm/snippets/{perspective-viewer-d924246f0b4a3dce → perspective-viewer-39ab7da3ca157861}/inline3.js +0 -0
  222. /package/dist/wasm/snippets/{perspective-viewer-d924246f0b4a3dce → perspective-viewer-39ab7da3ca157861}/inline4.js +0 -0
  223. /package/src/rust/{tasks → config}/export_method.rs +0 -0
  224. /package/src/rust/{tasks → queries}/export_app.rs +0 -0
  225. /package/src/rust/{tasks → queries}/is_invalid_drop.rs +0 -0
@@ -16,27 +16,28 @@ use itertools::Itertools;
16
16
  use perspective_client::config::*;
17
17
 
18
18
  use super::metadata::*;
19
- use crate::js::plugin::*;
19
+ use crate::config::PluginStaticConfig;
20
20
 
21
21
  #[extend::ext]
22
22
  pub impl ViewConfigUpdate {
23
23
  /// Appends additional columns to the `columns` field of this
24
24
  /// `ViewConfigUpdate` by picking appropriate new columns from the
25
- /// `SessionMetadata`, give the necessary column requirements of the plugin
26
- /// provided by a `ViewConfigRequirements`. For example, an "X/Y Scatter"
27
- /// chart needs a minimum of 2 numeric columns to be drawable.
25
+ /// `SessionMetadata`, given the necessary column requirements of the
26
+ /// plugin provided by a `PluginStaticConfig`. For example, an "X/Y
27
+ /// Scatter" chart needs a minimum of 2 numeric columns to be
28
+ /// drawable.
28
29
  fn set_update_column_defaults(
29
30
  &mut self,
30
31
  metadata: &SessionMetadata,
31
32
  columns: &[Option<String>],
32
- requirements: &ViewConfigRequirements,
33
+ config_static: &PluginStaticConfig,
33
34
  ) {
34
35
  let rollup_features = metadata
35
36
  .get_features()
36
37
  .map(|x| x.get_group_rollup_modes())
37
38
  .unwrap_or_default();
38
39
 
39
- let group_rollups = requirements.get_group_rollups(&rollup_features);
40
+ let group_rollups = config_static.get_group_rollups(&rollup_features);
40
41
  if !group_rollups.contains(
41
42
  self.group_rollup_mode
42
43
  .as_ref()
@@ -49,15 +50,8 @@ pub impl ViewConfigUpdate {
49
50
  );
50
51
  }
51
52
 
52
- if let (
53
- None,
54
- ViewConfigRequirements {
55
- min: Some(min_cols),
56
- names,
57
- ..
58
- },
59
- ) = (&self.columns, &requirements)
60
- {
53
+ if let (None, Some(min_cols)) = (&self.columns, config_static.min_config_columns) {
54
+ let names_len = config_static.config_column_names.len();
61
55
  // first try to take 2 numeric columns from existing config
62
56
  let numeric_config_columns = columns
63
57
  .iter()
@@ -68,16 +62,16 @@ pub impl ViewConfigUpdate {
68
62
  Some(ColumnType::Float | ColumnType::Integer)
69
63
  )
70
64
  })
71
- .take(*min_cols)
65
+ .take(min_cols)
72
66
  .cloned()
73
67
  .map(Some)
74
68
  .collect::<Vec<_>>();
75
69
 
76
- if numeric_config_columns.len() == *min_cols {
70
+ if numeric_config_columns.len() == min_cols {
77
71
  self.columns = Some(
78
72
  numeric_config_columns
79
73
  .into_iter()
80
- .pad_using(names.as_ref().map_or(0, |x| x.len()), |_| None)
74
+ .pad_using(names_len, |_| None)
81
75
  .collect::<Vec<_>>(),
82
76
  );
83
77
  } else {
@@ -104,14 +98,14 @@ pub impl ViewConfigUpdate {
104
98
  .cloned()
105
99
  .map(Some),
106
100
  )
107
- .take(*min_cols)
101
+ .take(min_cols)
108
102
  .collect::<Vec<_>>();
109
103
 
110
- if config_columns.len() == *min_cols {
104
+ if config_columns.len() == min_cols {
111
105
  self.columns = Some(
112
106
  config_columns
113
107
  .into_iter()
114
- .pad_using(names.as_ref().map_or(0, |x| x.len()), |_| None)
108
+ .pad_using(names_len, |_| None)
115
109
  .collect::<Vec<_>>(),
116
110
  );
117
111
  } else {
@@ -120,7 +114,7 @@ pub impl ViewConfigUpdate {
120
114
  .get_table_columns()
121
115
  .into_iter()
122
116
  .flatten()
123
- .take(*min_cols)
117
+ .take(min_cols)
124
118
  .cloned()
125
119
  .map(Some)
126
120
  .collect::<Vec<_>>(),
@@ -132,16 +126,14 @@ pub impl ViewConfigUpdate {
132
126
  let initial_len = self.columns.as_ref().map(|x| x.len()).unwrap_or_default();
133
127
  if let Some(last_filled) = columns.iter().rposition(|x| x.is_some()) {
134
128
  columns.truncate(last_filled + 1);
135
- if let ViewConfigRequirements {
136
- names: Some(names), ..
137
- } = &requirements
138
- {
129
+ if !config_static.config_column_names.is_empty() {
130
+ let names_len = config_static.config_column_names.len();
139
131
  columns = columns
140
132
  .into_iter()
141
133
  .enumerate()
142
- .filter(|(idx, x)| *idx < names.len() || x.is_some())
134
+ .filter(|(idx, x)| *idx < names_len || x.is_some())
143
135
  .map(|(_, x)| x)
144
- .pad_using(names.len(), |_| None)
136
+ .pad_using(names_len, |_| None)
145
137
  .collect::<Vec<_>>();
146
138
  } else {
147
139
  columns = columns
@@ -12,7 +12,7 @@
12
12
 
13
13
  use perspective_client::config::*;
14
14
 
15
- use crate::js::plugin::ViewConfigRequirements;
15
+ use crate::config::PluginStaticConfig;
16
16
  use crate::utils::{DragEffect, DragTarget};
17
17
 
18
18
  #[allow(clippy::too_many_arguments)]
@@ -27,23 +27,23 @@ pub impl ViewConfig {
27
27
  index: usize,
28
28
  drop: DragTarget,
29
29
  drag: DragEffect,
30
- requirements: &ViewConfigRequirements,
30
+ config_static: &PluginStaticConfig,
31
31
  features: &perspective_client::Features,
32
32
  ) -> ViewConfigUpdate {
33
33
  let mut config = self.clone();
34
34
  let mut update = ViewConfigUpdate::default();
35
- let is_to_swap = requirements.is_swap(index);
35
+ let is_to_swap = config_static.is_swap(index);
36
36
  let from_index = config
37
37
  .columns
38
38
  .iter()
39
39
  .position(|x| x.as_ref() == Some(&column));
40
40
 
41
41
  let is_from_required = from_index
42
- .and_then(|x| requirements.min.map(|z| x < z))
42
+ .and_then(|x| config_static.min_config_columns.map(|z| x < z))
43
43
  .unwrap_or_default();
44
44
 
45
45
  let is_from_swap = from_index
46
- .map(|x| requirements.is_swap(x))
46
+ .map(|x| config_static.is_swap(x))
47
47
  .unwrap_or_default();
48
48
 
49
49
  let is_to_empty = config
@@ -104,11 +104,11 @@ pub impl ViewConfig {
104
104
  if is_to_swap || is_from_required {
105
105
  let column = Some(column);
106
106
  config.columns.extend(std::iter::repeat_n(None, {
107
- let fill_to = requirements
108
- .names
109
- .as_ref()
110
- .map(|x| std::cmp::max(x.len() - 1, index))
111
- .unwrap_or(index);
107
+ let fill_to = if config_static.config_column_names.is_empty() {
108
+ index
109
+ } else {
110
+ std::cmp::max(config_static.config_column_names.len() - 1, index)
111
+ };
112
112
 
113
113
  if fill_to >= (config.columns.len() - 1) {
114
114
  fill_to + 1 - config.columns.len()
@@ -17,6 +17,7 @@ use std::ops::{Deref, DerefMut};
17
17
  use perspective_client::config::*;
18
18
  use perspective_js::apierror;
19
19
 
20
+ use crate::presentation::ColumnLocator;
20
21
  use crate::utils::PtrEqRc;
21
22
  use crate::*;
22
23
 
@@ -140,14 +141,14 @@ impl SessionMetadata {
140
141
  }
141
142
 
142
143
  pub fn get_expression_columns(&self) -> impl Iterator<Item = &'_ String> {
143
- maybe!(Some(
144
+ try {
144
145
  self.as_ref()?
145
146
  .expr_meta
146
147
  .as_ref()?
147
148
  .expressions
148
149
  .expression_schema
149
150
  .keys()
150
- ))
151
+ }
151
152
  .into_iter()
152
153
  .flatten()
153
154
  }
@@ -173,30 +174,28 @@ impl SessionMetadata {
173
174
  /// # Arguments
174
175
  /// - `alias` An alias name for an expression column in this `Session`.
175
176
  pub fn get_edit_by_alias(&self, alias: &str) -> Option<String> {
176
- maybe!(
177
+ try {
177
178
  self.as_ref()?
178
179
  .expr_meta
179
180
  .as_ref()?
180
181
  .edited
181
182
  .get(alias)
182
- .cloned()
183
- )
183
+ .cloned()?
184
+ }
184
185
  }
185
186
 
186
187
  pub fn set_edit_by_alias(&mut self, alias: &str, edit: String) {
187
- drop(maybe!(
188
+ let _: Option<_> = try {
188
189
  self.as_mut()?
189
190
  .expr_meta
190
191
  .as_mut()?
191
192
  .edited
192
193
  .insert(alias.to_owned(), edit)
193
- ))
194
+ };
194
195
  }
195
196
 
196
197
  pub fn clear_edit_by_alias(&mut self, alias: &str) {
197
- drop(maybe!(
198
- self.as_mut()?.expr_meta.as_mut()?.edited.remove(alias)
199
- ))
198
+ let _: Option<_> = try { self.as_mut()?.expr_meta.as_mut()?.edited.remove(alias) };
200
199
  }
201
200
 
202
201
  pub fn get_table_columns(&self) -> Option<&'_ Vec<String>> {
@@ -204,14 +203,14 @@ impl SessionMetadata {
204
203
  }
205
204
 
206
205
  pub fn is_column_expression(&self, name: &str) -> bool {
207
- let is_expr = maybe!(Some(
206
+ let is_expr: Option<bool> = try {
208
207
  self.as_ref()?
209
208
  .expr_meta
210
209
  .as_ref()?
211
210
  .expressions
212
211
  .expression_schema
213
212
  .contains_key(name)
214
- ));
213
+ };
215
214
 
216
215
  is_expr.unwrap_or_default()
217
216
  }
@@ -242,7 +241,7 @@ impl SessionMetadata {
242
241
  /// - `name` The column name (or expresison alias) to retrieve a principal
243
242
  /// type.
244
243
  pub fn get_column_table_type(&self, name: &str) -> Option<ColumnType> {
245
- maybe!({
244
+ try {
246
245
  let meta = self.as_ref()?;
247
246
  meta.table_schema.get(name).cloned().or_else(|| {
248
247
  meta.expr_meta
@@ -251,8 +250,8 @@ impl SessionMetadata {
251
250
  .expression_schema
252
251
  .get(name)
253
252
  .cloned()
254
- })
255
- })
253
+ })?
254
+ }
256
255
  }
257
256
 
258
257
  /// Returns the type of a column name relative to the `View`, including
@@ -265,7 +264,23 @@ impl SessionMetadata {
265
264
  /// - `name` The column name (or expresison alias) to retrieve a `View`
266
265
  /// type.
267
266
  pub fn get_column_view_type(&self, name: &str) -> Option<ColumnType> {
268
- maybe!(self.as_ref()?.view_schema.as_ref()?.get(name)).cloned()
267
+ let r: Option<&ColumnType> = try { self.as_ref()?.view_schema.as_ref()?.get(name)? };
268
+ r.cloned()
269
+ }
270
+
271
+ /// Returns the column name for a locator, generating a default for new
272
+ /// expressions.
273
+ pub fn locator_name_or_default(&self, locator: &ColumnLocator) -> String {
274
+ match locator {
275
+ ColumnLocator::Table(s) | ColumnLocator::Expression(s) => s.clone(),
276
+ ColumnLocator::NewExpression => self.make_new_column_name(None),
277
+ }
278
+ }
279
+
280
+ /// Returns the view type for a locator's column, if available.
281
+ pub fn locator_view_type(&self, locator: &ColumnLocator) -> Option<ColumnType> {
282
+ let name = locator.name().cloned().unwrap_or_default();
283
+ self.get_column_view_type(name.as_str())
269
284
  }
270
285
 
271
286
  pub fn get_column_aggregates<'a>(
@@ -10,14 +10,16 @@
10
10
  // ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11
11
  // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
12
 
13
+ use std::collections::HashMap;
14
+
13
15
  use perspective_client::config::*;
14
16
 
15
- use crate::js::plugin::ViewConfigRequirements;
17
+ use crate::config::PluginStaticConfig;
16
18
  use crate::session::column_defaults_update::ViewConfigUpdateExt;
17
19
  use crate::session::drag_drop_update::ViewConfigExt as DragDropExt;
18
20
  use crate::session::metadata::SessionMetadataRc;
19
21
  use crate::session::replace_expression_update::ViewConfigExt as ReplaceExprExt;
20
- use crate::session::{TableErrorState, ViewStats};
22
+ use crate::session::{ColumnStats, TableErrorState, ViewStats};
21
23
  use crate::utils::*;
22
24
 
23
25
  #[derive(Clone, Debug, PartialEq, Default)]
@@ -55,6 +57,13 @@ pub struct SessionProps {
55
57
  /// expression info, etc. from this snapshot instead of borrowing
56
58
  /// `Session`'s `RefCell` directly.
57
59
  pub metadata: SessionMetadataRc,
60
+
61
+ /// Snapshot of the per-column stats cache (currently `abs_max`
62
+ /// only), populated lazily by the `fetch_column_abs_max` task.
63
+ /// Cleared whenever `view_config` changes; rebuilt on each
64
+ /// `to_props()` call when the root component re-renders in
65
+ /// response to `column_stats_changed`.
66
+ pub column_stats: PtrEqRc<HashMap<String, ColumnStats>>,
58
67
  }
59
68
 
60
69
  impl SessionProps {
@@ -109,7 +118,7 @@ impl SessionProps {
109
118
  index: usize,
110
119
  drop: DragTarget,
111
120
  drag: DragEffect,
112
- requirements: &ViewConfigRequirements,
121
+ config_static: &PluginStaticConfig,
113
122
  ) -> ViewConfigUpdate {
114
123
  let col_type = self
115
124
  .metadata
@@ -122,7 +131,7 @@ impl SessionProps {
122
131
  index,
123
132
  drop,
124
133
  drag,
125
- requirements,
134
+ config_static,
126
135
  self.metadata.get_features().unwrap(),
127
136
  )
128
137
  }
@@ -132,12 +141,12 @@ impl SessionProps {
132
141
  pub fn set_update_column_defaults(
133
142
  &self,
134
143
  config_update: &mut ViewConfigUpdate,
135
- requirements: &ViewConfigRequirements,
144
+ config_static: &PluginStaticConfig,
136
145
  ) {
137
146
  config_update.set_update_column_defaults(
138
147
  &self.metadata,
139
148
  &self.all_columns().into_iter().map(Some).collect::<Vec<_>>(),
140
- requirements,
149
+ config_static,
141
150
  )
142
151
  }
143
152
 
@@ -153,6 +153,16 @@ impl ViewSubscription {
153
153
  &self.data.view
154
154
  }
155
155
 
156
+ /// Snapshot of the [`ViewConfig`] the bound `View` was constructed
157
+ /// from (or its operationally-equivalent successor on the
158
+ /// [`ValidSession::create_view`] fast path). This is the
159
+ /// [`ViewConfig`] consistent with the data the active plugin is
160
+ /// currently rendering — not the live session config, which may
161
+ /// have been mutated synchronously ahead of the next queued draw.
162
+ pub fn get_view_config(&self) -> Rc<ViewConfig> {
163
+ self.data.config.clone()
164
+ }
165
+
156
166
  /// Delete this `View`. Neglecting to call this method before a
157
167
  /// `ViewSubscription` is dropped will result in a log warning, but the
158
168
  /// `View` will not leak.