Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Import Observable library
import {Runtime, Inspector, Library} from '@observablehq/runtime';
import {customResolve} from './customResolve';
import {customFetch} from './customFetch';
// Fetch data locally
fetch = customFetch;
// Load modules locally
const runtime = new Runtime(new Library(customResolve));
// Render selected notebook cells into DOM elements of this page
export function render(notebook) {
runtime.module(notebook, name => {
switch (name) {
case 'chart':
// render 'chart' notebook cell into <div id="joyplot"></div>
return new Inspector(document.querySelector('#joyplot'));
break;
}
});
}
export function generateRuntime(notebook) {
const {modules, id} = notebook;
var library = new Library();
var map = new Map;
var runtime = new Runtime(library);
const main = runtime_module(id);
function runtime_module(id) {
let module = map.get(id);
if (!module) map.set(id, module = runtime.module());
return module;
}
for (const m of modules) {
const module = runtime_module(m.id);
let i = 0;
for (const v of m.variables) {
if (v.from) {