oox 0.3.0-beta11 → 0.3.0-beta13
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 -21
- package/README.md +32 -32
- package/app.js +143 -143
- package/bin/argv.js +70 -70
- package/bin/cli.js +49 -49
- package/bin/configurer.js +64 -64
- package/bin/loader.mjs +459 -459
- package/bin/proxyer.js +66 -66
- package/bin/register.js +55 -55
- package/bin/starter.js +71 -71
- package/index.js +168 -168
- package/index.mjs +4 -4
- package/logger.js +40 -40
- package/modules/http/index.js +192 -192
- package/modules/http/utils.js +73 -73
- package/modules/index.js +88 -88
- package/modules/module.js +16 -16
- package/modules/socketio/client.js +101 -101
- package/modules/socketio/index.js +168 -168
- package/modules/socketio/server.js +136 -136
- package/modules/socketio/socket.js +4 -4
- package/package.json +1 -1
- package/types/app.d.ts +51 -51
- package/types/bin/argv.d.ts +8 -8
- package/types/bin/cli.d.ts +4 -4
- package/types/bin/configurer.d.ts +3 -3
- package/types/bin/proxyer.d.ts +1 -1
- package/types/bin/register.d.ts +1 -1
- package/types/bin/starter.d.ts +3 -3
- package/types/index.d.ts +76 -76
- package/types/logger.d.ts +4 -4
- package/types/modules/http/index.d.ts +47 -47
- package/types/modules/http/utils.d.ts +17 -17
- package/types/modules/index.d.ts +24 -24
- package/types/modules/module.d.ts +13 -13
- package/types/modules/socketio/client.d.ts +23 -23
- package/types/modules/socketio/index.d.ts +37 -37
- package/types/modules/socketio/server.d.ts +35 -35
- package/types/modules/socketio/socket.d.ts +11 -11
- package/types/utils.d.ts +6 -6
- package/utils.js +63 -63
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import * as http from 'node:http';
|
|
3
|
-
import { Server, ServerOptions } from 'socket.io';
|
|
4
|
-
import { Module, ModuleConfig } from '../../index';
|
|
5
|
-
import { ServerSocket as Socket } from './socket';
|
|
6
|
-
export declare class SocketIOConfig extends ModuleConfig {
|
|
7
|
-
port: number;
|
|
8
|
-
path: string;
|
|
9
|
-
origin: string;
|
|
10
|
-
}
|
|
11
|
-
export default class SocketIOServer extends Module {
|
|
12
|
-
#private;
|
|
13
|
-
name: string;
|
|
14
|
-
config: SocketIOConfig;
|
|
15
|
-
server: http.Server;
|
|
16
|
-
socketServer: Server;
|
|
17
|
-
setConfig(config: SocketIOConfig): void;
|
|
18
|
-
getConfig(): SocketIOConfig;
|
|
19
|
-
serve(): Promise<void>;
|
|
20
|
-
stop(): Promise<void>;
|
|
21
|
-
genSocketIOServerOptions(): Partial<ServerOptions>;
|
|
22
|
-
createSocketIOServer(): void;
|
|
23
|
-
/**
|
|
24
|
-
* 服务端Socket连接事件
|
|
25
|
-
*/
|
|
26
|
-
serverOnSocketConnection(socket: Socket): void;
|
|
27
|
-
serverOnConnection(socket: Socket): void;
|
|
28
|
-
/**
|
|
29
|
-
* 服务端Socket断开事件
|
|
30
|
-
* @param {Socket} socket
|
|
31
|
-
* @param {Error} reason
|
|
32
|
-
*/
|
|
33
|
-
serverOnSocketDisconnect(socket: Socket, reason: string): void;
|
|
34
|
-
serverOnDisconnect(socket: Socket, reason: string): void;
|
|
35
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import * as http from 'node:http';
|
|
3
|
+
import { Server, ServerOptions } from 'socket.io';
|
|
4
|
+
import { Module, ModuleConfig } from '../../index';
|
|
5
|
+
import { ServerSocket as Socket } from './socket';
|
|
6
|
+
export declare class SocketIOConfig extends ModuleConfig {
|
|
7
|
+
port: number;
|
|
8
|
+
path: string;
|
|
9
|
+
origin: string;
|
|
10
|
+
}
|
|
11
|
+
export default class SocketIOServer extends Module {
|
|
12
|
+
#private;
|
|
13
|
+
name: string;
|
|
14
|
+
config: SocketIOConfig;
|
|
15
|
+
server: http.Server;
|
|
16
|
+
socketServer: Server;
|
|
17
|
+
setConfig(config: SocketIOConfig): void;
|
|
18
|
+
getConfig(): SocketIOConfig;
|
|
19
|
+
serve(): Promise<void>;
|
|
20
|
+
stop(): Promise<void>;
|
|
21
|
+
genSocketIOServerOptions(): Partial<ServerOptions>;
|
|
22
|
+
createSocketIOServer(): void;
|
|
23
|
+
/**
|
|
24
|
+
* 服务端Socket连接事件
|
|
25
|
+
*/
|
|
26
|
+
serverOnSocketConnection(socket: Socket): void;
|
|
27
|
+
serverOnConnection(socket: Socket): void;
|
|
28
|
+
/**
|
|
29
|
+
* 服务端Socket断开事件
|
|
30
|
+
* @param {Socket} socket
|
|
31
|
+
* @param {Error} reason
|
|
32
|
+
*/
|
|
33
|
+
serverOnSocketDisconnect(socket: Socket, reason: string): void;
|
|
34
|
+
serverOnDisconnect(socket: Socket, reason: string): void;
|
|
35
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Socket as _ServerSocket } from 'socket.io';
|
|
2
|
-
import { Socket as _ClientSocket } from 'socket.io-client';
|
|
3
|
-
import { RPCKeepAliveConnectionData } from '../../index';
|
|
4
|
-
export interface ServerSocket extends _ServerSocket {
|
|
5
|
-
data: RPCKeepAliveConnectionData;
|
|
6
|
-
}
|
|
7
|
-
export interface ClientSocket extends _ClientSocket {
|
|
8
|
-
data: RPCKeepAliveConnectionData;
|
|
9
|
-
}
|
|
10
|
-
export declare type Socket = ServerSocket | ClientSocket;
|
|
11
|
-
export declare const sockets: Map<string, Socket>;
|
|
1
|
+
import { Socket as _ServerSocket } from 'socket.io';
|
|
2
|
+
import { Socket as _ClientSocket } from 'socket.io-client';
|
|
3
|
+
import { RPCKeepAliveConnectionData } from '../../index';
|
|
4
|
+
export interface ServerSocket extends _ServerSocket {
|
|
5
|
+
data: RPCKeepAliveConnectionData;
|
|
6
|
+
}
|
|
7
|
+
export interface ClientSocket extends _ClientSocket {
|
|
8
|
+
data: RPCKeepAliveConnectionData;
|
|
9
|
+
}
|
|
10
|
+
export declare type Socket = ServerSocket | ClientSocket;
|
|
11
|
+
export declare const sockets: Map<string, Socket>;
|
package/types/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export declare function getIPAddress(version?: number): string[];
|
|
2
|
-
export declare function getAllCallablePropertyNames(obj: any): string[];
|
|
3
|
-
export declare function genKVMethods(methods: any, kvMethods?: Map<string, Function>, sourceKVMethods?: Map<string, Function>, nameStack?: string[]): {
|
|
4
|
-
kvMethods: Map<string, Function>;
|
|
5
|
-
sourceKVMethods: Map<string, Function>;
|
|
6
|
-
};
|
|
1
|
+
export declare function getIPAddress(version?: number): string[];
|
|
2
|
+
export declare function getAllCallablePropertyNames(obj: any): string[];
|
|
3
|
+
export declare function genKVMethods(methods: any, kvMethods?: Map<string, Function>, sourceKVMethods?: Map<string, Function>, nameStack?: string[]): {
|
|
4
|
+
kvMethods: Map<string, Function>;
|
|
5
|
+
sourceKVMethods: Map<string, Function>;
|
|
6
|
+
};
|
package/utils.js
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.genKVMethods = exports.getAllCallablePropertyNames = exports.getIPAddress = void 0;
|
|
4
|
-
const os_1 = require("os");
|
|
5
|
-
function getIPAddress(version = 4) {
|
|
6
|
-
const interfaces = (0, os_1.networkInterfaces)();
|
|
7
|
-
const ip = [];
|
|
8
|
-
for (const name of Object.keys(interfaces))
|
|
9
|
-
for (const intf of interfaces[name])
|
|
10
|
-
if (intf.mac !== '00:00:00:00:00:00')
|
|
11
|
-
if ((version !== 4 && version !== 6) || 'IPv' + version === intf.family)
|
|
12
|
-
ip.push(intf.address);
|
|
13
|
-
if (!ip.length) {
|
|
14
|
-
if (version !== 6)
|
|
15
|
-
ip.push('127.0.0.1');
|
|
16
|
-
if (version !== 4)
|
|
17
|
-
ip.push('::1');
|
|
18
|
-
}
|
|
19
|
-
return ip;
|
|
20
|
-
}
|
|
21
|
-
exports.getIPAddress = getIPAddress;
|
|
22
|
-
function getAllCallablePropertyNames(obj) {
|
|
23
|
-
if (!obj)
|
|
24
|
-
return [];
|
|
25
|
-
let props = [], tmpProps = [], index = 0, size = 0, tmpProp = '';
|
|
26
|
-
const bans = ["constructor", "__defineGetter__", "__defineSetter__",
|
|
27
|
-
"hasOwnProperty", "__lookupGetter__", "__lookupSetter__",
|
|
28
|
-
"isPrototypeOf", "propertyIsEnumerable", "toString",
|
|
29
|
-
"valueOf", "__proto__", "toLocaleString"];
|
|
30
|
-
do {
|
|
31
|
-
tmpProps = Object.getOwnPropertyNames(obj);
|
|
32
|
-
index = -1, size = tmpProps.length;
|
|
33
|
-
while (++index < size) {
|
|
34
|
-
tmpProp = tmpProps[index];
|
|
35
|
-
if (!props.includes(tmpProp) && !bans.includes(tmpProp)) {
|
|
36
|
-
props.push(tmpProp);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
} while (obj = Object.getPrototypeOf(obj));
|
|
40
|
-
return props;
|
|
41
|
-
}
|
|
42
|
-
exports.getAllCallablePropertyNames = getAllCallablePropertyNames;
|
|
43
|
-
function genKVMethods(methods, kvMethods = new Map(), sourceKVMethods = new Map(), nameStack = []) {
|
|
44
|
-
let keys = getAllCallablePropertyNames(methods);
|
|
45
|
-
for (const key of keys) {
|
|
46
|
-
/**
|
|
47
|
-
* @type {Function}
|
|
48
|
-
*/
|
|
49
|
-
let val = methods[key];
|
|
50
|
-
if ('function' === typeof val) {
|
|
51
|
-
const action = nameStack.concat(key).join('.');
|
|
52
|
-
// 原函数绑定
|
|
53
|
-
sourceKVMethods.set(action, val);
|
|
54
|
-
// 壳函数绑定
|
|
55
|
-
kvMethods.set(action, val.bind(methods));
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
genKVMethods(val, kvMethods, sourceKVMethods, nameStack.concat(key));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return { kvMethods, sourceKVMethods };
|
|
62
|
-
}
|
|
63
|
-
exports.genKVMethods = genKVMethods;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.genKVMethods = exports.getAllCallablePropertyNames = exports.getIPAddress = void 0;
|
|
4
|
+
const os_1 = require("os");
|
|
5
|
+
function getIPAddress(version = 4) {
|
|
6
|
+
const interfaces = (0, os_1.networkInterfaces)();
|
|
7
|
+
const ip = [];
|
|
8
|
+
for (const name of Object.keys(interfaces))
|
|
9
|
+
for (const intf of interfaces[name])
|
|
10
|
+
if (intf.mac !== '00:00:00:00:00:00')
|
|
11
|
+
if ((version !== 4 && version !== 6) || 'IPv' + version === intf.family)
|
|
12
|
+
ip.push(intf.address);
|
|
13
|
+
if (!ip.length) {
|
|
14
|
+
if (version !== 6)
|
|
15
|
+
ip.push('127.0.0.1');
|
|
16
|
+
if (version !== 4)
|
|
17
|
+
ip.push('::1');
|
|
18
|
+
}
|
|
19
|
+
return ip;
|
|
20
|
+
}
|
|
21
|
+
exports.getIPAddress = getIPAddress;
|
|
22
|
+
function getAllCallablePropertyNames(obj) {
|
|
23
|
+
if (!obj)
|
|
24
|
+
return [];
|
|
25
|
+
let props = [], tmpProps = [], index = 0, size = 0, tmpProp = '';
|
|
26
|
+
const bans = ["constructor", "__defineGetter__", "__defineSetter__",
|
|
27
|
+
"hasOwnProperty", "__lookupGetter__", "__lookupSetter__",
|
|
28
|
+
"isPrototypeOf", "propertyIsEnumerable", "toString",
|
|
29
|
+
"valueOf", "__proto__", "toLocaleString"];
|
|
30
|
+
do {
|
|
31
|
+
tmpProps = Object.getOwnPropertyNames(obj);
|
|
32
|
+
index = -1, size = tmpProps.length;
|
|
33
|
+
while (++index < size) {
|
|
34
|
+
tmpProp = tmpProps[index];
|
|
35
|
+
if (!props.includes(tmpProp) && !bans.includes(tmpProp)) {
|
|
36
|
+
props.push(tmpProp);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
} while (obj = Object.getPrototypeOf(obj));
|
|
40
|
+
return props;
|
|
41
|
+
}
|
|
42
|
+
exports.getAllCallablePropertyNames = getAllCallablePropertyNames;
|
|
43
|
+
function genKVMethods(methods, kvMethods = new Map(), sourceKVMethods = new Map(), nameStack = []) {
|
|
44
|
+
let keys = getAllCallablePropertyNames(methods);
|
|
45
|
+
for (const key of keys) {
|
|
46
|
+
/**
|
|
47
|
+
* @type {Function}
|
|
48
|
+
*/
|
|
49
|
+
let val = methods[key];
|
|
50
|
+
if ('function' === typeof val) {
|
|
51
|
+
const action = nameStack.concat(key).join('.');
|
|
52
|
+
// 原函数绑定
|
|
53
|
+
sourceKVMethods.set(action, val);
|
|
54
|
+
// 壳函数绑定
|
|
55
|
+
kvMethods.set(action, val.bind(methods));
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
genKVMethods(val, kvMethods, sourceKVMethods, nameStack.concat(key));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return { kvMethods, sourceKVMethods };
|
|
62
|
+
}
|
|
63
|
+
exports.genKVMethods = genKVMethods;
|