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,372 @@
|
|
|
1
|
+
// https://github.com/Romainlg29/use-broadcast/
|
|
2
|
+
|
|
3
|
+
import { StateCreator, StoreMutatorIdentifier } from "zustand";
|
|
4
|
+
|
|
5
|
+
export type SharedOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* The name of the broadcast channel
|
|
8
|
+
* It must be unique
|
|
9
|
+
*/
|
|
10
|
+
name?: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Main timeout
|
|
14
|
+
* If the main tab / window doesn't respond in this time, this tab / window will become the main
|
|
15
|
+
* @default 100 ms
|
|
16
|
+
*/
|
|
17
|
+
mainTimeout?: number;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* If true, the store will only synchronize once with the main tab. After that, the store will be unsynchronized.
|
|
21
|
+
* @default false
|
|
22
|
+
*/
|
|
23
|
+
unsync?: boolean;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Callback when this tab / window becomes the main tab / window
|
|
27
|
+
* Triggered only in the main tab / window
|
|
28
|
+
*/
|
|
29
|
+
onBecomeMain?: (id: number) => void;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Callback when a new tab is opened / closed
|
|
33
|
+
* Triggered only in the main tab / window
|
|
34
|
+
*/
|
|
35
|
+
onTabsChange?: (ids: number[]) => void;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* The Shared type
|
|
40
|
+
*/
|
|
41
|
+
export type Shared = <
|
|
42
|
+
T,
|
|
43
|
+
Mps extends [StoreMutatorIdentifier, unknown][] = [],
|
|
44
|
+
Mcs extends [StoreMutatorIdentifier, unknown][] = [],
|
|
45
|
+
>(
|
|
46
|
+
f: StateCreator<T, Mps, Mcs>,
|
|
47
|
+
options?: SharedOptions,
|
|
48
|
+
) => StateCreator<T, Mps, Mcs>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Type implementation of the Shared function
|
|
52
|
+
*/
|
|
53
|
+
type SharedImpl = <T>(
|
|
54
|
+
f: StateCreator<T, [], []>,
|
|
55
|
+
options?: SharedOptions,
|
|
56
|
+
) => StateCreator<T, [], []>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Shared implementation
|
|
60
|
+
* @param f Zustand state creator
|
|
61
|
+
* @param options The options
|
|
62
|
+
*/
|
|
63
|
+
const sharedImpl: SharedImpl = (f, options) => (set, get, store) => {
|
|
64
|
+
/**
|
|
65
|
+
* The broadcast channel is not supported in SSR
|
|
66
|
+
*/
|
|
67
|
+
if (
|
|
68
|
+
typeof window === "undefined" &&
|
|
69
|
+
!(
|
|
70
|
+
typeof WorkerGlobalScope !== "undefined" &&
|
|
71
|
+
self instanceof WorkerGlobalScope
|
|
72
|
+
)
|
|
73
|
+
) {
|
|
74
|
+
// eslint-disable-next-line no-console
|
|
75
|
+
console.warn(
|
|
76
|
+
"BroadcastChannel is not supported in this environment. The store will not be shared.",
|
|
77
|
+
);
|
|
78
|
+
return f(set, get, store);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* If BroadcastChannel is not supported, return the basic store
|
|
83
|
+
*/
|
|
84
|
+
if (typeof BroadcastChannel === "undefined") {
|
|
85
|
+
// eslint-disable-next-line no-console
|
|
86
|
+
console.warn(
|
|
87
|
+
"BroadcastChannel is not supported in this browser. The store will not be shared.",
|
|
88
|
+
);
|
|
89
|
+
return f(set, get, store);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Types
|
|
94
|
+
*/
|
|
95
|
+
type Item = { [key: string]: unknown };
|
|
96
|
+
type Message =
|
|
97
|
+
| {
|
|
98
|
+
action: "sync";
|
|
99
|
+
}
|
|
100
|
+
| {
|
|
101
|
+
action: "change";
|
|
102
|
+
state: Item;
|
|
103
|
+
}
|
|
104
|
+
| {
|
|
105
|
+
action: "add_new_tab";
|
|
106
|
+
id: number;
|
|
107
|
+
}
|
|
108
|
+
| {
|
|
109
|
+
action: "close";
|
|
110
|
+
id: number;
|
|
111
|
+
}
|
|
112
|
+
| {
|
|
113
|
+
action: "change_main";
|
|
114
|
+
id: number;
|
|
115
|
+
tabs: number[];
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Is the store synced with the other tabs
|
|
120
|
+
*/
|
|
121
|
+
let isSynced = get() !== undefined;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Is this tab / window the main tab / window
|
|
125
|
+
* When a new tab / window is opened, it will be synced with the main
|
|
126
|
+
*/
|
|
127
|
+
let isMain = false;
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The broadcast channel name
|
|
131
|
+
*/
|
|
132
|
+
const name = options?.name ?? f.toString();
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* The id of the tab / window
|
|
136
|
+
*/
|
|
137
|
+
let id = 0;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Store a list of all the tabs / windows
|
|
141
|
+
* Only for the main tab / window
|
|
142
|
+
*/
|
|
143
|
+
const tabs: number[] = [0];
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Create the broadcast channel
|
|
147
|
+
*/
|
|
148
|
+
const channel = new BroadcastChannel(name);
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Handle the Zustand set function
|
|
152
|
+
* Trigger a postMessage to all the other tabs
|
|
153
|
+
*/
|
|
154
|
+
const onSet: typeof set = (...args) => {
|
|
155
|
+
/**
|
|
156
|
+
* Get the previous states
|
|
157
|
+
*/
|
|
158
|
+
const previous = get() as Item;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Update the states
|
|
162
|
+
*/
|
|
163
|
+
set(...(args as Parameters<typeof set>));
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* If the stores should not be synced, return.
|
|
167
|
+
*/
|
|
168
|
+
if (options?.unsync) {
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Get the fresh states
|
|
174
|
+
*/
|
|
175
|
+
const updated = get() as Item;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Get the states that changed
|
|
179
|
+
*/
|
|
180
|
+
const state = Object.entries(updated).reduce((obj, [key, val]) => {
|
|
181
|
+
if (previous[key] !== val) {
|
|
182
|
+
obj = { ...obj, [key]: val };
|
|
183
|
+
}
|
|
184
|
+
return obj;
|
|
185
|
+
}, {} as Item);
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Send the states to all the other tabs
|
|
189
|
+
*/
|
|
190
|
+
channel.postMessage({ action: "change", state } as Message);
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Subscribe to the broadcast channel
|
|
195
|
+
*/
|
|
196
|
+
channel.onmessage = (e) => {
|
|
197
|
+
if ((e.data as Message).action === "sync") {
|
|
198
|
+
/**
|
|
199
|
+
* If this tab / window is not the main, return
|
|
200
|
+
*/
|
|
201
|
+
if (!isMain) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* Remove all the functions and symbols from the store
|
|
207
|
+
*/
|
|
208
|
+
const state = Object.entries(get() as Item).reduce((obj, [key, val]) => {
|
|
209
|
+
if (typeof val !== "function" && typeof val !== "symbol") {
|
|
210
|
+
obj = { ...obj, [key]: val };
|
|
211
|
+
}
|
|
212
|
+
return obj;
|
|
213
|
+
}, {});
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Send the state to the other tabs
|
|
217
|
+
*/
|
|
218
|
+
channel.postMessage({ action: "change", state } as Message);
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Set the new tab / window id
|
|
222
|
+
*/
|
|
223
|
+
const new_id = tabs[tabs.length - 1]! + 1;
|
|
224
|
+
tabs.push(new_id);
|
|
225
|
+
|
|
226
|
+
options?.onTabsChange?.(tabs);
|
|
227
|
+
|
|
228
|
+
channel.postMessage({ action: "add_new_tab", id: new_id } as Message);
|
|
229
|
+
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Set an id for the tab / window if it doesn't have one
|
|
235
|
+
*/
|
|
236
|
+
if ((e.data as Message).action === "add_new_tab" && !isMain && id === 0) {
|
|
237
|
+
id = e.data.id;
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* On receiving a new state, update the state
|
|
243
|
+
*/
|
|
244
|
+
if ((e.data as Message).action === "change") {
|
|
245
|
+
/**
|
|
246
|
+
* Update the state
|
|
247
|
+
*/
|
|
248
|
+
set(e.data.state);
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* Set the synced attribute
|
|
252
|
+
*/
|
|
253
|
+
isSynced = true;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* On receiving a close message, remove the tab / window id from the list
|
|
258
|
+
*/
|
|
259
|
+
if ((e.data as Message).action === "close") {
|
|
260
|
+
if (!isMain) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
const index = tabs.indexOf(e.data.id);
|
|
265
|
+
if (index !== -1) {
|
|
266
|
+
tabs.splice(index, 1);
|
|
267
|
+
|
|
268
|
+
options?.onTabsChange?.(tabs);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* On receiving a change_main message, change the main tab / window
|
|
274
|
+
*/
|
|
275
|
+
if ((e.data as Message).action === "change_main") {
|
|
276
|
+
if (e.data.id === id) {
|
|
277
|
+
isMain = true;
|
|
278
|
+
tabs.splice(0, tabs.length, ...e.data.tabs);
|
|
279
|
+
|
|
280
|
+
options?.onBecomeMain?.(id);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Synchronize with the main tab
|
|
287
|
+
*/
|
|
288
|
+
const synchronize = (): void => {
|
|
289
|
+
channel.postMessage({ action: "sync" } as Message);
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* If isSynced is false after 100ms, this tab is the main tab
|
|
293
|
+
*/
|
|
294
|
+
setTimeout(() => {
|
|
295
|
+
if (!isSynced) {
|
|
296
|
+
isMain = true;
|
|
297
|
+
isSynced = true;
|
|
298
|
+
|
|
299
|
+
options?.onBecomeMain?.(id);
|
|
300
|
+
}
|
|
301
|
+
}, options?.mainTimeout ?? 100);
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Handle case when the tab / window is closed
|
|
306
|
+
*/
|
|
307
|
+
const onClose = (): void => {
|
|
308
|
+
channel.postMessage({ action: "close", id } as Message);
|
|
309
|
+
|
|
310
|
+
/**
|
|
311
|
+
* If we're closing the main, make the second the new main
|
|
312
|
+
*/
|
|
313
|
+
if (isMain) {
|
|
314
|
+
/**
|
|
315
|
+
* If there is only one tab left, close the channel and return
|
|
316
|
+
*/
|
|
317
|
+
if (tabs.length === 1) {
|
|
318
|
+
/**
|
|
319
|
+
* Clean up
|
|
320
|
+
*/
|
|
321
|
+
channel.close();
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const remaining_tabs = tabs.filter((tab) => tab !== id);
|
|
326
|
+
channel.postMessage({
|
|
327
|
+
action: "change_main",
|
|
328
|
+
id: remaining_tabs[0],
|
|
329
|
+
tabs: remaining_tabs,
|
|
330
|
+
} as Message);
|
|
331
|
+
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Add close event listener
|
|
338
|
+
*/
|
|
339
|
+
if (typeof window !== "undefined") {
|
|
340
|
+
window.addEventListener("beforeunload", onClose);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* Synchronize with the main tab
|
|
345
|
+
*/
|
|
346
|
+
if (!isSynced) {
|
|
347
|
+
synchronize();
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Modify and return the Zustand store
|
|
352
|
+
*/
|
|
353
|
+
store.setState = onSet;
|
|
354
|
+
|
|
355
|
+
return f(onSet, get, store);
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* Shared middleware
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* import { create } from 'zustand';
|
|
363
|
+
* import { shared } from 'use-broadcast-ts';
|
|
364
|
+
*
|
|
365
|
+
* const useStore = create(
|
|
366
|
+
* shared(
|
|
367
|
+
* (set) => ({ count: 0 }),
|
|
368
|
+
* { name: 'my-store' }
|
|
369
|
+
* )
|
|
370
|
+
* );
|
|
371
|
+
*/
|
|
372
|
+
export const shared = sharedImpl as Shared;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// https://github.com/Romainlg29/use-broadcast/
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Our hook will return an object with three properties:
|
|
6
|
+
* - send: a function that will send a message to all other tabs
|
|
7
|
+
* - state: the current state of the broadcast
|
|
8
|
+
* - subscribe: a function that will subscribe to the broadcast (Only if options.subscribe is true)
|
|
9
|
+
*/
|
|
10
|
+
export type UseBroadcastReturn<T> = {
|
|
11
|
+
send: (val: T) => void;
|
|
12
|
+
state: T | undefined;
|
|
13
|
+
subscribe: (callback: (e: T) => void) => () => void;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The options for the useBroadcast hook
|
|
18
|
+
*/
|
|
19
|
+
export type UseBroadcastOptions = {
|
|
20
|
+
subscribe?: boolean;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param name The name of the broadcast channel
|
|
26
|
+
* @param val The initial value of the broadcast
|
|
27
|
+
* @returns Returns an object with three properties: send, state and subscribe
|
|
28
|
+
*/
|
|
29
|
+
export const useBroadcast = <T>(
|
|
30
|
+
name: string,
|
|
31
|
+
val?: T,
|
|
32
|
+
options?: UseBroadcastOptions,
|
|
33
|
+
): UseBroadcastReturn<T> => {
|
|
34
|
+
/**
|
|
35
|
+
* Store the state of the broadcast
|
|
36
|
+
*/
|
|
37
|
+
const [state, setState] = useState<T | undefined>(val);
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Store the BroadcastChannel instance
|
|
41
|
+
*/
|
|
42
|
+
const channel = useRef<BroadcastChannel | null>(null);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Store the listeners
|
|
46
|
+
*/
|
|
47
|
+
const listeners = useRef<((e: T) => void)[]>([]);
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* This function send the value to all the other tabs
|
|
51
|
+
* @param val The value to send
|
|
52
|
+
*/
|
|
53
|
+
const send = (val: T) => {
|
|
54
|
+
if (!channel.current) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Send the value to all the other tabs
|
|
60
|
+
*/
|
|
61
|
+
channel.current.postMessage(val);
|
|
62
|
+
|
|
63
|
+
if (!options?.subscribe) {
|
|
64
|
+
setState(val);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Dispatch the event to the listeners
|
|
69
|
+
*/
|
|
70
|
+
listeners.current.forEach((listener) => listener(val));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* This function subscribe to the broadcast
|
|
75
|
+
* @param callback The callback function
|
|
76
|
+
* @returns Returns a function that unsubscribe the callback
|
|
77
|
+
*/
|
|
78
|
+
const subscribe = (callback: (e: T) => void) => {
|
|
79
|
+
/**
|
|
80
|
+
* Add the callback to the listeners
|
|
81
|
+
*/
|
|
82
|
+
listeners.current.push(callback);
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Return a function that unsubscribe the callback
|
|
86
|
+
*/
|
|
87
|
+
return () =>
|
|
88
|
+
listeners.current.splice(listeners.current.indexOf(callback), 1);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
/**
|
|
93
|
+
* If BroadcastChannel is not supported, we log an error and return
|
|
94
|
+
*/
|
|
95
|
+
if (typeof window === "undefined") {
|
|
96
|
+
// eslint-disable-next-line no-console
|
|
97
|
+
console.error("Window is undefined!");
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!window.BroadcastChannel) {
|
|
102
|
+
// eslint-disable-next-line no-console
|
|
103
|
+
console.error("BroadcastChannel is not supported!");
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* If the channel is null, we create a new one
|
|
109
|
+
*/
|
|
110
|
+
if (!channel.current) {
|
|
111
|
+
channel.current = new BroadcastChannel(name);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Subscribe to the message event
|
|
116
|
+
* @param e The message event
|
|
117
|
+
*/
|
|
118
|
+
channel.current.onmessage = (e) => {
|
|
119
|
+
/**
|
|
120
|
+
* Update the state
|
|
121
|
+
*/
|
|
122
|
+
if (!options?.subscribe) {
|
|
123
|
+
setState(e.data);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Dispatch an event to the listeners
|
|
128
|
+
*/
|
|
129
|
+
listeners.current.forEach((listener) => listener(e.data));
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Cleanup
|
|
134
|
+
*/
|
|
135
|
+
return () => {
|
|
136
|
+
if (!channel.current) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
channel.current.close();
|
|
141
|
+
channel.current = null;
|
|
142
|
+
};
|
|
143
|
+
}, [name, options]);
|
|
144
|
+
|
|
145
|
+
return { send, state, subscribe };
|
|
146
|
+
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HydrationBoundary,
|
|
3
|
+
QueryClient,
|
|
4
|
+
QueryClientProvider,
|
|
5
|
+
} from "@tanstack/react-query";
|
|
1
6
|
import { type HelmetData, HelmetProvider } from "@zudoku/react-helmet-async";
|
|
2
|
-
import { StrictMode } from "react";
|
|
7
|
+
import { StrictMode, useState } from "react";
|
|
3
8
|
import { type createBrowserRouter, RouterProvider } from "react-router-dom";
|
|
4
9
|
import {
|
|
5
10
|
type createStaticRouter,
|
|
@@ -15,13 +20,31 @@ const Bootstrap = ({
|
|
|
15
20
|
hydrate?: boolean;
|
|
16
21
|
router: ReturnType<typeof createBrowserRouter>;
|
|
17
22
|
}) => {
|
|
23
|
+
const [queryClient] = useState(
|
|
24
|
+
() =>
|
|
25
|
+
new QueryClient({
|
|
26
|
+
defaultOptions: {
|
|
27
|
+
queries: {
|
|
28
|
+
staleTime: 1000 * 60 * 5,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
}),
|
|
32
|
+
);
|
|
33
|
+
|
|
18
34
|
return (
|
|
19
35
|
<StrictMode>
|
|
20
|
-
<
|
|
21
|
-
<
|
|
22
|
-
<
|
|
23
|
-
|
|
24
|
-
|
|
36
|
+
<QueryClientProvider client={queryClient}>
|
|
37
|
+
<HydrationBoundary state={hydrate ? (window as any).DATA : undefined}>
|
|
38
|
+
<HelmetProvider>
|
|
39
|
+
<StaggeredRenderContext.Provider value={{ stagger: !hydrate }}>
|
|
40
|
+
<RouterProvider
|
|
41
|
+
router={router}
|
|
42
|
+
future={{ v7_startTransition: true }}
|
|
43
|
+
/>
|
|
44
|
+
</StaggeredRenderContext.Provider>
|
|
45
|
+
</HelmetProvider>
|
|
46
|
+
</HydrationBoundary>
|
|
47
|
+
</QueryClientProvider>
|
|
25
48
|
</StrictMode>
|
|
26
49
|
);
|
|
27
50
|
};
|
|
@@ -29,16 +52,20 @@ const Bootstrap = ({
|
|
|
29
52
|
const BootstrapStatic = ({
|
|
30
53
|
router,
|
|
31
54
|
context,
|
|
55
|
+
queryClient,
|
|
32
56
|
helmetContext,
|
|
33
57
|
}: {
|
|
34
58
|
helmetContext: HelmetData["context"];
|
|
35
59
|
context: StaticHandlerContext;
|
|
60
|
+
queryClient: QueryClient;
|
|
36
61
|
router: ReturnType<typeof createStaticRouter>;
|
|
37
62
|
}) => (
|
|
38
63
|
<StrictMode>
|
|
39
|
-
<
|
|
40
|
-
<
|
|
41
|
-
|
|
64
|
+
<QueryClientProvider client={queryClient}>
|
|
65
|
+
<HelmetProvider context={helmetContext}>
|
|
66
|
+
<StaticRouterProvider router={router} context={context} />
|
|
67
|
+
</HelmetProvider>
|
|
68
|
+
</QueryClientProvider>
|
|
42
69
|
</StrictMode>
|
|
43
70
|
);
|
|
44
71
|
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { useSyncExternalStore } from "react";
|
|
1
|
+
import { type ReactNode, useSyncExternalStore } from "react";
|
|
2
2
|
|
|
3
3
|
const noop = () => () => {};
|
|
4
4
|
|
|
5
|
-
export const ClientOnly = (props: {
|
|
5
|
+
export const ClientOnly = (props: {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
fallback?: ReactNode;
|
|
8
|
+
}) => {
|
|
6
9
|
const value = useSyncExternalStore(
|
|
7
10
|
noop,
|
|
8
11
|
() => "client",
|
|
9
12
|
() => "server",
|
|
10
13
|
);
|
|
11
14
|
|
|
12
|
-
return value === "client" ? props.children :
|
|
15
|
+
return value === "client" ? props.children : props.fallback;
|
|
13
16
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import { Callout } from "../ui/Callout.js";
|
|
3
|
+
import { Markdown } from "./Markdown.js";
|
|
3
4
|
|
|
4
5
|
export const DeveloperHint = ({
|
|
5
6
|
children,
|
|
@@ -13,7 +14,11 @@ export const DeveloperHint = ({
|
|
|
13
14
|
return (
|
|
14
15
|
<Callout type="caution" title="Developer hint" className={className}>
|
|
15
16
|
<div className="flex flex-col gap-2">
|
|
16
|
-
|
|
17
|
+
{typeof children === "string" ? (
|
|
18
|
+
<Markdown content={children} />
|
|
19
|
+
) : (
|
|
20
|
+
<div>{children}</div>
|
|
21
|
+
)}
|
|
17
22
|
<small className="italic">
|
|
18
23
|
Note: This hint is only shown in development mode.
|
|
19
24
|
</small>
|