fromsrc 0.0.2 → 0.0.21

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 (408) hide show
  1. package/dist/access.d.ts +7 -7
  2. package/dist/access.js +12 -5
  3. package/dist/adapter.js +8 -16
  4. package/dist/adapterbrowser.js +6 -10
  5. package/dist/adapternext.js +7 -18
  6. package/dist/adapterreactrouter.js +5 -9
  7. package/dist/adapterremix.js +8 -17
  8. package/dist/adaptertanstack.js +6 -10
  9. package/dist/algolia.js +43 -21
  10. package/dist/analytics.d.ts +1 -1
  11. package/dist/analytics.js +16 -10
  12. package/dist/ansi.js +76 -37
  13. package/dist/api.d.ts +10 -10
  14. package/dist/api.js +14 -11
  15. package/dist/audit.d.ts +6 -6
  16. package/dist/audit.js +29 -10
  17. package/dist/autotype.js +20 -10
  18. package/dist/batch.d.ts +6 -6
  19. package/dist/batch.js +16 -9
  20. package/dist/changelog.js +28 -14
  21. package/dist/changelogutil.d.ts +4 -4
  22. package/dist/changelogutil.js +33 -13
  23. package/dist/cli.d.ts +6 -6
  24. package/dist/cli.js +7 -3
  25. package/dist/client.d.ts +1 -1
  26. package/dist/codesample.d.ts +4 -4
  27. package/dist/codesample.js +63 -24
  28. package/dist/collapse.js +31 -13
  29. package/dist/collections.js +36 -16
  30. package/dist/components/accordion.d.ts +1 -1
  31. package/dist/components/accordion.js +5 -1
  32. package/dist/components/alert.d.ts +1 -1
  33. package/dist/components/alert.js +24 -13
  34. package/dist/components/announce.js +40 -17
  35. package/dist/components/autofill.js +17 -7
  36. package/dist/components/avatar.js +4 -4
  37. package/dist/components/avatarstack.js +2 -2
  38. package/dist/components/backtotop.d.ts +1 -1
  39. package/dist/components/backtotop.js +17 -4
  40. package/dist/components/badge.js +9 -4
  41. package/dist/components/banner.js +22 -5
  42. package/dist/components/breadcrumb.js +11 -4
  43. package/dist/components/breadcrumbnav.js +37 -21
  44. package/dist/components/button.js +23 -8
  45. package/dist/components/callout.d.ts +1 -1
  46. package/dist/components/callout.js +33 -29
  47. package/dist/components/changelog.js +21 -8
  48. package/dist/components/checkbox.js +32 -19
  49. package/dist/components/code.d.ts +1 -1
  50. package/dist/components/code.js +6 -3
  51. package/dist/components/codeblock.js +157 -39
  52. package/dist/components/codecopy.d.ts +1 -1
  53. package/dist/components/codecopy.js +36 -13
  54. package/dist/components/codegroup.js +87 -25
  55. package/dist/components/collapsible.d.ts +1 -1
  56. package/dist/components/collapsible.js +5 -1
  57. package/dist/components/command.d.ts +1 -1
  58. package/dist/components/command.js +42 -15
  59. package/dist/components/compare.js +20 -8
  60. package/dist/components/content.js +121 -79
  61. package/dist/components/copybutton.d.ts +1 -1
  62. package/dist/components/copybutton.js +14 -7
  63. package/dist/components/countdown.js +9 -3
  64. package/dist/components/create.js +34 -24
  65. package/dist/components/definition.js +11 -4
  66. package/dist/components/diffview.js +63 -29
  67. package/dist/components/divider.js +5 -1
  68. package/dist/components/docheader.js +8 -1
  69. package/dist/components/doclinkcard.js +27 -3
  70. package/dist/components/dropdown.d.ts +1 -1
  71. package/dist/components/dropdown.js +32 -11
  72. package/dist/components/dynamiccode.js +5 -3
  73. package/dist/components/editlink.js +35 -23
  74. package/dist/components/embed.js +15 -7
  75. package/dist/components/endpoint.d.ts +3 -3
  76. package/dist/components/endpoint.js +24 -9
  77. package/dist/components/errormessage.d.ts +1 -1
  78. package/dist/components/errormessage.js +4 -1
  79. package/dist/components/expandcode.d.ts +1 -1
  80. package/dist/components/expandcode.js +6 -2
  81. package/dist/components/feature.js +8 -1
  82. package/dist/components/featuregrid.d.ts +4 -4
  83. package/dist/components/featuregrid.js +7 -1
  84. package/dist/components/feedback.js +6 -2
  85. package/dist/components/feedbackwidget.js +10 -4
  86. package/dist/components/files.d.ts +1 -1
  87. package/dist/components/files.js +52 -18
  88. package/dist/components/folder.d.ts +1 -1
  89. package/dist/components/folder.js +21 -4
  90. package/dist/components/footer.js +5 -1
  91. package/dist/components/formlabel.d.ts +1 -1
  92. package/dist/components/formlabel.js +31 -18
  93. package/dist/components/github.js +43 -14
  94. package/dist/components/graph.js +38 -14
  95. package/dist/components/heading.js +36 -29
  96. package/dist/components/headingcopy.js +13 -5
  97. package/dist/components/hero.js +20 -14
  98. package/dist/components/highlight.d.ts +2 -2
  99. package/dist/components/highlight.js +14 -8
  100. package/dist/components/hover.d.ts +2 -2
  101. package/dist/components/hover.js +11 -4
  102. package/dist/components/icons.js +4 -1
  103. package/dist/components/inlinetoc.js +3 -1
  104. package/dist/components/input.js +13 -3
  105. package/dist/components/install.js +34 -24
  106. package/dist/components/kbd.js +19 -11
  107. package/dist/components/langicon.d.ts +1 -1
  108. package/dist/components/langicon.js +22 -17
  109. package/dist/components/language.d.ts +1 -1
  110. package/dist/components/language.js +12 -4
  111. package/dist/components/lastupdated.d.ts +2 -2
  112. package/dist/components/lastupdated.js +36 -12
  113. package/dist/components/link.d.ts +1 -1
  114. package/dist/components/linkcard.js +3 -1
  115. package/dist/components/list.d.ts +1 -1
  116. package/dist/components/list.js +4 -1
  117. package/dist/components/math.js +33 -8
  118. package/dist/components/mermaid.js +3 -3
  119. package/dist/components/mobilenav.d.ts +2 -1
  120. package/dist/components/mobilenav.js +116 -47
  121. package/dist/components/modal.d.ts +1 -1
  122. package/dist/components/modal.js +9 -2
  123. package/dist/components/navlink.js +17 -3
  124. package/dist/components/openapi.d.ts +1 -1
  125. package/dist/components/openapi.js +102 -32
  126. package/dist/components/openapischema.d.ts +1 -1
  127. package/dist/components/openapischema.js +29 -9
  128. package/dist/components/openapitags.js +6 -2
  129. package/dist/components/pagetransition.js +5 -3
  130. package/dist/components/pagination.js +3 -2
  131. package/dist/components/panel.js +91 -15
  132. package/dist/components/playground.d.ts +1 -1
  133. package/dist/components/playground.js +153 -50
  134. package/dist/components/popover.js +9 -7
  135. package/dist/components/prelink.js +40 -9
  136. package/dist/components/prevnext.d.ts +1 -1
  137. package/dist/components/prevnext.js +36 -16
  138. package/dist/components/progress.js +2 -2
  139. package/dist/components/property.js +3 -1
  140. package/dist/components/quote.d.ts +2 -2
  141. package/dist/components/quote.js +32 -4
  142. package/dist/components/radio.js +36 -18
  143. package/dist/components/rating.js +14 -3
  144. package/dist/components/recent.d.ts +1 -1
  145. package/dist/components/recent.js +26 -10
  146. package/dist/components/responsive.js +21 -13
  147. package/dist/components/results.js +8 -4
  148. package/dist/components/screenshot.js +61 -21
  149. package/dist/components/scrollprogress.js +9 -5
  150. package/dist/components/scrollspy.d.ts +2 -2
  151. package/dist/components/scrollspy.js +9 -3
  152. package/dist/components/search.js +47 -18
  153. package/dist/components/searchbutton.js +3 -1
  154. package/dist/components/searchdialog.js +35 -22
  155. package/dist/components/searcher.d.ts +1 -1
  156. package/dist/components/searcher.js +51 -26
  157. package/dist/components/select.js +27 -13
  158. package/dist/components/shortcuts.d.ts +1 -1
  159. package/dist/components/shortcuts.js +57 -38
  160. package/dist/components/sidebar.d.ts +2 -1
  161. package/dist/components/sidebar.js +221 -56
  162. package/dist/components/sidebarfilter.d.ts +1 -1
  163. package/dist/components/sidebarfilter.js +30 -6
  164. package/dist/components/sidebarscript.d.ts +5 -0
  165. package/dist/components/sidebarscript.js +18 -0
  166. package/dist/components/skeleton.js +15 -3
  167. package/dist/components/spinner.js +13 -3
  168. package/dist/components/status.js +20 -8
  169. package/dist/components/steps.js +3 -1
  170. package/dist/components/switch.js +4 -4
  171. package/dist/components/table.js +37 -12
  172. package/dist/components/tabnav.d.ts +1 -1
  173. package/dist/components/tabnav.js +48 -36
  174. package/dist/components/tabs.d.ts +1 -1
  175. package/dist/components/tabs.js +56 -40
  176. package/dist/components/tag.js +8 -3
  177. package/dist/components/terminal.js +14 -4
  178. package/dist/components/textarea.js +96 -82
  179. package/dist/components/theme.d.ts +1 -1
  180. package/dist/components/theme.js +25 -3
  181. package/dist/components/themeprovider.d.ts +4 -4
  182. package/dist/components/themeprovider.js +16 -5
  183. package/dist/components/toast.d.ts +1 -1
  184. package/dist/components/toast.js +23 -14
  185. package/dist/components/toc/default.d.ts +1 -1
  186. package/dist/components/toc/default.js +28 -13
  187. package/dist/components/toc/hook.js +28 -14
  188. package/dist/components/toc/index.js +8 -4
  189. package/dist/components/toc/inline.js +12 -2
  190. package/dist/components/toc/minimal.js +11 -5
  191. package/dist/components/toc/zigzag.d.ts +1 -1
  192. package/dist/components/toc/zigzag.js +37 -17
  193. package/dist/components/tocprogress.d.ts +1 -1
  194. package/dist/components/tocprogress.js +66 -34
  195. package/dist/components/tooltip.d.ts +1 -1
  196. package/dist/components/tooltip.js +20 -8
  197. package/dist/components/trigger.js +13 -5
  198. package/dist/components/twoslash.js +49 -26
  199. package/dist/components/typetable.js +23 -4
  200. package/dist/components/typewriter.js +6 -2
  201. package/dist/components/version.js +40 -14
  202. package/dist/components/video.js +25 -15
  203. package/dist/components/zoom.js +6 -2
  204. package/dist/config.d.ts +2 -2
  205. package/dist/config.js +56 -30
  206. package/dist/content.d.ts +5 -5
  207. package/dist/content.js +121 -57
  208. package/dist/contentcache.d.ts +10 -10
  209. package/dist/contentcache.js +9 -5
  210. package/dist/contentdiff.d.ts +4 -4
  211. package/dist/contentdiff.js +16 -8
  212. package/dist/contributors.d.ts +4 -4
  213. package/dist/contributors.js +49 -19
  214. package/dist/diff.d.ts +6 -6
  215. package/dist/diff.js +37 -16
  216. package/dist/draft.d.ts +11 -11
  217. package/dist/draft.js +9 -5
  218. package/dist/env.js +21 -7
  219. package/dist/export.js +4 -4
  220. package/dist/frontmatter.js +11 -9
  221. package/dist/github.js +60 -30
  222. package/dist/gitsource.d.ts +1 -1
  223. package/dist/gitsource.js +16 -9
  224. package/dist/hash.d.ts +6 -6
  225. package/dist/hash.js +19 -7
  226. package/dist/highlight.d.ts +4 -4
  227. package/dist/highlight.js +34 -14
  228. package/dist/hooks/anchor.js +26 -14
  229. package/dist/hooks/arrownav.js +25 -7
  230. package/dist/hooks/async.js +3 -3
  231. package/dist/hooks/battery.js +11 -3
  232. package/dist/hooks/breakpoint.js +10 -2
  233. package/dist/hooks/clickoutside.js +10 -3
  234. package/dist/hooks/clipboard-paste.js +7 -3
  235. package/dist/hooks/clipboard.d.ts +2 -2
  236. package/dist/hooks/clipboard.js +21 -15
  237. package/dist/hooks/copy.js +11 -6
  238. package/dist/hooks/countdown.js +1 -1
  239. package/dist/hooks/counter.js +1 -1
  240. package/dist/hooks/escapekey.js +6 -1
  241. package/dist/hooks/eventlistener.js +3 -1
  242. package/dist/hooks/eventsource.js +4 -2
  243. package/dist/hooks/eyedropper.js +7 -3
  244. package/dist/hooks/favicon.js +1 -1
  245. package/dist/hooks/fetch.js +12 -4
  246. package/dist/hooks/focustrap.js +20 -8
  247. package/dist/hooks/focuswithin.js +6 -2
  248. package/dist/hooks/form.d.ts +2 -2
  249. package/dist/hooks/form.js +15 -2
  250. package/dist/hooks/fullscreen.js +1 -1
  251. package/dist/hooks/geolocation.js +8 -8
  252. package/dist/hooks/hotkeys.js +19 -7
  253. package/dist/hooks/hover.d.ts +4 -1
  254. package/dist/hooks/hover.js +3 -1
  255. package/dist/hooks/idle.js +13 -3
  256. package/dist/hooks/infinitescroll.js +4 -2
  257. package/dist/hooks/interval.js +3 -1
  258. package/dist/hooks/inview.js +7 -3
  259. package/dist/hooks/keyboard.js +36 -12
  260. package/dist/hooks/keypress.js +6 -2
  261. package/dist/hooks/list.js +11 -1
  262. package/dist/hooks/longpress.js +3 -3
  263. package/dist/hooks/map.js +1 -1
  264. package/dist/hooks/measure.js +16 -7
  265. package/dist/hooks/mediarecorder.js +7 -3
  266. package/dist/hooks/networkstate.js +4 -2
  267. package/dist/hooks/os.js +12 -4
  268. package/dist/hooks/pagination.js +6 -4
  269. package/dist/hooks/permission.js +6 -2
  270. package/dist/hooks/queue.js +4 -2
  271. package/dist/hooks/readprogress.js +6 -2
  272. package/dist/hooks/resizeobserver.js +6 -4
  273. package/dist/hooks/script.js +1 -1
  274. package/dist/hooks/scrolllock.js +6 -2
  275. package/dist/hooks/scrollspy.js +4 -2
  276. package/dist/hooks/selection.js +6 -3
  277. package/dist/hooks/share.js +18 -9
  278. package/dist/hooks/speechrecognition.js +7 -3
  279. package/dist/hooks/stepper.js +4 -4
  280. package/dist/hooks/storage.js +9 -3
  281. package/dist/hooks/stylesheet.js +4 -2
  282. package/dist/hooks/textselection.js +6 -3
  283. package/dist/hooks/throttle.js +6 -2
  284. package/dist/hooks/undoredo.js +19 -11
  285. package/dist/hooks/vibrate.js +3 -1
  286. package/dist/hooks/viewtransition.js +8 -4
  287. package/dist/hooks/wakelock.js +12 -7
  288. package/dist/hooks/websocket.js +4 -2
  289. package/dist/hooks/windowsize.js +2 -2
  290. package/dist/i18n.d.ts +2 -2
  291. package/dist/i18n.js +27 -14
  292. package/dist/index.d.ts +1 -0
  293. package/dist/index.js +1 -0
  294. package/dist/lastmodified.js +11 -5
  295. package/dist/linkcheck.d.ts +6 -6
  296. package/dist/linkcheck.js +55 -14
  297. package/dist/llms.js +20 -4
  298. package/dist/manifest.js +7 -7
  299. package/dist/mcp.js +28 -22
  300. package/dist/mdtoc.d.ts +4 -4
  301. package/dist/mdtoc.js +11 -5
  302. package/dist/mdxscope.d.ts +2 -2
  303. package/dist/mdxscope.js +3 -1
  304. package/dist/meta.js +19 -7
  305. package/dist/migrate.js +35 -25
  306. package/dist/navgen.d.ts +8 -8
  307. package/dist/navgen.js +73 -30
  308. package/dist/navtree.d.ts +1 -1
  309. package/dist/navtree.js +39 -19
  310. package/dist/oembed.d.ts +4 -4
  311. package/dist/oembed.js +24 -18
  312. package/dist/ogimage.d.ts +11 -11
  313. package/dist/ogimage.js +24 -24
  314. package/dist/openapi.js +60 -33
  315. package/dist/openapiguard.js +21 -11
  316. package/dist/openapiutil.js +66 -20
  317. package/dist/orama.js +52 -34
  318. package/dist/pipeline.d.ts +4 -4
  319. package/dist/pipeline.js +4 -4
  320. package/dist/preload.d.ts +2 -2
  321. package/dist/preload.js +4 -4
  322. package/dist/ranking.d.ts +6 -6
  323. package/dist/ranking.js +39 -13
  324. package/dist/readtime.js +3 -1
  325. package/dist/redirects.d.ts +2 -2
  326. package/dist/redirects.js +20 -12
  327. package/dist/rehype.js +16 -9
  328. package/dist/rehypeautolink.d.ts +2 -2
  329. package/dist/rehypeautolink.js +25 -23
  330. package/dist/rehypecode.js +38 -28
  331. package/dist/rehypecopy.js +17 -13
  332. package/dist/rehypeinline.js +33 -27
  333. package/dist/rehypelinks.js +28 -20
  334. package/dist/rehyperaw.js +9 -3
  335. package/dist/rehypeslug.d.ts +1 -1
  336. package/dist/rehypeslug.js +23 -19
  337. package/dist/rehypetablewrap.d.ts +2 -2
  338. package/dist/rehypetablewrap.js +9 -5
  339. package/dist/rehypetoc.d.ts +1 -1
  340. package/dist/rehypetoc.js +15 -7
  341. package/dist/remark.js +28 -13
  342. package/dist/remarkadmonition.js +40 -14
  343. package/dist/remarkannotation.d.ts +2 -2
  344. package/dist/remarkannotation.js +26 -10
  345. package/dist/remarkbadge.js +43 -31
  346. package/dist/remarkblockmath.js +29 -15
  347. package/dist/remarkcallout.js +32 -14
  348. package/dist/remarkcaption.js +28 -16
  349. package/dist/remarkcodetitle.js +29 -13
  350. package/dist/remarkcolumns.js +22 -10
  351. package/dist/remarkdetails.js +34 -14
  352. package/dist/remarkdirective.js +47 -20
  353. package/dist/remarkembed.js +38 -22
  354. package/dist/remarkfiletree.js +29 -19
  355. package/dist/remarkfootnote.js +46 -18
  356. package/dist/remarkgfm.js +13 -8
  357. package/dist/remarkheadingid.js +16 -6
  358. package/dist/remarkimage.js +54 -34
  359. package/dist/remarkinclude.js +20 -8
  360. package/dist/remarkinstall.js +20 -12
  361. package/dist/remarklinkcard.js +33 -14
  362. package/dist/remarkmath.js +34 -15
  363. package/dist/remarkmermaid.js +10 -6
  364. package/dist/remarkmeta.d.ts +2 -2
  365. package/dist/remarkmeta.js +15 -5
  366. package/dist/remarkreadingtime.d.ts +2 -2
  367. package/dist/remarkreadingtime.js +3 -1
  368. package/dist/remarksteps.js +26 -14
  369. package/dist/remarkstructure.js +16 -10
  370. package/dist/remarktabs.js +31 -14
  371. package/dist/remarktoc.js +40 -24
  372. package/dist/remarkts2js.js +51 -40
  373. package/dist/remarktwoslash.d.ts +4 -4
  374. package/dist/remarktwoslash.js +24 -14
  375. package/dist/remarkvideo.d.ts +4 -4
  376. package/dist/remarkvideo.js +42 -16
  377. package/dist/schema.d.ts +14 -14
  378. package/dist/schema.js +2 -2
  379. package/dist/search.js +106 -48
  380. package/dist/searchindex.js +86 -34
  381. package/dist/searchpolicy.js +1 -1
  382. package/dist/searchscore.js +5 -5
  383. package/dist/searchtypo.js +30 -10
  384. package/dist/seo.d.ts +2 -2
  385. package/dist/seo.js +14 -14
  386. package/dist/shortcodes.d.ts +4 -4
  387. package/dist/shortcodes.js +25 -20
  388. package/dist/sitemap.js +18 -8
  389. package/dist/snippets.js +26 -18
  390. package/dist/source.js +75 -41
  391. package/dist/stats.d.ts +4 -4
  392. package/dist/stats.js +18 -12
  393. package/dist/testing.d.ts +7 -7
  394. package/dist/testing.js +74 -29
  395. package/dist/themeutil.d.ts +6 -6
  396. package/dist/themeutil.js +145 -27
  397. package/dist/typegen.js +31 -12
  398. package/dist/validate.js +19 -7
  399. package/dist/validator.d.ts +11 -11
  400. package/dist/validator.js +68 -19
  401. package/dist/versioning.d.ts +7 -7
  402. package/dist/versioning.js +27 -11
  403. package/dist/watcher.js +39 -15
  404. package/dist/webhook.d.ts +6 -6
  405. package/dist/webhook.js +34 -12
  406. package/dist/workspace.js +26 -12
  407. package/package.json +137 -137
  408. package/styles/reset.css +1 -1
package/dist/github.js CHANGED
@@ -9,7 +9,9 @@ function createCache() {
9
9
  return {
10
10
  get(key) {
11
11
  const entry = store.get(key);
12
- if (!entry) return null;
12
+ if (!entry) {
13
+ return null;
14
+ }
13
15
  if (Date.now() - entry.timestamp > TTL) {
14
16
  store.delete(key);
15
17
  return null;
@@ -22,7 +24,9 @@ function createCache() {
22
24
  };
23
25
  }
24
26
  async function maplimit(items, limit, run) {
25
- if (items.length === 0) return [];
27
+ if (items.length === 0) {
28
+ return [];
29
+ }
26
30
  const workers = Math.max(1, Math.min(limit, items.length));
27
31
  const output = new Array(items.length);
28
32
  let cursor = 0;
@@ -31,7 +35,9 @@ async function maplimit(items, limit, run) {
31
35
  while (cursor < items.length) {
32
36
  const index = cursor++;
33
37
  const item = items[index];
34
- if (item === void 0) continue;
38
+ if (item === void 0) {
39
+ continue;
40
+ }
35
41
  output[index] = await run(item, index);
36
42
  }
37
43
  })
@@ -87,7 +93,9 @@ function createGithubSource(config) {
87
93
  return `https://api.github.com/repos/${config.owner}/${config.repo}/git/trees/${ref}${suffix}`;
88
94
  }
89
95
  function joinPath(base, path) {
90
- if (!base) return path;
96
+ if (!base) {
97
+ return path;
98
+ }
91
99
  return `${base}/${path}`;
92
100
  }
93
101
  async function tree(ref, recursive) {
@@ -110,8 +118,8 @@ function createGithubSource(config) {
110
118
  (item) => typeof item.path === "string" && (item.type === "blob" || item.type === "tree") && typeof item.sha === "string"
111
119
  ).map((item) => ({
112
120
  path: item.path,
113
- type: item.type,
114
- sha: item.sha
121
+ sha: item.sha,
122
+ type: item.type
115
123
  }));
116
124
  const result = {
117
125
  entries,
@@ -119,14 +127,16 @@ function createGithubSource(config) {
119
127
  };
120
128
  treeCache.set(url, {
121
129
  entries: result.entries,
122
- truncated: result.truncated,
123
- etag: res.headers.get("etag") ?? void 0
130
+ etag: res.headers.get("etag") ?? void 0,
131
+ truncated: result.truncated
124
132
  });
125
133
  return result;
126
134
  }
127
135
  async function allEntries() {
128
136
  const recursive = await tree(branch, true);
129
- if (!recursive.truncated) return recursive.entries;
137
+ if (!recursive.truncated) {
138
+ return recursive.entries;
139
+ }
130
140
  const root = await tree(branch, false);
131
141
  const files = root.entries.filter((item) => item.type === "blob");
132
142
  const queue = root.entries.filter((item) => item.type === "tree");
@@ -154,12 +164,16 @@ function createGithubSource(config) {
154
164
  }
155
165
  const list = async () => {
156
166
  const cached = listCache.get("list");
157
- if (cached) return cached;
167
+ if (cached) {
168
+ return cached;
169
+ }
158
170
  try {
159
171
  const entries = await allEntries();
160
172
  const prefix = docsPath ? `${docsPath}/` : "";
161
173
  const paths = {};
162
- const docs = entries.filter((item) => item.path.startsWith(prefix) && item.path.endsWith(".mdx")).map((item) => {
174
+ const docs = entries.filter(
175
+ (item) => item.path.startsWith(prefix) && item.path.endsWith(".mdx")
176
+ ).map((item) => {
163
177
  const rawSlug = item.path.slice(prefix.length).replace(/\.mdx$/, "").replace(/\/index$/, "");
164
178
  const slug = rawSlug === "index" ? "" : rawSlug;
165
179
  const fallbackTitle = slug === "" ? "index" : slug.split("/").pop() ?? slug;
@@ -179,7 +193,9 @@ function createGithubSource(config) {
179
193
  const slugValue = slug.join("/");
180
194
  const cacheKey = path;
181
195
  const cached = fileCache.get(cacheKey);
182
- if (cached) return cached;
196
+ if (cached) {
197
+ return cached;
198
+ }
183
199
  const knownPaths = pathCache.get("paths") ?? {};
184
200
  const knownPath = knownPaths[slugValue];
185
201
  const filepath = `${docsPath}/${path}.mdx`;
@@ -187,7 +203,9 @@ function createGithubSource(config) {
187
203
  const candidates = knownPath ? [knownPath, filepath, indexPath] : [filepath, indexPath];
188
204
  const seen = /* @__PURE__ */ new Set();
189
205
  for (const candidate of candidates) {
190
- if (seen.has(candidate)) continue;
206
+ if (seen.has(candidate)) {
207
+ continue;
208
+ }
191
209
  seen.add(candidate);
192
210
  try {
193
211
  const url = rawUrl(candidate);
@@ -202,7 +220,9 @@ function createGithubSource(config) {
202
220
  fileCache.set(cacheKey, result2);
203
221
  return result2;
204
222
  }
205
- if (!res.ok) continue;
223
+ if (!res.ok) {
224
+ continue;
225
+ }
206
226
  const raw = await res.text();
207
227
  const { content, data } = matter(raw);
208
228
  const result = { content, data };
@@ -221,28 +241,38 @@ function createGithubSource(config) {
221
241
  return null;
222
242
  };
223
243
  return {
224
- list,
225
244
  get,
245
+ list,
226
246
  async search() {
227
247
  const cached = searchCache.get("search");
228
- if (cached) return cached;
248
+ if (cached) {
249
+ return cached;
250
+ }
229
251
  const listed = await list();
230
- const values = await maplimit(listed, SEARCH_CONCURRENCY, async (doc) => {
231
- const value = await get(doc.slug ? doc.slug.split("/") : []);
232
- if (!value) return null;
233
- const title = typeof value.data.title === "string" && value.data.title.length > 0 ? value.data.title : doc.title;
234
- const description = typeof value.data.description === "string" ? value.data.description : doc.description;
235
- return {
236
- slug: doc.slug,
237
- title,
238
- description,
239
- content: value.content,
240
- headings: extractHeadings(value.content)
241
- };
242
- });
252
+ const values = await maplimit(
253
+ listed,
254
+ SEARCH_CONCURRENCY,
255
+ async (doc) => {
256
+ const value = await get(doc.slug ? doc.slug.split("/") : []);
257
+ if (!value) {
258
+ return null;
259
+ }
260
+ const title = typeof value.data.title === "string" && value.data.title.length > 0 ? value.data.title : doc.title;
261
+ const description = typeof value.data.description === "string" ? value.data.description : doc.description;
262
+ return {
263
+ content: value.content,
264
+ description,
265
+ headings: extractHeadings(value.content),
266
+ slug: doc.slug,
267
+ title
268
+ };
269
+ }
270
+ );
243
271
  const docs = [];
244
272
  for (const item of values) {
245
- if (!item) continue;
273
+ if (!item) {
274
+ continue;
275
+ }
246
276
  docs.push(item);
247
277
  }
248
278
  searchCache.set("search", docs);
@@ -16,8 +16,8 @@ declare function readFile(config: GitSourceConfig, path: string): Promise<GitFil
16
16
  declare function getLastModified(dir: string, path: string): Promise<Date>;
17
17
  declare function getFileHash(dir: string, path: string): Promise<string>;
18
18
  declare function createGitSource(config: GitSourceConfig): {
19
- list(): Promise<string[]>;
20
19
  get(path: string): Promise<GitFile>;
20
+ list(): Promise<string[]>;
21
21
  };
22
22
 
23
23
  export { type GitFile, type GitSourceConfig, createGitSource, getFileHash, getLastModified, gitExec, listFiles, readFile };
package/dist/gitsource.js CHANGED
@@ -10,10 +10,17 @@ async function gitExec(args, cwd) {
10
10
  return stdout.trim();
11
11
  }
12
12
  async function listFiles(config) {
13
- const output = await gitExec(["ls-tree", "-r", "--name-only", ref(config)], config.dir);
14
- if (!output) return [];
13
+ const output = await gitExec(
14
+ ["ls-tree", "-r", "--name-only", ref(config)],
15
+ config.dir
16
+ );
17
+ if (!output) {
18
+ return [];
19
+ }
15
20
  const files = output.split("\n");
16
- if (!config.glob) return files;
21
+ if (!config.glob) {
22
+ return files;
23
+ }
17
24
  const pattern = globToRegex(config.glob);
18
25
  return files.filter((f) => pattern.test(f));
19
26
  }
@@ -22,7 +29,7 @@ async function readFile(config, path) {
22
29
  const content = await gitExec(["show", `${r}:${path}`], config.dir);
23
30
  const lastModified = await getLastModified(config.dir, path);
24
31
  const hash = await getFileHash(config.dir, path);
25
- return { path, content, lastModified, hash };
32
+ return { content, hash, lastModified, path };
26
33
  }
27
34
  async function getLastModified(dir, path) {
28
35
  const output = await gitExec(["log", "-1", "--format=%aI", path], dir);
@@ -34,16 +41,16 @@ async function getFileHash(dir, path) {
34
41
  }
35
42
  function createGitSource(config) {
36
43
  return {
37
- async list() {
38
- return listFiles(config);
39
- },
40
- async get(path) {
44
+ get(path) {
41
45
  return readFile(config, path);
46
+ },
47
+ list() {
48
+ return listFiles(config);
42
49
  }
43
50
  };
44
51
  }
45
52
  function globToRegex(glob) {
46
- const escaped = glob.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "\0").replace(/\*/g, "[^/]*").replace(/\0/g, ".*").replace(/\?/g, "[^/]");
53
+ const escaped = glob.replaceAll(/[.+^${}()|[\]\\]/g, "\\$&").replaceAll("**", "\0").replaceAll("*", "[^/]*").replaceAll("\0", ".*").replaceAll("?", "[^/]");
47
54
  return new RegExp(`^${escaped}$`);
48
55
  }
49
56
 
package/dist/hash.d.ts CHANGED
@@ -1,17 +1,17 @@
1
- type ContentHash = {
1
+ interface ContentHash {
2
2
  path: string;
3
3
  hash: string;
4
4
  size: number;
5
- };
6
- type HashManifest = {
5
+ }
6
+ interface HashManifest {
7
7
  generated: string;
8
8
  hashes: ContentHash[];
9
- };
10
- type Changes = {
9
+ }
10
+ interface Changes {
11
11
  added: string[];
12
12
  modified: string[];
13
13
  removed: string[];
14
- };
14
+ }
15
15
  declare function hashContent(content: string): string;
16
16
  declare function hashFile(filepath: string): Promise<ContentHash>;
17
17
  declare function generateHashManifest(dir: string): Promise<HashManifest>;
package/dist/hash.js CHANGED
@@ -13,8 +13,11 @@ function hashContent(content) {
13
13
  return fnv1a(content);
14
14
  }
15
15
  async function hashFile(filepath) {
16
- const [content, info] = await Promise.all([readFile(filepath, "utf-8"), stat(filepath)]);
17
- return { path: filepath, hash: fnv1a(content), size: info.size };
16
+ const [content, info] = await Promise.all([
17
+ readFile(filepath, "utf8"),
18
+ stat(filepath)
19
+ ]);
20
+ return { hash: fnv1a(content), path: filepath, size: info.size };
18
21
  }
19
22
  async function collectFiles(dir) {
20
23
  const results = [];
@@ -46,19 +49,28 @@ function detectChanges(previous, current) {
46
49
  const modified = [];
47
50
  const removed = [];
48
51
  for (const [path, hash] of curr) {
49
- if (!prev.has(path)) added.push(path);
50
- else if (prev.get(path) !== hash) modified.push(path);
52
+ if (!prev.has(path)) {
53
+ added.push(path);
54
+ } else if (prev.get(path) !== hash) {
55
+ modified.push(path);
56
+ }
51
57
  }
52
58
  for (const path of prev.keys()) {
53
- if (!curr.has(path)) removed.push(path);
59
+ if (!curr.has(path)) {
60
+ removed.push(path);
61
+ }
54
62
  }
55
63
  return { added, modified, removed };
56
64
  }
57
65
  function hashFrontmatter(content) {
58
66
  const match = content.match(/^---\r?\n([\s\S]*?)\r?\n---/);
59
- if (!match) return null;
67
+ if (!match) {
68
+ return null;
69
+ }
60
70
  const body = match[1];
61
- if (!body) return null;
71
+ if (!body) {
72
+ return null;
73
+ }
62
74
  return fnv1a(body);
63
75
  }
64
76
 
@@ -1,14 +1,14 @@
1
- type HighlightResult = {
1
+ interface HighlightResult {
2
2
  text: string;
3
3
  ranges: {
4
4
  start: number;
5
5
  end: number;
6
6
  }[];
7
- };
8
- type SnippetOptions = {
7
+ }
8
+ interface SnippetOptions {
9
9
  maxLength?: number;
10
10
  surroundingWords?: number;
11
- };
11
+ }
12
12
  declare function highlightMatches(text: string, query: string): HighlightResult;
13
13
  declare function generateSnippet(text: string, query: string, options?: SnippetOptions): string;
14
14
  declare function highlightHtml(text: string, query: string): string;
package/dist/highlight.js CHANGED
@@ -1,5 +1,5 @@
1
1
  function escape(t) {
2
- return t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
2
+ return t.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;");
3
3
  }
4
4
  function findAll(text, query) {
5
5
  const ranges = [];
@@ -8,20 +8,24 @@ function findAll(text, query) {
8
8
  let pos = 0;
9
9
  while (pos < lower.length) {
10
10
  const idx = lower.indexOf(q, pos);
11
- if (idx === -1) break;
12
- ranges.push({ start: idx, end: idx + q.length });
11
+ if (idx === -1) {
12
+ break;
13
+ }
14
+ ranges.push({ end: idx + q.length, start: idx });
13
15
  pos = idx + 1;
14
16
  }
15
17
  return ranges;
16
18
  }
17
19
  function highlightMatches(text, query) {
18
- return { text, ranges: query ? findAll(text, query) : [] };
20
+ return { ranges: query ? findAll(text, query) : [], text };
19
21
  }
20
22
  function generateSnippet(text, query, options) {
21
23
  const maxLength = options?.maxLength ?? 200;
22
24
  const surrounding = options?.surroundingWords ?? 10;
23
25
  const idx = text.toLowerCase().indexOf(query.toLowerCase());
24
- if (idx === -1) return text.slice(0, maxLength) + (text.length > maxLength ? "..." : "");
26
+ if (idx === -1) {
27
+ return text.slice(0, maxLength) + (text.length > maxLength ? "..." : "");
28
+ }
25
29
  const words = text.split(/(\s+)/);
26
30
  let charCount = 0;
27
31
  let matchWord = 0;
@@ -36,15 +40,21 @@ function generateSnippet(text, query, options) {
36
40
  const startWord = Math.max(0, matchWord - surrounding * 2);
37
41
  const endWord = Math.min(words.length, matchWord + surrounding * 2 + 1);
38
42
  let snippet = words.slice(startWord, endWord).join("");
39
- if (snippet.length > maxLength) snippet = snippet.slice(0, maxLength);
43
+ if (snippet.length > maxLength) {
44
+ snippet = snippet.slice(0, maxLength);
45
+ }
40
46
  const prefix = startWord > 0 ? "..." : "";
41
47
  const suffix = endWord < words.length || snippet.length >= maxLength ? "..." : "";
42
48
  return prefix + snippet.trim() + suffix;
43
49
  }
44
50
  function highlightHtml(text, query) {
45
- if (!query) return escape(text);
51
+ if (!query) {
52
+ return escape(text);
53
+ }
46
54
  const terms = tokenize(query).map((term) => term.toLowerCase()).filter(Boolean);
47
- if (terms.length === 0) return escape(text);
55
+ if (terms.length === 0) {
56
+ return escape(text);
57
+ }
48
58
  const result = [];
49
59
  const lower = text.toLowerCase();
50
60
  let last = 0;
@@ -54,15 +64,21 @@ function highlightHtml(text, query) {
54
64
  let match = "";
55
65
  for (const term of terms) {
56
66
  const idx = lower.indexOf(term, pos);
57
- if (idx === -1) continue;
67
+ if (idx === -1) {
68
+ continue;
69
+ }
58
70
  if (nearest === -1 || idx < nearest) {
59
71
  nearest = idx;
60
72
  match = term;
61
73
  }
62
74
  }
63
- if (nearest === -1 || !match) break;
75
+ if (nearest === -1 || !match) {
76
+ break;
77
+ }
64
78
  result.push(escape(text.slice(last, nearest)));
65
- result.push(`<mark>${escape(text.slice(nearest, nearest + match.length))}</mark>`);
79
+ result.push(
80
+ `<mark>${escape(text.slice(nearest, nearest + match.length))}</mark>`
81
+ );
66
82
  last = nearest + match.length;
67
83
  pos = nearest + 1;
68
84
  }
@@ -75,16 +91,20 @@ function tokenize(query) {
75
91
  let match;
76
92
  while ((match = regex.exec(query)) !== null) {
77
93
  const term = match[1] ?? match[2];
78
- if (!term) continue;
94
+ if (!term) {
95
+ continue;
96
+ }
79
97
  terms.push(term);
80
98
  }
81
99
  return terms;
82
100
  }
83
101
  function fuzzyHighlight(text, terms) {
84
102
  const ranges = [];
85
- for (const term of terms) ranges.push(...findAll(text, term));
103
+ for (const term of terms) {
104
+ ranges.push(...findAll(text, term));
105
+ }
86
106
  ranges.sort((a, b) => a.start - b.start);
87
- return { text, ranges };
107
+ return { ranges, text };
88
108
  }
89
109
 
90
110
  export { fuzzyHighlight, generateSnippet, highlightHtml, highlightMatches, tokenize };
@@ -5,20 +5,28 @@ function useAnchorScroll(options = {}) {
5
5
  const { offset = 80, smooth = true } = options;
6
6
  useEffect(() => {
7
7
  function handleClick(e) {
8
- if (!(e.target instanceof Element)) return;
9
- const target = e.target;
8
+ if (!(e.target instanceof Element)) {
9
+ return;
10
+ }
11
+ const { target } = e;
10
12
  const anchor = target.closest("a");
11
- if (!anchor) return;
13
+ if (!anchor) {
14
+ return;
15
+ }
12
16
  const href = anchor.getAttribute("href");
13
- if (!href?.startsWith("#")) return;
17
+ if (!href?.startsWith("#")) {
18
+ return;
19
+ }
14
20
  const id = href.slice(1);
15
- const element = document.getElementById(id);
16
- if (!element) return;
21
+ const element = document.querySelector(`#${id}`);
22
+ if (!element) {
23
+ return;
24
+ }
17
25
  e.preventDefault();
18
26
  const top = element.offsetTop - offset;
19
27
  window.scrollTo({
20
- top: Math.max(0, top),
21
- behavior: smooth ? "smooth" : "auto"
28
+ behavior: smooth ? "smooth" : "auto",
29
+ top: Math.max(0, top)
22
30
  });
23
31
  window.history.pushState(null, "", href);
24
32
  }
@@ -26,16 +34,20 @@ function useAnchorScroll(options = {}) {
26
34
  return () => document.removeEventListener("click", handleClick);
27
35
  }, [offset, smooth]);
28
36
  useEffect(() => {
29
- const hash = window.location.hash;
30
- if (!hash) return;
37
+ const { hash } = window.location;
38
+ if (!hash) {
39
+ return;
40
+ }
31
41
  const id = hash.slice(1);
32
- const element = document.getElementById(id);
33
- if (!element) return;
42
+ const element = document.querySelector(`#${id}`);
43
+ if (!element) {
44
+ return;
45
+ }
34
46
  setTimeout(() => {
35
47
  const top = element.offsetTop - offset;
36
48
  window.scrollTo({
37
- top: Math.max(0, top),
38
- behavior: "auto"
49
+ behavior: "auto",
50
+ top: Math.max(0, top)
39
51
  });
40
52
  }, 100);
41
53
  }, [offset]);
@@ -1,25 +1,43 @@
1
1
  function getNextIndex(key, options) {
2
- const { count, current, direction = "vertical", wrap = true, isDisabled } = options;
3
- if (count === 0) return -1;
2
+ const {
3
+ count,
4
+ current,
5
+ direction = "vertical",
6
+ wrap = true,
7
+ isDisabled
8
+ } = options;
9
+ if (count === 0) {
10
+ return -1;
11
+ }
4
12
  const isUp = key === "ArrowUp" || direction !== "vertical" && key === "ArrowLeft";
5
13
  const isDown = key === "ArrowDown" || direction !== "vertical" && key === "ArrowRight";
6
14
  const isHome = key === "Home";
7
15
  const isEnd = key === "End";
8
- if (!isUp && !isDown && !isHome && !isEnd) return current;
16
+ if (!isUp && !isDown && !isHome && !isEnd) {
17
+ return current;
18
+ }
9
19
  let next = current;
10
20
  if (isHome) {
11
21
  next = 0;
12
22
  if (isDisabled) {
13
- while (next < count && isDisabled(next)) next++;
14
- if (next >= count) return current;
23
+ while (next < count && isDisabled(next)) {
24
+ next++;
25
+ }
26
+ if (next >= count) {
27
+ return current;
28
+ }
15
29
  }
16
30
  return next;
17
31
  }
18
32
  if (isEnd) {
19
33
  next = count - 1;
20
34
  if (isDisabled) {
21
- while (next >= 0 && isDisabled(next)) next--;
22
- if (next < 0) return current;
35
+ while (next >= 0 && isDisabled(next)) {
36
+ next--;
37
+ }
38
+ if (next < 0) {
39
+ return current;
40
+ }
23
41
  }
24
42
  return next;
25
43
  }
@@ -14,15 +14,15 @@ function useAsync(fn) {
14
14
  setData(result);
15
15
  setLoading(false);
16
16
  return result;
17
- } catch (e) {
18
- setError(e instanceof Error ? e : new Error(String(e)));
17
+ } catch (error2) {
18
+ setError(error2 instanceof Error ? error2 : new Error(String(error2)));
19
19
  setLoading(false);
20
20
  return null;
21
21
  }
22
22
  },
23
23
  [fn]
24
24
  );
25
- return { data, error, loading, execute };
25
+ return { data, error, execute, loading };
26
26
  }
27
27
 
28
28
  export { useAsync };
@@ -9,11 +9,19 @@ function useBattery() {
9
9
  });
10
10
  useEffect(() => {
11
11
  const nav = navigator;
12
- if (typeof navigator === "undefined" || typeof nav.getBattery !== "function") return;
12
+ if (typeof navigator === "undefined" || typeof nav.getBattery !== "function") {
13
+ return;
14
+ }
13
15
  let battery = null;
14
16
  const update = () => {
15
- if (!battery) return;
16
- setState({ charging: battery.charging, level: battery.level, supported: true });
17
+ if (!battery) {
18
+ return;
19
+ }
20
+ setState({
21
+ charging: battery.charging,
22
+ level: battery.level,
23
+ supported: true
24
+ });
17
25
  };
18
26
  nav.getBattery().then((b) => {
19
27
  battery = b;
@@ -1,10 +1,18 @@
1
1
  import { useState, useEffect } from 'react';
2
2
 
3
- const defaults = { sm: 640, md: 768, lg: 1024, xl: 1280, "2xl": 1536 };
3
+ const defaults = {
4
+ "2xl": 1536,
5
+ lg: 1024,
6
+ md: 768,
7
+ sm: 640,
8
+ xl: 1280
9
+ };
4
10
  const ordered = ["2xl", "xl", "lg", "md", "sm"];
5
11
  function resolve(config) {
6
12
  for (const bp of ordered) {
7
- if (window.matchMedia(`(min-width: ${config[bp]}px)`).matches) return bp;
13
+ if (window.matchMedia(`(min-width: ${config[bp]}px)`).matches) {
14
+ return bp;
15
+ }
8
16
  }
9
17
  return "sm";
10
18
  }
@@ -5,15 +5,22 @@ import { useEventListener } from './eventlistener';
5
5
  function useClickOutside(ref, handler, enabled = true) {
6
6
  const handleClick = useCallback(
7
7
  (e) => {
8
- const target = e.target;
9
- if (!(target instanceof Node)) return;
8
+ const { target } = e;
9
+ if (!(target instanceof Node)) {
10
+ return;
11
+ }
10
12
  if (ref.current && !ref.current.contains(target)) {
11
13
  handler();
12
14
  }
13
15
  },
14
16
  [ref, handler]
15
17
  );
16
- useEventListener(typeof document !== "undefined" ? document : null, "click", handleClick, enabled);
18
+ useEventListener(
19
+ typeof document !== "undefined" ? document : null,
20
+ "click",
21
+ handleClick,
22
+ enabled
23
+ );
17
24
  }
18
25
 
19
26
  export { useClickOutside };
@@ -2,12 +2,16 @@
2
2
  import { useState, useEffect } from 'react';
3
3
 
4
4
  function useClipboardPaste() {
5
- const [data, setData] = useState({ text: null, files: [], timestamp: 0 });
5
+ const [data, setData] = useState({
6
+ files: [],
7
+ text: null,
8
+ timestamp: 0
9
+ });
6
10
  useEffect(() => {
7
11
  function handler(e) {
8
12
  const text = e.clipboardData?.getData("text/plain") ?? null;
9
- const files = Array.from(e.clipboardData?.files ?? []);
10
- setData({ text, files, timestamp: Date.now() });
13
+ const files = [...e.clipboardData?.files ?? []];
14
+ setData({ files, text, timestamp: Date.now() });
11
15
  }
12
16
  document.addEventListener("paste", handler);
13
17
  return () => document.removeEventListener("paste", handler);