Published
Edited
Jul 30, 2022
1 fork
Importers
19 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
interpret = new Interpreter()
Insert cell
Insert cell
{
const target = html`<div>`;
const runtime = new Runtime();
const main = runtime.module();
const observer = Inspector.into(target);

interpret.module(source, main, observer);
invalidation.then(() => runtime.dispose());

return target;
}
Insert cell
Insert cell
compile = new Compiler()
Insert cell
compile.module(source)
Insert cell
Insert cell
Insert cell
compile.module(circleSource)
Insert cell
Insert cell
Insert cell
Insert cell
compile.module(circleSource, { treeShake: ["circle"] })
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
cc = require("@alex.garcia/unofficial-observablehq-compiler@v0.6.0-alpha.6")
Insert cell
Compiler = cc.Compiler
Insert cell
Interpreter = cc.Interpreter
Insert cell
parser = cc.parser
Insert cell
r = require("@observablehq/runtime")
Insert cell
Inspector = r.Inspector
Insert cell
Runtime = r.Runtime
Insert cell
Library = r.Library
Insert cell
inputCompiledTreeShaked = compile.module(inputsSource, { treeShake: ["Table"] })
Insert cell
inputCompiledBefore = compile.module(inputsSource)
Insert cell
prettyBytes = (await import('https://cdn.skypack.dev/pretty-bytes')).default
Insert cell
timechartSource = timechartNotebook.nodes.map(d => d.value).join("\n\n")
Insert cell
ojs = timechartNotebook.nodes.map(d => d.value).join("\n\n")
Insert cell
x = timechartNotebook.nodes.map(d => parser.parseCell(d.value))
Insert cell
compiled = {
const compile = new Compiler();
return {
default: compile.module(ojs),
treeShaked: compile.module(ojs, {
treeShake: ["TimeChart", "TimeAxis"]
})
};
}
Insert cell
inputsSource = inputsNotebook.nodes.map(d => d.value).join("\n")
Insert cell
inputs = {
const src = inputsNotebook.nodes.map(d => d.value).join("\n");
const compile = new Compiler();
return {
default: compile.module(src),
treeShaked: compile.module(src, {
treeShake: ["Table"]
})
};
}
Insert cell
url = (source, invalidation) => {
const url = URL.createObjectURL(
new Blob([source], { type: "text/javascript" })
);
invalidation.then(() => URL.revokeObjectURL(url));
return url;
}
Insert cell
render(
(await import(url(compiled.default, invalidation))).default,
invalidation
)
Insert cell
render(
(await import(url(compiled.treeShaked, invalidation))).default,
invalidation
)
Insert cell
function render(define, invalidation) {
const container = html`<div style="border: 2px solid #ccc; max-height: 450px; overflow: auto;">
<div style="position: absolute; top: 0; left: 0; background-color: #ccc; font-weight: 700; padding: .02rem .5rem; border-radius: 0 0 .5rem 0; font-family: monospace; font-size: .875rem; z-index: 100;">RENDERED NOTEBOOK</div>
<div class="target"></div>
</div>`;
const target = container.querySelector(".target");
const observer = Inspector.into(target);
const runtime = new Runtime();
const main = runtime.module(define, observer);
invalidation.then(() => runtime.dispose());
return container;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more