Public
Edited
May 2
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
source_define = {
if (!load_source) throw "Load source not ticked";
return (
await import(`https://api.observablehq.com/${source_notebook}.js?v=4`)
).default;
}
Insert cell
embedded_frame = embedded_runtime.module(frame_define)
Insert cell
embedded_source = embedded_runtime.module(source_define)
Insert cell
mutable output = undefined
Insert cell
modules = {
embedded_frame;
embedded_source;
return moduleMap(embedded_runtime);
}
Insert cell
[...embedded_runtime._variables].map(toObject)
Insert cell
module_selections = [...modules.values()].filter(
(info) => info.name == "@tomlarkworthy/module-selection"
)
Insert cell
exporters = [...modules.values()].filter(
(info) => info.name == "@tomlarkworthy/exporter"
)
Insert cell
register_additional_module = {
embedded_frame;
embedded_source;

return Promise.all(
module_selections.map(async (module_selection) => {
const file = jsonFileAttachment("additionalModules.json", [
source_notebook
]);
setFileAttachment(file, module_selection.module);
})
);
}
Insert cell
Insert cell
register_export_state = {
embedded_frame;
embedded_source;

return Promise.all(
exporters.map(async (exporter) => {
const file = jsonFileAttachment("export_state.json", export_state);
setFileAttachment(file, exporter.module);
})
);
}
Insert cell
exported = {
register_additional_module;
register_export_state;
return viewof task.send({
notebook: frame_notebook,
module: embedded_frame,
modules: new Map([[source_notebook, embedded_source]]),
options: {
debug: false,
headless: true,
main_files: false,
style: default_style,
output: (out) => (mutable output = out)
}
});
}
Insert cell
tasks = {
tomlarkworthy_exporter_task;
}
Insert cell
dir = "/" +
target_git.replace("https://", "").replaceAll("/", "_").replaceAll(".", "_")
Insert cell
update_main_branch = {
if (!commit) throw "skipped";
try {
await filesystem.lstat(dir);
await git.checkout({
fs: filesystem,
filesystem,
http,
dir,
corsProxy: "https://cors.isomorphic-git.org",
url: target_git,
ref: "main",
singleBranch: true,
depth: 1,
author: {
name: "Jumpgate",
email: "jumpgate@lopecode.com"
}
});
return git.pull({
fs: filesystem,
filesystem,
http,
dir,
corsProxy: "https://cors.isomorphic-git.org",
url: target_git,
ref: "main",
singleBranch: true,
depth: 1,
author: {
name: "Jumpgate",
email: "jumpgate@lopecode.com"
}
});
} catch (err) {
return git.clone({
fs: filesystem,
filesystem,
http,
dir,
corsProxy: "https://cors.isomorphic-git.org",
url: target_git,
ref: "main",
singleBranch: true,
depth: 1
});
}
}
Insert cell
Insert cell
branch_to_ref = {
update_main_branch;
return await git.branch({
fs: filesystem,
dir,
ref
});
}
Insert cell
create_directory = {
branch_to_ref;
try {
return await filesystem.mkdir(`${dir}/notebooks`); //EEXIST if opening this page again, FS persists to IndexedDB!
} catch (err) {
if (err.message === "EEXIST") {
return;
} else {
throw err;
}
}
}
Insert cell
write_notebook = {
create_directory;
return filesystem.writeFile(
`${dir}/notebooks/${notebook_filename}`,
exported.source
);
}
Insert cell
filepaths = {
write_notebook;
return filesystem.readdir(`${dir}/notebooks/`);
}
Insert cell
written_file = {
write_notebook;
return filesystem.readFile(`${dir}/notebooks/${notebook_filename}`, {
encoding: "utf8"
});
}
Insert cell
add_git = {
written_file;
return git.add({
fs: filesystem,
dir,
filepath: `notebooks/${notebook_filename}`
});
}
Insert cell
Insert cell
commit_git = {
if (!commit) throw "skipped";

add_git;
return git.commit({
fs: filesystem,
dir,
author: {
name: "Jumpgate",
email: "jumpgate@lopecode.com"
},
message: `Jumpgate for ${ref}`
});
}
Insert cell
push_git = {
commit_git;
return git.push({
fs: filesystem,
http,
dir,
remote: "origin",
ref,
remoteRef: ref,
force: true,
onAuth: () => ({ username: github_token })
});
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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