@treeseed/core 0.1.2

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 (384) hide show
  1. package/README.md +145 -0
  2. package/dist/agents/index.js +5 -0
  3. package/dist/agents/registry-helper.js +14 -0
  4. package/dist/agents/registry.js +88 -0
  5. package/dist/components/DevWatchReload.astro +45 -0
  6. package/dist/components/SiteTitle.astro +51 -0
  7. package/dist/components/content/ContentStatusLegend.astro +18 -0
  8. package/dist/components/content/StatusBadge.astro +11 -0
  9. package/dist/components/docs/BookFontControls.astro +180 -0
  10. package/dist/components/docs/DesktopSidebarToggle.astro +88 -0
  11. package/dist/components/docs/DownloadBook.astro +34 -0
  12. package/dist/components/docs/Footer.astro +196 -0
  13. package/dist/components/docs/Header.astro +150 -0
  14. package/dist/components/docs/PageFrame.astro +260 -0
  15. package/dist/components/docs/PageSidebar.astro +63 -0
  16. package/dist/components/docs/PageTitle.astro +39 -0
  17. package/dist/components/docs/Sidebar.astro +41 -0
  18. package/dist/components/docs/ThemeSelect.astro +3 -0
  19. package/dist/components/forms/ContactForm.astro +234 -0
  20. package/dist/components/forms/FooterSubscribeForm.astro +189 -0
  21. package/dist/components/site/BookList.astro +27 -0
  22. package/dist/components/site/CTASection.astro +24 -0
  23. package/dist/components/site/ChronicleList.astro +33 -0
  24. package/dist/components/site/Hero.astro +18 -0
  25. package/dist/components/site/NotesList.astro +18 -0
  26. package/dist/components/site/PathCard.astro +16 -0
  27. package/dist/components/site/ProfileList.astro +30 -0
  28. package/dist/components/site/SectionIntro.astro +9 -0
  29. package/dist/components/site/StageBanner.astro +8 -0
  30. package/dist/components/site/TrustCallout.astro +9 -0
  31. package/dist/components/starlight.js +6 -0
  32. package/dist/config.js +8 -0
  33. package/dist/content-config.js +9 -0
  34. package/dist/content.js +230 -0
  35. package/dist/contracts.d.ts +130 -0
  36. package/dist/contracts.js +0 -0
  37. package/dist/deploy/config.d.ts +4 -0
  38. package/dist/deploy/config.js +154 -0
  39. package/dist/deploy/runtime.js +77 -0
  40. package/dist/env.yaml +322 -0
  41. package/dist/environment.d.ts +130 -0
  42. package/dist/environment.js +324 -0
  43. package/dist/index.js +81 -0
  44. package/dist/layouts/AuthoredEntryLayout.astro +87 -0
  45. package/dist/layouts/BookLayout.astro +35 -0
  46. package/dist/layouts/BridgeLayout.astro +11 -0
  47. package/dist/layouts/ContentLayout.astro +24 -0
  48. package/dist/layouts/MainLayout.astro +203 -0
  49. package/dist/layouts/NoteLayout.astro +26 -0
  50. package/dist/layouts/ProfileLayout.astro +81 -0
  51. package/dist/middleware/starlightRouteData.js +45 -0
  52. package/dist/pages/404.astro +29 -0
  53. package/dist/pages/[slug].astro +30 -0
  54. package/dist/pages/agents/[slug].astro +29 -0
  55. package/dist/pages/agents/index.astro +27 -0
  56. package/dist/pages/api/form/submit.js +14 -0
  57. package/dist/pages/books/[slug].astro +19 -0
  58. package/dist/pages/books/index.astro +28 -0
  59. package/dist/pages/contact.astro +27 -0
  60. package/dist/pages/feed.xml.js +34 -0
  61. package/dist/pages/index.astro +290 -0
  62. package/dist/pages/notes/[slug].astro +19 -0
  63. package/dist/pages/notes/index.astro +21 -0
  64. package/dist/pages/objectives/[slug].astro +31 -0
  65. package/dist/pages/objectives/index.astro +30 -0
  66. package/dist/pages/people/[slug].astro +29 -0
  67. package/dist/pages/people/index.astro +28 -0
  68. package/dist/pages/questions/[slug].astro +31 -0
  69. package/dist/pages/questions/index.astro +30 -0
  70. package/dist/plugin-default.js +4 -0
  71. package/dist/plugins/builtin/default-plugin.d.ts +21 -0
  72. package/dist/plugins/builtin/default-plugin.js +32 -0
  73. package/dist/plugins/constants.d.ts +21 -0
  74. package/dist/plugins/constants.js +28 -0
  75. package/dist/plugins/plugin.d.ts +42 -0
  76. package/dist/plugins/plugin.js +6 -0
  77. package/dist/plugins/runtime.d.ts +31 -0
  78. package/dist/plugins/runtime.js +120 -0
  79. package/dist/scripts/aggregate-book.js +112 -0
  80. package/dist/scripts/assert-release-tag-version.js +21 -0
  81. package/dist/scripts/build-dist.js +384 -0
  82. package/dist/scripts/build-tenant-worker.js +36 -0
  83. package/dist/scripts/package-tools.js +88 -0
  84. package/dist/scripts/patch-starlight-content-path.js +172 -0
  85. package/dist/scripts/paths.js +11 -0
  86. package/dist/scripts/publish-package.js +20 -0
  87. package/dist/scripts/release-verify.js +52 -0
  88. package/dist/scripts/run-fixture-astro-command.js +21 -0
  89. package/dist/scripts/tenant-astro-command.js +3 -0
  90. package/dist/scripts/tenant-build.js +16 -0
  91. package/dist/scripts/tenant-check.js +7 -0
  92. package/dist/scripts/test-smoke.js +105 -0
  93. package/dist/server.js +53 -0
  94. package/dist/site-resources.d.ts +29 -0
  95. package/dist/site-resources.js +127 -0
  96. package/dist/site.js +313 -0
  97. package/dist/styles/global.css +683 -0
  98. package/dist/styles/prose.css +89 -0
  99. package/dist/styles/tokens.css +24 -0
  100. package/dist/tenant/bridge.js +5 -0
  101. package/dist/tenant/config.d.ts +9 -0
  102. package/dist/tenant/config.js +124 -0
  103. package/dist/tenant/runtime-config.js +20 -0
  104. package/dist/tsconfigs/strict.json +3 -0
  105. package/dist/types/agents.d.ts +1 -0
  106. package/dist/types/agents.js +1 -0
  107. package/dist/types/astro-build.d.js +0 -0
  108. package/dist/types/cloudflare-sockets.d.js +0 -0
  109. package/dist/types/cloudflare.d.ts +1 -0
  110. package/dist/types/cloudflare.js +1 -0
  111. package/dist/types/forms.js +4 -0
  112. package/dist/utils/agents/adapters/execution.js +90 -0
  113. package/dist/utils/agents/adapters/mutations.js +30 -0
  114. package/dist/utils/agents/adapters/notification.js +16 -0
  115. package/dist/utils/agents/adapters/repository.js +61 -0
  116. package/dist/utils/agents/adapters/research.js +25 -0
  117. package/dist/utils/agents/adapters/verification.js +62 -0
  118. package/dist/utils/agents/cli-tools.js +5 -0
  119. package/dist/utils/agents/contracts/messages.d.ts +88 -0
  120. package/dist/utils/agents/contracts/messages.js +138 -0
  121. package/dist/utils/agents/contracts/run.d.ts +20 -0
  122. package/dist/utils/agents/contracts/run.js +0 -0
  123. package/dist/utils/agents/runtime-types.d.ts +117 -0
  124. package/dist/utils/agents/runtime-types.js +4 -0
  125. package/dist/utils/books-data.js +82 -0
  126. package/dist/utils/content-status.js +38 -0
  127. package/dist/utils/forms/config.js +87 -0
  128. package/dist/utils/forms/constants.js +27 -0
  129. package/dist/utils/forms/contact-submissions-local.js +19 -0
  130. package/dist/utils/forms/contact-submissions.js +72 -0
  131. package/dist/utils/forms/crypto.js +64 -0
  132. package/dist/utils/forms/guard.js +76 -0
  133. package/dist/utils/forms/http.js +51 -0
  134. package/dist/utils/forms/provider-core.js +88 -0
  135. package/dist/utils/forms/routing-core.js +7 -0
  136. package/dist/utils/forms/routing.js +13 -0
  137. package/dist/utils/forms/runtime-core.js +17 -0
  138. package/dist/utils/forms/runtime.js +27 -0
  139. package/dist/utils/forms/service-core.js +256 -0
  140. package/dist/utils/forms/service.js +55 -0
  141. package/dist/utils/forms/session.js +57 -0
  142. package/dist/utils/forms/smtp-cloudflare.js +107 -0
  143. package/dist/utils/forms/smtp-node.js +27 -0
  144. package/dist/utils/forms/smtp.js +10 -0
  145. package/dist/utils/forms/subscribers-local.js +21 -0
  146. package/dist/utils/forms/subscribers.js +53 -0
  147. package/dist/utils/forms/turnstile.js +31 -0
  148. package/dist/utils/forms/validation.js +58 -0
  149. package/dist/utils/hub-content.js +28 -0
  150. package/dist/utils/plugin-runtime.js +158 -0
  151. package/dist/utils/routes.js +17 -0
  152. package/dist/utils/seo.js +4 -0
  153. package/dist/utils/site-config-schema.js +282 -0
  154. package/dist/utils/site-config.js +122 -0
  155. package/dist/utils/starlight-nav.js +62 -0
  156. package/dist/utils/theme.js +49 -0
  157. package/dist/vendor/starlight/components/AnchorHeading.astro +53 -0
  158. package/dist/vendor/starlight/components/Banner.astro +23 -0
  159. package/dist/vendor/starlight/components/ContentNotice.astro +33 -0
  160. package/dist/vendor/starlight/components/ContentPanel.astro +27 -0
  161. package/dist/vendor/starlight/components/DraftContentNotice.astro +5 -0
  162. package/dist/vendor/starlight/components/EditLink.astro +28 -0
  163. package/dist/vendor/starlight/components/FallbackContentNotice.astro +5 -0
  164. package/dist/vendor/starlight/components/Footer.astro +61 -0
  165. package/dist/vendor/starlight/components/Head.astro +5 -0
  166. package/dist/vendor/starlight/components/Header.astro +94 -0
  167. package/dist/vendor/starlight/components/Hero.astro +143 -0
  168. package/dist/vendor/starlight/components/Icons.js +121 -0
  169. package/dist/vendor/starlight/components/LanguageSelect.astro +57 -0
  170. package/dist/vendor/starlight/components/LastUpdated.astro +14 -0
  171. package/dist/vendor/starlight/components/MarkdownContent.astro +5 -0
  172. package/dist/vendor/starlight/components/MobileMenuFooter.astro +35 -0
  173. package/dist/vendor/starlight/components/MobileMenuToggle.astro +107 -0
  174. package/dist/vendor/starlight/components/MobileTableOfContents.astro +151 -0
  175. package/dist/vendor/starlight/components/Page.astro +126 -0
  176. package/dist/vendor/starlight/components/PageFrame.astro +97 -0
  177. package/dist/vendor/starlight/components/PageSidebar.astro +59 -0
  178. package/dist/vendor/starlight/components/PageTitle.astro +17 -0
  179. package/dist/vendor/starlight/components/Pagination.astro +79 -0
  180. package/dist/vendor/starlight/components/Search.astro +488 -0
  181. package/dist/vendor/starlight/components/Select.astro +99 -0
  182. package/dist/vendor/starlight/components/Sidebar.astro +15 -0
  183. package/dist/vendor/starlight/components/SidebarPersistState.js +43 -0
  184. package/dist/vendor/starlight/components/SidebarPersister.astro +78 -0
  185. package/dist/vendor/starlight/components/SidebarRestorePoint.astro +12 -0
  186. package/dist/vendor/starlight/components/SidebarSublist.astro +154 -0
  187. package/dist/vendor/starlight/components/SiteTitle.astro +59 -0
  188. package/dist/vendor/starlight/components/SkipLink.astro +26 -0
  189. package/dist/vendor/starlight/components/SocialIcons.astro +32 -0
  190. package/dist/vendor/starlight/components/StarlightPage.astro +17 -0
  191. package/dist/vendor/starlight/components/TableOfContents/TableOfContentsList.astro +79 -0
  192. package/dist/vendor/starlight/components/TableOfContents/starlight-toc.js +93 -0
  193. package/dist/vendor/starlight/components/TableOfContents.astro +18 -0
  194. package/dist/vendor/starlight/components/ThemeProvider.astro +38 -0
  195. package/dist/vendor/starlight/components/ThemeSelect.astro +73 -0
  196. package/dist/vendor/starlight/components/TwoColumnContent.astro +54 -0
  197. package/dist/vendor/starlight/components.js +26 -0
  198. package/dist/vendor/starlight/constants.js +4 -0
  199. package/dist/vendor/starlight/expressive-code.d.js +1 -0
  200. package/dist/vendor/starlight/global.d.js +0 -0
  201. package/dist/vendor/starlight/i18n.d.js +1 -0
  202. package/dist/vendor/starlight/index.js +119 -0
  203. package/dist/vendor/starlight/integrations/asides-error.js +12 -0
  204. package/dist/vendor/starlight/integrations/asides.js +179 -0
  205. package/dist/vendor/starlight/integrations/code-rtl-support.js +21 -0
  206. package/dist/vendor/starlight/integrations/expressive-code/hast.d.js +1 -0
  207. package/dist/vendor/starlight/integrations/expressive-code/index.js +63 -0
  208. package/dist/vendor/starlight/integrations/expressive-code/preprocessor.js +92 -0
  209. package/dist/vendor/starlight/integrations/expressive-code/themes/night-owl-dark.jsonc +1796 -0
  210. package/dist/vendor/starlight/integrations/expressive-code/themes/night-owl-dark.jsonc.js +1 -0
  211. package/dist/vendor/starlight/integrations/expressive-code/themes/night-owl-light.jsonc +1695 -0
  212. package/dist/vendor/starlight/integrations/expressive-code/themes/night-owl-light.jsonc.js +1 -0
  213. package/dist/vendor/starlight/integrations/expressive-code/theming.js +62 -0
  214. package/dist/vendor/starlight/integrations/expressive-code/translations.js +29 -0
  215. package/dist/vendor/starlight/integrations/heading-links.js +61 -0
  216. package/dist/vendor/starlight/integrations/pagefind.js +43 -0
  217. package/dist/vendor/starlight/integrations/remark-rehype.js +68 -0
  218. package/dist/vendor/starlight/integrations/shared/absolutePathToLang.js +15 -0
  219. package/dist/vendor/starlight/integrations/shared/localeToLang.js +9 -0
  220. package/dist/vendor/starlight/integrations/shared/slugToLocale.js +10 -0
  221. package/dist/vendor/starlight/integrations/sitemap.js +20 -0
  222. package/dist/vendor/starlight/integrations/virtual-user-config.js +110 -0
  223. package/dist/vendor/starlight/integrations/vite-layer-order.js +42 -0
  224. package/dist/vendor/starlight/internal.js +6 -0
  225. package/dist/vendor/starlight/loaders.js +36 -0
  226. package/dist/vendor/starlight/locals.d.js +0 -0
  227. package/dist/vendor/starlight/locals.js +30 -0
  228. package/dist/vendor/starlight/package.json +231 -0
  229. package/dist/vendor/starlight/package.json.js +248 -0
  230. package/dist/vendor/starlight/props.js +0 -0
  231. package/dist/vendor/starlight/route-data.js +6 -0
  232. package/dist/vendor/starlight/routes/common.astro +23 -0
  233. package/dist/vendor/starlight/routes/ssr/404.astro +7 -0
  234. package/dist/vendor/starlight/routes/ssr/index.astro +14 -0
  235. package/dist/vendor/starlight/routes/static/404.astro +7 -0
  236. package/dist/vendor/starlight/routes/static/index.astro +12 -0
  237. package/dist/vendor/starlight/schema.js +102 -0
  238. package/dist/vendor/starlight/schemas/badge.js +26 -0
  239. package/dist/vendor/starlight/schemas/components.js +235 -0
  240. package/dist/vendor/starlight/schemas/expressiveCode.js +12 -0
  241. package/dist/vendor/starlight/schemas/favicon.js +33 -0
  242. package/dist/vendor/starlight/schemas/head.js +32 -0
  243. package/dist/vendor/starlight/schemas/hero.js +57 -0
  244. package/dist/vendor/starlight/schemas/i18n.js +101 -0
  245. package/dist/vendor/starlight/schemas/icon.js +7 -0
  246. package/dist/vendor/starlight/schemas/logo.js +24 -0
  247. package/dist/vendor/starlight/schemas/pagefind.js +108 -0
  248. package/dist/vendor/starlight/schemas/prevNextLink.js +14 -0
  249. package/dist/vendor/starlight/schemas/sidebar.js +80 -0
  250. package/dist/vendor/starlight/schemas/site-title.js +19 -0
  251. package/dist/vendor/starlight/schemas/social.js +19 -0
  252. package/dist/vendor/starlight/schemas/tableOfContents.js +16 -0
  253. package/dist/vendor/starlight/style/anchor-links.css +131 -0
  254. package/dist/vendor/starlight/style/asides.css +51 -0
  255. package/dist/vendor/starlight/style/layers.css +1 -0
  256. package/dist/vendor/starlight/style/markdown.css +253 -0
  257. package/dist/vendor/starlight/style/print.css +175 -0
  258. package/dist/vendor/starlight/style/props.css +188 -0
  259. package/dist/vendor/starlight/style/reset.css +52 -0
  260. package/dist/vendor/starlight/style/util.css +63 -0
  261. package/dist/vendor/starlight/translations/ar.json +30 -0
  262. package/dist/vendor/starlight/translations/ar.json.js +32 -0
  263. package/dist/vendor/starlight/translations/ca.json +43 -0
  264. package/dist/vendor/starlight/translations/ca.json.js +45 -0
  265. package/dist/vendor/starlight/translations/cs.json +43 -0
  266. package/dist/vendor/starlight/translations/cs.json.js +45 -0
  267. package/dist/vendor/starlight/translations/da.json +30 -0
  268. package/dist/vendor/starlight/translations/da.json.js +32 -0
  269. package/dist/vendor/starlight/translations/de.json +30 -0
  270. package/dist/vendor/starlight/translations/de.json.js +32 -0
  271. package/dist/vendor/starlight/translations/el.json +30 -0
  272. package/dist/vendor/starlight/translations/el.json.js +32 -0
  273. package/dist/vendor/starlight/translations/en.json +30 -0
  274. package/dist/vendor/starlight/translations/en.json.js +32 -0
  275. package/dist/vendor/starlight/translations/es.json +43 -0
  276. package/dist/vendor/starlight/translations/es.json.js +45 -0
  277. package/dist/vendor/starlight/translations/fa.json +30 -0
  278. package/dist/vendor/starlight/translations/fa.json.js +32 -0
  279. package/dist/vendor/starlight/translations/fi.json +30 -0
  280. package/dist/vendor/starlight/translations/fi.json.js +32 -0
  281. package/dist/vendor/starlight/translations/fr.json +33 -0
  282. package/dist/vendor/starlight/translations/fr.json.js +35 -0
  283. package/dist/vendor/starlight/translations/gl.json +43 -0
  284. package/dist/vendor/starlight/translations/gl.json.js +45 -0
  285. package/dist/vendor/starlight/translations/he.json +30 -0
  286. package/dist/vendor/starlight/translations/he.json.js +32 -0
  287. package/dist/vendor/starlight/translations/hi.json +30 -0
  288. package/dist/vendor/starlight/translations/hi.json.js +32 -0
  289. package/dist/vendor/starlight/translations/hu.json +43 -0
  290. package/dist/vendor/starlight/translations/hu.json.js +45 -0
  291. package/dist/vendor/starlight/translations/id.json +30 -0
  292. package/dist/vendor/starlight/translations/id.json.js +32 -0
  293. package/dist/vendor/starlight/translations/index.js +77 -0
  294. package/dist/vendor/starlight/translations/it.json +30 -0
  295. package/dist/vendor/starlight/translations/it.json.js +32 -0
  296. package/dist/vendor/starlight/translations/ja.json +30 -0
  297. package/dist/vendor/starlight/translations/ja.json.js +32 -0
  298. package/dist/vendor/starlight/translations/ko.json +30 -0
  299. package/dist/vendor/starlight/translations/ko.json.js +32 -0
  300. package/dist/vendor/starlight/translations/lv.json +30 -0
  301. package/dist/vendor/starlight/translations/lv.json.js +32 -0
  302. package/dist/vendor/starlight/translations/nb.json +30 -0
  303. package/dist/vendor/starlight/translations/nb.json.js +32 -0
  304. package/dist/vendor/starlight/translations/nl.json +30 -0
  305. package/dist/vendor/starlight/translations/nl.json.js +32 -0
  306. package/dist/vendor/starlight/translations/pl.json +33 -0
  307. package/dist/vendor/starlight/translations/pl.json.js +35 -0
  308. package/dist/vendor/starlight/translations/pt.json +30 -0
  309. package/dist/vendor/starlight/translations/pt.json.js +32 -0
  310. package/dist/vendor/starlight/translations/ro.json +30 -0
  311. package/dist/vendor/starlight/translations/ro.json.js +32 -0
  312. package/dist/vendor/starlight/translations/ru.json +33 -0
  313. package/dist/vendor/starlight/translations/ru.json.js +35 -0
  314. package/dist/vendor/starlight/translations/sk.json +30 -0
  315. package/dist/vendor/starlight/translations/sk.json.js +32 -0
  316. package/dist/vendor/starlight/translations/sv.json +30 -0
  317. package/dist/vendor/starlight/translations/sv.json.js +32 -0
  318. package/dist/vendor/starlight/translations/th.json +30 -0
  319. package/dist/vendor/starlight/translations/th.json.js +32 -0
  320. package/dist/vendor/starlight/translations/tr.json +30 -0
  321. package/dist/vendor/starlight/translations/tr.json.js +32 -0
  322. package/dist/vendor/starlight/translations/uk.json +30 -0
  323. package/dist/vendor/starlight/translations/uk.json.js +32 -0
  324. package/dist/vendor/starlight/translations/vi.json +30 -0
  325. package/dist/vendor/starlight/translations/vi.json.js +32 -0
  326. package/dist/vendor/starlight/translations/zh-CN.json +30 -0
  327. package/dist/vendor/starlight/translations/zh-CN.json.js +32 -0
  328. package/dist/vendor/starlight/translations/zh-TW.json +30 -0
  329. package/dist/vendor/starlight/translations/zh-TW.json.js +32 -0
  330. package/dist/vendor/starlight/types.js +0 -0
  331. package/dist/vendor/starlight/user-components/Aside.astro +40 -0
  332. package/dist/vendor/starlight/user-components/Badge.astro +148 -0
  333. package/dist/vendor/starlight/user-components/Card.astro +68 -0
  334. package/dist/vendor/starlight/user-components/CardGrid.astro +38 -0
  335. package/dist/vendor/starlight/user-components/FileTree.astro +137 -0
  336. package/dist/vendor/starlight/user-components/Icon.astro +42 -0
  337. package/dist/vendor/starlight/user-components/LinkButton.astro +78 -0
  338. package/dist/vendor/starlight/user-components/LinkCard.astro +78 -0
  339. package/dist/vendor/starlight/user-components/Steps.astro +90 -0
  340. package/dist/vendor/starlight/user-components/TabItem.astro +19 -0
  341. package/dist/vendor/starlight/user-components/Tabs.astro +268 -0
  342. package/dist/vendor/starlight/user-components/file-tree-icons.js +608 -0
  343. package/dist/vendor/starlight/user-components/rehype-file-tree.js +160 -0
  344. package/dist/vendor/starlight/user-components/rehype-steps.js +53 -0
  345. package/dist/vendor/starlight/user-components/rehype-tabs.js +73 -0
  346. package/dist/vendor/starlight/utils/base.js +14 -0
  347. package/dist/vendor/starlight/utils/canonical.js +13 -0
  348. package/dist/vendor/starlight/utils/collection-fs.js +13 -0
  349. package/dist/vendor/starlight/utils/collection.js +16 -0
  350. package/dist/vendor/starlight/utils/createPathFormatter.js +39 -0
  351. package/dist/vendor/starlight/utils/createTranslationSystem.js +60 -0
  352. package/dist/vendor/starlight/utils/error-map.js +110 -0
  353. package/dist/vendor/starlight/utils/format-path.js +9 -0
  354. package/dist/vendor/starlight/utils/generateToC.js +18 -0
  355. package/dist/vendor/starlight/utils/git.js +92 -0
  356. package/dist/vendor/starlight/utils/gitInlined.js +13 -0
  357. package/dist/vendor/starlight/utils/head.js +156 -0
  358. package/dist/vendor/starlight/utils/i18n.js +121 -0
  359. package/dist/vendor/starlight/utils/localizedUrl.js +37 -0
  360. package/dist/vendor/starlight/utils/navigation.js +320 -0
  361. package/dist/vendor/starlight/utils/path.js +52 -0
  362. package/dist/vendor/starlight/utils/plugins.js +355 -0
  363. package/dist/vendor/starlight/utils/routing/data.js +116 -0
  364. package/dist/vendor/starlight/utils/routing/index.js +107 -0
  365. package/dist/vendor/starlight/utils/routing/middleware.js +40 -0
  366. package/dist/vendor/starlight/utils/routing/types.js +0 -0
  367. package/dist/vendor/starlight/utils/routing.js +1 -0
  368. package/dist/vendor/starlight/utils/slugs.js +70 -0
  369. package/dist/vendor/starlight/utils/starlight-page.js +123 -0
  370. package/dist/vendor/starlight/utils/translations-fs.js +31 -0
  371. package/dist/vendor/starlight/utils/translations.js +31 -0
  372. package/dist/vendor/starlight/utils/types.js +0 -0
  373. package/dist/vendor/starlight/utils/url.js +5 -0
  374. package/dist/vendor/starlight/utils/user-config.js +255 -0
  375. package/dist/vendor/starlight/utils/validateLogoImports.js +22 -0
  376. package/dist/vendor/starlight/virtual-internal.d.js +0 -0
  377. package/dist/vendor/starlight/virtual.d.js +0 -0
  378. package/dist/worker/forms-worker.js +141 -0
  379. package/package.json +156 -0
  380. package/style/anchor-links.css +131 -0
  381. package/templates/github/deploy.workflow.yml +47 -0
  382. package/tsconfigs/strict.json +3 -0
  383. package/utils/git.ts +121 -0
  384. package/utils/gitInlined.ts +20 -0
@@ -0,0 +1,78 @@
1
+ ---
2
+ /*
3
+ This component is designed to wrap the tree of `<SidebarSublist>` components in the sidebar.
4
+
5
+ It does the following:
6
+ - Wraps the tree in an `<sl-sidebar-state-persist>` custom element
7
+ - Before the tree renders, adds an inline script which loads state and defines
8
+ the behaviour for the `<sl-sidebar-restore>` custom element.
9
+ - After the tree renders, adds an inline script which restores the sidebar scroll state.
10
+
11
+ Notes:
12
+ - On smaller viewports, restoring state is skipped as the sidebar is collapsed inside a menu.
13
+ - The state is parsed from session storage and restored.
14
+ - This is a progressive enhancement, so any errors are swallowed silently.
15
+
16
+ The `aria-hidden` attribute on script tags is used to prevent a Safari/VoiceOver bug where the
17
+ script is read out loud due to them being inside a container with `display: contents`.
18
+ @see https://bugs.webkit.org/show_bug.cgi?id=283645
19
+ @see https://github.com/withastro/starlight/pull/2633
20
+ */
21
+
22
+ import { getSidebarHash } from '../utils/navigation';
23
+
24
+ const hash = getSidebarHash(Astro.locals.starlightRoute.sidebar);
25
+
26
+ declare global {
27
+ interface Window {
28
+ /** Restored scroll position. Briefly stored on the `window` global to pass between inline scripts. */
29
+ _starlightScrollRestore?: number;
30
+ }
31
+ }
32
+ ---
33
+
34
+ <sl-sidebar-state-persist data-hash={hash}>
35
+ <script is:inline aria-hidden="true">
36
+ (() => {
37
+ try {
38
+ if (!matchMedia('(min-width: 50em)').matches) return;
39
+ /** @type {HTMLElement | null} */
40
+ const target = document.querySelector('sl-sidebar-state-persist');
41
+ const state = JSON.parse(sessionStorage.getItem('sl-sidebar-state') || '0');
42
+ if (!target || !state || target.dataset.hash !== state.hash) return;
43
+ window._starlightScrollRestore = state.scroll;
44
+ customElements.define(
45
+ 'sl-sidebar-restore',
46
+ class SidebarRestore extends HTMLElement {
47
+ connectedCallback() {
48
+ try {
49
+ const idx = parseInt(this.dataset.index || '');
50
+ const details = this.closest('details');
51
+ if (details && typeof state.open[idx] === 'boolean') details.open = state.open[idx];
52
+ } catch {}
53
+ }
54
+ }
55
+ );
56
+ } catch {}
57
+ })();
58
+ </script>
59
+
60
+ <slot />
61
+
62
+ <script is:inline aria-hidden="true">
63
+ (() => {
64
+ const scroller = document.getElementById('starlight__sidebar');
65
+ if (!window._starlightScrollRestore || !scroller) return;
66
+ scroller.scrollTop = window._starlightScrollRestore;
67
+ delete window._starlightScrollRestore;
68
+ })();
69
+ </script>
70
+ </sl-sidebar-state-persist>
71
+
72
+ <style>
73
+ @layer starlight.core {
74
+ sl-sidebar-state-persist {
75
+ display: contents;
76
+ }
77
+ }
78
+ </style>
@@ -0,0 +1,12 @@
1
+ ---
2
+ /** Unique symbol for storing a running index in `locals`. */
3
+ const currentGroupIndexSymbol = Symbol.for('starlight-sidebar-group-index');
4
+ const locals = Astro.locals as App.Locals & { [currentGroupIndexSymbol]: number };
5
+
6
+ /** The current sidebar group’s index retrieved from `locals` if set, starting at `0`. */
7
+ const index = locals[currentGroupIndexSymbol] || 0;
8
+ // Increment the index for the next instance.
9
+ locals[currentGroupIndexSymbol] = index + 1;
10
+ ---
11
+
12
+ <sl-sidebar-restore data-index={index}></sl-sidebar-restore>
@@ -0,0 +1,154 @@
1
+ ---
2
+ import { flattenSidebar } from '../utils/navigation';
3
+ import type { SidebarEntry } from '../utils/routing/types';
4
+ import Icon from '../user-components/Icon.astro';
5
+ import Badge from '../user-components/Badge.astro';
6
+ import SidebarRestorePoint from './SidebarRestorePoint.astro';
7
+
8
+ interface Props {
9
+ sublist: SidebarEntry[];
10
+ nested?: boolean;
11
+ }
12
+
13
+ const { sublist, nested } = Astro.props;
14
+ ---
15
+
16
+ <ul class:list={{ 'top-level': !nested }}>
17
+ {
18
+ sublist.map((entry) => (
19
+ <li>
20
+ {entry.type === 'link' ? (
21
+ <a
22
+ href={entry.href}
23
+ aria-current={entry.isCurrent ? 'page' : undefined}
24
+ class:list={[{ large: !nested }, entry.attrs.class]}
25
+ {...entry.attrs}
26
+ >
27
+ <span>{entry.label}</span>
28
+ {entry.badge && (
29
+ <Badge
30
+ variant={entry.badge.variant}
31
+ class={entry.badge.class}
32
+ text={entry.badge.text}
33
+ />
34
+ )}
35
+ </a>
36
+ ) : (
37
+ <details
38
+ open={flattenSidebar(entry.entries).some((i) => i.isCurrent) || !entry.collapsed}
39
+ >
40
+ <summary>
41
+ <span class="group-label">
42
+ <span class="large">{entry.label}</span>
43
+ {entry.badge && (
44
+ <Badge
45
+ variant={entry.badge.variant}
46
+ class={entry.badge.class}
47
+ text={entry.badge.text}
48
+ />
49
+ )}
50
+ </span>
51
+ <Icon name="right-caret" class="caret" size="1.25rem" />
52
+ </summary>
53
+ <SidebarRestorePoint />
54
+ <Astro.self sublist={entry.entries} nested />
55
+ </details>
56
+ )}
57
+ </li>
58
+ ))
59
+ }
60
+ </ul>
61
+
62
+ <style>
63
+ @layer starlight.core {
64
+ ul {
65
+ --sl-sidebar-item-padding-inline: 0.5rem;
66
+ list-style: none;
67
+ padding: 0;
68
+ }
69
+
70
+ li {
71
+ overflow-wrap: anywhere;
72
+ }
73
+
74
+ ul ul li {
75
+ margin-inline-start: var(--sl-sidebar-item-padding-inline);
76
+ border-inline-start: 1px solid var(--sl-color-hairline-light);
77
+ padding-inline-start: var(--sl-sidebar-item-padding-inline);
78
+ }
79
+
80
+ .large {
81
+ font-size: var(--sl-text-lg);
82
+ font-weight: 600;
83
+ color: var(--sl-color-white);
84
+ }
85
+
86
+ .top-level > li + li {
87
+ margin-top: 0.75rem;
88
+ }
89
+
90
+ summary {
91
+ display: flex;
92
+ align-items: center;
93
+ justify-content: space-between;
94
+ padding: 0.2em var(--sl-sidebar-item-padding-inline);
95
+ line-height: 1.4;
96
+ cursor: pointer;
97
+ user-select: none;
98
+ }
99
+ summary::marker,
100
+ summary::-webkit-details-marker {
101
+ display: none;
102
+ }
103
+
104
+ .caret {
105
+ transition: transform 0.2s ease-in-out;
106
+ flex-shrink: 0;
107
+ }
108
+ :global([dir='rtl']) .caret {
109
+ transform: rotateZ(180deg);
110
+ }
111
+ [open] > summary .caret {
112
+ transform: rotateZ(90deg);
113
+ }
114
+
115
+ a {
116
+ display: block;
117
+ border-radius: 0.25rem;
118
+ text-decoration: none;
119
+ color: var(--sl-color-gray-2);
120
+ padding: 0.3em var(--sl-sidebar-item-padding-inline);
121
+ line-height: 1.4;
122
+ }
123
+
124
+ a:hover,
125
+ a:focus {
126
+ color: var(--sl-color-white);
127
+ }
128
+
129
+ [aria-current='page'],
130
+ [aria-current='page']:hover,
131
+ [aria-current='page']:focus {
132
+ font-weight: 600;
133
+ color: var(--sl-color-text-invert);
134
+ background-color: var(--sl-color-text-accent);
135
+ }
136
+
137
+ a > *:not(:last-child),
138
+ .group-label > *:not(:last-child) {
139
+ margin-inline-end: 0.25em;
140
+ }
141
+
142
+ @media (min-width: 50rem) {
143
+ .top-level > li + li {
144
+ margin-top: 0.5rem;
145
+ }
146
+ .large {
147
+ font-size: var(--sl-text-base);
148
+ }
149
+ a {
150
+ font-size: var(--sl-text-sm);
151
+ }
152
+ }
153
+ }
154
+ </style>
@@ -0,0 +1,59 @@
1
+ ---
2
+ import { logos } from 'virtual:starlight/user-images';
3
+ import config from 'virtual:starlight/user-config';
4
+ const { siteTitle, siteTitleHref } = Astro.locals.starlightRoute;
5
+ ---
6
+
7
+ <a href={siteTitleHref} class="site-title sl-flex">
8
+ {
9
+ config.logo && logos.dark && (
10
+ <>
11
+ <img
12
+ class:list={{ 'light:sl-hidden print:hidden': !('src' in config.logo) }}
13
+ alt={config.logo.alt}
14
+ src={logos.dark.src}
15
+ width={logos.dark.width}
16
+ height={logos.dark.height}
17
+ />
18
+ {/* Show light alternate if a user configure both light and dark logos. */}
19
+ {!('src' in config.logo) && (
20
+ <img
21
+ class="dark:sl-hidden print:block"
22
+ alt={config.logo.alt}
23
+ src={logos.light?.src}
24
+ width={logos.light?.width}
25
+ height={logos.light?.height}
26
+ />
27
+ )}
28
+ </>
29
+ )
30
+ }
31
+ <span class:list={{ 'sr-only': config.logo?.replacesTitle }} translate="no">
32
+ {siteTitle}
33
+ </span>
34
+ </a>
35
+
36
+ <style>
37
+ @layer starlight.core {
38
+ .site-title {
39
+ align-items: center;
40
+ gap: var(--sl-nav-gap);
41
+ font-size: var(--sl-text-h4);
42
+ font-weight: 600;
43
+ color: var(--sl-color-text-accent);
44
+ text-decoration: none;
45
+ white-space: nowrap;
46
+ min-width: 0;
47
+ }
48
+ span {
49
+ overflow: hidden;
50
+ }
51
+ img {
52
+ height: calc(var(--sl-nav-height) - 2 * var(--sl-nav-pad-y));
53
+ width: auto;
54
+ max-width: 100%;
55
+ object-fit: contain;
56
+ object-position: 0 50%;
57
+ }
58
+ }
59
+ </style>
@@ -0,0 +1,26 @@
1
+ ---
2
+ import { PAGE_TITLE_ID } from '../constants';
3
+ ---
4
+
5
+ <a href={`#${PAGE_TITLE_ID}`}>{Astro.locals.t('skipLink.label')}</a>
6
+
7
+ <style>
8
+ @layer starlight.core {
9
+ a {
10
+ clip: rect(0, 0, 0, 0);
11
+ position: fixed;
12
+ top: 0.75rem;
13
+ inset-inline-start: 0.75rem;
14
+ }
15
+ a:focus {
16
+ clip: unset;
17
+ z-index: var(--sl-z-index-skiplink);
18
+ display: block;
19
+ padding: 0.5rem 1rem;
20
+ text-decoration: none;
21
+ color: var(--sl-color-text-invert);
22
+ background-color: var(--sl-color-text-accent);
23
+ box-shadow: var(--sl-shadow-lg);
24
+ }
25
+ }
26
+ </style>
@@ -0,0 +1,32 @@
1
+ ---
2
+ import config from 'virtual:starlight/user-config';
3
+ import Icon from '../user-components/Icon.astro';
4
+
5
+ const links = config.social || [];
6
+ ---
7
+
8
+ {
9
+ links.length > 0 && (
10
+ <>
11
+ {links.map(({ label, href, icon }) => (
12
+ <a {href} rel="me" class="sl-flex">
13
+ <span class="sr-only">{label}</span>
14
+ <Icon name={icon} />
15
+ </a>
16
+ ))}
17
+ </>
18
+ )
19
+ }
20
+
21
+ <style>
22
+ @layer starlight.core {
23
+ a {
24
+ color: var(--sl-color-text-accent);
25
+ padding: 0.5em;
26
+ margin: -0.5em;
27
+ }
28
+ a:hover {
29
+ opacity: 0.66;
30
+ }
31
+ }
32
+ </style>
@@ -0,0 +1,17 @@
1
+ ---
2
+ import { attachRouteDataAndRunMiddleware } from '../utils/routing/middleware';
3
+ import {
4
+ generateStarlightPageRouteData,
5
+ type StarlightPageProps as Props,
6
+ } from '../utils/starlight-page';
7
+ import Page from './Page.astro';
8
+
9
+ export type StarlightPageProps = Props;
10
+
11
+ await attachRouteDataAndRunMiddleware(
12
+ Astro,
13
+ await generateStarlightPageRouteData({ props: Astro.props, context: Astro })
14
+ );
15
+ ---
16
+
17
+ <Page><slot /></Page>
@@ -0,0 +1,79 @@
1
+ ---
2
+ import type { TocItem } from '../../utils/generateToC';
3
+
4
+ interface Props {
5
+ toc: TocItem[];
6
+ depth?: number;
7
+ isMobile?: boolean;
8
+ }
9
+
10
+ const { toc, isMobile = false, depth = 0 } = Astro.props;
11
+ ---
12
+
13
+ <ul class:list={{ isMobile }}>
14
+ {
15
+ toc.map((heading) => (
16
+ <li>
17
+ <a href={'#' + heading.slug}>
18
+ <span>{heading.text}</span>
19
+ </a>
20
+ {heading.children.length > 0 && (
21
+ <Astro.self toc={heading.children} depth={depth + 1} isMobile={isMobile} />
22
+ )}
23
+ </li>
24
+ ))
25
+ }
26
+ </ul>
27
+
28
+ <style define:vars={{ depth }}>
29
+ @layer starlight.core {
30
+ ul {
31
+ padding: 0;
32
+ list-style: none;
33
+ }
34
+ a {
35
+ --pad-inline: 0.5rem;
36
+ display: block;
37
+ border-radius: 0.25rem;
38
+ padding-block: 0.25rem;
39
+ padding-inline: calc(1rem * var(--depth) + var(--pad-inline)) var(--pad-inline);
40
+ line-height: 1.25;
41
+ }
42
+ a[aria-current='true'] {
43
+ color: var(--sl-color-text-accent);
44
+ }
45
+ .isMobile a {
46
+ --pad-inline: 1rem;
47
+ display: flex;
48
+ justify-content: space-between;
49
+ gap: var(--pad-inline);
50
+ border-top: 1px solid var(--sl-color-gray-6);
51
+ border-radius: 0;
52
+ padding-block: 0.5rem;
53
+ color: var(--sl-color-text);
54
+ font-size: var(--sl-text-sm);
55
+ text-decoration: none;
56
+ outline-offset: var(--sl-outline-offset-inside);
57
+ }
58
+ .isMobile:first-child > li:first-child > a {
59
+ border-top: 0;
60
+ }
61
+ .isMobile a[aria-current='true'],
62
+ .isMobile a[aria-current='true']:hover,
63
+ .isMobile a[aria-current='true']:focus {
64
+ color: var(--sl-color-white);
65
+ background-color: unset;
66
+ }
67
+ .isMobile a[aria-current='true']::after {
68
+ content: '';
69
+ width: 1rem;
70
+ background-color: var(--sl-color-text-accent);
71
+ /* Check mark SVG icon */
72
+ -webkit-mask-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAxNCAxNCc+PHBhdGggZD0nTTEwLjkxNCA0LjIwNmEuNTgzLjU4MyAwIDAgMC0uODI4IDBMNS43NCA4LjU1NyAzLjkxNCA2LjcyNmEuNTk2LjU5NiAwIDAgMC0uODI4Ljg1N2wyLjI0IDIuMjRhLjU4My41ODMgMCAwIDAgLjgyOCAwbDQuNzYtNC43NmEuNTgzLjU4MyAwIDAgMCAwLS44NTdaJy8+PC9zdmc+Cg==');
73
+ mask-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAxNCAxNCc+PHBhdGggZD0nTTEwLjkxNCA0LjIwNmEuNTgzLjU4MyAwIDAgMC0uODI4IDBMNS43NCA4LjU1NyAzLjkxNCA2LjcyNmEuNTk2LjU5NiAwIDAgMC0uODI4Ljg1N2wyLjI0IDIuMjRhLjU4My41ODMgMCAwIDAgLjgyOCAwbDQuNzYtNC43NmEuNTgzLjU4MyAwIDAgMCAwLS44NTdaJy8+PC9zdmc+Cg==');
74
+ -webkit-mask-repeat: no-repeat;
75
+ mask-repeat: no-repeat;
76
+ flex-shrink: 0;
77
+ }
78
+ }
79
+ </style>
@@ -0,0 +1,93 @@
1
+ import { PAGE_TITLE_ID } from "../../constants.js";
2
+ class StarlightTOC extends HTMLElement {
3
+ _current = this.querySelector('a[aria-current="true"]');
4
+ minH = parseInt(this.dataset.minH || "2", 10);
5
+ maxH = parseInt(this.dataset.maxH || "3", 10);
6
+ /**
7
+ * CSS selector string that matches only headings that can appear in the table of contents.
8
+ * Generates a selector like `h1#_top,:where(h2,h3)[id]`.
9
+ */
10
+ tocHeadingSelector = `h1#${PAGE_TITLE_ID},:where(${[...Array.from({ length: 1 + this.maxH - this.minH }).map((_, index) => `h${this.minH + index}`)].join()})[id]`;
11
+ set current(link) {
12
+ if (link === this._current) return;
13
+ if (this._current) this._current.removeAttribute("aria-current");
14
+ link.setAttribute("aria-current", "true");
15
+ this._current = link;
16
+ }
17
+ onIdle = (cb) => (window.requestIdleCallback || ((cb2) => setTimeout(cb2, 1)))(cb);
18
+ constructor() {
19
+ super();
20
+ this.onIdle(() => this.init());
21
+ }
22
+ init = () => {
23
+ const links = [...this.querySelectorAll("a")];
24
+ const isHeading = (el) => el.matches(this.tocHeadingSelector);
25
+ const getElementHeading = (el) => {
26
+ if (!el) return null;
27
+ const origin = el;
28
+ while (el) {
29
+ if (el.matches(".sl-markdown-content, main > *")) {
30
+ return document.getElementById(PAGE_TITLE_ID);
31
+ }
32
+ if (isHeading(el)) return el;
33
+ const childHeading = el.querySelector(this.tocHeadingSelector);
34
+ if (childHeading) return childHeading;
35
+ el = el.previousElementSibling;
36
+ while (el?.lastElementChild) {
37
+ el = el.lastElementChild;
38
+ }
39
+ const h = getElementHeading(el);
40
+ if (h) return h;
41
+ }
42
+ return getElementHeading(origin.parentElement);
43
+ };
44
+ const setCurrent = (entries) => {
45
+ for (const { isIntersecting, target } of entries) {
46
+ if (!isIntersecting) continue;
47
+ const heading = getElementHeading(target);
48
+ if (!heading) continue;
49
+ const link = links.find((link2) => link2.hash === "#" + encodeURIComponent(heading.id));
50
+ if (link) {
51
+ this.current = link;
52
+ break;
53
+ }
54
+ }
55
+ };
56
+ const toObserve = document.querySelectorAll(
57
+ [
58
+ `main :where(${this.tocHeadingSelector})`,
59
+ `main :where(${this.tocHeadingSelector}, .sl-heading-wrapper) ~ *:not(:has(${this.tocHeadingSelector}))`,
60
+ `main .sl-markdown-content > *:not(:has(${this.tocHeadingSelector}))`,
61
+ `main > *:not(:has(${this.tocHeadingSelector}))`
62
+ ].join()
63
+ );
64
+ let observer;
65
+ const observe = () => {
66
+ if (observer) return;
67
+ observer = new IntersectionObserver(setCurrent, { rootMargin: this.getRootMargin() });
68
+ toObserve.forEach((h) => observer.observe(h));
69
+ };
70
+ observe();
71
+ let timeout;
72
+ window.addEventListener("resize", () => {
73
+ if (observer) {
74
+ observer.disconnect();
75
+ observer = void 0;
76
+ }
77
+ clearTimeout(timeout);
78
+ timeout = setTimeout(() => this.onIdle(observe), 200);
79
+ });
80
+ };
81
+ getRootMargin() {
82
+ const navBarHeight = document.querySelector("header")?.getBoundingClientRect().height || 0;
83
+ const mobileTocHeight = this.querySelector("summary")?.getBoundingClientRect().height || 0;
84
+ const top = navBarHeight + mobileTocHeight + 32;
85
+ const bottom = top + 53;
86
+ const height = document.documentElement.clientHeight;
87
+ return `-${top}px 0% ${bottom - height}px`;
88
+ }
89
+ }
90
+ customElements.define("starlight-toc", StarlightTOC);
91
+ export {
92
+ StarlightTOC
93
+ };
@@ -0,0 +1,18 @@
1
+ ---
2
+ import TableOfContentsList from './TableOfContents/TableOfContentsList.astro';
3
+
4
+ const { toc } = Astro.locals.starlightRoute;
5
+ ---
6
+
7
+ {
8
+ toc && (
9
+ <starlight-toc data-min-h={toc.minHeadingLevel} data-max-h={toc.maxHeadingLevel}>
10
+ <nav aria-labelledby="starlight__on-this-page">
11
+ <h2 id="starlight__on-this-page">{Astro.locals.t('tableOfContents.onThisPage')}</h2>
12
+ <TableOfContentsList toc={toc.items} />
13
+ </nav>
14
+ </starlight-toc>
15
+ )
16
+ }
17
+
18
+ <script src="./TableOfContents/starlight-toc.js"></script>
@@ -0,0 +1,38 @@
1
+ ---
2
+ import Icon from '../user-components/Icon.astro';
3
+ ---
4
+
5
+ {/* This is intentionally inlined to avoid FOUC. */}
6
+ <script is:inline>
7
+ window.StarlightThemeProvider = (() => {
8
+ const storedTheme =
9
+ typeof localStorage !== 'undefined' && localStorage.getItem('starlight-theme');
10
+ const theme =
11
+ storedTheme ||
12
+ (window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark');
13
+ document.documentElement.dataset.theme = theme === 'light' ? 'light' : 'dark';
14
+ return {
15
+ updatePickers(theme = storedTheme || 'auto') {
16
+ document.querySelectorAll('starlight-theme-select').forEach((picker) => {
17
+ const select = picker.querySelector('select');
18
+ if (select) select.value = theme;
19
+ /** @type {HTMLTemplateElement | null} */
20
+ const tmpl = document.querySelector(`#theme-icons`);
21
+ const newIcon = tmpl && tmpl.content.querySelector('.' + theme);
22
+ if (newIcon) {
23
+ const oldIcon = picker.querySelector('svg.label-icon');
24
+ if (oldIcon) {
25
+ oldIcon.replaceChildren(...newIcon.cloneNode(true).childNodes);
26
+ }
27
+ }
28
+ });
29
+ },
30
+ };
31
+ })();
32
+ </script>
33
+
34
+ <template id="theme-icons">
35
+ <Icon name="sun" class="light" />
36
+ <Icon name="moon" class="dark" />
37
+ <Icon name="laptop" class="auto" />
38
+ </template>
@@ -0,0 +1,73 @@
1
+ ---
2
+ import Select from './Select.astro';
3
+ ---
4
+
5
+ <starlight-theme-select>
6
+ {/* TODO: Can we give this select a width that works well for each language’s strings? */}
7
+ <Select
8
+ icon="laptop"
9
+ label={Astro.locals.t('themeSelect.accessibleLabel')}
10
+ options={[
11
+ { label: Astro.locals.t('themeSelect.dark'), selected: false, value: 'dark' },
12
+ { label: Astro.locals.t('themeSelect.light'), selected: false, value: 'light' },
13
+ { label: Astro.locals.t('themeSelect.auto'), selected: true, value: 'auto' },
14
+ ]}
15
+ width="6.25em"
16
+ />
17
+ </starlight-theme-select>
18
+
19
+ {/* Inlined to avoid FOUC. Uses global scope from `ThemeProvider.astro` */}
20
+ <script is:inline>
21
+ StarlightThemeProvider.updatePickers();
22
+ </script>
23
+
24
+ <script>
25
+ type Theme = 'auto' | 'dark' | 'light';
26
+
27
+ /** Key in `localStorage` to store color theme preference at. */
28
+ const storageKey = 'starlight-theme';
29
+
30
+ /** Get a typesafe theme string from any JS value (unknown values are coerced to `'auto'`). */
31
+ const parseTheme = (theme: unknown): Theme =>
32
+ theme === 'auto' || theme === 'dark' || theme === 'light' ? theme : 'auto';
33
+
34
+ /** Load the user’s preference from `localStorage`. */
35
+ const loadTheme = (): Theme =>
36
+ parseTheme(typeof localStorage !== 'undefined' && localStorage.getItem(storageKey));
37
+
38
+ /** Store the user’s preference in `localStorage`. */
39
+ function storeTheme(theme: Theme): void {
40
+ if (typeof localStorage !== 'undefined') {
41
+ localStorage.setItem(storageKey, theme === 'light' || theme === 'dark' ? theme : '');
42
+ }
43
+ }
44
+
45
+ /** Get the preferred system color scheme. */
46
+ const getPreferredColorScheme = (): Theme =>
47
+ matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';
48
+
49
+ /** Update select menu UI, document theme, and local storage state. */
50
+ function onThemeChange(theme: Theme): void {
51
+ StarlightThemeProvider.updatePickers(theme);
52
+ document.documentElement.dataset.theme = theme === 'auto' ? getPreferredColorScheme() : theme;
53
+ storeTheme(theme);
54
+ }
55
+
56
+ // React to changes in system color scheme.
57
+ matchMedia(`(prefers-color-scheme: light)`).addEventListener('change', () => {
58
+ if (loadTheme() === 'auto') onThemeChange('auto');
59
+ });
60
+
61
+ class StarlightThemeSelect extends HTMLElement {
62
+ constructor() {
63
+ super();
64
+ onThemeChange(loadTheme());
65
+ this.querySelector('select')?.addEventListener('change', (e) => {
66
+ if (e.currentTarget instanceof HTMLSelectElement) {
67
+ onThemeChange(parseTheme(e.currentTarget.value));
68
+ }
69
+ });
70
+ }
71
+ }
72
+ customElements.define('starlight-theme-select', StarlightThemeSelect);
73
+ </script>