zudoku 0.0.0-f3858d6 → 0.0.0-f49e3ea
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/README.md +121 -0
- 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 +6 -6
- package/dist/app/entry.server.js.map +1 -1
- package/dist/app/main.d.ts +1 -1
- package/dist/app/main.js +5 -7
- 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/cli/cli.js +1 -2
- package/dist/cli/cli.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 +21 -6
- package/dist/config/validators/InputSidebarSchema.js +7 -28
- package/dist/config/validators/InputSidebarSchema.js.map +1 -1
- package/dist/config/validators/SidebarSchema.d.ts +24 -1
- package/dist/config/validators/SidebarSchema.js +77 -37
- package/dist/config/validators/SidebarSchema.js.map +1 -1
- package/dist/config/validators/validate.d.ts +354 -256
- package/dist/config/validators/validate.js +19 -2
- package/dist/config/validators/validate.js.map +1 -1
- package/dist/index.d.ts +3 -3
- 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/components/CallbackHandler.js +21 -31
- package/dist/lib/authentication/components/CallbackHandler.js.map +1 -1
- 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 +12 -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 +7 -8
- package/dist/lib/components/Header.js.map +1 -1
- package/dist/lib/components/Heading.d.ts +1 -1
- package/dist/lib/components/Layout.js +6 -3
- package/dist/lib/components/Layout.js.map +1 -1
- package/dist/lib/components/MobileTopNavigation.js +8 -6
- package/dist/lib/components/MobileTopNavigation.js.map +1 -1
- package/dist/lib/components/Search.js +1 -1
- package/dist/lib/components/Search.js.map +1 -1
- package/dist/lib/components/SlotletProvider.d.ts +7 -2
- package/dist/lib/components/SlotletProvider.js +3 -5
- package/dist/lib/components/SlotletProvider.js.map +1 -1
- package/dist/lib/components/SyntaxHighlight.js +19 -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 +5 -0
- package/dist/lib/components/TopNavigation.js +22 -8
- 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 -6
- 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 +30 -13
- package/dist/lib/components/index.js +11 -5
- 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/SidebarCategory.js +18 -7
- package/dist/lib/components/navigation/SidebarCategory.js.map +1 -1
- package/dist/lib/components/navigation/SidebarItem.js +12 -5
- package/dist/lib/components/navigation/SidebarItem.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.d.ts +1 -1
- package/dist/lib/errors/ErrorAlert.js +8 -3
- package/dist/lib/errors/ErrorAlert.js.map +1 -1
- package/dist/lib/oas/graphql/index.js +4 -4
- package/dist/lib/oas/graphql/index.js.map +1 -1
- package/dist/lib/oas/parser/upgrade/index.js +3 -1
- package/dist/lib/oas/parser/upgrade/index.js.map +1 -1
- package/dist/lib/plugins/api-keys/CreateApiKey.js +1 -1
- package/dist/lib/plugins/api-keys/CreateApiKey.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/CustomPage.d.ts +2 -0
- package/dist/lib/plugins/custom-pages/CustomPage.js +11 -0
- package/dist/lib/plugins/custom-pages/CustomPage.js.map +1 -0
- package/dist/lib/plugins/custom-pages/index.d.ts +9 -7
- package/dist/lib/plugins/custom-pages/index.js +3 -4
- package/dist/lib/plugins/custom-pages/index.js.map +1 -1
- package/dist/lib/plugins/markdown/MdxPage.js +1 -1
- package/dist/lib/plugins/markdown/MdxPage.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/CollapsibleCode.d.ts +5 -0
- package/dist/lib/plugins/openapi/CollapsibleCode.js +24 -0
- package/dist/lib/plugins/openapi/CollapsibleCode.js.map +1 -0
- 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 +21 -22
- package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
- package/dist/lib/plugins/openapi/ParameterListItem.js +6 -1
- package/dist/lib/plugins/openapi/ParameterListItem.js.map +1 -1
- package/dist/lib/plugins/openapi/RequestBodySidecarBox.js +7 -3
- package/dist/lib/plugins/openapi/RequestBodySidecarBox.js.map +1 -1
- package/dist/lib/plugins/openapi/ResponsesSidecarBox.js +9 -2
- package/dist/lib/plugins/openapi/ResponsesSidecarBox.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 +35 -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 -51
- package/dist/lib/plugins/openapi/graphql/gql.js +4 -2
- package/dist/lib/plugins/openapi/graphql/gql.js.map +1 -1
- package/dist/lib/plugins/openapi/graphql/graphql.d.ts +32 -8
- package/dist/lib/plugins/openapi/graphql/graphql.js +194 -662
- 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/playground/Playground.js +2 -1
- package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js +1 -1
- package/dist/lib/plugins/openapi/playground/PlaygroundDialog.js.map +1 -1
- package/dist/lib/plugins/openapi/schema/SchemaView.js +2 -1
- package/dist/lib/plugins/openapi/schema/SchemaView.js.map +1 -1
- package/dist/lib/plugins/openapi/util/generateSchemaExample.d.ts +0 -1
- package/dist/lib/plugins/openapi/util/generateSchemaExample.js +25 -36
- package/dist/lib/plugins/openapi/util/generateSchemaExample.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 +4 -7
- package/dist/lib/plugins/redirect/index.js +1 -1
- 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/Accordion.d.ts +7 -0
- package/dist/lib/ui/Accordion.js +14 -0
- package/dist/lib/ui/Accordion.js.map +1 -0
- package/dist/lib/ui/ActionButton.d.ts +4 -0
- package/dist/lib/ui/ActionButton.js +10 -0
- package/dist/lib/ui/ActionButton.js.map +1 -0
- package/dist/lib/ui/Alert.d.ts +8 -0
- package/dist/lib/ui/Alert.js +23 -0
- package/dist/lib/ui/Alert.js.map +1 -0
- package/dist/lib/ui/AlertDialog.d.ts +20 -0
- package/dist/lib/ui/AlertDialog.js +27 -0
- package/dist/lib/ui/AlertDialog.js.map +1 -0
- package/dist/lib/ui/AspectRatio.d.ts +3 -0
- package/dist/lib/ui/AspectRatio.js +4 -0
- package/dist/lib/ui/AspectRatio.js.map +1 -0
- package/dist/lib/ui/Badge.d.ts +9 -0
- package/dist/lib/ui/Badge.js +21 -0
- package/dist/lib/ui/Badge.js.map +1 -0
- package/dist/lib/ui/Breadcrumb.d.ts +19 -0
- package/dist/lib/ui/Breadcrumb.js +24 -0
- package/dist/lib/ui/Breadcrumb.js.map +1 -0
- package/dist/lib/ui/Button.d.ts +2 -3
- package/dist/lib/ui/Button.js +1 -1
- package/dist/lib/ui/Button.js.map +1 -1
- package/dist/lib/ui/Carousel.d.ts +18 -0
- package/dist/lib/ui/Carousel.js +99 -0
- package/dist/lib/ui/Carousel.js.map +1 -0
- package/dist/lib/ui/Checkbox.d.ts +4 -0
- package/dist/lib/ui/Checkbox.js +9 -0
- package/dist/lib/ui/Checkbox.js.map +1 -0
- package/dist/lib/ui/Collapsible.d.ts +5 -0
- package/dist/lib/ui/Collapsible.js +6 -0
- package/dist/lib/ui/Collapsible.js.map +1 -0
- package/dist/lib/ui/Command.d.ts +80 -0
- package/dist/lib/ui/Command.js +31 -0
- package/dist/lib/ui/Command.js.map +1 -0
- package/dist/lib/{components → ui}/Dialog.js +2 -2
- package/dist/lib/ui/Dialog.js.map +1 -0
- package/dist/lib/ui/Form.d.ts +23 -0
- package/dist/lib/ui/Form.js +63 -0
- package/dist/lib/ui/Form.js.map +1 -0
- package/dist/lib/ui/HoverCard.d.ts +6 -0
- package/dist/lib/ui/HoverCard.js +10 -0
- package/dist/lib/ui/HoverCard.js.map +1 -0
- package/dist/lib/ui/Label.d.ts +5 -0
- package/dist/lib/ui/Label.js +10 -0
- package/dist/lib/ui/Label.js.map +1 -0
- package/dist/lib/ui/Pagination.d.ts +28 -0
- package/dist/lib/ui/Pagination.js +24 -0
- package/dist/lib/ui/Pagination.js.map +1 -0
- package/dist/lib/ui/Popover.d.ts +6 -0
- package/dist/lib/ui/Popover.js +10 -0
- package/dist/lib/ui/Popover.js.map +1 -0
- package/dist/lib/ui/Progress.d.ts +4 -0
- package/dist/lib/ui/Progress.js +8 -0
- package/dist/lib/ui/Progress.js.map +1 -0
- package/dist/lib/ui/RadioGroup.d.ts +5 -0
- package/dist/lib/ui/RadioGroup.js +15 -0
- package/dist/lib/ui/RadioGroup.js.map +1 -0
- package/dist/lib/ui/ScrollArea.d.ts +5 -0
- package/dist/lib/ui/ScrollArea.js +12 -0
- package/dist/lib/ui/ScrollArea.js.map +1 -0
- package/dist/lib/ui/Select.js.map +1 -0
- package/dist/lib/ui/Skeleton.d.ts +2 -0
- package/dist/lib/ui/Skeleton.js +7 -0
- package/dist/lib/ui/Skeleton.js.map +1 -0
- package/dist/lib/ui/Slider.d.ts +4 -0
- package/dist/lib/ui/Slider.js +8 -0
- package/dist/lib/ui/Slider.js.map +1 -0
- package/dist/lib/ui/Switch.d.ts +4 -0
- package/dist/lib/ui/Switch.js +8 -0
- package/dist/lib/ui/Switch.js.map +1 -0
- package/dist/lib/ui/Textarea.d.ts +4 -0
- package/dist/lib/ui/Textarea.js +9 -0
- package/dist/lib/ui/Textarea.js.map +1 -0
- package/dist/lib/ui/Toggle.d.ts +12 -0
- package/dist/lib/ui/Toggle.js +26 -0
- package/dist/lib/ui/Toggle.js.map +1 -0
- package/dist/lib/ui/ToggleGroup.d.ts +12 -0
- package/dist/lib/ui/ToggleGroup.js +21 -0
- package/dist/lib/ui/ToggleGroup.js.map +1 -0
- package/dist/lib/ui/Tooltip.d.ts +7 -0
- package/dist/lib/ui/Tooltip.js +11 -0
- package/dist/lib/ui/Tooltip.js.map +1 -0
- package/dist/lib/util/MdxComponents.d.ts +1 -1
- package/dist/lib/util/MdxComponents.js.map +1 -1
- package/dist/lib/util/invariant.d.ts +9 -0
- package/dist/lib/util/invariant.js +7 -3
- package/dist/lib/util/invariant.js.map +1 -1
- package/dist/lib/util/useExposedProps.d.ts +2 -0
- package/dist/lib/util/useExposedProps.js +9 -0
- package/dist/lib/util/useExposedProps.js.map +1 -0
- package/dist/lib/util/useIsomorphicLayoutEffect.d.ts +3 -0
- package/dist/lib/util/useIsomorphicLayoutEffect.js +4 -0
- package/dist/lib/util/useIsomorphicLayoutEffect.js.map +1 -0
- 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/build.js +5 -1
- package/dist/vite/build.js.map +1 -1
- package/dist/vite/config.d.ts +2 -8
- package/dist/vite/config.js +23 -59
- package/dist/vite/config.js.map +1 -1
- package/dist/vite/dev-server.js +1 -1
- package/dist/vite/dev-server.js.map +1 -1
- package/dist/vite/html.js +0 -2
- package/dist/vite/html.js.map +1 -1
- package/dist/vite/output.d.ts +101 -0
- package/dist/vite/output.js +33 -0
- package/dist/vite/output.js.map +1 -0
- package/dist/vite/plugin-component.js +17 -7
- package/dist/vite/plugin-component.js.map +1 -1
- package/dist/vite/plugin-config-reload.js +0 -2
- package/dist/vite/plugin-config-reload.js.map +1 -1
- package/dist/vite/plugin-config.d.ts +2 -3
- package/dist/vite/plugin-config.js +2 -3
- package/dist/vite/plugin-config.js.map +1 -1
- package/dist/vite/plugin-docs.js +13 -2
- package/dist/vite/plugin-docs.js.map +1 -1
- package/dist/vite/plugin-frontmatter.d.ts +2 -1
- package/dist/vite/plugin-frontmatter.js +27 -24
- package/dist/vite/plugin-frontmatter.js.map +1 -1
- package/dist/vite/plugin-mdx.d.ts +0 -6
- package/dist/vite/plugin-mdx.js +20 -2
- package/dist/vite/plugin-mdx.js.map +1 -1
- package/dist/vite/plugin-search.d.ts +3 -0
- package/dist/vite/plugin-search.js +26 -0
- package/dist/vite/plugin-search.js.map +1 -0
- package/dist/vite/plugin-sidebar.js +4 -6
- package/dist/vite/plugin-sidebar.js.map +1 -1
- package/dist/vite/plugin.js +4 -4
- package/dist/vite/plugin.js.map +1 -1
- package/dist/vite/prerender.js +3 -2
- package/dist/vite/prerender.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-DovtSBJk.js → AnchorLink-CDlhr8gL.js} +12 -11
- package/lib/{AnchorLink-DovtSBJk.js.map → AnchorLink-CDlhr8gL.js.map} +1 -1
- package/lib/{AuthenticationPlugin-Cnqy9csQ.js → AuthenticationPlugin-DeGDVa1r.js} +6 -5
- package/lib/{AuthenticationPlugin-Cnqy9csQ.js.map → AuthenticationPlugin-DeGDVa1r.js.map} +1 -1
- package/lib/Button-jK0EsymC.js +48 -0
- package/lib/Button-jK0EsymC.js.map +1 -0
- package/lib/{CategoryHeading-C7VfgpFZ.js → CategoryHeading-Bb9dqxD3.js} +4 -4
- package/lib/{CategoryHeading-C7VfgpFZ.js.map → CategoryHeading-Bb9dqxD3.js.map} +1 -1
- package/lib/ClientOnly-E7hGysn1.js +11 -0
- package/lib/ClientOnly-E7hGysn1.js.map +1 -0
- package/lib/Dialog-k70Qfukb.js +67 -0
- package/lib/Dialog-k70Qfukb.js.map +1 -0
- package/lib/Markdown-ievDDhFT.js +15192 -0
- package/lib/Markdown-ievDDhFT.js.map +1 -0
- package/lib/{MdxPage-C5I9c7R1.js → MdxPage-Bwn-VSsH.js} +17 -16
- package/lib/{MdxPage-C5I9c7R1.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-O9ZM3ZgX.js +223 -0
- 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/SyntaxHighlight-DkLOsjHS.js +2983 -0
- package/lib/SyntaxHighlight-DkLOsjHS.js.map +1 -0
- package/lib/_commonjsHelpers-BkfeUUK-.js +29 -0
- package/lib/_commonjsHelpers-BkfeUUK-.js.map +1 -0
- package/lib/assets/{worker-DaFlmuyf.js → worker-CPsGZsve.js} +2590 -2500
- package/lib/assets/{worker-DaFlmuyf.js.map → worker-CPsGZsve.js.map} +1 -1
- package/lib/cn-BmFQLtkS.js +2279 -0
- package/lib/cn-BmFQLtkS.js.map +1 -0
- 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-hEqe7fPB.js +227 -0
- package/lib/hook-hEqe7fPB.js.map +1 -0
- package/lib/index-Bn6Lc9tq.js +9 -0
- package/lib/{index-DJqnphbT.js.map → index-Bn6Lc9tq.js.map} +1 -1
- package/lib/index-BuAyrJe3.js +46 -0
- package/lib/index-BuAyrJe3.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-D06ATMgg.js → index-LNp6rxyU.js} +2 -2
- package/lib/{index-D06ATMgg.js.map → index-LNp6rxyU.js.map} +1 -1
- package/lib/index-Yn8c3UWE.js +921 -0
- package/lib/index-Yn8c3UWE.js.map +1 -0
- package/lib/index.esm-C5mr_sKO.js +1193 -0
- package/lib/index.esm-C5mr_sKO.js.map +1 -0
- package/lib/invariant-Caa8-XvF.js +26 -0
- package/lib/invariant-Caa8-XvF.js.map +1 -0
- package/lib/{router-Oe6YmY6B.js → router-lfyopgBI.js} +23 -23
- package/lib/{router-Oe6YmY6B.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/Accordion.js +47 -0
- package/lib/ui/Accordion.js.map +1 -0
- package/lib/ui/ActionButton.js +25 -0
- package/lib/ui/ActionButton.js.map +1 -0
- package/lib/ui/Alert.js +51 -0
- package/lib/ui/Alert.js.map +1 -0
- package/lib/ui/AlertDialog.js +114 -0
- package/lib/ui/AlertDialog.js.map +1 -0
- package/lib/ui/AspectRatio.js +6 -0
- package/lib/ui/AspectRatio.js.map +1 -0
- package/lib/ui/Badge.js +27 -0
- package/lib/ui/Badge.js.map +1 -0
- package/lib/ui/Breadcrumb.js +94 -0
- package/lib/ui/Breadcrumb.js.map +1 -0
- package/lib/ui/Button.js +49 -0
- package/lib/ui/Button.js.map +1 -0
- package/lib/ui/Callout.js +77 -0
- package/lib/ui/Callout.js.map +1 -0
- package/lib/ui/Card.js +62 -0
- package/lib/ui/Card.js.map +1 -0
- package/lib/ui/Carousel.js +1410 -0
- package/lib/ui/Carousel.js.map +1 -0
- package/lib/ui/Checkbox.js +28 -0
- package/lib/ui/Checkbox.js.map +1 -0
- package/lib/ui/Collapsible.js +8 -0
- package/lib/ui/Collapsible.js.map +1 -0
- package/lib/ui/Command.js +550 -0
- package/lib/ui/Command.js.map +1 -0
- package/lib/ui/Dialog.js +101 -0
- package/lib/ui/Dialog.js.map +1 -0
- package/lib/ui/Drawer.js +1153 -0
- package/lib/ui/Drawer.js.map +1 -0
- package/lib/ui/DropdownMenu.js +145 -0
- package/lib/ui/DropdownMenu.js.map +1 -0
- package/lib/ui/Form.js +95 -0
- package/lib/ui/Form.js.map +1 -0
- package/lib/ui/HoverCard.js +24 -0
- package/lib/ui/HoverCard.js.map +1 -0
- package/lib/ui/Input.js +22 -0
- package/lib/ui/Input.js.map +1 -0
- package/lib/ui/Label.js +20 -0
- package/lib/ui/Label.js.map +1 -0
- package/lib/ui/Pagination.js +106 -0
- package/lib/ui/Pagination.js.map +1 -0
- package/lib/ui/Popover.js +24 -0
- package/lib/ui/Popover.js.map +1 -0
- package/lib/ui/Progress.js +27 -0
- package/lib/ui/Progress.js.map +1 -0
- package/lib/ui/RadioGroup.js +32 -0
- package/lib/ui/RadioGroup.js.map +1 -0
- package/lib/ui/ScrollArea.js +39 -0
- package/lib/ui/ScrollArea.js.map +1 -0
- package/lib/ui/Select.js +122 -0
- package/lib/ui/Select.js.map +1 -0
- package/lib/ui/Skeleton.js +18 -0
- package/lib/ui/Skeleton.js.map +1 -0
- package/lib/ui/Slider.js +24 -0
- package/lib/ui/Slider.js.map +1 -0
- package/lib/ui/Switch.js +28 -0
- package/lib/ui/Switch.js.map +1 -0
- package/lib/ui/Tabs.js +47 -0
- package/lib/ui/Tabs.js.map +1 -0
- package/lib/ui/Textarea.js +21 -0
- package/lib/ui/Textarea.js.map +1 -0
- package/lib/ui/Toggle.js +38 -0
- package/lib/ui/Toggle.js.map +1 -0
- package/lib/ui/ToggleGroup.js +42 -0
- package/lib/ui/ToggleGroup.js.map +1 -0
- package/lib/ui/Tooltip.js +24 -0
- package/lib/ui/Tooltip.js.map +1 -0
- package/lib/useExposedProps-CTPtylCV.js +10 -0
- package/lib/useExposedProps-CTPtylCV.js.map +1 -0
- package/lib/{ZudokuContext-DSipF8sq.js → utils-DcpDOncX.js} +244 -248
- 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 +506 -526
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/lib/zudoku.components.js +1152 -3009
- package/lib/zudoku.components.js.map +1 -1
- package/lib/zudoku.openapi-worker.js +10 -16250
- package/lib/zudoku.openapi-worker.js.map +1 -1
- package/lib/zudoku.plugin-api-keys.js +68 -75
- package/lib/zudoku.plugin-api-keys.js.map +1 -1
- package/lib/zudoku.plugin-custom-pages.js +17 -8
- 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 +6 -10
- package/lib/zudoku.plugin-openapi.js.map +1 -1
- package/lib/zudoku.plugin-redirect.js +2 -2
- package/lib/zudoku.plugin-redirect.js.map +1 -1
- package/lib/zudoku.plugin-search-inkeep.js +9 -13
- package/lib/zudoku.plugin-search-inkeep.js.map +1 -1
- package/package.json +43 -11
- package/src/app/demo.tsx +0 -3
- package/src/app/entry.client.tsx +14 -0
- package/src/app/entry.server.tsx +59 -53
- package/src/app/main.css +1 -2
- package/src/app/main.tsx +7 -9
- package/src/app/standalone.tsx +0 -3
- package/src/lib/authentication/authentication.ts +2 -2
- package/src/lib/authentication/components/CallbackHandler.tsx +20 -51
- package/src/lib/authentication/hook.ts +1 -3
- package/src/lib/authentication/providers/auth0.tsx +17 -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 +44 -42
- package/src/lib/components/Layout.tsx +43 -36
- package/src/lib/components/MobileTopNavigation.tsx +23 -20
- package/src/lib/components/Search.tsx +1 -1
- package/src/lib/components/SlotletProvider.tsx +16 -7
- package/src/lib/components/SyntaxHighlight.tsx +85 -46
- package/src/lib/components/ThemeSwitch.tsx +26 -0
- package/src/lib/components/TopNavigation.tsx +39 -18
- 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 +14 -6
- package/src/lib/components/navigation/Sidebar.tsx +4 -4
- package/src/lib/components/navigation/SidebarCategory.tsx +34 -26
- package/src/lib/components/navigation/SidebarItem.tsx +16 -17
- 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 +20 -6
- package/src/lib/oas/graphql/index.ts +4 -4
- package/src/lib/oas/parser/upgrade/index.ts +3 -1
- package/src/lib/plugins/api-keys/CreateApiKey.tsx +2 -2
- package/src/lib/plugins/api-keys/index.tsx +9 -9
- package/src/lib/plugins/custom-pages/CustomPage.tsx +18 -0
- package/src/lib/plugins/custom-pages/index.tsx +13 -11
- package/src/lib/plugins/markdown/MdxPage.tsx +10 -8
- package/src/lib/plugins/markdown/index.tsx +2 -2
- package/src/lib/plugins/openapi/CollapsibleCode.tsx +80 -0
- 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 +20 -40
- package/src/lib/plugins/openapi/ParameterListItem.tsx +37 -31
- package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +18 -13
- package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +17 -12
- package/src/lib/plugins/openapi/Route.tsx +11 -12
- package/src/lib/plugins/openapi/Sidecar.tsx +73 -59
- 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 +10 -27
- package/src/lib/plugins/openapi/graphql/graphql.ts +233 -665
- package/src/lib/plugins/openapi/index.tsx +42 -67
- package/src/lib/plugins/openapi/playground/Playground.tsx +4 -3
- package/src/lib/plugins/openapi/playground/PlaygroundDialog.tsx +1 -1
- package/src/lib/plugins/openapi/schema/SchemaView.tsx +5 -2
- package/src/lib/plugins/openapi/util/generateSchemaExample.ts +28 -42
- package/src/lib/plugins/openapi-worker.ts +11 -1
- package/src/lib/plugins/redirect/index.tsx +5 -9
- package/src/lib/plugins/search-inkeep/index.tsx +2 -2
- package/src/lib/ui/Accordion.tsx +56 -0
- package/src/lib/ui/ActionButton.tsx +28 -0
- package/src/lib/ui/{Note.tsx → Alert.tsx} +11 -10
- package/src/lib/ui/AlertDialog.tsx +139 -0
- package/src/lib/ui/AspectRatio.tsx +5 -0
- package/src/lib/ui/Badge.tsx +36 -0
- package/src/lib/ui/Breadcrumb.tsx +115 -0
- package/src/lib/ui/Button.tsx +1 -1
- package/src/lib/ui/Carousel.tsx +260 -0
- package/src/lib/ui/Checkbox.tsx +28 -0
- package/src/lib/ui/Collapsible.tsx +9 -0
- package/src/lib/ui/Command.tsx +151 -0
- package/src/lib/{components → ui}/Dialog.tsx +4 -3
- package/src/lib/ui/Form.tsx +177 -0
- package/src/lib/ui/HoverCard.tsx +27 -0
- package/src/lib/ui/Label.tsx +24 -0
- package/src/lib/ui/Pagination.tsx +117 -0
- package/src/lib/ui/Popover.tsx +29 -0
- package/src/lib/ui/Progress.tsx +26 -0
- package/src/lib/ui/RadioGroup.tsx +42 -0
- package/src/lib/ui/ScrollArea.tsx +46 -0
- package/src/lib/ui/Skeleton.tsx +15 -0
- package/src/lib/ui/Slider.tsx +26 -0
- package/src/lib/ui/Switch.tsx +27 -0
- package/src/lib/ui/Textarea.tsx +23 -0
- package/src/lib/ui/Toggle.tsx +43 -0
- package/src/lib/ui/ToggleGroup.tsx +59 -0
- package/src/lib/ui/Tooltip.tsx +28 -0
- package/src/lib/util/MdxComponents.tsx +0 -1
- package/src/lib/util/invariant.ts +15 -3
- package/src/lib/util/useExposedProps.tsx +16 -0
- package/src/lib/util/useIsomorphicLayoutEffect.ts +5 -0
- package/src/lib/util/useOnScreen.ts +32 -0
- package/dist/internal.d.ts +0 -1
- package/dist/internal.js +0 -2
- package/dist/internal.js.map +0 -1
- package/dist/lib/components/DevPortal.js.map +0 -1
- package/dist/lib/components/Dialog.js.map +0 -1
- package/dist/lib/components/Select.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 -12
- package/dist/lib/plugins/openapi/client/createMemoryClient.js +0 -46
- 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 -61
- 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/ui/Note.d.ts +0 -8
- package/dist/lib/ui/Note.js +0 -23
- package/dist/lib/ui/Note.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/DeveloperHint-CNyuFROc.js +0 -16
- package/lib/DeveloperHint-CNyuFROc.js.map +0 -1
- package/lib/ErrorPage-CUz-Zzmx.js +0 -16
- package/lib/ErrorPage-CUz-Zzmx.js.map +0 -1
- package/lib/Input-x-t53FyR.js +0 -2229
- package/lib/Input-x-t53FyR.js.map +0 -1
- package/lib/Markdown-C-0TaxoY.js +0 -20441
- package/lib/Markdown-C-0TaxoY.js.map +0 -1
- package/lib/OperationList-qsBOguHS.js +0 -601
- package/lib/OperationList-qsBOguHS.js.map +0 -1
- package/lib/Route-DlKvXPAO.js +0 -13
- package/lib/Route-DlKvXPAO.js.map +0 -1
- package/lib/SidebarBadge-DaA0-bFW.js +0 -503
- package/lib/SidebarBadge-DaA0-bFW.js.map +0 -1
- package/lib/SlotletProvider-BGEs7yyu.js +0 -240
- package/lib/SlotletProvider-BGEs7yyu.js.map +0 -1
- package/lib/ZudokuContext-DSipF8sq.js.map +0 -1
- package/lib/index-BIl-R3aH.js +0 -5952
- package/lib/index-BIl-R3aH.js.map +0 -1
- package/lib/index-CKmSo0py.js +0 -124
- package/lib/index-CKmSo0py.js.map +0 -1
- package/lib/index-DJqnphbT.js +0 -35
- package/lib/index-Dssw7Gff.js +0 -2867
- package/lib/index-Dssw7Gff.js.map +0 -1
- package/lib/index-SrtqdZ3j.js +0 -1781
- package/lib/index-SrtqdZ3j.js.map +0 -1
- package/lib/state-CsuHT8ZO.js +0 -183
- package/lib/urql-core-KJnLL26g.js +0 -1455
- package/lib/urql-core-KJnLL26g.js.map +0 -1
- 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 -51
- package/src/lib/plugins/openapi/client/createWorkerClient.ts +0 -75
- 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
- /package/dist/lib/{components → ui}/Dialog.d.ts +0 -0
- /package/dist/lib/{components → ui}/Select.d.ts +0 -0
- /package/dist/lib/{components → ui}/Select.js +0 -0
- /package/src/lib/{components → ui}/Select.tsx +0 -0
|
@@ -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
|
-
|
|
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
|
|
198
|
-
if (!
|
|
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
|
-
|
|
203
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
1
|
+
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
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
|
|
|
@@ -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
|
+
};
|