I think you’re running into the issue with the v1 modules served by Observable’s API described in thesethreads.
The recommended solution is to switch to using the V3 runtime. I think changing the script in your HTML file to the following should work (not tested!):
import {Runtime, Inspector} from "https://cdn.jsdelivr.net/npm/@observablehq/runtime@4/dist/runtime.js";
import notebook from "https://api.observablehq.com/d/d1345cfb039d5b19.js?v=3";
const renders = {
"viewof value": "#labels",
};
for (let i in renders)
renders[i] = document.querySelector(renders[i]);
const runtime = new Runtime();
const main = runtime.module(define, name => {
if (renders[name]) {
return new Inspector(renders[name]);
}
});
Thanks Bryan. Unfortunately it still doesn’t work. That is, the rendered error message disappeared, but now the console returns:
Uncaught
observable_embed_timeout.html:26
ReferenceError: define is not defined
at observable_embed_timeout.html:26
(So maybe it did work, but now there’s another error in my notebook that I need to sort out)?
Regarding the runtime version - I am surprised that the ?v=3 doesn’t refer to notebook version. Isn’t the runtime already defined as v4 here: https://cdn.jsdelivr.net/npm/@observablehq/runtime@4/dist/runtime.js
Ah, my bad, I screwed up the code! Change define to notebook:
import {Runtime, Inspector} from "https://cdn.jsdelivr.net/npm/@observablehq/runtime@4/dist/runtime.js";
import notebook from "https://api.observablehq.com/d/d1345cfb039d5b19.js?v=3";
const renders = {
"viewof value": "#labels",
};
for (let i in renders)
renders[i] = document.querySelector(renders[i]);
const runtime = new Runtime();
const main = runtime.module(notebook, name => {
if (renders[name]) {
return new Inspector(renders[name]);
}
});
You were importing the Observable runtime library v4 correctly, but you needed to add ?v=3 to the import statement for your own notebook.
I got it in a slightly different way, following Jeremy’s example:
import {Runtime, Inspector} from "https://cdn.jsdelivr.net/npm/@observablehq/runtime@4/dist/runtime.js";
import notebook from "https://api.observablehq.com/d/d1345cfb039d5b19.js?v=3";
new Runtime().module(notebook, name => {
if (name === "viewof value") {
return new Inspector(document.querySelector("#labels"));
}
});
… but I’ll switch over the your solution to allow me to define multiple cells.