tinymist_core/
web.rs

1//! Tinymist Web APIs.
2
3#![allow(unused)]
4
5use js_sys::{Function, Promise};
6use wasm_bindgen::prelude::*;
7
8use crate::LONG_VERSION;
9
10/// Gets the long version description of the library.
11#[wasm_bindgen]
12pub fn version() -> String {
13    LONG_VERSION.clone()
14}
15
16/// The Tinymist Language Server for WebAssembly.
17#[wasm_bindgen]
18pub struct TinymistLanguageServer {
19    send_diagnostics: Function,
20    send_request: Function,
21    send_notification: Function,
22}
23
24#[wasm_bindgen]
25impl TinymistLanguageServer {
26    /// Creates a new instance of the Tinymist Language Server.
27    #[wasm_bindgen(constructor)]
28    pub fn new(
29        send_diagnostics: Function,
30        send_request: Function,
31        send_notification: Function,
32    ) -> Self {
33        std::panic::set_hook(Box::new(console_error_panic_hook::hook));
34
35        Self {
36            send_diagnostics,
37            send_request,
38            send_notification,
39        }
40    }
41
42    /// Handles incoming requests.
43    pub fn on_request(&self, method: String, js_params: JsValue) -> Result<JsValue, JsValue> {
44        todo!()
45    }
46
47    /// Handles incoming notifications.
48    pub fn on_notification(&self, method: String, js_params: JsValue) -> Promise {
49        todo!()
50    }
51}