@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,44 @@
|
|
|
1
|
+
export const common = (pths: string[]): string => {
|
|
2
|
+
if (pths.length === 0) return ''
|
|
3
|
+
|
|
4
|
+
const split = pths.map((p) => p.split('/'))
|
|
5
|
+
const first = split[0]!
|
|
6
|
+
let i = 0
|
|
7
|
+
for (; i < first.length; i++) {
|
|
8
|
+
if (!split.every((parts) => parts[i] === first[i])) break
|
|
9
|
+
}
|
|
10
|
+
return first.slice(0, i).join('/')
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const slugMaker = () => {
|
|
14
|
+
const used = new Set<string>()
|
|
15
|
+
return {
|
|
16
|
+
uniq: (sl: string) => uniqueSlug(sl, used),
|
|
17
|
+
add: (sl: string) => {
|
|
18
|
+
if (used.has(sl)) throw new Error(`Duplicate slug: ${sl}`)
|
|
19
|
+
used.add(sl)
|
|
20
|
+
},
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const make = slugMaker()
|
|
25
|
+
|
|
26
|
+
export const stripExt = (s: string): string => s.replace(/\.[^./]+$/, '')
|
|
27
|
+
|
|
28
|
+
export const toSlug = (s: string): string =>
|
|
29
|
+
s
|
|
30
|
+
.toLowerCase()
|
|
31
|
+
.replace(/[^a-z0-9.]+/g, '-')
|
|
32
|
+
.replace(/^-+|-+$/g, '')
|
|
33
|
+
|
|
34
|
+
const uniqueSlug = (base: string, used: Set<string>): string => {
|
|
35
|
+
if (!used.has(base)) {
|
|
36
|
+
used.add(base)
|
|
37
|
+
return base
|
|
38
|
+
}
|
|
39
|
+
let n = 2
|
|
40
|
+
while (used.has(`${base}-${n}`)) n++
|
|
41
|
+
const slug = `${base}-${n}`
|
|
42
|
+
used.add(slug)
|
|
43
|
+
return slug
|
|
44
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { exports as resolveExports, type Package } from 'resolve.exports'
|
|
2
|
+
import { promises as fs } from 'node:fs'
|
|
3
|
+
import path from 'node:path'
|
|
4
|
+
|
|
5
|
+
import * as tsconfig from '../tsconfig/index.ts'
|
|
6
|
+
import { memo1 } from '../util/index.ts'
|
|
7
|
+
|
|
8
|
+
export interface PackageJson extends Package {
|
|
9
|
+
repository?: { type: string; url: string; directory?: string } | string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const read = memo1(async (projectDir: string) => {
|
|
13
|
+
const pkg = JSON.parse(await fs.readFile(path.join(projectDir, 'package.json'), 'utf8'))
|
|
14
|
+
return pkg as PackageJson
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
export type ExportedSource = { path: string; as: string }
|
|
18
|
+
|
|
19
|
+
interface Options {
|
|
20
|
+
/** Resolve "require"/"node" conditions instead of "import". @default false */
|
|
21
|
+
require?: boolean
|
|
22
|
+
/** Extra user conditions to match (e.g. "development"). */
|
|
23
|
+
conditions?: readonly string[]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Returns the source files corresponding to a package's published entry points,
|
|
28
|
+
* resolving `exports` (with conditions/wildcards) or `main`, mapping each emitted
|
|
29
|
+
* file back to its source via `.d.ts.map`/`.js.map` source maps when available,
|
|
30
|
+
* and otherwise via the tsconfig `outDir`/`rootDir` swap.
|
|
31
|
+
*/
|
|
32
|
+
export const resolveExportedSources = async (
|
|
33
|
+
projectDir: string,
|
|
34
|
+
pkg: PackageJson,
|
|
35
|
+
options: Options = {},
|
|
36
|
+
): Promise<ExportedSource[]> => {
|
|
37
|
+
// --- 1. enumerate (subpath -> dist file) -------------------------------
|
|
38
|
+
const entries: { as: string; dist: string }[] = []
|
|
39
|
+
|
|
40
|
+
if (pkg.exports != null) {
|
|
41
|
+
for (const subpath of listExportSubpaths(pkg.exports)) {
|
|
42
|
+
// resolve.exports applies condition + wildcard logic for this subpath.
|
|
43
|
+
const resolved = resolveExports(pkg, subpath, {
|
|
44
|
+
require: options.require,
|
|
45
|
+
conditions: options.conditions,
|
|
46
|
+
})
|
|
47
|
+
const dist = resolved?.[0]
|
|
48
|
+
if (dist) entries.push({ as: subpath, dist })
|
|
49
|
+
}
|
|
50
|
+
} else if (typeof pkg.main === 'string') {
|
|
51
|
+
entries.push({ as: '.', dist: pkg.main })
|
|
52
|
+
} else if (typeof pkg.module === 'string') {
|
|
53
|
+
entries.push({ as: '.', dist: pkg.module })
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// --- 2. tsconfig fallback paths ----------------------------------------
|
|
57
|
+
const { outDir, rootDir } = tsconfig.resolve(projectDir)
|
|
58
|
+
|
|
59
|
+
// --- 3. dist -> source --------------------------------------------------
|
|
60
|
+
const results: ExportedSource[] = []
|
|
61
|
+
const seen = new Set<string>()
|
|
62
|
+
|
|
63
|
+
for (const { as, dist } of entries) {
|
|
64
|
+
const distAbs = path.resolve(projectDir, dist)
|
|
65
|
+
const src =
|
|
66
|
+
(await resolveViaSourceMap(distAbs, projectDir)) ??
|
|
67
|
+
(await resolveViaTsconfig(distAbs, projectDir, outDir, rootDir))
|
|
68
|
+
if (!src) continue
|
|
69
|
+
|
|
70
|
+
const key = `${as}\0${src}`
|
|
71
|
+
if (seen.has(key)) continue
|
|
72
|
+
seen.add(key)
|
|
73
|
+
results.push({ as, path: src })
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return results
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// --- exports enumeration --------------------------------------------------
|
|
80
|
+
|
|
81
|
+
/** List the subpath keys of an `exports` field (".", "./foo", ...). */
|
|
82
|
+
const listExportSubpaths = (exportsField: unknown): string[] => {
|
|
83
|
+
if (typeof exportsField === 'string') return ['.']
|
|
84
|
+
if (exportsField == null || typeof exportsField !== 'object') return []
|
|
85
|
+
|
|
86
|
+
const keys = Object.keys(exportsField as Record<string, unknown>)
|
|
87
|
+
const subpathKeys = keys.filter((k) => k === '.' || k.startsWith('./'))
|
|
88
|
+
|
|
89
|
+
// If no subpath-style keys, the object is a bare conditions map for ".".
|
|
90
|
+
return subpathKeys.length > 0 ? subpathKeys : ['.']
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// --- dist -> source: source maps -----------------------------------------
|
|
94
|
+
|
|
95
|
+
const resolveViaSourceMap = async (distAbs: string, projectDir: string): Promise<string | null> => {
|
|
96
|
+
// Prefer the declaration map, then the js map.
|
|
97
|
+
const mapCandidates = [
|
|
98
|
+
distAbs.replace(/\.d\.ts$/, '.d.ts.map'),
|
|
99
|
+
distAbs + '.map',
|
|
100
|
+
distAbs.replace(/\.(js|mjs|cjs|jsx)$/, (m) => m + '.map'),
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
for (const mapPath of mapCandidates) {
|
|
104
|
+
let raw: string
|
|
105
|
+
try {
|
|
106
|
+
raw = await fs.readFile(mapPath, 'utf8')
|
|
107
|
+
} catch {
|
|
108
|
+
continue
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
let map: { sources?: string[]; sourceRoot?: string }
|
|
112
|
+
try {
|
|
113
|
+
map = JSON.parse(raw)
|
|
114
|
+
} catch {
|
|
115
|
+
continue
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const first = map.sources?.[0]
|
|
119
|
+
if (!first) continue
|
|
120
|
+
|
|
121
|
+
const sourceAbs = path.resolve(path.dirname(mapPath), map.sourceRoot ?? '', first)
|
|
122
|
+
return toPosixRelative(projectDir, sourceAbs)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return null
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// --- dist -> source: tsconfig outDir/rootDir swap ------------------------
|
|
129
|
+
|
|
130
|
+
const resolveViaTsconfig = async (
|
|
131
|
+
distAbs: string,
|
|
132
|
+
projectDir: string,
|
|
133
|
+
outDir: string,
|
|
134
|
+
rootDir: string,
|
|
135
|
+
): Promise<string | null> => {
|
|
136
|
+
const rel = path.relative(outDir, distAbs)
|
|
137
|
+
if (rel.startsWith('..')) return null
|
|
138
|
+
|
|
139
|
+
const base = rel.replace(/\.d\.ts$/, '').replace(/\.(js|mjs|cjs|jsx)$/, '')
|
|
140
|
+
const candidateBase = path.join(rootDir, base)
|
|
141
|
+
|
|
142
|
+
for (const ext of ['.ts', '.tsx', '.mts', '.cts', '.js', '.jsx']) {
|
|
143
|
+
for (const candidate of [candidateBase + ext, path.join(candidateBase, 'index' + ext)]) {
|
|
144
|
+
if (await exists(candidate)) {
|
|
145
|
+
return toPosixRelative(projectDir, candidate)
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return null
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// --- helpers --------------------------------------------------------------
|
|
153
|
+
|
|
154
|
+
function toPosixRelative(from: string, to: string): string {
|
|
155
|
+
return path.relative(from, to).split(path.sep).join('/')
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
async function exists(p: string): Promise<boolean> {
|
|
159
|
+
try {
|
|
160
|
+
await fs.access(p)
|
|
161
|
+
return true
|
|
162
|
+
} catch {
|
|
163
|
+
return false
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { execFile } from 'node:child_process'
|
|
2
|
+
import { promisify } from 'node:util'
|
|
3
|
+
|
|
4
|
+
import hostedGitInfo from 'hosted-git-info'
|
|
5
|
+
import * as pkg from '../pkg/index.ts'
|
|
6
|
+
|
|
7
|
+
const exec = promisify(execFile)
|
|
8
|
+
|
|
9
|
+
export interface RepoInfo {
|
|
10
|
+
/** Clean browseable web URL, e.g. https://github.com/user/repo */
|
|
11
|
+
url: string
|
|
12
|
+
/** Web URL pointing at the package's subdirectory, if `directory` is set. */
|
|
13
|
+
directoryUrl?: string
|
|
14
|
+
/** Normalized git clone URL, e.g. git+https://github.com/user/repo.git */
|
|
15
|
+
git: string
|
|
16
|
+
/** Host shortcut, e.g. github:user/repo */
|
|
17
|
+
shortcut: string
|
|
18
|
+
host: string // "github.com", "gitlab.com", ...
|
|
19
|
+
user: string
|
|
20
|
+
project: string
|
|
21
|
+
/** Short commit hash of HEAD, if inside a git work tree. */
|
|
22
|
+
commit?: string
|
|
23
|
+
/** Nearest tag describing HEAD (e.g. "v1.2.0" or "v1.2.0-3-gabc123"). */
|
|
24
|
+
tag?: string
|
|
25
|
+
/** Web URL pinned to the resolved commit, if available. */
|
|
26
|
+
commitUrl?: string
|
|
27
|
+
/** Web URL pinned to the resolved commit, if available. */
|
|
28
|
+
fileUrl?: string
|
|
29
|
+
/** Where the URL came from. */
|
|
30
|
+
source: 'package.json' | 'git'
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Resolve a project's repository URL.
|
|
35
|
+
* Reads package.json `repository` (string or object, including monorepo
|
|
36
|
+
* `directory`), falling back to the local git `origin` remote.
|
|
37
|
+
*/
|
|
38
|
+
export const info = async (projectDir: string): Promise<RepoInfo | null> => {
|
|
39
|
+
const rev = await getGitRevision(projectDir)
|
|
40
|
+
const fromPkg = await fromPackageJson(projectDir, rev)
|
|
41
|
+
if (fromPkg) return fromPkg
|
|
42
|
+
return fromGit(projectDir, rev)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
type GitRevision = { commit?: string; tag?: string }
|
|
46
|
+
|
|
47
|
+
async function getGitRevision(projectDir: string): Promise<GitRevision> {
|
|
48
|
+
const commit = await gitOut(projectDir, ['rev-parse', '--short', 'HEAD'])
|
|
49
|
+
const described = await gitOut(projectDir, ['describe', '--tags', '--always'])
|
|
50
|
+
const tag = described && described !== commit ? described : undefined
|
|
51
|
+
return { commit: commit || undefined, tag }
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function gitOut(cwd: string, args: string[]): Promise<string | null> {
|
|
55
|
+
try {
|
|
56
|
+
const { stdout } = await exec('git', args, { cwd })
|
|
57
|
+
return stdout.trim()
|
|
58
|
+
} catch {
|
|
59
|
+
return null
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function fromPackageJson(projectDir: string, rev: GitRevision): Promise<RepoInfo | null> {
|
|
64
|
+
let pk: pkg.PackageJson
|
|
65
|
+
try {
|
|
66
|
+
pk = await pkg.read(projectDir)
|
|
67
|
+
} catch {
|
|
68
|
+
return null
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const repo = pk.repository
|
|
72
|
+
if (repo == null) return null
|
|
73
|
+
|
|
74
|
+
const rawUrl = typeof repo === 'string' ? repo : repo.url
|
|
75
|
+
const directory = typeof repo === 'object' ? repo.directory : undefined
|
|
76
|
+
if (typeof rawUrl !== 'string') return null
|
|
77
|
+
|
|
78
|
+
const info = hostedGitInfo.fromUrl(rawUrl)
|
|
79
|
+
if (!info) {
|
|
80
|
+
// Unrecognized host: return the raw url, best-effort.
|
|
81
|
+
return {
|
|
82
|
+
url: rawUrl.replace(/^git\+/, '').replace(/\.git$/, ''),
|
|
83
|
+
git: rawUrl,
|
|
84
|
+
shortcut: rawUrl,
|
|
85
|
+
host: '',
|
|
86
|
+
user: '',
|
|
87
|
+
project: '',
|
|
88
|
+
commit: rev.commit,
|
|
89
|
+
tag: rev.tag,
|
|
90
|
+
source: 'package.json',
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return build(info, directory, rev, 'package.json')
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
async function fromGit(projectDir: string, rev: GitRevision): Promise<RepoInfo | null> {
|
|
98
|
+
const origin = await gitOut(projectDir, ['config', '--get', 'remote.origin.url'])
|
|
99
|
+
if (!origin) return null
|
|
100
|
+
|
|
101
|
+
const info = hostedGitInfo.fromUrl(origin)
|
|
102
|
+
if (!info) return null
|
|
103
|
+
return build(info, undefined, rev, 'git')
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function build(
|
|
107
|
+
info: hostedGitInfo,
|
|
108
|
+
directory: string | undefined,
|
|
109
|
+
rev: GitRevision,
|
|
110
|
+
source: RepoInfo['source'],
|
|
111
|
+
): RepoInfo {
|
|
112
|
+
const url = info.browse()
|
|
113
|
+
// Pin to the commit: `${repo}/tree/${commit}[/${directory}]`. This layout is
|
|
114
|
+
// shared by GitHub, GitLab, and Bitbucket; browse()'s committish arg is only
|
|
115
|
+
// a URL fragment in this version, so we construct it explicitly.
|
|
116
|
+
const commitUrl = rev.commit
|
|
117
|
+
? `${url}/tree/${rev.commit}${directory ? '/' + directory.replace(/^\/+/, '') : ''}`
|
|
118
|
+
: undefined
|
|
119
|
+
|
|
120
|
+
const fileUrl = rev.commit
|
|
121
|
+
? `${url}/blob/${rev.commit}${directory ? '/' + directory.replace(/^\/+/, '') : ''}{PATH}#L{LINE}`
|
|
122
|
+
: undefined
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
url,
|
|
126
|
+
directoryUrl: directory ? info.browse(directory) : undefined,
|
|
127
|
+
git: info.https(),
|
|
128
|
+
shortcut: info.shortcut(),
|
|
129
|
+
host: info.domain,
|
|
130
|
+
user: info.user,
|
|
131
|
+
project: info.project,
|
|
132
|
+
commit: rev.commit,
|
|
133
|
+
tag: rev.tag,
|
|
134
|
+
commitUrl,
|
|
135
|
+
fileUrl,
|
|
136
|
+
source,
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const slugBuilder = () => {
|
|
2
|
+
const used = new Set<string>()
|
|
3
|
+
return (sl: string) => uniqueSlug(toSlug(sl), used)
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export const make = slugBuilder()
|
|
7
|
+
|
|
8
|
+
export const stripExt = (s: string): string => s.replace(/\.[^./]+$/, '')
|
|
9
|
+
|
|
10
|
+
export const toSlug = (s: string): string =>
|
|
11
|
+
s
|
|
12
|
+
.toLowerCase()
|
|
13
|
+
.replace(/[^a-z0-9.]+/g, '-')
|
|
14
|
+
.replace(/^-+|-+$/g, '')
|
|
15
|
+
|
|
16
|
+
const uniqueSlug = (base: string, used: Set<string>): string => {
|
|
17
|
+
if (!used.has(base)) {
|
|
18
|
+
used.add(base)
|
|
19
|
+
return base
|
|
20
|
+
}
|
|
21
|
+
let n = 2
|
|
22
|
+
while (used.has(`${base}-${n}`)) n++
|
|
23
|
+
const slug = `${base}-${n}`
|
|
24
|
+
used.add(slug)
|
|
25
|
+
return slug
|
|
26
|
+
}
|
package/src/_lib/t.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type MapKind<
|
|
2
|
+
Map extends Record<string, any>,
|
|
3
|
+
Key extends string = 'kind',
|
|
4
|
+
Extra extends Record<string, any> = {},
|
|
5
|
+
> = {
|
|
6
|
+
[K in keyof Map]: Compute<Map[K] & Extra & { [_K in Key]: K }>
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export type MapKindUnion<
|
|
10
|
+
Map extends Record<string, any>,
|
|
11
|
+
Key extends string = 'kind',
|
|
12
|
+
Extra extends Record<string, any> = {},
|
|
13
|
+
> = MapKind<Map, Key, Extra>[keyof Map]
|
|
14
|
+
|
|
15
|
+
export type Compute<T> = { [K in keyof T]: T[K] } & {}
|
|
16
|
+
|
|
17
|
+
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { getTsconfig, type TsConfigResult } from 'get-tsconfig'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
|
|
4
|
+
import { memo1 } from '../util/index.ts'
|
|
5
|
+
|
|
6
|
+
export type ResolvedTsconfig = {
|
|
7
|
+
config: TsConfigResult | null
|
|
8
|
+
outDir: string
|
|
9
|
+
rootDir: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const resolve = memo1((projectDir: string): ResolvedTsconfig => {
|
|
13
|
+
const tsconfigResult = getTsconfig(projectDir) // resolves `extends`, JSONC, etc.
|
|
14
|
+
const opts = tsconfigResult?.config.compilerOptions ?? {}
|
|
15
|
+
const tsconfigDir = tsconfigResult ? path.dirname(tsconfigResult.path) : projectDir
|
|
16
|
+
const outDir = path.resolve(tsconfigDir, opts.outDir ?? 'dist')
|
|
17
|
+
const rootDir = path.resolve(tsconfigDir, opts.rootDir ?? 'src')
|
|
18
|
+
|
|
19
|
+
return { outDir, rootDir, config: tsconfigResult }
|
|
20
|
+
})
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
type Fn = (...args: any[]) => any
|
|
2
|
+
export const memo = <F extends Fn>(fn: F): F => {
|
|
3
|
+
const cache = new Map<string, ReturnType<F>>()
|
|
4
|
+
return ((...args: any[]) => {
|
|
5
|
+
const key = JSON.stringify(args)
|
|
6
|
+
if (cache.has(key)) return cache.get(key)!
|
|
7
|
+
const result = fn(...args)
|
|
8
|
+
cache.set(key, result)
|
|
9
|
+
return result
|
|
10
|
+
}) as F
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Cache on the first argument */
|
|
14
|
+
export const memo1 = <F extends Fn>(fn: F): F => {
|
|
15
|
+
const cache = new Map<any, ReturnType<F>>()
|
|
16
|
+
return ((...args: any[]) => {
|
|
17
|
+
const key = args[0]
|
|
18
|
+
if (cache.has(key)) return cache.get(key)!
|
|
19
|
+
const result = fn(...args)
|
|
20
|
+
cache.set(key, result)
|
|
21
|
+
return result
|
|
22
|
+
}) as F
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Serialise overlapping async invocations; if a call arrives mid-run, replay once. */
|
|
26
|
+
export const serial = (fn: () => Promise<any>) => {
|
|
27
|
+
let busy = false
|
|
28
|
+
let queued = false
|
|
29
|
+
const run = async (): Promise<void> => {
|
|
30
|
+
if (busy) return void (queued = true)
|
|
31
|
+
busy = true
|
|
32
|
+
try {
|
|
33
|
+
await fn()
|
|
34
|
+
} catch (e) {
|
|
35
|
+
console.error('[build]', e)
|
|
36
|
+
}
|
|
37
|
+
busy = false
|
|
38
|
+
if (queued) {
|
|
39
|
+
queued = false
|
|
40
|
+
await run()
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return run
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export const registerNodeCleanup = (fn: () => any) => {
|
|
47
|
+
const cleanup = async () => {
|
|
48
|
+
await fn()
|
|
49
|
+
process.exit(0)
|
|
50
|
+
}
|
|
51
|
+
process.on('SIGINT', cleanup)
|
|
52
|
+
process.on('SIGTERM', cleanup)
|
|
53
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import * as cmd from 'cmd-ts'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
|
|
4
|
+
import * as config from '../../config/load.ts'
|
|
5
|
+
import * as core from '../../core/index.ts'
|
|
6
|
+
import * as lib from '../../_lib/index.ts'
|
|
7
|
+
import * as vite from '../vite/index.ts'
|
|
8
|
+
import { getRootPath } from '../env.ts'
|
|
9
|
+
|
|
10
|
+
export const dev = cmd.command({
|
|
11
|
+
name: 'dev',
|
|
12
|
+
description: 'Start a local dev server that rebuilds and live-reloads the docs on change',
|
|
13
|
+
args: {
|
|
14
|
+
docsDir: cmd.option({
|
|
15
|
+
long: 'docs-dir',
|
|
16
|
+
short: 'd',
|
|
17
|
+
type: cmd.optional(cmd.string),
|
|
18
|
+
description: 'Directory containing the docs sources (defaults to the configured srcDir)',
|
|
19
|
+
}),
|
|
20
|
+
port: cmd.option({
|
|
21
|
+
long: 'port',
|
|
22
|
+
short: 'p',
|
|
23
|
+
type: cmd.optional(cmd.number),
|
|
24
|
+
description: 'Port the dev server listens on (defaults to Vite\u2019s next free port)',
|
|
25
|
+
}),
|
|
26
|
+
},
|
|
27
|
+
handler: (args) => runDev(args),
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
export const build = cmd.command({
|
|
31
|
+
name: 'build',
|
|
32
|
+
description: 'Build the static documentation site into the output directory',
|
|
33
|
+
args: {
|
|
34
|
+
docsDir: cmd.option({
|
|
35
|
+
long: 'docs-dir',
|
|
36
|
+
short: 'd',
|
|
37
|
+
type: cmd.optional(cmd.string),
|
|
38
|
+
description: 'Directory containing the docs sources (defaults to the configured srcDir)',
|
|
39
|
+
}),
|
|
40
|
+
},
|
|
41
|
+
handler: (args) => runBuild(args),
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
type Options = {
|
|
45
|
+
docsDir?: string
|
|
46
|
+
port?: number
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const runDev = async (opts: Options) => {
|
|
50
|
+
let watchList: string[] = []
|
|
51
|
+
const configFile = await config.findFile(process.cwd())
|
|
52
|
+
if (configFile) watchList.push(configFile)
|
|
53
|
+
|
|
54
|
+
const c = await config.load()
|
|
55
|
+
if (c.srcDir) watchList.push(c.srcDir)
|
|
56
|
+
watchList.push(getRootPath('src/core'))
|
|
57
|
+
|
|
58
|
+
const server = await vite.dev({
|
|
59
|
+
...c,
|
|
60
|
+
build: async () =>
|
|
61
|
+
lib.jiti
|
|
62
|
+
.importModule<typeof core>(getRootPath('src/core'))
|
|
63
|
+
.then(async (core) => core.project.buildJson(await config.loadGen(process.cwd()))),
|
|
64
|
+
watchPaths: [...watchList],
|
|
65
|
+
entrypoint: c.custom ? path.join(process.cwd(), c.custom) : undefined,
|
|
66
|
+
viteConfig: {
|
|
67
|
+
server: { port: opts.port },
|
|
68
|
+
},
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
lib.util.registerNodeCleanup(async () => await server.close())
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export const runBuild = async (opts: Options = {}) => {
|
|
75
|
+
const c = await config.load(opts.docsDir ?? process.cwd())
|
|
76
|
+
const json = await core.project.buildJson(await config.toGenerateOptions(c))
|
|
77
|
+
|
|
78
|
+
await vite.build({
|
|
79
|
+
...c,
|
|
80
|
+
build: async () => json,
|
|
81
|
+
entrypoint: c.custom ? path.join(process.cwd(), c.custom) : undefined,
|
|
82
|
+
viteConfig: {
|
|
83
|
+
build: { outDir: c.custom ? path.join(path.dirname(c.custom), 'dist') : 'docs/dist' },
|
|
84
|
+
},
|
|
85
|
+
})
|
|
86
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as cmd from 'cmd-ts'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
|
|
4
|
+
import * as lib from '../../_lib/index.ts'
|
|
5
|
+
|
|
6
|
+
export const init = cmd.command({
|
|
7
|
+
name: 'init',
|
|
8
|
+
description: 'Scaffold a config file and docs directory with a custom-component example',
|
|
9
|
+
args: {
|
|
10
|
+
dir: cmd.option({
|
|
11
|
+
long: 'dir',
|
|
12
|
+
short: 'd',
|
|
13
|
+
type: cmd.optional(cmd.string),
|
|
14
|
+
description: 'Directory to create the docs scaffold in (defaults to ./docs)',
|
|
15
|
+
}),
|
|
16
|
+
file: cmd.option({
|
|
17
|
+
long: 'config',
|
|
18
|
+
short: 'c',
|
|
19
|
+
type: cmd.optional(cmd.string),
|
|
20
|
+
defaultValue: () => path.join(process.cwd(), 'lickle.ts'),
|
|
21
|
+
description: 'Path to write the configuration file to (defaults to ./lickle.ts)',
|
|
22
|
+
}),
|
|
23
|
+
force: cmd.flag({
|
|
24
|
+
long: 'force',
|
|
25
|
+
short: 'f',
|
|
26
|
+
description: 'Overwrite existing scaffold files instead of skipping them',
|
|
27
|
+
}),
|
|
28
|
+
},
|
|
29
|
+
handler: async (args) => {
|
|
30
|
+
const file = args.file ?? path.join(process.cwd(), 'lickle.ts')
|
|
31
|
+
const dir = args.dir ?? path.join(process.cwd(), 'docs')
|
|
32
|
+
|
|
33
|
+
await lib.fs.ensureDir(file)
|
|
34
|
+
await lib.fs.writeFile(file, configTemplate)
|
|
35
|
+
|
|
36
|
+
await lib.fs.ensureDir(dir)
|
|
37
|
+
await writeInitFiles(dir, args.force)
|
|
38
|
+
},
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const configTemplate = `
|
|
42
|
+
import { defineConfig } from '@lickle/docs/config'
|
|
43
|
+
|
|
44
|
+
export default defineConfig({
|
|
45
|
+
name: '@lickle/docs',
|
|
46
|
+
pages: [{ title: 'Overview', content: './README.md' }],
|
|
47
|
+
custom: './docs/index.tsx',
|
|
48
|
+
})
|
|
49
|
+
`
|
|
50
|
+
|
|
51
|
+
const example = `
|
|
52
|
+
import { registerComponent, LiveExample, transform } from '@lickle/docs/ui'
|
|
53
|
+
|
|
54
|
+
// Execute the compiled example into its preview host. \`host\` is the live DOM
|
|
55
|
+
// node, available to the example as a global.
|
|
56
|
+
const run = (code: string, host: HTMLElement) => new Function('host', code)(host)
|
|
57
|
+
|
|
58
|
+
// Opt in to runnable \`@example\` blocks: compile with \`transform\` then \`run\`.
|
|
59
|
+
registerComponent('tag.example', (props) => (
|
|
60
|
+
<LiveExample {...props} run={(code, host) => run(transform(code), host)} />
|
|
61
|
+
))`
|
|
62
|
+
|
|
63
|
+
const initFiles = {
|
|
64
|
+
'.gitignore': [`docs.json`, `dist`],
|
|
65
|
+
'index.tsx': [example.trim()],
|
|
66
|
+
'tsconfig.json': [`{`, ` "extends": "@lickle/docs/tsconfig/tsconfig.client.json",`, ` "include": ["*"],`, `}`],
|
|
67
|
+
}
|
|
68
|
+
const writeInitFiles = async (dir: string, force: boolean = false) => {
|
|
69
|
+
for (const [file, content] of Object.entries(initFiles)) {
|
|
70
|
+
if (force) {
|
|
71
|
+
await lib.fs.writeFile(path.join(dir, file), content.join('\n'))
|
|
72
|
+
continue
|
|
73
|
+
}
|
|
74
|
+
if (await lib.fs.exists(path.join(dir, file))) {
|
|
75
|
+
console.log(`skipping ${file} as it already exists`)
|
|
76
|
+
continue
|
|
77
|
+
}
|
|
78
|
+
await lib.fs.writeFile(path.join(dir, file), content.join('\n'))
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as cmd from 'cmd-ts'
|
|
2
|
+
|
|
3
|
+
import * as project from '../../core/project/index.ts'
|
|
4
|
+
import * as config from '../../config/load.ts'
|
|
5
|
+
import * as core from '../../core/index.ts'
|
|
6
|
+
import * as lib from '../../_lib/index.ts'
|
|
7
|
+
|
|
8
|
+
export const json = cmd.command({
|
|
9
|
+
name: 'json',
|
|
10
|
+
description: 'Generate the project\u2019s JSON reflection data into the docs directory',
|
|
11
|
+
args: {
|
|
12
|
+
print: cmd.flag({
|
|
13
|
+
long: 'print',
|
|
14
|
+
short: 'p',
|
|
15
|
+
description: 'Print the generated route tree to the console',
|
|
16
|
+
}),
|
|
17
|
+
full: cmd.flag({
|
|
18
|
+
long: 'full',
|
|
19
|
+
description: 'Document every declaration, not just the exported public API',
|
|
20
|
+
}),
|
|
21
|
+
},
|
|
22
|
+
handler: async (args) => {
|
|
23
|
+
await lib.fs.ensureDir('docs')
|
|
24
|
+
const p = await core.project.buildJson(await config.loadGen(process.cwd(), { full: args.full }))
|
|
25
|
+
if (args.print) project.displayRoutes(p.routes)
|
|
26
|
+
await lib.fs.writeFile('docs/project.json', JSON.stringify(p, null, 2))
|
|
27
|
+
},
|
|
28
|
+
})
|
package/src/cli/env.ts
ADDED
package/src/cli/index.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as cmd from 'cmd-ts'
|
|
2
|
+
|
|
3
|
+
import * as cmds from './cmd/index.ts'
|
|
4
|
+
import * as lib from '../_lib/index.ts'
|
|
5
|
+
|
|
6
|
+
export const app = async () => {
|
|
7
|
+
const version = await lib.pkg.read(process.cwd())
|
|
8
|
+
return cmd.subcommands({
|
|
9
|
+
name: 'ldocs',
|
|
10
|
+
version: version.version,
|
|
11
|
+
description: 'Generate documentation sites from TypeScript projects',
|
|
12
|
+
cmds: { json: cmds.json, dev: cmds.dev, build: cmds.build, init: cmds.init },
|
|
13
|
+
})
|
|
14
|
+
}
|