Skip to content

Commit 731491d

Browse files
authored
Merge pull request #31 from kalm/v4.0.0
V4.0.0
2 parents 7240230 + ce6d1af commit 731491d

File tree

38 files changed

+760
-194
lines changed

38 files changed

+760
-194
lines changed

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,18 @@ packages/tcp/bin
5050
packages/udp/bin
5151
packages/ws/bin
5252
packages/webrtc/bin
53+
54+
# publish-only files
55+
packages/kalm/LICENSE
56+
packages/ipc/LICENSE
57+
packages/tcp/LICENSE
58+
packages/udp/LICENSE
59+
packages/ws/LICENSE
60+
packages/webrtc/LICENSE
61+
62+
packages/kalm/CHANGELOG.md
63+
packages/ipc/CHANGELOG.md
64+
packages/tcp/CHANGELOG.md
65+
packages/udp/CHANGELOG.md
66+
packages/ws/CHANGELOG.md
67+
packages/webrtc/CHANGELOG.md

CHANGELOG.md

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
# Changelog
2+
3+
## [v3.3.0] - 2020-01-30
4+
5+
commit: [af46059](https://github.com/kalm/kalm.js/commit/af4605958c567b5243887f911850a3c0eb6c6659)
6+
7+
### Added
8+
- Adds webrtc package and examples
9+
- Adds the getChannels method on Client
10+
11+
### Removed
12+
- Removed home implementation of EventEmitter in favor of Node's
13+
14+
## [v3.2.3] - 2020-01-14
15+
16+
commit: [c188225](https://github.com/kalm/kalm.js/commit/c18822532a49f2026eddf44cfbe3cfc1521110f8)
17+
18+
### Added
19+
- Added pre-hook for lint on commit
20+
21+
### Changed
22+
- Cleaned up Types management and typings file accessibility
23+
- Migrated test suite to Jest and centralized test tooling
24+
- Removed output rollup, and using only tsc with none modules
25+
- Fixed linting (was not targeting .ts files properly)
26+
- Fixed stats events (were previously unreachable, now exposed through client emitter as .*)
27+
- Fixed timeout behavior (only logged, now actually disconnects)
28+
29+
## [v3.1.2] - 2019-07-01
30+
31+
commit: [fac8047](https://github.com/kalm/kalm.js/commit/fac8047d4b7048d56803505103159e16d8f518a8)
32+
33+
### Changed
34+
- Changed dev tooling from lerna to yarn workspaces
35+
- Changed dev tooling from tslint to eslint + @typescript-eslint
36+
- Housekeeping
37+
38+
## [v3.0.0] - 2019-01-18
39+
40+
commit: [a4c687d](https://github.com/kalm/kalm.js/commit/a4c687dd5786a70723d9d0964a9d189220d58418)
41+
42+
### Added
43+
- New monorepo structure
44+
- Massive new changes to the interface
45+
46+
### Changed
47+
- Serialization is now a toggle for json/binary
48+
- Re-written the entire codebase in Typescript
49+
50+
### Removed
51+
- Transports are no longer bundled and must be installed separately and must be instantiated with options.
52+
- [ipc](https://www.npmjs.com/package/@kalm/ipc)
53+
- [tcp](https://www.npmjs.com/package/@kalm/tcp)
54+
- [udp](https://www.npmjs.com/package/@kalm/udp)
55+
- [ws](https://www.npmjs.com/package/@kalm/ws)
56+
- Profiles become routines and must be instantiated with options.
57+
- No more session stores
58+
- No more encryption
59+
60+
## [v2.6.1] - 2018-01-27
61+
62+
commit: [7393d17](https://github.com/kalm/kalm.js/commit/7393d17efb02088d7283ba83108fd7ab15e3d39e)
63+
64+
### Added
65+
- Added package-lock.json file
66+
- Added server reference in the client object
67+
68+
## [v2.5.0] - 2017-09-21
69+
70+
commit: [2c687f6](https://github.com/kalm/kalm.js/commit/2c687f6074787af6b39c10abe19669fe20e7b02d)
71+
72+
### Added
73+
- Added engines reqs
74+
75+
### Changed
76+
- Some minor performance tuning
77+
78+
## [v2.4.0] - 2017-09-01
79+
80+
commit: [a7b8f95](https://github.com/kalm/kalm.js/commit/a7b8f950da56cbe35c538dc02e3dcc0e6d3a3db3)
81+
82+
### Changed
83+
- Tuned performances
84+
- Added build targets for Node 8.x and 6.x
85+
- UDP client cache (tied with socketTimeout)
86+
- Bumped dependencies
87+
- Proper callback on disconnect
88+
89+
### Removed
90+
- Dropped support for Node 4.x
91+
92+
## [v2.3.0] - 2017-07-25
93+
94+
commit: [f323bcd](https://github.com/kalm/kalm.js/commit/f323bcdc163faa40b0f8515fd4a8759e5180f516)
95+
96+
### Added
97+
- Added realtime profile
98+
- Added JSDoc
99+
- Added parameter validation and error messages
100+
101+
### Changed
102+
- Better performances (3x with default congestion)
103+
104+
## [v2.2.0] - 2017-06-21
105+
106+
commit: [b9f3bdd](https://github.com/kalm/kalm.js/commit/b9f3bdd50de8dae2b92a0866d234a0cb2e72f22b)
107+
108+
### Added
109+
- Added support for node 8
110+
111+
## [v2.1.0] - 2017-06-20
112+
113+
commit: [129146f](https://github.com/kalm/kalm.js/commit/129146feeab14e94a540a4d9c54e05a4614fdb39)
114+
115+
### Changed
116+
- Simplified and optimized queue system logic
117+
- Now allowing 0 to be passed as tick value in profiles
118+
- Added warning when non-serialized message are sent and serial config is `null`
119+
- Fixed hanging packets on maxBytes just reached
120+
121+
## [v2.0.0] - 2017-03-02
122+
123+
commit: [b5209ec](https://github.com/kalm/kalm.js/commit/b5209ec4d3ab86000b72b502d120f0a5b4da85af)
124+
125+
### Added
126+
- Migrated the codebase from the [original repo](https://github.com/fed135/kalm)
127+
- Implemeted new interface

jest.config.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

package.json

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"scripts": {
88
"lint": "eslint **/*.ts **/*.spec.ts",
99
"lint:fix": "yarn lint --fix",
10-
"test": "jest ./packages && jest ./tests/integration --forceExit",
10+
"test": "yarn workspaces run test && jest ./tests/integration --forceExit",
1111
"build": "yarn workspaces run build",
1212
"clean": "yarn workspaces run clean",
1313
"bench": "node ./scripts/benchmarks"
@@ -39,23 +39,29 @@
3939
"pre-commit": "yarn lint"
4040
}
4141
},
42+
"jest": {
43+
"preset": "ts-jest",
44+
"testEnvironment": "node",
45+
"globals": {
46+
"ts-jest": {
47+
"diagnostics": false,
48+
"isolatedModules": true
49+
}
50+
}
51+
},
4252
"devDependencies": {
43-
"@types/jest": "^24.0.17",
44-
"@types/node": "^13.1.0",
45-
"@typescript-eslint/eslint-plugin": "^2.14.0",
46-
"@typescript-eslint/parser": "^2.14.0",
53+
"@types/jest": "^25.1.0",
54+
"@types/node": "^13.9.0",
55+
"@typescript-eslint/eslint-plugin": "^2.24.0",
56+
"@typescript-eslint/parser": "^2.24.0",
4757
"eslint": "^6.8.0",
48-
"eslint-config-airbnb-base": "^14.0.0",
49-
"eslint-plugin-import": "^2.19.0",
50-
"husky": "^3.1.0",
51-
"jest": "^24.9.0",
58+
"eslint-config-airbnb-base": "^14.1.0",
59+
"eslint-plugin-import": "^2.20.0",
60+
"husky": "^4.2.0",
61+
"jest": "^25.1.0",
5262
"socket.io": "^2.3.0",
5363
"socket.io-client": "^2.3.0",
54-
"ts-jest": "^24.2.0",
55-
"typescript": "^3.7.4"
56-
},
57-
"dependencies": {
58-
"webpack": "^4.41.5",
59-
"webpack-cli": "^3.3.10"
64+
"ts-jest": "^25.2.0",
65+
"typescript": "^3.8.0"
6066
}
6167
}

packages/ipc/README.md

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
# Kalm IPC (Inter-process-communication) transport
1+
<h1 align="center">
2+
<a title="The socket optimizer" href="http://kalm.js.org">
3+
<img alt="Kalm" width="300px" src="https://kalm.js.org/images/kalmv3.png" />
4+
<br/>
5+
</a>
6+
Kalm
7+
</h1>
8+
<h3 align="center">
9+
The Socket Optimizer
10+
<br/><br/>
11+
</h3>
12+
<br/>
13+
14+
[![Kalm](https://img.shields.io/npm/v/kalm.svg)](https://www.npmjs.com/package/@kalm/ipc)
15+
[![Build Status](https://github.com/kalm/kalm.js/workflows/master-status/badge.svg)](https://github.com/kalm/kalm.js/actions?query=workflow%3A+master-status)
16+
![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/kalm/kalm.js)
17+
[![Financial Contributors on Open Collective](https://opencollective.com/kalm/all/badge.svg?label=financial+contributors)](https://opencollective.com/kalm)
18+
[![Join the chat at https://gitter.im/KALM/home](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/KALM/?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
19+
220

321
## Installing
422

@@ -8,8 +26,8 @@
826

927
```
1028
{
11-
socketTimeout = 30000,
12-
path = '/tmp/app.socket-'
29+
socketTimeout: 30000,
30+
path: '/tmp/app.socket'
1331
}
1432
```
1533

packages/ipc/package.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"main": "bin/ipc.js",
66
"scripts": {
77
"build": "../../scripts/build.sh ipc",
8-
"clean": "../../scripts/cleanup.sh"
8+
"clean": "../../scripts/cleanup.sh",
9+
"test": "jest ./tests",
10+
"prepublish": "cp ../../LICENSE ./LICENSE && cp ../../CHANGELOG.md ./CHANGELOG.md"
911
},
1012
"funding": {
1113
"type": "Open Collective",
@@ -16,23 +18,11 @@
1618
"url": "git+https://github.com/kalm/kalm-js.git"
1719
},
1820
"keywords": [
19-
"multiplex",
21+
"framework",
2022
"network",
21-
"optimize",
23+
"realtime",
2224
"socket",
23-
"websocket",
24-
"client",
25-
"server",
26-
"service",
27-
"peer",
28-
"micro",
29-
"latency",
30-
"messaging",
31-
"queue",
3225
"nagle",
33-
"buffer",
34-
"protocol",
35-
"web",
3626
"ipc"
3727
],
3828
"files": ["bin", "types.d.ts"],
@@ -49,5 +39,15 @@
4939
"browser": {
5040
"net": false,
5141
"fs": false
42+
},
43+
"jest": {
44+
"preset": "ts-jest",
45+
"testEnvironment": "node",
46+
"globals": {
47+
"ts-jest": {
48+
"diagnostics": false,
49+
"isolatedModules": true
50+
}
51+
}
5252
}
5353
}

packages/ipc/src/ipc.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface IPCSocket extends net.Socket {
1313
}
1414
}
1515

16-
export function ipc({ socketTimeout = 30000, path = '/tmp/app.socket-' }: IPCConfig = {}): KalmTransport {
16+
function ipc({ socketTimeout = 30000, path = '/tmp/app.socket-' }: IPCConfig = {}): KalmTransport {
1717
return function socket(params: ClientConfig, emitter: NodeJS.EventEmitter): Socket {
1818
let listener: net.Server;
1919

@@ -25,8 +25,8 @@ export function ipc({ socketTimeout = 30000, path = '/tmp/app.socket-' }: IPCCon
2525

2626
function remote(handle: IPCSocket): Remote {
2727
return {
28-
host: handle._server._pipeName,
29-
port: handle._handle.fd,
28+
host: handle && handle._server && handle._server._pipeName || null,
29+
port: handle && handle._handle && handle._handle.fd || null,
3030
};
3131
}
3232

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,40 @@
1+
import { EventEmitter } from 'events';
12
import * as ipc from '../../src/ipc';
23

34
describe('IPC transport', () => {
4-
it('TODO', () => { expect(ipc).not.toBeUndefined(); });
5+
it('basic setup', () => {
6+
expect(typeof ipc.default).toBe('function');
7+
const transport = ipc.default();
8+
expect(typeof transport).toBe('function');
9+
const socket = transport({}, new EventEmitter());
10+
11+
expect(socket).toHaveProperty('bind', expect.any(Function));
12+
expect(socket).toHaveProperty('connect', expect.any(Function));
13+
expect(socket).toHaveProperty('disconnect', expect.any(Function));
14+
expect(socket).toHaveProperty('remote', expect.any(Function));
15+
expect(socket).toHaveProperty('stop', expect.any(Function));
16+
expect(socket).toHaveProperty('send', expect.any(Function));
17+
});
18+
19+
describe('Given an empty handle reference and no configs', () => {
20+
const transport = ipc.default();
21+
const socket = transport({}, new EventEmitter());
22+
23+
describe('when fetching remote', () => {
24+
it('should return null values', () => {
25+
expect(socket.remote()).toEqual({ host: null, port: null });
26+
});
27+
});
28+
});
29+
30+
describe('Given a handle reference and no configs', () => {
31+
const transport = ipc.default();
32+
const socket = transport({}, new EventEmitter());
33+
34+
describe('when fetching remote', () => {
35+
it('should return handle\'s values', () => {
36+
expect(socket.remote({ _server: { _pipeName: '/foo' }, _handle: { fd: 12345 } })).toEqual({ host: '/foo', port: 12345 });
37+
});
38+
});
39+
});
540
});

0 commit comments

Comments
 (0)