@orbytes/astrolab 0.3.0 → 0.4.0-next.1

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.
Files changed (69) hide show
  1. package/README.md +109 -64
  2. package/defaults.mjs +65 -0
  3. package/dist/core/virtual-module/virtual-routes.js +12 -1
  4. package/docs/PIN-CONTRACT.md +8 -0
  5. package/docs/PIN.md +29 -19
  6. package/index.d.ts +40 -16
  7. package/index.mjs +32 -10
  8. package/package.json +6 -2
  9. package/src/Home.astro +167 -264
  10. package/src/LabHead.astro +37 -1047
  11. package/src/chrome/ComponentCard.astro +69 -0
  12. package/src/chrome/Icon.astro +21 -0
  13. package/src/chrome/LICENSE-icons +43 -0
  14. package/src/chrome/Nav.astro +105 -0
  15. package/src/chrome/Panel.astro +104 -0
  16. package/src/chrome/Shell.astro +106 -0
  17. package/src/chrome/Sprite.astro +23 -0
  18. package/src/chrome/StoryView.astro +251 -0
  19. package/src/chrome/Tree.astro +83 -0
  20. package/src/chrome/ViewportControls.astro +98 -0
  21. package/src/chrome/ViewportStage.astro +32 -0
  22. package/src/chrome/fonts/OFL.txt +93 -0
  23. package/src/chrome/fonts/inter-latin-wght-normal.woff2 +0 -0
  24. package/src/chrome/icons.ts +59 -0
  25. package/src/chrome/marks-client.ts +102 -0
  26. package/src/chrome/model.ts +142 -0
  27. package/src/chrome/pins-data.ts +30 -0
  28. package/src/chrome/shell-client.ts +372 -0
  29. package/src/chrome/site-data.ts +230 -0
  30. package/src/chrome/trees.ts +152 -0
  31. package/src/chrome/viewport-client.ts +579 -0
  32. package/src/chrome/views/Assets.astro +110 -0
  33. package/src/chrome/views/Pages.astro +178 -0
  34. package/src/chrome/views/Placeholder.astro +37 -0
  35. package/src/chrome/views/Tasks.astro +107 -0
  36. package/src/core/LICENSE-astrobook +16 -0
  37. package/src/core/lib/components/home.astro +4 -2
  38. package/src/core/lib/pages/story.astro +12 -10
  39. package/src/core/virtual-module/virtual-routes.ts +20 -4
  40. package/src/pin/board.mjs +389 -175
  41. package/src/pin/index.mjs +33 -2
  42. package/src/pin/toolbar.js +1 -1
  43. package/src/shell/Browse.astro +106 -353
  44. package/src/shell/Viewport.astro +22 -1315
  45. package/src/shell/lab-index.ts +23 -14
  46. package/src/ui/components/app.astro +5 -7
  47. package/src/ui/components/theme-script.astro +13 -2
  48. package/src/ui/lab.css +2152 -370
  49. package/virtual.d.ts +13 -0
  50. package/src/shell/CardGrid.astro +0 -297
  51. package/src/ui/components/build-path.ts +0 -13
  52. package/src/ui/components/build-tree.ts +0 -108
  53. package/src/ui/components/collapse-duration.ts +0 -28
  54. package/src/ui/components/compress-terms.ts +0 -10
  55. package/src/ui/components/dashboard-layout.astro +0 -39
  56. package/src/ui/components/home.astro +0 -65
  57. package/src/ui/components/layout.astro +0 -110
  58. package/src/ui/components/sidebar-button-fullscreen.astro +0 -38
  59. package/src/ui/components/sidebar-button-search.astro +0 -23
  60. package/src/ui/components/sidebar-button-theme.astro +0 -9
  61. package/src/ui/components/sidebar-button.astro +0 -24
  62. package/src/ui/components/sidebar-resize-handle.astro +0 -74
  63. package/src/ui/components/sidebar-search-panel.astro +0 -41
  64. package/src/ui/components/sidebar-search-script.ts +0 -103
  65. package/src/ui/components/sidebar-title.astro +0 -17
  66. package/src/ui/components/sidebar-tree-node.astro +0 -143
  67. package/src/ui/components/sidebar-tree.astro +0 -84
  68. package/src/ui/components/sidebar.astro +0 -29
  69. package/src/ui/components/theme-toggle.astro +0 -63
@@ -13,8 +13,8 @@
13
13
  // survives a multi-page site.
14
14
  // 5. <directory>/responsive.json, through marks.mjs — the hand-set responsive marks. The one
15
15
  // thing here that is ticked rather than derived, because approval cannot be read from code.
16
- // 6. The stories files themselves — the component they render, the leading comment (summary)
17
- // and, through import.meta.glob, the default export's optional `meta.tags`.
16
+ // 6. The stories files themselves, read as text — the component they render, the leading
17
+ // comment (summary) and the default export's optional `meta.tags`.
18
18
  //
19
19
  // Classification is by Astrobook `directory` (relative to its `directory` option):
20
20
  // <tier>/<Section>/<Version>/… tier = first segment; for the tier holding the RESPONSIVE role
@@ -108,17 +108,26 @@ export interface LabIndex {
108
108
  live: { file: string; page: string; slot: number; of: number }[];
109
109
  }
110
110
 
111
- // Only for the optional `meta` on a story module's default export — Astrobook ignores unknown
112
- // keys, so `export default { component, meta: { tags: [...] } }` is legal and this is where it is
113
- // read. Keys are root-relative (`/src/...`); the pattern covers both the current and target trees.
114
- const storyExports = import.meta.glob("/src/**/*.stories.ts", { eager: true }) as Record<
115
- string,
116
- { default?: { meta?: { tags?: unknown } } } | undefined
117
- >;
118
-
119
- const tagsOf = (moduleFile: string): string[] => {
120
- const tags = storyExports[`/${moduleFile}`]?.default?.meta?.tags;
121
- return Array.isArray(tags) ? tags.filter((t): t is string => typeof t === "string") : [];
111
+ // The optional `meta.tags` on a story module's default export — Astrobook ignores unknown keys, so
112
+ // `export default { component, meta: { tags: ["cta", "v2"] } }` is legal and this is where it is
113
+ // read.
114
+ //
115
+ // READ AS TEXT, NOT IMPORTED (2026-09-24, ASTROL-12). This used to be an EAGER
116
+ // `import.meta.glob("/src/**/*.stories.ts")`, and importing a stories file imports the component it
117
+ // renders — so every chrome page's module graph held every section, and Astro put every section's
118
+ // scoped stylesheet on every chrome page (18 of them on the lab home). The tags are string
119
+ // literals in the file, so a parse of its text gives the same answer and imports nothing. A tag
120
+ // built at runtime is not seen, which a tag never needs to be.
121
+ const tagsOf = (rootDir: string, moduleFile: string): string[] => {
122
+ let source = "";
123
+ try {
124
+ source = readFileSync(path.join(rootDir, moduleFile), "utf8");
125
+ } catch {
126
+ return [];
127
+ }
128
+ const list = source.match(/\bmeta\s*:\s*\{[^}]*?\btags\s*:\s*\[([^\]]*)\]/);
129
+ if (!list) return [];
130
+ return [...list[1]!.matchAll(/["'`]([^"'`\n]+)["'`]/g)].map((m) => m[1]!);
122
131
  };
123
132
 
124
133
  // First sentence of the leading `//` comment block — the stories files already open with the
@@ -200,7 +209,7 @@ export function buildLabIndex(): LabIndex {
200
209
  const liveOn = (componentFile ? mountsByFile.get(componentFile) : undefined) ?? [];
201
210
  const primary = liveOn[0];
202
211
  const { tier, section, version } = classify(mod.directory);
203
- const tags = tagsOf(moduleFile);
212
+ const tags = tagsOf(rootDir, moduleFile);
204
213
  const summary = summaryOf(rootDir, moduleFile);
205
214
  const responsive = RESPONSIVE_DIR && moduleFile.startsWith(RESPONSIVE_DIR)
206
215
  ? { done: doneMarks.has(moduleFile), approved: approvedMarks.has(moduleFile) }
@@ -1,13 +1,11 @@
1
1
  ---
2
2
  // Vendored from astrobook 0.13.3 (packages/ui/src/components/app.astro) — see
3
- // ../../core/LICENSE-astrobook. Unchanged apart from the .astro extension on the relative import.
3
+ // ../../core/LICENSE-astrobook.
4
4
  //
5
- // The `/lab` home page: pure chrome, so it renders through ./layout.astro and gets no consumer
6
- // CSS at all (ruled 2026-09-22 — ../lab.css).
7
- import Layout from './layout.astro'
5
+ // The `/lab` home page. Divergence: upstream wrapped the `home` component in its layout; since the
6
+ // redesign (2026-09-24) the home component IS the whole document — it renders through the
7
+ // package's chrome shell (../../chrome/Shell.astro) itself, so this file only mounts it.
8
8
  import Home from 'virtual:astrobook/components/home.mjs'
9
9
  ---
10
10
 
11
- <Layout story={undefined} hasSidebar={true}>
12
- <Home />
13
- </Layout>
11
+ <Home />
@@ -18,11 +18,22 @@
18
18
  //
19
19
  // `is:inline` and no bundling on purpose: this must run before the first paint, or the lab
20
20
  // flashes light before turning dark.
21
+ //
22
+ // TWO THEMES SINCE 2026-09-24, one per KEY. The chrome's light/dark and the preview's are
23
+ // separate (decided that day): switching the lab to dark must not switch the site inside the
24
+ // frame. Both documents share an origin and so share localStorage, so the only thing that can
25
+ // keep them apart is the key — the chrome passes `lab-chrome-theme`, and the preview keeps the
26
+ // original `theme-toggle`, so a preview preference stored before the split still applies.
27
+ interface Props {
28
+ storageKey?: string;
29
+ }
30
+
31
+ const { storageKey = "theme-toggle" } = Astro.props;
21
32
  ---
22
33
 
23
- <script is:inline>
34
+ <script is:inline define:vars={{ storageKey }}>
24
35
  (() => {
25
- const STORAGE_KEY = "theme-toggle";
36
+ const STORAGE_KEY = storageKey;
26
37
  let current;
27
38
 
28
39
  const systemTheme = () =>