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/ogimage.js CHANGED
@@ -11,38 +11,38 @@ function generateOgMeta(base, config) {
11
11
  const width = config.width ?? 1200;
12
12
  const height = config.height ?? 630;
13
13
  const url = ogImageUrl(base, {
14
- title: config.title,
14
+ accentColor: config.accentColor,
15
15
  description: config.description,
16
- siteName: config.siteName,
16
+ height: String(height),
17
17
  logo: config.logo,
18
+ siteName: config.siteName,
18
19
  theme: config.theme,
19
- accentColor: config.accentColor,
20
- width: String(width),
21
- height: String(height)
20
+ title: config.title,
21
+ width: String(width)
22
22
  });
23
23
  return {
24
- url,
25
- width,
26
- height,
27
24
  alt: config.description ?? config.title,
28
- type: "image/png"
25
+ height,
26
+ type: "image/png",
27
+ url,
28
+ width
29
29
  };
30
30
  }
31
31
  function defaultTemplate(config) {
32
32
  const dark = config.theme === "dark";
33
33
  return {
34
- title: config.title,
35
- description: config.description ?? "",
36
- siteName: config.siteName ?? "",
37
- logo: config.logo ?? "",
38
- width: config.width ?? 1200,
39
- height: config.height ?? 630,
40
34
  colors: {
35
+ accent: config.accentColor ?? (dark ? "#3b82f6" : "#2563eb"),
41
36
  background: dark ? "#0a0a0a" : "#ffffff",
42
37
  foreground: dark ? "#fafafa" : "#0a0a0a",
43
- muted: dark ? "#a1a1aa" : "#71717a",
44
- accent: config.accentColor ?? (dark ? "#3b82f6" : "#2563eb")
45
- }
38
+ muted: dark ? "#a1a1aa" : "#71717a"
39
+ },
40
+ description: config.description ?? "",
41
+ height: config.height ?? 630,
42
+ logo: config.logo ?? "",
43
+ siteName: config.siteName ?? "",
44
+ title: config.title,
45
+ width: config.width ?? 1200
46
46
  };
47
47
  }
48
48
  function socialMeta(config) {
@@ -50,12 +50,12 @@ function socialMeta(config) {
50
50
  const height = config.height ?? 630;
51
51
  const alt = config.description ?? config.title;
52
52
  return [
53
- { property: "og:image", content: config.url },
54
- { property: "og:image:width", content: String(width) },
55
- { property: "og:image:height", content: String(height) },
56
- { property: "og:image:alt", content: alt },
57
- { name: "twitter:card", content: "summary_large_image" },
58
- { name: "twitter:image", content: config.url }
53
+ { content: config.url, property: "og:image" },
54
+ { content: String(width), property: "og:image:width" },
55
+ { content: String(height), property: "og:image:height" },
56
+ { content: alt, property: "og:image:alt" },
57
+ { content: "summary_large_image", name: "twitter:card" },
58
+ { content: config.url, name: "twitter:image" }
59
59
  ];
60
60
  }
61
61
 
package/dist/openapi.js CHANGED
@@ -1,8 +1,17 @@
1
+ import { parsespec, rootschema } from './openapiguard';
1
2
  import { resolveSchema, resolveRef, resolveContent } from './openapiutil';
2
3
  export { generateEndpointSlug } from './openapiutil';
3
- import { parsespec, rootschema } from './openapiguard';
4
4
 
5
- const HTTP_METHODS = ["get", "post", "put", "patch", "delete", "head", "options", "trace"];
5
+ const HTTP_METHODS = [
6
+ "get",
7
+ "post",
8
+ "put",
9
+ "patch",
10
+ "delete",
11
+ "head",
12
+ "options",
13
+ "trace"
14
+ ];
6
15
  function isrecord(value) {
7
16
  return typeof value === "object" && value !== null;
8
17
  }
@@ -10,63 +19,79 @@ function asrecord(value) {
10
19
  return isrecord(value) ? value : {};
11
20
  }
12
21
  function extractParameters(root, raw) {
13
- if (!Array.isArray(raw)) return [];
22
+ if (!Array.isArray(raw)) {
23
+ return [];
24
+ }
14
25
  return raw.flatMap((item) => {
15
26
  const input = asrecord(item);
16
27
  const ref = typeof input.$ref === "string" ? resolveRef(root, input.$ref) : input;
17
28
  const resolved = asrecord(ref);
18
29
  const name = typeof resolved.name === "string" ? resolved.name : "";
19
30
  const location = resolved.in;
20
- if (!["query", "path", "header", "cookie"].includes(String(location))) return [];
21
- return [{
22
- name,
23
- in: location,
24
- required: typeof resolved.required === "boolean" ? resolved.required : void 0,
25
- description: typeof resolved.description === "string" ? resolved.description : void 0,
26
- schema: resolved.schema ? resolveSchema(root, resolved.schema) : void 0
27
- }];
31
+ if (!["query", "path", "header", "cookie"].includes(String(location))) {
32
+ return [];
33
+ }
34
+ return [
35
+ {
36
+ description: typeof resolved.description === "string" ? resolved.description : void 0,
37
+ in: location,
38
+ name,
39
+ required: typeof resolved.required === "boolean" ? resolved.required : void 0,
40
+ schema: resolved.schema ? resolveSchema(root, resolved.schema) : void 0
41
+ }
42
+ ];
28
43
  });
29
44
  }
30
45
  function extractRequestBody(root, raw) {
31
- if (!raw) return void 0;
46
+ if (!raw) {
47
+ return void 0;
48
+ }
32
49
  const input = asrecord(raw);
33
50
  const ref = typeof input.$ref === "string" ? resolveRef(root, input.$ref) : input;
34
51
  const resolved = asrecord(ref);
35
52
  return {
53
+ content: resolveContent(root, resolved.content) ?? {},
36
54
  description: typeof resolved.description === "string" ? resolved.description : void 0,
37
- required: typeof resolved.required === "boolean" ? resolved.required : void 0,
38
- content: resolveContent(root, resolved.content) ?? {}
55
+ required: typeof resolved.required === "boolean" ? resolved.required : void 0
39
56
  };
40
57
  }
41
58
  function extractResponses(root, raw) {
42
- if (!isrecord(raw)) return [];
59
+ if (!isrecord(raw)) {
60
+ return [];
61
+ }
43
62
  const list = Object.entries(raw).map(([status, val]) => {
44
63
  const input = asrecord(val);
45
64
  const ref = typeof input.$ref === "string" ? resolveRef(root, input.$ref) : input;
46
65
  const resolved = asrecord(ref);
47
66
  return {
48
- status,
67
+ content: resolveContent(root, resolved.content),
49
68
  description: typeof resolved.description === "string" ? resolved.description : void 0,
50
- content: resolveContent(root, resolved.content)
69
+ status
51
70
  };
52
71
  });
53
72
  const rank = (status) => {
54
- if (status === "default") return Number.MAX_SAFE_INTEGER;
73
+ if (status === "default") {
74
+ return Number.MAX_SAFE_INTEGER;
75
+ }
55
76
  const numeric = Number(status);
56
77
  return Number.isFinite(numeric) ? numeric : Number.MAX_SAFE_INTEGER - 1;
57
78
  };
58
79
  return list.sort((left, right) => rank(left.status) - rank(right.status));
59
80
  }
60
81
  function extractSecurity(raw) {
61
- if (!Array.isArray(raw) || raw.length === 0) return void 0;
82
+ if (!Array.isArray(raw) || raw.length === 0) {
83
+ return void 0;
84
+ }
62
85
  const names = /* @__PURE__ */ new Set();
63
86
  for (const item of raw) {
64
- if (!isrecord(item)) continue;
87
+ if (!isrecord(item)) {
88
+ continue;
89
+ }
65
90
  for (const key of Object.keys(item)) {
66
91
  names.add(key);
67
92
  }
68
93
  }
69
- return Array.from(names);
94
+ return [...names];
70
95
  }
71
96
  function extractEndpoints(root) {
72
97
  const doc = asrecord(root);
@@ -77,23 +102,25 @@ function extractEndpoints(root) {
77
102
  const shared = methods.parameters;
78
103
  for (const method of HTTP_METHODS) {
79
104
  const op = asrecord(methods[method]);
80
- if (Object.keys(op).length === 0) continue;
105
+ if (Object.keys(op).length === 0) {
106
+ continue;
107
+ }
81
108
  const opParams = Array.isArray(op.parameters) ? op.parameters : [];
82
109
  const sharedParams = Array.isArray(shared) ? shared : [];
83
110
  const params = [...sharedParams, ...opParams];
84
111
  const tags = Array.isArray(op.tags) ? op.tags.filter((item) => typeof item === "string") : [];
85
112
  endpoints.push({
113
+ deprecated: typeof op.deprecated === "boolean" ? op.deprecated : void 0,
114
+ description: typeof op.description === "string" ? op.description : void 0,
86
115
  method: method.toUpperCase(),
87
- path,
88
116
  operationId: typeof op.operationId === "string" ? op.operationId : void 0,
89
- summary: typeof op.summary === "string" ? op.summary : void 0,
90
- description: typeof op.description === "string" ? op.description : void 0,
91
- tags,
92
117
  parameters: extractParameters(root, params),
118
+ path,
93
119
  requestBody: extractRequestBody(root, op.requestBody),
94
120
  responses: extractResponses(root, op.responses),
95
- deprecated: typeof op.deprecated === "boolean" ? op.deprecated : void 0,
96
- security: extractSecurity(op.security)
121
+ security: extractSecurity(op.security),
122
+ summary: typeof op.summary === "string" ? op.summary : void 0,
123
+ tags
97
124
  });
98
125
  }
99
126
  }
@@ -127,14 +154,14 @@ function parseOpenApi(spec) {
127
154
  const parsed = rootschema.parse(root);
128
155
  const endpoints = extractEndpoints(root);
129
156
  return {
157
+ endpoints,
130
158
  info: {
159
+ description: parsed.info.description,
131
160
  title: parsed.info.title,
132
- version: parsed.info.version,
133
- description: parsed.info.description
161
+ version: parsed.info.version
134
162
  },
135
- endpoints,
136
- tags: extractTags(root, endpoints),
137
- schemas: extractSchemas(root)
163
+ schemas: extractSchemas(root),
164
+ tags: extractTags(root, endpoints)
138
165
  };
139
166
  }
140
167
 
@@ -10,19 +10,25 @@ function torecord(value) {
10
10
  function parseinfo(value) {
11
11
  const input = torecord(value) ?? {};
12
12
  return {
13
+ description: totext(input.description),
13
14
  title: totext(input.title) ?? "",
14
- version: totext(input.version) ?? "",
15
- description: totext(input.description)
15
+ version: totext(input.version) ?? ""
16
16
  };
17
17
  }
18
18
  function parsetags(value) {
19
- if (!Array.isArray(value)) return [];
19
+ if (!Array.isArray(value)) {
20
+ return [];
21
+ }
20
22
  return value.flatMap((item) => {
21
23
  const input = torecord(item);
22
- if (!input) return [];
24
+ if (!input) {
25
+ return [];
26
+ }
23
27
  const name = totext(input.name);
24
- if (!name || name.length === 0) return [];
25
- return [{ name, description: totext(input.description) }];
28
+ if (!name || name.length === 0) {
29
+ return [];
30
+ }
31
+ return [{ description: totext(input.description), name }];
26
32
  });
27
33
  }
28
34
  function parsepaths(value) {
@@ -30,9 +36,13 @@ function parsepaths(value) {
30
36
  }
31
37
  function parsecomponents(value) {
32
38
  const input = torecord(value);
33
- if (!input) return void 0;
39
+ if (!input) {
40
+ return void 0;
41
+ }
34
42
  const schemas = torecord(input.schemas);
35
- if (!schemas) return void 0;
43
+ if (!schemas) {
44
+ return void 0;
45
+ }
36
46
  return { schemas };
37
47
  }
38
48
  function parsedefinitions(value) {
@@ -43,11 +53,11 @@ function parseroot(value) {
43
53
  throw new Error("invalid openapi specification");
44
54
  }
45
55
  return {
56
+ components: parsecomponents(value.components),
57
+ definitions: parsedefinitions(value.definitions),
46
58
  info: parseinfo(value.info),
47
59
  paths: parsepaths(value.paths),
48
- tags: parsetags(value.tags),
49
- components: parsecomponents(value.components),
50
- definitions: parsedefinitions(value.definitions)
60
+ tags: parsetags(value.tags)
51
61
  };
52
62
  }
53
63
  const rootschema = {
@@ -1,40 +1,70 @@
1
1
  function generateEndpointSlug(method, path) {
2
- return `${method.toLowerCase()}-${path.replace(/^\//, "").replace(/[/{}}]/g, "-").replace(/-+/g, "-").replace(/-$/, "")}`;
2
+ return `${method.toLowerCase()}-${path.replace(/^\//, "").replaceAll(/[/{}}]/g, "-").replaceAll(/-+/g, "-").replace(/-$/, "")}`;
3
3
  }
4
4
  const MAX_SCHEMA_DEPTH = 40;
5
5
  function isrecord(value) {
6
6
  return typeof value === "object" && value !== null;
7
7
  }
8
8
  function resolveRef(root, ref) {
9
- if (!ref.startsWith("#/")) return {};
9
+ if (!ref.startsWith("#/")) {
10
+ return {};
11
+ }
10
12
  const parts = ref.slice(2).split("/");
11
13
  let current = root;
12
14
  for (const part of parts) {
13
- if (!isrecord(current)) return {};
15
+ if (!isrecord(current)) {
16
+ return {};
17
+ }
14
18
  current = current[part];
15
- if (current === void 0) return {};
19
+ if (current === void 0) {
20
+ return {};
21
+ }
16
22
  }
17
23
  return current;
18
24
  }
19
25
  function resolveSchema(root, raw, depth = 0, refs = /* @__PURE__ */ new Set()) {
20
- if (depth > MAX_SCHEMA_DEPTH) return {};
21
- if (!isrecord(raw)) return {};
26
+ if (depth > MAX_SCHEMA_DEPTH) {
27
+ return {};
28
+ }
29
+ if (!isrecord(raw)) {
30
+ return {};
31
+ }
22
32
  if (typeof raw.$ref === "string") {
23
- if (refs.has(raw.$ref)) return {};
33
+ if (refs.has(raw.$ref)) {
34
+ return {};
35
+ }
24
36
  const next = new Set(refs);
25
37
  next.add(raw.$ref);
26
38
  return resolveSchema(root, resolveRef(root, raw.$ref), depth + 1, next);
27
39
  }
28
40
  const schema = {};
29
- if (typeof raw.type === "string") schema.type = raw.type;
30
- if (typeof raw.format === "string") schema.format = raw.format;
31
- if (typeof raw.description === "string") schema.description = raw.description;
32
- if (typeof raw.nullable === "boolean") schema.nullable = raw.nullable;
33
- if (raw.default !== void 0) schema.default = raw.default;
34
- if (raw.example !== void 0) schema.example = raw.example;
35
- if (Array.isArray(raw.enum)) schema.enum = raw.enum.filter((item) => typeof item === "string");
41
+ if (typeof raw.type === "string") {
42
+ schema.type = raw.type;
43
+ }
44
+ if (typeof raw.format === "string") {
45
+ schema.format = raw.format;
46
+ }
47
+ if (typeof raw.description === "string") {
48
+ schema.description = raw.description;
49
+ }
50
+ if (typeof raw.nullable === "boolean") {
51
+ schema.nullable = raw.nullable;
52
+ }
53
+ if (raw.default !== void 0) {
54
+ schema.default = raw.default;
55
+ }
56
+ if (raw.example !== void 0) {
57
+ schema.example = raw.example;
58
+ }
59
+ if (Array.isArray(raw.enum)) {
60
+ schema.enum = raw.enum.filter(
61
+ (item) => typeof item === "string"
62
+ );
63
+ }
36
64
  if (Array.isArray(raw.required)) {
37
- schema.required = raw.required.filter((item) => typeof item === "string");
65
+ schema.required = raw.required.filter(
66
+ (item) => typeof item === "string"
67
+ );
38
68
  }
39
69
  if (isrecord(raw.properties)) {
40
70
  schema.properties = {};
@@ -42,14 +72,30 @@ function resolveSchema(root, raw, depth = 0, refs = /* @__PURE__ */ new Set()) {
42
72
  schema.properties[key] = resolveSchema(root, val, depth + 1, refs);
43
73
  }
44
74
  }
45
- if (raw.items) schema.items = resolveSchema(root, raw.items, depth + 1, refs);
46
- if (Array.isArray(raw.oneOf)) schema.oneOf = raw.oneOf.map((schemaitem) => resolveSchema(root, schemaitem, depth + 1, refs));
47
- if (Array.isArray(raw.anyOf)) schema.anyOf = raw.anyOf.map((schemaitem) => resolveSchema(root, schemaitem, depth + 1, refs));
48
- if (Array.isArray(raw.allOf)) schema.allOf = raw.allOf.map((schemaitem) => resolveSchema(root, schemaitem, depth + 1, refs));
75
+ if (raw.items) {
76
+ schema.items = resolveSchema(root, raw.items, depth + 1, refs);
77
+ }
78
+ if (Array.isArray(raw.oneOf)) {
79
+ schema.oneOf = raw.oneOf.map(
80
+ (schemaitem) => resolveSchema(root, schemaitem, depth + 1, refs)
81
+ );
82
+ }
83
+ if (Array.isArray(raw.anyOf)) {
84
+ schema.anyOf = raw.anyOf.map(
85
+ (schemaitem) => resolveSchema(root, schemaitem, depth + 1, refs)
86
+ );
87
+ }
88
+ if (Array.isArray(raw.allOf)) {
89
+ schema.allOf = raw.allOf.map(
90
+ (schemaitem) => resolveSchema(root, schemaitem, depth + 1, refs)
91
+ );
92
+ }
49
93
  return schema;
50
94
  }
51
95
  function resolveContent(root, raw) {
52
- if (!isrecord(raw)) return void 0;
96
+ if (!isrecord(raw)) {
97
+ return void 0;
98
+ }
53
99
  const result = {};
54
100
  for (const [mediaType, val] of Object.entries(raw)) {
55
101
  const value = isrecord(val) ? val.schema : void 0;
package/dist/orama.js CHANGED
@@ -9,36 +9,44 @@ function getnumber(value) {
9
9
  return typeof value === "number" ? value : void 0;
10
10
  }
11
11
  function parsehit(value, depth = 0) {
12
- if (!isrecord(value)) return null;
13
- if (depth > MAX_DEPTH) return null;
12
+ if (!isrecord(value)) {
13
+ return null;
14
+ }
15
+ if (depth > MAX_DEPTH) {
16
+ return null;
17
+ }
14
18
  const nested = isrecord(value.document) ? parsehit(value.document, depth + 1) : null;
15
19
  const document = nested ?? void 0;
16
20
  return {
17
- slug: getstring(value.slug),
18
- path: getstring(value.path),
19
- title: getstring(value.title),
20
- description: getstring(value.description),
21
- content: getstring(value.content),
22
21
  anchor: getstring(value.anchor),
22
+ content: getstring(value.content),
23
+ description: getstring(value.description),
24
+ document,
23
25
  heading: getstring(value.heading),
24
- snippet: getstring(value.snippet),
26
+ path: getstring(value.path),
25
27
  score: getnumber(value.score),
26
- document
28
+ slug: getstring(value.slug),
29
+ snippet: getstring(value.snippet),
30
+ title: getstring(value.title)
27
31
  };
28
32
  }
29
33
  function parsehits(value) {
30
- if (Array.isArray(value)) return value.map(parsehit).filter((item) => item !== null);
31
- if (!isrecord(value)) return [];
34
+ if (Array.isArray(value)) {
35
+ return value.map(parsehit).filter((item) => item !== null);
36
+ }
37
+ if (!isrecord(value)) {
38
+ return [];
39
+ }
32
40
  const hits = Array.isArray(value.hits) ? value.hits : Array.isArray(value.results) ? value.results : [];
33
41
  return hits.map(parsehit).filter((item) => item !== null);
34
42
  }
35
43
  function normalize(doc) {
36
44
  return {
37
- slug: doc.slug,
38
- title: doc.title,
39
- description: doc.description,
40
45
  content: doc.content ?? "",
41
- headings: doc.headings
46
+ description: doc.description,
47
+ headings: doc.headings,
48
+ slug: doc.slug,
49
+ title: doc.title
42
50
  };
43
51
  }
44
52
  function fallback(docs, limit) {
@@ -48,48 +56,58 @@ function maphit(entry, index, total) {
48
56
  const source = entry.document ?? entry;
49
57
  const slug = source.slug ?? source.path;
50
58
  const title = source.title ?? source.heading ?? slug;
51
- if (!slug || !title) return null;
59
+ if (!slug || !title) {
60
+ return null;
61
+ }
52
62
  return {
63
+ anchor: source.anchor,
53
64
  doc: normalize({
54
- slug,
55
- title,
65
+ content: source.content ?? "",
56
66
  description: source.description,
57
- content: source.content ?? ""
67
+ slug,
68
+ title
58
69
  }),
70
+ heading: source.heading,
59
71
  score: source.score ?? Math.max(1, total - index),
60
- snippet: source.snippet ?? source.description ?? source.content,
61
- anchor: source.anchor,
62
- heading: source.heading
72
+ snippet: source.snippet ?? source.description ?? source.content
63
73
  };
64
74
  }
65
75
  function createOramaAdapter(config) {
66
76
  return {
67
77
  async search(query, docs, limit = 8) {
68
78
  const value = query.trim();
69
- if (!value) return fallback(docs, limit);
79
+ if (!value) {
80
+ return fallback(docs, limit);
81
+ }
70
82
  const response = await fetch(config.endpoint, {
71
- method: "POST",
83
+ body: JSON.stringify({
84
+ index: config.index,
85
+ limit,
86
+ query: value,
87
+ term: value
88
+ }),
72
89
  headers: {
73
90
  "content-type": "application/json",
74
91
  ...config.key ? { authorization: `Bearer ${config.key}` } : {},
75
- ...config.headers ?? {}
92
+ ...config.headers
76
93
  },
77
- body: JSON.stringify({
78
- query: value,
79
- term: value,
80
- limit,
81
- index: config.index
82
- })
94
+ method: "POST"
83
95
  });
84
- if (!response.ok) return [];
96
+ if (!response.ok) {
97
+ return [];
98
+ }
85
99
  const json = await response.json();
86
100
  const hits = parsehits(json);
87
101
  const result = [];
88
102
  for (let i = 0; i < hits.length; i++) {
89
103
  const hit = hits[i];
90
- if (!hit) continue;
104
+ if (!hit) {
105
+ continue;
106
+ }
91
107
  const item = maphit(hit, i, hits.length);
92
- if (item) result.push(item);
108
+ if (item) {
109
+ result.push(item);
110
+ }
93
111
  }
94
112
  return result;
95
113
  }
@@ -1,15 +1,15 @@
1
- type PipelineContext = {
1
+ interface PipelineContext {
2
2
  path: string;
3
3
  content: string;
4
4
  frontmatter: Record<string, unknown>;
5
5
  meta: Record<string, unknown>;
6
- };
6
+ }
7
7
  type Transform = (ctx: PipelineContext) => PipelineContext | Promise<PipelineContext>;
8
- type Pipeline = {
8
+ interface Pipeline {
9
9
  use(transform: Transform): Pipeline;
10
10
  process(ctx: PipelineContext): Promise<PipelineContext>;
11
11
  transforms(): Transform[];
12
- };
12
+ }
13
13
  declare function createPipeline(...initial: Transform[]): Pipeline;
14
14
  declare function composeTransforms(...transforms: Transform[]): Transform;
15
15
  declare function conditionalTransform(predicate: (ctx: PipelineContext) => boolean, transform: Transform): Transform;
package/dist/pipeline.js CHANGED
@@ -1,10 +1,6 @@
1
1
  function createPipeline(...initial) {
2
2
  const list = [...initial];
3
3
  const pipeline = {
4
- use(transform) {
5
- list.push(transform);
6
- return pipeline;
7
- },
8
4
  async process(ctx) {
9
5
  let result = ctx;
10
6
  for (const t of list) {
@@ -14,6 +10,10 @@ function createPipeline(...initial) {
14
10
  },
15
11
  transforms() {
16
12
  return [...list];
13
+ },
14
+ use(transform) {
15
+ list.push(transform);
16
+ return pipeline;
17
17
  }
18
18
  };
19
19
  return pipeline;
package/dist/preload.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  declare function preloadPage(slug: string): {
2
- rel: "prefetch";
3
2
  href: string;
3
+ rel: "prefetch";
4
4
  };
5
5
  declare function preloadSearch(): {
6
- rel: "prefetch";
7
6
  href: string;
7
+ rel: "prefetch";
8
8
  };
9
9
  declare const preloadConfig: {
10
10
  hoverDelay: number;
package/dist/preload.js CHANGED
@@ -1,13 +1,13 @@
1
1
  function preloadPage(slug) {
2
2
  return {
3
- rel: "prefetch",
4
- href: `/docs/${slug}`
3
+ href: `/docs/${slug}`,
4
+ rel: "prefetch"
5
5
  };
6
6
  }
7
7
  function preloadSearch() {
8
8
  return {
9
- rel: "prefetch",
10
- href: "/api/search"
9
+ href: "/api/search",
10
+ rel: "prefetch"
11
11
  };
12
12
  }
13
13
  const preloadConfig = {
package/dist/ranking.d.ts CHANGED
@@ -1,26 +1,26 @@
1
- type RankableItem = {
1
+ interface RankableItem {
2
2
  title: string;
3
3
  description?: string;
4
4
  content?: string;
5
5
  tags?: string[];
6
6
  path: string;
7
7
  weight?: number;
8
- };
9
- type RankResult = {
8
+ }
9
+ interface RankResult {
10
10
  item: RankableItem;
11
11
  score: number;
12
12
  matches: {
13
13
  field: string;
14
14
  positions: number[];
15
15
  }[];
16
- };
17
- type RankOptions = {
16
+ }
17
+ interface RankOptions {
18
18
  titleWeight?: number;
19
19
  descriptionWeight?: number;
20
20
  contentWeight?: number;
21
21
  tagWeight?: number;
22
22
  fuzzy?: boolean;
23
- };
23
+ }
24
24
  declare function rank(items: RankableItem[], query: string, options?: RankOptions): RankResult[];
25
25
  declare function bm25(items: RankableItem[], query: string): RankResult[];
26
26
  declare function boostRecent(results: RankResult[], dateFn: (item: RankableItem) => Date, maxBoost?: number): RankResult[];