feat: standalone playground for Yggdrasil#315
Conversation
| pub fn new() -> WasmEngine { | ||
| WasmEngine { | ||
| compiled_state: CompiledState::default(), | ||
| grammars: HashMap::new(), | ||
| } | ||
| } |
Check warning
Code scanning / clippy
you should consider adding a Default implementation for WasmEngine Warning
| pub fn load_client_features(&mut self, features_json: &str) -> Result<JsValue, JsValue> { | ||
| let warnings = self | ||
| .load_client_features_internal(features_json) | ||
| .map_err(|err| js_error(err))?; |
Check warning
Code scanning / clippy
redundant closure Warning
| #[wasm_bindgen(js_name = "setToggleGrammar")] | ||
| pub fn set_toggle_grammar(&mut self, toggle_name: &str, grammar: &str) -> Result<(), JsValue> { | ||
| self.apply_grammar_internal(toggle_name, grammar) | ||
| .map_err(|err| js_error(err)) |
Check warning
Code scanning / clippy
redundant closure Warning
|
|
||
| for (toggle_name, grammar) in updates { | ||
| self.apply_grammar_internal(&toggle_name, &grammar) | ||
| .map_err(|err| js_error(err))?; |
Check warning
Code scanning / clippy
redundant closure Warning
| pub fn evaluate(&self, toggle_name: &str, context_json: &str) -> Result<JsValue, JsValue> { | ||
| let evaluation = self | ||
| .evaluate_internal(toggle_name, context_json) | ||
| .map_err(|err| js_error(err))?; |
Check warning
Code scanning / clippy
redundant closure Warning
| self.compiled_state | ||
| .iter() | ||
| .map(|(_, toggle)| ToggleDefinition { | ||
| name: toggle.name.clone(), | ||
| feature_type: toggle.feature_type.clone(), | ||
| project: toggle.project.clone(), | ||
| enabled: toggle.enabled, | ||
| }) |
Check warning
Code scanning / clippy
iterating on a map's values Warning
This creates a UI that allows a user to query an Unleash server with its client features definitions and show the compiled grammar from Yggdrasil, allowing the user to modify and play around with the grammar in real time. Yggdrasil engine runs in the browser as a WASM module, which means it only needs one call to the server to get the definitions, and then changes in the grammar can be applied without re-fetching.
This is what the UI looks like: