zudoku 0.26.1 → 0.28.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 (264) hide show
  1. package/dist/app/main.d.ts +1 -1
  2. package/dist/app/main.js +19 -7
  3. package/dist/app/main.js.map +1 -1
  4. package/dist/config/loader.js +1 -1
  5. package/dist/config/loader.js.map +1 -1
  6. package/dist/config/validators/InputSidebarSchema.d.ts +2 -2
  7. package/dist/config/validators/common.d.ts +67 -0
  8. package/dist/config/validators/common.js +5 -0
  9. package/dist/config/validators/common.js.map +1 -1
  10. package/dist/config/validators/validate.d.ts +29 -0
  11. package/dist/lib/components/AnchorLink.js +5 -2
  12. package/dist/lib/components/AnchorLink.js.map +1 -1
  13. package/dist/lib/components/Header.js +1 -1
  14. package/dist/lib/components/Header.js.map +1 -1
  15. package/dist/lib/components/Heading.d.ts +1 -1
  16. package/dist/lib/components/Markdown.d.ts +2 -2
  17. package/dist/lib/components/Markdown.js +3 -1
  18. package/dist/lib/components/Markdown.js.map +1 -1
  19. package/dist/lib/components/StatusPage.d.ts +7 -0
  20. package/dist/lib/components/StatusPage.js +71 -0
  21. package/dist/lib/components/StatusPage.js.map +1 -0
  22. package/dist/lib/components/SyntaxHighlight.d.ts +2 -1
  23. package/dist/lib/components/SyntaxHighlight.js +2 -2
  24. package/dist/lib/components/SyntaxHighlight.js.map +1 -1
  25. package/dist/lib/components/ThemeSwitch.js +4 -4
  26. package/dist/lib/components/ThemeSwitch.js.map +1 -1
  27. package/dist/lib/components/cache.d.ts +6 -0
  28. package/dist/lib/components/cache.js +13 -0
  29. package/dist/lib/components/cache.js.map +1 -0
  30. package/dist/lib/components/context/ViewportAnchorContext.js +16 -4
  31. package/dist/lib/components/context/ViewportAnchorContext.js.map +1 -1
  32. package/dist/lib/components/context/ZudokuContext.js +2 -1
  33. package/dist/lib/components/context/ZudokuContext.js.map +1 -1
  34. package/dist/lib/components/index.d.ts +9 -2
  35. package/dist/lib/components/index.js +3 -0
  36. package/dist/lib/components/index.js.map +1 -1
  37. package/dist/lib/components/navigation/SidebarCategory.js +3 -3
  38. package/dist/lib/components/navigation/SidebarCategory.js.map +1 -1
  39. package/dist/lib/core/RouteGuard.d.ts +1 -0
  40. package/dist/lib/core/RouteGuard.js +28 -0
  41. package/dist/lib/core/RouteGuard.js.map +1 -0
  42. package/dist/lib/core/ZudokuContext.d.ts +4 -2
  43. package/dist/lib/core/ZudokuContext.js +9 -7
  44. package/dist/lib/core/ZudokuContext.js.map +1 -1
  45. package/dist/lib/oas/graphql/circular.d.ts +3 -0
  46. package/dist/lib/oas/graphql/circular.js +27 -0
  47. package/dist/lib/oas/graphql/circular.js.map +1 -0
  48. package/dist/lib/oas/graphql/index.d.ts +1 -0
  49. package/dist/lib/oas/graphql/index.js +46 -29
  50. package/dist/lib/oas/graphql/index.js.map +1 -1
  51. package/dist/lib/oas/parser/dereference/index.d.ts +0 -1
  52. package/dist/lib/oas/parser/dereference/index.js +1 -1
  53. package/dist/lib/oas/parser/dereference/index.js.map +1 -1
  54. package/dist/lib/plugins/openapi/Endpoint.js +2 -2
  55. package/dist/lib/plugins/openapi/Endpoint.js.map +1 -1
  56. package/dist/lib/plugins/openapi/{Route.d.ts → OpenApiRoute.d.ts} +2 -1
  57. package/dist/lib/plugins/openapi/{Route.js → OpenApiRoute.js} +3 -4
  58. package/dist/lib/plugins/openapi/OpenApiRoute.js.map +1 -0
  59. package/dist/lib/plugins/openapi/OperationList.d.ts +4 -1
  60. package/dist/lib/plugins/openapi/OperationList.js +20 -14
  61. package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
  62. package/dist/lib/plugins/openapi/OperationListItem.js +1 -1
  63. package/dist/lib/plugins/openapi/OperationListItem.js.map +1 -1
  64. package/dist/lib/plugins/openapi/ParameterListItem.js +1 -1
  65. package/dist/lib/plugins/openapi/ParameterListItem.js.map +1 -1
  66. package/dist/lib/plugins/openapi/RequestBodySidecarBox.d.ts +1 -1
  67. package/dist/lib/plugins/openapi/RequestBodySidecarBox.js +2 -0
  68. package/dist/lib/plugins/openapi/RequestBodySidecarBox.js.map +1 -1
  69. package/dist/lib/plugins/openapi/Sidecar.js +3 -3
  70. package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
  71. package/dist/lib/plugins/openapi/SidecarExamples.js +17 -14
  72. package/dist/lib/plugins/openapi/SidecarExamples.js.map +1 -1
  73. package/dist/lib/plugins/openapi/graphql/gql.d.ts +6 -2
  74. package/dist/lib/plugins/openapi/graphql/gql.js +3 -2
  75. package/dist/lib/plugins/openapi/graphql/gql.js.map +1 -1
  76. package/dist/lib/plugins/openapi/graphql/graphql.d.ts +47 -26
  77. package/dist/lib/plugins/openapi/graphql/graphql.js +20 -16
  78. package/dist/lib/plugins/openapi/graphql/graphql.js.map +1 -1
  79. package/dist/lib/plugins/openapi/index.js +101 -65
  80. package/dist/lib/plugins/openapi/index.js.map +1 -1
  81. package/dist/lib/plugins/openapi/interfaces.d.ts +8 -2
  82. package/dist/lib/plugins/openapi/playground/ExamplesDropdown.js +5 -5
  83. package/dist/lib/plugins/openapi/playground/ExamplesDropdown.js.map +1 -1
  84. package/dist/lib/plugins/openapi/playground/Headers.js +17 -16
  85. package/dist/lib/plugins/openapi/playground/Headers.js.map +1 -1
  86. package/dist/lib/plugins/openapi/playground/ParamsGrid.d.ts +5 -0
  87. package/dist/lib/plugins/openapi/playground/ParamsGrid.js +4 -0
  88. package/dist/lib/plugins/openapi/playground/ParamsGrid.js.map +1 -0
  89. package/dist/lib/plugins/openapi/playground/PathParams.js +4 -12
  90. package/dist/lib/plugins/openapi/playground/PathParams.js.map +1 -1
  91. package/dist/lib/plugins/openapi/playground/Playground.d.ts +13 -0
  92. package/dist/lib/plugins/openapi/playground/Playground.js +19 -31
  93. package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
  94. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js +1 -1
  95. package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js.map +1 -1
  96. package/dist/lib/plugins/openapi/playground/QueryParams.js +4 -3
  97. package/dist/lib/plugins/openapi/playground/QueryParams.js.map +1 -1
  98. package/dist/lib/plugins/openapi/playground/SubmitButton.d.ts +7 -0
  99. package/dist/lib/plugins/openapi/playground/SubmitButton.js +22 -0
  100. package/dist/lib/plugins/openapi/playground/SubmitButton.js.map +1 -0
  101. package/dist/lib/plugins/openapi/playground/result-panel/RequestTab.d.ts +7 -0
  102. package/dist/lib/plugins/openapi/playground/result-panel/RequestTab.js +11 -0
  103. package/dist/lib/plugins/openapi/playground/result-panel/RequestTab.js.map +1 -0
  104. package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.d.ts +8 -0
  105. package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js +95 -0
  106. package/dist/lib/plugins/openapi/playground/result-panel/ResponseTab.js.map +1 -0
  107. package/dist/lib/plugins/openapi/playground/result-panel/ResultPanel.d.ts +7 -0
  108. package/dist/lib/plugins/openapi/playground/result-panel/ResultPanel.js +16 -0
  109. package/dist/lib/plugins/openapi/playground/result-panel/ResultPanel.js.map +1 -0
  110. package/dist/lib/plugins/openapi/playground/result-panel/convertToTypes.d.ts +10 -0
  111. package/dist/lib/plugins/openapi/playground/result-panel/convertToTypes.js +32 -0
  112. package/dist/lib/plugins/openapi/playground/result-panel/convertToTypes.js.map +1 -0
  113. package/dist/lib/plugins/openapi/playground/result-panel/convertToTypes.test.d.ts +1 -0
  114. package/dist/lib/plugins/openapi/playground/result-panel/convertToTypes.test.js +56 -0
  115. package/dist/lib/plugins/openapi/playground/result-panel/convertToTypes.test.js.map +1 -0
  116. package/dist/lib/plugins/openapi/schema/SchemaComponents.js +1 -1
  117. package/dist/lib/plugins/openapi/schema/SchemaComponents.js.map +1 -1
  118. package/dist/lib/ui/Command.js +1 -1
  119. package/dist/lib/ui/Command.js.map +1 -1
  120. package/dist/lib/ui/Select.js +2 -2
  121. package/dist/lib/ui/Select.js.map +1 -1
  122. package/dist/lib/util/MdxComponents.js +2 -2
  123. package/dist/lib/util/MdxComponents.js.map +1 -1
  124. package/dist/lib/util/joinUrl.js +1 -1
  125. package/dist/lib/util/joinUrl.js.map +1 -1
  126. package/dist/lib/util/joinUrl.test.d.ts +1 -0
  127. package/dist/lib/util/joinUrl.test.js +43 -0
  128. package/dist/lib/util/joinUrl.test.js.map +1 -0
  129. package/dist/lib/util/useScrollToAnchor.d.ts +1 -0
  130. package/dist/lib/util/useScrollToAnchor.js +26 -15
  131. package/dist/lib/util/useScrollToAnchor.js.map +1 -1
  132. package/dist/vite/plugin-api.js +15 -3
  133. package/dist/vite/plugin-api.js.map +1 -1
  134. package/dist/vite/prerender.js +1 -0
  135. package/dist/vite/prerender.js.map +1 -1
  136. package/dist/zuplo/enrich-with-zuplo.js +1 -1
  137. package/dist/zuplo/enrich-with-zuplo.js.map +1 -1
  138. package/dist/zuplo/with-zuplo.d.ts +2 -1
  139. package/dist/zuplo/with-zuplo.js +3 -1
  140. package/dist/zuplo/with-zuplo.js.map +1 -1
  141. package/lib/{AuthenticationPlugin-C9SwOxkc.js → AuthenticationPlugin-Du8cLBSr.js} +3 -3
  142. package/lib/{AuthenticationPlugin-C9SwOxkc.js.map → AuthenticationPlugin-Du8cLBSr.js.map} +1 -1
  143. package/lib/{Markdown-DFN6p0J-.js → Markdown-Cyrx_JrO.js} +1195 -1185
  144. package/lib/{Markdown-DFN6p0J-.js.map → Markdown-Cyrx_JrO.js.map} +1 -1
  145. package/lib/{MdxPage-D9c4z09Q.js → MdxPage-DewragjB.js} +6 -6
  146. package/lib/{MdxPage-D9c4z09Q.js.map → MdxPage-DewragjB.js.map} +1 -1
  147. package/lib/OpenApiRoute-UrC_t0e5.js +36 -0
  148. package/lib/OpenApiRoute-UrC_t0e5.js.map +1 -0
  149. package/lib/{OperationList-DGJWDx1G.js → OperationList-D_ejrepA.js} +1970 -1957
  150. package/lib/OperationList-D_ejrepA.js.map +1 -0
  151. package/lib/{Select-D3O7wISy.js → Select-CnCZ4WhS.js} +61 -61
  152. package/lib/Select-CnCZ4WhS.js.map +1 -0
  153. package/lib/{SlotletProvider-_3zzX_g_.js → SlotletProvider-mQiPDQIH.js} +4 -4
  154. package/lib/{SlotletProvider-_3zzX_g_.js.map → SlotletProvider-mQiPDQIH.js.map} +1 -1
  155. package/lib/{SyntaxHighlight-CJCSPG1F.js → SyntaxHighlight-B0L4SC_N.js} +309 -298
  156. package/lib/SyntaxHighlight-B0L4SC_N.js.map +1 -0
  157. package/lib/{ZudokuContext-DeQZEp-x.js → ZudokuContext-BTUJPpQl.js} +257 -246
  158. package/lib/ZudokuContext-BTUJPpQl.js.map +1 -0
  159. package/lib/{chunk-SYFQ2XB5-BF5IDYrB.js → chunk-SYFQ2XB5-BPvC-soB.js} +5 -5
  160. package/lib/{chunk-SYFQ2XB5-BF5IDYrB.js.map → chunk-SYFQ2XB5-BPvC-soB.js.map} +1 -1
  161. package/lib/circular-Dgpd6AN-.js +15397 -0
  162. package/lib/circular-Dgpd6AN-.js.map +1 -0
  163. package/lib/{createServer-BcaswoFO.js → createServer-BydbkTsd.js} +3487 -5601
  164. package/lib/createServer-BydbkTsd.js.map +1 -0
  165. package/lib/{hook-BRQEDRbn.js → hook-FT3SJLe_.js} +2 -2
  166. package/lib/{hook-BRQEDRbn.js.map → hook-FT3SJLe_.js.map} +1 -1
  167. package/lib/{index-LNp6rxyU.js → index-CjJS0l4l.js} +2 -2
  168. package/lib/{index-LNp6rxyU.js.map → index-CjJS0l4l.js.map} +1 -1
  169. package/lib/index-DGugJOLc.js +1974 -0
  170. package/lib/index-DGugJOLc.js.map +1 -0
  171. package/lib/{joinUrl-BTy9bvoK.js → joinUrl-nLx9pD-Z.js} +2 -2
  172. package/lib/joinUrl-nLx9pD-Z.js.map +1 -0
  173. package/lib/ui/Command.js +27 -27
  174. package/lib/ui/Command.js.map +1 -1
  175. package/lib/ui/Select.js +2 -2
  176. package/lib/ui/Select.js.map +1 -1
  177. package/lib/{useExposedProps-CetwhZpP.js → useExposedProps-BLKFBylA.js} +2 -2
  178. package/lib/{useExposedProps-CetwhZpP.js.map → useExposedProps-BLKFBylA.js.map} +1 -1
  179. package/lib/useScrollToAnchor-eRM9tVvD.js +289 -0
  180. package/lib/useScrollToAnchor-eRM9tVvD.js.map +1 -0
  181. package/lib/zudoku.auth-clerk.js +1 -1
  182. package/lib/zudoku.auth-openid.js +4 -4
  183. package/lib/zudoku.components.js +740 -979
  184. package/lib/zudoku.components.js.map +1 -1
  185. package/lib/zudoku.plugin-api-catalog.js +4 -4
  186. package/lib/zudoku.plugin-api-keys.js +5 -5
  187. package/lib/zudoku.plugin-custom-pages.js +2 -2
  188. package/lib/zudoku.plugin-markdown.js +1 -1
  189. package/lib/zudoku.plugin-openapi.js +6 -5
  190. package/lib/zudoku.plugin-openapi.js.map +1 -1
  191. package/lib/zudoku.plugin-redirect.js +1 -1
  192. package/package.json +2 -2
  193. package/src/app/main.tsx +26 -7
  194. package/src/lib/components/AnchorLink.tsx +5 -2
  195. package/src/lib/components/Header.tsx +1 -1
  196. package/src/lib/components/Markdown.tsx +14 -15
  197. package/src/lib/components/StatusPage.tsx +91 -0
  198. package/src/lib/components/SyntaxHighlight.tsx +14 -0
  199. package/src/lib/components/ThemeSwitch.tsx +14 -15
  200. package/src/lib/components/cache.ts +15 -0
  201. package/src/lib/components/context/ViewportAnchorContext.tsx +20 -6
  202. package/src/lib/components/context/ZudokuContext.ts +3 -1
  203. package/src/lib/components/index.ts +7 -0
  204. package/src/lib/components/navigation/SidebarCategory.tsx +3 -2
  205. package/src/lib/core/RouteGuard.tsx +35 -0
  206. package/src/lib/core/ZudokuContext.ts +9 -8
  207. package/src/lib/oas/graphql/circular.ts +29 -0
  208. package/src/lib/oas/graphql/index.ts +72 -44
  209. package/src/lib/oas/parser/dereference/index.ts +1 -2
  210. package/src/lib/plugins/openapi/Endpoint.tsx +2 -2
  211. package/src/lib/plugins/openapi/{Route.tsx → OpenApiRoute.tsx} +3 -3
  212. package/src/lib/plugins/openapi/OperationList.tsx +34 -12
  213. package/src/lib/plugins/openapi/OperationListItem.tsx +0 -2
  214. package/src/lib/plugins/openapi/ParameterListItem.tsx +1 -0
  215. package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +2 -0
  216. package/src/lib/plugins/openapi/Sidecar.tsx +4 -3
  217. package/src/lib/plugins/openapi/SidecarExamples.tsx +24 -24
  218. package/src/lib/plugins/openapi/graphql/gql.ts +12 -4
  219. package/src/lib/plugins/openapi/graphql/graphql.ts +66 -43
  220. package/src/lib/plugins/openapi/index.tsx +134 -82
  221. package/src/lib/plugins/openapi/interfaces.ts +11 -2
  222. package/src/lib/plugins/openapi/playground/ExamplesDropdown.tsx +30 -27
  223. package/src/lib/plugins/openapi/playground/Headers.tsx +65 -65
  224. package/src/lib/plugins/openapi/playground/ParamsGrid.tsx +8 -0
  225. package/src/lib/plugins/openapi/playground/PathParams.tsx +34 -74
  226. package/src/lib/plugins/openapi/playground/Playground.tsx +64 -116
  227. package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +1 -1
  228. package/src/lib/plugins/openapi/playground/QueryParams.tsx +46 -45
  229. package/src/lib/plugins/openapi/playground/SubmitButton.tsx +75 -0
  230. package/src/lib/plugins/openapi/playground/result-panel/RequestTab.tsx +73 -0
  231. package/src/lib/plugins/openapi/playground/result-panel/ResponseTab.tsx +210 -0
  232. package/src/lib/plugins/openapi/playground/result-panel/ResultPanel.tsx +101 -0
  233. package/src/lib/plugins/openapi/playground/result-panel/convertToTypes.test.ts +64 -0
  234. package/src/lib/plugins/openapi/playground/result-panel/convertToTypes.ts +36 -0
  235. package/src/lib/plugins/openapi/schema/SchemaComponents.tsx +1 -1
  236. package/src/lib/ui/Command.tsx +1 -1
  237. package/src/lib/ui/Select.tsx +1 -1
  238. package/src/lib/util/MdxComponents.tsx +2 -1
  239. package/src/lib/util/joinUrl.test.ts +62 -0
  240. package/src/lib/util/joinUrl.ts +1 -1
  241. package/src/lib/util/useScrollToAnchor.ts +32 -15
  242. package/dist/lib/plugins/openapi/Route.js.map +0 -1
  243. package/dist/lib/plugins/openapi/playground/ResponseTab.d.ts +0 -4
  244. package/dist/lib/plugins/openapi/playground/ResponseTab.js +0 -42
  245. package/dist/lib/plugins/openapi/playground/ResponseTab.js.map +0 -1
  246. package/lib/AnchorLink-bObQitZv.js +0 -34
  247. package/lib/AnchorLink-bObQitZv.js.map +0 -1
  248. package/lib/OperationList-DGJWDx1G.js.map +0 -1
  249. package/lib/Route-VdmEyOD0.js +0 -35
  250. package/lib/Route-VdmEyOD0.js.map +0 -1
  251. package/lib/Select-D3O7wISy.js.map +0 -1
  252. package/lib/StaggeredRender-DgsamH_G.js +0 -17
  253. package/lib/StaggeredRender-DgsamH_G.js.map +0 -1
  254. package/lib/SyntaxHighlight-CJCSPG1F.js.map +0 -1
  255. package/lib/ZudokuContext-DeQZEp-x.js.map +0 -1
  256. package/lib/createServer-BcaswoFO.js.map +0 -1
  257. package/lib/index-Bn6Lc9tq.js +0 -9
  258. package/lib/index-Bn6Lc9tq.js.map +0 -1
  259. package/lib/index-CXRrqOIl.js +0 -1750
  260. package/lib/index-CXRrqOIl.js.map +0 -1
  261. package/lib/index-TaRXY2w1.js +0 -43
  262. package/lib/index-TaRXY2w1.js.map +0 -1
  263. package/lib/joinUrl-BTy9bvoK.js.map +0 -1
  264. package/src/lib/plugins/openapi/playground/ResponseTab.tsx +0 -76
@@ -61,7 +61,7 @@ const CommandInlineInput = React.forwardRef<
61
61
  <CommandPrimitive.Input
62
62
  ref={ref}
63
63
  className={cn(
64
- "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
64
+ "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",
65
65
  "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
66
66
  className,
67
67
  )}
@@ -83,9 +83,9 @@ const SelectContent = React.forwardRef<
83
83
  <SelectScrollUpButton />
84
84
  <SelectPrimitive.Viewport
85
85
  className={cn(
86
- "p-1",
87
86
  position === "popper" &&
88
87
  "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]",
88
+ "divide-y",
89
89
  )}
90
90
  >
91
91
  {children}
@@ -61,7 +61,7 @@ export const MdxComponents = {
61
61
  code: ({ className, children, ...props }) => {
62
62
  // `inline` provided by the rehype plugin, as react-markdown removed support for that
63
63
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
64
- const inline = (props as any).inline;
64
+ const { inline, title } = props as Record<string, unknown>;
65
65
 
66
66
  if (inline === true || inline === "true") {
67
67
  return <InlineCode className={className}>{children}</InlineCode>;
@@ -75,6 +75,7 @@ export const MdxComponents = {
75
75
  className="rounded-xl p-4 border dark:!bg-foreground/10 dark:border-transparent"
76
76
  showLanguageIndicator
77
77
  code={String(children).trim()}
78
+ title={typeof title === "string" ? title : undefined}
78
79
  />
79
80
  );
80
81
  },
@@ -0,0 +1,62 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { joinUrl } from "./joinUrl.js";
3
+
4
+ describe("joinUrl", () => {
5
+ test("handles basic URL joining", () => {
6
+ expect(joinUrl("https://example.com", "path")).toBe(
7
+ "https://example.com/path",
8
+ );
9
+ expect(joinUrl("https://example.com/", "path")).toBe(
10
+ "https://example.com/path",
11
+ );
12
+ expect(joinUrl("https://example.com/", "/path")).toBe(
13
+ "https://example.com/path",
14
+ );
15
+ });
16
+
17
+ test("handles multiple path segments", () => {
18
+ expect(joinUrl("https://example.com", "api", "v1", "users")).toBe(
19
+ "https://example.com/api/v1/users",
20
+ );
21
+ });
22
+
23
+ // test("handles query parameters", () => {
24
+ // expect(joinUrl("https://example.com", "path?query=1")).toBe(
25
+ // "https://example.com/path?query=1",
26
+ // );
27
+ // expect(joinUrl("https://example.com?base=1", "path?query=1")).toBe(
28
+ // "https://example.com/path?query=1",
29
+ // );
30
+ // });
31
+
32
+ // test("handles repeated dots and question marks", () => {
33
+ // expect(joinUrl("https://example.com", "path/../../../test")).toBe(
34
+ // "https://example.com/path/../../../test",
35
+ // );
36
+ // expect(joinUrl("https://example.com", "test????a=1")).toBe(
37
+ // "https://example.com/test????a=1",
38
+ // );
39
+ // });
40
+
41
+ test("handles falsy values", () => {
42
+ expect(joinUrl("https://example.com", null, undefined, false, "path")).toBe(
43
+ "https://example.com/path",
44
+ );
45
+ });
46
+
47
+ test("handles numeric values", () => {
48
+ expect(joinUrl("https://example.com", "api", 123, "test")).toBe(
49
+ "https://example.com/api/123/test",
50
+ );
51
+ });
52
+
53
+ test("handles relative paths", () => {
54
+ expect(joinUrl("/api", "v1", "users")).toBe("/api/v1/users");
55
+ expect(joinUrl("api", "v1", "users")).toBe("/api/v1/users");
56
+ });
57
+
58
+ test("handles empty input", () => {
59
+ expect(joinUrl()).toBe("/");
60
+ expect(joinUrl("")).toBe("/");
61
+ });
62
+ });
@@ -1,5 +1,5 @@
1
1
  // Mostly adapted from https://github.com/moxystudio/js-proper-url-join
2
- const defaultUrlRegExp = /^(\w+:\/\/[^/?]+)?(.*?)(\?.+)?$/;
2
+ const defaultUrlRegExp = /^(\w+:\/\/[^/?]+)?([^?]*)(\?.*)?$/;
3
3
 
4
4
  const normalizeParts = (
5
5
  parts: (string | number | null | undefined | false)[],
@@ -1,4 +1,4 @@
1
- import { useEffect } from "react";
1
+ import { useCallback, useEffect } from "react";
2
2
  import { useLocation } from "react-router";
3
3
  import { useViewportAnchor } from "../components/context/ViewportAnchorContext.js";
4
4
  import { DATA_ANCHOR_ATTR } from "../components/navigation/SidebarItem.js";
@@ -22,32 +22,49 @@ const scrollIntoViewIfNeeded = (
22
22
  element.scrollIntoView(options);
23
23
  };
24
24
 
25
- export const useScrollToAnchor = () => {
26
- const location = useLocation();
25
+ export const useScrollToHash = () => {
27
26
  const { setActiveAnchor } = useViewportAnchor();
28
27
 
29
- useEffect(() => {
30
- if (!location.hash) return;
31
-
32
- const hash = decodeURIComponent(location.hash.split("/")[0]!.slice(1));
33
-
34
- const scrollToElement = () => {
35
- const element = document.getElementById(hash);
36
- const link = document.querySelector(`[${DATA_ANCHOR_ATTR}="${hash}"]`);
28
+ const scrollToHash = useCallback(
29
+ (hash: string) => {
30
+ const cleanHash = hash
31
+ .replace(/^#/, "")
32
+ // Operation list items might have subdivisions that the sidebar doesn't show.
33
+ // The subdivisions are separated by a slash so we need to remove everything before the slash to get the sidebar correct item.
34
+ .split("/")
35
+ .at(0)!;
36
+ const element = document.getElementById(decodeURIComponent(cleanHash));
37
+ const link = document.querySelector(
38
+ `[${DATA_ANCHOR_ATTR}="${cleanHash}"]`,
39
+ );
37
40
 
38
41
  if (element) {
39
42
  element.scrollIntoView();
40
43
  scrollIntoViewIfNeeded(link);
41
- requestIdleCallback(() => setActiveAnchor(hash));
44
+ requestIdleCallback(() => setActiveAnchor(cleanHash));
42
45
  return true;
43
46
  }
44
47
 
48
+ // Scroll didn't happen
45
49
  return false;
46
- };
50
+ },
51
+ [setActiveAnchor],
52
+ );
53
+
54
+ return scrollToHash;
55
+ };
56
+
57
+ export const useScrollToAnchor = () => {
58
+ const location = useLocation();
59
+ const { setActiveAnchor } = useViewportAnchor();
60
+ const scrollToHash = useScrollToHash();
61
+
62
+ useEffect(() => {
63
+ if (!location.hash) return;
47
64
 
48
- if (!scrollToElement()) {
65
+ if (!scrollToHash(location.hash)) {
49
66
  const observer = new MutationObserver((_, obs) => {
50
- if (!scrollToElement()) return;
67
+ if (!scrollToHash(location.hash)) return;
51
68
  obs.disconnect();
52
69
  });
53
70
 
@@ -1 +0,0 @@
1
- {"version":3,"file":"Route.js","sourceRoot":"","sources":["../../../../src/lib/plugins/openapi/Route.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,E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AC,CAAC"}
@@ -1,4 +0,0 @@
1
- export declare const ResponseTab: ({ body, headers, }: {
2
- body?: string;
3
- headers: Headers;
4
- }) => import("react/jsx-runtime").JSX.Element;
@@ -1,42 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState } from "react";
3
- import { SyntaxHighlight } from "../../../components/SyntaxHighlight.js";
4
- import { Card } from "../../../ui/Card.js";
5
- import { SimpleSelect } from "../SimpleSelect.js";
6
- const mimeTypeToLanguage = (mimeType) => {
7
- const mimeTypeMapping = {
8
- "application/json": "json",
9
- "text/json": "json",
10
- "text/html": "html",
11
- "text/css": "css",
12
- "text/javascript": "javascript",
13
- "application/xml": "xml",
14
- "application/xhtml+xml": "xhtml",
15
- };
16
- return Object.entries(mimeTypeMapping).find(([mime]) => mimeType.includes(mime))?.[1];
17
- };
18
- const detectLanguage = (headers) => {
19
- const contentType = headers.get("Content-Type") || "";
20
- return mimeTypeToLanguage(contentType);
21
- };
22
- const tryParseJson = (body) => {
23
- try {
24
- return JSON.stringify(JSON.parse(body), null, 2);
25
- }
26
- catch {
27
- return null;
28
- }
29
- };
30
- export const ResponseTab = ({ body = "", headers, }) => {
31
- const detectedLanguage = detectLanguage(headers);
32
- const jsonContent = tryParseJson(body);
33
- const beautifiedBody = jsonContent || body;
34
- const [view, setView] = useState(jsonContent ? "formatted" : "raw");
35
- return (_jsxs("div", { className: "flex flex-col gap-2", children: [_jsx(Card, { className: "shadow-none", children: _jsx(SyntaxHighlight, { language: view === "raw" ? (jsonContent ? "plain" : detectedLanguage) : "json", noBackground: true,
36
- // playground dialog has h-5/6 ≈ 83.333vh
37
- className: "overflow-x-auto p-4 text-xs max-h-[calc(83.333vh-180px)]", code: view === "raw" ? body : beautifiedBody }) }), jsonContent && (_jsx("div", { className: "flex justify-end", children: _jsx(SimpleSelect, { value: view, onChange: (e) => setView(e.target.value), options: [
38
- { value: "formatted", label: "Formatted" },
39
- { value: "raw", label: "Raw" },
40
- ] }) }))] }));
41
- };
42
- //# sourceMappingURL=ResponseTab.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ResponseTab.js","sourceRoot":"","sources":["../../../../../src/lib/plugins/openapi/playground/ResponseTab.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,MAAM,kBAAkB,GAAG,CAAC,QAAgB,EAAE,EAAE;IAC9C,MAAM,eAAe,GAAG;QACtB,kBAAkB,EAAE,MAAM;QAC1B,WAAW,EAAE,MAAM;QACnB,WAAW,EAAE,MAAM;QACnB,UAAU,EAAE,KAAK;QACjB,iBAAiB,EAAE,YAAY;QAC/B,iBAAiB,EAAE,KAAK;QACxB,uBAAuB,EAAE,OAAO;KACjC,CAAC;IAEF,OAAO,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CACrD,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CACxB,EAAE,CAAC,CAAC,CAAC,CAAC;AACT,CAAC,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,OAAgB,EAAE,EAAE;IAC1C,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC;IACtD,OAAO,kBAAkB,CAAC,WAAW,CAAC,CAAC;AACzC,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE;IACpC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACnD,CAAC;IAAC,MAAM,CAAC;QACP,OA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0 @@
1
- import e from "react";
2
- import { j as r } from "./jsx-runtime-Bdg6XQ1m.js";
3
- import { u as l, L as m } from "./chunk-SYFQ2XB5-BF5IDYrB.js";
4
- const c = {}, u = e.createContext(c);
5
- function f(t) {
6
- const n = e.useContext(u);
7
- return e.useMemo(
8
- function() {
9
- return typeof t == "function" ? t(n) : { ...n, ...t };
10
- },
11
- [n, t]
12
- );
13
- }
14
- function h(t) {
15
- let n;
16
- return t.disableParentContext ? n = typeof t.components == "function" ? t.components(c) : t.components || c : n = f(t.components), e.createElement(
17
- u.Provider,
18
- { value: n },
19
- t.children
20
- );
21
- }
22
- const y = (t) => {
23
- const n = l(), o = typeof t.to == "string" ? t.to : t.to.hash, i = (a) => {
24
- var s;
25
- !(o != null && o.startsWith("#")) || o !== n.hash || (a.preventDefault(), (s = document.getElementById(o.slice(1))) == null || s.scrollIntoView());
26
- };
27
- return /* @__PURE__ */ r.jsx(m, { onClick: i, ...t });
28
- };
29
- export {
30
- y as A,
31
- h as M,
32
- f as u
33
- };
34
- //# sourceMappingURL=AnchorLink-bObQitZv.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AnchorLink-bObQitZv.js","sources":["../../../node_modules/.pnpm/@mdx-js+react@3.1.0_@types+react@19.0.7_react@19.0.0/node_modules/@mdx-js/react/lib/index.js","../src/lib/components/AnchorLink.tsx"],"sourcesContent":["/**\n * @import {MDXComponents} from 'mdx/types.js'\n * @import {Component, ReactElement, ReactNode} from 'react'\n */\n\n/**\n * @callback MergeComponents\n * Custom merge function.\n * @param {Readonly<MDXComponents>} currentComponents\n * Current components from the context.\n * @returns {MDXComponents}\n * Additional components.\n *\n * @typedef Props\n * Configuration for `MDXProvider`.\n * @property {ReactNode | null | undefined} [children]\n * Children (optional).\n * @property {Readonly<MDXComponents> | MergeComponents | null | undefined} [components]\n * Additional components to use or a function that creates them (optional).\n * @property {boolean | null | undefined} [disableParentContext=false]\n * Turn off outer component context (default: `false`).\n */\n\nimport React from 'react'\n\n/** @type {Readonly<MDXComponents>} */\nconst emptyComponents = {}\n\nconst MDXContext = React.createContext(emptyComponents)\n\n/**\n * Get current components from the MDX Context.\n *\n * @param {Readonly<MDXComponents> | MergeComponents | null | undefined} [components]\n * Additional components to use or a function that creates them (optional).\n * @returns {MDXComponents}\n * Current components.\n */\nexport function useMDXComponents(components) {\n const contextComponents = React.useContext(MDXContext)\n\n // Memoize to avoid unnecessary top-level context changes\n return React.useMemo(\n function () {\n // Custom merge via a function prop\n if (typeof components === 'function') {\n return components(contextComponents)\n }\n\n return {...contextComponents, ...components}\n },\n [contextComponents, components]\n )\n}\n\n/**\n * Provider for MDX context.\n *\n * @param {Readonly<Props>} properties\n * Properties.\n * @returns {ReactElement}\n * Element.\n * @satisfies {Component}\n */\nexport function MDXProvider(properties) {\n /** @type {Readonly<MDXComponents>} */\n let allComponents\n\n if (properties.disableParentContext) {\n allComponents =\n typeof properties.components === 'function'\n ? properties.components(emptyComponents)\n : properties.components || emptyComponents\n } else {\n allComponents = useMDXComponents(properties.components)\n }\n\n return React.createElement(\n MDXContext.Provider,\n {value: allComponents},\n properties.children\n )\n}\n","import React from \"react\";\nimport { Link, type LinkProps, useLocation } from \"react-router\";\n\n/**\n * Link that scrolls to anchor even if the hash is already set in the URL.\n */\nexport const AnchorLink = (props: LinkProps) => {\n const location = useLocation();\n const hash = typeof props.to === \"string\" ? props.to : props.to.hash;\n\n const handleClick = (event: React.MouseEvent<HTMLAnchorElement>) => {\n if (!hash?.startsWith(\"#\") || hash !== location.hash) return;\n\n event.preventDefault();\n document.getElementById(hash.slice(1))?.scrollIntoView();\n };\n\n return <Link onClick={handleClick} {...props} />;\n};\n"],"names":["emptyComponents","MDXContext","React","useMDXComponents","components","contextComponents","MDXProvider","properties","allComponents","AnchorLink","props","location","useLocation","hash","handleClick","event","_a","jsx","Link"],"mappings":";;;AA0BA,MAAMA,IAAkB,CAAA,GAElBC,IAAaC,EAAM,cAAcF,CAAe;AAU/C,SAASG,EAAiBC,GAAY;AAC3C,QAAMC,IAAoBH,EAAM,WAAWD,CAAU;AAGrD,SAAOC,EAAM;AAAA,IACX,WAAY;AAEV,aAAI,OAAOE,KAAe,aACjBA,EAAWC,CAAiB,IAG9B,EAAC,GAAGA,GAAmB,GAAGD,EAAU;AAAA,IAC5C;AAAA,IACD,CAACC,GAAmBD,CAAU;AAAA,EAClC;AACA;AAWO,SAASE,EAAYC,GAAY;AAEtC,MAAIC;AAEJ,SAAID,EAAW,uBACbC,IACE,OAAOD,EAAW,cAAe,aAC7BA,EAAW,WAAWP,CAAe,IACrCO,EAAW,cAAcP,IAE/BQ,IAAgBL,EAAiBI,EAAW,UAAU,GAGjDL,EAAM;AAAA,IACXD,EAAW;AAAA,IACX,EAAC,OAAOO,EAAa;AAAA,IACrBD,EAAW;AAAA,EACf;AACA;AC5Ea,MAAAE,IAAa,CAACC,MAAqB;AAC9C,QAAMC,IAAWC,EAAY,GACvBC,IAAO,OAAOH,EAAM,MAAO,WAAWA,EAAM,KAAKA,EAAM,GAAG,MAE1DI,IAAc,CAACC,MAA+C;;AAClE,IAAI,EAACF,KAAA,QAAAA,EAAM,WAAW,SAAQA,MAASF,EAAS,SAEhDI,EAAM,eAAe,IACrBC,IAAA,SAAS,eAAeH,EAAK,MAAM,CAAC,CAAC,MAArC,QAAAG,EAAwC;AAAA,EAC1C;AAEA,SAAQC,gBAAAA,EAAAA,IAAAC,GAAA,EAAK,SAASJ,GAAc,GAAGJ,GAAO;AAChD;","x_google_ignoreList":[0]}