(name, exportNames)
| 123 | |
| 124 | /* Register a main-thread module at `mt:<name>`: push a stub per export (the real call defers to the page) and tell the compiler its export names. */ |
| 125 | const registerHost = (name, exportNames) => { |
| 126 | const baseId = nativeTable.length; |
| 127 | for (const fnName of exportNames) { |
| 128 | const stub = () => {}; |
| 129 | stub.__edge_kind = 'capability'; |
| 130 | stub.__edge_main_thread = true; |
| 131 | stub.__edge_name = fnName; |
| 132 | stub.__edge_module = name; |
| 133 | nativeTable.push(stub); |
| 134 | } |
| 135 | const specBytes = TE.encode(`mt:${name}`); |
| 136 | const namesBytes = TE.encode(exportNames.join('\n')); |
| 137 | exports.register_native_module( |
| 138 | writeBytes(specBytes), specBytes.length, |
| 139 | writeBytes(namesBytes), namesBytes.length, |
| 140 | baseId, |
| 141 | ); |
| 142 | }; |
| 143 | |
| 144 | /* Both kinds graft `<name> -> mt:<name>` so the bare name resolves; eager ones (programmatic objects) register now, lazy ones (urls) load on first import during prefetch. In incremental mode the native table is preserved, so skip re-registration. */ |
| 145 | const mainThreadSpecs = new Set(); |
no test coverage detected