react-lib-tools 0.0.37 → 0.0.39

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-sImKiGx8.cjs → CommonQuestionsRoute-DKgVI5bf.cjs} +2 -2
  2. package/dist/{CommonQuestionsRoute-sImKiGx8.cjs.map → CommonQuestionsRoute-DKgVI5bf.cjs.map} +1 -1
  3. package/dist/{CommonQuestionsRoute-BwwqUJyI.js → CommonQuestionsRoute-XeGPl1Yz.js} +2 -2
  4. package/dist/{CommonQuestionsRoute-BwwqUJyI.js.map → CommonQuestionsRoute-XeGPl1Yz.js.map} +1 -1
  5. package/dist/{GettingStartedRoute-ClJU7JcL.js → GettingStartedRoute-B1_jfqKR.js} +2 -2
  6. package/dist/{GettingStartedRoute-ClJU7JcL.js.map → GettingStartedRoute-B1_jfqKR.js.map} +1 -1
  7. package/dist/{GettingStartedRoute-tyikH6yS.cjs → GettingStartedRoute-Dj9vAFwF.cjs} +2 -2
  8. package/dist/{GettingStartedRoute-tyikH6yS.cjs.map → GettingStartedRoute-Dj9vAFwF.cjs.map} +1 -1
  9. package/dist/{PageNotFound-ibjIlKwX.js → PageNotFound-BcpV_MGp.js} +2 -2
  10. package/dist/{PageNotFound-ibjIlKwX.js.map → PageNotFound-BcpV_MGp.js.map} +1 -1
  11. package/dist/{PageNotFound-CSDM7qet.cjs → PageNotFound-pPQgf0wT.cjs} +2 -2
  12. package/dist/{PageNotFound-CSDM7qet.cjs.map → PageNotFound-pPQgf0wT.cjs.map} +1 -1
  13. package/dist/{SupportRoute-CaVQtANn.cjs → SupportRoute-BbSurNA_.cjs} +2 -2
  14. package/dist/{SupportRoute-CaVQtANn.cjs.map → SupportRoute-BbSurNA_.cjs.map} +1 -1
  15. package/dist/{SupportRoute-BWxqeS9G.js → SupportRoute-CxxAV1Mo.js} +2 -2
  16. package/dist/{SupportRoute-BWxqeS9G.js.map → SupportRoute-CxxAV1Mo.js.map} +1 -1
  17. package/dist/{VersionsRoute-CRPHJWuY.js → VersionsRoute-CeLRC38k.js} +2 -2
  18. package/dist/{VersionsRoute-CRPHJWuY.js.map → VersionsRoute-CeLRC38k.js.map} +1 -1
  19. package/dist/{VersionsRoute-s9kvgKZE.cjs → VersionsRoute-DpDr0_Rf.cjs} +2 -2
  20. package/dist/{VersionsRoute-s9kvgKZE.cjs.map → VersionsRoute-DpDr0_Rf.cjs.map} +1 -1
  21. package/dist/{index-DbkaDE2f.js → index-5mMRCwy2.js} +1328 -1289
  22. package/dist/{index-DbkaDE2f.js.map → index-5mMRCwy2.js.map} +1 -1
  23. package/dist/{index-D_pov2Kn.cjs → index-BWhTJgvX.cjs} +5 -5
  24. package/dist/{index-D_pov2Kn.cjs.map → index-BWhTJgvX.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 +2 -1
  29. package/scripts/compile-search-index.ts +13 -0
  30. package/scripts/utils/search/crawlPage.ts +22 -10
  31. package/styles.css +1 -1
@@ -1,2 +1,2 @@
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;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./index-BWhTJgvX.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-DbkaDE2f.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-5mMRCwy2.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.37",
3
+ "version": "0.0.39",
4
4
  "type": "module",
5
5
  "author": "Brian Vaughn <brian.david.vaughn@gmail.com> (https://github.com/bvaughn/)",
6
6
  "contributors": [
@@ -62,6 +62,7 @@
62
62
  "@headlessui/react": "^2.2.4",
63
63
  "@headlessui/tailwindcss": "^0.2.2",
64
64
  "@heroicons/react": "^2.2.0",
65
+ "@puppeteer/browsers": "^2.13.0",
65
66
  "@tailwindcss/vite": "^4.1.11",
66
67
  "@tailwindplus/elements": "^1.0.5",
67
68
  "@testing-library/jest-dom": "^6.6.4",
@@ -1,3 +1,4 @@
1
+ import { Browser, BrowserPlatform, install } from "@puppeteer/browsers";
1
2
  import Fuse from "fuse.js";
2
3
  import { writeFile } from "node:fs/promises";
3
4
  import { join } from "node:path";
@@ -6,15 +7,27 @@ import { crawlPage } from "./utils/search/crawlPage";
6
7
  import type { SiteSearchPage } from "./utils/search/types";
7
8
 
8
9
  export async function compileSearchIndex({
10
+ filterSelector,
9
11
  host = "http://localhost:3000",
10
12
  outputPath = ["public", "generated"]
11
13
  }: {
14
+ filterSelector?: string | undefined;
12
15
  host?: string;
13
16
  outputPath?: string[];
14
17
  } = {}) {
15
18
  const recordsMap: Record<string, SiteSearchPage> = {};
16
19
 
20
+ console.log("Installing browsers ...");
21
+
22
+ await install({
23
+ browser: Browser.CHROME,
24
+ buildId: "120.0.6099.109",
25
+ platform: BrowserPlatform.LINUX,
26
+ cacheDir: "/tmp/puppeteer-cache"
27
+ });
28
+
17
29
  await crawlPage({
30
+ filterSelector,
18
31
  host,
19
32
  path: "/",
20
33
  records: recordsMap
@@ -3,10 +3,12 @@ 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>;
@@ -24,7 +26,7 @@ export async function crawlPage({
24
26
  await page.waitForSelector("main");
25
27
 
26
28
  const result = await page.evaluate(
27
- async ([stopWords]) => {
29
+ async ([filterSelector, stopWords]) => {
28
30
  const paths: string[] = [];
29
31
  for (const element of document.body.querySelectorAll("[data-link]")) {
30
32
  const to = element.getAttribute("data-link");
@@ -40,12 +42,13 @@ export async function crawlPage({
40
42
  document.body.querySelector("header [data-title]")?.textContent ?? "";
41
43
 
42
44
  const words = new Set<string>();
45
+ const texts: string[] = [];
43
46
 
44
47
  const main = document.body.querySelector("header")?.parentElement;
45
48
  if (main) {
46
49
  for (const child of main.children) {
47
50
  switch (child.tagName) {
48
- case "CODE":
51
+ // case "CODE":
49
52
  case "HEADER": {
50
53
  continue;
51
54
  }
@@ -55,29 +58,37 @@ export async function crawlPage({
55
58
  continue;
56
59
  }
57
60
 
58
- child.textContent?.split(/[\s.:]/).forEach((word) => {
59
- word = word.trim().toLowerCase();
60
- if (word && !stopWords.includes(word)) {
61
- words.add(word);
62
- }
63
- });
61
+ if (filterSelector && child.querySelector(filterSelector)) {
62
+ continue;
63
+ }
64
+
65
+ if (child.textContent) {
66
+ texts.push(child.textContent);
67
+ child.textContent.split(/[\s.:]/).forEach((word) => {
68
+ word = word.trim().toLowerCase();
69
+ if (word && !stopWords.includes(word)) {
70
+ words.add(word);
71
+ }
72
+ });
73
+ }
64
74
  }
65
75
  }
66
76
 
67
77
  return {
68
78
  paths,
69
79
  section,
80
+ text: texts.join(" "),
70
81
  title,
71
82
  words: Array.from(words)
72
83
  };
73
84
  },
74
- [stopWords]
85
+ [filterSelector, stopWords] as const
75
86
  );
76
87
 
77
88
  records[path] = {
78
89
  path,
79
90
  section: result.section,
80
- text: result.words.join(" "),
91
+ text: result.text,
81
92
  title: result.title
82
93
  };
83
94
 
@@ -92,6 +103,7 @@ export async function crawlPage({
92
103
  };
93
104
 
94
105
  return crawlPage({
106
+ filterSelector,
95
107
  host,
96
108
  path: current,
97
109
  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);