@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
@@ -53,41 +53,33 @@ perspective-viewer[theme="Vaporwave"] {
53
53
  --psp-datagrid--pos-cell--color: #7dc3f0;
54
54
  --psp-datagrid--neg-cell--color: #ff9485;
55
55
 
56
- /* perspective-viewer-pro-dark--d3fc (overrides) */
57
- --psp-d3fc--legend--color: #c5c9d0;
58
- --psp-d3fc--treemap--labels: white;
59
- --psp-d3fc--treemap--hover-highlight: white;
60
- --psp-d3fc--tooltip--color: white;
61
- --psp-d3fc--axis-ticks--color: #c5c9d0;
62
- --psp-d3fc--axis-lines--color: #61656e;
63
- --psp-d3fc--gridline--color: #3b3f46;
64
- --psp-d3fc--tooltip--background: rgba(42, 44, 47, 1);
65
- --psp-d3fc--tooltip--border-color: #242526;
66
- --psp-d3fc--legend--background: var(--psp--background-color);
67
- --psp-d3fc--series--color: rgb(71, 120, 194);
68
- --psp-d3fc--series-1--color: rgb(71, 120, 194);
69
- --psp-d3fc--series-2--color: rgb(204, 120, 48);
70
- --psp-d3fc--series-3--color: rgb(158, 84, 192);
71
- --psp-d3fc--series-4--color: rgb(51, 150, 153);
72
- --psp-d3fc--series-5--color: rgb(102, 114, 143);
73
- --psp-d3fc--series-6--color: rgb(211, 103, 189);
74
- --psp-d3fc--series-7--color: rgb(109, 124, 77);
75
- --psp-d3fc--series-8--color: rgb(221, 99, 103);
76
- --psp-d3fc--series-9--color: rgb(120, 104, 206);
77
- --psp-d3fc--series-10--color: rgb(23, 166, 123);
78
- --psp-d3fc--full-gradient--background: linear-gradient(
56
+ /* perspective-viewer-pro-dark--webgl (overrides) */
57
+ --psp-charts--legend--color: #c5c9d0;
58
+ --psp-charts--treemap--labels: white;
59
+ --psp-charts--treemap--hover-highlight: white;
60
+ --psp-charts--tooltip--color: white;
61
+ --psp-charts--axis-ticks--color: #c5c9d0;
62
+ --psp-charts--axis-lines--color: #61656e;
63
+ --psp-charts--gridline--color: #3b3f46;
64
+ --psp-charts--tooltip--background: rgba(42, 44, 47, 1);
65
+ --psp-charts--tooltip--border-color: #242526;
66
+ --psp-charts--legend--background: var(--psp--background-color);
67
+ --psp-charts--series--color: rgb(71, 120, 194);
68
+ --psp-charts--series-1--color: rgb(71, 120, 194);
69
+ --psp-charts--series-2--color: rgb(204, 120, 48);
70
+ --psp-charts--series-3--color: rgb(158, 84, 192);
71
+ --psp-charts--series-4--color: rgb(51, 150, 153);
72
+ --psp-charts--series-5--color: rgb(102, 114, 143);
73
+ --psp-charts--series-6--color: rgb(211, 103, 189);
74
+ --psp-charts--series-7--color: rgb(109, 124, 77);
75
+ --psp-charts--series-8--color: rgb(221, 99, 103);
76
+ --psp-charts--series-9--color: rgb(120, 104, 206);
77
+ --psp-charts--series-10--color: rgb(23, 166, 123);
78
+ --psp-charts--gradient--background: linear-gradient(
79
79
  #dd6367 0%,
80
80
  #242526 50%,
81
81
  #3289c8 100%
82
82
  );
83
- --psp-d3fc--pos-gradient--background: linear-gradient(
84
- #242526 0%,
85
- #3289c8 100%
86
- );
87
- --psp-d3fc--neg-gradient--background: linear-gradient(
88
- #dd6367 0%,
89
- #242526 100%
90
- );
91
83
 
92
84
  /* perspective-viewer-pro-dark--openlayers (overrides) */
93
85
  --psp-openlayers--tile-url: "http://{a-c}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png";
@@ -143,49 +135,23 @@ perspective-viewer[theme="Vaporwave"] {
143
135
  background-position: 0px -10px;
144
136
  }
145
137
 
146
- /* perspective-viewer-vaporwave--d3fc */
147
- --psp-d3fc--axis-ticks--color: #49acff;
148
- --psp-d3fc--gridline--color: rgb(19, 33, 50);
149
- --psp-d3fc--series--color: #01cdfe;
150
- --psp-d3fc--series-1--color: #01cdfe;
151
- --psp-d3fc--series-2--color: #ff71ce;
152
- --psp-d3fc--series-3--color: #05ffa1;
153
- --psp-d3fc--series-4--color: #b967ff;
154
- --psp-d3fc--series-5--color: #fffb96;
155
-
156
- --psp-d3fc--series-6--color: hsl(192, 99%, 25%);
157
- --psp-d3fc--series-7--color: hsl(321, 100%, 36%);
158
- --psp-d3fc--series-8--color: hsl(192, 99%, 25%);
159
- --psp-d3fc--series-9--color: hsl(157, 100%, 25%);
160
- --psp-d3fc--series-10--color: hsl(272, 100%, 35%);
161
-
162
- --psp-d3fc--neg-gradient--background: linear-gradient(
163
- #f3d431,
164
- #efb92d,
165
- #ed9c25,
166
- #eb7e20,
167
- #e75d1e,
168
- #d14632,
169
- #b03e38,
170
- #8c3a36,
171
- #643633,
172
- #07081d
173
- ) !important;
174
-
175
- --psp-d3fc--pos-gradient--background: linear-gradient(
176
- #07081d,
177
- #2e4463,
178
- #1e588a,
179
- #086da7,
180
- #0082b9,
181
- #039ac7,
182
- #12b1d4,
183
- #2bc8e2,
184
- #3ddff0,
185
- #61f4fb
186
- ) !important;
187
-
188
- --psp-d3fc--full-gradient--background: linear-gradient(
138
+ /* perspective-viewer-vaporwave--webgl */
139
+ --psp-charts--axis-ticks--color: #49acff;
140
+ --psp-charts--gridline--color: rgb(19, 33, 50);
141
+ --psp-charts--series--color: #01cdfe;
142
+ --psp-charts--series-1--color: #01cdfe;
143
+ --psp-charts--series-2--color: #ff71ce;
144
+ --psp-charts--series-3--color: #05ffa1;
145
+ --psp-charts--series-4--color: #b967ff;
146
+ --psp-charts--series-5--color: #fffb96;
147
+
148
+ --psp-charts--series-6--color: hsl(192, 99%, 25%);
149
+ --psp-charts--series-7--color: hsl(321, 100%, 36%);
150
+ --psp-charts--series-8--color: hsl(192, 99%, 25%);
151
+ --psp-charts--series-9--color: hsl(157, 100%, 25%);
152
+ --psp-charts--series-10--color: hsl(272, 100%, 35%);
153
+
154
+ --psp-charts--gradient--background: linear-gradient(
189
155
  #f3d431,
190
156
  #efb92d,
191
157
  #ed9c25,
@@ -10,17 +10,28 @@
10
10
  // ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11
11
  // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
12
 
13
- import * as wasm_module from "../../dist/wasm/perspective-viewer.js";
13
+ import type * as wasm_module_type from "../../dist/wasm/perspective-viewer.js";
14
14
  import { load_wasm_stage_0 } from "@perspective-dev/client/src/ts/wasm/decompress.ts";
15
15
 
16
+ // @ts-ignore
17
+ import * as worker_url from "./perspective-viewer.worker";
18
+
16
19
  export async function init_client(
17
20
  wasm_binary:
18
21
  | Promise<Response | ArrayBuffer | Uint8Array>
19
22
  | Response
20
23
  | ArrayBuffer
21
24
  | Uint8Array,
25
+ wasm_module?: typeof wasm_module_type,
22
26
  ) {
23
- const module_or_path = await load_wasm_stage_0(wasm_binary);
27
+ // @ts-ignore
28
+ const url = await worker_url.getWorkerURL();
29
+ if (wasm_module === undefined) {
30
+ wasm_module = (await import(url)) as typeof wasm_module_type;
31
+ }
32
+
33
+ const unzipped = await load_wasm_stage_0(wasm_binary);
34
+ const module_or_path = await WebAssembly.compile(unzipped as BufferSource);
24
35
  await wasm_module.default({ module_or_path });
25
- await wasm_module.init();
36
+ await wasm_module.init(module_or_path, url);
26
37
  }
@@ -0,0 +1,162 @@
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
+ /**
14
+ * Cross-package helpers for per-column value formatting. Used by both
15
+ * `viewer-datagrid` (cell formatting) and `viewer-charts` (axis ticks,
16
+ * tooltips, legends) so a column's `number_format` / `date_format`
17
+ * configuration produces identical output across plugins.
18
+ *
19
+ * The format configs mirror the `Intl.NumberFormatOptions` /
20
+ * `Intl.DateTimeFormatOptions` shapes one-for-one — they're written
21
+ * straight into the respective constructors. The `date_format.format`
22
+ * discriminator ("simple" | "custom") selects between two derivation
23
+ * paths: simple uses `dateStyle` / `timeStyle`, custom uses the
24
+ * per-field overrides (year / month / day / ...).
25
+ */
26
+
27
+ export interface NumberFormatConfig {
28
+ style?: "decimal" | "currency" | "percent" | "unit";
29
+ minimumFractionDigits?: number;
30
+ maximumFractionDigits?: number;
31
+ minimumIntegerDigits?: number;
32
+ minimumSignificantDigits?: number;
33
+ maximumSignificantDigits?: number;
34
+ currency?: string;
35
+ currencyDisplay?: "code" | "symbol" | "narrowSymbol" | "name";
36
+ notation?: "standard" | "scientific" | "engineering" | "compact";
37
+ compactDisplay?: "short" | "long";
38
+ useGrouping?: boolean;
39
+ }
40
+
41
+ export interface DateFormatConfig {
42
+ format?: "custom" | string;
43
+ timeZone?: string;
44
+ dateStyle?: "short" | "medium" | "long" | "full" | "disabled";
45
+ timeStyle?: "short" | "medium" | "long" | "full" | "disabled";
46
+ second?: "numeric" | "2-digit" | "disabled";
47
+ minute?: "numeric" | "2-digit" | "disabled";
48
+ hour?: "numeric" | "2-digit" | "disabled";
49
+ day?: "numeric" | "2-digit" | "disabled";
50
+ weekday?: "narrow" | "short" | "long" | "disabled";
51
+ month?: "numeric" | "2-digit" | "narrow" | "short" | "long" | "disabled";
52
+ year?: "numeric" | "2-digit" | "disabled";
53
+ hour12?: boolean;
54
+ fractionalSecondDigits?: 1 | 2 | 3;
55
+ }
56
+
57
+ /**
58
+ * Default `Intl.NumberFormatOptions` applied when a numeric column has no
59
+ * `number_format` configured. Float columns get two fractional digits to
60
+ * match the legacy datagrid behavior; integer columns get an empty
61
+ * options bag (locale-default integer rendering).
62
+ */
63
+ const NUMERIC_LEGACY_DEFAULTS: Record<string, Intl.NumberFormatOptions> = {
64
+ float: {
65
+ style: "decimal",
66
+ minimumFractionDigits: 2,
67
+ maximumFractionDigits: 2,
68
+ },
69
+ };
70
+
71
+ /**
72
+ * Default `Intl.DateTimeFormatOptions` applied when a datetime column has
73
+ * no `date_format` configured.
74
+ */
75
+ const DATETIME_LEGACY_DEFAULTS: Intl.DateTimeFormatOptions = {
76
+ dateStyle: "short",
77
+ timeStyle: "medium",
78
+ };
79
+
80
+ const DATE_LEGACY_DEFAULTS: Intl.DateTimeFormatOptions = {
81
+ dateStyle: "short",
82
+ };
83
+
84
+ export function createNumberFormatter(
85
+ type: string,
86
+ cfg?: NumberFormatConfig,
87
+ ): Intl.NumberFormat {
88
+ const opts: Intl.NumberFormatOptions =
89
+ cfg ?? NUMERIC_LEGACY_DEFAULTS[type] ?? {};
90
+ return new Intl.NumberFormat(navigator.languages as string[], opts);
91
+ }
92
+
93
+ export function createDatetimeFormatter(
94
+ cfg?: DateFormatConfig,
95
+ ): Intl.DateTimeFormat {
96
+ if (!cfg || cfg.format !== "custom") {
97
+ const opts: Intl.DateTimeFormatOptions = {
98
+ timeZone: cfg?.timeZone,
99
+ dateStyle:
100
+ cfg?.dateStyle === "disabled"
101
+ ? undefined
102
+ : (cfg?.dateStyle ?? DATETIME_LEGACY_DEFAULTS.dateStyle),
103
+ timeStyle:
104
+ cfg?.timeStyle === "disabled"
105
+ ? undefined
106
+ : (cfg?.timeStyle ?? DATETIME_LEGACY_DEFAULTS.timeStyle),
107
+ };
108
+
109
+ return new Intl.DateTimeFormat(navigator.languages as string[], opts);
110
+ }
111
+
112
+ const opts: Intl.DateTimeFormatOptions = {
113
+ timeZone: cfg.timeZone,
114
+ hour12: cfg.hour12 ?? true,
115
+ fractionalSecondDigits: cfg.fractionalSecondDigits,
116
+ };
117
+ if (cfg.year !== "disabled") {
118
+ opts.year = cfg.year ?? "2-digit";
119
+ }
120
+ if (cfg.month !== "disabled") {
121
+ opts.month = cfg.month ?? "numeric";
122
+ }
123
+ if (cfg.day !== "disabled") {
124
+ opts.day = cfg.day ?? "numeric";
125
+ }
126
+ if (cfg.weekday && cfg.weekday !== "disabled") {
127
+ opts.weekday = cfg.weekday;
128
+ }
129
+ if (cfg.hour !== "disabled") {
130
+ opts.hour = cfg.hour ?? "numeric";
131
+ }
132
+ if (cfg.minute !== "disabled") {
133
+ opts.minute = cfg.minute ?? "numeric";
134
+ }
135
+ if (cfg.second !== "disabled") {
136
+ opts.second = cfg.second ?? "numeric";
137
+ }
138
+ return new Intl.DateTimeFormat(navigator.languages as string[], opts);
139
+ }
140
+
141
+ export function createDateFormatter(
142
+ cfg?: DateFormatConfig,
143
+ ): Intl.DateTimeFormat {
144
+ const opts: Intl.DateTimeFormatOptions = {
145
+ timeZone: "utc",
146
+ dateStyle:
147
+ cfg?.dateStyle === "disabled"
148
+ ? undefined
149
+ : (cfg?.dateStyle ?? DATE_LEGACY_DEFAULTS.dateStyle),
150
+ };
151
+ return new Intl.DateTimeFormat(navigator.languages as string[], opts);
152
+ }
153
+
154
+ /**
155
+ * Recover the source column name from a synthetic split-by path. Split
156
+ * pivoting produces paths of the form `<split_val_1>|...|<source_col>`;
157
+ * per-column config (formatters, aggregate styling, …) is always keyed
158
+ * on the trailing source column.
159
+ */
160
+ export function sourceColumn(path: string): string {
161
+ return path.split("|").at(-1) ?? path;
162
+ }
@@ -178,6 +178,10 @@ export interface PerspectiveViewerElementExt {
178
178
  */
179
179
  registerPlugin(name: string): Promise<void>;
180
180
 
181
+ get_wasm_module(): WebAssembly.Module;
182
+
183
+ get_worker_url(): URL;
184
+
181
185
  addEventListener(
182
186
  name: "perspective-click",
183
187
  cb: (e: CustomEvent) => void,
@@ -34,14 +34,22 @@
34
34
  export { IPerspectiveViewerPlugin } from "./plugin";
35
35
  export { HTMLPerspectiveViewerPluginElement } from "./plugin";
36
36
 
37
+ export {
38
+ createNumberFormatter,
39
+ createDatetimeFormatter,
40
+ createDateFormatter,
41
+ sourceColumn,
42
+ } from "./column-format";
43
+ export type { NumberFormatConfig, DateFormatConfig } from "./column-format";
44
+
37
45
  export type * from "./extensions.ts";
38
46
  export { PerspectiveSelectDetail } from "./extensions.ts";
39
47
  export type * from "./ts-rs/ViewerConfigUpdate.d.ts";
40
48
  export type * from "./ts-rs/ViewerConfig.d.ts";
41
- export type * from "./ts-rs/ColumnConfigValues.d.ts";
42
49
  export type * from "./ts-rs/Filter.d.ts";
43
50
  export type * from "./ts-rs/FilterTerm.d.ts";
44
51
  export type * from "./ts-rs/FilterReducer.d.ts";
52
+ export type * from "./ts-rs/PluginStaticConfig.ts";
45
53
 
46
54
  export { init_client } from "./bootstrap";
47
55
  import { init_client } from "./bootstrap";
@@ -10,25 +10,5 @@
10
10
  // ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃
11
11
  // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
12
 
13
- use yew::{Html, Properties, function_component, html};
14
-
15
- #[derive(Properties, PartialEq)]
16
- pub struct StubProps {
17
- pub error: Option<String>,
18
- pub message: String,
19
- }
20
-
21
- #[function_component(Stub)]
22
- pub fn stub(p: &StubProps) -> Html {
23
- if let Some(error) = p.error.clone() {
24
- tracing::error!("Rendered stub: {error}");
25
- }
26
-
27
- html! {
28
- <div class="style_contents">
29
- <div id="column-style-container" class="no-style">
30
- <div class="style-contents">{ p.message.clone() }</div>
31
- </div>
32
- </div>
33
- }
34
- }
13
+ export * from "../../dist/wasm/perspective-viewer.js";
14
+ export { default } from "../../dist/wasm/perspective-viewer.js";
package/src/ts/plugin.ts CHANGED
@@ -11,8 +11,7 @@
11
11
  // ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
12
12
 
13
13
  import type { View } from "@perspective-dev/client";
14
-
15
- // import type * as perspective from "@perspective-dev/client";
14
+ import { PluginStaticConfig } from "./ts-rs/PluginStaticConfig.js";
16
15
 
17
16
  /**
18
17
  * The `IPerspectiveViewerPlugin` interface defines the necessary API for a
@@ -21,7 +20,8 @@ import type { View } from "@perspective-dev/client";
21
20
  * scratch however, the simplest way is to inherit from
22
21
  * `<perspective-viewer-plugin>`, which implements `IPerspectiveViewerPlugin`
23
22
  * with non-offensive default implementations, where only the `draw()` and
24
- * `name()` methods need be overridden to get started with a simple plugin.
23
+ * `get_static_config()` methods need be overridden to get started with a
24
+ * simple plugin.
25
25
  *
26
26
  * Note that plugins are frozen once a `<perspective-viewer>` has been
27
27
  * instantiated, so generally new plugin code must be executed at the module
@@ -32,8 +32,8 @@ import type { View } from "@perspective-dev/client";
32
32
  * ```javascript
33
33
  * const BasePlugin = customElements.get("perspective-viewer-plugin");
34
34
  * class MyPlugin extends BasePlugin {
35
- * get name() {
36
- * return "My Plugin";
35
+ * get_static_config() {
36
+ * return { name: "My Plugin", config_column_names: [] };
37
37
  * }
38
38
  * async draw(view) {
39
39
  * const count = await view.num_rows();
@@ -49,63 +49,17 @@ import type { View } from "@perspective-dev/client";
49
49
  */
50
50
  export interface IPerspectiveViewerPlugin {
51
51
  /**
52
- * The name for this plugin, which is used as both it's unique key for use
53
- * as a parameter for the `plugin` field of a `ViewerConfig`, and as the
54
- * display name for this plugin in the `<perspective-viewer>` UI.
55
- */
56
- get name(): string;
57
-
58
- /**
59
- * Select mode determines how column add/remove buttons behave for this
60
- * plugin. `"select"` mode exclusively selects the added column, removing
61
- * other columns. `"toggle"` mode toggles the column on or off (dependent
62
- * on column state), leaving existing columns alone.
63
- */
64
- get select_mode(): string | undefined;
65
-
66
- /**
67
- * The minimum number of columns required for this plugin to operate.
68
- * This mostly affects drag/drop and column remove button behavior,
69
- * preventing the use from applying configs which violate this min.
70
- *
71
- * While this option can technically be `undefined` (as in the case of
72
- * `@perspective-dev/viewer-datagrid`), doing so currently has nearly
73
- * identical behavior to 1.
74
- */
75
- get min_config_columns(): number | undefined;
76
-
77
- /**
78
- * The named column labels, if desired. Named columns behave differently
79
- * in drag/drop mode than unnamed columns, having replace/swap behavior
80
- * rather than insert. If provided, the length of `config_column_names`
81
- * _must_ be `>= min_config_columns`, as this is assumed by the drag/drop
82
- * logic.
83
- */
84
- get config_column_names(): string[] | undefined;
85
-
86
- /**
87
- * The load priority of the plugin. If the plugin shares priority with another,
88
- * the first to load has a higher priority.
89
- *
90
- * A larger number has a higher priority.
91
- *
92
- * The plugin with the highest priority will be loaded by default by the Perspective viewer.
93
- * If you would like to instead begin with a lower priority plugin, choose it explicitly with
94
- * a `HTMLPerspectiveViewerPluginElement.restore` call.
95
- */
96
- get priority(): number | undefined;
97
-
98
- /**
99
- * Given a column's grouping (determined by indexing it in `plugin.config_column_names`)
100
- * and its view type, determines whether or not to render column styles in the settings sidebar.
101
- * Implementing this function and `column_style_config` allows the plugin to interface with the viewer's column configuration API.
52
+ * Static plugin configuration. Called exactly once per plugin at
53
+ * registration time and cached; the result must be stable for the
54
+ * lifetime of the application.
102
55
  */
103
- can_render_column_styles?: (view_type: string, group: string) => boolean;
56
+ get_static_config(): PluginStaticConfig;
104
57
 
105
58
  /**
106
59
  * Determines which column configuration controls are populated in the viewer.
107
- * Corresponds to the data the plugin will recieve on save.
108
- * Implementing this function and `can_render_column_styles` allows the plugin to interface with the viewer's column configuration API.
60
+ * Corresponds to the data the plugin will recieve on save. Only
61
+ * invoked when `can_render_column_styles` is `true` in the static
62
+ * config.
109
63
  */
110
64
  column_style_config?: (view_type: string, group: string) => any;
111
65
 
@@ -163,20 +117,7 @@ export interface IPerspectiveViewerPlugin {
163
117
  * Notify the plugin that the style environment has changed. Useful for
164
118
  * plugins which read CSS styles via `window.getComputedStyle()`.
165
119
  */
166
- restyle(view: View): Promise<void>;
167
-
168
- /**
169
- * Save this plugin's state to a JSON-serializable value. While this value
170
- * can be anything, it should work reciprocally with `restore()` to return
171
- * this plugin's renderer to the same state, though potentially with a
172
- * different `View`.
173
- *
174
- * `save()` should be used for user-persistent settings that are
175
- * data-agnostic, so the user can have persistent view during refresh or
176
- * reload. For example, `@perspective-dev/viewer-d3fc` uses
177
- * `plugin_config` to remember the user-repositionable legend coordinates.
178
- */
179
- save(): any;
120
+ restyle(): void;
180
121
 
181
122
  /**
182
123
  * Restore this plugin to a state previously returned by `save()`.
@@ -213,33 +154,16 @@ export class HTMLPerspectiveViewerPluginElement
213
154
  super();
214
155
  }
215
156
 
216
- get name(): string {
217
- return "Debug";
218
- }
219
-
220
- get select_mode(): "select" | "toggle" {
221
- return "select";
222
- }
223
-
224
- get min_config_columns(): number | undefined {
225
- return undefined;
226
- }
227
-
228
- get config_column_names(): string[] | undefined {
229
- return undefined;
230
- }
231
-
232
- get priority(): number {
233
- return 0;
234
- }
235
-
236
- can_render_column_styles(): boolean {
237
- return false;
157
+ get_static_config(): PluginStaticConfig {
158
+ return {
159
+ name: "Debug",
160
+ select_mode: "select",
161
+ config_column_names: [],
162
+ };
238
163
  }
239
164
 
240
165
  column_style_config(): any {
241
- {
242
- }
166
+ return {};
243
167
  }
244
168
 
245
169
  async update(view: View): Promise<void> {
@@ -261,11 +185,7 @@ export class HTMLPerspectiveViewerPluginElement
261
185
  // Not Implemented
262
186
  }
263
187
 
264
- async restyle(view: View): Promise<void> {
265
- // Not Implemented
266
- }
267
-
268
- save(): any {
188
+ restyle() {
269
189
  // Not Implemented
270
190
  }
271
191
 
@@ -276,4 +196,8 @@ export class HTMLPerspectiveViewerPluginElement
276
196
  async delete(): Promise<void> {
277
197
  // Not Implemented
278
198
  }
199
+
200
+ get supports_streaming(): boolean {
201
+ return false;
202
+ }
279
203
  }
@@ -1,3 +1,3 @@
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
- export type FormatUnit = "custom";
3
+ export type ColumnSelectMode = "toggle" | "select";
@@ -0,0 +1,78 @@
1
+ // This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
2
+ import type { ColumnSelectMode } from "./ColumnSelectMode.js";
3
+ import type { GroupRollupMode } from "./GroupRollupMode.js";
4
+
5
+ /**
6
+ * Static, immutable configuration for a plugin.
7
+ *
8
+ * Returned once per plugin from `get_static_config()` at registration
9
+ * time and cached in [`crate::renderer::PluginRecord`]. Consumers
10
+ * (renderer, session, queries, components) read these fields off the
11
+ * renderer's active-plugin metadata rather than calling back into JS.
12
+ *
13
+ * `<perspective-viewer>` reads this exactly once per plugin (at
14
+ * `registerPlugin` time) and caches it for the lifetime of the
15
+ * application. The result must be stable; do not mutate any field
16
+ * after registration.
17
+ */
18
+ export type PluginStaticConfig = {
19
+ /**
20
+ * The unique key for this plugin. Used as the `plugin` field in a
21
+ * `ViewerConfig` and as the display name key in the
22
+ * `<perspective-viewer>` UI.
23
+ */
24
+ name: string,
25
+ /**
26
+ * Category in the plugin picker menu.
27
+ */
28
+ category?: string | null,
29
+ /**
30
+ * Soft limit on the number of columns the plugin will render.
31
+ * Triggers the "Rendering N of M" warning when the view exceeds
32
+ * this value (until dismissed).
33
+ */
34
+ max_columns?: number | null,
35
+ /**
36
+ * Soft limit on the number of cells (rows × columns) the plugin
37
+ * will render. Triggers the "Rendering N of M" warning when the view
38
+ * exceeds this value (until dismissed).
39
+ */
40
+ max_cells?: number | null,
41
+ /**
42
+ * Column add/remove behavior. `"select"` exclusively selects the
43
+ * added column, removing other columns. `"toggle"` toggles the
44
+ * column on or off based on its current state, leaving other
45
+ * columns alone.
46
+ */
47
+ select_mode?: ColumnSelectMode,
48
+ /**
49
+ * Minimum number of columns the plugin requires to render. Mostly
50
+ * affects drag/drop and column-remove button behavior. `undefined`
51
+ * is treated identically to `1`.
52
+ */
53
+ min_config_columns?: number | null,
54
+ /**
55
+ * Named column slots. Named columns have replace/swap behavior in
56
+ * drag/drop rather than insert. The length must be at least
57
+ * `min_config_columns`.
58
+ */
59
+ config_column_names?: Array<string>,
60
+ /**
61
+ * Group-rollup modes the plugin accepts, in preference order.
62
+ * The first entry that matches a feature flag becomes the default.
63
+ */
64
+ group_rollup_modes?: Array<GroupRollupMode> | null,
65
+ /**
66
+ * Plugin load priority. Higher numbers win; ties resolve in
67
+ * registration order. The highest-priority plugin is loaded by
68
+ * default unless `restore({ plugin })` overrides it.
69
+ */
70
+ priority?: number | null,
71
+ /**
72
+ * Whether this plugin opts into per-column style controls in the
73
+ * settings sidebar. When `true`, the StyleTab is shown for active
74
+ * columns and the plugin's `column_config_schema` is queried for
75
+ * the per-column field set. When `false` or omitted, no StyleTab
76
+ * is shown.
77
+ */
78
+ can_render_column_styles?: boolean, };