Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rodgc/ngx-socket-io
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v4.6.1
Choose a base ref
...
head repository: rodgc/ngx-socket-io
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on May 24, 2024

  1. Release v4.7.0

    rodgc committed May 24, 2024
    Copy the full SHA
    a567a13 View commit details

Commits on Jun 14, 2024

  1. Copy the full SHA
    1078ada View commit details
  2. Bump braces from 3.0.2 to 3.0.3

    Bumps [braces](https://github.com/micromatch/braces) from 3.0.2 to 3.0.3.
    - [Changelog](https://github.com/micromatch/braces/blob/master/CHANGELOG.md)
    - [Commits](micromatch/braces@3.0.2...3.0.3)
    
    ---
    updated-dependencies:
    - dependency-name: braces
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored Jun 14, 2024
    Copy the full SHA
    f52a80a View commit details
  3. Merge pull request #175 from rodgc/dependabot/npm_and_yarn/braces-3.0.3

    Bump braces from 3.0.2 to 3.0.3
    rodgc authored Jun 14, 2024
    Copy the full SHA
    3975561 View commit details

Commits on Oct 24, 2024

  1. Included documentation for standalone applications (#178)

    * update docs
    
    * tell file
    meurele authored Oct 24, 2024
    Copy the full SHA
    62cd3fb View commit details
  2. Bump cookie and socket.io (#181)

    Bumps [cookie](https://github.com/jshttp/cookie) to 0.7.2 and updates ancestor dependency [socket.io](https://github.com/socketio/socket.io). These dependencies need to be updated together.
    
    
    Updates `cookie` from 0.4.2 to 0.7.2
    - [Release notes](https://github.com/jshttp/cookie/releases)
    - [Commits](jshttp/cookie@v0.4.2...v0.7.2)
    
    Updates `socket.io` from 4.7.2 to 4.8.0
    - [Release notes](https://github.com/socketio/socket.io/releases)
    - [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/socketio/socket.io/compare/4.7.2...socket.io@4.8.0)
    
    ---
    updated-dependencies:
    - dependency-name: cookie
      dependency-type: indirect
    - dependency-name: socket.io
      dependency-type: direct:production
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Oct 24, 2024
    Copy the full SHA
    8af1609 View commit details
  3. Bump rollup from 4.18.0 to 4.22.4 (#180)

    Bumps [rollup](https://github.com/rollup/rollup) from 4.18.0 to 4.22.4.
    - [Release notes](https://github.com/rollup/rollup/releases)
    - [Changelog](https://github.com/rollup/rollup/blob/master/CHANGELOG.md)
    - [Commits](rollup/rollup@v4.18.0...v4.22.4)
    
    ---
    updated-dependencies:
    - dependency-name: rollup
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Oct 24, 2024
    Copy the full SHA
    f639045 View commit details
  4. Bump ws, socket.io-adapter and engine.io-client (#182)

    Bumps [ws](https://github.com/websockets/ws), [socket.io-adapter](https://github.com/socketio/socket.io-adapter) and [engine.io-client](https://github.com/socketio/socket.io). These dependencies needed to be updated together.
    
    Updates `ws` from 8.11.0 to 8.17.1
    - [Release notes](https://github.com/websockets/ws/releases)
    - [Commits](websockets/ws@8.11.0...8.17.1)
    
    Updates `socket.io-adapter` from 2.5.2 to 2.5.5
    - [Release notes](https://github.com/socketio/socket.io-adapter/releases)
    - [Changelog](https://github.com/socketio/socket.io-adapter/blob/2.5.5/CHANGELOG.md)
    - [Commits](socketio/socket.io-adapter@2.5.2...2.5.5)
    
    Updates `engine.io-client` from 6.5.2 to 6.5.4
    - [Release notes](https://github.com/socketio/socket.io/releases)
    - [Changelog](https://github.com/socketio/socket.io/blob/main/CHANGELOG.md)
    - [Commits](https://github.com/socketio/socket.io/commits)
    
    ---
    updated-dependencies:
    - dependency-name: ws
      dependency-type: indirect
    - dependency-name: socket.io-adapter
      dependency-type: indirect
    - dependency-name: engine.io-client
      dependency-type: indirect
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Oct 24, 2024
    Copy the full SHA
    07b4ba1 View commit details

Commits on Oct 25, 2024

  1. Update README.md

    Adjust the version for angular 17 that allows minor updates of angular packages
    sucotronic authored Oct 25, 2024
    Copy the full SHA
    af80686 View commit details

Commits on Nov 21, 2024

  1. Copy the full SHA
    84ef2c4 View commit details
  2. Release v4.8.0

    rodgc committed Nov 21, 2024
    Copy the full SHA
    3f9b6f7 View commit details
  3. Update CHANGELOG

    rodgc committed Nov 21, 2024
    Copy the full SHA
    e7bdaa5 View commit details

Commits on Nov 25, 2024

  1. Bump @angular/core to v19

    rodgc committed Nov 25, 2024
    Copy the full SHA
    6ff0545 View commit details

Commits on Dec 27, 2024

  1. Export SOCKET_CONFIG_TOKEN (#188)

    This is needed if one needs to extend a basic configuration with
    namespaces, for example.
    barbieri authored Dec 27, 2024
    Copy the full SHA
    64774f4 View commit details
  2. Fix and sync api wrapper (#190)

    * Fix socket.of() method
    
    Socket-io's of() only exists in the server API and it returns a new
    instance.
    
    For client we must create a new `io()` with the URL containing the
    namespace. Let's do this and share instances whenever the namespace is
    reused.
    
    * Fix chaining methods
    
    Since we're wrapping the socket, we must return ourselves and not the
    internal socket.
    
    * Fix volatile usage
    
    It's a getter that toggles a flag, but then we must return the actual
    instance
    
    * Add return types to help users
    
    Since we're not importing socket.io-client typings, these are
    particularly important to avoid `any`
    
    * Add emitWithAck()
    
    * Add offAny() and offAnyOutgoing()
    
    These match onAny() and onAnyOutgoing()
    
    * Add send()
    
    Basically emit('message', ...args)
    
    * Add compress()
    
    * Add attributes
    
    * Fix connect() and disconnect() arguments
    
    According to
    https://github.com/socketio/socket.io/blob/main/packages/socket.io-client/lib/socket.ts
    and https://socket.io/docs/v4/client-api/
    these functions do not receive any arguments.
    barbieri authored Dec 27, 2024
    Copy the full SHA
    0cda11e View commit details
  3. Release v4.8.2

    rodgc committed Dec 27, 2024
    Copy the full SHA
    d5f9d72 View commit details

Commits on Feb 8, 2025

  1. Fix typing (#191)

    * Fix: off() takes a single function, not array
    
    * Fix and lock typescript typings
    
    The previous attempt to manually sync missed some details, then remove
    the outdated @types/socket-io and use the built-in types instead.
    
    Then do a mapping of the original IoSocket type to the wrapped,
    forcing the wrapper to be returned for chained, properties should
    alway match.
    
    This will force the wrapper to be in sync without much effort.
    
    * Breaking: mark internal fields as private, all as readonly
    
    None of these fields should be reassigned once they are created, so
    they are all readonly.
    
    Except by ioSocket, all are of internal use, so keep them private.
    
    * Breaking: fix off() behavior, sync with socket-io-client
    
    off() without an event name just unregisters all event handlers via
    EventEmitter.
    
    The comment implied offAny() would do this, but it's not the case:
    that just removes the onAny() handlers.
    
    If we really wanted to remove all event handlers for everything we
    should be calling:
     - offAny()
     - offAnyOutgoing()
     - off()
    
    But that would not match the wrapped behavior, so let's just keep it
    simple.
    barbieri authored Feb 8, 2025
    Copy the full SHA
    04f35ac View commit details
  2. Update CHANGELOG

    rodgc committed Feb 8, 2025
    Copy the full SHA
    1d07da8 View commit details
  3. Release v4.8.3

    rodgc committed Feb 8, 2025
    Copy the full SHA
    77d16a2 View commit details

Commits on Feb 9, 2025

  1. The options property in the SocketIoConfig interface has been updated…

    … to use Partial<ManagerOptions> instead of a custom-defined object:
    rodgc committed Feb 9, 2025
    Copy the full SHA
    88a0dc5 View commit details
  2. Update Changelog

    rodgc committed Feb 9, 2025
    Copy the full SHA
    0fff31a View commit details
  3. Release v4.8.4

    rodgc committed Feb 9, 2025
    Copy the full SHA
    c07677b View commit details
Showing with 2,148 additions and 2,413 deletions.
  1. +22 −0 .github/workflows/close-inactive-issues.yml
  2. +1 −4 .husky/pre-commit
  3. +56 −0 CHANGELOG.md
  4. +25 −4 README.md
  5. +1 −1 index.ts
  6. +1,793 −2,199 package-lock.json
  7. +19 −21 package.json
  8. +4 −132 src/config/socket-io.config.ts
  9. +227 −52 src/socket-io.service.ts
22 changes: 22 additions & 0 deletions .github/workflows/close-inactive-issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Close inactive issues
on:
schedule:
- cron: '30 1 * * *'

jobs:
close-issues:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v5
with:
days-before-issue-stale: 30
days-before-issue-close: 7
stale-issue-label: 'stale'
stale-issue-message: 'This issue is stale because it has been open for 30 days with no activity.'
close-issue-message: 'This issue was closed because it has been inactive for 7 days since being marked as stale.'
days-before-pr-stale: -1
days-before-pr-close: -1
repo-token: ${{ secrets.GITHUB_TOKEN }}
5 changes: 1 addition & 4 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run format
npm run format
56 changes: 56 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -5,6 +5,62 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [4.8.4] - 2025-02-09

### Changed

- Updated the `options` property in the `SocketIoConfig` interface to use `Partial<ManagerOptions>` instead of a `custom-defined` object.

## [4.8.3] - 2025-02-06

### Fixed

- `off()` behavior, sync with socket-io-client and takes a single function, not array
- Mark internal fields as private in `WrappedSocket`.

### Removed

- Outdated `@types/socket-io` & `@types/socket.io-client` dependencies and use the built-in types instead.

## [4.8.2] - 2024-12-27

### Added

- Return types to help users.
- emitWithAck().
- offAny().
- offAnyOutgoing().
- send().
- compress().
- export SOCKET_CONFIG_TOKEN.

### Fixed

- socket.of() method.
- Chaining methods.
- Volatile usage.
- connect() and disconnect() arguments.

## [4.8.1] - 2024-11-25

### Update

- Bump `@angular/core` dependencies to v19.0.0.

## [4.8.0] - 2024-11-21

### Update

- Bump `@angular` dependencies to v19.0.0.

## [4.7.0] - 2024-05-24

### Update

- Bump `@angular` dependencies to v18.0.0.
- Bump `ng-packagr` dependencies to v18.0.0.
- Bump `typescript` dependencies to v5.4.0.

## [4.6.1] - 2023-11-09

### Fixed
29 changes: 25 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -22,11 +22,13 @@ Make sure you're using the proper corresponding version of socket.io on the serv
| v4.3.0 | v4.5.1 | 14.x |
| v4.4.0 | v4.5.1 | 15.x |
| v4.5.0 | v4.5.1 | 16.x |
| v4.6.0 | v4.7.2 | 17.x |
| v4.6.1 | v4.7.2 | 17.x |
| v4.7.0 | v4.7.2 | 18.x |
| v4.8.1 | v4.8.1 | 19.x |

## How to use

### Import and configure SocketIoModule
### Import and configure SocketIoModule for NgModule based applications

```ts
import { SocketIoModule, SocketIoConfig } from 'ngx-socket-io';
@@ -46,6 +48,23 @@ We need to configure `SocketIoModule` module using the object `config` of type `

Now we pass the configuration to the static method `forRoot` of `SocketIoModule`

### Import and configure SocketIoModule for standalone based applications

In app.config.ts use the following:

```ts
import { ApplicationConfig, importProvidersFrom } from '@angular/core';
import { SocketIoModule, SocketIoConfig } from 'ngx-socket-io';

const config: SocketIoConfig = { url: 'http://localhost:8988', options: {} };

export const appConfig: ApplicationConfig = {
providers: [importProvidersFrom(SocketIoModule.forRoot(config))],
};
```

For standalone applications we do not have the AppModule where we can import the `SocketIoModule`. Instead we can use the `importProvidersFrom` provided by angular to provide the `SocketIoModule` to our application. The usage of the socket instance is then the same as if we used a NgModule based application.

### Using your socket Instance

The `SocketIoModule` provides now a configured `Socket` service that can be injected anywhere inside the `AppModule`.
@@ -116,8 +135,10 @@ The only addition is the `fromEvent` method, which returns an `Observable` that

### `socket.of(namespace: string)`

Takes an namespace.
Works the same as in Socket.IO.
Takes a namespace and returns an instance based on the current config and the given namespace,
that is added to the end of the current url.
See [Namespaces - Client Initialization](https://socket.io/docs/v4/namespaces/#client-initialization).
Instances are reused based on the namespace.

### `socket.on(eventName: string, callback: Function)`

2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { SocketIoModule } from './src/socket-io.module';
export { SocketIoModule, SOCKET_CONFIG_TOKEN } from './src/socket-io.module';
export { SocketIoConfig } from './src/config/socket-io.config';
export { WrappedSocket as Socket } from './src/socket-io.service';
Loading