zudoku 0.46.1 → 0.46.3
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/config/validators/InputSidebarSchema.d.ts +3 -0
- package/dist/config/validators/InputSidebarSchema.js +1 -0
- package/dist/config/validators/InputSidebarSchema.js.map +1 -1
- package/dist/config/validators/SidebarSchema.d.ts +1 -1
- package/dist/config/validators/validate.d.ts +12 -12
- package/dist/config/validators/validate.js +3 -1
- package/dist/config/validators/validate.js.map +1 -1
- package/dist/lib/authentication/AuthenticationPlugin.d.ts +0 -5
- package/dist/lib/authentication/AuthenticationPlugin.js +0 -12
- package/dist/lib/authentication/AuthenticationPlugin.js.map +1 -1
- package/dist/lib/components/navigation/SidebarItem.js +2 -3
- package/dist/lib/components/navigation/SidebarItem.js.map +1 -1
- package/dist/lib/plugins/api-keys/SettingsApiKeys.js +110 -15
- package/dist/lib/plugins/api-keys/SettingsApiKeys.js.map +1 -1
- package/dist/lib/plugins/api-keys/index.d.ts +3 -3
- package/dist/lib/plugins/api-keys/index.js +14 -14
- package/dist/lib/plugins/api-keys/index.js.map +1 -1
- package/dist/lib/plugins/openapi/Sidecar.js +11 -91
- package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/BodyPanel.d.ts +5 -0
- package/dist/lib/plugins/openapi/playground/BodyPanel.js +22 -0
- package/dist/lib/plugins/openapi/playground/BodyPanel.js.map +1 -0
- package/dist/lib/plugins/openapi/playground/ExamplesDropdown.js +2 -1
- package/dist/lib/plugins/openapi/playground/ExamplesDropdown.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/Headers.js +25 -25
- package/dist/lib/plugins/openapi/playground/Headers.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/IdentitySelector.js +1 -1
- package/dist/lib/plugins/openapi/playground/IdentitySelector.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/ParamsGrid.js +2 -2
- package/dist/lib/plugins/openapi/playground/ParamsGrid.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/PathParams.js +1 -1
- package/dist/lib/plugins/openapi/playground/PathParams.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/Playground.d.ts +3 -8
- package/dist/lib/plugins/openapi/playground/Playground.js +70 -65
- package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js +1 -1
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/QueryParams.js +1 -1
- package/dist/lib/plugins/openapi/playground/QueryParams.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/fileUtils.d.ts +2 -0
- package/dist/lib/plugins/openapi/playground/fileUtils.js +22 -0
- package/dist/lib/plugins/openapi/playground/fileUtils.js.map +1 -0
- package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.d.ts +4 -1
- package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js +29 -20
- package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/result-panel/ResultPanel.js +2 -2
- package/dist/lib/plugins/openapi/playground/result-panel/ResultPanel.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/useRememberSkipLoginDialog.d.ts +16 -0
- package/dist/lib/plugins/openapi/playground/useRememberSkipLoginDialog.js +10 -0
- package/dist/lib/plugins/openapi/playground/useRememberSkipLoginDialog.js.map +1 -0
- package/dist/lib/plugins/openapi/util/createHttpSnippet.d.ts +11 -0
- package/dist/lib/plugins/openapi/util/createHttpSnippet.js +89 -0
- package/dist/lib/plugins/openapi/util/createHttpSnippet.js.map +1 -0
- package/dist/lib/shiki.d.ts +8 -12
- package/dist/lib/shiki.js +11 -13
- package/dist/lib/shiki.js.map +1 -1
- package/dist/lib/ui/CodeBlock.js +1 -1
- package/dist/lib/ui/CodeBlock.js.map +1 -1
- package/dist/lib/ui/Dialog.d.ts +3 -1
- package/dist/lib/ui/Dialog.js +2 -2
- package/dist/lib/ui/Dialog.js.map +1 -1
- package/dist/lib/util/humanFileSize.d.ts +6 -0
- package/dist/lib/util/humanFileSize.js +14 -0
- package/dist/lib/util/humanFileSize.js.map +1 -0
- package/dist/lib/util/humanFileSize.test.d.ts +1 -0
- package/dist/lib/util/humanFileSize.test.js +22 -0
- package/dist/lib/util/humanFileSize.test.js.map +1 -0
- package/dist/vite/build.js +1 -4
- package/dist/vite/build.js.map +1 -1
- package/lib/{Callout-BkgOUkoZ.js → Callout-CoVxYafP.js} +2 -2
- package/lib/{Callout-BkgOUkoZ.js.map → Callout-CoVxYafP.js.map} +1 -1
- package/lib/{Dialog-Du6WMcIA.js → Dialog-BxpuVLh9.js} +25 -25
- package/lib/Dialog-BxpuVLh9.js.map +1 -0
- package/lib/{Markdown-BRAyzyUJ.js → Markdown-D81l28Ib.js} +310 -306
- package/lib/{Markdown-BRAyzyUJ.js.map → Markdown-D81l28Ib.js.map} +1 -1
- package/lib/{MdxPage-B3v1BSKr.js → MdxPage-S_CxlNmX.js} +5 -5
- package/lib/{MdxPage-B3v1BSKr.js.map → MdxPage-S_CxlNmX.js.map} +1 -1
- package/lib/{OasProvider-5jrFuhVk.js → OasProvider-D5rt6WMb.js} +3 -3
- package/lib/{OasProvider-5jrFuhVk.js.map → OasProvider-D5rt6WMb.js.map} +1 -1
- package/lib/{OperationList-BmoMLQPO.js → OperationList-CNhg654C.js} +1139 -1131
- package/lib/OperationList-CNhg654C.js.map +1 -0
- package/lib/{Pagination-Cr0fWZS3.js → Pagination-CCxhL836.js} +2 -2
- package/lib/{Pagination-Cr0fWZS3.js.map → Pagination-CCxhL836.js.map} +1 -1
- package/lib/{RouteGuard-PrSVLbSr.js → RouteGuard-CZ_uLv3g.js} +6 -6
- package/lib/{RouteGuard-PrSVLbSr.js.map → RouteGuard-CZ_uLv3g.js.map} +1 -1
- package/lib/{SchemaList-B4riYLoP.js → SchemaList-BvzCrTYg.js} +6 -6
- package/lib/{SchemaList-B4riYLoP.js.map → SchemaList-BvzCrTYg.js.map} +1 -1
- package/lib/{SchemaView-CPZ6RgsF.js → SchemaView-Br1RupCp.js} +3 -3
- package/lib/{SchemaView-CPZ6RgsF.js.map → SchemaView-Br1RupCp.js.map} +1 -1
- package/lib/{SignUp-CWaiH0tY.js → SignUp-B-1Pvc-8.js} +3 -3
- package/lib/{SignUp-CWaiH0tY.js.map → SignUp-B-1Pvc-8.js.map} +1 -1
- package/lib/{Slot-Bo6K4tnb.js → Slot-T8NJUkm4.js} +11 -11
- package/lib/{Slot-Bo6K4tnb.js.map → Slot-T8NJUkm4.js.map} +1 -1
- package/lib/{SyntaxHighlight-DedRjJNr.js → SyntaxHighlight-Cz6Me7-F.js} +4474 -3323
- package/lib/SyntaxHighlight-Cz6Me7-F.js.map +1 -0
- package/lib/{Toc-lL3fzNkl.js → Toc-PA-j0gEu.js} +2 -2
- package/lib/{Toc-lL3fzNkl.js.map → Toc-PA-j0gEu.js.map} +1 -1
- package/lib/{chunk-BAXFHI7N-C9WnHsLV.js → chunk-DQRVZFIR-BblmKnHy.js} +697 -697
- package/lib/chunk-DQRVZFIR-BblmKnHy.js.map +1 -0
- package/lib/{circular-oB4auIIg.js → circular-5FeDWJOn.js} +1812 -1807
- package/lib/circular-5FeDWJOn.js.map +1 -0
- package/lib/{createServer-DCB82j2t.js → createServer-BC2RZgmW.js} +3648 -3493
- package/lib/createServer-BC2RZgmW.js.map +1 -0
- package/lib/{hook-DawSLaZr.js → hook-k7PfUIsj.js} +10 -10
- package/lib/{hook-DawSLaZr.js.map → hook-k7PfUIsj.js.map} +1 -1
- package/lib/{index-BXYvD5-7.js → index-CJZthJSj.js} +1053 -1095
- package/lib/index-CJZthJSj.js.map +1 -0
- package/lib/index.esm-Cp4wkyud.js +1236 -0
- package/lib/index.esm-Cp4wkyud.js.map +1 -0
- package/lib/{mutation-oxMvODNQ.js → mutation-BSeQ8pEK.js} +2 -2
- package/lib/{mutation-oxMvODNQ.js.map → mutation-BSeQ8pEK.js.map} +1 -1
- package/lib/react-nprogress.esm-C2MPXjiJ.js +389 -0
- package/lib/react-nprogress.esm-C2MPXjiJ.js.map +1 -0
- package/lib/ui/CodeBlock.js +17 -16
- package/lib/ui/CodeBlock.js.map +1 -1
- package/lib/ui/Command.js +1 -1
- package/lib/ui/Dialog.js +25 -25
- package/lib/ui/Dialog.js.map +1 -1
- package/lib/ui/Form.js +1 -1
- package/lib/ui/SyntaxHighlight.js +2 -2
- package/lib/{useExposedProps-DG8J6ewJ.js → useExposedProps-BZQkZneR.js} +2 -2
- package/lib/{useExposedProps-DG8J6ewJ.js.map → useExposedProps-BZQkZneR.js.map} +1 -1
- package/lib/{useMutation-C_j3dA_L.js → useMutation-CZSmsIGW.js} +3 -3
- package/lib/{useMutation-C_j3dA_L.js.map → useMutation-CZSmsIGW.js.map} +1 -1
- package/lib/zudoku.auth-auth0.js +1 -1
- package/lib/zudoku.auth-clerk.js +2 -2
- package/lib/zudoku.auth-openid.js +57 -66
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/lib/zudoku.components.js +1698 -2082
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.hooks.js +11 -11
- package/lib/zudoku.plugin-api-catalog.js +5 -5
- package/lib/zudoku.plugin-api-keys.js +473 -4970
- package/lib/zudoku.plugin-api-keys.js.map +1 -1
- package/lib/zudoku.plugin-custom-pages.js +2 -2
- package/lib/zudoku.plugin-markdown.js +1 -1
- package/lib/zudoku.plugin-openapi.js +3 -3
- package/lib/zudoku.plugin-redirect.js +1 -1
- package/lib/zudoku.plugin-search-pagefind.js +5 -5
- package/package.json +33 -34
- package/src/lib/authentication/AuthenticationPlugin.tsx +0 -14
- package/src/lib/components/navigation/SidebarItem.tsx +2 -1
- package/src/lib/plugins/api-keys/SettingsApiKeys.tsx +193 -48
- package/src/lib/plugins/api-keys/index.tsx +25 -18
- package/src/lib/plugins/openapi/Sidecar.tsx +11 -97
- package/src/lib/plugins/openapi/playground/BodyPanel.tsx +46 -0
- package/src/lib/plugins/openapi/playground/ExamplesDropdown.tsx +4 -1
- package/src/lib/plugins/openapi/playground/Headers.tsx +110 -106
- package/src/lib/plugins/openapi/playground/IdentitySelector.tsx +13 -11
- package/src/lib/plugins/openapi/playground/ParamsGrid.tsx +2 -2
- package/src/lib/plugins/openapi/playground/PathParams.tsx +1 -1
- package/src/lib/plugins/openapi/playground/Playground.tsx +127 -211
- package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +2 -1
- package/src/lib/plugins/openapi/playground/QueryParams.tsx +1 -1
- package/src/lib/plugins/openapi/playground/fileUtils.ts +32 -0
- package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +74 -39
- package/src/lib/plugins/openapi/playground/result-panel/ResultPanel.tsx +4 -1
- package/src/lib/plugins/openapi/playground/useRememberSkipLoginDialog.tsx +20 -0
- package/src/lib/plugins/openapi/util/createHttpSnippet.ts +107 -0
- package/src/lib/shiki.ts +21 -22
- package/src/lib/ui/CodeBlock.tsx +1 -0
- package/src/lib/ui/Dialog.tsx +11 -7
- package/src/lib/util/humanFileSize.test.ts +24 -0
- package/src/lib/util/humanFileSize.ts +16 -0
- package/dist/lib/plugins/openapi/playground/SubmitButton.d.ts +0 -7
- package/dist/lib/plugins/openapi/playground/SubmitButton.js +0 -19
- package/dist/lib/plugins/openapi/playground/SubmitButton.js.map +0 -1
- package/lib/Dialog-Du6WMcIA.js.map +0 -1
- package/lib/OperationList-BmoMLQPO.js.map +0 -1
- package/lib/SyntaxHighlight-DedRjJNr.js.map +0 -1
- package/lib/chunk-BAXFHI7N-C9WnHsLV.js.map +0 -1
- package/lib/circular-oB4auIIg.js.map +0 -1
- package/lib/createServer-DCB82j2t.js.map +0 -1
- package/lib/index-BXYvD5-7.js.map +0 -1
- package/lib/index.esm-DSfX_eMP.js +0 -1216
- package/lib/index.esm-DSfX_eMP.js.map +0 -1
- package/src/lib/plugins/openapi/playground/SubmitButton.tsx +0 -70
|
@@ -32,7 +32,7 @@ export const ResultPanel = ({
|
|
|
32
32
|
}) => {
|
|
33
33
|
const status = ((queryMutation.data?.status ?? 0) / 100).toFixed(0);
|
|
34
34
|
return (
|
|
35
|
-
<div className="min-w-0 p-4 py-
|
|
35
|
+
<div className="min-w-0 p-4 py-4 bg-muted/50">
|
|
36
36
|
{queryMutation.error ? (
|
|
37
37
|
<div className="flex flex-col gap-2">
|
|
38
38
|
{showPathParamsWarning && (
|
|
@@ -83,6 +83,9 @@ export const ResultPanel = ({
|
|
|
83
83
|
headers={queryMutation.data.headers}
|
|
84
84
|
body={queryMutation.data.body}
|
|
85
85
|
url={queryMutation.data.request.url}
|
|
86
|
+
isBinary={queryMutation.data.isBinary}
|
|
87
|
+
fileName={queryMutation.data.fileName}
|
|
88
|
+
blob={queryMutation.data.blob}
|
|
86
89
|
/>
|
|
87
90
|
</TabsContent>
|
|
88
91
|
</Tabs>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { create } from "zustand";
|
|
2
|
+
import { createJSONStorage, persist } from "zustand/middleware";
|
|
3
|
+
|
|
4
|
+
type RememberSkipLoginState = {
|
|
5
|
+
skipLogin: boolean;
|
|
6
|
+
setSkipLogin: (skipLogin: boolean) => void;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const useRememberSkipLoginDialog = create<RememberSkipLoginState>()(
|
|
10
|
+
persist(
|
|
11
|
+
(set) => ({
|
|
12
|
+
skipLogin: false,
|
|
13
|
+
setSkipLogin: (skipLogin: boolean) => set({ skipLogin }),
|
|
14
|
+
}),
|
|
15
|
+
{
|
|
16
|
+
name: "remember-skip-login",
|
|
17
|
+
storage: createJSONStorage(() => sessionStorage),
|
|
18
|
+
},
|
|
19
|
+
),
|
|
20
|
+
);
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { HTTPSnippet } from "@zudoku/httpsnippet";
|
|
2
|
+
import type { OperationsFragmentFragment } from "../graphql/graphql.js";
|
|
3
|
+
|
|
4
|
+
export const createHttpSnippet = ({
|
|
5
|
+
operation,
|
|
6
|
+
selectedServer,
|
|
7
|
+
exampleBody,
|
|
8
|
+
}: {
|
|
9
|
+
operation: OperationsFragmentFragment;
|
|
10
|
+
selectedServer: string;
|
|
11
|
+
exampleBody: {
|
|
12
|
+
mimeType: string;
|
|
13
|
+
text?: string;
|
|
14
|
+
};
|
|
15
|
+
}) => {
|
|
16
|
+
return new HTTPSnippet({
|
|
17
|
+
method: operation.method.toUpperCase(),
|
|
18
|
+
url:
|
|
19
|
+
selectedServer + operation.path.replaceAll("{", ":").replaceAll("}", ""),
|
|
20
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
21
|
+
postData: exampleBody,
|
|
22
|
+
headers: [
|
|
23
|
+
...(exampleBody.text
|
|
24
|
+
? [{ name: "Content-Type", value: exampleBody.mimeType }]
|
|
25
|
+
: []),
|
|
26
|
+
...(operation.parameters
|
|
27
|
+
?.filter((p) => p.in === "header" && p.required === true)
|
|
28
|
+
.map((p) => ({
|
|
29
|
+
name: p.name,
|
|
30
|
+
value:
|
|
31
|
+
p.schema?.default ??
|
|
32
|
+
p.examples?.find((x) => x.value)?.value ??
|
|
33
|
+
(p.schema?.type === "string"
|
|
34
|
+
? "<string>"
|
|
35
|
+
: p.schema?.type === "number" || p.schema?.type === "integer"
|
|
36
|
+
? "<number>"
|
|
37
|
+
: p.schema?.type === "boolean"
|
|
38
|
+
? "<bool>"
|
|
39
|
+
: "<value>"),
|
|
40
|
+
})) ?? []),
|
|
41
|
+
],
|
|
42
|
+
queryString:
|
|
43
|
+
operation.parameters
|
|
44
|
+
?.filter((p) => p.in === "query" && p.required === true)
|
|
45
|
+
.map((p) => ({
|
|
46
|
+
name: p.name,
|
|
47
|
+
value:
|
|
48
|
+
p.schema?.default ??
|
|
49
|
+
p.examples?.find((x) => x.value)?.value ??
|
|
50
|
+
(p.schema?.type === "string"
|
|
51
|
+
? "<string>"
|
|
52
|
+
: p.schema?.type === "number" || p.schema?.type === "integer"
|
|
53
|
+
? "<number>"
|
|
54
|
+
: p.schema?.type === "boolean"
|
|
55
|
+
? "<bool>"
|
|
56
|
+
: "<value>"),
|
|
57
|
+
})) ?? [],
|
|
58
|
+
httpVersion: "",
|
|
59
|
+
cookies: [],
|
|
60
|
+
headersSize: 0,
|
|
61
|
+
bodySize: 0,
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export const getConverted = (snippet: HTTPSnippet, option: string) => {
|
|
66
|
+
let converted;
|
|
67
|
+
switch (option) {
|
|
68
|
+
case "shell":
|
|
69
|
+
converted = snippet.convert("shell", "curl");
|
|
70
|
+
break;
|
|
71
|
+
case "js":
|
|
72
|
+
converted = snippet.convert("javascript", "fetch");
|
|
73
|
+
break;
|
|
74
|
+
case "python":
|
|
75
|
+
converted = snippet.convert("python", "requests");
|
|
76
|
+
break;
|
|
77
|
+
case "java":
|
|
78
|
+
converted = snippet.convert("java", "okhttp");
|
|
79
|
+
break;
|
|
80
|
+
case "go":
|
|
81
|
+
converted = snippet.convert("go", "native");
|
|
82
|
+
break;
|
|
83
|
+
case "csharp":
|
|
84
|
+
converted = snippet.convert("csharp", "httpclient");
|
|
85
|
+
break;
|
|
86
|
+
case "kotlin":
|
|
87
|
+
converted = snippet.convert("kotlin", "okhttp");
|
|
88
|
+
break;
|
|
89
|
+
case "objc":
|
|
90
|
+
converted = snippet.convert("objc", "nsurlsession");
|
|
91
|
+
break;
|
|
92
|
+
case "php":
|
|
93
|
+
converted = snippet.convert("php", "http2");
|
|
94
|
+
break;
|
|
95
|
+
case "ruby":
|
|
96
|
+
converted = snippet.convert("ruby");
|
|
97
|
+
break;
|
|
98
|
+
case "swift":
|
|
99
|
+
converted = snippet.convert("swift");
|
|
100
|
+
break;
|
|
101
|
+
default:
|
|
102
|
+
converted = snippet.convert("shell");
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return converted ? converted[0] : "";
|
|
107
|
+
};
|
package/src/lib/shiki.ts
CHANGED
|
@@ -9,7 +9,12 @@ import type { Root } from "hast";
|
|
|
9
9
|
import { toJsxRuntime } from "hast-util-to-jsx-runtime";
|
|
10
10
|
import { Fragment, type JSX } from "react";
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
import type {
|
|
12
|
+
import type {
|
|
13
|
+
BundledLanguage,
|
|
14
|
+
BundledTheme,
|
|
15
|
+
CodeOptionsMultipleThemes,
|
|
16
|
+
HighlighterCore,
|
|
17
|
+
} from "shiki";
|
|
13
18
|
import { createHighlighterCore } from "shiki/core";
|
|
14
19
|
import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
|
|
15
20
|
import type { Pluggable } from "unified";
|
|
@@ -30,11 +35,13 @@ export const highlighter = await createHighlighterCore({
|
|
|
30
35
|
},
|
|
31
36
|
});
|
|
32
37
|
|
|
38
|
+
type ThemesRecord = CodeOptionsMultipleThemes<BundledTheme>["themes"];
|
|
39
|
+
|
|
33
40
|
export const defaultHighlightOptions = {
|
|
34
41
|
themes: {
|
|
35
42
|
light: "github-light",
|
|
36
43
|
dark: "github-dark",
|
|
37
|
-
}
|
|
44
|
+
},
|
|
38
45
|
defaultColor: false,
|
|
39
46
|
inline: "tailing-curly-colon",
|
|
40
47
|
addLanguageClass: true,
|
|
@@ -97,31 +104,23 @@ const rehypeCodeBlockPlugin = () => (tree: Root) => {
|
|
|
97
104
|
});
|
|
98
105
|
};
|
|
99
106
|
|
|
100
|
-
export const createConfiguredShikiRehypePlugins = (themes?:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
} satisfies RehypeShikiCoreOptions,
|
|
112
|
-
] satisfies Pluggable,
|
|
113
|
-
rehypeCodeBlockPlugin,
|
|
114
|
-
];
|
|
115
|
-
};
|
|
107
|
+
export const createConfiguredShikiRehypePlugins = (themes?: ThemesRecord) => [
|
|
108
|
+
[
|
|
109
|
+
rehypeShikiFromHighlighter,
|
|
110
|
+
highlighter,
|
|
111
|
+
{
|
|
112
|
+
...defaultHighlightOptions,
|
|
113
|
+
themes: themes ?? defaultHighlightOptions.themes,
|
|
114
|
+
},
|
|
115
|
+
] satisfies Pluggable,
|
|
116
|
+
rehypeCodeBlockPlugin,
|
|
117
|
+
];
|
|
116
118
|
|
|
117
119
|
export const highlight = (
|
|
118
120
|
highlighter: HighlighterCore,
|
|
119
121
|
code: string,
|
|
120
122
|
lang = "text",
|
|
121
|
-
themes:
|
|
122
|
-
light: BundledTheme;
|
|
123
|
-
dark: BundledTheme;
|
|
124
|
-
} = defaultHighlightOptions.themes,
|
|
123
|
+
themes: ThemesRecord = defaultHighlightOptions.themes,
|
|
125
124
|
) => {
|
|
126
125
|
const value = highlighter.codeToHast(code, {
|
|
127
126
|
lang,
|
package/src/lib/ui/CodeBlock.tsx
CHANGED
package/src/lib/ui/Dialog.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
2
|
-
import { X } from "lucide-react";
|
|
3
2
|
import * as React from "react";
|
|
4
3
|
|
|
4
|
+
import { XIcon } from "lucide-react";
|
|
5
5
|
import { cn } from "../util/cn.js";
|
|
6
6
|
|
|
7
7
|
const Dialog = DialogPrimitive.Root;
|
|
@@ -29,8 +29,10 @@ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|
|
29
29
|
|
|
30
30
|
const DialogContent = React.forwardRef<
|
|
31
31
|
React.ElementRef<typeof DialogPrimitive.Content>,
|
|
32
|
-
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>
|
|
33
|
-
|
|
32
|
+
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
|
|
33
|
+
showCloseButton?: boolean;
|
|
34
|
+
}
|
|
35
|
+
>(({ className, children, showCloseButton = true, ...props }, ref) => (
|
|
34
36
|
<DialogPortal>
|
|
35
37
|
<DialogOverlay />
|
|
36
38
|
<DialogPrimitive.Content
|
|
@@ -42,10 +44,12 @@ const DialogContent = React.forwardRef<
|
|
|
42
44
|
{...props}
|
|
43
45
|
>
|
|
44
46
|
{children}
|
|
45
|
-
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
{showCloseButton && (
|
|
48
|
+
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground">
|
|
49
|
+
<XIcon className="h-4 w-4" />
|
|
50
|
+
<span className="sr-only">Close</span>
|
|
51
|
+
</DialogPrimitive.Close>
|
|
52
|
+
)}
|
|
49
53
|
</DialogPrimitive.Content>
|
|
50
54
|
</DialogPortal>
|
|
51
55
|
));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { humanFileSize } from "./humanFileSize.js";
|
|
2
|
+
|
|
3
|
+
describe("humanFileSize", () => {
|
|
4
|
+
it("should handle zero bytes", () => {
|
|
5
|
+
expect(humanFileSize(0)).toBe("0 B");
|
|
6
|
+
expect(humanFileSize()).toBe("0 B");
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
it("should handle undefined bytes", () => {
|
|
10
|
+
expect(humanFileSize(undefined)).toBe("0 B");
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("should handle positive bytes", () => {
|
|
14
|
+
expect(humanFileSize(200)).toBe("200 B");
|
|
15
|
+
expect(humanFileSize(1000)).toBe("1.00 kB");
|
|
16
|
+
expect(humanFileSize(1000000)).toBe("1.00 MB");
|
|
17
|
+
expect(humanFileSize(1000000000)).toBe("1.00 GB");
|
|
18
|
+
expect(humanFileSize(1000000000000)).toBe("1.00 TB");
|
|
19
|
+
expect(humanFileSize(1000000000000000)).toBe("1.00 PB");
|
|
20
|
+
expect(humanFileSize(1000000000000000000)).toBe("1.00 EB");
|
|
21
|
+
expect(humanFileSize(1000000000000000000000)).toBe("1.00 ZB");
|
|
22
|
+
expect(humanFileSize(1000000000000000000000000)).toBe("1.00 YB");
|
|
23
|
+
});
|
|
24
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a number of bytes to a human-readable file size string
|
|
3
|
+
* @param bytes - The number of bytes (defaults to 0)
|
|
4
|
+
* @returns A formatted string like "1.23 MB" or "456 B"
|
|
5
|
+
*/
|
|
6
|
+
export const humanFileSize = (bytes = 0) => {
|
|
7
|
+
if (bytes === 0) {
|
|
8
|
+
return "0 B";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const exponent = Math.floor(Math.log(bytes) / Math.log(1000.0));
|
|
12
|
+
const decimal = (bytes / Math.pow(1000.0, exponent)).toFixed(
|
|
13
|
+
exponent ? 2 : 0,
|
|
14
|
+
);
|
|
15
|
+
return `${decimal} ${exponent ? `${"kMGTPEZY"[exponent - 1]}B` : "B"}`;
|
|
16
|
+
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { type ApiIdentity } from "../../../core/ZudokuContext.js";
|
|
2
|
-
declare const SubmitButton: ({ identities, formRef, disabled, }: {
|
|
3
|
-
identities: ApiIdentity[];
|
|
4
|
-
formRef?: React.RefObject<HTMLFormElement | null>;
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
-
export default SubmitButton;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { CheckIcon, ChevronDownIcon } from "lucide-react";
|
|
3
|
-
import { useFormContext } from "react-hook-form";
|
|
4
|
-
import { Button } from "zudoku/ui/Button.js";
|
|
5
|
-
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "zudoku/ui/DropdownMenu.js";
|
|
6
|
-
import { NO_IDENTITY } from "./Playground.js";
|
|
7
|
-
const SubmitButton = ({ identities, formRef, disabled, }) => {
|
|
8
|
-
const { setValue, watch } = useFormContext();
|
|
9
|
-
const formIdentity = watch("identity");
|
|
10
|
-
if (identities.length === 0) {
|
|
11
|
-
return _jsx(Button, { disabled: disabled, children: "Send" });
|
|
12
|
-
}
|
|
13
|
-
return (_jsxs("div", { className: "flex", children: [_jsx(Button, { className: "rounded-r-none inset-shadow-xs", disabled: disabled, onClick: () => formRef?.current?.requestSubmit(), children: "Send" }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { disabled: disabled, className: "rounded-l-none border-l border-border/40 inset-shadow-xs w-6", size: "icon", children: _jsx(ChevronDownIcon, { className: "w-4 h-4" }) }) }), _jsx(DropdownMenuContent, { className: "w-56", align: "end", alignOffset: -150, children: [{ id: NO_IDENTITY, label: "None" }, ...identities].map((identity) => (_jsxs(DropdownMenuItem, { onClick: () => {
|
|
14
|
-
setValue("identity", identity.id);
|
|
15
|
-
formRef?.current?.requestSubmit();
|
|
16
|
-
}, children: [identity.label, formIdentity === identity.id && (_jsx(CheckIcon, { className: "ms-2", size: 16 }))] }, identity.id))) })] })] }));
|
|
17
|
-
};
|
|
18
|
-
export default SubmitButton;
|
|
19
|
-
//# sourceMappingURL=SubmitButton.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SubmitButton.js","sourceRoot":"","sources":["../../../../../src/lib/plugins/openapi/playground/SubmitButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,WAAW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AAE,IAAI,CAC/B,KAAC,SAAS,IAAC,SAAS,EAAC,MAAM,EAAC,IAAI,EAAE,EAAE,GAAI,CACzC,KATI,QAAQ,CAAC,EAAE,CAUC,CACpB,CACF,GACmB,IACT,IACX,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Dialog-Du6WMcIA.js","sources":["../src/lib/ui/Dialog.tsx"],"sourcesContent":["import * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport { X } from \"lucide-react\";\nimport * as React from \"react\";\n\nimport { cn } from \"../util/cn.js\";\n\nconst Dialog = DialogPrimitive.Root;\n\nconst DialogTrigger = DialogPrimitive.Trigger;\n\nconst DialogPortal = DialogPrimitive.Portal;\n\nconst DialogClose = DialogPrimitive.Close;\n\nconst DialogOverlay = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Overlay>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Overlay\n ref={ref}\n className={cn(\n \"fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0\",\n className,\n )}\n {...props}\n />\n));\nDialogOverlay.displayName = DialogPrimitive.Overlay.displayName;\n\nconst DialogContent = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Content>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content>\n>(({ className, children, ...props }, ref) => (\n <DialogPortal>\n <DialogOverlay />\n <DialogPrimitive.Content\n ref={ref}\n className={cn(\n \"fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg\",\n className,\n )}\n {...props}\n >\n {children}\n <DialogPrimitive.Close className=\"absolute right-4 top-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-hidden focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground\">\n <X className=\"h-4 w-4\" />\n <span className=\"sr-only\">Close</span>\n </DialogPrimitive.Close>\n </DialogPrimitive.Content>\n </DialogPortal>\n));\nDialogContent.displayName = DialogPrimitive.Content.displayName;\n\nconst DialogHeader = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\n \"flex flex-col space-y-1.5 text-center sm:text-left\",\n className,\n )}\n {...props}\n />\n);\nDialogHeader.displayName = \"DialogHeader\";\n\nconst DialogFooter = ({\n className,\n ...props\n}: React.HTMLAttributes<HTMLDivElement>) => (\n <div\n className={cn(\n \"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2\",\n className,\n )}\n {...props}\n />\n);\nDialogFooter.displayName = \"DialogFooter\";\n\nconst DialogTitle = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Title>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Title>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Title\n ref={ref}\n className={cn(\n \"text-lg font-semibold leading-none tracking-tight\",\n className,\n )}\n {...props}\n />\n));\nDialogTitle.displayName = DialogPrimitive.Title.displayName;\n\nconst DialogDescription = React.forwardRef<\n React.ElementRef<typeof DialogPrimitive.Description>,\n React.ComponentPropsWithoutRef<typeof DialogPrimitive.Description>\n>(({ className, ...props }, ref) => (\n <DialogPrimitive.Description\n ref={ref}\n className={cn(\"text-sm text-muted-foreground\", className)}\n {...props}\n />\n));\nDialogDescription.displayName = DialogPrimitive.Description.displayName;\n\nexport {\n Dialog,\n DialogClose,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogOverlay,\n DialogPortal,\n DialogTitle,\n DialogTrigger,\n};\n"],"names":["Dialog","DialogPrimitive","DialogTrigger","DialogPortal","DialogClose","DialogOverlay","React","className","props","ref","jsx","cn","DialogContent","children","jsxs","X","DialogHeader","DialogFooter","DialogTitle","DialogDescription"],"mappings":";;;;;AAMA,MAAMA,IAASC,EAAgB,MAEzBC,IAAgBD,EAAgB,SAEhCE,IAAeF,EAAgB,QAE/BG,IAAcH,EAAgB,OAE9BI,IAAgBC,EAAM,WAG1B,CAAC,EAAE,WAAAC,GAAW,GAAGC,EAAM,GAAGC,MAC1BC,gBAAAA,EAAA;AAAA,EAACT,EAAgB;AAAA,EAAhB;AAAA,IACC,KAAAQ;AAAA,IACA,WAAWE;AAAA,MACT;AAAA,MACAJ;AAAA,IACF;AAAA,IACC,GAAGC;AAAA,EAAA;AACN,CACD;AACDH,EAAc,cAAcJ,EAAgB,QAAQ;AAEpD,MAAMW,IAAgBN,EAAM,WAG1B,CAAC,EAAE,WAAAC,GAAW,UAAAM,GAAU,GAAGL,EAAM,GAAGC,MACpCK,gBAAAA,EAAAA,KAACX,GACC,EAAA,UAAA;AAAA,EAAAO,gBAAAA,EAAA,IAACL,GAAc,EAAA;AAAA,EACfS,gBAAAA,EAAA;AAAA,IAACb,EAAgB;AAAA,IAAhB;AAAA,MACC,KAAAQ;AAAA,MACA,WAAWE;AAAA,QACT;AAAA,QACAJ;AAAA,MACF;AAAA,MACC,GAAGC;AAAA,MAEH,UAAA;AAAA,QAAAK;AAAA,QACAC,gBAAAA,EAAA,KAAAb,EAAgB,OAAhB,EAAsB,WAAU,mRAC/B,UAAA;AAAA,UAACS,gBAAAA,EAAAA,IAAAK,GAAA,EAAE,WAAU,UAAU,CAAA;AAAA,UACtBL,gBAAAA,EAAA,IAAA,QAAA,EAAK,WAAU,WAAU,UAAK,QAAA,CAAA;AAAA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