馃悕馃悕馃悕
1
2export async function main(target) {
3 const container = $div();
4
5 const input = $element("input");
6 input.type = "text";
7 input.placeholder = "...";
8
9 async function handleLoad() {
10 const inputValue = input.value.trim();
11 const inputSplit = inputValue.split(/\s+/);
12 const moduleName = inputSplit[0];
13 const args = inputSplit.slice(1);
14
15 const result = await $mod(moduleName, container.parentNode, args);
16 if (result?.replace) {
17 container.remove();
18 }
19 }
20
21 input.addEventListener("keypress", async (e) => {
22 if (e.key === "Enter") {
23 handleLoad();
24 }
25 });
26
27 target.$with(container.$with(input));
28
29 input.focus();
30
31 return {
32 replace: true
33 };
34}
35