@perspective-dev/viewer 4.0.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.
- package/LICENSE.md +193 -0
- package/README.md +4 -0
- package/dist/cdn/perspective-viewer.js +3 -0
- package/dist/cdn/perspective-viewer.js.map +7 -0
- package/dist/css/dracula.css +1 -0
- package/dist/css/gruvbox-dark.css +1 -0
- package/dist/css/gruvbox.css +1 -0
- package/dist/css/icons.css +1 -0
- package/dist/css/intl/de.css +1 -0
- package/dist/css/intl/es.css +1 -0
- package/dist/css/intl/fr.css +1 -0
- package/dist/css/intl/ja.css +1 -0
- package/dist/css/intl/pt.css +1 -0
- package/dist/css/intl/zh.css +1 -0
- package/dist/css/intl.css +1 -0
- package/dist/css/monokai.css +1 -0
- package/dist/css/pro-dark.css +1 -0
- package/dist/css/pro.css +1 -0
- package/dist/css/solarized-dark.css +1 -0
- package/dist/css/solarized.css +1 -0
- package/dist/css/themes.css +1 -0
- package/dist/css/vaporwave.css +1 -0
- package/dist/css/variables.css +0 -0
- package/dist/esm/bootstrap.d.ts +1 -0
- package/dist/esm/extensions.d.ts +70 -0
- package/dist/esm/perspective-viewer.d.ts +39 -0
- package/dist/esm/perspective-viewer.inline.js +3 -0
- package/dist/esm/perspective-viewer.inline.js.map +7 -0
- package/dist/esm/perspective-viewer.js +3 -0
- package/dist/esm/perspective-viewer.js.map +7 -0
- package/dist/esm/plugin.d.ts +195 -0
- package/dist/esm/ts-rs/Aggregate.d.ts +1 -0
- package/dist/esm/ts-rs/ColumnConfigValues.d.ts +31 -0
- package/dist/esm/ts-rs/CustomDatetimeFormat.d.ts +1 -0
- package/dist/esm/ts-rs/CustomDatetimeStyleConfig.d.ts +15 -0
- package/dist/esm/ts-rs/CustomNumberFormatConfig.d.ts +18 -0
- package/dist/esm/ts-rs/DatetimeColorMode.d.ts +1 -0
- package/dist/esm/ts-rs/DatetimeFormatType.d.ts +6 -0
- package/dist/esm/ts-rs/Expressions.d.ts +3 -0
- package/dist/esm/ts-rs/Filter.d.ts +2 -0
- package/dist/esm/ts-rs/FilterReducer.d.ts +1 -0
- package/dist/esm/ts-rs/FilterTerm.d.ts +2 -0
- package/dist/esm/ts-rs/FormatMode.d.ts +1 -0
- package/dist/esm/ts-rs/FormatUnit.d.ts +1 -0
- package/dist/esm/ts-rs/NumberBackgroundMode.d.ts +1 -0
- package/dist/esm/ts-rs/NumberForegroundMode.d.ts +1 -0
- package/dist/esm/ts-rs/OptionalUpdate.d.ts +1 -0
- package/dist/esm/ts-rs/PluginConfig.d.ts +2 -0
- package/dist/esm/ts-rs/RoundingMode.d.ts +1 -0
- package/dist/esm/ts-rs/RoundingPriority.d.ts +1 -0
- package/dist/esm/ts-rs/Scalar.d.ts +5 -0
- package/dist/esm/ts-rs/SignDisplay.d.ts +1 -0
- package/dist/esm/ts-rs/SimpleDatetimeFormat.d.ts +1 -0
- package/dist/esm/ts-rs/SimpleDatetimeStyleConfig.d.ts +6 -0
- package/dist/esm/ts-rs/Sort.d.ts +2 -0
- package/dist/esm/ts-rs/SortDir.d.ts +1 -0
- package/dist/esm/ts-rs/StringColorMode.d.ts +1 -0
- package/dist/esm/ts-rs/TrailingZeroDisplay.d.ts +1 -0
- package/dist/esm/ts-rs/UseGrouping.d.ts +1 -0
- package/dist/esm/ts-rs/ViewerConfigUpdate.d.ts +102 -0
- package/dist/esm/ts-rs/serde_json/JsonValue.d.ts +3 -0
- package/dist/wasm/perspective-viewer.d.ts +1291 -0
- package/dist/wasm/perspective-viewer.js +3883 -0
- package/dist/wasm/perspective-viewer.wasm +0 -0
- package/dist/wasm/perspective-viewer.wasm.d.ts +142 -0
- package/dist/wasm/snippets/perspective-viewer-c69283f6f62a5f14/inline0.js +1 -0
- package/dist/wasm/snippets/perspective-viewer-c69283f6f62a5f14/inline1.js +1 -0
- package/dist/wasm/snippets/perspective-viewer-c69283f6f62a5f14/inline2.js +1 -0
- package/dist/wasm/snippets/perspective-viewer-c69283f6f62a5f14/inline3.js +44 -0
- package/dist/wasm/snippets/perspective-viewer-c69283f6f62a5f14/inline4.js +1 -0
- package/package.json +55 -0
- package/src/less/aggregate-selector.less +72 -0
- package/src/less/column-dropdown.less +95 -0
- package/src/less/column-selector.less +551 -0
- package/src/less/column-settings-panel.less +255 -0
- package/src/less/column-style.less +319 -0
- package/src/less/column-symbol-attributes.less +73 -0
- package/src/less/config-selector.less +363 -0
- package/src/less/containers/dropdown-menu.less +94 -0
- package/src/less/containers/pairs-list.less +46 -0
- package/src/less/containers/radio-list.less +29 -0
- package/src/less/containers/scroll-panel.less +27 -0
- package/src/less/containers/split-panel.less +80 -0
- package/src/less/containers/tabs.less +90 -0
- package/src/less/dom/checkbox.less +100 -0
- package/src/less/dom/scrollbar.less +35 -0
- package/src/less/dom/select.less +63 -0
- package/src/less/empty-column.less +72 -0
- package/src/less/expression-editor.less +152 -0
- package/src/less/filter-dropdown.less +53 -0
- package/src/less/filter-item.less +126 -0
- package/src/less/form/code-editor.less +137 -0
- package/src/less/form/debug.less +88 -0
- package/src/less/function-dropdown.less +45 -0
- package/src/less/plugin-selector.less +173 -0
- package/src/less/render-warning.less +81 -0
- package/src/less/status-bar.less +551 -0
- package/src/less/type-icon.less +68 -0
- package/src/less/viewer.less +368 -0
- package/src/rust/components/column_dropdown.rs +162 -0
- package/src/rust/components/column_selector/active_column.rs +462 -0
- package/src/rust/components/column_selector/add_expression_button.rs +59 -0
- package/src/rust/components/column_selector/aggregate_selector.rs +186 -0
- package/src/rust/components/column_selector/config_selector.rs +674 -0
- package/src/rust/components/column_selector/empty_column.rs +134 -0
- package/src/rust/components/column_selector/expression_toolbar.rs +45 -0
- package/src/rust/components/column_selector/filter_column.rs +530 -0
- package/src/rust/components/column_selector/inactive_column.rs +221 -0
- package/src/rust/components/column_selector/invalid_column.rs +37 -0
- package/src/rust/components/column_selector/pivot_column.rs +93 -0
- package/src/rust/components/column_selector/sort_column.rs +135 -0
- package/src/rust/components/column_selector.rs +426 -0
- package/src/rust/components/column_settings_sidebar/attributes_tab.rs +34 -0
- package/src/rust/components/column_settings_sidebar/mod.rs +17 -0
- package/src/rust/components/column_settings_sidebar/save_settings.rs +68 -0
- package/src/rust/components/column_settings_sidebar/sidebar.rs +396 -0
- package/src/rust/components/column_settings_sidebar/style_tab/column_style.rs +177 -0
- package/src/rust/components/column_settings_sidebar/style_tab/stub.rs +34 -0
- package/src/rust/components/column_settings_sidebar/style_tab/symbol/row_selector.rs +101 -0
- package/src/rust/components/column_settings_sidebar/style_tab/symbol/symbol_config.rs +24 -0
- package/src/rust/components/column_settings_sidebar/style_tab/symbol/symbol_pairs.rs +185 -0
- package/src/rust/components/column_settings_sidebar/style_tab/symbol/symbol_selector.rs +55 -0
- package/src/rust/components/column_settings_sidebar/style_tab/symbol.rs +131 -0
- package/src/rust/components/column_settings_sidebar/style_tab.rs +231 -0
- package/src/rust/components/containers/dragdrop_list.rs +325 -0
- package/src/rust/components/containers/dropdown_menu.rs +104 -0
- package/src/rust/components/containers/kvpair.rs +47 -0
- package/src/rust/components/containers/mod.rs +28 -0
- package/src/rust/components/containers/scroll_panel.rs +311 -0
- package/src/rust/components/containers/scroll_panel_item.rs +111 -0
- package/src/rust/components/containers/select.rs +269 -0
- package/src/rust/components/containers/sidebar.rs +89 -0
- package/src/rust/components/containers/split_panel.rs +483 -0
- package/src/rust/components/containers/tab_list.rs +104 -0
- package/src/rust/components/containers/tests/mod.rs +11 -0
- package/src/rust/components/containers/tests/split_panel.rs +91 -0
- package/src/rust/components/containers/trap_door_panel.rs +50 -0
- package/src/rust/components/copy_dropdown.rs +136 -0
- package/src/rust/components/datetime_column_style/custom.rs +222 -0
- package/src/rust/components/datetime_column_style/simple.rs +122 -0
- package/src/rust/components/datetime_column_style.rs +284 -0
- package/src/rust/components/editable_header.rs +183 -0
- package/src/rust/components/empty_row.rs +169 -0
- package/src/rust/components/error_message.rs +56 -0
- package/src/rust/components/export_dropdown.rs +153 -0
- package/src/rust/components/expression_editor.rs +153 -0
- package/src/rust/components/filter_dropdown.rs +144 -0
- package/src/rust/components/font_loader.rs +254 -0
- package/src/rust/components/form/code_editor.rs +286 -0
- package/src/rust/components/form/color_range_selector.rs +115 -0
- package/src/rust/components/form/color_selector.rs +54 -0
- package/src/rust/components/form/debug.rs +253 -0
- package/src/rust/components/form/highlight.rs +50 -0
- package/src/rust/components/form/mod.rs +29 -0
- package/src/rust/components/form/number_field.rs +72 -0
- package/src/rust/components/form/number_input.rs +45 -0
- package/src/rust/components/form/number_range_field.rs +77 -0
- package/src/rust/components/form/optional_field.rs +53 -0
- package/src/rust/components/form/select_field.rs +104 -0
- package/src/rust/components/function_dropdown.rs +151 -0
- package/src/rust/components/mod.rs +45 -0
- package/src/rust/components/modal.rs +171 -0
- package/src/rust/components/number_column_style.rs +522 -0
- package/src/rust/components/plugin_selector.rs +196 -0
- package/src/rust/components/render_warning.rs +178 -0
- package/src/rust/components/status_bar.rs +315 -0
- package/src/rust/components/status_bar_counter.rs +229 -0
- package/src/rust/components/status_indicator.rs +164 -0
- package/src/rust/components/string_column_style.rs +186 -0
- package/src/rust/components/style/local_style.rs +35 -0
- package/src/rust/components/style/mod.rs +52 -0
- package/src/rust/components/style/style_cache.rs +132 -0
- package/src/rust/components/style/style_provider.rs +65 -0
- package/src/rust/components/style_controls/number_string_format/digits_section.rs +140 -0
- package/src/rust/components/style_controls/number_string_format/misc_section.rs +56 -0
- package/src/rust/components/style_controls/number_string_format/style_section.rs +69 -0
- package/src/rust/components/style_controls/number_string_format/types.rs +31 -0
- package/src/rust/components/style_controls/number_string_format.rs +259 -0
- package/src/rust/components/style_controls.rs +15 -0
- package/src/rust/components/type_icon.rs +53 -0
- package/src/rust/components/viewer.rs +668 -0
- package/src/rust/config/columns_config.rs +132 -0
- package/src/rust/config/datetime_column_style/color_mode.rs +62 -0
- package/src/rust/config/datetime_column_style/custom.rs +121 -0
- package/src/rust/config/datetime_column_style/custom_format.rs +90 -0
- package/src/rust/config/datetime_column_style/simple.rs +55 -0
- package/src/rust/config/datetime_column_style/simple_format.rs +86 -0
- package/src/rust/config/datetime_column_style.rs +104 -0
- package/src/rust/config/mod.rs +30 -0
- package/src/rust/config/number_column_style.rs +138 -0
- package/src/rust/config/number_string_format/enums.rs +298 -0
- package/src/rust/config/number_string_format.rs +269 -0
- package/src/rust/config/string_column_style.rs +140 -0
- package/src/rust/config/view_config.rs +24 -0
- package/src/rust/config/viewer_config.rs +337 -0
- package/src/rust/custom_elements/column_dropdown.rs +123 -0
- package/src/rust/custom_elements/copy_dropdown.rs +112 -0
- package/src/rust/custom_elements/debug_plugin.rs +114 -0
- package/src/rust/custom_elements/export_dropdown.rs +112 -0
- package/src/rust/custom_elements/filter_dropdown.rs +179 -0
- package/src/rust/custom_elements/function_dropdown.rs +115 -0
- package/src/rust/custom_elements/mod.rs +24 -0
- package/src/rust/custom_elements/modal.rs +395 -0
- package/src/rust/custom_elements/viewer.rs +880 -0
- package/src/rust/custom_events.rs +214 -0
- package/src/rust/dragdrop.rs +362 -0
- package/src/rust/exprtk/cursor.rs +81 -0
- package/src/rust/exprtk/mod.rs +17 -0
- package/src/rust/exprtk/tokenize/comment.rs +21 -0
- package/src/rust/exprtk/tokenize/number.rs +44 -0
- package/src/rust/exprtk/tokenize/string.rs +98 -0
- package/src/rust/exprtk/tokenize/symbol.rs +26 -0
- package/src/rust/exprtk/tokenize.rs +190 -0
- package/src/rust/js/clipboard.rs +77 -0
- package/src/rust/js/clipboard_item.rs +21 -0
- package/src/rust/js/intersection_observer.rs +32 -0
- package/src/rust/js/mimetype.rs +42 -0
- package/src/rust/js/mod.rs +29 -0
- package/src/rust/js/plugin.rs +167 -0
- package/src/rust/js/resize_observer.rs +37 -0
- package/src/rust/js/testing.rs +149 -0
- package/src/rust/lib.rs +116 -0
- package/src/rust/model/columns_iter_set.rs +340 -0
- package/src/rust/model/copy_export.rs +157 -0
- package/src/rust/model/create_col.rs +59 -0
- package/src/rust/model/edit_expression.rs +95 -0
- package/src/rust/model/export_app.rs +58 -0
- package/src/rust/model/export_method.rs +151 -0
- package/src/rust/model/get_viewer_config.rs +85 -0
- package/src/rust/model/intersection_observer.rs +81 -0
- package/src/rust/model/is_invalid_drop.rs +36 -0
- package/src/rust/model/mod.rs +93 -0
- package/src/rust/model/plugin_column_styles.rs +106 -0
- package/src/rust/model/resize_observer.rs +98 -0
- package/src/rust/model/restore_and_render.rs +113 -0
- package/src/rust/model/structural.rs +73 -0
- package/src/rust/model/update_and_render.rs +74 -0
- package/src/rust/presentation.rs +370 -0
- package/src/rust/renderer/activate.rs +49 -0
- package/src/rust/renderer/limits.rs +200 -0
- package/src/rust/renderer/plugin_store.rs +45 -0
- package/src/rust/renderer/registry.rs +135 -0
- package/src/rust/renderer/render_timer.rs +185 -0
- package/src/rust/renderer.rs +463 -0
- package/src/rust/session/column_defaults_update.rs +141 -0
- package/src/rust/session/drag_drop_update.rs +179 -0
- package/src/rust/session/metadata.rs +308 -0
- package/src/rust/session/replace_expression_update.rs +131 -0
- package/src/rust/session/view_subscription.rs +189 -0
- package/src/rust/session.rs +794 -0
- package/src/rust/utils/browser/blob.rs +49 -0
- package/src/rust/utils/browser/download.rs +26 -0
- package/src/rust/utils/browser/mod.rs +24 -0
- package/src/rust/utils/browser/request_animation_frame.rs +76 -0
- package/src/rust/utils/browser/selection.rs +79 -0
- package/src/rust/utils/browser/tests/debounce.rs +114 -0
- package/src/rust/utils/browser/tests/mod.rs +13 -0
- package/src/rust/utils/custom_element.rs +85 -0
- package/src/rust/utils/datetime.rs +49 -0
- package/src/rust/utils/debounce.rs +54 -0
- package/src/rust/utils/hooks/mod.rs +15 -0
- package/src/rust/utils/hooks/use_async_callback.rs +53 -0
- package/src/rust/utils/mod.rs +114 -0
- package/src/rust/utils/number_format.rs +48 -0
- package/src/rust/utils/pubsub.rs +222 -0
- package/src/rust/utils/scope.rs +54 -0
- package/src/rust/utils/tee.rs +88 -0
- package/src/rust/utils/tests/mod.rs +14 -0
- package/src/rust/utils/tests/pubsub.rs +95 -0
- package/src/rust/utils/tests/request_animation_frame.rs +42 -0
- package/src/rust/utils/wasm_abi.rs +61 -0
- package/src/rust/utils/weak_scope.rs +39 -0
- package/src/svg/align-scroll-icon.svg +7 -0
- package/src/svg/bg-pattern.png +0 -0
- package/src/svg/boolean-type.svg +3 -0
- package/src/svg/checkbox-checked-icon.svg +7 -0
- package/src/svg/checkbox-hover.svg +4 -0
- package/src/svg/checkbox-off.svg +4 -0
- package/src/svg/checkbox-on.svg +4 -0
- package/src/svg/checkbox-unchecked-icon.svg +3 -0
- package/src/svg/close-icon.svg +6 -0
- package/src/svg/column-settings-icon.svg +6 -0
- package/src/svg/datagrid-select-column.svg +15 -0
- package/src/svg/datagrid-select-region.svg +15 -0
- package/src/svg/datagrid-select-row.svg +13 -0
- package/src/svg/datagrid.svg +13 -0
- package/src/svg/date-type.svg +23 -0
- package/src/svg/downloading.gif +0 -0
- package/src/svg/drag-handle.svg +10 -0
- package/src/svg/drawer-bg-pattern-hidpi.png +0 -0
- package/src/svg/drawer-tab-hover.svg +8 -0
- package/src/svg/drawer-tab-invert-hover.svg +9 -0
- package/src/svg/drawer-tab-invert.svg +8 -0
- package/src/svg/drawer-tab.svg +7 -0
- package/src/svg/dropdown-selector-light.svg +3 -0
- package/src/svg/dropdown-selector.svg +3 -0
- package/src/svg/duplicate-icon.svg +4 -0
- package/src/svg/editable-icon.svg +5 -0
- package/src/svg/export-icon.svg +4 -0
- package/src/svg/expression.svg +10 -0
- package/src/svg/free-scroll-icon.svg +5 -0
- package/src/svg/inactive-mouseover.svg +4 -0
- package/src/svg/mega-menu-icons-candlestick.svg +38 -0
- package/src/svg/mega-menu-icons-datagrid.svg +38 -0
- package/src/svg/mega-menu-icons-heatmap.svg +60 -0
- package/src/svg/mega-menu-icons-map-scatter.svg +43 -0
- package/src/svg/mega-menu-icons-ohlc.svg +40 -0
- package/src/svg/mega-menu-icons-sunburst.svg +39 -0
- package/src/svg/mega-menu-icons-treemap.svg +44 -0
- package/src/svg/mega-menu-icons-x-bar.svg +36 -0
- package/src/svg/mega-menu-icons-x-y-line.svg +38 -0
- package/src/svg/mega-menu-icons-x-y-scatter.svg +72 -0
- package/src/svg/mega-menu-icons-y-area.svg +73 -0
- package/src/svg/mega-menu-icons-y-bar.svg +36 -0
- package/src/svg/mega-menu-icons-y-line.svg +36 -0
- package/src/svg/mega-menu-icons-y-scatter.svg +72 -0
- package/src/svg/number-type.svg +4 -0
- package/src/svg/radio-hover.svg +4 -0
- package/src/svg/radio-off.svg +3 -0
- package/src/svg/radio-on.svg +4 -0
- package/src/svg/read-only-icon.svg +6 -0
- package/src/svg/revert-icon.svg +4 -0
- package/src/svg/sort-abs-asc-icon.svg +3 -0
- package/src/svg/sort-abs-col-asc-icon.svg +3 -0
- package/src/svg/sort-abs-col-desc-icon.svg +3 -0
- package/src/svg/sort-abs-desc-icon.svg +3 -0
- package/src/svg/sort-asc-icon.svg +4 -0
- package/src/svg/sort-col-asc-icon.svg +4 -0
- package/src/svg/sort-col-desc-icon.svg +4 -0
- package/src/svg/sort-desc-icon.svg +4 -0
- package/src/svg/sort-none-icon.svg +3 -0
- package/src/svg/status_error.svg +70 -0
- package/src/svg/status_ok.svg +26 -0
- package/src/svg/string-type.svg +8 -0
- package/src/svg/theme-icon.svg +5 -0
- package/src/svg/updating.gif +0 -0
- package/src/themes/dracula.less +101 -0
- package/src/themes/gruvbox-dark.less +116 -0
- package/src/themes/gruvbox.less +152 -0
- package/src/themes/icons.less +130 -0
- package/src/themes/intl/de.less +102 -0
- package/src/themes/intl/es.less +102 -0
- package/src/themes/intl/fr.less +102 -0
- package/src/themes/intl/ja.less +102 -0
- package/src/themes/intl/pt.less +102 -0
- package/src/themes/intl/zh.less +102 -0
- package/src/themes/intl.less +102 -0
- package/src/themes/monokai.less +107 -0
- package/src/themes/pro-dark.less +147 -0
- package/src/themes/pro.less +186 -0
- package/src/themes/solarized-dark.less +78 -0
- package/src/themes/solarized.less +102 -0
- package/src/themes/themes.less +21 -0
- package/src/themes/vaporwave.less +145 -0
- package/src/themes/variables.less +24 -0
- package/src/ts/bootstrap.ts +26 -0
- package/src/ts/extensions.ts +124 -0
- package/src/ts/perspective-viewer.cdn.ts +19 -0
- package/src/ts/perspective-viewer.inline.ts +23 -0
- package/src/ts/perspective-viewer.ts +59 -0
- package/src/ts/plugin.ts +279 -0
- package/src/ts/ts-rs/Aggregate.ts +3 -0
- package/src/ts/ts-rs/ColumnConfigValues.ts +14 -0
- package/src/ts/ts-rs/CustomDatetimeFormat.ts +3 -0
- package/src/ts/ts-rs/CustomDatetimeStyleConfig.ts +5 -0
- package/src/ts/ts-rs/CustomNumberFormatConfig.ts +8 -0
- package/src/ts/ts-rs/DatetimeColorMode.ts +3 -0
- package/src/ts/ts-rs/DatetimeFormatType.ts +8 -0
- package/src/ts/ts-rs/Expressions.ts +3 -0
- package/src/ts/ts-rs/Filter.ts +4 -0
- package/src/ts/ts-rs/FilterReducer.ts +3 -0
- package/src/ts/ts-rs/FilterTerm.ts +4 -0
- package/src/ts/ts-rs/FormatMode.ts +3 -0
- package/src/ts/ts-rs/FormatUnit.ts +3 -0
- package/src/ts/ts-rs/NumberBackgroundMode.ts +3 -0
- package/src/ts/ts-rs/NumberForegroundMode.ts +3 -0
- package/src/ts/ts-rs/OnUpdateData.ts +8 -0
- package/src/ts/ts-rs/OptionalUpdate.ts +3 -0
- package/src/ts/ts-rs/PluginConfig.ts +4 -0
- package/src/ts/ts-rs/RoundingMode.ts +3 -0
- package/src/ts/ts-rs/RoundingPriority.ts +3 -0
- package/src/ts/ts-rs/Scalar.ts +7 -0
- package/src/ts/ts-rs/SignDisplay.ts +3 -0
- package/src/ts/ts-rs/SimpleDatetimeFormat.ts +3 -0
- package/src/ts/ts-rs/SimpleDatetimeStyleConfig.ts +4 -0
- package/src/ts/ts-rs/Sort.ts +4 -0
- package/src/ts/ts-rs/SortDir.ts +3 -0
- package/src/ts/ts-rs/StringColorMode.ts +3 -0
- package/src/ts/ts-rs/TrailingZeroDisplay.ts +3 -0
- package/src/ts/ts-rs/UseGrouping.ts +3 -0
- package/src/ts/ts-rs/ViewOnUpdateResp.ts +3 -0
- package/src/ts/ts-rs/ViewerConfigUpdate.ts +90 -0
- package/src/ts/ts-rs/serde_json/JsonValue.ts +3 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,167 @@
|
|
|
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
|
+
use perspective_js::utils::*;
|
|
14
|
+
use serde::*;
|
|
15
|
+
use wasm_bindgen::prelude::*;
|
|
16
|
+
|
|
17
|
+
use crate::presentation::ColumnConfigMap;
|
|
18
|
+
|
|
19
|
+
/// Perspective FFI
|
|
20
|
+
#[wasm_bindgen]
|
|
21
|
+
#[rustfmt::skip]
|
|
22
|
+
extern "C" {
|
|
23
|
+
#[derive(Clone)]
|
|
24
|
+
pub type JsPerspectiveViewerPlugin;
|
|
25
|
+
|
|
26
|
+
#[wasm_bindgen(method, getter)]
|
|
27
|
+
pub fn name(this: &JsPerspectiveViewerPlugin) -> String;
|
|
28
|
+
|
|
29
|
+
#[wasm_bindgen(method, getter)]
|
|
30
|
+
pub fn category(this: &JsPerspectiveViewerPlugin) -> Option<String>;
|
|
31
|
+
|
|
32
|
+
#[wasm_bindgen(method, getter)]
|
|
33
|
+
pub fn max_columns(this: &JsPerspectiveViewerPlugin) -> Option<usize>;
|
|
34
|
+
|
|
35
|
+
#[wasm_bindgen(method, getter)]
|
|
36
|
+
pub fn max_cells(this: &JsPerspectiveViewerPlugin) -> Option<usize>;
|
|
37
|
+
|
|
38
|
+
// TODO This can be an internal property
|
|
39
|
+
#[wasm_bindgen(method, getter)]
|
|
40
|
+
pub fn render_warning(this: &JsPerspectiveViewerPlugin) -> Option<bool>;
|
|
41
|
+
|
|
42
|
+
#[wasm_bindgen(method, setter)]
|
|
43
|
+
pub fn set_render_warning(this: &JsPerspectiveViewerPlugin, val: bool);
|
|
44
|
+
|
|
45
|
+
#[wasm_bindgen(method, getter)]
|
|
46
|
+
pub fn select_mode(this: &JsPerspectiveViewerPlugin) -> JsValue;
|
|
47
|
+
|
|
48
|
+
#[wasm_bindgen(method, getter)]
|
|
49
|
+
pub fn min_config_columns(this: &JsPerspectiveViewerPlugin) -> Option<usize>;
|
|
50
|
+
|
|
51
|
+
#[wasm_bindgen(method, getter)]
|
|
52
|
+
pub fn config_column_names(this: &JsPerspectiveViewerPlugin) -> Option<js_sys::Array>;
|
|
53
|
+
|
|
54
|
+
#[wasm_bindgen(method, getter)]
|
|
55
|
+
pub fn priority(this: &JsPerspectiveViewerPlugin) -> Option<i32>;
|
|
56
|
+
|
|
57
|
+
/// Don't call this method directly. Instead, call the corresponding method on the PluginColumnStyles model.
|
|
58
|
+
#[wasm_bindgen(method, catch)]
|
|
59
|
+
pub fn can_render_column_styles(this: &JsPerspectiveViewerPlugin, view_type: &str, group: Option<&str>) -> ApiResult<bool>;
|
|
60
|
+
|
|
61
|
+
#[wasm_bindgen(method, catch)]
|
|
62
|
+
pub fn column_style_controls(this: &JsPerspectiveViewerPlugin, view_type: &str, group: Option<&str>) -> ApiResult<JsValue>;
|
|
63
|
+
|
|
64
|
+
#[wasm_bindgen(method, catch)]
|
|
65
|
+
pub fn save(this: &JsPerspectiveViewerPlugin) -> ApiResult<JsValue>;
|
|
66
|
+
|
|
67
|
+
#[wasm_bindgen(method, js_name=restore, catch)]
|
|
68
|
+
pub fn _restore(this: &JsPerspectiveViewerPlugin, token: &JsValue, columns_config: &JsValue) -> ApiResult<()>;
|
|
69
|
+
|
|
70
|
+
#[wasm_bindgen(method)]
|
|
71
|
+
pub fn delete(this: &JsPerspectiveViewerPlugin);
|
|
72
|
+
|
|
73
|
+
#[wasm_bindgen(method, catch)]
|
|
74
|
+
pub async fn restyle(
|
|
75
|
+
this: &JsPerspectiveViewerPlugin,
|
|
76
|
+
view: perspective_js::View
|
|
77
|
+
) -> ApiResult<JsValue>;
|
|
78
|
+
|
|
79
|
+
#[wasm_bindgen(method, catch)]
|
|
80
|
+
pub async fn draw(
|
|
81
|
+
this: &JsPerspectiveViewerPlugin,
|
|
82
|
+
view: perspective_js::View,
|
|
83
|
+
column_limit: Option<usize>,
|
|
84
|
+
row_limit: Option<usize>,
|
|
85
|
+
force: bool
|
|
86
|
+
) -> ApiResult<()>;
|
|
87
|
+
|
|
88
|
+
#[wasm_bindgen(method, catch)]
|
|
89
|
+
pub async fn update(
|
|
90
|
+
this: &JsPerspectiveViewerPlugin,
|
|
91
|
+
view: perspective_js::View,
|
|
92
|
+
column_limit: Option<usize>,
|
|
93
|
+
row_limit: Option<usize>,
|
|
94
|
+
force: bool
|
|
95
|
+
) -> ApiResult<()>;
|
|
96
|
+
|
|
97
|
+
#[wasm_bindgen(method, catch)]
|
|
98
|
+
pub async fn clear(this: &JsPerspectiveViewerPlugin) -> ApiResult<JsValue>;
|
|
99
|
+
|
|
100
|
+
#[wasm_bindgen(method, catch)]
|
|
101
|
+
pub async fn resize(this: &JsPerspectiveViewerPlugin) -> ApiResult<JsValue>;
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
impl JsPerspectiveViewerPlugin {
|
|
106
|
+
pub fn restore(
|
|
107
|
+
&self,
|
|
108
|
+
token: &JsValue,
|
|
109
|
+
columns_config: Option<&ColumnConfigMap>,
|
|
110
|
+
) -> ApiResult<()> {
|
|
111
|
+
let columns_config = JsValue::from_serde_ext(&columns_config).unwrap();
|
|
112
|
+
self._restore(token, &columns_config)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
#[derive(Clone, Copy, Debug, Default, Deserialize, Eq, PartialEq)]
|
|
117
|
+
#[serde(rename_all = "camelCase")]
|
|
118
|
+
pub enum ColumnSelectMode {
|
|
119
|
+
#[default]
|
|
120
|
+
Toggle,
|
|
121
|
+
Select,
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
impl ColumnSelectMode {
|
|
125
|
+
pub fn css(&self) -> yew::Classes {
|
|
126
|
+
match self {
|
|
127
|
+
Self::Toggle => yew::classes!("toggle-mode", "is_column_active"),
|
|
128
|
+
Self::Select => yew::classes!("select-mode", "is_column_active"),
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
#[derive(Clone, Debug, Default)]
|
|
134
|
+
pub struct ViewConfigRequirements {
|
|
135
|
+
pub min: Option<usize>,
|
|
136
|
+
pub names: Option<Vec<String>>,
|
|
137
|
+
pub mode: ColumnSelectMode,
|
|
138
|
+
pub max_columns: Option<usize>,
|
|
139
|
+
pub max_cells: Option<usize>,
|
|
140
|
+
pub name: String,
|
|
141
|
+
pub render_warning: bool,
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
impl ViewConfigRequirements {
|
|
145
|
+
pub fn is_swap(&self, index: usize) -> bool {
|
|
146
|
+
self.names
|
|
147
|
+
.as_ref()
|
|
148
|
+
.map(|x| index < x.len() - 1)
|
|
149
|
+
.unwrap_or(false)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
impl JsPerspectiveViewerPlugin {
|
|
154
|
+
pub fn get_requirements(&self) -> ApiResult<ViewConfigRequirements> {
|
|
155
|
+
Ok(ViewConfigRequirements {
|
|
156
|
+
min: self.min_config_columns(),
|
|
157
|
+
mode: self.select_mode().into_serde_ext()?,
|
|
158
|
+
names: self
|
|
159
|
+
.config_column_names()
|
|
160
|
+
.map(|x| x.into_serde_ext().unwrap()),
|
|
161
|
+
max_columns: self.max_columns(),
|
|
162
|
+
max_cells: self.max_cells(),
|
|
163
|
+
name: self.name(),
|
|
164
|
+
render_warning: self.render_warning().unwrap_or(true),
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
// `rustfmt` removes `async` from extern blocks in rust stable
|
|
14
|
+
// [issue](https://github.com/rust-lang/rustfmt/issues/4288)
|
|
15
|
+
|
|
16
|
+
use wasm_bindgen::prelude::*;
|
|
17
|
+
// use web_sys::HtmlElement;
|
|
18
|
+
|
|
19
|
+
#[wasm_bindgen(inline_js = "export const ResizeObserver = window.ResizeObserver")]
|
|
20
|
+
extern "C" {
|
|
21
|
+
pub type ResizeObserver;
|
|
22
|
+
|
|
23
|
+
#[wasm_bindgen(constructor, js_class = "ResizeObserver")]
|
|
24
|
+
pub fn new(callback: &js_sys::Function) -> ResizeObserver;
|
|
25
|
+
|
|
26
|
+
#[wasm_bindgen(method)]
|
|
27
|
+
pub fn observe(this: &ResizeObserver, elem: &web_sys::HtmlElement);
|
|
28
|
+
|
|
29
|
+
#[wasm_bindgen(method)]
|
|
30
|
+
pub fn unobserve(this: &ResizeObserver, elem: &web_sys::HtmlElement);
|
|
31
|
+
|
|
32
|
+
pub type ResizeObserverEntry;
|
|
33
|
+
|
|
34
|
+
#[wasm_bindgen(method, getter, js_name = "contentRect")]
|
|
35
|
+
pub fn content_rect(this: &ResizeObserverEntry) -> web_sys::DomRectReadOnly;
|
|
36
|
+
|
|
37
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
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
|
+
#[cfg(test)]
|
|
14
|
+
use wasm_bindgen::prelude::*;
|
|
15
|
+
|
|
16
|
+
// Must use inline build because the test runner does not import itself in
|
|
17
|
+
// the browser with `type=module` which causes `import.meta` calls to fail,
|
|
18
|
+
// and `currentScript` does not resolve dynamic imports so the polyfill
|
|
19
|
+
// for `import.meta` does not work either.
|
|
20
|
+
#[cfg(test)]
|
|
21
|
+
#[wasm_bindgen(inline_js = "
|
|
22
|
+
|
|
23
|
+
export async function worker() {
|
|
24
|
+
await import('/dist/wasm/test/perspective.js');
|
|
25
|
+
return window.perspective.worker();
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
")]
|
|
29
|
+
extern "C" {
|
|
30
|
+
fn worker() -> js_sys::Promise;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// /// Generate a test `Table`, but only create teh webworker once or the tests
|
|
34
|
+
// /// will figuratively literally run forever.
|
|
35
|
+
// #[cfg(test)]
|
|
36
|
+
// pub async fn get_mock_table() -> JsPerspectiveTable {
|
|
37
|
+
// thread_local! {
|
|
38
|
+
// static WORKER: RefCell<Option<JsPerspectiveWorker>> =
|
|
39
|
+
// RefCell::new(None); }
|
|
40
|
+
|
|
41
|
+
// let worker: JsPerspectiveWorker = match WORKER.with(|x|
|
|
42
|
+
// x.borrow().clone()) { Some(x) => x,
|
|
43
|
+
// None => JsFuture::from(worker()).await.unwrap().unchecked_into(),
|
|
44
|
+
// };
|
|
45
|
+
|
|
46
|
+
// WORKER.with(|x| {
|
|
47
|
+
// *x.borrow_mut() = Some(worker.clone());
|
|
48
|
+
// });
|
|
49
|
+
|
|
50
|
+
// worker
|
|
51
|
+
// .table(
|
|
52
|
+
// json!({
|
|
53
|
+
// "A": [1, 2, 3]
|
|
54
|
+
// })
|
|
55
|
+
// .unchecked_into(),
|
|
56
|
+
// )
|
|
57
|
+
// .await
|
|
58
|
+
// .unwrap()
|
|
59
|
+
// }
|
|
60
|
+
|
|
61
|
+
/// A macro which set a property called `weak_link` on the container
|
|
62
|
+
/// `Properties` when `cfg(test)`, such that unit tests may send messages to a
|
|
63
|
+
/// component.
|
|
64
|
+
///
|
|
65
|
+
/// This macro needs to be called in `create()` on any Component which needs to
|
|
66
|
+
/// receive messages in a test.
|
|
67
|
+
#[macro_export]
|
|
68
|
+
macro_rules! enable_weak_link_test {
|
|
69
|
+
($props:expr, $link:expr) => {
|
|
70
|
+
#[cfg(test)]
|
|
71
|
+
{
|
|
72
|
+
*$props.weak_link.borrow_mut() = Some($link.clone());
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/// A macro which derives a `yew::Component` for an arbitrary HTML snippet and
|
|
78
|
+
/// mounts it, for testing.
|
|
79
|
+
#[macro_export]
|
|
80
|
+
macro_rules! test_html {
|
|
81
|
+
($($html:tt)*) => {{
|
|
82
|
+
use wasm_bindgen::JsCast;
|
|
83
|
+
use yew::prelude::*;
|
|
84
|
+
|
|
85
|
+
struct TestElement {}
|
|
86
|
+
|
|
87
|
+
#[derive(Properties, PartialEq)]
|
|
88
|
+
struct TestElementProps {
|
|
89
|
+
html: Html,
|
|
90
|
+
root: NodeRef,
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
impl Component for TestElement {
|
|
94
|
+
type Message = ();
|
|
95
|
+
type Properties = TestElementProps;
|
|
96
|
+
|
|
97
|
+
fn create(_ctx: &Context<Self>) -> Self {
|
|
98
|
+
TestElement {}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
fn update(&mut self, _ctx: &Context<Self>, _msg: Self::Message) -> bool {
|
|
102
|
+
false
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
fn changed(&mut self, _ctx: &Context<Self>, _old: &Self::Properties) -> bool {
|
|
106
|
+
true
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
fn view(&self, ctx: &Context<Self>) -> Html {
|
|
110
|
+
html! {
|
|
111
|
+
<>
|
|
112
|
+
<style>
|
|
113
|
+
{ "#test{position:absolute;top:0;bottom:0;left:0;right:0;}" }
|
|
114
|
+
</style>
|
|
115
|
+
<div ref={ ctx.props().root.clone() }>
|
|
116
|
+
{ ctx.props().html.clone() }
|
|
117
|
+
</div>
|
|
118
|
+
</>
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
let document = ::perspective_js::utils::global::document();
|
|
124
|
+
let body = document.body().unwrap();
|
|
125
|
+
let div = document.create_element("div").unwrap();
|
|
126
|
+
body.append_child(&div).unwrap();
|
|
127
|
+
|
|
128
|
+
let init = web_sys::ShadowRootInit::new(web_sys::ShadowRootMode::Open);
|
|
129
|
+
let shadow_root = div
|
|
130
|
+
.attach_shadow(&init)
|
|
131
|
+
.unwrap()
|
|
132
|
+
.unchecked_into::<web_sys::Element>();
|
|
133
|
+
|
|
134
|
+
let root = NodeRef::default();
|
|
135
|
+
let props = TestElementProps {
|
|
136
|
+
html: html!{ $($html)* },
|
|
137
|
+
root: root.clone(),
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
yew::Renderer::<TestElement>::with_root_and_props(shadow_root, props).render();
|
|
141
|
+
request_animation_frame().await;
|
|
142
|
+
root.cast::<web_sys::HtmlElement>()
|
|
143
|
+
.unwrap()
|
|
144
|
+
.children()
|
|
145
|
+
.get_with_index(0)
|
|
146
|
+
.unwrap()
|
|
147
|
+
.unchecked_into::<web_sys::HtmlElement>()
|
|
148
|
+
}}
|
|
149
|
+
}
|
package/src/rust/lib.rs
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
//! The API for the [`@perspective-dev/viewer`]() JavaScript
|
|
14
|
+
//! library.
|
|
15
|
+
|
|
16
|
+
// Required by yew's `html` macro.
|
|
17
|
+
#![recursion_limit = "1024"]
|
|
18
|
+
#![feature(const_type_name)]
|
|
19
|
+
#![feature(let_chains)]
|
|
20
|
+
#![feature(macro_metavar_expr)]
|
|
21
|
+
#![feature(iter_intersperse)]
|
|
22
|
+
#![feature(stmt_expr_attributes)]
|
|
23
|
+
#![allow(async_fn_in_trait)]
|
|
24
|
+
#![warn(
|
|
25
|
+
clippy::all,
|
|
26
|
+
clippy::panic_in_result_fn,
|
|
27
|
+
clippy::await_holding_refcell_ref
|
|
28
|
+
)]
|
|
29
|
+
|
|
30
|
+
pub mod components;
|
|
31
|
+
pub mod config;
|
|
32
|
+
pub mod custom_elements;
|
|
33
|
+
mod custom_events;
|
|
34
|
+
mod dragdrop;
|
|
35
|
+
pub mod exprtk;
|
|
36
|
+
mod js;
|
|
37
|
+
|
|
38
|
+
#[doc(hidden)]
|
|
39
|
+
pub mod model;
|
|
40
|
+
mod presentation;
|
|
41
|
+
mod renderer;
|
|
42
|
+
mod session;
|
|
43
|
+
pub mod utils;
|
|
44
|
+
|
|
45
|
+
use perspective_js::utils::*;
|
|
46
|
+
use wasm_bindgen::prelude::*;
|
|
47
|
+
|
|
48
|
+
use crate::custom_elements::copy_dropdown::CopyDropDownMenuElement;
|
|
49
|
+
use crate::custom_elements::debug_plugin::PerspectiveDebugPluginElement;
|
|
50
|
+
use crate::custom_elements::export_dropdown::ExportDropDownMenuElement;
|
|
51
|
+
use crate::custom_elements::viewer::PerspectiveViewerElement;
|
|
52
|
+
use crate::utils::define_web_component;
|
|
53
|
+
|
|
54
|
+
#[wasm_bindgen(typescript_custom_section)]
|
|
55
|
+
const TS_APPEND_CONTENT: &'static str = r#"
|
|
56
|
+
import type {
|
|
57
|
+
TableInitOptions,
|
|
58
|
+
ColumnWindow,
|
|
59
|
+
ViewWindow,
|
|
60
|
+
OnUpdateOptions,
|
|
61
|
+
UpdateOptions,
|
|
62
|
+
DeleteOptions,
|
|
63
|
+
ViewConfigUpdate,
|
|
64
|
+
SystemInfo,
|
|
65
|
+
} from "@perspective-dev/client";
|
|
66
|
+
"#;
|
|
67
|
+
|
|
68
|
+
/// Register a plugin globally.
|
|
69
|
+
#[wasm_bindgen]
|
|
70
|
+
#[allow(non_snake_case)]
|
|
71
|
+
pub fn registerPlugin(name: &str) {
|
|
72
|
+
use crate::renderer::*;
|
|
73
|
+
PLUGIN_REGISTRY.register_plugin(name);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/// Register this crate's Custom Elements in the browser's current session.
|
|
77
|
+
///
|
|
78
|
+
/// This must occur before calling any public API methods on these Custom
|
|
79
|
+
/// Elements from JavaScript, as the methods themselves won't be defined yet.
|
|
80
|
+
/// By default, this crate does not register `PerspectiveViewerElement` (as to
|
|
81
|
+
/// preserve backwards-compatible synchronous API).
|
|
82
|
+
#[cfg(not(feature = "external-bootstrap"))]
|
|
83
|
+
#[wasm_bindgen(js_name = "init")]
|
|
84
|
+
pub fn js_init() {
|
|
85
|
+
perspective_js::utils::set_global_logging();
|
|
86
|
+
define_web_components!("export * as psp from '../../perspective-viewer.js'");
|
|
87
|
+
tracing::info!("Perspective initialized.");
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/// Register Web Components with the global registry, given a Perspective
|
|
91
|
+
/// module.
|
|
92
|
+
///
|
|
93
|
+
/// This function shouldn't be called directly; instead, use the
|
|
94
|
+
/// `define_web_components!` macro to both call this method and hook the
|
|
95
|
+
/// wasm_bindgen module object.
|
|
96
|
+
pub fn bootstrap_web_components(psp: &JsValue) {
|
|
97
|
+
define_web_component::<PerspectiveViewerElement>(psp);
|
|
98
|
+
define_web_component::<PerspectiveDebugPluginElement>(psp);
|
|
99
|
+
|
|
100
|
+
define_web_component::<ExportDropDownMenuElement>(psp);
|
|
101
|
+
define_web_component::<CopyDropDownMenuElement>(psp);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
#[macro_export]
|
|
105
|
+
macro_rules! define_web_components {
|
|
106
|
+
($x:expr) => {{
|
|
107
|
+
#[wasm_bindgen::prelude::wasm_bindgen(inline_js = $x)]
|
|
108
|
+
extern "C" {
|
|
109
|
+
#[wasm_bindgen::prelude::wasm_bindgen(js_name = "psp")]
|
|
110
|
+
#[wasm_bindgen::prelude::wasm_bindgen(thread_local_v2)]
|
|
111
|
+
pub static PSP: wasm_bindgen::prelude::JsValue;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
PSP.with(|x| $crate::bootstrap_web_components(x));
|
|
115
|
+
}};
|
|
116
|
+
}
|