@eleven-am/pondsocket 0.1.218 → 0.1.219

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +84 -164
  2. package/{abstracts → dist/abstracts}/types.d.ts +3 -3
  3. package/{contexts → dist/contexts}/baseContext.d.ts +3 -1
  4. package/{contexts → dist/contexts}/baseContext.js +6 -0
  5. package/{contexts → dist/contexts}/eventContext.d.ts +2 -2
  6. package/{contexts → dist/contexts}/joinContext.js +8 -2
  7. package/dist/contexts/outgoingContext.d.ts +36 -0
  8. package/{contexts → dist/contexts}/outgoingContext.js +12 -6
  9. package/{engines → dist/engines}/channelEngine.d.ts +1 -1
  10. package/{engines → dist/engines}/channelEngine.js +23 -11
  11. package/{engines → dist/engines}/endpointEngine.d.ts +2 -1
  12. package/{engines → dist/engines}/endpointEngine.js +29 -11
  13. package/{engines → dist/engines}/lobbyEngine.js +12 -8
  14. package/{index.d.ts → dist/index.d.ts} +1 -0
  15. package/dist/matcher/matcher.js +17 -0
  16. package/{server → dist/server}/server.d.ts +8 -4
  17. package/{server → dist/server}/server.js +112 -33
  18. package/{types.d.ts → dist/types.d.ts} +1 -0
  19. package/{wrappers → dist/wrappers}/channel.d.ts +5 -5
  20. package/{wrappers → dist/wrappers}/channel.js +9 -6
  21. package/{wrappers → dist/wrappers}/endpoint.d.ts +4 -2
  22. package/{wrappers → dist/wrappers}/pondChannel.d.ts +4 -4
  23. package/{wrappers → dist/wrappers}/pondChannel.js +6 -6
  24. package/package.json +48 -64
  25. package/contexts/outgoingContext.d.ts +0 -28
  26. package/matcher/matcher.js +0 -74
  27. /package/{abstracts → dist/abstracts}/distributor.d.ts +0 -0
  28. /package/{abstracts → dist/abstracts}/distributor.js +0 -0
  29. /package/{abstracts → dist/abstracts}/middleware.d.ts +0 -0
  30. /package/{abstracts → dist/abstracts}/middleware.js +0 -0
  31. /package/{abstracts → dist/abstracts}/types.js +0 -0
  32. /package/{contexts → dist/contexts}/connectionContext.d.ts +0 -0
  33. /package/{contexts → dist/contexts}/connectionContext.js +0 -0
  34. /package/{contexts → dist/contexts}/eventContext.js +0 -0
  35. /package/{contexts → dist/contexts}/joinContext.d.ts +0 -0
  36. /package/{engines → dist/engines}/lobbyEngine.d.ts +0 -0
  37. /package/{engines → dist/engines}/presenceEngine.d.ts +0 -0
  38. /package/{engines → dist/engines}/presenceEngine.js +0 -0
  39. /package/{errors → dist/errors}/httpError.d.ts +0 -0
  40. /package/{errors → dist/errors}/httpError.js +0 -0
  41. /package/{index.js → dist/index.js} +0 -0
  42. /package/{matcher → dist/matcher}/matcher.d.ts +0 -0
  43. /package/{types.js → dist/types.js} +0 -0
  44. /package/{wrappers → dist/wrappers}/endpoint.js +0 -0
package/package.json CHANGED
@@ -1,80 +1,65 @@
1
1
  {
2
2
  "name": "@eleven-am/pondsocket",
3
- "version": "0.1.218",
4
- "description": "PondSocket is a fast simple socket server",
3
+ "version": "0.1.219",
4
+ "description": "Typed WebSocket and SSE server with presence and distributed messaging.",
5
5
  "keywords": [
6
- "socket",
7
- "server",
8
- "ws",
6
+ "pondsocket",
9
7
  "websocket",
10
- "pubsub",
11
- "presence",
8
+ "sse",
12
9
  "realtime",
13
- "realtime server"
10
+ "presence",
11
+ "pubsub",
12
+ "redis"
14
13
  ],
15
- "publishConfig": {
16
- "access": "public"
17
- },
18
- "scripts": {
19
- "test": "jest --coverage --verbose --forceExit --detectOpenHandles --runInBand --bail",
20
- "build": "rimraf dist && tsc --project tsconfig.build.json && rm -rf dist/tests",
21
- "lint": "eslint --ext .ts src",
22
- "lint:fix": "eslint --fix --ext .ts src",
23
- "copy": "cp package.json dist && cp README.md dist && cp LICENSE dist",
24
- "push": "npm version patch && npm run copy && cd dist && npm publish && cd ..",
25
- "pipeline": "npm run lint:fix && npm run lint && npm run test && npm run build && npm run push"
26
- },
27
14
  "author": "Roy OSSAI",
28
15
  "license": "GPL-3.0",
29
- "main": "./index.js",
30
- "types": "./index.d.ts",
16
+ "homepage": "https://github.com/eleven-am/pondsocket#readme",
17
+ "bugs": {
18
+ "url": "https://github.com/eleven-am/pondsocket/issues"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/eleven-am/pondsocket.git",
23
+ "directory": "javascript/core"
24
+ },
25
+ "engines": {
26
+ "node": ">=20"
27
+ },
28
+ "type": "commonjs",
29
+ "main": "./dist/index.js",
30
+ "types": "./dist/index.d.ts",
31
31
  "exports": {
32
32
  ".": {
33
- "types": "./index.d.ts",
34
- "default": "./index.js"
33
+ "types": "./dist/index.d.ts",
34
+ "require": "./dist/index.js",
35
+ "default": "./dist/index.js"
35
36
  },
36
37
  "./types": {
37
- "types": "./index.d.ts",
38
- "default": "./index.js"
38
+ "types": "./dist/index.d.ts",
39
+ "require": "./dist/index.js",
40
+ "default": "./dist/index.js"
39
41
  }
40
42
  },
41
- "repository": {
42
- "type": "git",
43
- "url": "git+https://github.com/Eleven-am/pondSocket.git"
43
+ "files": [
44
+ "dist"
45
+ ],
46
+ "publishConfig": {
47
+ "access": "public",
48
+ "registry": "https://registry.npmjs.org"
44
49
  },
45
- "dependencies": {
46
- "@eleven-am/pondsocket-common": "^0.0.40",
47
- "@types/node": "^25.3.3",
48
- "@types/ws": "^8.18.1",
49
- "redis": "^5.12.1",
50
- "ws": "^8.20.1"
50
+ "scripts": {
51
+ "clean": "rimraf dist",
52
+ "build": "npm run clean && tsc --project tsconfig.build.json",
53
+ "test": "jest --coverage --verbose --detectOpenHandles --runInBand --bail",
54
+ "lint": "eslint src --max-warnings=0",
55
+ "prepack": "npm run build"
51
56
  },
52
- "devDependencies": {
53
- "@eslint/compat": "^1.4.0",
54
- "@eslint/eslintrc": "^3.3.4",
55
- "@eslint/js": "^9.39.4",
56
- "@stylistic/eslint-plugin-ts": "^4.4.1",
57
- "@types/jest": "^30.0.0",
58
- "@types/node": "^25.3.3",
57
+ "dependencies": {
58
+ "@eleven-am/pondsocket-common": "^0.0.41",
59
+ "@types/node": "^20.19.43",
59
60
  "@types/ws": "^8.18.1",
60
- "@typescript-eslint/eslint-plugin": "^8.59.4",
61
- "@typescript-eslint/parser": "^8.59.4",
62
- "eslint": "^9.39.4",
63
- "eslint-config-prettier": "^10.1.8",
64
- "eslint-import-resolver-node": "^0.3.9",
65
- "eslint-plugin-file-progress": "^3.0.2",
66
- "eslint-plugin-import": "^2.32.0",
67
- "eslint-plugin-prettier": "^5.5.5",
68
- "globals": "^16.4.0",
69
- "jest": "^30.2.0",
70
- "prettier": "^3.8.3",
71
- "source-map-support": "^0.5.21",
72
- "supertest": "^7.2.2",
73
- "ts-jest": "^29.4.11",
74
- "ts-loader": "^9.5.7",
75
- "ts-node": "^10.9.2",
76
- "tsconfig-paths": "^4.2.0",
77
- "typescript": "^5.9.3"
61
+ "redis": "^6.1.0",
62
+ "ws": "^8.21.0"
78
63
  },
79
64
  "jest": {
80
65
  "moduleFileExtensions": [
@@ -85,7 +70,7 @@
85
70
  "rootDir": "src",
86
71
  "testRegex": ".*\\.test\\.ts$",
87
72
  "transform": {
88
- "^.+\\.(t|j)s$": [
73
+ "^.+\\.ts$": [
89
74
  "ts-jest",
90
75
  {
91
76
  "diagnostics": false
@@ -93,15 +78,14 @@
93
78
  ]
94
79
  },
95
80
  "collectCoverageFrom": [
96
- "**/*.(t|j)s",
81
+ "**/*.ts",
97
82
  "!**/*.test.ts",
98
83
  "!**/*.d.ts",
99
84
  "!**/index.ts",
100
85
  "!**/tests/**",
101
- "!**/types.d.ts",
102
86
  "!**/abstracts/distributor.ts"
103
87
  ],
104
- "coverageDirectory": "../coverage",
88
+ "coverageDirectory": "../coverage/core",
105
89
  "testEnvironment": "node",
106
90
  "moduleNameMapper": {
107
91
  "^@eleven-am/pondsocket-common$": "<rootDir>/../../comnon/dist"
@@ -1,28 +0,0 @@
1
- import { ChannelReceivers, AnyPondSchema, Event, EventParams, EventPayload, EventsOf, PondObject } from '@eleven-am/pondsocket-common';
2
- import { BaseContext } from './baseContext';
3
- import { ChannelEngine } from '../engines/channelEngine';
4
- export declare class OutgoingContext<Path extends string, Schema extends AnyPondSchema = AnyPondSchema, EventName extends Extract<keyof EventsOf<Schema>, string> = Extract<keyof EventsOf<Schema>, string>> extends BaseContext<Path, Schema, EventName, EventPayload<EventsOf<Schema>, EventName>> {
5
- #private;
6
- constructor(event: Event, params: EventParams<Path>, engine: ChannelEngine, userid: string);
7
- get payload(): EventPayload<EventsOf<Schema>, EventName>;
8
- /**
9
- * Blocks the outgoing context, preventing further processing of the event.
10
- */
11
- block(): this;
12
- /**
13
- * Checks if the outgoing context is blocked.
14
- * @returns {boolean} - True if blocked, false otherwise.
15
- */
16
- isBlocked(): boolean;
17
- /**
18
- * Transforms the outgoing context with a new payload.
19
- * @param payload - The new payload to set for the context.
20
- */
21
- transform(payload: EventPayload<EventsOf<Schema>, EventName>): this;
22
- /**
23
- * Updates the parameters of the outgoing context.
24
- * @param params - The new parameters to set for the context.
25
- */
26
- updateParams(params: EventParams<Path>): void;
27
- protected _sendMessageToRecipients(_recipient: ChannelReceivers, _event: string, _payload: PondObject): void;
28
- }
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseAddress = parseAddress;
4
- function pathToRegexp(path) {
5
- const parts = path.split('/');
6
- const regexpParts = parts.map((part) => {
7
- if (part.startsWith(':')) {
8
- return '([^/]+)';
9
- }
10
- else if (part === '*') {
11
- return '(.*)';
12
- }
13
- return part;
14
- });
15
- return new RegExp(`^${regexpParts.join('/')}$`);
16
- }
17
- function getParams(path, route) {
18
- const regexp = pathToRegexp(route);
19
- const match = path.match(regexp);
20
- if (!match) {
21
- return null;
22
- }
23
- const cleanRoute = route.replace(/:/g, '');
24
- const cleanMatch = cleanRoute.match(regexp);
25
- if (!cleanMatch) {
26
- return null;
27
- }
28
- const keys = cleanMatch.slice(1).filter((s) => s !== '');
29
- const values = match.slice(1).filter((s) => s !== '');
30
- if (keys.length !== values.length) {
31
- return {};
32
- }
33
- return keys.reduce((params, key, index) => {
34
- if (key === '*') {
35
- params[key] = `/${values.slice(index).join('/')}`.replace(/\/+/g, '/');
36
- return params;
37
- }
38
- params[key] = values[index];
39
- return params;
40
- }, {});
41
- }
42
- function getQuery(query) {
43
- if (!query) {
44
- return {};
45
- }
46
- const searchParams = new URLSearchParams(query);
47
- const params = {};
48
- searchParams.forEach((value, key) => {
49
- params[key] = value;
50
- });
51
- return params;
52
- }
53
- function parseAddress(route, address) {
54
- if (route instanceof RegExp) {
55
- const match = address.match(route);
56
- if (!match) {
57
- return null;
58
- }
59
- return {
60
- params: {},
61
- query: {},
62
- };
63
- }
64
- const [path, queryParams] = address.split('?');
65
- const params = getParams(path, route);
66
- if (!params) {
67
- return null;
68
- }
69
- const query = getQuery(queryParams);
70
- return {
71
- params,
72
- query,
73
- };
74
- }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes