zudoku 0.3.0-dev.56 → 0.3.0-dev.57

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 (55) 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 +1 -1
  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/{OperationList-DpR4KzIJ.js → OperationList-DypxLtSC.js} +813 -805
  33. package/lib/OperationList-DypxLtSC.js.map +1 -0
  34. package/lib/assets/{worker-BjPv-hjP.js → worker-BWwCA-wk.js} +8 -5
  35. package/lib/assets/{worker-BjPv-hjP.js.map → worker-BWwCA-wk.js.map} +1 -1
  36. package/lib/{index-DZ910ttL.js → index-Bg82-bqR.js} +2 -2
  37. package/lib/{index-DZ910ttL.js.map → index-Bg82-bqR.js.map} +1 -1
  38. package/lib/zudoku.components.js +53 -45
  39. package/lib/zudoku.components.js.map +1 -1
  40. package/lib/zudoku.openapi-worker.js +8 -5
  41. package/lib/zudoku.openapi-worker.js.map +1 -1
  42. package/lib/zudoku.plugin-openapi.js +1 -1
  43. package/package.json +2 -2
  44. package/src/app/demo.tsx +6 -1
  45. package/src/app/entry.client.tsx +1 -1
  46. package/src/app/entry.server.tsx +1 -1
  47. package/src/app/main.tsx +11 -2
  48. package/src/app/standalone.tsx +6 -1
  49. package/src/lib/components/Header.tsx +6 -1
  50. package/src/lib/components/navigation/SideNavigationCategory.tsx +3 -3
  51. package/src/lib/core/DevPortalContext.ts +8 -1
  52. package/src/lib/oas/graphql/index.ts +7 -3
  53. package/src/lib/plugins/openapi/OperationList.tsx +9 -6
  54. package/src/lib/plugins/openapi/StaggeredRender.tsx +17 -0
  55. package/lib/OperationList-DpR4KzIJ.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  import "./jsx-runtime-CJZJivg2.js";
2
- import { o as n } from "./index-DZ910ttL.js";
2
+ import { o as n } from "./index-Bg82-bqR.js";
3
3
  import "./urql-DMlBWUKL.js";
4
4
  import "zudoku/openapi-worker";
5
5
  import "./Markdown-DtLFdxD1.js";
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.57",
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
  }}
@@ -19,7 +19,12 @@ export const Header = memo(function HeaderInner() {
19
19
  <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
20
  <div className="flex items-center gap-3.5">
21
21
  {page?.logo && (
22
- <img src={page.logo} alt={page.pageTitle} className="h-10" />
22
+ <img
23
+ src={isDark ? page.logo.src.dark : page.logo.src.light}
24
+ alt={page.logo.alt ?? page.pageTitle}
25
+ style={{ width: page.logo.width }}
26
+ className="h-10"
27
+ />
23
28
  )}
24
29
  <span className="font-bold text-2xl text-foreground/85 tracking-wide">
25
30
  {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;