zudoku 0.3.0-dev.56 → 0.3.0-dev.58

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 (69) hide show
  1. package/dist/app/demo.js +6 -1
  2. package/dist/app/demo.js.map +1 -1
  3. package/dist/app/entry.client.d.ts +1 -1
  4. package/dist/app/entry.client.js +1 -1
  5. package/dist/app/entry.client.js.map +1 -1
  6. package/dist/app/entry.server.d.ts +1 -1
  7. package/dist/app/entry.server.js +1 -1
  8. package/dist/app/entry.server.js.map +1 -1
  9. package/dist/app/main.d.ts +1 -1
  10. package/dist/app/main.js +9 -2
  11. package/dist/app/main.js.map +1 -1
  12. package/dist/app/standalone.js +6 -1
  13. package/dist/app/standalone.js.map +1 -1
  14. package/dist/config/validators/validate.d.ts +65 -5
  15. package/dist/config/validators/validate.js +7 -1
  16. package/dist/config/validators/validate.js.map +1 -1
  17. package/dist/lib/components/Header.js +3 -2
  18. package/dist/lib/components/Header.js.map +1 -1
  19. package/dist/lib/components/navigation/SideNavigationCategory.js +2 -2
  20. package/dist/lib/components/navigation/SideNavigationCategory.js.map +1 -1
  21. package/dist/lib/core/DevPortalContext.d.ts +8 -1
  22. package/dist/lib/core/DevPortalContext.js.map +1 -1
  23. package/dist/lib/oas/graphql/index.js +5 -3
  24. package/dist/lib/oas/graphql/index.js.map +1 -1
  25. package/dist/lib/plugins/openapi/OperationList.js +2 -1
  26. package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
  27. package/dist/lib/plugins/openapi/StaggeredRender.d.ts +5 -0
  28. package/dist/lib/plugins/openapi/StaggeredRender.js +13 -0
  29. package/dist/lib/plugins/openapi/StaggeredRender.js.map +1 -0
  30. package/dist/vite/plugin-custom-css.js +2 -3
  31. package/dist/vite/plugin-custom-css.js.map +1 -1
  32. package/lib/{AnchorLink-GNsUeGSX.js → AnchorLink-B4IgsA83.js} +2 -2
  33. package/lib/{AnchorLink-GNsUeGSX.js.map → AnchorLink-B4IgsA83.js.map} +1 -1
  34. package/lib/{Button-DpHMZvVs.js → Button-CnuhSW99.js} +2 -2
  35. package/lib/{Button-DpHMZvVs.js.map → Button-CnuhSW99.js.map} +1 -1
  36. package/lib/{Markdown-DtLFdxD1.js → Markdown-DQrAhTkw.js} +3 -3
  37. package/lib/{Markdown-DtLFdxD1.js.map → Markdown-DQrAhTkw.js.map} +1 -1
  38. package/lib/{MdxPage-CbwYRKf5.js → MdxPage-DMP-pM_g.js} +3 -3
  39. package/lib/{MdxPage-CbwYRKf5.js.map → MdxPage-DMP-pM_g.js.map} +1 -1
  40. package/lib/{OperationList-DpR4KzIJ.js → OperationList-Dw2SadHL.js} +813 -805
  41. package/lib/OperationList-Dw2SadHL.js.map +1 -0
  42. package/lib/{Spinner-Bhbs5aPI.js → Spinner-BuBOzK_8.js} +2 -2
  43. package/lib/{Spinner-Bhbs5aPI.js.map → Spinner-BuBOzK_8.js.map} +1 -1
  44. package/lib/assets/{worker-BjPv-hjP.js → worker-BWwCA-wk.js} +8 -5
  45. package/lib/assets/{worker-BjPv-hjP.js.map → worker-BWwCA-wk.js.map} +1 -1
  46. package/lib/{hook-Biq3zYel.js → hook-CrQMC_eg.js} +2 -2
  47. package/lib/{hook-Biq3zYel.js.map → hook-CrQMC_eg.js.map} +1 -1
  48. package/lib/{index-DZ910ttL.js → index-tOwoT-uJ.js} +3 -3
  49. package/lib/{index-DZ910ttL.js.map → index-tOwoT-uJ.js.map} +1 -1
  50. package/lib/zudoku.components.js +127 -106
  51. package/lib/zudoku.components.js.map +1 -1
  52. package/lib/zudoku.openapi-worker.js +8 -5
  53. package/lib/zudoku.openapi-worker.js.map +1 -1
  54. package/lib/zudoku.plugin-api-keys.js +6 -6
  55. package/lib/zudoku.plugin-markdown.js +1 -1
  56. package/lib/zudoku.plugin-openapi.js +2 -2
  57. package/package.json +2 -2
  58. package/src/app/demo.tsx +6 -1
  59. package/src/app/entry.client.tsx +1 -1
  60. package/src/app/entry.server.tsx +1 -1
  61. package/src/app/main.tsx +11 -2
  62. package/src/app/standalone.tsx +6 -1
  63. package/src/lib/components/Header.tsx +17 -1
  64. package/src/lib/components/navigation/SideNavigationCategory.tsx +3 -3
  65. package/src/lib/core/DevPortalContext.ts +8 -1
  66. package/src/lib/oas/graphql/index.ts +7 -3
  67. package/src/lib/plugins/openapi/OperationList.tsx +9 -6
  68. package/src/lib/plugins/openapi/StaggeredRender.tsx +17 -0
  69. package/lib/OperationList-DpR4KzIJ.js.map +0 -1
@@ -1,7 +1,7 @@
1
- import { j as e, a as j, O as v } from "./jsx-runtime-CJZJivg2.js";
2
- import { u as b, R as w } from "./hook-Biq3zYel.js";
3
- import { u as k, a as h, S as N, b as K, c as E, d as A, e as S, f as p, B as o } from "./Button-DpHMZvVs.js";
4
- import { c as l, e as m, L as x } from "./Markdown-DtLFdxD1.js";
1
+ import { j as e, a as j, O as b } from "./jsx-runtime-CJZJivg2.js";
2
+ import { u as v, R as w } from "./hook-CrQMC_eg.js";
3
+ import { u as k, a as h, S as N, b as K, c as E, d as A, e as S, f as p, B as o } from "./Button-CnuhSW99.js";
4
+ import { c as l, b as m, L as x } from "./Markdown-DQrAhTkw.js";
5
5
  import { u as y, q as D, t as P } from "./DevPortalProvider-Do9oJqme.js";
6
6
  import * as C from "react";
7
7
  import { useState as I } from "react";
@@ -138,8 +138,8 @@ const T = ({ service: t }) => {
138
138
  const n = /* @__PURE__ */ new Date();
139
139
  return n.setDate(n.getDate() + t), n.toISOString();
140
140
  }, F = () => {
141
- const t = b();
142
- return t.isAuthEnabled && t.isPending ? null : t.isAuthenticated ? /* @__PURE__ */ e.jsx(v, {}) : t.isAuthEnabled ? /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2", children: [
141
+ const t = v();
142
+ return t.isAuthEnabled && t.isPending ? null : t.isAuthenticated ? /* @__PURE__ */ e.jsx(b, {}) : t.isAuthEnabled ? /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2", children: [
143
143
  "Please login first to view this page",
144
144
  /* @__PURE__ */ e.jsx(o, { onClick: () => t.login(), children: "Login" })
145
145
  ] }) : /* @__PURE__ */ e.jsx("div", { className: "flex flex-col justify-center gap-2 items-center h-1/2", children: /* @__PURE__ */ e.jsxs(R, { className: "max-w-[600px]", children: [
@@ -10,7 +10,7 @@ const h = (t, e) => {
10
10
  return {
11
11
  path: i.at(-1) === "index" ? i.slice(0, -1).join("/") : o,
12
12
  lazy: async () => {
13
- const { MdxPage: u } = await import("./MdxPage-CbwYRKf5.js"), { default: c, ...l } = await m();
13
+ const { MdxPage: u } = await import("./MdxPage-DMP-pM_g.js"), { default: c, ...l } = await m();
14
14
  return {
15
15
  element: /* @__PURE__ */ s.jsx(
16
16
  u,
@@ -1,8 +1,8 @@
1
1
  import "./jsx-runtime-CJZJivg2.js";
2
- import { o as n } from "./index-DZ910ttL.js";
2
+ import { o as n } from "./index-tOwoT-uJ.js";
3
3
  import "./urql-DMlBWUKL.js";
4
4
  import "zudoku/openapi-worker";
5
- import "./Markdown-DtLFdxD1.js";
5
+ import "./Markdown-DQrAhTkw.js";
6
6
  import "./router-CBw2vqJE.js";
7
7
  export {
8
8
  n as openApiPlugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudoku",
3
- "version": "0.3.0-dev.56",
3
+ "version": "0.3.0-dev.58",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist",
@@ -67,7 +67,7 @@
67
67
  "dependencies": {
68
68
  "@envelop/core": "5.0.1",
69
69
  "@graphql-typed-document-node/core": "3.2.0",
70
- "@hiogawa/vite-plugin-ssr-css": "0.0.0",
70
+ "@hiogawa/vite-plugin-ssr-css": "0.0.1",
71
71
  "@lekoarts/rehype-meta-as-attributes": "3.0.1",
72
72
  "@mdx-js/react": "3.0.1",
73
73
  "@mdx-js/rollup": "3.0.1",
package/src/app/demo.tsx CHANGED
@@ -24,7 +24,12 @@ createRoot(document.getElementById("root")!).render(
24
24
  <StrictMode>
25
25
  <DevPortal
26
26
  page={{
27
- logo: "https://cdn.zudoku.dev/logos/icon.svg",
27
+ logo: {
28
+ src: {
29
+ light: "https://cdn.zudoku.dev/logos/icon.svg",
30
+ dark: "https://cdn.zudoku.dev/logos/icon.svg",
31
+ },
32
+ },
28
33
  pageTitle: "Developer Portal",
29
34
  }}
30
35
  navigation={[
@@ -5,7 +5,7 @@ import {
5
5
  type RouteObject,
6
6
  } from "react-router-dom";
7
7
  import config from "virtual:zudoku-config";
8
- import "virtual:zudoku-custom-css.css";
8
+ import "virtual:zudoku-theme.css";
9
9
  import { Bootstrap } from "zudoku/components";
10
10
  import "./main.css";
11
11
  import { getRoutesByConfig } from "./main.js";
@@ -8,7 +8,7 @@ import {
8
8
  createStaticHandler,
9
9
  createStaticRouter,
10
10
  } from "react-router-dom/server.js";
11
- import "virtual:zudoku-custom-css.css";
11
+ import "virtual:zudoku-theme.css";
12
12
  import { BootstrapStatic, ServerError } from "zudoku/components";
13
13
  import type { ZudokuConfig } from "../config/config.js";
14
14
  import type { FileWritingResponse } from "../vite/prerender.js";
package/src/app/main.tsx CHANGED
@@ -2,9 +2,9 @@ import { type RouteObject } from "react-router-dom";
2
2
  import { configuredApiKeysPlugin } from "virtual:zudoku-api-keys-plugin";
3
3
  import { configuredApiPlugins } from "virtual:zudoku-api-plugins";
4
4
  import { configuredAuthProvider } from "virtual:zudoku-auth";
5
- import "virtual:zudoku-custom-css.css";
6
5
  import { configuredDocsPlugins } from "virtual:zudoku-docs-plugins";
7
6
  import { configuredRedirectPlugin } from "virtual:zudoku-redirect-plugin";
7
+ import "virtual:zudoku-theme.css";
8
8
  import { DevPortal, Layout, RouterError } from "zudoku/components";
9
9
  import { isNavigationPlugin } from "zudoku/internal";
10
10
  import type { ZudokuConfig } from "../config/config.js";
@@ -13,11 +13,20 @@ import type { ZudokuContextOptions } from "../lib/core/DevPortalContext.js";
13
13
  export const convertZudokuConfigToOptions = (
14
14
  config: ZudokuConfig,
15
15
  ): ZudokuContextOptions => {
16
+ const fallbackLogo =
17
+ config.page?.logoUrl ?? "https://cdn.zudoku.dev/logos/icon.svg";
18
+
16
19
  return {
17
20
  page: {
18
- logo: "https://cdn.zudoku.dev/logos/icon.svg",
19
21
  pageTitle: "Developer Portal",
20
22
  ...config.page,
23
+ logo: {
24
+ ...config.page?.logo,
25
+ src: {
26
+ light: config.page?.logo?.src?.light ?? fallbackLogo,
27
+ dark: config.page?.logo?.src?.dark ?? fallbackLogo,
28
+ },
29
+ },
21
30
  },
22
31
  metadata: {
23
32
  favicon: "https://cdn.zudoku.dev/logos/icon.svg",
@@ -29,7 +29,12 @@ createRoot(root).render(
29
29
  <StrictMode>
30
30
  <DevPortal
31
31
  page={{
32
- logo: logoUrl ?? "https://cdn.zudoku.dev/logos/icon.svg",
32
+ logo: {
33
+ src: {
34
+ light: logoUrl ?? "https://cdn.zudoku.dev/logos/icon.svg",
35
+ dark: logoUrl ?? "https://cdn.zudoku.dev/logos/icon.svg",
36
+ },
37
+ },
33
38
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
34
39
  pageTitle: pageTitle ?? "Developer Portal",
35
40
  }}
@@ -2,6 +2,7 @@ import { MoonStarIcon, SunIcon } from "lucide-react";
2
2
  import { memo } from "react";
3
3
 
4
4
  import { useAuth } from "../authentication/hook.js";
5
+ import { cn } from "../util/cn.js";
5
6
  import { TopNavigation } from "./TopNavigation.js";
6
7
  import { useDevPortal } from "./context/DevPortalProvider.js";
7
8
  import { useTheme } from "./context/ThemeContext.js";
@@ -19,7 +20,22 @@ export const Header = memo(function HeaderInner() {
19
20
  <div className="grid grid-cols-[calc(var(--side-nav-width))_1fr] lg:gap-12 items-center border-b border-border px-12 h-[--top-header-height]">
20
21
  <div className="flex items-center gap-3.5">
21
22
  {page?.logo && (
22
- <img src={page.logo} alt={page.pageTitle} className="h-10" />
23
+ <>
24
+ <img
25
+ src={page.logo.src.light}
26
+ alt={page.logo.alt ?? page.pageTitle}
27
+ style={{ width: page.logo.width }}
28
+ className={cn("h-10", isDark && "hidden")}
29
+ loading="lazy"
30
+ />
31
+ <img
32
+ src={page.logo.src.dark}
33
+ alt={page.logo.alt ?? page.pageTitle}
34
+ style={{ width: page.logo.width }}
35
+ className={cn("h-10", !isDark && "hidden")}
36
+ loading="lazy"
37
+ />
38
+ </>
23
39
  )}
24
40
  <span className="font-bold text-2xl text-foreground/85 tracking-wide">
25
41
  {page?.pageTitle}
@@ -8,7 +8,7 @@ import { useTopNavigationItem } from "../context/DevPortalProvider.js";
8
8
  import { useViewportAnchor } from "../context/ViewportAnchorContext.js";
9
9
  import { SideNavigationItem } from "./SideNavigationItem.js";
10
10
  import { useNavigationCollapsibleState } from "./useNavigationCollapsibleState.js";
11
- import { checkHasActiveItem, isPathItem } from "./util.js";
11
+ import { checkHasActiveItem } from "./util.js";
12
12
 
13
13
  export const SideNavigationCategory = ({
14
14
  category,
@@ -59,9 +59,9 @@ export const SideNavigationCategory = ({
59
59
  <Collapsible.Content className="CollapsibleContent -mx-[--padding-nav-item]">
60
60
  {/* margin on Collapsible.Content will lead jumpiness when animating because it's not added to the calculated height */}
61
61
  <ul className="space-y-0.5 mt-1.5 mb-4 ms-3">
62
- {category.children.map((item) => (
62
+ {category.children.map((item, i) => (
63
63
  <SideNavigationItem
64
- key={isPathItem(item) ? item.path + item.label : item.href}
64
+ key={i}
65
65
  category={category}
66
66
  item={item}
67
67
  activeAnchor={activeAnchor}
@@ -73,7 +73,14 @@ type Metadata = Partial<{
73
73
  }>;
74
74
  type Page = Partial<{
75
75
  pageTitle?: string;
76
- logo?: string;
76
+ logo?: {
77
+ src: {
78
+ light: string;
79
+ dark: string;
80
+ };
81
+ width?: string;
82
+ alt?: string;
83
+ };
77
84
  }>;
78
85
  export type ZudokuContextOptions = {
79
86
  metadata?: Metadata;
@@ -36,11 +36,15 @@ type OperationLike = {
36
36
  method: string;
37
37
  };
38
38
  export const slugifyOperation = (operation: OperationLike, tag?: string) => {
39
+ const summary =
40
+ operation.summary +
41
+ (operation.operationId
42
+ ? "-" + operation.operationId.slice(0, operation.summary ? 4 : 12)
43
+ : "");
44
+
39
45
  return slugify(
40
46
  (tag ? tag + "-" : "") +
41
- (operation.summary ??
42
- operation.operationId ??
43
- `${operation.method}-${operation.path}`),
47
+ (summary || `${operation.method}-${operation.path}`),
44
48
  { lower: true, trim: true },
45
49
  );
46
50
  };
@@ -8,6 +8,7 @@ import { Markdown } from "../../components/Markdown.js";
8
8
  import { SyntaxHighlight } from "../../components/SyntaxHighlight.js";
9
9
  import { cn } from "../../util/cn.js";
10
10
  import { OperationListItem } from "./OperationListItem.js";
11
+ import StaggeredRender from "./StaggeredRender.js";
11
12
  import { useOasConfig } from "./context.js";
12
13
  import { graphql } from "./graphql/index.js";
13
14
  import { SchemaProseClasses } from "./util/prose.js";
@@ -146,12 +147,14 @@ export const OperationList = () => {
146
147
  />
147
148
  )}
148
149
  <div className="operation mb-12">
149
- {tag.operations.map((fragment) => (
150
- <OperationListItem
151
- key={fragment.slug}
152
- operationFragment={fragment}
153
- />
154
- ))}
150
+ <StaggeredRender>
151
+ {tag.operations.map((fragment) => (
152
+ <OperationListItem
153
+ key={fragment.slug}
154
+ operationFragment={fragment}
155
+ />
156
+ ))}
157
+ </StaggeredRender>
155
158
  </div>
156
159
  </div>
157
160
  ))}
@@ -0,0 +1,17 @@
1
+ import { Children, ReactNode, useEffect, useState } from "react";
2
+
3
+ const StaggeredRender = ({ children }: { children: ReactNode[] }) => {
4
+ const [isMounted, setIsMounted] = useState(typeof window === "undefined");
5
+
6
+ useEffect(() => {
7
+ const x = window.requestIdleCallback(() => {
8
+ setIsMounted(true);
9
+ });
10
+
11
+ return () => window.cancelIdleCallback(x);
12
+ }, []);
13
+
14
+ return !isMounted ? Children.toArray(children).slice(0, 3) : children;
15
+ };
16
+
17
+ export default StaggeredRender;