Skip to content

Commit

Permalink
deploy: 6e5364b
Browse files Browse the repository at this point in the history
  • Loading branch information
Zheoni committed Dec 31, 2024
1 parent a10c779 commit 80f162d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 18 deletions.
41 changes: 23 additions & 18 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,10 @@ <h1>cooklang-rs playground</h1>

<select id="parserSelect">
<option value="render" selected>Render</option>
<option value="full" selected>Full parse</option>
<option value="full">Full parse</option>
<option value="events">Events</option>
<option value="ast">AST</option>
<option value="stdmeta">Standard metadata</option>
</select>
<div hidden id="servingscontainer">
<label for="servings">Servings</label>
Expand Down Expand Up @@ -219,7 +220,7 @@ <h1>cooklang-rs playground</h1>
</main>

<script type="module">
import init, { State,version } from "./pkg/cooklang_playground.js";
import init, { State, version } from "./pkg/cooklang_playground.js";

async function run() {
await init();
Expand Down Expand Up @@ -286,7 +287,13 @@ <h1>cooklang-rs playground</h1>
break;
}
case "render": {
const { value, error } = state.parse_render(input, servings.value.length === 0 ? null : servings.valueAsNumber );
const { value, error } = state.parse_render(input, servings.value.length === 0 ? null : servings.valueAsNumber);
output.innerHTML = value;
errors.innerHTML = error;
break;
}
case "stdmeta": {
const { value, error } = state.std_metadata(input);
output.innerHTML = value;
errors.innerHTML = error;
break;
Expand Down Expand Up @@ -329,21 +336,19 @@ <h1>cooklang-rs playground</h1>
servings.addEventListener("change", () => parse());

const extensionsContainer = document.getElementById("extensions-container");

const extensions = [
"COMPONENT_MODIFIERS",
"COMPONENT_ALIAS",
"ADVANCED_UNITS",
"MODES",
"TEMPERATURE",
"RANGE_VALUES",
"TIMER_REQUIRES_TIME",
"INTERMEDIATE_PREPARATIONS",
"SPECIAL_METADATA",
].forEach((e, i) => {
let bits = 1 << i;
if (i == 11) {
bits |= 1 << 1;
}
["COMPONENT_MODIFIERS", 1 << 1],
["COMPONENT_ALIAS", 1 << 3],
["ADVANCED_UNITS", 1 << 5],
["MODES", 1 << 6],
["TEMPERATURE", 1 << 7],
["RANGE_VALUES", 1 << 9],
["TIMER_REQUIRES_TIME", 1 << 10],
["INTERMEDIATE_PREPARATIONS", 1 << 11 | 1 << 1]
];

extensions.forEach(([e, bits]) => {
const elem = document.createElement("input");
elem.setAttribute("type", "checkbox");
elem.setAttribute("id", e);
Expand Down Expand Up @@ -414,4 +419,4 @@ <h1>cooklang-rs playground</h1>
</script>
</body>

</html>
</html>
10 changes: 10 additions & 0 deletions pkg/cooklang_playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,16 @@ export class State {
const ret = wasm.state_parse_render(this.__wbg_ptr, ptr0, len0, isLikeNone(scale) ? 0x100000001 : (scale) >>> 0);
return FallibleResult.__wrap(ret);
}
/**
* @param {string} input
* @returns {FallibleResult}
*/
std_metadata(input) {
const ptr0 = passStringToWasm0(input, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
const len0 = WASM_VECTOR_LEN;
const ret = wasm.state_std_metadata(this.__wbg_ptr, ptr0, len0);
return FallibleResult.__wrap(ret);
}
}

async function __wbg_load(module, imports) {
Expand Down
Binary file modified pkg/cooklang_playground_bg.wasm
Binary file not shown.

0 comments on commit 80f162d

Please sign in to comment.