fix compilation issues
This commit is contained in:
21
index.html
21
index.html
@@ -138,7 +138,7 @@ name + " is " + string(age) + " years old and " + (active ? "active" : "inactive
|
||||
|
||||
<div class="full-width">
|
||||
<button onclick="evaluate()">Evaluate CEL Expression</button>
|
||||
<button onclick="evaluateAsJs()">Evaluate & Return as JS Value</button>
|
||||
<button onclick="evaluateAsString()">Evaluate & Return as String</button>
|
||||
</div>
|
||||
|
||||
<div class="full-width">
|
||||
@@ -208,7 +208,7 @@ name + " is " + string(age) + " years old and " + (active ? "active" : "inactive
|
||||
<script type="module">
|
||||
import init, {
|
||||
evaluate_cel,
|
||||
evaluate_cel_js,
|
||||
evaluate_cel_string,
|
||||
} from "./pkg/cel_rust_wasm.js";
|
||||
|
||||
let wasmModule;
|
||||
@@ -219,7 +219,7 @@ name + " is " + string(age) + " years old and " + (active ? "active" : "inactive
|
||||
|
||||
// Make functions globally available
|
||||
window.evaluate_cel = evaluate_cel;
|
||||
window.evaluate_cel_js = evaluate_cel_js;
|
||||
window.evaluate_cel_string = evaluate_cel_string;
|
||||
|
||||
// Enable the evaluate button
|
||||
document.querySelector("button").disabled = false;
|
||||
@@ -230,7 +230,7 @@ name + " is " + string(age) + " years old and " + (active ? "active" : "inactive
|
||||
|
||||
// Make functions globally available for onclick handlers
|
||||
window.evaluate = evaluate;
|
||||
window.evaluateAsJs = evaluateAsJs;
|
||||
window.evaluateAsString = evaluateAsString;
|
||||
window.loadExample = loadExample;
|
||||
</script>
|
||||
|
||||
@@ -266,8 +266,8 @@ name + " is " + string(age) + " years old and " + (active ? "active" : "inactive
|
||||
}
|
||||
}
|
||||
|
||||
function evaluateAsJs() {
|
||||
if (!window.evaluate_cel_js) {
|
||||
function evaluateAsString() {
|
||||
if (!window.evaluate_cel_string) {
|
||||
document.getElementById("result").textContent =
|
||||
"WASM module not loaded yet...";
|
||||
return;
|
||||
@@ -281,14 +281,11 @@ name + " is " + string(age) + " years old and " + (active ? "active" : "inactive
|
||||
// Parse the context as JavaScript object
|
||||
const context = contextStr.trim() ? JSON.parse(contextStr) : {};
|
||||
|
||||
// Evaluate using the JavaScript value result version
|
||||
const result = window.evaluate_cel_js(expression, context);
|
||||
// Evaluate using the string result version
|
||||
const result = window.evaluate_cel_string(expression, context);
|
||||
|
||||
resultDiv.className = "result success";
|
||||
resultDiv.textContent = `Success (JS Value): ${JSON.stringify(result, null, 2)}`;
|
||||
|
||||
// Log the actual JavaScript object to console
|
||||
console.log("CEL Result as JavaScript value:", result);
|
||||
resultDiv.textContent = `Success (String): ${result}`;
|
||||
} catch (e) {
|
||||
resultDiv.className = "result error";
|
||||
resultDiv.textContent = `Error: ${e}`;
|
||||
|
||||
Reference in New Issue
Block a user