zudoku 0.16.3 → 0.18.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.
- package/dist/app/demo.js +0 -2
- package/dist/app/demo.js.map +1 -1
- package/dist/app/entry.client.js +14 -0
- package/dist/app/entry.client.js.map +1 -1
- package/dist/app/entry.server.js +5 -4
- package/dist/app/entry.server.js.map +1 -1
- package/dist/app/main.d.ts +1 -1
- package/dist/app/main.js +2 -2
- package/dist/app/main.js.map +1 -1
- package/dist/app/standalone.js +0 -2
- package/dist/app/standalone.js.map +1 -1
- package/dist/codegen.d.ts +3 -0
- package/dist/codegen.js +45 -0
- package/dist/codegen.js.map +1 -0
- package/dist/config/validators/InputSidebarSchema.d.ts +10 -10
- package/dist/config/validators/validate.d.ts +114 -114
- package/dist/config/validators/validate.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/authentication/authentication.d.ts +2 -2
- package/dist/lib/authentication/hook.d.ts +5 -4
- package/dist/lib/authentication/hook.js +1 -3
- package/dist/lib/authentication/hook.js.map +1 -1
- package/dist/lib/authentication/providers/auth0.js +11 -11
- package/dist/lib/authentication/providers/auth0.js.map +1 -1
- package/dist/lib/authentication/providers/openid.d.ts +0 -1
- package/dist/lib/authentication/providers/openid.js +11 -26
- package/dist/lib/authentication/providers/openid.js.map +1 -1
- package/dist/lib/authentication/state.d.ts +25 -4
- package/dist/lib/authentication/state.js +28 -3
- package/dist/lib/authentication/state.js.map +1 -1
- package/dist/lib/authentication/use-broadcast/shared.d.ts +48 -0
- package/dist/lib/authentication/use-broadcast/shared.js +243 -0
- package/dist/lib/authentication/use-broadcast/shared.js.map +1 -0
- package/dist/lib/authentication/use-broadcast/useBroadcast.d.ts +24 -0
- package/dist/lib/authentication/use-broadcast/useBroadcast.js +106 -0
- package/dist/lib/authentication/use-broadcast/useBroadcast.js.map +1 -0
- package/dist/lib/components/Bootstrap.d.ts +3 -1
- package/dist/lib/components/Bootstrap.js +11 -3
- package/dist/lib/components/Bootstrap.js.map +1 -1
- package/dist/lib/components/ClientOnly.d.ts +4 -2
- package/dist/lib/components/ClientOnly.js +1 -1
- package/dist/lib/components/ClientOnly.js.map +1 -1
- package/dist/lib/components/DeveloperHint.js +2 -1
- package/dist/lib/components/DeveloperHint.js.map +1 -1
- package/dist/lib/components/Header.js +5 -7
- package/dist/lib/components/Header.js.map +1 -1
- package/dist/lib/components/Heading.d.ts +1 -1
- package/dist/lib/components/Layout.js +11 -3
- package/dist/lib/components/Layout.js.map +1 -1
- package/dist/lib/components/MobileTopNavigation.js +6 -7
- package/dist/lib/components/MobileTopNavigation.js.map +1 -1
- package/dist/lib/components/SyntaxHighlight.js +16 -12
- package/dist/lib/components/SyntaxHighlight.js.map +1 -1
- package/dist/lib/components/ThemeSwitch.d.ts +1 -0
- package/dist/lib/components/ThemeSwitch.js +13 -0
- package/dist/lib/components/ThemeSwitch.js.map +1 -0
- package/dist/lib/components/TopNavigation.d.ts +2 -0
- package/dist/lib/components/TopNavigation.js +13 -7
- package/dist/lib/components/TopNavigation.js.map +1 -1
- package/dist/lib/components/{DevPortal.d.ts → Zudoku.d.ts} +3 -3
- package/dist/lib/components/{DevPortal.js → Zudoku.js} +13 -14
- package/dist/lib/components/Zudoku.js.map +1 -0
- package/dist/lib/components/context/ZudokuContext.d.ts +7 -7
- package/dist/lib/components/context/ZudokuContext.js +8 -13
- package/dist/lib/components/context/ZudokuContext.js.map +1 -1
- package/dist/lib/components/context/ZudokuProvider.d.ts +2 -2
- package/dist/lib/components/context/ZudokuProvider.js.map +1 -1
- package/dist/lib/components/index.d.ts +18 -10
- package/dist/lib/components/index.js +2 -3
- package/dist/lib/components/index.js.map +1 -1
- package/dist/lib/components/navigation/Sidebar.js +1 -1
- package/dist/lib/components/navigation/Sidebar.js.map +1 -1
- package/dist/lib/components/navigation/utils.js +2 -2
- package/dist/lib/components/navigation/utils.js.map +1 -1
- package/dist/lib/core/{DevPortalContext.d.ts → ZudokuContext.d.ts} +3 -7
- package/dist/lib/core/{DevPortalContext.js → ZudokuContext.js} +2 -7
- package/dist/lib/core/ZudokuContext.js.map +1 -0
- package/dist/lib/core/plugins.d.ts +12 -12
- package/dist/lib/core/plugins.js.map +1 -1
- package/dist/lib/errors/ErrorAlert.js +1 -1
- package/dist/lib/errors/ErrorAlert.js.map +1 -1
- package/dist/lib/plugins/api-keys/index.d.ts +9 -9
- package/dist/lib/plugins/api-keys/index.js.map +1 -1
- package/dist/lib/plugins/custom-pages/index.d.ts +2 -2
- package/dist/lib/plugins/custom-pages/index.js.map +1 -1
- package/dist/lib/plugins/markdown/index.d.ts +2 -2
- package/dist/lib/plugins/markdown/index.js.map +1 -1
- package/dist/lib/plugins/openapi/ColorizedParam.js +13 -9
- package/dist/lib/plugins/openapi/ColorizedParam.js.map +1 -1
- package/dist/lib/plugins/openapi/Endpoint.d.ts +1 -1
- package/dist/lib/plugins/openapi/Endpoint.js +5 -9
- package/dist/lib/plugins/openapi/Endpoint.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationList.d.ts +2 -2
- package/dist/lib/plugins/openapi/OperationList.js +7 -22
- package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
- package/dist/lib/plugins/openapi/Route.d.ts +4 -4
- package/dist/lib/plugins/openapi/Route.js +2 -4
- package/dist/lib/plugins/openapi/Route.js.map +1 -1
- package/dist/lib/plugins/openapi/Sidecar.d.ts +1 -1
- package/dist/lib/plugins/openapi/Sidecar.js +34 -33
- package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
- package/dist/lib/plugins/openapi/client/GraphQLClient.d.ts +8 -0
- package/dist/lib/plugins/openapi/client/GraphQLClient.js +102 -0
- package/dist/lib/plugins/openapi/client/GraphQLClient.js.map +1 -0
- package/dist/lib/plugins/openapi/client/GraphQLContext.d.ts +7 -0
- package/dist/lib/plugins/openapi/client/GraphQLContext.js +5 -0
- package/dist/lib/plugins/openapi/client/GraphQLContext.js.map +1 -0
- package/dist/lib/plugins/openapi/client/createServer.d.ts +1 -0
- package/dist/lib/plugins/openapi/client/useCreateQuery.d.ts +5 -0
- package/dist/lib/plugins/openapi/client/useCreateQuery.js +13 -0
- package/dist/lib/plugins/openapi/client/useCreateQuery.js.map +1 -0
- package/dist/lib/plugins/openapi/client/worker.d.ts +4 -1
- package/dist/lib/plugins/openapi/client/worker.js +23 -14
- package/dist/lib/plugins/openapi/client/worker.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/fragment-masking.d.ts +3 -3
- package/dist/lib/plugins/openapi/graphql/fragment-masking.js +3 -4
- package/dist/lib/plugins/openapi/graphql/fragment-masking.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/gql.d.ts +5 -52
- package/dist/lib/plugins/openapi/graphql/gql.js +2 -1
- package/dist/lib/plugins/openapi/graphql/gql.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/graphql.d.ts +134 -9
- package/dist/lib/plugins/openapi/graphql/graphql.js +194 -778
- package/dist/lib/plugins/openapi/graphql/graphql.js.map +1 -1
- package/dist/lib/plugins/openapi/index.d.ts +2 -2
- package/dist/lib/plugins/openapi/index.js +40 -53
- package/dist/lib/plugins/openapi/index.js.map +1 -1
- package/dist/lib/plugins/openapi/schema/SchemaView.js.map +1 -1
- package/dist/lib/plugins/openapi-worker.d.ts +1 -1
- package/dist/lib/plugins/openapi-worker.js +7 -1
- package/dist/lib/plugins/openapi-worker.js.map +1 -1
- package/dist/lib/plugins/redirect/index.d.ts +2 -2
- package/dist/lib/plugins/redirect/index.js.map +1 -1
- package/dist/lib/plugins/search-inkeep/index.d.ts +2 -2
- package/dist/lib/plugins/search-inkeep/index.js.map +1 -1
- package/dist/lib/ui/ActionButton.d.ts +3 -1
- package/dist/lib/util/MdxComponents.d.ts +1 -1
- package/dist/lib/util/useOnScreen.d.ts +4 -0
- package/dist/lib/util/useOnScreen.js +19 -0
- package/dist/lib/util/useOnScreen.js.map +1 -0
- package/dist/vite/config.js +0 -1
- package/dist/vite/config.js.map +1 -1
- package/dist/vite/html.js +0 -2
- package/dist/vite/html.js.map +1 -1
- package/dist/vite/plugin-component.js +1 -1
- package/dist/vite/plugin-component.js.map +1 -1
- package/dist/vite/plugin-mdx.d.ts +0 -6
- package/dist/vite/plugin-mdx.js +3 -2
- package/dist/vite/plugin-mdx.js.map +1 -1
- package/dist/vite/plugin.js +0 -2
- package/dist/vite/plugin.js.map +1 -1
- package/dist/vite/remarkStaticGeneration.d.ts +3 -0
- package/dist/vite/remarkStaticGeneration.js +125 -0
- package/dist/vite/remarkStaticGeneration.js.map +1 -0
- package/lib/{AnchorLink-BbB2q-jx.js → AnchorLink-CDlhr8gL.js} +11 -10
- package/lib/{AnchorLink-BbB2q-jx.js.map → AnchorLink-CDlhr8gL.js.map} +1 -1
- package/lib/{AuthenticationPlugin-C9BHGXlE.js → AuthenticationPlugin-DeGDVa1r.js} +6 -5
- package/lib/{AuthenticationPlugin-C9BHGXlE.js.map → AuthenticationPlugin-DeGDVa1r.js.map} +1 -1
- package/lib/{Spinner-ChOGyPls.js → Button-jK0EsymC.js} +12 -15
- package/lib/Button-jK0EsymC.js.map +1 -0
- package/lib/{ClientOnly-CVN6leDu.js → ClientOnly-E7hGysn1.js} +4 -4
- package/lib/ClientOnly-E7hGysn1.js.map +1 -0
- package/lib/Markdown-ievDDhFT.js +15192 -0
- package/lib/Markdown-ievDDhFT.js.map +1 -0
- package/lib/{MdxPage-DKMH_t0f.js → MdxPage-Bwn-VSsH.js} +5 -5
- package/lib/{MdxPage-DKMH_t0f.js.map → MdxPage-Bwn-VSsH.js.map} +1 -1
- package/lib/OperationList-BwBl1xrD.js +4691 -0
- package/lib/OperationList-BwBl1xrD.js.map +1 -0
- package/lib/Route-DlG_HTMu.js +11 -0
- package/lib/Route-DlG_HTMu.js.map +1 -0
- package/lib/{Select-Bagt3Bme.js → Select-O9ZM3ZgX.js} +7 -7
- package/lib/Select-O9ZM3ZgX.js.map +1 -0
- package/lib/SidebarBadge-DxFJcJ6V.js +51 -0
- package/lib/SidebarBadge-DxFJcJ6V.js.map +1 -0
- package/lib/SlotletProvider-DyomlzGx.js +252 -0
- package/lib/SlotletProvider-DyomlzGx.js.map +1 -0
- package/lib/Spinner-3cQDBVGr.js +7 -0
- package/lib/Spinner-3cQDBVGr.js.map +1 -0
- package/lib/SyntaxHighlight-DkLOsjHS.js +2983 -0
- package/lib/SyntaxHighlight-DkLOsjHS.js.map +1 -0
- package/lib/assets/{worker-YA-aCP3P.js → worker-CPsGZsve.js} +24 -22
- package/lib/assets/{worker-YA-aCP3P.js.map → worker-CPsGZsve.js.map} +1 -1
- package/lib/context-D1nXWxm7.js +22 -0
- package/lib/context-D1nXWxm7.js.map +1 -0
- package/lib/createServer-DK-g7kbB.js +16089 -0
- package/lib/createServer-DK-g7kbB.js.map +1 -0
- package/lib/{hook-sn0zMTkE.js → hook-hEqe7fPB.js} +12 -14
- package/lib/hook-hEqe7fPB.js.map +1 -0
- package/lib/index-Czzd9rjU.js +899 -0
- package/lib/index-Czzd9rjU.js.map +1 -0
- package/lib/index-DNxQ_rCt.js +1273 -0
- package/lib/index-DNxQ_rCt.js.map +1 -0
- package/lib/index-Yn8c3UWE.js +921 -0
- package/lib/index-Yn8c3UWE.js.map +1 -0
- package/lib/{router-BsfSoK2j.js → router-lfyopgBI.js} +23 -23
- package/lib/{router-BsfSoK2j.js.map → router-lfyopgBI.js.map} +1 -1
- package/lib/state-tsXBLONe.js +203 -0
- package/lib/{state-CsuHT8ZO.js.map → state-tsXBLONe.js.map} +1 -1
- package/lib/ui/ActionButton.js +11 -10
- package/lib/ui/ActionButton.js.map +1 -1
- package/lib/useExposedProps-CTPtylCV.js +10 -0
- package/lib/{useExposedProps-ChOIUaS4.js.map → useExposedProps-CTPtylCV.js.map} +1 -1
- package/lib/{ZudokuContext-BKXGJTmu.js → utils-DcpDOncX.js} +242 -246
- package/lib/utils-DcpDOncX.js.map +1 -0
- package/lib/zudoku.auth-auth0.js +24 -18
- package/lib/zudoku.auth-auth0.js.map +1 -1
- package/lib/zudoku.auth-clerk.js +2 -2
- package/lib/zudoku.auth-openid.js +124 -138
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/lib/zudoku.components.js +1284 -1121
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.openapi-worker.js +10 -16346
- package/lib/zudoku.openapi-worker.js.map +1 -1
- package/lib/zudoku.plugin-api-keys.js +18 -18
- package/lib/zudoku.plugin-api-keys.js.map +1 -1
- package/lib/zudoku.plugin-custom-pages.js +2 -2
- package/lib/zudoku.plugin-custom-pages.js.map +1 -1
- package/lib/zudoku.plugin-markdown.js +1 -1
- package/lib/zudoku.plugin-markdown.js.map +1 -1
- package/lib/zudoku.plugin-openapi.js +5 -9
- package/lib/zudoku.plugin-openapi.js.map +1 -1
- package/lib/zudoku.plugin-redirect.js +1 -1
- package/lib/zudoku.plugin-redirect.js.map +1 -1
- package/lib/zudoku.plugin-search-inkeep.js +1 -1
- package/lib/zudoku.plugin-search-inkeep.js.map +1 -1
- package/package.json +14 -4
- package/src/app/demo.tsx +0 -3
- package/src/app/entry.client.tsx +14 -0
- package/src/app/entry.server.tsx +59 -57
- package/src/app/main.tsx +4 -4
- package/src/app/standalone.tsx +0 -3
- package/src/lib/authentication/authentication.ts +2 -2
- package/src/lib/authentication/hook.ts +1 -3
- package/src/lib/authentication/providers/auth0.tsx +16 -11
- package/src/lib/authentication/providers/openid.tsx +12 -30
- package/src/lib/authentication/state.ts +50 -9
- package/{LICENSE.md → src/lib/authentication/use-broadcast/LICENSE.md} +2 -2
- package/src/lib/authentication/use-broadcast/shared.ts +372 -0
- package/src/lib/authentication/use-broadcast/useBroadcast.ts +146 -0
- package/src/lib/components/Bootstrap.tsx +36 -9
- package/src/lib/components/ClientOnly.tsx +6 -3
- package/src/lib/components/DeveloperHint.tsx +6 -1
- package/src/lib/components/Header.tsx +32 -37
- package/src/lib/components/Layout.tsx +48 -36
- package/src/lib/components/MobileTopNavigation.tsx +15 -18
- package/src/lib/components/SyntaxHighlight.tsx +81 -46
- package/src/lib/components/ThemeSwitch.tsx +26 -0
- package/src/lib/components/TopNavigation.tsx +27 -19
- package/src/lib/components/Zudoku.tsx +108 -0
- package/src/lib/components/context/ZudokuContext.ts +11 -16
- package/src/lib/components/context/ZudokuProvider.tsx +2 -2
- package/src/lib/components/index.ts +2 -3
- package/src/lib/components/navigation/Sidebar.tsx +3 -3
- package/src/lib/components/navigation/utils.ts +2 -2
- package/src/lib/core/{DevPortalContext.ts → ZudokuContext.ts} +3 -11
- package/src/lib/core/plugins.ts +12 -16
- package/src/lib/errors/ErrorAlert.tsx +2 -1
- package/src/lib/plugins/api-keys/index.tsx +9 -9
- package/src/lib/plugins/custom-pages/index.tsx +2 -2
- package/src/lib/plugins/markdown/index.tsx +2 -2
- package/src/lib/plugins/openapi/ColorizedParam.tsx +23 -14
- package/src/lib/plugins/openapi/Endpoint.tsx +5 -10
- package/src/lib/plugins/openapi/OperationList.tsx +6 -40
- package/src/lib/plugins/openapi/Route.tsx +11 -12
- package/src/lib/plugins/openapi/Sidecar.tsx +72 -61
- package/src/lib/plugins/openapi/client/GraphQLClient.tsx +140 -0
- package/src/lib/plugins/openapi/client/GraphQLContext.tsx +16 -0
- package/src/lib/plugins/openapi/client/createServer.ts +2 -0
- package/src/lib/plugins/openapi/client/useCreateQuery.ts +18 -0
- package/src/lib/plugins/openapi/client/worker.ts +38 -24
- package/src/lib/plugins/openapi/graphql/fragment-masking.ts +11 -18
- package/src/lib/plugins/openapi/graphql/gql.ts +7 -25
- package/src/lib/plugins/openapi/graphql/graphql.ts +351 -782
- package/src/lib/plugins/openapi/index.tsx +42 -67
- package/src/lib/plugins/openapi/schema/SchemaView.tsx +1 -1
- package/src/lib/plugins/openapi-worker.ts +11 -1
- package/src/lib/plugins/redirect/index.tsx +2 -2
- package/src/lib/plugins/search-inkeep/index.tsx +2 -2
- package/src/lib/ui/ActionButton.tsx +1 -1
- package/src/lib/util/useOnScreen.ts +32 -0
- package/dist/lib/components/DevPortal.js.map +0 -1
- package/dist/lib/components/context/ThemeContext.d.ts +0 -2
- package/dist/lib/components/context/ThemeContext.js +0 -7
- package/dist/lib/components/context/ThemeContext.js.map +0 -1
- package/dist/lib/components/context/ThemeProvider.d.ts +0 -4
- package/dist/lib/components/context/ThemeProvider.js +0 -23
- package/dist/lib/components/context/ThemeProvider.js.map +0 -1
- package/dist/lib/core/DevPortalContext.js.map +0 -1
- package/dist/lib/plugins/openapi/client/createMemoryClient.d.ts +0 -9
- package/dist/lib/plugins/openapi/client/createMemoryClient.js +0 -54
- package/dist/lib/plugins/openapi/client/createMemoryClient.js.map +0 -1
- package/dist/lib/plugins/openapi/client/createWorkerClient.d.ts +0 -10
- package/dist/lib/plugins/openapi/client/createWorkerClient.js +0 -62
- package/dist/lib/plugins/openapi/client/createWorkerClient.js.map +0 -1
- package/dist/lib/plugins/openapi/client/interfaces.d.ts +0 -4
- package/dist/lib/plugins/openapi/client/interfaces.js +0 -2
- package/dist/lib/plugins/openapi/client/interfaces.js.map +0 -1
- package/dist/lib/themeToggle.d.ts +0 -1
- package/dist/lib/themeToggle.js +0 -7
- package/dist/lib/themeToggle.js.map +0 -1
- package/dist/lib/util/createWaitForNotify.d.ts +0 -1
- package/dist/lib/util/createWaitForNotify.js +0 -15
- package/dist/lib/util/createWaitForNotify.js.map +0 -1
- package/dist/vite/plugin-html-transform.d.ts +0 -2
- package/dist/vite/plugin-html-transform.js +0 -15
- package/dist/vite/plugin-html-transform.js.map +0 -1
- package/lib/ClientOnly-CVN6leDu.js.map +0 -1
- package/lib/DeveloperHint-DHdLXGHA.js +0 -16
- package/lib/DeveloperHint-DHdLXGHA.js.map +0 -1
- package/lib/Markdown-BDcCAWwm.js +0 -18059
- package/lib/Markdown-BDcCAWwm.js.map +0 -1
- package/lib/OperationList-BjppA5yM.js +0 -621
- package/lib/OperationList-BjppA5yM.js.map +0 -1
- package/lib/Route-D_djzMv3.js +0 -13
- package/lib/Route-D_djzMv3.js.map +0 -1
- package/lib/Select-Bagt3Bme.js.map +0 -1
- package/lib/SidebarBadge-Bbt92M5K.js +0 -38
- package/lib/SidebarBadge-Bbt92M5K.js.map +0 -1
- package/lib/SlotletProvider-Da7eFgd2.js +0 -241
- package/lib/SlotletProvider-Da7eFgd2.js.map +0 -1
- package/lib/Spinner-ChOGyPls.js.map +0 -1
- package/lib/StaggeredRender-DDHSzQKE.js +0 -17
- package/lib/StaggeredRender-DDHSzQKE.js.map +0 -1
- package/lib/ZudokuContext-BKXGJTmu.js.map +0 -1
- package/lib/hook-sn0zMTkE.js.map +0 -1
- package/lib/index-CRo94sKK.js +0 -1783
- package/lib/index-CRo94sKK.js.map +0 -1
- package/lib/index-_gtpPhlu.js +0 -5877
- package/lib/index-_gtpPhlu.js.map +0 -1
- package/lib/state-CsuHT8ZO.js +0 -183
- package/lib/urql-core-35Qt_U4i.js +0 -1511
- package/lib/urql-core-35Qt_U4i.js.map +0 -1
- package/lib/useExposedProps-ChOIUaS4.js +0 -9
- package/src/lib/components/DevPortal.tsx +0 -111
- package/src/lib/components/context/ThemeContext.tsx +0 -8
- package/src/lib/components/context/ThemeProvider.tsx +0 -27
- package/src/lib/plugins/openapi/client/createMemoryClient.ts +0 -65
- package/src/lib/plugins/openapi/client/createWorkerClient.ts +0 -79
- package/src/lib/plugins/openapi/client/interfaces.ts +0 -5
- package/src/lib/themeToggle.ts +0 -7
- package/src/lib/util/createWaitForNotify.ts +0 -18
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { MDXProvider } from "@mdx-js/react";
|
|
2
|
+
import { Helmet } from "@zudoku/react-helmet-async";
|
|
3
|
+
import { ThemeProvider } from "next-themes";
|
|
4
|
+
import {
|
|
5
|
+
Fragment,
|
|
6
|
+
memo,
|
|
7
|
+
type PropsWithChildren,
|
|
8
|
+
useContext,
|
|
9
|
+
useEffect,
|
|
10
|
+
useMemo,
|
|
11
|
+
useState,
|
|
12
|
+
} from "react";
|
|
13
|
+
import { ErrorBoundary } from "react-error-boundary";
|
|
14
|
+
import { Outlet, useNavigation } from "react-router-dom";
|
|
15
|
+
import { hasHead, isMdxProviderPlugin } from "../core/plugins.js";
|
|
16
|
+
import { ZudokuContext, ZudokuContextOptions } from "../core/ZudokuContext.js";
|
|
17
|
+
import { TopLevelError } from "../errors/TopLevelError.js";
|
|
18
|
+
import { StaggeredRenderContext } from "../plugins/openapi/StaggeredRender.js";
|
|
19
|
+
import { MdxComponents } from "../util/MdxComponents.js";
|
|
20
|
+
import "../util/requestIdleCallbackPolyfill.js";
|
|
21
|
+
import {
|
|
22
|
+
ComponentsProvider,
|
|
23
|
+
DEFAULT_COMPONENTS,
|
|
24
|
+
} from "./context/ComponentsContext.js";
|
|
25
|
+
import { ViewportAnchorProvider } from "./context/ViewportAnchorContext.js";
|
|
26
|
+
import { ZudokuProvider } from "./context/ZudokuProvider.js";
|
|
27
|
+
import { SlotletProvider } from "./SlotletProvider.js";
|
|
28
|
+
|
|
29
|
+
const ZudokoInner = memo(
|
|
30
|
+
({ children, ...props }: PropsWithChildren<ZudokuContextOptions>) => {
|
|
31
|
+
const components = useMemo(
|
|
32
|
+
() => ({ ...DEFAULT_COMPONENTS, ...props.overrides }),
|
|
33
|
+
[props.overrides],
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const mdxComponents = useMemo(() => {
|
|
37
|
+
const componentsFromPlugins = (props.plugins ?? [])
|
|
38
|
+
.filter(isMdxProviderPlugin)
|
|
39
|
+
.flatMap((plugin) =>
|
|
40
|
+
plugin.getMdxComponents ? [plugin.getMdxComponents()] : [],
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
...componentsFromPlugins.reduce(
|
|
45
|
+
(acc, curr) => ({ ...acc, ...curr }),
|
|
46
|
+
{},
|
|
47
|
+
),
|
|
48
|
+
...MdxComponents,
|
|
49
|
+
...props.mdx?.components,
|
|
50
|
+
};
|
|
51
|
+
}, [props.mdx?.components, props.plugins]);
|
|
52
|
+
const { stagger } = useContext(StaggeredRenderContext);
|
|
53
|
+
const [didNavigate, setDidNavigate] = useState(false);
|
|
54
|
+
const staggeredValue = useMemo(
|
|
55
|
+
() => (didNavigate ? { stagger: true } : { stagger }),
|
|
56
|
+
[stagger, didNavigate],
|
|
57
|
+
);
|
|
58
|
+
const navigation = useNavigation();
|
|
59
|
+
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
if (didNavigate) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
setDidNavigate(true);
|
|
65
|
+
}, [didNavigate, navigation.location]);
|
|
66
|
+
|
|
67
|
+
const [zudokuContext] = useState(() => new ZudokuContext(props));
|
|
68
|
+
|
|
69
|
+
const heads = props.plugins
|
|
70
|
+
?.filter(hasHead)
|
|
71
|
+
// eslint-disable-next-line react/no-array-index-key
|
|
72
|
+
.map((plugin, i) => <Fragment key={i}>{plugin.getHead?.()}</Fragment>);
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<>
|
|
76
|
+
<Helmet>{heads}</Helmet>
|
|
77
|
+
<StaggeredRenderContext.Provider value={staggeredValue}>
|
|
78
|
+
<ZudokuProvider context={zudokuContext}>
|
|
79
|
+
<MDXProvider components={mdxComponents}>
|
|
80
|
+
<ThemeProvider attribute="class" disableTransitionOnChange>
|
|
81
|
+
<ComponentsProvider value={components}>
|
|
82
|
+
<SlotletProvider slotlets={props.slotlets}>
|
|
83
|
+
<ViewportAnchorProvider>
|
|
84
|
+
{children ?? <Outlet />}
|
|
85
|
+
</ViewportAnchorProvider>
|
|
86
|
+
</SlotletProvider>
|
|
87
|
+
</ComponentsProvider>
|
|
88
|
+
</ThemeProvider>
|
|
89
|
+
</MDXProvider>
|
|
90
|
+
</ZudokuProvider>
|
|
91
|
+
</StaggeredRenderContext.Provider>
|
|
92
|
+
</>
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
ZudokoInner.displayName = "ZudokoInner";
|
|
98
|
+
|
|
99
|
+
const Zudoku = (props: ZudokuContextOptions) => {
|
|
100
|
+
return (
|
|
101
|
+
<ErrorBoundary FallbackComponent={TopLevelError}>
|
|
102
|
+
<ZudokoInner {...props} />
|
|
103
|
+
</ErrorBoundary>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
106
|
+
Zudoku.displayName = "Zudoku";
|
|
107
|
+
|
|
108
|
+
export { Zudoku };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useQuery, useSuspenseQuery } from "@tanstack/react-query";
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
3
|
import { matchPath, useLocation } from "react-router-dom";
|
|
4
|
-
import {
|
|
4
|
+
import { ZudokuContext } from "../../core/ZudokuContext.js";
|
|
5
5
|
import { joinPath } from "../../util/joinPath.js";
|
|
6
6
|
import { traverseSidebar } from "../navigation/utils.js";
|
|
7
7
|
|
|
8
|
-
export const ZudokuReactContext = createContext<
|
|
8
|
+
export const ZudokuReactContext = createContext<ZudokuContext | undefined>(
|
|
9
9
|
undefined,
|
|
10
10
|
);
|
|
11
11
|
|
|
@@ -13,7 +13,7 @@ export const useZudoku = () => {
|
|
|
13
13
|
const context = useContext(ZudokuReactContext);
|
|
14
14
|
|
|
15
15
|
if (!context) {
|
|
16
|
-
throw new Error("
|
|
16
|
+
throw new Error("useZudoku must be used within a ZudokuProvider.");
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
return context;
|
|
@@ -49,18 +49,13 @@ export const useCurrentNavigation = () => {
|
|
|
49
49
|
topNavigation.find((t) => t.id === currentSidebarItem?.[0]) ??
|
|
50
50
|
topNavigation.find((item) => matchPath(item.id, location.pathname));
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
queryFn:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return {
|
|
57
|
-
sidebar: [
|
|
58
|
-
...(currentSidebarItem ? currentSidebarItem[1] : []),
|
|
59
|
-
...pluginSidebar,
|
|
60
|
-
],
|
|
61
|
-
topNavItem: currentTopNavItem,
|
|
62
|
-
};
|
|
63
|
-
},
|
|
64
|
-
queryKey: ["navigation", location.pathname],
|
|
52
|
+
const { data } = useSuspenseQuery({
|
|
53
|
+
queryFn: () => getPluginSidebar(location.pathname),
|
|
54
|
+
queryKey: ["plugin-sidebar", location.pathname],
|
|
65
55
|
});
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
sidebar: [...(currentSidebarItem ? currentSidebarItem[1] : []), ...data],
|
|
59
|
+
topNavItem: currentTopNavItem,
|
|
60
|
+
};
|
|
66
61
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { useSuspenseQuery } from "@tanstack/react-query";
|
|
2
2
|
import type { PropsWithChildren } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { ZudokuContext } from "../../core/ZudokuContext.js";
|
|
4
4
|
import { ZudokuReactContext } from "./ZudokuContext.js";
|
|
5
5
|
|
|
6
6
|
export const ZudokuProvider = ({
|
|
7
7
|
children,
|
|
8
8
|
context,
|
|
9
|
-
}: PropsWithChildren<{ context:
|
|
9
|
+
}: PropsWithChildren<{ context: ZudokuContext }>) => {
|
|
10
10
|
useSuspenseQuery({
|
|
11
11
|
queryFn: async () => {
|
|
12
12
|
await context.initialize();
|
|
@@ -11,11 +11,10 @@ import {
|
|
|
11
11
|
BootstrapStatic as BootstrapStaticImport,
|
|
12
12
|
} from "./Bootstrap.js";
|
|
13
13
|
import { ClientOnly as ClientOnlyImport } from "./ClientOnly.js";
|
|
14
|
-
import { DevPortal as DevPortalImport } from "./DevPortal.js";
|
|
15
14
|
import { Layout as LayoutImport } from "./Layout.js";
|
|
15
|
+
import { Zudoku as ZudokuImport } from "./Zudoku.js";
|
|
16
16
|
import { useZudoku as useZudokuImport } from "./context/ZudokuContext.js";
|
|
17
17
|
export const useMDXComponents = /*@__PURE__*/ useMDXComponentsImport;
|
|
18
|
-
export const DevPortal = /*@__PURE__*/ DevPortalImport;
|
|
19
18
|
export const Layout = /*@__PURE__*/ LayoutImport;
|
|
20
19
|
export const RouterError = /*@__PURE__*/ RouterErrorImport;
|
|
21
20
|
export const ServerError = /*@__PURE__*/ ServerErrorImport;
|
|
@@ -26,7 +25,7 @@ export const Head = /*@__PURE__*/ Helmet;
|
|
|
26
25
|
|
|
27
26
|
export const useZudoku = /*@__PURE__*/ useZudokuImport;
|
|
28
27
|
export const useAuth = /*@__PURE__*/ useAuthState;
|
|
29
|
-
export const Zudoku = /*@__PURE__*/
|
|
28
|
+
export const Zudoku = /*@__PURE__*/ ZudokuImport;
|
|
30
29
|
|
|
31
30
|
export const Callout = /*@__PURE__*/ CalloutImport;
|
|
32
31
|
export const ClientOnly = /*@__PURE__*/ ClientOnlyImport;
|
|
@@ -15,10 +15,10 @@ export const Sidebar = () => {
|
|
|
15
15
|
<>
|
|
16
16
|
<SidebarWrapper
|
|
17
17
|
ref={navRef}
|
|
18
|
-
pushMainContent={navigation.
|
|
18
|
+
pushMainContent={navigation.sidebar.length > 0}
|
|
19
19
|
>
|
|
20
20
|
<Slotlet name="zudoku-before-navigation" />
|
|
21
|
-
{navigation.
|
|
21
|
+
{navigation.sidebar.map((item) => (
|
|
22
22
|
<SidebarItem key={item.label} item={item} />
|
|
23
23
|
))}
|
|
24
24
|
<Slotlet name="zudoku-after-navigation" />
|
|
@@ -30,7 +30,7 @@ export const Sidebar = () => {
|
|
|
30
30
|
<VisuallyHidden>
|
|
31
31
|
<DrawerTitle>Sidebar</DrawerTitle>
|
|
32
32
|
</VisuallyHidden>
|
|
33
|
-
{navigation.
|
|
33
|
+
{navigation.sidebar.map((item) => (
|
|
34
34
|
<SidebarItem key={item.label} item={item} />
|
|
35
35
|
))}
|
|
36
36
|
</DrawerContent>
|
|
@@ -44,7 +44,7 @@ export const useCurrentItem = () => {
|
|
|
44
44
|
const location = useLocation();
|
|
45
45
|
const nav = useCurrentNavigation();
|
|
46
46
|
|
|
47
|
-
const currentSidebar = nav.
|
|
47
|
+
const currentSidebar = nav.sidebar;
|
|
48
48
|
|
|
49
49
|
return traverseSidebar(currentSidebar, (item) => {
|
|
50
50
|
if (item.type === "doc" && joinPath(item.id) === location.pathname) {
|
|
@@ -79,7 +79,7 @@ export const usePrevNext = (): {
|
|
|
79
79
|
} => {
|
|
80
80
|
const currentId = useLocation().pathname;
|
|
81
81
|
const nav = useCurrentNavigation();
|
|
82
|
-
const currentSidebar = nav.
|
|
82
|
+
const currentSidebar = nav.sidebar;
|
|
83
83
|
|
|
84
84
|
let prev;
|
|
85
85
|
let next;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { QueryClient } from "@tanstack/react-query";
|
|
2
1
|
import { ReactNode } from "react";
|
|
3
2
|
import type { SidebarConfig } from "../../config/validators/SidebarSchema.js";
|
|
4
3
|
import { TopNavigationItem } from "../../config/validators/validate.js";
|
|
@@ -8,11 +7,11 @@ import { Slotlets } from "../components/SlotletProvider.js";
|
|
|
8
7
|
import { joinPath } from "../util/joinPath.js";
|
|
9
8
|
import type { MdxComponentsType } from "../util/MdxComponents.js";
|
|
10
9
|
import {
|
|
11
|
-
type DevPortalPlugin,
|
|
12
10
|
isApiIdentityPlugin,
|
|
13
11
|
isNavigationPlugin,
|
|
14
12
|
type NavigationPlugin,
|
|
15
13
|
needsInitialization,
|
|
14
|
+
type ZudokuPlugin,
|
|
16
15
|
} from "./plugins.js";
|
|
17
16
|
|
|
18
17
|
export interface ApiIdentity {
|
|
@@ -21,10 +20,7 @@ export interface ApiIdentity {
|
|
|
21
20
|
id: string;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
export const queryClient = new QueryClient();
|
|
25
|
-
|
|
26
23
|
export type ApiKeyCache = "api-keys";
|
|
27
|
-
export type DevPortalCacheKey = ApiKeyCache | string;
|
|
28
24
|
|
|
29
25
|
type Metadata = Partial<{
|
|
30
26
|
title: string;
|
|
@@ -63,7 +59,7 @@ export type ZudokuContextOptions = {
|
|
|
63
59
|
authentication?: AuthenticationProvider;
|
|
64
60
|
topNavigation?: TopNavigationItem[];
|
|
65
61
|
sidebars?: SidebarConfig;
|
|
66
|
-
plugins?:
|
|
62
|
+
plugins?: ZudokuPlugin[];
|
|
67
63
|
slotlets?: Slotlets;
|
|
68
64
|
mdx?: {
|
|
69
65
|
components?: MdxComponentsType;
|
|
@@ -71,7 +67,7 @@ export type ZudokuContextOptions = {
|
|
|
71
67
|
overrides?: ComponentsContextType;
|
|
72
68
|
};
|
|
73
69
|
|
|
74
|
-
export class
|
|
70
|
+
export class ZudokuContext {
|
|
75
71
|
public plugins: NonNullable<ZudokuContextOptions["plugins"]>;
|
|
76
72
|
public sidebars: SidebarConfig;
|
|
77
73
|
public topNavigation: NonNullable<ZudokuContextOptions["topNavigation"]>;
|
|
@@ -98,10 +94,6 @@ export class DevPortalContext {
|
|
|
98
94
|
);
|
|
99
95
|
};
|
|
100
96
|
|
|
101
|
-
invalidateCache = async (key: DevPortalCacheKey[]) => {
|
|
102
|
-
await queryClient.invalidateQueries({ queryKey: key });
|
|
103
|
-
};
|
|
104
|
-
|
|
105
97
|
getApiIdentities = async () => {
|
|
106
98
|
const keys = await Promise.all(
|
|
107
99
|
this.plugins
|
package/src/lib/core/plugins.ts
CHANGED
|
@@ -2,9 +2,9 @@ import { type ReactElement } from "react";
|
|
|
2
2
|
import { type RouteObject } from "react-router-dom";
|
|
3
3
|
import type { Sidebar } from "../../config/validators/SidebarSchema.js";
|
|
4
4
|
import { MdxComponentsType } from "../util/MdxComponents.js";
|
|
5
|
-
import {
|
|
5
|
+
import { ZudokuContext, type ApiIdentity } from "./ZudokuContext.js";
|
|
6
6
|
|
|
7
|
-
export type
|
|
7
|
+
export type ZudokuPlugin =
|
|
8
8
|
| CommonPlugin
|
|
9
9
|
| ProfileMenuPlugin
|
|
10
10
|
| NavigationPlugin
|
|
@@ -19,7 +19,7 @@ export interface NavigationPlugin {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export interface ApiIdentityPlugin {
|
|
22
|
-
getIdentities: (context:
|
|
22
|
+
getIdentities: (context: ZudokuContext) => Promise<ApiIdentity[]>;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export interface SearchProviderPlugin {
|
|
@@ -30,7 +30,7 @@ export interface SearchProviderPlugin {
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface ProfileMenuPlugin {
|
|
33
|
-
getProfileMenuItems: (context:
|
|
33
|
+
getProfileMenuItems: (context: ZudokuContext) => ProfileNavigationItem[];
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export type ProfileNavigationItem = {
|
|
@@ -41,41 +41,37 @@ export type ProfileNavigationItem = {
|
|
|
41
41
|
|
|
42
42
|
export interface CommonPlugin {
|
|
43
43
|
initialize?: (
|
|
44
|
-
context:
|
|
44
|
+
context: ZudokuContext,
|
|
45
45
|
) => Promise<void | boolean> | void | boolean;
|
|
46
46
|
getHead?: () => ReactElement | undefined;
|
|
47
47
|
getMdxComponents?: () => MdxComponentsType;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
export const isProfileMenuPlugin = (
|
|
51
|
-
obj:
|
|
51
|
+
obj: ZudokuPlugin,
|
|
52
52
|
): obj is ProfileMenuPlugin =>
|
|
53
53
|
"getProfileMenuItems" in obj && typeof obj.getProfileMenuItems === "function";
|
|
54
54
|
|
|
55
55
|
export const isNavigationPlugin = (
|
|
56
|
-
obj:
|
|
56
|
+
obj: ZudokuPlugin,
|
|
57
57
|
): obj is NavigationPlugin =>
|
|
58
58
|
"getRoutes" in obj && typeof obj.getRoutes === "function";
|
|
59
59
|
|
|
60
60
|
export const isSearchPlugin = (
|
|
61
|
-
obj:
|
|
61
|
+
obj: ZudokuPlugin,
|
|
62
62
|
): obj is SearchProviderPlugin =>
|
|
63
63
|
"renderSearch" in obj && typeof obj.renderSearch === "function";
|
|
64
64
|
|
|
65
|
-
export const needsInitialization = (
|
|
66
|
-
obj: DevPortalPlugin,
|
|
67
|
-
): obj is CommonPlugin =>
|
|
65
|
+
export const needsInitialization = (obj: ZudokuPlugin): obj is CommonPlugin =>
|
|
68
66
|
"initialize" in obj && typeof obj.initialize === "function";
|
|
69
67
|
|
|
70
|
-
export const hasHead = (obj:
|
|
68
|
+
export const hasHead = (obj: ZudokuPlugin): obj is CommonPlugin =>
|
|
71
69
|
"getHead" in obj && typeof obj.getHead === "function";
|
|
72
70
|
|
|
73
|
-
export const isMdxProviderPlugin = (
|
|
74
|
-
obj: DevPortalPlugin,
|
|
75
|
-
): obj is CommonPlugin =>
|
|
71
|
+
export const isMdxProviderPlugin = (obj: ZudokuPlugin): obj is CommonPlugin =>
|
|
76
72
|
"getMdxComponents" in obj && typeof obj.getMdxComponents === "function";
|
|
77
73
|
|
|
78
74
|
export const isApiIdentityPlugin = (
|
|
79
|
-
obj:
|
|
75
|
+
obj: ZudokuPlugin,
|
|
80
76
|
): obj is ApiIdentityPlugin =>
|
|
81
77
|
"getIdentities" in obj && typeof obj.getIdentities === "function";
|
|
@@ -5,6 +5,7 @@ import { ZudokuError } from "../util/invariant.js";
|
|
|
5
5
|
export function ErrorAlert({ error }: { error: unknown }) {
|
|
6
6
|
const message =
|
|
7
7
|
error instanceof Error ? error.message : "Something went wrong";
|
|
8
|
+
|
|
8
9
|
const hint = error instanceof ZudokuError ? error.developerHint : undefined;
|
|
9
10
|
const title =
|
|
10
11
|
error instanceof ZudokuError ? error.title : "Something went wrong";
|
|
@@ -12,7 +13,7 @@ export function ErrorAlert({ error }: { error: unknown }) {
|
|
|
12
13
|
const cause = error instanceof Error ? error.cause : undefined;
|
|
13
14
|
|
|
14
15
|
return (
|
|
15
|
-
<div className="flex h-screen max-h-
|
|
16
|
+
<div className="flex h-screen max-h-[calc(100vh-var(--header-height))] min-h-full items-center justify-center bg-primary-background px-4 py-16 lg:px-8">
|
|
16
17
|
<div className="mx-auto max-w-[85%] sm:max-w-[50%]">
|
|
17
18
|
<h1 className="text-4xl font-bold tracking-tight text-h1-text sm:text-5xl">
|
|
18
19
|
{title}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type RouteObject } from "react-router-dom";
|
|
2
|
-
import {
|
|
2
|
+
import { ZudokuContext } from "../../core/ZudokuContext.js";
|
|
3
3
|
import {
|
|
4
4
|
type ApiIdentityPlugin,
|
|
5
|
-
type
|
|
5
|
+
type ZudokuPlugin,
|
|
6
6
|
ProfileMenuPlugin,
|
|
7
7
|
} from "../../core/plugins.js";
|
|
8
8
|
import { RouterError } from "../../errors/RouterError.js";
|
|
@@ -15,17 +15,17 @@ const DEFAULT_API_KEY_ENDPOINT =
|
|
|
15
15
|
"https://zudoku-rewiringamerica-main-ef9c9c0.d2.zuplo.dev";
|
|
16
16
|
|
|
17
17
|
export type ApiKeyService = {
|
|
18
|
-
getKeys: (context:
|
|
19
|
-
rollKey?: (id: string, context:
|
|
20
|
-
deleteKey?: (id: string, context:
|
|
18
|
+
getKeys: (context: ZudokuContext) => Promise<ApiKey[]>;
|
|
19
|
+
rollKey?: (id: string, context: ZudokuContext) => Promise<void>;
|
|
20
|
+
deleteKey?: (id: string, context: ZudokuContext) => Promise<void>;
|
|
21
21
|
updateKeyDescription?: (
|
|
22
22
|
apiKey: { id: string; description: string },
|
|
23
|
-
context:
|
|
23
|
+
context: ZudokuContext,
|
|
24
24
|
) => Promise<void>;
|
|
25
|
-
getUsage?: (apiKeys: string[], context:
|
|
25
|
+
getUsage?: (apiKeys: string[], context: ZudokuContext) => Promise<void>;
|
|
26
26
|
createKey?: (
|
|
27
27
|
apiKey: { description: string; expiresOn?: string },
|
|
28
|
-
context:
|
|
28
|
+
context: ZudokuContext,
|
|
29
29
|
) => Promise<void>;
|
|
30
30
|
};
|
|
31
31
|
|
|
@@ -93,7 +93,7 @@ const createDefaultHandler = (endpoint: string): ApiKeyService => {
|
|
|
93
93
|
|
|
94
94
|
export const apiKeyPlugin = (
|
|
95
95
|
options: ApiKeyPluginOptions,
|
|
96
|
-
):
|
|
96
|
+
): ZudokuPlugin & ApiIdentityPlugin & ProfileMenuPlugin => {
|
|
97
97
|
const endpoint =
|
|
98
98
|
"endpoint" in options ? options.endpoint : DEFAULT_API_KEY_ENDPOINT;
|
|
99
99
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ComponentType, type ReactNode } from "react";
|
|
2
2
|
import type { RouteObject } from "react-router-dom";
|
|
3
3
|
import { type ExposedComponentProps } from "../../components/SlotletProvider.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { NavigationPlugin, ZudokuPlugin } from "../../core/plugins.js";
|
|
5
5
|
import { CustomPage } from "./CustomPage.js";
|
|
6
6
|
|
|
7
7
|
export type CustomPageConfig = {
|
|
@@ -13,7 +13,7 @@ export type CustomPageConfig = {
|
|
|
13
13
|
|
|
14
14
|
export const customPagesPlugin = (
|
|
15
15
|
config: CustomPageConfig[],
|
|
16
|
-
):
|
|
16
|
+
): ZudokuPlugin & NavigationPlugin => {
|
|
17
17
|
return {
|
|
18
18
|
getRoutes: (): RouteObject[] =>
|
|
19
19
|
config.map(({ path, ...props }) => ({
|
|
@@ -2,7 +2,7 @@ import type { Toc } from "@stefanprobst/rehype-extract-toc";
|
|
|
2
2
|
import type { MDXProps } from "mdx/types.js";
|
|
3
3
|
import { RouteObject } from "react-router-dom";
|
|
4
4
|
import { ZudokuDocsConfig } from "../../../config/validators/validate.js";
|
|
5
|
-
import type {
|
|
5
|
+
import type { ZudokuPlugin } from "../../core/plugins.js";
|
|
6
6
|
import { DocResolver } from "./resolver.js";
|
|
7
7
|
|
|
8
8
|
export interface MarkdownPluginOptions extends ZudokuDocsConfig {
|
|
@@ -29,7 +29,7 @@ export type MDXImport = {
|
|
|
29
29
|
|
|
30
30
|
export const markdownPlugin = (
|
|
31
31
|
options: MarkdownPluginOptions[],
|
|
32
|
-
):
|
|
32
|
+
): ZudokuPlugin => ({
|
|
33
33
|
getRoutes: () => {
|
|
34
34
|
const routeMap = new Map<string, RouteObject>();
|
|
35
35
|
options.forEach(({ fileImports, files, defaultOptions }) =>
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useTheme } from "next-themes";
|
|
2
|
+
import { useEffect, useRef, type CSSProperties, type ReactNode } from "react";
|
|
3
3
|
import { cn } from "../../util/cn.js";
|
|
4
4
|
import { pastellize } from "../../util/pastellize.js";
|
|
5
5
|
|
|
6
6
|
export const DATA_ATTR = "data-linked-param";
|
|
7
7
|
|
|
8
8
|
export const usePastellizedColor = (name: string) => {
|
|
9
|
-
const
|
|
9
|
+
const { resolvedTheme } = useTheme();
|
|
10
10
|
return pastellize(
|
|
11
11
|
name,
|
|
12
|
-
|
|
12
|
+
resolvedTheme === "light" ? { saturation: 85, lightness: 50 } : undefined,
|
|
13
13
|
);
|
|
14
14
|
};
|
|
15
15
|
|
|
@@ -61,27 +61,36 @@ export const ColorizedParam = ({
|
|
|
61
61
|
});
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
-
ref.current
|
|
65
|
-
|
|
64
|
+
const el = ref.current;
|
|
65
|
+
|
|
66
|
+
el.addEventListener("mouseenter", onMouseEnter);
|
|
67
|
+
el.addEventListener("mouseleave", onMouseLeave);
|
|
66
68
|
|
|
67
69
|
return () => {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
el.removeEventListener("mouseenter", onMouseEnter);
|
|
71
|
+
el.removeEventListener("mouseleave", onMouseLeave);
|
|
70
72
|
};
|
|
71
73
|
}, [normalizedSlug]);
|
|
72
74
|
|
|
73
75
|
return (
|
|
74
76
|
<span
|
|
75
|
-
className={cn("inline-flex relative rounded group", className)}
|
|
76
77
|
{...{ [DATA_ATTR]: normalizedSlug }}
|
|
78
|
+
className={cn(
|
|
79
|
+
"relative after:rounded after:absolute after:inset-0 after:-bottom-0.5 after:border-b-2 after:transition-opacity after:duration-200",
|
|
80
|
+
"after:pointer-events-none after:border-[--border-color] after:opacity-30 after:data-[active=true]:opacity-100",
|
|
81
|
+
className,
|
|
82
|
+
)}
|
|
83
|
+
suppressHydrationWarning
|
|
77
84
|
ref={ref}
|
|
78
85
|
onClick={onClick}
|
|
86
|
+
style={
|
|
87
|
+
{
|
|
88
|
+
"--border-color": borderColor,
|
|
89
|
+
"--background-color": backgroundColor,
|
|
90
|
+
} as CSSProperties
|
|
91
|
+
}
|
|
79
92
|
>
|
|
80
|
-
|
|
81
|
-
className="absolute inset-0 border-b-2 transition-opacity duration-200 opacity-30 group-data-[active=true]:opacity-100"
|
|
82
|
-
style={{ borderColor, backgroundColor }}
|
|
83
|
-
/>
|
|
84
|
-
<span className="relative">{children ?? name}</span>
|
|
93
|
+
{children ?? name}
|
|
85
94
|
</span>
|
|
86
95
|
);
|
|
87
96
|
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { useSuspenseQuery } from "@tanstack/react-query";
|
|
1
2
|
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
2
3
|
import { useState, useTransition } from "react";
|
|
3
|
-
import { useQuery } from "urql";
|
|
4
4
|
import { useSelectedServerStore } from "../../authentication/state.js";
|
|
5
5
|
import { InlineCode } from "../../components/InlineCode.js";
|
|
6
6
|
import { Button } from "../../ui/Button.js";
|
|
7
|
+
import { useCreateQuery } from "./client/useCreateQuery.js";
|
|
7
8
|
import { useOasConfig } from "./context.js";
|
|
8
9
|
import { graphql } from "./graphql/index.js";
|
|
9
10
|
import { SimpleSelect } from "./SimpleSelect.js";
|
|
@@ -42,19 +43,13 @@ const CopyButton = ({ url }: { url: string }) => {
|
|
|
42
43
|
);
|
|
43
44
|
};
|
|
44
45
|
|
|
45
|
-
const context = { suspense: true } as const;
|
|
46
|
-
|
|
47
46
|
export const Endpoint = () => {
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
context,
|
|
52
|
-
});
|
|
47
|
+
const { input, type } = useOasConfig();
|
|
48
|
+
const query = useCreateQuery(ServersQuery, { input, type });
|
|
49
|
+
const result = useSuspenseQuery(query);
|
|
53
50
|
const [, startTransition] = useTransition();
|
|
54
51
|
const { selectedServer, setSelectedServer } = useSelectedServerStore();
|
|
55
52
|
|
|
56
|
-
if (!result.data) return null;
|
|
57
|
-
|
|
58
53
|
const { servers } = result.data.schema;
|
|
59
54
|
|
|
60
55
|
if (servers.length === 1) {
|
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { ResultOf } from "@graphql-typed-document-node/core";
|
|
2
|
-
import {
|
|
2
|
+
import { useSuspenseQuery } from "@tanstack/react-query";
|
|
3
3
|
import { CategoryHeading } from "../../components/CategoryHeading.js";
|
|
4
|
-
import { DeveloperHint } from "../../components/DeveloperHint.js";
|
|
5
|
-
import { ErrorPage } from "../../components/ErrorPage.js";
|
|
6
4
|
import { Heading } from "../../components/Heading.js";
|
|
7
|
-
import { InlineCode } from "../../components/InlineCode.js";
|
|
8
5
|
import { Markdown, ProseClasses } from "../../components/Markdown.js";
|
|
9
|
-
import { SyntaxHighlight } from "../../components/SyntaxHighlight.js";
|
|
10
6
|
import { cn } from "../../util/cn.js";
|
|
11
7
|
import { Endpoint } from "./Endpoint.js";
|
|
12
8
|
import { OperationListItem } from "./OperationListItem.js";
|
|
13
9
|
import StaggeredRender from "./StaggeredRender.js";
|
|
10
|
+
import { useCreateQuery } from "./client/useCreateQuery.js";
|
|
14
11
|
import { useOasConfig } from "./context.js";
|
|
15
12
|
import { graphql } from "./graphql/index.js";
|
|
16
13
|
|
|
@@ -99,41 +96,10 @@ const AllOperationsQuery = graphql(/* GraphQL */ `
|
|
|
99
96
|
}
|
|
100
97
|
`);
|
|
101
98
|
|
|
102
|
-
const suspenseContext = { suspense: true };
|
|
103
|
-
|
|
104
99
|
export const OperationList = () => {
|
|
105
|
-
const {
|
|
106
|
-
|
|
107
|
-
const
|
|
108
|
-
query: AllOperationsQuery,
|
|
109
|
-
variables: { type, input },
|
|
110
|
-
context: suspenseContext,
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
const error = result.error?.graphQLErrors.at(0);
|
|
114
|
-
|
|
115
|
-
// Looks like there is no Suspense level error handling (yet)?
|
|
116
|
-
// So we handle the error case in the component directly
|
|
117
|
-
if (error) {
|
|
118
|
-
return (
|
|
119
|
-
<ErrorPage
|
|
120
|
-
category="Error"
|
|
121
|
-
title="Schema cannot be displayed"
|
|
122
|
-
message={
|
|
123
|
-
<>
|
|
124
|
-
<DeveloperHint className="mb-4">
|
|
125
|
-
Check your configuration value <InlineCode>apis.type</InlineCode>{" "}
|
|
126
|
-
and <InlineCode>apis.input</InlineCode> in the Zudoku config.
|
|
127
|
-
</DeveloperHint>
|
|
128
|
-
An error occurred while trying to fetch the API reference:
|
|
129
|
-
<SyntaxHighlight code={error.toString()} language="plain" />
|
|
130
|
-
</>
|
|
131
|
-
}
|
|
132
|
-
/>
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (!result.data) return null;
|
|
100
|
+
const { input, type } = useOasConfig();
|
|
101
|
+
const query = useCreateQuery(AllOperationsQuery, { input, type });
|
|
102
|
+
const result = useSuspenseQuery(query);
|
|
137
103
|
|
|
138
104
|
return (
|
|
139
105
|
<div className="pt-[--padding-content-top]">
|
|
@@ -154,7 +120,7 @@ export const OperationList = () => {
|
|
|
154
120
|
{result.data.schema.tags
|
|
155
121
|
.filter((tag) => tag.operations.length > 0)
|
|
156
122
|
.map((tag) => (
|
|
157
|
-
<div key={tag.name}>
|
|
123
|
+
<div key={tag.name} className="[content-visibility:auto]">
|
|
158
124
|
{tag.name && <CategoryHeading>{tag.name}</CategoryHeading>}
|
|
159
125
|
{tag.description && (
|
|
160
126
|
<Markdown
|