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/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)
|
|
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)
|
|
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)
|
|
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)
|
|
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
|
-
|
|
114
|
-
|
|
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
|
-
|
|
123
|
-
|
|
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)
|
|
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)
|
|
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(
|
|
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)
|
|
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))
|
|
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)
|
|
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)
|
|
248
|
+
if (cached) {
|
|
249
|
+
return cached;
|
|
250
|
+
}
|
|
229
251
|
const listed = await list();
|
|
230
|
-
const values = await maplimit(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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)
|
|
273
|
+
if (!item) {
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
246
276
|
docs.push(item);
|
|
247
277
|
}
|
|
248
278
|
searchCache.set("search", docs);
|
package/dist/gitsource.d.ts
CHANGED
|
@@ -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(
|
|
14
|
-
|
|
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)
|
|
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 {
|
|
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
|
-
|
|
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.
|
|
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
|
-
|
|
1
|
+
interface ContentHash {
|
|
2
2
|
path: string;
|
|
3
3
|
hash: string;
|
|
4
4
|
size: number;
|
|
5
|
-
}
|
|
6
|
-
|
|
5
|
+
}
|
|
6
|
+
interface HashManifest {
|
|
7
7
|
generated: string;
|
|
8
8
|
hashes: ContentHash[];
|
|
9
|
-
}
|
|
10
|
-
|
|
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([
|
|
17
|
-
|
|
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))
|
|
50
|
-
|
|
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))
|
|
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)
|
|
67
|
+
if (!match) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
60
70
|
const body = match[1];
|
|
61
|
-
if (!body)
|
|
71
|
+
if (!body) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
62
74
|
return fnv1a(body);
|
|
63
75
|
}
|
|
64
76
|
|
package/dist/highlight.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
interface HighlightResult {
|
|
2
2
|
text: string;
|
|
3
3
|
ranges: {
|
|
4
4
|
start: number;
|
|
5
5
|
end: number;
|
|
6
6
|
}[];
|
|
7
|
-
}
|
|
8
|
-
|
|
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.
|
|
2
|
+
return t.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">");
|
|
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)
|
|
12
|
-
|
|
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 {
|
|
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)
|
|
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)
|
|
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)
|
|
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)
|
|
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)
|
|
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)
|
|
75
|
+
if (nearest === -1 || !match) {
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
64
78
|
result.push(escape(text.slice(last, nearest)));
|
|
65
|
-
result.push(
|
|
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)
|
|
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)
|
|
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 {
|
|
107
|
+
return { ranges, text };
|
|
88
108
|
}
|
|
89
109
|
|
|
90
110
|
export { fuzzyHighlight, generateSnippet, highlightHtml, highlightMatches, tokenize };
|
package/dist/hooks/anchor.js
CHANGED
|
@@ -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))
|
|
9
|
-
|
|
8
|
+
if (!(e.target instanceof Element)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const { target } = e;
|
|
10
12
|
const anchor = target.closest("a");
|
|
11
|
-
if (!anchor)
|
|
13
|
+
if (!anchor) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
12
16
|
const href = anchor.getAttribute("href");
|
|
13
|
-
if (!href?.startsWith("#"))
|
|
17
|
+
if (!href?.startsWith("#")) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
14
20
|
const id = href.slice(1);
|
|
15
|
-
const element = document.
|
|
16
|
-
if (!element)
|
|
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
|
-
|
|
21
|
-
|
|
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
|
|
30
|
-
if (!hash)
|
|
37
|
+
const { hash } = window.location;
|
|
38
|
+
if (!hash) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
31
41
|
const id = hash.slice(1);
|
|
32
|
-
const element = document.
|
|
33
|
-
if (!element)
|
|
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
|
-
|
|
38
|
-
|
|
49
|
+
behavior: "auto",
|
|
50
|
+
top: Math.max(0, top)
|
|
39
51
|
});
|
|
40
52
|
}, 100);
|
|
41
53
|
}, [offset]);
|
package/dist/hooks/arrownav.js
CHANGED
|
@@ -1,25 +1,43 @@
|
|
|
1
1
|
function getNextIndex(key, options) {
|
|
2
|
-
const {
|
|
3
|
-
|
|
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)
|
|
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))
|
|
14
|
-
|
|
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))
|
|
22
|
-
|
|
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
|
}
|
package/dist/hooks/async.js
CHANGED
|
@@ -14,15 +14,15 @@ function useAsync(fn) {
|
|
|
14
14
|
setData(result);
|
|
15
15
|
setLoading(false);
|
|
16
16
|
return result;
|
|
17
|
-
} catch (
|
|
18
|
-
setError(
|
|
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,
|
|
25
|
+
return { data, error, execute, loading };
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export { useAsync };
|
package/dist/hooks/battery.js
CHANGED
|
@@ -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")
|
|
12
|
+
if (typeof navigator === "undefined" || typeof nav.getBattery !== "function") {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
13
15
|
let battery = null;
|
|
14
16
|
const update = () => {
|
|
15
|
-
if (!battery)
|
|
16
|
-
|
|
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;
|
package/dist/hooks/breakpoint.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
2
|
|
|
3
|
-
const defaults = {
|
|
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)
|
|
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
|
|
9
|
-
if (!(target instanceof Node))
|
|
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(
|
|
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({
|
|
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 =
|
|
10
|
-
setData({
|
|
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);
|