Skip to content

Commit 99a3ab9

Browse files
authored
v7.0.0 (#40)
* ts cleanup, housekeeping, ws agent and timeout * modernized linter, fixed types, added udp timeout, added ts transports config comments * updated READMEs, added description in ts definitions, fixed bugs in tick
1 parent a0e88e3 commit 99a3ab9

40 files changed

+546
-564
lines changed

.eslintignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
*.js
22
examples
33
node_modules
4-
scripts
4+
scripts
5+
*.d.ts
6+
tests

.eslintrc

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
{
2-
"extends": "airbnb-base",
3-
"parser": "@typescript-eslint/parser",
4-
"plugins": [ "import", "@typescript-eslint" ],
5-
"settings": {
6-
"import/resolver": {
7-
"node": {
8-
"paths": ["packages"],
9-
"extensions": [".ts", ".spec.ts"]
10-
}
2+
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": [ "@typescript-eslint" ],
5+
"settings": {
6+
"import/resolver": {
7+
"node": {
8+
"extensions": [".js", ".ts"],
9+
"moduleDirectory": ["node_modules", "packages/"]
1110
}
12-
},
13-
"rules": {
11+
}
12+
},
13+
"rules": {
1414
"import/extensions": 0,
1515
"no-bitwise": 0,
1616
"linebreak-style": 1,
@@ -26,13 +26,14 @@
2626
"no-continue": 0,
2727
"no-unused-vars": 0,
2828
"global-require": 0,
29-
"max-len": [1, 140],
29+
"max-len": [1, 180],
3030
"@typescript-eslint/no-unused-vars": [
3131
"error",
3232
{ "vars": "all", "args": "after-used", "ignoreRestSiblings": false }
3333
],
34-
"import/no-extraneous-dependencies": 0,
35-
"import/no-unresolved": 1
34+
"@typescript-eslint/no-explicit-any": 0,
35+
"@typescript-eslint/ban-types": 0,
36+
"@typescript-eslint/no-empty-function": 0
3637
},
3738
"env": {
3839
"browser": true,

CHANGELOG.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,41 @@
11
# Changelog
22

3+
## [v7.0.0] - 2023-03-17
4+
5+
commit [#](https://github.com/kalm/kalm.js/commits)
6+
7+
### Major changes
8+
9+
- Standardized parameter names and expected behavior
10+
- Removed `secure` WS option, instead checking if `cert` and `key` are set
11+
- Routines.dynamic option `hz` is now `maxInterval` and is measured in milliseconds
12+
- Renamed `provider` internally to `server` for easier understanding
13+
- Removed previously deprecated UDP `connectTimeout` option
14+
- Added UDP idle timeout behavior
15+
- Added WS idle timeout behavior
16+
- Added WS Agent option for proxying
17+
- frameId counter now goes up to 0xffffffff before cycling instead of 0xffff
18+
19+
### Bug fixes
20+
21+
- Fixed an issue in Routines.tick where all queues shared the same frameId counter
22+
- Routines.tick option `seed` now correctly sets the `frameId` and starts the counter to match the expected pace
23+
- Fixed references to Node modules in TS definitions
24+
25+
## [v6.1.0] - 2022-09-21
26+
27+
commit [a0e88e3](https://github.com/kalm/kalm.js/commit/a0e88e310d98646b53fbcc56f6efeea4db5e87d8)
28+
29+
### Major changes
30+
31+
- Removed SYN/ACK UDP handshake, which removes the socket timeout behaviour for that transport
32+
- Added error event for UDP packet over the safe limit (16384 bytes), previous behaviour was to crash silently
33+
- Routines are no longer event emitters, but have a size function
34+
35+
336
## [v6.0.0] - 2021-04-26
437

5-
commit: [#](https://github.com/kalm/kalm.js/commits)
38+
commit: [47b810d](https://github.com/kalm/kalm.js/commit/47b810d5ab212686c3194d53e781e1728bd735f9)
639

740
### Breaking changes
841

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2022 Frederic Charette
1+
Copyright 2023 Frederic Charette
22

33
Licensed under the Apache License, Version 2.0 (the "License");
44
you may not use this file except in compliance with the License.

SECURITY.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
| Version | Supported |
66
| ------- | ------------------ |
7+
| 7.x | :white_check_mark: |
78
| 6.x | :white_check_mark: |
8-
| 5.x | :white_check_mark: |
9-
| <= 4.x | :x: |
9+
| <= 5.x | :x: |
1010

1111
## Reporting a Vulnerability
1212

examples/typescript/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {connect, routines} from 'kalm';
22
import ws from '@kalm/ws';
33

44
const client = connect({
5-
transport: ws(),
5+
transport: ws({}),
66
port: 3938,
77
routine: routines.realtime(),
88
});

package.json

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
22
"name": "kalm",
33
"private": true,
4-
"version": "6.1.0",
4+
"version": "7.0.0",
55
"description": "The socket optimizer",
66
"main": "packages/kalm/bin/kalm.js",
77
"scripts": {
8-
"lint": "eslint packages/**/*.ts packages/**/*.spec.ts tests/**/*.spec.ts",
9-
"lint:fix": "yarn lint --fix",
8+
"lint": "eslint .",
9+
"lint:fix": "eslint . --fix",
1010
"test": "yarn workspaces run test && yarn run test:integration",
1111
"test:integration": "jest ./tests/integration --forceExit",
1212
"build": "yarn workspaces run build",
@@ -52,18 +52,16 @@
5252
}
5353
},
5454
"devDependencies": {
55-
"@types/jest": "^29.2.0",
56-
"@types/node": "^18.11.0",
57-
"@typescript-eslint/eslint-plugin": "^5.40.0",
58-
"@typescript-eslint/parser": "^5.40.0",
59-
"eslint": "^8.25.0",
60-
"eslint-config-airbnb-base": "^15.0.0",
61-
"eslint-plugin-import": "^2.26.0",
55+
"@types/jest": "^29.4.0",
56+
"@types/node": "^18.15.0",
57+
"@typescript-eslint/eslint-plugin": "^5.55.0",
58+
"@typescript-eslint/parser": "^5.55.0",
59+
"eslint": "^8.36.0",
6260
"husky": "^8.0.0",
63-
"jest": "^29.2.0",
64-
"socket.io": "^4.5.0",
65-
"socket.io-client": "^4.5.0",
61+
"jest": "^29.5.0",
62+
"socket.io": "^4.6.0",
63+
"socket.io-client": "^4.6.0",
6664
"ts-jest": "^29.0.0",
67-
"typescript": "^4.8.0"
65+
"typescript": "^4.9.0"
6866
}
6967
}

packages/ipc/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kalm/ipc",
3-
"version": "6.1.0",
3+
"version": "7.0.0",
44
"description": "IPC transport for Kalm",
55
"main": "bin/ipc.js",
66
"scripts": {

packages/ipc/src/ipc.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
/* Requires ------------------------------------------------------------------*/
2-
31
import net from 'net';
42

5-
/* Methods -------------------------------------------------------------------*/
6-
73
interface IPCSocket extends net.Socket {
8-
server: {
4+
server?: {
95
_connectionKey: string
106
}
11-
_server: {
7+
_server?: {
128
_pipeName: string
139
}
14-
_handle: {
10+
_handle?: {
1511
fd: number
1612
}
1713
}
1814

15+
type IPCConfig = {
16+
socketTimeout?: number
17+
path?: string
18+
}
19+
1920
function ipc({ socketTimeout = 30000, path = '/tmp/app.socket-' }: IPCConfig = {}): KalmTransport {
2021
return function socket(params: ClientConfig, emitter: NodeJS.EventEmitter): Socket {
2122
let listener: net.Server;
@@ -40,7 +41,7 @@ function ipc({ socketTimeout = 30000, path = '/tmp/app.socket-' }: IPCConfig = {
4041
}
4142
}
4243

43-
function connect(handle: net.Socket): net.Socket {
44+
function connect(handle: IPCSocket): IPCSocket {
4445
const connection: net.Socket = handle || net.connect(`${path}${params.port}`);
4546
let buffer = '';
4647
connection.on('data', req => {
@@ -83,6 +84,5 @@ function ipc({ socketTimeout = 30000, path = '/tmp/app.socket-' }: IPCConfig = {
8384
};
8485
}
8586

86-
/* Exports -------------------------------------------------------------------*/
87-
87+
// Ensures support for modules and requires
8888
module.exports = ipc;

packages/ipc/types.d.ts

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,13 @@
1-
/* eslint-disable */
2-
31
declare module '@kalm/ipc' {
4-
interface IPCConfig {
2+
interface IPCConfig {
3+
/** The maximum idle time for the connection before it hangs up */
54
socketTimeout?: number
5+
/** The unique path for the IPC file descriptor (Unix only) */
66
path?: string
77
}
88

9-
interface KalmTransport {
10-
(params: any, emitter: NodeJS.EventEmitter): Socket
11-
}
12-
13-
type Remote = {
14-
host: string
15-
port: number
16-
}
17-
18-
type SocketHandle = NodeJS.Socket
19-
20-
interface Socket {
21-
bind: () => void
22-
remote: (handle: SocketHandle) => Remote
23-
connect: (handle?: SocketHandle) => SocketHandle
24-
stop: () => void
25-
send: (handle: SocketHandle, message: number[] | Buffer) => void
26-
disconnect: (handle: SocketHandle) => void
27-
}
28-
29-
export default function ipc(config?: IPCConfig): (config?: IPCConfig) => Transport;
9+
/**
10+
* Creates an IPC Transport
11+
*/
12+
export default function ipc(config?: IPCConfig): (config?: IPCConfig) => any;
3013
}

0 commit comments

Comments
 (0)