Commit Graph

1601 Commits

Author SHA1 Message Date
Damien Arrachequesne
1eaeeece35 refactor: remove unused option
This option was added by error during the TypeScript migration.

Related: 587ccf3380
2022-12-14 06:56:05 +01:00
Damien Arrachequesne
ec5a596680 refactor: improve typings
Note: `readyState` and `writeBuffer` are set to public, as they might
be useful for the end user.
2022-12-14 06:49:23 +01:00
Damien Arrachequesne
2ddcb825ae chore: bump caniuse-lite version 2022-12-13 15:40:56 +01:00
Damien Arrachequesne
528a61f86f refactor: bump prettier to version 2.8.1
This major bump creates a lot of noise, but it is necessary for
prettier to be able to parse new syntax such as:

- typed imports: `import { type xxx } from ...`
- private attributes: `class A { #b; #c() {} }`
2022-12-13 15:36:28 +01:00
Damien Arrachequesne
721837c2c9 ci: update the versions of actions/checkout and actions/setup-node
Reference: https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/
2022-12-13 15:33:39 +01:00
Damien Arrachequesne
6565c8e956 ci: temporarily disable browser tests
The tests are in failure since the 13th November, without any logs from
Saucelabs, so we temporarily disable them until further investigation.

See: https://github.com/socketio/engine.io-client/actions/runs/3453198221
2022-12-13 15:29:20 +01:00
Damien Arrachequesne
824ab4cdd8 chore: bump ws to version 8.11.0
Diff: https://github.com/websockets/ws/compare/8.2.3...8.11.0
2022-12-09 09:36:46 +01:00
iifawzi
21a6e1219a feat: add the "addTrailingSlash" option (#694)
The "addTrailingSlash" option allows to control whether a trailing
slash is added to the path of the HTTP requests created by the library:

- true (default): "/engine.io/"
- false: "/engine.io"

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

Signed-off-by: iifawzi <iifawzie@gmail.com>
2022-12-09 08:50:03 +01:00
Damien Arrachequesne
9d772e36b5 chore(release): 6.2.3
Diff: https://github.com/socketio/engine.io-client/compare/6.2.2...6.2.3
2022-10-13 12:36:04 +02:00
Damien Arrachequesne
99925a4775 fix: properly clear "beforeunload" event listener
Related: https://github.com/socketio/engine.io-client/issues/693
2022-10-13 12:20:03 +02:00
Damien Arrachequesne
d4d6463ded refactor: export the nextTick helper method
Related: https://github.com/socketio/socket.io-client/issues/1551
2022-10-13 11:13:44 +02:00
dependabot[bot]
5e585705de chore: bump terser from 4.8.0 to 4.8.1 (#692)
Bumps [terser](https://github.com/terser/terser) from 4.8.0 to 4.8.1.
- [Release notes](https://github.com/terser/terser/releases)
- [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md)
- [Commits](https://github.com/terser/terser/commits)

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

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

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-13 11:02:31 +02:00
Lam Wei Li
dfee8ded72 refactor: replace deprecated String.prototype.substr() (#691)
`.substr()` is deprecated so we replace it with `.slice()` which works
similarly but isn't deprecated.

See also: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr

Signed-off-by: Lam Wei Li <peteriman@mail.com>
2022-06-15 01:49:18 +02:00
Damien Arrachequesne
1975c5c995 chore(release): 6.2.2
Diff: https://github.com/socketio/engine.io-client/compare/6.2.1...6.2.2
2022-05-02 10:11:32 +02:00
Damien Arrachequesne
7e3fe43965 chore: update caniuse-lite version
See https://github.com/browserslist/browserslist#browsers-data-updating
2022-05-02 10:00:31 +02:00
Damien Arrachequesne
ef1c28295e refactor: use named export for XMLHttpRequest shim 2022-05-02 10:00:27 +02:00
Damien Arrachequesne
f158c8e255 fix: simplify the check for WebSocket availability
This check was added for the flashsocket transport, which has been
deprecated for a while now ([1]). But it fails with latest webpack
versions, as the expression `"__initialize" in WebSocket` gets
evaluated to `true`.

Related:

- https://github.com/socketio/engine.io-client/issues/689
- https://github.com/socketio/socket.io-client/issues/1537

[1]: dbc65f3b5a
2022-05-02 09:48:38 +02:00
yujiosaka
32878ea047 fix: use named export for globalThis shim (#688)
Default export of globalThis seems to have a problem in the "browser"
field when the library is loaded asynchronously with webpack.
2022-05-02 09:47:16 +02:00
Damien Arrachequesne
8437600aee chore(release): 6.2.1 2022-04-18 00:46:54 +02:00
Damien Arrachequesne
a2946fc697 chore: bump engine.io-parser to version 5.0.3
In order to make sure the types added in [1] are included.

[1]: ad5bd7ddf5
2022-04-18 00:45:25 +02:00
Damien Arrachequesne
e2ab447d63 refactor: add missing .js extension for ESM usage 2022-04-18 00:43:40 +02:00
Damien Arrachequesne
582f4fe9ba chore: point the CI badge towards the main branch 2022-04-18 00:42:52 +02:00
Damien Arrachequesne
d0773b8e6d chore(release): 6.2.0
Diff: https://github.com/socketio/engine.io-client/compare/6.1.1...6.2.0
2022-04-17 23:46:57 +02:00
Damien Arrachequesne
bc3cefb57b refactor: replace custom clone method by Object.assign() 2022-04-17 23:35:52 +02:00
Damien Arrachequesne
71cd3ba911 chore: bump @socket.io/component-emitter to version 3.1.0
Release notes: https://github.com/socketio/emitter/releases/tag/3.1.0
2022-04-17 23:28:12 +02:00
Damien Arrachequesne
df32277c3f refactor: import single-file 3rd party modules
This commit allows to:

- provide an ESM version of those modules ([1])
- reduce the attack surface in case of supply chain attacks
- reduce the size of the bundle with tree-shaking

As a downside, we won't receive security updates for those modules
anymore.

[1]: https://github.com/socketio/socket.io-client/issues/1536
2022-04-13 08:31:02 +02:00
Damien Arrachequesne
b4b3ed5c68 refactor: merge the polling.ts and polling-xhr.ts files
In the past, there were two implementations of the HTTP long-polling
feature, one with XMLHttpRequest and one based on JSONP for ancient
browsers (IE7/IE8). The JSONP implementation has been removed in [1].

[1]: b2c73812e9
2022-04-11 18:57:43 +02:00
Damien Arrachequesne
b9252e2074 feat: add details to the "close" event
The close event will now include additional details to help debugging
if anything has gone wrong.

Example when a payload is over the maxHttpBufferSize value in HTTP
long-polling mode:

```js
socket.on("close", (reason, details) => {
  console.log(reason); // "transport error"

  // in that case, details is an error object
  console.log(details.message); "xhr post error"
  console.log(details.description); // 413 (the HTTP status of the response)

  // details.context refers to the XMLHttpRequest object
  console.log(details.context.status); // 413
  console.log(details.context.responseText); // ""
});
```

Note: the error object was already included before this commit and is
kept for backward compatibility

Example when a payload is over the maxHttpBufferSize value with
WebSockets:

```js
socket.on("close", (reason, details) => {
  console.log(reason); // "transport close"

  // in that case, details is a plain object
  console.log(details.description); // "websocket connection closed"

  // details.context is a CloseEvent object
  console.log(details.context.code); // 1009 (which means "Message Too Big")
  console.log(details.context.reason); // ""
});
```

Example within a cluster without sticky sessions:

```js
socket.on("close", (reason, details) => {
  console.log(details.context.status); // 400
  console.log(details.context.responseText); // '{"code":1,"message":"Session ID unknown"}'
});
```

Note: we could also print some warnings in development for the "usual"
errors:

- CORS error
- HTTP 400 with multiple nodes
- HTTP 413 with maxHttpBufferSize

but that would require an additional step when going to production
(i.e. setting NODE_ENV variable to "production"). This is open to
discussion!

Related:

- https://github.com/socketio/socket.io/issues/3946
- https://github.com/socketio/socket.io/issues/1979
- https://github.com/socketio/socket.io-client/issues/1518
2022-04-11 17:15:08 +02:00
Damien Arrachequesne
6e1bbff784 chore: add Node.js 16 in the test matrix
See also: https://github.com/nodejs/Release
2022-03-12 11:12:19 +01:00
Damien Arrachequesne
46fdc2f0ed feat: slice write buffer according to the maxPayload value
The server will now include a "maxPayload" field in the handshake
details, allowing the clients to decide how many packets they have to
send to stay under the maxHttpBufferSize value.

Related:

- https://github.com/socketio/socket.io-client/issues/1531
- 088dcb4dff
2022-03-12 11:11:17 +01:00
Damien Arrachequesne
f4725f1021 test: exclude iOS 15 from the test matrix for now
Related:

- https://bugs.webkit.org/show_bug.cgi?id=228296
- https://github.com/socketio/socket.io/issues/4263
2022-03-12 06:24:02 +01:00
dependabot[bot]
f51ca4ac3e chore: bump cached-path-relative from 1.0.2 to 1.1.0 (#686)
Bumps [cached-path-relative](https://github.com/ashaffer/cached-path-relative) from 1.0.2 to 1.1.0.
- [Release notes](https://github.com/ashaffer/cached-path-relative/releases)
- [Commits](https://github.com/ashaffer/cached-path-relative/commits)

---
updated-dependencies:
- dependency-name: cached-path-relative
  dependency-type: indirect
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-08 07:10:28 +01:00
dependabot[bot]
00c673475a chore: bump ajv from 6.10.2 to 6.12.6 (#687)
Bumps [ajv](https://github.com/ajv-validator/ajv) from 6.10.2 to 6.12.6.
- [Release notes](https://github.com/ajv-validator/ajv/releases)
- [Commits](https://github.com/ajv-validator/ajv/compare/v6.10.2...v6.12.6)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-16 06:26:38 +01:00
dependabot[bot]
56af9c59b9 chore: bump engine.io from 4.0.2 to 4.1.2 (#685)
Bumps [engine.io](https://github.com/socketio/engine.io) from 4.0.2 to 4.1.2.
- [Release notes](https://github.com/socketio/engine.io/releases)
- [Changelog](https://github.com/socketio/engine.io/blob/4.1.2/CHANGELOG.md)
- [Commits](https://github.com/socketio/engine.io/compare/4.0.2...4.1.2)

---
updated-dependencies:
- dependency-name: engine.io
  dependency-type: direct:development
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-15 07:59:15 +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
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
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
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
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
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
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