jcc-express-mvc 1.8.7 → 1.8.21

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.
Files changed (296) hide show
  1. package/Core/index.d.ts +4 -0
  2. package/Core/index.d.ts.map +1 -1
  3. package/Core/index.js +5 -0
  4. package/__tests__/Job.test.d.ts +2 -0
  5. package/__tests__/Job.test.d.ts.map +1 -0
  6. package/__tests__/Job.test.js +205 -0
  7. package/__tests__/MySqlSchemaBlueprint.test.d.ts +2 -0
  8. package/__tests__/MySqlSchemaBlueprint.test.d.ts.map +1 -0
  9. package/__tests__/MySqlSchemaBlueprint.test.js +55 -0
  10. package/__tests__/PostgresTranslator.test.d.ts +2 -0
  11. package/__tests__/PostgresTranslator.test.d.ts.map +1 -0
  12. package/__tests__/PostgresTranslator.test.js +82 -0
  13. package/__tests__/SQLiteTranslator.test.d.ts +2 -0
  14. package/__tests__/SQLiteTranslator.test.d.ts.map +1 -0
  15. package/__tests__/SQLiteTranslator.test.js +125 -0
  16. package/__tests__/SchemaAlterBlueprint.test.d.ts +2 -0
  17. package/__tests__/SchemaAlterBlueprint.test.d.ts.map +1 -0
  18. package/__tests__/SchemaAlterBlueprint.test.js +35 -0
  19. package/global.d.ts +3 -1
  20. package/index.d.ts +28 -3
  21. package/index.d.ts.map +1 -1
  22. package/index.js +33 -75
  23. package/lib/Application/Application.d.ts.map +1 -1
  24. package/lib/Application/Application.js +2 -2
  25. package/lib/Application/ApplicationBuilder.d.ts.map +1 -1
  26. package/lib/Application/ApplicationBuilder.js +22 -11
  27. package/lib/Auth/AuthMiddleware.d.ts.map +1 -1
  28. package/lib/Auth/AuthMiddleware.js +29 -12
  29. package/lib/Auth/index.d.ts +17 -3
  30. package/lib/Auth/index.d.ts.map +1 -1
  31. package/lib/Auth/index.js +128 -26
  32. package/lib/Auth/loginRateLimit.d.ts +6 -0
  33. package/lib/Auth/loginRateLimit.d.ts.map +1 -0
  34. package/lib/Auth/loginRateLimit.js +25 -0
  35. package/lib/Auth/refreshTokenStore.d.ts +24 -0
  36. package/lib/Auth/refreshTokenStore.d.ts.map +1 -0
  37. package/lib/Auth/refreshTokenStore.js +46 -0
  38. package/lib/Command-Line/DBCommand.d.ts.map +1 -1
  39. package/lib/Command-Line/DBCommand.js +9 -3
  40. package/lib/Command-Line/KeyGenerateCommand.d.ts +6 -0
  41. package/lib/Command-Line/KeyGenerateCommand.d.ts.map +1 -0
  42. package/lib/Command-Line/KeyGenerateCommand.js +47 -0
  43. package/lib/Command-Line/MakeCommand.d.ts +1 -0
  44. package/lib/Command-Line/MakeCommand.d.ts.map +1 -1
  45. package/lib/Command-Line/MakeCommand.js +36 -32
  46. package/lib/Command-Line/NodeArtisanCommand.d.ts +2 -0
  47. package/lib/Command-Line/NodeArtisanCommand.d.ts.map +1 -1
  48. package/lib/Command-Line/NodeArtisanCommand.js +24 -6
  49. package/lib/Command-Line/NodeTinker/Tinker.d.ts +5 -2
  50. package/lib/Command-Line/NodeTinker/Tinker.d.ts.map +1 -1
  51. package/lib/Command-Line/NodeTinker/Tinker.js +13 -3
  52. package/lib/Command-Line/WatchCommand.d.ts +29 -0
  53. package/lib/Command-Line/WatchCommand.d.ts.map +1 -0
  54. package/lib/Command-Line/WatchCommand.js +234 -0
  55. package/lib/Command-Line/files/Models.d.ts.map +1 -1
  56. package/lib/Command-Line/files/Models.js +67 -0
  57. package/lib/Console/Command.d.ts +18 -0
  58. package/lib/Console/Command.d.ts.map +1 -1
  59. package/lib/Console/Command.js +29 -0
  60. package/lib/Container/index.d.ts.map +1 -1
  61. package/lib/Container/index.js +22 -8
  62. package/lib/Database/Database.d.ts +21 -0
  63. package/lib/Database/Database.d.ts.map +1 -0
  64. package/lib/Database/Database.js +55 -0
  65. package/lib/Database/DatabaseServiceProvider.d.ts +22 -0
  66. package/lib/Database/DatabaseServiceProvider.d.ts.map +1 -0
  67. package/lib/Database/DatabaseServiceProvider.js +50 -0
  68. package/lib/Database/Drivers/KnexDriver.d.ts +13 -0
  69. package/lib/Database/Drivers/KnexDriver.d.ts.map +1 -0
  70. package/lib/Database/Drivers/KnexDriver.js +29 -0
  71. package/lib/Database/Drivers/MongooseDriver.d.ts +20 -0
  72. package/lib/Database/Drivers/MongooseDriver.d.ts.map +1 -0
  73. package/lib/Database/Drivers/MongooseDriver.js +57 -0
  74. package/lib/Database/Drivers/SequelizeDriver.d.ts +24 -0
  75. package/lib/Database/Drivers/SequelizeDriver.d.ts.map +1 -0
  76. package/lib/Database/Drivers/SequelizeDriver.js +82 -0
  77. package/lib/Database/index.d.ts +7 -0
  78. package/lib/Database/index.d.ts.map +1 -0
  79. package/lib/Database/index.js +11 -0
  80. package/lib/Database/interface.d.ts +14 -0
  81. package/lib/Database/interface.d.ts.map +1 -0
  82. package/lib/Database/interface.js +2 -0
  83. package/lib/Database/type.d.ts +18 -0
  84. package/lib/Database/type.d.ts.map +1 -0
  85. package/lib/Database/type.js +2 -0
  86. package/lib/Error/DisplayErrorCode.d.ts.map +1 -1
  87. package/lib/Error/DisplayErrorCode.js +27 -17
  88. package/lib/Error/MissMatchTokenException/index.d.ts +4 -0
  89. package/lib/Error/MissMatchTokenException/index.d.ts.map +1 -0
  90. package/lib/Error/MissMatchTokenException/index.js +9 -0
  91. package/lib/Error/SocialiteAuthError/SocialiteAuthError.d.ts +9 -0
  92. package/lib/Error/SocialiteAuthError/SocialiteAuthError.d.ts.map +1 -0
  93. package/lib/Error/SocialiteAuthError/SocialiteAuthError.js +17 -0
  94. package/lib/Global/helpers.d.ts.map +1 -1
  95. package/lib/Global/helpers.js +7 -6
  96. package/lib/Http/index.d.ts +3 -1
  97. package/lib/Http/index.d.ts.map +1 -1
  98. package/lib/Http/index.js +26 -5
  99. package/lib/Interface/index.d.ts +17 -3
  100. package/lib/Interface/index.d.ts.map +1 -1
  101. package/lib/Jcc-eloquent/lib/Builder.d.ts +12 -1
  102. package/lib/Jcc-eloquent/lib/Builder.d.ts.map +1 -1
  103. package/lib/Jcc-eloquent/lib/Builder.js +119 -5
  104. package/lib/Jcc-eloquent/lib/Database/index.d.ts.map +1 -1
  105. package/lib/Jcc-eloquent/lib/Database/index.js +2 -1
  106. package/lib/Jcc-eloquent/lib/Interfaces/index.d.ts +37 -2
  107. package/lib/Jcc-eloquent/lib/Interfaces/index.d.ts.map +1 -1
  108. package/lib/Jcc-eloquent/lib/Migration.d.ts +6 -0
  109. package/lib/Jcc-eloquent/lib/Migration.d.ts.map +1 -1
  110. package/lib/Jcc-eloquent/lib/Migration.js +24 -2
  111. package/lib/Jcc-eloquent/lib/Model.d.ts +24 -7
  112. package/lib/Jcc-eloquent/lib/Model.d.ts.map +1 -1
  113. package/lib/Jcc-eloquent/lib/Model.js +35 -2
  114. package/lib/Jcc-eloquent/lib/QueryBuilder.d.ts +2 -1
  115. package/lib/Jcc-eloquent/lib/QueryBuilder.d.ts.map +1 -1
  116. package/lib/Jcc-eloquent/lib/QueryBuilder.js +10 -1
  117. package/lib/Jcc-eloquent/lib/Rollback.d.ts.map +1 -1
  118. package/lib/Jcc-eloquent/lib/Rollback.js +9 -2
  119. package/lib/Jcc-eloquent/lib/Schema/BaseSchemaEntity/index.d.ts.map +1 -1
  120. package/lib/Jcc-eloquent/lib/Schema/BaseSchemaEntity/index.js +3 -3
  121. package/lib/Jcc-eloquent/lib/Schema/BluePrint/index.d.ts +6 -2
  122. package/lib/Jcc-eloquent/lib/Schema/BluePrint/index.d.ts.map +1 -1
  123. package/lib/Jcc-eloquent/lib/Schema/BluePrint/index.js +41 -12
  124. package/lib/Jcc-eloquent/lib/Schema/Translator/Sqlite.d.ts.map +1 -1
  125. package/lib/Jcc-eloquent/lib/Schema/Translator/Sqlite.js +21 -3
  126. package/lib/Jcc-eloquent/lib/Schema/Translator/postgres.d.ts +1 -0
  127. package/lib/Jcc-eloquent/lib/Schema/Translator/postgres.d.ts.map +1 -1
  128. package/lib/Jcc-eloquent/lib/Schema/Translator/postgres.js +70 -14
  129. package/lib/Jcc-eloquent/lib/Schema/index.d.ts +12 -0
  130. package/lib/Jcc-eloquent/lib/Schema/index.d.ts.map +1 -1
  131. package/lib/Jcc-eloquent/lib/Schema/index.js +27 -6
  132. package/lib/Jcc-eloquent/lib/utils/index.d.ts +13 -0
  133. package/lib/Jcc-eloquent/lib/utils/index.d.ts.map +1 -1
  134. package/lib/Jcc-eloquent/lib/utils/index.js +62 -0
  135. package/lib/Middleware/index.d.ts +1 -0
  136. package/lib/Middleware/index.d.ts.map +1 -1
  137. package/lib/Middleware/index.js +20 -8
  138. package/lib/Model/Sequelize.d.ts +3 -0
  139. package/lib/Model/Sequelize.d.ts.map +1 -0
  140. package/lib/Model/Sequelize.js +6 -0
  141. package/lib/Providers/RouteServiceProvider.d.ts.map +1 -1
  142. package/lib/Providers/RouteServiceProvider.js +3 -0
  143. package/lib/Providers/SessionServiceProvider.d.ts +12 -0
  144. package/lib/Providers/SessionServiceProvider.d.ts.map +1 -0
  145. package/lib/Providers/SessionServiceProvider.js +47 -0
  146. package/lib/Queue/Controllers/QueueControllers.d.ts +31 -0
  147. package/lib/Queue/Controllers/QueueControllers.d.ts.map +1 -0
  148. package/lib/Queue/Controllers/QueueControllers.js +126 -0
  149. package/lib/Queue/Drivers/DatabaseDriver.d.ts +6 -1
  150. package/lib/Queue/Drivers/DatabaseDriver.d.ts.map +1 -1
  151. package/lib/Queue/Drivers/DatabaseDriver.js +76 -21
  152. package/lib/Queue/Drivers/MemoryDriver.d.ts +17 -6
  153. package/lib/Queue/Drivers/MemoryDriver.d.ts.map +1 -1
  154. package/lib/Queue/Drivers/MemoryDriver.js +323 -14
  155. package/lib/Queue/Drivers/RedisDriver.d.ts +48 -0
  156. package/lib/Queue/Drivers/RedisDriver.d.ts.map +1 -0
  157. package/lib/Queue/Drivers/RedisDriver.js +533 -0
  158. package/lib/Queue/Job.d.ts +8 -0
  159. package/lib/Queue/Job.d.ts.map +1 -1
  160. package/lib/Queue/Job.js +25 -1
  161. package/lib/Queue/JobsLogger.d.ts.map +1 -1
  162. package/lib/Queue/JobsLogger.js +6 -3
  163. package/lib/Queue/Queue.d.ts +17 -0
  164. package/lib/Queue/Queue.d.ts.map +1 -1
  165. package/lib/Queue/Queue.js +146 -11
  166. package/lib/Queue/QueueServiceProvider.d.ts +6 -0
  167. package/lib/Queue/QueueServiceProvider.d.ts.map +1 -0
  168. package/lib/Queue/QueueServiceProvider.js +18 -0
  169. package/lib/Queue/Route/web.d.ts +2 -0
  170. package/lib/Queue/Route/web.d.ts.map +1 -0
  171. package/lib/Queue/Route/web.js +16 -0
  172. package/lib/Queue/index.d.ts +1 -0
  173. package/lib/Queue/index.d.ts.map +1 -1
  174. package/lib/Queue/index.js +3 -0
  175. package/lib/Queue/interface.d.ts +25 -0
  176. package/lib/Queue/interface.d.ts.map +1 -1
  177. package/lib/Queue/middleware/queueDashboardGuard.d.ts +7 -0
  178. package/lib/Queue/middleware/queueDashboardGuard.d.ts.map +1 -0
  179. package/lib/Queue/middleware/queueDashboardGuard.js +43 -0
  180. package/lib/Queue/type.d.ts +12 -1
  181. package/lib/Queue/type.d.ts.map +1 -1
  182. package/lib/Response/index.d.ts.map +1 -1
  183. package/lib/Response/index.js +6 -1
  184. package/lib/Routes/Route.d.ts +2 -2
  185. package/lib/Routes/Route.d.ts.map +1 -1
  186. package/lib/Routes/RouteBuilder.d.ts +2 -2
  187. package/lib/Routes/RouteBuilder.d.ts.map +1 -1
  188. package/lib/Security/CsrfMiddleware.d.ts +37 -0
  189. package/lib/Security/CsrfMiddleware.d.ts.map +1 -0
  190. package/lib/Security/CsrfMiddleware.js +85 -0
  191. package/lib/Security/MethodSpoofingMiddleware.d.ts +36 -0
  192. package/lib/Security/MethodSpoofingMiddleware.d.ts.map +1 -0
  193. package/lib/Security/MethodSpoofingMiddleware.js +51 -0
  194. package/lib/Security/index.d.ts +5 -0
  195. package/lib/Security/index.d.ts.map +1 -0
  196. package/lib/Security/index.js +7 -0
  197. package/lib/Session/DatabaseSession.d.ts +9 -3
  198. package/lib/Session/DatabaseSession.d.ts.map +1 -1
  199. package/lib/Session/DatabaseSession.js +38 -36
  200. package/lib/Session/ExpressJccSession.d.ts +23 -0
  201. package/lib/Session/ExpressJccSession.d.ts.map +1 -0
  202. package/lib/Session/ExpressJccSession.js +110 -0
  203. package/lib/Session/RedisSession.d.ts +2 -2
  204. package/lib/Session/RedisSession.d.ts.map +1 -1
  205. package/lib/Session/RedisSession.js +19 -5
  206. package/lib/Session/SessionManager.d.ts +18 -4
  207. package/lib/Session/SessionManager.d.ts.map +1 -1
  208. package/lib/Session/SessionManager.js +53 -17
  209. package/lib/Socialite/AbstractProvider.d.ts +60 -0
  210. package/lib/Socialite/AbstractProvider.d.ts.map +1 -0
  211. package/lib/Socialite/AbstractProvider.js +136 -0
  212. package/lib/Socialite/Drivers/facebook/FacebookDriver.d.ts +9 -0
  213. package/lib/Socialite/Drivers/facebook/FacebookDriver.d.ts.map +1 -0
  214. package/lib/Socialite/Drivers/facebook/FacebookDriver.js +40 -0
  215. package/lib/Socialite/Drivers/facebook/FacebookProvider.d.ts +15 -0
  216. package/lib/Socialite/Drivers/facebook/FacebookProvider.d.ts.map +1 -0
  217. package/lib/Socialite/Drivers/facebook/FacebookProvider.js +28 -0
  218. package/lib/Socialite/Drivers/github/GitHubDriver.d.ts +9 -0
  219. package/lib/Socialite/Drivers/github/GitHubDriver.d.ts.map +1 -0
  220. package/lib/Socialite/Drivers/github/GitHubDriver.js +54 -0
  221. package/lib/Socialite/Drivers/github/GitHubProvider.d.ts +15 -0
  222. package/lib/Socialite/Drivers/github/GitHubProvider.d.ts.map +1 -0
  223. package/lib/Socialite/Drivers/github/GitHubProvider.js +28 -0
  224. package/lib/Socialite/Drivers/gitlab/GitLabDriver.d.ts +10 -0
  225. package/lib/Socialite/Drivers/gitlab/GitLabDriver.d.ts.map +1 -0
  226. package/lib/Socialite/Drivers/gitlab/GitLabDriver.js +37 -0
  227. package/lib/Socialite/Drivers/gitlab/GitLabProvider.d.ts +15 -0
  228. package/lib/Socialite/Drivers/gitlab/GitLabProvider.d.ts.map +1 -0
  229. package/lib/Socialite/Drivers/gitlab/GitLabProvider.js +28 -0
  230. package/lib/Socialite/Drivers/google/GoogleDriver.d.ts +9 -0
  231. package/lib/Socialite/Drivers/google/GoogleDriver.d.ts.map +1 -0
  232. package/lib/Socialite/Drivers/google/GoogleDriver.js +39 -0
  233. package/lib/Socialite/Drivers/google/GoogleProvider.d.ts +15 -0
  234. package/lib/Socialite/Drivers/google/GoogleProvider.d.ts.map +1 -0
  235. package/lib/Socialite/Drivers/google/GoogleProvider.js +28 -0
  236. package/lib/Socialite/Drivers/slack/SlackDriver.d.ts +9 -0
  237. package/lib/Socialite/Drivers/slack/SlackDriver.d.ts.map +1 -0
  238. package/lib/Socialite/Drivers/slack/SlackDriver.js +41 -0
  239. package/lib/Socialite/Drivers/slack/SlackProvider.d.ts +16 -0
  240. package/lib/Socialite/Drivers/slack/SlackProvider.d.ts.map +1 -0
  241. package/lib/Socialite/Drivers/slack/SlackProvider.js +37 -0
  242. package/lib/Socialite/Drivers/twitter/TwitterDriver.d.ts +9 -0
  243. package/lib/Socialite/Drivers/twitter/TwitterDriver.d.ts.map +1 -0
  244. package/lib/Socialite/Drivers/twitter/TwitterDriver.js +57 -0
  245. package/lib/Socialite/Drivers/twitter/TwitterProvider.d.ts +16 -0
  246. package/lib/Socialite/Drivers/twitter/TwitterProvider.d.ts.map +1 -0
  247. package/lib/Socialite/Drivers/twitter/TwitterProvider.js +38 -0
  248. package/lib/Socialite/SocialUser.d.ts +42 -0
  249. package/lib/Socialite/SocialUser.d.ts.map +1 -0
  250. package/lib/Socialite/SocialUser.js +116 -0
  251. package/lib/Socialite/Socialite.d.ts +13 -0
  252. package/lib/Socialite/Socialite.d.ts.map +1 -0
  253. package/lib/Socialite/Socialite.js +41 -0
  254. package/lib/Socialite/SocialiteProvider.d.ts +9 -0
  255. package/lib/Socialite/SocialiteProvider.d.ts.map +1 -0
  256. package/lib/Socialite/SocialiteProvider.js +15 -0
  257. package/lib/Socialite/config.d.ts +7 -0
  258. package/lib/Socialite/config.d.ts.map +1 -0
  259. package/lib/Socialite/config.js +44 -0
  260. package/lib/Socialite/constant.d.ts +18 -0
  261. package/lib/Socialite/constant.d.ts.map +1 -0
  262. package/lib/Socialite/constant.js +20 -0
  263. package/lib/Socialite/index.d.ts +13 -0
  264. package/lib/Socialite/index.d.ts.map +1 -0
  265. package/lib/Socialite/index.js +25 -0
  266. package/lib/Socialite/types.d.ts +13 -0
  267. package/lib/Socialite/types.d.ts.map +1 -0
  268. package/lib/Socialite/types.js +2 -0
  269. package/lib/Templating-engine/benchmark.d.ts +7 -0
  270. package/lib/Templating-engine/benchmark.d.ts.map +1 -0
  271. package/lib/Templating-engine/benchmark.js +44 -0
  272. package/lib/Templating-engine/engineHelper.d.ts +37 -8
  273. package/lib/Templating-engine/engineHelper.d.ts.map +1 -1
  274. package/lib/Templating-engine/engineHelper.js +203 -26
  275. package/lib/Templating-engine/errors.d.ts +15 -0
  276. package/lib/Templating-engine/errors.d.ts.map +1 -0
  277. package/lib/Templating-engine/errors.js +35 -0
  278. package/lib/Templating-engine/expressions.d.ts +24 -0
  279. package/lib/Templating-engine/expressions.d.ts.map +1 -1
  280. package/lib/Templating-engine/expressions.js +27 -5
  281. package/lib/Templating-engine/index.d.ts +87 -17
  282. package/lib/Templating-engine/index.d.ts.map +1 -1
  283. package/lib/Templating-engine/index.js +701 -96
  284. package/lib/Templating-engine/plugins.d.ts +30 -0
  285. package/lib/Templating-engine/plugins.d.ts.map +1 -0
  286. package/lib/Templating-engine/plugins.js +47 -0
  287. package/lib/Type/index.d.ts +1 -0
  288. package/lib/Type/index.d.ts.map +1 -1
  289. package/lib/Validation/Validator/CustomValidation.d.ts.map +1 -1
  290. package/lib/Validation/Validator/CustomValidation.js +2 -2
  291. package/lib/Validation/Validator/helper.d.ts.map +1 -1
  292. package/lib/Validation/Validator/helper.js +8 -1
  293. package/lib/util/index.d.ts +42 -1
  294. package/lib/util/index.d.ts.map +1 -1
  295. package/lib/util/index.js +154 -17
  296. package/package.json +1 -1
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveSocialiteConfig = resolveSocialiteConfig;
4
+ const Config_1 = require("../Config/Config");
5
+ function normalizeAppUrl(url) {
6
+ let u = (url || "").trim().replace(/\/$/, "");
7
+ if (!u)
8
+ u = "http://localhost:5500";
9
+ if (!/^https?:\/\//i.test(u))
10
+ u = `http://${u}`;
11
+ return u;
12
+ }
13
+ const defaultCallbackPath = {
14
+ google: "/auth/google/callback",
15
+ github: "/auth/github/callback",
16
+ facebook: "/auth/facebook/callback",
17
+ gitlab: "/auth/gitlab/callback",
18
+ twitter: "/auth/twitter/callback",
19
+ slack: "/auth/slack/callback",
20
+ };
21
+ /**
22
+ * Laravel `config/services.php` shape expressed via env:
23
+ * `{DRIVER}_CLIENT_ID`, `{DRIVER}_CLIENT_SECRET`, optional `{DRIVER}_REDIRECT_URI`.
24
+ */
25
+ function resolveSocialiteConfig(driver) {
26
+ const key = driver.toUpperCase();
27
+ const clientId = String(Config_1.config.get(`${key}_CLIENT_ID`, "") ?? "");
28
+ const clientSecret = String(Config_1.config.get(`${key}_CLIENT_SECRET`, "") ?? "");
29
+ let redirectUri = String(Config_1.config.get(`${key}_REDIRECT_URI`, "") ?? "");
30
+ if (!redirectUri) {
31
+ const base = normalizeAppUrl(String(Config_1.config.get("APP_URL", "") ?? ""));
32
+ const path = defaultCallbackPath[driver] ?? `/auth/${encodeURIComponent(driver)}/callback`;
33
+ redirectUri = `${base}${path.startsWith("/") ? path : `/${path}`}`;
34
+ }
35
+ const out = {
36
+ clientId,
37
+ clientSecret,
38
+ redirectUri,
39
+ };
40
+ if (driver === "gitlab") {
41
+ out.gitlabUrl = String(Config_1.config.get("GITLAB_URL", "https://gitlab.com") ?? "https://gitlab.com").replace(/\/$/, "");
42
+ }
43
+ return out;
44
+ }
@@ -0,0 +1,18 @@
1
+ export declare const GOOGLE_AUTH = "https://accounts.google.com/o/oauth2/v2/auth";
2
+ export declare const GOOGLE_TOKEN = "https://oauth2.googleapis.com/token";
3
+ export declare const GOOGLE_USERINFO = "https://openidconnect.googleapis.com/v1/userinfo";
4
+ export declare const GITHUB_AUTHORIZE = "https://github.com/login/oauth/authorize";
5
+ export declare const GITHUB_TOKEN = "https://github.com/login/oauth/access_token";
6
+ export declare const GITHUB_USER = "https://api.github.com/user";
7
+ export declare const GITHUB_EMAILS = "https://api.github.com/user/emails";
8
+ export declare const FACEBOOK_GRAPH_VERSION = "v21.0";
9
+ export declare const FACEBOOK_AUTHORIZE = "https://www.facebook.com/v21.0/dialog/oauth";
10
+ export declare const FACEBOOK_TOKEN = "https://graph.facebook.com/v21.0/oauth/access_token";
11
+ export declare const TWITTER_AUTHORIZE = "https://twitter.com/i/oauth2/authorize";
12
+ export declare const TWITTER_TOKEN = "https://api.twitter.com/2/oauth2/token";
13
+ export declare const TWITTER_USER_ME = "https://api.twitter.com/2/users/me";
14
+ /** Slack Sign in with Slack — OpenID Connect */
15
+ export declare const SLACK_OPENID_AUTHORIZE = "https://slack.com/openid/connect/authorize";
16
+ export declare const SLACK_OPENID_TOKEN = "https://slack.com/api/openid.connect.token";
17
+ export declare const SLACK_OPENID_USERINFO = "https://slack.com/api/openid.connect.userInfo";
18
+ //# sourceMappingURL=constant.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constant.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Socialite/constant.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,iDAAiD,CAAC;AAC1E,eAAO,MAAM,YAAY,wCAAwC,CAAC;AAClE,eAAO,MAAM,eAAe,qDACwB,CAAC;AAErD,eAAO,MAAM,gBAAgB,6CAA6C,CAAC;AAC3E,eAAO,MAAM,YAAY,gDAAgD,CAAC;AAC1E,eAAO,MAAM,WAAW,gCAAgC,CAAC;AACzD,eAAO,MAAM,aAAa,uCAAuC,CAAC;AAElE,eAAO,MAAM,sBAAsB,UAAU,CAAC;AAC9C,eAAO,MAAM,kBAAkB,gDAAoE,CAAC;AACpG,eAAO,MAAM,cAAc,wDAA4E,CAAC;AAExG,eAAO,MAAM,iBAAiB,2CAA2C,CAAC;AAC1E,eAAO,MAAM,aAAa,2CAA2C,CAAC;AACtE,eAAO,MAAM,eAAe,uCAAuC,CAAC;AAEpE,gDAAgD;AAChD,eAAO,MAAM,sBAAsB,+CACW,CAAC;AAC/C,eAAO,MAAM,kBAAkB,+CAA+C,CAAC;AAC/E,eAAO,MAAM,qBAAqB,kDACe,CAAC"}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SLACK_OPENID_USERINFO = exports.SLACK_OPENID_TOKEN = exports.SLACK_OPENID_AUTHORIZE = exports.TWITTER_USER_ME = exports.TWITTER_TOKEN = exports.TWITTER_AUTHORIZE = exports.FACEBOOK_TOKEN = exports.FACEBOOK_AUTHORIZE = exports.FACEBOOK_GRAPH_VERSION = exports.GITHUB_EMAILS = exports.GITHUB_USER = exports.GITHUB_TOKEN = exports.GITHUB_AUTHORIZE = exports.GOOGLE_USERINFO = exports.GOOGLE_TOKEN = exports.GOOGLE_AUTH = void 0;
4
+ exports.GOOGLE_AUTH = "https://accounts.google.com/o/oauth2/v2/auth";
5
+ exports.GOOGLE_TOKEN = "https://oauth2.googleapis.com/token";
6
+ exports.GOOGLE_USERINFO = "https://openidconnect.googleapis.com/v1/userinfo";
7
+ exports.GITHUB_AUTHORIZE = "https://github.com/login/oauth/authorize";
8
+ exports.GITHUB_TOKEN = "https://github.com/login/oauth/access_token";
9
+ exports.GITHUB_USER = "https://api.github.com/user";
10
+ exports.GITHUB_EMAILS = "https://api.github.com/user/emails";
11
+ exports.FACEBOOK_GRAPH_VERSION = "v21.0";
12
+ exports.FACEBOOK_AUTHORIZE = `https://www.facebook.com/${exports.FACEBOOK_GRAPH_VERSION}/dialog/oauth`;
13
+ exports.FACEBOOK_TOKEN = `https://graph.facebook.com/${exports.FACEBOOK_GRAPH_VERSION}/oauth/access_token`;
14
+ exports.TWITTER_AUTHORIZE = "https://twitter.com/i/oauth2/authorize";
15
+ exports.TWITTER_TOKEN = "https://api.twitter.com/2/oauth2/token";
16
+ exports.TWITTER_USER_ME = "https://api.twitter.com/2/users/me";
17
+ /** Slack Sign in with Slack — OpenID Connect */
18
+ exports.SLACK_OPENID_AUTHORIZE = "https://slack.com/openid/connect/authorize";
19
+ exports.SLACK_OPENID_TOKEN = "https://slack.com/api/openid.connect.token";
20
+ exports.SLACK_OPENID_USERINFO = "https://slack.com/api/openid.connect.userInfo";
@@ -0,0 +1,13 @@
1
+ export { Socialite } from "./Socialite";
2
+ export { AbstractProvider } from "./AbstractProvider";
3
+ export type { OAuthAuthorizeContext, OAuthProviderConfig } from "./types";
4
+ export { resolveSocialiteConfig } from "./config";
5
+ export { SocialUser } from "./SocialUser";
6
+ export { SocialiteProvider } from "./SocialiteProvider";
7
+ export { GoogleProvider } from "./Drivers/google/GoogleProvider";
8
+ export { GitHubProvider } from "./Drivers/github/GitHubProvider";
9
+ export { FacebookProvider } from "./Drivers/facebook/FacebookProvider";
10
+ export { GitLabProvider } from "./Drivers/gitlab/GitLabProvider";
11
+ export { TwitterProvider } from "./Drivers/twitter/TwitterProvider";
12
+ export { SlackProvider } from "./Drivers/slack/SlackProvider";
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Socialite/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,YAAY,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SlackProvider = exports.TwitterProvider = exports.GitLabProvider = exports.FacebookProvider = exports.GitHubProvider = exports.GoogleProvider = exports.SocialiteProvider = exports.SocialUser = exports.resolveSocialiteConfig = exports.AbstractProvider = exports.Socialite = void 0;
4
+ var Socialite_1 = require("./Socialite");
5
+ Object.defineProperty(exports, "Socialite", { enumerable: true, get: function () { return Socialite_1.Socialite; } });
6
+ var AbstractProvider_1 = require("./AbstractProvider");
7
+ Object.defineProperty(exports, "AbstractProvider", { enumerable: true, get: function () { return AbstractProvider_1.AbstractProvider; } });
8
+ var config_1 = require("./config");
9
+ Object.defineProperty(exports, "resolveSocialiteConfig", { enumerable: true, get: function () { return config_1.resolveSocialiteConfig; } });
10
+ var SocialUser_1 = require("./SocialUser");
11
+ Object.defineProperty(exports, "SocialUser", { enumerable: true, get: function () { return SocialUser_1.SocialUser; } });
12
+ var SocialiteProvider_1 = require("./SocialiteProvider");
13
+ Object.defineProperty(exports, "SocialiteProvider", { enumerable: true, get: function () { return SocialiteProvider_1.SocialiteProvider; } });
14
+ var GoogleProvider_1 = require("./Drivers/google/GoogleProvider");
15
+ Object.defineProperty(exports, "GoogleProvider", { enumerable: true, get: function () { return GoogleProvider_1.GoogleProvider; } });
16
+ var GitHubProvider_1 = require("./Drivers/github/GitHubProvider");
17
+ Object.defineProperty(exports, "GitHubProvider", { enumerable: true, get: function () { return GitHubProvider_1.GitHubProvider; } });
18
+ var FacebookProvider_1 = require("./Drivers/facebook/FacebookProvider");
19
+ Object.defineProperty(exports, "FacebookProvider", { enumerable: true, get: function () { return FacebookProvider_1.FacebookProvider; } });
20
+ var GitLabProvider_1 = require("./Drivers/gitlab/GitLabProvider");
21
+ Object.defineProperty(exports, "GitLabProvider", { enumerable: true, get: function () { return GitLabProvider_1.GitLabProvider; } });
22
+ var TwitterProvider_1 = require("./Drivers/twitter/TwitterProvider");
23
+ Object.defineProperty(exports, "TwitterProvider", { enumerable: true, get: function () { return TwitterProvider_1.TwitterProvider; } });
24
+ var SlackProvider_1 = require("./Drivers/slack/SlackProvider");
25
+ Object.defineProperty(exports, "SlackProvider", { enumerable: true, get: function () { return SlackProvider_1.SlackProvider; } });
@@ -0,0 +1,13 @@
1
+ export interface OAuthProviderConfig {
2
+ clientId: string;
3
+ clientSecret: string;
4
+ redirectUri: string;
5
+ /** Self-hosted GitLab base URL (no trailing slash). Default https://gitlab.com */
6
+ gitlabUrl?: string;
7
+ }
8
+ /** Optional PKCE context passed to {@link AbstractProvider.buildAuthorizeUrl} (Twitter). */
9
+ export type OAuthAuthorizeContext = {
10
+ codeChallenge: string;
11
+ codeChallengeMethod: string;
12
+ };
13
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Socialite/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,kFAAkF;IAClF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,4FAA4F;AAC5F,MAAM,MAAM,qBAAqB,GAAG;IAClC,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Simple benchmark for the templating engine.
3
+ * Run: npx ts-node jcc-express-mvc/lib/Templating-engine/benchmark.ts
4
+ * Or: node build/jcc-express-mvc/lib/Templating-engine/benchmark.js
5
+ */
6
+ export {};
7
+ //# sourceMappingURL=benchmark.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"benchmark.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Templating-engine/benchmark.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /**
3
+ * Simple benchmark for the templating engine.
4
+ * Run: npx ts-node jcc-express-mvc/lib/Templating-engine/benchmark.ts
5
+ * Or: node build/jcc-express-mvc/lib/Templating-engine/benchmark.js
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const index_1 = require("./index");
9
+ const ITERATIONS = 5000;
10
+ const template = `
11
+ <div class="user">
12
+ <h1>{{ user.name }}</h1>
13
+ <p>{{ user.email }}</p>
14
+ @if(user.active)
15
+ <span class="badge">Active</span>
16
+ @endif
17
+ @foreach(items as item)
18
+ <li>{{ item.name }} - {{ item.price }}</li>
19
+ @endforeach
20
+ </div>
21
+ `;
22
+ const data = {
23
+ user: { name: "John Doe", email: "john@example.com", active: true },
24
+ items: [
25
+ { name: "Item 1", price: "$10" },
26
+ { name: "Item 2", price: "$20" },
27
+ { name: "Item 3", price: "$30" },
28
+ ],
29
+ };
30
+ function runBenchmark() {
31
+ // Warmup
32
+ for (let i = 0; i < 100; i++) {
33
+ (0, index_1.compileString)(template, data);
34
+ }
35
+ const start = performance.now();
36
+ for (let i = 0; i < ITERATIONS; i++) {
37
+ (0, index_1.compileString)(template, data);
38
+ }
39
+ const elapsed = performance.now() - start;
40
+ console.log(`Rendered ${ITERATIONS} templates in ${elapsed.toFixed(2)}ms`);
41
+ console.log(`Average: ${(elapsed / ITERATIONS).toFixed(3)}ms per template`);
42
+ console.log(`Throughput: ${(ITERATIONS / (elapsed / 1000)).toFixed(0)} templates/sec`);
43
+ }
44
+ runBenchmark();
@@ -11,11 +11,11 @@ export declare class EngineHelpers extends TemplateRegex {
11
11
  */
12
12
  protected content(content: string, match: any): ContentType;
13
13
  /**
14
- * Escapes special characters in a string to HTML entities.
14
+ * Escapes special characters in a string to HTML entities (Laravel {{ }} behavior).
15
15
  * @param {string} str - The original string.
16
16
  * @returns {string} - The string with special characters replaced by HTML entities.
17
17
  */
18
- private htmlspecialchars;
18
+ protected htmlspecialchars(str: any): string;
19
19
  /**
20
20
  * Replaces placeholders in layout content with section body content.
21
21
  * @param {string} content - The content with section placeholders.
@@ -23,33 +23,62 @@ export declare class EngineHelpers extends TemplateRegex {
23
23
  * @returns {string} - The layout content with replaced section content.
24
24
  */
25
25
  protected layout(content: string, layoutContent: string): string;
26
+ /** Path segment cache to avoid repeated split in hot loops. */
27
+ private _pathCache;
28
+ private _pathCacheSize;
29
+ private static readonly PATH_CACHE_MAX;
30
+ /** Clear path cache (call with clearCache in dev). */
31
+ clearPathCache(): void;
32
+ /**
33
+ * Fast path resolution - avoids repeated split in hot paths.
34
+ */
35
+ private getPathParts;
26
36
  /**
27
37
  * Accesses nested properties of an object using dot notation.
28
- * @param {object} obj - The object to access properties from.
29
- * @param {string} propertyString - Dot-separated string representing the property path.
30
- * @returns {*} - The value of the nested property, or an empty string if not found.
38
+ * Optimized: for-loop, path cache for repeated lookups.
39
+ */
40
+ protected accessNestedProperty(obj: any, propertyString: string): any;
41
+ /** Whitelist of safe JS methods allowed in templates (e.g. join, split, trim). */
42
+ private static readonly ALLOWED_METHODS;
43
+ /** String methods that work on primitives - coerce to string first if needed. */
44
+ private static readonly STRING_METHODS;
45
+ /** Parse method arguments: quoted strings, numbers, or variable names. */
46
+ private parseMethodArgs;
47
+ /** Split by comma, respecting quoted strings. */
48
+ private splitArgs;
49
+ /**
50
+ * Resolve variable expression with optional method calls, top-level function calls, and ternary.
51
+ * Supports: items.join(', '), statusBadge(job.status), url == '/path' ? 'active' : ''
52
+ */
53
+ protected resolveVariableExpression(expr: string, param: Record<string, any>): any;
54
+ /** Resolve ternary branch: quoted string or variable reference. */
55
+ protected resolveTernaryBranch(branch: string, param: Record<string, any>): any;
56
+ /**
57
+ * Checks if a nested property exists (for @isset).
31
58
  */
32
- protected accessNestedProperty(obj: any, propertyString: string): string;
59
+ protected hasNestedProperty(obj: any, propertyString: string): boolean;
33
60
  /**
34
61
  * Reads file content from the specified path.
35
62
  * @param {string} path - The path to the file.
36
63
  * @returns {string} - The content of the file.
37
64
  */
38
65
  protected readFile(path: string): string;
66
+ /** Check if a view file exists (for @includeIf). */
67
+ protected viewExists(viewPath: string): boolean;
39
68
  /**
40
69
  * Removes quotes from a string.
41
70
  * @param {string} str - The original string.
42
71
  * @returns {string} - The string with quotes removed.
43
72
  */
44
73
  protected removeQuotes(str: string): string;
45
- protected evaluateCondition(condition: string, locals: any): string | boolean;
74
+ protected evaluateCondition(condition: string, locals: any): any;
46
75
  protected getAssets(content: string): string;
47
76
  protected getPublicFile(file: string): string;
48
77
  protected addScriptTag(src: string): string;
49
78
  protected getAssetPath(resolvePath: string, beforeMatch: string, afterMatch: string, cssPath?: string): string;
50
79
  protected addCSSLinkTag(link: string): string;
51
80
  protected getResource(resources: Array<string>, select?: number): string;
52
- protected injectReactRefefresh(): string;
81
+ protected injectReactRefresh(): string;
53
82
  protected escapeJsonForHtml(json: string): string;
54
83
  }
55
84
  //# sourceMappingURL=engineHelper.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"engineHelper.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Templating-engine/engineHelper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAK9C,qBAAa,aAAc,SAAQ,aAAa;IAE9C,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC;;IAK3B;;;;;OAKG;IACH,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,WAAW;IAM3D;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAcxB;;;;;OAKG;IACH,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM;IA2BhE;;;;;OAKG;IACH,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,GAAG,MAAM;IAKxE;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAYxC;;;;OAIG;IACH,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAI3C,SAAS,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG;IAgC1D,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM;IAWnC,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM;IAgBpC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM;IAOlC,SAAS,CAAC,YAAY,CACpB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,GACf,MAAM;IA8BT,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM;IAIpC,SAAS,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,GAAE,MAAU;IAOlE,SAAS,CAAC,oBAAoB;IAU9B,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAUlD"}
1
+ {"version":3,"file":"engineHelper.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Templating-engine/engineHelper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAK9C,qBAAa,aAAc,SAAQ,aAAa;IAE9C,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC;;IAK3B;;;;;OAKG;IACH,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,WAAW;IAM3D;;;;OAIG;IACH,SAAS,CAAC,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM;IAc5C;;;;;OAKG;IACH,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM;IA2BhE,+DAA+D;IAC/D,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,cAAc,CAAK;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAAO;IAE7C,sDAAsD;IACtD,cAAc,IAAI,IAAI;IAKtB;;OAEG;IACH,OAAO,CAAC,YAAY;IAapB;;;OAGG;IACH,SAAS,CAAC,oBAAoB,CAAC,GAAG,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,GAAG,GAAG;IAUrE,kFAAkF;IAClF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAIpC;IAEH,iFAAiF;IACjF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAInC;IAEH,0EAA0E;IAC1E,OAAO,CAAC,eAAe;IAiBvB,iDAAiD;IACjD,OAAO,CAAC,SAAS;IA4BjB;;;OAGG;IACH,SAAS,CAAC,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG;IAgDlF,mEAAmE;IACnE,SAAS,CAAC,oBAAoB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG;IAQ/E;;OAEG;IACH,SAAS,CAAC,iBAAiB,CAAC,GAAG,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,GAAG,OAAO;IAYtE;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAYxC,oDAAoD;IACpD,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAM/C;;;;OAIG;IACH,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAI3C,SAAS,CAAC,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG;IA+B1D,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,MAAM;IAWnC,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM;IAYpC,SAAS,CAAC,YAAY,CAAC,GAAG,EAAE,MAAM;IAOlC,SAAS,CAAC,YAAY,CACpB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,GACf,MAAM;IA8BT,SAAS,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM;IAIpC,SAAS,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,GAAE,MAAU;IAOlE,SAAS,CAAC,kBAAkB;IAU5B,SAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;CAUlD"}
@@ -13,6 +13,9 @@ const colors_1 = __importDefault(require("colors"));
13
13
  class EngineHelpers extends expressions_1.TemplateRegex {
14
14
  constructor() {
15
15
  super();
16
+ /** Path segment cache to avoid repeated split in hot loops. */
17
+ this._pathCache = new Map();
18
+ this._pathCacheSize = 0;
16
19
  this.viteHost = this.getPublicFile("hot") || "";
17
20
  }
18
21
  /**
@@ -27,12 +30,15 @@ class EngineHelpers extends expressions_1.TemplateRegex {
27
30
  return { afterMatch, beforMatch };
28
31
  }
29
32
  /**
30
- * Escapes special characters in a string to HTML entities.
33
+ * Escapes special characters in a string to HTML entities (Laravel {{ }} behavior).
31
34
  * @param {string} str - The original string.
32
35
  * @returns {string} - The string with special characters replaced by HTML entities.
33
36
  */
34
37
  htmlspecialchars(str) {
35
- let map = {
38
+ if (str == null || str === undefined)
39
+ return "";
40
+ const s = String(str);
41
+ const map = {
36
42
  "&": "&amp;",
37
43
  "<": "&lt;",
38
44
  ">": "&gt;",
@@ -40,9 +46,7 @@ class EngineHelpers extends expressions_1.TemplateRegex {
40
46
  "'": "&#x27;",
41
47
  "/": "&#x2F;",
42
48
  };
43
- return str.replace(/[&<>"'/]/g, function (m) {
44
- return map[m];
45
- });
49
+ return s.replace(/[&<>"'/]/g, (m) => map[m] ?? m);
46
50
  }
47
51
  /**
48
52
  * Replaces placeholders in layout content with section body content.
@@ -71,15 +75,168 @@ class EngineHelpers extends expressions_1.TemplateRegex {
71
75
  }
72
76
  return layoutContent;
73
77
  }
78
+ /** Clear path cache (call with clearCache in dev). */
79
+ clearPathCache() {
80
+ this._pathCache.clear();
81
+ this._pathCacheSize = 0;
82
+ }
83
+ /**
84
+ * Fast path resolution - avoids repeated split in hot paths.
85
+ */
86
+ getPathParts(propertyPath) {
87
+ if (propertyPath.length === 0)
88
+ return [];
89
+ let parts = this._pathCache.get(propertyPath);
90
+ if (!parts) {
91
+ parts = propertyPath.replace(/\s/g, "").split(".").filter(Boolean);
92
+ if (this._pathCacheSize < EngineHelpers.PATH_CACHE_MAX) {
93
+ this._pathCache.set(propertyPath, parts);
94
+ this._pathCacheSize++;
95
+ }
96
+ }
97
+ return parts;
98
+ }
74
99
  /**
75
100
  * Accesses nested properties of an object using dot notation.
76
- * @param {object} obj - The object to access properties from.
77
- * @param {string} propertyString - Dot-separated string representing the property path.
78
- * @returns {*} - The value of the nested property, or an empty string if not found.
101
+ * Optimized: for-loop, path cache for repeated lookups.
79
102
  */
80
103
  accessNestedProperty(obj, propertyString) {
81
- const properties = propertyString.replace(/\s/g, "")?.split(".") ?? [];
82
- return properties.reduce((acc, prop) => acc?.[prop], obj) ?? "";
104
+ const parts = this.getPathParts(propertyString);
105
+ let val = obj;
106
+ for (let i = 0; i < parts.length; i++) {
107
+ if (val == null)
108
+ return "";
109
+ val = val[parts[i]];
110
+ }
111
+ return val === undefined || val === null ? "" : val;
112
+ }
113
+ /** Parse method arguments: quoted strings, numbers, or variable names. */
114
+ parseMethodArgs(argsStr, param) {
115
+ const args = [];
116
+ const parts = this.splitArgs(argsStr);
117
+ for (const p of parts) {
118
+ const s = p.trim();
119
+ if (s.length === 0)
120
+ continue;
121
+ if ((s.startsWith("'") && s.endsWith("'")) || (s.startsWith('"') && s.endsWith('"'))) {
122
+ args.push(s.slice(1, -1).replace(/\\(.)/g, "$1"));
123
+ }
124
+ else if (/^-?\d+\.?\d*$/.test(s)) {
125
+ args.push(parseFloat(s));
126
+ }
127
+ else {
128
+ args.push(this.accessNestedProperty(param, s));
129
+ }
130
+ }
131
+ return args;
132
+ }
133
+ /** Split by comma, respecting quoted strings. */
134
+ splitArgs(argsStr) {
135
+ const parts = [];
136
+ let current = "";
137
+ let i = 0;
138
+ let inQuote = "";
139
+ while (i < argsStr.length) {
140
+ const c = argsStr[i];
141
+ if (inQuote) {
142
+ current += c;
143
+ if (c === inQuote && argsStr[i - 1] !== "\\")
144
+ inQuote = "";
145
+ i++;
146
+ }
147
+ else if (c === '"' || c === "'") {
148
+ inQuote = c;
149
+ current += c;
150
+ i++;
151
+ }
152
+ else if (c === ",") {
153
+ parts.push(current);
154
+ current = "";
155
+ i++;
156
+ }
157
+ else {
158
+ current += c;
159
+ i++;
160
+ }
161
+ }
162
+ parts.push(current);
163
+ return parts;
164
+ }
165
+ /**
166
+ * Resolve variable expression with optional method calls, top-level function calls, and ternary.
167
+ * Supports: items.join(', '), statusBadge(job.status), url == '/path' ? 'active' : ''
168
+ */
169
+ resolveVariableExpression(expr, param) {
170
+ const e = expr.trim();
171
+ const ternaryRe = /^(.+?)\s*\?\s*(.+?)\s*:\s*(.+)$/;
172
+ const ternaryMatch = e.match(ternaryRe);
173
+ if (ternaryMatch) {
174
+ const cond = ternaryMatch[1].trim();
175
+ const trueVal = ternaryMatch[2].trim();
176
+ const falseVal = ternaryMatch[3].trim();
177
+ const branch = this.evaluateCondition(cond, param) ? trueVal : falseVal;
178
+ const resolved = this.resolveTernaryBranch(branch, param);
179
+ return resolved === undefined || resolved === null ? "" : resolved;
180
+ }
181
+ const topLevelCallRe = /^(\w+)\s*\(\s*([^)]*)\s*\)\s*$/;
182
+ const topMatch = e.match(topLevelCallRe);
183
+ if (topMatch) {
184
+ const fnName = topMatch[1];
185
+ const fn = this.accessNestedProperty(param, fnName);
186
+ if (typeof fn === "function") {
187
+ const args = this.parseMethodArgs(topMatch[2], param);
188
+ const val = fn(...args);
189
+ return val === undefined || val === null ? "" : val;
190
+ }
191
+ }
192
+ const methodCallRe = /\.\s*(\w+)\s*\(\s*([^)]*)\s*\)/g;
193
+ const methodMatches = [...e.matchAll(methodCallRe)];
194
+ if (methodMatches.length === 0) {
195
+ return this.accessNestedProperty(param, e);
196
+ }
197
+ const firstMethodIndex = methodMatches[0].index;
198
+ const base = e.slice(0, firstMethodIndex).trim();
199
+ let val = this.accessNestedProperty(param, base);
200
+ for (const m of methodMatches) {
201
+ const methodName = m[1];
202
+ if (val == null && methodName !== "toString")
203
+ return "";
204
+ if (!EngineHelpers.ALLOWED_METHODS.has(methodName))
205
+ return "";
206
+ const argsStr = m[2];
207
+ const args = this.parseMethodArgs(argsStr, param);
208
+ // Coerce to string for string methods when value isn't a string (e.g. job.status from DB)
209
+ if (EngineHelpers.STRING_METHODS.has(methodName) && typeof val !== "string") {
210
+ val = val == null ? "" : String(val);
211
+ }
212
+ const fn = val[methodName];
213
+ if (typeof fn !== "function")
214
+ return "";
215
+ val = fn.apply(val, args);
216
+ }
217
+ return val === undefined || val === null ? "" : val;
218
+ }
219
+ /** Resolve ternary branch: quoted string or variable reference. */
220
+ resolveTernaryBranch(branch, param) {
221
+ const t = branch.trim();
222
+ if ((t.startsWith("'") && t.endsWith("'")) || (t.startsWith('"') && t.endsWith('"'))) {
223
+ return t.slice(1, -1).replace(/\\(.)/g, "$1");
224
+ }
225
+ return this.accessNestedProperty(param, t);
226
+ }
227
+ /**
228
+ * Checks if a nested property exists (for @isset).
229
+ */
230
+ hasNestedProperty(obj, propertyString) {
231
+ const parts = this.getPathParts(propertyString);
232
+ let current = obj;
233
+ for (let i = 0; i < parts.length; i++) {
234
+ if (current == null || typeof current !== "object" || !(parts[i] in current)) {
235
+ return false;
236
+ }
237
+ current = current[parts[i]];
238
+ }
239
+ return true;
83
240
  }
84
241
  /**
85
242
  * Reads file content from the specified path.
@@ -98,6 +255,12 @@ class EngineHelpers extends expressions_1.TemplateRegex {
98
255
  }
99
256
  return "";
100
257
  }
258
+ /** Check if a view file exists (for @includeIf). */
259
+ viewExists(viewPath) {
260
+ const resolvePath = viewPath.replace(/\./g, "/").replace(/\"/g, "");
261
+ const fullPath = `${app_root_path_1.default.path}/resources/${resolvePath}.blade.html`;
262
+ return fs_1.default.existsSync(fullPath);
263
+ }
101
264
  /**
102
265
  * Removes quotes from a string.
103
266
  * @param {string} str - The original string.
@@ -107,12 +270,13 @@ class EngineHelpers extends expressions_1.TemplateRegex {
107
270
  return str.replace(/(\'|\")/g, "");
108
271
  }
109
272
  evaluateCondition(condition, locals) {
110
- const operatorRegex = /\s*(===|!==|==|!=|>|<|>=|<=)\s*/g;
111
- if (!operatorRegex.test(condition)) {
112
- return this.accessNestedProperty(locals, condition);
273
+ const operatorRegex = /\s*(===|!==|==|!=|>|<|>=|<=)\s*/;
274
+ const parts = this.removeQuotes(condition).split(operatorRegex).filter(Boolean);
275
+ if (parts.length < 3) {
276
+ return this.accessNestedProperty(locals, condition.trim());
113
277
  }
114
- const [variable, operator, value] = this.removeQuotes(condition).split(operatorRegex);
115
- const actualValue = this.accessNestedProperty(locals, variable);
278
+ const [variable, operator, value] = parts;
279
+ const actualValue = this.accessNestedProperty(locals, variable?.trim() ?? "");
116
280
  switch (operator) {
117
281
  case "==":
118
282
  return actualValue == value;
@@ -121,7 +285,6 @@ class EngineHelpers extends expressions_1.TemplateRegex {
121
285
  case "===":
122
286
  return actualValue === value;
123
287
  case "!==":
124
- case "!=":
125
288
  return actualValue !== value;
126
289
  case ">":
127
290
  return actualValue > value;
@@ -146,16 +309,17 @@ class EngineHelpers extends expressions_1.TemplateRegex {
146
309
  return assetType === "js" ? `${path}.js` : `${path}.css`;
147
310
  }
148
311
  getPublicFile(file) {
149
- const bundler = `${app_root_path_1.default.path}/public/${file}`;
150
- if (fs_1.default.existsSync(bundler) && Config_1.config.get("APP_ENV") != "production") {
151
- return fs_1.default.readFileSync(bundler).toString();
312
+ const publicPath = `${app_root_path_1.default.path}/public/${file}`;
313
+ const buildPath = `${app_root_path_1.default.path}/build/public/${file}`;
314
+ if (Config_1.config.get("APP_ENV") != "production") {
315
+ if (fs_1.default.existsSync(publicPath))
316
+ return fs_1.default.readFileSync(publicPath).toString();
152
317
  }
153
318
  else {
154
- const buildBundler = `${app_root_path_1.default.path}/build/public/${file}`;
155
- if (Config_1.config.get("APP_ENV") == "production" &&
156
- fs_1.default.existsSync(buildBundler)) {
157
- return fs_1.default.readFileSync(buildBundler).toString();
158
- }
319
+ if (fs_1.default.existsSync(buildPath))
320
+ return fs_1.default.readFileSync(buildPath).toString();
321
+ if (fs_1.default.existsSync(publicPath))
322
+ return fs_1.default.readFileSync(publicPath).toString();
159
323
  }
160
324
  return "";
161
325
  }
@@ -173,7 +337,7 @@ class EngineHelpers extends expressions_1.TemplateRegex {
173
337
  const manifestContent = this.getPublicFile("build/manifest.json");
174
338
  if (!manifestContent) {
175
339
  console.log(colors_1.default.yellow("Run npm run vite in your terminal"));
176
- return "";
340
+ return `${beforeMatch}${afterMatch}`;
177
341
  }
178
342
  const manifest = JSON.parse(manifestContent);
179
343
  const assetData = manifest[resolvePath];
@@ -195,7 +359,7 @@ class EngineHelpers extends expressions_1.TemplateRegex {
195
359
  const resource = resources[resources.length > 1 ? select : 0].trim();
196
360
  return this.removeQuotes(resource.startsWith("/") ? resource.slice(1) : resource);
197
361
  }
198
- injectReactRefefresh() {
362
+ injectReactRefresh() {
199
363
  return ` <script type="module">
200
364
  import RefreshRuntime from '${this.viteHost}/@react-refresh';
201
365
  RefreshRuntime.injectIntoGlobalHook(window);
@@ -216,3 +380,16 @@ class EngineHelpers extends expressions_1.TemplateRegex {
216
380
  }
217
381
  }
218
382
  exports.EngineHelpers = EngineHelpers;
383
+ EngineHelpers.PATH_CACHE_MAX = 128;
384
+ /** Whitelist of safe JS methods allowed in templates (e.g. join, split, trim). */
385
+ EngineHelpers.ALLOWED_METHODS = new Set([
386
+ "join", "split", "slice", "trim", "trimStart", "trimEnd",
387
+ "toUpperCase", "toLowerCase", "toString", "replace", "repeat",
388
+ "includes", "indexOf", "startsWith", "endsWith", "padStart", "padEnd",
389
+ ]);
390
+ /** String methods that work on primitives - coerce to string first if needed. */
391
+ EngineHelpers.STRING_METHODS = new Set([
392
+ "toUpperCase", "toLowerCase", "trim", "trimStart", "trimEnd",
393
+ "toString", "replace", "repeat", "includes", "indexOf", "startsWith", "endsWith",
394
+ "padStart", "padEnd", "slice", "split",
395
+ ]);
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Template engine errors with line/column context.
3
+ */
4
+ export declare class TemplateError extends Error {
5
+ readonly line?: number | undefined;
6
+ readonly column?: number | undefined;
7
+ readonly templatePath?: string | undefined;
8
+ constructor(message: string, line?: number | undefined, column?: number | undefined, templatePath?: string | undefined);
9
+ toString(): string;
10
+ }
11
+ export declare function getLineColumn(source: string, index: number): {
12
+ line: number;
13
+ column: number;
14
+ };
15
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Templating-engine/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,aAAc,SAAQ,KAAK;aAGpB,IAAI,CAAC,EAAE,MAAM;aACb,MAAM,CAAC,EAAE,MAAM;aACf,YAAY,CAAC,EAAE,MAAM;gBAHrC,OAAO,EAAE,MAAM,EACC,IAAI,CAAC,EAAE,MAAM,YAAA,EACb,MAAM,CAAC,EAAE,MAAM,YAAA,EACf,YAAY,CAAC,EAAE,MAAM,YAAA;IAOvC,QAAQ,IAAI,MAAM;CAQnB;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAI7F"}