Commit Graph

7693 Commits

Author SHA1 Message Date
dependabot[bot]
83cce96d1a chore(deps): bump y18n from 4.0.0 to 4.0.3 (#79)
Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.3.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/y18n-v4.0.3/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/compare/v4.0.0...y18n-v4.0.3)

---
updated-dependencies:
- dependency-name: y18n
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-16 15:24:26 +01:00
Damien Arrachequesne
1c0fd939a9 docs(changelog): add changelog for version 6.0.3 2021-11-14 08:28:06 +01:00
Damien Arrachequesne
3c40aa91b0 chore(release): 6.1.1
Diff: https://github.com/socketio/engine.io-client/compare/6.1.0...6.1.1
2021-11-14 08:03:50 +01:00
Damien Arrachequesne
6e798fbb5b fix: add package name in nested package.json
Related: https://github.com/socketio/socket.io-client/issues/1513
2021-11-14 07:57:25 +01:00
Damien Arrachequesne
c557707fb6 fix: fix vite build for CommonJS users
Related: https://github.com/socketio/socket.io-client/issues/1504
2021-11-14 07:57:25 +01:00
Sten Feldman
8de51c3e37 chore: add bundle files as exportable asset (#682)
This restores the possibility to import the bundle directly, without
getting the following error:
    
> [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './dist/engine.io.min.js' is not defined by "exports"
2021-11-14 07:56:31 +01:00
Damien Arrachequesne
cb26d5cbb6 chore(release): 5.0.2
Diff: https://github.com/socketio/engine.io-parser/compare/5.0.1...5.0.2
2021-11-14 07:26:24 +01:00
Damien Arrachequesne
7e271596c3 fix: add package name in nested package.json
Related: https://github.com/socketio/socket.io-client/issues/1513
2021-11-14 07:23:10 +01:00
Damien Arrachequesne
5f22ed0527 fix: fix vite build for CommonJS users
Related: https://github.com/socketio/socket.io-client/issues/1504
2021-11-14 07:23:10 +01:00
Luigi Pinca
27936285ea chore: make postcompile.sh script work on macOS (#681)
On macOS the script was interpreted as the value of the `-i` option. It
will now use an empty extension for the `-i` option and the `-e` option
to specify the script.
2021-11-13 06:33:06 +01:00
Damien Arrachequesne
02b0f73e2c fix: only set 'connected' to true after middleware execution
The Socket instance is only considered connected when the "connection"
event is emitted, and not during the middleware(s) execution.

```js
io.use((socket, next) => {
  console.log(socket.connected); // prints "false"
  next();
});

io.on("connection", (socket) => {
  console.log(socket.connected); // prints "true"
});
```

Related: https://github.com/socketio/socket.io/issues/4129
2021-11-12 07:31:52 +01:00
Damien Arrachequesne
c0d8c5ab23 feat: add an implementation based on uWebSockets.js
Usage:

```js
const { App } = require("uWebSockets.js");
const { Server } = require("socket.io");

const app = new App();
const server = new Server();

server.attachApp(app);

app.listen(3000);
```

The Adapter prototype is updated so we can benefit from the publish
functionality of uWebSockets.js, so this will apply to all adapters
extending the default adapter.

Reference: https://github.com/uNetworking/uWebSockets.js

Related:

- https://github.com/socketio/socket.io/issues/3601
- https://github.com/socketio/engine.io/issues/578
2021-11-12 07:01:55 +01:00
Nikita Kolmogorov
fe8730ca0f feat: add type information to socket.data (#4159)
Usage:

```js
interface SocketData {
  name: string;
  age: number;
}

const io = new Server<ClientToServerEvents, ServerToClientEvents, InterServerEvents, SocketData>();

io.on("connection", (socket) => {
  socket.data.name = "john";
  socket.data.age = 42;
});
```
2021-11-08 15:21:48 +01:00
Damien Arrachequesne
4c306af945 chore(release): 6.1.0
Diff: https://github.com/socketio/engine.io/compare/6.0.0...6.1.0
2021-11-08 08:37:22 +01:00
Damien Arrachequesne
e7b4700d83 chore(release): 6.1.0
Diff: https://github.com/socketio/engine.io-client/compare/6.0.2...6.1.0
2021-11-08 08:29:00 +01:00
Damien Arrachequesne
972de60ffb docs: add changelog for release 6.0.1
Merged from the 6.0.x branch.
2021-11-08 08:20:30 +01:00
Damien Arrachequesne
6d9f0c364a chore: bump mocha to version 9.1.3
The uWebSocket.js App has no close method for now, so we can't properly
stop the engine at the end of the tests, hence the "--exit".
2021-11-08 08:18:18 +01:00
Damien Arrachequesne
35b6b505df test: replace "s" package by string interpolation 2021-11-08 08:17:25 +01:00
dependabot[bot]
ab84c2d2f3 chore: bump ansi-regex from 5.0.0 to 5.0.1 (#123)
Bumps [ansi-regex](https://github.com/chalk/ansi-regex) from 5.0.0 to 5.0.1.
- [Release notes](https://github.com/chalk/ansi-regex/releases)
- [Commits](https://github.com/chalk/ansi-regex/compare/v5.0.0...v5.0.1)

---
updated-dependencies:
- dependency-name: ansi-regex
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-11-08 06:41:27 +01:00
Damien Arrachequesne
ed8483da4d chore(release): 4.3.2
Diff: https://github.com/socketio/socket.io/compare/4.3.1...4.3.2
4.3.2
2021-11-08 06:39:20 +01:00
Damien Arrachequesne
ed50fc346b fix: fix payload encoding for v3 clients
The v3 parser (used for compatibility with older clients) was broken
during the migration to TypeScript ([1]).

This was not caught in the test suite because the Node.js client does
not support binary packet in polling mode (packets are base64-encoded).

[1]: c0d6eaa1ba

Backported from 6.0.x branch: 3f42262fd2
2021-11-06 08:03:57 +01:00
Damien Arrachequesne
e7ebf4b7dc chore: update caniuse-lite 2021-11-05 07:45:47 +01:00
Damien Arrachequesne
c813fff67c test: skip flaky test
This test fails in CI on chrome 95 / Windows 2012.
2021-11-05 07:42:38 +01:00
Damien Arrachequesne
018e1afcc5 fix(typings): allow any value in the query option
Related: https://github.com/socketio/engine.io-client/issues/679
2021-11-05 07:26:32 +01:00
Kaan Gökdemir
8f68f77825 fix(typings): allow port to be a number (#680)
`string` is kept for backward compatibility (and `location.port` is a
string).

Reference: https://developer.mozilla.org/en-US/docs/Web/API/Location/port

Related: https://github.com/socketio/socket.io-client/issues/1444
2021-11-05 07:22:58 +01:00
Damien Arrachequesne
271e2df94d feat: add an implementation based on uWebSockets.js
```js
const { App } = require("uWebSockets.js");
const { uServer } = require("engine.io");

const app = new App();
const server = new uServer();

server.attach(app);

app.listen(3000);
```

Reference: https://github.com/uNetworking/uWebSockets.js

Related: https://github.com/socketio/engine.io/issues/578
2021-11-02 22:46:09 +01:00
Tom Atkinson
37474c7e67 perf: refresh ping timer (#628)
Reference: https://nodejs.org/docs/latest/api/timers.html#timeoutrefresh
2021-11-01 21:33:15 +01:00
Sebastiaan Marynissen
9d86397243 fix: fix race condition in dynamic namespaces (#4137)
Using an async operation with `io.use()` could lead to the creation of
several instances of a same namespace, each of them overriding the
previous one.

Example:

```js
io.use(async (nsp, auth, next) => {
  await anOperationThatTakesSomeTime();
  next();
});
```

Related: https://github.com/socketio/socket.io/pull/4136
2021-10-24 07:46:29 +02:00
Naseem
44e20ba5bf refactor: add event type for use() (#4138) 2021-10-24 07:19:43 +02:00
Damien Arrachequesne
da0b8282f3 chore(release): 4.3.2
Diff: https://github.com/socketio/socket.io-client/compare/4.3.1...4.3.2
2021-10-17 01:13:27 +02:00
Damien Arrachequesne
6780f29624 fix: restore the default export (bis)
The previous commit, while successfully restoring support for:

```js
const socket = require("socket.io-client")(...);
```

breaks for some other cases:

- https://github.com/socketio/socket.io/issues/4128
- https://github.com/socketio/socket.io-client/issues/1509

According to [1], we should use `export = `, but this is not supported
by module "esnext":

> Export assignment cannot be used when targeting ECMAScript modules

So we'll go for this ugly workaround, at least until we remove the
default export in the next major release.

[1]: https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require
2021-10-17 01:00:28 +02:00
Damien Arrachequesne
ccc5ec39a8 chore(release): 4.3.1
Diff: https://github.com/socketio/socket.io/compare/4.3.0...4.3.1
4.3.1
2021-10-17 00:02:16 +02:00
Josh Field
0ef2a4d02c fix: fix server attachment (#4127)
The check excluded an HTTPS server from being properly attached.

Related: https://github.com/socketio/socket.io/issues/4124
2021-10-16 23:58:55 +02:00
Damien Arrachequesne
68dc241444 chore(release): 6.0.2
Diff: https://github.com/socketio/engine.io-client/compare/6.0.1...6.0.2
2021-10-16 01:39:53 +02:00
Damien Arrachequesne
faa9f318e7 fix(bundle): fix vite build
Some bundlers (like vite) do not support having a "browser" field in a
nested package.json.

Note: the previous commit ([1]) fixed the resolution of the "browser"
field in the dev bundle, but the production bundle still failed.

Related: https://github.com/socketio/socket.io-client/issues/1504

[1]: 49719142f6
2021-10-16 01:36:18 +02:00
Damien Arrachequesne
fa6d4f6d84 chore(release): 5.0.1
Diff: https://github.com/socketio/engine.io-parser/compare/5.0.0...5.0.1
2021-10-16 01:23:30 +02:00
Damien Arrachequesne
900346ea34 fix: fix vite build
Some bundlers (like vite) do not support having a "browser" field in a
nested package.json.

Related: https://github.com/socketio/socket.io-client/issues/1504
2021-10-16 01:19:51 +02:00
Damien Arrachequesne
ca614b28f8 chore(release): 4.3.1
Diff: https://github.com/socketio/socket.io-client/compare/4.3.0...4.3.1
2021-10-16 01:13:08 +02:00
Damien Arrachequesne
f0aae8457a fix: restore the default export
The default export was accidentally removed in [1].

Note: that being said, users are encouraged to use the named exports,
because the default export has a different meaning for CommonJS and ES
modules users.

```js
// BAD
import io from "socket.io-client";

// GOOD
import { io } from "socket.io-client";
```

Related:

- https://github.com/socketio/socket.io-client/issues/1505
- https://github.com/socketio/socket.io-client/issues/1507
- https://github.com/socketio/socket.io-client/issues/1508

[1]: 16b65698ae
2021-10-16 01:09:43 +02:00
Chris Krycho
8737d0ae6f fix: restore the namespace export
This restores the previous behavior, where the "io" object available in
the browser could be used as a function (`io()`) or as a namespace
(`io.connect()`).

The breaking change was introduced in [1].

Related: https://github.com/socketio/socket.io/issues/4121

[1]: 16b65698ae
2021-10-16 00:52:31 +02:00
Damien Arrachequesne
95810aa62d chore(release): 4.3.0
Diff: https://github.com/socketio/socket.io/compare/4.2.0...4.3.0
4.3.0
2021-10-14 14:59:13 +02:00
Damien Arrachequesne
c76d36778d chore(release): 4.3.0
Diff: https://github.com/socketio/socket.io-client/compare/4.2.0...4.3.0
2021-10-14 14:37:33 +02:00
Damien Arrachequesne
91b948b860 refactor: move the typed events to @socket.io/component-emitter
The typed events have been moved to [1] in order to remove the
intermediary class and reduce the bundle size.

Diff: https://github.com/socketio/emitter/compare/2.0.0...3.0.0

[1]: https://github.com/socketio/emitter/
2021-10-14 14:09:23 +02:00
Damien Arrachequesne
9a622949a0 chore(release): 6.0.1
Diff: https://github.com/socketio/engine.io-client/compare/6.0.0...6.0.1
2021-10-14 14:01:49 +02:00
Damien Arrachequesne
ea86f413ed chore(release): 4.1.1
DIff: https://github.com/socketio/socket.io-parser/compare/4.1.0...4.1.1
2021-10-14 13:52:49 +02:00
Damien Arrachequesne
00fcb6e540 chore: export package.json file
Reference: https://nodejs.org/api/packages.html#packages_package_entry_points
2021-10-14 13:49:06 +02:00
Damien Arrachequesne
49719142f6 fix: fix usage with vite
It seems vite has issues with absolute dependencies in the "browser"
field, so we'll provide a quick workaround.

Related:

- https://github.com/socketio/socket.io-client/issues/1494
- https://github.com/socketio/socket.io-client/issues/1495
2021-10-14 13:47:29 +02:00
Damien Arrachequesne
b3bb73aac7 chore: bump @socket.io/component-emitter to version 3.0.0
The typed events have been moved from [1] to [2] in order to remove
the intermediary class and reduce the bundle size.

Diff: https://github.com/socketio/emitter/compare/2.0.0...3.0.0

[1]: https://github.com/socketio/socket.io-client
[2]: https://github.com/socketio/emitter/
2021-10-14 13:46:08 +02:00
Damien Arrachequesne
eb708d1936 chore: bump @socket.io/component-emitter to version 3.0.0
The typed events have been moved from [1] to [2], in order to remove
the intermediary class and reduce the bundle size.

Diff: https://github.com/socketio/emitter/compare/2.0.0...3.0.0

[1]: https://github.com/socketio/socket.io-client/
[2]: https://github.com/socketio/emitter/
2021-10-14 13:11:55 +02:00
Damien Arrachequesne
cd703fe28e chore(release): 3.0.0
Diff: https://github.com/socketio/emitter/compare/2.0.0...3.0.0
2021-10-14 12:35:03 +02:00