-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
299 additions
and
421 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bun | ||
|
||
import { readdir, readFile, writeFile } from "fs/promises"; | ||
import { join } from "path"; | ||
|
||
const filePath = new URL("../dist/wasm/twsearch.js", import.meta.url); | ||
|
||
let modified = false; // For idempotence | ||
|
||
let contents = await readFile(filePath, "utf-8"); | ||
const lines = [ | ||
`// Mangled so that bundlers don't try to inline the source. | ||
const node_fs_promises_mangled = "node:-fs/pr-omises"; | ||
const node_fs_promises_unmangled = () => node_fs_promises_mangled.replace(/-/g, ""); | ||
`, | ||
]; | ||
for (const line of contents.split("\n")) { | ||
if (line.trim() === "input = fetch(input);") { | ||
lines.push(` try { | ||
input = await fetch(input); | ||
} catch (e) { | ||
if (!(e instanceof TypeError)) { | ||
throw e; | ||
} | ||
input = await (await import(node_fs_promises_unmangled())).readFile(input); | ||
}`); | ||
modified = true; | ||
} else { | ||
lines.push(line); | ||
} | ||
} | ||
if (modified) { | ||
contents = lines.join("\n"); | ||
await writeFile(filePath, contents); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
console.log("loading…"); | ||
|
||
import { | ||
default as init, | ||
internal_init, | ||
search_test, | ||
} from "../dist/wasm/twsearch.js"; | ||
|
||
console.log("Initializating WASM"); | ||
|
||
await init(); | ||
await internal_init(); | ||
|
||
console.log("Initialized!"); | ||
console.log("Found alg:", search_test("R U R' U' R' F R2 U' R' U' R U R' F'")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,6 @@ pub use search::*; | |
|
||
mod serve; | ||
pub use serve::*; | ||
|
||
mod wasm; | ||
pub use wasm::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{ "type": "module" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.