@rljson/server 0.0.3
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.
- package/LICENSE +21 -0
- package/README.architecture.md +9 -0
- package/README.blog.md +11 -0
- package/README.contributors.md +32 -0
- package/README.md +24 -0
- package/README.public.md +129 -0
- package/README.trouble.md +23 -0
- package/dist/README.architecture.md +9 -0
- package/dist/README.blog.md +11 -0
- package/dist/README.contributors.md +32 -0
- package/dist/README.md +24 -0
- package/dist/README.public.md +129 -0
- package/dist/README.trouble.md +23 -0
- package/dist/base-node.d.ts +22 -0
- package/dist/client.d.ts +56 -0
- package/dist/example.d.ts +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/server.d.ts +104 -0
- package/dist/server.js +1403 -0
- package/dist/socket-io-bridge.d.ts +29 -0
- package/dist/src/example.ts +27 -0
- package/package.json +60 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Socket } from '@rljson/io';
|
|
2
|
+
import { Socket as ServerSocket } from 'socket.io';
|
|
3
|
+
import { Socket as ClientSocket } from 'socket.io-client';
|
|
4
|
+
/**
|
|
5
|
+
* Bridge class that adapts Socket.IO sockets to the \@rljson/io Socket interface.
|
|
6
|
+
* Works with both server-side and client-side Socket.IO implementations.
|
|
7
|
+
*/
|
|
8
|
+
export declare class SocketIoBridge implements Socket {
|
|
9
|
+
private _socket;
|
|
10
|
+
constructor(_socket: ServerSocket | ClientSocket);
|
|
11
|
+
get connected(): boolean;
|
|
12
|
+
get disconnected(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Connect the socket.
|
|
15
|
+
* Note: Socket.IO server sockets don't have a connect() method as they are
|
|
16
|
+
* already connected when created. This is a no-op for server sockets.
|
|
17
|
+
* For client sockets, this calls the underlying connect() method.
|
|
18
|
+
*/
|
|
19
|
+
connect(): void;
|
|
20
|
+
disconnect(): void;
|
|
21
|
+
on(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
22
|
+
emit(eventName: string | symbol, ...args: any[]): this;
|
|
23
|
+
off(eventName: string | symbol, listener: (...args: any[]) => void): this;
|
|
24
|
+
removeAllListeners(eventName?: string | symbol): this;
|
|
25
|
+
/**
|
|
26
|
+
* Get the underlying Socket.IO socket instance.
|
|
27
|
+
*/
|
|
28
|
+
get rawSocket(): ServerSocket | ClientSocket;
|
|
29
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// @license
|
|
2
|
+
// Copyright (c) 2025 Rljson
|
|
3
|
+
//
|
|
4
|
+
// Use of this source code is governed by terms that can be
|
|
5
|
+
// found in the LICENSE file in the root of this package.
|
|
6
|
+
|
|
7
|
+
import { Server } from './server.ts';
|
|
8
|
+
|
|
9
|
+
export const example = async () => {
|
|
10
|
+
// Print methods
|
|
11
|
+
const l = console.log;
|
|
12
|
+
const h1 = (text: string) => l(`${text}`);
|
|
13
|
+
const h2 = (text: string) => l(` ${text.split('\n')}`);
|
|
14
|
+
const p = (text: string) => l(` ${text}`);
|
|
15
|
+
|
|
16
|
+
// Example
|
|
17
|
+
h1('Server.example');
|
|
18
|
+
h2('Returns an instance of the Server.');
|
|
19
|
+
const example = await Server.example();
|
|
20
|
+
p(JSON.stringify(example.clients, null, 2));
|
|
21
|
+
p(JSON.stringify(example.route, null, 2));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/*
|
|
25
|
+
// Run via "npx vite-node src/example.ts"
|
|
26
|
+
example();
|
|
27
|
+
*/
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rljson/server",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "Rljson server description",
|
|
5
|
+
"homepage": "https://github.com/rljson/server",
|
|
6
|
+
"bugs": "https://github.com/rljson/server/issues",
|
|
7
|
+
"private": false,
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"engines": {
|
|
10
|
+
"node": ">=22.14.0"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/rljson/server.git"
|
|
15
|
+
},
|
|
16
|
+
"main": "dist/server.js",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"type": "module",
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^25.0.10",
|
|
24
|
+
"@typescript-eslint/eslint-plugin": "^8.53.1",
|
|
25
|
+
"@typescript-eslint/parser": "^8.53.1",
|
|
26
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
27
|
+
"cross-env": "^10.1.0",
|
|
28
|
+
"eslint": "^9.39.2",
|
|
29
|
+
"eslint-plugin-jsdoc": "^62.3.1",
|
|
30
|
+
"eslint-plugin-tsdoc": "^0.5.0",
|
|
31
|
+
"globals": "^17.1.0",
|
|
32
|
+
"jsdoc": "^4.0.5",
|
|
33
|
+
"read-pkg": "^10.0.0",
|
|
34
|
+
"socket.io": "^4.8.3",
|
|
35
|
+
"socket.io-client": "^4.8.3",
|
|
36
|
+
"typescript": "~5.9.3",
|
|
37
|
+
"typescript-eslint": "^8.53.1",
|
|
38
|
+
"vite": "^7.3.1",
|
|
39
|
+
"vite-node": "^5.3.0",
|
|
40
|
+
"vite-plugin-dts": "^4.5.4",
|
|
41
|
+
"vite-tsconfig-paths": "^6.0.4",
|
|
42
|
+
"vitest": "^4.0.18",
|
|
43
|
+
"vitest-dom": "^0.1.1"
|
|
44
|
+
},
|
|
45
|
+
"dependencies": {
|
|
46
|
+
"@rljson/bs": "^0.0.19",
|
|
47
|
+
"@rljson/db": "^0.0.12",
|
|
48
|
+
"@rljson/hash": "^0.0.18",
|
|
49
|
+
"@rljson/io": "^0.0.64",
|
|
50
|
+
"@rljson/json": "^0.0.23",
|
|
51
|
+
"@rljson/rljson": "^0.0.74"
|
|
52
|
+
},
|
|
53
|
+
"scripts": {
|
|
54
|
+
"build": "pnpx vite build && tsc && node scripts/copy-readme-to-dist.js",
|
|
55
|
+
"test": "pnpx vitest run --coverage && pnpm run lint",
|
|
56
|
+
"prebuild": "npm run test",
|
|
57
|
+
"lint": "pnpx eslint",
|
|
58
|
+
"updateGoldens": "cross-env UPDATE_GOLDENS=true pnpm test"
|
|
59
|
+
}
|
|
60
|
+
}
|