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.
- package/dist/access.d.ts +7 -7
- package/dist/access.js +12 -5
- package/dist/adapter.js +8 -16
- package/dist/adapterbrowser.js +6 -10
- package/dist/adapternext.js +7 -18
- package/dist/adapterreactrouter.js +5 -9
- package/dist/adapterremix.js +8 -17
- package/dist/adaptertanstack.js +6 -10
- package/dist/algolia.js +43 -21
- package/dist/analytics.d.ts +1 -1
- package/dist/analytics.js +16 -10
- package/dist/ansi.js +76 -37
- package/dist/api.d.ts +10 -10
- package/dist/api.js +14 -11
- package/dist/audit.d.ts +6 -6
- package/dist/audit.js +29 -10
- package/dist/autotype.js +20 -10
- package/dist/batch.d.ts +6 -6
- package/dist/batch.js +16 -9
- package/dist/changelog.js +28 -14
- package/dist/changelogutil.d.ts +4 -4
- package/dist/changelogutil.js +33 -13
- package/dist/cli.d.ts +6 -6
- package/dist/cli.js +7 -3
- package/dist/client.d.ts +1 -1
- package/dist/codesample.d.ts +4 -4
- package/dist/codesample.js +63 -24
- package/dist/collapse.js +31 -13
- package/dist/collections.js +36 -16
- package/dist/components/accordion.d.ts +1 -1
- package/dist/components/accordion.js +5 -1
- package/dist/components/alert.d.ts +1 -1
- package/dist/components/alert.js +24 -13
- package/dist/components/announce.js +40 -17
- package/dist/components/autofill.js +17 -7
- package/dist/components/avatar.js +4 -4
- package/dist/components/avatarstack.js +2 -2
- package/dist/components/backtotop.d.ts +1 -1
- package/dist/components/backtotop.js +17 -4
- package/dist/components/badge.js +9 -4
- package/dist/components/banner.js +22 -5
- package/dist/components/breadcrumb.js +11 -4
- package/dist/components/breadcrumbnav.js +37 -21
- package/dist/components/button.js +23 -8
- package/dist/components/callout.d.ts +1 -1
- package/dist/components/callout.js +33 -29
- package/dist/components/changelog.js +21 -8
- package/dist/components/checkbox.js +32 -19
- package/dist/components/code.d.ts +1 -1
- package/dist/components/code.js +6 -3
- package/dist/components/codeblock.js +157 -39
- package/dist/components/codecopy.d.ts +1 -1
- package/dist/components/codecopy.js +36 -13
- package/dist/components/codegroup.js +87 -25
- package/dist/components/collapsible.d.ts +1 -1
- package/dist/components/collapsible.js +5 -1
- package/dist/components/command.d.ts +1 -1
- package/dist/components/command.js +42 -15
- package/dist/components/compare.js +20 -8
- package/dist/components/content.js +121 -79
- package/dist/components/copybutton.d.ts +1 -1
- package/dist/components/copybutton.js +14 -7
- package/dist/components/countdown.js +9 -3
- package/dist/components/create.js +34 -24
- package/dist/components/definition.js +11 -4
- package/dist/components/diffview.js +63 -29
- package/dist/components/divider.js +5 -1
- package/dist/components/docheader.js +8 -1
- package/dist/components/doclinkcard.js +27 -3
- package/dist/components/dropdown.d.ts +1 -1
- package/dist/components/dropdown.js +32 -11
- package/dist/components/dynamiccode.js +5 -3
- package/dist/components/editlink.js +35 -23
- package/dist/components/embed.js +15 -7
- package/dist/components/endpoint.d.ts +3 -3
- package/dist/components/endpoint.js +24 -9
- package/dist/components/errormessage.d.ts +1 -1
- package/dist/components/errormessage.js +4 -1
- package/dist/components/expandcode.d.ts +1 -1
- package/dist/components/expandcode.js +6 -2
- package/dist/components/feature.js +8 -1
- package/dist/components/featuregrid.d.ts +4 -4
- package/dist/components/featuregrid.js +7 -1
- package/dist/components/feedback.js +6 -2
- package/dist/components/feedbackwidget.js +10 -4
- package/dist/components/files.d.ts +1 -1
- package/dist/components/files.js +52 -18
- package/dist/components/folder.d.ts +1 -1
- package/dist/components/folder.js +21 -4
- package/dist/components/footer.js +5 -1
- package/dist/components/formlabel.d.ts +1 -1
- package/dist/components/formlabel.js +31 -18
- package/dist/components/github.js +43 -14
- package/dist/components/graph.js +38 -14
- package/dist/components/heading.js +36 -29
- package/dist/components/headingcopy.js +13 -5
- package/dist/components/hero.js +20 -14
- package/dist/components/highlight.d.ts +2 -2
- package/dist/components/highlight.js +14 -8
- package/dist/components/hover.d.ts +2 -2
- package/dist/components/hover.js +11 -4
- package/dist/components/icons.js +4 -1
- package/dist/components/inlinetoc.js +3 -1
- package/dist/components/input.js +13 -3
- package/dist/components/install.js +34 -24
- package/dist/components/kbd.js +19 -11
- package/dist/components/langicon.d.ts +1 -1
- package/dist/components/langicon.js +22 -17
- package/dist/components/language.d.ts +1 -1
- package/dist/components/language.js +12 -4
- package/dist/components/lastupdated.d.ts +2 -2
- package/dist/components/lastupdated.js +36 -12
- package/dist/components/link.d.ts +1 -1
- package/dist/components/linkcard.js +3 -1
- package/dist/components/list.d.ts +1 -1
- package/dist/components/list.js +4 -1
- package/dist/components/math.js +33 -8
- package/dist/components/mermaid.js +3 -3
- package/dist/components/mobilenav.d.ts +2 -1
- package/dist/components/mobilenav.js +116 -47
- package/dist/components/modal.d.ts +1 -1
- package/dist/components/modal.js +9 -2
- package/dist/components/navlink.js +17 -3
- package/dist/components/openapi.d.ts +1 -1
- package/dist/components/openapi.js +102 -32
- package/dist/components/openapischema.d.ts +1 -1
- package/dist/components/openapischema.js +29 -9
- package/dist/components/openapitags.js +6 -2
- package/dist/components/pagetransition.js +5 -3
- package/dist/components/pagination.js +3 -2
- package/dist/components/panel.js +91 -15
- package/dist/components/playground.d.ts +1 -1
- package/dist/components/playground.js +153 -50
- package/dist/components/popover.js +9 -7
- package/dist/components/prelink.js +40 -9
- package/dist/components/prevnext.d.ts +1 -1
- package/dist/components/prevnext.js +36 -16
- package/dist/components/progress.js +2 -2
- package/dist/components/property.js +3 -1
- package/dist/components/quote.d.ts +2 -2
- package/dist/components/quote.js +32 -4
- package/dist/components/radio.js +36 -18
- package/dist/components/rating.js +14 -3
- package/dist/components/recent.d.ts +1 -1
- package/dist/components/recent.js +26 -10
- package/dist/components/responsive.js +21 -13
- package/dist/components/results.js +8 -4
- package/dist/components/screenshot.js +61 -21
- package/dist/components/scrollprogress.js +9 -5
- package/dist/components/scrollspy.d.ts +2 -2
- package/dist/components/scrollspy.js +9 -3
- package/dist/components/search.js +47 -18
- package/dist/components/searchbutton.js +3 -1
- package/dist/components/searchdialog.js +35 -22
- package/dist/components/searcher.d.ts +1 -1
- package/dist/components/searcher.js +51 -26
- package/dist/components/select.js +27 -13
- package/dist/components/shortcuts.d.ts +1 -1
- package/dist/components/shortcuts.js +57 -38
- package/dist/components/sidebar.d.ts +2 -1
- package/dist/components/sidebar.js +221 -56
- package/dist/components/sidebarfilter.d.ts +1 -1
- package/dist/components/sidebarfilter.js +30 -6
- package/dist/components/sidebarscript.d.ts +5 -0
- package/dist/components/sidebarscript.js +18 -0
- package/dist/components/skeleton.js +15 -3
- package/dist/components/spinner.js +13 -3
- package/dist/components/status.js +20 -8
- package/dist/components/steps.js +3 -1
- package/dist/components/switch.js +4 -4
- package/dist/components/table.js +37 -12
- package/dist/components/tabnav.d.ts +1 -1
- package/dist/components/tabnav.js +48 -36
- package/dist/components/tabs.d.ts +1 -1
- package/dist/components/tabs.js +56 -40
- package/dist/components/tag.js +8 -3
- package/dist/components/terminal.js +14 -4
- package/dist/components/textarea.js +96 -82
- package/dist/components/theme.d.ts +1 -1
- package/dist/components/theme.js +25 -3
- package/dist/components/themeprovider.d.ts +4 -4
- package/dist/components/themeprovider.js +16 -5
- package/dist/components/toast.d.ts +1 -1
- package/dist/components/toast.js +23 -14
- package/dist/components/toc/default.d.ts +1 -1
- package/dist/components/toc/default.js +28 -13
- package/dist/components/toc/hook.js +28 -14
- package/dist/components/toc/index.js +8 -4
- package/dist/components/toc/inline.js +12 -2
- package/dist/components/toc/minimal.js +11 -5
- package/dist/components/toc/zigzag.d.ts +1 -1
- package/dist/components/toc/zigzag.js +37 -17
- package/dist/components/tocprogress.d.ts +1 -1
- package/dist/components/tocprogress.js +66 -34
- package/dist/components/tooltip.d.ts +1 -1
- package/dist/components/tooltip.js +20 -8
- package/dist/components/trigger.js +13 -5
- package/dist/components/twoslash.js +49 -26
- package/dist/components/typetable.js +23 -4
- package/dist/components/typewriter.js +6 -2
- package/dist/components/version.js +40 -14
- package/dist/components/video.js +25 -15
- package/dist/components/zoom.js +6 -2
- package/dist/config.d.ts +2 -2
- package/dist/config.js +56 -30
- package/dist/content.d.ts +5 -5
- package/dist/content.js +121 -57
- package/dist/contentcache.d.ts +10 -10
- package/dist/contentcache.js +9 -5
- package/dist/contentdiff.d.ts +4 -4
- package/dist/contentdiff.js +16 -8
- package/dist/contributors.d.ts +4 -4
- package/dist/contributors.js +49 -19
- package/dist/diff.d.ts +6 -6
- package/dist/diff.js +37 -16
- package/dist/draft.d.ts +11 -11
- package/dist/draft.js +9 -5
- package/dist/env.js +21 -7
- package/dist/export.js +4 -4
- package/dist/frontmatter.js +11 -9
- package/dist/github.js +60 -30
- package/dist/gitsource.d.ts +1 -1
- package/dist/gitsource.js +16 -9
- package/dist/hash.d.ts +6 -6
- package/dist/hash.js +19 -7
- package/dist/highlight.d.ts +4 -4
- package/dist/highlight.js +34 -14
- package/dist/hooks/anchor.js +26 -14
- package/dist/hooks/arrownav.js +25 -7
- package/dist/hooks/async.js +3 -3
- package/dist/hooks/battery.js +11 -3
- package/dist/hooks/breakpoint.js +10 -2
- package/dist/hooks/clickoutside.js +10 -3
- package/dist/hooks/clipboard-paste.js +7 -3
- package/dist/hooks/clipboard.d.ts +2 -2
- package/dist/hooks/clipboard.js +21 -15
- package/dist/hooks/copy.js +11 -6
- package/dist/hooks/countdown.js +1 -1
- package/dist/hooks/counter.js +1 -1
- package/dist/hooks/escapekey.js +6 -1
- package/dist/hooks/eventlistener.js +3 -1
- package/dist/hooks/eventsource.js +4 -2
- package/dist/hooks/eyedropper.js +7 -3
- package/dist/hooks/favicon.js +1 -1
- package/dist/hooks/fetch.js +12 -4
- package/dist/hooks/focustrap.js +20 -8
- package/dist/hooks/focuswithin.js +6 -2
- package/dist/hooks/form.d.ts +2 -2
- package/dist/hooks/form.js +15 -2
- package/dist/hooks/fullscreen.js +1 -1
- package/dist/hooks/geolocation.js +8 -8
- package/dist/hooks/hotkeys.js +19 -7
- package/dist/hooks/hover.d.ts +4 -1
- package/dist/hooks/hover.js +3 -1
- package/dist/hooks/idle.js +13 -3
- package/dist/hooks/infinitescroll.js +4 -2
- package/dist/hooks/interval.js +3 -1
- package/dist/hooks/inview.js +7 -3
- package/dist/hooks/keyboard.js +36 -12
- package/dist/hooks/keypress.js +6 -2
- package/dist/hooks/list.js +11 -1
- package/dist/hooks/longpress.js +3 -3
- package/dist/hooks/map.js +1 -1
- package/dist/hooks/measure.js +16 -7
- package/dist/hooks/mediarecorder.js +7 -3
- package/dist/hooks/networkstate.js +4 -2
- package/dist/hooks/os.js +12 -4
- package/dist/hooks/pagination.js +6 -4
- package/dist/hooks/permission.js +6 -2
- package/dist/hooks/queue.js +4 -2
- package/dist/hooks/readprogress.js +6 -2
- package/dist/hooks/resizeobserver.js +6 -4
- package/dist/hooks/script.js +1 -1
- package/dist/hooks/scrolllock.js +6 -2
- package/dist/hooks/scrollspy.js +4 -2
- package/dist/hooks/selection.js +6 -3
- package/dist/hooks/share.js +18 -9
- package/dist/hooks/speechrecognition.js +7 -3
- package/dist/hooks/stepper.js +4 -4
- package/dist/hooks/storage.js +9 -3
- package/dist/hooks/stylesheet.js +4 -2
- package/dist/hooks/textselection.js +6 -3
- package/dist/hooks/throttle.js +6 -2
- package/dist/hooks/undoredo.js +19 -11
- package/dist/hooks/vibrate.js +3 -1
- package/dist/hooks/viewtransition.js +8 -4
- package/dist/hooks/wakelock.js +12 -7
- package/dist/hooks/websocket.js +4 -2
- package/dist/hooks/windowsize.js +2 -2
- package/dist/i18n.d.ts +2 -2
- package/dist/i18n.js +27 -14
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lastmodified.js +11 -5
- package/dist/linkcheck.d.ts +6 -6
- package/dist/linkcheck.js +55 -14
- package/dist/llms.js +20 -4
- package/dist/manifest.js +7 -7
- package/dist/mcp.js +28 -22
- package/dist/mdtoc.d.ts +4 -4
- package/dist/mdtoc.js +11 -5
- package/dist/mdxscope.d.ts +2 -2
- package/dist/mdxscope.js +3 -1
- package/dist/meta.js +19 -7
- package/dist/migrate.js +35 -25
- package/dist/navgen.d.ts +8 -8
- package/dist/navgen.js +73 -30
- package/dist/navtree.d.ts +1 -1
- package/dist/navtree.js +39 -19
- package/dist/oembed.d.ts +4 -4
- package/dist/oembed.js +24 -18
- package/dist/ogimage.d.ts +11 -11
- package/dist/ogimage.js +24 -24
- package/dist/openapi.js +60 -33
- package/dist/openapiguard.js +21 -11
- package/dist/openapiutil.js +66 -20
- package/dist/orama.js +52 -34
- package/dist/pipeline.d.ts +4 -4
- package/dist/pipeline.js +4 -4
- package/dist/preload.d.ts +2 -2
- package/dist/preload.js +4 -4
- package/dist/ranking.d.ts +6 -6
- package/dist/ranking.js +39 -13
- package/dist/readtime.js +3 -1
- package/dist/redirects.d.ts +2 -2
- package/dist/redirects.js +20 -12
- package/dist/rehype.js +16 -9
- package/dist/rehypeautolink.d.ts +2 -2
- package/dist/rehypeautolink.js +25 -23
- package/dist/rehypecode.js +38 -28
- package/dist/rehypecopy.js +17 -13
- package/dist/rehypeinline.js +33 -27
- package/dist/rehypelinks.js +28 -20
- package/dist/rehyperaw.js +9 -3
- package/dist/rehypeslug.d.ts +1 -1
- package/dist/rehypeslug.js +23 -19
- package/dist/rehypetablewrap.d.ts +2 -2
- package/dist/rehypetablewrap.js +9 -5
- package/dist/rehypetoc.d.ts +1 -1
- package/dist/rehypetoc.js +15 -7
- package/dist/remark.js +28 -13
- package/dist/remarkadmonition.js +40 -14
- package/dist/remarkannotation.d.ts +2 -2
- package/dist/remarkannotation.js +26 -10
- package/dist/remarkbadge.js +43 -31
- package/dist/remarkblockmath.js +29 -15
- package/dist/remarkcallout.js +32 -14
- package/dist/remarkcaption.js +28 -16
- package/dist/remarkcodetitle.js +29 -13
- package/dist/remarkcolumns.js +22 -10
- package/dist/remarkdetails.js +34 -14
- package/dist/remarkdirective.js +47 -20
- package/dist/remarkembed.js +38 -22
- package/dist/remarkfiletree.js +29 -19
- package/dist/remarkfootnote.js +46 -18
- package/dist/remarkgfm.js +13 -8
- package/dist/remarkheadingid.js +16 -6
- package/dist/remarkimage.js +54 -34
- package/dist/remarkinclude.js +20 -8
- package/dist/remarkinstall.js +20 -12
- package/dist/remarklinkcard.js +33 -14
- package/dist/remarkmath.js +34 -15
- package/dist/remarkmermaid.js +10 -6
- package/dist/remarkmeta.d.ts +2 -2
- package/dist/remarkmeta.js +15 -5
- package/dist/remarkreadingtime.d.ts +2 -2
- package/dist/remarkreadingtime.js +3 -1
- package/dist/remarksteps.js +26 -14
- package/dist/remarkstructure.js +16 -10
- package/dist/remarktabs.js +31 -14
- package/dist/remarktoc.js +40 -24
- package/dist/remarkts2js.js +51 -40
- package/dist/remarktwoslash.d.ts +4 -4
- package/dist/remarktwoslash.js +24 -14
- package/dist/remarkvideo.d.ts +4 -4
- package/dist/remarkvideo.js +42 -16
- package/dist/schema.d.ts +14 -14
- package/dist/schema.js +2 -2
- package/dist/search.js +106 -48
- package/dist/searchindex.js +86 -34
- package/dist/searchpolicy.js +1 -1
- package/dist/searchscore.js +5 -5
- package/dist/searchtypo.js +30 -10
- package/dist/seo.d.ts +2 -2
- package/dist/seo.js +14 -14
- package/dist/shortcodes.d.ts +4 -4
- package/dist/shortcodes.js +25 -20
- package/dist/sitemap.js +18 -8
- package/dist/snippets.js +26 -18
- package/dist/source.js +75 -41
- package/dist/stats.d.ts +4 -4
- package/dist/stats.js +18 -12
- package/dist/testing.d.ts +7 -7
- package/dist/testing.js +74 -29
- package/dist/themeutil.d.ts +6 -6
- package/dist/themeutil.js +145 -27
- package/dist/typegen.js +31 -12
- package/dist/validate.js +19 -7
- package/dist/validator.d.ts +11 -11
- package/dist/validator.js +68 -19
- package/dist/versioning.d.ts +7 -7
- package/dist/versioning.js +27 -11
- package/dist/watcher.js +39 -15
- package/dist/webhook.d.ts +6 -6
- package/dist/webhook.js +34 -12
- package/dist/workspace.js +26 -12
- package/package.json +137 -137
- 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
|
-
|
|
14
|
+
accentColor: config.accentColor,
|
|
15
15
|
description: config.description,
|
|
16
|
-
|
|
16
|
+
height: String(height),
|
|
17
17
|
logo: config.logo,
|
|
18
|
+
siteName: config.siteName,
|
|
18
19
|
theme: config.theme,
|
|
19
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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"
|
|
54
|
-
{ property: "og:image:width"
|
|
55
|
-
{ property: "og:image:height"
|
|
56
|
-
{ property: "og:image:alt"
|
|
57
|
-
{
|
|
58
|
-
{ name: "twitter:image"
|
|
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 = [
|
|
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))
|
|
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)))
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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)
|
|
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))
|
|
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
|
-
|
|
67
|
+
content: resolveContent(root, resolved.content),
|
|
49
68
|
description: typeof resolved.description === "string" ? resolved.description : void 0,
|
|
50
|
-
|
|
69
|
+
status
|
|
51
70
|
};
|
|
52
71
|
});
|
|
53
72
|
const rank = (status) => {
|
|
54
|
-
if (status === "default")
|
|
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)
|
|
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))
|
|
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
|
|
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)
|
|
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
|
-
|
|
96
|
-
|
|
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
|
-
|
|
136
|
-
tags: extractTags(root, endpoints)
|
|
137
|
-
schemas: extractSchemas(root)
|
|
163
|
+
schemas: extractSchemas(root),
|
|
164
|
+
tags: extractTags(root, endpoints)
|
|
138
165
|
};
|
|
139
166
|
}
|
|
140
167
|
|
package/dist/openapiguard.js
CHANGED
|
@@ -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))
|
|
19
|
+
if (!Array.isArray(value)) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
20
22
|
return value.flatMap((item) => {
|
|
21
23
|
const input = torecord(item);
|
|
22
|
-
if (!input)
|
|
24
|
+
if (!input) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
23
27
|
const name = totext(input.name);
|
|
24
|
-
if (!name || name.length === 0)
|
|
25
|
-
|
|
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)
|
|
39
|
+
if (!input) {
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
34
42
|
const schemas = torecord(input.schemas);
|
|
35
|
-
if (!schemas)
|
|
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 = {
|
package/dist/openapiutil.js
CHANGED
|
@@ -1,40 +1,70 @@
|
|
|
1
1
|
function generateEndpointSlug(method, path) {
|
|
2
|
-
return `${method.toLowerCase()}-${path.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("#/"))
|
|
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))
|
|
15
|
+
if (!isrecord(current)) {
|
|
16
|
+
return {};
|
|
17
|
+
}
|
|
14
18
|
current = current[part];
|
|
15
|
-
if (current === void 0)
|
|
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)
|
|
21
|
-
|
|
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))
|
|
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")
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (typeof raw.
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
if (
|
|
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(
|
|
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)
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
if (Array.isArray(raw.
|
|
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))
|
|
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))
|
|
13
|
-
|
|
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
|
-
|
|
26
|
+
path: getstring(value.path),
|
|
25
27
|
score: getnumber(value.score),
|
|
26
|
-
|
|
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))
|
|
31
|
-
|
|
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
|
-
|
|
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)
|
|
59
|
+
if (!slug || !title) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
52
62
|
return {
|
|
63
|
+
anchor: source.anchor,
|
|
53
64
|
doc: normalize({
|
|
54
|
-
|
|
55
|
-
title,
|
|
65
|
+
content: source.content ?? "",
|
|
56
66
|
description: source.description,
|
|
57
|
-
|
|
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)
|
|
79
|
+
if (!value) {
|
|
80
|
+
return fallback(docs, limit);
|
|
81
|
+
}
|
|
70
82
|
const response = await fetch(config.endpoint, {
|
|
71
|
-
|
|
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
|
-
|
|
78
|
-
query: value,
|
|
79
|
-
term: value,
|
|
80
|
-
limit,
|
|
81
|
-
index: config.index
|
|
82
|
-
})
|
|
94
|
+
method: "POST"
|
|
83
95
|
});
|
|
84
|
-
if (!response.ok)
|
|
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)
|
|
104
|
+
if (!hit) {
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
91
107
|
const item = maphit(hit, i, hits.length);
|
|
92
|
-
if (item)
|
|
108
|
+
if (item) {
|
|
109
|
+
result.push(item);
|
|
110
|
+
}
|
|
93
111
|
}
|
|
94
112
|
return result;
|
|
95
113
|
}
|
package/dist/pipeline.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4
|
-
|
|
3
|
+
href: `/docs/${slug}`,
|
|
4
|
+
rel: "prefetch"
|
|
5
5
|
};
|
|
6
6
|
}
|
|
7
7
|
function preloadSearch() {
|
|
8
8
|
return {
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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[];
|