@lensmap/starlight 0.2.1 → 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.
@@ -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
- return lensmap({
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 step = 180;
78
- const padding = 56;
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: _position, ...node }) => {
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) => [node.key, node.position]),
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
- ({ key, id, title, markdown, unresolved, position, destination }) => ({
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(({ key, from, to, kind, type }) => ({
192
- key,
193
- from,
194
- to,
195
- kind,
196
- ...type !== void 0 ? { type } : {}
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(({ position: _position, ...node }) => ({
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.1",
2
+ "version": "0.3.0",
3
3
  "type": "module",
4
4
  "license": "MIT",
5
5
  "files": [
@@ -33,31 +33,31 @@
33
33
  "./viewer.css": "./dist/ViewerHost.css"
34
34
  },
35
35
  "dependencies": {
36
- "@lensmap/astro-loader": "0.2.1",
37
- "@lensmap/document": "0.2.1",
38
- "react-markdown": "10.1.0",
36
+ "@lensmap/astro-loader": "0.3.0",
37
+ "@lensmap/document": "0.3.0",
39
38
  "d3-force": "3.0.1",
40
- "d3-polygon": "3.0.2"
39
+ "d3-polygon": "3.0.2",
40
+ "react-markdown": "10.1.0"
41
41
  },
42
42
  "peerDependencies": {
43
- "astro": "7.4.0",
44
- "@astrojs/starlight": "0.42.6",
45
43
  "@astrojs/react": "6.0.6",
44
+ "@astrojs/starlight": "0.42.6",
45
+ "astro": "7.4.0",
46
46
  "react": "19.3.1",
47
47
  "react-dom": "19.3.1"
48
48
  },
49
49
  "devDependencies": {
50
- "@lensmap/web": "0.0.0",
51
- "astro": "7.4.0",
52
- "@astrojs/starlight": "0.42.6",
53
50
  "@astrojs/react": "6.0.6",
54
- "react": "19.3.1",
55
- "react-dom": "19.3.1",
51
+ "@astrojs/starlight": "0.42.6",
52
+ "@lensmap/web": "0.0.0",
53
+ "@types/node": "24.19.2",
56
54
  "@types/react": "19.3.0",
57
55
  "@types/react-dom": "19.3.0",
56
+ "astro": "7.4.0",
58
57
  "esbuild": "0.28.2",
59
- "typescript": "7.0.2",
60
- "@types/node": "24.19.2"
58
+ "react": "19.3.1",
59
+ "react-dom": "19.3.1",
60
+ "typescript": "7.0.2"
61
61
  },
62
62
  "scripts": {
63
63
  "build": "node build.mjs",