react-lib-tools 0.0.48 → 0.0.49
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-B4bBnTyv.cjs → CommonQuestionsRoute-C7Dvx_8D.cjs} +2 -2
- package/dist/{CommonQuestionsRoute-B4bBnTyv.cjs.map → CommonQuestionsRoute-C7Dvx_8D.cjs.map} +1 -1
- package/dist/{CommonQuestionsRoute-Batfohax.js → CommonQuestionsRoute-CRSNF0Pf.js} +2 -2
- package/dist/{CommonQuestionsRoute-Batfohax.js.map → CommonQuestionsRoute-CRSNF0Pf.js.map} +1 -1
- package/dist/{GettingStartedRoute-eV1Gvnp5.cjs → GettingStartedRoute-BKH20xPD.cjs} +2 -2
- package/dist/{GettingStartedRoute-eV1Gvnp5.cjs.map → GettingStartedRoute-BKH20xPD.cjs.map} +1 -1
- package/dist/{GettingStartedRoute-CRNXqZFq.js → GettingStartedRoute-CnQSytXZ.js} +2 -2
- package/dist/{GettingStartedRoute-CRNXqZFq.js.map → GettingStartedRoute-CnQSytXZ.js.map} +1 -1
- package/dist/{PageNotFound-qGDSWCcK.js → PageNotFound-0sTGJQpW.js} +2 -2
- package/dist/{PageNotFound-qGDSWCcK.js.map → PageNotFound-0sTGJQpW.js.map} +1 -1
- package/dist/{PageNotFound-DdwZ_HlO.cjs → PageNotFound-BP1q3mAm.cjs} +2 -2
- package/dist/{PageNotFound-DdwZ_HlO.cjs.map → PageNotFound-BP1q3mAm.cjs.map} +1 -1
- package/dist/{SupportRoute-BI1UlEjB.js → SupportRoute-B70W0nGt.js} +2 -2
- package/dist/{SupportRoute-BI1UlEjB.js.map → SupportRoute-B70W0nGt.js.map} +1 -1
- package/dist/{SupportRoute-C4AyaiIN.cjs → SupportRoute-DJ8l10dE.cjs} +2 -2
- package/dist/{SupportRoute-C4AyaiIN.cjs.map → SupportRoute-DJ8l10dE.cjs.map} +1 -1
- package/dist/{VersionsRoute-DSiHKAu2.cjs → VersionsRoute-B9OjVQl5.cjs} +2 -2
- package/dist/{VersionsRoute-DSiHKAu2.cjs.map → VersionsRoute-B9OjVQl5.cjs.map} +1 -1
- package/dist/{VersionsRoute-DFEViErJ.js → VersionsRoute-BDTmCVHk.js} +2 -2
- package/dist/{VersionsRoute-DFEViErJ.js.map → VersionsRoute-BDTmCVHk.js.map} +1 -1
- package/dist/{index-r-XtNIqq.cjs → index-D8_W9HHv.cjs} +2 -2
- package/dist/index-D8_W9HHv.cjs.map +1 -0
- package/dist/{index-glKzZg5t.js → index-DjmISh76.js} +87 -99
- package/dist/index-DjmISh76.js.map +1 -0
- package/dist/react-lib-tools.cjs +1 -1
- package/dist/react-lib-tools.js +1 -1
- package/package.json +1 -2
- package/scripts/compile-search-index.ts +5 -19
- package/scripts/utils/search/crawlPage.ts +28 -28
- package/dist/fuse-BvOe6mNx.js +0 -1023
- package/dist/fuse-BvOe6mNx.js.map +0 -1
- package/dist/fuse-CM2wbN_z.cjs +0 -2
- package/dist/fuse-CM2wbN_z.cjs.map +0 -1
- package/dist/index-glKzZg5t.js.map +0 -1
- package/dist/index-r-XtNIqq.cjs.map +0 -1
- package/scripts/utils/search/stopWords.ts +0 -129
- package/scripts/utils/search/types.ts +0 -6
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-D8_W9HHv.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
|
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-DjmISh76.js";
|
|
2
2
|
export {
|
|
3
3
|
o as AppRoot,
|
|
4
4
|
e as Block,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-lib-tools",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.49",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "Brian Vaughn <brian.david.vaughn@gmail.com> (https://github.com/bvaughn/)",
|
|
6
6
|
"contributors": [
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
"@codemirror/state": "^6.5.3",
|
|
53
53
|
"@lezer/highlight": "^1.2.3",
|
|
54
54
|
"@ts-ast-parser/core": "^0.8.0",
|
|
55
|
-
"fuse.js": "^7.1.0",
|
|
56
55
|
"puppeteer": "^24.38.0"
|
|
57
56
|
},
|
|
58
57
|
"devDependencies": {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import Fuse from "fuse.js";
|
|
2
1
|
import { writeFile } from "node:fs/promises";
|
|
3
2
|
import { join } from "node:path";
|
|
4
|
-
import type {
|
|
3
|
+
import type { SiteMapPage } from "../types";
|
|
5
4
|
import { crawlPage } from "./utils/search/crawlPage";
|
|
6
5
|
import { scheduleWork } from "./utils/search/scheduleWork";
|
|
7
|
-
import type { SiteSearchPage } from "./utils/search/types";
|
|
8
6
|
import { waitForConnection } from "./utils/search/waitForConnection";
|
|
9
7
|
|
|
10
8
|
export async function compileSearchIndex({
|
|
@@ -18,7 +16,7 @@ export async function compileSearchIndex({
|
|
|
18
16
|
host?: string;
|
|
19
17
|
outputPath?: string[];
|
|
20
18
|
} = {}) {
|
|
21
|
-
const
|
|
19
|
+
const siteMap: Record<string, SiteMapPage> = {};
|
|
22
20
|
|
|
23
21
|
const url = new URL(host);
|
|
24
22
|
|
|
@@ -33,24 +31,12 @@ export async function compileSearchIndex({
|
|
|
33
31
|
filterSelector,
|
|
34
32
|
host,
|
|
35
33
|
path: "/",
|
|
36
|
-
|
|
34
|
+
siteMap
|
|
37
35
|
})
|
|
38
36
|
);
|
|
39
37
|
|
|
40
|
-
const records = Object.values(recordsMap);
|
|
41
|
-
|
|
42
|
-
const searchIndex = Fuse.createIndex<SiteSearchRecord>(
|
|
43
|
-
["title", "section", "text"],
|
|
44
|
-
records
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
await writeFile(
|
|
48
|
-
join(...outputPath, `search-records.json`),
|
|
49
|
-
JSON.stringify(records, null, 2)
|
|
50
|
-
);
|
|
51
|
-
|
|
52
38
|
await writeFile(
|
|
53
|
-
join(...outputPath, `
|
|
54
|
-
JSON.stringify(
|
|
39
|
+
join(...outputPath, `site-map.json`),
|
|
40
|
+
JSON.stringify(Object.values(siteMap), null, 2)
|
|
55
41
|
);
|
|
56
42
|
}
|
|
@@ -1,20 +1,19 @@
|
|
|
1
1
|
import puppeteer from "puppeteer";
|
|
2
|
+
import type { SiteMapPage } from "../../../types";
|
|
2
3
|
import { scheduleWork } from "./scheduleWork";
|
|
3
|
-
import { stopWords } from "./stopWords";
|
|
4
|
-
import type { SiteSearchPage } from "./types";
|
|
5
4
|
|
|
6
5
|
export async function crawlPage({
|
|
7
6
|
chromeExecutablePath,
|
|
8
7
|
filterSelector,
|
|
9
8
|
host,
|
|
10
9
|
path,
|
|
11
|
-
|
|
10
|
+
siteMap
|
|
12
11
|
}: {
|
|
13
12
|
chromeExecutablePath?: string | undefined;
|
|
14
13
|
filterSelector?: string | undefined;
|
|
15
14
|
host: string;
|
|
16
15
|
path: string;
|
|
17
|
-
|
|
16
|
+
siteMap: Record<string, SiteMapPage>;
|
|
18
17
|
}) {
|
|
19
18
|
console.log(`Crawling ${host}${path} ...`);
|
|
20
19
|
|
|
@@ -39,7 +38,7 @@ export async function crawlPage({
|
|
|
39
38
|
page.on("console", (event) => console.log(event.text()));
|
|
40
39
|
|
|
41
40
|
const result = await page.evaluate(
|
|
42
|
-
async ([
|
|
41
|
+
async ([HTML_ENTITIES, filterSelector]) => {
|
|
43
42
|
const paths: string[] = [];
|
|
44
43
|
for (const element of document.body.querySelectorAll("[data-link]")) {
|
|
45
44
|
const to = element.getAttribute("data-link");
|
|
@@ -54,11 +53,16 @@ export async function crawlPage({
|
|
|
54
53
|
const title =
|
|
55
54
|
document.body.querySelector("header [data-title]")?.textContent ?? "";
|
|
56
55
|
|
|
57
|
-
const words = new Set<string>();
|
|
58
56
|
let text = "";
|
|
59
57
|
|
|
60
58
|
const main = document.body.querySelector("[data-main-scrollable]");
|
|
61
59
|
if (main) {
|
|
60
|
+
// Pre-convert content inside of <code> blocks (example code) into plain text
|
|
61
|
+
for (const code of main.querySelectorAll("code")) {
|
|
62
|
+
// eslint-disable-next-line no-self-assign
|
|
63
|
+
code.textContent = code.textContent;
|
|
64
|
+
}
|
|
65
|
+
|
|
62
66
|
text = main.innerHTML;
|
|
63
67
|
|
|
64
68
|
// Filter out special content (e.g. lorem ipsum type text)
|
|
@@ -76,39 +80,25 @@ export async function crawlPage({
|
|
|
76
80
|
text = text.replaceAll(/<[^>]+>/g, "");
|
|
77
81
|
|
|
78
82
|
// Replace HTML entities
|
|
79
|
-
const HTML_ENTITIES: { [chars: string]: string } = {
|
|
80
|
-
"&": "&",
|
|
81
|
-
"<": "<",
|
|
82
|
-
">": ">",
|
|
83
|
-
""": '"',
|
|
84
|
-
"'": "'",
|
|
85
|
-
"–": "-",
|
|
86
|
-
" ": " "
|
|
87
|
-
};
|
|
88
83
|
for (const chars in HTML_ENTITIES) {
|
|
89
84
|
text = text.replaceAll(chars, HTML_ENTITIES[chars]);
|
|
90
85
|
}
|
|
91
86
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (word && !stopWords.includes(word)) {
|
|
95
|
-
words.add(word);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
87
|
+
// Remove excess white space
|
|
88
|
+
text = text.replaceAll(/ {2,}/g, " ");
|
|
98
89
|
}
|
|
99
90
|
|
|
100
91
|
return {
|
|
101
92
|
paths,
|
|
102
93
|
section,
|
|
103
94
|
text,
|
|
104
|
-
title
|
|
105
|
-
words: Array.from(words)
|
|
95
|
+
title
|
|
106
96
|
};
|
|
107
97
|
},
|
|
108
|
-
[
|
|
98
|
+
[HTML_ENTITIES, filterSelector] as const
|
|
109
99
|
);
|
|
110
100
|
|
|
111
|
-
|
|
101
|
+
siteMap[path] = {
|
|
112
102
|
path,
|
|
113
103
|
section: result.section,
|
|
114
104
|
text: result.text,
|
|
@@ -116,8 +106,8 @@ export async function crawlPage({
|
|
|
116
106
|
};
|
|
117
107
|
|
|
118
108
|
const filteredPaths = result.paths.filter((current) => {
|
|
119
|
-
if (!
|
|
120
|
-
|
|
109
|
+
if (!siteMap[current]) {
|
|
110
|
+
siteMap[current] = {
|
|
121
111
|
path: current,
|
|
122
112
|
text: "",
|
|
123
113
|
title: ""
|
|
@@ -137,8 +127,18 @@ export async function crawlPage({
|
|
|
137
127
|
filterSelector,
|
|
138
128
|
host,
|
|
139
129
|
path: current,
|
|
140
|
-
|
|
130
|
+
siteMap
|
|
141
131
|
})
|
|
142
132
|
)
|
|
143
133
|
);
|
|
144
134
|
}
|
|
135
|
+
|
|
136
|
+
const HTML_ENTITIES: { [chars: string]: string } = {
|
|
137
|
+
"&": "&",
|
|
138
|
+
"<": "<",
|
|
139
|
+
">": ">",
|
|
140
|
+
""": '"',
|
|
141
|
+
"'": "'",
|
|
142
|
+
"–": "-",
|
|
143
|
+
" ": " "
|
|
144
|
+
};
|