(outputFile, symbolsOnly)
| 384 | const PROXY_SYNC_ASYNC = 2; |
| 385 | |
| 386 | export async function runJSify(outputFile, symbolsOnly) { |
| 387 | const libraryItems = []; |
| 388 | const symbolDeps = {}; |
| 389 | const asyncFuncs = []; |
| 390 | let postSets = []; |
| 391 | |
| 392 | LibraryManager.load(); |
| 393 | |
| 394 | let outputHandle = process.stdout; |
| 395 | if (outputFile) { |
| 396 | outputHandle = await fs.open(outputFile, 'w'); |
| 397 | } |
| 398 | |
| 399 | async function writeOutput(str) { |
| 400 | // Unmangle previously mangled `import.meta` references. |
| 401 | // See also: `mangleUnsupportedSyntax` in parseTools.mjs. |
| 402 | if (EXPORT_ES6) { |
| 403 | str = str.replaceAll('EMSCRIPTEN$IMPORT$META', 'import.meta'); |
| 404 | } |
| 405 | |
| 406 | await outputHandle.write(str + '\n'); |
| 407 | } |
| 408 | |
| 409 | const symbolsNeeded = DEFAULT_LIBRARY_FUNCS_TO_INCLUDE; |
| 410 | symbolsNeeded.push(...extraLibraryFuncs); |
| 411 | for (const sym of EXPORTED_RUNTIME_METHODS) { |
| 412 | if ('$' + sym in LibraryManager.library) { |
| 413 | symbolsNeeded.push('$' + sym); |
| 414 | } |
| 415 | } |
| 416 | |
| 417 | for (const key of Object.keys(LibraryManager.library)) { |
| 418 | if (!isDecorator(key)) { |
| 419 | if (INCLUDE_FULL_LIBRARY || EXPORTED_FUNCTIONS.has(mangleCSymbolName(key))) { |
| 420 | symbolsNeeded.push(key); |
| 421 | } |
| 422 | } |
| 423 | } |
| 424 | |
| 425 | function processLibraryFunction(snippet, symbol, mangled, deps, isStub) { |
| 426 | // It is possible that when printing the function as a string on Windows, |
| 427 | // the js interpreter we are in returns the string with Windows line endings |
| 428 | // \r\n. This is undesirable, since line endings are managed in the form \n |
| 429 | // in the output for binary file writes, so make sure the endings are |
| 430 | // uniform. |
| 431 | snippet = snippet.toString().replace(/\r\n/gm, '\n'); |
| 432 | |
| 433 | // Is this a shorthand `foo() {}` method syntax? |
| 434 | // If so, prepend a function keyword so that it's valid syntax when extracted. |
| 435 | if (snippet.startsWith(symbol)) { |
| 436 | snippet = 'function ' + snippet; |
| 437 | } |
| 438 | |
| 439 | if (isStub) { |
| 440 | return snippet; |
| 441 | } |
| 442 | |
| 443 | // apply LIBRARY_DEBUG if relevant |
nothing calls this directly
no test coverage detected