cgserver 7.9.2113 → 7.11.2113
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/package.json +1 -1
- package/dist/Framework/AI/AiObject.js +0 -11
- package/dist/Framework/AI/AiObject.js.map +0 -1
- package/dist/Framework/AI/Astar.js +0 -134
- package/dist/Framework/AI/Astar.js.map +0 -1
- package/dist/Framework/AI/BehaviorAI.js +0 -309
- package/dist/Framework/AI/BehaviorAI.js.map +0 -1
- package/dist/Framework/AI/Entity.js +0 -34
- package/dist/Framework/AI/Entity.js.map +0 -1
- package/dist/Framework/AI/Point.js +0 -69
- package/dist/Framework/AI/Point.js.map +0 -1
- package/dist/Framework/AI/TriggerMgr.js +0 -202
- package/dist/Framework/AI/TriggerMgr.js.map +0 -1
- package/dist/Framework/Config/Config.js +0 -55
- package/dist/Framework/Config/Config.js.map +0 -1
- package/dist/Framework/Config/FrameworkConfig.js +0 -241
- package/dist/Framework/Config/FrameworkConfig.js.map +0 -1
- package/dist/Framework/Config/IServerConfig.js +0 -27
- package/dist/Framework/Config/IServerConfig.js.map +0 -1
- package/dist/Framework/Config/_error_.js +0 -36
- package/dist/Framework/Config/_error_.js.map +0 -1
- package/dist/Framework/Core/Core.js +0 -641
- package/dist/Framework/Core/Core.js.map +0 -1
- package/dist/Framework/Core/Timer.js +0 -117
- package/dist/Framework/Core/Timer.js.map +0 -1
- package/dist/Framework/Database/Decorator/AutoIncrement.js +0 -12
- package/dist/Framework/Database/Decorator/AutoIncrement.js.map +0 -1
- package/dist/Framework/Database/Decorator/DBCache.js +0 -66
- package/dist/Framework/Database/Decorator/DBCache.js.map +0 -1
- package/dist/Framework/Database/Decorator/NotNull.js +0 -12
- package/dist/Framework/Database/Decorator/NotNull.js.map +0 -1
- package/dist/Framework/Database/Decorator/PrimaryKey.js +0 -12
- package/dist/Framework/Database/Decorator/PrimaryKey.js.map +0 -1
- package/dist/Framework/Database/Decorator/Property.js +0 -62
- package/dist/Framework/Database/Decorator/Property.js.map +0 -1
- package/dist/Framework/Database/Decorator/Table.js +0 -16
- package/dist/Framework/Database/Decorator/Table.js.map +0 -1
- package/dist/Framework/Database/Decorator/Type.js +0 -21
- package/dist/Framework/Database/Decorator/Type.js.map +0 -1
- package/dist/Framework/Database/MSSqlManager.js +0 -45
- package/dist/Framework/Database/MSSqlManager.js.map +0 -1
- package/dist/Framework/Database/MongoBaseService.js +0 -115
- package/dist/Framework/Database/MongoBaseService.js.map +0 -1
- package/dist/Framework/Database/MongoManager.js +0 -429
- package/dist/Framework/Database/MongoManager.js.map +0 -1
- package/dist/Framework/Database/MysqlBaseService.js +0 -282
- package/dist/Framework/Database/MysqlBaseService.js.map +0 -1
- package/dist/Framework/Database/MysqlManager.js +0 -182
- package/dist/Framework/Database/MysqlManager.js.map +0 -1
- package/dist/Framework/Database/RedisManager.js +0 -410
- package/dist/Framework/Database/RedisManager.js.map +0 -1
- package/dist/Framework/Logic/CacheTool.js +0 -75
- package/dist/Framework/Logic/CacheTool.js.map +0 -1
- package/dist/Framework/Logic/EventTool.js +0 -29
- package/dist/Framework/Logic/EventTool.js.map +0 -1
- package/dist/Framework/Logic/HttpTool.js +0 -77
- package/dist/Framework/Logic/HttpTool.js.map +0 -1
- package/dist/Framework/Logic/Log.js +0 -142
- package/dist/Framework/Logic/Log.js.map +0 -1
- package/dist/Framework/Logic/SyncQueueTool.js +0 -44
- package/dist/Framework/Logic/SyncQueueTool.js.map +0 -1
- package/dist/Framework/Service/AccountService.js +0 -482
- package/dist/Framework/Service/AccountService.js.map +0 -1
- package/dist/Framework/Service/MongoAccountService.js +0 -404
- package/dist/Framework/Service/MongoAccountService.js.map +0 -1
- package/dist/Framework/Service/MongoCacheService.js +0 -43
- package/dist/Framework/Service/MongoCacheService.js.map +0 -1
- package/dist/Framework/Service/MongoUserService.js +0 -95
- package/dist/Framework/Service/MongoUserService.js.map +0 -1
- package/dist/Framework/Service/UserService.js +0 -200
- package/dist/Framework/Service/UserService.js.map +0 -1
- package/dist/Framework/Service/ini.js +0 -37
- package/dist/Framework/Service/ini.js.map +0 -1
- package/dist/Framework/SocketServer/IClientWebSocket.js +0 -45
- package/dist/Framework/SocketServer/IClientWebSocket.js.map +0 -1
- package/dist/Framework/SocketServer/IRpc.js +0 -13
- package/dist/Framework/SocketServer/IRpc.js.map +0 -1
- package/dist/Framework/SocketServer/IRpcClientWebSocket.js +0 -64
- package/dist/Framework/SocketServer/IRpcClientWebSocket.js.map +0 -1
- package/dist/Framework/SocketServer/IRpcServerWebSocket.js +0 -64
- package/dist/Framework/SocketServer/IRpcServerWebSocket.js.map +0 -1
- package/dist/Framework/SocketServer/IServerWebSocket.js +0 -77
- package/dist/Framework/SocketServer/IServerWebSocket.js.map +0 -1
- package/dist/Framework/SocketServer/ISocketServer.js +0 -204
- package/dist/Framework/SocketServer/ISocketServer.js.map +0 -1
- package/dist/Framework/SocketServer/IWebSocket.js +0 -197
- package/dist/Framework/SocketServer/IWebSocket.js.map +0 -1
- package/dist/Framework/SocketServer/ProtoFilter/GoogleProtoFilter.js +0 -59
- package/dist/Framework/SocketServer/ProtoFilter/GoogleProtoFilter.js.map +0 -1
- package/dist/Framework/SocketServer/ProtoFilter/IProtoFilter.js +0 -9
- package/dist/Framework/SocketServer/ProtoFilter/IProtoFilter.js.map +0 -1
- package/dist/Framework/SocketServer/ProtoFilter/JsonProtoFilter.js +0 -30
- package/dist/Framework/SocketServer/ProtoFilter/JsonProtoFilter.js.map +0 -1
- package/dist/Framework/SocketServer/ProtoFilter/ProtoFactory.js +0 -32
- package/dist/Framework/SocketServer/ProtoFilter/ProtoFactory.js.map +0 -1
- package/dist/Framework/ThirdParty/AlipayTool.js +0 -205
- package/dist/Framework/ThirdParty/AlipayTool.js.map +0 -1
- package/dist/Framework/ThirdParty/Alisms.js +0 -47
- package/dist/Framework/ThirdParty/Alisms.js.map +0 -1
- package/dist/Framework/ThirdParty/AppleTool.js +0 -236
- package/dist/Framework/ThirdParty/AppleTool.js.map +0 -1
- package/dist/Framework/ThirdParty/CgMq.js +0 -133
- package/dist/Framework/ThirdParty/CgMq.js.map +0 -1
- package/dist/Framework/ThirdParty/EmailTool.js +0 -35
- package/dist/Framework/ThirdParty/EmailTool.js.map +0 -1
- package/dist/Framework/ThirdParty/OpenSocial.js +0 -33
- package/dist/Framework/ThirdParty/OpenSocial.js.map +0 -1
- package/dist/Framework/ThirdParty/QQTool.js +0 -117
- package/dist/Framework/ThirdParty/QQTool.js.map +0 -1
- package/dist/Framework/ThirdParty/QiniuTool.js +0 -23
- package/dist/Framework/ThirdParty/QiniuTool.js.map +0 -1
- package/dist/Framework/ThirdParty/Rpc.js +0 -64
- package/dist/Framework/ThirdParty/Rpc.js.map +0 -1
- package/dist/Framework/ThirdParty/WechatOATool.js +0 -62
- package/dist/Framework/ThirdParty/WechatOATool.js.map +0 -1
- package/dist/Framework/ThirdParty/WechatTool.js +0 -76
- package/dist/Framework/ThirdParty/WechatTool.js.map +0 -1
- package/dist/Framework/WebServer/Controller/BaseController.js +0 -113
- package/dist/Framework/WebServer/Controller/BaseController.js.map +0 -1
- package/dist/Framework/WebServer/Controller/BaseUserController.js +0 -170
- package/dist/Framework/WebServer/Controller/BaseUserController.js.map +0 -1
- package/dist/Framework/WebServer/Controller/MongoBaseUserController.js +0 -170
- package/dist/Framework/WebServer/Controller/MongoBaseUserController.js.map +0 -1
- package/dist/Framework/WebServer/Decorator/AdminValidate.js +0 -20
- package/dist/Framework/WebServer/Decorator/AdminValidate.js.map +0 -1
- package/dist/Framework/WebServer/Decorator/AuthorityValidate.js +0 -23
- package/dist/Framework/WebServer/Decorator/AuthorityValidate.js.map +0 -1
- package/dist/Framework/WebServer/Decorator/CreatorValidate.js +0 -20
- package/dist/Framework/WebServer/Decorator/CreatorValidate.js.map +0 -1
- package/dist/Framework/WebServer/Decorator/JsonAdminValidate.js +0 -16
- package/dist/Framework/WebServer/Decorator/JsonAdminValidate.js.map +0 -1
- package/dist/Framework/WebServer/Decorator/JsonAuthorityValidate.js +0 -21
- package/dist/Framework/WebServer/Decorator/JsonAuthorityValidate.js.map +0 -1
- package/dist/Framework/WebServer/Decorator/JsonCreatorValidate.js +0 -20
- package/dist/Framework/WebServer/Decorator/JsonCreatorValidate.js.map +0 -1
- package/dist/Framework/WebServer/Decorator/SyncCall.js +0 -22
- package/dist/Framework/WebServer/Decorator/SyncCall.js.map +0 -1
- package/dist/Framework/WebServer/Decorator/SyncCallServer.js +0 -42
- package/dist/Framework/WebServer/Decorator/SyncCallServer.js.map +0 -1
- package/dist/Framework/WebServer/Engine/ControllerManager.js +0 -113
- package/dist/Framework/WebServer/Engine/ControllerManager.js.map +0 -1
- package/dist/Framework/WebServer/Engine/Engine.js +0 -155
- package/dist/Framework/WebServer/Engine/Engine.js.map +0 -1
- package/dist/Framework/WebServer/Engine/RazorJs.js +0 -545
- package/dist/Framework/WebServer/Engine/RazorJs.js.map +0 -1
- package/dist/Framework/WebServer/Engine/Request.js +0 -217
- package/dist/Framework/WebServer/Engine/Request.js.map +0 -1
- package/dist/Framework/WebServer/Engine/Response.js +0 -102
- package/dist/Framework/WebServer/Engine/Response.js.map +0 -1
- package/dist/Framework/WebServer/IWebServer.js +0 -55
- package/dist/Framework/WebServer/IWebServer.js.map +0 -1
- package/dist/Framework/cgserver.js +0 -88
- package/dist/Framework/cgserver.js.map +0 -1
- package/dist/Framework/index.js +0 -184
- package/dist/Framework/index.js.map +0 -1
- package/dist/lib/AI/AiObject.js +0 -13
- package/dist/lib/AI/Astar.js +0 -140
- package/dist/lib/AI/BehaviorAI.js +0 -302
- package/dist/lib/AI/Entity.js +0 -48
- package/dist/lib/AI/Point.js +0 -71
- package/dist/lib/AI/TriggerMgr.js +0 -207
- package/dist/lib/Config/Config.js +0 -54
- package/dist/lib/Config/FrameworkConfig.js +0 -261
- package/dist/lib/Config/IServerConfig.js +0 -48
- package/dist/lib/Config/_error_.js +0 -37
- package/dist/lib/Core/Core.js +0 -710
- package/dist/lib/Core/Timer.js +0 -149
- package/dist/lib/Database/Decorator/AutoIncrement.js +0 -11
- package/dist/lib/Database/Decorator/DBCache.js +0 -118
- package/dist/lib/Database/Decorator/NotNull.js +0 -11
- package/dist/lib/Database/Decorator/PrimaryKey.js +0 -11
- package/dist/lib/Database/Decorator/Property.js +0 -70
- package/dist/lib/Database/Decorator/Table.js +0 -15
- package/dist/lib/Database/Decorator/Type.js +0 -20
- package/dist/lib/Database/MSSqlManager.js +0 -106
- package/dist/lib/Database/MongoBaseService.js +0 -293
- package/dist/lib/Database/MongoManager.js +0 -670
- package/dist/lib/Database/MysqlBaseService.js +0 -478
- package/dist/lib/Database/MysqlManager.js +0 -250
- package/dist/lib/Database/RedisManager.js +0 -475
- package/dist/lib/Framework/AI/AiObject.js.map +0 -1
- package/dist/lib/Framework/AI/Astar.js.map +0 -1
- package/dist/lib/Framework/AI/BehaviorAI.js.map +0 -1
- package/dist/lib/Framework/AI/Entity.js.map +0 -1
- package/dist/lib/Framework/AI/Point.js.map +0 -1
- package/dist/lib/Framework/AI/TriggerMgr.js.map +0 -1
- package/dist/lib/Framework/Config/Config.js.map +0 -1
- package/dist/lib/Framework/Config/FrameworkConfig.js.map +0 -1
- package/dist/lib/Framework/Config/IServerConfig.js.map +0 -1
- package/dist/lib/Framework/Config/_error_.js.map +0 -1
- package/dist/lib/Framework/Core/Core.js.map +0 -1
- package/dist/lib/Framework/Core/Timer.js.map +0 -1
- package/dist/lib/Framework/Database/Decorator/AutoIncrement.js.map +0 -1
- package/dist/lib/Framework/Database/Decorator/DBCache.js.map +0 -1
- package/dist/lib/Framework/Database/Decorator/NotNull.js.map +0 -1
- package/dist/lib/Framework/Database/Decorator/PrimaryKey.js.map +0 -1
- package/dist/lib/Framework/Database/Decorator/Property.js.map +0 -1
- package/dist/lib/Framework/Database/Decorator/Table.js.map +0 -1
- package/dist/lib/Framework/Database/Decorator/Type.js.map +0 -1
- package/dist/lib/Framework/Database/MSSqlManager.js.map +0 -1
- package/dist/lib/Framework/Database/MongoBaseService.js.map +0 -1
- package/dist/lib/Framework/Database/MongoManager.js.map +0 -1
- package/dist/lib/Framework/Database/MysqlBaseService.js.map +0 -1
- package/dist/lib/Framework/Database/MysqlManager.js.map +0 -1
- package/dist/lib/Framework/Database/RedisManager.js.map +0 -1
- package/dist/lib/Framework/Logic/CacheTool.js.map +0 -1
- package/dist/lib/Framework/Logic/EventTool.js.map +0 -1
- package/dist/lib/Framework/Logic/HttpTool.js.map +0 -1
- package/dist/lib/Framework/Logic/Log.js.map +0 -1
- package/dist/lib/Framework/Logic/SyncQueueTool.js.map +0 -1
- package/dist/lib/Framework/Service/AccountService.js.map +0 -1
- package/dist/lib/Framework/Service/MongoAccountService.js.map +0 -1
- package/dist/lib/Framework/Service/MongoCacheService.js.map +0 -1
- package/dist/lib/Framework/Service/MongoUserService.js.map +0 -1
- package/dist/lib/Framework/Service/UserService.js.map +0 -1
- package/dist/lib/Framework/Service/ini.js.map +0 -1
- package/dist/lib/Framework/SocketServer/IClientWebSocket.js.map +0 -1
- package/dist/lib/Framework/SocketServer/IRpc.js.map +0 -1
- package/dist/lib/Framework/SocketServer/IRpcClientWebSocket.js.map +0 -1
- package/dist/lib/Framework/SocketServer/IRpcServerWebSocket.js.map +0 -1
- package/dist/lib/Framework/SocketServer/IServerWebSocket.js.map +0 -1
- package/dist/lib/Framework/SocketServer/ISocketServer.js.map +0 -1
- package/dist/lib/Framework/SocketServer/IWebSocket.js.map +0 -1
- package/dist/lib/Framework/SocketServer/ProtoFilter/GoogleProtoFilter.js.map +0 -1
- package/dist/lib/Framework/SocketServer/ProtoFilter/IProtoFilter.js.map +0 -1
- package/dist/lib/Framework/SocketServer/ProtoFilter/JsonProtoFilter.js.map +0 -1
- package/dist/lib/Framework/SocketServer/ProtoFilter/ProtoFactory.js.map +0 -1
- package/dist/lib/Framework/ThirdParty/AlipayTool.js.map +0 -1
- package/dist/lib/Framework/ThirdParty/Alisms.js.map +0 -1
- package/dist/lib/Framework/ThirdParty/AppleTool.js.map +0 -1
- package/dist/lib/Framework/ThirdParty/CgMq.js.map +0 -1
- package/dist/lib/Framework/ThirdParty/EmailTool.js.map +0 -1
- package/dist/lib/Framework/ThirdParty/OpenSocial.js.map +0 -1
- package/dist/lib/Framework/ThirdParty/QQTool.js.map +0 -1
- package/dist/lib/Framework/ThirdParty/QiniuTool.js.map +0 -1
- package/dist/lib/Framework/ThirdParty/Rpc.js.map +0 -1
- package/dist/lib/Framework/ThirdParty/WechatOATool.js.map +0 -1
- package/dist/lib/Framework/ThirdParty/WechatTool.js.map +0 -1
- package/dist/lib/Framework/WebServer/Controller/BaseController.js.map +0 -1
- package/dist/lib/Framework/WebServer/Controller/BaseUserController.js.map +0 -1
- package/dist/lib/Framework/WebServer/Controller/MongoBaseUserController.js.map +0 -1
- package/dist/lib/Framework/WebServer/Decorator/AdminValidate.js.map +0 -1
- package/dist/lib/Framework/WebServer/Decorator/AuthorityValidate.js.map +0 -1
- package/dist/lib/Framework/WebServer/Decorator/CreatorValidate.js.map +0 -1
- package/dist/lib/Framework/WebServer/Decorator/JsonAdminValidate.js.map +0 -1
- package/dist/lib/Framework/WebServer/Decorator/JsonAuthorityValidate.js.map +0 -1
- package/dist/lib/Framework/WebServer/Decorator/JsonCreatorValidate.js.map +0 -1
- package/dist/lib/Framework/WebServer/Decorator/SyncCall.js.map +0 -1
- package/dist/lib/Framework/WebServer/Decorator/SyncCallServer.js.map +0 -1
- package/dist/lib/Framework/WebServer/Engine/ControllerManager.js.map +0 -1
- package/dist/lib/Framework/WebServer/Engine/Engine.js.map +0 -1
- package/dist/lib/Framework/WebServer/Engine/RazorJs.js.map +0 -1
- package/dist/lib/Framework/WebServer/Engine/Request.js.map +0 -1
- package/dist/lib/Framework/WebServer/Engine/Response.js.map +0 -1
- package/dist/lib/Framework/WebServer/IWebServer.js.map +0 -1
- package/dist/lib/Framework/cgserver.js.map +0 -1
- package/dist/lib/Framework/index.js.map +0 -1
- package/dist/lib/Logic/CacheTool.js +0 -77
- package/dist/lib/Logic/EventTool.js +0 -42
- package/dist/lib/Logic/HttpTool.js +0 -78
- package/dist/lib/Logic/Log.js +0 -148
- package/dist/lib/Logic/SyncQueueTool.js +0 -134
- package/dist/lib/Service/AccountService.js +0 -665
- package/dist/lib/Service/MongoAccountService.js +0 -598
- package/dist/lib/Service/MongoCacheService.js +0 -122
- package/dist/lib/Service/MongoUserService.js +0 -197
- package/dist/lib/Service/UserService.js +0 -296
- package/dist/lib/Service/ini.js +0 -36
- package/dist/lib/SocketServer/IClientWebSocket.js +0 -76
- package/dist/lib/SocketServer/IRpc.js +0 -36
- package/dist/lib/SocketServer/IRpcClientWebSocket.js +0 -130
- package/dist/lib/SocketServer/IRpcServerWebSocket.js +0 -130
- package/dist/lib/SocketServer/IServerWebSocket.js +0 -112
- package/dist/lib/SocketServer/ISocketServer.js +0 -275
- package/dist/lib/SocketServer/IWebSocket.js +0 -288
- package/dist/lib/SocketServer/ProtoFilter/GoogleProtoFilter.js +0 -60
- package/dist/lib/SocketServer/ProtoFilter/IProtoFilter.js +0 -8
- package/dist/lib/SocketServer/ProtoFilter/JsonProtoFilter.js +0 -32
- package/dist/lib/SocketServer/ProtoFilter/ProtoFactory.js +0 -34
- package/dist/lib/ThirdParty/AlipayTool.js +0 -264
- package/dist/lib/ThirdParty/Alisms.js +0 -50
- package/dist/lib/ThirdParty/AppleTool.js +0 -314
- package/dist/lib/ThirdParty/CgMq.js +0 -282
- package/dist/lib/ThirdParty/EmailTool.js +0 -36
- package/dist/lib/ThirdParty/OpenSocial.js +0 -91
- package/dist/lib/ThirdParty/QQTool.js +0 -182
- package/dist/lib/ThirdParty/QiniuTool.js +0 -28
- package/dist/lib/ThirdParty/Rpc.js +0 -181
- package/dist/lib/ThirdParty/WechatOATool.js +0 -67
- package/dist/lib/ThirdParty/WechatTool.js +0 -148
- package/dist/lib/WebServer/Controller/BaseController.js +0 -178
- package/dist/lib/WebServer/Controller/BaseUserController.js +0 -303
- package/dist/lib/WebServer/Controller/MongoBaseUserController.js +0 -303
- package/dist/lib/WebServer/Decorator/AdminValidate.js +0 -19
- package/dist/lib/WebServer/Decorator/AuthorityValidate.js +0 -22
- package/dist/lib/WebServer/Decorator/CreatorValidate.js +0 -19
- package/dist/lib/WebServer/Decorator/JsonAdminValidate.js +0 -15
- package/dist/lib/WebServer/Decorator/JsonAuthorityValidate.js +0 -20
- package/dist/lib/WebServer/Decorator/JsonCreatorValidate.js +0 -19
- package/dist/lib/WebServer/Decorator/SyncCall.js +0 -63
- package/dist/lib/WebServer/Decorator/SyncCallServer.js +0 -110
- package/dist/lib/WebServer/Engine/ControllerManager.js +0 -117
- package/dist/lib/WebServer/Engine/Engine.js +0 -207
- package/dist/lib/WebServer/Engine/RazorJs.js +0 -547
- package/dist/lib/WebServer/Engine/Request.js +0 -274
- package/dist/lib/WebServer/Engine/Response.js +0 -102
- package/dist/lib/WebServer/IWebServer.js +0 -107
- package/dist/lib/cgserver.js +0 -100
- package/dist/lib/index.js +0 -194
- package/dist/lib/test/test.js.map +0 -1
- package/dist/test/test.js +0 -11
- package/dist/test/test.js.map +0 -1
- package/dist/types/AI/AiObject.d.ts +0 -5
- package/dist/types/AI/Astar.d.ts +0 -38
- package/dist/types/AI/BehaviorAI.d.ts +0 -24
- package/dist/types/AI/Entity.d.ts +0 -12
- package/dist/types/AI/Point.d.ts +0 -17
- package/dist/types/AI/TriggerMgr.d.ts +0 -52
- package/dist/types/Config/Config.d.ts +0 -12
- package/dist/types/Config/FrameworkConfig.d.ts +0 -228
- package/dist/types/Config/IServerConfig.d.ts +0 -9
- package/dist/types/Config/_error_.d.ts +0 -99
- package/dist/types/Core/Core.d.ts +0 -108
- package/dist/types/Core/Timer.d.ts +0 -16
- package/dist/types/Database/Decorator/AutoIncrement.d.ts +0 -1
- package/dist/types/Database/Decorator/DBCache.d.ts +0 -23
- package/dist/types/Database/Decorator/NotNull.d.ts +0 -1
- package/dist/types/Database/Decorator/PrimaryKey.d.ts +0 -1
- package/dist/types/Database/Decorator/Property.d.ts +0 -57
- package/dist/types/Database/Decorator/Table.d.ts +0 -1
- package/dist/types/Database/Decorator/Type.d.ts +0 -1
- package/dist/types/Database/MSSqlManager.d.ts +0 -17
- package/dist/types/Database/MongoBaseService.d.ts +0 -81
- package/dist/types/Database/MongoManager.d.ts +0 -143
- package/dist/types/Database/MysqlBaseService.d.ts +0 -34
- package/dist/types/Database/MysqlManager.d.ts +0 -41
- package/dist/types/Database/RedisManager.d.ts +0 -64
- package/dist/types/Logic/CacheTool.d.ts +0 -27
- package/dist/types/Logic/EventTool.d.ts +0 -13
- package/dist/types/Logic/HttpTool.d.ts +0 -15
- package/dist/types/Logic/Log.d.ts +0 -25
- package/dist/types/Logic/SyncQueueTool.d.ts +0 -21
- package/dist/types/Service/AccountService.d.ts +0 -77
- package/dist/types/Service/MongoAccountService.d.ts +0 -78
- package/dist/types/Service/MongoCacheService.d.ts +0 -14
- package/dist/types/Service/MongoUserService.d.ts +0 -36
- package/dist/types/Service/UserService.d.ts +0 -36
- package/dist/types/Service/ini.d.ts +0 -29
- package/dist/types/SocketServer/IClientWebSocket.d.ts +0 -17
- package/dist/types/SocketServer/IRpc.d.ts +0 -8
- package/dist/types/SocketServer/IRpcClientWebSocket.d.ts +0 -16
- package/dist/types/SocketServer/IRpcServerWebSocket.d.ts +0 -16
- package/dist/types/SocketServer/IServerWebSocket.d.ts +0 -28
- package/dist/types/SocketServer/ISocketServer.d.ts +0 -45
- package/dist/types/SocketServer/IWebSocket.d.ts +0 -60
- package/dist/types/SocketServer/ProtoFilter/GoogleProtoFilter.d.ts +0 -9
- package/dist/types/SocketServer/ProtoFilter/IProtoFilter.d.ts +0 -9
- package/dist/types/SocketServer/ProtoFilter/JsonProtoFilter.d.ts +0 -6
- package/dist/types/SocketServer/ProtoFilter/ProtoFactory.d.ts +0 -8
- package/dist/types/ThirdParty/AlipayTool.d.ts +0 -109
- package/dist/types/ThirdParty/Alisms.d.ts +0 -14
- package/dist/types/ThirdParty/AppleTool.d.ts +0 -131
- package/dist/types/ThirdParty/CgMq.d.ts +0 -51
- package/dist/types/ThirdParty/EmailTool.d.ts +0 -5
- package/dist/types/ThirdParty/OpenSocial.d.ts +0 -7
- package/dist/types/ThirdParty/QQTool.d.ts +0 -41
- package/dist/types/ThirdParty/QiniuTool.d.ts +0 -6
- package/dist/types/ThirdParty/Rpc.d.ts +0 -20
- package/dist/types/ThirdParty/WechatOATool.d.ts +0 -13
- package/dist/types/ThirdParty/WechatTool.d.ts +0 -20
- package/dist/types/WebServer/Controller/BaseController.d.ts +0 -33
- package/dist/types/WebServer/Controller/BaseUserController.d.ts +0 -27
- package/dist/types/WebServer/Controller/MongoBaseUserController.d.ts +0 -27
- package/dist/types/WebServer/Decorator/AdminValidate.d.ts +0 -1
- package/dist/types/WebServer/Decorator/AuthorityValidate.d.ts +0 -2
- package/dist/types/WebServer/Decorator/CreatorValidate.d.ts +0 -1
- package/dist/types/WebServer/Decorator/JsonAdminValidate.d.ts +0 -1
- package/dist/types/WebServer/Decorator/JsonAuthorityValidate.d.ts +0 -2
- package/dist/types/WebServer/Decorator/JsonCreatorValidate.d.ts +0 -1
- package/dist/types/WebServer/Decorator/SyncCall.d.ts +0 -7
- package/dist/types/WebServer/Decorator/SyncCallServer.d.ts +0 -7
- package/dist/types/WebServer/Engine/ControllerManager.d.ts +0 -35
- package/dist/types/WebServer/Engine/Engine.d.ts +0 -21
- package/dist/types/WebServer/Engine/RazorJs.d.ts +0 -21
- package/dist/types/WebServer/Engine/Request.d.ts +0 -35
- package/dist/types/WebServer/Engine/Response.d.ts +0 -30
- package/dist/types/WebServer/IWebServer.d.ts +0 -20
- package/dist/types/cgserver.d.ts +0 -24
- package/dist/types/index.d.ts +0 -85
- package/src/Framework/AI/AiObject.ts +0 -12
- package/src/Framework/AI/Astar.ts +0 -157
- package/src/Framework/AI/BehaviorAI.ts +0 -382
- package/src/Framework/AI/Entity.ts +0 -37
- package/src/Framework/AI/Point.ts +0 -84
- package/src/Framework/AI/TriggerMgr.ts +0 -280
- package/src/Framework/Config/Config.ts +0 -61
- package/src/Framework/Config/FrameworkConfig.ts +0 -286
- package/src/Framework/Config/IServerConfig.ts +0 -28
- package/src/Framework/Config/_error_.ts +0 -32
- package/src/Framework/Core/Core.ts +0 -810
- package/src/Framework/Core/Timer.ts +0 -147
- package/src/Framework/Database/Decorator/AutoIncrement.ts +0 -9
- package/src/Framework/Database/Decorator/DBCache.ts +0 -74
- package/src/Framework/Database/Decorator/NotNull.ts +0 -9
- package/src/Framework/Database/Decorator/PrimaryKey.ts +0 -9
- package/src/Framework/Database/Decorator/Property.ts +0 -64
- package/src/Framework/Database/Decorator/Table.ts +0 -13
- package/src/Framework/Database/Decorator/Type.ts +0 -21
- package/src/Framework/Database/MSSqlManager.ts +0 -52
- package/src/Framework/Database/MongoBaseService.ts +0 -136
- package/src/Framework/Database/MongoManager.ts +0 -501
- package/src/Framework/Database/MysqlBaseService.ts +0 -345
- package/src/Framework/Database/MysqlManager.ts +0 -212
- package/src/Framework/Database/RedisManager.ts +0 -544
- package/src/Framework/Logic/CacheTool.ts +0 -85
- package/src/Framework/Logic/EventTool.ts +0 -31
- package/src/Framework/Logic/HttpTool.ts +0 -82
- package/src/Framework/Logic/Log.ts +0 -171
- package/src/Framework/Logic/SyncQueueTool.ts +0 -51
- package/src/Framework/Service/AccountService.ts +0 -508
- package/src/Framework/Service/MongoAccountService.ts +0 -456
- package/src/Framework/Service/MongoCacheService.ts +0 -48
- package/src/Framework/Service/MongoUserService.ts +0 -103
- package/src/Framework/Service/UserService.ts +0 -168
- package/src/Framework/Service/ini.ts +0 -33
- package/src/Framework/SocketServer/IClientWebSocket.ts +0 -50
- package/src/Framework/SocketServer/IRpc.ts +0 -12
- package/src/Framework/SocketServer/IRpcClientWebSocket.ts +0 -75
- package/src/Framework/SocketServer/IRpcServerWebSocket.ts +0 -76
- package/src/Framework/SocketServer/IServerWebSocket.ts +0 -88
- package/src/Framework/SocketServer/ISocketServer.ts +0 -243
- package/src/Framework/SocketServer/IWebSocket.ts +0 -243
- package/src/Framework/SocketServer/ProtoFilter/GoogleProtoFilter.ts +0 -68
- package/src/Framework/SocketServer/ProtoFilter/IProtoFilter.ts +0 -11
- package/src/Framework/SocketServer/ProtoFilter/JsonProtoFilter.ts +0 -34
- package/src/Framework/SocketServer/ProtoFilter/ProtoFactory.ts +0 -34
- package/src/Framework/ThirdParty/AlipayTool.ts +0 -224
- package/src/Framework/ThirdParty/Alisms.ts +0 -53
- package/src/Framework/ThirdParty/AppleTool.ts +0 -252
- package/src/Framework/ThirdParty/CgMq.ts +0 -153
- package/src/Framework/ThirdParty/EmailTool.ts +0 -37
- package/src/Framework/ThirdParty/OpenSocial.ts +0 -36
- package/src/Framework/ThirdParty/QQTool.ts +0 -124
- package/src/Framework/ThirdParty/QiniuTool.ts +0 -23
- package/src/Framework/ThirdParty/Rpc.ts +0 -75
- package/src/Framework/ThirdParty/WechatOATool.ts +0 -61
- package/src/Framework/ThirdParty/WechatTool.ts +0 -80
- package/src/Framework/WebServer/Controller/BaseController.ts +0 -140
- package/src/Framework/WebServer/Controller/BaseUserController.ts +0 -209
- package/src/Framework/WebServer/Controller/MongoBaseUserController.ts +0 -209
- package/src/Framework/WebServer/Decorator/AdminValidate.ts +0 -19
- package/src/Framework/WebServer/Decorator/AuthorityValidate.ts +0 -25
- package/src/Framework/WebServer/Decorator/CreatorValidate.ts +0 -19
- package/src/Framework/WebServer/Decorator/JsonAdminValidate.ts +0 -16
- package/src/Framework/WebServer/Decorator/JsonAuthorityValidate.d.ts +0 -2
- package/src/Framework/WebServer/Decorator/JsonAuthorityValidate.ts +0 -23
- package/src/Framework/WebServer/Decorator/JsonCreatorValidate.ts +0 -19
- package/src/Framework/WebServer/Decorator/SyncCall.ts +0 -20
- package/src/Framework/WebServer/Decorator/SyncCallServer.ts +0 -45
- package/src/Framework/WebServer/Engine/ControllerManager.ts +0 -134
- package/src/Framework/WebServer/Engine/Engine.ts +0 -186
- package/src/Framework/WebServer/Engine/RazorJs.ts +0 -720
- package/src/Framework/WebServer/Engine/Request.ts +0 -267
- package/src/Framework/WebServer/Engine/Response.ts +0 -123
- package/src/Framework/WebServer/IWebServer.ts +0 -61
- package/src/Framework/cgserver.ts +0 -112
- package/src/Framework/index.ts +0 -92
- package/src/test/test.ts +0 -12
|
@@ -1,720 +0,0 @@
|
|
|
1
|
-
import { GLog } from './../../Logic/Log';
|
|
2
|
-
'use strict';
|
|
3
|
-
var _suffix = ".cshtml"
|
|
4
|
-
var _MATCH_HTML = /[&<>\'"]/g
|
|
5
|
-
var _ENCODE_HTML_RULES = {
|
|
6
|
-
'&': '&'
|
|
7
|
-
, '<': '<'
|
|
8
|
-
, '>': '>'
|
|
9
|
-
, '"': '"'
|
|
10
|
-
, "'": '''
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
var encode_char = function (c)
|
|
14
|
-
{
|
|
15
|
-
return _ENCODE_HTML_RULES[c] || c;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
var utils =
|
|
19
|
-
{
|
|
20
|
-
regExpChars: /[|\\{}()[\]^$+*?.]/g,
|
|
21
|
-
|
|
22
|
-
escapeRegExpChars : function (string)
|
|
23
|
-
{
|
|
24
|
-
// istanbul ignore if
|
|
25
|
-
if (!string)
|
|
26
|
-
{
|
|
27
|
-
return '';
|
|
28
|
-
}
|
|
29
|
-
return String(string).replace(this.regExpChars, '\\$&');
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
escapeFuncStr :
|
|
33
|
-
'var _ENCODE_HTML_RULES = {\n'
|
|
34
|
-
+ ' "&": "&"\n'
|
|
35
|
-
+ ' , "<": "<"\n'
|
|
36
|
-
+ ' , ">": ">"\n'
|
|
37
|
-
+ ' , \'"\': """\n'
|
|
38
|
-
+ ' , "\'": "'"\n'
|
|
39
|
-
+ ' }\n'
|
|
40
|
-
+ ' , _MATCH_HTML = /[&<>\'"]/g;\n'
|
|
41
|
-
+ 'function encode_char(c) {\n'
|
|
42
|
-
+ ' return _ENCODE_HTML_RULES[c] || c;\n'
|
|
43
|
-
+ '};\n',
|
|
44
|
-
|
|
45
|
-
escapeXML : function (markup)
|
|
46
|
-
{
|
|
47
|
-
return markup == undefined
|
|
48
|
-
? ''
|
|
49
|
-
: String(markup)
|
|
50
|
-
.replace(_MATCH_HTML, encode_char);
|
|
51
|
-
},
|
|
52
|
-
shallowCopy : function (to, from)
|
|
53
|
-
{
|
|
54
|
-
from = from || {};
|
|
55
|
-
for (var p in from)
|
|
56
|
-
{
|
|
57
|
-
to[p] = from[p];
|
|
58
|
-
}
|
|
59
|
-
return to;
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
cache :
|
|
63
|
-
{
|
|
64
|
-
_data: {},
|
|
65
|
-
set: function (key, val)
|
|
66
|
-
{
|
|
67
|
-
this._data[key] = val;
|
|
68
|
-
},
|
|
69
|
-
get: function (key)
|
|
70
|
-
{
|
|
71
|
-
return this._data[key];
|
|
72
|
-
},
|
|
73
|
-
reset: function ()
|
|
74
|
-
{
|
|
75
|
-
this._data = {};
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
utils.escapeXML.toString = function ()
|
|
81
|
-
{
|
|
82
|
-
return Function.prototype.toString.call(this) + ';\n' + this.escapeFuncStr
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
var fs = require('fs')
|
|
89
|
-
var scopeOptionWarned = false
|
|
90
|
-
var _DEFAULT_DELIMITER = '%'
|
|
91
|
-
var _DEFAULT_LOCALS_NAME = 'locals'
|
|
92
|
-
var _REGEX_STRING = '(<%%|<%=|<%-|<%_|<%#|<%|%>|-%>|_%>)'
|
|
93
|
-
var _OPTS = ['cache', 'filename', 'delimiter', 'scope', 'context'
|
|
94
|
-
, 'debug', 'compileDebug', 'client', '_with', 'rmWhitespace'
|
|
95
|
-
, 'strict', 'localsName'
|
|
96
|
-
]
|
|
97
|
-
var _TRAILING_SEMCOL = /;\s*$/
|
|
98
|
-
var _BOM = /^\uFEFF/
|
|
99
|
-
|
|
100
|
-
export class RazorJs
|
|
101
|
-
{
|
|
102
|
-
protected _request=null
|
|
103
|
-
protected _response=null
|
|
104
|
-
cache=utils.cache
|
|
105
|
-
localsName=_DEFAULT_LOCALS_NAME
|
|
106
|
-
constructor()
|
|
107
|
-
{
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
resolveInclude(name, filename)
|
|
111
|
-
{
|
|
112
|
-
var path = require('path')
|
|
113
|
-
, dirname = path.dirname
|
|
114
|
-
, extname = path.extname
|
|
115
|
-
, resolve = path.resolve
|
|
116
|
-
, includePath = resolve(dirname(filename), name)
|
|
117
|
-
, ext = extname(name);
|
|
118
|
-
if (!ext)
|
|
119
|
-
{
|
|
120
|
-
includePath += _suffix;
|
|
121
|
-
}
|
|
122
|
-
return includePath;
|
|
123
|
-
}
|
|
124
|
-
_handleCache(options, template?)
|
|
125
|
-
{
|
|
126
|
-
var fn
|
|
127
|
-
var path = options.filename
|
|
128
|
-
var hasTemplate = arguments.length > 1;
|
|
129
|
-
|
|
130
|
-
if (options.cache)
|
|
131
|
-
{
|
|
132
|
-
if (!path)
|
|
133
|
-
{
|
|
134
|
-
throw new Error('cache option requires a filename');
|
|
135
|
-
}
|
|
136
|
-
fn = exports.cache.get(path);
|
|
137
|
-
if (fn)
|
|
138
|
-
{
|
|
139
|
-
return fn;
|
|
140
|
-
}
|
|
141
|
-
if (!hasTemplate)
|
|
142
|
-
{
|
|
143
|
-
template = fs.readFileSync(path).toString().replace(_BOM, '');
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
else if (!hasTemplate)
|
|
147
|
-
{
|
|
148
|
-
// istanbul ignore if: should not happen at all
|
|
149
|
-
if (!path)
|
|
150
|
-
{
|
|
151
|
-
throw new Error('Internal Razor error: no file name or template '
|
|
152
|
-
+ 'provided');
|
|
153
|
-
}
|
|
154
|
-
template = fs.readFileSync(path).toString().replace(_BOM, '');
|
|
155
|
-
}
|
|
156
|
-
fn = this.compile(template, options);
|
|
157
|
-
if (options.cache)
|
|
158
|
-
{
|
|
159
|
-
this.cache.set(path, fn);
|
|
160
|
-
}
|
|
161
|
-
return fn;
|
|
162
|
-
}
|
|
163
|
-
includeFile(path, options)
|
|
164
|
-
{
|
|
165
|
-
var opts = utils.shallowCopy({}, options);
|
|
166
|
-
if (!opts.filename)
|
|
167
|
-
{
|
|
168
|
-
throw new Error('`include` requires the \'filename\' option.');
|
|
169
|
-
}
|
|
170
|
-
opts.filename = this.resolveInclude(path, opts.filename);
|
|
171
|
-
return this._handleCache(opts);
|
|
172
|
-
}
|
|
173
|
-
includeSource(path, options)
|
|
174
|
-
{
|
|
175
|
-
var opts = utils.shallowCopy({}, options)
|
|
176
|
-
, includePath
|
|
177
|
-
, template;
|
|
178
|
-
includePath = path;
|
|
179
|
-
/*
|
|
180
|
-
if (!opts.filename)
|
|
181
|
-
{
|
|
182
|
-
includePath = path;
|
|
183
|
-
}
|
|
184
|
-
else
|
|
185
|
-
{
|
|
186
|
-
includePath = this.resolveInclude(path, opts.filename);
|
|
187
|
-
}
|
|
188
|
-
*/
|
|
189
|
-
/*解决view里面使用其他controller的action返回的分部view,,,但是该功能暂时搁置,因为按照现在的写法无法支持异步操作
|
|
190
|
-
* 而nodejs异步操作是特点所以不去扼杀它的优势了
|
|
191
|
-
if (includePath.lastIndexOf(".") <= 0)
|
|
192
|
-
{
|
|
193
|
-
engine.getEngine().getHtmlFromPath(this._request,this._response,includePath)
|
|
194
|
-
return null
|
|
195
|
-
}
|
|
196
|
-
* */
|
|
197
|
-
template = fs.readFileSync(includePath).toString().replace(_BOM, '');
|
|
198
|
-
|
|
199
|
-
options.filename = includePath;
|
|
200
|
-
opts.filename = includePath;
|
|
201
|
-
var templ = new Template(this, template, opts);
|
|
202
|
-
templ.generateSource();
|
|
203
|
-
return templ.source;
|
|
204
|
-
}
|
|
205
|
-
_cpOptsInData(data, opts)
|
|
206
|
-
{
|
|
207
|
-
_OPTS.forEach(function (p)
|
|
208
|
-
{
|
|
209
|
-
if (typeof data[p] != 'undefined')
|
|
210
|
-
{
|
|
211
|
-
opts[p] = data[p]
|
|
212
|
-
}
|
|
213
|
-
})
|
|
214
|
-
}
|
|
215
|
-
compile(template, opts)
|
|
216
|
-
{
|
|
217
|
-
var templ;
|
|
218
|
-
|
|
219
|
-
// v1 compat
|
|
220
|
-
// 'scope' is 'context'
|
|
221
|
-
// FIXME: Remove this in a future version
|
|
222
|
-
if (opts && opts.scope)
|
|
223
|
-
{
|
|
224
|
-
if (!scopeOptionWarned)
|
|
225
|
-
{
|
|
226
|
-
console.warn('`scope` option is deprecated and will be removed in Razor 3');
|
|
227
|
-
scopeOptionWarned = true;
|
|
228
|
-
}
|
|
229
|
-
if (!opts.context)
|
|
230
|
-
{
|
|
231
|
-
opts.context = opts.scope;
|
|
232
|
-
}
|
|
233
|
-
delete opts.scope;
|
|
234
|
-
}
|
|
235
|
-
templ = new Template(this, template, opts);
|
|
236
|
-
return templ.compile();
|
|
237
|
-
}
|
|
238
|
-
render(req, res, tmpl_path, data, opts)
|
|
239
|
-
{
|
|
240
|
-
this._request = req
|
|
241
|
-
this._response = res
|
|
242
|
-
var cs_path=tmpl_path+".cshtml"
|
|
243
|
-
var template = fs.readFileSync(cs_path).toString()
|
|
244
|
-
if(!template)
|
|
245
|
-
{
|
|
246
|
-
var h5_path=tmpl_path+".html"
|
|
247
|
-
var html = fs.readFileSync(h5_path).toString()
|
|
248
|
-
if(html)
|
|
249
|
-
{
|
|
250
|
-
return html
|
|
251
|
-
}
|
|
252
|
-
GLog.error("no view:"+tmpl_path)
|
|
253
|
-
return "Server Error(No View)"
|
|
254
|
-
}
|
|
255
|
-
data = data || {};
|
|
256
|
-
opts = opts || {};
|
|
257
|
-
var fn;
|
|
258
|
-
|
|
259
|
-
// No options object -- if there are optiony names
|
|
260
|
-
// in the data, copy them to options
|
|
261
|
-
if (arguments.length == 2)
|
|
262
|
-
{
|
|
263
|
-
this._cpOptsInData(data, opts)
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
return this._handleCache(opts, template)(data);
|
|
267
|
-
}
|
|
268
|
-
renderFile()
|
|
269
|
-
{
|
|
270
|
-
var args = Array.prototype.slice.call(arguments)
|
|
271
|
-
, path = args.shift()
|
|
272
|
-
, cb = args.pop()
|
|
273
|
-
, data = args.shift() || {}
|
|
274
|
-
, opts = args.pop() || {}
|
|
275
|
-
, result;
|
|
276
|
-
|
|
277
|
-
// Don't pollute passed in opts obj with new vals
|
|
278
|
-
opts = utils.shallowCopy({}, opts);
|
|
279
|
-
|
|
280
|
-
// No options object -- if there are optiony names
|
|
281
|
-
// in the data, copy them to options
|
|
282
|
-
if (arguments.length == 3)
|
|
283
|
-
{
|
|
284
|
-
// Express 4
|
|
285
|
-
if (data.settings && data.settings['view options'])
|
|
286
|
-
{
|
|
287
|
-
this._cpOptsInData(data.settings['view options'], opts);
|
|
288
|
-
}
|
|
289
|
-
// Express 3 and lower
|
|
290
|
-
else
|
|
291
|
-
{
|
|
292
|
-
this._cpOptsInData(data, opts);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
opts.filename = path;
|
|
296
|
-
|
|
297
|
-
try
|
|
298
|
-
{
|
|
299
|
-
result = this._handleCache(opts)(data);
|
|
300
|
-
}
|
|
301
|
-
catch (err)
|
|
302
|
-
{
|
|
303
|
-
return cb(err);
|
|
304
|
-
}
|
|
305
|
-
return cb(null, result);
|
|
306
|
-
}
|
|
307
|
-
clearCache ()
|
|
308
|
-
{
|
|
309
|
-
this.cache.reset();
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
var rethrow = function (err, str, filename, lineno)
|
|
314
|
-
{
|
|
315
|
-
var lines = str.split('\n')
|
|
316
|
-
, start = Math.max(lineno - 3, 0)
|
|
317
|
-
, end = Math.min(lines.length, lineno + 3);
|
|
318
|
-
|
|
319
|
-
// Error context
|
|
320
|
-
var context = lines.slice(start, end).map(function (line, i)
|
|
321
|
-
{
|
|
322
|
-
var curr = i + start + 1;
|
|
323
|
-
return (curr == lineno ? ' >> ' : ' ')
|
|
324
|
-
+ curr
|
|
325
|
-
+ '| '
|
|
326
|
-
+ line;
|
|
327
|
-
}).join('\n');
|
|
328
|
-
|
|
329
|
-
// Alter exception message
|
|
330
|
-
err.path = filename;
|
|
331
|
-
err.message = (filename || 'razor') + ':'
|
|
332
|
-
+ lineno + '\n'
|
|
333
|
-
+ context + '\n\n'
|
|
334
|
-
+ err.message;
|
|
335
|
-
|
|
336
|
-
throw err;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
class Template
|
|
340
|
-
{
|
|
341
|
-
_razorJs=null
|
|
342
|
-
templateText:string=""
|
|
343
|
-
mode=null
|
|
344
|
-
truncate:boolean=false
|
|
345
|
-
currentLine:number=1
|
|
346
|
-
source:string=""
|
|
347
|
-
dependencies=[]
|
|
348
|
-
opts=null
|
|
349
|
-
regex=null
|
|
350
|
-
modes =
|
|
351
|
-
{
|
|
352
|
-
EVAL: 'eval',
|
|
353
|
-
ESCAPED: 'escaped',
|
|
354
|
-
RAW: 'raw',
|
|
355
|
-
COMMENT: 'comment',
|
|
356
|
-
LITERAL: 'literal'
|
|
357
|
-
}
|
|
358
|
-
constructor(razorjs, text, opts)
|
|
359
|
-
{
|
|
360
|
-
this._razorJs = razorjs;
|
|
361
|
-
opts = opts || {};
|
|
362
|
-
this.templateText = text;
|
|
363
|
-
var options =
|
|
364
|
-
{
|
|
365
|
-
client : opts.client || false,
|
|
366
|
-
escapeFunction : opts.escape || utils.escapeXML,
|
|
367
|
-
compileDebug : opts.compileDebug !== false,
|
|
368
|
-
debug : !!opts.debug,
|
|
369
|
-
filename : opts.filename,
|
|
370
|
-
delimiter : opts.delimiter || exports.delimiter || _DEFAULT_DELIMITER,
|
|
371
|
-
strict : opts.strict || false,
|
|
372
|
-
context : opts.context,
|
|
373
|
-
cache : opts.cache || false,
|
|
374
|
-
rmWhitespace : opts.rmWhitespace,
|
|
375
|
-
localsName : opts.localsName || exports.localsName || _DEFAULT_LOCALS_NAME,
|
|
376
|
-
_with:false,
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
if (!options.strict)
|
|
380
|
-
{
|
|
381
|
-
options._with = typeof opts._with != 'undefined' ? opts._with : true;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
this.opts = options;
|
|
385
|
-
|
|
386
|
-
this.regex = this.createRegex();
|
|
387
|
-
}
|
|
388
|
-
createRegex()
|
|
389
|
-
{
|
|
390
|
-
var str = _REGEX_STRING
|
|
391
|
-
, delim = utils.escapeRegExpChars(this.opts.delimiter);
|
|
392
|
-
str = str.replace(/%/g, delim);
|
|
393
|
-
return new RegExp(str);
|
|
394
|
-
}
|
|
395
|
-
compile()
|
|
396
|
-
{
|
|
397
|
-
var src
|
|
398
|
-
, fn
|
|
399
|
-
, opts = this.opts
|
|
400
|
-
, prepended = ''
|
|
401
|
-
, appended = ''
|
|
402
|
-
, escape = opts.escapeFunction;
|
|
403
|
-
|
|
404
|
-
if (opts.rmWhitespace)
|
|
405
|
-
{
|
|
406
|
-
// Have to use two separate replace here as `^` and `$` operators don't
|
|
407
|
-
// work well with `\r`.
|
|
408
|
-
this.templateText =
|
|
409
|
-
this.templateText.replace(/\r/g, '').replace(/^\s+|\s+$/gm, '');
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
// Slurp spaces and tabs before <%_ and after _%>
|
|
413
|
-
this.templateText =
|
|
414
|
-
this.templateText.replace(/[ \t]*<%_/gm, '<%_').replace(/_%>[ \t]*/gm, '_%>');
|
|
415
|
-
|
|
416
|
-
if (!this.source)
|
|
417
|
-
{
|
|
418
|
-
this.generateSource();
|
|
419
|
-
prepended += ' var __output = [], __append = __output.push.bind(__output);' + '\n';
|
|
420
|
-
if (opts._with !== false)
|
|
421
|
-
{
|
|
422
|
-
prepended += ' with (' + opts.localsName + ' || {}) {' + '\n';
|
|
423
|
-
appended += ' }' + '\n';
|
|
424
|
-
}
|
|
425
|
-
appended += ' return __output.join("");' + '\n';
|
|
426
|
-
this.source = prepended + this.source + appended;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
if (opts.compileDebug)
|
|
430
|
-
{
|
|
431
|
-
src = 'var __line = 1' + '\n'
|
|
432
|
-
+ ' , __lines = ' + JSON.stringify(this.templateText) + '\n'
|
|
433
|
-
+ ' , __filename = ' + (opts.filename ?
|
|
434
|
-
JSON.stringify(opts.filename) : 'undefined') + ';' + '\n'
|
|
435
|
-
+ 'try {' + '\n'
|
|
436
|
-
+ this.source
|
|
437
|
-
+ '} catch (e) {' + '\n'
|
|
438
|
-
+ ' rethrow(e, __lines, __filename, __line);' + '\n'
|
|
439
|
-
+ '}' + '\n';
|
|
440
|
-
}
|
|
441
|
-
else
|
|
442
|
-
{
|
|
443
|
-
src = this.source;
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
if (opts.debug)
|
|
447
|
-
{
|
|
448
|
-
console.log(src);
|
|
449
|
-
}
|
|
450
|
-
|
|
451
|
-
if (opts.client)
|
|
452
|
-
{
|
|
453
|
-
src = 'escape = escape || ' + escape.toString() + ';' + '\n' + src;
|
|
454
|
-
if (opts.compileDebug)
|
|
455
|
-
{
|
|
456
|
-
src = 'rethrow = rethrow || ' + rethrow.toString() + ';' + '\n' + src;
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
if (opts.strict)
|
|
461
|
-
{
|
|
462
|
-
src = '"use strict";\n' + src;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
try
|
|
466
|
-
{
|
|
467
|
-
fn = new Function(opts.localsName + ', escape, include, rethrow', src);
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
catch (e)
|
|
471
|
-
{
|
|
472
|
-
// istanbul ignore else
|
|
473
|
-
if (e instanceof SyntaxError)
|
|
474
|
-
{
|
|
475
|
-
if (opts.filename)
|
|
476
|
-
{
|
|
477
|
-
e.message += ' in ' + opts.filename;
|
|
478
|
-
}
|
|
479
|
-
e.message += ' while compiling razor';
|
|
480
|
-
}
|
|
481
|
-
throw e;
|
|
482
|
-
}
|
|
483
|
-
|
|
484
|
-
if (opts.client)
|
|
485
|
-
{
|
|
486
|
-
fn.dependencies = this.dependencies;
|
|
487
|
-
return fn;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
// Return a callable function which will execute the function
|
|
491
|
-
// created by the source-code, with the passed data as locals
|
|
492
|
-
// Adds a local `include` function which allows full recursive include
|
|
493
|
-
var returnedFn:any = (data)=>
|
|
494
|
-
{
|
|
495
|
-
var include = (path, includeData)=>
|
|
496
|
-
{
|
|
497
|
-
var d = utils.shallowCopy({}, data);
|
|
498
|
-
if (includeData)
|
|
499
|
-
{
|
|
500
|
-
d = utils.shallowCopy(d, includeData);
|
|
501
|
-
}
|
|
502
|
-
return this._razorJs.includeFile(path, opts)(d);
|
|
503
|
-
};
|
|
504
|
-
return fn.apply(opts.context, [data || {}, escape, include, rethrow]);
|
|
505
|
-
};
|
|
506
|
-
returnedFn.dependencies = this.dependencies;
|
|
507
|
-
return returnedFn;
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
generateSource()
|
|
511
|
-
{
|
|
512
|
-
var self = this
|
|
513
|
-
var matches = this.parseTemplateText()
|
|
514
|
-
var d = this.opts.delimiter
|
|
515
|
-
|
|
516
|
-
if (matches && matches.length)
|
|
517
|
-
{
|
|
518
|
-
matches.forEach(function (line, index)
|
|
519
|
-
{
|
|
520
|
-
var opening
|
|
521
|
-
var closing
|
|
522
|
-
var include
|
|
523
|
-
var includeOpts
|
|
524
|
-
var includeSrc
|
|
525
|
-
// If this is an opening tag, check for closing tags
|
|
526
|
-
// FIXME: May end up with some false positives here
|
|
527
|
-
// Better to store modes as k/v with '<' + delimiter as key
|
|
528
|
-
// Then this can simply check against the map
|
|
529
|
-
if (line.indexOf('<' + d) === 0 // If it is a tag
|
|
530
|
-
&& line.indexOf('<' + d + d) !== 0)
|
|
531
|
-
{ // and is not escaped
|
|
532
|
-
closing = matches[index + 2];
|
|
533
|
-
if (!(closing == d + '>' || closing == '-' + d + '>' || closing == '_' + d + '>'))
|
|
534
|
-
{
|
|
535
|
-
throw new Error('Could not find matching close tag for "' + line + '".');
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
// HACK: backward-compat `include` preprocessor directives
|
|
539
|
-
if ((include = line.match(/^\s*include\s+(\S+)/)))
|
|
540
|
-
{
|
|
541
|
-
opening = matches[index - 1];
|
|
542
|
-
// Must be in EVAL or RAW mode
|
|
543
|
-
if (opening && (opening == '<' + d || opening == '<' + d + '-' || opening == '<' + d + '_'))
|
|
544
|
-
{
|
|
545
|
-
includeOpts = utils.shallowCopy({}, self.opts);
|
|
546
|
-
includeSrc = self._razorJs.includeSource(include[1], includeOpts);
|
|
547
|
-
includeSrc = ' ; (function(){' + '\n' + includeSrc +
|
|
548
|
-
' ; })()' + '\n';
|
|
549
|
-
self.source += includeSrc;
|
|
550
|
-
self.dependencies.push(self._razorJs.resolveInclude(include[1],
|
|
551
|
-
includeOpts.filename));
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
self.scanLine(line);
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
|
|
559
|
-
}
|
|
560
|
-
parseTemplateText()
|
|
561
|
-
{
|
|
562
|
-
var str = this.templateText
|
|
563
|
-
, pat = this.regex
|
|
564
|
-
, result = pat.exec(str)
|
|
565
|
-
, arr = []
|
|
566
|
-
, firstPos
|
|
567
|
-
, lastPos;
|
|
568
|
-
|
|
569
|
-
while (result)
|
|
570
|
-
{
|
|
571
|
-
firstPos = result.index;
|
|
572
|
-
lastPos = pat.lastIndex;
|
|
573
|
-
|
|
574
|
-
if (firstPos !== 0)
|
|
575
|
-
{
|
|
576
|
-
arr.push(str.substring(0, firstPos));
|
|
577
|
-
str = str.slice(firstPos);
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
arr.push(result[0]);
|
|
581
|
-
str = str.slice(result[0].length);
|
|
582
|
-
result = pat.exec(str);
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
if (str)
|
|
586
|
-
{
|
|
587
|
-
arr.push(str);
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
return arr;
|
|
591
|
-
}
|
|
592
|
-
scanLine(line)
|
|
593
|
-
{
|
|
594
|
-
var self = this
|
|
595
|
-
, d = this.opts.delimiter
|
|
596
|
-
, newLineCount = 0;
|
|
597
|
-
|
|
598
|
-
function _addOutput()
|
|
599
|
-
{
|
|
600
|
-
if (self.truncate)
|
|
601
|
-
{
|
|
602
|
-
// Only replace single leading linebreak in the line after
|
|
603
|
-
// -%> tag -- this is the single, trailing linebreak
|
|
604
|
-
// after the tag that the truncation mode replaces
|
|
605
|
-
// Handle Win / Unix / old Mac linebreaks -- do the \r\n
|
|
606
|
-
// combo first in the regex-or
|
|
607
|
-
line = line.replace(/^(?:\r\n|\r|\n)/, '')
|
|
608
|
-
self.truncate = false;
|
|
609
|
-
}
|
|
610
|
-
else if (self.opts.rmWhitespace)
|
|
611
|
-
{
|
|
612
|
-
// Gotta be more careful here.
|
|
613
|
-
// .replace(/^(\s*)\n/, '$1') might be more appropriate here but as
|
|
614
|
-
// rmWhitespace already removes trailing spaces anyway so meh.
|
|
615
|
-
line = line.replace(/^\n/, '');
|
|
616
|
-
}
|
|
617
|
-
if (!line)
|
|
618
|
-
{
|
|
619
|
-
return;
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
// Preserve literal slashes
|
|
623
|
-
line = line.replace(/\\/g, '\\\\');
|
|
624
|
-
|
|
625
|
-
// Convert linebreaks
|
|
626
|
-
line = line.replace(/\n/g, '\\n');
|
|
627
|
-
line = line.replace(/\r/g, '\\r');
|
|
628
|
-
|
|
629
|
-
// Escape double-quotes
|
|
630
|
-
// - this will be the delimiter during execution
|
|
631
|
-
line = line.replace(/"/g, '\\"');
|
|
632
|
-
self.source += ' ; __append("' + line + '")' + '\n';
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
newLineCount = (line.split('\n').length - 1);
|
|
636
|
-
|
|
637
|
-
switch (line)
|
|
638
|
-
{
|
|
639
|
-
case '<' + d:
|
|
640
|
-
case '<' + d + '_':
|
|
641
|
-
this.mode = this.modes.EVAL;
|
|
642
|
-
break;
|
|
643
|
-
case '<' + d + '=':
|
|
644
|
-
this.mode = this.modes.ESCAPED;
|
|
645
|
-
break;
|
|
646
|
-
case '<' + d + '-':
|
|
647
|
-
this.mode = this.modes.RAW;
|
|
648
|
-
break;
|
|
649
|
-
case '<' + d + '#':
|
|
650
|
-
this.mode = this.modes.COMMENT;
|
|
651
|
-
break;
|
|
652
|
-
case '<' + d + d:
|
|
653
|
-
this.mode = this.modes.LITERAL;
|
|
654
|
-
this.source += ' ; __append("' + line.replace('<' + d + d, '<' + d) + '")' + '\n';
|
|
655
|
-
break;
|
|
656
|
-
case d + '>':
|
|
657
|
-
case '-' + d + '>':
|
|
658
|
-
case '_' + d + '>':
|
|
659
|
-
if (this.mode == this.modes.LITERAL)
|
|
660
|
-
{
|
|
661
|
-
_addOutput();
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
this.mode = null;
|
|
665
|
-
this.truncate = line.indexOf('-') === 0 || line.indexOf('_') === 0;
|
|
666
|
-
break;
|
|
667
|
-
default:
|
|
668
|
-
// In script mode, depends on type of tag
|
|
669
|
-
if (this.mode)
|
|
670
|
-
{
|
|
671
|
-
// If '//' is found without a line break, add a line break.
|
|
672
|
-
switch (this.mode)
|
|
673
|
-
{
|
|
674
|
-
case this.modes.EVAL:
|
|
675
|
-
case this.modes.ESCAPED:
|
|
676
|
-
case this.modes.RAW:
|
|
677
|
-
if (line.lastIndexOf('//') > line.lastIndexOf('\n'))
|
|
678
|
-
{
|
|
679
|
-
line += '\n';
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
switch (this.mode)
|
|
683
|
-
{
|
|
684
|
-
// Just executing code
|
|
685
|
-
case this.modes.EVAL:
|
|
686
|
-
this.source += ' ; ' + line + '\n';
|
|
687
|
-
break;
|
|
688
|
-
// Exec, esc, and output
|
|
689
|
-
case this.modes.ESCAPED:
|
|
690
|
-
this.source += ' ; __append(escape(' +
|
|
691
|
-
line.replace(_TRAILING_SEMCOL, '').trim() + '))' + '\n';
|
|
692
|
-
break;
|
|
693
|
-
// Exec and output
|
|
694
|
-
case this.modes.RAW:
|
|
695
|
-
this.source += ' ; __append(' +
|
|
696
|
-
line.replace(_TRAILING_SEMCOL, '').trim() + ')' + '\n';
|
|
697
|
-
break;
|
|
698
|
-
case this.modes.COMMENT:
|
|
699
|
-
// Do nothing
|
|
700
|
-
break;
|
|
701
|
-
// Literal <%% mode, append as raw output
|
|
702
|
-
case this.modes.LITERAL:
|
|
703
|
-
_addOutput();
|
|
704
|
-
break;
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
// In string mode, just add the output
|
|
708
|
-
else
|
|
709
|
-
{
|
|
710
|
-
_addOutput();
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
if (self.opts.compileDebug && newLineCount)
|
|
715
|
-
{
|
|
716
|
-
this.currentLine += newLineCount;
|
|
717
|
-
this.source += ' ; __line = ' + this.currentLine + '\n';
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
}
|