zudoku 0.0.0-f865d81 → 0.0.0-fa903e7

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 (446) hide show
  1. package/dist/app/demo.js +0 -2
  2. package/dist/app/demo.js.map +1 -1
  3. package/dist/app/entry.client.js +14 -0
  4. package/dist/app/entry.client.js.map +1 -1
  5. package/dist/app/entry.server.js +6 -6
  6. package/dist/app/entry.server.js.map +1 -1
  7. package/dist/app/main.d.ts +1 -1
  8. package/dist/app/main.js +2 -2
  9. package/dist/app/main.js.map +1 -1
  10. package/dist/app/standalone.js +0 -2
  11. package/dist/app/standalone.js.map +1 -1
  12. package/dist/cli/cli.js +1 -2
  13. package/dist/cli/cli.js.map +1 -1
  14. package/dist/cli/common/logger.js +9 -0
  15. package/dist/cli/common/logger.js.map +1 -1
  16. package/dist/codegen.d.ts +3 -0
  17. package/dist/codegen.js +45 -0
  18. package/dist/codegen.js.map +1 -0
  19. package/dist/config/validators/InputSidebarSchema.d.ts +10 -10
  20. package/dist/config/validators/validate.d.ts +148 -117
  21. package/dist/config/validators/validate.js +13 -6
  22. package/dist/config/validators/validate.js.map +1 -1
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.js +1 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/lib/authentication/AuthenticationPlugin.d.ts +4 -2
  27. package/dist/lib/authentication/AuthenticationPlugin.js +3 -0
  28. package/dist/lib/authentication/AuthenticationPlugin.js.map +1 -1
  29. package/dist/lib/authentication/authentication.d.ts +3 -3
  30. package/dist/lib/authentication/hook.d.ts +5 -4
  31. package/dist/lib/authentication/hook.js +1 -3
  32. package/dist/lib/authentication/hook.js.map +1 -1
  33. package/dist/lib/authentication/providers/auth0.js +12 -11
  34. package/dist/lib/authentication/providers/auth0.js.map +1 -1
  35. package/dist/lib/authentication/providers/openid.d.ts +0 -1
  36. package/dist/lib/authentication/providers/openid.js +11 -26
  37. package/dist/lib/authentication/providers/openid.js.map +1 -1
  38. package/dist/lib/authentication/state.d.ts +25 -4
  39. package/dist/lib/authentication/state.js +28 -3
  40. package/dist/lib/authentication/state.js.map +1 -1
  41. package/dist/lib/authentication/use-broadcast/shared.d.ts +48 -0
  42. package/dist/lib/authentication/use-broadcast/shared.js +243 -0
  43. package/dist/lib/authentication/use-broadcast/shared.js.map +1 -0
  44. package/dist/lib/authentication/use-broadcast/useBroadcast.d.ts +24 -0
  45. package/dist/lib/authentication/use-broadcast/useBroadcast.js +106 -0
  46. package/dist/lib/authentication/use-broadcast/useBroadcast.js.map +1 -0
  47. package/dist/lib/components/Bootstrap.d.ts +3 -1
  48. package/dist/lib/components/Bootstrap.js +10 -4
  49. package/dist/lib/components/Bootstrap.js.map +1 -1
  50. package/dist/lib/components/ClientOnly.d.ts +4 -2
  51. package/dist/lib/components/ClientOnly.js +1 -1
  52. package/dist/lib/components/ClientOnly.js.map +1 -1
  53. package/dist/lib/components/DeveloperHint.js +2 -1
  54. package/dist/lib/components/DeveloperHint.js.map +1 -1
  55. package/dist/lib/components/Header.js +16 -10
  56. package/dist/lib/components/Header.js.map +1 -1
  57. package/dist/lib/components/Heading.d.ts +1 -1
  58. package/dist/lib/components/Layout.js +12 -4
  59. package/dist/lib/components/Layout.js.map +1 -1
  60. package/dist/lib/components/MobileTopNavigation.js +6 -7
  61. package/dist/lib/components/MobileTopNavigation.js.map +1 -1
  62. package/dist/lib/components/SyntaxHighlight.js +16 -12
  63. package/dist/lib/components/SyntaxHighlight.js.map +1 -1
  64. package/dist/lib/components/ThemeSwitch.d.ts +1 -0
  65. package/dist/lib/components/ThemeSwitch.js +13 -0
  66. package/dist/lib/components/ThemeSwitch.js.map +1 -0
  67. package/dist/lib/components/TopNavigation.d.ts +2 -0
  68. package/dist/lib/components/TopNavigation.js +13 -7
  69. package/dist/lib/components/TopNavigation.js.map +1 -1
  70. package/dist/lib/components/{DevPortal.d.ts → Zudoku.d.ts} +3 -3
  71. package/dist/lib/components/{DevPortal.js → Zudoku.js} +13 -14
  72. package/dist/lib/components/Zudoku.js.map +1 -0
  73. package/dist/lib/components/context/ZudokuContext.d.ts +7 -7
  74. package/dist/lib/components/context/ZudokuContext.js +8 -13
  75. package/dist/lib/components/context/ZudokuContext.js.map +1 -1
  76. package/dist/lib/components/context/ZudokuProvider.d.ts +2 -2
  77. package/dist/lib/components/context/ZudokuProvider.js.map +1 -1
  78. package/dist/lib/components/index.d.ts +18 -10
  79. package/dist/lib/components/index.js +2 -3
  80. package/dist/lib/components/index.js.map +1 -1
  81. package/dist/lib/components/navigation/Sidebar.js +1 -1
  82. package/dist/lib/components/navigation/Sidebar.js.map +1 -1
  83. package/dist/lib/components/navigation/utils.js +2 -2
  84. package/dist/lib/components/navigation/utils.js.map +1 -1
  85. package/dist/lib/core/{DevPortalContext.d.ts → ZudokuContext.d.ts} +3 -7
  86. package/dist/lib/core/{DevPortalContext.js → ZudokuContext.js} +2 -7
  87. package/dist/lib/core/ZudokuContext.js.map +1 -0
  88. package/dist/lib/core/plugins.d.ts +18 -12
  89. package/dist/lib/core/plugins.js.map +1 -1
  90. package/dist/lib/errors/ErrorAlert.js +1 -1
  91. package/dist/lib/errors/ErrorAlert.js.map +1 -1
  92. package/dist/lib/oas/graphql/index.js +4 -4
  93. package/dist/lib/oas/graphql/index.js.map +1 -1
  94. package/dist/lib/oas/parser/upgrade/index.d.ts +2 -2
  95. package/dist/lib/oas/parser/upgrade/index.js +2 -17
  96. package/dist/lib/oas/parser/upgrade/index.js.map +1 -1
  97. package/dist/lib/plugins/api-keys/index.d.ts +9 -9
  98. package/dist/lib/plugins/api-keys/index.js +3 -0
  99. package/dist/lib/plugins/api-keys/index.js.map +1 -1
  100. package/dist/lib/plugins/custom-pages/index.d.ts +2 -2
  101. package/dist/lib/plugins/custom-pages/index.js.map +1 -1
  102. package/dist/lib/plugins/markdown/MdxPage.d.ts +9 -1
  103. package/dist/lib/plugins/markdown/MdxPage.js +14 -1
  104. package/dist/lib/plugins/markdown/MdxPage.js.map +1 -1
  105. package/dist/lib/plugins/markdown/index.d.ts +2 -2
  106. package/dist/lib/plugins/markdown/index.js +1 -1
  107. package/dist/lib/plugins/markdown/index.js.map +1 -1
  108. package/dist/lib/plugins/openapi/CollapsibleCode.d.ts +5 -0
  109. package/dist/lib/plugins/openapi/CollapsibleCode.js +24 -0
  110. package/dist/lib/plugins/openapi/CollapsibleCode.js.map +1 -0
  111. package/dist/lib/plugins/openapi/ColorizedParam.js +13 -9
  112. package/dist/lib/plugins/openapi/ColorizedParam.js.map +1 -1
  113. package/dist/lib/plugins/openapi/Endpoint.d.ts +1 -1
  114. package/dist/lib/plugins/openapi/Endpoint.js +5 -9
  115. package/dist/lib/plugins/openapi/Endpoint.js.map +1 -1
  116. package/dist/lib/plugins/openapi/OperationList.d.ts +2 -2
  117. package/dist/lib/plugins/openapi/OperationList.js +21 -22
  118. package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
  119. package/dist/lib/plugins/openapi/ParameterListItem.js +6 -1
  120. package/dist/lib/plugins/openapi/ParameterListItem.js.map +1 -1
  121. package/dist/lib/plugins/openapi/RequestBodySidecarBox.js +7 -3
  122. package/dist/lib/plugins/openapi/RequestBodySidecarBox.js.map +1 -1
  123. package/dist/lib/plugins/openapi/ResponsesSidecarBox.js +9 -2
  124. package/dist/lib/plugins/openapi/ResponsesSidecarBox.js.map +1 -1
  125. package/dist/lib/plugins/openapi/Route.d.ts +4 -4
  126. package/dist/lib/plugins/openapi/Route.js +2 -4
  127. package/dist/lib/plugins/openapi/Route.js.map +1 -1
  128. package/dist/lib/plugins/openapi/Sidecar.d.ts +1 -1
  129. package/dist/lib/plugins/openapi/Sidecar.js +35 -33
  130. package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
  131. package/dist/lib/plugins/openapi/client/GraphQLClient.d.ts +8 -0
  132. package/dist/lib/plugins/openapi/client/GraphQLClient.js +114 -0
  133. package/dist/lib/plugins/openapi/client/GraphQLClient.js.map +1 -0
  134. package/dist/lib/plugins/openapi/client/GraphQLContext.d.ts +7 -0
  135. package/dist/lib/plugins/openapi/client/GraphQLContext.js +5 -0
  136. package/dist/lib/plugins/openapi/client/GraphQLContext.js.map +1 -0
  137. package/dist/lib/plugins/openapi/client/createServer.d.ts +1 -0
  138. package/dist/lib/plugins/openapi/client/useCreateQuery.d.ts +5 -0
  139. package/dist/lib/plugins/openapi/client/useCreateQuery.js +15 -0
  140. package/dist/lib/plugins/openapi/client/useCreateQuery.js.map +1 -0
  141. package/dist/lib/plugins/openapi/client/worker.d.ts +4 -1
  142. package/dist/lib/plugins/openapi/client/worker.js +23 -14
  143. package/dist/lib/plugins/openapi/client/worker.js.map +1 -1
  144. package/dist/lib/plugins/openapi/graphql/fragment-masking.d.ts +3 -3
  145. package/dist/lib/plugins/openapi/graphql/fragment-masking.js +3 -4
  146. package/dist/lib/plugins/openapi/graphql/fragment-masking.js.map +1 -1
  147. package/dist/lib/plugins/openapi/graphql/gql.d.ts +5 -51
  148. package/dist/lib/plugins/openapi/graphql/gql.js +4 -2
  149. package/dist/lib/plugins/openapi/graphql/gql.js.map +1 -1
  150. package/dist/lib/plugins/openapi/graphql/graphql.d.ts +32 -8
  151. package/dist/lib/plugins/openapi/graphql/graphql.js +194 -662
  152. package/dist/lib/plugins/openapi/graphql/graphql.js.map +1 -1
  153. package/dist/lib/plugins/openapi/index.d.ts +2 -2
  154. package/dist/lib/plugins/openapi/index.js +40 -53
  155. package/dist/lib/plugins/openapi/index.js.map +1 -1
  156. package/dist/lib/plugins/openapi/interfaces.d.ts +1 -1
  157. package/dist/lib/plugins/openapi/post-processors/removeExtensions.d.ts +6 -0
  158. package/dist/lib/plugins/openapi/post-processors/removeExtensions.js +14 -0
  159. package/dist/lib/plugins/openapi/post-processors/removeExtensions.js.map +1 -0
  160. package/dist/lib/plugins/openapi/post-processors/removeExtensions.test.d.ts +1 -0
  161. package/dist/lib/plugins/openapi/post-processors/removeExtensions.test.js +125 -0
  162. package/dist/lib/plugins/openapi/post-processors/removeExtensions.test.js.map +1 -0
  163. package/dist/lib/plugins/openapi/post-processors/removePaths.d.ts +11 -0
  164. package/dist/lib/plugins/openapi/post-processors/removePaths.js +33 -0
  165. package/dist/lib/plugins/openapi/post-processors/removePaths.js.map +1 -0
  166. package/dist/lib/plugins/openapi/post-processors/removePaths.test.d.ts +1 -0
  167. package/dist/lib/plugins/openapi/post-processors/removePaths.test.js +104 -0
  168. package/dist/lib/plugins/openapi/post-processors/removePaths.test.js.map +1 -0
  169. package/dist/lib/plugins/openapi/post-processors/traverse.d.ts +1 -0
  170. package/dist/lib/plugins/openapi/post-processors/traverse.js +2 -0
  171. package/dist/lib/plugins/openapi/post-processors/traverse.js.map +1 -0
  172. package/dist/lib/plugins/openapi/schema/SchemaView.js +2 -1
  173. package/dist/lib/plugins/openapi/schema/SchemaView.js.map +1 -1
  174. package/dist/lib/plugins/openapi/util/generateSchemaExample.d.ts +0 -1
  175. package/dist/lib/plugins/openapi/util/generateSchemaExample.js +25 -36
  176. package/dist/lib/plugins/openapi/util/generateSchemaExample.js.map +1 -1
  177. package/dist/lib/plugins/openapi-worker.d.ts +1 -1
  178. package/dist/lib/plugins/openapi-worker.js +7 -1
  179. package/dist/lib/plugins/openapi-worker.js.map +1 -1
  180. package/dist/lib/plugins/redirect/index.d.ts +4 -7
  181. package/dist/lib/plugins/redirect/index.js +1 -1
  182. package/dist/lib/plugins/redirect/index.js.map +1 -1
  183. package/dist/lib/plugins/search-inkeep/index.d.ts +2 -2
  184. package/dist/lib/plugins/search-inkeep/index.js.map +1 -1
  185. package/dist/lib/ui/ActionButton.d.ts +4 -0
  186. package/dist/lib/ui/ActionButton.js +10 -0
  187. package/dist/lib/ui/ActionButton.js.map +1 -0
  188. package/dist/lib/util/MdxComponents.d.ts +1 -1
  189. package/dist/lib/util/traverse.d.ts +2 -0
  190. package/dist/lib/util/traverse.js +18 -0
  191. package/dist/lib/util/traverse.js.map +1 -0
  192. package/dist/lib/util/useIsomorphicLayoutEffect.d.ts +3 -0
  193. package/dist/lib/util/useIsomorphicLayoutEffect.js +4 -0
  194. package/dist/lib/util/useIsomorphicLayoutEffect.js.map +1 -0
  195. package/dist/lib/util/useOnScreen.d.ts +4 -0
  196. package/dist/lib/util/useOnScreen.js +19 -0
  197. package/dist/lib/util/useOnScreen.js.map +1 -0
  198. package/dist/vite/build.js +5 -1
  199. package/dist/vite/build.js.map +1 -1
  200. package/dist/vite/config.d.ts +2 -8
  201. package/dist/vite/config.js +25 -54
  202. package/dist/vite/config.js.map +1 -1
  203. package/dist/vite/config.test.js +3 -4
  204. package/dist/vite/config.test.js.map +1 -1
  205. package/dist/vite/html.js +0 -2
  206. package/dist/vite/html.js.map +1 -1
  207. package/dist/vite/output.d.ts +101 -0
  208. package/dist/vite/output.js +53 -0
  209. package/dist/vite/output.js.map +1 -0
  210. package/dist/vite/plugin-api.js +23 -19
  211. package/dist/vite/plugin-api.js.map +1 -1
  212. package/dist/vite/plugin-component.js +14 -19
  213. package/dist/vite/plugin-component.js.map +1 -1
  214. package/dist/vite/plugin-config.d.ts +2 -3
  215. package/dist/vite/plugin-config.js +2 -3
  216. package/dist/vite/plugin-config.js.map +1 -1
  217. package/dist/vite/plugin-docs.test.js +15 -23
  218. package/dist/vite/plugin-docs.test.js.map +1 -1
  219. package/dist/vite/plugin-mdx.d.ts +0 -6
  220. package/dist/vite/plugin-mdx.js +13 -5
  221. package/dist/vite/plugin-mdx.js.map +1 -1
  222. package/dist/vite/plugin.js +1 -3
  223. package/dist/vite/plugin.js.map +1 -1
  224. package/dist/vite/prerender.js +3 -2
  225. package/dist/vite/prerender.js.map +1 -1
  226. package/dist/vite/remarkStaticGeneration.d.ts +3 -0
  227. package/dist/vite/remarkStaticGeneration.js +125 -0
  228. package/dist/vite/remarkStaticGeneration.js.map +1 -0
  229. package/dist/zuplo/with-zuplo.d.ts +3 -0
  230. package/dist/zuplo/with-zuplo.js +28 -0
  231. package/dist/zuplo/with-zuplo.js.map +1 -0
  232. package/lib/{AnchorLink-BbB2q-jx.js → AnchorLink-CDlhr8gL.js} +11 -10
  233. package/lib/{AnchorLink-BbB2q-jx.js.map → AnchorLink-CDlhr8gL.js.map} +1 -1
  234. package/lib/AuthenticationPlugin-D0Em0SwR.js +59 -0
  235. package/lib/{AuthenticationPlugin-C9BHGXlE.js.map → AuthenticationPlugin-D0Em0SwR.js.map} +1 -1
  236. package/lib/Button-jK0EsymC.js +48 -0
  237. package/lib/Button-jK0EsymC.js.map +1 -0
  238. package/lib/{ClientOnly-CVN6leDu.js → ClientOnly-E7hGysn1.js} +4 -4
  239. package/lib/ClientOnly-E7hGysn1.js.map +1 -0
  240. package/lib/Markdown-ievDDhFT.js +15192 -0
  241. package/lib/Markdown-ievDDhFT.js.map +1 -0
  242. package/lib/MdxPage-B2FpJ9KC.js +183 -0
  243. package/lib/MdxPage-B2FpJ9KC.js.map +1 -0
  244. package/lib/OperationList-BkNQEsNs.js +4693 -0
  245. package/lib/OperationList-BkNQEsNs.js.map +1 -0
  246. package/lib/Route-DlG_HTMu.js +11 -0
  247. package/lib/Route-DlG_HTMu.js.map +1 -0
  248. package/lib/{Select-Bagt3Bme.js → Select-O9ZM3ZgX.js} +7 -7
  249. package/lib/Select-O9ZM3ZgX.js.map +1 -0
  250. package/lib/{Spinner-C6zroowC.js → SidebarBadge-DxFJcJ6V.js} +28 -17
  251. package/lib/SidebarBadge-DxFJcJ6V.js.map +1 -0
  252. package/lib/SlotletProvider-DyomlzGx.js +252 -0
  253. package/lib/SlotletProvider-DyomlzGx.js.map +1 -0
  254. package/lib/Spinner-3cQDBVGr.js +7 -0
  255. package/lib/Spinner-3cQDBVGr.js.map +1 -0
  256. package/lib/SyntaxHighlight-DkLOsjHS.js +2983 -0
  257. package/lib/SyntaxHighlight-DkLOsjHS.js.map +1 -0
  258. package/lib/assets/{worker-Bf8vjASY.js → worker-BHClFO3A.js} +156 -156
  259. package/lib/assets/worker-BHClFO3A.js.map +1 -0
  260. package/lib/context-D1nXWxm7.js +22 -0
  261. package/lib/context-D1nXWxm7.js.map +1 -0
  262. package/lib/createServer-CpJlUPtn.js +15299 -0
  263. package/lib/createServer-CpJlUPtn.js.map +1 -0
  264. package/lib/{hook-sn0zMTkE.js → hook-hEqe7fPB.js} +12 -14
  265. package/lib/hook-hEqe7fPB.js.map +1 -0
  266. package/lib/index-C7SaIME0.js +1277 -0
  267. package/lib/index-C7SaIME0.js.map +1 -0
  268. package/lib/index-Czzd9rjU.js +899 -0
  269. package/lib/index-Czzd9rjU.js.map +1 -0
  270. package/lib/index-Yn8c3UWE.js +921 -0
  271. package/lib/index-Yn8c3UWE.js.map +1 -0
  272. package/lib/object_hash-CvlLgU-M.js +785 -0
  273. package/lib/object_hash-CvlLgU-M.js.map +1 -0
  274. package/lib/post-processors/removeExtensions.js +11 -0
  275. package/lib/post-processors/removeExtensions.js.map +1 -0
  276. package/lib/post-processors/removePaths.js +28 -0
  277. package/lib/post-processors/removePaths.js.map +1 -0
  278. package/lib/post-processors/traverse.js +12 -0
  279. package/lib/post-processors/traverse.js.map +1 -0
  280. package/lib/{router-BsfSoK2j.js → router-lfyopgBI.js} +23 -23
  281. package/lib/{router-BsfSoK2j.js.map → router-lfyopgBI.js.map} +1 -1
  282. package/lib/state-tsXBLONe.js +203 -0
  283. package/lib/{state-CsuHT8ZO.js.map → state-tsXBLONe.js.map} +1 -1
  284. package/lib/ui/ActionButton.js +25 -0
  285. package/lib/ui/ActionButton.js.map +1 -0
  286. package/lib/useExposedProps-CTPtylCV.js +10 -0
  287. package/lib/{useExposedProps-ChOIUaS4.js.map → useExposedProps-CTPtylCV.js.map} +1 -1
  288. package/lib/{ZudokuContext-BKXGJTmu.js → utils-DcpDOncX.js} +242 -246
  289. package/lib/utils-DcpDOncX.js.map +1 -0
  290. package/lib/zudoku.auth-auth0.js +24 -18
  291. package/lib/zudoku.auth-auth0.js.map +1 -1
  292. package/lib/zudoku.auth-clerk.js +2 -2
  293. package/lib/zudoku.auth-openid.js +124 -138
  294. package/lib/zudoku.auth-openid.js.map +1 -1
  295. package/lib/zudoku.components.js +1291 -1119
  296. package/lib/zudoku.components.js.map +1 -1
  297. package/lib/zudoku.openapi-worker.js +10 -16336
  298. package/lib/zudoku.openapi-worker.js.map +1 -1
  299. package/lib/zudoku.plugin-api-keys.js +41 -39
  300. package/lib/zudoku.plugin-api-keys.js.map +1 -1
  301. package/lib/zudoku.plugin-custom-pages.js +2 -2
  302. package/lib/zudoku.plugin-custom-pages.js.map +1 -1
  303. package/lib/zudoku.plugin-markdown.js +15 -14
  304. package/lib/zudoku.plugin-markdown.js.map +1 -1
  305. package/lib/zudoku.plugin-openapi.js +5 -9
  306. package/lib/zudoku.plugin-openapi.js.map +1 -1
  307. package/lib/zudoku.plugin-redirect.js +2 -2
  308. package/lib/zudoku.plugin-redirect.js.map +1 -1
  309. package/lib/zudoku.plugin-search-inkeep.js +1 -1
  310. package/lib/zudoku.plugin-search-inkeep.js.map +1 -1
  311. package/package.json +27 -7
  312. package/src/app/demo.tsx +0 -3
  313. package/src/app/entry.client.tsx +14 -0
  314. package/src/app/entry.server.tsx +59 -53
  315. package/src/app/main.css +1 -1
  316. package/src/app/main.tsx +4 -4
  317. package/src/app/standalone.tsx +0 -3
  318. package/src/lib/authentication/AuthenticationPlugin.tsx +4 -1
  319. package/src/lib/authentication/authentication.ts +3 -3
  320. package/src/lib/authentication/hook.ts +1 -3
  321. package/src/lib/authentication/providers/auth0.tsx +17 -11
  322. package/src/lib/authentication/providers/openid.tsx +12 -30
  323. package/src/lib/authentication/state.ts +50 -9
  324. package/{LICENSE.md → src/lib/authentication/use-broadcast/LICENSE.md} +2 -2
  325. package/src/lib/authentication/use-broadcast/shared.ts +372 -0
  326. package/src/lib/authentication/use-broadcast/useBroadcast.ts +146 -0
  327. package/src/lib/components/Bootstrap.tsx +36 -14
  328. package/src/lib/components/ClientOnly.tsx +6 -3
  329. package/src/lib/components/DeveloperHint.tsx +6 -1
  330. package/src/lib/components/Header.tsx +68 -40
  331. package/src/lib/components/Layout.tsx +49 -37
  332. package/src/lib/components/MobileTopNavigation.tsx +15 -18
  333. package/src/lib/components/SyntaxHighlight.tsx +81 -46
  334. package/src/lib/components/ThemeSwitch.tsx +26 -0
  335. package/src/lib/components/TopNavigation.tsx +27 -19
  336. package/src/lib/components/Zudoku.tsx +108 -0
  337. package/src/lib/components/context/ZudokuContext.ts +11 -16
  338. package/src/lib/components/context/ZudokuProvider.tsx +2 -2
  339. package/src/lib/components/index.ts +2 -3
  340. package/src/lib/components/navigation/Sidebar.tsx +3 -3
  341. package/src/lib/components/navigation/utils.ts +2 -2
  342. package/src/lib/core/{DevPortalContext.ts → ZudokuContext.ts} +3 -11
  343. package/src/lib/core/plugins.ts +20 -16
  344. package/src/lib/errors/ErrorAlert.tsx +2 -1
  345. package/src/lib/oas/graphql/index.ts +4 -4
  346. package/src/lib/oas/parser/upgrade/index.ts +3 -24
  347. package/src/lib/plugins/api-keys/index.tsx +12 -9
  348. package/src/lib/plugins/custom-pages/index.tsx +2 -2
  349. package/src/lib/plugins/markdown/MdxPage.tsx +25 -1
  350. package/src/lib/plugins/markdown/index.tsx +3 -2
  351. package/src/lib/plugins/openapi/CollapsibleCode.tsx +80 -0
  352. package/src/lib/plugins/openapi/ColorizedParam.tsx +23 -14
  353. package/src/lib/plugins/openapi/Endpoint.tsx +5 -10
  354. package/src/lib/plugins/openapi/OperationList.tsx +20 -40
  355. package/src/lib/plugins/openapi/ParameterListItem.tsx +37 -31
  356. package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +18 -13
  357. package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +17 -12
  358. package/src/lib/plugins/openapi/Route.tsx +11 -12
  359. package/src/lib/plugins/openapi/Sidecar.tsx +73 -59
  360. package/src/lib/plugins/openapi/client/GraphQLClient.tsx +157 -0
  361. package/src/lib/plugins/openapi/client/GraphQLContext.tsx +16 -0
  362. package/src/lib/plugins/openapi/client/createServer.ts +2 -0
  363. package/src/lib/plugins/openapi/client/useCreateQuery.ts +21 -0
  364. package/src/lib/plugins/openapi/client/worker.ts +38 -24
  365. package/src/lib/plugins/openapi/graphql/fragment-masking.ts +11 -18
  366. package/src/lib/plugins/openapi/graphql/gql.ts +10 -27
  367. package/src/lib/plugins/openapi/graphql/graphql.ts +233 -665
  368. package/src/lib/plugins/openapi/index.tsx +42 -67
  369. package/src/lib/plugins/openapi/interfaces.ts +1 -1
  370. package/src/lib/plugins/openapi/post-processors/removeExtensions.test.ts +144 -0
  371. package/src/lib/plugins/openapi/post-processors/removeExtensions.ts +24 -0
  372. package/src/lib/plugins/openapi/post-processors/removePaths.test.ts +126 -0
  373. package/src/lib/plugins/openapi/post-processors/removePaths.ts +55 -0
  374. package/src/lib/plugins/openapi/post-processors/traverse.ts +1 -0
  375. package/src/lib/plugins/openapi/schema/SchemaView.tsx +5 -2
  376. package/src/lib/plugins/openapi/util/generateSchemaExample.ts +28 -42
  377. package/src/lib/plugins/openapi-worker.ts +11 -1
  378. package/src/lib/plugins/redirect/index.tsx +5 -9
  379. package/src/lib/plugins/search-inkeep/index.tsx +2 -2
  380. package/src/lib/ui/ActionButton.tsx +28 -0
  381. package/src/lib/util/traverse.ts +25 -0
  382. package/src/lib/util/useIsomorphicLayoutEffect.ts +5 -0
  383. package/src/lib/util/useOnScreen.ts +32 -0
  384. package/dist/lib/components/DevPortal.js.map +0 -1
  385. package/dist/lib/components/context/ThemeContext.d.ts +0 -2
  386. package/dist/lib/components/context/ThemeContext.js +0 -7
  387. package/dist/lib/components/context/ThemeContext.js.map +0 -1
  388. package/dist/lib/components/context/ThemeProvider.d.ts +0 -4
  389. package/dist/lib/components/context/ThemeProvider.js +0 -23
  390. package/dist/lib/components/context/ThemeProvider.js.map +0 -1
  391. package/dist/lib/core/DevPortalContext.js.map +0 -1
  392. package/dist/lib/plugins/openapi/client/createMemoryClient.d.ts +0 -12
  393. package/dist/lib/plugins/openapi/client/createMemoryClient.js +0 -46
  394. package/dist/lib/plugins/openapi/client/createMemoryClient.js.map +0 -1
  395. package/dist/lib/plugins/openapi/client/createWorkerClient.d.ts +0 -10
  396. package/dist/lib/plugins/openapi/client/createWorkerClient.js +0 -61
  397. package/dist/lib/plugins/openapi/client/createWorkerClient.js.map +0 -1
  398. package/dist/lib/plugins/openapi/client/interfaces.d.ts +0 -4
  399. package/dist/lib/plugins/openapi/client/interfaces.js +0 -2
  400. package/dist/lib/plugins/openapi/client/interfaces.js.map +0 -1
  401. package/dist/lib/themeToggle.d.ts +0 -1
  402. package/dist/lib/themeToggle.js +0 -7
  403. package/dist/lib/themeToggle.js.map +0 -1
  404. package/dist/lib/util/createWaitForNotify.d.ts +0 -1
  405. package/dist/lib/util/createWaitForNotify.js +0 -15
  406. package/dist/lib/util/createWaitForNotify.js.map +0 -1
  407. package/dist/vite/plugin-html-transform.d.ts +0 -2
  408. package/dist/vite/plugin-html-transform.js +0 -15
  409. package/dist/vite/plugin-html-transform.js.map +0 -1
  410. package/lib/AuthenticationPlugin-C9BHGXlE.js +0 -55
  411. package/lib/ClientOnly-CVN6leDu.js.map +0 -1
  412. package/lib/DeveloperHint-DHdLXGHA.js +0 -16
  413. package/lib/DeveloperHint-DHdLXGHA.js.map +0 -1
  414. package/lib/Markdown-BDcCAWwm.js +0 -18059
  415. package/lib/Markdown-BDcCAWwm.js.map +0 -1
  416. package/lib/MdxPage-DKMH_t0f.js +0 -174
  417. package/lib/MdxPage-DKMH_t0f.js.map +0 -1
  418. package/lib/OperationList-Tj7ubW_t.js +0 -604
  419. package/lib/OperationList-Tj7ubW_t.js.map +0 -1
  420. package/lib/Route-C3DGB6OS.js +0 -13
  421. package/lib/Route-C3DGB6OS.js.map +0 -1
  422. package/lib/Select-Bagt3Bme.js.map +0 -1
  423. package/lib/SlotletProvider-Da7eFgd2.js +0 -241
  424. package/lib/SlotletProvider-Da7eFgd2.js.map +0 -1
  425. package/lib/Spinner-C6zroowC.js.map +0 -1
  426. package/lib/StaggeredRender-DDHSzQKE.js +0 -17
  427. package/lib/StaggeredRender-DDHSzQKE.js.map +0 -1
  428. package/lib/ZudokuContext-BKXGJTmu.js.map +0 -1
  429. package/lib/assets/worker-Bf8vjASY.js.map +0 -1
  430. package/lib/hook-sn0zMTkE.js.map +0 -1
  431. package/lib/index-AjWCJNGC.js +0 -5690
  432. package/lib/index-AjWCJNGC.js.map +0 -1
  433. package/lib/index-CRo94sKK.js +0 -1783
  434. package/lib/index-CRo94sKK.js.map +0 -1
  435. package/lib/state-CsuHT8ZO.js +0 -183
  436. package/lib/urql-core-KJnLL26g.js +0 -1455
  437. package/lib/urql-core-KJnLL26g.js.map +0 -1
  438. package/lib/useExposedProps-ChOIUaS4.js +0 -9
  439. package/src/lib/components/DevPortal.tsx +0 -111
  440. package/src/lib/components/context/ThemeContext.tsx +0 -8
  441. package/src/lib/components/context/ThemeProvider.tsx +0 -27
  442. package/src/lib/plugins/openapi/client/createMemoryClient.ts +0 -51
  443. package/src/lib/plugins/openapi/client/createWorkerClient.ts +0 -75
  444. package/src/lib/plugins/openapi/client/interfaces.ts +0 -5
  445. package/src/lib/themeToggle.ts +0 -7
  446. package/src/lib/util/createWaitForNotify.ts +0 -18
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zudoku",
3
- "version": "0.0.0-f865d81",
3
+ "version": "0.0.0-fa903e7",
4
4
  "type": "module",
5
5
  "homepage": "https://zudoku.dev",
6
6
  "repository": {
@@ -82,6 +82,10 @@
82
82
  "import": "./lib/zudoku.components.js",
83
83
  "types": "./dist/lib/components/index.d.ts"
84
84
  },
85
+ "./post-processors/*": {
86
+ "import": "./lib/post-processors/*.js",
87
+ "types": "./dist/lib/plugins/openapi/post-processors/*.d.ts"
88
+ },
85
89
  "./icons": {
86
90
  "import": "./lib/zudoku.icons.js",
87
91
  "types": "./dist/lib/icons.d.ts"
@@ -100,6 +104,10 @@
100
104
  },
101
105
  "./app/*": {
102
106
  "import": "./src/app/*"
107
+ },
108
+ "./with-zuplo": {
109
+ "require": "./dist/zuplo/with-zuplo.js",
110
+ "import": "./dist/zuplo/with-zuplo.js"
103
111
  }
104
112
  },
105
113
  "dependencies": {
@@ -123,7 +131,7 @@
123
131
  "@radix-ui/react-popover": "1.1.2",
124
132
  "@radix-ui/react-progress": "1.1.0",
125
133
  "@radix-ui/react-radio-group": "1.2.1",
126
- "@radix-ui/react-scroll-area": "1.2.0",
134
+ "@radix-ui/react-scroll-area": "1.2.1",
127
135
  "@radix-ui/react-select": "2.1.2",
128
136
  "@radix-ui/react-slider": "1.2.1",
129
137
  "@radix-ui/react-slot": "1.1.0",
@@ -137,10 +145,11 @@
137
145
  "@sindresorhus/slugify": "2.2.1",
138
146
  "@stefanprobst/rehype-extract-toc": "2.2.0",
139
147
  "@tailwindcss/typography": "0.5.15",
140
- "@tanstack/react-query": "5.59.13",
148
+ "@tanstack/react-query": "5.61.0",
141
149
  "@types/react": "18.3.11",
142
150
  "@types/react-dom": "18.3.1",
143
- "@vitejs/plugin-react": "4.3.1",
151
+ "@vitejs/plugin-react": "4.3.4",
152
+ "@zudoku/config": "0.0.0-fa903e7",
144
153
  "@zudoku/httpsnippet": "10.0.9",
145
154
  "@zudoku/react-helmet-async": "2.0.4",
146
155
  "autoprefixer": "10.4.20",
@@ -150,6 +159,7 @@
150
159
  "cmdk": "1.0.4",
151
160
  "dotenv": "16.4.5",
152
161
  "embla-carousel-react": "8.3.1",
162
+ "estree-util-value-to-estree": "3.2.1",
153
163
  "express": "4.21.1",
154
164
  "glob": "11.0.0",
155
165
  "graphql": "16.9.0",
@@ -160,6 +170,7 @@
160
170
  "loglevel": "1.9.2",
161
171
  "lru-cache": "11.0.1",
162
172
  "lucide-react": "0.452.0",
173
+ "next-themes": "0.4.3",
163
174
  "oauth4webapi": "2.17.0",
164
175
  "object-hash": "3.0.0",
165
176
  "openapi-types": "12.1.3",
@@ -184,14 +195,15 @@
184
195
  "rollup": "4.24.0",
185
196
  "semver": "7.6.3",
186
197
  "sitemap": "8.0.0",
198
+ "spin-delay": "2.0.1",
187
199
  "strip-ansi": "7.1.0",
188
200
  "tailwind-merge": "2.5.4",
189
201
  "tailwindcss": "3.4.13",
190
- "tsx": "4.19.1",
191
202
  "ulidx": "2.4.1",
192
203
  "unist-util-visit": "5.0.0",
193
204
  "urql": "4.1.0",
194
205
  "vaul": "1.1.0",
206
+ "vfile": "6.0.3",
195
207
  "vite": "5.4.9",
196
208
  "yaml": "2.6.0",
197
209
  "yargs": "17.7.2",
@@ -200,19 +212,26 @@
200
212
  "zustand": "5.0.0"
201
213
  },
202
214
  "devDependencies": {
215
+ "@graphql-codegen/cli": "5.0.3",
216
+ "@graphql-codegen/client-preset": "4.5.0",
217
+ "@types/estree": "1.0.6",
203
218
  "@types/express": "5.0.0",
204
219
  "@types/har-format": "1.2.15",
205
220
  "@types/json-schema": "7.0.15",
221
+ "@types/mdast": "4.0.4",
206
222
  "@types/mdx": "2.0.13",
207
223
  "@types/node": "20.16.11",
208
224
  "@types/object-hash": "3.0.6",
209
225
  "@types/react-is": "18.3.0",
210
226
  "@types/semver": "7.5.8",
211
227
  "@types/yargs": "17.0.33",
228
+ "@vitest/coverage-v8": "2.1.8",
229
+ "mdast-util-mdx": "3.0.0",
212
230
  "react": "18.3.1",
213
231
  "react-dom": "18.3.1",
214
232
  "rollup-plugin-visualizer": "5.12.0",
215
- "typescript": "5.6.3"
233
+ "typescript": "5.7.2",
234
+ "vitest": "2.1.8"
216
235
  },
217
236
  "peerDependencies": {
218
237
  "react": ">=18",
@@ -229,7 +248,8 @@
229
248
  "build:standalone:html": "cp ./src/app/standalone.html ./standalone/standalone.html && cp ./src/app/demo.html ./standalone/demo.html && cp ./src/app/demo-cdn.html ./standalone/index.html",
230
249
  "hack:fix-worker-paths": "node ./scripts/hack-worker.mjs",
231
250
  "clean": "tsc --build --clean",
232
- "test": "node --test --enable-source-maps"
251
+ "codegen": "graphql-codegen --config ./src/codegen.ts",
252
+ "test": "vitest run"
233
253
  },
234
254
  "module": "./dist/index.js",
235
255
  "types": "./dist/index.d.ts"
package/src/app/demo.tsx CHANGED
@@ -5,7 +5,6 @@ import { Bootstrap } from "zudoku/components";
5
5
  import type { ZudokuConfig } from "../config/validators/validate.js";
6
6
  import DemoAnnouncement from "../lib/demo/DemoAnnouncement.js";
7
7
  import { openApiPlugin } from "../lib/plugins/openapi/index.js";
8
- import { themeToggle } from "../lib/themeToggle.js";
9
8
  import "../lib/util/logInit.js";
10
9
  import "./main.css";
11
10
  import { getRoutesByConfig } from "./main.js";
@@ -18,8 +17,6 @@ if (!apiUrl) {
18
17
  );
19
18
  }
20
19
 
21
- themeToggle();
22
-
23
20
  logger.info(`API URL: ${apiUrl}`);
24
21
 
25
22
  const root =
@@ -38,6 +38,13 @@ async function hydrateLazyRoutes(routes: RouteObject[]) {
38
38
  function render(routes: RouteObject[]) {
39
39
  const router = createBrowserRouter(routes, {
40
40
  basename: config.basePath,
41
+ future: {
42
+ v7_relativeSplatPath: true,
43
+ v7_fetcherPersist: true,
44
+ v7_partialHydration: true,
45
+ v7_skipActionErrorRevalidation: true,
46
+ v7_normalizeFormMethod: true,
47
+ },
41
48
  });
42
49
  createRoot(root).render(<Bootstrap router={router} />);
43
50
  }
@@ -46,6 +53,13 @@ async function hydrate(routes: RouteObject[]) {
46
53
  await hydrateLazyRoutes(routes);
47
54
  const router = createBrowserRouter(routes, {
48
55
  basename: config.basePath,
56
+ future: {
57
+ v7_relativeSplatPath: true,
58
+ v7_fetcherPersist: true,
59
+ v7_partialHydration: true,
60
+ v7_skipActionErrorRevalidation: true,
61
+ v7_normalizeFormMethod: true,
62
+ },
49
63
  });
50
64
 
51
65
  hydrateRoot(root, <Bootstrap hydrate router={router} />);
@@ -1,3 +1,4 @@
1
+ import { dehydrate, QueryClient } from "@tanstack/react-query";
1
2
  import { type HelmetData } from "@zudoku/react-helmet-async";
2
3
  import type express from "express";
3
4
  import logger from "loglevel";
@@ -32,15 +33,13 @@ export const render = async ({
32
33
  const { query, dataRoutes } = createStaticHandler(routes, {
33
34
  basename: config.basePath,
34
35
  });
36
+ const queryClient = new QueryClient();
35
37
 
36
38
  const request =
37
39
  baseRequest instanceof Request
38
40
  ? baseRequest
39
41
  : createFetchRequest(baseRequest, response);
40
42
 
41
- if (!request) {
42
- throw new Error("Either fetchRequest or expressRequest must be provided");
43
- }
44
43
  const context = await query(request);
45
44
  let status = 200;
46
45
 
@@ -66,65 +65,72 @@ export const render = async ({
66
65
  const router = createStaticRouter(dataRoutes, context);
67
66
  const helmetContext = {} as HelmetData["context"];
68
67
 
69
- const { pipe } = renderToPipeableStream(
68
+ const App = (
70
69
  <BootstrapStatic
71
70
  router={router}
72
71
  context={context}
72
+ queryClient={queryClient}
73
73
  helmetContext={helmetContext}
74
- />,
75
- {
76
- onShellError(error) {
77
- response.status(500);
78
- response.set({ "Content-Type": "text/html" });
79
-
80
- const html = renderToStaticMarkup(<ServerError error={error} />);
81
-
82
- response.send(html);
83
- },
84
- // for SSG we could use onAllReady instead of onShellReady
85
- // https://react.dev/reference/react-dom/server/renderToPipeableStream#waiting-for-all-content-to-load-for-crawlers-and-static-generation
86
- onShellReady() {
87
- response.set({ "Content-Type": "text/html" });
88
- response.status(status);
89
-
90
- const transformStream = new Transform({
91
- transform(chunk, encoding, callback) {
92
- response.write(chunk, encoding);
93
- callback();
94
- },
95
- });
96
-
97
- const [htmlStart, htmlEnd] = template.split("<!--app-html-->");
98
-
99
- if (!htmlStart) {
100
- throw new Error("No <!--app-html--> found in template");
101
- }
74
+ />
75
+ );
76
+
77
+ const { pipe } = renderToPipeableStream(App, {
78
+ onShellError(error) {
79
+ response.status(500);
80
+ response.set({ "Content-Type": "text/html" });
81
+
82
+ const html = renderToStaticMarkup(<ServerError error={error} />);
83
+
84
+ response.send(html);
85
+ },
86
+ // for SSG we could use onAllReady instead of onShellReady
87
+ // https://react.dev/reference/react-dom/server/renderToPipeableStream#waiting-for-all-content-to-load-for-crawlers-and-static-generation
88
+ onAllReady() {
89
+ response.set({ "Content-Type": "text/html" });
90
+ response.status(status);
91
+
92
+ const transformStream = new Transform({
93
+ transform(chunk, encoding, callback) {
94
+ response.write(chunk, encoding);
95
+ callback();
96
+ },
97
+ });
98
+
99
+ const [htmlStart, htmlEnd] = template.split("<!--app-html-->");
100
+
101
+ if (!htmlStart) {
102
+ throw new Error("No <!--app-html--> found in template");
103
+ }
104
+
105
+ response.write(
106
+ htmlStart.replace(
107
+ "<!--app-helmet-->",
108
+ [
109
+ helmetContext.helmet.title.toString(),
110
+ helmetContext.helmet.meta.toString(),
111
+ helmetContext.helmet.link.toString(),
112
+ helmetContext.helmet.style.toString(),
113
+ helmetContext.helmet.script.toString(),
114
+ ].join("\n"),
115
+ ),
116
+ );
102
117
 
103
- response.write(
104
- htmlStart.replace(
105
- "<!--app-helmet-->",
106
- [
107
- helmetContext.helmet.title.toString(),
108
- helmetContext.helmet.meta.toString(),
109
- helmetContext.helmet.link.toString(),
110
- helmetContext.helmet.style.toString(),
111
- helmetContext.helmet.script.toString(),
112
- ].join("\n"),
118
+ transformStream.on("finish", () => {
119
+ response.end(
120
+ htmlEnd?.replace(
121
+ "</body>",
122
+ `<script>window.DATA = ${JSON.stringify(dehydrate(queryClient))}</script></body>`,
113
123
  ),
114
124
  );
125
+ });
115
126
 
116
- transformStream.on("finish", () => {
117
- response.end(htmlEnd);
118
- });
119
-
120
- pipe(transformStream);
121
- },
122
- onError(error) {
123
- status = 500;
124
- logger.error(error);
125
- },
127
+ pipe(transformStream);
126
128
  },
127
- );
129
+ onError(error) {
130
+ status = 500;
131
+ logger.error(error);
132
+ },
133
+ });
128
134
  };
129
135
 
130
136
  export function createFetchRequest(
package/src/app/main.css CHANGED
@@ -187,7 +187,7 @@
187
187
  }
188
188
 
189
189
  .scrollbar:hover {
190
- scrollbar-color: hsla(var(--border)) transparent;
190
+ scrollbar-color: var(--scrollbar-color, hsla(var(--border))) transparent;
191
191
  }
192
192
 
193
193
  .scrollbar::-webkit-scrollbar {
package/src/app/main.tsx CHANGED
@@ -8,9 +8,9 @@ import { configuredRedirectPlugin } from "virtual:zudoku-redirect-plugin";
8
8
  import { configuredSearchPlugin } from "virtual:zudoku-search-plugin";
9
9
  import { configuredSidebar } from "virtual:zudoku-sidebar";
10
10
  import "virtual:zudoku-theme.css";
11
- import { DevPortal, Layout, RouterError } from "zudoku/components";
11
+ import { Layout, RouterError, Zudoku } from "zudoku/components";
12
12
  import type { ZudokuConfig } from "../config/config.js";
13
- import type { ZudokuContextOptions } from "../lib/core/DevPortalContext.js";
13
+ import type { ZudokuContextOptions } from "../lib/core/ZudokuContext.js";
14
14
  import { isNavigationPlugin } from "../lib/core/plugins.js";
15
15
 
16
16
  export const convertZudokuConfigToOptions = (
@@ -92,9 +92,9 @@ export const getRoutesByConfig = (config: ZudokuConfig): RouteObject[] => {
92
92
  return [
93
93
  {
94
94
  element: (
95
- <DevPortal {...options}>
95
+ <Zudoku {...options}>
96
96
  <Layout />
97
- </DevPortal>
97
+ </Zudoku>
98
98
  ),
99
99
  children: [
100
100
  {
@@ -3,7 +3,6 @@ import { createBrowserRouter } from "react-router-dom";
3
3
  import { Bootstrap } from "zudoku/components";
4
4
  import type { ZudokuConfig } from "../config/validators/validate.js";
5
5
  import { openApiPlugin } from "../lib/plugins/openapi/index.js";
6
- import { themeToggle } from "../lib/themeToggle.js";
7
6
  import "../lib/util/logInit.js";
8
7
  import "./main.css";
9
8
  import { getRoutesByConfig } from "./main.js";
@@ -13,8 +12,6 @@ if (!root) {
13
12
  throw new Error("No div found with attribute data-api-url");
14
13
  }
15
14
 
16
- themeToggle();
17
-
18
15
  const apiUrl = root.getAttribute("data-api-url");
19
16
  const pageTitle = document.getElementsByTagName("title")[0]!.innerText;
20
17
  const logoUrl = root.getAttribute("data-logo-url");
@@ -1,3 +1,4 @@
1
+ import { LogOutIcon } from "lucide-react";
1
2
  import {
2
3
  CommonPlugin,
3
4
  NavigationPlugin,
@@ -32,7 +33,9 @@ export class AuthenticationPlugin implements PluginInterface {
32
33
  {
33
34
  label: "Logout",
34
35
  path: "/signout",
35
- },
36
+ category: "bottom",
37
+ icon: LogOutIcon,
38
+ } as const,
36
39
  ];
37
40
  }
38
41
  }
@@ -1,12 +1,12 @@
1
- import { DevPortalPlugin } from "../core/plugins.js";
1
+ import { ZudokuPlugin } from "../core/plugins.js";
2
2
 
3
3
  export interface AuthenticationProvider {
4
4
  signUp(options?: { redirectTo?: string }): Promise<void>;
5
5
  signIn(options?: { redirectTo?: string }): Promise<void>;
6
6
  signOut(): Promise<void>;
7
7
  getAccessToken(): Promise<string>;
8
- pageLoad?(): void;
9
- getAuthenticationPlugin?(): DevPortalPlugin;
8
+ getAuthenticationPlugin?(): ZudokuPlugin;
9
+ onPageLoad?(): void;
10
10
  }
11
11
 
12
12
  export interface AuthenticationProviderInitializer<TConfig> {
@@ -8,9 +8,7 @@ export const useAuth = () => {
8
8
 
9
9
  return {
10
10
  isAuthEnabled,
11
- isPending: authState.isPending,
12
- profile: authState.profile,
13
- isAuthenticated: Boolean(authState.profile),
11
+ ...authState,
14
12
 
15
13
  login: async () => {
16
14
  if (!isAuthEnabled) {
@@ -18,23 +18,27 @@ class Auth0AuthenticationProvider extends OpenIDAuthenticationProvider {
18
18
  url: URL,
19
19
  { isSignUp }: { isSignUp: boolean },
20
20
  ) => {
21
+ url.searchParams.set("prompt", "login");
21
22
  if (isSignUp) {
22
23
  url.searchParams.set("screen_hint", "signup");
23
24
  }
24
25
  };
25
26
 
26
27
  signOut = async (): Promise<void> => {
28
+ const as = await this.getAuthServer();
29
+ const idToken = await this.getAccessToken();
30
+
27
31
  useAuthState.setState({
28
32
  isAuthenticated: false,
29
33
  isPending: false,
30
- profile: undefined,
34
+ profile: null,
35
+ providerData: null,
31
36
  });
32
- sessionStorage.clear();
33
- const as = await this.getAuthServer();
34
37
 
35
38
  const redirectUrl = new URL(
36
39
  window.location.origin + this.logoutRedirectUrlPath,
37
40
  );
41
+
38
42
  redirectUrl.pathname = this.logoutRedirectUrlPath;
39
43
 
40
44
  // SEE: https://auth0.com/docs/authenticate/login/logout/log-users-out-of-auth0
@@ -42,22 +46,24 @@ class Auth0AuthenticationProvider extends OpenIDAuthenticationProvider {
42
46
  // Logout End Session Endpoint Discovery is enabled by default.
43
47
  // Otherwise we fallback to the old non-compliant logout
44
48
 
45
- let logoutUrl: URL;
46
49
  // The endSessionEndpoint is set, the IdP supports some form of logout,
47
50
  // so we use the IdP logout. Otherwise, just redirect the user to home
48
51
  if (as.end_session_endpoint) {
49
- logoutUrl = new URL(as.end_session_endpoint);
50
- // TODO: get id_token and set hint
51
- // const { id_token } = session;
52
- // if (id_token) {
53
- // logoutUrl.searchParams.set("id_token_hint", id_token);
54
- // }
52
+ const logoutUrl = new URL(as.end_session_endpoint);
53
+ if (idToken) {
54
+ logoutUrl.searchParams.set("id_token_hint", idToken);
55
+ }
55
56
  logoutUrl.searchParams.set(
56
57
  "post_logout_redirect_uri",
57
58
  redirectUrl.toString(),
58
59
  );
60
+
61
+ // window.location.href = logoutUrl.toString();
59
62
  } else {
60
- logoutUrl = new URL(`${this.issuer}oidc/logout`);
63
+ const logoutUrl = new URL(
64
+ `${this.issuer.replace(/\/$/, "")}/oidc/logout`,
65
+ );
66
+ // window.location.href = logoutUrl.toString();
61
67
  }
62
68
  };
63
69
  }
@@ -107,7 +107,10 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
107
107
  expiresOn: new Date(Date.now() + response.expires_in * 1000),
108
108
  tokenType: response.token_type,
109
109
  };
110
- sessionStorage.setItem("token-state", JSON.stringify(tokens));
110
+
111
+ useAuthState.setState({
112
+ providerData: tokens,
113
+ });
111
114
  }
112
115
 
113
116
  async signUp({ redirectTo }: { redirectTo?: string } = {}) {
@@ -194,14 +197,14 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
194
197
 
195
198
  async getAccessToken(): Promise<string> {
196
199
  const as = await this.getAuthServer();
197
- const tokenState = sessionStorage.getItem("token-state");
198
- if (!tokenState) {
200
+ const { providerData } = useAuthState.getState();
201
+ if (!providerData) {
199
202
  throw new AuthorizationError("User is not authenticated");
200
203
  }
204
+ const tokenState = providerData as TokenState;
201
205
 
202
- const state = JSON.parse(tokenState) as TokenState;
203
- if (state.expiresOn < new Date()) {
204
- if (!state.refreshToken) {
206
+ if (tokenState.expiresOn < new Date()) {
207
+ if (!tokenState.refreshToken) {
205
208
  await this.signIn();
206
209
  return "";
207
210
  }
@@ -209,7 +212,7 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
209
212
  const request = await oauth.refreshTokenGrantRequest(
210
213
  as,
211
214
  this.client,
212
- state.refreshToken,
215
+ tokenState.refreshToken,
213
216
  );
214
217
  const response = await oauth.processRefreshTokenResponse(
215
218
  as,
@@ -225,7 +228,7 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
225
228
 
226
229
  return response.access_token.toString();
227
230
  } else {
228
- return state.accessToken;
231
+ return tokenState.accessToken;
229
232
  }
230
233
  }
231
234
 
@@ -234,8 +237,8 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
234
237
  isAuthenticated: false,
235
238
  isPending: false,
236
239
  profile: undefined,
240
+ providerData: undefined,
237
241
  });
238
- sessionStorage.clear();
239
242
 
240
243
  const as = await this.getAuthServer();
241
244
 
@@ -342,32 +345,11 @@ export class OpenIDAuthenticationProvider implements AuthenticationProvider {
342
345
  profile,
343
346
  });
344
347
 
345
- sessionStorage.setItem(
346
- "profile-state",
347
- JSON.stringify(useAuthState.getState().profile),
348
- );
349
-
350
348
  const redirectTo = sessionStorage.getItem("redirect-to") ?? "/";
351
349
  sessionStorage.removeItem("redirect-to");
352
350
  return redirectTo;
353
351
  };
354
352
 
355
- pageLoad(): void {
356
- const profileState = sessionStorage.getItem("profile-state");
357
- if (profileState) {
358
- try {
359
- const profile = JSON.parse(profileState);
360
- useAuthState.setState({
361
- isAuthenticated: true,
362
- isPending: false,
363
- profile,
364
- });
365
- } catch (err) {
366
- logger.error("Error parsing auth state", err);
367
- }
368
- }
369
- }
370
-
371
353
  getAuthenticationPlugin() {
372
354
  // TODO: This API is a bit messy, we need to refactor auth plugins/providers
373
355
  // to remove the extra layers of abstraction.
@@ -1,15 +1,56 @@
1
- import { create } from "zustand";
2
- import { persist } from "zustand/middleware";
1
+ import { create, type Mutate, type StoreApi } from "zustand";
2
+ import { createJSONStorage, persist } from "zustand/middleware";
3
3
 
4
- export const useAuthState = create<AuthState>(() => ({
5
- isPending: false,
6
- isAuthenticated: false,
7
- }));
8
-
9
- export interface AuthState {
4
+ export interface AuthState<ProviderData = unknown> {
10
5
  isAuthenticated: boolean;
11
6
  isPending: boolean;
12
- profile?: UserProfile;
7
+ profile: UserProfile | null;
8
+ providerData: ProviderData | null;
9
+ }
10
+
11
+ export class Authentication {
12
+ async setLoggedIn(isLoggedIn: boolean) {}
13
+ async setProfile() {}
14
+ async setPersistentProviderData() {}
15
+ }
16
+
17
+ export type StoreWithPersist<T> = Mutate<
18
+ StoreApi<T>,
19
+ [["zustand/persist", unknown]]
20
+ >;
21
+
22
+ export const withStorageDOMEvents = <T>(store: StoreWithPersist<T>) => {
23
+ const storageEventCallback = (e: StorageEvent) => {
24
+ if (e.key === store.persist.getOptions().name && e.newValue) {
25
+ void store.persist.rehydrate();
26
+ }
27
+ };
28
+
29
+ window.addEventListener("storage", storageEventCallback);
30
+
31
+ return () => {
32
+ window.removeEventListener("storage", storageEventCallback);
33
+ };
34
+ };
35
+
36
+ export const useAuthState = create<AuthState>()(
37
+ persist(
38
+ (state) => ({
39
+ isAuthenticated: false,
40
+ isPending: false,
41
+ profile: null,
42
+ providerData: null,
43
+ }),
44
+ {
45
+ name: "auth-state",
46
+ storage: createJSONStorage(() => localStorage),
47
+ // partialize: (s) => ({ state: s }),
48
+ },
49
+ ),
50
+ );
51
+
52
+ if (typeof window !== "undefined") {
53
+ withStorageDOMEvents(useAuthState);
13
54
  }
14
55
 
15
56
  export interface UserProfile {
@@ -1,6 +1,6 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
- Copyright (c) Zuplo, Inc.
3
+ Copyright (c) 2023 Romain
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
6