zudoku 0.1.1-dev.18 → 0.1.1-dev.19
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/lib/plugins/openapi/worker/createSharedWorkerClient.js +2 -3
- package/dist/lib/plugins/openapi/worker/createSharedWorkerClient.js.map +1 -1
- package/dist/lib/plugins/openapi/worker/shared-worker.d.ts +1 -0
- package/dist/lib/plugins/openapi/worker/shared-worker.js +6 -0
- package/dist/lib/plugins/openapi/worker/shared-worker.js.map +1 -0
- package/dist/vite/config.d.ts +1 -1
- package/dist/vite/config.js +13 -13
- package/dist/vite/config.js.map +1 -1
- package/dist/vite/dev-server.js +1 -1
- package/dist/vite/dev-server.js.map +1 -1
- package/lib/zudoku.openapi-worker.js +12 -0
- package/lib/zudoku.plugins.js +1318 -1323
- package/package.json +5 -2
- package/src/cli/build/handler.ts +14 -0
- package/src/cli/cli.ts +77 -0
- package/src/cli/cmds/build.ts +24 -0
- package/src/cli/cmds/dev.ts +29 -0
- package/src/cli/common/analytics/lib.ts +89 -0
- package/src/cli/common/constants.ts +10 -0
- package/src/cli/common/logger.ts +5 -0
- package/src/cli/common/machine-id/lib.ts +85 -0
- package/src/cli/common/outdated.ts +102 -0
- package/src/cli/common/output.ts +86 -0
- package/src/cli/common/utils/box.license.txt +202 -0
- package/src/cli/common/utils/box.ts +116 -0
- package/src/cli/common/utils/ports.ts +21 -0
- package/src/cli/common/validators/lib.ts +43 -0
- package/src/cli/common/xdg/lib.ts +36 -0
- package/src/cli/dev/handler.ts +42 -0
- package/src/config/config.ts +56 -0
- package/src/index.ts +8 -0
- package/src/lib/DevPortal.tsx +93 -0
- package/src/lib/Heading.tsx +60 -0
- package/src/lib/Router.tsx +28 -0
- package/src/lib/auth.ts +1 -0
- package/src/lib/authentication/authentication.ts +18 -0
- package/src/lib/authentication/clerk.ts +45 -0
- package/src/lib/authentication/openid.ts +192 -0
- package/src/lib/components/AnchorLink.tsx +19 -0
- package/src/lib/components/CategoryHeading.tsx +16 -0
- package/src/lib/components/Dialog.tsx +119 -0
- package/src/lib/components/DynamicIcon.tsx +60 -0
- package/src/lib/components/Header.tsx +69 -0
- package/src/lib/components/Input.tsx +24 -0
- package/src/lib/components/Layout.tsx +56 -0
- package/src/lib/components/Markdown.tsx +37 -0
- package/src/lib/components/SyntaxHighlight.tsx +94 -0
- package/src/lib/components/TopNavigation.tsx +32 -0
- package/src/lib/components/context/ComponentsContext.tsx +24 -0
- package/src/lib/components/context/DevPortalProvider.ts +54 -0
- package/src/lib/components/context/PluginSystem.ts +0 -0
- package/src/lib/components/context/ThemeContext.tsx +46 -0
- package/src/lib/components/context/ViewportAnchorContext.tsx +139 -0
- package/src/lib/components/navigation/SideNavigation.tsx +18 -0
- package/src/lib/components/navigation/SideNavigationCategory.tsx +74 -0
- package/src/lib/components/navigation/SideNavigationItem.tsx +143 -0
- package/src/lib/components/navigation/SideNavigationWrapper.tsx +15 -0
- package/src/lib/components/navigation/useNavigationCollapsibleState.ts +27 -0
- package/src/lib/components/navigation/util.ts +38 -0
- package/src/lib/components.ts +3 -0
- package/src/lib/core/DevPortalContext.ts +164 -0
- package/src/lib/core/helmet.ts +5 -0
- package/src/lib/core/icons.tsx +1 -0
- package/src/lib/core/plugins.ts +43 -0
- package/src/lib/core/router.tsx +1 -0
- package/src/lib/core/types/combine.ts +16 -0
- package/src/lib/oas/graphql/index.ts +422 -0
- package/src/lib/oas/graphql/server.ts +10 -0
- package/src/lib/oas/parser/dereference/index.ts +59 -0
- package/src/lib/oas/parser/dereference/resolveRef.ts +32 -0
- package/src/lib/oas/parser/index.ts +94 -0
- package/src/lib/oas/parser/schemas/v3.0.json +1489 -0
- package/src/lib/oas/parser/schemas/v3.1.json +1298 -0
- package/src/lib/oas/parser/upgrade/index.ts +108 -0
- package/src/lib/plugins/api-key/SettingsApiKeys.tsx +22 -0
- package/src/lib/plugins/api-key/index.tsx +123 -0
- package/src/lib/plugins/markdown/MdxPage.tsx +128 -0
- package/src/lib/plugins/markdown/Toc.tsx +122 -0
- package/src/lib/plugins/markdown/generateRoutes.tsx +72 -0
- package/src/lib/plugins/markdown/index.tsx +31 -0
- package/src/lib/plugins/openapi/ColorizedParam.tsx +82 -0
- package/src/lib/plugins/openapi/MakeRequest.tsx +49 -0
- package/src/lib/plugins/openapi/MethodBadge.tsx +36 -0
- package/src/lib/plugins/openapi/OperationList.tsx +117 -0
- package/src/lib/plugins/openapi/OperationListItem.tsx +55 -0
- package/src/lib/plugins/openapi/ParameterList.tsx +32 -0
- package/src/lib/plugins/openapi/ParameterListItem.tsx +60 -0
- package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +51 -0
- package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +60 -0
- package/src/lib/plugins/openapi/Select.tsx +35 -0
- package/src/lib/plugins/openapi/Sidecar.tsx +160 -0
- package/src/lib/plugins/openapi/SidecarBox.tsx +36 -0
- package/src/lib/plugins/openapi/graphql/fragment-masking.ts +111 -0
- package/src/lib/plugins/openapi/graphql/gql.ts +70 -0
- package/src/lib/plugins/openapi/graphql/graphql.ts +795 -0
- package/src/lib/plugins/openapi/graphql/index.ts +2 -0
- package/src/lib/plugins/openapi/index.tsx +142 -0
- package/src/lib/plugins/openapi/playground/Playground.tsx +309 -0
- package/src/lib/plugins/openapi/queries.graphql +6 -0
- package/src/lib/plugins/openapi/util/generateSchemaExample.ts +59 -0
- package/src/lib/plugins/openapi/util/urql.ts +8 -0
- package/src/lib/plugins/openapi/worker/createSharedWorkerClient.ts +60 -0
- package/src/lib/plugins/openapi/worker/shared-worker.ts +5 -0
- package/src/lib/plugins/openapi/worker/worker.ts +30 -0
- package/src/lib/plugins/redirect/index.tsx +20 -0
- package/src/lib/plugins.ts +5 -0
- package/src/lib/ui/Button.tsx +56 -0
- package/src/lib/ui/Callout.tsx +87 -0
- package/src/lib/ui/Card.tsx +82 -0
- package/src/lib/ui/Note.tsx +58 -0
- package/src/lib/ui/Tabs.tsx +52 -0
- package/src/lib/util/MdxComponents.tsx +70 -0
- package/src/lib/util/cn.ts +6 -0
- package/src/lib/util/createVariantComponent.tsx +30 -0
- package/src/lib/util/createWaitForNotify.ts +18 -0
- package/src/lib/util/groupBy.ts +24 -0
- package/src/lib/util/joinPath.tsx +10 -0
- package/src/lib/util/pastellize.ts +25 -0
- package/src/lib/util/slugify.ts +3 -0
- package/src/lib/util/traverseNavigation.ts +55 -0
- package/src/lib/util/useScrollToAnchor.ts +38 -0
- package/src/lib/util/useScrollToTop.ts +13 -0
- package/src/ts.ts +94 -0
- package/src/types.d.ts +24 -0
- package/src/vite/build.ts +33 -0
- package/src/vite/config.test.ts +10 -0
- package/src/vite/config.ts +183 -0
- package/src/vite/dev-server.ts +64 -0
- package/src/vite/html.ts +37 -0
- package/src/vite/plugin-api.ts +57 -0
- package/src/vite/plugin-auth.ts +32 -0
- package/src/vite/plugin-component.ts +26 -0
- package/src/vite/plugin-config.ts +31 -0
- package/src/vite/plugin-docs.test.ts +32 -0
- package/src/vite/plugin-docs.ts +52 -0
- package/src/vite/plugin-html.ts +50 -0
- package/src/vite/plugin-mdx.ts +74 -0
- package/src/vite/plugin-metadata.ts +30 -0
- package/src/vite/plugin.ts +23 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
|
|
3
|
+
const themeScript = `
|
|
4
|
+
if (
|
|
5
|
+
localStorage.getItem("theme") === "dark" ||
|
|
6
|
+
(!("theme" in localStorage) &&
|
|
7
|
+
window.matchMedia("(prefers-color-scheme: dark)").matches)
|
|
8
|
+
) {
|
|
9
|
+
document.documentElement.classList.add("dark");
|
|
10
|
+
} else {
|
|
11
|
+
document.documentElement.classList.remove("dark");
|
|
12
|
+
}
|
|
13
|
+
`.trim();
|
|
14
|
+
|
|
15
|
+
const viteHtmlPlugin = (): Plugin => {
|
|
16
|
+
return {
|
|
17
|
+
name: "vite-zudoku-core-plugin",
|
|
18
|
+
transformIndexHtml: (html) => {
|
|
19
|
+
return {
|
|
20
|
+
html,
|
|
21
|
+
tags: [
|
|
22
|
+
{
|
|
23
|
+
tag: "script",
|
|
24
|
+
attrs: { type: "module" },
|
|
25
|
+
children: themeScript,
|
|
26
|
+
injectTo: "head",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
tag: "link",
|
|
30
|
+
attrs: {
|
|
31
|
+
rel: "preconnect",
|
|
32
|
+
href: "https://cdn.zuplo.com/",
|
|
33
|
+
},
|
|
34
|
+
injectTo: "head",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
tag: "link",
|
|
38
|
+
attrs: {
|
|
39
|
+
rel: "stylesheet",
|
|
40
|
+
href: "https://cdn.zuplo.com/static/fonts/geist.css",
|
|
41
|
+
},
|
|
42
|
+
injectTo: "head",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default viteHtmlPlugin;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import rehypeMetaAsAttributes from "@lekoarts/rehype-meta-as-attributes";
|
|
2
|
+
import mdx, { type Options } from "@mdx-js/rollup";
|
|
3
|
+
import withToc from "@stefanprobst/rehype-extract-toc";
|
|
4
|
+
import withTocExport from "@stefanprobst/rehype-extract-toc/mdx";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import rehypeSlug from "rehype-slug";
|
|
7
|
+
import remarkComment from "remark-comment";
|
|
8
|
+
import remarkDirective from "remark-directive";
|
|
9
|
+
import remarkDirectiveRehype from "remark-directive-rehype";
|
|
10
|
+
import remarkFrontmatter from "remark-frontmatter";
|
|
11
|
+
import remarkGfm from "remark-gfm";
|
|
12
|
+
import remarkMdxFrontmatter from "remark-mdx-frontmatter";
|
|
13
|
+
import { visit } from "unist-util-visit";
|
|
14
|
+
import { Plugin } from "vite";
|
|
15
|
+
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
const rehypeCodeBlockPlugin = () => (tree: any) => {
|
|
18
|
+
visit(tree, "element", (node, index, parent) => {
|
|
19
|
+
if (node.tagName === "code") {
|
|
20
|
+
node.properties.inline = `${parent?.tagName !== "pre"}`;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
const remarkLinkRewritePlugin = () => (tree: any) => {
|
|
27
|
+
visit(tree, "link", (node) => {
|
|
28
|
+
if (!node.url) return;
|
|
29
|
+
|
|
30
|
+
if (!node.url.startsWith("http") && !node.url.startsWith("/")) {
|
|
31
|
+
node.url = path.join("../", node.url);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
node.url = node.url.replace(/\.mdx?(#.*?)?/, "$1");
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type DevPortalPluginOptions = {
|
|
39
|
+
remarkPlugins?: Options["remarkPlugins"];
|
|
40
|
+
rehypePlugins?: Options["rehypePlugins"];
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const viteMdxPlugin = ({
|
|
44
|
+
remarkPlugins,
|
|
45
|
+
rehypePlugins,
|
|
46
|
+
}: DevPortalPluginOptions = {}): Plugin => {
|
|
47
|
+
return {
|
|
48
|
+
enforce: "pre",
|
|
49
|
+
...mdx({
|
|
50
|
+
providerImportSource: "@mdx-js/react",
|
|
51
|
+
remarkPlugins: [
|
|
52
|
+
remarkComment,
|
|
53
|
+
remarkGfm,
|
|
54
|
+
remarkFrontmatter,
|
|
55
|
+
remarkMdxFrontmatter,
|
|
56
|
+
remarkDirective,
|
|
57
|
+
remarkDirectiveRehype,
|
|
58
|
+
remarkLinkRewritePlugin,
|
|
59
|
+
...(remarkPlugins ?? []),
|
|
60
|
+
],
|
|
61
|
+
rehypePlugins: [
|
|
62
|
+
rehypeSlug,
|
|
63
|
+
rehypeCodeBlockPlugin,
|
|
64
|
+
rehypeMetaAsAttributes,
|
|
65
|
+
withToc,
|
|
66
|
+
withTocExport,
|
|
67
|
+
...(rehypePlugins ?? []),
|
|
68
|
+
],
|
|
69
|
+
}),
|
|
70
|
+
name: "vite-zudoku-mdx-plugin",
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default viteMdxPlugin;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { writeFileSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { Plugin } from "vite";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Used for debugging, writes metadata to build.
|
|
7
|
+
*/
|
|
8
|
+
const viteBuildMetadata = (): Plugin => {
|
|
9
|
+
return {
|
|
10
|
+
name: "vite-zudoku-build-metadata-plugin",
|
|
11
|
+
buildEnd() {
|
|
12
|
+
const deps = [];
|
|
13
|
+
for (const id of this.getModuleIds()) {
|
|
14
|
+
const m = this.getModuleInfo(id);
|
|
15
|
+
if (m != null && !m.isExternal) {
|
|
16
|
+
for (const target of m.importedIds) {
|
|
17
|
+
deps.push({ source: m.id, target });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
writeFileSync(
|
|
23
|
+
path.join(__dirname, "graph.json"),
|
|
24
|
+
JSON.stringify(deps, null, 2),
|
|
25
|
+
);
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default viteBuildMetadata;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import react from "@vitejs/plugin-react";
|
|
2
|
+
import { type PluginOption } from "vite";
|
|
3
|
+
import { ZudokuPluginOptions } from "../config/config.js";
|
|
4
|
+
import viteApiPlugin from "./plugin-api.js";
|
|
5
|
+
import viteAuthPlugin from "./plugin-auth.js";
|
|
6
|
+
import viteConfigPlugin from "./plugin-config.js";
|
|
7
|
+
import viteDocsPlugin from "./plugin-docs.js";
|
|
8
|
+
import viteHtmlPlugin from "./plugin-html.js";
|
|
9
|
+
import viteMdxPlugin from "./plugin-mdx.js";
|
|
10
|
+
|
|
11
|
+
export default function vitePlugin(
|
|
12
|
+
config: ZudokuPluginOptions,
|
|
13
|
+
): PluginOption[] {
|
|
14
|
+
return [
|
|
15
|
+
viteMdxPlugin(config.build),
|
|
16
|
+
react({ include: /\.(mdx?|jsx?|tsx?)$/ }),
|
|
17
|
+
viteHtmlPlugin(),
|
|
18
|
+
viteConfigPlugin(config),
|
|
19
|
+
viteAuthPlugin(config),
|
|
20
|
+
viteDocsPlugin(config),
|
|
21
|
+
viteApiPlugin(config),
|
|
22
|
+
];
|
|
23
|
+
}
|