@xiaoguomeiyitian/core 1.0.8 → 1.1.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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.RandomGenerator = exports.delFiles = exports.copyDir = exports.Entity = exports.Global = void 0;
4
+ exports.delFiles = exports.copyDir = exports.Entity = exports.Global = void 0;
5
5
  require("bytenode");
6
- _a = require("./lib_" + process.platform + '_' + process.versions.node.split('.')[0] + '.jsc'), exports.Global = _a.Global, exports.Entity = _a.Entity, exports.copyDir = _a.copyDir, exports.delFiles = _a.delFiles, exports.RandomGenerator = _a.RandomGenerator;
6
+ _a = require("./lib_" + process.platform + '_' + process.versions.node.split('.')[0] + '.jsc'), exports.Global = _a.Global, exports.Entity = _a.Entity, exports.copyDir = _a.copyDir, exports.delFiles = _a.delFiles;
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@xiaoguomeiyitian/core",
3
- "version": "1.0.8",
3
+ "version": "1.1.0",
4
4
  "main": "dist/index.js",
5
- "types": "types/index.d.ts",
5
+ "types": "types/lib.d.ts",
6
6
  "bin": {
7
7
  "core": "./dist/cli.js"
8
8
  },
9
9
  "files": [
10
- "types",
10
+ "types/lib.d.ts",
11
11
  "dist/index.js",
12
12
  "dist/cli.js",
13
13
  "dist/lib_*.jsc"
package/types/lib.d.ts ADDED
@@ -0,0 +1,85 @@
1
+ import { EventEmitter } from "events";
2
+ import { WsConnection } from "tsrpc";
3
+ export declare class Global {
4
+ event: EventEmitter;
5
+ entityDefList: any;
6
+ serviceProto: any;
7
+ serviceProtoServer: any;
8
+ constructor();
9
+ init(entityDefList: any, serviceProto: any, serviceProtoServer: any): Promise<void>;
10
+ /**获取某类实体属性的类型 */
11
+ getPropType(type: string, prop: string): any;
12
+ /**获取某类实体属性的默认值 */
13
+ getPropDefault(type: string, prop: string): any;
14
+ /**从redis读取数据 */
15
+ loadByRedis(type: string, id: string): Promise<any>;
16
+ /**数据写入到redis */
17
+ setToRedis(type: string, id: string, data: any): Promise<void>;
18
+ /**创建实体 单个进程只会创建一个相同id的实体*/
19
+ create(type: string, id?: string, cdata?: any): Promise<any>;
20
+ /**根据类型和id获取实体 */
21
+ get(type: string, id?: string): any;
22
+ /**获取rpc对象 */
23
+ getRpc(type: string, serverUrl: string): any;
24
+ /**获取某类实体属性的类型 */
25
+ getByType(type: string): any[];
26
+ /**加载某个文件夹下的所有文件*/
27
+ loadAllFile(source: any): void;
28
+ /**热更新某个文件 @param { boolean} reChain 是否更新继承链上的其他实体 @param { boolean} reload 是否重新加载文件 */
29
+ loadfile(filePath: string, reChain?: boolean, reload?: boolean): Promise<void>;
30
+ /**保存之前没有保存的dump数据*/
31
+ flushDumpData(): Promise<void>;
32
+ /** 获取V8 CPU调用统计信息,默认统计10秒钟 cwd/profile.cpuprofile*/
33
+ profiler(time?: number): void;
34
+ /** 获取V8 GC统计信息,默认统计10秒钟 */
35
+ profilerGC(time?: number): void;
36
+ /** 生成内存快照 cwd/heapSnapshot.heapsnapshot*/
37
+ profilerHeap(password: string): void;
38
+ }
39
+ export declare class Entity {
40
+ type: string; /** 实体类型 */
41
+ id: string; /** 实体id */
42
+ conns: WsConnection[];
43
+ constructor(type: string, id?: string);
44
+ /**获取属性类型 */
45
+ getPropType(prop: string): any;
46
+ /**获取未定义的数据默认值 */
47
+ getPropDefault(prop: string): any;
48
+ /**递归地设置对象中的值 */
49
+ setValueByPath(path: string[], value: any, type?: "inc" | "set" | "unset" | "push" | "pull", ext?: {
50
+ min?: number;
51
+ max?: number;
52
+ leng?: number;
53
+ }): void;
54
+ /**递归地获取对象中的值 */
55
+ getValueByPath(path: string[]): any;
56
+ /**保持数据至缓存 */
57
+ saveToDump(prop: string, value: any): Promise<void>;
58
+ /**属性变化 */
59
+ propChange(prop: string, value: any, key?: string): Promise<void>;
60
+ /**创建 */
61
+ create(): Promise<void>;
62
+ /**实体同步到客户端 */
63
+ syncEntity(conns?: WsConnection[]): void;
64
+ /**写入数据库 */
65
+ flush(): Promise<void>;
66
+ /**销毁 */
67
+ destroy(): Promise<void>;
68
+ /**添加定时器 */
69
+ addOneLoop(funcName: Function, time: number): number;
70
+ /**清除定时器 */
71
+ clearOneLoop(timeId: number): void;
72
+ /**添加循环 */
73
+ addLoop(funcName: Function, time: number): number;
74
+ /**清除循环 */
75
+ clearLoop(timeId: number): void;
76
+ /**清除所有定时器 */
77
+ clearAllLoop(): void;
78
+ onCreate(): void;
79
+ onPropChange(prop: string, value: any): void;
80
+ onDestroy(): void;
81
+ }
82
+ /** 拷贝文件或目录 */
83
+ export declare function copyDir(sourceDir: string, destDir: string): Promise<void>;
84
+ /** 删除文件或者目录 */
85
+ export declare function delFiles(dir: string, exts?: string[]): Promise<void>;
package/types/index.d.ts DELETED
@@ -1,25 +0,0 @@
1
- export declare class Global {
2
- constructor();
3
- }
4
- export declare class Entity {
5
- type: string;/** 实体类型 */
6
- id: string;/** 实体id */
7
- constructor(type: string, id?: string);
8
- }
9
- export declare class RandomGenerator {
10
- a: number;
11
- c: number;
12
- m: number;
13
- seed: number; /** 随机种子 */
14
- constructor(seed: number);
15
- /** 快速幂算法计算 (a^n) % m */
16
- fastPow(a: any, n: any, m: any): number;
17
- /** 获取第n次的随机值 (0-1之间) */
18
- getNthRandom(n: any): number;
19
- /** 获取第n次的随机整数 [min, max] */
20
- getNthRandomInt(n: any, min: any, max: any): number;
21
- }
22
- /** 拷贝文件或目录 */
23
- export declare function copyDir(sourceDir: string, destDir: string): Promise<void>;
24
- /** 删除文件或者目录 */
25
- export declare function delFiles(dir: string, exts?: string[]): Promise<void>;