severo / observable-to-standalone Goto Github PK
View Code? Open in Web Editor NEWImporting an Observable notebook into a standalone application
License: GNU General Public License v3.0
Importing an Observable notebook into a standalone application
License: GNU General Public License v3.0
based on from https://github.com/Fil/SphericalContoursStandalone
Load local data, detecting if we serve a notebook as a local app or not. For https://github.com/severo/observable-to-standalone/tree/master/bundle_js_and_deploy.
Ideally yarn notebook && yarn serve
would update the notebook's code and serve the new version; but it seems that it's not enough currently: I have to do all of
rm -rf node_modules/ src/notebook/ yarn.lock
yarn notebook && yarn
For example:
d3 = require('d3@5', 'd3-array@2')
This will help debug.
const importScript = u =>
window.location.href.includes(".observableusercontent.com")
? `https://unpkg.com/${u}`
: `${window.location.href.replace(/\/[^/]*$/, "")}/${u}.js`;
const worker = createWorkerFrom(`
// load external scripts
importScripts("${importScript("d3@5")}");
importScripts("${importScript("d3-delaunay@5")}");
…
`)
I'm not sure it's up to date… and dependabot is trying to kill it. Better to archive it @severo
I don't like downloaded code to be mixed with main.js
Another solution would be to put main.js in a different directory (after all it is only html/wrapper/container/glue).
For example, some notebooks work with "[email protected]" but not @1, or "d3-geo-projection@2” but not @2.7
@Fil: could you add a reproducible error case?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.