@@ -15,15 +15,19 @@ if (typeof SharedArrayBuffer === "undefined") {
1515
1616const WASM_URL = "/wasm/uutils.wasm" ;
1717// Some utilities ship as their own standalone WASM modules rather than as part
18- // of the coreutils multicall binary (grep lives in uutils/grep, find in
19- // uutils/findutils, diff and cmp in uutils/diffutils, sed in uutils/sed). Each
20- // module is loaded on demand and is optional — see loadStandalone. A single
21- // module can provide several commands (diffutils → diff, cmp), which the
22- // diffutils binary dispatches on argv[0], so each command is invoked directly
23- // by its own name.
18+ // of the coreutils multicall binary (grep lives in uutils/grep, find/locate/
19+ // updatedb in uutils/findutils, diff and cmp in uutils/diffutils, sed in
20+ // uutils/sed). Each module is loaded on demand and is optional — see
21+ // loadStandalone. A single module can provide several commands (diffutils →
22+ // diff, cmp), which the binary dispatches on argv[0], so each command is invoked
23+ // directly by its own name. findutils ships separate binaries, so each is its
24+ // own module. (xargs is intentionally absent: it must spawn child processes,
25+ // which the browser WASI sandbox can't do.)
2426const STANDALONE_MODULES = {
2527 grep : { url : "/wasm/grep.wasm" , commands : [ "grep" ] } ,
2628 find : { url : "/wasm/find.wasm" , commands : [ "find" ] } ,
29+ locate : { url : "/wasm/locate.wasm" , commands : [ "locate" ] } ,
30+ updatedb : { url : "/wasm/updatedb.wasm" , commands : [ "updatedb" ] } ,
2731 diffutils : { url : "/wasm/diffutils.wasm" , commands : [ "diff" , "cmp" ] } ,
2832 sed : { url : "/wasm/sed.wasm" , commands : [ "sed" ] } ,
2933} ;
@@ -75,7 +79,7 @@ const FALLBACK_COMMANDS = [
7579 "sha1sum" , "sha224sum" , "sha256sum" , "sha384sum" , "sha512sum" ,
7680 "shred" , "shuf" , "sleep" , "sum" , "tee" , "true" , "truncate" ,
7781 "uname" , "unexpand" , "uniq" , "unlink" , "vdir" , "wc" ,
78- "grep" , "find" , "diff" , "cmp" , "sed" ,
82+ "grep" , "find" , "locate" , "updatedb" , " diff", "cmp" , "sed" ,
7983] ;
8084const AVAILABLE_COMMANDS =
8185 ( typeof WASM_COMMANDS !== "undefined" && Array . isArray ( WASM_COMMANDS ) && WASM_COMMANDS . length > 0 )
@@ -233,7 +237,8 @@ async function initWasm() {
233237 if ( wasmReady ) return ;
234238 try {
235239 // Only the coreutils multicall binary loads eagerly; the standalone
236- // modules (grep, find, diffutils) are fetched on demand — see loadStandalone.
240+ // modules (grep, find, locate, updatedb, diffutils, sed) are fetched
241+ // on demand — see loadStandalone.
237242 await Promise . all ( [ loadWasiShim ( ) , loadWasm ( ) ] ) ;
238243 wasmReady = true ;
239244 } catch ( e ) {
@@ -626,8 +631,9 @@ async function executeCommandLine(line) {
626631 return `uutils: command not found: ${ cmd } \nType 'help' for available commands.\n` ;
627632 }
628633
629- // Some utilities (grep, find, diff, cmp) are separate WASM modules rather
630- // than part of the coreutils multicall binary, and are loaded on demand.
634+ // Some utilities (grep, find, locate, updatedb, diff, cmp, sed) are
635+ // separate WASM modules rather than part of the coreutils multicall binary,
636+ // and are loaded on demand.
631637 // Fetch the module the first time one of its commands is used (no-op once
632638 // cached; diff and cmp share the single diffutils module).
633639 const moduleName = STANDALONE_COMMAND_MODULE [ cmd ] ;
@@ -955,7 +961,7 @@ async function initPlayground(containerId) {
955961 terminal . writeln ( "" ) ;
956962 terminal . writeln ( "Type \x1b[1;32mhelp\x1b[0m for available commands." ) ;
957963 terminal . writeln ( "Sample data files: names.txt, numbers.txt, fruits.txt, csv.txt, words.txt" ) ;
958- terminal . writeln ( "\x1b[2mgrep, find, sed and diff/cmp load on demand — just run them, or use the buttons below.\x1b[0m" ) ;
964+ terminal . writeln ( "\x1b[2mgrep, find/locate/updatedb , sed and diff/cmp load on demand — just run them, or use the buttons below.\x1b[0m" ) ;
959965 } catch ( e ) {
960966 terminal . writeln ( " \x1b[1;31mfailed\x1b[0m" ) ;
961967 terminal . writeln ( "Failed to load WASM binary. Commands are not available." ) ;
@@ -1003,8 +1009,9 @@ window.uutilsExecute = executeCommandLine;
10031009window . runInTerminal = runInTerminal ;
10041010window . setLocale = setLocale ;
10051011
1006- // On-demand loading of the optional standalone modules (grep, find, diffutils),
1007- // used by the "Load" buttons on the playground page. Keyed by module name; one
1012+ // On-demand loading of the optional standalone modules (grep, find, locate,
1013+ // updatedb, diffutils, sed), used by the "Load" buttons on the
1014+ // playground page. Keyed by module name; one
10081015// module may back several commands (diffutils → diff, cmp).
10091016window . uutilsPrograms = Object . keys ( STANDALONE_MODULES ) ;
10101017window . loadProgram = ( mod ) => loadStandalone ( mod ) ;
0 commit comments