@observablehq/notebook-kit 1.7.7 → 1.7.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.json
CHANGED
|
@@ -4,7 +4,10 @@ const CODE_DOLLAR = 36;
|
|
|
4
4
|
export function resolveObservableImport(specifier) {
|
|
5
5
|
if (!specifier.startsWith("observable:"))
|
|
6
6
|
return specifier;
|
|
7
|
-
|
|
7
|
+
let path = specifier.slice("observable:".length);
|
|
8
|
+
if (/^[0-9a-f]{16}(@|$)/.test(path))
|
|
9
|
+
path = `d/${path}`;
|
|
10
|
+
return `https://api.observablehq.com/${path}.js?v=4`;
|
|
8
11
|
}
|
|
9
12
|
export function isObservableImport(node, specifier) {
|
|
10
13
|
const type = node.attributes?.find((a) => getImportAttributeKey(a) === "type")?.value;
|
|
@@ -81,7 +81,7 @@ export function observable({ window = new JSDOM().window, parser = new window.DO
|
|
|
81
81
|
child.on("exit", (code) => {
|
|
82
82
|
if (code === 0)
|
|
83
83
|
return resolve();
|
|
84
|
-
|
|
84
|
+
unlinkSyncIfExists(cachePath); // don’t pollute cache with failure
|
|
85
85
|
reject(new Error(`${cell.database} query exited with ${code}`));
|
|
86
86
|
});
|
|
87
87
|
});
|
|
@@ -106,7 +106,7 @@ export function observable({ window = new JSDOM().window, parser = new window.DO
|
|
|
106
106
|
child.on("exit", (code) => {
|
|
107
107
|
if (code === 0)
|
|
108
108
|
return resolve();
|
|
109
|
-
|
|
109
|
+
unlinkSyncIfExists(cachePath); // don’t pollute cache with failure
|
|
110
110
|
reject(new Error(`${mode} interpreter exited with ${code}`));
|
|
111
111
|
});
|
|
112
112
|
});
|
|
@@ -240,3 +240,13 @@ function isSpaceCode(code) {
|
|
|
240
240
|
function escapeScript(script) {
|
|
241
241
|
return script.replace(/<\/script>/g, "<\\/script>"); // TODO handle other contexts
|
|
242
242
|
}
|
|
243
|
+
function unlinkSyncIfExists(path) {
|
|
244
|
+
try {
|
|
245
|
+
unlinkSync(path);
|
|
246
|
+
}
|
|
247
|
+
catch (error) {
|
|
248
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT")
|
|
249
|
+
return;
|
|
250
|
+
throw error;
|
|
251
|
+
}
|
|
252
|
+
}
|