MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / registerHost

Function registerHost

runtime/worker/engine.js:125–142  ·  view source on GitHub ↗
(name, exportNames)

Source from the content-addressed store, hash-verified

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();

Callers 1

runFunction · 0.85

Calls 2

pushMethod · 0.80
writeBytesFunction · 0.70

Tested by

no test coverage detected