@publish.os/nextjs 0.0.1-alpha.6 → 0.0.1-alpha.7

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 (220) hide show
  1. package/README.md +3 -5
  2. package/compiler-assets/nextjs/defaults/app/globals.css +6 -0
  3. package/compiler-assets/nextjs/defaults/group/layout.tsx +23 -0
  4. package/compiler-assets/nextjs/defaults/group/leaf.tsx +48 -0
  5. package/compiler-assets/nextjs/defaults/group/page.tsx +50 -0
  6. package/compiler-assets/nextjs/defaults/project/next.config.mjs +45 -0
  7. package/compiler-assets/nextjs/defaults/project/postcss.config.mjs +5 -0
  8. package/compiler-assets/nextjs/defaults/project/tsconfig.json.template +41 -0
  9. package/compiler-assets/nextjs/defaults/root/css/animation.css +90 -0
  10. package/compiler-assets/nextjs/defaults/root/css/components/dialog.css +21 -0
  11. package/compiler-assets/nextjs/defaults/root/css/components/drawer.css +21 -0
  12. package/compiler-assets/nextjs/defaults/root/css/components/menu.css +23 -0
  13. package/compiler-assets/nextjs/defaults/root/css/components/navigation-menu.css +25 -0
  14. package/compiler-assets/nextjs/defaults/root/css/components/popover.css +17 -0
  15. package/compiler-assets/nextjs/defaults/root/css/components/select.css +23 -0
  16. package/compiler-assets/nextjs/defaults/root/css/components/toast.css +19 -0
  17. package/compiler-assets/nextjs/defaults/root/css/components/tooltip.css +15 -0
  18. package/compiler-assets/nextjs/defaults/root/css/layout.css +22 -0
  19. package/compiler-assets/nextjs/defaults/root/css/media.css +81 -0
  20. package/compiler-assets/nextjs/defaults/root/css/radius.css +49 -0
  21. package/compiler-assets/nextjs/defaults/root/css/scrollbar.css +43 -0
  22. package/compiler-assets/nextjs/defaults/root/css/shadow.css +145 -0
  23. package/compiler-assets/nextjs/defaults/root/css/typography.css +607 -0
  24. package/compiler-assets/nextjs/defaults/root/css/zindex.css +39 -0
  25. package/compiler-assets/nextjs/defaults/root/globals.css +191 -0
  26. package/compiler-assets/nextjs/defaults/root/layout.tsx +19 -0
  27. package/compiler-assets/nextjs/defaults/root/page.tsx +61 -0
  28. package/compiler-assets/nextjs/defaults/root/theme.css +50 -0
  29. package/compiler-assets/nextjs/defaults/source/_internal/logger.ts +21 -0
  30. package/compiler-assets/nextjs/shims/generated-group-layout.tsx +19 -0
  31. package/compiler-assets/nextjs/shims/generated-group-page.tsx +18 -0
  32. package/compiler-assets/nextjs/shims/generated-leaf-page.tsx +21 -0
  33. package/compiler-assets/nextjs/shims/global-layout.tsx +134 -0
  34. package/compiler-assets/nextjs/shims/markdown-route.ts +29 -0
  35. package/compiler-assets/nextjs/shims/og-image-route.ts +18 -0
  36. package/compiler-assets/nextjs/shims/powered-by-footer.tsx +40 -0
  37. package/compiler-assets/nextjs/shims/providers.tsx +13 -0
  38. package/compiler-assets/nextjs/shims/proxy.ts +317 -0
  39. package/compiler-assets/nextjs/shims/publish-os-theme-provider.tsx +77 -0
  40. package/compiler-assets/nextjs/shims/root-page.tsx +13 -0
  41. package/compiler-assets/nextjs/shims/theme-defaults.css +177 -0
  42. package/dist/button-CFdx-ohV.d.ts +20 -0
  43. package/dist/cache/tags.js +6 -14
  44. package/dist/compiler.d.ts +100 -0
  45. package/dist/compiler.js +13379 -0
  46. package/dist/config/createNextConfig.d.ts +2 -1
  47. package/dist/config/createNextConfig.js +16 -12
  48. package/dist/icons.d.ts +1 -0
  49. package/dist/icons.js +2 -0
  50. package/dist/index.d.ts +303 -15
  51. package/dist/index.js +30 -1198
  52. package/dist/kernel/components/blocks/AgentActions.d.ts +9 -3
  53. package/dist/kernel/components/blocks/AgentActions.js +114 -200
  54. package/dist/kernel/components/blocks/animated-icon-swap.js +4 -25
  55. package/dist/kernel/components/blocks/color-palette.js +88 -169
  56. package/dist/kernel/components/blocks/design-system-preview.d.ts +38 -6
  57. package/dist/kernel/components/blocks/design-system-preview.js +44 -52
  58. package/dist/kernel/components/blocks/link-playground.js +23 -71
  59. package/dist/kernel/components/blocks/logo-block.js +18 -47
  60. package/dist/kernel/components/blocks/nav-breadcrumb.d.ts +1 -1
  61. package/dist/kernel/components/blocks/nav-breadcrumb.js +28 -42
  62. package/dist/kernel/components/blocks/navbar.d.ts +1 -1
  63. package/dist/kernel/components/blocks/navbar.js +14 -41
  64. package/dist/kernel/components/blocks/navigation-progress-playground.js +56 -149
  65. package/dist/kernel/components/blocks/navigation-progress.js +53 -157
  66. package/dist/kernel/components/blocks/next-prev.d.ts +1 -1
  67. package/dist/kernel/components/blocks/next-prev.js +16 -42
  68. package/dist/kernel/components/blocks/page-list.d.ts +1 -1
  69. package/dist/kernel/components/blocks/page-list.js +11 -16
  70. package/dist/kernel/components/blocks/search.d.ts +13 -2
  71. package/dist/kernel/components/blocks/search.js +116 -247
  72. package/dist/kernel/components/blocks/sidebar-node.d.ts +2 -2
  73. package/dist/kernel/components/blocks/sidebar-node.js +56 -95
  74. package/dist/kernel/components/blocks/sidebar.d.ts +5 -23
  75. package/dist/kernel/components/blocks/sidebar.js +35 -103
  76. package/dist/kernel/components/blocks/theme-toggle.d.ts +7 -3
  77. package/dist/kernel/components/blocks/theme-toggle.js +2 -2
  78. package/dist/kernel/components/blocks/toc.js +42 -178
  79. package/dist/kernel/components/mdx/components/blockquote.js +3 -24
  80. package/dist/kernel/components/mdx/components/callout.d.ts +1 -1
  81. package/dist/kernel/components/mdx/components/callout.js +15 -47
  82. package/dist/kernel/components/mdx/components/code-block.js +2 -2
  83. package/dist/kernel/components/mdx/components/figure-caption.js +6 -24
  84. package/dist/kernel/components/mdx/components/figure.js +9 -36
  85. package/dist/kernel/components/mdx/components/footnotes.js +3 -24
  86. package/dist/kernel/components/mdx/components/heading-copy-link.js +13 -37
  87. package/dist/kernel/components/mdx/components/heading.d.ts +8 -3
  88. package/dist/kernel/components/mdx/components/heading.js +32 -116
  89. package/dist/kernel/components/mdx/components/hr.d.ts +5 -3
  90. package/dist/kernel/components/mdx/components/hr.js +2 -2
  91. package/dist/kernel/components/mdx/components/image-zoom.js +2 -3
  92. package/dist/kernel/components/mdx/components/image.js +22 -62
  93. package/dist/kernel/components/mdx/components/inline-code.js +3 -24
  94. package/dist/kernel/components/mdx/components/kbd.d.ts +9 -4
  95. package/dist/kernel/components/mdx/components/kbd.js +2 -2
  96. package/dist/kernel/components/mdx/components/link.d.ts +1 -2
  97. package/dist/kernel/components/mdx/components/link.js +2 -2
  98. package/dist/kernel/components/mdx/components/paragraph.js +13 -41
  99. package/dist/kernel/components/mdx/components/pre.js +3 -24
  100. package/dist/kernel/components/mdx/components/strikethrough.js +6 -24
  101. package/dist/kernel/components/mdx/components/table.js +2 -2
  102. package/dist/kernel/components/mdx/components/task-list.js +6 -28
  103. package/dist/kernel/components/mdx/components/video-player.js +53 -88
  104. package/dist/kernel/components/mdx/components/video.js +27 -75
  105. package/dist/kernel/components/mdx/error-boundary.d.ts +1 -1
  106. package/dist/kernel/components/mdx/error-boundary.js +12 -15
  107. package/dist/kernel/components/mdx/error-fallback.js +4 -4
  108. package/dist/kernel/components/mdx/mdx.d.ts +68 -11
  109. package/dist/kernel/components/mdx/mdx.js +29 -29
  110. package/dist/kernel/components/mdx/rehype-heading-ids.js +11 -67
  111. package/dist/kernel/components/mdx/types.d.ts +1 -1
  112. package/dist/kernel/components/ui/accordion.js +3 -26
  113. package/dist/kernel/components/ui/breadcrumb-trail.d.ts +23 -7
  114. package/dist/kernel/components/ui/breadcrumb-trail.js +32 -80
  115. package/dist/kernel/components/ui/breadcrumb.d.ts +1 -1
  116. package/dist/kernel/components/ui/breadcrumb.js +20 -54
  117. package/dist/kernel/components/ui/button-group.d.ts +4 -3
  118. package/dist/kernel/components/ui/button-group.js +7 -30
  119. package/dist/kernel/components/ui/button.js +13 -36
  120. package/dist/kernel/components/ui/card.d.ts +2 -2
  121. package/dist/kernel/components/ui/card.js +2 -23
  122. package/dist/kernel/components/ui/dialog.d.ts +9 -9
  123. package/dist/kernel/components/ui/dialog.js +15 -33
  124. package/dist/kernel/components/ui/drawer.d.ts +10 -10
  125. package/dist/kernel/components/ui/drawer.js +15 -33
  126. package/dist/kernel/components/ui/input.js +6 -30
  127. package/dist/kernel/components/ui/kbd.js +10 -31
  128. package/dist/kernel/components/ui/link.d.ts +1 -1
  129. package/dist/kernel/components/ui/link.js +53 -104
  130. package/dist/kernel/components/ui/menu.d.ts +21 -21
  131. package/dist/kernel/components/ui/menu.js +10 -32
  132. package/dist/kernel/components/ui/meta-key.d.ts +9 -4
  133. package/dist/kernel/components/ui/meta-key.js +2 -2
  134. package/dist/kernel/components/ui/navigation-menu.d.ts +14 -14
  135. package/dist/kernel/components/ui/navigation-menu.js +9 -30
  136. package/dist/kernel/components/ui/popover.d.ts +10 -10
  137. package/dist/kernel/components/ui/popover.js +19 -34
  138. package/dist/kernel/components/ui/progress.js +2 -25
  139. package/dist/kernel/components/ui/scroll-area.js +39 -118
  140. package/dist/kernel/components/ui/select.d.ts +15 -15
  141. package/dist/kernel/components/ui/select.js +19 -35
  142. package/dist/kernel/components/ui/separator.js +2 -25
  143. package/dist/kernel/components/ui/table.js +2 -23
  144. package/dist/kernel/components/ui/tabs.js +39 -99
  145. package/dist/kernel/components/ui/tag.d.ts +2 -2
  146. package/dist/kernel/components/ui/tag.js +4 -25
  147. package/dist/kernel/components/ui/text.d.ts +2 -2
  148. package/dist/kernel/components/ui/text.js +3 -25
  149. package/dist/kernel/components/ui/theme-toggle.d.ts +18 -4
  150. package/dist/kernel/components/ui/theme-toggle.js +18 -44
  151. package/dist/kernel/components/ui/toast.d.ts +10 -10
  152. package/dist/kernel/components/ui/toast.js +13 -35
  153. package/dist/kernel/components/ui/tooltip.d.ts +8 -8
  154. package/dist/kernel/components/ui/tooltip.js +8 -29
  155. package/dist/kernel/defaults.registry.d.ts +1 -1
  156. package/dist/kernel/defaults.registry.js +2 -2
  157. package/dist/kernel/framework-icons.d.ts +1 -0
  158. package/dist/kernel/framework-icons.js +39 -0
  159. package/dist/kernel/routes/agent/markdown.js +36 -65
  160. package/dist/kernel/routes/layouts/group.d.ts +1 -1
  161. package/dist/kernel/routes/layouts/group.js +20 -109
  162. package/dist/kernel/routes/metadata/feed.d.ts +1 -2
  163. package/dist/kernel/routes/metadata/feed.js +46 -127
  164. package/dist/kernel/routes/metadata/llms.d.ts +1 -2
  165. package/dist/kernel/routes/metadata/llms.js +40 -120
  166. package/dist/kernel/routes/metadata/og-image.d.ts +10 -0
  167. package/dist/kernel/routes/metadata/og-image.js +264 -198
  168. package/dist/kernel/routes/metadata/robots.d.ts +1 -2
  169. package/dist/kernel/routes/metadata/robots.js +21 -90
  170. package/dist/kernel/routes/metadata/sitemap.d.ts +1 -2
  171. package/dist/kernel/routes/metadata/sitemap.js +36 -102
  172. package/dist/kernel/routes/pages/group.d.ts +1 -1
  173. package/dist/kernel/routes/pages/group.js +42 -137
  174. package/dist/kernel/routes/pages/leaf.d.ts +1 -1
  175. package/dist/kernel/routes/pages/leaf.js +74 -213
  176. package/dist/kernel/routes/pages/root.d.ts +1 -1
  177. package/dist/kernel/routes/pages/root.js +37 -108
  178. package/dist/keyboard-shortcuts.js +69 -141
  179. package/dist/link-CYaCRDb6.d.ts +35 -0
  180. package/dist/resolvers/manifest-resolver.d.ts +3 -3
  181. package/dist/resolvers/manifest-resolver.js +15 -21
  182. package/dist/route-metadata-og-image-BeKKFHg7.d.ts +58 -0
  183. package/dist/search.d.ts +81 -4
  184. package/dist/search.js +124 -195
  185. package/dist/sidebar-types-Bgchdfd6.d.ts +25 -0
  186. package/dist/theme-scope.d.ts +15 -0
  187. package/dist/theme-scope.js +23 -0
  188. package/dist/types-B_b3C0U6.d.ts +63 -0
  189. package/dist/types-CIwwieNw.d.ts +127 -0
  190. package/dist/types-DHBm7-j6.d.ts +57 -0
  191. package/dist/types-sM2g9nW0.d.ts +12 -0
  192. package/dist/types.d.ts +0 -1
  193. package/dist/types.js +1 -1
  194. package/dist/utils/cn.d.ts +5 -9
  195. package/dist/utils/cn.js +13 -7
  196. package/dist/utils/heading-ids.js +20 -47
  197. package/dist/utils/pretty-date.js +7 -13
  198. package/init/seed/minimal/publish.os/assets/logo/publish-dev-logo.dark.png +0 -0
  199. package/init/seed/minimal/publish.os/assets/logo/publish-dev-logo.png +0 -0
  200. package/init/seed/minimal/publish.os/docs/content/get-started.mdx +54 -0
  201. package/init/seed/minimal/publish.os/docs/content/groups.mdx +31 -0
  202. package/init/seed/minimal/publish.os/docs/content/theme.mdx +64 -0
  203. package/init/seed/minimal/publish.os/publish.os.config.json +21 -0
  204. package/init/seed/minimal/publish.os/theme.css +47 -0
  205. package/init/seed/minimal/seed.json +13 -0
  206. package/package.json +469 -35
  207. package/release/{package.json → app/lucide/package.json} +11 -5
  208. package/release/app/lucide/pnpm-lock.yaml.template +2905 -0
  209. package/release/app/lucide/pnpm-workspace.yaml +11 -0
  210. package/release/app/phosphor/package.json +30 -0
  211. package/release/app/phosphor/pnpm-lock.yaml.template +2908 -0
  212. package/release/app/phosphor/pnpm-workspace.yaml +11 -0
  213. package/release/app/tabler/package.json +30 -0
  214. package/release/app/tabler/pnpm-lock.yaml.template +2911 -0
  215. package/release/app/tabler/pnpm-workspace.yaml +11 -0
  216. package/release/compiler/package.json +20 -0
  217. package/release/compiler/pnpm-lock.yaml.template +2432 -0
  218. package/release/compiler/pnpm-workspace.yaml +11 -0
  219. package/release/release.json +29 -5
  220. package/release/runtime-pnpm-lock.yaml +0 -1316
package/dist/search.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
 
3
- // src/search.tsx
3
+ // src/modules/search/search.tsx
4
4
  import { useShortcut } from "@publish.os/nextjs/keyboard-shortcuts";
5
5
  import { useRouter } from "next/navigation";
6
6
  import {
@@ -19,12 +19,7 @@ var EMPTY_SEARCH_OUTPUT = {
19
19
  nextOffset: null,
20
20
  status: "idle",
21
21
  total: 0
22
- };
23
- var MAX_SEARCH_QUERY_LENGTH = 128;
24
- var MAX_SEARCH_RESULTS = 20;
25
- var DEFAULT_SEARCH_LIMIT = 10;
26
- var SEARCH_DEBOUNCE_MS = 140;
27
- var SearchBlockContext = createContext(null);
22
+ }, MAX_SEARCH_QUERY_LENGTH = 128, MAX_SEARCH_RESULTS = 20, DEFAULT_SEARCH_LIMIT = 10, SEARCH_DEBOUNCE_MS = 140, SearchBlockContext = createContext(null);
28
23
  function normalizeSearchInput(input) {
29
24
  return {
30
25
  filters: input.filters,
@@ -45,38 +40,53 @@ function inactiveIndexMessage() {
45
40
  total: 0
46
41
  };
47
42
  }
48
- var SEARCH_STATUS_URL = "/pagefind/publishos-search-status.json";
49
- var PAGEFIND_URL = "/pagefind/pagefind.js";
50
- var pagefindModulePromise = null;
43
+ var SEARCH_STATUS_URL = "/pagefind/pagefind-entry.json", PAGEFIND_URL = "/pagefind/pagefind.js", pagefindModulePromise = null, activeIndex;
51
44
  async function fetchSearchStatus(signal) {
52
- const response = await fetch(SEARCH_STATUS_URL, {
45
+ let response = await fetch(SEARCH_STATUS_URL, {
53
46
  cache: "no-store",
54
47
  signal
55
48
  }).catch((error) => {
56
- if (error instanceof DOMException && error.name === "AbortError") {
49
+ if (error instanceof DOMException && error.name === "AbortError")
57
50
  throw error;
58
- }
59
51
  return null;
60
52
  });
61
- if (!response?.ok) return null;
62
- return await response.json();
53
+ return response?.ok ? (await response.json()).publishos ?? null : null;
63
54
  }
64
55
  async function loadPagefind() {
65
- pagefindModulePromise ??= new Function("src", "return import(src)")(PAGEFIND_URL).then(async (mod) => {
66
- const pagefind = mod;
67
- await pagefind.options?.({ bundlePath: "/pagefind/" });
68
- await pagefind.init?.();
69
- return pagefind;
70
- });
71
- return pagefindModulePromise;
56
+ return pagefindModulePromise ??= new Function("src", "return import(src)")(PAGEFIND_URL), pagefindModulePromise;
57
+ }
58
+ async function withPagefindIndex(revision, run) {
59
+ let release = async (index) => {
60
+ index.retired && index.readers === 0 && await (await index.instance).destroy();
61
+ };
62
+ if (!activeIndex || activeIndex.revision !== revision) {
63
+ let previous = activeIndex;
64
+ activeIndex = {
65
+ revision,
66
+ readers: 0,
67
+ retired: !1,
68
+ instance: loadPagefind().then(async (module) => {
69
+ let instance = module.createInstance({ bundlePath: "/pagefind/" });
70
+ return await instance.init?.(), instance;
71
+ })
72
+ }, previous && (previous.retired = !0, release(previous).catch(() => {
73
+ }));
74
+ }
75
+ let selected = activeIndex;
76
+ selected.readers += 1;
77
+ try {
78
+ return await run(await selected.instance);
79
+ } finally {
80
+ selected.readers -= 1, await release(selected);
81
+ }
72
82
  }
73
83
  function pagefindFilters(filters) {
74
- if (!filters) return void 0;
75
- const entries = Object.entries({
84
+ if (!filters) return;
85
+ let entries = Object.entries({
76
86
  author: filters.author,
77
87
  group: filters.group,
78
88
  tag: filters.tag
79
- }).filter((entry) => Boolean(entry[1]));
89
+ }).filter((entry) => !!entry[1]);
80
90
  return entries.length > 0 ? Object.fromEntries(entries) : void 0;
81
91
  }
82
92
  function titleForResult(data) {
@@ -87,8 +97,7 @@ function toSearchResult({
87
97
  fallbackId,
88
98
  score
89
99
  }) {
90
- const title = titleForResult(data);
91
- const excerpt = data.excerpt ?? "";
100
+ let title = titleForResult(data), excerpt = data.excerpt ?? "";
92
101
  return {
93
102
  excerpt,
94
103
  id: data.url || fallbackId,
@@ -106,235 +115,155 @@ function toSearchResult({
106
115
  };
107
116
  }
108
117
  function statusOutput(status) {
109
- if (status.status === "ready" || status.status === void 0) return null;
110
- if (status.status === "empty") {
111
- return {
112
- items: [],
113
- message: "No searchable pages are available.",
114
- nextOffset: null,
115
- status: "ready",
116
- total: 0
117
- };
118
- }
119
- if (status.status === "building") {
120
- return {
121
- items: [],
122
- message: status.message ?? "Building search index...",
123
- nextOffset: null,
124
- status: "building",
125
- total: 0
126
- };
127
- }
128
- if (status.status === "stale") {
129
- return {
130
- items: [],
131
- message: status.message ?? "Updating search index...",
132
- nextOffset: null,
133
- status: "stale",
134
- total: 0
135
- };
136
- }
137
- if (status.status === "error") {
138
- return {
139
- items: [],
140
- message: status.message ?? "Search is temporarily unavailable",
141
- nextOffset: null,
142
- status: "error",
143
- total: 0
144
- };
145
- }
146
- return null;
118
+ return status.status === "ready" || status.status === void 0 ? null : status.status === "empty" ? {
119
+ items: [],
120
+ message: "No searchable pages are available.",
121
+ nextOffset: null,
122
+ status: "ready",
123
+ total: 0
124
+ } : status.status === "building" ? {
125
+ items: [],
126
+ message: status.message ?? "Building search index...",
127
+ nextOffset: null,
128
+ status: "building",
129
+ total: 0
130
+ } : status.status === "stale" ? {
131
+ items: [],
132
+ message: status.message ?? "Updating search index...",
133
+ nextOffset: null,
134
+ status: "stale",
135
+ total: 0
136
+ } : status.status === "error" ? {
137
+ items: [],
138
+ message: status.message ?? "Search is temporarily unavailable",
139
+ nextOffset: null,
140
+ status: "error",
141
+ total: 0
142
+ } : null;
147
143
  }
148
144
  async function runPagefindSearch(input) {
149
- const normalized = normalizeSearchInput(input);
150
- if (!normalized.q) {
145
+ let normalized = normalizeSearchInput(input);
146
+ if (!normalized.q)
151
147
  return EMPTY_SEARCH_OUTPUT;
152
- }
153
- const status = await fetchSearchStatus(input.signal);
154
- const blockedByStatus = status ? statusOutput(status) : null;
155
- if (blockedByStatus) return blockedByStatus;
156
- const pagefind = await loadPagefind();
157
- const limit = normalized.limit ?? DEFAULT_SEARCH_LIMIT;
158
- const offset = normalized.offset ?? 0;
159
- const result = await pagefind.search(normalized.q, {
160
- filters: pagefindFilters(normalized.filters),
161
- limit,
162
- offset
148
+ let status = await fetchSearchStatus(input.signal), blockedByStatus = status ? statusOutput(status) : null;
149
+ return blockedByStatus || await withPagefindIndex(status?.revision, async (pagefind) => {
150
+ let limit = normalized.limit ?? DEFAULT_SEARCH_LIMIT, offset = normalized.offset ?? 0, result = await pagefind.search(normalized.q, {
151
+ filters: pagefindFilters(normalized.filters),
152
+ limit,
153
+ offset
154
+ });
155
+ if (!result) return EMPTY_SEARCH_OUTPUT;
156
+ let items = await Promise.all(
157
+ result.results.map(
158
+ async (pagefindResult) => toSearchResult({
159
+ data: await pagefindResult.data(),
160
+ fallbackId: pagefindResult.id,
161
+ score: pagefindResult.score
162
+ })
163
+ )
164
+ ), total = result.unfilteredResultCount ?? items.length, nextOffset = offset + limit < total ? offset + limit : null;
165
+ return {
166
+ items,
167
+ nextOffset,
168
+ status: "ready",
169
+ total
170
+ };
163
171
  });
164
- if (!result) return EMPTY_SEARCH_OUTPUT;
165
- const items = await Promise.all(
166
- result.results.map(
167
- async (pagefindResult) => toSearchResult({
168
- data: await pagefindResult.data(),
169
- fallbackId: pagefindResult.id,
170
- score: pagefindResult.score
171
- })
172
- )
173
- );
174
- const total = result.unfilteredResultCount ?? items.length;
175
- const nextOffset = offset + limit < total ? offset + limit : null;
176
- return {
177
- items,
178
- nextOffset,
179
- status: "ready",
180
- total
181
- };
182
172
  }
183
173
  async function search(input) {
184
- const normalized = normalizeSearchInput(input);
185
- if (!normalized.q) {
174
+ let normalized = normalizeSearchInput(input);
175
+ if (!normalized.q)
186
176
  return EMPTY_SEARCH_OUTPUT;
187
- }
188
177
  try {
189
178
  return await runPagefindSearch(normalized);
190
179
  } catch (error) {
191
- if (error instanceof DOMException && error.name === "AbortError") {
192
- return EMPTY_SEARCH_OUTPUT;
193
- }
194
- return inactiveIndexMessage();
180
+ return error instanceof DOMException && error.name === "AbortError" ? EMPTY_SEARCH_OUTPUT : inactiveIndexMessage();
195
181
  }
196
182
  }
197
183
  function useSearch(input) {
198
- const { filters, limit, offset, q } = input;
199
- const stableInput = useMemo(
184
+ let { filters, limit, offset, q } = input, stableInput = useMemo(
200
185
  () => normalizeSearchInput({ filters, limit, offset, q }),
201
186
  [filters, limit, offset, q]
202
- );
203
- const [output, setOutput] = useState(EMPTY_SEARCH_OUTPUT);
204
- const requestId = useRef(0);
205
- useEffect(() => {
206
- const nextRequestId = requestId.current + 1;
207
- requestId.current = nextRequestId;
208
- if (!stableInput.q) {
187
+ ), [output, setOutput] = useState(EMPTY_SEARCH_OUTPUT), requestId = useRef(0);
188
+ return useEffect(() => {
189
+ let nextRequestId = requestId.current + 1;
190
+ if (requestId.current = nextRequestId, !stableInput.q) {
209
191
  setOutput(EMPTY_SEARCH_OUTPUT);
210
192
  return;
211
193
  }
212
- const controller = new AbortController();
213
- const timer = window.setTimeout(() => {
214
- setOutput((current) => ({ ...current, status: "idle" }));
215
- runPagefindSearch({ ...stableInput, signal: controller.signal }).then((result) => {
216
- if (requestId.current !== nextRequestId) return;
217
- setOutput(result);
194
+ let controller = new AbortController(), timer = window.setTimeout(() => {
195
+ setOutput((current) => ({ ...current, status: "idle" })), runPagefindSearch({ ...stableInput, signal: controller.signal }).then((result) => {
196
+ requestId.current === nextRequestId && setOutput(result);
218
197
  }).catch((error) => {
219
- if (requestId.current !== nextRequestId) return;
220
- if (error instanceof DOMException && error.name === "AbortError") {
221
- return;
222
- }
223
- setOutput(inactiveIndexMessage());
198
+ requestId.current === nextRequestId && (error instanceof DOMException && error.name === "AbortError" || setOutput(inactiveIndexMessage()));
224
199
  });
225
200
  }, SEARCH_DEBOUNCE_MS);
226
201
  return () => {
227
- window.clearTimeout(timer);
228
- controller.abort();
202
+ window.clearTimeout(timer), controller.abort();
229
203
  };
230
- }, [stableInput]);
231
- return output;
204
+ }, [stableInput]), output;
232
205
  }
233
206
  function useSearchBlock() {
234
- const value = useContext(SearchBlockContext);
235
- if (!value) {
207
+ let value = useContext(SearchBlockContext);
208
+ if (!value)
236
209
  throw new Error("useSearchBlock must be used inside <Search.Root>.");
237
- }
238
210
  return value;
239
211
  }
240
212
  function SearchProvider({
241
213
  children,
242
- defaultOpen = false,
214
+ defaultOpen = !1,
243
215
  limit = DEFAULT_SEARCH_LIMIT,
244
216
  onOpenChange,
245
217
  open: controlledOpen,
246
218
  shortcut = "mod+k",
247
219
  variant = "desktop"
248
220
  }) {
249
- const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
250
- const [query, setQuery] = useState("");
251
- const [isTyping, setIsTyping] = useState(false);
252
- const [selectedValue, setSelectedValue] = useState("");
253
- const typingTimer = useRef(null);
254
- const inputRef = useRef(null);
255
- const listRef = useRef(null);
256
- const router = useRouter();
257
- const inputId = useId();
258
- const listId = useId();
259
- const open = controlledOpen ?? uncontrolledOpen;
260
- const output = useSearch({ limit, q: query });
261
- const [displayResults, setDisplayResults] = useState([]);
262
- const selectedResult = displayResults.find((result) => result.id === selectedValue) ?? displayResults[0];
263
- const selectedResultId = selectedResult?.id ?? "";
264
- const loading = Boolean(query.trim()) && !isTyping && output.status === "idle";
265
- const setOpen = useCallback(
221
+ let [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen), [query, setQuery] = useState(""), [isTyping, setIsTyping] = useState(!1), [selectedValue, setSelectedValue] = useState(""), typingTimer = useRef(null), inputRef = useRef(null), listRef = useRef(null), router = useRouter(), inputId = useId(), listId = useId(), open = controlledOpen ?? uncontrolledOpen, output = useSearch({ limit, q: query }), [displayResults, setDisplayResults] = useState([]), selectedResultId = (displayResults.find((result) => result.id === selectedValue) ?? displayResults[0])?.id ?? "", loading = !!query.trim() && !isTyping && output.status === "idle", setOpen = useCallback(
266
222
  (nextOpen) => {
267
- if (controlledOpen === void 0) {
268
- setUncontrolledOpen(nextOpen);
269
- }
270
- onOpenChange?.(nextOpen);
271
- if (!nextOpen) {
272
- setQuery("");
273
- setSelectedValue("");
274
- setIsTyping(false);
275
- }
223
+ controlledOpen === void 0 && setUncontrolledOpen(nextOpen), onOpenChange?.(nextOpen), nextOpen || (setQuery(""), setSelectedValue(""), setIsTyping(!1));
276
224
  },
277
225
  [controlledOpen, onOpenChange]
278
- );
279
- const setQueryValue = useCallback((value) => {
280
- setQuery(value);
281
- }, []);
282
- const handleInputChange = useCallback((value) => {
226
+ ), setQueryValue = useCallback((value) => {
283
227
  setQuery(value);
284
- setIsTyping(true);
285
- if (typingTimer.current !== null) {
286
- window.clearTimeout(typingTimer.current);
287
- }
288
- typingTimer.current = window.setTimeout(() => {
289
- setIsTyping(false);
290
- typingTimer.current = null;
228
+ }, []), handleInputChange = useCallback((value) => {
229
+ setQuery(value), setIsTyping(!0), typingTimer.current !== null && window.clearTimeout(typingTimer.current), typingTimer.current = window.setTimeout(() => {
230
+ setIsTyping(!1), typingTimer.current = null;
291
231
  }, SEARCH_DEBOUNCE_MS);
292
- }, []);
293
- const navigateToResult = useCallback(
232
+ }, []), navigateToResult = useCallback(
294
233
  (result) => {
295
- setOpen(false);
296
- router.push(result.url);
234
+ setOpen(!1), router.push(result.url);
297
235
  },
298
236
  [router, setOpen]
299
237
  );
300
238
  useEffect(() => {
301
239
  if (!open) return;
302
- const frame = window.requestAnimationFrame(() => {
240
+ let frame = window.requestAnimationFrame(() => {
303
241
  inputRef.current?.focus();
304
242
  });
305
243
  return () => window.cancelAnimationFrame(frame);
306
- }, [open]);
307
- useShortcut(shortcut, () => setOpen(true), {
244
+ }, [open]), useShortcut(shortcut, () => setOpen(!0), {
308
245
  description: "Open search",
309
246
  group: "Search",
310
247
  priority: 100
311
- });
312
- useEffect(() => {
248
+ }), useEffect(() => {
313
249
  if (!query.trim()) {
314
- setDisplayResults([]);
315
- setSelectedValue("");
250
+ setDisplayResults([]), setSelectedValue("");
316
251
  return;
317
252
  }
318
- if (isTyping || loading) return;
319
- if (output.status === "ready") {
320
- setDisplayResults(output.items);
321
- setSelectedValue(output.items[0]?.id ?? "");
322
- return;
323
- }
324
- if (output.status === "building" || output.status === "stale" || output.status === "error") {
325
- setDisplayResults([]);
326
- setSelectedValue("");
253
+ if (!(isTyping || loading)) {
254
+ if (output.status === "ready") {
255
+ setDisplayResults(output.items), setSelectedValue(output.items[0]?.id ?? "");
256
+ return;
257
+ }
258
+ (output.status === "building" || output.status === "stale" || output.status === "error") && (setDisplayResults([]), setSelectedValue(""));
327
259
  }
328
- }, [isTyping, loading, output.items, output.status, query]);
329
- useEffect(
260
+ }, [isTyping, loading, output.items, output.status, query]), useEffect(
330
261
  () => () => {
331
- if (typingTimer.current !== null) {
332
- window.clearTimeout(typingTimer.current);
333
- }
262
+ typingTimer.current !== null && window.clearTimeout(typingTimer.current);
334
263
  },
335
264
  []
336
265
  );
337
- const contextValue = useMemo(
266
+ let contextValue = useMemo(
338
267
  () => ({
339
268
  actions: {
340
269
  handleInputChange,
@@ -0,0 +1,25 @@
1
+ import { Ref, ReactNode, MouseEvent } from 'react';
2
+ import { T as TreeNode } from './types-DHBm7-j6.js';
3
+
4
+ type SidebarTreeNode = TreeNode & {
5
+ children?: SidebarTreeNode[];
6
+ };
7
+ type SidebarActiveState = "path-active" | "child-path-active";
8
+ type SidebarDepth = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
9
+ type SidebarNodePrimitiveProps = {
10
+ activeState?: SidebarActiveState;
11
+ activeItemRef?: Ref<HTMLDivElement>;
12
+ children?: ReactNode;
13
+ contentId?: string;
14
+ depth: SidebarDepth;
15
+ expanded?: boolean;
16
+ href?: string;
17
+ isExpandable?: boolean;
18
+ node: SidebarTreeNode;
19
+ onLinkClick?: (event: MouseEvent<HTMLAnchorElement>) => void;
20
+ onToggle?: () => void;
21
+ parentExpanded: boolean;
22
+ title: string;
23
+ };
24
+
25
+ export type { SidebarNodePrimitiveProps as S, SidebarTreeNode as a, SidebarActiveState as b, SidebarDepth as c };
@@ -0,0 +1,15 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+
4
+ type ThemeScopeProps = Readonly<{
5
+ "data-group": string;
6
+ "data-theme-root": "";
7
+ }>;
8
+ type ThemeScopeProviderProps = Readonly<{
9
+ children: ReactNode;
10
+ group?: string;
11
+ }>;
12
+ declare function ThemeScopeProvider({ children, group, }: ThemeScopeProviderProps): react_jsx_runtime.JSX.Element;
13
+ declare function useThemeScope(): ThemeScopeProps;
14
+
15
+ export { type ThemeScopeProps, ThemeScopeProvider, type ThemeScopeProviderProps, useThemeScope };
@@ -0,0 +1,23 @@
1
+ "use client";
2
+
3
+ // src/lib/theme/theme-scope.tsx
4
+ import { createContext, use } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+ var ROOT_SCOPE = Object.freeze({
7
+ "data-group": "",
8
+ "data-theme-root": ""
9
+ }), ThemeGroupContext = createContext("");
10
+ function ThemeScopeProvider({
11
+ children,
12
+ group
13
+ }) {
14
+ return /* @__PURE__ */ jsx(ThemeGroupContext, { value: group ?? "", children });
15
+ }
16
+ function useThemeScope() {
17
+ let group = use(ThemeGroupContext);
18
+ return group ? { "data-group": group, "data-theme-root": "" } : ROOT_SCOPE;
19
+ }
20
+ export {
21
+ ThemeScopeProvider,
22
+ useThemeScope
23
+ };
@@ -0,0 +1,63 @@
1
+ type SiteData = {
2
+ name: string;
3
+ description?: string;
4
+ url?: string;
5
+ og?: OgMetadata;
6
+ };
7
+ type OgImageMetadata = string | {
8
+ src: string;
9
+ alt?: string;
10
+ };
11
+ type OgMetadata = {
12
+ title?: string;
13
+ description?: string;
14
+ image?: OgImageMetadata;
15
+ };
16
+ type Author = {
17
+ id?: string;
18
+ name: string;
19
+ handle?: string;
20
+ avatar?: string;
21
+ url?: string;
22
+ };
23
+ type PageStatus = "published" | "draft" | "archived";
24
+ type PageNode = {
25
+ type: "page";
26
+ fileID: string;
27
+ title: string;
28
+ path: string;
29
+ group: string;
30
+ description?: string;
31
+ status: PageStatus;
32
+ publishedAt?: string;
33
+ updatedAt?: string;
34
+ authors: Author[];
35
+ tags?: string[];
36
+ og?: OgMetadata;
37
+ meta: Record<string, unknown>;
38
+ };
39
+ type SectionNode = {
40
+ type: "section";
41
+ id: string;
42
+ title: string;
43
+ path?: string;
44
+ group?: string;
45
+ children: TreeNode[];
46
+ };
47
+ type FolderNode = {
48
+ type: "folder";
49
+ id: string;
50
+ title: string;
51
+ path?: string;
52
+ group?: string;
53
+ children: TreeNode[];
54
+ };
55
+ type LinkNode = {
56
+ type: "link";
57
+ id: string;
58
+ title: string;
59
+ href: string;
60
+ };
61
+ type TreeNode = PageNode | SectionNode | FolderNode | LinkNode;
62
+
63
+ export type { SiteData as S, TreeNode as T };
@@ -0,0 +1,127 @@
1
+ type SiteData = {
2
+ name: string;
3
+ description?: string;
4
+ url?: string;
5
+ og?: OgMetadata;
6
+ };
7
+ type OgImageMetadata = string | {
8
+ src: string;
9
+ alt?: string;
10
+ };
11
+ type OgMetadata = {
12
+ title?: string;
13
+ description?: string;
14
+ image?: OgImageMetadata;
15
+ };
16
+ type Author = {
17
+ id?: string;
18
+ name: string;
19
+ handle?: string;
20
+ avatar?: string;
21
+ url?: string;
22
+ };
23
+ type PageStatus = "published" | "draft" | "archived";
24
+ type PageData<TMeta extends Record<string, unknown> = Record<string, unknown>> = {
25
+ fileID: string;
26
+ group: string;
27
+ slug: string;
28
+ path: string;
29
+ title: string;
30
+ description?: string;
31
+ status: PageStatus;
32
+ publishedAt?: string;
33
+ updatedAt?: string;
34
+ authors: Author[];
35
+ tags: string[];
36
+ og?: OgMetadata;
37
+ meta: TMeta;
38
+ body: string;
39
+ };
40
+ type PageNode = {
41
+ type: "page";
42
+ fileID: string;
43
+ title: string;
44
+ path: string;
45
+ group: string;
46
+ description?: string;
47
+ status: PageStatus;
48
+ publishedAt?: string;
49
+ updatedAt?: string;
50
+ authors: Author[];
51
+ tags?: string[];
52
+ og?: OgMetadata;
53
+ meta: Record<string, unknown>;
54
+ };
55
+ type SectionNode = {
56
+ type: "section";
57
+ id: string;
58
+ title: string;
59
+ path?: string;
60
+ group?: string;
61
+ children: TreeNode[];
62
+ };
63
+ type FolderNode = {
64
+ type: "folder";
65
+ id: string;
66
+ title: string;
67
+ path?: string;
68
+ group?: string;
69
+ children: TreeNode[];
70
+ };
71
+ type LinkNode = {
72
+ type: "link";
73
+ id: string;
74
+ title: string;
75
+ href: string;
76
+ };
77
+ type TreeNode = PageNode | SectionNode | FolderNode | LinkNode;
78
+ type RouteRecord = {
79
+ fileID: string;
80
+ slug: string;
81
+ path: string;
82
+ group: string;
83
+ };
84
+ type ResolvedAttribution = {
85
+ enabled: false;
86
+ } | {
87
+ enabled: true;
88
+ variant: "publish-dev";
89
+ label?: string;
90
+ hrefLabel?: string;
91
+ href: string;
92
+ };
93
+ type GroupManifest = {
94
+ key: string;
95
+ title: string;
96
+ path: string;
97
+ ancestry?: string[];
98
+ meta?: Record<string, unknown>;
99
+ tree: TreeNode[];
100
+ pages: PageData[];
101
+ };
102
+ type ManifestLike = {
103
+ site: SiteData;
104
+ groups: Record<string, GroupManifest>;
105
+ routes: RouteRecord[];
106
+ pages: PageData[];
107
+ tree: TreeNode[];
108
+ attribution?: Record<string, ResolvedAttribution>;
109
+ contentHash: string;
110
+ };
111
+ type LayoutProps = {
112
+ children: React.ReactNode;
113
+ site: SiteData;
114
+ tree: TreeNode[];
115
+ node: TreeNode;
116
+ currentPath: string;
117
+ group: string;
118
+ };
119
+ type IndexPageProps = {
120
+ site: SiteData;
121
+ tree: TreeNode[];
122
+ node: TreeNode;
123
+ currentPath: string;
124
+ group: string;
125
+ };
126
+
127
+ export type { IndexPageProps as I, LayoutProps as L, ManifestLike as M, PageStatus as P };