@perspective-dev/viewer 5.6.0 → 5.6.1

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 (72) hide show
  1. package/dist/cdn/perspective-viewer.js +9 -9
  2. package/dist/cdn/perspective-viewer.js.map +4 -4
  3. package/dist/css/blueprint.css +1 -1
  4. package/dist/css/botanical.css +1 -1
  5. package/dist/css/dracula.css +1 -1
  6. package/dist/css/eggplant.css +1 -1
  7. package/dist/css/gruvbox-dark.css +1 -1
  8. package/dist/css/gruvbox.css +1 -1
  9. package/dist/css/intl/ar.css +1 -1
  10. package/dist/css/intl/de.css +1 -1
  11. package/dist/css/intl/es.css +1 -1
  12. package/dist/css/intl/fr.css +1 -1
  13. package/dist/css/intl/ja.css +1 -1
  14. package/dist/css/intl/pt.css +1 -1
  15. package/dist/css/intl/zh.css +1 -1
  16. package/dist/css/intl.css +1 -1
  17. package/dist/css/ledger.css +1 -1
  18. package/dist/css/monokai.css +1 -1
  19. package/dist/css/nord.css +1 -1
  20. package/dist/css/phosphor.css +1 -1
  21. package/dist/css/pro-dark.css +1 -1
  22. package/dist/css/pro.css +1 -1
  23. package/dist/css/solarized-dark.css +1 -1
  24. package/dist/css/solarized.css +1 -1
  25. package/dist/css/themes.css +1 -1
  26. package/dist/css/vaporwave.css +1 -1
  27. package/dist/css/velvet.css +1 -1
  28. package/dist/docs/perspective-docs.json +1 -1
  29. package/dist/esm/perspective-viewer.js +9 -9
  30. package/dist/esm/perspective-viewer.js.map +4 -4
  31. package/dist/esm/ts-rs/Layout.d.ts +2 -2
  32. package/dist/esm/ts-rs/Orientation.d.ts +2 -1
  33. package/dist/esm/ts-rs/SplitLayout.d.ts +13 -0
  34. package/dist/esm/ts-rs/TabLayout.d.ts +3 -0
  35. package/dist/esm/ts-rs/WorkspaceConfigUpdate.d.ts +2 -1
  36. package/dist/wasm/perspective-viewer.d.ts +16 -16
  37. package/dist/wasm/perspective-viewer.js +111 -111
  38. package/dist/wasm/perspective-viewer.wasm +0 -0
  39. package/dist/wasm/perspective-viewer.wasm.d.ts +16 -16
  40. package/package.json +7 -7
  41. package/src/rust/agent/preamble.md +2 -0
  42. package/src/rust/agent/tools.rs +280 -1
  43. package/src/rust/components/column_selector/config_selector.rs +1 -1
  44. package/src/rust/components/column_selector/filter_column.rs +2 -2
  45. package/src/rust/components/column_settings_sidebar/style_tab/symbol/row_selector.rs +1 -1
  46. package/src/rust/components/empty_row.rs +3 -3
  47. package/src/rust/components/filter_dropdown.rs +100 -101
  48. package/src/rust/components/main_panel/reconcile.rs +65 -28
  49. package/src/rust/components/main_panel/update.rs +8 -47
  50. package/src/rust/components/main_panel.rs +5 -16
  51. package/src/rust/config/workspace_config.rs +2 -1
  52. package/src/rust/js/regular_layout.rs +225 -3
  53. package/src/rust/tasks/sync_update_panels.rs +10 -19
  54. package/src/themes/intl/ar.css +1 -0
  55. package/src/themes/intl/de.css +1 -0
  56. package/src/themes/intl/es.css +1 -0
  57. package/src/themes/intl/fr.css +1 -0
  58. package/src/themes/intl/ja.css +1 -0
  59. package/src/themes/intl/pt.css +1 -0
  60. package/src/themes/intl/zh.css +1 -0
  61. package/src/themes/intl.css +1 -0
  62. package/src/ts/ts-rs/Layout.ts +2 -2
  63. package/src/ts/ts-rs/Orientation.ts +2 -1
  64. package/src/ts/ts-rs/SplitLayout.ts +17 -1
  65. package/src/ts/ts-rs/TabLayout.ts +3 -0
  66. package/src/ts/ts-rs/WorkspaceConfigUpdate.ts +2 -1
  67. /package/dist/wasm/snippets/{perspective-viewer-d0d525977a1acba2 → perspective-viewer-7fc45549159e01e4}/inline0.js +0 -0
  68. /package/dist/wasm/snippets/{perspective-viewer-d0d525977a1acba2 → perspective-viewer-7fc45549159e01e4}/inline1.js +0 -0
  69. /package/dist/wasm/snippets/{perspective-viewer-d0d525977a1acba2 → perspective-viewer-7fc45549159e01e4}/inline2.js +0 -0
  70. /package/dist/wasm/snippets/{perspective-viewer-d0d525977a1acba2 → perspective-viewer-7fc45549159e01e4}/inline3.js +0 -0
  71. /package/dist/wasm/snippets/{perspective-viewer-d0d525977a1acba2 → perspective-viewer-7fc45549159e01e4}/inline4.js +0 -0
  72. /package/dist/wasm/snippets/{perspective-viewer-d0d525977a1acba2 → perspective-viewer-7fc45549159e01e4}/inline5.js +0 -0
@@ -162,7 +162,8 @@ impl RegularLayout {
162
162
  }
163
163
  }
164
164
 
165
- /// The orientation of a [`SplitLayout`].
165
+ /// The direction a [`SplitLayout`] divides its space in: `horizontal` places
166
+ /// children side by side as columns, `vertical` stacks them as rows.
166
167
  #[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, ts_rs::TS)]
167
168
  #[serde(rename_all = "lowercase")]
168
169
  pub enum Orientation {
@@ -170,8 +171,8 @@ pub enum Orientation {
170
171
  Vertical,
171
172
  }
172
173
 
173
- /// A serde mirror of `regular-layout`'s serialized layout tree, as returned by
174
- /// [`RegularLayout::save`] and accepted by [`RegularLayout::restore`].
174
+ /// A dashboard's panel arrangement: nested splits whose leaves are tab stacks
175
+ /// of panel ids, naming every panel exactly once.
175
176
  #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ts_rs::TS)]
176
177
  #[serde(tag = "type")]
177
178
  pub enum Layout {
@@ -184,13 +185,21 @@ pub enum Layout {
184
185
  Tab(TabLayout),
185
186
  }
186
187
 
188
+ /// A row or column of child layouts, nested to form a grid.
187
189
  #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ts_rs::TS)]
188
190
  pub struct SplitLayout {
191
+ /// Child layouts, in left-to-right or top-to-bottom order.
189
192
  pub children: Vec<Layout>,
193
+
194
+ /// Each child's fraction of the split, one per child, summing to 1.
190
195
  pub sizes: Vec<f64>,
196
+
197
+ /// Whether children sit side by side (`horizontal`) or stacked
198
+ /// (`vertical`).
191
199
  pub orientation: Orientation,
192
200
  }
193
201
 
202
+ /// A stack of panels shown as tabs, one visible at a time.
194
203
  #[derive(Clone, Debug, PartialEq, Serialize, Deserialize, ts_rs::TS)]
195
204
  pub struct TabLayout {
196
205
  /// Panel ids (slot names) in this stack.
@@ -202,7 +211,220 @@ pub struct TabLayout {
202
211
  pub selected: Option<usize>,
203
212
  }
204
213
 
214
+ /// A normalized `[0, 1]` rectangle of the layout box (regular-layout's
215
+ /// `ViewWindow`).
216
+ #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
217
+ pub struct ViewWindow {
218
+ pub row_start: f64,
219
+ pub row_end: f64,
220
+ pub col_start: f64,
221
+ pub col_end: f64,
222
+ }
223
+
205
224
  impl Layout {
225
+ /// Mirror of regular-layout's `insert_child(tree, name, [index],
226
+ /// orientation)`, the single-index split insert `MainPanel::reconcile`
227
+ /// issues.
228
+ pub fn insert_split(&self, index: usize, name: &str, orientation: Orientation) -> Layout {
229
+ let leaf = Layout::Tab(TabLayout {
230
+ tabs: vec![name.to_owned()],
231
+ selected: None,
232
+ });
233
+
234
+ match self {
235
+ Layout::Split(split) if split.orientation == orientation => {
236
+ let index = index.min(split.children.len());
237
+ let mut children = split.children.clone();
238
+ let mut sizes = split.sizes.clone();
239
+ children.insert(index, leaf);
240
+ sizes.insert(index, 1.0 / (children.len() - 1).max(1) as f64);
241
+ let total: f64 = sizes.iter().sum();
242
+ let sizes = if total.is_finite() && total > 0.0 {
243
+ sizes.iter().map(|size| size / total).collect()
244
+ } else {
245
+ vec![1.0 / children.len() as f64; children.len()]
246
+ };
247
+
248
+ Layout::Split(SplitLayout {
249
+ children,
250
+ sizes,
251
+ orientation,
252
+ })
253
+ },
254
+ _ => Layout::Split(SplitLayout {
255
+ children: if index == 0 {
256
+ vec![leaf, self.clone()]
257
+ } else {
258
+ vec![self.clone(), leaf]
259
+ },
260
+ sizes: vec![0.5, 0.5],
261
+ orientation,
262
+ }),
263
+ }
264
+ }
265
+
266
+ /// The normalized box the visible panel `name` occupies (mirror of
267
+ /// regular-layout's `calculate_presize_paths`).
268
+ pub fn view_window(&self, name: &str) -> Option<ViewWindow> {
269
+ self.view_window_in(name, ViewWindow {
270
+ row_start: 0.0,
271
+ row_end: 1.0,
272
+ col_start: 0.0,
273
+ col_end: 1.0,
274
+ })
275
+ }
276
+
277
+ fn view_window_in(&self, name: &str, window: ViewWindow) -> Option<ViewWindow> {
278
+ match self {
279
+ Layout::Tab(tab) => {
280
+ let selected = tab.tabs.get(tab.selected.unwrap_or(0));
281
+ (selected.map(String::as_str) == Some(name)).then_some(window)
282
+ },
283
+ Layout::Split(split) => {
284
+ let vertical = split.orientation == Orientation::Vertical;
285
+ let (start, end) = if vertical {
286
+ (window.row_start, window.row_end)
287
+ } else {
288
+ (window.col_start, window.col_end)
289
+ };
290
+
291
+ let mut pos = start;
292
+ for (child, size) in split.children.iter().zip(&split.sizes) {
293
+ let next = pos + (end - start) * size;
294
+ let child_window = if vertical {
295
+ ViewWindow {
296
+ row_start: pos,
297
+ row_end: next,
298
+ ..window
299
+ }
300
+ } else {
301
+ ViewWindow {
302
+ col_start: pos,
303
+ col_end: next,
304
+ ..window
305
+ }
306
+ };
307
+
308
+ if let Some(found) = child.view_window_in(name, child_window) {
309
+ return Some(found);
310
+ }
311
+
312
+ pos = next;
313
+ }
314
+
315
+ None
316
+ },
317
+ }
318
+ }
319
+
320
+ /// Check that this tree names each of `ids` exactly once and is
321
+ /// well-formed, describing the first violation found.
322
+ pub fn validate(&self, ids: &[String]) -> Result<(), String> {
323
+ if let Layout::Split(split) = self
324
+ && split.children.is_empty()
325
+ && split.sizes.is_empty()
326
+ && ids.is_empty()
327
+ {
328
+ return Ok(());
329
+ }
330
+
331
+ let mut seen = Vec::new();
332
+ self.validate_node("layout", ids, &mut seen)?;
333
+ let missing = ids
334
+ .iter()
335
+ .filter(|id| !seen.contains(id))
336
+ .collect::<Vec<_>>();
337
+
338
+ if !missing.is_empty() {
339
+ return Err(format!(
340
+ "Invalid layout: panels {missing:?} are missing - a layout must name every panel \
341
+ exactly once (panels: {ids:?})"
342
+ ));
343
+ }
344
+
345
+ Ok(())
346
+ }
347
+
348
+ fn validate_node(
349
+ &self,
350
+ path: &str,
351
+ ids: &[String],
352
+ seen: &mut Vec<String>,
353
+ ) -> Result<(), String> {
354
+ match self {
355
+ Layout::Split(split) => {
356
+ if split.children.is_empty() {
357
+ return Err(format!("Invalid layout: {path}.children is empty"));
358
+ }
359
+
360
+ if split.sizes.len() != split.children.len() {
361
+ return Err(format!(
362
+ "Invalid layout: {path}.sizes has {} entries for {} children - give one \
363
+ size per child",
364
+ split.sizes.len(),
365
+ split.children.len()
366
+ ));
367
+ }
368
+
369
+ if let Some(size) = split.sizes.iter().find(|x| !x.is_finite() || **x <= 0.0) {
370
+ return Err(format!(
371
+ "Invalid layout: {path}.sizes contains {size} - sizes must be positive \
372
+ fractions"
373
+ ));
374
+ }
375
+
376
+ let total: f64 = split.sizes.iter().sum();
377
+ if (total - 1.0).abs() > 1e-6 {
378
+ return Err(format!(
379
+ "Invalid layout: {path}.sizes sum to {total} - sizes are fractions of the \
380
+ split and must sum to 1"
381
+ ));
382
+ }
383
+
384
+ for (index, child) in split.children.iter().enumerate() {
385
+ child.validate_node(&format!("{path}.children[{index}]"), ids, seen)?;
386
+ }
387
+
388
+ Ok(())
389
+ },
390
+ Layout::Tab(tab) => {
391
+ if tab.tabs.is_empty() {
392
+ return Err(format!("Invalid layout: {path}.tabs is empty"));
393
+ }
394
+
395
+ if let Some(selected) = tab.selected
396
+ && selected >= tab.tabs.len()
397
+ {
398
+ return Err(format!(
399
+ "Invalid layout: {path}.selected is {selected} but {path}.tabs has {} \
400
+ entries",
401
+ tab.tabs.len()
402
+ ));
403
+ }
404
+
405
+ for name in &tab.tabs {
406
+ if !ids.contains(name) {
407
+ return Err(format!(
408
+ "Invalid layout: {path}.tabs names unknown panel \"{name}\" (panels: \
409
+ {ids:?})"
410
+ ));
411
+ }
412
+
413
+ if seen.contains(name) {
414
+ return Err(format!(
415
+ "Invalid layout: panel \"{name}\" appears more than once - a layout \
416
+ must name every panel exactly once"
417
+ ));
418
+ }
419
+
420
+ seen.push(name.clone());
421
+ }
422
+
423
+ Ok(())
424
+ },
425
+ }
426
+ }
427
+
206
428
  /// Collect every panel id (slot name) in the tree, depth-first.
207
429
  pub fn slot_names(&self) -> Vec<String> {
208
430
  match self {
@@ -64,6 +64,16 @@ pub fn sync_update_panels(
64
64
 
65
65
  let old_ids = this.workspace.panel_ids();
66
66
  let replace = panels.is_some();
67
+ if let Some(layout) = &layout {
68
+ let ids = match &panels {
69
+ Some(panels) => panels.keys().cloned().collect::<Vec<_>>(),
70
+ None => old_ids.iter().map(|id| id.as_str().to_owned()).collect(),
71
+ };
72
+
73
+ layout
74
+ .validate(&ids)
75
+ .map_err(|e| ApiError::from(JsValue::from_str(&e)))?;
76
+ }
67
77
 
68
78
  // Phase 1 — models only, NO renders and NO draws
69
79
  let mut id_map: HashMap<String, String> = Default::default();
@@ -127,25 +137,6 @@ pub fn sync_update_panels(
127
137
  if !replace {
128
138
  this.workspace.layout_staged().emit(());
129
139
  }
130
- } else if replace && contents.len() > 1 {
131
- // No saved tree: synthesize the equal-split default so a
132
- // multi-panel replace still mounts in ONE layout commit —
133
- // per-cell `insertPanel` commits are async, and a commit landing
134
- // between two inserts drops the later one.
135
- this.workspace
136
- .set_pending_layout(crate::js::Layout::Split(crate::js::SplitLayout {
137
- orientation: crate::js::Orientation::Horizontal,
138
- sizes: vec![1.0 / contents.len() as f64; contents.len()],
139
- children: contents
140
- .iter()
141
- .map(|(id, ..)| {
142
- crate::js::Layout::Tab(crate::js::TabLayout {
143
- tabs: vec![id.as_str().to_owned()],
144
- selected: Some(0),
145
- })
146
- })
147
- .collect(),
148
- }));
149
140
  }
150
141
 
151
142
  // Phase 3 — the single visible commit
@@ -175,6 +175,7 @@ perspective-viewer {
175
175
  --psp-label--point-size-px--content: "حجم النقطة";
176
176
  --psp-label--band-inner-frac--content: "عرض النطاق";
177
177
  --psp-label--bar-inner-pad--content: "تباعد الأعمدة";
178
+ --psp-label--group-pad--content: "تباعد المجموعات";
178
179
  --psp-label--wick-width-px--content: "عرض الفتيل";
179
180
  --psp-label--ohlc-line-width-px--content: "عرض خط OHLC";
180
181
  --psp-label--include-zero--content: "تضمين الصفر";
@@ -173,6 +173,7 @@ perspective-viewer {
173
173
  --psp-label--point-size-px--content: "Punktgröße";
174
174
  --psp-label--band-inner-frac--content: "Bandbreite";
175
175
  --psp-label--bar-inner-pad--content: "Balkenabstand";
176
+ --psp-label--group-pad--content: "Gruppenabstand";
176
177
  --psp-label--wick-width-px--content: "Dochtbreite";
177
178
  --psp-label--ohlc-line-width-px--content: "OHLC-Linienbreite";
178
179
  --psp-label--include-zero--content: "Null einschließen";
@@ -173,6 +173,7 @@ perspective-viewer {
173
173
  --psp-label--point-size-px--content: "Tamaño del punto";
174
174
  --psp-label--band-inner-frac--content: "Ancho de banda";
175
175
  --psp-label--bar-inner-pad--content: "Separación de barras";
176
+ --psp-label--group-pad--content: "Separación de grupos";
176
177
  --psp-label--wick-width-px--content: "Ancho de mecha";
177
178
  --psp-label--ohlc-line-width-px--content: "Ancho de línea OHLC";
178
179
  --psp-label--include-zero--content: "Incluir cero";
@@ -173,6 +173,7 @@ perspective-viewer {
173
173
  --psp-label--point-size-px--content: "Taille du point";
174
174
  --psp-label--band-inner-frac--content: "Largeur de bande";
175
175
  --psp-label--bar-inner-pad--content: "Espacement des barres";
176
+ --psp-label--group-pad--content: "Espacement des groupes";
176
177
  --psp-label--wick-width-px--content: "Largeur de mèche";
177
178
  --psp-label--ohlc-line-width-px--content: "Épaisseur ligne OHLC";
178
179
  --psp-label--include-zero--content: "Inclure zéro";
@@ -173,6 +173,7 @@ perspective-viewer {
173
173
  --psp-label--point-size-px--content: "点のサイズ";
174
174
  --psp-label--band-inner-frac--content: "バンド幅";
175
175
  --psp-label--bar-inner-pad--content: "バー間隔";
176
+ --psp-label--group-pad--content: "グループ間隔";
176
177
  --psp-label--wick-width-px--content: "ヒゲの幅";
177
178
  --psp-label--ohlc-line-width-px--content: "OHLC線の幅";
178
179
  --psp-label--include-zero--content: "ゼロを含める";
@@ -173,6 +173,7 @@ perspective-viewer {
173
173
  --psp-label--point-size-px--content: "Tamanho do ponto";
174
174
  --psp-label--band-inner-frac--content: "Largura da banda";
175
175
  --psp-label--bar-inner-pad--content: "Espaçamento das barras";
176
+ --psp-label--group-pad--content: "Espaçamento dos grupos";
176
177
  --psp-label--wick-width-px--content: "Largura do pavio";
177
178
  --psp-label--ohlc-line-width-px--content: "Largura da linha OHLC";
178
179
  --psp-label--include-zero--content: "Incluir zero";
@@ -173,6 +173,7 @@ perspective-viewer {
173
173
  --psp-label--point-size-px--content: "点大小";
174
174
  --psp-label--band-inner-frac--content: "带宽";
175
175
  --psp-label--bar-inner-pad--content: "条形间距";
176
+ --psp-label--group-pad--content: "分组间距";
176
177
  --psp-label--wick-width-px--content: "影线宽度";
177
178
  --psp-label--ohlc-line-width-px--content: "OHLC线宽";
178
179
  --psp-label--include-zero--content: "包含零";
@@ -186,6 +186,7 @@ perspective-viewer {
186
186
  --psp-label--point-size-px--content: "Point size";
187
187
  --psp-label--band-inner-frac--content: "Band width";
188
188
  --psp-label--bar-inner-pad--content: "Bar padding";
189
+ --psp-label--group-pad--content: "Group padding";
189
190
  --psp-label--wick-width-px--content: "Wick width";
190
191
  --psp-label--ohlc-line-width-px--content: "OHLC line width";
191
192
  --psp-label--include-zero--content: "Include zero";
@@ -3,7 +3,7 @@ import type { SplitLayout } from "./SplitLayout.js";
3
3
  import type { TabLayout } from "./TabLayout.js";
4
4
 
5
5
  /**
6
- * A serde mirror of `regular-layout`'s serialized layout tree, as returned by
7
- * [`RegularLayout::save`] and accepted by [`RegularLayout::restore`].
6
+ * A dashboard's panel arrangement: nested splits whose leaves are tab stacks
7
+ * of panel ids, naming every panel exactly once.
8
8
  */
9
9
  export type Layout = { "type": "split-layout" } & SplitLayout | { "type": "tab-layout" } & TabLayout;
@@ -1,6 +1,7 @@
1
1
  // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
2
 
3
3
  /**
4
- * The orientation of a [`SplitLayout`].
4
+ * The direction a [`SplitLayout`] divides its space in: `horizontal` places
5
+ * children side by side as columns, `vertical` stacks them as rows.
5
6
  */
6
7
  export type Orientation = "horizontal" | "vertical";
@@ -2,4 +2,20 @@
2
2
  import type { Layout } from "./Layout.js";
3
3
  import type { Orientation } from "./Orientation.js";
4
4
 
5
- export type SplitLayout = { children: Array<Layout>, sizes: Array<number>, orientation: Orientation, };
5
+ /**
6
+ * A row or column of child layouts, nested to form a grid.
7
+ */
8
+ export type SplitLayout = {
9
+ /**
10
+ * Child layouts, in left-to-right or top-to-bottom order.
11
+ */
12
+ children: Array<Layout>,
13
+ /**
14
+ * Each child's fraction of the split, one per child, summing to 1.
15
+ */
16
+ sizes: Array<number>,
17
+ /**
18
+ * Whether children sit side by side (`horizontal`) or stacked
19
+ * (`vertical`).
20
+ */
21
+ orientation: Orientation, };
@@ -1,5 +1,8 @@
1
1
  // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
2
 
3
+ /**
4
+ * A stack of panels shown as tabs, one visible at a time.
5
+ */
3
6
  export type TabLayout = {
4
7
  /**
5
8
  * Panel ids (slot names) in this stack.
@@ -18,7 +18,8 @@ export type WorkspaceConfigUpdate = {
18
18
  */
19
19
  active?: OptionalUpdate<string>,
20
20
  /**
21
- * The layout tree to stage, naming `panels` keys or existing panel ids.
21
+ * The layout tree to stage, naming every `panels` key (or, without
22
+ * `panels`, every existing panel id) exactly once.
22
23
  */
23
24
  layout?: Layout,
24
25
  /**