wenay-common 1.0.250 → 1.0.252
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/lib/Common/Listen.d.ts +3 -3
- package/lib/Common/Listen.js +0 -1
- package/lib/Common/SocketBuffer.d.ts +1 -1
- package/lib/Common/SocketServerHook.d.ts +2 -2
- package/lib/Common/commonsServerMini2.js +19 -8
- package/package.json +1 -1
- package/lib/Common/node_test.d.ts +0 -1
- package/lib/Common/node_test.js +0 -14
- package/lib/tsconfig.json +0 -6
package/lib/Common/Listen.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export declare function funcListenCallbackFast<T>(a: (e: (Listener<NormalizeTupl
|
|
|
25
25
|
addListen: (cb: Listener<NormalizeTuple<T>>, cbClose?: (() => void) | undefined) => () => void;
|
|
26
26
|
removeListen: (cb: Listener<NormalizeTuple<T>> | null) => void;
|
|
27
27
|
count: () => number;
|
|
28
|
-
readonly getAllKeys: Listener<NormalizeTuple<
|
|
28
|
+
readonly getAllKeys: Listener<NormalizeTuple<T>>[];
|
|
29
29
|
};
|
|
30
30
|
export declare function funcListenCallback<T>(a: (e: (Listener<NormalizeTuple<T>> | null)) => (void | (() => void)), event?: (type: "add" | "remove", count: number, api: ReturnType<typeof funcListenCallbackBase<T>>) => void, fast?: boolean): {
|
|
31
31
|
func: Listener<NormalizeTuple<T>>;
|
|
@@ -37,7 +37,7 @@ export declare function funcListenCallback<T>(a: (e: (Listener<NormalizeTuple<T>
|
|
|
37
37
|
addListen: (cb: Listener<NormalizeTuple<T>>, cbClose?: (() => void) | undefined) => () => void;
|
|
38
38
|
removeListen: (cb: Listener<NormalizeTuple<T>> | null) => void;
|
|
39
39
|
count: () => number;
|
|
40
|
-
readonly getAllKeys: Listener<NormalizeTuple<
|
|
40
|
+
readonly getAllKeys: Listener<NormalizeTuple<T>>[];
|
|
41
41
|
};
|
|
42
42
|
export declare function UseListen<T>(data?: Parameters<typeof funcListenCallbackBase<T>>[1]): readonly [(...a: NormalizeTuple<T>) => void, {
|
|
43
43
|
func: Listener<NormalizeTuple<T>>;
|
|
@@ -49,7 +49,7 @@ export declare function UseListen<T>(data?: Parameters<typeof funcListenCallback
|
|
|
49
49
|
addListen: (cb: Listener<NormalizeTuple<T>>, cbClose?: (() => void) | undefined) => () => void;
|
|
50
50
|
removeListen: (cb: Listener<NormalizeTuple<T>> | null) => void;
|
|
51
51
|
count: () => number;
|
|
52
|
-
readonly getAllKeys: Listener<NormalizeTuple<
|
|
52
|
+
readonly getAllKeys: Listener<NormalizeTuple<T>>[];
|
|
53
53
|
}];
|
|
54
54
|
export declare function isListenCallback(obj: any): obj is ReturnType<typeof funcListenCallbackBase>;
|
|
55
55
|
export {};
|
package/lib/Common/Listen.js
CHANGED
|
@@ -31,7 +31,7 @@ export declare function funcListenCallbackSnapshot<T extends realSocket2<any | a
|
|
|
31
31
|
addListen: (cb: import("./Listen").Listener<[data: getTypeCallback<T>, memo: T3]>, cbClose?: (() => void) | undefined) => () => void;
|
|
32
32
|
removeListen: (cb: import("./Listen").Listener<[data: getTypeCallback<T>, memo: T3]> | null) => void;
|
|
33
33
|
count: () => number;
|
|
34
|
-
readonly getAllKeys: import("./Listen").Listener<
|
|
34
|
+
readonly getAllKeys: import("./Listen").Listener<[data: getTypeCallback<T>, memo: T3]>[];
|
|
35
35
|
};
|
|
36
36
|
connect: () => void;
|
|
37
37
|
readonly disconnect: ((a: Omit<Parameters<T>[0], "callback"> & {
|
|
@@ -14,7 +14,7 @@ export declare function SocketServerHook(opt?: {
|
|
|
14
14
|
addListen: (cb: import("./Listen").Listener<[unknown]>, cbClose?: (() => void) | undefined) => () => void;
|
|
15
15
|
removeListen: (cb: import("./Listen").Listener<[unknown]> | null) => void;
|
|
16
16
|
count: () => number;
|
|
17
|
-
readonly getAllKeys: import("./Listen").Listener<
|
|
17
|
+
readonly getAllKeys: import("./Listen").Listener<[unknown]>[];
|
|
18
18
|
}];
|
|
19
19
|
};
|
|
20
20
|
get(tag: string): readonly [(a_0: unknown) => void, {
|
|
@@ -27,7 +27,7 @@ export declare function SocketServerHook(opt?: {
|
|
|
27
27
|
addListen: (cb: import("./Listen").Listener<[unknown]>, cbClose?: (() => void) | undefined) => () => void;
|
|
28
28
|
removeListen: (cb: import("./Listen").Listener<[unknown]> | null) => void;
|
|
29
29
|
count: () => number;
|
|
30
|
-
readonly getAllKeys: import("./Listen").Listener<
|
|
30
|
+
readonly getAllKeys: import("./Listen").Listener<[unknown]>[];
|
|
31
31
|
}];
|
|
32
32
|
provider: (tag: string, data: any) => void;
|
|
33
33
|
};
|
|
@@ -103,22 +103,26 @@ function createServer(socket, key, target, hooks, limits) {
|
|
|
103
103
|
const contexts = [];
|
|
104
104
|
const routeMap = {};
|
|
105
105
|
function transformTree(obj) {
|
|
106
|
-
|
|
107
|
-
|
|
106
|
+
let current = obj;
|
|
107
|
+
if (hooks?.resolveTransform && !(0, isProxy_1.isProxy)(current)) {
|
|
108
|
+
current = hooks.resolveTransform(current);
|
|
109
|
+
}
|
|
110
|
+
if (current == null || typeof current != "object" || (0, isProxy_1.isProxy)(current))
|
|
111
|
+
return current;
|
|
108
112
|
const out = {};
|
|
109
|
-
for (const k of Object.keys(
|
|
113
|
+
for (const k of Object.keys(current)) {
|
|
110
114
|
if (!isSafeKey(k))
|
|
111
115
|
continue;
|
|
112
|
-
const v =
|
|
116
|
+
const v = current[k];
|
|
113
117
|
if ((0, isProxy_1.isProxy)(v)) {
|
|
114
|
-
|
|
118
|
+
out[k] = v;
|
|
115
119
|
continue;
|
|
116
120
|
}
|
|
117
121
|
out[k] = typeof v == "function" ? v : v != null && typeof v == "object" ? transformTree(v) : v;
|
|
118
122
|
}
|
|
119
123
|
return out;
|
|
120
124
|
}
|
|
121
|
-
const resolved =
|
|
125
|
+
const resolved = transformTree(target);
|
|
122
126
|
function index(obj, prefix) {
|
|
123
127
|
for (const k of Object.keys(obj)) {
|
|
124
128
|
if (!isSafeKey(k))
|
|
@@ -141,6 +145,7 @@ function createServer(socket, key, target, hooks, limits) {
|
|
|
141
145
|
if (!isSafeKey(k))
|
|
142
146
|
continue;
|
|
143
147
|
const v = obj[k];
|
|
148
|
+
console.log(k);
|
|
144
149
|
switch (true) {
|
|
145
150
|
case v == null:
|
|
146
151
|
out[k] = "null";
|
|
@@ -171,6 +176,7 @@ function createServer(socket, key, target, hooks, limits) {
|
|
|
171
176
|
}
|
|
172
177
|
if (!Array.isArray(msg) || msg[0] !== Pkt.CALL)
|
|
173
178
|
return;
|
|
179
|
+
console.log(msg);
|
|
174
180
|
const [, reqId, ref, rawArgs, w] = msg;
|
|
175
181
|
const wait = w !== false;
|
|
176
182
|
if (typeof reqId !== "number" || !Number.isFinite(reqId)) {
|
|
@@ -211,18 +217,21 @@ function createServer(socket, key, target, hooks, limits) {
|
|
|
211
217
|
let curr = target;
|
|
212
218
|
for (let i = 0; i < ref.length - 1; i++) {
|
|
213
219
|
const seg = ref[i];
|
|
214
|
-
|
|
220
|
+
console.log(seg, !(seg in curr));
|
|
221
|
+
if (curr == null || typeof curr !== "object" || !(seg in curr)) {
|
|
215
222
|
curr = undefined;
|
|
216
223
|
break;
|
|
217
224
|
}
|
|
218
225
|
curr = curr[seg];
|
|
226
|
+
console.log(111);
|
|
219
227
|
if (hooks?.resolveTransform && !(0, isProxy_1.isProxy)(curr))
|
|
220
228
|
curr = hooks.resolveTransform(curr);
|
|
221
229
|
}
|
|
222
230
|
const last = ref[ref.length - 1];
|
|
223
231
|
if (curr != null && typeof curr == "object") {
|
|
224
232
|
ctx = curr;
|
|
225
|
-
fn =
|
|
233
|
+
fn = last in curr ? curr[last] : undefined;
|
|
234
|
+
console.log(fn, last);
|
|
226
235
|
}
|
|
227
236
|
}
|
|
228
237
|
}
|
|
@@ -355,6 +364,8 @@ function createClient(socket, key, opts) {
|
|
|
355
364
|
return undefined;
|
|
356
365
|
if (p == "call" && tgt == "func")
|
|
357
366
|
return (_, ...args) => sendCall(path, args, wait);
|
|
367
|
+
if (tgt === "func")
|
|
368
|
+
return undefined;
|
|
358
369
|
const child = tgt?.[String(p)];
|
|
359
370
|
return child == "null" || child == undefined ? undefined : buildStrict([...path, String(p)], wait);
|
|
360
371
|
},
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/lib/Common/node_test.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
console.log("=== ОБЫЧНЫЙ ERROR.STACK ===");
|
|
4
|
-
console.log(new Error().stack);
|
|
5
|
-
console.log("=== PREPARE STACK TRACE ===");
|
|
6
|
-
const originalPrepareStackTrace = Error.prepareStackTrace;
|
|
7
|
-
Error.prepareStackTrace = (_, stack) => stack;
|
|
8
|
-
const stack = new Error().stack;
|
|
9
|
-
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
10
|
-
console.log("Stack frames:");
|
|
11
|
-
for (let i = 0; i < Math.min(stack.length, 3); i++) {
|
|
12
|
-
const frame = stack[i];
|
|
13
|
-
console.log(`Frame[${i}]: ${frame.getFileName()}:${frame.getLineNumber()}:${frame.getColumnNumber()}`);
|
|
14
|
-
}
|