@domain.js/main 0.6.5 → 0.7.0
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/dist/deps/defines.js +17 -17
- package/dist/http/socket.d.ts +1 -0
- package/dist/http/socket.js +12 -0
- package/dist/index.d.ts +3 -3
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +1 -1
package/dist/deps/defines.js
CHANGED
|
@@ -37,21 +37,21 @@ const schema = __importStar(require("./schema"));
|
|
|
37
37
|
const sequelize = __importStar(require("./sequelize"));
|
|
38
38
|
const signer = __importStar(require("./signer"));
|
|
39
39
|
module.exports = {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
aes: aes,
|
|
41
|
+
cache: cache,
|
|
42
|
+
checker: checker,
|
|
43
|
+
counter: counter,
|
|
44
|
+
cron: cron,
|
|
45
|
+
frequency: frequency,
|
|
46
|
+
graceful: graceful,
|
|
47
|
+
hash: hash,
|
|
48
|
+
logger: logger,
|
|
49
|
+
myCia: myCia,
|
|
50
|
+
parallel: parallel,
|
|
51
|
+
redis: redis,
|
|
52
|
+
request: request,
|
|
53
|
+
rest: rest,
|
|
54
|
+
schema: schema,
|
|
55
|
+
sequelize: sequelize,
|
|
56
|
+
signer: signer,
|
|
57
57
|
};
|
package/dist/http/socket.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export declare type Client = Socket<DefaultEventsMap, DefaultEventsMap, DefaultE
|
|
|
14
14
|
/** 退出房间回调函数 */
|
|
15
15
|
quit?: Function;
|
|
16
16
|
entranceOpts?: any[];
|
|
17
|
+
extra?: Record<string, any>;
|
|
17
18
|
};
|
|
18
19
|
declare const makeProfile: (client: Client, type: string | undefined, auth: string | Signature | undefined, extra?: Profile["extra"]) => Profile;
|
|
19
20
|
export declare function BridgeSocket(io: Server, domain: Domain): void;
|
package/dist/http/socket.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BridgeSocket = void 0;
|
|
4
|
+
const basic_errors_1 = require("../basic-errors");
|
|
4
5
|
const proxyIps = new Set(["127.0.0.1"]);
|
|
5
6
|
class MyError extends Error {
|
|
6
7
|
constructor(code, message, data) {
|
|
@@ -83,12 +84,18 @@ function BridgeSocket(io, domain) {
|
|
|
83
84
|
io.on("connection", (client) => {
|
|
84
85
|
// 定义toJSON 避免 schema 验证报错
|
|
85
86
|
Object.assign(client, {
|
|
87
|
+
extra: {},
|
|
86
88
|
toJSON() {
|
|
87
89
|
return {};
|
|
88
90
|
},
|
|
89
91
|
});
|
|
90
92
|
console.log("[%s] connection: client.id: %s", new Date(), client.id);
|
|
91
93
|
client.on("init", async (type, auth, extra = {}) => {
|
|
94
|
+
if (client.inited)
|
|
95
|
+
throw basic_errors_1.errors.notAllowed("已经初始化,请勿重复操作");
|
|
96
|
+
if (client.extra.initing)
|
|
97
|
+
throw basic_errors_1.errors.notAllowed("正在初始化,请勿重复操作");
|
|
98
|
+
client.extra.initing = true;
|
|
92
99
|
console.log("[%s] socket.init: client.id: %s", new Date(), client.id);
|
|
93
100
|
try {
|
|
94
101
|
Object.assign(client, { profile: makeProfile(client, type, auth, extra) });
|
|
@@ -106,8 +113,12 @@ function BridgeSocket(io, domain) {
|
|
|
106
113
|
client.emit("internalError", e.code || "unknown", e.message, e.data);
|
|
107
114
|
console.error(e);
|
|
108
115
|
}
|
|
116
|
+
client.extra.initing = false;
|
|
109
117
|
});
|
|
110
118
|
client.on("entrance", async (roomId, ...opts) => {
|
|
119
|
+
if (client.extra.entrancing)
|
|
120
|
+
throw basic_errors_1.errors.notAllowed("正在进入房间,请勿重复操作");
|
|
121
|
+
client.extra.entrancing = true;
|
|
111
122
|
try {
|
|
112
123
|
if (!client.profile || !client.inited)
|
|
113
124
|
return;
|
|
@@ -123,6 +134,7 @@ function BridgeSocket(io, domain) {
|
|
|
123
134
|
client.emit("internalError", e.code || "unknown", e.message, e.data);
|
|
124
135
|
console.error(e);
|
|
125
136
|
}
|
|
137
|
+
client.extra.entrancing = false;
|
|
126
138
|
});
|
|
127
139
|
client.use(async ([name, params, responseId], next) => {
|
|
128
140
|
if (name === "init" || name === "entrance")
|
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare function Main<T extends Readonly<Array<keyof TDeps>>>(features: T
|
|
|
28
28
|
myCia: typeof import("./deps/myCia");
|
|
29
29
|
parallel: typeof import("./deps/parallel");
|
|
30
30
|
redis: typeof import("./deps/redis");
|
|
31
|
-
request: typeof import("./deps/request");
|
|
31
|
+
request: typeof import("./deps/request");
|
|
32
32
|
rest: typeof import("./deps/rest");
|
|
33
33
|
schema: typeof import("./deps/schema");
|
|
34
34
|
sequelize: typeof import("./deps/sequelize");
|
|
@@ -46,7 +46,7 @@ export declare function Main<T extends Readonly<Array<keyof TDeps>>>(features: T
|
|
|
46
46
|
myCia: typeof import("./deps/myCia");
|
|
47
47
|
parallel: typeof import("./deps/parallel");
|
|
48
48
|
redis: typeof import("./deps/redis");
|
|
49
|
-
request: typeof import("./deps/request");
|
|
49
|
+
request: typeof import("./deps/request");
|
|
50
50
|
rest: typeof import("./deps/rest");
|
|
51
51
|
schema: typeof import("./deps/schema");
|
|
52
52
|
sequelize: typeof import("./deps/sequelize");
|
|
@@ -64,7 +64,7 @@ export declare function Main<T extends Readonly<Array<keyof TDeps>>>(features: T
|
|
|
64
64
|
myCia: typeof import("./deps/myCia");
|
|
65
65
|
parallel: typeof import("./deps/parallel");
|
|
66
66
|
redis: typeof import("./deps/redis");
|
|
67
|
-
request: typeof import("./deps/request");
|
|
67
|
+
request: typeof import("./deps/request");
|
|
68
68
|
rest: typeof import("./deps/rest");
|
|
69
69
|
schema: typeof import("./deps/schema");
|
|
70
70
|
sequelize: typeof import("./deps/sequelize");
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -105,5 +105,5 @@ export declare const deepReaddir: (dir: string, exts: Set<string>, excludes?: Se
|
|
|
105
105
|
* 判断某个值是否为一个流
|
|
106
106
|
* @param stream 要判断的对象
|
|
107
107
|
*/
|
|
108
|
-
export declare const isStream: (stream: any) =>
|
|
108
|
+
export declare const isStream: (stream: any) => boolean;
|
|
109
109
|
export {};
|
package/dist/utils/index.js
CHANGED
|
@@ -209,5 +209,5 @@ exports.deepReaddir = deepReaddir;
|
|
|
209
209
|
* 判断某个值是否为一个流
|
|
210
210
|
* @param stream 要判断的对象
|
|
211
211
|
*/
|
|
212
|
-
const isStream = (stream) => stream && typeof stream === "object" && typeof stream.pipe === "function";
|
|
212
|
+
const isStream = (stream) => Boolean(stream && typeof stream === "object" && typeof stream.pipe === "function");
|
|
213
213
|
exports.isStream = isStream;
|