@lickle/docs 0.0.0-dev.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.
- package/README.md +3 -0
- package/dist/esm/_lib/fs/index.js +20 -0
- package/dist/esm/_lib/fs/index.js.map +1 -0
- package/dist/esm/_lib/fs/watch.js +30 -0
- package/dist/esm/_lib/fs/watch.js.map +1 -0
- package/dist/esm/_lib/index.js +9 -0
- package/dist/esm/_lib/index.js.map +1 -0
- package/dist/esm/_lib/jiti/index.js +16 -0
- package/dist/esm/_lib/jiti/index.js.map +1 -0
- package/dist/esm/_lib/path/index.js +42 -0
- package/dist/esm/_lib/path/index.js.map +1 -0
- package/dist/esm/_lib/pkg/index.js +128 -0
- package/dist/esm/_lib/pkg/index.js.map +1 -0
- package/dist/esm/_lib/repo/index.js +100 -0
- package/dist/esm/_lib/repo/index.js.map +1 -0
- package/dist/esm/_lib/slug/index.js +23 -0
- package/dist/esm/_lib/slug/index.js.map +1 -0
- package/dist/esm/_lib/t.js +2 -0
- package/dist/esm/_lib/t.js.map +1 -0
- package/dist/esm/_lib/tsconfig/index.js +12 -0
- package/dist/esm/_lib/tsconfig/index.js.map +1 -0
- package/dist/esm/_lib/util/index.js +54 -0
- package/dist/esm/_lib/util/index.js.map +1 -0
- package/dist/esm/cli/cmd/dev.js +74 -0
- package/dist/esm/cli/cmd/dev.js.map +1 -0
- package/dist/esm/cli/cmd/index.js +4 -0
- package/dist/esm/cli/cmd/index.js.map +1 -0
- package/dist/esm/cli/cmd/init.js +74 -0
- package/dist/esm/cli/cmd/init.js.map +1 -0
- package/dist/esm/cli/cmd/json.js +28 -0
- package/dist/esm/cli/cmd/json.js.map +1 -0
- package/dist/esm/cli/env.js +5 -0
- package/dist/esm/cli/env.js.map +1 -0
- package/dist/esm/cli/index.js +13 -0
- package/dist/esm/cli/index.js.map +1 -0
- package/dist/esm/cli/vite/client/index.jsx +20 -0
- package/dist/esm/cli/vite/client/index.jsx.map +1 -0
- package/dist/esm/cli/vite/index.js +100 -0
- package/dist/esm/cli/vite/index.js.map +1 -0
- package/dist/esm/cli.js +5 -0
- package/dist/esm/cli.js.map +1 -0
- package/dist/esm/config/defaults.js +32 -0
- package/dist/esm/config/defaults.js.map +1 -0
- package/dist/esm/config/file.js +48 -0
- package/dist/esm/config/file.js.map +1 -0
- package/dist/esm/config/index.js +7 -0
- package/dist/esm/config/index.js.map +1 -0
- package/dist/esm/config/load.js +79 -0
- package/dist/esm/config/load.js.map +1 -0
- package/dist/esm/config/types.js +2 -0
- package/dist/esm/config/types.js.map +1 -0
- package/dist/esm/core/index.js +3 -0
- package/dist/esm/core/index.js.map +1 -0
- package/dist/esm/core/project/debug.js +26 -0
- package/dist/esm/core/project/debug.js.map +1 -0
- package/dist/esm/core/project/index.js +39 -0
- package/dist/esm/core/project/index.js.map +1 -0
- package/dist/esm/core/project/naming.js +39 -0
- package/dist/esm/core/project/naming.js.map +1 -0
- package/dist/esm/core/project/routing.js +173 -0
- package/dist/esm/core/project/routing.js.map +1 -0
- package/dist/esm/core/project/types.js +4 -0
- package/dist/esm/core/project/types.js.map +1 -0
- package/dist/esm/core/reflect/index.js +10 -0
- package/dist/esm/core/reflect/index.js.map +1 -0
- package/dist/esm/core/reflect/indexed.js +195 -0
- package/dist/esm/core/reflect/indexed.js.map +1 -0
- package/dist/esm/core/reflect/resolve.js +157 -0
- package/dist/esm/core/reflect/resolve.js.map +1 -0
- package/dist/esm/core/reflect/scan.js +787 -0
- package/dist/esm/core/reflect/scan.js.map +1 -0
- package/dist/esm/core/reflect/state.js +29 -0
- package/dist/esm/core/reflect/state.js.map +1 -0
- package/dist/esm/core/reflect/types.js +16 -0
- package/dist/esm/core/reflect/types.js.map +1 -0
- package/dist/esm/core/reflect/walk.js +106 -0
- package/dist/esm/core/reflect/walk.js.map +1 -0
- package/dist/esm/solidjs/index.js +2 -0
- package/dist/esm/solidjs/index.js.map +1 -0
- package/dist/esm/solidjs/jsx-runtime.js +2 -0
- package/dist/esm/solidjs/jsx-runtime.js.map +1 -0
- package/dist/esm/ui/App.jsx +71 -0
- package/dist/esm/ui/App.jsx.map +1 -0
- package/dist/esm/ui/components/Breadcrumb.jsx +45 -0
- package/dist/esm/ui/components/Breadcrumb.jsx.map +1 -0
- package/dist/esm/ui/components/Code/index.jsx +89 -0
- package/dist/esm/ui/components/Code/index.jsx.map +1 -0
- package/dist/esm/ui/components/Comment.jsx +176 -0
- package/dist/esm/ui/components/Comment.jsx.map +1 -0
- package/dist/esm/ui/components/Declaration.jsx +147 -0
- package/dist/esm/ui/components/Declaration.jsx.map +1 -0
- package/dist/esm/ui/components/Header.jsx +66 -0
- package/dist/esm/ui/components/Header.jsx.map +1 -0
- package/dist/esm/ui/components/Layout.jsx +44 -0
- package/dist/esm/ui/components/Layout.jsx.map +1 -0
- package/dist/esm/ui/components/Link.jsx +34 -0
- package/dist/esm/ui/components/Link.jsx.map +1 -0
- package/dist/esm/ui/components/LivePreview/Example.jsx +76 -0
- package/dist/esm/ui/components/LivePreview/Example.jsx.map +1 -0
- package/dist/esm/ui/components/LivePreview/Sandbox.jsx +25 -0
- package/dist/esm/ui/components/LivePreview/Sandbox.jsx.map +1 -0
- package/dist/esm/ui/components/LivePreview/index.js +4 -0
- package/dist/esm/ui/components/LivePreview/index.js.map +1 -0
- package/dist/esm/ui/components/LivePreview/transform.js +16 -0
- package/dist/esm/ui/components/LivePreview/transform.js.map +1 -0
- package/dist/esm/ui/components/Markdown.jsx +14 -0
- package/dist/esm/ui/components/Markdown.jsx.map +1 -0
- package/dist/esm/ui/components/Page.jsx +121 -0
- package/dist/esm/ui/components/Page.jsx.map +1 -0
- package/dist/esm/ui/components/References.jsx +32 -0
- package/dist/esm/ui/components/References.jsx.map +1 -0
- package/dist/esm/ui/components/SearchPalette.jsx +178 -0
- package/dist/esm/ui/components/SearchPalette.jsx.map +1 -0
- package/dist/esm/ui/components/Sidebar.jsx +63 -0
- package/dist/esm/ui/components/Sidebar.jsx.map +1 -0
- package/dist/esm/ui/components/Syntax.jsx +10 -0
- package/dist/esm/ui/components/Syntax.jsx.map +1 -0
- package/dist/esm/ui/components/ThemeToggle.jsx +25 -0
- package/dist/esm/ui/components/ThemeToggle.jsx.map +1 -0
- package/dist/esm/ui/components/Type.jsx +444 -0
- package/dist/esm/ui/components/Type.jsx.map +1 -0
- package/dist/esm/ui/components/index.js +16 -0
- package/dist/esm/ui/components/index.js.map +1 -0
- package/dist/esm/ui/context/components.jsx +30 -0
- package/dist/esm/ui/context/components.jsx.map +1 -0
- package/dist/esm/ui/context/global.js +15 -0
- package/dist/esm/ui/context/global.js.map +1 -0
- package/dist/esm/ui/context/index.js +5 -0
- package/dist/esm/ui/context/index.js.map +1 -0
- package/dist/esm/ui/context/markup/index.jsx +25 -0
- package/dist/esm/ui/context/markup/index.jsx.map +1 -0
- package/dist/esm/ui/context/markup/markdown.js +34 -0
- package/dist/esm/ui/context/markup/markdown.js.map +1 -0
- package/dist/esm/ui/context/markup/shiki.js +58 -0
- package/dist/esm/ui/context/markup/shiki.js.map +1 -0
- package/dist/esm/ui/context/markup/util.js +22 -0
- package/dist/esm/ui/context/markup/util.js.map +1 -0
- package/dist/esm/ui/context/project/index.jsx +27 -0
- package/dist/esm/ui/context/project/index.jsx.map +1 -0
- package/dist/esm/ui/context/project/indexed.js +47 -0
- package/dist/esm/ui/context/project/indexed.js.map +1 -0
- package/dist/esm/ui/context/project/types.js +2 -0
- package/dist/esm/ui/context/project/types.js.map +1 -0
- package/dist/esm/ui/context/theme.jsx +36 -0
- package/dist/esm/ui/context/theme.jsx.map +1 -0
- package/dist/esm/ui/hooks/index.js +94 -0
- package/dist/esm/ui/hooks/index.js.map +1 -0
- package/dist/esm/ui/index.js +5 -0
- package/dist/esm/ui/index.js.map +1 -0
- package/dist/esm/ui/renderer.jsx +21 -0
- package/dist/esm/ui/renderer.jsx.map +1 -0
- package/dist/esm/ui/util/comment.js +14 -0
- package/dist/esm/ui/util/comment.js.map +1 -0
- package/dist/esm/ui/util/kind.js +85 -0
- package/dist/esm/ui/util/kind.js.map +1 -0
- package/dist/esm/ui/util/markdown.js +66 -0
- package/dist/esm/ui/util/markdown.js.map +1 -0
- package/dist/esm/ui/util/search.js +75 -0
- package/dist/esm/ui/util/search.js.map +1 -0
- package/dist/ts/_lib/fs/index.d.ts +6 -0
- package/dist/ts/_lib/fs/index.d.ts.map +1 -0
- package/dist/ts/_lib/fs/watch.d.ts +14 -0
- package/dist/ts/_lib/fs/watch.d.ts.map +1 -0
- package/dist/ts/_lib/index.d.ts +10 -0
- package/dist/ts/_lib/index.d.ts.map +1 -0
- package/dist/ts/_lib/jiti/index.d.ts +2 -0
- package/dist/ts/_lib/jiti/index.d.ts.map +1 -0
- package/dist/ts/_lib/path/index.d.ts +12 -0
- package/dist/ts/_lib/path/index.d.ts.map +1 -0
- package/dist/ts/_lib/pkg/index.d.ts +28 -0
- package/dist/ts/_lib/pkg/index.d.ts.map +1 -0
- package/dist/ts/_lib/repo/index.d.ts +30 -0
- package/dist/ts/_lib/repo/index.d.ts.map +1 -0
- package/dist/ts/_lib/slug/index.d.ts +4 -0
- package/dist/ts/_lib/slug/index.d.ts.map +1 -0
- package/dist/ts/_lib/t.d.ts +11 -0
- package/dist/ts/_lib/t.d.ts.map +1 -0
- package/dist/ts/_lib/tsconfig/index.d.ts +8 -0
- package/dist/ts/_lib/tsconfig/index.d.ts.map +1 -0
- package/dist/ts/_lib/util/index.d.ts +9 -0
- package/dist/ts/_lib/util/index.d.ts.map +1 -0
- package/dist/ts/cli/cmd/dev.d.ts +27 -0
- package/dist/ts/cli/cmd/dev.d.ts.map +1 -0
- package/dist/ts/cli/cmd/index.d.ts +4 -0
- package/dist/ts/cli/cmd/index.d.ts.map +1 -0
- package/dist/ts/cli/cmd/init.d.ts +14 -0
- package/dist/ts/cli/cmd/init.d.ts.map +1 -0
- package/dist/ts/cli/cmd/json.d.ts +12 -0
- package/dist/ts/cli/cmd/json.d.ts.map +1 -0
- package/dist/ts/cli/env.d.ts +2 -0
- package/dist/ts/cli/env.d.ts.map +1 -0
- package/dist/ts/cli/index.d.ts +78 -0
- package/dist/ts/cli/index.d.ts.map +1 -0
- package/dist/ts/cli/vite/client/index.d.ts +10 -0
- package/dist/ts/cli/vite/client/index.d.ts.map +1 -0
- package/dist/ts/cli/vite/index.d.ts +12 -0
- package/dist/ts/cli/vite/index.d.ts.map +1 -0
- package/dist/ts/cli.d.ts +3 -0
- package/dist/ts/cli.d.ts.map +1 -0
- package/dist/ts/config/defaults.d.ts +10 -0
- package/dist/ts/config/defaults.d.ts.map +1 -0
- package/dist/ts/config/file.d.ts +3 -0
- package/dist/ts/config/file.d.ts.map +1 -0
- package/dist/ts/config/index.d.ts +6 -0
- package/dist/ts/config/index.d.ts.map +1 -0
- package/dist/ts/config/load.d.ts +36 -0
- package/dist/ts/config/load.d.ts.map +1 -0
- package/dist/ts/config/types.d.ts +56 -0
- package/dist/ts/config/types.d.ts.map +1 -0
- package/dist/ts/core/index.d.ts +3 -0
- package/dist/ts/core/index.d.ts.map +1 -0
- package/dist/ts/core/project/debug.d.ts +3 -0
- package/dist/ts/core/project/debug.d.ts.map +1 -0
- package/dist/ts/core/project/index.d.ts +17 -0
- package/dist/ts/core/project/index.d.ts.map +1 -0
- package/dist/ts/core/project/naming.d.ts +23 -0
- package/dist/ts/core/project/naming.d.ts.map +1 -0
- package/dist/ts/core/project/routing.d.ts +61 -0
- package/dist/ts/core/project/routing.d.ts.map +1 -0
- package/dist/ts/core/project/types.d.ts +56 -0
- package/dist/ts/core/project/types.d.ts.map +1 -0
- package/dist/ts/core/reflect/index.d.ts +22 -0
- package/dist/ts/core/reflect/index.d.ts.map +1 -0
- package/dist/ts/core/reflect/indexed.d.ts +83 -0
- package/dist/ts/core/reflect/indexed.d.ts.map +1 -0
- package/dist/ts/core/reflect/resolve.d.ts +3 -0
- package/dist/ts/core/reflect/resolve.d.ts.map +1 -0
- package/dist/ts/core/reflect/scan.d.ts +218 -0
- package/dist/ts/core/reflect/scan.d.ts.map +1 -0
- package/dist/ts/core/reflect/state.d.ts +44 -0
- package/dist/ts/core/reflect/state.d.ts.map +1 -0
- package/dist/ts/core/reflect/types.d.ts +289 -0
- package/dist/ts/core/reflect/types.d.ts.map +1 -0
- package/dist/ts/core/reflect/walk.d.ts +28 -0
- package/dist/ts/core/reflect/walk.d.ts.map +1 -0
- package/dist/ts/solidjs/index.d.ts +2 -0
- package/dist/ts/solidjs/index.d.ts.map +1 -0
- package/dist/ts/solidjs/jsx-runtime.d.ts +2 -0
- package/dist/ts/solidjs/jsx-runtime.d.ts.map +1 -0
- package/dist/ts/ui/App.d.ts +17 -0
- package/dist/ts/ui/App.d.ts.map +1 -0
- package/dist/ts/ui/components/Breadcrumb.d.ts +4 -0
- package/dist/ts/ui/components/Breadcrumb.d.ts.map +1 -0
- package/dist/ts/ui/components/Code/index.d.ts +17 -0
- package/dist/ts/ui/components/Code/index.d.ts.map +1 -0
- package/dist/ts/ui/components/Comment.d.ts +49 -0
- package/dist/ts/ui/components/Comment.d.ts.map +1 -0
- package/dist/ts/ui/components/Declaration.d.ts +122 -0
- package/dist/ts/ui/components/Declaration.d.ts.map +1 -0
- package/dist/ts/ui/components/Header.d.ts +5 -0
- package/dist/ts/ui/components/Header.d.ts.map +1 -0
- package/dist/ts/ui/components/Layout.d.ts +5 -0
- package/dist/ts/ui/components/Layout.d.ts.map +1 -0
- package/dist/ts/ui/components/Link.d.ts +15 -0
- package/dist/ts/ui/components/Link.d.ts.map +1 -0
- package/dist/ts/ui/components/LivePreview/Example.d.ts +16 -0
- package/dist/ts/ui/components/LivePreview/Example.d.ts.map +1 -0
- package/dist/ts/ui/components/LivePreview/Sandbox.d.ts +20 -0
- package/dist/ts/ui/components/LivePreview/Sandbox.d.ts.map +1 -0
- package/dist/ts/ui/components/LivePreview/index.d.ts +4 -0
- package/dist/ts/ui/components/LivePreview/index.d.ts.map +1 -0
- package/dist/ts/ui/components/LivePreview/transform.d.ts +19 -0
- package/dist/ts/ui/components/LivePreview/transform.d.ts.map +1 -0
- package/dist/ts/ui/components/Markdown.d.ts +11 -0
- package/dist/ts/ui/components/Markdown.d.ts.map +1 -0
- package/dist/ts/ui/components/Page.d.ts +21 -0
- package/dist/ts/ui/components/Page.d.ts.map +1 -0
- package/dist/ts/ui/components/References.d.ts +2 -0
- package/dist/ts/ui/components/References.d.ts.map +1 -0
- package/dist/ts/ui/components/SearchPalette.d.ts +5 -0
- package/dist/ts/ui/components/SearchPalette.d.ts.map +1 -0
- package/dist/ts/ui/components/Sidebar.d.ts +5 -0
- package/dist/ts/ui/components/Sidebar.d.ts.map +1 -0
- package/dist/ts/ui/components/Syntax.d.ts +15 -0
- package/dist/ts/ui/components/Syntax.d.ts.map +1 -0
- package/dist/ts/ui/components/ThemeToggle.d.ts +2 -0
- package/dist/ts/ui/components/ThemeToggle.d.ts.map +1 -0
- package/dist/ts/ui/components/Type.d.ts +82 -0
- package/dist/ts/ui/components/Type.d.ts.map +1 -0
- package/dist/ts/ui/components/index.d.ts +15 -0
- package/dist/ts/ui/components/index.d.ts.map +1 -0
- package/dist/ts/ui/context/components.d.ts +124 -0
- package/dist/ts/ui/context/components.d.ts.map +1 -0
- package/dist/ts/ui/context/global.d.ts +210 -0
- package/dist/ts/ui/context/global.d.ts.map +1 -0
- package/dist/ts/ui/context/index.d.ts +5 -0
- package/dist/ts/ui/context/index.d.ts.map +1 -0
- package/dist/ts/ui/context/markup/index.d.ts +20 -0
- package/dist/ts/ui/context/markup/index.d.ts.map +1 -0
- package/dist/ts/ui/context/markup/markdown.d.ts +4 -0
- package/dist/ts/ui/context/markup/markdown.d.ts.map +1 -0
- package/dist/ts/ui/context/markup/shiki.d.ts +17 -0
- package/dist/ts/ui/context/markup/shiki.d.ts.map +1 -0
- package/dist/ts/ui/context/markup/util.d.ts +11 -0
- package/dist/ts/ui/context/markup/util.d.ts.map +1 -0
- package/dist/ts/ui/context/project/index.d.ts +25 -0
- package/dist/ts/ui/context/project/index.d.ts.map +1 -0
- package/dist/ts/ui/context/project/indexed.d.ts +4 -0
- package/dist/ts/ui/context/project/indexed.d.ts.map +1 -0
- package/dist/ts/ui/context/project/types.d.ts +13 -0
- package/dist/ts/ui/context/project/types.d.ts.map +1 -0
- package/dist/ts/ui/context/theme.d.ts +12 -0
- package/dist/ts/ui/context/theme.d.ts.map +1 -0
- package/dist/ts/ui/hooks/index.d.ts +29 -0
- package/dist/ts/ui/hooks/index.d.ts.map +1 -0
- package/dist/ts/ui/index.d.ts +5 -0
- package/dist/ts/ui/index.d.ts.map +1 -0
- package/dist/ts/ui/renderer.d.ts +200 -0
- package/dist/ts/ui/renderer.d.ts.map +1 -0
- package/dist/ts/ui/util/comment.d.ts +4 -0
- package/dist/ts/ui/util/comment.d.ts.map +1 -0
- package/dist/ts/ui/util/kind.d.ts +15 -0
- package/dist/ts/ui/util/kind.d.ts.map +1 -0
- package/dist/ts/ui/util/markdown.d.ts +8 -0
- package/dist/ts/ui/util/markdown.d.ts.map +1 -0
- package/dist/ts/ui/util/search.d.ts +20 -0
- package/dist/ts/ui/util/search.d.ts.map +1 -0
- package/package.json +89 -0
- package/src/_lib/fs/index.ts +23 -0
- package/src/_lib/fs/watch.ts +40 -0
- package/src/_lib/index.ts +9 -0
- package/src/_lib/jiti/index.ts +18 -0
- package/src/_lib/path/index.ts +44 -0
- package/src/_lib/pkg/index.ts +165 -0
- package/src/_lib/repo/index.ts +138 -0
- package/src/_lib/slug/index.ts +26 -0
- package/src/_lib/t.ts +17 -0
- package/src/_lib/tsconfig/index.ts +20 -0
- package/src/_lib/util/index.ts +53 -0
- package/src/cli/cmd/dev.ts +86 -0
- package/src/cli/cmd/index.ts +3 -0
- package/src/cli/cmd/init.ts +80 -0
- package/src/cli/cmd/json.ts +28 -0
- package/src/cli/env.ts +6 -0
- package/src/cli/index.ts +14 -0
- package/src/cli/vite/client/index.html +27 -0
- package/src/cli/vite/client/index.tsx +30 -0
- package/src/cli/vite/client/public/apple-touch-icon.png +0 -0
- package/src/cli/vite/client/public/favicon-96x96.png +0 -0
- package/src/cli/vite/client/public/favicon.ico +0 -0
- package/src/cli/vite/client/public/favicon.svg +1 -0
- package/src/cli/vite/client/public/site.webmanifest +21 -0
- package/src/cli/vite/client/public/web-app-manifest-192x192.png +0 -0
- package/src/cli/vite/client/public/web-app-manifest-512x512.png +0 -0
- package/src/cli/vite/index.ts +115 -0
- package/src/cli.ts +6 -0
- package/src/config/defaults.ts +36 -0
- package/src/config/file.ts +53 -0
- package/src/config/index.ts +11 -0
- package/src/config/load.ts +95 -0
- package/src/config/types.ts +59 -0
- package/src/core/index.ts +2 -0
- package/src/core/project/debug.ts +30 -0
- package/src/core/project/index.ts +58 -0
- package/src/core/project/naming.ts +49 -0
- package/src/core/project/routing.ts +234 -0
- package/src/core/project/types.ts +47 -0
- package/src/core/reflect/index.ts +18 -0
- package/src/core/reflect/indexed.ts +242 -0
- package/src/core/reflect/resolve.ts +159 -0
- package/src/core/reflect/scan.ts +816 -0
- package/src/core/reflect/state.ts +75 -0
- package/src/core/reflect/types.ts +164 -0
- package/src/core/reflect/walk.ts +121 -0
- package/src/solidjs/index.ts +1 -0
- package/src/solidjs/jsx-runtime.ts +1 -0
- package/src/ui/App.tsx +115 -0
- package/src/ui/components/Breadcrumb.tsx +53 -0
- package/src/ui/components/Code/index.tsx +112 -0
- package/src/ui/components/Comment.tsx +221 -0
- package/src/ui/components/Declaration.tsx +210 -0
- package/src/ui/components/Header.tsx +99 -0
- package/src/ui/components/Layout.tsx +62 -0
- package/src/ui/components/Link.tsx +43 -0
- package/src/ui/components/LivePreview/Example.tsx +104 -0
- package/src/ui/components/LivePreview/Sandbox.tsx +36 -0
- package/src/ui/components/LivePreview/index.ts +3 -0
- package/src/ui/components/LivePreview/transform.ts +28 -0
- package/src/ui/components/Markdown.tsx +16 -0
- package/src/ui/components/Page.tsx +162 -0
- package/src/ui/components/References.tsx +34 -0
- package/src/ui/components/SearchPalette.tsx +266 -0
- package/src/ui/components/Sidebar.tsx +107 -0
- package/src/ui/components/Syntax.tsx +10 -0
- package/src/ui/components/ThemeToggle.tsx +50 -0
- package/src/ui/components/Type.tsx +583 -0
- package/src/ui/components/index.ts +15 -0
- package/src/ui/context/components.tsx +103 -0
- package/src/ui/context/global.ts +33 -0
- package/src/ui/context/index.ts +4 -0
- package/src/ui/context/markup/index.tsx +39 -0
- package/src/ui/context/markup/markdown.ts +37 -0
- package/src/ui/context/markup/shiki.ts +72 -0
- package/src/ui/context/markup/util.ts +20 -0
- package/src/ui/context/project/index.tsx +47 -0
- package/src/ui/context/project/indexed.ts +52 -0
- package/src/ui/context/project/types.ts +14 -0
- package/src/ui/context/theme.tsx +45 -0
- package/src/ui/hooks/index.ts +116 -0
- package/src/ui/index.ts +4 -0
- package/src/ui/renderer.tsx +31 -0
- package/src/ui/util/comment.ts +12 -0
- package/src/ui/util/kind.ts +120 -0
- package/src/ui/util/markdown.ts +74 -0
- package/src/ui/util/search.ts +84 -0
- package/theme.css +301 -0
- package/tsconfig.client.json +12 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "lickle docs",
|
|
3
|
+
"short_name": "docs",
|
|
4
|
+
"icons": [
|
|
5
|
+
{
|
|
6
|
+
"src": "/web-app-manifest-192x192.png",
|
|
7
|
+
"sizes": "192x192",
|
|
8
|
+
"type": "image/png",
|
|
9
|
+
"purpose": "maskable"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"src": "/web-app-manifest-512x512.png",
|
|
13
|
+
"sizes": "512x512",
|
|
14
|
+
"type": "image/png",
|
|
15
|
+
"purpose": "maskable"
|
|
16
|
+
}
|
|
17
|
+
],
|
|
18
|
+
"theme_color": "#ffffff",
|
|
19
|
+
"background_color": "#ffffff",
|
|
20
|
+
"display": "standalone"
|
|
21
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
2
|
+
import { fileURLToPath } from 'node:url'
|
|
3
|
+
import solid from 'vite-plugin-solid'
|
|
4
|
+
import * as vite from 'vite'
|
|
5
|
+
import path from 'node:path'
|
|
6
|
+
|
|
7
|
+
import * as config from '../../config/index.ts'
|
|
8
|
+
import * as core from '../../core/index.ts'
|
|
9
|
+
import * as lib from '../../_lib/index.ts'
|
|
10
|
+
|
|
11
|
+
const JSON_ID = 'virtual:lickle/docs.json'
|
|
12
|
+
const CUSTOM_ID = 'virtual:lickle/custom.ts'
|
|
13
|
+
const viteRoot = fileURLToPath(new URL('./client', import.meta.url))
|
|
14
|
+
const libRoot = fileURLToPath(new URL('../../../', import.meta.url))
|
|
15
|
+
|
|
16
|
+
export interface DocsOptions extends config.ConfigJson {
|
|
17
|
+
build: () => Promise<core.project.ProjectJson>
|
|
18
|
+
entrypoint?: string | undefined
|
|
19
|
+
watchPaths?: string[]
|
|
20
|
+
viteConfig?: vite.InlineConfig
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const resolveOptions = (opts: DocsOptions, mode: 'dev' | 'build') => {
|
|
24
|
+
const outDir = opts.custom ? path.join(path.dirname(opts.custom), 'dist') : 'docs/dist'
|
|
25
|
+
return {
|
|
26
|
+
root: viteRoot,
|
|
27
|
+
plugins: [solid(), tailwindcss(), docsPlugin(opts, mode)],
|
|
28
|
+
build: { outDir: outDir ? path.resolve(process.cwd(), outDir) : path.resolve(process.cwd(), 'docs/dist') },
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export const dev = async (options: DocsOptions) => {
|
|
33
|
+
const server = await vite.createServer(resolveOptions(options, 'dev'))
|
|
34
|
+
await server.listen()
|
|
35
|
+
server.printUrls()
|
|
36
|
+
return server
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export const build = async (options: DocsOptions) => vite.build(resolveOptions(options, 'build'))
|
|
40
|
+
|
|
41
|
+
const docsPlugin = (opts: DocsOptions, mode: 'dev' | 'build'): vite.Plugin => {
|
|
42
|
+
let json: string | undefined
|
|
43
|
+
let logger: vite.Logger | undefined = undefined
|
|
44
|
+
|
|
45
|
+
const HMR_PATH = `/@virtual:${JSON_ID}`
|
|
46
|
+
const LIB_UI_PATH = path.resolve(libRoot, './src/ui/index.ts')
|
|
47
|
+
const LIB_THEME_CSS_PATH = path.resolve(libRoot, 'theme.css')
|
|
48
|
+
const LIB_SOLIDJS_PATH = path.resolve(libRoot, './src/solidjs/index.ts')
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
name: 'docs',
|
|
52
|
+
enforce: 'pre',
|
|
53
|
+
configResolved(config) {
|
|
54
|
+
logger = config.logger
|
|
55
|
+
},
|
|
56
|
+
config: () => {
|
|
57
|
+
return {
|
|
58
|
+
resolve: {
|
|
59
|
+
alias: {
|
|
60
|
+
'@lickle/docs/ui': LIB_UI_PATH,
|
|
61
|
+
'@lickle/docs/theme.css': LIB_THEME_CSS_PATH,
|
|
62
|
+
'@lickle/docs/solidjs': LIB_SOLIDJS_PATH,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
server: { fs: { allow: [viteRoot, opts.entrypoint ? path.dirname(opts.entrypoint) : viteRoot] } },
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
// transformIndexHtml: {
|
|
70
|
+
// order: 'pre',
|
|
71
|
+
// handler(html) {
|
|
72
|
+
// return html.replace('<script type="module" src="./index.tsx"></script>', `<script type="module" src="${entrypoint}"></script>`)
|
|
73
|
+
// },
|
|
74
|
+
// },
|
|
75
|
+
|
|
76
|
+
resolveId(id) {
|
|
77
|
+
if (id === JSON_ID || id === HMR_PATH) return '\0' + JSON_ID
|
|
78
|
+
if (id === CUSTOM_ID) return '\0' + CUSTOM_ID
|
|
79
|
+
return undefined
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
async load(id) {
|
|
83
|
+
if (id === '\0' + JSON_ID) {
|
|
84
|
+
if (mode === 'build') return JSON.stringify(await opts.build())
|
|
85
|
+
return json ?? 'null'
|
|
86
|
+
}
|
|
87
|
+
if (id === '\0' + CUSTOM_ID) return opts.entrypoint ? `import ${JSON.stringify(opts.entrypoint)}\n` : '\n'
|
|
88
|
+
return undefined
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
configureServer(s) {
|
|
92
|
+
if (!opts.build) return
|
|
93
|
+
const build = opts.build
|
|
94
|
+
const handleJson = async () => {
|
|
95
|
+
if (json) logger?.info('Rebuilding docs', { timestamp: true })
|
|
96
|
+
const nextJson = await build()
|
|
97
|
+
json = JSON.stringify(nextJson)
|
|
98
|
+
logger?.info('Docs built successfully', { timestamp: true })
|
|
99
|
+
|
|
100
|
+
const mod = s.moduleGraph.getModuleById('\0' + JSON_ID)
|
|
101
|
+
if (mod) {
|
|
102
|
+
s.moduleGraph.invalidateModule(mod)
|
|
103
|
+
s.ws.send({ type: 'custom', event: 'docs-update', data: nextJson })
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const watchPaths = opts.watchPaths ?? []
|
|
108
|
+
watchPaths.forEach((p) => s.watcher.add(p))
|
|
109
|
+
|
|
110
|
+
const rebuild = lib.util.serial(() => handleJson())
|
|
111
|
+
s.watcher.on('change', (changedPath) => watchPaths.some((p) => changedPath.includes(p)) && rebuild())
|
|
112
|
+
rebuild()
|
|
113
|
+
},
|
|
114
|
+
}
|
|
115
|
+
}
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import path from 'node:path'
|
|
2
|
+
|
|
3
|
+
import type { ConfigJson } from './types.ts'
|
|
4
|
+
|
|
5
|
+
import * as lib from '../_lib/index.ts'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Resolve a partial `UserConfig` into a fully-defaulted `NewProjectConfig`.
|
|
9
|
+
*
|
|
10
|
+
* Missing fields fall back to `package.json`, conventional project files
|
|
11
|
+
* (`README.md`) and the working directory. `declarations` / `children` stay
|
|
12
|
+
* empty here — the reflection pass fills them once scanning is wired up.
|
|
13
|
+
*/
|
|
14
|
+
export const apply = async (dir: string, c?: Partial<ConfigJson>): Promise<ConfigJson> => {
|
|
15
|
+
const pkg = await lib.pkg.read(process.cwd())
|
|
16
|
+
const info = await lib.repo.info(dir)
|
|
17
|
+
const readme = await lib.fs.existingPath(path.join(dir, 'README.md'))
|
|
18
|
+
const defualtLinks = info ? [{ label: 'Repository', href: info.url }] : []
|
|
19
|
+
const entrypoints = c?.entrypoints ?? (await lib.pkg.resolveExportedSources(dir, pkg))
|
|
20
|
+
const tsconfig = lib.tsconfig.resolve(dir)
|
|
21
|
+
|
|
22
|
+
const name = c?.name ?? pkg?.name
|
|
23
|
+
if (!name) throw new Error('No project name found')
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
...c,
|
|
27
|
+
name,
|
|
28
|
+
version: c?.version ?? pkg?.version ?? info?.tag,
|
|
29
|
+
readme,
|
|
30
|
+
entrypoints,
|
|
31
|
+
links: c?.links ?? defualtLinks,
|
|
32
|
+
repository: info ? { url: info.url, rev: info.commit, fileUrl: info.fileUrl } : undefined,
|
|
33
|
+
srcDir: c?.srcDir ?? tsconfig.rootDir,
|
|
34
|
+
full: c?.full,
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { pathToFileURL } from 'node:url'
|
|
2
|
+
import { createJiti } from 'jiti'
|
|
3
|
+
import fs from 'node:fs/promises'
|
|
4
|
+
import { v } from '@lickle/is'
|
|
5
|
+
import fg from 'fast-glob'
|
|
6
|
+
|
|
7
|
+
import { type ConfigJson } from './types.ts'
|
|
8
|
+
|
|
9
|
+
const EXT = ['ts', 'mts', 'cts', 'js', 'cjs', 'mjs', 'json']
|
|
10
|
+
|
|
11
|
+
export const load = async (dir: string): Promise<ConfigJson | undefined> => {
|
|
12
|
+
const file = await find(dir)
|
|
13
|
+
if (!file) return undefined
|
|
14
|
+
if (file.endsWith('.json')) return readJson(file)
|
|
15
|
+
return readCode(file)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const find = async (dir: string): Promise<string | undefined> => {
|
|
19
|
+
const ext = EXT.join(',')
|
|
20
|
+
const files = await fg.glob(`lickle.{${ext}}`, { cwd: dir, absolute: true })
|
|
21
|
+
return files?.[0]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const readCode = async (file: string): Promise<ConfigJson> => {
|
|
25
|
+
const jti = createJiti(pathToFileURL(import.meta.url).href, {
|
|
26
|
+
moduleCache: false,
|
|
27
|
+
cache: false,
|
|
28
|
+
})
|
|
29
|
+
const mod = await jti.import<{ default: any }>(file)
|
|
30
|
+
const fl = await mod.default
|
|
31
|
+
return valid(fl)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const readJson = async (file: string): Promise<ConfigJson> => {
|
|
35
|
+
const content = await fs.readFile(file, 'utf-8')
|
|
36
|
+
const j = JSON.parse(content) as unknown
|
|
37
|
+
return valid(j)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const schema = v.struct({
|
|
41
|
+
name: v.string,
|
|
42
|
+
version: v.or(v.string, v.undefined),
|
|
43
|
+
readme: v.or(v.string, v.undefined),
|
|
44
|
+
links: v.or(v.array(v.struct({ label: v.string, href: v.string })), v.undefined),
|
|
45
|
+
tsconfig: v.or(v.string, v.undefined),
|
|
46
|
+
repository: v.or(v.struct({ url: v.string, rev: v.string, fileUrl: v.string }), v.undefined),
|
|
47
|
+
srcDir: v.or(v.string, v.undefined),
|
|
48
|
+
entrypoints: v.or(v.array(v.struct({ as: v.string, path: v.string })), v.undefined),
|
|
49
|
+
exclude: v.or(v.array(v.string), v.undefined),
|
|
50
|
+
full: v.or(v.boolean, v.undefined),
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
const valid = v.assert(schema)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as lib from '../_lib/index.ts'
|
|
2
|
+
|
|
3
|
+
import type { ConfigJson } from './types.ts'
|
|
4
|
+
export type * from './types.ts'
|
|
5
|
+
|
|
6
|
+
export const defineConfig = <C extends ConfigJson | (() => ConfigJson) | (() => Promise<ConfigJson>)>(config: C) => {
|
|
7
|
+
const c = typeof config === 'function' ? config() : config
|
|
8
|
+
return Promise.resolve(c)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const fromExports = async () => lib.pkg.resolveExportedSources(process.cwd(), await lib.pkg.read(process.cwd()))
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import fs from 'node:fs/promises'
|
|
2
|
+
import { v } from '@lickle/is'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
import ts from 'typescript'
|
|
5
|
+
import fg from 'fast-glob'
|
|
6
|
+
|
|
7
|
+
import type * as project from '../core/project/index.ts'
|
|
8
|
+
import * as lib from '../_lib/index.ts'
|
|
9
|
+
|
|
10
|
+
import { type ConfigJson } from './types.ts'
|
|
11
|
+
import * as defaults from './defaults.ts'
|
|
12
|
+
import * as types from './types.ts'
|
|
13
|
+
|
|
14
|
+
export type * from './types.ts'
|
|
15
|
+
|
|
16
|
+
const EXT = ['ts', 'mts', 'cts', 'js', 'cjs', 'mjs', 'json']
|
|
17
|
+
|
|
18
|
+
export const loadGen = async (dir: string = process.cwd(), opts?: Partial<types.ConfigJson>) => {
|
|
19
|
+
const c = await load(dir, opts)
|
|
20
|
+
return toGenerateOptions(c)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const toGenerateOptions = async (c: ConfigJson & { compilerOptions: ts.CompilerOptions }) => {
|
|
24
|
+
const gen: project.GenerateOptions = {
|
|
25
|
+
dir: process.cwd(),
|
|
26
|
+
...c,
|
|
27
|
+
exclude: c.exclude ?? [],
|
|
28
|
+
config: { entrypoints: [], links: [], ...c, routes: [] },
|
|
29
|
+
compilerOptions: c.compilerOptions,
|
|
30
|
+
full: c.full,
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (c.readme) {
|
|
34
|
+
const page: project.PageType<'markdown'> = {
|
|
35
|
+
kind: 'markdown',
|
|
36
|
+
content: await lib.fs.readFile(c.readme, 'utf-8'),
|
|
37
|
+
}
|
|
38
|
+
gen.config.routes = [{ label: 'README', slug: 'readme', page, children: [], sidebar: true }]
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return gen
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const load = async (
|
|
45
|
+
dir: string = process.cwd(),
|
|
46
|
+
opts?: Partial<types.ConfigJson>,
|
|
47
|
+
): Promise<types.ConfigJson & { compilerOptions: ts.CompilerOptions }> => {
|
|
48
|
+
const c = lib.tsconfig.resolve(dir)
|
|
49
|
+
if (!c.config) throw new Error('No tsconfig.json found')
|
|
50
|
+
const loaded = await loadFile(dir)
|
|
51
|
+
const info = await defaults.apply(dir, { ...loaded, ...opts })
|
|
52
|
+
const parsed = ts.parseJsonConfigFileContent(c.config, ts.sys, path.dirname(c.config.path))
|
|
53
|
+
return { ...info, compilerOptions: parsed.options }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const loadFile = async (dir: string): Promise<ConfigJson | undefined> => {
|
|
57
|
+
const file = await findFile(dir)
|
|
58
|
+
if (!file) return undefined
|
|
59
|
+
if (file.endsWith('.json')) return readJson(file)
|
|
60
|
+
return readCode(file)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const findFile = async (dir: string): Promise<string | undefined> => {
|
|
64
|
+
const ext = EXT.join(',')
|
|
65
|
+
const files = await fg.glob(`lickle.{${ext}}`, { cwd: dir, absolute: true })
|
|
66
|
+
return files?.[0]
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const readCode = async (file: string): Promise<ConfigJson> => {
|
|
70
|
+
const mod = await lib.jiti.importModule<{ default: any }>(file)
|
|
71
|
+
return valid(mod.default)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const readJson = async (file: string): Promise<ConfigJson> => {
|
|
75
|
+
const content = await fs.readFile(file, 'utf-8')
|
|
76
|
+
const j = JSON.parse(content) as unknown
|
|
77
|
+
return valid(j)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const schema = v.struct({
|
|
81
|
+
name: v.string,
|
|
82
|
+
version: v.or(v.string, v.undefined),
|
|
83
|
+
readme: v.or(v.string, v.undefined),
|
|
84
|
+
links: v.or(v.array(v.struct({ label: v.string, href: v.string })), v.undefined),
|
|
85
|
+
tsconfig: v.or(v.string, v.undefined),
|
|
86
|
+
repository: v.or(v.struct({ url: v.string, rev: v.string, fileUrl: v.string }), v.undefined),
|
|
87
|
+
srcDir: v.or(v.string, v.undefined),
|
|
88
|
+
entrypoints: v.or(v.array(v.struct({ as: v.string, path: v.string })), v.undefined),
|
|
89
|
+
exclude: v.or(v.array(v.string), v.undefined),
|
|
90
|
+
full: v.or(v.boolean, v.undefined),
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const valid = (c: unknown): ConfigJson => {
|
|
94
|
+
return c as ConfigJson
|
|
95
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** Configuration used for generating the project json */
|
|
2
|
+
export interface ConfigJson {
|
|
3
|
+
/** The name of the project. default is the package name from package.json */
|
|
4
|
+
name: string
|
|
5
|
+
/** The version of the project. default is the package version from package.json */
|
|
6
|
+
version?: string
|
|
7
|
+
/** README file path, default is README.md in the project root shown as home page */
|
|
8
|
+
readme?: string
|
|
9
|
+
/** Links for the project. defaults to package.json repository url */
|
|
10
|
+
links?: Link[]
|
|
11
|
+
/** tsconfig.json file path, default is tsconfig.json in the project root */
|
|
12
|
+
tsconfig?: string
|
|
13
|
+
/** Repository information */
|
|
14
|
+
repository?: Repo
|
|
15
|
+
/** Source directory, default to tsconfig.json `rootDir` or src */
|
|
16
|
+
srcDir?: string
|
|
17
|
+
/** Entrypoints — relative source paths reachable from `main` / `exports`. */
|
|
18
|
+
entrypoints?: Entry[]
|
|
19
|
+
/** Pages to include in the project. Default is the README file. */
|
|
20
|
+
pages?: Page[]
|
|
21
|
+
/** Custom */
|
|
22
|
+
custom?: string
|
|
23
|
+
/** Files to exclude from the project (micromatch glob patterns) */
|
|
24
|
+
exclude?: string[]
|
|
25
|
+
/** Document every declaration, not just the exported public API. Default false. */
|
|
26
|
+
full?: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface Page {
|
|
30
|
+
/** Page title */
|
|
31
|
+
title: string
|
|
32
|
+
/** Page path */
|
|
33
|
+
slug?: string
|
|
34
|
+
/** Page content */
|
|
35
|
+
content: string
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface Entry {
|
|
39
|
+
/** Label used in the navigation */
|
|
40
|
+
as: string
|
|
41
|
+
/** File path or array of file paths, ['./src/index.ts'] */
|
|
42
|
+
path: string
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface Link {
|
|
46
|
+
/** Label used in the navigation */
|
|
47
|
+
label: string
|
|
48
|
+
/** URL */
|
|
49
|
+
href: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface Repo {
|
|
53
|
+
/** Repository URL */
|
|
54
|
+
url: string
|
|
55
|
+
/** Repository commit */
|
|
56
|
+
rev?: string
|
|
57
|
+
/** Repository file URL template with {PATH} {LINE} {COLUMN} to link to the source code */
|
|
58
|
+
fileUrl?: string
|
|
59
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { RouteNode } from './index.ts'
|
|
2
|
+
|
|
3
|
+
export const displayRoutes = (routes: RouteNode[], prefix: string = '') => {
|
|
4
|
+
const kinds = { module: 'M', markdown: '.MD', declaration: 'D' }
|
|
5
|
+
// console.log(JSON.stringify(compact(routes)))
|
|
6
|
+
|
|
7
|
+
// routes.map
|
|
8
|
+
for (const r of routes) {
|
|
9
|
+
const id = (r.page as { id?: number }).id ?? r.label
|
|
10
|
+
console.log(`${prefix}${kinds[r.page.kind]} ${id} (${r.slug})`)
|
|
11
|
+
if (r.children) displayRoutes(r.children, prefix + ' ')
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type CompactRouteNode = Pick<RouteNode, 'label' | 'slug'> & { children: CompactRouteNode[] }
|
|
16
|
+
|
|
17
|
+
const compact = (routes: RouteNode[]): CompactRouteNode[] => {
|
|
18
|
+
return routes
|
|
19
|
+
.map((r) => {
|
|
20
|
+
// if (r.page.kind === 'declaration') return ['D']
|
|
21
|
+
return [
|
|
22
|
+
{
|
|
23
|
+
label: r.label,
|
|
24
|
+
slug: r.slug,
|
|
25
|
+
children: compact(r.children),
|
|
26
|
+
},
|
|
27
|
+
]
|
|
28
|
+
})
|
|
29
|
+
.flat()
|
|
30
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import ts from 'typescript'
|
|
2
|
+
import mm from 'micromatch'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
|
|
5
|
+
import type { ProjectJson, RouteNode } from './types.ts'
|
|
6
|
+
import * as reflect from '../reflect/index.ts'
|
|
7
|
+
import * as routing from './routing.ts'
|
|
8
|
+
|
|
9
|
+
export * from './debug.ts'
|
|
10
|
+
export * from './types.ts'
|
|
11
|
+
|
|
12
|
+
export type GenerateOptions = {
|
|
13
|
+
dir: string
|
|
14
|
+
exclude: string[]
|
|
15
|
+
config: Omit<ProjectJson, 'declarations'>
|
|
16
|
+
compilerOptions: ts.CompilerOptions
|
|
17
|
+
/** Override route naming / grouping / nav visibility. */
|
|
18
|
+
routeProvider?: routing.RouteProvider
|
|
19
|
+
/** Route every scanned declaration (incl. non-exported), not just the public API. */
|
|
20
|
+
full?: boolean
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const buildJson = async (opts: GenerateOptions): Promise<ProjectJson> => {
|
|
24
|
+
const graph = reflect.generate(opts.config.entrypoints, {
|
|
25
|
+
compilerOptions: opts.compilerOptions,
|
|
26
|
+
rootDir: opts.dir,
|
|
27
|
+
include: keepFile(opts),
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const routes = Array.from(
|
|
31
|
+
routing.buildRoutes(graph, {
|
|
32
|
+
entrypoints: opts.config.entrypoints,
|
|
33
|
+
rootName: opts.config.name,
|
|
34
|
+
provider: opts.routeProvider,
|
|
35
|
+
mode: opts.full ? 'full' : 'exposed',
|
|
36
|
+
reserved: collectSlugs(opts.config.routes),
|
|
37
|
+
}),
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
...opts.config,
|
|
42
|
+
declarations: [...graph.declarations()],
|
|
43
|
+
routes: [...opts.config.routes, ...routes],
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** All slugs in a route subtree, so routing can avoid colliding with them. */
|
|
48
|
+
const collectSlugs = (routes: RouteNode[]): string[] => routes.flatMap((r) => [r.slug, ...collectSlugs(r.children)])
|
|
49
|
+
|
|
50
|
+
const keepFile =
|
|
51
|
+
(opts: GenerateOptions) =>
|
|
52
|
+
(sf: ts.SourceFile): boolean => {
|
|
53
|
+
if (sf.isDeclarationFile) return false
|
|
54
|
+
if (sf.fileName.includes('/node_modules/')) return false
|
|
55
|
+
const relative = path.relative(opts.dir, sf.fileName)
|
|
56
|
+
if (opts.exclude?.some((i) => mm.isMatch(relative, i))) return false
|
|
57
|
+
return true
|
|
58
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as path from '../../_lib/path/index.ts'
|
|
2
|
+
import type * as reflect from '../reflect/index.ts'
|
|
3
|
+
|
|
4
|
+
/** Display + URL identity for a route. */
|
|
5
|
+
export type Parts = { label: string; slug: string; qualified: string }
|
|
6
|
+
|
|
7
|
+
export type NameOptions = {
|
|
8
|
+
/** Project name, used as the label of the main entry module. */
|
|
9
|
+
rootName: string
|
|
10
|
+
/** Module path -> entrypoint alias (the `as` value without a leading `./`). */
|
|
11
|
+
aliases: Map<string, string>
|
|
12
|
+
/** Common directory prefix shared by every module path. */
|
|
13
|
+
commonDir: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Parts for a root entry module — its slug is the site-relative base that all
|
|
18
|
+
* descendants build on. The main entry (`.`) lives at the root (`''`).
|
|
19
|
+
*/
|
|
20
|
+
export const rootParts = (d: reflect.Declaration<'module'>, opts: NameOptions): Parts => {
|
|
21
|
+
const alias = opts.aliases.get(d.path)
|
|
22
|
+
if (alias && alias !== '.') return { label: alias, slug: alias, qualified: alias }
|
|
23
|
+
const seg = moduleSegments(d.path, opts.commonDir)
|
|
24
|
+
if (seg.length === 0) return { label: opts.rootName, slug: '', qualified: opts.rootName }
|
|
25
|
+
const joined = seg.join('.')
|
|
26
|
+
return { label: joined, slug: seg.join('/'), qualified: joined }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Parts for a route nested under `parent`, named by its local `segment`. */
|
|
30
|
+
export const childParts = (segment: string, parent: Parts): Parts => ({
|
|
31
|
+
label: segment,
|
|
32
|
+
slug: parent.slug ? `${parent.slug}/${segment}` : segment,
|
|
33
|
+
qualified: parent.qualified ? `${parent.qualified}.${segment}` : segment,
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Module path -> path segments, relative to the common source dir, with the
|
|
38
|
+
* file extension dropped and a trailing `index` removed. Pure string ops, so
|
|
39
|
+
* no regex is built from (and broken by) arbitrary file paths.
|
|
40
|
+
*/
|
|
41
|
+
const moduleSegments = (modulePath: string, commonDir: string): string[] => {
|
|
42
|
+
let rel = modulePath
|
|
43
|
+
if (commonDir && rel.startsWith(commonDir)) rel = rel.slice(commonDir.length)
|
|
44
|
+
const segs = rel.split('/').filter(Boolean)
|
|
45
|
+
const last = segs[segs.length - 1]
|
|
46
|
+
if (last && /^index\./.test(last)) segs.pop()
|
|
47
|
+
else if (last) segs[segs.length - 1] = path.stripExt(last)
|
|
48
|
+
return segs
|
|
49
|
+
}
|