@wrksz/docs 0.0.0-stage → 0.1.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 (156) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +157 -2
  3. package/dist/agents.d.ts +30 -0
  4. package/dist/agents.js +70 -0
  5. package/dist/components/agent-logos.js +90 -0
  6. package/dist/components/agent-prompt.d.ts +29 -0
  7. package/dist/components/agent-prompt.js +100 -0
  8. package/dist/components/badge.d.ts +16 -0
  9. package/dist/components/badge.js +26 -0
  10. package/dist/components/brand.js +32 -0
  11. package/dist/components/callout.d.ts +24 -0
  12. package/dist/components/callout.js +58 -0
  13. package/dist/components/cards.d.ts +26 -0
  14. package/dist/components/cards.js +48 -0
  15. package/dist/components/code-body.js +18 -0
  16. package/dist/components/code-group.d.ts +20 -0
  17. package/dist/components/code-group.js +41 -0
  18. package/dist/components/code-tabs.d.ts +30 -0
  19. package/dist/components/code-tabs.js +49 -0
  20. package/dist/components/content-tabs.d.ts +14 -0
  21. package/dist/components/content-tabs.js +27 -0
  22. package/dist/components/copy-code.js +41 -0
  23. package/dist/components/deferred-analytics.js +5 -0
  24. package/dist/components/details.d.ts +20 -0
  25. package/dist/components/details.js +29 -0
  26. package/dist/components/heading-link.js +23 -0
  27. package/dist/components/heading.d.ts +5 -0
  28. package/dist/components/heading.js +22 -0
  29. package/dist/components/icons.js +362 -0
  30. package/dist/components/image.d.ts +27 -0
  31. package/dist/components/image.js +204 -0
  32. package/dist/components/inline-text.js +14 -0
  33. package/dist/components/install.d.ts +22 -0
  34. package/dist/components/install.js +62 -0
  35. package/dist/components/mdx-tabs.d.ts +22 -0
  36. package/dist/components/mdx-tabs.js +30 -0
  37. package/dist/components/practice.d.ts +41 -0
  38. package/dist/components/practice.js +99 -0
  39. package/dist/components/props.d.ts +37 -0
  40. package/dist/components/props.js +70 -0
  41. package/dist/components/status.js +35 -0
  42. package/dist/components/steps.d.ts +18 -0
  43. package/dist/components/steps.js +23 -0
  44. package/dist/components/theme-switch.js +31 -0
  45. package/dist/components/ui/kbd.js +410 -0
  46. package/dist/components/ui/scroll-area.js +169 -0
  47. package/dist/components/ui/table.d.ts +33 -0
  48. package/dist/components/ui/table.js +103 -0
  49. package/dist/components/ui/tabs.js +69 -0
  50. package/dist/components/ui/toast.js +629 -0
  51. package/dist/components/ui/tooltip.js +31 -0
  52. package/dist/components/wrksz-mark.js +12 -0
  53. package/dist/docs/index.d.ts +8 -0
  54. package/dist/docs/index.js +8 -0
  55. package/dist/docs/layout.d.ts +6 -0
  56. package/dist/docs/layout.js +10 -0
  57. package/dist/docs/page-actions.d.ts +36 -0
  58. package/dist/docs/page-actions.js +136 -0
  59. package/dist/docs/page-footer.d.ts +14 -0
  60. package/dist/docs/page-footer.js +68 -0
  61. package/dist/docs/page-header.d.ts +13 -0
  62. package/dist/docs/page-header.js +57 -0
  63. package/dist/docs/page.d.ts +16 -0
  64. package/dist/docs/page.js +38 -0
  65. package/dist/docs/reading.js +64 -0
  66. package/dist/docs/shell.js +101 -0
  67. package/dist/docs/sidebar.js +161 -0
  68. package/dist/docs/toc-bar.d.ts +12 -0
  69. package/dist/docs/toc-bar.js +132 -0
  70. package/dist/docs/toc.d.ts +11 -0
  71. package/dist/docs/toc.js +127 -0
  72. package/dist/fonts/Inter-Italic.woff2 +0 -0
  73. package/dist/fonts/Inter-LICENSE.txt +92 -0
  74. package/dist/fonts/Inter.woff2 +0 -0
  75. package/dist/fonts/IoskeleyMono-Bold.woff2 +0 -0
  76. package/dist/fonts/IoskeleyMono-Italic.woff2 +0 -0
  77. package/dist/fonts/IoskeleyMono-LICENSE.txt +92 -0
  78. package/dist/fonts/IoskeleyMono-Regular.woff2 +0 -0
  79. package/dist/fonts.d.ts +1 -0
  80. package/dist/fonts.js +38 -0
  81. package/dist/home/features.d.ts +39 -0
  82. package/dist/home/features.js +75 -0
  83. package/dist/home/footer.d.ts +4 -0
  84. package/dist/home/footer.js +79 -0
  85. package/dist/home/hero-content.js +102 -0
  86. package/dist/home/hero-install.js +128 -0
  87. package/dist/home/hero-stage.d.ts +4 -0
  88. package/dist/home/hero-stage.js +9 -0
  89. package/dist/home/hero.d.ts +6 -0
  90. package/dist/home/hero.js +16 -0
  91. package/dist/home/home-header.d.ts +1 -0
  92. package/dist/home/home-header.js +173 -0
  93. package/dist/home/index.d.ts +7 -0
  94. package/dist/home/index.js +7 -0
  95. package/dist/home/layout.d.ts +6 -0
  96. package/dist/home/layout.js +15 -0
  97. package/dist/home/reveal.js +31 -0
  98. package/dist/index.d.ts +4 -0
  99. package/dist/index.js +4 -0
  100. package/dist/lib/clipboard.js +55 -0
  101. package/dist/lib/cn.js +1 -0
  102. package/dist/lib/format.js +9 -0
  103. package/dist/lib/package-manager-script.js +12 -0
  104. package/dist/lib/package-manager.js +54 -0
  105. package/dist/lib/theme-config.js +10 -0
  106. package/dist/llms.d.ts +34 -0
  107. package/dist/llms.js +111 -0
  108. package/dist/next.d.ts +18 -0
  109. package/dist/next.js +45 -0
  110. package/dist/node_modules/.pnpm/@types_mdast@4.0.4/node_modules/@types/mdast/index.d.ts +930 -0
  111. package/dist/node_modules/.pnpm/@types_mdx@2.0.14/node_modules/@types/mdx/types.d.ts +81 -0
  112. package/dist/node_modules/.pnpm/@types_unist@3.0.3/node_modules/@types/unist/index.d.ts +80 -0
  113. package/dist/registry.d.ts +61 -0
  114. package/dist/registry.js +113 -0
  115. package/dist/root.d.ts +9 -0
  116. package/dist/root.js +34 -0
  117. package/dist/search.d.ts +5 -0
  118. package/dist/search.js +43 -0
  119. package/dist/seo/index.d.ts +6 -0
  120. package/dist/seo/index.js +6 -0
  121. package/dist/seo/json-ld.d.ts +17 -0
  122. package/dist/seo/json-ld.js +88 -0
  123. package/dist/seo/metadata.d.ts +21 -0
  124. package/dist/seo/metadata.js +75 -0
  125. package/dist/seo/robots.d.ts +14 -0
  126. package/dist/seo/robots.js +18 -0
  127. package/dist/seo/sitemap.d.ts +16 -0
  128. package/dist/seo/sitemap.js +26 -0
  129. package/dist/seo/url.d.ts +6 -0
  130. package/dist/seo/url.js +11 -0
  131. package/dist/server.js +63 -0
  132. package/dist/site-context.js +17 -0
  133. package/dist/site.d.ts +41 -0
  134. package/dist/site.js +13 -0
  135. package/dist/source/compile.d.ts +6 -0
  136. package/dist/source/compile.js +32 -0
  137. package/dist/source/errors.d.ts +4 -0
  138. package/dist/source/errors.js +10 -0
  139. package/dist/source/frontmatter.d.ts +13 -0
  140. package/dist/source/frontmatter.js +102 -0
  141. package/dist/source/highlight.js +102 -0
  142. package/dist/source/index.d.ts +36 -0
  143. package/dist/source/index.js +102 -0
  144. package/dist/source/markdown.d.ts +48 -0
  145. package/dist/source/markdown.js +393 -0
  146. package/dist/source/prompt.js +33 -0
  147. package/dist/source/scan.d.ts +8 -0
  148. package/dist/source/scan.js +64 -0
  149. package/dist/source/toc.d.ts +5 -0
  150. package/dist/source/toc.js +28 -0
  151. package/dist/source/tree.d.ts +29 -0
  152. package/dist/source/tree.js +91 -0
  153. package/dist/styles.css +879 -0
  154. package/dist/typography.d.ts +101 -0
  155. package/dist/typography.js +232 -0
  156. package/package.json +84 -4
@@ -0,0 +1,173 @@
1
+ "use client";
2
+ import Link from "next/link";
3
+ import { SearchIcon } from "../components/icons.js";
4
+ import { Brand } from "../components/brand.js";
5
+ import { ThemeSwitch } from "../components/theme-switch.js";
6
+ import { Shortcut } from "../components/ui/kbd.js";
7
+ import { githubUrl } from "../site.js";
8
+ import { useSearch } from "../search.js";
9
+ import { useSite } from "../site-context.js";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ // src/home/home-header.tsx
12
+ const MENU = "home-menu";
13
+ const RAISED_ICON = "control-raised flex size-9 shrink-0 items-center justify-center rounded-[10px] text-fd-foreground outline-none focus-visible:ring-2 focus-visible:ring-fd-ring active:scale-96";
14
+ function external(href) {
15
+ return href.startsWith("http") ? {
16
+ target: "_blank",
17
+ rel: "noreferrer noopener"
18
+ } : {};
19
+ }
20
+ function MenuLink({ onClick, ...props }) {
21
+ const close = (event) => {
22
+ onClick?.(event);
23
+ event.currentTarget.closest("[popover]")?.hidePopover();
24
+ };
25
+ return /* @__PURE__ */ jsx(Link, {
26
+ onClick: close,
27
+ ...props
28
+ });
29
+ }
30
+ function HomeHeader() {
31
+ const site = useSite();
32
+ const LINKS = [
33
+ {
34
+ label: "Docs",
35
+ href: "/docs"
36
+ },
37
+ ...site.nav ?? [],
38
+ {
39
+ label: "GitHub",
40
+ href: githubUrl(site)
41
+ }
42
+ ];
43
+ const { setOpen } = useSearch();
44
+ const search = () => {
45
+ document.getElementById(MENU)?.hidePopover();
46
+ setOpen(true);
47
+ };
48
+ return /* @__PURE__ */ jsx("header", {
49
+ className: "home-header sticky top-0 z-40 w-full px-4 pt-4 pb-4 sm:pt-6",
50
+ children: /* @__PURE__ */ jsxs("div", {
51
+ className: "mx-auto flex h-10 w-full max-w-4xl items-center justify-between gap-4",
52
+ children: [/* @__PURE__ */ jsx("span", {
53
+ className: "flex min-w-0 items-center gap-2.5 text-sm",
54
+ children: /* @__PURE__ */ jsx(Link, {
55
+ href: "/",
56
+ "aria-label": `${site.name} home`,
57
+ className: "rounded-md outline-none focus-visible:ring-2 focus-visible:ring-fd-ring",
58
+ children: /* @__PURE__ */ jsx(Brand, {})
59
+ })
60
+ }), /* @__PURE__ */ jsxs("nav", {
61
+ "aria-label": "Main",
62
+ className: "flex shrink-0 items-center gap-2 sm:gap-6",
63
+ children: [
64
+ /* @__PURE__ */ jsx("ul", {
65
+ className: "hidden items-center gap-6 sm:flex",
66
+ children: LINKS.map((link) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(Link, {
67
+ href: link.href,
68
+ ...external(link.href),
69
+ className: "rounded-sm text-sm text-fd-foreground outline-none transition-colors duration-150 hover:text-fd-muted-foreground focus-visible:ring-2 focus-visible:ring-fd-ring",
70
+ children: link.label
71
+ }) }, link.href))
72
+ }),
73
+ /* @__PURE__ */ jsxs("button", {
74
+ type: "button",
75
+ onClick: search,
76
+ "aria-keyshortcuts": "Meta+K Control+K",
77
+ className: "group flex shrink-0 items-center gap-2 rounded-sm text-sm text-fd-foreground outline-none transition-colors duration-150 hover:text-fd-muted-foreground focus-visible:ring-2 focus-visible:ring-fd-ring max-sm:hidden",
78
+ children: ["Search", /* @__PURE__ */ jsx(Shortcut, {
79
+ keys: "mod+k",
80
+ size: "sm"
81
+ })]
82
+ }),
83
+ /* @__PURE__ */ jsx(ThemeSwitch, { className: "-mx-2 max-sm:hidden" }),
84
+ /* @__PURE__ */ jsx("button", {
85
+ type: "button",
86
+ onClick: search,
87
+ "aria-label": "Search the docs",
88
+ className: `${RAISED_ICON} sm:hidden`,
89
+ children: /* @__PURE__ */ jsx(SearchIcon, { className: "size-4" })
90
+ }),
91
+ /* @__PURE__ */ jsx("button", {
92
+ type: "button",
93
+ popoverTarget: MENU,
94
+ "aria-label": "Open menu",
95
+ className: `${RAISED_ICON} sm:hidden`,
96
+ children: /* @__PURE__ */ jsx("svg", {
97
+ viewBox: "0 0 16 16",
98
+ fill: "none",
99
+ stroke: "currentColor",
100
+ strokeWidth: "1.5",
101
+ strokeLinecap: "round",
102
+ "aria-hidden": true,
103
+ className: "size-4",
104
+ children: /* @__PURE__ */ jsx("path", { d: "M3.5 5.75h9M3.5 10.25h9" })
105
+ })
106
+ }),
107
+ /* @__PURE__ */ jsxs("div", {
108
+ id: MENU,
109
+ popover: "auto",
110
+ className: "menu-panel fixed inset-0 m-0 size-auto max-h-none max-w-none flex-col bg-fd-background/60 px-4 pt-4 pb-8 text-fd-foreground backdrop-blur-2xl backdrop-saturate-150 open:flex sm:hidden",
111
+ children: [
112
+ /* @__PURE__ */ jsxs("div", {
113
+ className: "flex h-10 shrink-0 items-center justify-between",
114
+ children: [/* @__PURE__ */ jsx(MenuLink, {
115
+ href: "/",
116
+ "aria-label": `${site.name} home`,
117
+ className: "text-sm",
118
+ children: /* @__PURE__ */ jsx(Brand, {})
119
+ }), /* @__PURE__ */ jsx("button", {
120
+ type: "button",
121
+ popoverTarget: MENU,
122
+ popoverTargetAction: "hide",
123
+ "aria-label": "Close menu",
124
+ className: RAISED_ICON,
125
+ children: /* @__PURE__ */ jsxs("svg", {
126
+ viewBox: "0 0 16 16",
127
+ fill: "none",
128
+ stroke: "currentColor",
129
+ strokeWidth: "1.5",
130
+ strokeLinecap: "round",
131
+ "aria-hidden": true,
132
+ className: "size-4",
133
+ children: [/* @__PURE__ */ jsx("path", {
134
+ className: "menu-x",
135
+ d: "M3.5 8h9"
136
+ }), /* @__PURE__ */ jsx("path", {
137
+ className: "menu-x",
138
+ d: "M3.5 8h9"
139
+ })]
140
+ })
141
+ })]
142
+ }),
143
+ /* @__PURE__ */ jsx("ul", {
144
+ className: "mt-16 flex flex-col",
145
+ children: LINKS.map((link, i) => /* @__PURE__ */ jsx("li", {
146
+ className: "menu-item",
147
+ style: { "--i": i },
148
+ children: /* @__PURE__ */ jsx(MenuLink, {
149
+ href: link.href,
150
+ ...external(link.href),
151
+ className: "block py-1 text-5xl font-medium tracking-[-0.02em] transition-colors duration-150 active:text-fd-muted-foreground",
152
+ children: link.label
153
+ })
154
+ }, link.href))
155
+ }),
156
+ /* @__PURE__ */ jsxs("div", {
157
+ className: "menu-item mt-auto flex items-center gap-3 pt-16",
158
+ style: { "--i": LINKS.length },
159
+ children: [/* @__PURE__ */ jsxs("button", {
160
+ type: "button",
161
+ onClick: search,
162
+ className: "control-ink flex h-12 flex-1 items-center justify-center gap-2.5 rounded-[11px] text-[15px] font-medium outline-none active:scale-96",
163
+ children: [/* @__PURE__ */ jsx(SearchIcon, { className: "size-4" }), "Search the docs"]
164
+ }), /* @__PURE__ */ jsx(ThemeSwitch, { className: "control-raised size-12 rounded-[11px] text-fd-foreground" })]
165
+ })
166
+ ]
167
+ })
168
+ ]
169
+ })]
170
+ })
171
+ });
172
+ }
173
+ export { HomeHeader };
@@ -0,0 +1,7 @@
1
+ import { Feature, FeatureImage, Features } from "./features.js";
2
+ import { Footer } from "./footer.js";
3
+ import { Hero } from "./hero.js";
4
+ import { HeroStage } from "./hero-stage.js";
5
+ import { HomeHeader } from "./home-header.js";
6
+ import { HomeLayout } from "./layout.js";
7
+ export { Feature, type FeatureImage, Features, Footer, Hero, HeroStage, HomeHeader, HomeLayout };
@@ -0,0 +1,7 @@
1
+ import { Feature, Features } from "./features.js";
2
+ import { Footer } from "./footer.js";
3
+ import { Hero } from "./hero.js";
4
+ import { HeroStage } from "./hero-stage.js";
5
+ import { HomeHeader } from "./home-header.js";
6
+ import { HomeLayout } from "./layout.js";
7
+ export { Feature, Features, Footer, Hero, HeroStage, HomeHeader, HomeLayout };
@@ -0,0 +1,6 @@
1
+ import { ReactNode } from "react";
2
+ import { Site } from "../site.js";
3
+ export declare function HomeLayout({ site, children }: {
4
+ site: Site;
5
+ children: ReactNode;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { Footer } from "./footer.js";
2
+ import { HomeHeader } from "./home-header.js";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ // src/home/layout.tsx
5
+ function HomeLayout({ site, children }) {
6
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(HomeHeader, {}), /* @__PURE__ */ jsxs("main", {
7
+ className: "relative flex flex-1 flex-col items-center overflow-hidden px-4",
8
+ children: [
9
+ children,
10
+ /* @__PURE__ */ jsx("div", { className: "flex-1" }),
11
+ /* @__PURE__ */ jsx(Footer, { site })
12
+ ]
13
+ })] });
14
+ }
15
+ export { HomeLayout };
@@ -0,0 +1,31 @@
1
+ "use client";
2
+ import { useEffect, useRef } from "react";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/home/reveal.tsx
5
+ /**
6
+ * Holds its `docs-reveal` items until the block comes into view, then lets them in one after
7
+ * another. When it is on screen from the start, it waits for the hero to finish first.
8
+ */
9
+ function Reveal({ className, ...props }) {
10
+ const ref = useRef(null);
11
+ useEffect(() => {
12
+ const node = ref.current;
13
+ if (!node) return;
14
+ let first = true;
15
+ const observer = new IntersectionObserver((entries) => {
16
+ if (entries.some((entry) => entry.isIntersecting)) {
17
+ node.dataset.shown = first ? "load" : "scroll";
18
+ observer.disconnect();
19
+ }
20
+ first = false;
21
+ }, { rootMargin: "0px 0px -10% 0px" });
22
+ observer.observe(node);
23
+ return () => observer.disconnect();
24
+ }, []);
25
+ return /* @__PURE__ */ jsx("div", {
26
+ ref,
27
+ className: `docs-reveal ${className ?? ""}`,
28
+ ...props
29
+ });
30
+ }
31
+ export { Reveal };
@@ -0,0 +1,4 @@
1
+ import { Agent, BUILT_IN_AGENTS, DEFAULT_AGENTS, defineAgent, fillPrompt } from "./agents.js";
2
+ import { Package, PackageManager, Registry, defineRegistry, installCommands, npm, pypi, registryUrl } from "./registry.js";
3
+ import { Site, SiteLink, defineSite, editUrl, githubUrl } from "./site.js";
4
+ export { type Agent, BUILT_IN_AGENTS, DEFAULT_AGENTS, type Package, type PackageManager, type Registry, type Site, type SiteLink, defineAgent, defineRegistry, defineSite, editUrl, fillPrompt, githubUrl, installCommands, npm, pypi, registryUrl };
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { BUILT_IN_AGENTS, DEFAULT_AGENTS, defineAgent, fillPrompt } from "./agents.js";
2
+ import { defineRegistry, installCommands, npm, pypi, registryUrl } from "./registry.js";
3
+ import { defineSite, editUrl, githubUrl } from "./site.js";
4
+ export { BUILT_IN_AGENTS, DEFAULT_AGENTS, defineAgent, defineRegistry, defineSite, editUrl, fillPrompt, githubUrl, installCommands, npm, pypi, registryUrl };
@@ -0,0 +1,55 @@
1
+ "use client";
2
+ import { useRef, useState } from "react";
3
+ import { toast } from "../components/ui/toast.js";
4
+ import { jsx } from "react/jsx-runtime";
5
+ // src/lib/clipboard.tsx
6
+ /**
7
+ * Writes text to the clipboard and reports whether it worked. The text can be a promise, for
8
+ * copies that fetch first: it goes in as a `ClipboardItem`, so Safari still treats the write
9
+ * as part of the click. A failure always gets an error
10
+ * toast, since the reader would otherwise paste something stale; with `notify` a success
11
+ * gets a toast too, for copies that happen as a side effect of another action.
12
+ */
13
+ async function copyText(text, { notify = false } = {}) {
14
+ let value;
15
+ try {
16
+ if (typeof text === "string") {
17
+ value = text;
18
+ await navigator.clipboard.writeText(text);
19
+ } else if (typeof ClipboardItem !== "undefined") {
20
+ const blob = text.then((it) => new Blob([it], { type: "text/plain" }));
21
+ await navigator.clipboard.write([new ClipboardItem({ "text/plain": blob })]);
22
+ value = await text;
23
+ } else {
24
+ value = await text;
25
+ await navigator.clipboard.writeText(value);
26
+ }
27
+ } catch {
28
+ toast.error("Could not copy", { description: "Select the text and copy it instead." });
29
+ return false;
30
+ }
31
+ if (notify) toast.success("Copied to clipboard", { description: /* @__PURE__ */ jsx("code", {
32
+ className: "font-mono text-[0.8125rem] break-all",
33
+ children: value
34
+ }) });
35
+ return true;
36
+ }
37
+ /**
38
+ * For copy buttons: `copy(text)` goes through `copyText`, and `copied` stays true for two
39
+ * seconds after a successful copy, long enough to show a check mark.
40
+ */
41
+ function useCopy() {
42
+ const [copied, setCopied] = useState(false);
43
+ const timer = useRef(void 0);
44
+ async function copy(text) {
45
+ if (!await copyText(text)) return;
46
+ setCopied(true);
47
+ clearTimeout(timer.current);
48
+ timer.current = setTimeout(() => setCopied(false), 2e3);
49
+ }
50
+ return {
51
+ copied,
52
+ copy
53
+ };
54
+ }
55
+ export { copyText, useCopy };
package/dist/lib/cn.js ADDED
@@ -0,0 +1 @@
1
+ export { twMerge as cn } from "tailwind-merge";
@@ -0,0 +1,9 @@
1
+ // src/lib/format.ts
2
+ const compact = new Intl.NumberFormat("en", {
3
+ notation: "compact",
4
+ maximumFractionDigits: 1
5
+ });
6
+ function formatCount(count) {
7
+ return compact.format(count);
8
+ }
9
+ export { formatCount };
@@ -0,0 +1,12 @@
1
+ // src/lib/package-manager-script.ts
2
+ /** `localStorage` key prefix for the reader's package manager, one key per registry id. */
3
+ const PM_PREFIX = "wrksz-docs:package-manager:";
4
+ /**
5
+ * Runs before the page paints. Static pages render the default package manager, so for every
6
+ * saved choice this adds CSS that shows the saved option instead, until the component marks
7
+ * itself `data-pm-ready` after hydration. Elements opt in with `data-pm-registry` on the
8
+ * container and `data-pm` plus one of `data-pm-panel`, `data-pm-text` or `data-pm-tab` on
9
+ * each option.
10
+ */
11
+ const packageManagerScript = `(function(){try{var p=${JSON.stringify(PM_PREFIX)},c="";for(var i=0;i<localStorage.length;i++){var k=localStorage.key(i);if(!k||k.indexOf(p)!==0)continue;var r=CSS.escape(k.slice(p.length)),m=CSS.escape(localStorage.getItem(k)||""),s='[data-pm-registry="'+r+'"]:not([data-pm-ready]) ',o='[data-pm="'+m+'"]',n=':not('+o+')';c+=s+'[data-pm-panel]'+n+'{display:none!important}'+s+'[data-pm-panel]'+o+'{display:block!important}'+s+'[data-pm-text]'+n+'{visibility:hidden!important}'+s+'[data-pm-text]'+o+'{visibility:visible!important}'+s+'[data-pm-tab]'+n+'{color:var(--color-fd-muted-foreground)!important}'+s+'[data-pm-tab]'+n+'::after{opacity:0!important}'+s+'[data-pm-tab]'+o+'{color:var(--color-fd-foreground)!important}'+s+'[data-pm-tab]'+o+'::after{opacity:1!important}'}if(c){var e=document.createElement("style");e.textContent=c;document.head.appendChild(e)}}catch(e){}})()`;
12
+ export { PM_PREFIX, packageManagerScript };
@@ -0,0 +1,54 @@
1
+ "use client";
2
+ import { useEffect, useState, useSyncExternalStore } from "react";
3
+ import { defaultManager } from "../registry.js";
4
+ import { PM_PREFIX } from "./package-manager-script.js";
5
+ // src/lib/package-manager.ts
6
+ const listeners = /* @__PURE__ */ new Set();
7
+ const memory = {};
8
+ function read(registry) {
9
+ try {
10
+ const stored = localStorage.getItem(PM_PREFIX + registry.id);
11
+ if (stored && registry.managers.some((manager) => manager.name === stored)) return stored;
12
+ } catch {}
13
+ return memory[registry.id] ?? defaultManager(registry);
14
+ }
15
+ /** Saves the reader's package manager for a registry and updates every picker on the page. */
16
+ function writePm(registry, manager) {
17
+ memory[registry.id] = manager;
18
+ try {
19
+ localStorage.setItem(PM_PREFIX + registry.id, manager);
20
+ } catch {}
21
+ for (const listener of listeners) listener();
22
+ }
23
+ function subscribe(listener) {
24
+ const onStorage = (event) => {
25
+ if (event.key?.startsWith("wrksz-docs:package-manager:")) listener();
26
+ };
27
+ listeners.add(listener);
28
+ window.addEventListener("storage", onStorage);
29
+ return () => {
30
+ listeners.delete(listener);
31
+ window.removeEventListener("storage", onStorage);
32
+ };
33
+ }
34
+ const noop = () => () => {};
35
+ /**
36
+ * True one frame after hydration, once React shows the saved package manager itself. Until
37
+ * then the pre-paint CSS from `packageManagerScript` does, and the sliding indicator and
38
+ * panel fade stay off so nothing travels from the default to the saved choice.
39
+ */
40
+ function usePmReady() {
41
+ const hydrated = useSyncExternalStore(noop, () => true, () => false);
42
+ const [ready, setReady] = useState(false);
43
+ useEffect(() => {
44
+ if (!hydrated) return;
45
+ const frame = requestAnimationFrame(() => setReady(true));
46
+ return () => cancelAnimationFrame(frame);
47
+ }, [hydrated]);
48
+ return ready;
49
+ }
50
+ /** The reader's package manager for a registry, shared across tabs. */
51
+ function usePackageManager(registry) {
52
+ return useSyncExternalStore(subscribe, () => read(registry), () => defaultManager(registry));
53
+ }
54
+ export { usePackageManager, usePmReady, writePm };
@@ -0,0 +1,10 @@
1
+ // src/lib/theme-config.ts
2
+ const appThemes = ["light", "dark"];
3
+ const themeProviderDefaults = {
4
+ attribute: "class",
5
+ defaultTheme: "system",
6
+ enableSystem: true,
7
+ storage: "localStorage",
8
+ disableTransitionOnChange: true
9
+ };
10
+ export { appThemes, themeProviderDefaults };
package/dist/llms.d.ts ADDED
@@ -0,0 +1,34 @@
1
+ import { MarkdownOptions } from "./source/markdown.js";
2
+ import { Site } from "./site.js";
3
+ import { Source } from "./source/index.js";
4
+ /** Absolute URL of a page's Markdown version: `/docs/guides` → `https://…/docs/guides.md`. */
5
+ export declare function markdownUrl(site: Site, url: string): string;
6
+ /** A page as Markdown, or `undefined` when no published page has these slugs. */
7
+ export declare function pageMarkdown(site: Site, source: Source, slugs?: string[], extra?: MarkdownOptions): string | undefined;
8
+ /**
9
+ * `llms.txt` in the format of llmstxt.org: the site's name and description, then every page
10
+ * as a link to its Markdown version with its description, grouped like the sidebar.
11
+ */
12
+ export declare function llmsIndex(site: Site, source: Source): string;
13
+ /** Every page as Markdown in sidebar order, for agents that read the whole docs at once. */
14
+ export declare function llmsFull(site: Site, source: Source, extra?: MarkdownOptions): string;
15
+ /**
16
+ * Everything a site serves for agents from one route handler: `llms.txt`, `llms-full.txt`
17
+ * and every page as Markdown. Put it at `app/llms.mdx/[[...path]]/route.ts`; `withDocs` in
18
+ * `next.config.ts` maps the public URLs onto it.
19
+ *
20
+ * ```ts
21
+ * export const { GET, generateStaticParams } = createLlmsRoute(site, source);
22
+ * ```
23
+ */
24
+ export declare function createLlmsRoute(site: Site, source: Source, extra?: MarkdownOptions): {
25
+ /** Every response is built at build time. */
26
+ generateStaticParams(): {
27
+ path: string[];
28
+ }[];
29
+ GET(_request: Request, context: {
30
+ params: Promise<{
31
+ path?: string[];
32
+ }>;
33
+ }): Promise<Response>;
34
+ };
package/dist/llms.js ADDED
@@ -0,0 +1,111 @@
1
+ import { BUILT_IN_REGISTRIES } from "./registry.js";
2
+ // src/llms.ts
3
+ /** Options the Markdown exports share: absolute links on the site and its own registry. */
4
+ function markdownOptions(site, source, extra = {}) {
5
+ return {
6
+ origin: site.url,
7
+ baseUrl: source.baseUrl,
8
+ registry: site.package.registry,
9
+ registries: {
10
+ ...BUILT_IN_REGISTRIES,
11
+ [site.package.registry.id]: site.package.registry
12
+ },
13
+ ...extra
14
+ };
15
+ }
16
+ /** Absolute URL of a page's Markdown version: `/docs/guides` → `https://…/docs/guides.md`. */
17
+ function markdownUrl(site, url) {
18
+ return `${site.url.replace(/\/$/, "")}${url.replace(/\/$/, "")}.md`;
19
+ }
20
+ /** A page as Markdown, or `undefined` when no published page has these slugs. */
21
+ function pageMarkdown(site, source, slugs = [], extra) {
22
+ const page = source.page(slugs);
23
+ return page ? source.markdown(page, markdownOptions(site, source, extra)) : void 0;
24
+ }
25
+ function entry(site, page, title, url) {
26
+ const description = page?.data.description ? `: ${page.data.description}` : "";
27
+ return `- [${title}](${markdownUrl(site, url)})${description}`;
28
+ }
29
+ /**
30
+ * `llms.txt` in the format of llmstxt.org: the site's name and description, then every page
31
+ * as a link to its Markdown version with its description, grouped like the sidebar.
32
+ */
33
+ function llmsIndex(site, source) {
34
+ const pages = new Map(source.pages().map((page) => [page.url, page]));
35
+ const lines = [
36
+ `# ${site.package.name}`,
37
+ "",
38
+ `> ${site.description}`
39
+ ];
40
+ let opened = false;
41
+ const walk = (nodes, depth) => {
42
+ for (const node of nodes) {
43
+ const indent = " ".repeat(depth);
44
+ if (node.type === "section") {
45
+ lines.push("", `## ${node.title}`, "");
46
+ opened = true;
47
+ continue;
48
+ }
49
+ if (!opened) {
50
+ lines.push("", "## Docs", "");
51
+ opened = true;
52
+ }
53
+ if (node.type === "page") lines.push(indent + entry(site, pages.get(node.url), node.title, node.url));
54
+ else if (node.type === "link") lines.push(`${indent}- [${node.title}](${node.href})`);
55
+ else {
56
+ lines.push(node.url ? indent + entry(site, pages.get(node.url), node.title, node.url) : `${indent}- ${node.title}`);
57
+ walk(node.children, depth + 1);
58
+ }
59
+ }
60
+ };
61
+ walk(source.tree(), 0);
62
+ return `${lines.join("\n")}\n`;
63
+ }
64
+ /** Every page as Markdown in sidebar order, for agents that read the whole docs at once. */
65
+ function llmsFull(site, source, extra) {
66
+ const pages = new Map(source.pages().map((page) => [page.url, page]));
67
+ const ordered = [];
68
+ const walk = (nodes) => {
69
+ for (const node of nodes) {
70
+ const url = node.type === "page" ? node.url : node.type === "folder" ? node.url : void 0;
71
+ const page = url ? pages.get(url) : void 0;
72
+ if (page) ordered.push(page);
73
+ if (node.type === "folder") walk(node.children);
74
+ }
75
+ };
76
+ walk(source.tree());
77
+ const options = markdownOptions(site, source, extra);
78
+ return ordered.map((page) => `${source.markdown(page, options)}\nSource: ${markdownUrl(site, page.url)}\n`).join("\n---\n\n");
79
+ }
80
+ const MARKDOWN = { "Content-Type": "text/markdown; charset=utf-8" };
81
+ /**
82
+ * Everything a site serves for agents from one route handler: `llms.txt`, `llms-full.txt`
83
+ * and every page as Markdown. Put it at `app/llms.mdx/[[...path]]/route.ts`; `withDocs` in
84
+ * `next.config.ts` maps the public URLs onto it.
85
+ *
86
+ * ```ts
87
+ * export const { GET, generateStaticParams } = createLlmsRoute(site, source);
88
+ * ```
89
+ */
90
+ function createLlmsRoute(site, source, extra) {
91
+ const base = source.baseUrl.split("/").filter(Boolean);
92
+ return {
93
+ /** Every response is built at build time. */
94
+ generateStaticParams() {
95
+ return [
96
+ { path: ["llms.txt"] },
97
+ { path: ["llms-full.txt"] },
98
+ ...source.params().map(({ slug }) => ({ path: [...base, ...slug] }))
99
+ ];
100
+ },
101
+ async GET(_request, context) {
102
+ const { path = [] } = await context.params;
103
+ const [first] = path;
104
+ if (path.length === 1 && first === "llms.txt") return new Response(llmsIndex(site, source), { headers: MARKDOWN });
105
+ if (path.length === 1 && first === "llms-full.txt") return new Response(llmsFull(site, source, extra), { headers: MARKDOWN });
106
+ const markdown = base.every((segment, index) => path[index] === segment) ? pageMarkdown(site, source, path.slice(base.length), extra) : void 0;
107
+ return markdown === void 0 ? new Response("Not found", { status: 404 }) : new Response(markdown, { headers: MARKDOWN });
108
+ }
109
+ };
110
+ }
111
+ export { createLlmsRoute, llmsFull, llmsIndex, markdownUrl, pageMarkdown };
package/dist/next.d.ts ADDED
@@ -0,0 +1,18 @@
1
+ import { NextConfig } from "next";
2
+ export type DocsConfigOptions = {
3
+ /** Path the docs are served under; match `createSource({ baseUrl })`. */
4
+ baseUrl?: string;
5
+ /** Where `createLlmsRoute` lives, e.g. `app/llms.mdx/[[...path]]/route.ts`. */
6
+ route?: string;
7
+ };
8
+ /**
9
+ * Adds what the docs engine needs to a Next config: the public URLs for agents, mapped
10
+ * onto the route of `createLlmsRoute`. `/llms.txt`, `/llms-full.txt`, `/docs.md` and
11
+ * `/docs/<page>.md` then work without anything else in the app. Kept free of the engine's
12
+ * other modules, since Next loads its config outside the bundler.
13
+ *
14
+ * ```ts
15
+ * export default withDocs({ reactStrictMode: true });
16
+ * ```
17
+ */
18
+ export declare function withDocs(config?: NextConfig, { baseUrl, route }?: DocsConfigOptions): NextConfig;
package/dist/next.js ADDED
@@ -0,0 +1,45 @@
1
+ // src/next.ts
2
+ /**
3
+ * Adds what the docs engine needs to a Next config: the public URLs for agents, mapped
4
+ * onto the route of `createLlmsRoute`. `/llms.txt`, `/llms-full.txt`, `/docs.md` and
5
+ * `/docs/<page>.md` then work without anything else in the app. Kept free of the engine's
6
+ * other modules, since Next loads its config outside the bundler.
7
+ *
8
+ * ```ts
9
+ * export default withDocs({ reactStrictMode: true });
10
+ * ```
11
+ */
12
+ function withDocs(config = {}, { baseUrl = "/docs", route = "/llms.mdx" } = {}) {
13
+ const ours = [
14
+ {
15
+ source: "/llms.txt",
16
+ destination: `${route}/llms.txt`
17
+ },
18
+ {
19
+ source: "/llms-full.txt",
20
+ destination: `${route}/llms-full.txt`
21
+ },
22
+ {
23
+ source: `${baseUrl}.md`,
24
+ destination: `${route}${baseUrl}`
25
+ },
26
+ {
27
+ source: `${baseUrl}/:path(.*)\\.md`,
28
+ destination: `${route}${baseUrl}/:path`
29
+ }
30
+ ];
31
+ return {
32
+ ...config,
33
+ transpilePackages: [.../* @__PURE__ */ new Set([...config.transpilePackages ?? [], "@wrksz/docs"])],
34
+ async rewrites() {
35
+ const existing = await config.rewrites?.();
36
+ if (!existing) return ours;
37
+ if (Array.isArray(existing)) return [...ours, ...existing];
38
+ return {
39
+ ...existing,
40
+ beforeFiles: [...ours, ...existing.beforeFiles ?? []]
41
+ };
42
+ }
43
+ };
44
+ }
45
+ export { withDocs };