zudoku 0.1.1-dev.17 → 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.
Files changed (150) hide show
  1. package/dist/lib/plugins/openapi/worker/createSharedWorkerClient.js +2 -3
  2. package/dist/lib/plugins/openapi/worker/createSharedWorkerClient.js.map +1 -1
  3. package/dist/lib/plugins/openapi/worker/shared-worker.d.ts +1 -0
  4. package/dist/lib/plugins/openapi/worker/shared-worker.js +6 -0
  5. package/dist/lib/plugins/openapi/worker/shared-worker.js.map +1 -0
  6. package/dist/vite/config.d.ts +1 -1
  7. package/dist/vite/config.js +13 -13
  8. package/dist/vite/config.js.map +1 -1
  9. package/dist/vite/dev-server.js +1 -1
  10. package/dist/vite/dev-server.js.map +1 -1
  11. package/lib/DevPortal-DqcnbwLT.js +12967 -0
  12. package/lib/assets/index-BPdJm2ty.js +4764 -0
  13. package/lib/assets/worker-CnXQsqxH.js +14511 -0
  14. package/lib/prism-bash.min-DadFsM4Z.js +6 -0
  15. package/lib/prism-java.min-d5iT_mOd.js +6 -0
  16. package/lib/prism-json.min-B1GJqK1k.js +1 -0
  17. package/lib/prism-markup-templating-DZrrEs0A.js +61 -0
  18. package/lib/prism-php.min-o7FpoMP_.js +10 -0
  19. package/lib/prism-ruby.min-C7LwcKyz.js +9 -0
  20. package/lib/zudoku.auth.js +19712 -0
  21. package/lib/zudoku.components.js +6 -0
  22. package/lib/zudoku.openapi-worker.js +12 -0
  23. package/lib/zudoku.plugins.js +17382 -0
  24. package/package.json +6 -2
  25. package/src/cli/build/handler.ts +14 -0
  26. package/src/cli/cli.ts +77 -0
  27. package/src/cli/cmds/build.ts +24 -0
  28. package/src/cli/cmds/dev.ts +29 -0
  29. package/src/cli/common/analytics/lib.ts +89 -0
  30. package/src/cli/common/constants.ts +10 -0
  31. package/src/cli/common/logger.ts +5 -0
  32. package/src/cli/common/machine-id/lib.ts +85 -0
  33. package/src/cli/common/outdated.ts +102 -0
  34. package/src/cli/common/output.ts +86 -0
  35. package/src/cli/common/utils/box.license.txt +202 -0
  36. package/src/cli/common/utils/box.ts +116 -0
  37. package/src/cli/common/utils/ports.ts +21 -0
  38. package/src/cli/common/validators/lib.ts +43 -0
  39. package/src/cli/common/xdg/lib.ts +36 -0
  40. package/src/cli/dev/handler.ts +42 -0
  41. package/src/config/config.ts +56 -0
  42. package/src/index.ts +8 -0
  43. package/src/lib/DevPortal.tsx +93 -0
  44. package/src/lib/Heading.tsx +60 -0
  45. package/src/lib/Router.tsx +28 -0
  46. package/src/lib/auth.ts +1 -0
  47. package/src/lib/authentication/authentication.ts +18 -0
  48. package/src/lib/authentication/clerk.ts +45 -0
  49. package/src/lib/authentication/openid.ts +192 -0
  50. package/src/lib/components/AnchorLink.tsx +19 -0
  51. package/src/lib/components/CategoryHeading.tsx +16 -0
  52. package/src/lib/components/Dialog.tsx +119 -0
  53. package/src/lib/components/DynamicIcon.tsx +60 -0
  54. package/src/lib/components/Header.tsx +69 -0
  55. package/src/lib/components/Input.tsx +24 -0
  56. package/src/lib/components/Layout.tsx +56 -0
  57. package/src/lib/components/Markdown.tsx +37 -0
  58. package/src/lib/components/SyntaxHighlight.tsx +94 -0
  59. package/src/lib/components/TopNavigation.tsx +32 -0
  60. package/src/lib/components/context/ComponentsContext.tsx +24 -0
  61. package/src/lib/components/context/DevPortalProvider.ts +54 -0
  62. package/src/lib/components/context/PluginSystem.ts +0 -0
  63. package/src/lib/components/context/ThemeContext.tsx +46 -0
  64. package/src/lib/components/context/ViewportAnchorContext.tsx +139 -0
  65. package/src/lib/components/navigation/SideNavigation.tsx +18 -0
  66. package/src/lib/components/navigation/SideNavigationCategory.tsx +74 -0
  67. package/src/lib/components/navigation/SideNavigationItem.tsx +143 -0
  68. package/src/lib/components/navigation/SideNavigationWrapper.tsx +15 -0
  69. package/src/lib/components/navigation/useNavigationCollapsibleState.ts +27 -0
  70. package/src/lib/components/navigation/util.ts +38 -0
  71. package/src/lib/components.ts +3 -0
  72. package/src/lib/core/DevPortalContext.ts +164 -0
  73. package/src/lib/core/helmet.ts +5 -0
  74. package/src/lib/core/icons.tsx +1 -0
  75. package/src/lib/core/plugins.ts +43 -0
  76. package/src/lib/core/router.tsx +1 -0
  77. package/src/lib/core/types/combine.ts +16 -0
  78. package/src/lib/oas/graphql/index.ts +422 -0
  79. package/src/lib/oas/graphql/server.ts +10 -0
  80. package/src/lib/oas/parser/dereference/index.ts +59 -0
  81. package/src/lib/oas/parser/dereference/resolveRef.ts +32 -0
  82. package/src/lib/oas/parser/index.ts +94 -0
  83. package/src/lib/oas/parser/schemas/v3.0.json +1489 -0
  84. package/src/lib/oas/parser/schemas/v3.1.json +1298 -0
  85. package/src/lib/oas/parser/upgrade/index.ts +108 -0
  86. package/src/lib/plugins/api-key/SettingsApiKeys.tsx +22 -0
  87. package/src/lib/plugins/api-key/index.tsx +123 -0
  88. package/src/lib/plugins/markdown/MdxPage.tsx +128 -0
  89. package/src/lib/plugins/markdown/Toc.tsx +122 -0
  90. package/src/lib/plugins/markdown/generateRoutes.tsx +72 -0
  91. package/src/lib/plugins/markdown/index.tsx +31 -0
  92. package/src/lib/plugins/openapi/ColorizedParam.tsx +82 -0
  93. package/src/lib/plugins/openapi/MakeRequest.tsx +49 -0
  94. package/src/lib/plugins/openapi/MethodBadge.tsx +36 -0
  95. package/src/lib/plugins/openapi/OperationList.tsx +117 -0
  96. package/src/lib/plugins/openapi/OperationListItem.tsx +55 -0
  97. package/src/lib/plugins/openapi/ParameterList.tsx +32 -0
  98. package/src/lib/plugins/openapi/ParameterListItem.tsx +60 -0
  99. package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +51 -0
  100. package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +60 -0
  101. package/src/lib/plugins/openapi/Select.tsx +35 -0
  102. package/src/lib/plugins/openapi/Sidecar.tsx +160 -0
  103. package/src/lib/plugins/openapi/SidecarBox.tsx +36 -0
  104. package/src/lib/plugins/openapi/graphql/fragment-masking.ts +111 -0
  105. package/src/lib/plugins/openapi/graphql/gql.ts +70 -0
  106. package/src/lib/plugins/openapi/graphql/graphql.ts +795 -0
  107. package/src/lib/plugins/openapi/graphql/index.ts +2 -0
  108. package/src/lib/plugins/openapi/index.tsx +142 -0
  109. package/src/lib/plugins/openapi/playground/Playground.tsx +309 -0
  110. package/src/lib/plugins/openapi/queries.graphql +6 -0
  111. package/src/lib/plugins/openapi/util/generateSchemaExample.ts +59 -0
  112. package/src/lib/plugins/openapi/util/urql.ts +8 -0
  113. package/src/lib/plugins/openapi/worker/createSharedWorkerClient.ts +60 -0
  114. package/src/lib/plugins/openapi/worker/shared-worker.ts +5 -0
  115. package/src/lib/plugins/openapi/worker/worker.ts +30 -0
  116. package/src/lib/plugins/redirect/index.tsx +20 -0
  117. package/src/lib/plugins.ts +5 -0
  118. package/src/lib/ui/Button.tsx +56 -0
  119. package/src/lib/ui/Callout.tsx +87 -0
  120. package/src/lib/ui/Card.tsx +82 -0
  121. package/src/lib/ui/Note.tsx +58 -0
  122. package/src/lib/ui/Tabs.tsx +52 -0
  123. package/src/lib/util/MdxComponents.tsx +70 -0
  124. package/src/lib/util/cn.ts +6 -0
  125. package/src/lib/util/createVariantComponent.tsx +30 -0
  126. package/src/lib/util/createWaitForNotify.ts +18 -0
  127. package/src/lib/util/groupBy.ts +24 -0
  128. package/src/lib/util/joinPath.tsx +10 -0
  129. package/src/lib/util/pastellize.ts +25 -0
  130. package/src/lib/util/slugify.ts +3 -0
  131. package/src/lib/util/traverseNavigation.ts +55 -0
  132. package/src/lib/util/useScrollToAnchor.ts +38 -0
  133. package/src/lib/util/useScrollToTop.ts +13 -0
  134. package/src/ts.ts +94 -0
  135. package/src/types.d.ts +24 -0
  136. package/src/vite/build.ts +33 -0
  137. package/src/vite/config.test.ts +10 -0
  138. package/src/vite/config.ts +183 -0
  139. package/src/vite/dev-server.ts +64 -0
  140. package/src/vite/html.ts +37 -0
  141. package/src/vite/plugin-api.ts +57 -0
  142. package/src/vite/plugin-auth.ts +32 -0
  143. package/src/vite/plugin-component.ts +26 -0
  144. package/src/vite/plugin-config.ts +31 -0
  145. package/src/vite/plugin-docs.test.ts +32 -0
  146. package/src/vite/plugin-docs.ts +52 -0
  147. package/src/vite/plugin-html.ts +50 -0
  148. package/src/vite/plugin-mdx.ts +74 -0
  149. package/src/vite/plugin-metadata.ts +30 -0
  150. 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
+ }