elseware-docs-engine 1.3.0 → 1.3.1

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 (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +7 -6
  3. package/dist/components/docs-page-renderer/DocsPageRenderer.d.ts +6 -0
  4. package/dist/components/docs-page-renderer/DocsPageRenderer.d.ts.map +1 -0
  5. package/dist/components/index.d.ts +3 -0
  6. package/dist/components/index.d.ts.map +1 -0
  7. package/dist/context/DocsContext.d.ts +7 -0
  8. package/dist/context/DocsContext.d.ts.map +1 -0
  9. package/dist/context/DocsProvider.d.ts +10 -0
  10. package/dist/context/DocsProvider.d.ts.map +1 -0
  11. package/dist/context/index.d.ts +3 -0
  12. package/dist/context/index.d.ts.map +1 -0
  13. package/dist/engine/DocsEngine.d.ts +10 -0
  14. package/dist/engine/DocsEngine.d.ts.map +1 -0
  15. package/dist/engine/index.d.ts +3 -0
  16. package/dist/engine/index.d.ts.map +1 -0
  17. package/dist/hooks/index.d.ts +6 -0
  18. package/dist/hooks/index.d.ts.map +1 -0
  19. package/dist/hooks/useCurrentDocsSection.d.ts +2 -0
  20. package/dist/hooks/useCurrentDocsSection.d.ts.map +1 -0
  21. package/dist/hooks/useCurrentPage.d.ts +6 -0
  22. package/dist/hooks/useCurrentPage.d.ts.map +1 -0
  23. package/dist/hooks/useDocs.d.ts +2 -0
  24. package/dist/hooks/useDocs.d.ts.map +1 -0
  25. package/dist/hooks/useScopedSidebar.d.ts +2 -0
  26. package/dist/hooks/useScopedSidebar.d.ts.map +1 -0
  27. package/dist/hooks/useSidebar.d.ts +2 -0
  28. package/dist/hooks/useSidebar.d.ts.map +1 -0
  29. package/dist/index.css +6 -1
  30. package/dist/index.css.map +1 -1
  31. package/dist/index.d.ts +10 -73
  32. package/dist/index.d.ts.map +1 -0
  33. package/dist/index.js +2 -2
  34. package/dist/index.js.map +1 -1
  35. package/dist/index.mjs +2 -2
  36. package/dist/index.mjs.map +1 -1
  37. package/dist/router/generateDocsRoutes.d.ts +9 -0
  38. package/dist/router/generateDocsRoutes.d.ts.map +1 -0
  39. package/dist/router/index.d.ts +2 -0
  40. package/dist/router/index.d.ts.map +1 -0
  41. package/dist/types/docs.d.ts +12 -0
  42. package/dist/types/docs.d.ts.map +1 -0
  43. package/dist/types/index.d.ts +2 -0
  44. package/dist/types/index.d.ts.map +1 -0
  45. package/dist/utils/docs.d.ts +10 -0
  46. package/dist/utils/docs.d.ts.map +1 -0
  47. package/dist/utils/index.d.ts +4 -0
  48. package/dist/utils/index.d.ts.map +1 -0
  49. package/dist/utils/path.d.ts +5 -0
  50. package/dist/utils/path.d.ts.map +1 -0
  51. package/dist/utils/sidebar.d.ts +4 -0
  52. package/dist/utils/sidebar.d.ts.map +1 -0
  53. package/package.json +19 -19
  54. package/dist/index.d.mts +0 -73
package/dist/index.d.ts CHANGED
@@ -1,73 +1,10 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as react from 'react';
3
- import { ReactNode } from 'react';
4
- import * as elseware_ui from 'elseware-ui';
5
- import { MenuNode } from 'elseware-ui';
6
- import { RouteObject } from 'react-router-dom';
7
-
8
- interface DocsPageRendererProps {
9
- content: string;
10
- }
11
- declare function DocsPageRenderer({ content }: DocsPageRendererProps): react_jsx_runtime.JSX.Element;
12
-
13
- interface DocsPage {
14
- title: string;
15
- path: string;
16
- content: string;
17
- }
18
- interface DocsCategory {
19
- title: string;
20
- path: string;
21
- children: DocsNode[];
22
- }
23
- type DocsNode = DocsCategory | DocsPage;
24
-
25
- interface DocsContextType {
26
- docs: DocsCategory[];
27
- basePath: string;
28
- }
29
- declare const DocsContext: react.Context<DocsContextType | undefined>;
30
-
31
- interface DocsEngineProps {
32
- docs: DocsCategory[];
33
- basePath?: string;
34
- children: ReactNode;
35
- }
36
- declare function DocsEngine({ docs, basePath, children }: DocsEngineProps): react_jsx_runtime.JSX.Element;
37
-
38
- declare function useCurrentDocsSection(): DocsCategory | undefined;
39
-
40
- interface UseCurrentPageProps {
41
- debug?: boolean;
42
- }
43
- declare function useCurrentPage({ debug }?: UseCurrentPageProps): DocsPage | null;
44
-
45
- declare function useDocs(): DocsContextType;
46
-
47
- declare function useScopedSidebar(): elseware_ui.MenuNode[];
48
-
49
- declare function useSidebar(): elseware_ui.MenuNode[];
50
-
51
- interface GenerateDocsRoutesProps {
52
- basePath?: string;
53
- element: ReactNode;
54
- }
55
- declare function generateDocsRoutes({ basePath, element, }: GenerateDocsRoutesProps): RouteObject[];
56
-
57
- interface ResolvedDocsPage extends DocsPage {
58
- id: string;
59
- fullPath: string;
60
- }
61
- declare function isPage(node: DocsNode): node is DocsPage;
62
- declare function findPageByPath(nodes: DocsNode[], targetPath: string, parentPath?: string): DocsPage | null;
63
- declare function resolveDocs(nodes: DocsNode[], parentPath?: string): ResolvedDocsPage[];
64
- declare function findFirstPage(nodes: DocsNode[], parentPath?: string): string | null;
65
-
66
- declare function normalizePath(path: string): string;
67
- declare function normalizeRoutePath(path: string): string;
68
- declare function isPathWithin(path: string, parentPath: string): boolean;
69
- declare function stripBasePath(path: string, basePath: string): string | null;
70
-
71
- declare function generateSidebar(docs: DocsCategory[], basePath: string): MenuNode[];
72
-
73
- export { type DocsCategory, DocsContext, type DocsContextType, DocsEngine, type DocsNode, type DocsPage, DocsPageRenderer, type ResolvedDocsPage, findFirstPage, findPageByPath, generateDocsRoutes, generateSidebar, isPage, isPathWithin, normalizePath, normalizeRoutePath, resolveDocs, stripBasePath, useCurrentDocsSection, useCurrentPage, useDocs, useScopedSidebar, useSidebar };
1
+ import "./styles/index.css";
2
+ import "elseware-ui/styles.css";
3
+ export * from "./components";
4
+ export * from "./context";
5
+ export * from "./engine";
6
+ export * from "./hooks";
7
+ export * from "./router";
8
+ export * from "./types";
9
+ export * from "./utils";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAC5B,OAAO,wBAAwB,CAAC;AAEhC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- 'use strict';require('elseware-ui/styles.css');var elsewareUi=require('elseware-ui'),jsxRuntime=require('react/jsx-runtime'),react=require('react'),reactRouterDom=require('react-router-dom');function x({content:t}){return jsxRuntime.jsx(elsewareUi.DocumentationPanel,{value:t})}var v=x;var c=react.createContext(void 0);function z({docs:t,basePath:o,children:r}){return jsxRuntime.jsx(c.Provider,{value:{docs:t,basePath:o},children:r})}var f=z;function n(t){return "/"+t.replace(/\/+/g,"/").replace(/^\/|\/$/g,"")}function g(t){return t.replace(/^\/+/,"").replace(/\/+$/,"")}function p(t,o){let r=n(t),e=n(o);return e==="/"||r===e||r.startsWith(`${e}/`)}function d(t,o){let r=n(t),e=n(o);return p(r,e)?e==="/"?r:n(r.slice(e.length)):null}function s(t){return "content"in t}function h(t,o,r=""){let e=n(o);for(let i of t){let m=n(`${r}/${i.path}`);if(s(i)){if(m===e)return i}else {let u=h(i.children,o,m);if(u)return u}}return null}function C(t,o=""){let r=[];return t.forEach(e=>{let i=n(`${o}/${e.path}`);if(s(e)){r.push({...e,id:i.replace(/\//g,"-").replace(/^-/,""),fullPath:i});return}r.push(...C(e.children,i));}),r}function R(t,o=""){for(let r of t){let e=n(`${o}/${r.path}`);if(s(r))return e;let i=R(r.children,e);if(i)return i}return null}function b(t,o,r=""){return t.map(e=>{let i=n(`${r}/${e.path}`);return s(e)?{type:"item",name:e.title,to:n(`${o}/${i}`)}:{type:"group",name:e.title,items:b(e.children,o,i)}})}function l(t,o){return b(t,o)}function S({docs:t,basePath:o="/",children:r}){let e=n(o);return jsxRuntime.jsx(f,{docs:t,basePath:e,children:r})}var N=S;function a(){let t=react.useContext(c);if(!t)throw new Error("useDocs must be used within DocsProvider");return t}function w(){let{docs:t,basePath:o}=a(),r=reactRouterDom.useLocation(),e=d(r.pathname,o);if(e)return t.find(i=>p(e,i.path))}function ft({debug:t=false}={}){let{docs:o,basePath:r}=a(),e=reactRouterDom.useLocation(),i=d(e.pathname,r);return t&&(console.log("location.pathname",e.pathname),console.log("basePath",r),console.log("pagePath",i)),i?h(o,i):null}function xt(){let{basePath:t}=a(),o=w();return o?l([o],t):[]}function zt(){let{docs:t,basePath:o}=a();return l(t,o)}function St({basePath:t="/docs",element:o}){return [{path:`${g(t)}/*`,element:o}]}
2
- exports.DocsContext=c;exports.DocsEngine=N;exports.DocsPageRenderer=v;exports.findFirstPage=R;exports.findPageByPath=h;exports.generateDocsRoutes=St;exports.generateSidebar=l;exports.isPage=s;exports.isPathWithin=p;exports.normalizePath=n;exports.normalizeRoutePath=g;exports.resolveDocs=C;exports.stripBasePath=d;exports.useCurrentDocsSection=w;exports.useCurrentPage=ft;exports.useDocs=a;exports.useScopedSidebar=xt;exports.useSidebar=zt;//# sourceMappingURL=index.js.map
1
+ 'use strict';var elsewareUi=require('elseware-ui'),jsxRuntime=require('react/jsx-runtime'),react=require('react'),reactRouterDom=require('react-router-dom');function y({content:r}){return jsxRuntime.jsx(elsewareUi.DocumentationPanel,{value:r})}var k=y;var c=react.createContext(void 0);function _({docs:r,basePath:o,children:e}){return jsxRuntime.jsx(c.Provider,{value:{docs:r,basePath:o},children:e})}var m=_;function i(r){return "/"+r.replace(/\/+/g,"/").replace(/^\/|\/$/g,"")}function h(r){return r.replace(/^\/+/,"").replace(/\/+$/,"")}function p(r,o){let e=i(r),t=i(o);return t==="/"||e===t||e.startsWith(`${t}/`)}function g(r,o){let e=i(r),t=i(o);return p(e,t)?t==="/"?e:i(e.slice(t.length)):null}function n(r){return "content"in r}function s(r,o,e=""){let t=i(o);for(let a of r){let w=i(`${e}/${a.path}`);if(n(a)){if(w===t)return a}else {let l=s(a.children,o,w);if(l)return l}}return null}function P(r,o=""){let e=[];return r.forEach(t=>{let a=i(`${o}/${t.path}`);if(n(t)){e.push({...t,id:a.replace(/\//g,"-").replace(/^-/,""),fullPath:a});return}e.push(...P(t.children,a));}),e}function B(r,o=""){for(let e of r){let t=i(`${o}/${e.path}`);if(n(e))return t;let a=B(e.children,t);if(a)return a}return null}function x(r,o,e=""){return r.map(t=>{let a=i(`${e}/${t.path}`);return n(t)?{type:"item",name:t.title,to:i(`${o}/${a}`)}:{type:"group",name:t.title,items:x(t.children,o,a)}})}function b(r,o){return x(r,o)}function Y({docs:r,basePath:o="/",children:e}){let t=i(o);return jsxRuntime.jsx(m,{docs:r,basePath:t,children:e})}var j=Y;function d(){let r=react.useContext(c);if(!r)throw new Error("useDocs must be used within DocsProvider");return r}function u(){let{docs:r,basePath:o}=d(),e=reactRouterDom.useLocation(),t=g(e.pathname,o);if(t)return r.find(a=>p(t,a.path))}function xr({debug:r=false}={}){let{docs:o,basePath:e}=d(),t=reactRouterDom.useLocation(),a=g(t.pathname,e);return r&&(console.log("location.pathname",t.pathname),console.log("basePath",e),console.log("pagePath",a)),a?s(o,a):null}function fr(){let{basePath:r}=d(),o=u();return o?b([o],r):[]}function Pr(){let{docs:r,basePath:o}=d();return b(r,o)}function Xr({basePath:r="/docs",element:o}){return [{path:`${h(r)}/*`,element:o}]}
2
+ exports.DocsContext=c;exports.DocsEngine=j;exports.DocsPageRenderer=k;exports.findFirstPage=B;exports.findPageByPath=s;exports.generateDocsRoutes=Xr;exports.generateSidebar=b;exports.isPage=n;exports.isPathWithin=p;exports.normalizePath=i;exports.normalizeRoutePath=h;exports.resolveDocs=P;exports.stripBasePath=g;exports.useCurrentDocsSection=u;exports.useCurrentPage=xr;exports.useDocs=d;exports.useScopedSidebar=fr;exports.useSidebar=Pr;//# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/docs-page-renderer/DocsPageRenderer.tsx","../src/context/DocsContext.ts","../src/context/DocsProvider.tsx","../src/utils/path.ts","../src/utils/docs.ts","../src/utils/sidebar.ts","../src/engine/DocsEngine.tsx","../src/hooks/useDocs.ts","../src/hooks/useCurrentDocsSection.ts","../src/hooks/useCurrentPage.ts","../src/hooks/useScopedSidebar.ts","../src/hooks/useSidebar.ts","../src/router/generateDocsRoutes.tsx"],"names":["DocsPageRenderer","content","jsx","DocumentationPanel","DocsPageRenderer_default","DocsContext","createContext","DocsProvider","docs","basePath","children","DocsProvider_default","normalizePath","path","normalizeRoutePath","isPathWithin","parentPath","normalizedPath","normalizedParent","stripBasePath","normalizedBase","isPage","node","findPageByPath","nodes","targetPath","normalizedTarget","currentPath","result","resolveDocs","pages","findFirstPage","child","mapNodes","fullPath","generateSidebar","DocsEngine","normalizedBasePath","DocsEngine_default","useDocs","context","useContext","useCurrentDocsSection","location","useLocation","pagePath","doc","useCurrentPage","debug","useScopedSidebar","section","useSidebar","generateDocsRoutes","element"],"mappings":"+LAMA,SAASA,EAAiB,CAAE,OAAA,CAAAC,CAAQ,CAAA,CAA0B,CAC5D,OAAOC,cAAAA,CAACC,6BAAAA,CAAA,CAAmB,KAAA,CAAOF,CAAAA,CAAS,CAC7C,KAEOG,CAAAA,CAAQJ,ECDR,IAAMK,CAAAA,CAAcC,mBAAAA,CACzB,MACF,ECCA,SAASC,CAAAA,CAAa,CAAE,IAAA,CAAAC,EAAM,QAAA,CAAAC,CAAAA,CAAU,QAAA,CAAAC,CAAS,EAAsB,CACrE,OACER,cAAAA,CAACG,CAAAA,CAAY,SAAZ,CAAqB,KAAA,CAAO,CAAE,IAAA,CAAAG,EAAM,QAAA,CAAAC,CAAS,CAAA,CAC3C,QAAA,CAAAC,EACH,CAEJ,CAEA,IAAOC,CAAAA,CAAQJ,ECpBR,SAASK,CAAAA,CAAcC,CAAAA,CAAsB,CAClD,OAAO,GAAA,CAAMA,CAAAA,CAA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MC,CAAQ,CACvC,CCGO,SAAS2C,GAAmB,CACjC,QAAA,CAAA3C,CAAAA,CAAW,OAAA,CACX,QAAA4C,CACF,CAAA,CAA2C,CAGzC,OAAO,CACL,CACE,IAAA,CAAM,CAAA,EAJavC,CAAAA,CAAmBL,CAAQ,CAIvB,CAAA,EAAA,CAAA,CACvB,OAAA,CAAA4C,CACF,CACF,CACF","file":"index.js","sourcesContent":["import { DocumentationPanel } from \"elseware-ui\";\n\ninterface DocsPageRendererProps {\n content: string;\n}\n\nfunction DocsPageRenderer({ content }: DocsPageRendererProps) {\n return <DocumentationPanel value={content} />;\n}\n\nexport default DocsPageRenderer;\n","import { createContext } from \"react\";\n\nimport { type DocsCategory } from \"../types\";\n\nexport interface DocsContextType {\n docs: DocsCategory[];\n basePath: string;\n}\n\nexport const DocsContext = createContext<DocsContextType | undefined>(\n undefined,\n);\n","import type { ReactNode } from \"react\";\n\nimport { DocsContext } from \"./DocsContext\";\n\nimport { type DocsCategory } from \"../types\";\n\ninterface DocsProviderProps {\n docs: DocsCategory[];\n basePath: string;\n children: ReactNode;\n}\n\nfunction DocsProvider({ docs, basePath, children }: DocsProviderProps) {\n return (\n <DocsContext.Provider value={{ docs, basePath }}>\n {children}\n </DocsContext.Provider>\n );\n}\n\nexport default DocsProvider;\n","export function normalizePath(path: string): string {\n return \"/\" + path.replace(/\\/+/g, \"/\").replace(/^\\/|\\/$/g, \"\");\n}\n\nexport function normalizeRoutePath(path: string): string {\n return path.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n}\n\nexport function isPathWithin(path: string, parentPath: string): boolean {\n const normalizedPath = normalizePath(path);\n const normalizedParent = normalizePath(parentPath);\n\n return (\n normalizedParent === \"/\" ||\n normalizedPath === normalizedParent ||\n normalizedPath.startsWith(`${normalizedParent}/`)\n );\n}\n\nexport function stripBasePath(path: string, basePath: string): string | null {\n const normalizedPath = normalizePath(path);\n const normalizedBase = normalizePath(basePath);\n\n if (!isPathWithin(normalizedPath, normalizedBase)) {\n return null;\n }\n\n if (normalizedBase === \"/\") {\n return normalizedPath;\n }\n\n return normalizePath(normalizedPath.slice(normalizedBase.length));\n}\n","import { type DocsNode, type DocsPage } from \"../types\";\n\nimport { normalizePath } from \"./path\";\n\nexport interface ResolvedDocsPage extends DocsPage {\n id: string;\n fullPath: string;\n}\n\nexport function isPage(node: DocsNode): node is DocsPage {\n return \"content\" in node;\n}\n\nexport function findPageByPath(\n nodes: DocsNode[],\n targetPath: string,\n parentPath = \"\",\n): DocsPage | null {\n const normalizedTarget = normalizePath(targetPath);\n\n for (const node of nodes) {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n if (currentPath === normalizedTarget) {\n return node;\n }\n } else {\n const result = findPageByPath(node.children, targetPath, currentPath);\n\n if (result) {\n return result;\n }\n }\n }\n\n return null;\n}\n\nexport function resolveDocs(\n nodes: DocsNode[],\n parentPath = \"\",\n): ResolvedDocsPage[] {\n const pages: ResolvedDocsPage[] = [];\n\n nodes.forEach((node) => {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n pages.push({\n ...node,\n id: currentPath.replace(/\\//g, \"-\").replace(/^-/, \"\"),\n fullPath: currentPath,\n });\n\n return;\n }\n\n pages.push(...resolveDocs(node.children, currentPath));\n });\n\n return pages;\n}\n\nexport function findFirstPage(\n nodes: DocsNode[],\n parentPath = \"\",\n): string | null {\n for (const node of nodes) {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n return currentPath;\n }\n\n const child = findFirstPage(node.children, currentPath);\n\n if (child) {\n return child;\n }\n }\n\n return null;\n}\n","import { type MenuNode } from \"elseware-ui\";\n\nimport { type DocsCategory, type DocsNode } from \"../types\";\n\nimport { normalizePath } from \"./path\";\n\nimport { isPage } from \"./docs\";\n\nfunction mapNodes(\n nodes: DocsNode[],\n basePath: string,\n parentPath = \"\",\n): MenuNode[] {\n return nodes.map((node) => {\n const fullPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n return {\n type: \"item\",\n name: node.title,\n to: normalizePath(`${basePath}/${fullPath}`),\n };\n }\n\n return {\n type: \"group\",\n name: node.title,\n items: mapNodes(node.children, basePath, fullPath),\n };\n });\n}\n\nexport function generateSidebar(\n docs: DocsCategory[],\n basePath: string,\n): MenuNode[] {\n return mapNodes(docs, basePath);\n}\n","import type { ReactNode } from \"react\";\n\nimport DocsProvider from \"../context/DocsProvider\";\n\nimport { type DocsCategory } from \"../types\";\nimport { normalizePath } from \"../utils\";\n\ninterface DocsEngineProps {\n docs: DocsCategory[];\n basePath?: string;\n children: ReactNode;\n}\n\nfunction DocsEngine({ docs, basePath = \"/\", children }: DocsEngineProps) {\n const normalizedBasePath = normalizePath(basePath);\n\n return (\n <DocsProvider docs={docs} basePath={normalizedBasePath}>\n {children}\n </DocsProvider>\n );\n}\n\nexport default DocsEngine;\n","import { useContext } from \"react\";\n\nimport { DocsContext } from \"../context\";\n\nexport function useDocs() {\n const context = useContext(DocsContext);\n\n if (!context) {\n throw new Error(\"useDocs must be used within DocsProvider\");\n }\n\n return context;\n}\n","import { useLocation } from \"react-router-dom\";\n\nimport { useDocs } from \"./useDocs\";\n\nimport { isPathWithin, stripBasePath } from \"../utils\";\n\nexport function useCurrentDocsSection() {\n const { docs, basePath } = useDocs();\n\n const location = useLocation();\n\n const pagePath = stripBasePath(location.pathname, basePath);\n\n if (!pagePath) {\n return undefined;\n }\n\n return docs.find((doc) => isPathWithin(pagePath, doc.path));\n}\n","import { useLocation } from \"react-router-dom\";\n\nimport { useDocs } from \"./useDocs\";\n\nimport { findPageByPath, stripBasePath } from \"../utils\";\n\ninterface UseCurrentPageProps {\n debug?: boolean;\n}\n\nexport function useCurrentPage({ debug = false }: UseCurrentPageProps = {}) {\n const { docs, basePath } = useDocs();\n\n const location = useLocation();\n\n const pagePath = stripBasePath(location.pathname, basePath);\n\n if (debug) {\n console.log(\"location.pathname\", location.pathname);\n console.log(\"basePath\", basePath);\n console.log(\"pagePath\", pagePath);\n }\n\n if (!pagePath) {\n return null;\n }\n\n return findPageByPath(docs, pagePath);\n}\n","import { generateSidebar } from \"../utils\";\n\nimport { useCurrentDocsSection } from \"./useCurrentDocsSection\";\nimport { useDocs } from \"./useDocs\";\n\nexport function useScopedSidebar() {\n const { basePath } = useDocs();\n\n const section = useCurrentDocsSection();\n\n if (!section) {\n return [];\n }\n\n return generateSidebar([section], basePath);\n}\n","import { generateSidebar } from \"../utils\";\n\nimport { useDocs } from \"./useDocs\";\n\nexport function useSidebar() {\n const { docs, basePath } = useDocs();\n\n return generateSidebar(docs, basePath);\n}\n","import type { ReactNode } from \"react\";\n\nimport { type RouteObject } from \"react-router-dom\";\n\nimport { normalizeRoutePath } from \"../utils\";\n\ninterface GenerateDocsRoutesProps {\n basePath?: string;\n element: ReactNode;\n}\n\nexport function generateDocsRoutes({\n basePath = \"/docs\",\n element,\n}: GenerateDocsRoutesProps): RouteObject[] {\n const normalizedBase = normalizeRoutePath(basePath);\n\n return [\n {\n path: `${normalizedBase}/*`,\n element,\n },\n ];\n}\n"]}
1
+ {"version":3,"sources":["../src/components/docs-page-renderer/DocsPageRenderer.tsx","../src/context/DocsContext.ts","../src/context/DocsProvider.tsx","../src/utils/path.ts","../src/utils/docs.ts","../src/utils/sidebar.ts","../src/engine/DocsEngine.tsx","../src/hooks/useDocs.ts","../src/hooks/useCurrentDocsSection.ts","../src/hooks/useCurrentPage.ts","../src/hooks/useScopedSidebar.ts","../src/hooks/useSidebar.ts","../src/router/generateDocsRoutes.tsx"],"names":["DocsPageRenderer","content","jsx","DocumentationPanel","DocsPageRenderer_default","DocsContext","createContext","DocsProvider","docs","basePath","children","DocsProvider_default","normalizePath","path","normalizeRoutePath","isPathWithin","parentPath","normalizedPath","normalizedParent","stripBasePath","normalizedBase","isPage","node","findPageByPath","nodes","targetPath","normalizedTarget","currentPath","result","resolveDocs","pages","findFirstPage","child","mapNodes","fullPath","generateSidebar","DocsEngine","normalizedBasePath","DocsEngine_default","useDocs","context","useContext","useCurrentDocsSection","location","useLocation","pagePath","doc","useCurrentPage","debug","useScopedSidebar","section","useSidebar","generateDocsRoutes","element"],"mappings":"6JAMA,SAASA,CAAAA,CAAiB,CAAE,QAAAC,CAAQ,CAAA,CAA0B,CAC5D,OAAOC,eAACC,6BAAAA,CAAA,CAAmB,KAAA,CAAOF,CAAAA,CAAS,CAC7C,CAEA,IAAOG,CAAAA,CAAQJ,MCDFK,CAAAA,CAAcC,mBAAAA,CACzB,MACF,ECCA,SAASC,CAAAA,CAAa,CAAE,IAAA,CAAAC,CAAAA,CAAM,QAAA,CAAAC,EAAU,QAAA,CAAAC,CAAS,CAAA,CAAsB,CACrE,OACER,cAAAA,CAACG,CAAAA,CAAY,QAAA,CAAZ,CAAqB,MAAO,CAAE,IAAA,CAAAG,CAAAA,CAAM,QAAA,CAAAC,CAAS,CAAA,CAC3C,QAAA,CAAAC,CAAAA,CACH,CAEJ,CAEA,IAAOC,CAAAA,CAAQJ,CAAAA,CCpBR,SAASK,CAAAA,CAAcC,CAAAA,CAAsB,CAClD,OAAO,IAAMA,CAAAA,CAAK,OAAA,CAAQ,MAAA,CAAQ,GAAG,CAAA,CAAE,OAAA,CAAQ,UAAA,CAAY,EAAE,CAC/D,CAEO,SAASC,CAAAA,CAAmBD,CAAAA,CAAsB,CACvD,OAAOA,CAAAA,CAAK,OAAA,CAAQ,MAAA,CAAQ,EAAE,CAAA,CAAE,OAAA,CAAQ,MAAA,CAAQ,EAAE,CACpD,CAEO,SAASE,CAAAA,CAAaF,EAAcG,CAAAA,CAA6B,CACtE,IAAMC,CAAAA,CAAiBL,EAAcC,CAAI,CAAA,CACnCK,CAAAA,CAAmBN,CAAAA,CAAcI,CAAU,CAAA,CAEjD,OACEE,CAAAA,GAAqB,GAAA,EACrBD,CAAAA,GAAmBC,CAAAA,EACnBD,CAAAA,CAAe,UAAA,CAAW,GAAGC,CAAgB,CAAA,CAAA,CAAG,CAEpD,CAEO,SAASC,CA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XC,CAAAA,CAAW1B,CAAAA,CAAcwB,CAAAA,CAAS,QAAA,CAAUlC,CAAQ,CAAA,CAQ1D,OANIuC,CAAAA,GACF,OAAA,CAAQ,IAAI,mBAAA,CAAqBL,CAAAA,CAAS,QAAQ,CAAA,CAClD,QAAQ,GAAA,CAAI,UAAA,CAAYlC,CAAQ,CAAA,CAChC,QAAQ,GAAA,CAAI,UAAA,CAAYoC,CAAQ,CAAA,CAAA,CAG7BA,CAAAA,CAIEtB,CAAAA,CAAef,CAAAA,CAAMqC,CAAQ,EAH3B,IAIX,CCvBO,SAASI,EAAAA,EAAmB,CACjC,GAAM,CAAE,QAAA,CAAAxC,CAAS,EAAI8B,CAAAA,EAAQ,CAEvBW,CAAAA,CAAUR,CAAAA,EAAsB,CAEtC,OAAKQ,CAAAA,CAIEf,CAAAA,CAAgB,CAACe,CAAO,CAAA,CAAGzC,CAAQ,CAAA,CAHjC,EAIX,CCXO,SAAS0C,EAAAA,EAAa,CAC3B,GAAM,CAAE,IAAA,CAAA3C,CAAAA,CAAM,QAAA,CAAAC,CAAS,CAAA,CAAI8B,CAAAA,GAE3B,OAAOJ,CAAAA,CAAgB3B,CAAAA,CAAMC,CAAQ,CACvC,CCGO,SAAS2C,GAAmB,CACjC,QAAA,CAAA3C,CAAAA,CAAW,OAAA,CACX,QAAA4C,CACF,CAAA,CAA2C,CAGzC,OAAO,CACL,CACE,IAAA,CAAM,CAAA,EAJavC,CAAAA,CAAmBL,CAAQ,CAIvB,CAAA,EAAA,CAAA,CACvB,OAAA,CAAA4C,CACF,CACF,CACF","file":"index.js","sourcesContent":["import { DocumentationPanel } from \"elseware-ui\";\n\ninterface DocsPageRendererProps {\n content: string;\n}\n\nfunction DocsPageRenderer({ content }: DocsPageRendererProps) {\n return <DocumentationPanel value={content} />;\n}\n\nexport default DocsPageRenderer;\n","import { createContext } from \"react\";\n\nimport { type DocsCategory } from \"../types\";\n\nexport interface DocsContextType {\n docs: DocsCategory[];\n basePath: string;\n}\n\nexport const DocsContext = createContext<DocsContextType | undefined>(\n undefined,\n);\n","import type { ReactNode } from \"react\";\n\nimport { DocsContext } from \"./DocsContext\";\n\nimport { type DocsCategory } from \"../types\";\n\ninterface DocsProviderProps {\n docs: DocsCategory[];\n basePath: string;\n children: ReactNode;\n}\n\nfunction DocsProvider({ docs, basePath, children }: DocsProviderProps) {\n return (\n <DocsContext.Provider value={{ docs, basePath }}>\n {children}\n </DocsContext.Provider>\n );\n}\n\nexport default DocsProvider;\n","export function normalizePath(path: string): string {\n return \"/\" + path.replace(/\\/+/g, \"/\").replace(/^\\/|\\/$/g, \"\");\n}\n\nexport function normalizeRoutePath(path: string): string {\n return path.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n}\n\nexport function isPathWithin(path: string, parentPath: string): boolean {\n const normalizedPath = normalizePath(path);\n const normalizedParent = normalizePath(parentPath);\n\n return (\n normalizedParent === \"/\" ||\n normalizedPath === normalizedParent ||\n normalizedPath.startsWith(`${normalizedParent}/`)\n );\n}\n\nexport function stripBasePath(path: string, basePath: string): string | null {\n const normalizedPath = normalizePath(path);\n const normalizedBase = normalizePath(basePath);\n\n if (!isPathWithin(normalizedPath, normalizedBase)) {\n return null;\n }\n\n if (normalizedBase === \"/\") {\n return normalizedPath;\n }\n\n return normalizePath(normalizedPath.slice(normalizedBase.length));\n}\n","import { type DocsNode, type DocsPage } from \"../types\";\n\nimport { normalizePath } from \"./path\";\n\nexport interface ResolvedDocsPage extends DocsPage {\n id: string;\n fullPath: string;\n}\n\nexport function isPage(node: DocsNode): node is DocsPage {\n return \"content\" in node;\n}\n\nexport function findPageByPath(\n nodes: DocsNode[],\n targetPath: string,\n parentPath = \"\",\n): DocsPage | null {\n const normalizedTarget = normalizePath(targetPath);\n\n for (const node of nodes) {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n if (currentPath === normalizedTarget) {\n return node;\n }\n } else {\n const result = findPageByPath(node.children, targetPath, currentPath);\n\n if (result) {\n return result;\n }\n }\n }\n\n return null;\n}\n\nexport function resolveDocs(\n nodes: DocsNode[],\n parentPath = \"\",\n): ResolvedDocsPage[] {\n const pages: ResolvedDocsPage[] = [];\n\n nodes.forEach((node) => {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n pages.push({\n ...node,\n id: currentPath.replace(/\\//g, \"-\").replace(/^-/, \"\"),\n fullPath: currentPath,\n });\n\n return;\n }\n\n pages.push(...resolveDocs(node.children, currentPath));\n });\n\n return pages;\n}\n\nexport function findFirstPage(\n nodes: DocsNode[],\n parentPath = \"\",\n): string | null {\n for (const node of nodes) {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n return currentPath;\n }\n\n const child = findFirstPage(node.children, currentPath);\n\n if (child) {\n return child;\n }\n }\n\n return null;\n}\n","import { type MenuNode } from \"elseware-ui\";\n\nimport { type DocsCategory, type DocsNode } from \"../types\";\n\nimport { normalizePath } from \"./path\";\n\nimport { isPage } from \"./docs\";\n\nfunction mapNodes(\n nodes: DocsNode[],\n basePath: string,\n parentPath = \"\",\n): MenuNode[] {\n return nodes.map((node) => {\n const fullPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n return {\n type: \"item\",\n name: node.title,\n to: normalizePath(`${basePath}/${fullPath}`),\n };\n }\n\n return {\n type: \"group\",\n name: node.title,\n items: mapNodes(node.children, basePath, fullPath),\n };\n });\n}\n\nexport function generateSidebar(\n docs: DocsCategory[],\n basePath: string,\n): MenuNode[] {\n return mapNodes(docs, basePath);\n}\n","import type { ReactNode } from \"react\";\n\nimport DocsProvider from \"../context/DocsProvider\";\n\nimport { type DocsCategory } from \"../types\";\nimport { normalizePath } from \"../utils\";\n\ninterface DocsEngineProps {\n docs: DocsCategory[];\n basePath?: string;\n children: ReactNode;\n}\n\nfunction DocsEngine({ docs, basePath = \"/\", children }: DocsEngineProps) {\n const normalizedBasePath = normalizePath(basePath);\n\n return (\n <DocsProvider docs={docs} basePath={normalizedBasePath}>\n {children}\n </DocsProvider>\n );\n}\n\nexport default DocsEngine;\n","import { useContext } from \"react\";\n\nimport { DocsContext } from \"../context\";\n\nexport function useDocs() {\n const context = useContext(DocsContext);\n\n if (!context) {\n throw new Error(\"useDocs must be used within DocsProvider\");\n }\n\n return context;\n}\n","import { useLocation } from \"react-router-dom\";\n\nimport { useDocs } from \"./useDocs\";\n\nimport { isPathWithin, stripBasePath } from \"../utils\";\n\nexport function useCurrentDocsSection() {\n const { docs, basePath } = useDocs();\n\n const location = useLocation();\n\n const pagePath = stripBasePath(location.pathname, basePath);\n\n if (!pagePath) {\n return undefined;\n }\n\n return docs.find((doc) => isPathWithin(pagePath, doc.path));\n}\n","import { useLocation } from \"react-router-dom\";\n\nimport { useDocs } from \"./useDocs\";\n\nimport { findPageByPath, stripBasePath } from \"../utils\";\n\ninterface UseCurrentPageProps {\n debug?: boolean;\n}\n\nexport function useCurrentPage({ debug = false }: UseCurrentPageProps = {}) {\n const { docs, basePath } = useDocs();\n\n const location = useLocation();\n\n const pagePath = stripBasePath(location.pathname, basePath);\n\n if (debug) {\n console.log(\"location.pathname\", location.pathname);\n console.log(\"basePath\", basePath);\n console.log(\"pagePath\", pagePath);\n }\n\n if (!pagePath) {\n return null;\n }\n\n return findPageByPath(docs, pagePath);\n}\n","import { generateSidebar } from \"../utils\";\n\nimport { useCurrentDocsSection } from \"./useCurrentDocsSection\";\nimport { useDocs } from \"./useDocs\";\n\nexport function useScopedSidebar() {\n const { basePath } = useDocs();\n\n const section = useCurrentDocsSection();\n\n if (!section) {\n return [];\n }\n\n return generateSidebar([section], basePath);\n}\n","import { generateSidebar } from \"../utils\";\n\nimport { useDocs } from \"./useDocs\";\n\nexport function useSidebar() {\n const { docs, basePath } = useDocs();\n\n return generateSidebar(docs, basePath);\n}\n","import type { ReactNode } from \"react\";\n\nimport { type RouteObject } from \"react-router-dom\";\n\nimport { normalizeRoutePath } from \"../utils\";\n\ninterface GenerateDocsRoutesProps {\n basePath?: string;\n element: ReactNode;\n}\n\nexport function generateDocsRoutes({\n basePath = \"/docs\",\n element,\n}: GenerateDocsRoutesProps): RouteObject[] {\n const normalizedBase = normalizeRoutePath(basePath);\n\n return [\n {\n path: `${normalizedBase}/*`,\n element,\n },\n ];\n}\n"]}
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
- import'elseware-ui/styles.css';import {DocumentationPanel}from'elseware-ui';import {jsx}from'react/jsx-runtime';import {createContext,useContext}from'react';import {useLocation}from'react-router-dom';function x({content:t}){return jsx(DocumentationPanel,{value:t})}var v=x;var c=createContext(void 0);function z({docs:t,basePath:o,children:r}){return jsx(c.Provider,{value:{docs:t,basePath:o},children:r})}var f=z;function n(t){return "/"+t.replace(/\/+/g,"/").replace(/^\/|\/$/g,"")}function g(t){return t.replace(/^\/+/,"").replace(/\/+$/,"")}function p(t,o){let r=n(t),e=n(o);return e==="/"||r===e||r.startsWith(`${e}/`)}function d(t,o){let r=n(t),e=n(o);return p(r,e)?e==="/"?r:n(r.slice(e.length)):null}function s(t){return "content"in t}function h(t,o,r=""){let e=n(o);for(let i of t){let m=n(`${r}/${i.path}`);if(s(i)){if(m===e)return i}else {let u=h(i.children,o,m);if(u)return u}}return null}function C(t,o=""){let r=[];return t.forEach(e=>{let i=n(`${o}/${e.path}`);if(s(e)){r.push({...e,id:i.replace(/\//g,"-").replace(/^-/,""),fullPath:i});return}r.push(...C(e.children,i));}),r}function R(t,o=""){for(let r of t){let e=n(`${o}/${r.path}`);if(s(r))return e;let i=R(r.children,e);if(i)return i}return null}function b(t,o,r=""){return t.map(e=>{let i=n(`${r}/${e.path}`);return s(e)?{type:"item",name:e.title,to:n(`${o}/${i}`)}:{type:"group",name:e.title,items:b(e.children,o,i)}})}function l(t,o){return b(t,o)}function S({docs:t,basePath:o="/",children:r}){let e=n(o);return jsx(f,{docs:t,basePath:e,children:r})}var N=S;function a(){let t=useContext(c);if(!t)throw new Error("useDocs must be used within DocsProvider");return t}function w(){let{docs:t,basePath:o}=a(),r=useLocation(),e=d(r.pathname,o);if(e)return t.find(i=>p(e,i.path))}function ft({debug:t=false}={}){let{docs:o,basePath:r}=a(),e=useLocation(),i=d(e.pathname,r);return t&&(console.log("location.pathname",e.pathname),console.log("basePath",r),console.log("pagePath",i)),i?h(o,i):null}function xt(){let{basePath:t}=a(),o=w();return o?l([o],t):[]}function zt(){let{docs:t,basePath:o}=a();return l(t,o)}function St({basePath:t="/docs",element:o}){return [{path:`${g(t)}/*`,element:o}]}
2
- export{c as DocsContext,N as DocsEngine,v as DocsPageRenderer,R as findFirstPage,h as findPageByPath,St as generateDocsRoutes,l as generateSidebar,s as isPage,p as isPathWithin,n as normalizePath,g as normalizeRoutePath,C as resolveDocs,d as stripBasePath,w as useCurrentDocsSection,ft as useCurrentPage,a as useDocs,xt as useScopedSidebar,zt as useSidebar};//# sourceMappingURL=index.mjs.map
1
+ import {DocumentationPanel}from'elseware-ui';import {jsx}from'react/jsx-runtime';import {createContext,useContext}from'react';import {useLocation}from'react-router-dom';function y({content:r}){return jsx(DocumentationPanel,{value:r})}var k=y;var c=createContext(void 0);function _({docs:r,basePath:o,children:e}){return jsx(c.Provider,{value:{docs:r,basePath:o},children:e})}var m=_;function i(r){return "/"+r.replace(/\/+/g,"/").replace(/^\/|\/$/g,"")}function h(r){return r.replace(/^\/+/,"").replace(/\/+$/,"")}function p(r,o){let e=i(r),t=i(o);return t==="/"||e===t||e.startsWith(`${t}/`)}function g(r,o){let e=i(r),t=i(o);return p(e,t)?t==="/"?e:i(e.slice(t.length)):null}function n(r){return "content"in r}function s(r,o,e=""){let t=i(o);for(let a of r){let w=i(`${e}/${a.path}`);if(n(a)){if(w===t)return a}else {let l=s(a.children,o,w);if(l)return l}}return null}function P(r,o=""){let e=[];return r.forEach(t=>{let a=i(`${o}/${t.path}`);if(n(t)){e.push({...t,id:a.replace(/\//g,"-").replace(/^-/,""),fullPath:a});return}e.push(...P(t.children,a));}),e}function B(r,o=""){for(let e of r){let t=i(`${o}/${e.path}`);if(n(e))return t;let a=B(e.children,t);if(a)return a}return null}function x(r,o,e=""){return r.map(t=>{let a=i(`${e}/${t.path}`);return n(t)?{type:"item",name:t.title,to:i(`${o}/${a}`)}:{type:"group",name:t.title,items:x(t.children,o,a)}})}function b(r,o){return x(r,o)}function Y({docs:r,basePath:o="/",children:e}){let t=i(o);return jsx(m,{docs:r,basePath:t,children:e})}var j=Y;function d(){let r=useContext(c);if(!r)throw new Error("useDocs must be used within DocsProvider");return r}function u(){let{docs:r,basePath:o}=d(),e=useLocation(),t=g(e.pathname,o);if(t)return r.find(a=>p(t,a.path))}function xr({debug:r=false}={}){let{docs:o,basePath:e}=d(),t=useLocation(),a=g(t.pathname,e);return r&&(console.log("location.pathname",t.pathname),console.log("basePath",e),console.log("pagePath",a)),a?s(o,a):null}function fr(){let{basePath:r}=d(),o=u();return o?b([o],r):[]}function Pr(){let{docs:r,basePath:o}=d();return b(r,o)}function Xr({basePath:r="/docs",element:o}){return [{path:`${h(r)}/*`,element:o}]}
2
+ export{c as DocsContext,j as DocsEngine,k as DocsPageRenderer,B as findFirstPage,s as findPageByPath,Xr as generateDocsRoutes,b as generateSidebar,n as isPage,p as isPathWithin,i as normalizePath,h as normalizeRoutePath,P as resolveDocs,g as stripBasePath,u as useCurrentDocsSection,xr as useCurrentPage,d as useDocs,fr as useScopedSidebar,Pr as useSidebar};//# sourceMappingURL=index.mjs.map
3
3
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/components/docs-page-renderer/DocsPageRenderer.tsx","../src/context/DocsContext.ts","../src/context/DocsProvider.tsx","../src/utils/path.ts","../src/utils/docs.ts","../src/utils/sidebar.ts","../src/engine/DocsEngine.tsx","../src/hooks/useDocs.ts","../src/hooks/useCurrentDocsSection.ts","../src/hooks/useCurrentPage.ts","../src/hooks/useScopedSidebar.ts","../src/hooks/useSidebar.ts","../src/router/generateDocsRoutes.tsx"],"names":["DocsPageRenderer","content","jsx","DocumentationPanel","DocsPageRenderer_default","DocsContext","createContext","DocsProvider","docs","basePath","children","DocsProvider_default","normalizePath","path","normalizeRoutePath","isPathWithin","parentPath","normalizedPath","normalizedParent","stripBasePath","normalizedBase","isPage","node","findPageByPath","nodes","targetPath","normalizedTarget","currentPath","result","resolveDocs","pages","findFirstPage","child","mapNodes","fullPath","generateSidebar","DocsEngine","normalizedBasePath","DocsEngine_default","useDocs","context","useContext","useCurrentDocsSection","location","useLocation","pagePath","doc","useCurrentPage","debug","useScopedSidebar","section","useSidebar","generateDocsRoutes","element"],"mappings":"wMAMA,SAASA,EAAiB,CAAE,OAAA,CAAAC,CAAQ,CAAA,CAA0B,CAC5D,OAAOC,GAAAA,CAACC,kBAAAA,CAAA,CAAmB,KAAA,CAAOF,CAAAA,CAAS,CAC7C,KAEOG,CAAAA,CAAQJ,ECDR,IAAMK,CAAAA,CAAcC,aAAAA,CACzB,MACF,ECCA,SAASC,CAAAA,CAAa,CAAE,IAAA,CAAAC,EAAM,QAAA,CAAAC,CAAAA,CAAU,QAAA,CAAAC,CAAS,EAAsB,CACrE,OACER,GAAAA,CAACG,CAAAA,CAAY,SAAZ,CAAqB,KAAA,CAAO,CAAE,IAAA,CAAAG,EAAM,QAAA,CAAAC,CAAS,CAAA,CAC3C,QAAA,CAAAC,EACH,CAEJ,CAEA,IAAOC,CAAAA,CAAQJ,ECpBR,SAASK,CAAAA,CAAcC,CAAAA,CAAsB,CAClD,OAAO,GAAA,CAAMA,CAAAA,CAAK,OAAA,CAAQ,MAAA,CAAQ,GAAG,CAAA,CAAE,OAAA,CAAQ,UAAA,CAAY,EAAE,CAC/D,CAEO,SAASC,CAAAA,CAAmBD,EAAsB,CACvD,OAAOA,CAAAA,CAAK,OAAA,CAAQ,OAAQ,EAAE,CAAA,CAAE,OAAA,CAAQ,MAAA,CAAQ,EAAE,CACpD,CAEO,SAASE,EAAaF,CAAAA,CAAcG,CAAAA,CAA6B,CACtE,IAAMC,EAAiBL,CAAAA,CAAcC,CAA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;\n}\n\nfunction DocsPageRenderer({ content }: DocsPageRendererProps) {\n return <DocumentationPanel value={content} />;\n}\n\nexport default DocsPageRenderer;\n","import { createContext } from \"react\";\n\nimport { type DocsCategory } from \"../types\";\n\nexport interface DocsContextType {\n docs: DocsCategory[];\n basePath: string;\n}\n\nexport const DocsContext = createContext<DocsContextType | undefined>(\n undefined,\n);\n","import type { ReactNode } from \"react\";\n\nimport { DocsContext } from \"./DocsContext\";\n\nimport { type DocsCategory } from \"../types\";\n\ninterface DocsProviderProps {\n docs: DocsCategory[];\n basePath: string;\n children: ReactNode;\n}\n\nfunction DocsProvider({ docs, basePath, children }: DocsProviderProps) {\n return (\n <DocsContext.Provider value={{ docs, basePath }}>\n {children}\n </DocsContext.Provider>\n );\n}\n\nexport default DocsProvider;\n","export function normalizePath(path: string): string {\n return \"/\" + path.replace(/\\/+/g, \"/\").replace(/^\\/|\\/$/g, \"\");\n}\n\nexport function normalizeRoutePath(path: string): string {\n return path.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n}\n\nexport function isPathWithin(path: string, parentPath: string): boolean {\n const normalizedPath = normalizePath(path);\n const normalizedParent = normalizePath(parentPath);\n\n return (\n normalizedParent === \"/\" ||\n normalizedPath === normalizedParent ||\n normalizedPath.startsWith(`${normalizedParent}/`)\n );\n}\n\nexport function stripBasePath(path: string, basePath: string): string | null {\n const normalizedPath = normalizePath(path);\n const normalizedBase = normalizePath(basePath);\n\n if (!isPathWithin(normalizedPath, normalizedBase)) {\n return null;\n }\n\n if (normalizedBase === \"/\") {\n return normalizedPath;\n }\n\n return normalizePath(normalizedPath.slice(normalizedBase.length));\n}\n","import { type DocsNode, type DocsPage } from \"../types\";\n\nimport { normalizePath } from \"./path\";\n\nexport interface ResolvedDocsPage extends DocsPage {\n id: string;\n fullPath: string;\n}\n\nexport function isPage(node: DocsNode): node is DocsPage {\n return \"content\" in node;\n}\n\nexport function findPageByPath(\n nodes: DocsNode[],\n targetPath: string,\n parentPath = \"\",\n): DocsPage | null {\n const normalizedTarget = normalizePath(targetPath);\n\n for (const node of nodes) {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n if (currentPath === normalizedTarget) {\n return node;\n }\n } else {\n const result = findPageByPath(node.children, targetPath, currentPath);\n\n if (result) {\n return result;\n }\n }\n }\n\n return null;\n}\n\nexport function resolveDocs(\n nodes: DocsNode[],\n parentPath = \"\",\n): ResolvedDocsPage[] {\n const pages: ResolvedDocsPage[] = [];\n\n nodes.forEach((node) => {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n pages.push({\n ...node,\n id: currentPath.replace(/\\//g, \"-\").replace(/^-/, \"\"),\n fullPath: currentPath,\n });\n\n return;\n }\n\n pages.push(...resolveDocs(node.children, currentPath));\n });\n\n return pages;\n}\n\nexport function findFirstPage(\n nodes: DocsNode[],\n parentPath = \"\",\n): string | null {\n for (const node of nodes) {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n return currentPath;\n }\n\n const child = findFirstPage(node.children, currentPath);\n\n if (child) {\n return child;\n }\n }\n\n return null;\n}\n","import { type MenuNode } from \"elseware-ui\";\n\nimport { type DocsCategory, type DocsNode } from \"../types\";\n\nimport { normalizePath } from \"./path\";\n\nimport { isPage } from \"./docs\";\n\nfunction mapNodes(\n nodes: DocsNode[],\n basePath: string,\n parentPath = \"\",\n): MenuNode[] {\n return nodes.map((node) => {\n const fullPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n return {\n type: \"item\",\n name: node.title,\n to: normalizePath(`${basePath}/${fullPath}`),\n };\n }\n\n return {\n type: \"group\",\n name: node.title,\n items: mapNodes(node.children, basePath, fullPath),\n };\n });\n}\n\nexport function generateSidebar(\n docs: DocsCategory[],\n basePath: string,\n): MenuNode[] {\n return mapNodes(docs, basePath);\n}\n","import type { ReactNode } from \"react\";\n\nimport DocsProvider from \"../context/DocsProvider\";\n\nimport { type DocsCategory } from \"../types\";\nimport { normalizePath } from \"../utils\";\n\ninterface DocsEngineProps {\n docs: DocsCategory[];\n basePath?: string;\n children: ReactNode;\n}\n\nfunction DocsEngine({ docs, basePath = \"/\", children }: DocsEngineProps) {\n const normalizedBasePath = normalizePath(basePath);\n\n return (\n <DocsProvider docs={docs} basePath={normalizedBasePath}>\n {children}\n </DocsProvider>\n );\n}\n\nexport default DocsEngine;\n","import { useContext } from \"react\";\n\nimport { DocsContext } from \"../context\";\n\nexport function useDocs() {\n const context = useContext(DocsContext);\n\n if (!context) {\n throw new Error(\"useDocs must be used within DocsProvider\");\n }\n\n return context;\n}\n","import { useLocation } from \"react-router-dom\";\n\nimport { useDocs } from \"./useDocs\";\n\nimport { isPathWithin, stripBasePath } from \"../utils\";\n\nexport function useCurrentDocsSection() {\n const { docs, basePath } = useDocs();\n\n const location = useLocation();\n\n const pagePath = stripBasePath(location.pathname, basePath);\n\n if (!pagePath) {\n return undefined;\n }\n\n return docs.find((doc) => isPathWithin(pagePath, doc.path));\n}\n","import { useLocation } from \"react-router-dom\";\n\nimport { useDocs } from \"./useDocs\";\n\nimport { findPageByPath, stripBasePath } from \"../utils\";\n\ninterface UseCurrentPageProps {\n debug?: boolean;\n}\n\nexport function useCurrentPage({ debug = false }: UseCurrentPageProps = {}) {\n const { docs, basePath } = useDocs();\n\n const location = useLocation();\n\n const pagePath = stripBasePath(location.pathname, basePath);\n\n if (debug) {\n console.log(\"location.pathname\", location.pathname);\n console.log(\"basePath\", basePath);\n console.log(\"pagePath\", pagePath);\n }\n\n if (!pagePath) {\n return null;\n }\n\n return findPageByPath(docs, pagePath);\n}\n","import { generateSidebar } from \"../utils\";\n\nimport { useCurrentDocsSection } from \"./useCurrentDocsSection\";\nimport { useDocs } from \"./useDocs\";\n\nexport function useScopedSidebar() {\n const { basePath } = useDocs();\n\n const section = useCurrentDocsSection();\n\n if (!section) {\n return [];\n }\n\n return generateSidebar([section], basePath);\n}\n","import { generateSidebar } from \"../utils\";\n\nimport { useDocs } from \"./useDocs\";\n\nexport function useSidebar() {\n const { docs, basePath } = useDocs();\n\n return generateSidebar(docs, basePath);\n}\n","import type { ReactNode } from \"react\";\n\nimport { type RouteObject } from \"react-router-dom\";\n\nimport { normalizeRoutePath } from \"../utils\";\n\ninterface GenerateDocsRoutesProps {\n basePath?: string;\n element: ReactNode;\n}\n\nexport function generateDocsRoutes({\n basePath = \"/docs\",\n element,\n}: GenerateDocsRoutesProps): RouteObject[] {\n const normalizedBase = normalizeRoutePath(basePath);\n\n return [\n {\n path: `${normalizedBase}/*`,\n element,\n },\n ];\n}\n"]}
1
+ {"version":3,"sources":["../src/components/docs-page-renderer/DocsPageRenderer.tsx","../src/context/DocsContext.ts","../src/context/DocsProvider.tsx","../src/utils/path.ts","../src/utils/docs.ts","../src/utils/sidebar.ts","../src/engine/DocsEngine.tsx","../src/hooks/useDocs.ts","../src/hooks/useCurrentDocsSection.ts","../src/hooks/useCurrentPage.ts","../src/hooks/useScopedSidebar.ts","../src/hooks/useSidebar.ts","../src/router/generateDocsRoutes.tsx"],"names":["DocsPageRenderer","content","jsx","DocumentationPanel","DocsPageRenderer_default","DocsContext","createContext","DocsProvider","docs","basePath","children","DocsProvider_default","normalizePath","path","normalizeRoutePath","isPathWithin","parentPath","normalizedPath","normalizedParent","stripBasePath","normalizedBase","isPage","node","findPageByPath","nodes","targetPath","normalizedTarget","currentPath","result","resolveDocs","pages","findFirstPage","child","mapNodes","fullPath","generateSidebar","DocsEngine","normalizedBasePath","DocsEngine_default","useDocs","context","useContext","useCurrentDocsSection","location","useLocation","pagePath","doc","useCurrentPage","debug","useScopedSidebar","section","useSidebar","generateDocsRoutes","element"],"mappings":"yKAMA,SAASA,CAAAA,CAAiB,CAAE,QAAAC,CAAQ,CAAA,CAA0B,CAC5D,OAAOC,IAACC,kBAAAA,CAAA,CAAmB,KAAA,CAAOF,CAAAA,CAAS,CAC7C,CAEA,IAAOG,CAAAA,CAAQJ,MCDFK,CAAAA,CAAcC,aAAAA,CACzB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AA,CAAMqC,CAAQ,EAH3B,IAIX,CCvBO,SAASI,EAAAA,EAAmB,CACjC,GAAM,CAAE,QAAA,CAAAxC,CAAS,EAAI8B,CAAAA,EAAQ,CAEvBW,CAAAA,CAAUR,CAAAA,EAAsB,CAEtC,OAAKQ,CAAAA,CAIEf,CAAAA,CAAgB,CAACe,CAAO,CAAA,CAAGzC,CAAQ,CAAA,CAHjC,EAIX,CCXO,SAAS0C,EAAAA,EAAa,CAC3B,GAAM,CAAE,IAAA,CAAA3C,CAAAA,CAAM,QAAA,CAAAC,CAAS,CAAA,CAAI8B,CAAAA,GAE3B,OAAOJ,CAAAA,CAAgB3B,CAAAA,CAAMC,CAAQ,CACvC,CCGO,SAAS2C,GAAmB,CACjC,QAAA,CAAA3C,CAAAA,CAAW,OAAA,CACX,QAAA4C,CACF,CAAA,CAA2C,CAGzC,OAAO,CACL,CACE,IAAA,CAAM,CAAA,EAJavC,CAAAA,CAAmBL,CAAQ,CAIvB,CAAA,EAAA,CAAA,CACvB,OAAA,CAAA4C,CACF,CACF,CACF","file":"index.mjs","sourcesContent":["import { DocumentationPanel } from \"elseware-ui\";\n\ninterface DocsPageRendererProps {\n content: string;\n}\n\nfunction DocsPageRenderer({ content }: DocsPageRendererProps) {\n return <DocumentationPanel value={content} />;\n}\n\nexport default DocsPageRenderer;\n","import { createContext } from \"react\";\n\nimport { type DocsCategory } from \"../types\";\n\nexport interface DocsContextType {\n docs: DocsCategory[];\n basePath: string;\n}\n\nexport const DocsContext = createContext<DocsContextType | undefined>(\n undefined,\n);\n","import type { ReactNode } from \"react\";\n\nimport { DocsContext } from \"./DocsContext\";\n\nimport { type DocsCategory } from \"../types\";\n\ninterface DocsProviderProps {\n docs: DocsCategory[];\n basePath: string;\n children: ReactNode;\n}\n\nfunction DocsProvider({ docs, basePath, children }: DocsProviderProps) {\n return (\n <DocsContext.Provider value={{ docs, basePath }}>\n {children}\n </DocsContext.Provider>\n );\n}\n\nexport default DocsProvider;\n","export function normalizePath(path: string): string {\n return \"/\" + path.replace(/\\/+/g, \"/\").replace(/^\\/|\\/$/g, \"\");\n}\n\nexport function normalizeRoutePath(path: string): string {\n return path.replace(/^\\/+/, \"\").replace(/\\/+$/, \"\");\n}\n\nexport function isPathWithin(path: string, parentPath: string): boolean {\n const normalizedPath = normalizePath(path);\n const normalizedParent = normalizePath(parentPath);\n\n return (\n normalizedParent === \"/\" ||\n normalizedPath === normalizedParent ||\n normalizedPath.startsWith(`${normalizedParent}/`)\n );\n}\n\nexport function stripBasePath(path: string, basePath: string): string | null {\n const normalizedPath = normalizePath(path);\n const normalizedBase = normalizePath(basePath);\n\n if (!isPathWithin(normalizedPath, normalizedBase)) {\n return null;\n }\n\n if (normalizedBase === \"/\") {\n return normalizedPath;\n }\n\n return normalizePath(normalizedPath.slice(normalizedBase.length));\n}\n","import { type DocsNode, type DocsPage } from \"../types\";\n\nimport { normalizePath } from \"./path\";\n\nexport interface ResolvedDocsPage extends DocsPage {\n id: string;\n fullPath: string;\n}\n\nexport function isPage(node: DocsNode): node is DocsPage {\n return \"content\" in node;\n}\n\nexport function findPageByPath(\n nodes: DocsNode[],\n targetPath: string,\n parentPath = \"\",\n): DocsPage | null {\n const normalizedTarget = normalizePath(targetPath);\n\n for (const node of nodes) {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n if (currentPath === normalizedTarget) {\n return node;\n }\n } else {\n const result = findPageByPath(node.children, targetPath, currentPath);\n\n if (result) {\n return result;\n }\n }\n }\n\n return null;\n}\n\nexport function resolveDocs(\n nodes: DocsNode[],\n parentPath = \"\",\n): ResolvedDocsPage[] {\n const pages: ResolvedDocsPage[] = [];\n\n nodes.forEach((node) => {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n pages.push({\n ...node,\n id: currentPath.replace(/\\//g, \"-\").replace(/^-/, \"\"),\n fullPath: currentPath,\n });\n\n return;\n }\n\n pages.push(...resolveDocs(node.children, currentPath));\n });\n\n return pages;\n}\n\nexport function findFirstPage(\n nodes: DocsNode[],\n parentPath = \"\",\n): string | null {\n for (const node of nodes) {\n const currentPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n return currentPath;\n }\n\n const child = findFirstPage(node.children, currentPath);\n\n if (child) {\n return child;\n }\n }\n\n return null;\n}\n","import { type MenuNode } from \"elseware-ui\";\n\nimport { type DocsCategory, type DocsNode } from \"../types\";\n\nimport { normalizePath } from \"./path\";\n\nimport { isPage } from \"./docs\";\n\nfunction mapNodes(\n nodes: DocsNode[],\n basePath: string,\n parentPath = \"\",\n): MenuNode[] {\n return nodes.map((node) => {\n const fullPath = normalizePath(`${parentPath}/${node.path}`);\n\n if (isPage(node)) {\n return {\n type: \"item\",\n name: node.title,\n to: normalizePath(`${basePath}/${fullPath}`),\n };\n }\n\n return {\n type: \"group\",\n name: node.title,\n items: mapNodes(node.children, basePath, fullPath),\n };\n });\n}\n\nexport function generateSidebar(\n docs: DocsCategory[],\n basePath: string,\n): MenuNode[] {\n return mapNodes(docs, basePath);\n}\n","import type { ReactNode } from \"react\";\n\nimport DocsProvider from \"../context/DocsProvider\";\n\nimport { type DocsCategory } from \"../types\";\nimport { normalizePath } from \"../utils\";\n\ninterface DocsEngineProps {\n docs: DocsCategory[];\n basePath?: string;\n children: ReactNode;\n}\n\nfunction DocsEngine({ docs, basePath = \"/\", children }: DocsEngineProps) {\n const normalizedBasePath = normalizePath(basePath);\n\n return (\n <DocsProvider docs={docs} basePath={normalizedBasePath}>\n {children}\n </DocsProvider>\n );\n}\n\nexport default DocsEngine;\n","import { useContext } from \"react\";\n\nimport { DocsContext } from \"../context\";\n\nexport function useDocs() {\n const context = useContext(DocsContext);\n\n if (!context) {\n throw new Error(\"useDocs must be used within DocsProvider\");\n }\n\n return context;\n}\n","import { useLocation } from \"react-router-dom\";\n\nimport { useDocs } from \"./useDocs\";\n\nimport { isPathWithin, stripBasePath } from \"../utils\";\n\nexport function useCurrentDocsSection() {\n const { docs, basePath } = useDocs();\n\n const location = useLocation();\n\n const pagePath = stripBasePath(location.pathname, basePath);\n\n if (!pagePath) {\n return undefined;\n }\n\n return docs.find((doc) => isPathWithin(pagePath, doc.path));\n}\n","import { useLocation } from \"react-router-dom\";\n\nimport { useDocs } from \"./useDocs\";\n\nimport { findPageByPath, stripBasePath } from \"../utils\";\n\ninterface UseCurrentPageProps {\n debug?: boolean;\n}\n\nexport function useCurrentPage({ debug = false }: UseCurrentPageProps = {}) {\n const { docs, basePath } = useDocs();\n\n const location = useLocation();\n\n const pagePath = stripBasePath(location.pathname, basePath);\n\n if (debug) {\n console.log(\"location.pathname\", location.pathname);\n console.log(\"basePath\", basePath);\n console.log(\"pagePath\", pagePath);\n }\n\n if (!pagePath) {\n return null;\n }\n\n return findPageByPath(docs, pagePath);\n}\n","import { generateSidebar } from \"../utils\";\n\nimport { useCurrentDocsSection } from \"./useCurrentDocsSection\";\nimport { useDocs } from \"./useDocs\";\n\nexport function useScopedSidebar() {\n const { basePath } = useDocs();\n\n const section = useCurrentDocsSection();\n\n if (!section) {\n return [];\n }\n\n return generateSidebar([section], basePath);\n}\n","import { generateSidebar } from \"../utils\";\n\nimport { useDocs } from \"./useDocs\";\n\nexport function useSidebar() {\n const { docs, basePath } = useDocs();\n\n return generateSidebar(docs, basePath);\n}\n","import type { ReactNode } from \"react\";\n\nimport { type RouteObject } from \"react-router-dom\";\n\nimport { normalizeRoutePath } from \"../utils\";\n\ninterface GenerateDocsRoutesProps {\n basePath?: string;\n element: ReactNode;\n}\n\nexport function generateDocsRoutes({\n basePath = \"/docs\",\n element,\n}: GenerateDocsRoutesProps): RouteObject[] {\n const normalizedBase = normalizeRoutePath(basePath);\n\n return [\n {\n path: `${normalizedBase}/*`,\n element,\n },\n ];\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from "react";
2
+ import { type RouteObject } from "react-router-dom";
3
+ interface GenerateDocsRoutesProps {
4
+ basePath?: string;
5
+ element: ReactNode;
6
+ }
7
+ export declare function generateDocsRoutes({ basePath, element, }: GenerateDocsRoutesProps): RouteObject[];
8
+ export {};
9
+ //# sourceMappingURL=generateDocsRoutes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateDocsRoutes.d.ts","sourceRoot":"","sources":["../../src/router/generateDocsRoutes.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAIpD,UAAU,uBAAuB;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,SAAS,CAAC;CACpB;AAED,wBAAgB,kBAAkB,CAAC,EACjC,QAAkB,EAClB,OAAO,GACR,EAAE,uBAAuB,GAAG,WAAW,EAAE,CASzC"}
@@ -0,0 +1,2 @@
1
+ export * from "./generateDocsRoutes";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,12 @@
1
+ export interface DocsPage {
2
+ title: string;
3
+ path: string;
4
+ content: string;
5
+ }
6
+ export interface DocsCategory {
7
+ title: string;
8
+ path: string;
9
+ children: DocsNode[];
10
+ }
11
+ export type DocsNode = DocsCategory | DocsPage;
12
+ //# sourceMappingURL=docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/types/docs.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,QAAQ,EAAE,CAAC;CACtB;AAED,MAAM,MAAM,QAAQ,GAAG,YAAY,GAAG,QAAQ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./docs";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type DocsNode, type DocsPage } from "../types";
2
+ export interface ResolvedDocsPage extends DocsPage {
3
+ id: string;
4
+ fullPath: string;
5
+ }
6
+ export declare function isPage(node: DocsNode): node is DocsPage;
7
+ export declare function findPageByPath(nodes: DocsNode[], targetPath: string, parentPath?: string): DocsPage | null;
8
+ export declare function resolveDocs(nodes: DocsNode[], parentPath?: string): ResolvedDocsPage[];
9
+ export declare function findFirstPage(nodes: DocsNode[], parentPath?: string): string | null;
10
+ //# sourceMappingURL=docs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"docs.d.ts","sourceRoot":"","sources":["../../src/utils/docs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,MAAM,UAAU,CAAC;AAIxD,MAAM,WAAW,gBAAiB,SAAQ,QAAQ;IAChD,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,QAAQ,GAAG,IAAI,IAAI,QAAQ,CAEvD;AAED,wBAAgB,cAAc,CAC5B,KAAK,EAAE,QAAQ,EAAE,EACjB,UAAU,EAAE,MAAM,EAClB,UAAU,SAAK,GACd,QAAQ,GAAG,IAAI,CAoBjB;AAED,wBAAgB,WAAW,CACzB,KAAK,EAAE,QAAQ,EAAE,EACjB,UAAU,SAAK,GACd,gBAAgB,EAAE,CAoBpB;AAED,wBAAgB,aAAa,CAC3B,KAAK,EAAE,QAAQ,EAAE,EACjB,UAAU,SAAK,GACd,MAAM,GAAG,IAAI,CAgBf"}
@@ -0,0 +1,4 @@
1
+ export * from "./docs";
2
+ export * from "./path";
3
+ export * from "./sidebar";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AACvB,cAAc,WAAW,CAAC"}
@@ -0,0 +1,5 @@
1
+ export declare function normalizePath(path: string): string;
2
+ export declare function normalizeRoutePath(path: string): string;
3
+ export declare function isPathWithin(path: string, parentPath: string): boolean;
4
+ export declare function stripBasePath(path: string, basePath: string): string | null;
5
+ //# sourceMappingURL=path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/utils/path.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAStE;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAa3E"}
@@ -0,0 +1,4 @@
1
+ import { type MenuNode } from "elseware-ui";
2
+ import { type DocsCategory } from "../types";
3
+ export declare function generateSidebar(docs: DocsCategory[], basePath: string): MenuNode[];
4
+ //# sourceMappingURL=sidebar.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sidebar.d.ts","sourceRoot":"","sources":["../../src/utils/sidebar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,KAAK,YAAY,EAAiB,MAAM,UAAU,CAAC;AA8B5D,wBAAgB,eAAe,CAC7B,IAAI,EAAE,YAAY,EAAE,EACpB,QAAQ,EAAE,MAAM,GACf,QAAQ,EAAE,CAEZ"}
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "elseware-docs-engine",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "private": false,
5
5
  "description": "React documentation engine by elseware Technology",
6
6
  "license": "MIT",
7
+ "author": "elseware Technology",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/elsewaretechnology/elseware-docs-engine.git"
11
+ },
7
12
  "main": "./dist/index.js",
8
13
  "module": "./dist/index.mjs",
9
14
  "types": "./dist/index.d.ts",
@@ -35,44 +40,39 @@
35
40
  "react-router-dom": "^6"
36
41
  },
37
42
  "dependencies": {
38
- "elseware-ui": "^2.39.2"
43
+ "elseware-ui": "^3.2.0"
39
44
  },
40
45
  "devDependencies": {
41
- "@eslint/js": "^9.39.4",
42
46
  "@types/node": "^24.0.3",
43
47
  "@types/react": "^18.3.12",
44
48
  "@types/react-dom": "^18.3.1",
45
- "@typescript/native": "npm:typescript@^7.0.2",
46
- "@vitejs/plugin-react": "^4.2.1",
49
+ "@vitejs/plugin-react": "^6.0.3",
47
50
  "autoprefixer": "^10.4.21",
48
- "eslint": "^9.39.4",
49
- "eslint-config-prettier": "^10.1.8",
50
- "eslint-plugin-react": "^7.37.5",
51
- "eslint-plugin-react-hooks": "^7.1.1",
52
- "globals": "^16.5.0",
53
51
  "husky": "^9.1.7",
54
52
  "knip": "^6.15.0",
55
53
  "lint-staged": "^17.0.7",
54
+ "oxlint": "^1.74.0",
56
55
  "prettier": "^3.8.3",
57
56
  "rimraf": "^6.1.3",
58
57
  "tailwindcss": "^3.4.0",
59
58
  "tsup": "^8.5.1",
60
- "typescript": "npm:@typescript/typescript6@^6.0.2",
61
- "typescript-eslint": "^8.61.1",
62
- "vite": "^5.2.0"
59
+ "typescript": "^7.0.2",
60
+ "vite": "^8.1.4"
61
+ },
62
+ "overrides": {
63
+ "esbuild": "^0.28.1"
63
64
  },
64
65
  "scripts": {
65
66
  "dev": "vite",
66
- "build": "tsup",
67
+ "build": "tsup && tsc --project tsconfig.build.json",
67
68
  "clean": "rimraf dist node_modules/.cache",
68
69
  "typecheck": "tsc --noEmit",
69
- "typecheck:compat": "tsc6 --noEmit",
70
- "lint": "eslint .",
71
- "lint:fix": "eslint . --fix",
70
+ "lint": "oxlint --deny-warnings",
71
+ "lint:fix": "oxlint --fix --deny-warnings",
72
72
  "format": "prettier . --write",
73
73
  "format:check": "prettier . --check",
74
74
  "deadcode": "knip",
75
- "validate": "npm run typecheck && npm run typecheck:compat && npm run lint && npm run format:check && npm run deadcode && npm run build",
75
+ "validate": "npm run typecheck && npm run lint && npm run format:check && npm run deadcode && npm run build",
76
76
  "full": "npm run lint:fix && npm run format && npm run validate",
77
77
  "prepare": "husky",
78
78
  "prepublishOnly": "npm run validate",
@@ -80,7 +80,7 @@
80
80
  },
81
81
  "lint-staged": {
82
82
  "*.{js,jsx,ts,tsx,mjs,cjs}": [
83
- "eslint --fix",
83
+ "oxlint --fix --deny-warnings",
84
84
  "prettier --write"
85
85
  ],
86
86
  "*.{json,md,css,yml,yaml}": [
package/dist/index.d.mts DELETED
@@ -1,73 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as react from 'react';
3
- import { ReactNode } from 'react';
4
- import * as elseware_ui from 'elseware-ui';
5
- import { MenuNode } from 'elseware-ui';
6
- import { RouteObject } from 'react-router-dom';
7
-
8
- interface DocsPageRendererProps {
9
- content: string;
10
- }
11
- declare function DocsPageRenderer({ content }: DocsPageRendererProps): react_jsx_runtime.JSX.Element;
12
-
13
- interface DocsPage {
14
- title: string;
15
- path: string;
16
- content: string;
17
- }
18
- interface DocsCategory {
19
- title: string;
20
- path: string;
21
- children: DocsNode[];
22
- }
23
- type DocsNode = DocsCategory | DocsPage;
24
-
25
- interface DocsContextType {
26
- docs: DocsCategory[];
27
- basePath: string;
28
- }
29
- declare const DocsContext: react.Context<DocsContextType | undefined>;
30
-
31
- interface DocsEngineProps {
32
- docs: DocsCategory[];
33
- basePath?: string;
34
- children: ReactNode;
35
- }
36
- declare function DocsEngine({ docs, basePath, children }: DocsEngineProps): react_jsx_runtime.JSX.Element;
37
-
38
- declare function useCurrentDocsSection(): DocsCategory | undefined;
39
-
40
- interface UseCurrentPageProps {
41
- debug?: boolean;
42
- }
43
- declare function useCurrentPage({ debug }?: UseCurrentPageProps): DocsPage | null;
44
-
45
- declare function useDocs(): DocsContextType;
46
-
47
- declare function useScopedSidebar(): elseware_ui.MenuNode[];
48
-
49
- declare function useSidebar(): elseware_ui.MenuNode[];
50
-
51
- interface GenerateDocsRoutesProps {
52
- basePath?: string;
53
- element: ReactNode;
54
- }
55
- declare function generateDocsRoutes({ basePath, element, }: GenerateDocsRoutesProps): RouteObject[];
56
-
57
- interface ResolvedDocsPage extends DocsPage {
58
- id: string;
59
- fullPath: string;
60
- }
61
- declare function isPage(node: DocsNode): node is DocsPage;
62
- declare function findPageByPath(nodes: DocsNode[], targetPath: string, parentPath?: string): DocsPage | null;
63
- declare function resolveDocs(nodes: DocsNode[], parentPath?: string): ResolvedDocsPage[];
64
- declare function findFirstPage(nodes: DocsNode[], parentPath?: string): string | null;
65
-
66
- declare function normalizePath(path: string): string;
67
- declare function normalizeRoutePath(path: string): string;
68
- declare function isPathWithin(path: string, parentPath: string): boolean;
69
- declare function stripBasePath(path: string, basePath: string): string | null;
70
-
71
- declare function generateSidebar(docs: DocsCategory[], basePath: string): MenuNode[];
72
-
73
- export { type DocsCategory, DocsContext, type DocsContextType, DocsEngine, type DocsNode, type DocsPage, DocsPageRenderer, type ResolvedDocsPage, findFirstPage, findPageByPath, generateDocsRoutes, generateSidebar, isPage, isPathWithin, normalizePath, normalizeRoutePath, resolveDocs, stripBasePath, useCurrentDocsSection, useCurrentPage, useDocs, useScopedSidebar, useSidebar };