@perspective-dev/viewer 5.0.0 → 5.2.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 (213) 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/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/docs/perspective-docs.json +1 -0
  24. package/dist/esm/column-format.d.ts +19 -28
  25. package/dist/esm/perspective-viewer.d.ts +2 -0
  26. package/dist/esm/perspective-viewer.inline.js +8 -8
  27. package/dist/esm/perspective-viewer.inline.js.map +4 -4
  28. package/dist/esm/perspective-viewer.js +9 -9
  29. package/dist/esm/perspective-viewer.js.map +4 -4
  30. package/dist/esm/providers.d.ts +79 -0
  31. package/dist/esm/ts-rs/CompactDisplay.d.ts +5 -0
  32. package/dist/esm/ts-rs/CurrencyCode.d.ts +1 -0
  33. package/dist/esm/ts-rs/CurrencyDisplay.d.ts +1 -0
  34. package/dist/esm/ts-rs/CurrencyNumberFormatStyle.d.ts +8 -0
  35. package/dist/esm/ts-rs/CurrencySign.d.ts +1 -0
  36. package/dist/esm/ts-rs/CustomDatetimeFormat.d.ts +1 -0
  37. package/dist/esm/ts-rs/CustomDatetimeStyleConfig.d.ts +54 -0
  38. package/dist/esm/ts-rs/CustomNumberFormatConfig.d.ts +34 -0
  39. package/dist/esm/ts-rs/DatetimeColorMode.d.ts +1 -0
  40. package/dist/esm/ts-rs/DatetimeFormatType.d.ts +6 -0
  41. package/dist/esm/ts-rs/FormatMode.d.ts +1 -0
  42. package/dist/esm/ts-rs/FormatUnit.d.ts +1 -0
  43. package/dist/esm/ts-rs/Notation.d.ts +17 -0
  44. package/dist/esm/ts-rs/NumberFormatStyle.d.ts +18 -0
  45. package/dist/esm/ts-rs/PanelViewerConfig.d.ts +43 -1
  46. package/dist/esm/ts-rs/PluginStaticConfig.d.ts +35 -0
  47. package/dist/esm/ts-rs/RestoreOptions.d.ts +19 -0
  48. package/dist/esm/ts-rs/RoundingMode.d.ts +1 -0
  49. package/dist/esm/ts-rs/RoundingPriority.d.ts +1 -0
  50. package/dist/esm/ts-rs/SignDisplay.d.ts +1 -0
  51. package/dist/esm/ts-rs/SimpleDatetimeFormat.d.ts +1 -0
  52. package/dist/esm/ts-rs/SimpleDatetimeStyleConfig.d.ts +24 -0
  53. package/dist/esm/ts-rs/SplitRollupMode.d.ts +9 -0
  54. package/dist/esm/ts-rs/StringColorMode.d.ts +1 -0
  55. package/dist/esm/ts-rs/TrailingZeroDisplay.d.ts +1 -0
  56. package/dist/esm/ts-rs/Unit.d.ts +1 -0
  57. package/dist/esm/ts-rs/UnitDisplay.d.ts +1 -0
  58. package/dist/esm/ts-rs/UnitNumberFormatStyle.d.ts +6 -0
  59. package/dist/esm/ts-rs/UseGrouping.d.ts +1 -0
  60. package/dist/esm/ts-rs/ViewerConfig.d.ts +43 -1
  61. package/dist/esm/ts-rs/ViewerConfigInitial.d.ts +175 -0
  62. package/dist/esm/ts-rs/ViewerConfigUpdate.d.ts +72 -0
  63. package/dist/esm/ts-rs/WindowSort.d.ts +7 -0
  64. package/dist/esm/ts-rs/WindowSortDir.d.ts +6 -0
  65. package/dist/esm/ts-rs/WindowSpec.d.ts +47 -0
  66. package/dist/esm/ts-rs/Windows.d.ts +10 -0
  67. package/dist/esm/ts-rs/WorkspaceConfigUpdate.d.ts +7 -6
  68. package/dist/wasm/perspective-viewer.d.ts +222 -26
  69. package/dist/wasm/perspective-viewer.js +378 -125
  70. package/dist/wasm/perspective-viewer.wasm +0 -0
  71. package/dist/wasm/perspective-viewer.wasm.d.ts +18 -15
  72. package/package.json +2 -1
  73. package/src/css/_viewer_bundle.css +1 -0
  74. package/src/css/column-selector.css +9 -0
  75. package/src/css/column-settings-panel.css +67 -2
  76. package/src/css/column-style.css +4 -3
  77. package/src/css/config-selector.css +60 -4
  78. package/src/css/containers/context-menu.css +12 -6
  79. package/src/css/containers/tabs.css +2 -2
  80. package/src/css/form/code-editor.css +2 -3
  81. package/src/css/form/mirrored-textarea.css +81 -0
  82. package/src/css/viewer.css +336 -0
  83. package/src/rust/agent/client/mod.rs +19 -0
  84. package/src/rust/agent/client/protocol.rs +320 -0
  85. package/src/rust/agent/client/transport.rs +287 -0
  86. package/src/rust/agent/client/turn.rs +174 -0
  87. package/src/rust/agent/config.rs +159 -0
  88. package/src/rust/agent/docs.rs +293 -0
  89. package/src/rust/agent/markdown/block.rs +509 -0
  90. package/src/rust/agent/markdown/entity.rs +52 -0
  91. package/src/rust/agent/markdown/events.rs +71 -0
  92. package/src/rust/agent/markdown/inline.rs +497 -0
  93. package/src/rust/agent/markdown/mod.rs +466 -0
  94. package/src/rust/agent/mod.rs +23 -0
  95. package/src/rust/agent/preamble.md +16 -0
  96. package/src/rust/agent/runtime.rs +201 -0
  97. package/src/rust/agent/slot.rs +236 -0
  98. package/src/rust/agent/tools.rs +1110 -0
  99. package/src/rust/components/chat_panel.rs +289 -0
  100. package/src/rust/components/column_selector/active_column.rs +21 -27
  101. package/src/rust/components/column_selector/column_selector_column_row.rs +73 -0
  102. package/src/rust/components/column_selector/config_selector.rs +83 -8
  103. package/src/rust/components/column_selector/expr_edit_button.rs +7 -1
  104. package/src/rust/components/column_selector/inactive_column.rs +8 -1
  105. package/src/rust/components/column_selector.rs +27 -3
  106. package/src/rust/components/column_settings_sidebar/style_tab.rs +2 -1
  107. package/src/rust/components/column_settings_sidebar/window_tab.rs +34 -0
  108. package/src/rust/components/column_settings_sidebar.rs +163 -16
  109. package/src/rust/components/containers/dragdrop_list.rs +110 -3
  110. package/src/rust/components/containers/sidebar.rs +99 -22
  111. package/src/rust/components/containers/split_panel.rs +6 -0
  112. package/src/rust/components/editable_header.rs +2 -0
  113. package/src/rust/components/form/code_editor.rs +14 -23
  114. package/src/rust/components/form/debug.rs +8 -5
  115. package/src/rust/components/form/mirrored_textarea.rs +165 -0
  116. package/src/rust/components/form/mod.rs +1 -0
  117. package/src/rust/components/main_panel.rs +5 -0
  118. package/src/rust/components/mod.rs +3 -0
  119. package/src/rust/components/panel_menu.rs +7 -0
  120. package/src/rust/components/panel_tab.rs +5 -0
  121. package/src/rust/components/portal.rs +7 -0
  122. package/src/rust/components/settings_panel.rs +80 -2
  123. package/src/rust/components/viewer/msg.rs +2 -0
  124. package/src/rust/components/viewer/panels.rs +9 -14
  125. package/src/rust/components/viewer/render.rs +14 -0
  126. package/src/rust/components/viewer/settings.rs +33 -1
  127. package/src/rust/components/viewer.rs +2 -0
  128. package/src/rust/components/window_editor.rs +985 -0
  129. package/src/rust/config/datetime_column_style/custom.rs +17 -0
  130. package/src/rust/config/datetime_column_style/simple.rs +10 -0
  131. package/src/rust/config/number_string_format.rs +33 -0
  132. package/src/rust/config/options.rs +18 -0
  133. package/src/rust/config/plugin_static_config.rs +120 -5
  134. package/src/rust/config/viewer_config.rs +220 -1
  135. package/src/rust/config/workspace_config.rs +7 -6
  136. package/src/rust/custom_elements/viewer.rs +209 -18
  137. package/src/rust/custom_events.rs +29 -0
  138. package/src/rust/lib.rs +17 -1
  139. package/src/rust/presentation/column_locator.rs +16 -1
  140. package/src/rust/presentation.rs +8 -0
  141. package/src/rust/queries/columns_iter_set.rs +7 -1
  142. package/src/rust/queries/get_viewer_config.rs +5 -1
  143. package/src/rust/renderer/dispatch.rs +85 -58
  144. package/src/rust/renderer.rs +34 -1
  145. package/src/rust/session/column_defaults_update.rs +18 -0
  146. package/src/rust/session/drag_drop_update.rs +18 -0
  147. package/src/rust/session/metadata.rs +64 -9
  148. package/src/rust/session/replace_expression_update.rs +2 -0
  149. package/src/rust/session.rs +7 -5
  150. package/src/rust/tasks/create_panel.rs +18 -8
  151. package/src/rust/tasks/edit_window.rs +155 -0
  152. package/src/rust/tasks/mod.rs +2 -0
  153. package/src/rust/tasks/restore_panel.rs +34 -17
  154. package/src/rust/tasks/sync_update_panels.rs +7 -23
  155. package/src/rust/utils/browser/dragdrop.rs +12 -0
  156. package/src/rust/utils/browser/tests/debounce.rs +49 -0
  157. package/src/rust/utils/debounce.rs +76 -27
  158. package/src/rust/workspace.rs +112 -20
  159. package/src/svg/pin-icon.svg +5 -0
  160. package/src/themes/icons.css +1 -0
  161. package/src/themes/intl/de.css +23 -0
  162. package/src/themes/intl/es.css +23 -0
  163. package/src/themes/intl/fr.css +23 -0
  164. package/src/themes/intl/ja.css +23 -0
  165. package/src/themes/intl/pt.css +23 -0
  166. package/src/themes/intl/zh.css +23 -0
  167. package/src/themes/intl.css +26 -1
  168. package/src/ts/column-format.ts +67 -46
  169. package/src/ts/perspective-viewer.ts +2 -0
  170. package/src/ts/providers.ts +96 -0
  171. package/src/ts/ts-rs/CompactDisplay.ts +3 -0
  172. package/src/ts/ts-rs/CurrencyCode.ts +3 -0
  173. package/src/ts/ts-rs/CurrencyDisplay.ts +3 -0
  174. package/src/ts/ts-rs/CurrencyNumberFormatStyle.ts +6 -0
  175. package/src/ts/ts-rs/CurrencySign.ts +3 -0
  176. package/src/ts/ts-rs/CustomDatetimeFormat.ts +3 -0
  177. package/src/ts/ts-rs/CustomDatetimeStyleConfig.ts +54 -0
  178. package/src/ts/ts-rs/CustomNumberFormatConfig.ts +25 -0
  179. package/src/ts/ts-rs/DatetimeColorMode.ts +3 -0
  180. package/src/ts/ts-rs/DatetimeFormatType.ts +8 -0
  181. package/src/ts/ts-rs/FormatMode.ts +3 -0
  182. package/src/ts/ts-rs/FormatUnit.ts +3 -0
  183. package/src/ts/ts-rs/Notation.ts +11 -0
  184. package/src/ts/ts-rs/NumberFormatStyle.ts +12 -0
  185. package/src/ts/ts-rs/PanelViewerConfig.ts +48 -1
  186. package/src/ts/ts-rs/PluginStaticConfig.ts +36 -1
  187. package/src/ts/ts-rs/RestoreOptions.ts +20 -0
  188. package/src/ts/ts-rs/RoundingMode.ts +3 -0
  189. package/src/ts/ts-rs/RoundingPriority.ts +3 -0
  190. package/src/ts/ts-rs/SignDisplay.ts +3 -0
  191. package/src/ts/ts-rs/SimpleDatetimeFormat.ts +3 -0
  192. package/src/ts/ts-rs/SimpleDatetimeStyleConfig.ts +25 -0
  193. package/src/ts/ts-rs/SplitRollupMode.ts +11 -0
  194. package/src/ts/ts-rs/StringColorMode.ts +3 -0
  195. package/src/ts/ts-rs/TrailingZeroDisplay.ts +3 -0
  196. package/src/ts/ts-rs/Unit.ts +3 -0
  197. package/src/ts/ts-rs/UnitDisplay.ts +3 -0
  198. package/src/ts/ts-rs/UnitNumberFormatStyle.ts +5 -0
  199. package/src/ts/ts-rs/UseGrouping.ts +3 -0
  200. package/src/ts/ts-rs/ViewerConfig.ts +48 -1
  201. package/src/ts/ts-rs/ViewerConfigInitial.ts +164 -0
  202. package/src/ts/ts-rs/ViewerConfigUpdate.ts +81 -2
  203. package/src/ts/ts-rs/WindowSort.ts +9 -0
  204. package/src/ts/ts-rs/WindowSortDir.ts +8 -0
  205. package/src/ts/ts-rs/WindowSpec.ts +47 -0
  206. package/src/ts/ts-rs/Windows.ts +10 -0
  207. package/src/ts/ts-rs/WorkspaceConfigUpdate.ts +7 -6
  208. /package/dist/wasm/snippets/{perspective-viewer-daeef4ceb066e6c7 → perspective-viewer-02e461f3d7062b26}/inline0.js +0 -0
  209. /package/dist/wasm/snippets/{perspective-viewer-daeef4ceb066e6c7 → perspective-viewer-02e461f3d7062b26}/inline1.js +0 -0
  210. /package/dist/wasm/snippets/{perspective-viewer-daeef4ceb066e6c7 → perspective-viewer-02e461f3d7062b26}/inline2.js +0 -0
  211. /package/dist/wasm/snippets/{perspective-viewer-daeef4ceb066e6c7 → perspective-viewer-02e461f3d7062b26}/inline3.js +0 -0
  212. /package/dist/wasm/snippets/{perspective-viewer-daeef4ceb066e6c7 → perspective-viewer-02e461f3d7062b26}/inline4.js +0 -0
  213. /package/dist/wasm/snippets/{perspective-viewer-daeef4ceb066e6c7 → perspective-viewer-02e461f3d7062b26}/inline5.js +0 -0
@@ -0,0 +1,175 @@
1
+ import type { Aggregate } from "./Aggregate.js";
2
+ import type { Expressions } from "./Expressions.js";
3
+ import type { Filter } from "./Filter.js";
4
+ import type { FilterReducer } from "./FilterReducer.js";
5
+ import type { GroupRollupMode } from "./GroupRollupMode.js";
6
+ import type { Sort } from "./Sort.js";
7
+ import type { SplitRollupMode } from "./SplitRollupMode.js";
8
+ import type { Windows } from "./Windows.js";
9
+ import type { JsonValue } from "./serde_json/JsonValue.js";
10
+ /**
11
+ * The initial configuration of a NEW panel (`addPanel`, `restore`'s
12
+ * panel-creating upsert, `restoreWorkspace` `panels` entries). Unlike
13
+ * [`ViewerConfigUpdate`] — a patch against existing state — creation has
14
+ * no prior state: `table` is REQUIRED (a placed panel without a table
15
+ * binding would be permanently blank), absent fields mean "default"
16
+ * rather than "leave unchanged" (so no [`OptionalUpdate`] tri-state), and
17
+ * there is no `settings` field (element-level, not per-panel).
18
+ */
19
+ export type ViewerConfigInitial = {
20
+ /**
21
+ * Name of the `Table` the new panel renders, as hosted on the
22
+ * `Client`. REQUIRED: a placed panel with no table binding would be
23
+ * permanently blank.
24
+ */
25
+ table: string;
26
+ /**
27
+ * The `@perspective-dev/viewer` version a saved config was written
28
+ * by. Omit it when creating a panel.
29
+ */
30
+ version?: string;
31
+ /**
32
+ * Name of the visualization plugin, from the set registered on the
33
+ * page (the `list_plugins` agent tool, or the plugin picker).
34
+ * Decides what the view fields MEAN: `columns` is positional and
35
+ * every plugin reads the positions differently, and
36
+ * `group_by`/`split_by` draw different things per plugin. Absent
37
+ * uses the default plugin.
38
+ */
39
+ plugin?: string;
40
+ /**
41
+ * Panel title, shown in its tab. Absent renders the default title.
42
+ */
43
+ title?: string;
44
+ /**
45
+ * Theme NAME (e.g. `"Pro Dark"`) — not a CSS value. Valid names are
46
+ * the Perspective themes loaded on the page. Absent uses the
47
+ * default.
48
+ */
49
+ theme?: string;
50
+ /**
51
+ * Plugin-wide settings (as opposed to the per-column
52
+ * [`Self::columns_config`]). Opaque to the viewer and defined by
53
+ * the ACTIVE plugin; query the valid keys with `get_style_schema`
54
+ * rather than guessing.
55
+ */
56
+ plugin_config?: {
57
+ [key in string]?: JsonValue;
58
+ };
59
+ /**
60
+ * Per-column styling — formatting, colors, and other per-column
61
+ * controls — keyed by column name. Plugin-defined like
62
+ * [`Self::plugin_config`]; see `get_style_schema`.
63
+ */
64
+ columns_config?: {
65
+ [key in string]?: {
66
+ [key in string]?: JsonValue;
67
+ };
68
+ };
69
+ /**
70
+ * A group by _groups_ the dataset by the unique values of each column used
71
+ * as a group by - a close analogue in SQL to the `GROUP BY` statement.
72
+ * The underlying dataset is aggregated to show the values belonging to
73
+ * each group, and a total row is calculated for each group, showing
74
+ * the currently selected aggregated value (e.g. `sum`) of the column.
75
+ * Group by are useful for hierarchies, categorizing data and
76
+ * attributing values, i.e. showing the number of units sold based on
77
+ * State and City. In Perspective, group by are represented as an array
78
+ * of string column names to pivot, are applied in the order provided;
79
+ * For example, a group by of `["State", "City", "Postal Code"]` shows
80
+ * the values for each Postal Code, which are grouped by City,
81
+ * which are in turn grouped by State.
82
+ */
83
+ group_by?: Array<string>;
84
+ /**
85
+ * A split by _splits_ the dataset by the unique values of each column used
86
+ * as a split by. The underlying dataset is not aggregated, and a new
87
+ * column is created for each unique value of the split by. Each newly
88
+ * created column contains the parts of the dataset that correspond to
89
+ * the column header, i.e. a `View` that has `["State"]` as its split
90
+ * by will have a new column for each state. In Perspective, Split By
91
+ * are represented as an array of string column names to pivot.
92
+ */
93
+ split_by?: Array<string>;
94
+ /**
95
+ * The `columns` property specifies which columns should be included in the
96
+ * [`crate::View`]'s output. This allows users to show or hide a specific
97
+ * subset of columns, as well as control the order in which columns
98
+ * appear to the user. This is represented in Perspective as an array
99
+ * of string column names.
100
+ */
101
+ columns?: Array<string | null>;
102
+ /**
103
+ * The `filter` property specifies columns on which the query can be
104
+ * filtered, returning rows that pass the specified filter condition.
105
+ * This is analogous to the `WHERE` clause in SQL. There is no limit on
106
+ * the number of columns where `filter` is applied, but the resulting
107
+ * dataset is one that passes all the filter conditions, i.e. the
108
+ * filters are joined with an `AND` condition.
109
+ *
110
+ * Perspective represents `filter` as an array of arrays, with the values
111
+ * of each inner array being a string column name, a string filter
112
+ * operator, and a filter operand in the type of the column.
113
+ */
114
+ filter?: Array<Filter>;
115
+ /**
116
+ * The `sort` property specifies columns on which the query should be
117
+ * sorted, analogous to `ORDER BY` in SQL. A column can be sorted
118
+ * regardless of its data type, and sorts can be applied in ascending
119
+ * or descending order. Perspective represents `sort` as an array of
120
+ * arrays, with the values of each inner array being a string column
121
+ * name and a string sort direction. When `column-pivots` are applied,
122
+ * the additional sort directions `"col asc"` and `"col desc"` will
123
+ * determine the order of pivot columns groups.
124
+ *
125
+ * `sort` is the ONLY thing that orders a `View`'s rows — without it
126
+ * they keep the `Table`'s natural (insertion) order, which any
127
+ * consumer reading rows sequentially will reflect. Not to be
128
+ * confused with a window column's `order_by`, which orders rows
129
+ * WITHIN a window frame and does not reorder the `View`.
130
+ */
131
+ sort?: Array<Sort>;
132
+ /**
133
+ * The `expressions` property specifies _new_ columns in Perspective that
134
+ * are created using existing column values or arbitary scalar values
135
+ * defined within the expression. In `<perspective-viewer>`,
136
+ * expressions are added using the "New Column" button in the side
137
+ * panel.
138
+ */
139
+ expressions?: Expressions;
140
+ /**
141
+ * The `windows` property declares ordered, partitioned rolling
142
+ * computations (moving aggregates, cumulative sums) as _new_ columns
143
+ * keyed by output alias (`{"name": {...spec}}`, symmetric with
144
+ * `expressions`), analogous to SQL window functions. See
145
+ * [`crate::config::WindowSpec`].
146
+ */
147
+ windows?: Windows;
148
+ /**
149
+ * Aggregates perform a calculation over an entire column, and are
150
+ * displayed when one or more [Group By](#group-by) are applied to the
151
+ * `View`. Aggregates can be specified by the user, or Perspective will
152
+ * use the following sensible default aggregates based on column type:
153
+ *
154
+ * - "sum" for `integer` and `float` columns
155
+ * - "count" for all other columns
156
+ *
157
+ * Perspective provides a selection of aggregate functions that can be
158
+ * applied to columns in the `View` constructor using a dictionary of
159
+ * column name to aggregate function name.
160
+ *
161
+ * An aggregate also determines the column's RESULT TYPE, which need
162
+ * not match the input: `"count"` yields an `integer` whatever it
163
+ * counts, so a `date` column left on the default `"count"` is an
164
+ * `integer` in the resulting `View` — no longer a date. Set an
165
+ * aggregate that preserves the type (e.g. `"any"`, `"last"`) when
166
+ * the original type matters, such as a date used as a chart axis.
167
+ */
168
+ aggregates?: {
169
+ [key in string]?: Aggregate;
170
+ };
171
+ group_by_depth?: number;
172
+ filter_op?: FilterReducer;
173
+ group_rollup_mode?: GroupRollupMode;
174
+ split_rollup_mode?: SplitRollupMode;
175
+ };
@@ -5,17 +5,67 @@ import type { FilterReducer } from "./FilterReducer.js";
5
5
  import type { GroupRollupMode } from "./GroupRollupMode.js";
6
6
  import type { OptionalUpdate } from "./OptionalUpdate.js";
7
7
  import type { Sort } from "./Sort.js";
8
+ import type { SplitRollupMode } from "./SplitRollupMode.js";
9
+ import type { Windows } from "./Windows.js";
8
10
  import type { JsonValue } from "./serde_json/JsonValue.js";
9
11
  export type ViewerConfigUpdate = {
12
+ /**
13
+ * The `@perspective-dev/viewer` version a saved config was written
14
+ * by, used to migrate older tokens. Omit it — the viewer stamps
15
+ * the current version on save.
16
+ */
10
17
  version?: OptionalUpdate<string>;
18
+ /**
19
+ * Name of the visualization plugin to switch to, from the set
20
+ * registered on the page (the `list_plugins` agent tool, or the
21
+ * plugin picker). Changing it changes what the view fields MEAN:
22
+ * `columns` is positional and every plugin reads the positions
23
+ * differently, and `group_by`/`split_by` draw different things per
24
+ * plugin — so read the new plugin's roles before writing `columns`
25
+ * for it.
26
+ */
11
27
  plugin?: OptionalUpdate<string>;
28
+ /**
29
+ * Panel title, shown in its tab. `null` restores the default
30
+ * title; omitting the field leaves the current one.
31
+ */
12
32
  title?: OptionalUpdate<string>;
33
+ /**
34
+ * Name of the `Table` to render, as hosted on this panel's
35
+ * `Client`. Rebinding an existing panel to another table keeps the
36
+ * rest of the config, so column names that do not exist in the new
37
+ * table will fail validation.
38
+ */
13
39
  table?: OptionalUpdate<string>;
40
+ /**
41
+ * Theme NAME (e.g. `"Pro Dark"`) — not a CSS value. Valid names are
42
+ * the Perspective themes loaded on the page, re-scanned by
43
+ * `resetThemes()`. `null` selects the default.
44
+ */
14
45
  theme?: OptionalUpdate<string>;
46
+ /**
47
+ * Whether the settings sidebar is OPEN. Purely cosmetic chrome —
48
+ * it does not affect what the viewer renders, and it is
49
+ * element-level rather than per-panel.
50
+ */
15
51
  settings?: OptionalUpdate<boolean>;
52
+ /**
53
+ * Plugin-wide settings (as opposed to the per-column
54
+ * [`Self::columns_config`]). The viewer passes these through
55
+ * opaquely — their valid keys are defined by the ACTIVE plugin and
56
+ * vary by plugin and by state, so query them with the
57
+ * `get_style_schema` agent tool rather than guessing.
58
+ */
16
59
  plugin_config?: OptionalUpdate<{
17
60
  [key in string]?: JsonValue;
18
61
  }>;
62
+ /**
63
+ * Per-column styling — formatting, colors, and other per-column
64
+ * controls — keyed by column name. Opaque to the viewer and
65
+ * plugin-defined like [`Self::plugin_config`]; `get_style_schema`
66
+ * reports the valid keys for a given column under the active
67
+ * plugin.
68
+ */
19
69
  columns_config?: OptionalUpdate<{
20
70
  [key in string]?: {
21
71
  [key in string]?: JsonValue;
@@ -76,6 +126,12 @@ export type ViewerConfigUpdate = {
76
126
  * name and a string sort direction. When `column-pivots` are applied,
77
127
  * the additional sort directions `"col asc"` and `"col desc"` will
78
128
  * determine the order of pivot columns groups.
129
+ *
130
+ * `sort` is the ONLY thing that orders a `View`'s rows — without it
131
+ * they keep the `Table`'s natural (insertion) order, which any
132
+ * consumer reading rows sequentially will reflect. Not to be
133
+ * confused with a window column's `order_by`, which orders rows
134
+ * WITHIN a window frame and does not reorder the `View`.
79
135
  */
80
136
  sort?: Array<Sort>;
81
137
  /**
@@ -86,6 +142,14 @@ export type ViewerConfigUpdate = {
86
142
  * panel.
87
143
  */
88
144
  expressions?: Expressions;
145
+ /**
146
+ * The `windows` property declares ordered, partitioned rolling
147
+ * computations (moving aggregates, cumulative sums) as _new_ columns
148
+ * keyed by output alias (`{"name": {...spec}}`, symmetric with
149
+ * `expressions`), analogous to SQL window functions. See
150
+ * [`crate::config::WindowSpec`].
151
+ */
152
+ windows?: Windows;
89
153
  /**
90
154
  * Aggregates perform a calculation over an entire column, and are
91
155
  * displayed when one or more [Group By](#group-by) are applied to the
@@ -98,6 +162,13 @@ export type ViewerConfigUpdate = {
98
162
  * Perspective provides a selection of aggregate functions that can be
99
163
  * applied to columns in the `View` constructor using a dictionary of
100
164
  * column name to aggregate function name.
165
+ *
166
+ * An aggregate also determines the column's RESULT TYPE, which need
167
+ * not match the input: `"count"` yields an `integer` whatever it
168
+ * counts, so a `date` column left on the default `"count"` is an
169
+ * `integer` in the resulting `View` — no longer a date. Set an
170
+ * aggregate that preserves the type (e.g. `"any"`, `"last"`) when
171
+ * the original type matters, such as a date used as a chart axis.
101
172
  */
102
173
  aggregates?: {
103
174
  [key in string]?: Aggregate;
@@ -105,4 +176,5 @@ export type ViewerConfigUpdate = {
105
176
  group_by_depth?: number;
106
177
  filter_op?: FilterReducer;
107
178
  group_rollup_mode?: GroupRollupMode;
179
+ split_rollup_mode?: SplitRollupMode;
108
180
  };
@@ -0,0 +1,7 @@
1
+ import type { WindowSortDir } from "./WindowSortDir.js";
2
+ /**
3
+ * The `Table` column which orders each partition, with its direction -
4
+ * serialized as a two-element array (`["ts", "desc"]`), symmetric with the
5
+ * `ViewConfig`'s `sort` field.
6
+ */
7
+ export type WindowSort = [string, WindowSortDir];
@@ -0,0 +1,6 @@
1
+ /**
2
+ * A window's order direction. A dedicated two-variant enum rather than
3
+ * [`crate::config::SortDir`] - the column-sort extras (`col asc`, `abs`,
4
+ * `none`) are meaningless inside a window frame and unrepresentable here.
5
+ */
6
+ export type WindowSortDir = "asc" | "desc";
@@ -0,0 +1,47 @@
1
+ import type { WindowSort } from "./WindowSort.js";
2
+ /**
3
+ * The serialized form of [`WindowSpec`].
4
+ */
5
+ export type WindowSpec = {
6
+ /**
7
+ * The input column - either a real `Table` column or an expression
8
+ * alias from the same `ViewConfig`.
9
+ */
10
+ column: string;
11
+ aggregate: string;
12
+ /**
13
+ * Columns whose distinct value tuples partition the rows; empty
14
+ * partitions the whole `Table` as one group.
15
+ */
16
+ partition_by?: Array<string>;
17
+ /**
18
+ * The `Table` column which orders each partition, and the direction.
19
+ * This orders rows WITHIN the window frame only — it does not
20
+ * reorder the `View`, which is what the view-level `sort` does.
21
+ */
22
+ order_by?: WindowSort | null;
23
+ /**
24
+ * A frame of the `rows` preceding each row, plus the row itself.
25
+ * Mutually exclusive with `range` and `cumulative`.
26
+ */
27
+ rows?: number | null;
28
+ /**
29
+ * A frame of the rows whose `order_by` value lies within `range` of
30
+ * each row's, requiring a numeric or temporal `order_by`. Mutually
31
+ * exclusive with `rows` and `cumulative`.
32
+ */
33
+ range?: number | null;
34
+ /**
35
+ * `true` frames all rows from the partition start through each row.
36
+ * Default can be omitted.
37
+ */
38
+ cumulative?: boolean | null;
39
+ /**
40
+ * Row offset for `lag`/`lead` (default 1).
41
+ */
42
+ offset?: number | null;
43
+ /**
44
+ * Smoothing factor in `(0, 1]` for `ema`.
45
+ */
46
+ alpha?: number | null;
47
+ };
@@ -0,0 +1,10 @@
1
+ import type { WindowSpec } from "./WindowSpec.js";
2
+ /**
3
+ * The window columns of a `ViewConfig`, keyed by output column alias -
4
+ * symmetric with `expressions` (`{"name": {...spec}}`). An alias must not
5
+ * collide with a `Table` column, expression alias, or another window's
6
+ * key.
7
+ */
8
+ export type Windows = {
9
+ [key in string]?: WindowSpec;
10
+ };
@@ -1,18 +1,19 @@
1
1
  import type { Filter } from "./Filter.js";
2
2
  import type { Layout } from "./Layout.js";
3
- import type { ViewerConfigUpdate } from "./ViewerConfigUpdate.js";
3
+ import type { ViewerConfigInitial } from "./ViewerConfigInitial.js";
4
4
  /**
5
5
  * The parse target of a whole-element config in
6
- * [`PerspectiveViewerElement::restore`]. Mirrors [`WorkspaceConfig`],
7
- * but `panels` entries are full [`ViewerConfigUpdate`]s so a stray per-panel
8
- * `settings` can be detected (warned, then ignored — `create_panel` strips
9
- * it).
6
+ * [`PerspectiveViewerElement::restoreWorkspace`]. Mirrors
7
+ * [`WorkspaceConfig`], but `panels` entries are [`ViewerConfigInitial`]s —
8
+ * every entry creates a NEW panel, so `table` is required by type (a
9
+ * stray per-panel `settings` key is ignored; it is element-level state,
10
+ * carried by the top-level `active` field).
10
11
  */
11
12
  export type WorkspaceConfigUpdate = {
12
13
  active?: string;
13
14
  layout?: Layout;
14
15
  panels: {
15
- [key in string]?: ViewerConfigUpdate;
16
+ [key in string]?: ViewerConfigInitial;
16
17
  };
17
18
  /**
18
19
  * The element-level global (master/detail cross-) filters to re-apply as