@lensmap/starlight 0.2.0 → 0.3.0
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/ViewerHost.css +15 -0
- package/dist/ViewerHost.d.ts +5 -1
- package/dist/ViewerHost.js +637 -245
- package/dist/components/MapContent.astro +2 -1
- package/dist/index.js +16 -1
- package/dist/layout.js +38 -13
- package/package.json +20 -21
|
@@ -10,6 +10,7 @@ interface Props {
|
|
|
10
10
|
authoredFrontmatter: Record<string, unknown>;
|
|
11
11
|
executable: boolean;
|
|
12
12
|
inspectorId?: string;
|
|
13
|
+
mapId?: string;
|
|
13
14
|
}
|
|
14
15
|
const { graph: semantic, executable, inspectorId = "default" } = Astro.props;
|
|
15
16
|
const entry = Astro.props.entry ?? Astro.locals.starlightRoute?.entry;
|
|
@@ -29,7 +30,7 @@ const publicGraph = {
|
|
|
29
30
|
};
|
|
30
31
|
---
|
|
31
32
|
<div data-lensmap-document data-executable={String(executable)}>
|
|
32
|
-
<div class="not-content"><ViewerHost client:load graph={publicGraph} rendered={rendered} inspectorId={inspectorId} /></div>
|
|
33
|
+
<div class="not-content"><ViewerHost client:load mapId={Astro.props.mapId} graph={publicGraph} rendered={rendered} inspectorId={inspectorId} /></div>
|
|
33
34
|
<section data-static-thoughts>
|
|
34
35
|
{graph.nodes.map((node) => <section data-thought={node.key}><h2>{node.title}</h2><div set:html={rendered[node.key]} /></section>)}
|
|
35
36
|
</section>
|
package/dist/index.js
CHANGED
|
@@ -2,12 +2,27 @@
|
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
import lensmap from "@lensmap/astro-loader";
|
|
4
4
|
function starlightLensmap(options = {}) {
|
|
5
|
-
|
|
5
|
+
const integration = lensmap({
|
|
6
6
|
...options,
|
|
7
7
|
contentComponent: fileURLToPath(
|
|
8
8
|
new URL("./components/MapContent.astro", import.meta.url)
|
|
9
9
|
)
|
|
10
10
|
});
|
|
11
|
+
const setup = integration.hooks["astro:config:setup"];
|
|
12
|
+
integration.hooks["astro:config:setup"] = async (context) => {
|
|
13
|
+
await setup?.(context);
|
|
14
|
+
context.updateConfig({
|
|
15
|
+
vite: {
|
|
16
|
+
optimizeDeps: {
|
|
17
|
+
include: [
|
|
18
|
+
"@lensmap/starlight > @lensmap/document",
|
|
19
|
+
"@lensmap/starlight > react-markdown"
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
return integration;
|
|
11
26
|
}
|
|
12
27
|
export {
|
|
13
28
|
starlightLensmap as default
|
package/dist/layout.js
CHANGED
|
@@ -74,8 +74,9 @@ function layoutGraph(nodes, edges) {
|
|
|
74
74
|
}
|
|
75
75
|
const roots = nodes.filter((node) => !childKeys.has(node.key));
|
|
76
76
|
const placed = /* @__PURE__ */ new Map();
|
|
77
|
-
const
|
|
78
|
-
const
|
|
77
|
+
const maximum = Math.max(43, ...nodes.map((n) => n.baseRadius ?? 43));
|
|
78
|
+
const step = Math.max(180, maximum * 2 + 24);
|
|
79
|
+
const padding = Math.max(56, maximum + 13);
|
|
79
80
|
function plan(node, isRoot) {
|
|
80
81
|
const descendants = (children.get(node.key) ?? []).map(
|
|
81
82
|
(child) => plan(child, false)
|
|
@@ -132,12 +133,13 @@ function layoutGraph(nodes, edges) {
|
|
|
132
133
|
);
|
|
133
134
|
simulation.tick(ticks);
|
|
134
135
|
return {
|
|
135
|
-
nodes: nodes.map(({ position
|
|
136
|
+
nodes: nodes.map(({ position, ...node }) => {
|
|
136
137
|
const point = placed.get(node.key);
|
|
137
138
|
if (!point)
|
|
138
139
|
throw new Error(`Automatic layout could not place node "${node.key}".`);
|
|
139
140
|
return {
|
|
140
141
|
...node,
|
|
142
|
+
...position ? { position } : {},
|
|
141
143
|
x: point.x,
|
|
142
144
|
y: point.y
|
|
143
145
|
};
|
|
@@ -146,10 +148,19 @@ function layoutGraph(nodes, edges) {
|
|
|
146
148
|
};
|
|
147
149
|
}
|
|
148
150
|
|
|
151
|
+
// ../../apps/web/src/node-style.ts
|
|
152
|
+
function baseRadius(style) {
|
|
153
|
+
return 43 * (typeof style?.scale === "number" ? style.scale : 1);
|
|
154
|
+
}
|
|
155
|
+
|
|
149
156
|
// ../../apps/web/src/semantic-layout.ts
|
|
150
157
|
var branches = ["blue", "amber", "mint", "rose"];
|
|
151
158
|
var layoutKey = (graph) => JSON.stringify({
|
|
152
|
-
nodes: graph.nodes.map((node) => [
|
|
159
|
+
nodes: graph.nodes.map((node) => [
|
|
160
|
+
node.key,
|
|
161
|
+
node.position,
|
|
162
|
+
baseRadius(node.style)
|
|
163
|
+
]),
|
|
153
164
|
edges: graph.edges.map((edge) => [edge.key, edge.from, edge.to, edge.kind])
|
|
154
165
|
});
|
|
155
166
|
function layoutSemanticGraph(graph, previous) {
|
|
@@ -177,30 +188,44 @@ function layoutSemanticGraph(graph, previous) {
|
|
|
177
188
|
colour(node.key, branches[i % branches.length], 0);
|
|
178
189
|
});
|
|
179
190
|
const drafts = graph.nodes.map(
|
|
180
|
-
({
|
|
191
|
+
({
|
|
192
|
+
key,
|
|
193
|
+
id,
|
|
194
|
+
title,
|
|
195
|
+
markdown,
|
|
196
|
+
unresolved,
|
|
197
|
+
position,
|
|
198
|
+
destination,
|
|
199
|
+
style
|
|
200
|
+
}) => ({
|
|
181
201
|
key,
|
|
182
202
|
id,
|
|
183
203
|
title,
|
|
184
204
|
markdown,
|
|
185
205
|
unresolved,
|
|
186
206
|
position,
|
|
207
|
+
style,
|
|
208
|
+
baseRadius: baseRadius(style),
|
|
187
209
|
...destination ? { destination } : {},
|
|
188
210
|
branch: colours.get(key) ?? "blue"
|
|
189
211
|
})
|
|
190
212
|
);
|
|
191
|
-
const edges = graph.edges.map(
|
|
192
|
-
key,
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
213
|
+
const edges = graph.edges.map(
|
|
214
|
+
({ key, from, to, kind, type, presentation }) => ({
|
|
215
|
+
key,
|
|
216
|
+
from,
|
|
217
|
+
to,
|
|
218
|
+
kind,
|
|
219
|
+
...type !== void 0 ? { type } : {},
|
|
220
|
+
...presentation ? { presentation } : {}
|
|
221
|
+
})
|
|
222
|
+
);
|
|
198
223
|
if (previous && layoutKey(previous.semantic) === layoutKey(graph)) {
|
|
199
224
|
const points = new Map(
|
|
200
225
|
previous.layout.nodes.map((node) => [node.key, node])
|
|
201
226
|
);
|
|
202
227
|
return {
|
|
203
|
-
nodes: drafts.map((
|
|
228
|
+
nodes: drafts.map((node) => ({
|
|
204
229
|
...node,
|
|
205
230
|
x: points.get(node.key)?.x ?? 0,
|
|
206
231
|
y: points.get(node.key)?.y ?? 0
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.
|
|
2
|
+
"version": "0.3.0",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
@@ -32,37 +32,36 @@
|
|
|
32
32
|
},
|
|
33
33
|
"./viewer.css": "./dist/ViewerHost.css"
|
|
34
34
|
},
|
|
35
|
-
"scripts": {
|
|
36
|
-
"build": "node build.mjs",
|
|
37
|
-
"typecheck": "tsc -p tsconfig.check.json",
|
|
38
|
-
"test": "node --test test/*.test.ts",
|
|
39
|
-
"prepack": "pnpm build"
|
|
40
|
-
},
|
|
41
35
|
"dependencies": {
|
|
42
|
-
"@lensmap/astro-loader": "
|
|
43
|
-
"@lensmap/document": "
|
|
44
|
-
"react-markdown": "10.1.0",
|
|
36
|
+
"@lensmap/astro-loader": "0.3.0",
|
|
37
|
+
"@lensmap/document": "0.3.0",
|
|
45
38
|
"d3-force": "3.0.1",
|
|
46
|
-
"d3-polygon": "3.0.2"
|
|
39
|
+
"d3-polygon": "3.0.2",
|
|
40
|
+
"react-markdown": "10.1.0"
|
|
47
41
|
},
|
|
48
42
|
"peerDependencies": {
|
|
49
|
-
"astro": "7.4.0",
|
|
50
|
-
"@astrojs/starlight": "0.42.6",
|
|
51
43
|
"@astrojs/react": "6.0.6",
|
|
44
|
+
"@astrojs/starlight": "0.42.6",
|
|
45
|
+
"astro": "7.4.0",
|
|
52
46
|
"react": "19.3.1",
|
|
53
47
|
"react-dom": "19.3.1"
|
|
54
48
|
},
|
|
55
49
|
"devDependencies": {
|
|
56
|
-
"@lensmap/web": "workspace:*",
|
|
57
|
-
"astro": "7.4.0",
|
|
58
|
-
"@astrojs/starlight": "0.42.6",
|
|
59
50
|
"@astrojs/react": "6.0.6",
|
|
60
|
-
"
|
|
61
|
-
"
|
|
51
|
+
"@astrojs/starlight": "0.42.6",
|
|
52
|
+
"@lensmap/web": "0.0.0",
|
|
53
|
+
"@types/node": "24.19.2",
|
|
62
54
|
"@types/react": "19.3.0",
|
|
63
55
|
"@types/react-dom": "19.3.0",
|
|
56
|
+
"astro": "7.4.0",
|
|
64
57
|
"esbuild": "0.28.2",
|
|
65
|
-
"
|
|
66
|
-
"
|
|
58
|
+
"react": "19.3.1",
|
|
59
|
+
"react-dom": "19.3.1",
|
|
60
|
+
"typescript": "7.0.2"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "node build.mjs",
|
|
64
|
+
"typecheck": "tsc -p tsconfig.check.json",
|
|
65
|
+
"test": "node --test test/*.test.ts"
|
|
67
66
|
}
|
|
68
|
-
}
|
|
67
|
+
}
|