cgserver 6.1.2 → 6.1.5

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.
@@ -18,7 +18,7 @@ class VersionModel {
18
18
  exports.VersionModel = VersionModel;
19
19
  exports.GDBCache = null;
20
20
  class DBCache {
21
- _versions = new Map();
21
+ _versions = {};
22
22
  _path = __dirname + "/tmp_table_version.json";
23
23
  async init() {
24
24
  if (fs.existsSync(this._path)) {
@@ -32,7 +32,7 @@ class DBCache {
32
32
  }
33
33
  }
34
34
  else {
35
- this._versions = new Map();
35
+ this._versions = {};
36
36
  fs.writeFileSync(this._path, JSON.stringify(this._versions));
37
37
  }
38
38
  }
@@ -56,6 +56,6 @@ class TableProperty {
56
56
  auto_increment = null;
57
57
  charset = "utf8mb4";
58
58
  comment = null;
59
- items = new Map();
59
+ items = {};
60
60
  }
61
61
  exports.TableProperty = TableProperty;
@@ -10,7 +10,7 @@ class CacheItem {
10
10
  expire_time = -1;
11
11
  }
12
12
  class CacheTool {
13
- _items = new Map();
13
+ _items = {};
14
14
  constructor() {
15
15
  //一个小时清除一次过期缓存
16
16
  setInterval(this._refresh.bind(this), 60 * 60 * 1000);
@@ -37,7 +37,7 @@ class ISocketServer {
37
37
  return this._web_socket;
38
38
  }
39
39
  //来自于用户的链接
40
- _ws_clients = new Map();
40
+ _ws_clients = {};
41
41
  _listen_port = 0;
42
42
  get listenPort() {
43
43
  return this._listen_port;
@@ -3,10 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GCtrMgr = void 0;
4
4
  exports.GCtrMgr = null;
5
5
  class ControllerManager {
6
- _ctrs = new Map();
7
- _ctr_cls = new Map();
6
+ _static_ctr = {};
7
+ _ctr_cls = {};
8
8
  //module ctrname lower normal
9
- _cache_action_names = new Map();
9
+ _cache_action_names = {};
10
10
  registerController(module_name, ctr_name, cls) {
11
11
  module_name = module_name.toLowerCase();
12
12
  ctr_name = ctr_name.toLowerCase();
@@ -22,7 +22,7 @@ class ControllerManager {
22
22
  ctr_name = ctr_name.toLowerCase();
23
23
  //不能通过cls.name来获取ctr名称,因为混淆之后类名会变化
24
24
  let prototype = cls.prototype;
25
- let map_names = new Map();
25
+ let map_names = {};
26
26
  while (prototype && prototype.constructor.name != "BaseController") {
27
27
  let names = Object.getOwnPropertyNames(prototype);
28
28
  for (let action_name of names) {
@@ -61,15 +61,15 @@ class ControllerManager {
61
61
  registerStaticController(module_name, ctr_name, obj) {
62
62
  module_name = module_name.toLowerCase();
63
63
  ctr_name = ctr_name.toLowerCase();
64
- this._ctrs[module_name] = this._ctrs[module_name] || {};
65
- this._ctrs[module_name][ctr_name] = obj;
64
+ this._static_ctr[module_name] = this._static_ctr[module_name] || {};
65
+ this._static_ctr[module_name][ctr_name] = obj;
66
66
  this._cacheActionNameForStatic(module_name, ctr_name, obj);
67
67
  }
68
68
  _cacheActionNameForStatic(module_name, ctr_name, obj) {
69
69
  module_name = module_name.toLowerCase();
70
70
  ctr_name = ctr_name.toLowerCase();
71
71
  let prototype = Object.getPrototypeOf(obj);
72
- let map_names = new Map();
72
+ let map_names = {};
73
73
  while (prototype && prototype.constructor.name != "BaseController") {
74
74
  let names = Object.getOwnPropertyNames(prototype);
75
75
  for (let func_name of names) {
@@ -91,10 +91,10 @@ class ControllerManager {
91
91
  if (controller_name) {
92
92
  controller_name = controller_name.toLowerCase();
93
93
  }
94
- if (!this._ctrs[module_name]) {
94
+ if (!this._static_ctr[module_name]) {
95
95
  return;
96
96
  }
97
- return this._ctrs[module_name][controller_name];
97
+ return this._static_ctr[module_name][controller_name];
98
98
  }
99
99
  getClass(module_name, controller_name) {
100
100
  if (module_name) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IServerWebSocket = exports.IClientWebSocket = exports.JsonProtoFilter = exports.GoogleProtoFilter = exports.MongoCacheModel = exports.GMongoCacheSer = exports.MongoUserModel = exports.MysqlUserModel = exports.MongoUserService = exports.MysqlUserService = exports.GMongoAccountSer = exports.MongoAccountService = exports.GMysqlAccountSer = exports.MysqlAccountService = exports.EAccountFrom = exports.EUserState = exports.ERoleGroup = exports.GLog = exports.GHttpTool = exports.GCacheTool = exports.GRedisMgr = exports.GMysqlMgr = exports.MysqlBaseService = exports.GMSSqlMgr = exports.GMongoMgr = exports.MongoBaseModel = exports.MysqlBaseModel = exports.MongoBaseService = exports.EPropertyType = exports.Type = exports.Table = exports.Property = exports.PrimaryKey = exports.NotNull = exports.AutoIncrement = exports.Timer = exports.core = exports.ServerConfig = exports.FrameworkConfig = exports.Config = exports.FrameworkErrorCode = exports.GTriggerMgr = exports.Trigger = exports.Point = exports.Entity = exports.BehaviorAI = exports.AStar = exports.AiObject = exports.GDBCache = exports.GProtoFactory = void 0;
4
- exports.WebServerConfig = exports.Response = exports.Request = exports.RazorJs = exports.Engine = exports.GCtrMgr = exports.JsonCreatorValidate = exports.JsonAuthorityValidate = exports.JsonAdminValidate = exports.CreatorValidate = exports.AuthorityValidate = exports.AdminValidate = exports.MongoAccountModel = exports.MysqlAccountModel = exports.MongoBaseUserController = exports.BaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GOpenSocial = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.GAlipayTool = exports.IWebSocket = exports.ISocketServer = void 0;
3
+ exports.JsonProtoFilter = exports.GoogleProtoFilter = exports.MongoCacheModel = exports.GMongoCacheSer = exports.MongoUserModel = exports.MysqlUserModel = exports.MongoUserService = exports.MysqlUserService = exports.GMongoAccountSer = exports.MongoAccountService = exports.GMysqlAccountSer = exports.MysqlAccountService = exports.EAccountFrom = exports.EUserState = exports.ERoleGroup = exports.GLog = exports.GHttpTool = exports.GCacheTool = exports.RedisManager = exports.GRedisMgr = exports.GMysqlMgr = exports.MysqlBaseService = exports.GMSSqlMgr = exports.GMongoMgr = exports.MongoBaseModel = exports.MysqlBaseModel = exports.MongoBaseService = exports.EPropertyType = exports.Type = exports.Table = exports.Property = exports.PrimaryKey = exports.NotNull = exports.AutoIncrement = exports.Timer = exports.core = exports.ServerConfig = exports.GFCfg = exports.FrameworkConfig = exports.Config = exports.FrameworkErrorCode = exports.GTriggerMgr = exports.Trigger = exports.Point = exports.Entity = exports.BehaviorAI = exports.AStar = exports.AiObject = exports.GDBCache = exports.GProtoFactory = void 0;
4
+ exports.WebServerConfig = exports.Response = exports.Request = exports.RazorJs = exports.Engine = exports.GCtrMgr = exports.JsonCreatorValidate = exports.JsonAuthorityValidate = exports.JsonAdminValidate = exports.CreatorValidate = exports.AuthorityValidate = exports.AdminValidate = exports.MongoAccountModel = exports.MysqlAccountModel = exports.MongoBaseUserController = exports.BaseUserController = exports.BaseController = exports.IWebServer = exports.GWechatTool = exports.GWechatOATool = exports.GQQTool = exports.GQiniuTool = exports.GOpenSocial = exports.GEmailTool = exports.GAppleTool = exports.GSmsTool = exports.GAlipayTool = exports.IWebSocket = exports.ISocketServer = exports.IServerWebSocket = exports.IClientWebSocket = void 0;
5
5
  var ProtoFactory_1 = require("./SocketServer/ProtoFilter/ProtoFactory");
6
6
  Object.defineProperty(exports, "GProtoFactory", { enumerable: true, get: function () { return ProtoFactory_1.GProtoFactory; } });
7
7
  var DBCache_1 = require("./Database/Decorator/DBCache");
@@ -25,8 +25,10 @@ var Config_1 = require("./Config/Config");
25
25
  Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return Config_1.Config; } });
26
26
  var FrameworkConfig_1 = require("./Config/FrameworkConfig");
27
27
  Object.defineProperty(exports, "FrameworkConfig", { enumerable: true, get: function () { return FrameworkConfig_1.FrameworkConfig; } });
28
+ Object.defineProperty(exports, "GFCfg", { enumerable: true, get: function () { return FrameworkConfig_1.GFCfg; } });
28
29
  var ServerConfig_1 = require("./Config/ServerConfig");
29
30
  Object.defineProperty(exports, "ServerConfig", { enumerable: true, get: function () { return ServerConfig_1.ServerConfig; } });
31
+ 9;
30
32
  var Core_1 = require("./Core/Core");
31
33
  Object.defineProperty(exports, "core", { enumerable: true, get: function () { return Core_1.core; } });
32
34
  var Timer_1 = require("./Core/Timer");
@@ -61,6 +63,7 @@ var MysqlManager_1 = require("./Database/MysqlManager");
61
63
  Object.defineProperty(exports, "GMysqlMgr", { enumerable: true, get: function () { return MysqlManager_1.GMysqlMgr; } });
62
64
  var RedisManager_1 = require("./Database/RedisManager");
63
65
  Object.defineProperty(exports, "GRedisMgr", { enumerable: true, get: function () { return RedisManager_1.GRedisMgr; } });
66
+ Object.defineProperty(exports, "RedisManager", { enumerable: true, get: function () { return RedisManager_1.RedisManager; } });
64
67
  var CacheTool_1 = require("./Logic/CacheTool");
65
68
  Object.defineProperty(exports, "GCacheTool", { enumerable: true, get: function () { return CacheTool_1.GCacheTool; } });
66
69
  var HttpTool_1 = require("./Logic/HttpTool");
@@ -12,7 +12,9 @@ export declare class VersionModel {
12
12
  }
13
13
  export declare let GDBCache: DBCache;
14
14
  declare class DBCache {
15
- protected _versions: Map<String, VersionModel>;
15
+ protected _versions: {
16
+ [table_name: string]: VersionModel;
17
+ };
16
18
  protected _path: string;
17
19
  init(): Promise<void>;
18
20
  setVersion(table: string, version: number): Promise<void>;
@@ -51,5 +51,7 @@ export declare class TableProperty {
51
51
  auto_increment: number;
52
52
  charset: string;
53
53
  comment: string;
54
- items: Map<string, Property>;
54
+ items: {
55
+ [name: string]: Property;
56
+ };
55
57
  }
@@ -6,7 +6,9 @@ declare class CacheItem {
6
6
  expire_time: number;
7
7
  }
8
8
  declare class CacheTool {
9
- protected _items: Map<string, CacheItem>;
9
+ protected _items: {
10
+ [key: string]: CacheItem;
11
+ };
10
12
  constructor();
11
13
  /**
12
14
  * 定时清除缓存
@@ -11,7 +11,9 @@ export declare class ISocketServer {
11
11
  get fullServerName(): string;
12
12
  private _web_socket;
13
13
  get serverWebSocket(): ws.server;
14
- protected _ws_clients: Map<number, IServerWebSocket>;
14
+ protected _ws_clients: {
15
+ [socketid: number]: IServerWebSocket;
16
+ };
15
17
  private _listen_port;
16
18
  get listenPort(): number;
17
19
  set listenPort(value: number);
@@ -1,12 +1,26 @@
1
1
  import { BaseController } from "../Controller/BaseController";
2
2
  export declare let GCtrMgr: ControllerManager;
3
3
  declare class ControllerManager {
4
- protected _ctrs: Map<string, Map<string, BaseController>>;
5
- protected _ctr_cls: Map<string, Map<string, any>>;
6
- protected _cache_action_names: Map<string, Map<string, Map<string, string>>>;
7
- registerController(module_name: string, ctr_name: string, cls: Function): void;
4
+ protected _static_ctr: {
5
+ [module_name: string]: {
6
+ [ctrname: string]: BaseController;
7
+ };
8
+ };
9
+ protected _ctr_cls: {
10
+ [module_name: string]: {
11
+ [ctrname: string]: any;
12
+ };
13
+ };
14
+ protected _cache_action_names: {
15
+ [module: string]: {
16
+ [ctrname: string]: {
17
+ [lower: string]: string;
18
+ };
19
+ };
20
+ };
21
+ registerController(module_name: string, ctr_name: string, cls: any): void;
8
22
  protected _cacheActionName(module_name: string, ctr_name: string, cls: Function): void;
9
- getActionName(module_name: string, ctr_name: string, action_name: string): any;
23
+ getActionName(module_name: string, ctr_name: string, action_name: string): string;
10
24
  /**
11
25
  * 静态ctr,这样,ctr就不会被多次创建
12
26
  * @param module_name
@@ -8,7 +8,7 @@ export { Point } from "./AI/Point";
8
8
  export { Trigger, GTriggerMgr } from "./AI/TriggerMgr";
9
9
  export { FrameworkErrorCode } from "./Config/_error_";
10
10
  export { Config } from "./Config/Config";
11
- export { FrameworkConfig } from "./Config/FrameworkConfig";
11
+ export { FrameworkConfig, GFCfg } from "./Config/FrameworkConfig";
12
12
  export { ServerConfig } from "./Config/ServerConfig";
13
13
  export { core } from "./Core/Core";
14
14
  export { Timer } from "./Core/Timer";
@@ -26,7 +26,7 @@ export { GMongoMgr } from './Database/MongoManager';
26
26
  export { GMSSqlMgr } from './Database/MSSqlManager';
27
27
  export { BaseService as MysqlBaseService } from './Database/BaseService';
28
28
  export { GMysqlMgr } from './Database/MysqlManager';
29
- export { GRedisMgr } from './Database/RedisManager';
29
+ export { GRedisMgr, RedisManager } from './Database/RedisManager';
30
30
  export { GCacheTool } from './Logic/CacheTool';
31
31
  export { GHttpTool } from './Logic/HttpTool';
32
32
  export { GLog } from './Logic/Log';
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "cgserver",
3
- "version": "6.1.2",
3
+ "version": "6.1.5",
4
4
  "author": "trojan",
5
5
  "type": "commonjs",
6
6
  "description": "free for all.Websocket or Http",
7
7
  "main": "./dist/lib/cgserver.js",
8
- "types": "./dist/types",
8
+ "types": "./dist/types/cgserver.d.ts",
9
9
  "scripts": {
10
10
  "test": "echo \"Error: no test specified\" && exit 1"
11
11
  },