zudoku 0.38.0 → 0.39.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/dist/app/entry.server.d.ts +5 -4
- package/dist/app/entry.server.js +2 -2
- package/dist/app/entry.server.js.map +1 -1
- package/dist/app/tailwind.js +14 -0
- package/dist/app/tailwind.js.map +1 -1
- package/dist/cli/cmds/dev.js +1 -7
- package/dist/cli/cmds/dev.js.map +1 -1
- package/dist/config/validators/common.d.ts +17 -0
- package/dist/config/validators/common.js +1 -0
- package/dist/config/validators/common.js.map +1 -1
- package/dist/config/validators/validate.d.ts +7 -0
- package/dist/lib/components/Bootstrap.d.ts +2 -1
- package/dist/lib/components/Bootstrap.js +3 -2
- package/dist/lib/components/Bootstrap.js.map +1 -1
- package/dist/lib/components/Header.js +2 -2
- package/dist/lib/components/Header.js.map +1 -1
- package/dist/lib/components/Heading.d.ts +1 -1
- package/dist/lib/components/Layout.js +2 -9
- package/dist/lib/components/Layout.js.map +1 -1
- package/dist/lib/components/Main.js +3 -1
- package/dist/lib/components/Main.js.map +1 -1
- package/dist/lib/components/MobileTopNavigation.js +6 -3
- package/dist/lib/components/MobileTopNavigation.js.map +1 -1
- package/dist/lib/components/Pagination.d.ts +10 -0
- package/dist/lib/components/Pagination.js +10 -0
- package/dist/lib/components/Pagination.js.map +1 -0
- package/dist/lib/components/TopNavigation.d.ts +1 -0
- package/dist/lib/components/TopNavigation.js +18 -2
- package/dist/lib/components/TopNavigation.js.map +1 -1
- package/dist/lib/components/Zudoku.js +4 -1
- package/dist/lib/components/Zudoku.js.map +1 -1
- package/dist/lib/components/context/BypassProtectedRoutesContext.d.ts +1 -0
- package/dist/lib/components/context/BypassProtectedRoutesContext.js +3 -0
- package/dist/lib/components/context/BypassProtectedRoutesContext.js.map +1 -0
- package/dist/lib/components/index.d.ts +2 -1
- package/dist/lib/components/navigation/PoweredByZudoku.d.ts +3 -0
- package/dist/lib/components/navigation/PoweredByZudoku.js +6 -0
- package/dist/lib/components/navigation/PoweredByZudoku.js.map +1 -0
- package/dist/lib/components/navigation/SidebarItem.d.ts +1 -0
- package/dist/lib/components/navigation/SidebarItem.js +7 -3
- package/dist/lib/components/navigation/SidebarItem.js.map +1 -1
- package/dist/lib/components/navigation/SidebarWrapper.js +9 -2
- package/dist/lib/components/navigation/SidebarWrapper.js.map +1 -1
- package/dist/lib/{plugins/markdown → components/navigation}/Toc.js +5 -7
- package/dist/lib/components/navigation/Toc.js.map +1 -0
- package/dist/lib/components/navigation/ZudokuLogo.d.ts +6 -0
- package/dist/lib/components/navigation/ZudokuLogo.js +5 -0
- package/dist/lib/components/navigation/ZudokuLogo.js.map +1 -0
- package/dist/lib/core/RouteGuard.d.ts +1 -0
- package/dist/lib/core/RouteGuard.js +9 -3
- package/dist/lib/core/RouteGuard.js.map +1 -1
- package/dist/lib/core/ZudokuContext.d.ts +1 -0
- package/dist/lib/core/ZudokuContext.js.map +1 -1
- package/dist/lib/oas/graphql/index.d.ts +2 -1
- package/dist/lib/oas/graphql/index.js +74 -14
- package/dist/lib/oas/graphql/index.js.map +1 -1
- package/dist/lib/oas/parser/dereference/index.js +2 -0
- package/dist/lib/oas/parser/dereference/index.js.map +1 -1
- package/dist/lib/oas/parser/index.d.ts +5 -3
- package/dist/lib/oas/parser/index.js +0 -22
- package/dist/lib/oas/parser/index.js.map +1 -1
- package/dist/lib/plugins/api-catalog/index.js +19 -17
- package/dist/lib/plugins/api-catalog/index.js.map +1 -1
- package/dist/lib/plugins/markdown/MdxPage.js +3 -3
- package/dist/lib/plugins/markdown/MdxPage.js.map +1 -1
- package/dist/lib/plugins/openapi/ColorizedParam.js +1 -1
- package/dist/lib/plugins/openapi/ColorizedParam.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationList.d.ts +1 -1
- package/dist/lib/plugins/openapi/OperationList.js +28 -8
- package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationListItem.js +1 -1
- package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
- package/dist/lib/plugins/openapi/ParameterListItem.js +2 -1
- package/dist/lib/plugins/openapi/ParameterListItem.js.map +1 -1
- package/dist/lib/plugins/openapi/SchemaList.d.ts +1 -0
- package/dist/lib/plugins/openapi/SchemaList.js +52 -0
- package/dist/lib/plugins/openapi/SchemaList.js.map +1 -0
- package/dist/lib/plugins/openapi/client/GraphQLClient.d.ts +1 -1
- package/dist/lib/plugins/openapi/client/GraphQLClient.js +1 -1
- package/dist/lib/plugins/openapi/client/GraphQLClient.js.map +1 -1
- package/dist/lib/plugins/openapi/client/useCreateQuery.d.ts +6 -2
- package/dist/lib/plugins/openapi/client/useCreateQuery.js +5 -5
- package/dist/lib/plugins/openapi/client/useCreateQuery.js.map +1 -1
- package/dist/lib/plugins/openapi/components/EnumValues.js +1 -1
- package/dist/lib/plugins/openapi/components/EnumValues.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/gql.d.ts +6 -2
- package/dist/lib/plugins/openapi/graphql/gql.js +3 -2
- package/dist/lib/plugins/openapi/graphql/gql.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/graphql.d.ts +67 -11
- package/dist/lib/plugins/openapi/graphql/graphql.js +34 -5
- package/dist/lib/plugins/openapi/graphql/graphql.js.map +1 -1
- package/dist/lib/plugins/openapi/index.js +12 -0
- package/dist/lib/plugins/openapi/index.js.map +1 -1
- package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroup.d.ts +1 -2
- package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroup.js +2 -2
- package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroup.js.map +1 -1
- package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroupConnector.d.ts +2 -1
- package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroupConnector.js +2 -2
- package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroupConnector.js.map +1 -1
- package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroupItem.d.ts +0 -1
- package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroupItem.js +1 -1
- package/dist/lib/plugins/openapi/schema/LogicalGroup/LogicalGroupItem.js.map +1 -1
- package/dist/lib/plugins/openapi/schema/SchemaExampleAndDefault.d.ts +4 -0
- package/dist/lib/plugins/openapi/schema/SchemaExampleAndDefault.js +12 -0
- package/dist/lib/plugins/openapi/schema/SchemaExampleAndDefault.js.map +1 -0
- package/dist/lib/plugins/openapi/schema/SchemaPropertyItem.d.ts +2 -4
- package/dist/lib/plugins/openapi/schema/SchemaPropertyItem.js +12 -9
- package/dist/lib/plugins/openapi/schema/SchemaPropertyItem.js.map +1 -1
- package/dist/lib/plugins/openapi/schema/SchemaView.d.ts +1 -2
- package/dist/lib/plugins/openapi/schema/SchemaView.js +30 -52
- package/dist/lib/plugins/openapi/schema/SchemaView.js.map +1 -1
- package/dist/lib/plugins/openapi/schema/utils.d.ts +1 -0
- package/dist/lib/plugins/openapi/schema/utils.js +3 -1
- package/dist/lib/plugins/openapi/schema/utils.js.map +1 -1
- package/dist/lib/plugins/openapi/util/getRoutes.js +9 -3
- package/dist/lib/plugins/openapi/util/getRoutes.js.map +1 -1
- package/dist/lib/plugins/search-pagefind/PagefindSearch.js +9 -4
- package/dist/lib/plugins/search-pagefind/PagefindSearch.js.map +1 -1
- package/dist/lib/plugins/search-pagefind/ResultList.d.ts +1 -1
- package/dist/lib/plugins/search-pagefind/ResultList.js +6 -12
- package/dist/lib/plugins/search-pagefind/ResultList.js.map +1 -1
- package/dist/lib/plugins/search-pagefind/index.d.ts +1 -3
- package/dist/lib/util/useOnScreen.d.ts +3 -2
- package/dist/lib/util/useOnScreen.js +3 -3
- package/dist/lib/util/useOnScreen.js.map +1 -1
- package/dist/vite/api/schema-codegen.js +2 -2
- package/dist/vite/api/schema-codegen.js.map +1 -1
- package/dist/vite/api/schema-codegen.test.js +5 -0
- package/dist/vite/api/schema-codegen.test.js.map +1 -1
- package/dist/vite/build.js +1 -9
- package/dist/vite/build.js.map +1 -1
- package/dist/vite/plugin-api.js +8 -7
- package/dist/vite/plugin-api.js.map +1 -1
- package/dist/vite/plugin-search.js +1 -1
- package/dist/vite/plugin-search.js.map +1 -1
- package/dist/vite/prerender/FileWritingResponse.d.ts +9 -5
- package/dist/vite/prerender/FileWritingResponse.js +5 -5
- package/dist/vite/prerender/FileWritingResponse.js.map +1 -1
- package/dist/vite/prerender/InMemoryResponse.d.ts +16 -0
- package/dist/vite/prerender/InMemoryResponse.js +32 -0
- package/dist/vite/prerender/InMemoryResponse.js.map +1 -0
- package/dist/vite/prerender/PrerenderResponse.d.ts +10 -0
- package/dist/vite/prerender/PrerenderResponse.js +2 -0
- package/dist/vite/prerender/PrerenderResponse.js.map +1 -0
- package/dist/vite/prerender/prerender.d.ts +1 -0
- package/dist/vite/prerender/prerender.js +18 -0
- package/dist/vite/prerender/prerender.js.map +1 -1
- package/dist/vite/prerender/worker.js +36 -8
- package/dist/vite/prerender/worker.js.map +1 -1
- package/dist/zuplo/with-zuplo.js +4 -0
- package/dist/zuplo/with-zuplo.js.map +1 -1
- package/lib/{AuthenticationPlugin-Duy_R1TU.js → AuthenticationPlugin-foqdvvkf.js} +2 -2
- package/lib/{AuthenticationPlugin-Duy_R1TU.js.map → AuthenticationPlugin-foqdvvkf.js.map} +1 -1
- package/lib/{Markdown-DIZ8nBVC.js → Markdown-aF5FdsNi.js} +1339 -1335
- package/lib/{Markdown-DIZ8nBVC.js.map → Markdown-aF5FdsNi.js.map} +1 -1
- package/lib/MdxPage-JscVnWM8.js +84 -0
- package/lib/MdxPage-JscVnWM8.js.map +1 -0
- package/lib/{OasProvider-D1A10JeA.js → OasProvider-C7Y53snX.js} +3 -3
- package/lib/{OasProvider-D1A10JeA.js.map → OasProvider-C7Y53snX.js.map} +1 -1
- package/lib/OperationList-_M8wg22T.js +5066 -0
- package/lib/OperationList-_M8wg22T.js.map +1 -0
- package/lib/Pagination-DCCvGq0m.js +46 -0
- package/lib/Pagination-DCCvGq0m.js.map +1 -0
- package/lib/RouteGuard-CqZPoZYJ.js +744 -0
- package/lib/RouteGuard-CqZPoZYJ.js.map +1 -0
- package/lib/SchemaList-CrKZdUyo.js +148 -0
- package/lib/SchemaList-CrKZdUyo.js.map +1 -0
- package/lib/SchemaView-B4JHn-BX.js +354 -0
- package/lib/SchemaView-B4JHn-BX.js.map +1 -0
- package/lib/{Select-fAYcJ0OU.js → Select-DVFRKf1R.js} +3 -3
- package/lib/{Select-fAYcJ0OU.js.map → Select-DVFRKf1R.js.map} +1 -1
- package/lib/{SlotletProvider-BEwNY8q0.js → SlotletProvider-DXvc0aY6.js} +2 -2
- package/lib/{SlotletProvider-BEwNY8q0.js.map → SlotletProvider-DXvc0aY6.js.map} +1 -1
- package/lib/Toc-YBsgI72s.js +92 -0
- package/lib/Toc-YBsgI72s.js.map +1 -0
- package/lib/{createServer-DjgKDpGV.js → createServer-mYvGvmc0.js} +2596 -2502
- package/lib/createServer-mYvGvmc0.js.map +1 -0
- package/lib/{hook-Cge6LiTK.js → hook-CqpVYDqN.js} +28 -28
- package/lib/{hook-Cge6LiTK.js.map → hook-CqpVYDqN.js.map} +1 -1
- package/lib/{index-B0y3fTg-.js → index-C8-tlf_X.js} +771 -729
- package/lib/index-C8-tlf_X.js.map +1 -0
- package/lib/index-D6ktNq4i.js +1863 -0
- package/lib/index-D6ktNq4i.js.map +1 -0
- package/lib/{mutation-EChriCeF.js → mutation-8LjrN7uz.js} +2 -2
- package/lib/{mutation-EChriCeF.js.map → mutation-8LjrN7uz.js.map} +1 -1
- package/lib/objectEntries-yMIkr2mI.js +5 -0
- package/lib/objectEntries-yMIkr2mI.js.map +1 -0
- package/lib/useLatest-hmRS46UF.js +11 -0
- package/lib/useLatest-hmRS46UF.js.map +1 -0
- package/lib/zudoku.auth-auth0.js +1 -1
- package/lib/zudoku.auth-clerk.js +2 -2
- package/lib/zudoku.auth-openid.js +2 -2
- package/lib/zudoku.components.js +32 -1454
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.hooks.js +1 -1
- package/lib/zudoku.plugin-api-catalog.js +80 -76
- package/lib/zudoku.plugin-api-catalog.js.map +1 -1
- package/lib/zudoku.plugin-api-keys.js +3 -3
- package/lib/zudoku.plugin-custom-pages.js +1 -1
- package/lib/zudoku.plugin-markdown.js +1 -1
- package/lib/zudoku.plugin-openapi.js +2 -2
- package/lib/zudoku.plugin-search-pagefind.js +132 -137
- package/lib/zudoku.plugin-search-pagefind.js.map +1 -1
- package/package.json +6 -5
- package/src/app/entry.server.tsx +6 -3
- package/src/app/tailwind.ts +14 -0
- package/src/lib/components/Bootstrap.tsx +13 -6
- package/src/lib/components/Header.tsx +2 -2
- package/src/lib/components/Layout.tsx +5 -17
- package/src/lib/components/Main.tsx +6 -3
- package/src/lib/components/MobileTopNavigation.tsx +27 -18
- package/src/lib/components/Pagination.tsx +47 -0
- package/src/lib/components/TopNavigation.tsx +29 -2
- package/src/lib/components/Zudoku.tsx +5 -3
- package/src/lib/components/context/BypassProtectedRoutesContext.ts +3 -0
- package/src/lib/components/navigation/PoweredByZudoku.tsx +23 -0
- package/src/lib/components/navigation/SidebarItem.tsx +10 -4
- package/src/lib/components/navigation/SidebarWrapper.tsx +27 -13
- package/src/lib/{plugins/markdown → components/navigation}/Toc.tsx +5 -14
- package/src/lib/components/navigation/ZudokuLogo.tsx +25 -0
- package/src/lib/core/RouteGuard.tsx +26 -4
- package/src/lib/core/ZudokuContext.ts +1 -0
- package/src/lib/oas/graphql/index.ts +118 -45
- package/src/lib/oas/parser/dereference/index.ts +2 -0
- package/src/lib/oas/parser/index.ts +7 -29
- package/src/lib/plugins/api-catalog/index.tsx +40 -35
- package/src/lib/plugins/markdown/MdxPage.tsx +6 -36
- package/src/lib/plugins/openapi/ColorizedParam.tsx +1 -1
- package/src/lib/plugins/openapi/OperationList.tsx +36 -15
- package/src/lib/plugins/openapi/OperationListItem.tsx +7 -2
- package/src/lib/plugins/openapi/ParameterListItem.tsx +2 -0
- package/src/lib/plugins/openapi/SchemaList.tsx +151 -0
- package/src/lib/plugins/openapi/client/GraphQLClient.tsx +1 -1
- package/src/lib/plugins/openapi/client/useCreateQuery.ts +12 -5
- package/src/lib/plugins/openapi/components/EnumValues.tsx +1 -1
- package/src/lib/plugins/openapi/graphql/gql.ts +15 -6
- package/src/lib/plugins/openapi/graphql/graphql.ts +104 -15
- package/src/lib/plugins/openapi/index.tsx +13 -0
- package/src/lib/plugins/openapi/schema/LogicalGroup/LogicalGroup.tsx +1 -8
- package/src/lib/plugins/openapi/schema/LogicalGroup/LogicalGroupConnector.tsx +3 -0
- package/src/lib/plugins/openapi/schema/LogicalGroup/LogicalGroupItem.tsx +6 -3
- package/src/lib/plugins/openapi/schema/SchemaExampleAndDefault.tsx +36 -0
- package/src/lib/plugins/openapi/schema/SchemaPropertyItem.tsx +20 -21
- package/src/lib/plugins/openapi/schema/SchemaView.tsx +69 -141
- package/src/lib/plugins/openapi/schema/utils.ts +7 -1
- package/src/lib/plugins/openapi/util/getRoutes.tsx +9 -6
- package/src/lib/plugins/search-pagefind/PagefindSearch.tsx +11 -4
- package/src/lib/plugins/search-pagefind/ResultList.tsx +5 -16
- package/src/lib/plugins/search-pagefind/index.tsx +1 -1
- package/src/lib/util/useOnScreen.ts +6 -4
- package/dist/cli/dev/pagefind-command.d.ts +0 -3
- package/dist/cli/dev/pagefind-command.js +0 -59
- package/dist/cli/dev/pagefind-command.js.map +0 -1
- package/dist/lib/components/context/PluginSystem.d.ts +0 -1
- package/dist/lib/components/context/PluginSystem.js +0 -2
- package/dist/lib/components/context/PluginSystem.js.map +0 -1
- package/dist/lib/plugins/markdown/Toc.js.map +0 -1
- package/lib/MdxPage-JEdbfW-f.js +0 -195
- package/lib/MdxPage-JEdbfW-f.js.map +0 -1
- package/lib/OperationList-yOmYzMIp.js +0 -5379
- package/lib/OperationList-yOmYzMIp.js.map +0 -1
- package/lib/createServer-DjgKDpGV.js.map +0 -1
- package/lib/index-B0y3fTg-.js.map +0 -1
- package/lib/index.esm-CltAN0Tf.js +0 -711
- package/lib/index.esm-CltAN0Tf.js.map +0 -1
- package/lib/objectEntries-BS7aAgOm.js +0 -12
- package/lib/objectEntries-BS7aAgOm.js.map +0 -1
- package/src/lib/components/context/PluginSystem.ts +0 -0
- /package/dist/lib/{plugins/markdown → components/navigation}/Toc.d.ts +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as Collapsible from "@radix-ui/react-collapsible";
|
|
2
2
|
import { MinusIcon, PlusIcon, RefreshCcwDotIcon } from "lucide-react";
|
|
3
3
|
import { useCallback, useState } from "react";
|
|
4
|
+
import { InlineCode } from "../../../components/InlineCode.js";
|
|
4
5
|
import { Markdown, ProseClasses } from "../../../components/Markdown.js";
|
|
5
6
|
import type { SchemaObject } from "../../../oas/parser/index.js";
|
|
6
7
|
import { Button } from "../../../ui/Button.js";
|
|
@@ -10,6 +11,7 @@ import { EnumValues } from "../components/EnumValues.js";
|
|
|
10
11
|
import { SelectOnClick } from "../components/SelectOnClick.js";
|
|
11
12
|
import { ParamInfos } from "../ParamInfos.js";
|
|
12
13
|
import { LogicalGroup } from "./LogicalGroup/LogicalGroup.js";
|
|
14
|
+
import { SchemaExampleAndDefault } from "./SchemaExampleAndDefault.js";
|
|
13
15
|
import { SchemaView } from "./SchemaView.js";
|
|
14
16
|
import {
|
|
15
17
|
hasLogicalGroupings,
|
|
@@ -18,13 +20,7 @@ import {
|
|
|
18
20
|
LogicalSchemaTypeMap,
|
|
19
21
|
} from "./utils.js";
|
|
20
22
|
|
|
21
|
-
export const SchemaLogicalGroup = ({
|
|
22
|
-
schema,
|
|
23
|
-
level,
|
|
24
|
-
}: {
|
|
25
|
-
schema: SchemaObject;
|
|
26
|
-
level: number;
|
|
27
|
-
}) => {
|
|
23
|
+
export const SchemaLogicalGroup = ({ schema }: { schema: SchemaObject }) => {
|
|
28
24
|
const [isOpen, setIsOpen] = useState(true);
|
|
29
25
|
const toggleOpen = useCallback(() => setIsOpen((prev) => !prev), []);
|
|
30
26
|
|
|
@@ -37,31 +33,31 @@ export const SchemaLogicalGroup = ({
|
|
|
37
33
|
type={type}
|
|
38
34
|
isOpen={isOpen}
|
|
39
35
|
toggleOpen={toggleOpen}
|
|
40
|
-
level={level}
|
|
41
36
|
/>
|
|
42
37
|
);
|
|
43
38
|
}
|
|
44
39
|
};
|
|
45
40
|
|
|
46
41
|
const RecursiveIndicator = () => (
|
|
47
|
-
<
|
|
42
|
+
<InlineCode
|
|
43
|
+
className="inline-flex items-center gap-1.5 italic text-xs translate-y-0.5"
|
|
44
|
+
selectOnClick={false}
|
|
45
|
+
>
|
|
48
46
|
<RefreshCcwDotIcon size={13} />
|
|
49
47
|
<span>circular</span>
|
|
50
|
-
</
|
|
48
|
+
</InlineCode>
|
|
51
49
|
);
|
|
52
50
|
|
|
53
51
|
export const SchemaPropertyItem = ({
|
|
54
52
|
name,
|
|
55
53
|
schema,
|
|
56
54
|
group,
|
|
57
|
-
level,
|
|
58
55
|
defaultOpen = false,
|
|
59
56
|
showCollapseButton = true,
|
|
60
57
|
}: {
|
|
61
58
|
name: string;
|
|
62
59
|
schema: SchemaObject;
|
|
63
60
|
group: "required" | "optional" | "deprecated";
|
|
64
|
-
level: number;
|
|
65
61
|
defaultOpen?: boolean;
|
|
66
62
|
showCollapseButton?: boolean;
|
|
67
63
|
}) => {
|
|
@@ -73,9 +69,12 @@ export const SchemaPropertyItem = ({
|
|
|
73
69
|
<div className="flex flex-col gap-2.5 justify-between text-sm">
|
|
74
70
|
<div className="space-x-2">
|
|
75
71
|
<code>{name}</code>
|
|
76
|
-
<ParamInfos
|
|
77
|
-
|
|
72
|
+
<ParamInfos
|
|
73
|
+
schema={schema}
|
|
74
|
+
extraItems={[<RecursiveIndicator key="circular-ref" />]}
|
|
75
|
+
/>
|
|
78
76
|
</div>
|
|
77
|
+
<SchemaExampleAndDefault schema={schema} />
|
|
79
78
|
</div>
|
|
80
79
|
</li>
|
|
81
80
|
);
|
|
@@ -94,11 +93,11 @@ export const SchemaPropertyItem = ({
|
|
|
94
93
|
group !== "optional" && (
|
|
95
94
|
<span className="text-primary">required</span>
|
|
96
95
|
),
|
|
96
|
+
schema.type === "array" &&
|
|
97
|
+
"items" in schema &&
|
|
98
|
+
isCircularRef(schema.items) && <RecursiveIndicator />,
|
|
97
99
|
]}
|
|
98
100
|
/>
|
|
99
|
-
{schema.type === "array" &&
|
|
100
|
-
"items" in schema &&
|
|
101
|
-
isCircularRef(schema.items) && <RecursiveIndicator />}
|
|
102
101
|
</div>
|
|
103
102
|
{schema.description && (
|
|
104
103
|
<Markdown
|
|
@@ -110,7 +109,7 @@ export const SchemaPropertyItem = ({
|
|
|
110
109
|
<EnumValues values={schema.items.enum} />
|
|
111
110
|
)}
|
|
112
111
|
{schema.enum && <EnumValues values={schema.enum} />}
|
|
113
|
-
|
|
112
|
+
<SchemaExampleAndDefault schema={schema} />
|
|
114
113
|
{(hasLogicalGroupings(schema) || isComplexType(schema)) && (
|
|
115
114
|
<Collapsible.Root
|
|
116
115
|
defaultOpen={defaultOpen}
|
|
@@ -128,15 +127,15 @@ export const SchemaPropertyItem = ({
|
|
|
128
127
|
<Collapsible.Content>
|
|
129
128
|
<div className="mt-2">
|
|
130
129
|
{hasLogicalGroupings(schema) ? (
|
|
131
|
-
<SchemaLogicalGroup schema={schema}
|
|
130
|
+
<SchemaLogicalGroup schema={schema} />
|
|
132
131
|
) : schema.type === "object" ? (
|
|
133
|
-
<SchemaView schema={schema}
|
|
132
|
+
<SchemaView schema={schema} />
|
|
134
133
|
) : (
|
|
135
134
|
schema.type === "array" &&
|
|
136
135
|
"items" in schema &&
|
|
137
136
|
typeof schema.items === "object" &&
|
|
138
137
|
!isCircularRef(schema.items) && (
|
|
139
|
-
<SchemaView schema={schema.items}
|
|
138
|
+
<SchemaView schema={schema.items} />
|
|
140
139
|
)
|
|
141
140
|
)}
|
|
142
141
|
</div>
|
|
@@ -5,11 +5,12 @@ import { cn } from "../../../util/cn.js";
|
|
|
5
5
|
import { groupBy } from "../../../util/groupBy.js";
|
|
6
6
|
import { EnumValues } from "../components/EnumValues.js";
|
|
7
7
|
import { ParamInfos } from "../ParamInfos.js";
|
|
8
|
+
import { SchemaExampleAndDefault } from "./SchemaExampleAndDefault.js";
|
|
8
9
|
import {
|
|
9
10
|
SchemaLogicalGroup,
|
|
10
11
|
SchemaPropertyItem,
|
|
11
12
|
} from "./SchemaPropertyItem.js";
|
|
12
|
-
import { hasLogicalGroupings } from "./utils.js";
|
|
13
|
+
import { hasLogicalGroupings, isBasicType } from "./utils.js";
|
|
13
14
|
|
|
14
15
|
const renderMarkdown = (content?: string) =>
|
|
15
16
|
content && (
|
|
@@ -19,166 +20,93 @@ const renderMarkdown = (content?: string) =>
|
|
|
19
20
|
/>
|
|
20
21
|
);
|
|
21
22
|
|
|
23
|
+
const renderBasicSchema = (schema: SchemaObject) => (
|
|
24
|
+
<Card className="p-4 space-y-2">
|
|
25
|
+
<span className="text-sm text-muted-foreground">
|
|
26
|
+
<ParamInfos schema={schema} />
|
|
27
|
+
</span>
|
|
28
|
+
{schema.enum && <EnumValues values={schema.enum} />}
|
|
29
|
+
{renderMarkdown(schema.description)}
|
|
30
|
+
<SchemaExampleAndDefault schema={schema} />
|
|
31
|
+
</Card>
|
|
32
|
+
);
|
|
33
|
+
|
|
22
34
|
export const SchemaView = ({
|
|
23
35
|
schema,
|
|
24
|
-
level = 0,
|
|
25
36
|
defaultOpen = false,
|
|
26
37
|
}: {
|
|
27
38
|
schema?: SchemaObject | null;
|
|
28
|
-
level?: number;
|
|
29
39
|
defaultOpen?: boolean;
|
|
30
40
|
}) => {
|
|
31
41
|
if (!schema || Object.keys(schema).length === 0) {
|
|
32
42
|
return (
|
|
33
43
|
<Card className="p-4">
|
|
34
44
|
<span className="text-sm text-muted-foreground italic">
|
|
35
|
-
No
|
|
45
|
+
No schema specified
|
|
36
46
|
</span>
|
|
37
47
|
</Card>
|
|
38
48
|
);
|
|
39
49
|
}
|
|
40
50
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (Array.isArray(schema.type)) {
|
|
47
|
-
return (
|
|
48
|
-
<Card className="p-4 space-y-2">
|
|
49
|
-
<span className="text-sm text-muted-foreground">
|
|
50
|
-
<ParamInfos schema={schema} />
|
|
51
|
-
</span>
|
|
52
|
-
{schema.enum && <EnumValues values={schema.enum} />}
|
|
53
|
-
{renderMarkdown(schema.description)}
|
|
54
|
-
</Card>
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (schema.type === "array" && typeof schema.items === "object") {
|
|
59
|
-
const itemsSchema = schema.items as SchemaObject;
|
|
60
|
-
|
|
61
|
-
if (itemsSchema.enum) {
|
|
62
|
-
return (
|
|
63
|
-
<Card className="p-4">
|
|
64
|
-
<span className="text-sm text-muted-foreground">
|
|
65
|
-
<ParamInfos schema={schema} />
|
|
66
|
-
</span>
|
|
67
|
-
<EnumValues values={itemsSchema.enum} />
|
|
68
|
-
{renderMarkdown(schema.description)}
|
|
69
|
-
</Card>
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (
|
|
74
|
-
typeof itemsSchema.type === "string" &&
|
|
75
|
-
["string", "number", "boolean", "integer"].includes(itemsSchema.type)
|
|
76
|
-
) {
|
|
77
|
-
return (
|
|
78
|
-
<Card className="p-4">
|
|
79
|
-
<span className="text-sm text-muted-foreground">
|
|
80
|
-
<ParamInfos schema={schema} />
|
|
81
|
-
</span>
|
|
82
|
-
{renderMarkdown(schema.description)}
|
|
83
|
-
</Card>
|
|
84
|
-
);
|
|
85
|
-
} else if (itemsSchema.type === "object") {
|
|
86
|
-
return (
|
|
87
|
-
<Card className="flex flex-col gap-2 bg-border/30 p-4">
|
|
88
|
-
<span className="text-sm text-muted-foreground">object[]</span>
|
|
89
|
-
{renderSchema(itemsSchema, level + 1)}
|
|
90
|
-
</Card>
|
|
91
|
-
);
|
|
92
|
-
} else {
|
|
93
|
-
return renderSchema(itemsSchema, level + 1);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (
|
|
98
|
-
schema.type === "object" &&
|
|
99
|
-
(!schema.properties || Object.keys(schema.properties).length === 0)
|
|
100
|
-
) {
|
|
101
|
-
return (
|
|
102
|
-
<Card className="p-4 flex gap-2 items-baseline">
|
|
103
|
-
{"name" in schema && <>{schema.name as string}</>}
|
|
104
|
-
<span className="text-sm text-muted-foreground">
|
|
105
|
-
<ParamInfos schema={schema} />
|
|
106
|
-
</span>
|
|
107
|
-
{renderMarkdown(schema.description)}
|
|
108
|
-
</Card>
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (schema.properties) {
|
|
113
|
-
const groupedProperties = groupBy(
|
|
114
|
-
Object.entries(schema.properties),
|
|
115
|
-
([propertyName, property]) => {
|
|
116
|
-
return property.deprecated
|
|
117
|
-
? "deprecated"
|
|
118
|
-
: schema.required?.includes(propertyName)
|
|
119
|
-
? "required"
|
|
120
|
-
: "optional";
|
|
121
|
-
},
|
|
122
|
-
);
|
|
51
|
+
if (hasLogicalGroupings(schema)) {
|
|
52
|
+
return <SchemaLogicalGroup schema={schema} />;
|
|
53
|
+
}
|
|
123
54
|
|
|
124
|
-
|
|
55
|
+
if (isBasicType(schema.type)) {
|
|
56
|
+
return renderBasicSchema(schema);
|
|
57
|
+
}
|
|
125
58
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
(group) =>
|
|
130
|
-
groupedProperties[group] && (
|
|
131
|
-
<ul key={group} className="divide-y">
|
|
132
|
-
{groupedProperties[group].map(([name, schema]) => (
|
|
133
|
-
<SchemaPropertyItem
|
|
134
|
-
key={name}
|
|
135
|
-
name={name}
|
|
136
|
-
schema={schema}
|
|
137
|
-
group={group}
|
|
138
|
-
level={level}
|
|
139
|
-
defaultOpen={defaultOpen}
|
|
140
|
-
/>
|
|
141
|
-
))}
|
|
142
|
-
</ul>
|
|
143
|
-
),
|
|
144
|
-
)}
|
|
145
|
-
</Card>
|
|
146
|
-
);
|
|
147
|
-
}
|
|
59
|
+
if (schema.type === "array" && typeof schema.items === "object") {
|
|
60
|
+
return renderBasicSchema(schema.items as SchemaObject);
|
|
61
|
+
}
|
|
148
62
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
);
|
|
162
|
-
}
|
|
63
|
+
if (schema.type === "object") {
|
|
64
|
+
const groupedProperties = groupBy(
|
|
65
|
+
Object.entries(schema.properties ?? {}),
|
|
66
|
+
([propertyName, property]) => {
|
|
67
|
+
return property.deprecated
|
|
68
|
+
? "deprecated"
|
|
69
|
+
: schema.required?.includes(propertyName)
|
|
70
|
+
? "required"
|
|
71
|
+
: "optional";
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
const groupNames = ["required", "optional", "deprecated"] as const;
|
|
163
75
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
76
|
+
return (
|
|
77
|
+
<Card className="divide-y overflow-hidden">
|
|
78
|
+
{groupNames.map(
|
|
79
|
+
(group) =>
|
|
80
|
+
groupedProperties[group] && (
|
|
81
|
+
<ul key={group} className="divide-y">
|
|
82
|
+
{groupedProperties[group].map(([name, schema]) => (
|
|
83
|
+
<SchemaPropertyItem
|
|
84
|
+
key={name}
|
|
85
|
+
name={name}
|
|
86
|
+
schema={schema}
|
|
87
|
+
group={group}
|
|
88
|
+
defaultOpen={defaultOpen}
|
|
89
|
+
/>
|
|
90
|
+
))}
|
|
91
|
+
</ul>
|
|
92
|
+
),
|
|
93
|
+
)}
|
|
94
|
+
</Card>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
179
97
|
|
|
180
|
-
|
|
181
|
-
|
|
98
|
+
if (schema.additionalProperties) {
|
|
99
|
+
return (
|
|
100
|
+
<Card className="my-2">
|
|
101
|
+
<CardHeader>
|
|
102
|
+
<CardTitle>Additional Properties:</CardTitle>
|
|
103
|
+
</CardHeader>
|
|
104
|
+
<CardContent>
|
|
105
|
+
<SchemaView schema={schema.additionalProperties as SchemaObject} />
|
|
106
|
+
</CardContent>
|
|
107
|
+
</Card>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
182
110
|
|
|
183
|
-
return
|
|
111
|
+
return null;
|
|
184
112
|
};
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { CIRCULAR_REF } from "../../../oas/graphql/circular.js";
|
|
2
2
|
import type { SchemaObject } from "../../../oas/parser/index.js";
|
|
3
3
|
|
|
4
|
+
export const isBasicType = (
|
|
5
|
+
type: unknown,
|
|
6
|
+
): type is "string" | "number" | "boolean" | "integer" | "null" =>
|
|
7
|
+
typeof type === "string" &&
|
|
8
|
+
["string", "number", "boolean", "integer", "null"].includes(type);
|
|
9
|
+
|
|
4
10
|
export const isComplexType = (value: SchemaObject) =>
|
|
5
|
-
value.type === "object" ||
|
|
11
|
+
(value.type === "object" && Object.keys(value.properties ?? {}).length > 0) ||
|
|
6
12
|
(value.type === "array" &&
|
|
7
13
|
typeof value.items === "object" &&
|
|
8
14
|
(!value.items.type || value.items.type === "object"));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import slugify from "@sindresorhus/slugify";
|
|
2
1
|
import { redirect, type RouteObject } from "react-router";
|
|
3
2
|
import { joinUrl } from "../../../util/joinUrl.js";
|
|
4
3
|
import type { GraphQLClient } from "../client/GraphQLClient.js";
|
|
@@ -53,10 +52,7 @@ const createVersionRoutes = (
|
|
|
53
52
|
versionPath: string,
|
|
54
53
|
tagPages: string[],
|
|
55
54
|
): RouteObject[] => {
|
|
56
|
-
const firstTagRoute = joinUrl(
|
|
57
|
-
versionPath,
|
|
58
|
-
tagPages[0] ? slugify(tagPages[0]) : UNTAGGED_PATH,
|
|
59
|
-
);
|
|
55
|
+
const firstTagRoute = joinUrl(versionPath, tagPages.at(0) ?? UNTAGGED_PATH);
|
|
60
56
|
|
|
61
57
|
return [
|
|
62
58
|
// Redirect to first tag on the index route
|
|
@@ -64,7 +60,7 @@ const createVersionRoutes = (
|
|
|
64
60
|
// Create routes for each tag
|
|
65
61
|
...tagPages.map((tag) =>
|
|
66
62
|
createRoute({
|
|
67
|
-
path: joinUrl(versionPath,
|
|
63
|
+
path: joinUrl(versionPath, tag),
|
|
68
64
|
tag,
|
|
69
65
|
}),
|
|
70
66
|
),
|
|
@@ -73,6 +69,13 @@ const createVersionRoutes = (
|
|
|
73
69
|
path: joinUrl(versionPath, UNTAGGED_PATH),
|
|
74
70
|
untagged: true,
|
|
75
71
|
}),
|
|
72
|
+
{
|
|
73
|
+
path: joinUrl(versionPath, "~schemas"),
|
|
74
|
+
lazy: async () => {
|
|
75
|
+
const { SchemaList } = await import("../SchemaList.js");
|
|
76
|
+
return { element: <SchemaList /> };
|
|
77
|
+
},
|
|
78
|
+
},
|
|
76
79
|
];
|
|
77
80
|
};
|
|
78
81
|
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import { DialogTitle } from "zudoku/ui/Dialog.js";
|
|
12
12
|
import { useAuthState } from "../../authentication/state.js";
|
|
13
13
|
import { useZudoku } from "../../components/context/ZudokuContext.js";
|
|
14
|
+
import { SEARCH_PROTECTED_SECTION } from "../../core/RouteGuard.js";
|
|
14
15
|
import { joinUrl } from "../../util/joinUrl.js";
|
|
15
16
|
import { getResults } from "./get-results.js";
|
|
16
17
|
import type { PagefindOptions } from "./index.js";
|
|
@@ -35,11 +36,14 @@ const importPagefind = (basePath?: string): Promise<Pagefind> =>
|
|
|
35
36
|
: import(/* @vite-ignore */ joinUrl(basePath, "/pagefind/pagefind.js"));
|
|
36
37
|
|
|
37
38
|
const usePagefind = (options: PagefindOptions) => {
|
|
39
|
+
const {
|
|
40
|
+
options: { basePath },
|
|
41
|
+
} = useZudoku();
|
|
38
42
|
const { data: pagefind, ...result } = useQuery<Pagefind>({
|
|
39
43
|
queryKey: ["pagefind", options.ranking],
|
|
40
44
|
retry: false,
|
|
41
45
|
queryFn: async () => {
|
|
42
|
-
const pagefind = await importPagefind(
|
|
46
|
+
const pagefind = await importPagefind(basePath);
|
|
43
47
|
await pagefind.init();
|
|
44
48
|
await pagefind.options({
|
|
45
49
|
ranking: {
|
|
@@ -82,9 +86,13 @@ export const PagefindSearch = ({
|
|
|
82
86
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
83
87
|
|
|
84
88
|
const { data: searchResults } = useQuery({
|
|
85
|
-
queryKey: ["pagefind-search", searchTerm],
|
|
89
|
+
queryKey: ["pagefind-search", searchTerm, auth.isAuthenticated],
|
|
86
90
|
queryFn: async () => {
|
|
87
|
-
const
|
|
91
|
+
const filters = auth.isAuthenticated
|
|
92
|
+
? undefined
|
|
93
|
+
: { not: { section: SEARCH_PROTECTED_SECTION } };
|
|
94
|
+
|
|
95
|
+
const search = await pagefind?.search(searchTerm, { filters });
|
|
88
96
|
if (!search) return [];
|
|
89
97
|
return getResults({ search, options, auth, context });
|
|
90
98
|
},
|
|
@@ -145,7 +153,6 @@ export const PagefindSearch = ({
|
|
|
145
153
|
</div>
|
|
146
154
|
) : (
|
|
147
155
|
<ResultList
|
|
148
|
-
basePath={options.basePath}
|
|
149
156
|
searchResults={searchResults ?? []}
|
|
150
157
|
searchTerm={searchTerm}
|
|
151
158
|
onClose={onClose}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BracketsIcon, FileTextIcon } from "lucide-react";
|
|
2
|
-
import {
|
|
2
|
+
import { useLayoutEffect, useRef } from "react";
|
|
3
3
|
import { Link, useNavigate } from "react-router";
|
|
4
4
|
import { CommandGroup, CommandItem, CommandList } from "zudoku/ui/Command.js";
|
|
5
5
|
import {
|
|
@@ -22,7 +22,6 @@ const sortSubResults = (a: PagefindSubResult, b: PagefindSubResult) => {
|
|
|
22
22
|
const hoverClassname = `cursor-pointer border border-transparent data-[selected=true]:border-border`;
|
|
23
23
|
|
|
24
24
|
export const ResultList = ({
|
|
25
|
-
basePath,
|
|
26
25
|
searchResults,
|
|
27
26
|
searchTerm,
|
|
28
27
|
onClose,
|
|
@@ -37,16 +36,6 @@ export const ResultList = ({
|
|
|
37
36
|
const navigate = useNavigate();
|
|
38
37
|
const commandListRef = useRef<HTMLDivElement | null>(null);
|
|
39
38
|
|
|
40
|
-
const cleanResultUrl = useCallback(
|
|
41
|
-
(url: string) => {
|
|
42
|
-
const clean = url.replace(".html", "");
|
|
43
|
-
return basePath && clean.startsWith(basePath)
|
|
44
|
-
? clean.slice(basePath.length)
|
|
45
|
-
: clean;
|
|
46
|
-
},
|
|
47
|
-
[basePath],
|
|
48
|
-
);
|
|
49
|
-
|
|
50
39
|
useLayoutEffect(() => {
|
|
51
40
|
requestIdleCallback(() => {
|
|
52
41
|
commandListRef.current?.scrollTo({ top: 0 });
|
|
@@ -71,11 +60,11 @@ export const ResultList = ({
|
|
|
71
60
|
value={`${result.meta.title}-${result.url}`}
|
|
72
61
|
className={hoverClassname}
|
|
73
62
|
onSelect={() => {
|
|
74
|
-
void navigate(
|
|
63
|
+
void navigate(result.url);
|
|
75
64
|
onClose();
|
|
76
65
|
}}
|
|
77
66
|
>
|
|
78
|
-
<Link to={
|
|
67
|
+
<Link to={result.url}>
|
|
79
68
|
{result.meta.section === "openapi" ? (
|
|
80
69
|
<BracketsIcon />
|
|
81
70
|
) : (
|
|
@@ -94,11 +83,11 @@ export const ResultList = ({
|
|
|
94
83
|
value={`sub-${result.meta.title}-${subResult.url}`}
|
|
95
84
|
className={hoverClassname}
|
|
96
85
|
onSelect={() => {
|
|
97
|
-
void navigate(
|
|
86
|
+
void navigate(subResult.url);
|
|
98
87
|
onClose();
|
|
99
88
|
}}
|
|
100
89
|
>
|
|
101
|
-
<Link to={
|
|
90
|
+
<Link to={subResult.url} onClick={onClose}>
|
|
102
91
|
<div className="flex flex-col items-start gap-2 ms-2.5 ps-5 border-l border-muted-foreground/50">
|
|
103
92
|
<span className="font-bold">{subResult.title}</span>
|
|
104
93
|
<span
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from "react";
|
|
2
2
|
|
|
3
|
-
export const useOnScreen = ({
|
|
3
|
+
export const useOnScreen = <E extends Element = HTMLElement>({
|
|
4
4
|
rootMargin = "0px",
|
|
5
5
|
threshold,
|
|
6
|
+
root,
|
|
6
7
|
}: {
|
|
7
8
|
rootMargin?: string;
|
|
8
9
|
threshold?: number;
|
|
10
|
+
root?: Element | null;
|
|
9
11
|
} = {}) => {
|
|
10
12
|
const [isVisible, setIsVisible] = useState(false);
|
|
11
|
-
const ref = useRef<
|
|
13
|
+
const ref = useRef<E | null>(null);
|
|
12
14
|
|
|
13
15
|
useEffect(() => {
|
|
14
16
|
const observer = new IntersectionObserver(
|
|
@@ -16,7 +18,7 @@ export const useOnScreen = ({
|
|
|
16
18
|
if (!entry) return;
|
|
17
19
|
setIsVisible(entry.isIntersecting);
|
|
18
20
|
},
|
|
19
|
-
{ rootMargin, threshold },
|
|
21
|
+
{ rootMargin, threshold, root },
|
|
20
22
|
);
|
|
21
23
|
|
|
22
24
|
const currentElement = ref.current;
|
|
@@ -26,7 +28,7 @@ export const useOnScreen = ({
|
|
|
26
28
|
observer.observe(currentElement);
|
|
27
29
|
|
|
28
30
|
return () => observer.unobserve(currentElement);
|
|
29
|
-
}, [rootMargin, threshold]);
|
|
31
|
+
}, [root, rootMargin, threshold]);
|
|
30
32
|
|
|
31
33
|
return [ref, isVisible] as const;
|
|
32
34
|
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { glob } from "glob";
|
|
2
|
-
import fs from "node:fs/promises";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import colors from "picocolors";
|
|
5
|
-
import { runBuild } from "../../vite/build.js";
|
|
6
|
-
import { loadZudokuConfig } from "../../vite/config.js";
|
|
7
|
-
import { createPagefindIndex } from "../../vite/create-pagefind-index.js";
|
|
8
|
-
import { writeLine } from "../../vite/reporter.js";
|
|
9
|
-
import { logger } from "../common/logger.js";
|
|
10
|
-
const captureOutput = async (fn) => {
|
|
11
|
-
const stdout = process.stdout.write;
|
|
12
|
-
const stderr = process.stderr.write;
|
|
13
|
-
process.stdout.write = () => true;
|
|
14
|
-
process.stderr.write = () => true;
|
|
15
|
-
try {
|
|
16
|
-
return await fn();
|
|
17
|
-
}
|
|
18
|
-
finally {
|
|
19
|
-
process.stdout.write = stdout;
|
|
20
|
-
process.stderr.write = stderr;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
export const pagefindCommand = async (argv) => {
|
|
24
|
-
const dir = process.cwd();
|
|
25
|
-
const dist = path.join(dir, "dist");
|
|
26
|
-
const { config } = await loadZudokuConfig({ mode: "production", command: "build" }, dir);
|
|
27
|
-
if (config.search?.type !== "pagefind") {
|
|
28
|
-
logger.warn(colors.yellow("Search is not configured to use pagefind."));
|
|
29
|
-
}
|
|
30
|
-
const message = argv.forceBuild
|
|
31
|
-
? "creating build and pagefind index..."
|
|
32
|
-
: "building pagefind index...";
|
|
33
|
-
writeLine(colors.blue(message));
|
|
34
|
-
if (argv.forceBuild) {
|
|
35
|
-
await captureOutput(() => runBuild({ dir }));
|
|
36
|
-
}
|
|
37
|
-
const outputPath = await createPagefindIndex({
|
|
38
|
-
dir: dist,
|
|
39
|
-
outDir: path.join(process.cwd(), "public"),
|
|
40
|
-
});
|
|
41
|
-
const successMessage = argv.forceBuild
|
|
42
|
-
? `✓ build created and pagefind index written to ${outputPath}`
|
|
43
|
-
: `✓ pagefind index written to ${outputPath}`;
|
|
44
|
-
writeLine(colors.blue(successMessage));
|
|
45
|
-
// find pagefind directory in dist with glob
|
|
46
|
-
const pagefindGlob = await glob("**/pagefind/", {
|
|
47
|
-
cwd: dist,
|
|
48
|
-
absolute: true,
|
|
49
|
-
});
|
|
50
|
-
const pagefindDir = pagefindGlob.at(0);
|
|
51
|
-
if (!pagefindDir) {
|
|
52
|
-
throw new Error(`pagefind directory not found in ${dist}.`);
|
|
53
|
-
}
|
|
54
|
-
// move from dist to public dir so it can be consumed in dev
|
|
55
|
-
const publicDir = path.join(dir, "public/pagefind");
|
|
56
|
-
await fs.rm(publicDir, { recursive: true, force: true });
|
|
57
|
-
await fs.rename(pagefindDir, publicDir);
|
|
58
|
-
};
|
|
59
|
-
//# sourceMappingURL=pagefind-command.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pagefind-command.js","sourceRoot":"","sources":["../../../src/cli/dev/pagefind-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,MAAM,MAAM,YAAY,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,MAAM,aAAa,GAAG,KAAK,EAAK,EAAoB,EAAc,EAAE;IAClE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IACpC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC;IACpC,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;IAClC,OAAO,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,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M,cAAc,GAAG,IAAI,CAAC,UAAU;QACpC,CAAC,CAAC,iDAAiD,UAAU,EAAE;QAC/D,CAAC,CAAC,+BAA+B,UAAU,EAAE,CAAC;IAEhD,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC;IAEvC,4CAA4C;IAC5C,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,cAAc,EAAE;QAC9C,GAAG,EAAE,IAAI;QACT,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAEvC,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,mCAAmC,IAAI,GAAG,CAAC,CAAC;IAC9D,CAAC;IAED,4DAA4D;IAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;IAEpD,MAAM,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACzD,MAAM,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AAC1C,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PluginSystem.js","sourceRoot":"","sources":["../../../../src/lib/components/context/PluginSystem.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Toc.js","sourceRoot":"","sources":["../../../../src/lib/plugins/markdown/Toc.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,SAAS,EACT,MAAM,EACN,QAAQ,GAGT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAg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