@lensmap/starlight 0.0.0-stage → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Lensmap contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,99 @@
1
- # Temporary Holding Version
1
+ # @lensmap/starlight
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Experimental Starlight composition for Lensmap documents. Qualified against **Astro 7.4.0**, **Starlight 0.42.6**, **@astrojs/react 6.0.6**, and **React / React DOM 19.3.1**. Its loader's private Astro content seam is checked and deliberately version-bound. Node >=24.16 is required.
4
+
5
+ ```sh
6
+ pnpm add @lensmap/starlight @lensmap/astro-loader @lensmap/document \
7
+ astro@7.4.0 @astrojs/starlight@0.42.6 @astrojs/react@6.0.6 react@19.3.1 react-dom@19.3.1
8
+ ```
9
+
10
+ ```js
11
+ // astro.config.mjs
12
+ import { defineConfig } from "astro/config";
13
+ import starlight from "@astrojs/starlight";
14
+ import react from "@astrojs/react";
15
+ import lensmap from "@lensmap/starlight";
16
+ export default defineConfig({
17
+ integrations: [starlight({ title: "My notes" }), react(), lensmap()],
18
+ });
19
+ ```
20
+
21
+ ```ts
22
+ // src/content.config.ts
23
+ import { defineCollection } from "astro:content";
24
+ import { glob } from "astro/loaders";
25
+ import { docsSchema } from "@astrojs/starlight/schema";
26
+ export const collections = {
27
+ docs: defineCollection({
28
+ loader: glob({
29
+ pattern: "**/*.{md,mdx,lensmap}",
30
+ base: "./src/content/docs",
31
+ }),
32
+ schema: docsSchema(),
33
+ }),
34
+ };
35
+ ```
36
+
37
+ Keep `frontmatter.title` and any host schema fields in the `.lensmap` source. Native collection validation/defaults, routes, generated navigation, draft exclusion and searchable static content continue to belong to Astro/Starlight. **The stock Starlight docs loader does not include `.lensmap` automatically**: use the mixed native glob above, or compose the host's current loader deliberately. Do not silently replace custom ID/localization behavior with this minimal example.
38
+
39
+ `lensmap(options)` forwards loader execution options. Starlight installs its MDX integration; execution still requires explicit `mdx.admittedSources` in this integration. See `@lensmap/astro-loader` for the trust boundary. Default Markdown stays inert and inherits site processing; same origin or precompiled HTML never grants execution permission.
40
+
41
+ ## Host-owned sidebar composition
42
+
43
+ This package does **not** replace host panels, TOC or component overrides automatically. Extend the host's existing `PageSidebar` override, using these supported package components:
44
+
45
+ - `@lensmap/starlight/components/SidebarShell.astro`: `mobile-panels`, `mobile-inspector`, `mobile-toc`, `context-panels`, `inspector`, `toc` slots.
46
+ - `@lensmap/starlight/components/LiveInspector.astro`: desktop inspector mount.
47
+ - `@lensmap/starlight/components/MobileThoughts.astro`: independent, initially closed native **Thoughts** disclosure, using Starlight's public `Icon` / `right-caret`.
48
+ - `@lensmap/starlight/components/MapContent.astro`: normally selected by the integration, usable for explicit composition.
49
+
50
+ A minimal override, retaining ordinary-doc behavior:
51
+
52
+ ```astro
53
+ ---
54
+ import DefaultPageSidebar from '@astrojs/starlight/components/PageSidebar.astro';
55
+ import Shell from '@lensmap/starlight/components/SidebarShell.astro';
56
+ import Inspector from '@lensmap/starlight/components/LiveInspector.astro';
57
+ import Thoughts from '@lensmap/starlight/components/MobileThoughts.astro';
58
+ const isMap = Astro.locals.starlightRoute.entry.filePath?.endsWith('.lensmap');
59
+ ---
60
+ {isMap ? (
61
+ <Shell>
62
+ <div slot="context-panels"><!-- Your existing host panels --></div>
63
+ <Inspector slot="inspector" />
64
+ <Thoughts slot="mobile-inspector" />
65
+ <div slot="mobile-panels"><!-- Your existing mobile panels --></div>
66
+ <div slot="toc"><!-- Your existing host TOC composition --></div>
67
+ </Shell>
68
+ ) : <DefaultPageSidebar {...Astro.props} />}
69
+ ```
70
+
71
+ For a host override already composing panels/TOC, insert these mounts into that override rather than copying private Starlight controllers or IDs. Starlight can gate its entire right rail when TOC is disabled; this package does not fabricate headings or override that route policy. If you disable the rail, supply an explicit alternative mount. `inspectorId` on mounts and `<Content>` defaults to `default`; use matching unique IDs when deliberately composing multiple map sessions on one page. The normal native docs route renders one map/session.
72
+
73
+ ## Preserved viewer/reading behavior
74
+
75
+ The package build bundles the **existing Lensmap Viewer, ViewerConnections and layout/session implementation** into `dist`. It does not reimplement graph geometry or depend at runtime on the private web workspace. Semantic graph colors and readable node foregrounds remain viewer-owned; neutral chrome follows real Starlight tokens and inherited fonts.
76
+
77
+ The inspector portals into the responsive mounts from one live viewer session. Shared outgoing/incoming relationship wording, disclosures, empty states and focus callbacks are retained. Short thoughts are shown in full. Long thoughts get a text excerpt and accessible Show more/Show less; the original prepared HTML is genuinely hidden while collapsed, expands in normal page flow and resets on selection. No nested note scrollbar is added. Map-only desktop rails use natural height; ordinary docs retain native behavior.
78
+
79
+ Only the interactive viewer is inside `not-content`, keeping host prose spacing out of graph coordinates. The lower full article is server-rendered, always visible without JavaScript, in normal prose flow, with **no generated outer All thought content heading or disclosure**. Authored headings and summaries are not deduplicated or rewritten.
80
+
81
+ The mobile disclosure is independent of host panels/TOC. Changing selection does not force it open or scroll it. It uses native summary activation, not Escape/outside-auto-close behavior.
82
+
83
+ ## Optional rendered connection labels
84
+
85
+ For custom React compositions, `@lensmap/starlight/viewer` exports the bundled `ViewerHost` (default), `ViewerHostProps`, `GraphData` and `GraphNode` types. Import `@lensmap/starlight/viewer.css` once. Its `getLabel(node)` callback customizes only connection labels; shared directional algorithms remain unchanged. The default extracts a heading from already-rendered thought HTML. Supply callbacks inside a host React component, not as serialized Astro island props.
86
+
87
+ Prepared selected HTML is an HTML snapshot, not a second Astro island hydration root. Admitted MDX renders natively in the static article; this release does not promise independent hydration/lifecycle of arbitrary client components copied into the selected inspector. No metadata/request contexts are serialized by default: the island receives public laid-out graph data (without raw Markdown), prepared thought strings and a mount ID.
88
+
89
+ ## Verification
90
+
91
+ After workspace dependencies, document and loader builds:
92
+
93
+ ```sh
94
+ pnpm --filter @lensmap/starlight build
95
+ pnpm --filter @lensmap/starlight typecheck
96
+ pnpm --filter @lensmap/starlight test
97
+ ```
98
+
99
+ The synthetic native Starlight build/Playwright test covers no-JS full reading, actual MDX entry data, draft exclusion, metadata-free island props, live directional navigation, long/short prose and selection reset, closed mobile behavior/caret, host panel independence, Starlight light/dark changes, geometry alignment at desktop/intermediate/mobile widths and ordinary docs. Tests use the workspace's Playwright/Chromium tooling; no browser or BF content ships in this artifact.