react-lib-tools 0.0.38 → 0.0.40

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 (31) hide show
  1. package/dist/{CommonQuestionsRoute-Bi0vu3D0.cjs → CommonQuestionsRoute-BaUo7C5J.cjs} +2 -2
  2. package/dist/{CommonQuestionsRoute-Bi0vu3D0.cjs.map → CommonQuestionsRoute-BaUo7C5J.cjs.map} +1 -1
  3. package/dist/{CommonQuestionsRoute-BtHS1T3T.js → CommonQuestionsRoute-xnhbeLos.js} +2 -2
  4. package/dist/{CommonQuestionsRoute-BtHS1T3T.js.map → CommonQuestionsRoute-xnhbeLos.js.map} +1 -1
  5. package/dist/{GettingStartedRoute-Dh1xOg49.cjs → GettingStartedRoute-Caqc6Q58.cjs} +2 -2
  6. package/dist/{GettingStartedRoute-Dh1xOg49.cjs.map → GettingStartedRoute-Caqc6Q58.cjs.map} +1 -1
  7. package/dist/{GettingStartedRoute-vgWrIv_N.js → GettingStartedRoute-Cp6EFnMw.js} +2 -2
  8. package/dist/{GettingStartedRoute-vgWrIv_N.js.map → GettingStartedRoute-Cp6EFnMw.js.map} +1 -1
  9. package/dist/{PageNotFound-bzcasFul.cjs → PageNotFound-7zWg_AHz.cjs} +2 -2
  10. package/dist/{PageNotFound-bzcasFul.cjs.map → PageNotFound-7zWg_AHz.cjs.map} +1 -1
  11. package/dist/{PageNotFound-C293MV0R.js → PageNotFound-CB141q5L.js} +2 -2
  12. package/dist/{PageNotFound-C293MV0R.js.map → PageNotFound-CB141q5L.js.map} +1 -1
  13. package/dist/{SupportRoute-st_mJ-Mf.js → SupportRoute-BdQqhjzf.js} +2 -2
  14. package/dist/{SupportRoute-st_mJ-Mf.js.map → SupportRoute-BdQqhjzf.js.map} +1 -1
  15. package/dist/{SupportRoute-BxMpPywd.cjs → SupportRoute-CIsa-DtE.cjs} +2 -2
  16. package/dist/{SupportRoute-BxMpPywd.cjs.map → SupportRoute-CIsa-DtE.cjs.map} +1 -1
  17. package/dist/{VersionsRoute-0EYAk1l2.cjs → VersionsRoute-5s8sUTHm.cjs} +2 -2
  18. package/dist/{VersionsRoute-0EYAk1l2.cjs.map → VersionsRoute-5s8sUTHm.cjs.map} +1 -1
  19. package/dist/{VersionsRoute-CVwjE2Vw.js → VersionsRoute-BuGTWWLr.js} +2 -2
  20. package/dist/{VersionsRoute-CVwjE2Vw.js.map → VersionsRoute-BuGTWWLr.js.map} +1 -1
  21. package/dist/{index-zTJyJcqQ.js → index-Cpw2WkF7.js} +1328 -1289
  22. package/dist/{index-zTJyJcqQ.js.map → index-Cpw2WkF7.js.map} +1 -1
  23. package/dist/{index-B187mzi5.cjs → index-rOOr2GGh.cjs} +5 -5
  24. package/dist/{index-B187mzi5.cjs.map → index-rOOr2GGh.cjs.map} +1 -1
  25. package/dist/react-lib-tools.cjs +1 -1
  26. package/dist/react-lib-tools.d.ts +2 -1
  27. package/dist/react-lib-tools.js +1 -1
  28. package/package.json +1 -1
  29. package/scripts/compile-search-index.ts +3 -0
  30. package/scripts/utils/search/crawlPage.ts +33 -13
  31. package/styles.css +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-B187mzi5.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-rOOr2GGh.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
@@ -15,8 +15,9 @@ import { ReactNode } from 'react';
15
15
  /**
16
16
  * Displays an application shell with desktop and mobile layouts.
17
17
  */
18
- export declare function AppRoot({ navLinks, routes, ...context }: {
18
+ export declare function AppRoot({ enableSiteSearch, navLinks, routes, ...context }: {
19
19
  commonQuestions?: CommonQuestion[];
20
+ enableSiteSearch?: boolean | undefined;
20
21
  navLinks: ReactNode;
21
22
  overview?: ReactNode | undefined;
22
23
  packageDescription: string;
@@ -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-zTJyJcqQ.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-Cpw2WkF7.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.38",
3
+ "version": "0.0.40",
4
4
  "type": "module",
5
5
  "author": "Brian Vaughn <brian.david.vaughn@gmail.com> (https://github.com/bvaughn/)",
6
6
  "contributors": [
@@ -6,15 +6,18 @@ import { crawlPage } from "./utils/search/crawlPage";
6
6
  import type { SiteSearchPage } from "./utils/search/types";
7
7
 
8
8
  export async function compileSearchIndex({
9
+ filterSelector,
9
10
  host = "http://localhost:3000",
10
11
  outputPath = ["public", "generated"]
11
12
  }: {
13
+ filterSelector?: string | undefined;
12
14
  host?: string;
13
15
  outputPath?: string[];
14
16
  } = {}) {
15
17
  const recordsMap: Record<string, SiteSearchPage> = {};
16
18
 
17
19
  await crawlPage({
20
+ filterSelector,
18
21
  host,
19
22
  path: "/",
20
23
  records: recordsMap
@@ -3,19 +3,29 @@ import { stopWords } from "./stopWords";
3
3
  import type { SiteSearchPage } from "./types";
4
4
 
5
5
  export async function crawlPage({
6
+ filterSelector,
6
7
  host,
7
8
  path,
8
9
  records
9
10
  }: {
11
+ filterSelector?: string | undefined;
10
12
  host: string;
11
13
  path: string;
12
14
  records: Record<string, SiteSearchPage>;
13
15
  }) {
14
16
  console.log(`Crawling ${host}${path} ...`);
15
17
 
16
- const browser = await puppeteer.launch({
17
- headless: true
18
- });
18
+ const executablePath = process.env.CHROME_PATH;
19
+ const browser = await puppeteer.launch(
20
+ executablePath
21
+ ? {
22
+ executablePath,
23
+ headless: true
24
+ }
25
+ : {
26
+ headless: true
27
+ }
28
+ );
19
29
 
20
30
  const page = await browser.newPage();
21
31
 
@@ -24,7 +34,7 @@ export async function crawlPage({
24
34
  await page.waitForSelector("main");
25
35
 
26
36
  const result = await page.evaluate(
27
- async ([stopWords]) => {
37
+ async ([filterSelector, stopWords]) => {
28
38
  const paths: string[] = [];
29
39
  for (const element of document.body.querySelectorAll("[data-link]")) {
30
40
  const to = element.getAttribute("data-link");
@@ -40,12 +50,13 @@ export async function crawlPage({
40
50
  document.body.querySelector("header [data-title]")?.textContent ?? "";
41
51
 
42
52
  const words = new Set<string>();
53
+ const texts: string[] = [];
43
54
 
44
55
  const main = document.body.querySelector("header")?.parentElement;
45
56
  if (main) {
46
57
  for (const child of main.children) {
47
58
  switch (child.tagName) {
48
- case "CODE":
59
+ // case "CODE":
49
60
  case "HEADER": {
50
61
  continue;
51
62
  }
@@ -55,29 +66,37 @@ export async function crawlPage({
55
66
  continue;
56
67
  }
57
68
 
58
- child.textContent?.split(/[\s.:]/).forEach((word) => {
59
- word = word.trim().toLowerCase();
60
- if (word && !stopWords.includes(word)) {
61
- words.add(word);
62
- }
63
- });
69
+ if (filterSelector && child.querySelector(filterSelector)) {
70
+ continue;
71
+ }
72
+
73
+ if (child.textContent) {
74
+ texts.push(child.textContent);
75
+ child.textContent.split(/[\s.:]/).forEach((word) => {
76
+ word = word.trim().toLowerCase();
77
+ if (word && !stopWords.includes(word)) {
78
+ words.add(word);
79
+ }
80
+ });
81
+ }
64
82
  }
65
83
  }
66
84
 
67
85
  return {
68
86
  paths,
69
87
  section,
88
+ text: texts.join(" "),
70
89
  title,
71
90
  words: Array.from(words)
72
91
  };
73
92
  },
74
- [stopWords]
93
+ [filterSelector, stopWords] as const
75
94
  );
76
95
 
77
96
  records[path] = {
78
97
  path,
79
98
  section: result.section,
80
- text: result.words.join(" "),
99
+ text: result.text,
81
100
  title: result.title
82
101
  };
83
102
 
@@ -92,6 +111,7 @@ export async function crawlPage({
92
111
  };
93
112
 
94
113
  return crawlPage({
114
+ filterSelector,
95
115
  host,
96
116
  path: current,
97
117
  records
package/styles.css CHANGED
@@ -37,8 +37,8 @@
37
37
  --color-header-icons: var(--color-white);
38
38
 
39
39
  --color-data-focus: var(--color-sky-300);
40
- --color-link: var(--color-sky-400);
41
40
  --color-data-focus-bold: var(--color-sky-600);
41
+ --color-link: var(--color-sky-400);
42
42
 
43
43
  --color-nav-active: var(--color-fuchsia-400);
44
44
  --color-nav-hover: var(--color-fuchsia-200);