@a10k/iridium-dev-server 0.0.1 → 0.0.3
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/Readme.md +17 -8
- package/lib/viewer.js +4 -2
- package/package.json +2 -2
package/Readme.md
CHANGED
|
@@ -19,7 +19,7 @@ mkdir my-notebooks && cd my-notebooks
|
|
|
19
19
|
npx @a10k/iridium-dev-server
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
Open http://localhost:8080/ to edit the `index` notebook, or http://localhost:8080/my-notebook for any other (it's created on first save). Write a cell, run it with Shift+Enter, save with ⌘S / Ctrl+S.
|
|
22
|
+
Open http://localhost:8080/ to edit the `index` notebook, or http://localhost:8080/my-notebook for any other (it's created on first save). Write a cell, run it with Shift+Enter, save with ⌘S / Ctrl+S. Running or saving writes the notebook file and its compiled module (`<name>.js`).
|
|
23
23
|
|
|
24
24
|
Try these cells, one per cell:
|
|
25
25
|
|
|
@@ -53,21 +53,30 @@ or install it globally to get the `iridium-dev-server` command everywhere:
|
|
|
53
53
|
npm i -g @a10k/iridium-dev-server
|
|
54
54
|
```
|
|
55
55
|
|
|
56
|
-
##
|
|
56
|
+
## Importing other notebooks
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
Every saved notebook is also compiled to `<name>.js` next to it, so one notebook can import cells from another with a path starting `./`, `../` or `/`:
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
import { points } from "./my-data.js"
|
|
60
62
|
```
|
|
61
63
|
|
|
62
|
-
|
|
64
|
+
Paths resolve against the page (the server root), so `./my-data.js` is the compiled `my-data` notebook. Save the imported notebook first so its module is up to date. Names without a path (`@d3/color-legend`, or a notebook id) still load from observablehq.com, and full URLs are imported as written.
|
|
65
|
+
|
|
66
|
+
Other relative URLs in cells and in the `head` option (`fetch("./data.json")`, `<img src="./libs/logo.svg">`, `<link href="./libs/index.css">`) also resolve against the server root, so files in the `static` or `compiled` folders work with `./` paths. `FileAttachment("x")` reads from the notebook's own files folder (`<notebooks>/<name>/`).
|
|
63
67
|
|
|
64
68
|
## Notebook list API
|
|
65
69
|
|
|
66
|
-
`GET /api/notebooks?q=&page=1&per_page=25&sort=name|modified` returns the notebooks whose name or title contains `q` (any case), one page at a time:
|
|
70
|
+
`GET /api/notebooks?q=&page=1&per_page=25&sort=name|modified` returns the notebooks whose name or title contains `q` (any case), one page at a time. For example, with `my-notebook` and `my-data` saved, `GET /api/notebooks?q=my` returns:
|
|
67
71
|
|
|
68
72
|
```json
|
|
69
|
-
{
|
|
70
|
-
"
|
|
73
|
+
{
|
|
74
|
+
"q": "my", "sort": "name", "page": 1, "per_page": 25, "pages": 1, "total": 2,
|
|
75
|
+
"items": [
|
|
76
|
+
{ "name": "my-data", "title": "my-data", "url": "/my-data", "modified": "2026-11-21T10:00:00.000Z", "cells": 3, "size": 812 },
|
|
77
|
+
{ "name": "my-notebook", "title": "my-notebook", "url": "/my-notebook", "modified": "2026-11-21T10:05:00.000Z", "cells": 5, "size": 1240 }
|
|
78
|
+
]
|
|
79
|
+
}
|
|
71
80
|
```
|
|
72
81
|
|
|
73
82
|
`DELETE /api/notebooks/<name>` moves a notebook and its attachments folder to the Trash (macOS's, restorable with Put Back; elsewhere a `.trash` folder in the notebooks folder) and removes its compiled module.
|
package/lib/viewer.js
CHANGED
|
@@ -6,8 +6,6 @@ export const viewerPage = ({ name, iridiumBase, filesBase, head }) => `<!DOCTYPE
|
|
|
6
6
|
<head>
|
|
7
7
|
<meta charset="utf-8" />
|
|
8
8
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
9
|
-
<!-- FileAttachment("x") resolves against the base URL: the notebook's files folder. -->
|
|
10
|
-
<base href="${filesBase}" />
|
|
11
9
|
<!-- The tab's connection to the server: macOS-style green dot when connected, grey otherwise. -->
|
|
12
10
|
<link rel="icon" id="iridium-status" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='6.5' fill='%23c8c8c8' stroke='%23a6a6a6'/%3E%3C/svg%3E" />
|
|
13
11
|
<title>${name.replace(/[<&]/g, '')} · Iridium</title>
|
|
@@ -35,6 +33,10 @@ export const viewerPage = ({ name, iridiumBase, filesBase, head }) => `<!DOCTYPE
|
|
|
35
33
|
};
|
|
36
34
|
|
|
37
35
|
// This page edits one notebook, named by the URL.
|
|
36
|
+
// FileAttachment("x") is in the notebook's files folder. No <base>, so
|
|
37
|
+
// other relative URLs (fetch, img, head links) resolve against the
|
|
38
|
+
// server root, next to the notebooks.
|
|
39
|
+
Iridium.files_base = ${json(filesBase)};
|
|
38
40
|
Iridium.get_recent = () => name;
|
|
39
41
|
Iridium.set_recent = () => {};
|
|
40
42
|
Iridium.list = () => post('/list', {});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@a10k/iridium-dev-server",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "Local dev server for working with Observable notebooks.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"node": ">=22"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@a10k/iridium": "~0.0.
|
|
27
|
+
"@a10k/iridium": "~0.0.3",
|
|
28
28
|
"@koa/bodyparser": "^6.1.0",
|
|
29
29
|
"@koa/cors": "^5.0.0",
|
|
30
30
|
"@koa/router": "^15.7.1",
|