diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..55ea2b2d --- /dev/null +++ b/.prettierrc @@ -0,0 +1,4 @@ +{ + "tabWidth": 4, + "useTabs": false +} diff --git a/CHANGELOG.md b/CHANGELOG.md index 82ab886d..fbe341e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,15 @@ # Release Notes -## [Unreleased](https://github.com/laravel/echo/compare/v2.0.2...2.x) +## [Unreleased](https://github.com/laravel/echo/compare/v2.1.0...2.x) + +## [v2.1.0](https://github.com/laravel/echo/compare/v2.0.2...v2.1.0) - 2025-05-07 + +* fixes: unable to build by [@fxnm](https://github.com/fxnm) in https://github.com/laravel/echo/pull/419 +* Update logo by [@iamdavidhill](https://github.com/iamdavidhill) in https://github.com/laravel/echo/pull/421 +* CI Improvements by [@crynobone](https://github.com/crynobone) in https://github.com/laravel/echo/pull/424 +* React/Vue Typescript Hooks by [@tnylea](https://github.com/tnylea) in https://github.com/laravel/echo/pull/422 +* Final hook prep by [@joetannenbaum](https://github.com/joetannenbaum) in https://github.com/laravel/echo/pull/426 +* Added listen to `*`, stronger typing by [@joetannenbaum](https://github.com/joetannenbaum) in https://github.com/laravel/echo/pull/427 ## [v2.0.2](https://github.com/laravel/echo/compare/v2.0.0...v2.0.2) - 2025-02-18 diff --git a/packages/laravel-echo/package.json b/packages/laravel-echo/package.json index b2a7d6e9..c6954759 100644 --- a/packages/laravel-echo/package.json +++ b/packages/laravel-echo/package.json @@ -1,6 +1,6 @@ { "name": "laravel-echo", - "version": "2.1.0", + "version": "2.1.1", "description": "Laravel Echo library for beautiful Pusher and Socket.IO integration", "keywords": [ "laravel", diff --git a/packages/laravel-echo/src/echo.ts b/packages/laravel-echo/src/echo.ts index 4c2130c1..8d6d7f01 100644 --- a/packages/laravel-echo/src/echo.ts +++ b/packages/laravel-echo/src/echo.ts @@ -69,6 +69,7 @@ export default class Echo { } else if (this.options.broadcaster === "ably") { this.connector = new PusherConnector<"pusher">({ ...this.options, + cluster: "", broadcaster: "pusher", }); } else if (this.options.broadcaster === "socket.io") { diff --git a/packages/react/package.json b/packages/react/package.json index 14a4caaf..d3af0ca1 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,7 +1,7 @@ { "name": "@laravel/echo-react", - "version": "2.1.0", - "description": "Laravel Echo library for beautiful Pusher and Socket.IO integration", + "version": "2.1.1", + "description": "React hooks for seamless integration with Laravel Echo.", "keywords": [ "laravel", "pusher", diff --git a/packages/react/src/hooks/use-echo.ts b/packages/react/src/hooks/use-echo.ts index 9a839903..ca0bbd83 100644 --- a/packages/react/src/hooks/use-echo.ts +++ b/packages/react/src/hooks/use-echo.ts @@ -80,8 +80,8 @@ export const useEcho = < TVisibility extends Channel["visibility"] = "private", >( channelName: string, - event: string | string[], - callback: (payload: TPayload) => void, + event: string | string[] = [], + callback: (payload: TPayload) => void = () => {}, dependencies: any[] = [], visibility: TVisibility = "private" as TVisibility, ) => { @@ -173,8 +173,8 @@ export const useEchoPresence = < TDriver extends BroadcastDriver = BroadcastDriver, >( channelName: string, - event: string | string[], - callback: (payload: TPayload) => void, + event: string | string[] = [], + callback: (payload: TPayload) => void = () => {}, dependencies: any[] = [], ) => { return useEcho( @@ -191,8 +191,8 @@ export const useEchoPublic = < TDriver extends BroadcastDriver = BroadcastDriver, >( channelName: string, - event: string | string[], - callback: (payload: TPayload) => void, + event: string | string[] = [], + callback: (payload: TPayload) => void = () => {}, dependencies: any[] = [], ) => { return useEcho( @@ -211,8 +211,8 @@ export const useEchoModel = < >( model: TModel, identifier: string | number, - event: ModelEvents | ModelEvents[], - callback: (payload: ModelPayload) => void, + event: ModelEvents | ModelEvents[] = [], + callback: (payload: ModelPayload) => void = () => {}, dependencies: any[] = [], ) => { return useEcho, TDriver, "private">( diff --git a/packages/react/tests/use-echo.test.ts b/packages/react/tests/use-echo.test.ts index e1849619..96f52de2 100644 --- a/packages/react/tests/use-echo.test.ts +++ b/packages/react/tests/use-echo.test.ts @@ -307,6 +307,15 @@ describe("useEcho hook", async () => { const channel = echoInstance.private(channelName); expect(channel.listen).toHaveBeenCalledTimes(1); }); + + it("events and listeners are optional", async () => { + const channelName = "test-channel"; + + const { result } = renderHook(() => echoModule.useEcho(channelName)); + + expect(result.current).toHaveProperty("channel"); + expect(result.current.channel).not.toBeNull(); + }); }); describe("useEchoModel hook", async () => { @@ -524,6 +533,18 @@ describe("useEchoModel hook", async () => { const channel = echoInstance.private(expectedChannelName); expect(channel.listen).toHaveBeenCalledWith(`.${event}`, mockCallback); }); + + it("events and listeners are optional", async () => { + const model = "App.Models.User.Profile"; + const identifier = "123"; + + const { result } = renderHook(() => + echoModule.useEchoModel(model, identifier), + ); + + expect(result.current).toHaveProperty("channel"); + expect(result.current.channel).not.toBeNull(); + }); }); describe("useEchoPublic hook", async () => { @@ -661,6 +682,17 @@ describe("useEchoPublic hook", async () => { expect(echoInstance.leave).toHaveBeenCalledWith(channelName); }); + + it("events and listeners are optional", async () => { + const channelName = "test-channel"; + + const { result } = renderHook(() => + echoModule.useEchoPublic(channelName), + ); + + expect(result.current).toHaveProperty("channel"); + expect(result.current.channel).not.toBeNull(); + }); }); describe("useEchoPresence hook", async () => { @@ -810,4 +842,15 @@ describe("useEchoPresence hook", async () => { expect(echoInstance.leave).toHaveBeenCalledWith(channelName); }); + + it("events and listeners are optional", async () => { + const channelName = "test-channel"; + + const { result } = renderHook(() => + echoModule.useEchoPresence(channelName), + ); + + expect(result.current).toHaveProperty("channel"); + expect(result.current.channel).not.toBeNull(); + }); }); diff --git a/packages/vue/package.json b/packages/vue/package.json index 3b5a85a1..3a8ffe0f 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -1,7 +1,7 @@ { "name": "@laravel/echo-vue", - "version": "2.1.0", - "description": "Laravel Echo library for beautiful Pusher and Socket.IO integration", + "version": "2.1.1", + "description": "Vue hooks for seamless integration with Laravel Echo.", "keywords": [ "laravel", "pusher", diff --git a/packages/vue/src/composables/useEcho.ts b/packages/vue/src/composables/useEcho.ts index 1cf0f8e7..1768c121 100644 --- a/packages/vue/src/composables/useEcho.ts +++ b/packages/vue/src/composables/useEcho.ts @@ -80,8 +80,8 @@ export const useEcho = < TVisibility extends Channel["visibility"] = "private", >( channelName: string, - event: string | string[], - callback: (payload: TPayload) => void, + event: string | string[] = [], + callback: (payload: TPayload) => void = () => {}, dependencies: any[] = [], visibility: TVisibility = "private" as TVisibility, ) => { @@ -193,8 +193,8 @@ export const useEchoPresence = < TDriver extends BroadcastDriver = BroadcastDriver, >( channelName: string, - event: string | string[], - callback: (payload: TPayload) => void, + event: string | string[] = [], + callback: (payload: TPayload) => void = () => {}, dependencies: any[] = [], ) => { return useEcho( @@ -211,8 +211,8 @@ export const useEchoPublic = < TDriver extends BroadcastDriver = BroadcastDriver, >( channelName: string, - event: string | string[], - callback: (payload: TPayload) => void, + event: string | string[] = [], + callback: (payload: TPayload) => void = () => {}, dependencies: any[] = [], ) => { return useEcho( diff --git a/packages/vue/tests/useEcho.test.ts b/packages/vue/tests/useEcho.test.ts index d90fe647..2c80bcb4 100644 --- a/packages/vue/tests/useEcho.test.ts +++ b/packages/vue/tests/useEcho.test.ts @@ -29,8 +29,8 @@ const getUnConfiguredTestComponent = ( const getTestComponent = ( channelName: string, - event: string | string[], - callback: (data: any) => void, + event: string | string[] | undefined, + callback: ((data: any) => void) | undefined, dependencies: any[] = [], visibility: "private" | "public" = "private", ) => { @@ -58,8 +58,8 @@ const getTestComponent = ( const getPublicTestComponent = ( channelName: string, - event: string | string[], - callback: (data: any) => void, + event: string | string[] | undefined, + callback: ((data: any) => void) | undefined, dependencies: any[] = [], ) => { const TestComponent = defineComponent({ @@ -80,8 +80,8 @@ const getPublicTestComponent = ( const getPresenceTestComponent = ( channelName: string, - event: string | string[], - callback: (data: any) => void, + event: string | string[] | undefined, + callback: ((data: any) => void) | undefined, dependencies: any[] = [], ) => { const TestComponent = defineComponent({ @@ -416,6 +416,14 @@ describe("useEcho hook", async () => { ); }); }); + + it("events and listeners are optional", async () => { + const channelName = "test-channel"; + + wrapper = getTestComponent(channelName, undefined, undefined); + + expect(wrapper.vm.channel).not.toBeNull(); + }); }); describe("useEchoPublic hook", async () => { @@ -538,6 +546,14 @@ describe("useEchoPublic hook", async () => { expect(echoInstance.leave).toHaveBeenCalledWith(channelName); }); + + it("events and listeners are optional", async () => { + const channelName = "test-channel"; + + wrapper = getPublicTestComponent(channelName, undefined, undefined); + + expect(wrapper.vm.channel).not.toBeNull(); + }); }); describe("useEchoPresence hook", async () => { @@ -673,4 +689,12 @@ describe("useEchoPresence hook", async () => { expect(echoInstance.leave).toHaveBeenCalledWith(channelName); }); + + it("events and listeners are optional", async () => { + const channelName = "test-channel"; + + wrapper = getPresenceTestComponent(channelName, undefined, undefined); + + expect(wrapper.vm.channel).not.toBeNull(); + }); }); diff --git a/release.sh b/release.sh index e6833c7c..e797ff55 100755 --- a/release.sh +++ b/release.sh @@ -88,20 +88,26 @@ echo "" echo "" echo "Creating git tag: v$new_version" git tag "v$new_version" +git push --tags echo "" echo "Running release process..." echo "" -# for package_dir in packages/*; do -# if [ -d "$package_dir" ]; then -# echo "Releasing $package_dir" -# cd $package_dir -# pnpm run release -# cd ../.. -# echo "" -# fi -# done +for package_dir in packages/*; do + if [ -d "$package_dir" ]; then + echo "Releasing $package_dir" + cd $package_dir + pnpm run release + cd ../.. + echo "" + fi +done # Echo joke echo "Released! (Released!) (Released!)" + +echo "" + +echo "Release on GitHub:" +echo "https://github.com/laravel/echo/releases/tag/v$new_version"