runtime
runtime copied to clipboard
module.builtin() is not documented
Compiled Observable notebooks with file attachments call main.builtin() to register a FileAttachment builtin that is local to the module:
const main = runtime.module();
const fileAttachments = new Map([["chinook.db","https://static.observableusercontent.com/files/b3711cfd9bdf50cbe4e74751164d28e907ce366cd4bf56a39a980a48fdc5f998c42a019716a8033e2b54defdd97e4a55ebe4f6464b4f0678ea0311532605a115"]]);
main.builtin("FileAttachment", runtime.fileAttachments(name => fileAttachments.get(name)));
This is currently the only way to define local builtins, as the second argument of the Module constructor is not exposed via runtime.module(). Unfortunately the method is not documented.
(As an aside, runtime.fileAttachments isn't documented either.)