wenay-common 1.0.96 → 1.0.98
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/common.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Immutable, KeysWithoutType, Mutable, MutableFull, ReadonlyFull } from "./BaseTypes";
|
|
2
|
+
import "./node_console";
|
|
2
3
|
export declare function GetEnumKeys<TT extends {
|
|
3
4
|
[key: string]: any;
|
|
4
5
|
}>(T: TT): readonly (keyof typeof T)[];
|
|
@@ -185,7 +186,7 @@ export declare class CancelablePromise<T> extends Promise<T> {
|
|
|
185
186
|
static resolve<T>(value: T | PromiseLike<T>): CancelablePromise<T>;
|
|
186
187
|
}
|
|
187
188
|
export declare function createCancellableTimer(interval_ms: number, onTimer: () => boolean | void, onStop?: () => void): CancelablePromise<never>;
|
|
188
|
-
export declare function createCancellableTaskWrapper<T>(task: Promise<T>, isStopped: () => boolean, interval_ms?: number): Promise<"stopped"
|
|
189
|
+
export declare function createCancellableTaskWrapper<T>(task: Promise<T>, isStopped: () => boolean, interval_ms?: number): Promise<T | "stopped">;
|
|
189
190
|
export declare class MyTimerInterval {
|
|
190
191
|
private _timer;
|
|
191
192
|
private _onstop;
|
package/lib/Common/common.js
CHANGED
|
@@ -25,6 +25,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
exports.CCachedValueT = exports.WeakMapExt = exports.MapExt = exports.CObjectID = exports.copyToClipboard = exports.Mutex = exports.MyTimerInterval = exports.createCancellableTaskWrapper = exports.createCancellableTimer = exports.CancelablePromise = exports.CancelToken = exports.JSON_clone = exports.VirtualItems = exports.ArraySet = exports.ArrayMap = exports.StructSet = exports.StructMap = exports.MyNumMap = exports.MyMap = exports.__MyMap = exports.CreateArrayProxy = exports.ArrayItemHandler = exports.DblToStrAuto = exports.GetDblPrecision = exports.GetDblPrecision2 = exports.MaxCommonDivisorOnArray = exports.MaxCommonDivisor = exports.NormalizeDouble = exports._BSearchNearest = exports.BSearchNearest = exports.BSearchDefault = exports.BSearchAsync = exports.BSearch = exports.E_MATCH = exports.E_SORTMODE = exports.CBase = exports.sleepAsync = exports.arrayShallowEqual = exports.shallowEqual = exports.deepEqual = exports.readonlyFull = exports.toImmutable = exports.deepCloneObjectMutable = exports.deepCloneObject = exports.deepCloneMutable = exports.deepClone = exports._deepClone = exports.shallowClone = exports.isDate = exports.GetEnumKeys = void 0;
|
|
27
27
|
exports.isObjectCastableTo = exports.CCachedValue2 = void 0;
|
|
28
|
+
require("./node_console");
|
|
28
29
|
function GetEnumKeys(T) { return Object.keys(T).filter(k => isNaN(k)); }
|
|
29
30
|
exports.GetEnumKeys = GetEnumKeys;
|
|
30
31
|
function isDate(value) {
|
|
@@ -32,8 +32,8 @@ function funcPromiseServer(data, obj) {
|
|
|
32
32
|
}
|
|
33
33
|
const a = await (async () => buf(...request))()
|
|
34
34
|
.catch((e) => {
|
|
35
|
-
data.sendMessage({ mapId: datum.mapId, error: e });
|
|
36
|
-
console.error({
|
|
35
|
+
data.sendMessage({ mapId: datum.mapId, error: { error: e, key: key, arguments: request } });
|
|
36
|
+
console.error({ error: e, key: key, arguments: request });
|
|
37
37
|
})
|
|
38
38
|
.then(a => {
|
|
39
39
|
if (datum.wait !== false)
|
|
@@ -1,43 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
let wrapCallSite;
|
|
4
26
|
if (1)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
27
|
+
(async () => {
|
|
28
|
+
if (typeof self != 'object' && typeof window != "object") {
|
|
29
|
+
let wrapCallSite;
|
|
30
|
+
let moduleName = 'source-map-support';
|
|
31
|
+
try {
|
|
32
|
+
let module = await Promise.resolve(`${moduleName}`).then(s => __importStar(require(s)));
|
|
33
|
+
module.install();
|
|
34
|
+
wrapCallSite = module.wrapCallSite;
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
console.warn(e);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
for (let methodName of ['debug', 'log', 'warn', 'error']) {
|
|
41
|
+
const originalLoggingMethod = console[methodName];
|
|
42
|
+
console[methodName] = ((firstArgument, ...otherArguments) => {
|
|
43
|
+
const originalPrepareStackTrace = Error.prepareStackTrace;
|
|
44
|
+
Error.prepareStackTrace = (_, stack) => stack;
|
|
45
|
+
let callee = new Error().stack[1];
|
|
46
|
+
if (!callee)
|
|
47
|
+
return;
|
|
48
|
+
if (wrapCallSite)
|
|
49
|
+
callee = wrapCallSite(callee);
|
|
50
|
+
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
51
|
+
const fileName = callee.getFileName();
|
|
52
|
+
if (fileName?.includes("source-map-support")) {
|
|
53
|
+
originalLoggingMethod(firstArgument, ...otherArguments);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
let fileAndLine = `${fileName}:${callee.getLineNumber()}:${callee.getColumnNumber()} ` + callee.getFunctionName();
|
|
57
|
+
fileAndLine = fileAndLine.replaceAll("\\", "/");
|
|
58
|
+
if (!fileAndLine.toLowerCase().startsWith("file:///"))
|
|
59
|
+
fileAndLine = "file:///" + fileAndLine;
|
|
60
|
+
if (1)
|
|
61
|
+
originalLoggingMethod(firstArgument, ...otherArguments, "", fileAndLine);
|
|
62
|
+
else if (typeof firstArgument === 'string') {
|
|
63
|
+
originalLoggingMethod(fileAndLine + ' ' + firstArgument, ...otherArguments);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
originalLoggingMethod(fileAndLine, firstArgument, ...otherArguments);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
}
|
|
12
70
|
}
|
|
13
|
-
|
|
14
|
-
const originalLoggingMethod = console[methodName];
|
|
15
|
-
console[methodName] = ((firstArgument, ...otherArguments) => {
|
|
16
|
-
const originalPrepareStackTrace = Error.prepareStackTrace;
|
|
17
|
-
Error.prepareStackTrace = (_, stack) => stack;
|
|
18
|
-
let callee = new Error().stack[1];
|
|
19
|
-
if (!callee)
|
|
20
|
-
return;
|
|
21
|
-
if (wrapCallSite)
|
|
22
|
-
callee = wrapCallSite(callee);
|
|
23
|
-
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
24
|
-
const fileName = callee.getFileName();
|
|
25
|
-
if (fileName.includes("source-map-support")) {
|
|
26
|
-
originalLoggingMethod(firstArgument, ...otherArguments);
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
let fileAndLine = `${fileName}:${callee.getLineNumber()}:${callee.getColumnNumber()} ` + callee.getFunctionName();
|
|
30
|
-
fileAndLine = fileAndLine.replaceAll("\\", "/");
|
|
31
|
-
if (!fileAndLine.toLowerCase().startsWith("file:///"))
|
|
32
|
-
fileAndLine = "file:///" + fileAndLine;
|
|
33
|
-
if (1)
|
|
34
|
-
originalLoggingMethod(firstArgument, ...otherArguments, "", fileAndLine);
|
|
35
|
-
else if (typeof firstArgument === 'string') {
|
|
36
|
-
originalLoggingMethod(fileAndLine + ' ' + firstArgument, ...otherArguments);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
originalLoggingMethod(fileAndLine, firstArgument, ...otherArguments);
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
71
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wenay-common",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.98",
|
|
4
|
+
"description": "Common library",
|
|
5
5
|
"strict": true,
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"types": "lib/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"lib/**/*"
|
|
10
10
|
],
|
|
11
|
-
"author": "
|
|
11
|
+
"author": "wenay",
|
|
12
12
|
"license": "ISC",
|
|
13
13
|
"type": "commonjs",
|
|
14
14
|
"engines": {
|