#![recursion_limit = "1024"]
#![feature(const_type_name)]
#![feature(iter_intersperse)]
#![feature(stmt_expr_attributes)]
#![feature(try_blocks)]
#![allow(async_fn_in_trait)]
#![feature(more_qualified_paths)]
#![warn(
clippy::all,
clippy::panic_in_result_fn,
clippy::await_holding_refcell_ref,
clippy::fallible_impl_from,
clippy::unneeded_field_pattern
)]
pub mod components;
pub mod config;
pub mod custom_elements;
mod custom_events;
mod dragdrop;
pub mod exprtk;
mod js;
mod root;
pub mod engines;
mod presentation;
mod renderer;
mod session;
#[doc(hidden)]
pub mod tasks;
pub mod utils;
#[macro_use]
extern crate macro_rules_attribute;
extern crate alloc;
use perspective_js::utils::*;
use wasm_bindgen::prelude::*;
use crate::custom_elements::copy_dropdown::CopyDropDownMenuElement;
use crate::custom_elements::debug_plugin::PerspectiveDebugPluginElement;
use crate::custom_elements::export_dropdown::ExportDropDownMenuElement;
use crate::custom_elements::viewer::PerspectiveViewerElement;
use crate::utils::define_web_component;
#[wasm_bindgen(typescript_custom_section)]
const TS_APPEND_CONTENT: &'static str = r#"
import type {
ColumnType,
TableInitOptions,
ColumnWindow,
ViewWindow,
OnUpdateOptions,
JoinOptions,
UpdateOptions,
DeleteOptions,
ViewConfigUpdate,
SystemInfo,
} from "@perspective-dev/client";
"#;
#[wasm_bindgen]
#[allow(non_snake_case)]
pub fn registerPlugin(name: &str) {
use crate::renderer::*;
PLUGIN_REGISTRY.register_plugin(name);
}
#[cfg(not(feature = "external-bootstrap"))]
#[wasm_bindgen(js_name = "init")]
pub fn js_init() {
console_error_panic_hook::set_once();
perspective_js::utils::set_global_logging();
define_web_components!("export * as psp from '../../perspective-viewer.js'");
tracing::info!("Perspective initialized.");
}
pub fn bootstrap_web_components(psp: &JsValue) {
define_web_component::<PerspectiveViewerElement>(psp);
define_web_component::<PerspectiveDebugPluginElement>(psp);
define_web_component::<CopyDropDownMenuElement>(psp);
define_web_component::<ExportDropDownMenuElement>(psp);
}
#[macro_export]
macro_rules! define_web_components {
($x:expr) => {{
#[wasm_bindgen::prelude::wasm_bindgen(inline_js = $x)]
extern "C" {
#[wasm_bindgen::prelude::wasm_bindgen(js_name = "psp")]
#[wasm_bindgen::prelude::wasm_bindgen(thread_local_v2)]
pub static PSP: wasm_bindgen::prelude::JsValue;
}
PSP.with(|x| $crate::bootstrap_web_components(x));
}};
}