zudoku 0.35.6 → 0.36.0

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 (121) hide show
  1. package/dist/app/entry.server.js +5 -1
  2. package/dist/app/entry.server.js.map +1 -1
  3. package/dist/config/validators/common.d.ts +176 -176
  4. package/dist/config/validators/common.js +8 -6
  5. package/dist/config/validators/common.js.map +1 -1
  6. package/dist/config/validators/validate.d.ts +63 -63
  7. package/dist/lib/components/Layout.js +3 -14
  8. package/dist/lib/components/Layout.js.map +1 -1
  9. package/dist/lib/components/Zudoku.js +3 -1
  10. package/dist/lib/components/Zudoku.js.map +1 -1
  11. package/dist/lib/components/cache.d.ts +7 -0
  12. package/dist/lib/components/cache.js +7 -0
  13. package/dist/lib/components/cache.js.map +1 -1
  14. package/dist/lib/components/context/ViewportAnchorContext.js +3 -6
  15. package/dist/lib/components/context/ViewportAnchorContext.js.map +1 -1
  16. package/dist/lib/components/context/ZudokuContext.d.ts +1 -1
  17. package/dist/lib/components/context/ZudokuContext.js +4 -3
  18. package/dist/lib/components/context/ZudokuContext.js.map +1 -1
  19. package/dist/lib/core/ZudokuContext.d.ts +8 -6
  20. package/dist/lib/core/ZudokuContext.js +4 -2
  21. package/dist/lib/core/ZudokuContext.js.map +1 -1
  22. package/dist/lib/core/plugins.d.ts +3 -3
  23. package/dist/lib/hooks/useEvent.test.js +1 -1
  24. package/dist/lib/hooks/useEvent.test.js.map +1 -1
  25. package/dist/lib/oas/graphql/index.d.ts +13 -2
  26. package/dist/lib/oas/graphql/index.js +59 -39
  27. package/dist/lib/oas/graphql/index.js.map +1 -1
  28. package/dist/lib/plugins/openapi/OperationList.js +19 -5
  29. package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
  30. package/dist/lib/plugins/openapi/OperationListItem.js +1 -1
  31. package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
  32. package/dist/lib/plugins/openapi/Sidecar.js +2 -2
  33. package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
  34. package/dist/lib/plugins/openapi/client/useCreateQuery.d.ts +1 -1
  35. package/dist/lib/plugins/openapi/client/useCreateQuery.js +2 -1
  36. package/dist/lib/plugins/openapi/client/useCreateQuery.js.map +1 -1
  37. package/dist/lib/plugins/openapi/graphql/gql.d.ts +4 -4
  38. package/dist/lib/plugins/openapi/graphql/gql.js +3 -3
  39. package/dist/lib/plugins/openapi/graphql/gql.js.map +1 -1
  40. package/dist/lib/plugins/openapi/graphql/graphql.d.ts +33 -44
  41. package/dist/lib/plugins/openapi/graphql/graphql.js +19 -29
  42. package/dist/lib/plugins/openapi/graphql/graphql.js.map +1 -1
  43. package/dist/lib/plugins/openapi/index.d.ts +5 -10
  44. package/dist/lib/plugins/openapi/index.js +29 -60
  45. package/dist/lib/plugins/openapi/index.js.map +1 -1
  46. package/dist/lib/plugins/openapi/interfaces.d.ts +3 -1
  47. package/dist/lib/plugins/openapi/util/createSidebarCategory.js +5 -7
  48. package/dist/lib/plugins/openapi/util/createSidebarCategory.js.map +1 -1
  49. package/dist/lib/util/traverse.js +2 -2
  50. package/dist/lib/util/traverse.js.map +1 -1
  51. package/dist/lib/util/useScrollToAnchor.js +2 -0
  52. package/dist/lib/util/useScrollToAnchor.js.map +1 -1
  53. package/dist/vite/api/schema-codegen.js +19 -4
  54. package/dist/vite/api/schema-codegen.js.map +1 -1
  55. package/dist/vite/api/schema-codegen.test.js +61 -0
  56. package/dist/vite/api/schema-codegen.test.js.map +1 -1
  57. package/dist/vite/plugin-api.js +3 -11
  58. package/dist/vite/plugin-api.js.map +1 -1
  59. package/lib/{AuthenticationPlugin-4ip08maU.js → AuthenticationPlugin-Cr6xjOJD.js} +2 -2
  60. package/lib/{AuthenticationPlugin-4ip08maU.js.map → AuthenticationPlugin-Cr6xjOJD.js.map} +1 -1
  61. package/lib/{Markdown-C0eXdzGn.js → Markdown-BlioIqkZ.js} +8 -6
  62. package/lib/Markdown-BlioIqkZ.js.map +1 -0
  63. package/lib/{MdxPage-BKkG1cm1.js → MdxPage-7XnN9J9R.js} +3 -3
  64. package/lib/{MdxPage-BKkG1cm1.js.map → MdxPage-7XnN9J9R.js.map} +1 -1
  65. package/lib/{OasProvider-CwhKwrwl.js → OasProvider-BaRRMSsD.js} +3 -3
  66. package/lib/{OasProvider-CwhKwrwl.js.map → OasProvider-BaRRMSsD.js.map} +1 -1
  67. package/lib/{OperationList-DGYoFitT.js → OperationList-BjL1hzSx.js} +987 -960
  68. package/lib/OperationList-BjL1hzSx.js.map +1 -0
  69. package/lib/{SlotletProvider-BJC58V32.js → SlotletProvider-CXb3wQiR.js} +2 -2
  70. package/lib/{SlotletProvider-BJC58V32.js.map → SlotletProvider-CXb3wQiR.js.map} +1 -1
  71. package/lib/{circular-v7K6lDDh.js → circular-ByJI6Mci.js} +4887 -4419
  72. package/lib/circular-ByJI6Mci.js.map +1 -0
  73. package/lib/{createServer-CbL1Uh2Q.js → createServer-DjgKDpGV.js} +3301 -3747
  74. package/lib/createServer-DjgKDpGV.js.map +1 -0
  75. package/lib/{hook-CfCFKZ-2.js → hook-Bo80UX00.js} +75 -74
  76. package/lib/hook-Bo80UX00.js.map +1 -0
  77. package/lib/{index-Dm1QJHVl.js → index-D5m8_oyY.js} +605 -645
  78. package/lib/index-D5m8_oyY.js.map +1 -0
  79. package/lib/post-processors/traverse.js +2 -2
  80. package/lib/post-processors/traverse.js.map +1 -1
  81. package/lib/zudoku.auth-auth0.js +1 -1
  82. package/lib/zudoku.auth-clerk.js +2 -2
  83. package/lib/zudoku.auth-openid.js +2 -2
  84. package/lib/zudoku.components.js +395 -397
  85. package/lib/zudoku.components.js.map +1 -1
  86. package/lib/zudoku.hooks.js +1 -1
  87. package/lib/zudoku.plugin-api-catalog.js +2 -2
  88. package/lib/zudoku.plugin-api-keys.js +2 -2
  89. package/lib/zudoku.plugin-custom-pages.js +1 -1
  90. package/lib/zudoku.plugin-markdown.js +1 -1
  91. package/lib/zudoku.plugin-openapi.js +4 -5
  92. package/lib/zudoku.plugin-openapi.js.map +1 -1
  93. package/lib/zudoku.plugins.js.map +1 -1
  94. package/package.json +1 -1
  95. package/src/app/entry.server.tsx +7 -1
  96. package/src/lib/components/Layout.tsx +3 -16
  97. package/src/lib/components/Zudoku.tsx +5 -1
  98. package/src/lib/components/cache.ts +8 -0
  99. package/src/lib/components/context/ViewportAnchorContext.tsx +3 -6
  100. package/src/lib/components/context/ZudokuContext.ts +5 -4
  101. package/src/lib/core/ZudokuContext.ts +11 -8
  102. package/src/lib/core/plugins.ts +4 -4
  103. package/src/lib/hooks/useEvent.test.tsx +1 -1
  104. package/src/lib/oas/graphql/index.ts +104 -64
  105. package/src/lib/plugins/openapi/OperationList.tsx +30 -36
  106. package/src/lib/plugins/openapi/OperationListItem.tsx +1 -1
  107. package/src/lib/plugins/openapi/Sidecar.tsx +2 -2
  108. package/src/lib/plugins/openapi/client/useCreateQuery.ts +2 -1
  109. package/src/lib/plugins/openapi/graphql/gql.ts +17 -17
  110. package/src/lib/plugins/openapi/graphql/graphql.ts +57 -75
  111. package/src/lib/plugins/openapi/index.tsx +40 -84
  112. package/src/lib/plugins/openapi/interfaces.ts +4 -1
  113. package/src/lib/plugins/openapi/util/createSidebarCategory.tsx +5 -7
  114. package/src/lib/util/traverse.ts +2 -2
  115. package/src/lib/util/useScrollToAnchor.ts +2 -0
  116. package/lib/Markdown-C0eXdzGn.js.map +0 -1
  117. package/lib/OperationList-DGYoFitT.js.map +0 -1
  118. package/lib/circular-v7K6lDDh.js.map +0 -1
  119. package/lib/createServer-CbL1Uh2Q.js.map +0 -1
  120. package/lib/hook-CfCFKZ-2.js.map +0 -1
  121. package/lib/index-Dm1QJHVl.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { z as f } from "./index-DwT-v3zK.js";
2
2
  import { useState as m, useEffect as i } from "react";
3
- import { a } from "./hook-CfCFKZ-2.js";
3
+ import { a } from "./hook-Bo80UX00.js";
4
4
  function d(e, t) {
5
5
  const s = a(), [n, o] = m();
6
6
  return i(() => s.addEventListener(e, (...u) => {
@@ -2,10 +2,10 @@ import { j as e } from "./jsx-runtime-CYK1ROHF.js";
2
2
  import { s as h } from "./index-LNp6rxyU.js";
3
3
  import { d as b, m as x } from "./chunk-HA7DTUK3-ZGg2W6yV.js";
4
4
  import { j as d } from "./joinUrl-10po2Jdj.js";
5
- import { u as j, b as y } from "./hook-CfCFKZ-2.js";
5
+ import { u as j, b as y } from "./hook-Bo80UX00.js";
6
6
  import { H as v } from "./index.esm-CltAN0Tf.js";
7
7
  import { Link as N } from "./zudoku.components.js";
8
- import { H as S, M as w } from "./Markdown-C0eXdzGn.js";
8
+ import { H as S, M as w } from "./Markdown-BlioIqkZ.js";
9
9
  const H = ({
10
10
  items: s,
11
11
  filterCatalogItems: l = (n) => n,
@@ -1,12 +1,12 @@
1
1
  import { j as e } from "./jsx-runtime-CYK1ROHF.js";
2
2
  import { RotateCwIcon as j, TrashIcon as v, EyeOffIcon as w, EyeIcon as K, CheckIcon as b, CopyIcon as k, FileKey2Icon as N } from "lucide-react";
3
- import { D as I, S as x, R as S } from "./SlotletProvider-BJC58V32.js";
3
+ import { D as I, S as x, R as S } from "./SlotletProvider-CXb3wQiR.js";
4
4
  import { i as c } from "./invariant-Caa8-XvF.js";
5
5
  import { u as h } from "./useQuery-CQUwWR9i.js";
6
6
  import { u as d, S as A, a as C, b as E, c as P, d as D, e as p } from "./Select-FAYHOYTy.js";
7
7
  import { a as q } from "./index.esm--gIChbWs.js";
8
8
  import { a as R, L as u, O } from "./chunk-HA7DTUK3-ZGg2W6yV.js";
9
- import { a as g, e as z, b as F } from "./hook-CfCFKZ-2.js";
9
+ import { a as g, e as z, b as F } from "./hook-Bo80UX00.js";
10
10
  import { Button as l } from "./ui/Button.js";
11
11
  import { Input as T } from "./ui/Input.js";
12
12
  import { useState as y } from "react";
@@ -1,6 +1,6 @@
1
1
  import { j as o } from "./jsx-runtime-CYK1ROHF.js";
2
2
  import a from "react";
3
- import { P as n } from "./Markdown-C0eXdzGn.js";
3
+ import { P as n } from "./Markdown-BlioIqkZ.js";
4
4
  import { c } from "./cn-qaFjX9_3.js";
5
5
  import { u as p } from "./useExposedProps-BslIn-FE.js";
6
6
  const u = ({
@@ -53,7 +53,7 @@ const P = (e) => ({
53
53
  const u = {
54
54
  path: r,
55
55
  lazy: async () => {
56
- const { MdxPage: p } = await import("./MdxPage-BKkG1cm1.js"), { default: f, ...l } = await i();
56
+ const { MdxPage: p } = await import("./MdxPage-7XnN9J9R.js"), { default: f, ...l } = await i();
57
57
  return {
58
58
  element: /* @__PURE__ */ d.jsx(
59
59
  p,
@@ -1,13 +1,12 @@
1
1
  import "./jsx-runtime-CYK1ROHF.js";
2
- import "./index-LNp6rxyU.js";
3
2
  import "lucide-react";
4
3
  import "./chunk-HA7DTUK3-ZGg2W6yV.js";
5
- import "./hook-CfCFKZ-2.js";
4
+ import "./hook-Bo80UX00.js";
6
5
  import "./ui/Button.js";
7
6
  import "./joinUrl-10po2Jdj.js";
8
- import { U as n, o as s } from "./index-Dm1QJHVl.js";
7
+ import { U as e, o as n } from "./index-D5m8_oyY.js";
9
8
  export {
10
- n as UNTAGGED_PATH,
11
- s as openApiPlugin
9
+ e as UNTAGGED_PATH,
10
+ n as openApiPlugin
12
11
  };
13
12
  //# sourceMappingURL=zudoku.plugin-openapi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"zudoku.plugin-openapi.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
1
+ {"version":3,"file":"zudoku.plugin-openapi.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"zudoku.plugins.js","sources":["../src/lib/core/plugins.ts"],"sourcesContent":["import type { LucideIcon } from \"lucide-react\";\nimport { type ReactElement } from \"react\";\nimport { type RouteObject } from \"react-router\";\nimport type { Sidebar } from \"../../config/validators/SidebarSchema.js\";\nimport { MdxComponentsType } from \"../util/MdxComponents.js\";\nimport {\n ZudokuContext,\n ZudokuEvents,\n type ApiIdentity,\n} from \"./ZudokuContext.js\";\n\nexport type ZudokuPlugin =\n | CommonPlugin\n | ProfileMenuPlugin\n | NavigationPlugin\n | ApiIdentityPlugin\n | SearchProviderPlugin\n | EventConsumerPlugin;\n\nexport type { RouteObject };\n\nexport interface NavigationPlugin {\n getRoutes: () => RouteObject[];\n getSidebar?: (path: string) => Promise<Sidebar>;\n}\n\nexport const createApiIdentityPlugin = (\n plugin: ApiIdentityPlugin,\n): ApiIdentityPlugin => plugin;\n\nexport const createProfileMenuPlugin = (\n plugin: ProfileMenuPlugin,\n): ProfileMenuPlugin => plugin;\n\nexport interface ApiIdentityPlugin {\n getIdentities: (context: ZudokuContext) => Promise<ApiIdentity[]>;\n}\n\nexport interface SearchProviderPlugin {\n renderSearch: (o: {\n isOpen: boolean;\n onClose: () => void;\n }) => React.JSX.Element | null;\n}\n\nexport interface ProfileMenuPlugin {\n getProfileMenuItems: (context: ZudokuContext) => ProfileNavigationItem[];\n}\n\nexport type ProfileNavigationItem = {\n label: string;\n path?: string;\n weight?: number;\n category?: \"top\" | \"middle\" | \"bottom\";\n children?: ProfileNavigationItem[];\n icon?: LucideIcon;\n};\n\nexport interface CommonPlugin {\n initialize?: (\n context: ZudokuContext,\n ) => Promise<void | boolean> | void | boolean;\n getHead?: () => ReactElement | undefined;\n getMdxComponents?: () => MdxComponentsType;\n}\n\nexport type EventConsumerPlugin<Event extends ZudokuEvents = ZudokuEvents> = {\n events: { [K in keyof Event]: Event[K] };\n};\n\nexport const isEventConsumerPlugin = (\n obj: ZudokuPlugin,\n): obj is EventConsumerPlugin =>\n \"events\" in obj && typeof obj.events === \"object\";\n\nexport const isProfileMenuPlugin = (\n obj: ZudokuPlugin,\n): obj is ProfileMenuPlugin =>\n \"getProfileMenuItems\" in obj && typeof obj.getProfileMenuItems === \"function\";\n\nexport const isNavigationPlugin = (\n obj: ZudokuPlugin,\n): obj is NavigationPlugin =>\n \"getRoutes\" in obj && typeof obj.getRoutes === \"function\";\n\nexport const isSearchPlugin = (\n obj: ZudokuPlugin,\n): obj is SearchProviderPlugin =>\n \"renderSearch\" in obj && typeof obj.renderSearch === \"function\";\n\nexport const needsInitialization = (obj: ZudokuPlugin): obj is CommonPlugin =>\n \"initialize\" in obj && typeof obj.initialize === \"function\";\n\nexport const hasHead = (obj: ZudokuPlugin): obj is CommonPlugin =>\n \"getHead\" in obj && typeof obj.getHead === \"function\";\n\nexport const isMdxProviderPlugin = (obj: ZudokuPlugin): obj is CommonPlugin =>\n \"getMdxComponents\" in obj && typeof obj.getMdxComponents === \"function\";\n\nexport const isApiIdentityPlugin = (\n obj: ZudokuPlugin,\n): obj is ApiIdentityPlugin =>\n \"getIdentities\" in obj && typeof obj.getIdentities === \"function\";\n"],"names":["createApiIdentityPlugin","plugin","createProfileMenuPlugin","isEventConsumerPlugin","obj","isProfileMenuPlugin","isNavigationPlugin","isSearchPlugin","needsInitialization","hasHead","isMdxProviderPlugin","isApiIdentityPlugin"],"mappings":"AA0Ba,MAAAA,IAA0B,CACrCC,MACsBA,GAEXC,IAA0B,CACrCD,MACsBA,GAsCXE,IAAwB,CACnCC,MAEA,YAAYA,KAAO,OAAOA,EAAI,UAAW,UAE9BC,IAAsB,CACjCD,MAEA,yBAAyBA,KAAO,OAAOA,EAAI,uBAAwB,YAExDE,IAAqB,CAChCF,MAEA,eAAeA,KAAO,OAAOA,EAAI,aAAc,YAEpCG,IAAiB,CAC5BH,MAEA,kBAAkBA,KAAO,OAAOA,EAAI,gBAAiB,YAE1CI,IAAsB,CAACJ,MAClC,gBAAgBA,KAAO,OAAOA,EAAI,cAAe,YAEtCK,IAAU,CAACL,MACtB,aAAaA,KAAO,OAAOA,EAAI,WAAY,YAEhCM,IAAsB,CAACN,MAClC,sBAAsBA,KAAO,OAAOA,EAAI,oBAAqB,YAElDO,IAAsB,CACjCP,MAEA,mBAAmBA,KAAO,OAAOA,EAAI,iBAAkB;"}
1
+ {"version":3,"file":"zudoku.plugins.js","sources":["../src/lib/core/plugins.ts"],"sourcesContent":["import type { LucideIcon } from \"lucide-react\";\nimport { type ReactElement } from \"react\";\nimport { type RouteObject } from \"react-router\";\nimport type { Sidebar } from \"../../config/validators/SidebarSchema.js\";\nimport { type MdxComponentsType } from \"../util/MdxComponents.js\";\nimport {\n type ApiIdentity,\n type ZudokuContext,\n type ZudokuEvents,\n} from \"./ZudokuContext.js\";\n\nexport type ZudokuPlugin =\n | CommonPlugin\n | ProfileMenuPlugin\n | NavigationPlugin\n | ApiIdentityPlugin\n | SearchProviderPlugin\n | EventConsumerPlugin;\n\nexport type { RouteObject };\n\nexport interface NavigationPlugin {\n getRoutes: () => RouteObject[];\n getSidebar?: (path: string, context: ZudokuContext) => Promise<Sidebar>;\n}\n\nexport const createApiIdentityPlugin = (\n plugin: ApiIdentityPlugin,\n): ApiIdentityPlugin => plugin;\n\nexport const createProfileMenuPlugin = (\n plugin: ProfileMenuPlugin,\n): ProfileMenuPlugin => plugin;\n\nexport interface ApiIdentityPlugin {\n getIdentities: (context: ZudokuContext) => Promise<ApiIdentity[]>;\n}\n\nexport interface SearchProviderPlugin {\n renderSearch: (o: {\n isOpen: boolean;\n onClose: () => void;\n }) => React.JSX.Element | null;\n}\n\nexport interface ProfileMenuPlugin {\n getProfileMenuItems: (context: ZudokuContext) => ProfileNavigationItem[];\n}\n\nexport type ProfileNavigationItem = {\n label: string;\n path?: string;\n weight?: number;\n category?: \"top\" | \"middle\" | \"bottom\";\n children?: ProfileNavigationItem[];\n icon?: LucideIcon;\n};\n\nexport interface CommonPlugin {\n initialize?: (\n context: ZudokuContext,\n ) => Promise<void | boolean> | void | boolean;\n getHead?: () => ReactElement | undefined;\n getMdxComponents?: () => MdxComponentsType;\n}\n\nexport type EventConsumerPlugin<Event extends ZudokuEvents = ZudokuEvents> = {\n events: { [K in keyof Event]: Event[K] };\n};\n\nexport const isEventConsumerPlugin = (\n obj: ZudokuPlugin,\n): obj is EventConsumerPlugin =>\n \"events\" in obj && typeof obj.events === \"object\";\n\nexport const isProfileMenuPlugin = (\n obj: ZudokuPlugin,\n): obj is ProfileMenuPlugin =>\n \"getProfileMenuItems\" in obj && typeof obj.getProfileMenuItems === \"function\";\n\nexport const isNavigationPlugin = (\n obj: ZudokuPlugin,\n): obj is NavigationPlugin =>\n \"getRoutes\" in obj && typeof obj.getRoutes === \"function\";\n\nexport const isSearchPlugin = (\n obj: ZudokuPlugin,\n): obj is SearchProviderPlugin =>\n \"renderSearch\" in obj && typeof obj.renderSearch === \"function\";\n\nexport const needsInitialization = (obj: ZudokuPlugin): obj is CommonPlugin =>\n \"initialize\" in obj && typeof obj.initialize === \"function\";\n\nexport const hasHead = (obj: ZudokuPlugin): obj is CommonPlugin =>\n \"getHead\" in obj && typeof obj.getHead === \"function\";\n\nexport const isMdxProviderPlugin = (obj: ZudokuPlugin): obj is CommonPlugin =>\n \"getMdxComponents\" in obj && typeof obj.getMdxComponents === \"function\";\n\nexport const isApiIdentityPlugin = (\n obj: ZudokuPlugin,\n): obj is ApiIdentityPlugin =>\n \"getIdentities\" in obj && typeof obj.getIdentities === \"function\";\n"],"names":["createApiIdentityPlugin","plugin","createProfileMenuPlugin","isEventConsumerPlugin","obj","isProfileMenuPlugin","isNavigationPlugin","isSearchPlugin","needsInitialization","hasHead","isMdxProviderPlugin","isApiIdentityPlugin"],"mappings":"AA0Ba,MAAAA,IAA0B,CACrCC,MACsBA,GAEXC,IAA0B,CACrCD,MACsBA,GAsCXE,IAAwB,CACnCC,MAEA,YAAYA,KAAO,OAAOA,EAAI,UAAW,UAE9BC,IAAsB,CACjCD,MAEA,yBAAyBA,KAAO,OAAOA,EAAI,uBAAwB,YAExDE,IAAqB,CAChCF,MAEA,eAAeA,KAAO,OAAOA,EAAI,aAAc,YAEpCG,IAAiB,CAC5BH,MAEA,kBAAkBA,KAAO,OAAOA,EAAI,gBAAiB,YAE1CI,IAAsB,CAACJ,MAClC,gBAAgBA,KAAO,OAAOA,EAAI,cAAe,YAEtCK,IAAU,CAACL,MACtB,aAAaA,KAAO,OAAOA,EAAI,WAAY,YAEhCM,IAAsB,CAACN,MAClC,sBAAsBA,KAAO,OAAOA,EAAI,oBAAqB,YAElDO,IAAsB,CACjCP,MAEA,mBAAmBA,KAAO,OAAOA,EAAI,iBAAkB;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudoku",
3
- "version": "0.35.6",
3
+ "version": "0.36.0",
4
4
  "type": "module",
5
5
  "homepage": "https://zudoku.dev",
6
6
  "repository": {
@@ -13,6 +13,7 @@ import {
13
13
  import "virtual:zudoku-theme.css";
14
14
  import "vite/modulepreload-polyfill";
15
15
  import { BootstrapStatic, ServerError } from "zudoku/components";
16
+ import { NO_DEHYDRATE } from "../lib/components/cache.js";
16
17
  import type { FileWritingResponse } from "../vite/prerender/FileWritingResponse.js";
17
18
  import "./main.css";
18
19
  import { getRoutesByConfig } from "./main.js";
@@ -115,10 +116,15 @@ export const render = async ({
115
116
  );
116
117
 
117
118
  transformStream.on("finish", () => {
119
+ const dehydrated = dehydrate(queryClient, {
120
+ shouldDehydrateQuery: (query) =>
121
+ !query.queryKey.includes(NO_DEHYDRATE),
122
+ });
123
+
118
124
  response.end(
119
125
  htmlEnd?.replace(
120
126
  "</body>",
121
- `<script>window.DATA = ${JSON.stringify(dehydrate(queryClient))}</script></body>`,
127
+ `<script>window.DATA=${JSON.stringify(dehydrated)}</script></body>`,
122
128
  ),
123
129
  );
124
130
  });
@@ -1,10 +1,9 @@
1
1
  import { Helmet } from "@zudoku/react-helmet-async";
2
- import { Suspense, useEffect, useRef, type ReactNode } from "react";
3
- import { Outlet, useLocation, useNavigation } from "react-router";
2
+ import { Suspense, useEffect, type ReactNode } from "react";
3
+ import { Outlet, useNavigation } from "react-router";
4
4
  import { useSpinDelay } from "spin-delay";
5
5
  import { useScrollToAnchor } from "../util/useScrollToAnchor.js";
6
6
  import { useScrollToTop } from "../util/useScrollToTop.js";
7
- import { useViewportAnchor } from "./context/ViewportAnchorContext.js";
8
7
  import { useZudoku } from "./context/ZudokuContext.js";
9
8
  import { Header } from "./Header.js";
10
9
  import { Main } from "./Main.js";
@@ -18,29 +17,17 @@ const LoadingFallback = () => (
18
17
  );
19
18
 
20
19
  export const Layout = ({ children }: { children?: ReactNode }) => {
21
- const location = useLocation();
22
- const { setActiveAnchor } = useViewportAnchor();
23
20
  const { meta, authentication } = useZudoku();
24
21
 
25
22
  useScrollToAnchor();
26
23
  useScrollToTop();
27
24
 
28
- const previousLocationPath = useRef(location.pathname);
29
-
30
25
  useEffect(() => {
31
26
  // Initialize the authentication plugin
32
27
  authentication?.onPageLoad?.();
33
28
  }, [authentication]);
34
29
 
35
- useEffect(() => {
36
- // always reset on location change
37
- if (location.pathname !== previousLocationPath.current) {
38
- setActiveAnchor("");
39
- }
40
- previousLocationPath.current = location.pathname;
41
- }, [location.pathname, setActiveAnchor]);
42
-
43
- // Page transition is happening: https://reactrouter.com/start/framework/pending-ui#global-pending-navigation
30
+ // Page transition is happening: https://reactrouter.com/start/framework/pending-navigation
44
31
  const isNavigating = Boolean(useNavigation().location);
45
32
  const showSpinner = useSpinDelay(isNavigating, {
46
33
  delay: 300,
@@ -1,4 +1,5 @@
1
1
  import { MDXProvider } from "@mdx-js/react";
2
+ import { useQueryClient } from "@tanstack/react-query";
2
3
  import { Helmet } from "@zudoku/react-helmet-async";
3
4
  import { ThemeProvider } from "next-themes";
4
5
  import {
@@ -59,6 +60,7 @@ const ZudokoInner = memo(
59
60
  [stagger, didNavigate],
60
61
  );
61
62
  const navigation = useNavigation();
63
+ const queryClient = useQueryClient();
62
64
 
63
65
  useEffect(() => {
64
66
  if (didNavigate) {
@@ -67,7 +69,9 @@ const ZudokoInner = memo(
67
69
  setDidNavigate(true);
68
70
  }, [didNavigate, navigation.location]);
69
71
 
70
- const [zudokuContext] = useState(() => new ZudokuContext(props));
72
+ const [zudokuContext] = useState(
73
+ () => new ZudokuContext(props, queryClient),
74
+ );
71
75
 
72
76
  const heads = props.plugins
73
77
  ?.flatMap((plugin) => (hasHead(plugin) ? (plugin.getHead?.() ?? []) : []))
@@ -13,3 +13,11 @@ export const useCache = () => {
13
13
  },
14
14
  };
15
15
  };
16
+
17
+ /**
18
+ * If a query has this key in its queryKey, it will not put its result in the dehydrated state in the SSR.
19
+ *
20
+ * This is useful if the query should only be suspended and not included in the initial HTML response.
21
+ * (e.g. too large in size, or not needed for the initial page load)
22
+ */
23
+ export const NO_DEHYDRATE = "no-dehydrate";
@@ -94,14 +94,11 @@ export const ViewportAnchorProvider = ({ children }: PropsWithChildren) => {
94
94
  window.innerHeight + window.scrollY >= document.body.scrollHeight;
95
95
 
96
96
  if (hasReachedTop) {
97
- // reset the active anchor when we reach the top
98
97
  setActiveAnchor("");
99
98
  } else if (hasReachedBottom) {
100
- requestIdleCallback(() => {
101
- // set the last anchor when we reach the bottom
102
- const lastItem = Array.from(elements).pop();
103
- setActiveAnchor(lastItem?.id ?? "");
104
- });
99
+ const lastItem = Array.from(elements).pop();
100
+ const lastId = lastItem?.id ?? "";
101
+ setActiveAnchor(lastId);
105
102
  }
106
103
  };
107
104
 
@@ -2,9 +2,9 @@ import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
2
2
  import { createContext, useContext } from "react";
3
3
  import { matchPath, useLocation } from "react-router";
4
4
  import { useAuth } from "../../authentication/hook.js";
5
- import { ZudokuContext } from "../../core/ZudokuContext.js";
5
+ import type { ZudokuContext } from "../../core/ZudokuContext.js";
6
6
  import { joinPath } from "../../util/joinPath.js";
7
- import { CACHE_KEYS } from "../cache.js";
7
+ import { CACHE_KEYS, NO_DEHYDRATE } from "../cache.js";
8
8
  import { traverseSidebar } from "../navigation/utils.js";
9
9
 
10
10
  export const ZudokuReactContext = createContext<ZudokuContext | undefined>(
@@ -26,7 +26,7 @@ export const useApiIdentities = () => {
26
26
 
27
27
  return useQuery({
28
28
  queryFn: getApiIdentities,
29
- queryKey: [CACHE_KEYS.API_IDENTITIES],
29
+ queryKey: CACHE_KEYS.API_IDENTITIES,
30
30
  });
31
31
  };
32
32
 
@@ -59,7 +59,8 @@ export const useCurrentNavigation = () => {
59
59
 
60
60
  const { data } = useSuspenseQuery({
61
61
  queryFn: () => getPluginSidebar(location.pathname),
62
- queryKey: ["plugin-sidebar", location.pathname],
62
+ // We just want to suspend here and don't store in SSR dehydrated state
63
+ queryKey: ["plugin-sidebar", NO_DEHYDRATE, location.pathname],
63
64
  });
64
65
 
65
66
  const hideSidebar =
@@ -1,11 +1,12 @@
1
+ import type { QueryClient } from "@tanstack/react-query";
1
2
  import { createNanoEvents } from "nanoevents";
2
- import { ReactNode } from "react";
3
- import { Location } from "react-router";
4
- import { TopNavigationItem } from "../../config/validators/common.js";
3
+ import type { ReactNode } from "react";
4
+ import type { Location } from "react-router";
5
+ import type { TopNavigationItem } from "../../config/validators/common.js";
5
6
  import type { SidebarConfig } from "../../config/validators/SidebarSchema.js";
6
- import { type AuthenticationProvider } from "../authentication/authentication.js";
7
+ import type { AuthenticationProvider } from "../authentication/authentication.js";
7
8
  import type { ComponentsContextType } from "../components/context/ComponentsContext.js";
8
- import { Slotlets } from "../components/SlotletProvider.js";
9
+ import type { Slotlets } from "../components/SlotletProvider.js";
9
10
  import { joinPath } from "../util/joinPath.js";
10
11
  import type { MdxComponentsType } from "../util/MdxComponents.js";
11
12
  import { objectEntries } from "../util/objectEntries.js";
@@ -90,7 +91,10 @@ export class ZudokuContext {
90
91
  private readonly navigationPlugins: NavigationPlugin[];
91
92
  private emitter = createNanoEvents<ZudokuEvents>();
92
93
 
93
- constructor(public readonly options: ZudokuContextOptions) {
94
+ constructor(
95
+ public readonly options: ZudokuContextOptions,
96
+ public readonly queryClient: QueryClient,
97
+ ) {
94
98
  this.plugins = options.plugins ?? [];
95
99
  this.topNavigation = options.topNavigation ?? [];
96
100
  this.sidebars = options.sidebars ?? {};
@@ -98,7 +102,6 @@ export class ZudokuContext {
98
102
  this.authentication = options.authentication;
99
103
  this.meta = options.metadata;
100
104
  this.page = options.page;
101
-
102
105
  this.plugins.forEach((plugin) => {
103
106
  if (!isEventConsumerPlugin(plugin)) return;
104
107
 
@@ -143,7 +146,7 @@ export class ZudokuContext {
143
146
  getPluginSidebar = async (path: string) => {
144
147
  const navigations = await Promise.all(
145
148
  this.navigationPlugins.map((plugin) =>
146
- plugin.getSidebar?.(joinPath(path)),
149
+ plugin.getSidebar?.(joinPath(path), this),
147
150
  ),
148
151
  );
149
152
 
@@ -2,11 +2,11 @@ import type { LucideIcon } from "lucide-react";
2
2
  import { type ReactElement } from "react";
3
3
  import { type RouteObject } from "react-router";
4
4
  import type { Sidebar } from "../../config/validators/SidebarSchema.js";
5
- import { MdxComponentsType } from "../util/MdxComponents.js";
5
+ import { type MdxComponentsType } from "../util/MdxComponents.js";
6
6
  import {
7
- ZudokuContext,
8
- ZudokuEvents,
9
7
  type ApiIdentity,
8
+ type ZudokuContext,
9
+ type ZudokuEvents,
10
10
  } from "./ZudokuContext.js";
11
11
 
12
12
  export type ZudokuPlugin =
@@ -21,7 +21,7 @@ export type { RouteObject };
21
21
 
22
22
  export interface NavigationPlugin {
23
23
  getRoutes: () => RouteObject[];
24
- getSidebar?: (path: string) => Promise<Sidebar>;
24
+ getSidebar?: (path: string, context: ZudokuContext) => Promise<Sidebar>;
25
25
  }
26
26
 
27
27
  export const createApiIdentityPlugin = (
@@ -12,8 +12,8 @@ import { useEvent } from "./useEvent.js";
12
12
  */
13
13
 
14
14
  const createTestContext = () => {
15
- const context = new ZudokuContext({});
16
15
  const queryClient = new QueryClient();
16
+ const context = new ZudokuContext({}, queryClient);
17
17
  const wrapper = ({ children }: PropsWithChildren) => (
18
18
  <QueryClientProvider client={queryClient}>
19
19
  <ZudokuProvider context={context}>{children}</ZudokuProvider>
@@ -51,17 +51,19 @@ export const createOperationSlug = (
51
51
  return slugify(summary);
52
52
  };
53
53
 
54
- type SchemaImport = () => Promise<{ schema: OpenAPIDocument }>;
54
+ export type SchemaImport = () => Promise<{
55
+ schema: OpenAPIDocument;
56
+ slugs: ReturnType<typeof getAllSlugs>;
57
+ }>;
55
58
 
56
59
  export type SchemaImports = Record<string, SchemaImport>;
57
60
 
58
61
  type Context = {
59
62
  schema: OpenAPIDocument;
60
63
  operations: GraphQLOperationObject[];
61
- tags: TagObject[];
62
64
  schemaImports?: SchemaImports;
63
- slugify: CountableSlugify;
64
- slugs: Record<string, string>;
65
+ tags: ReturnType<typeof getAllTags>;
66
+ slugs: ReturnType<typeof getAllSlugs>;
65
67
  };
66
68
 
67
69
  const builder = new SchemaBuilder<{
@@ -87,17 +89,15 @@ const JSONScalar = builder.addScalarType("JSON", GraphQLJSON);
87
89
  const JSONObjectScalar = builder.addScalarType("JSONObject", GraphQLJSONObject);
88
90
  const JSONSchemaScalar = builder.addScalarType("JSONSchema", GraphQLJSONSchema);
89
91
 
90
- const resolveExtensions = (obj: Record<string, any>) => {
91
- const extensions: Record<string, any> = {};
92
- for (const [key, value] of Object.entries(obj)) {
93
- if (key.startsWith("x-")) {
94
- extensions[key] = value;
95
- }
96
- }
97
- return extensions;
98
- };
92
+ const resolveExtensions = (obj: Record<string, any>) =>
93
+ Object.fromEntries(
94
+ Object.entries(obj).filter(([key]) => key.startsWith("x-")),
95
+ );
99
96
 
100
- export const getAllTags = (schema: OpenAPIDocument): TagObject[] => {
97
+ export const getAllTags = (
98
+ schema: OpenAPIDocument,
99
+ slugs: ReturnType<typeof getAllSlugs>["tags"],
100
+ ): Array<TagObject & { slug?: string }> => {
101
101
  const rootTags = schema.tags ?? [];
102
102
  const operationTags = new Set(
103
103
  Object.values(schema.paths ?? {})
@@ -107,24 +107,42 @@ export const getAllTags = (schema: OpenAPIDocument): TagObject[] => {
107
107
 
108
108
  return [
109
109
  // Keep root tags that are actually used in operations
110
- ...rootTags.filter((tag) => operationTags.has(tag.name)),
110
+ ...rootTags
111
+ .filter((tag) => operationTags.has(tag.name))
112
+ .map((tag) => ({ ...tag, slug: slugs[tag.name] })),
111
113
  // Add tags found in operations but not defined in root tags
112
114
  ...[...operationTags]
113
115
  .filter((tag) => !rootTags.some((rt) => rt.name === tag))
114
- .map((tag) => ({ name: tag })),
116
+ .map((tag) => ({ name: tag, slug: slugs[tag] })),
115
117
  ];
116
118
  };
117
119
 
118
- const getAllSlugs = (operations: GraphQLOperationObject[]) =>
119
- Object.fromEntries(
120
- operations.map((op) => [
121
- getSlugName(op),
122
- createOperationSlug(slugifyWithCounter(), op),
120
+ export const getAllSlugs = (
121
+ ops: GraphQLOperationObject[],
122
+ schemaTags: TagObject[] = [],
123
+ ) => {
124
+ const slugify = slugifyWithCounter();
125
+
126
+ const tags = Array.from(
127
+ new Set([
128
+ ...ops.flatMap((op) => op.tags ?? []),
129
+ ...schemaTags.map((tag) => tag.name),
123
130
  ]),
124
131
  );
125
132
 
126
- const getSlugName = (op: GraphQLOperationObject) =>
127
- `${op.path}-${op.method}-${op.operationId}-${op.summary}`;
133
+ return {
134
+ operations: Object.fromEntries(
135
+ ops.map((op) => [
136
+ getOperationSlugKey(op),
137
+ createOperationSlug(slugify, op),
138
+ ]),
139
+ ),
140
+ tags: Object.fromEntries(tags.map((tag) => [tag, slugify(tag)])),
141
+ };
142
+ };
143
+
144
+ const getOperationSlugKey = (op: GraphQLOperationObject) =>
145
+ [op.path, op.method, op.operationId, op.summary].filter(Boolean).join("-");
128
146
 
129
147
  export const getAllOperations = (
130
148
  paths?: PathsObject,
@@ -163,30 +181,38 @@ export const getAllOperations = (
163
181
  return operations;
164
182
  };
165
183
 
166
- const SchemaTag = builder.objectRef<TagObject>("SchemaTag").implement({
167
- fields: (t) => ({
168
- name: t.exposeString("name"),
169
- description: t.exposeString("description", { nullable: true }),
170
- operations: t.field({
171
- type: [OperationItem],
172
- resolve: (parent, _args, ctx) => {
173
- const rootTags = ctx.tags.map((tag) => tag.name);
174
- return ctx.operations
175
- .filter((item) =>
176
- parent.name
177
- ? item.tags?.includes(parent.name)
178
- : item.tags?.length === 0 ||
179
- // If none of the tags are present in the root tags, then show them here
180
- item.tags?.every((tag) => !rootTags.includes(tag)),
181
- )
182
- .map((item) => ({
183
- ...item,
184
- parentTag: parent.name,
185
- }));
186
- },
184
+ const SchemaTag = builder
185
+ .objectRef<
186
+ Omit<TagObject, "name"> & { name?: string; slug?: string }
187
+ >("SchemaTag")
188
+ .implement({
189
+ fields: (t) => ({
190
+ name: t.exposeString("name", { nullable: true }),
191
+ slug: t.exposeString("slug", { nullable: true }),
192
+ description: t.exposeString("description", { nullable: true }),
193
+ operations: t.field({
194
+ type: [OperationItem],
195
+ resolve: (parent, _args, ctx) => {
196
+ const rootTags = ctx.tags.map((tag) => tag.name);
197
+
198
+ return ctx.operations
199
+ .filter((item) =>
200
+ parent.name
201
+ ? item.tags?.includes(parent.name)
202
+ : item.tags?.length === 0 ||
203
+ // If none of the tags are present in the root tags, then show them here
204
+ item.tags?.every((tag) => !rootTags.includes(tag)),
205
+ )
206
+ .map((item) => ({ ...item, parentTag: parent.name }));
207
+ },
208
+ }),
209
+ extensions: t.field({
210
+ type: JSONObjectScalar,
211
+ resolve: (parent) => resolveExtensions(parent),
212
+ nullable: true,
213
+ }),
187
214
  }),
188
- }),
189
- });
215
+ });
190
216
 
191
217
  const ServerItem = builder.objectRef<ServerObject>("Server").implement({
192
218
  fields: (t) => ({
@@ -350,7 +376,16 @@ const OperationItem = builder
350
376
  fields: (t) => ({
351
377
  slug: t.field({
352
378
  type: "String",
353
- resolve: (parent, _, ctx) => ctx.slugs[getSlugName(parent)]!,
379
+ resolve: (parent, _, ctx) => {
380
+ const slug = ctx.slugs.operations[getOperationSlugKey(parent)];
381
+
382
+ if (!slug) {
383
+ throw new Error(
384
+ `No slug found for operation: ${getOperationSlugKey(parent)}`,
385
+ );
386
+ }
387
+ return slug;
388
+ },
354
389
  }),
355
390
  path: t.exposeString("path"),
356
391
  method: t.exposeString("method"),
@@ -465,10 +500,17 @@ const Schema = builder.objectRef<OpenAPIDocument>("Schema").implement({
465
500
  name: t.arg.string(),
466
501
  },
467
502
  type: [SchemaTag],
468
- resolve: (root, args, ctx) => {
469
- return args.name
470
- ? ctx.tags.filter((tag) => tag.name === args.name)
471
- : ctx.tags;
503
+ resolve: (_root, args, ctx) => {
504
+ if (args.name) {
505
+ return ctx.tags.filter((tag) => tag.name === args.name);
506
+ }
507
+
508
+ // Append empty tag which will be used to display untagged operations
509
+ if (ctx.operations.some((op) => !op.tags?.length)) {
510
+ return [...ctx.tags, { name: undefined, slug: undefined }];
511
+ }
512
+
513
+ return ctx.tags;
472
514
  },
473
515
  }),
474
516
  operations: t.field({
@@ -512,27 +554,25 @@ builder.queryType({
512
554
  input: t.arg({ type: JSONScalar, required: true }),
513
555
  },
514
556
  resolve: async (_, args, ctx) => {
515
- let schema: OpenAPIDocument;
516
-
517
557
  if (args.type === "file" && typeof args.input === "string") {
518
558
  const loadSchema = ctx.schemaImports?.[args.input];
519
559
 
520
560
  if (!loadSchema) {
521
561
  throw new Error(`No schema loader found for path: ${args.input}`);
522
562
  }
523
- const module = await loadSchema();
524
- schema = module.schema;
563
+ const { schema, slugs } = await loadSchema();
564
+ ctx.schema = schema;
565
+ ctx.operations = getAllOperations(schema.paths);
566
+ ctx.slugs = slugs;
567
+ ctx.tags = getAllTags(schema, ctx.slugs.tags);
525
568
  } else {
526
- schema = await validate(args.input as string);
569
+ ctx.schema = await validate(args.input as string);
570
+ ctx.operations = getAllOperations(ctx.schema.paths);
571
+ ctx.slugs = getAllSlugs(ctx.operations);
572
+ ctx.tags = getAllTags(ctx.schema, ctx.slugs.tags);
527
573
  }
528
574
 
529
- ctx.schema = schema;
530
- ctx.operations = getAllOperations(schema.paths);
531
- ctx.slugify = slugifyWithCounter();
532
- ctx.tags = getAllTags(schema);
533
- ctx.slugs = getAllSlugs(ctx.operations);
534
-
535
- return schema;
575
+ return ctx.schema;
536
576
  },
537
577
  }),
538
578
  }),
@@ -542,4 +582,4 @@ export const schema = builder.toSchema();
542
582
 
543
583
  export const createGraphQLServer = (
544
584
  options?: Omit<YogaServerOptions<any, any>, "schema">,
545
- ) => createYoga({ schema, ...options });
585
+ ) => createYoga({ schema, batching: true, ...options });