@saolabs/client 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (383) hide show
  1. package/README.md +221 -0
  2. package/dist/index.d.ts +46 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +38 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/plugins.d.ts +38 -0
  7. package/dist/plugins.d.ts.map +1 -0
  8. package/dist/plugins.js +61 -0
  9. package/dist/plugins.js.map +1 -0
  10. package/dist/src/core/app/Application.d.ts +159 -0
  11. package/dist/src/core/app/Application.d.ts.map +1 -0
  12. package/dist/src/core/app/Application.js +338 -0
  13. package/dist/src/core/app/Application.js.map +1 -0
  14. package/dist/src/core/bootstrap/app.d.ts +4 -0
  15. package/dist/src/core/bootstrap/app.d.ts.map +1 -0
  16. package/dist/src/core/bootstrap/app.js +49 -0
  17. package/dist/src/core/bootstrap/app.js.map +1 -0
  18. package/dist/src/core/bootstrap/providers/ApiServiceProvider.d.ts +9 -0
  19. package/dist/src/core/bootstrap/providers/ApiServiceProvider.d.ts.map +1 -0
  20. package/dist/src/core/bootstrap/providers/ApiServiceProvider.js +18 -0
  21. package/dist/src/core/bootstrap/providers/ApiServiceProvider.js.map +1 -0
  22. package/dist/src/core/bootstrap/providers/CoreServiceProvider.d.ts +6 -0
  23. package/dist/src/core/bootstrap/providers/CoreServiceProvider.d.ts.map +1 -0
  24. package/dist/src/core/bootstrap/providers/CoreServiceProvider.js +21 -0
  25. package/dist/src/core/bootstrap/providers/CoreServiceProvider.js.map +1 -0
  26. package/dist/src/core/bootstrap/providers/HelperServiceProvider.d.ts +7 -0
  27. package/dist/src/core/bootstrap/providers/HelperServiceProvider.d.ts.map +1 -0
  28. package/dist/src/core/bootstrap/providers/HelperServiceProvider.js +14 -0
  29. package/dist/src/core/bootstrap/providers/HelperServiceProvider.js.map +1 -0
  30. package/dist/src/core/bootstrap/providers/RouteServiceProvider.d.ts +9 -0
  31. package/dist/src/core/bootstrap/providers/RouteServiceProvider.d.ts.map +1 -0
  32. package/dist/src/core/bootstrap/providers/RouteServiceProvider.js +18 -0
  33. package/dist/src/core/bootstrap/providers/RouteServiceProvider.js.map +1 -0
  34. package/dist/src/core/bootstrap/providers/ServiceProvider.d.ts +38 -0
  35. package/dist/src/core/bootstrap/providers/ServiceProvider.d.ts.map +1 -0
  36. package/dist/src/core/bootstrap/providers/ServiceProvider.js +41 -0
  37. package/dist/src/core/bootstrap/providers/ServiceProvider.js.map +1 -0
  38. package/dist/src/core/bootstrap/providers/ViewServiceProvider.d.ts +9 -0
  39. package/dist/src/core/bootstrap/providers/ViewServiceProvider.d.ts.map +1 -0
  40. package/dist/src/core/bootstrap/providers/ViewServiceProvider.js +18 -0
  41. package/dist/src/core/bootstrap/providers/ViewServiceProvider.js.map +1 -0
  42. package/dist/src/core/bootstrap/providers/default-providers.d.ts +14 -0
  43. package/dist/src/core/bootstrap/providers/default-providers.d.ts.map +1 -0
  44. package/dist/src/core/bootstrap/providers/default-providers.js +79 -0
  45. package/dist/src/core/bootstrap/providers/default-providers.js.map +1 -0
  46. package/dist/src/core/bootstrap/providers/index.d.ts +10 -0
  47. package/dist/src/core/bootstrap/providers/index.d.ts.map +1 -0
  48. package/dist/src/core/bootstrap/providers/index.js +9 -0
  49. package/dist/src/core/bootstrap/providers/index.js.map +1 -0
  50. package/dist/src/core/bootstrap/providers/provider-order.d.ts +19 -0
  51. package/dist/src/core/bootstrap/providers/provider-order.d.ts.map +1 -0
  52. package/dist/src/core/bootstrap/providers/provider-order.js +51 -0
  53. package/dist/src/core/bootstrap/providers/provider-order.js.map +1 -0
  54. package/dist/src/core/cache/ViewCache.d.ts +46 -0
  55. package/dist/src/core/cache/ViewCache.d.ts.map +1 -0
  56. package/dist/src/core/cache/ViewCache.js +85 -0
  57. package/dist/src/core/cache/ViewCache.js.map +1 -0
  58. package/dist/src/core/cache/index.d.ts +2 -0
  59. package/dist/src/core/cache/index.d.ts.map +1 -0
  60. package/dist/src/core/cache/index.js +2 -0
  61. package/dist/src/core/cache/index.js.map +1 -0
  62. package/dist/src/core/contracts/ApiInterface.d.ts +11 -0
  63. package/dist/src/core/contracts/ApiInterface.d.ts.map +1 -0
  64. package/dist/src/core/contracts/ApiInterface.js +2 -0
  65. package/dist/src/core/contracts/ApiInterface.js.map +1 -0
  66. package/dist/src/core/contracts/ApplicationInterface.d.ts +66 -0
  67. package/dist/src/core/contracts/ApplicationInterface.d.ts.map +1 -0
  68. package/dist/src/core/contracts/ApplicationInterface.js +3 -0
  69. package/dist/src/core/contracts/ApplicationInterface.js.map +1 -0
  70. package/dist/src/core/contracts/BlockInterface.d.ts +67 -0
  71. package/dist/src/core/contracts/BlockInterface.d.ts.map +1 -0
  72. package/dist/src/core/contracts/BlockInterface.js +2 -0
  73. package/dist/src/core/contracts/BlockInterface.js.map +1 -0
  74. package/dist/src/core/contracts/ComponentInterface.d.ts +24 -0
  75. package/dist/src/core/contracts/ComponentInterface.d.ts.map +1 -0
  76. package/dist/src/core/contracts/ComponentInterface.js +2 -0
  77. package/dist/src/core/contracts/ComponentInterface.js.map +1 -0
  78. package/dist/src/core/contracts/ElementInterface.d.ts +117 -0
  79. package/dist/src/core/contracts/ElementInterface.d.ts.map +1 -0
  80. package/dist/src/core/contracts/ElementInterface.js +2 -0
  81. package/dist/src/core/contracts/ElementInterface.js.map +1 -0
  82. package/dist/src/core/contracts/EventServiceInterface.d.ts +37 -0
  83. package/dist/src/core/contracts/EventServiceInterface.d.ts.map +1 -0
  84. package/dist/src/core/contracts/EventServiceInterface.js +3 -0
  85. package/dist/src/core/contracts/EventServiceInterface.js.map +1 -0
  86. package/dist/src/core/contracts/HelperInterface.d.ts +231 -0
  87. package/dist/src/core/contracts/HelperInterface.d.ts.map +1 -0
  88. package/dist/src/core/contracts/HelperInterface.js +3 -0
  89. package/dist/src/core/contracts/HelperInterface.js.map +1 -0
  90. package/dist/src/core/contracts/HttpServiceInterface.d.ts +38 -0
  91. package/dist/src/core/contracts/HttpServiceInterface.d.ts.map +1 -0
  92. package/dist/src/core/contracts/HttpServiceInterface.js +3 -0
  93. package/dist/src/core/contracts/HttpServiceInterface.js.map +1 -0
  94. package/dist/src/core/contracts/LoggerServiceInterface.d.ts +37 -0
  95. package/dist/src/core/contracts/LoggerServiceInterface.d.ts.map +1 -0
  96. package/dist/src/core/contracts/LoggerServiceInterface.js +3 -0
  97. package/dist/src/core/contracts/LoggerServiceInterface.js.map +1 -0
  98. package/dist/src/core/contracts/LoopContextInterface.d.ts +14 -0
  99. package/dist/src/core/contracts/LoopContextInterface.d.ts.map +1 -0
  100. package/dist/src/core/contracts/LoopContextInterface.js +3 -0
  101. package/dist/src/core/contracts/LoopContextInterface.js.map +1 -0
  102. package/dist/src/core/contracts/MarkerInterface.d.ts +55 -0
  103. package/dist/src/core/contracts/MarkerInterface.d.ts.map +1 -0
  104. package/dist/src/core/contracts/MarkerInterface.js +2 -0
  105. package/dist/src/core/contracts/MarkerInterface.js.map +1 -0
  106. package/dist/src/core/contracts/ReactiveInterface.d.ts +38 -0
  107. package/dist/src/core/contracts/ReactiveInterface.d.ts.map +1 -0
  108. package/dist/src/core/contracts/ReactiveInterface.js +2 -0
  109. package/dist/src/core/contracts/ReactiveInterface.js.map +1 -0
  110. package/dist/src/core/contracts/RouterInterface.d.ts +58 -0
  111. package/dist/src/core/contracts/RouterInterface.d.ts.map +1 -0
  112. package/dist/src/core/contracts/RouterInterface.js +2 -0
  113. package/dist/src/core/contracts/RouterInterface.js.map +1 -0
  114. package/dist/src/core/contracts/ServiceProviderInterface.d.ts +12 -0
  115. package/dist/src/core/contracts/ServiceProviderInterface.d.ts.map +1 -0
  116. package/dist/src/core/contracts/ServiceProviderInterface.js +2 -0
  117. package/dist/src/core/contracts/ServiceProviderInterface.js.map +1 -0
  118. package/dist/src/core/contracts/StorageServiceInterface.d.ts +43 -0
  119. package/dist/src/core/contracts/StorageServiceInterface.d.ts.map +1 -0
  120. package/dist/src/core/contracts/StorageServiceInterface.js +3 -0
  121. package/dist/src/core/contracts/StorageServiceInterface.js.map +1 -0
  122. package/dist/src/core/contracts/StoreServiceInterface.d.ts +45 -0
  123. package/dist/src/core/contracts/StoreServiceInterface.d.ts.map +1 -0
  124. package/dist/src/core/contracts/StoreServiceInterface.js +3 -0
  125. package/dist/src/core/contracts/StoreServiceInterface.js.map +1 -0
  126. package/dist/src/core/contracts/ViewCacheInterface.d.ts +13 -0
  127. package/dist/src/core/contracts/ViewCacheInterface.d.ts.map +1 -0
  128. package/dist/src/core/contracts/ViewCacheInterface.js +3 -0
  129. package/dist/src/core/contracts/ViewCacheInterface.js.map +1 -0
  130. package/dist/src/core/contracts/ViewControllerInterface.d.ts +115 -0
  131. package/dist/src/core/contracts/ViewControllerInterface.d.ts.map +1 -0
  132. package/dist/src/core/contracts/ViewControllerInterface.js +2 -0
  133. package/dist/src/core/contracts/ViewControllerInterface.js.map +1 -0
  134. package/dist/src/core/contracts/ViewInterface.d.ts +24 -0
  135. package/dist/src/core/contracts/ViewInterface.d.ts.map +1 -0
  136. package/dist/src/core/contracts/ViewInterface.js +2 -0
  137. package/dist/src/core/contracts/ViewInterface.js.map +1 -0
  138. package/dist/src/core/contracts/ViewManagerInterface.d.ts +44 -0
  139. package/dist/src/core/contracts/ViewManagerInterface.d.ts.map +1 -0
  140. package/dist/src/core/contracts/ViewManagerInterface.js +2 -0
  141. package/dist/src/core/contracts/ViewManagerInterface.js.map +1 -0
  142. package/dist/src/core/contracts/ViewStateInterface.d.ts +40 -0
  143. package/dist/src/core/contracts/ViewStateInterface.d.ts.map +1 -0
  144. package/dist/src/core/contracts/ViewStateInterface.js +3 -0
  145. package/dist/src/core/contracts/ViewStateInterface.js.map +1 -0
  146. package/dist/src/core/contracts/common.d.ts +28 -0
  147. package/dist/src/core/contracts/common.d.ts.map +1 -0
  148. package/dist/src/core/contracts/common.js +29 -0
  149. package/dist/src/core/contracts/common.js.map +1 -0
  150. package/dist/src/core/contracts/utils.d.ts +20 -0
  151. package/dist/src/core/contracts/utils.d.ts.map +1 -0
  152. package/dist/src/core/contracts/utils.js +4 -0
  153. package/dist/src/core/contracts/utils.js.map +1 -0
  154. package/dist/src/core/contracts/views.d.ts +23 -0
  155. package/dist/src/core/contracts/views.d.ts.map +1 -0
  156. package/dist/src/core/contracts/views.js +2 -0
  157. package/dist/src/core/contracts/views.js.map +1 -0
  158. package/dist/src/core/elements/Block.d.ts +58 -0
  159. package/dist/src/core/elements/Block.d.ts.map +1 -0
  160. package/dist/src/core/elements/Block.js +77 -0
  161. package/dist/src/core/elements/Block.js.map +1 -0
  162. package/dist/src/core/elements/BlockOutlet.d.ts +34 -0
  163. package/dist/src/core/elements/BlockOutlet.d.ts.map +1 -0
  164. package/dist/src/core/elements/BlockOutlet.js +59 -0
  165. package/dist/src/core/elements/BlockOutlet.js.map +1 -0
  166. package/dist/src/core/elements/Component.d.ts +62 -0
  167. package/dist/src/core/elements/Component.d.ts.map +1 -0
  168. package/dist/src/core/elements/Component.js +72 -0
  169. package/dist/src/core/elements/Component.js.map +1 -0
  170. package/dist/src/core/elements/ElementManager.d.ts +23 -0
  171. package/dist/src/core/elements/ElementManager.d.ts.map +1 -0
  172. package/dist/src/core/elements/ElementManager.js +33 -0
  173. package/dist/src/core/elements/ElementManager.js.map +1 -0
  174. package/dist/src/core/elements/Fragment.d.ts +51 -0
  175. package/dist/src/core/elements/Fragment.d.ts.map +1 -0
  176. package/dist/src/core/elements/Fragment.js +133 -0
  177. package/dist/src/core/elements/Fragment.js.map +1 -0
  178. package/dist/src/core/elements/Html.d.ts +52 -0
  179. package/dist/src/core/elements/Html.d.ts.map +1 -0
  180. package/dist/src/core/elements/Html.js +299 -0
  181. package/dist/src/core/elements/Html.js.map +1 -0
  182. package/dist/src/core/elements/Output.d.ts +69 -0
  183. package/dist/src/core/elements/Output.d.ts.map +1 -0
  184. package/dist/src/core/elements/Output.js +121 -0
  185. package/dist/src/core/elements/Output.js.map +1 -0
  186. package/dist/src/core/elements/Reactive.d.ts +77 -0
  187. package/dist/src/core/elements/Reactive.d.ts.map +1 -0
  188. package/dist/src/core/elements/Reactive.js +199 -0
  189. package/dist/src/core/elements/Reactive.js.map +1 -0
  190. package/dist/src/core/elements/TextElement.d.ts +46 -0
  191. package/dist/src/core/elements/TextElement.d.ts.map +1 -0
  192. package/dist/src/core/elements/TextElement.js +94 -0
  193. package/dist/src/core/elements/TextElement.js.map +1 -0
  194. package/dist/src/core/elements/Wrapper.d.ts +50 -0
  195. package/dist/src/core/elements/Wrapper.d.ts.map +1 -0
  196. package/dist/src/core/elements/Wrapper.js +96 -0
  197. package/dist/src/core/elements/Wrapper.js.map +1 -0
  198. package/dist/src/core/elements/Yield.d.ts +34 -0
  199. package/dist/src/core/elements/Yield.d.ts.map +1 -0
  200. package/dist/src/core/elements/Yield.js +56 -0
  201. package/dist/src/core/elements/Yield.js.map +1 -0
  202. package/dist/src/core/elements/helpers.d.ts +8 -0
  203. package/dist/src/core/elements/helpers.d.ts.map +1 -0
  204. package/dist/src/core/elements/helpers.js +40 -0
  205. package/dist/src/core/elements/helpers.js.map +1 -0
  206. package/dist/src/core/elements/index.d.ts +12 -0
  207. package/dist/src/core/elements/index.d.ts.map +1 -0
  208. package/dist/src/core/elements/index.js +12 -0
  209. package/dist/src/core/elements/index.js.map +1 -0
  210. package/dist/src/core/hellpers/ApiClient.d.ts +58 -0
  211. package/dist/src/core/hellpers/ApiClient.d.ts.map +1 -0
  212. package/dist/src/core/hellpers/ApiClient.js +122 -0
  213. package/dist/src/core/hellpers/ApiClient.js.map +1 -0
  214. package/dist/src/core/hellpers/app.d.ts +3 -0
  215. package/dist/src/core/hellpers/app.d.ts.map +1 -0
  216. package/dist/src/core/hellpers/app.js +53 -0
  217. package/dist/src/core/hellpers/app.js.map +1 -0
  218. package/dist/src/core/hellpers/utils.d.ts +26 -0
  219. package/dist/src/core/hellpers/utils.d.ts.map +1 -0
  220. package/dist/src/core/hellpers/utils.js +96 -0
  221. package/dist/src/core/hellpers/utils.js.map +1 -0
  222. package/dist/src/core/routers/Router.d.ts +212 -0
  223. package/dist/src/core/routers/Router.d.ts.map +1 -0
  224. package/dist/src/core/routers/Router.js +623 -0
  225. package/dist/src/core/routers/Router.js.map +1 -0
  226. package/dist/src/core/routers/index.d.ts +3 -0
  227. package/dist/src/core/routers/index.d.ts.map +1 -0
  228. package/dist/src/core/routers/index.js +2 -0
  229. package/dist/src/core/routers/index.js.map +1 -0
  230. package/dist/src/core/services/BlockManager.d.ts +63 -0
  231. package/dist/src/core/services/BlockManager.d.ts.map +1 -0
  232. package/dist/src/core/services/BlockManager.js +191 -0
  233. package/dist/src/core/services/BlockManager.js.map +1 -0
  234. package/dist/src/core/services/DomService.d.ts +9 -0
  235. package/dist/src/core/services/DomService.d.ts.map +1 -0
  236. package/dist/src/core/services/DomService.js +18 -0
  237. package/dist/src/core/services/DomService.js.map +1 -0
  238. package/dist/src/core/services/EventService.d.ts +58 -0
  239. package/dist/src/core/services/EventService.d.ts.map +1 -0
  240. package/dist/src/core/services/EventService.js +212 -0
  241. package/dist/src/core/services/EventService.js.map +1 -0
  242. package/dist/src/core/services/HelperService.d.ts +443 -0
  243. package/dist/src/core/services/HelperService.d.ts.map +1 -0
  244. package/dist/src/core/services/HelperService.js +1650 -0
  245. package/dist/src/core/services/HelperService.js.map +1 -0
  246. package/dist/src/core/services/HttpService.d.ts +63 -0
  247. package/dist/src/core/services/HttpService.d.ts.map +1 -0
  248. package/dist/src/core/services/HttpService.js +182 -0
  249. package/dist/src/core/services/HttpService.js.map +1 -0
  250. package/dist/src/core/services/LoggerService.d.ts +56 -0
  251. package/dist/src/core/services/LoggerService.d.ts.map +1 -0
  252. package/dist/src/core/services/LoggerService.js +94 -0
  253. package/dist/src/core/services/LoggerService.js.map +1 -0
  254. package/dist/src/core/services/MarkerRegistry.d.ts +94 -0
  255. package/dist/src/core/services/MarkerRegistry.d.ts.map +1 -0
  256. package/dist/src/core/services/MarkerRegistry.js +199 -0
  257. package/dist/src/core/services/MarkerRegistry.js.map +1 -0
  258. package/dist/src/core/services/MarkerService.d.ts +299 -0
  259. package/dist/src/core/services/MarkerService.d.ts.map +1 -0
  260. package/dist/src/core/services/MarkerService.js +723 -0
  261. package/dist/src/core/services/MarkerService.js.map +1 -0
  262. package/dist/src/core/services/StorageService.d.ts +69 -0
  263. package/dist/src/core/services/StorageService.d.ts.map +1 -0
  264. package/dist/src/core/services/StorageService.js +243 -0
  265. package/dist/src/core/services/StorageService.js.map +1 -0
  266. package/dist/src/core/services/StoreService.d.ts +80 -0
  267. package/dist/src/core/services/StoreService.d.ts.map +1 -0
  268. package/dist/src/core/services/StoreService.js +301 -0
  269. package/dist/src/core/services/StoreService.js.map +1 -0
  270. package/dist/src/core/services/index.d.ts +9 -0
  271. package/dist/src/core/services/index.d.ts.map +1 -0
  272. package/dist/src/core/services/index.js +9 -0
  273. package/dist/src/core/services/index.js.map +1 -0
  274. package/dist/src/core/types/utils.d.ts +29 -0
  275. package/dist/src/core/types/utils.d.ts.map +1 -0
  276. package/dist/src/core/types/utils.js +22 -0
  277. package/dist/src/core/types/utils.js.map +1 -0
  278. package/dist/src/core/view/LoopContext.d.ts +38 -0
  279. package/dist/src/core/view/LoopContext.d.ts.map +1 -0
  280. package/dist/src/core/view/LoopContext.js +100 -0
  281. package/dist/src/core/view/LoopContext.js.map +1 -0
  282. package/dist/src/core/view/Section.d.ts +41 -0
  283. package/dist/src/core/view/Section.d.ts.map +1 -0
  284. package/dist/src/core/view/Section.js +67 -0
  285. package/dist/src/core/view/Section.js.map +1 -0
  286. package/dist/src/core/view/View.d.ts +63 -0
  287. package/dist/src/core/view/View.d.ts.map +1 -0
  288. package/dist/src/core/view/View.js +85 -0
  289. package/dist/src/core/view/View.js.map +1 -0
  290. package/dist/src/core/view/ViewController.d.ts +277 -0
  291. package/dist/src/core/view/ViewController.d.ts.map +1 -0
  292. package/dist/src/core/view/ViewController.js +862 -0
  293. package/dist/src/core/view/ViewController.js.map +1 -0
  294. package/dist/src/core/view/ViewManager.d.ts +141 -0
  295. package/dist/src/core/view/ViewManager.d.ts.map +1 -0
  296. package/dist/src/core/view/ViewManager.js +565 -0
  297. package/dist/src/core/view/ViewManager.js.map +1 -0
  298. package/dist/src/core/view/ViewState.d.ts +117 -0
  299. package/dist/src/core/view/ViewState.d.ts.map +1 -0
  300. package/dist/src/core/view/ViewState.js +410 -0
  301. package/dist/src/core/view/ViewState.js.map +1 -0
  302. package/dist/src/core/view/index.d.ts +6 -0
  303. package/dist/src/core/view/index.d.ts.map +1 -0
  304. package/dist/src/core/view/index.js +6 -0
  305. package/dist/src/core/view/index.js.map +1 -0
  306. package/index.ts +62 -0
  307. package/package.json +70 -0
  308. package/plugins.ts +77 -0
  309. package/src/core/app/Application.ts +410 -0
  310. package/src/core/bootstrap/app.ts +58 -0
  311. package/src/core/bootstrap/providers/ApiServiceProvider.ts +18 -0
  312. package/src/core/bootstrap/providers/CoreServiceProvider.ts +19 -0
  313. package/src/core/bootstrap/providers/HelperServiceProvider.ts +12 -0
  314. package/src/core/bootstrap/providers/RouteServiceProvider.ts +17 -0
  315. package/src/core/bootstrap/providers/ServiceProvider.ts +51 -0
  316. package/src/core/bootstrap/providers/ViewServiceProvider.ts +17 -0
  317. package/src/core/bootstrap/providers/default-providers.ts +94 -0
  318. package/src/core/bootstrap/providers/index.ts +9 -0
  319. package/src/core/bootstrap/providers/provider-order.test.ts +67 -0
  320. package/src/core/bootstrap/providers/provider-order.ts +66 -0
  321. package/src/core/cache/ViewCache.ts +102 -0
  322. package/src/core/cache/index.ts +1 -0
  323. package/src/core/contracts/ApiInterface.ts +11 -0
  324. package/src/core/contracts/ApplicationInterface.ts +79 -0
  325. package/src/core/contracts/BlockInterface.ts +76 -0
  326. package/src/core/contracts/ComponentInterface.ts +26 -0
  327. package/src/core/contracts/ElementInterface.ts +140 -0
  328. package/src/core/contracts/EventServiceInterface.ts +47 -0
  329. package/src/core/contracts/HelperInterface.ts +256 -0
  330. package/src/core/contracts/HttpServiceInterface.ts +51 -0
  331. package/src/core/contracts/LoggerServiceInterface.ts +48 -0
  332. package/src/core/contracts/LoopContextInterface.ts +15 -0
  333. package/src/core/contracts/MarkerInterface.ts +77 -0
  334. package/src/core/contracts/ReactiveInterface.ts +45 -0
  335. package/src/core/contracts/RouterInterface.ts +65 -0
  336. package/src/core/contracts/ServiceProviderInterface.ts +12 -0
  337. package/src/core/contracts/StorageServiceInterface.ts +48 -0
  338. package/src/core/contracts/StoreServiceInterface.ts +50 -0
  339. package/src/core/contracts/ViewCacheInterface.ts +14 -0
  340. package/src/core/contracts/ViewControllerInterface.ts +135 -0
  341. package/src/core/contracts/ViewInterface.ts +31 -0
  342. package/src/core/contracts/ViewManagerInterface.ts +45 -0
  343. package/src/core/contracts/ViewStateInterface.ts +47 -0
  344. package/src/core/contracts/common.ts +27 -0
  345. package/src/core/contracts/utils.ts +23 -0
  346. package/src/core/contracts/views.ts +23 -0
  347. package/src/core/elements/Block.ts +113 -0
  348. package/src/core/elements/BlockOutlet.ts +83 -0
  349. package/src/core/elements/Component.ts +114 -0
  350. package/src/core/elements/ElementManager.ts +48 -0
  351. package/src/core/elements/Fragment.ts +168 -0
  352. package/src/core/elements/Html.ts +364 -0
  353. package/src/core/elements/Output.ts +167 -0
  354. package/src/core/elements/Reactive.ts +253 -0
  355. package/src/core/elements/TextElement.ts +110 -0
  356. package/src/core/elements/Wrapper.ts +131 -0
  357. package/src/core/elements/Yield.ts +70 -0
  358. package/src/core/elements/helpers.ts +56 -0
  359. package/src/core/elements/index.ts +26 -0
  360. package/src/core/hellpers/ApiClient.ts +145 -0
  361. package/src/core/hellpers/app.ts +57 -0
  362. package/src/core/hellpers/utils.ts +109 -0
  363. package/src/core/routers/Router.ts +765 -0
  364. package/src/core/routers/index.ts +2 -0
  365. package/src/core/services/BlockManager.ts +210 -0
  366. package/src/core/services/DomService.ts +26 -0
  367. package/src/core/services/EventService.ts +266 -0
  368. package/src/core/services/HelperService.ts +1653 -0
  369. package/src/core/services/HttpService.ts +235 -0
  370. package/src/core/services/LoggerService.ts +139 -0
  371. package/src/core/services/MarkerRegistry.ts +239 -0
  372. package/src/core/services/MarkerService.ts +923 -0
  373. package/src/core/services/StorageService.ts +268 -0
  374. package/src/core/services/StoreService.ts +338 -0
  375. package/src/core/services/index.ts +8 -0
  376. package/src/core/types/utils.ts +30 -0
  377. package/src/core/view/LoopContext.ts +109 -0
  378. package/src/core/view/Section.ts +86 -0
  379. package/src/core/view/View.ts +109 -0
  380. package/src/core/view/ViewController.ts +1002 -0
  381. package/src/core/view/ViewManager.ts +700 -0
  382. package/src/core/view/ViewState.ts +453 -0
  383. package/src/core/view/index.ts +5 -0
package/package.json ADDED
@@ -0,0 +1,70 @@
1
+ {
2
+ "name": "@saolabs/client",
3
+ "version": "1.0.0",
4
+ "description": "Saola Client - Modern TypeScript Framework for Laravel. Reactive SPAs with TypeScript-first approach.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.js"
12
+ },
13
+ "./plugins": {
14
+ "types": "./dist/plugins.d.ts",
15
+ "import": "./dist/plugins.js",
16
+ "require": "./dist/plugins.js"
17
+ },
18
+ "./core": {
19
+ "types": "./dist/core/index.d.ts",
20
+ "import": "./dist/core/index.js",
21
+ "require": "./dist/core/index.js"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "src",
27
+ "index.ts",
28
+ "plugins.ts"
29
+ ],
30
+ "scripts": {
31
+ "build": "tsc",
32
+ "dev": "tsc --watch",
33
+ "clean": "rm -rf dist",
34
+ "prepublishOnly": "npm run clean && npm run build",
35
+ "publish-dry-run": "npm publish --dry-run",
36
+ "test": "echo \"No tests specified yet\""
37
+ },
38
+ "keywords": [
39
+ "typescript",
40
+ "framework",
41
+ "laravel",
42
+ "spa",
43
+ "reactive",
44
+ "frontend"
45
+ ],
46
+ "author": "Saola Labs",
47
+ "license": "MIT",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "git+https://github.com/saolabs/saola-client.git"
51
+ },
52
+ "bugs": {
53
+ "url": "https://github.com/saolabs/saola-client/issues"
54
+ },
55
+ "homepage": "https://github.com/saolabs/saola-client#readme",
56
+ "devDependencies": {
57
+ "typescript": "^5.0.0",
58
+ "@types/node": "^20.0.0"
59
+ },
60
+ "engines": {
61
+ "node": ">=16.0.0"
62
+ },
63
+ "directories": {
64
+ "doc": "docs"
65
+ },
66
+ "dependencies": {
67
+ "undici-types": "^6.21.0"
68
+ },
69
+ "type": "commonjs"
70
+ }
package/plugins.ts ADDED
@@ -0,0 +1,77 @@
1
+ /**
2
+ * OneView Plugins
3
+ * Extension system for OneView framework
4
+ */
5
+
6
+ export interface PluginOptions {
7
+ [key: string]: unknown;
8
+ }
9
+
10
+ export interface Plugin {
11
+ name: string;
12
+ install(options?: PluginOptions): void;
13
+ }
14
+
15
+ class PluginManager {
16
+ private plugins: Map<string, Plugin> = new Map();
17
+ private installed: Set<string> = new Set();
18
+
19
+ /**
20
+ * Register a plugin
21
+ */
22
+ register(plugin: Plugin): this {
23
+ if (this.plugins.has(plugin.name)) {
24
+ console.warn(`Plugin "${plugin.name}" is already registered`);
25
+ return this;
26
+ }
27
+ this.plugins.set(plugin.name, plugin);
28
+ return this;
29
+ }
30
+
31
+ /**
32
+ * Install a registered plugin
33
+ */
34
+ install(name: string, options?: PluginOptions): this {
35
+ const plugin = this.plugins.get(name);
36
+ if (!plugin) {
37
+ throw new Error(`Plugin "${name}" is not registered`);
38
+ }
39
+
40
+ if (this.installed.has(name)) {
41
+ console.warn(`Plugin "${name}" is already installed`);
42
+ return this;
43
+ }
44
+
45
+ plugin.install(options);
46
+ this.installed.add(name);
47
+ return this;
48
+ }
49
+
50
+ /**
51
+ * Check if a plugin is installed
52
+ */
53
+ isInstalled(name: string): boolean {
54
+ return this.installed.has(name);
55
+ }
56
+
57
+ /**
58
+ * Get all registered plugins
59
+ */
60
+ getPlugins(): Plugin[] {
61
+ return Array.from(this.plugins.values());
62
+ }
63
+ }
64
+
65
+ export const pluginManager = new PluginManager();
66
+
67
+ /**
68
+ * Create a plugin
69
+ */
70
+ export function createPlugin(name: string, install: (options?: PluginOptions) => void): Plugin {
71
+ return {
72
+ name,
73
+ install
74
+ };
75
+ }
76
+
77
+ export default pluginManager;
@@ -0,0 +1,410 @@
1
+ /**
2
+ * Application — DI Container + App Lifecycle.
3
+ *
4
+ * Tương tự Laravel Service Container:
5
+ * - bind / singleton / instance → đăng ký service
6
+ * - make / resolve → lấy service
7
+ * - alias → tên tắt
8
+ * - register / boot → service providers
9
+ *
10
+ * Khác với core Application (hardcode services), bản này hoàn toàn DI-driven:
11
+ * mọi service (Router, ViewManager, Store...) đều được đăng ký qua providers.
12
+ *
13
+ * @example
14
+ * const app = new Application();
15
+ *
16
+ * // Đăng ký trực tiếp
17
+ * app.singleton('markerRegistry', MarkerRegistry);
18
+ * app.instance('config', { debug: true });
19
+ *
20
+ * // Đăng ký qua provider
21
+ * app.register({
22
+ * register(app) { app.singleton('router', () => new Router(app)); },
23
+ * boot(app) { app.make('router').start(); }
24
+ * });
25
+ *
26
+ * app.boot();
27
+ * const router = app.make('router');
28
+ */
29
+
30
+ import type { ApplicationInterface, ServiceKey, ServiceFactory, ServiceBinding } from '../contracts/ApplicationInterface';
31
+ import type { ServiceProviderInterface } from '../contracts/ServiceProviderInterface';
32
+ import type { ViewManagerInterface, RouterInterface } from '../contracts/utils';
33
+ import type { HelperInterface } from '../contracts/HelperInterface';
34
+ import type { EventServiceInterface } from '../contracts/EventServiceInterface';
35
+ import type { HttpServiceInterface } from '../contracts/HttpServiceInterface';
36
+ import type { StoreServiceInterface } from '../contracts/StoreServiceInterface';
37
+ import type { StorageServiceInterface } from '../contracts/StorageServiceInterface';
38
+ import type { LoggerServiceInterface } from '../contracts/LoggerServiceInterface';
39
+ import { APIClientInterface } from '../contracts/ApiInterface';
40
+ import { OneObjectType, OOTEnum } from '../types/utils';
41
+
42
+ // ─── Application ────────────────────────────────────────────────
43
+
44
+ export class Application implements ApplicationInterface {
45
+ readonly oneType: OneObjectType = OOTEnum.APPLICATION;
46
+ // Service properties — set during bootstrap via App.set()
47
+ declare isInitialized: boolean;
48
+ declare isStarted: boolean;
49
+ declare View: ViewManagerInterface;
50
+ declare Router: RouterInterface;
51
+ declare Helper: HelperInterface;
52
+ declare Events: EventServiceInterface;
53
+ declare Http: HttpServiceInterface;
54
+ declare API: APIClientInterface;
55
+ declare Store: StoreServiceInterface;
56
+ declare Storage: StorageServiceInterface;
57
+ declare Logger: LoggerServiceInterface;
58
+
59
+ /** Factory bindings — mỗi lần make() gọi factory tạo instance mới */
60
+ private bindings = new Map<ServiceKey, ServiceFactory<any>>();
61
+
62
+ /** Singleton instances — tạo một lần, reuse */
63
+ private singletons = new Map<ServiceKey, any>();
64
+
65
+ /** Aliases — tên tắt trỏ về key gốc */
66
+ private aliases = new Map<string | symbol, ServiceKey>();
67
+
68
+ /** Service providers đã đăng ký */
69
+ private providers: ServiceProviderInterface[] = [];
70
+
71
+ /** Đã boot chưa */
72
+ private booted = false;
73
+
74
+ private ownProperties: string[] = [
75
+ 'bindings',
76
+ 'singletons',
77
+ 'aliases',
78
+ 'providers',
79
+ 'booted',
80
+ 'ownProperties',
81
+ 'transient',
82
+ 'bind',
83
+ 'singleton',
84
+ 'instance',
85
+ 'alias',
86
+ 'make',
87
+ 'resolve',
88
+ 'has',
89
+ 'bound',
90
+ 'register',
91
+ 'boot',
92
+ 'isBooted',
93
+ 'flush',
94
+ 'destroy',
95
+ 'getBindings',
96
+ 'getSingletons',
97
+ '__store',
98
+ ]; // Để track dynamic properties nếu cần
99
+
100
+ __store: Map<string, { isOverridable: boolean, value: any }> = new Map(); // Store cho dynamic properties nếu cần
101
+
102
+ [key: string]: any; // Cho phép dynamic properties nếu cần
103
+
104
+ constructor() { }
105
+
106
+ // ─── Transient (factory — instance mới mỗi lần) ───────────
107
+
108
+ /**
109
+ * Đăng ký transient service.
110
+ * Mỗi lần make() trả về instance mới (không cache).
111
+ *
112
+ * @example
113
+ * app.transient('request', (app) => new Request(app.make('config')));
114
+ * app.transient(Database, Database); // class shorthand
115
+ */
116
+ transient<T>(key: ServiceKey<T>, value: ServiceBinding<T>): this {
117
+ this.bindings.set(key, (app) => {
118
+ if (typeof value === 'function' && value.prototype) {
119
+ return new (value as new (...args: any[]) => T)();
120
+ }
121
+ return (value as ServiceFactory<T>)(app);
122
+ });
123
+ return this;
124
+ }
125
+
126
+ bind<T>(key: ServiceKey<T>, value: ServiceBinding<T>): this {
127
+ return this.transient(key, value);
128
+ }
129
+
130
+ // ─── Singleton (instance duy nhất) ──────────────────────────
131
+
132
+ /**
133
+ * Đăng ký singleton — tạo một lần, reuse mãi mãi.
134
+ *
135
+ * @example
136
+ * app.singleton('store', StoreService); // class
137
+ * app.singleton('config', (app) => loadConfig()); // factory
138
+ * app.singleton(StoreService); // class, tự tạo
139
+ * app.singleton('store', existingInstance); // instance sẵn
140
+ */
141
+ singleton<T>(key: ServiceKey<T>, value?: ServiceBinding<T> | T): this {
142
+ // singleton(MyClass) — không có value, key là class
143
+ if (value === undefined) {
144
+ if (typeof key === 'function') {
145
+ this.singletons.set(key, new (key as new (...args: any[]) => T)());
146
+ return this;
147
+ }
148
+ throw new Error(`[Application] Singleton requires a value for key: ${String(key)}`);
149
+ }
150
+
151
+ // value là instance sẵn (object, không phải function)
152
+ if (value !== null && typeof value === 'object') {
153
+ this.singletons.set(key, value);
154
+ return this;
155
+ }
156
+
157
+ // value là class hoặc factory — lazy init
158
+ this.bindings.set(key, (app) => {
159
+ if (!this.singletons.has(key)) {
160
+ const isClass = typeof value === 'function' && (value as any).prototype;
161
+ const instance = isClass
162
+ ? new (value as new (...args: any[]) => T)()
163
+ : (value as ServiceFactory<T>)(app);
164
+ this.singletons.set(key, instance);
165
+ }
166
+ return this.singletons.get(key);
167
+ });
168
+ return this;
169
+ }
170
+
171
+ // ─── Instance (đăng ký instance sẵn) ────────────────────────
172
+
173
+ /**
174
+ * Đăng ký instance đã tạo sẵn.
175
+ * Shortcut cho singleton khi đã có instance.
176
+ *
177
+ * @example
178
+ * app.instance('config', { debug: true, api_url: '/api' });
179
+ */
180
+ instance<T>(key: ServiceKey<T>, value: T): this {
181
+ this.singletons.set(key, value);
182
+ return this;
183
+ }
184
+
185
+ // ─── Alias ──────────────────────────────────────────────────
186
+
187
+ /**
188
+ * Tạo tên tắt cho service.
189
+ *
190
+ * @example
191
+ * app.singleton('email.service', EmailService);
192
+ * app.alias('mailer', 'email.service');
193
+ * app.make('mailer') === app.make('email.service') // true
194
+ */
195
+ alias(alias: string | symbol, key: ServiceKey): this {
196
+ this.aliases.set(alias, key);
197
+ return this;
198
+ }
199
+
200
+ // ─── Resolve ────────────────────────────────────────────────
201
+
202
+ /**
203
+ * Lấy service instance. Shortcut cho resolve().
204
+ *
205
+ * @example
206
+ * const router = app.make<Router>('router');
207
+ */
208
+ make<T>(key: ServiceKey<T>, defaultValue?: T): T {
209
+ return this.resolve(key, defaultValue);
210
+ }
211
+
212
+ /**
213
+ * Resolve service instance.
214
+ *
215
+ * Thứ tự tìm:
216
+ * 1. Alias → resolve key gốc
217
+ * 2. Singleton đã tạo → reuse
218
+ * 3. Binding (factory) → gọi factory
219
+ * 4. Key là class → auto-instantiate + cache
220
+ * 5. defaultValue → trả về
221
+ * 6. Throw error
222
+ */
223
+ resolve<T>(key: ServiceKey<T>, defaultValue?: T): T {
224
+ // 1. Resolve alias
225
+ let resolved: ServiceKey<T> = key;
226
+ if ((typeof key === 'string' || typeof key === 'symbol') && this.aliases.has(key)) {
227
+ resolved = this.aliases.get(key)! as ServiceKey<T>;
228
+ }
229
+
230
+ // 2. Singleton đã có
231
+ if (this.singletons.has(resolved)) {
232
+ return this.singletons.get(resolved);
233
+ }
234
+
235
+ // 3. Binding factory
236
+ const factory = this.bindings.get(resolved);
237
+ if (factory) {
238
+ return factory(this);
239
+ }
240
+
241
+ // 4. Auto-instantiate class
242
+ if (typeof resolved === 'function') {
243
+ if (resolved.prototype) {
244
+ const inst = new (resolved as new (...args: any[]) => T)();
245
+ this.singletons.set(resolved, inst);
246
+ return inst;
247
+ }
248
+ return (resolved as Function)(this);
249
+ }
250
+
251
+ // 5. Default value
252
+ if (defaultValue !== undefined) {
253
+ return defaultValue;
254
+ }
255
+
256
+ // 6. Not found
257
+ throw new Error(`[Application] Cannot resolve: ${String(key)}`);
258
+ }
259
+
260
+ // ─── Query ──────────────────────────────────────────────────
261
+
262
+ /** Kiểm tra service đã đăng ký chưa */
263
+ has(key: ServiceKey): boolean {
264
+ const aliased = (typeof key === 'string' || typeof key === 'symbol') && this.aliases.has(key);
265
+ return this.bindings.has(key) || this.singletons.has(key) || aliased
266
+ || (typeof key === 'string' && this.__store.has(key));
267
+ }
268
+
269
+ /** Alias cho has() */
270
+ bound(key: ServiceKey): boolean {
271
+ return this.has(key);
272
+ }
273
+
274
+ // ─── Service Providers ──────────────────────────────────────
275
+
276
+ /**
277
+ * Đăng ký service provider.
278
+ * register() được gọi ngay, boot() gọi khi app.boot().
279
+ *
280
+ * @example
281
+ * app.register({
282
+ * register(app) { app.singleton('db', Database); },
283
+ * boot(app) { app.make('db').connect(); }
284
+ * });
285
+ */
286
+ register(provider: ServiceProviderInterface): this {
287
+ this.providers.push(provider);
288
+ if (typeof (provider as any).initApplication === 'function') {
289
+ (provider as any).initApplication();
290
+ }
291
+ provider.register();
292
+ return this;
293
+ }
294
+
295
+ /**
296
+ * Boot tất cả providers.
297
+ * Gọi boot() của mỗi provider theo thứ tự đăng ký.
298
+ * Chỉ chạy một lần.
299
+ */
300
+ boot(): void {
301
+ if (this.booted) return;
302
+
303
+ for (const provider of this.providers) {
304
+ if (typeof provider.boot === 'function') {
305
+ provider.boot();
306
+ }
307
+ }
308
+
309
+ this.booted = true;
310
+ }
311
+
312
+ /** Đã boot chưa */
313
+ get isBooted(): boolean {
314
+ return this.booted;
315
+ }
316
+
317
+ // ─── Cleanup ────────────────────────────────────────────────
318
+
319
+ /** Xóa toàn bộ bindings, singletons, aliases, __store. Reset container. */
320
+ flush(): void {
321
+ this.bindings.clear();
322
+ this.singletons.clear();
323
+ this.aliases.clear();
324
+ this.__store.clear();
325
+ this.providers = [];
326
+ this.booted = false;
327
+ }
328
+
329
+ /** Destroy app — flush + cleanup */
330
+ destroy(): void {
331
+ this.flush();
332
+ }
333
+
334
+ // ─── Introspection (debug) ──────────────────────────────────
335
+
336
+ getBindings(): Map<ServiceKey, ServiceFactory<any>> {
337
+ return this.bindings;
338
+ }
339
+
340
+ getSingletons(): Map<ServiceKey, any> {
341
+ return this.singletons;
342
+ }
343
+
344
+
345
+ set<T = any>(name: string, value: T, isOne: boolean = false): void {
346
+ if (this.ownProperties.includes(name)) {
347
+ return; // Không cho ghi đè lên thuộc tính có sẵn
348
+ }
349
+ if (this.__store.has(name) && this.__store.get(name)?.isOverridable === false) {
350
+ return; // Không cho ghi đè lên thuộc tính không thể override
351
+ }
352
+ this.__store.set(name, { value, isOverridable: !isOne });
353
+ this.singletons.set(name, value); // Sync → DI container
354
+ Object.defineProperty(this, name, {
355
+ get: () => this.__store.get(name)?.value,
356
+ set: (newValue) => {
357
+ if (this.__store.has(name) && this.__store.get(name)?.isOverridable === false) {
358
+ return; // Không cho ghi đè nếu isOverridable là false
359
+ }
360
+ this.__store.set(name, { value: newValue, isOverridable: !isOne });
361
+ this.singletons.set(name, newValue); // Sync → DI container
362
+ },
363
+ configurable: isOne ? false : true,
364
+ enumerable: false,
365
+ });
366
+ }
367
+
368
+ get<T = any>(name: string): T {
369
+ if (this.ownProperties.includes(name)) {
370
+ return (this as any)[name]; // Trả về thuộc tính có sẵn
371
+ }
372
+ // Check __store first (registered via set())
373
+ if (this.__store.has(name)) {
374
+ return this.__store.get(name)?.value;
375
+ }
376
+ // Fall back to DI container (registered via singleton/instance/bind)
377
+ if (this.singletons.has(name) || this.bindings.has(name) || this.aliases.has(name)) {
378
+ return this.resolve(name);
379
+ }
380
+ return undefined as T;
381
+ }
382
+
383
+ setMethod(name: string, method: Function, isOne: boolean = false): void {
384
+ if (this.ownProperties.includes(name)) {
385
+ return; // Không cho ghi đè lên thuộc tính có sẵn
386
+ }
387
+ if (this.__store.has(name) && this.__store.get(name)?.isOverridable === false) {
388
+ return; // Không cho ghi đè lên thuộc tính không thể override
389
+ }
390
+ this.__store.set(name, { value: method, isOverridable: !isOne });
391
+ (this as any)[name] = (...args: any[]) => {
392
+ const fn = this.get(name);
393
+ if (typeof fn === 'function') {
394
+ if (typeof fn.bind === 'function') {
395
+ return fn.bind(this)(...args);
396
+ }
397
+ return fn.apply(this, args);
398
+ }
399
+ throw new Error(`[Application] Method ${name} is not a function`);
400
+ };
401
+ if (isOne) {
402
+ Object.defineProperty(this, name, {
403
+ configurable: false,
404
+ writable: false,
405
+ });
406
+ }
407
+ }
408
+
409
+ // ─── Singleton App Instance ─────────────────────────────────────
410
+ }
@@ -0,0 +1,58 @@
1
+ import { ApplicationInterface } from "../contracts/ApplicationInterface";
2
+ import { app } from "../hellpers/app";
3
+ import { Router } from "../routers";
4
+ import { buildDefaultProviders, resolveProviderOrder } from "./providers";
5
+
6
+ const App: ApplicationInterface = app<ApplicationInterface>();
7
+
8
+ // ⚠️ Flags PHẢI dùng isOne=false để có thể cập nhật sau init/start
9
+ App.set<boolean>('isInitialized', false);
10
+ App.set<boolean>('isStarted', false);
11
+
12
+ /**
13
+ * Khởi tạo app — đăng ký + boot tất cả providers theo dependency order.
14
+ *
15
+ * @example
16
+ * App.init({
17
+ * view: { container: '#app', registry: {...} },
18
+ * router: { mode: 'history', routes: [...] },
19
+ * api: { endpoint: '/api' },
20
+ * providers: [{ name: 'analytics', dependsOn: ['core'], register(app) {...} }]
21
+ * });
22
+ */
23
+ App.setMethod('init', function (config: Record<string, any> = {}) {
24
+ if (App.isInitialized) {
25
+ console.warn('[Bootstrap] App already initialized.');
26
+ return;
27
+ }
28
+
29
+ const providers = resolveProviderOrder(buildDefaultProviders(config));
30
+ for (const provider of providers) {
31
+ App.register(provider);
32
+ }
33
+
34
+ App.boot();
35
+ App.isInitialized = true;
36
+ }, true);
37
+
38
+ /**
39
+ * Start app — init nếu chưa, rồi start Router.
40
+ *
41
+ * @example
42
+ * App.start(); // init với config mặc định
43
+ * App.start({ view: { container: '#app' } }); // init với config tùy chỉnh
44
+ */
45
+ App.setMethod('start', function (config?: Record<string, any>) {
46
+ if (App.isStarted) {
47
+ console.warn('[Bootstrap] App already started.');
48
+ return;
49
+ }
50
+ if (!App.isInitialized) {
51
+ App.init(config || {});
52
+ }
53
+
54
+ App.get<Router>('Router').start();
55
+ App.isStarted = true;
56
+ }, true);
57
+
58
+ export default App;
@@ -0,0 +1,18 @@
1
+ import { APIClientInterface } from "../../contracts/ApiInterface";
2
+ import { ApiClient } from "../../hellpers/ApiClient";
3
+ import { PROVIDER_NAMES } from "./provider-order";
4
+ import { ServiceProvider } from "./ServiceProvider";
5
+
6
+ export class ApiServiceProvider extends ServiceProvider {
7
+ readonly name = PROVIDER_NAMES.API;
8
+ readonly dependsOn = [PROVIDER_NAMES.CORE];
9
+ static config: Record<string, any> = {};
10
+
11
+ register(): void {
12
+ this.app.set<APIClientInterface>("API", new ApiClient(), true);
13
+ }
14
+
15
+ boot(): void {
16
+ this.app.get<APIClientInterface>("API").init(ApiServiceProvider.config);
17
+ }
18
+ }
@@ -0,0 +1,19 @@
1
+ import { app } from "../../hellpers/app";
2
+ import { EventService } from "../../services/EventService";
3
+ import { HttpService } from "../../services/HttpService";
4
+ import { MarkerService } from "../../services/MarkerService";
5
+ import { StoreService } from "../../services/StoreService";
6
+ import { PROVIDER_NAMES } from "./provider-order";
7
+ import { ServiceProvider } from "./ServiceProvider";
8
+
9
+ export class CoreServiceProvider extends ServiceProvider {
10
+ readonly name = PROVIDER_NAMES.CORE;
11
+
12
+ register(): void {
13
+ this.app.set<MarkerService>("Marker", app<MarkerService>(MarkerService), true);
14
+ this.app.set<StoreService>("Store", StoreService.instance(), true);
15
+ this.app.set<StoreService>("Storage", StoreService.instance(), true);
16
+ this.app.set<EventService>("Event", EventService.instance(), true);
17
+ this.app.set<HttpService>("Http", HttpService.instance(), true);
18
+ }
19
+ }
@@ -0,0 +1,12 @@
1
+ import { HelperService } from "../../services/HelperService";
2
+ import { PROVIDER_NAMES } from "./provider-order";
3
+ import { ServiceProvider } from "./ServiceProvider";
4
+
5
+ export class HelperServiceProvider extends ServiceProvider {
6
+ readonly name = PROVIDER_NAMES.HELPER;
7
+ readonly dependsOn = [PROVIDER_NAMES.CORE, PROVIDER_NAMES.ROUTER, PROVIDER_NAMES.VIEW];
8
+
9
+ register(): void {
10
+ this.app.set<HelperService>("Helper", new HelperService(this.app), true);
11
+ }
12
+ }
@@ -0,0 +1,17 @@
1
+ import { Router } from "../../routers";
2
+ import { PROVIDER_NAMES } from "./provider-order";
3
+ import { ServiceProvider } from "./ServiceProvider";
4
+
5
+ export class RouteServiceProvider extends ServiceProvider {
6
+ readonly name = PROVIDER_NAMES.ROUTER;
7
+ readonly dependsOn = [PROVIDER_NAMES.VIEW];
8
+ static config: Record<string, any> = {};
9
+
10
+ register(): void {
11
+ this.app.set<Router>("Router", new Router(this.app), true);
12
+ }
13
+
14
+ boot(): void {
15
+ this.app.get<Router>("Router").init(RouteServiceProvider.config);
16
+ }
17
+ }