react-lib-tools 0.0.34 → 0.0.36
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/{CommonQuestionsRoute-DmRskZnY.js → CommonQuestionsRoute-BwwqUJyI.js} +2 -2
- package/dist/{CommonQuestionsRoute-DmRskZnY.js.map → CommonQuestionsRoute-BwwqUJyI.js.map} +1 -1
- package/dist/{CommonQuestionsRoute-woOvTCB7.cjs → CommonQuestionsRoute-sImKiGx8.cjs} +2 -2
- package/dist/{CommonQuestionsRoute-woOvTCB7.cjs.map → CommonQuestionsRoute-sImKiGx8.cjs.map} +1 -1
- package/dist/{GettingStartedRoute-BwCE2V2M.js → GettingStartedRoute-ClJU7JcL.js} +2 -2
- package/dist/{GettingStartedRoute-BwCE2V2M.js.map → GettingStartedRoute-ClJU7JcL.js.map} +1 -1
- package/dist/{GettingStartedRoute-Bo5SxNiA.cjs → GettingStartedRoute-tyikH6yS.cjs} +2 -2
- package/dist/{GettingStartedRoute-Bo5SxNiA.cjs.map → GettingStartedRoute-tyikH6yS.cjs.map} +1 -1
- package/dist/{PageNotFound-yp0rd76-.cjs → PageNotFound-CSDM7qet.cjs} +2 -2
- package/dist/{PageNotFound-yp0rd76-.cjs.map → PageNotFound-CSDM7qet.cjs.map} +1 -1
- package/dist/{PageNotFound-Do-frKwc.js → PageNotFound-ibjIlKwX.js} +2 -2
- package/dist/{PageNotFound-Do-frKwc.js.map → PageNotFound-ibjIlKwX.js.map} +1 -1
- package/dist/{SupportRoute-DEqnIuv0.js → SupportRoute-BWxqeS9G.js} +2 -2
- package/dist/{SupportRoute-DEqnIuv0.js.map → SupportRoute-BWxqeS9G.js.map} +1 -1
- package/dist/{SupportRoute-Q9tiVrsw.cjs → SupportRoute-CaVQtANn.cjs} +2 -2
- package/dist/{SupportRoute-Q9tiVrsw.cjs.map → SupportRoute-CaVQtANn.cjs.map} +1 -1
- package/dist/{VersionsRoute-CQdZrZ85.js → VersionsRoute-CRPHJWuY.js} +2 -2
- package/dist/{VersionsRoute-CQdZrZ85.js.map → VersionsRoute-CRPHJWuY.js.map} +1 -1
- package/dist/{VersionsRoute-DJ7l0bVC.cjs → VersionsRoute-s9kvgKZE.cjs} +2 -2
- package/dist/{VersionsRoute-DJ7l0bVC.cjs.map → VersionsRoute-s9kvgKZE.cjs.map} +1 -1
- package/dist/fuse-BvOe6mNx.js +1023 -0
- package/dist/fuse-BvOe6mNx.js.map +1 -0
- package/dist/fuse-CM2wbN_z.cjs +2 -0
- package/dist/fuse-CM2wbN_z.cjs.map +1 -0
- package/dist/index-D_pov2Kn.cjs +8 -0
- package/dist/index-D_pov2Kn.cjs.map +1 -0
- package/dist/{index-BeyKcpAG.js → index-DbkaDE2f.js} +2773 -2446
- package/dist/index-DbkaDE2f.js.map +1 -0
- package/dist/react-lib-tools.cjs +1 -1
- package/dist/react-lib-tools.d.ts +13 -4
- package/dist/react-lib-tools.js +1 -1
- package/lib/types.ts +6 -0
- package/package.json +5 -4
- package/scripts/compile-search-index.ts +39 -0
- package/scripts/utils/search/crawlPage.ts +103 -0
- package/scripts/utils/search/stopWords.ts +129 -0
- package/scripts/utils/search/types.ts +6 -0
- package/dist/index-8LP1ujuh.cjs +0 -8
- package/dist/index-8LP1ujuh.cjs.map +0 -1
- package/dist/index-BeyKcpAG.js.map +0 -1
package/dist/react-lib-tools.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-D_pov2Kn.cjs");exports.AppRoot=o.AppRoot;exports.Block=o.Block;exports.Box=o.Box;exports.Button=o.Button;exports.Callout=o.Callout;exports.Checkbox=o.Checkbox;exports.Code=o.Code;exports.ComponentProps=o.ComponentProps;exports.ComponentPropsSection=o.ComponentPropsSection;exports.DocsSection=o.DocsSection;exports.ErrorBoundary=o.ErrorBoundary;exports.ExternalLink=o.ExternalLink;exports.Header=o.Header;exports.ImperativeHandle=o.ImperativeHandle;exports.Input=o.Input;exports.Link=o.Link;exports.LoadingSpinner=o.LoadingSpinner;exports.NavLink=o.NavLink;exports.NavSection=o.NavSection;exports.Radio=o.Radio;exports.Select=o.Select;exports.Tooltip=o.Tooltip;exports.assert=o.assert;exports.cn=o.cn;exports.getIntentClassNames=o.getIntentClassNames;
|
|
2
2
|
//# sourceMappingURL=react-lib-tools.cjs.map
|
|
@@ -8,13 +8,14 @@ import { JSX } from 'react/jsx-runtime';
|
|
|
8
8
|
import { KeyboardEvent as KeyboardEvent_2 } from 'react';
|
|
9
9
|
import { LazyExoticComponent } from 'react';
|
|
10
10
|
import { MouseEvent as MouseEvent_2 } from 'react';
|
|
11
|
+
import { Placement } from '@floating-ui/react';
|
|
11
12
|
import { PropsWithChildren } from 'react';
|
|
12
13
|
import { ReactNode } from 'react';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Displays an application shell with desktop and mobile layouts.
|
|
16
17
|
*/
|
|
17
|
-
export declare function AppRoot({
|
|
18
|
+
export declare function AppRoot({ navLinks, routes, ...context }: {
|
|
18
19
|
commonQuestions?: CommonQuestion[];
|
|
19
20
|
navLinks: ReactNode;
|
|
20
21
|
overview?: ReactNode | undefined;
|
|
@@ -162,9 +163,9 @@ export declare function Link({ children, onClick, to, ...rest }: Omit<HTMLAttrib
|
|
|
162
163
|
|
|
163
164
|
export declare function LoadingSpinner(): JSX.Element;
|
|
164
165
|
|
|
165
|
-
export declare function NavLink({ children, className, path }: PropsWithChildren<{
|
|
166
|
+
export declare function NavLink<Path extends string = DefaultPath>({ children, className, path }: PropsWithChildren<{
|
|
166
167
|
className?: string | undefined;
|
|
167
|
-
path:
|
|
168
|
+
path: Path;
|
|
168
169
|
}>): JSX.Element;
|
|
169
170
|
|
|
170
171
|
export declare function NavSection({ children, label }: PropsWithChildren<{
|
|
@@ -217,13 +218,21 @@ export declare function Select<Value extends string>({ className, defaultValue,
|
|
|
217
218
|
value: Option_2<Value> | undefined;
|
|
218
219
|
}): JSX.Element;
|
|
219
220
|
|
|
221
|
+
export declare type SiteSearchRecord = {
|
|
222
|
+
path: string;
|
|
223
|
+
section?: string | undefined;
|
|
224
|
+
title: string;
|
|
225
|
+
};
|
|
226
|
+
|
|
220
227
|
declare function SupportRoute(): JSX.Element;
|
|
221
228
|
|
|
222
|
-
export declare function Tooltip({ children, className, content, showOnFocus, showOnHover }: PropsWithChildren<{
|
|
229
|
+
export declare function Tooltip({ children, className, content, positions, showOnFocus, showOnHover, usePortal }: PropsWithChildren<{
|
|
223
230
|
className?: string;
|
|
224
231
|
content: ReactNode;
|
|
232
|
+
positions?: Array<Placement> | undefined;
|
|
225
233
|
showOnFocus?: boolean;
|
|
226
234
|
showOnHover?: boolean;
|
|
235
|
+
usePortal?: boolean;
|
|
227
236
|
}>): JSX.Element;
|
|
228
237
|
|
|
229
238
|
declare type Versions = {
|
package/dist/react-lib-tools.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as o, a as e, B as n, b as t, C as r, c as i, d as p, i as c, j as l, D as d, e as C, E as k, H as m, I as B, f as L, L as S, g as u, N as x, h as I, R as N, k as g, T as v, l as E, m as H, n as R } from "./index-
|
|
1
|
+
import { A as o, a as e, B as n, b as t, C as r, c as i, d as p, i as c, j as l, D as d, e as C, E as k, H as m, I as B, f as L, L as S, g as u, N as x, h as I, R as N, k as g, T as v, l as E, m as H, n as R } from "./index-DbkaDE2f.js";
|
|
2
2
|
export {
|
|
3
3
|
o as AppRoot,
|
|
4
4
|
e as Block,
|
package/lib/types.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-lib-tools",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Brian Vaughn <brian.david.vaughn@gmail.com> (https://github.com/bvaughn/)",
|
|
6
6
|
"contributors": [
|
|
@@ -51,7 +51,8 @@
|
|
|
51
51
|
"@codemirror/language": "^6.12.1",
|
|
52
52
|
"@codemirror/state": "^6.5.3",
|
|
53
53
|
"@lezer/highlight": "^1.2.3",
|
|
54
|
-
"@ts-ast-parser/core": "^0.8.0"
|
|
54
|
+
"@ts-ast-parser/core": "^0.8.0",
|
|
55
|
+
"fuse.js": "^7.1.0"
|
|
55
56
|
},
|
|
56
57
|
"devDependencies": {
|
|
57
58
|
"@csstools/postcss-oklab-function": "^4.0.11",
|
|
@@ -91,6 +92,7 @@
|
|
|
91
92
|
"postcss": "^8.5.6",
|
|
92
93
|
"prettier": "3.6.2",
|
|
93
94
|
"prettier-plugin-tailwindcss": "^0.7.1",
|
|
95
|
+
"puppeteer": "^24.38.0",
|
|
94
96
|
"react": "^19.2.3",
|
|
95
97
|
"react-docgen-typescript": "^2.4.0",
|
|
96
98
|
"react-dom": "^19.2.3",
|
|
@@ -113,7 +115,6 @@
|
|
|
113
115
|
"vite-plugin-dts": "^4.5.4",
|
|
114
116
|
"vite-plugin-svgr": "^4.3.0",
|
|
115
117
|
"vitest": "^3.2.4",
|
|
116
|
-
"vitest-fail-on-console": "^0.10.1"
|
|
117
|
-
"zustand": "^5.0.7"
|
|
118
|
+
"vitest-fail-on-console": "^0.10.1"
|
|
118
119
|
}
|
|
119
120
|
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import Fuse from "fuse.js";
|
|
2
|
+
import { writeFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import type { SiteSearchRecord } from "react-lib-tools";
|
|
5
|
+
import { crawlPage } from "./utils/search/crawlPage";
|
|
6
|
+
import type { SiteSearchPage } from "./utils/search/types";
|
|
7
|
+
|
|
8
|
+
export async function compileSearchIndex({
|
|
9
|
+
host = "http://localhost:3000",
|
|
10
|
+
outputPath = ["public", "generated"]
|
|
11
|
+
}: {
|
|
12
|
+
host?: string;
|
|
13
|
+
outputPath?: string[];
|
|
14
|
+
} = {}) {
|
|
15
|
+
const recordsMap: Record<string, SiteSearchPage> = {};
|
|
16
|
+
|
|
17
|
+
await crawlPage({
|
|
18
|
+
host,
|
|
19
|
+
path: "/",
|
|
20
|
+
records: recordsMap
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const records = Object.values(recordsMap);
|
|
24
|
+
|
|
25
|
+
const searchIndex = Fuse.createIndex<SiteSearchRecord>(
|
|
26
|
+
["title", "section", "text"],
|
|
27
|
+
records
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
await writeFile(
|
|
31
|
+
join(...outputPath, `search-records.json`),
|
|
32
|
+
JSON.stringify(records, null, 2)
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
await writeFile(
|
|
36
|
+
join(...outputPath, `search-index.json`),
|
|
37
|
+
JSON.stringify(searchIndex, null, 2)
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import puppeteer from "puppeteer";
|
|
2
|
+
import { stopWords } from "./stopWords";
|
|
3
|
+
import type { SiteSearchPage } from "./types";
|
|
4
|
+
|
|
5
|
+
export async function crawlPage({
|
|
6
|
+
host,
|
|
7
|
+
path,
|
|
8
|
+
records
|
|
9
|
+
}: {
|
|
10
|
+
host: string;
|
|
11
|
+
path: string;
|
|
12
|
+
records: Record<string, SiteSearchPage>;
|
|
13
|
+
}) {
|
|
14
|
+
console.log(`Crawling ${host}${path} ...`);
|
|
15
|
+
|
|
16
|
+
const browser = await puppeteer.launch({
|
|
17
|
+
headless: true
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const page = await browser.newPage();
|
|
21
|
+
|
|
22
|
+
// Navigate the page to a URL.
|
|
23
|
+
await page.goto(`${host}${path}`);
|
|
24
|
+
await page.waitForSelector("main");
|
|
25
|
+
|
|
26
|
+
const result = await page.evaluate(
|
|
27
|
+
async ([stopWords]) => {
|
|
28
|
+
const paths: string[] = [];
|
|
29
|
+
for (const element of document.body.querySelectorAll("[data-link]")) {
|
|
30
|
+
const to = element.getAttribute("data-link");
|
|
31
|
+
if (to) {
|
|
32
|
+
paths.push(to.split("#")[0]);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const section =
|
|
37
|
+
document.body.querySelector("header [data-section]")?.textContent ||
|
|
38
|
+
undefined;
|
|
39
|
+
const title =
|
|
40
|
+
document.body.querySelector("header [data-title]")?.textContent ?? "";
|
|
41
|
+
|
|
42
|
+
const words = new Set<string>();
|
|
43
|
+
|
|
44
|
+
const main = document.body.querySelector("header")?.parentElement;
|
|
45
|
+
if (main) {
|
|
46
|
+
for (const child of main.children) {
|
|
47
|
+
switch (child.tagName) {
|
|
48
|
+
case "CODE":
|
|
49
|
+
case "HEADER": {
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (child.hasAttribute("data-demo")) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
child.textContent?.split(/[\s.:]/).forEach((word) => {
|
|
59
|
+
word = word.trim().toLowerCase();
|
|
60
|
+
if (word && !stopWords.includes(word)) {
|
|
61
|
+
words.add(word);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
paths,
|
|
69
|
+
section,
|
|
70
|
+
title,
|
|
71
|
+
words: Array.from(words)
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
[stopWords]
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
records[path] = {
|
|
78
|
+
path,
|
|
79
|
+
section: result.section,
|
|
80
|
+
text: result.words.join(" "),
|
|
81
|
+
title: result.title
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
await Promise.all(
|
|
85
|
+
result.paths
|
|
86
|
+
.filter((current) => !records[current])
|
|
87
|
+
.map((current) => {
|
|
88
|
+
records[current] = {
|
|
89
|
+
path: current,
|
|
90
|
+
text: "",
|
|
91
|
+
title: ""
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return crawlPage({
|
|
95
|
+
host,
|
|
96
|
+
path: current,
|
|
97
|
+
records
|
|
98
|
+
});
|
|
99
|
+
})
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
await browser.close();
|
|
103
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
export const stopWords = [
|
|
2
|
+
"a",
|
|
3
|
+
"about",
|
|
4
|
+
"above",
|
|
5
|
+
"after",
|
|
6
|
+
"again",
|
|
7
|
+
"against",
|
|
8
|
+
"all",
|
|
9
|
+
"am",
|
|
10
|
+
"an",
|
|
11
|
+
"and",
|
|
12
|
+
"any",
|
|
13
|
+
"are",
|
|
14
|
+
"as",
|
|
15
|
+
"at",
|
|
16
|
+
"be",
|
|
17
|
+
"because",
|
|
18
|
+
"been",
|
|
19
|
+
"before",
|
|
20
|
+
"being",
|
|
21
|
+
"below",
|
|
22
|
+
"between",
|
|
23
|
+
"both",
|
|
24
|
+
"but",
|
|
25
|
+
"by",
|
|
26
|
+
"can",
|
|
27
|
+
"did",
|
|
28
|
+
"do",
|
|
29
|
+
"does",
|
|
30
|
+
"doing",
|
|
31
|
+
"don",
|
|
32
|
+
"down",
|
|
33
|
+
"during",
|
|
34
|
+
"each",
|
|
35
|
+
"few",
|
|
36
|
+
"for",
|
|
37
|
+
"from",
|
|
38
|
+
"further",
|
|
39
|
+
"had",
|
|
40
|
+
"has",
|
|
41
|
+
"have",
|
|
42
|
+
"having",
|
|
43
|
+
"he",
|
|
44
|
+
"her",
|
|
45
|
+
"here",
|
|
46
|
+
"hers",
|
|
47
|
+
"herself",
|
|
48
|
+
"him",
|
|
49
|
+
"himself",
|
|
50
|
+
"his",
|
|
51
|
+
"how",
|
|
52
|
+
"i",
|
|
53
|
+
"if",
|
|
54
|
+
"in",
|
|
55
|
+
"into",
|
|
56
|
+
"is",
|
|
57
|
+
"it",
|
|
58
|
+
"its",
|
|
59
|
+
"itself",
|
|
60
|
+
"just",
|
|
61
|
+
"me",
|
|
62
|
+
"more",
|
|
63
|
+
"most",
|
|
64
|
+
"my",
|
|
65
|
+
"myself",
|
|
66
|
+
"no",
|
|
67
|
+
"nor",
|
|
68
|
+
"not",
|
|
69
|
+
"now",
|
|
70
|
+
"of",
|
|
71
|
+
"off",
|
|
72
|
+
"on",
|
|
73
|
+
"once",
|
|
74
|
+
"only",
|
|
75
|
+
"or",
|
|
76
|
+
"other",
|
|
77
|
+
"our",
|
|
78
|
+
"ours",
|
|
79
|
+
"ourselves",
|
|
80
|
+
"out",
|
|
81
|
+
"over",
|
|
82
|
+
"own",
|
|
83
|
+
"s",
|
|
84
|
+
"same",
|
|
85
|
+
"she",
|
|
86
|
+
"should",
|
|
87
|
+
"so",
|
|
88
|
+
"some",
|
|
89
|
+
"such",
|
|
90
|
+
"t",
|
|
91
|
+
"than",
|
|
92
|
+
"that",
|
|
93
|
+
"the",
|
|
94
|
+
"their",
|
|
95
|
+
"theirs",
|
|
96
|
+
"them",
|
|
97
|
+
"themselves",
|
|
98
|
+
"then",
|
|
99
|
+
"there",
|
|
100
|
+
"these",
|
|
101
|
+
"they",
|
|
102
|
+
"this",
|
|
103
|
+
"those",
|
|
104
|
+
"through",
|
|
105
|
+
"to",
|
|
106
|
+
"too",
|
|
107
|
+
"under",
|
|
108
|
+
"until",
|
|
109
|
+
"up",
|
|
110
|
+
"very",
|
|
111
|
+
"was",
|
|
112
|
+
"we",
|
|
113
|
+
"were",
|
|
114
|
+
"what",
|
|
115
|
+
"when",
|
|
116
|
+
"where",
|
|
117
|
+
"which",
|
|
118
|
+
"while",
|
|
119
|
+
"who",
|
|
120
|
+
"whom",
|
|
121
|
+
"why",
|
|
122
|
+
"will",
|
|
123
|
+
"with",
|
|
124
|
+
"you",
|
|
125
|
+
"your",
|
|
126
|
+
"yours",
|
|
127
|
+
"yourself",
|
|
128
|
+
"yourselves"
|
|
129
|
+
];
|