react-lib-tools 0.0.47 → 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.
Files changed (37) hide show
  1. package/dist/{CommonQuestionsRoute-vsAObCFT.cjs → CommonQuestionsRoute-C7Dvx_8D.cjs} +2 -2
  2. package/dist/{CommonQuestionsRoute-vsAObCFT.cjs.map → CommonQuestionsRoute-C7Dvx_8D.cjs.map} +1 -1
  3. package/dist/{CommonQuestionsRoute-BA4ZhMTe.js → CommonQuestionsRoute-CRSNF0Pf.js} +2 -2
  4. package/dist/{CommonQuestionsRoute-BA4ZhMTe.js.map → CommonQuestionsRoute-CRSNF0Pf.js.map} +1 -1
  5. package/dist/{GettingStartedRoute-D144jL7r.cjs → GettingStartedRoute-BKH20xPD.cjs} +2 -2
  6. package/dist/{GettingStartedRoute-D144jL7r.cjs.map → GettingStartedRoute-BKH20xPD.cjs.map} +1 -1
  7. package/dist/{GettingStartedRoute-C1eEI6XL.js → GettingStartedRoute-CnQSytXZ.js} +2 -2
  8. package/dist/{GettingStartedRoute-C1eEI6XL.js.map → GettingStartedRoute-CnQSytXZ.js.map} +1 -1
  9. package/dist/{PageNotFound-CU9uqnRi.js → PageNotFound-0sTGJQpW.js} +2 -2
  10. package/dist/{PageNotFound-CU9uqnRi.js.map → PageNotFound-0sTGJQpW.js.map} +1 -1
  11. package/dist/{PageNotFound-CGbDPOsm.cjs → PageNotFound-BP1q3mAm.cjs} +2 -2
  12. package/dist/{PageNotFound-CGbDPOsm.cjs.map → PageNotFound-BP1q3mAm.cjs.map} +1 -1
  13. package/dist/{SupportRoute-D907jHET.js → SupportRoute-B70W0nGt.js} +2 -2
  14. package/dist/{SupportRoute-D907jHET.js.map → SupportRoute-B70W0nGt.js.map} +1 -1
  15. package/dist/{SupportRoute-BJbK64__.cjs → SupportRoute-DJ8l10dE.cjs} +2 -2
  16. package/dist/{SupportRoute-BJbK64__.cjs.map → SupportRoute-DJ8l10dE.cjs.map} +1 -1
  17. package/dist/{VersionsRoute-ahVJDsum.cjs → VersionsRoute-B9OjVQl5.cjs} +2 -2
  18. package/dist/{VersionsRoute-ahVJDsum.cjs.map → VersionsRoute-B9OjVQl5.cjs.map} +1 -1
  19. package/dist/{VersionsRoute-CXRx1ZeN.js → VersionsRoute-BDTmCVHk.js} +2 -2
  20. package/dist/{VersionsRoute-CXRx1ZeN.js.map → VersionsRoute-BDTmCVHk.js.map} +1 -1
  21. package/dist/{index-DwdhsbJr.cjs → index-D8_W9HHv.cjs} +2 -2
  22. package/dist/index-D8_W9HHv.cjs.map +1 -0
  23. package/dist/{index-DHqKf7uc.js → index-DjmISh76.js} +364 -351
  24. package/dist/index-DjmISh76.js.map +1 -0
  25. package/dist/react-lib-tools.cjs +1 -1
  26. package/dist/react-lib-tools.js +1 -1
  27. package/package.json +1 -2
  28. package/scripts/compile-search-index.ts +5 -19
  29. package/scripts/utils/search/crawlPage.ts +28 -28
  30. package/dist/fuse-BvOe6mNx.js +0 -1023
  31. package/dist/fuse-BvOe6mNx.js.map +0 -1
  32. package/dist/fuse-CM2wbN_z.cjs +0 -2
  33. package/dist/fuse-CM2wbN_z.cjs.map +0 -1
  34. package/dist/index-DHqKf7uc.js.map +0 -1
  35. package/dist/index-DwdhsbJr.cjs.map +0 -1
  36. package/scripts/utils/search/stopWords.ts +0 -129
  37. package/scripts/utils/search/types.ts +0 -6
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-DwdhsbJr.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;
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
@@ -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-DHqKf7uc.js";
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.47",
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 { SiteSearchRecord } from "react-lib-tools";
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 recordsMap: Record<string, SiteSearchPage> = {};
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
- records: recordsMap
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, `search-index.json`),
54
- JSON.stringify(searchIndex, null, 2)
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
- records
10
+ siteMap
12
11
  }: {
13
12
  chromeExecutablePath?: string | undefined;
14
13
  filterSelector?: string | undefined;
15
14
  host: string;
16
15
  path: string;
17
- records: Record<string, SiteSearchPage>;
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 ([filterSelector, stopWords]) => {
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
- "&amp;": "&",
81
- "&lt;": "<",
82
- "&gt;": ">",
83
- "&quot;": '"',
84
- "&#039;": "'",
85
- "&ndash;": "-",
86
- "&nbsp;": " "
87
- };
88
83
  for (const chars in HTML_ENTITIES) {
89
84
  text = text.replaceAll(chars, HTML_ENTITIES[chars]);
90
85
  }
91
86
 
92
- text.split(/[\s.:?]/).forEach((word) => {
93
- word = word.trim().toLowerCase();
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
- [filterSelector, stopWords] as const
98
+ [HTML_ENTITIES, filterSelector] as const
109
99
  );
110
100
 
111
- records[path] = {
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 (!records[current]) {
120
- records[current] = {
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
- records
130
+ siteMap
141
131
  })
142
132
  )
143
133
  );
144
134
  }
135
+
136
+ const HTML_ENTITIES: { [chars: string]: string } = {
137
+ "&amp;": "&",
138
+ "&lt;": "<",
139
+ "&gt;": ">",
140
+ "&quot;": '"',
141
+ "&#039;": "'",
142
+ "&ndash;": "-",
143
+ "&nbsp;": " "
144
+ };