|
1 | | -import { freemem } from "node:os"; |
| 1 | +import { freemem } from 'node:os'; |
2 | 2 | import { TextDecoder } from 'node:util'; |
3 | 3 | import { Buffer } from 'node:buffer'; |
4 | 4 | import { fileURLToPath } from 'node:url'; |
@@ -26,11 +26,34 @@ import { |
26 | 26 | export const { version } = JSON.parse( |
27 | 27 | await readFile(new URL('../package.json', import.meta.url), 'utf8'), |
28 | 28 | ); |
29 | | -const isWindows = platform === 'win32'; |
| 29 | + |
| 30 | +/** Whether the current platform is windows */ |
| 31 | +const IS_WINDOWS = platform === 'win32'; |
| 32 | + |
| 33 | +/** Prefix into wizer error output that indicates a error/trap */ |
| 34 | +const WIZER_ERROR_CAUSE_PREFIX = `Error: the \`componentize.wizer\` function trapped |
| 35 | +Caused by:`; |
| 36 | + |
| 37 | +/** Prefix into wizer error output that indicates exit status */ |
| 38 | +const WIZER_EXIT_CODE_PREFIX = 'Exited with i32 exit status'; |
| 39 | + |
| 40 | +/** Response code from check_init() that denotes success */ |
| 41 | +const CHECK_INIT_RETURN_OK = 0; |
| 42 | + |
| 43 | +/** Response code from check_init() that denotes being unable to extract exports list */ |
| 44 | +const CHECK_INIT_RETURN_FN_LIST = 1; |
| 45 | + |
| 46 | +/** Response code from check_init() that denotes being unable to parse core ABI export types */ |
| 47 | +const CHECK_INIT_RETURN_TYPE_PARSE = 2; |
| 48 | + |
| 49 | +/** Default path to the AOT weval cache */ |
| 50 | +const DEFAULT_AOT_CACHE = fileURLToPath( |
| 51 | + new URL(`../lib/starlingmonkey_ics.wevalcache`, import.meta.url), |
| 52 | +); |
30 | 53 |
|
31 | 54 | function maybeWindowsPath(path) { |
32 | 55 | if (!path) return path; |
33 | | - if (!isWindows) return resolve(path); |
| 56 | + if (!IS_WINDOWS) return resolve(path); |
34 | 57 | return '//?/' + resolve(path).replace(/\\/g, '/'); |
35 | 58 | } |
36 | 59 |
|
@@ -402,19 +425,15 @@ export async function componentize( |
402 | 425 | }; |
403 | 426 | } |
404 | 427 |
|
405 | | - const INIT_OK = 0; |
406 | | - const INIT_FN_LIST = 1; |
407 | | - const INIT_TYPE_PARSE = 2; |
408 | | - |
409 | 428 | const status = check_init(); |
410 | 429 | let err = null; |
411 | 430 | switch (status) { |
412 | | - case INIT_OK: |
| 431 | + case CHECK_INIT_RETURN_OK: |
413 | 432 | break; |
414 | | - case INIT_FN_LIST: |
| 433 | + case CHECK_INIT_RETURN_FN_LIST: |
415 | 434 | err = `Unable to extract expected exports list`; |
416 | 435 | break; |
417 | | - case INIT_TYPE_PARSE: |
| 436 | + case CHECK_INIT_RETURN_TYPE_PARSE: |
418 | 437 | err = `Unable to parse the core ABI export types`; |
419 | 438 | break; |
420 | 439 | default: |
|
0 commit comments