jopijs 0.0.1

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 (455) hide show
  1. package/README.md +134 -0
  2. package/bin/jopib.js +4 -0
  3. package/bin/jopin.js +4 -0
  4. package/dist/@bundler/_logs.d.ts +2 -0
  5. package/dist/@bundler/_logs.js +4 -0
  6. package/dist/@bundler/_logs.js.map +1 -0
  7. package/dist/@bundler/core.d.ts +1 -0
  8. package/dist/@bundler/core.js +34 -0
  9. package/dist/@bundler/core.js.map +1 -0
  10. package/dist/@bundler/esbuild.d.ts +6 -0
  11. package/dist/@bundler/esbuild.js +111 -0
  12. package/dist/@bundler/esbuild.js.map +1 -0
  13. package/dist/@bundler/index.d.ts +2 -0
  14. package/dist/@bundler/index.js +3 -0
  15. package/dist/@bundler/index.js.map +1 -0
  16. package/dist/@bundler/plugins.d.ts +13 -0
  17. package/dist/@bundler/plugins.js +145 -0
  18. package/dist/@bundler/plugins.js.map +1 -0
  19. package/dist/@bundler/tailwind.d.ts +3 -0
  20. package/dist/@bundler/tailwind.js +119 -0
  21. package/dist/@bundler/tailwind.js.map +1 -0
  22. package/dist/@core/PageComponent.d.ts +6 -0
  23. package/dist/@core/PageComponent.js +10 -0
  24. package/dist/@core/PageComponent.js.map +1 -0
  25. package/dist/@core/_logs.d.ts +7 -0
  26. package/dist/@core/_logs.js +9 -0
  27. package/dist/@core/_logs.js.map +1 -0
  28. package/dist/@core/automaticStartStop.d.ts +25 -0
  29. package/dist/@core/automaticStartStop.js +106 -0
  30. package/dist/@core/automaticStartStop.js.map +1 -0
  31. package/dist/@core/browserCacheControl.d.ts +21 -0
  32. package/dist/@core/browserCacheControl.js +17 -0
  33. package/dist/@core/browserCacheControl.js.map +1 -0
  34. package/dist/@core/bundler/bundler.d.ts +22 -0
  35. package/dist/@core/bundler/bundler.js +90 -0
  36. package/dist/@core/bundler/bundler.js.map +1 -0
  37. package/dist/@core/bundler/common.d.ts +2 -0
  38. package/dist/@core/bundler/common.js +17 -0
  39. package/dist/@core/bundler/common.js.map +1 -0
  40. package/dist/@core/bundler/config.d.ts +20 -0
  41. package/dist/@core/bundler/config.js +11 -0
  42. package/dist/@core/bundler/config.js.map +1 -0
  43. package/dist/@core/bundler/extraContent.d.ts +6 -0
  44. package/dist/@core/bundler/extraContent.js +27 -0
  45. package/dist/@core/bundler/extraContent.js.map +1 -0
  46. package/dist/@core/bundler/pagesGenerator.d.ts +1 -0
  47. package/dist/@core/bundler/pagesGenerator.js +173 -0
  48. package/dist/@core/bundler/pagesGenerator.js.map +1 -0
  49. package/dist/@core/bundler/server.d.ts +8 -0
  50. package/dist/@core/bundler/server.js +35 -0
  51. package/dist/@core/bundler/server.js.map +1 -0
  52. package/dist/@core/caches/InMemoryCache.d.ts +35 -0
  53. package/dist/@core/caches/InMemoryCache.js +353 -0
  54. package/dist/@core/caches/InMemoryCache.js.map +1 -0
  55. package/dist/@core/caches/SimpleFileCache.d.ts +18 -0
  56. package/dist/@core/caches/SimpleFileCache.js +171 -0
  57. package/dist/@core/caches/SimpleFileCache.js.map +1 -0
  58. package/dist/@core/caches/cache.d.ts +36 -0
  59. package/dist/@core/caches/cache.js +33 -0
  60. package/dist/@core/caches/cache.js.map +1 -0
  61. package/dist/@core/caches/webSiteMirrorCache.d.ts +16 -0
  62. package/dist/@core/caches/webSiteMirrorCache.js +81 -0
  63. package/dist/@core/caches/webSiteMirrorCache.js.map +1 -0
  64. package/dist/@core/gzip.d.ts +4 -0
  65. package/dist/@core/gzip.js +31 -0
  66. package/dist/@core/gzip.js.map +1 -0
  67. package/dist/@core/index.d.ts +18 -0
  68. package/dist/@core/index.js +19 -0
  69. package/dist/@core/index.js.map +1 -0
  70. package/dist/@core/internalTools.d.ts +14 -0
  71. package/dist/@core/internalTools.js +79 -0
  72. package/dist/@core/internalTools.js.map +1 -0
  73. package/dist/@core/jQuery.d.ts +5 -0
  74. package/dist/@core/jQuery.js +18 -0
  75. package/dist/@core/jQuery.js.map +1 -0
  76. package/dist/@core/jopiEasy.d.ts +287 -0
  77. package/dist/@core/jopiEasy.js +983 -0
  78. package/dist/@core/jopiEasy.js.map +1 -0
  79. package/dist/@core/jopiRequest.d.ts +269 -0
  80. package/dist/@core/jopiRequest.js +1060 -0
  81. package/dist/@core/jopiRequest.js.map +1 -0
  82. package/dist/@core/jopiServer.d.ts +77 -0
  83. package/dist/@core/jopiServer.js +100 -0
  84. package/dist/@core/jopiServer.js.map +1 -0
  85. package/dist/@core/jopiWebSite.d.ts +319 -0
  86. package/dist/@core/jopiWebSite.js +653 -0
  87. package/dist/@core/jopiWebSite.js.map +1 -0
  88. package/dist/@core/letsEncrypt.d.ts +25 -0
  89. package/dist/@core/letsEncrypt.js +189 -0
  90. package/dist/@core/letsEncrypt.js.map +1 -0
  91. package/dist/@core/linker.d.ts +4 -0
  92. package/dist/@core/linker.js +37 -0
  93. package/dist/@core/linker.js.map +1 -0
  94. package/dist/@core/loadBalancing.d.ts +18 -0
  95. package/dist/@core/loadBalancing.js +126 -0
  96. package/dist/@core/loadBalancing.js.map +1 -0
  97. package/dist/@core/middlewares/CorsMiddleware.d.ts +5 -0
  98. package/dist/@core/middlewares/CorsMiddleware.js +15 -0
  99. package/dist/@core/middlewares/CorsMiddleware.js.map +1 -0
  100. package/dist/@core/middlewares/DdosProtection.d.ts +42 -0
  101. package/dist/@core/middlewares/DdosProtection.js +62 -0
  102. package/dist/@core/middlewares/DdosProtection.js.map +1 -0
  103. package/dist/@core/middlewares/index.d.ts +10 -0
  104. package/dist/@core/middlewares/index.js +14 -0
  105. package/dist/@core/middlewares/index.js.map +1 -0
  106. package/dist/@core/publicTools.d.ts +8 -0
  107. package/dist/@core/publicTools.js +11 -0
  108. package/dist/@core/publicTools.js.map +1 -0
  109. package/dist/@core/routeConfig.d.ts +48 -0
  110. package/dist/@core/routeConfig.js +102 -0
  111. package/dist/@core/routeConfig.js.map +1 -0
  112. package/dist/@core/searchParamFilter.d.ts +70 -0
  113. package/dist/@core/searchParamFilter.js +212 -0
  114. package/dist/@core/searchParamFilter.js.map +1 -0
  115. package/dist/@core/serverFetch.d.ts +122 -0
  116. package/dist/@core/serverFetch.js +312 -0
  117. package/dist/@core/serverFetch.js.map +1 -0
  118. package/dist/@core/serverImpl/server_bunjs.d.ts +29 -0
  119. package/dist/@core/serverImpl/server_bunjs.js +180 -0
  120. package/dist/@core/serverImpl/server_bunjs.js.map +1 -0
  121. package/dist/@core/serverImpl/server_nodejs.d.ts +22 -0
  122. package/dist/@core/serverImpl/server_nodejs.js +235 -0
  123. package/dist/@core/serverImpl/server_nodejs.js.map +1 -0
  124. package/dist/@core/serverInstanceBuilder.d.ts +17 -0
  125. package/dist/@core/serverInstanceBuilder.js +14 -0
  126. package/dist/@core/serverInstanceBuilder.js.map +1 -0
  127. package/dist/@core/userStores.d.ts +13 -0
  128. package/dist/@core/userStores.js +20 -0
  129. package/dist/@core/userStores.js.map +1 -0
  130. package/dist/@crawler/common.d.ts +203 -0
  131. package/dist/@crawler/common.js +68 -0
  132. package/dist/@crawler/common.js.map +1 -0
  133. package/dist/@crawler/core.d.ts +87 -0
  134. package/dist/@crawler/core.js +586 -0
  135. package/dist/@crawler/core.js.map +1 -0
  136. package/dist/@crawler/directFileCache.d.ts +10 -0
  137. package/dist/@crawler/directFileCache.js +60 -0
  138. package/dist/@crawler/directFileCache.js.map +1 -0
  139. package/dist/@crawler/index.d.ts +4 -0
  140. package/dist/@crawler/index.js +5 -0
  141. package/dist/@crawler/index.js.map +1 -0
  142. package/dist/@crawler/urlMapping.d.ts +21 -0
  143. package/dist/@crawler/urlMapping.js +52 -0
  144. package/dist/@crawler/urlMapping.js.map +1 -0
  145. package/dist/@crawler/utils.d.ts +6 -0
  146. package/dist/@crawler/utils.js +13 -0
  147. package/dist/@crawler/utils.js.map +1 -0
  148. package/dist/@generated/index.d.ts +29 -0
  149. package/dist/@generated/index.js +93 -0
  150. package/dist/@generated/index.js.map +1 -0
  151. package/dist/@linker/arobaseTypes.d.ts +50 -0
  152. package/dist/@linker/arobaseTypes.js +235 -0
  153. package/dist/@linker/arobaseTypes.js.map +1 -0
  154. package/dist/@linker/changeProof.d.ts +5 -0
  155. package/dist/@linker/changeProof.js +50 -0
  156. package/dist/@linker/changeProof.js.map +1 -0
  157. package/dist/@linker/config.d.ts +2 -0
  158. package/dist/@linker/config.js +40 -0
  159. package/dist/@linker/config.js.map +1 -0
  160. package/dist/@linker/engine.d.ts +156 -0
  161. package/dist/@linker/engine.js +665 -0
  162. package/dist/@linker/engine.js.map +1 -0
  163. package/dist/@linker/index.d.ts +3 -0
  164. package/dist/@linker/index.js +4 -0
  165. package/dist/@linker/index.js.map +1 -0
  166. package/dist/@linker/install.d.ts +4 -0
  167. package/dist/@linker/install.js +42 -0
  168. package/dist/@linker/install.js.map +1 -0
  169. package/dist/@linker/modInstaller.d.ts +10 -0
  170. package/dist/@linker/modInstaller.js +38 -0
  171. package/dist/@linker/modInstaller.js.map +1 -0
  172. package/dist/@linker/typeEvents.d.ts +9 -0
  173. package/dist/@linker/typeEvents.js +48 -0
  174. package/dist/@linker/typeEvents.js.map +1 -0
  175. package/dist/@linker/typeRoutes.d.ts +23 -0
  176. package/dist/@linker/typeRoutes.js +197 -0
  177. package/dist/@linker/typeRoutes.js.map +1 -0
  178. package/dist/@linker/typeUiComposite.d.ts +6 -0
  179. package/dist/@linker/typeUiComposite.js +16 -0
  180. package/dist/@linker/typeUiComposite.js.map +1 -0
  181. package/dist/@loader/index.d.ts +1 -0
  182. package/dist/@loader/index.js +17 -0
  183. package/dist/@loader/index.js.map +1 -0
  184. package/dist/@loader/nodeJsLoader.d.ts +2 -0
  185. package/dist/@loader/nodeJsLoader.js +19 -0
  186. package/dist/@loader/nodeJsLoader.js.map +1 -0
  187. package/dist/@loader-client/index.d.ts +33 -0
  188. package/dist/@loader-client/index.js +98 -0
  189. package/dist/@loader-client/index.js.map +1 -0
  190. package/dist/@loader-tools/bunJsLoader.d.ts +1 -0
  191. package/dist/@loader-tools/bunJsLoader.js +28 -0
  192. package/dist/@loader-tools/bunJsLoader.js.map +1 -0
  193. package/dist/@loader-tools/config.d.ts +49 -0
  194. package/dist/@loader-tools/config.js +79 -0
  195. package/dist/@loader-tools/config.js.map +1 -0
  196. package/dist/@loader-tools/cssModuleCompiler.d.ts +5 -0
  197. package/dist/@loader-tools/cssModuleCompiler.js +65 -0
  198. package/dist/@loader-tools/cssModuleCompiler.js.map +1 -0
  199. package/dist/@loader-tools/esBuildPlugin.d.ts +5 -0
  200. package/dist/@loader-tools/esBuildPlugin.js +113 -0
  201. package/dist/@loader-tools/esBuildPlugin.js.map +1 -0
  202. package/dist/@loader-tools/index.d.ts +9 -0
  203. package/dist/@loader-tools/index.js +10 -0
  204. package/dist/@loader-tools/index.js.map +1 -0
  205. package/dist/@loader-tools/jopin.d.ts +10 -0
  206. package/dist/@loader-tools/jopin.js +331 -0
  207. package/dist/@loader-tools/jopin.js.map +1 -0
  208. package/dist/@loader-tools/nodeJsLoader.d.ts +13 -0
  209. package/dist/@loader-tools/nodeJsLoader.js +101 -0
  210. package/dist/@loader-tools/nodeJsLoader.js.map +1 -0
  211. package/dist/@loader-tools/nodeJsResolver.d.ts +2 -0
  212. package/dist/@loader-tools/nodeJsResolver.js +117 -0
  213. package/dist/@loader-tools/nodeJsResolver.js.map +1 -0
  214. package/dist/@loader-tools/rules.d.ts +3 -0
  215. package/dist/@loader-tools/rules.js +33 -0
  216. package/dist/@loader-tools/rules.js.map +1 -0
  217. package/dist/@loader-tools/sourceChangesWatcher.d.ts +39 -0
  218. package/dist/@loader-tools/sourceChangesWatcher.js +182 -0
  219. package/dist/@loader-tools/sourceChangesWatcher.js.map +1 -0
  220. package/dist/@loader-tools/tools.d.ts +21 -0
  221. package/dist/@loader-tools/tools.js +113 -0
  222. package/dist/@loader-tools/tools.js.map +1 -0
  223. package/dist/@loader-tools/transform.d.ts +5 -0
  224. package/dist/@loader-tools/transform.js +114 -0
  225. package/dist/@loader-tools/transform.js.map +1 -0
  226. package/dist/@loader-tools/virtualUrl.d.ts +9 -0
  227. package/dist/@loader-tools/virtualUrl.js +40 -0
  228. package/dist/@loader-tools/virtualUrl.js.map +1 -0
  229. package/dist/@tool-jopinb/index.d.ts +1 -0
  230. package/dist/@tool-jopinb/index.js +9 -0
  231. package/dist/@tool-jopinb/index.js.map +1 -0
  232. package/dist/@ui/components.d.ts +27 -0
  233. package/dist/@ui/components.js +42 -0
  234. package/dist/@ui/components.js.map +1 -0
  235. package/dist/@ui/cssModules.d.ts +11 -0
  236. package/dist/@ui/cssModules.js +17 -0
  237. package/dist/@ui/cssModules.js.map +1 -0
  238. package/dist/@ui/hooks.d.ts +31 -0
  239. package/dist/@ui/hooks.js +71 -0
  240. package/dist/@ui/hooks.js.map +1 -0
  241. package/dist/@ui/index.d.ts +9 -0
  242. package/dist/@ui/index.js +11 -0
  243. package/dist/@ui/index.js.map +1 -0
  244. package/dist/@ui/internal.d.ts +4 -0
  245. package/dist/@ui/internal.js +10 -0
  246. package/dist/@ui/internal.js.map +1 -0
  247. package/dist/@ui/modules.d.ts +41 -0
  248. package/dist/@ui/modules.js +74 -0
  249. package/dist/@ui/modules.js.map +1 -0
  250. package/dist/@ui/objectRegistry.d.ts +12 -0
  251. package/dist/@ui/objectRegistry.js +35 -0
  252. package/dist/@ui/objectRegistry.js.map +1 -0
  253. package/dist/@ui/pageController.d.ts +61 -0
  254. package/dist/@ui/pageController.js +166 -0
  255. package/dist/@ui/pageController.js.map +1 -0
  256. package/dist/@ui/tools.d.ts +24 -0
  257. package/dist/@ui/tools.js +78 -0
  258. package/dist/@ui/tools.js.map +1 -0
  259. package/dist/@uikit/core/UiKitModule.d.ts +6 -0
  260. package/dist/@uikit/core/UiKitModule.js +18 -0
  261. package/dist/@uikit/core/UiKitModule.js.map +1 -0
  262. package/dist/@uikit/core/index.d.ts +1 -0
  263. package/dist/@uikit/core/index.js +4 -0
  264. package/dist/@uikit/core/index.js.map +1 -0
  265. package/dist/@uikit/core/jBundler_ifBrowser.d.ts +1 -0
  266. package/dist/@uikit/core/jBundler_ifBrowser.js +5 -0
  267. package/dist/@uikit/core/jBundler_ifBrowser.js.map +1 -0
  268. package/dist/@uikit/core/jBundler_ifServer.d.ts +6 -0
  269. package/dist/@uikit/core/jBundler_ifServer.js +17 -0
  270. package/dist/@uikit/core/jBundler_ifServer.js.map +1 -0
  271. package/dist/@uikit/forms/components.d.ts +18 -0
  272. package/dist/@uikit/forms/components.js +69 -0
  273. package/dist/@uikit/forms/components.js.map +1 -0
  274. package/dist/@uikit/forms/hooks.d.ts +4 -0
  275. package/dist/@uikit/forms/hooks.js +31 -0
  276. package/dist/@uikit/forms/hooks.js.map +1 -0
  277. package/dist/@uikit/forms/index.d.ts +3 -0
  278. package/dist/@uikit/forms/index.js +4 -0
  279. package/dist/@uikit/forms/index.js.map +1 -0
  280. package/dist/@uikit/forms/interfaces.d.ts +101 -0
  281. package/dist/@uikit/forms/interfaces.js +4 -0
  282. package/dist/@uikit/forms/interfaces.js.map +1 -0
  283. package/dist/@uikit/forms/private.d.ts +40 -0
  284. package/dist/@uikit/forms/private.js +307 -0
  285. package/dist/@uikit/forms/private.js.map +1 -0
  286. package/dist/@uikit/helpers/hooks.d.ts +33 -0
  287. package/dist/@uikit/helpers/hooks.js +107 -0
  288. package/dist/@uikit/helpers/hooks.js.map +1 -0
  289. package/dist/@uikit/helpers/index.d.ts +2 -0
  290. package/dist/@uikit/helpers/index.js +3 -0
  291. package/dist/@uikit/helpers/index.js.map +1 -0
  292. package/dist/@uikit/helpers/tools.d.ts +8 -0
  293. package/dist/@uikit/helpers/tools.js +35 -0
  294. package/dist/@uikit/helpers/tools.js.map +1 -0
  295. package/dist/@uikit/index.d.ts +10 -0
  296. package/dist/@uikit/index.js +13 -0
  297. package/dist/@uikit/index.js.map +1 -0
  298. package/dist/@uikit/menu/core.d.ts +21 -0
  299. package/dist/@uikit/menu/core.js +191 -0
  300. package/dist/@uikit/menu/core.js.map +1 -0
  301. package/dist/@uikit/menu/hooks.d.ts +5 -0
  302. package/dist/@uikit/menu/hooks.js +24 -0
  303. package/dist/@uikit/menu/hooks.js.map +1 -0
  304. package/dist/@uikit/menu/index.d.ts +3 -0
  305. package/dist/@uikit/menu/index.js +4 -0
  306. package/dist/@uikit/menu/index.js.map +1 -0
  307. package/dist/@uikit/menu/interfaces.d.ts +20 -0
  308. package/dist/@uikit/menu/interfaces.js +8 -0
  309. package/dist/@uikit/menu/interfaces.js.map +1 -0
  310. package/dist/@uikit/menu/internal.d.ts +40 -0
  311. package/dist/@uikit/menu/internal.js +191 -0
  312. package/dist/@uikit/menu/internal.js.map +1 -0
  313. package/dist/@uikit/reactRouter/hooks/jBundler_ifBrowser.d.ts +18 -0
  314. package/dist/@uikit/reactRouter/hooks/jBundler_ifBrowser.js +40 -0
  315. package/dist/@uikit/reactRouter/hooks/jBundler_ifBrowser.js.map +1 -0
  316. package/dist/@uikit/reactRouter/hooks/jBundler_ifServer.d.ts +28 -0
  317. package/dist/@uikit/reactRouter/hooks/jBundler_ifServer.js +35 -0
  318. package/dist/@uikit/reactRouter/hooks/jBundler_ifServer.js.map +1 -0
  319. package/dist/@uikit/reactRouter/index.d.ts +1 -0
  320. package/dist/@uikit/reactRouter/index.js +2 -0
  321. package/dist/@uikit/reactRouter/index.js.map +1 -0
  322. package/dist/@uikit/users/hooks.d.ts +10 -0
  323. package/dist/@uikit/users/hooks.js +39 -0
  324. package/dist/@uikit/users/hooks.js.map +1 -0
  325. package/dist/@uikit/users/index.d.ts +1 -0
  326. package/dist/@uikit/users/index.js +2 -0
  327. package/dist/@uikit/users/index.js.map +1 -0
  328. package/dist/@uikit/variants/index.d.ts +7 -0
  329. package/dist/@uikit/variants/index.js +16 -0
  330. package/dist/@uikit/variants/index.js.map +1 -0
  331. package/package.json +115 -0
  332. package/src/@bundler/README.md +1 -0
  333. package/src/@bundler/_logs.ts +4 -0
  334. package/src/@bundler/core.ts +41 -0
  335. package/src/@bundler/esbuild.ts +141 -0
  336. package/src/@bundler/index.ts +3 -0
  337. package/src/@bundler/plugins.ts +163 -0
  338. package/src/@bundler/tailwind.ts +139 -0
  339. package/src/@core/PageComponent.tsx +25 -0
  340. package/src/@core/README.md +1 -0
  341. package/src/@core/_logs.ts +11 -0
  342. package/src/@core/automaticStartStop.ts +132 -0
  343. package/src/@core/browserCacheControl.ts +40 -0
  344. package/src/@core/bundler/bundler.ts +128 -0
  345. package/src/@core/bundler/common.ts +18 -0
  346. package/src/@core/bundler/config.ts +37 -0
  347. package/src/@core/bundler/extraContent.ts +30 -0
  348. package/src/@core/bundler/pagesGenerator.ts +194 -0
  349. package/src/@core/bundler/server.ts +41 -0
  350. package/src/@core/caches/InMemoryCache.ts +483 -0
  351. package/src/@core/caches/SimpleFileCache.ts +205 -0
  352. package/src/@core/caches/cache.ts +77 -0
  353. package/src/@core/caches/webSiteMirrorCache.ts +90 -0
  354. package/src/@core/cheerio.d.ts +332 -0
  355. package/src/@core/gzip.ts +33 -0
  356. package/src/@core/index.ts +23 -0
  357. package/src/@core/internalTools.ts +95 -0
  358. package/src/@core/jQuery.ts +22 -0
  359. package/src/@core/jopiEasy.ts +1285 -0
  360. package/src/@core/jopiRequest.tsx +1279 -0
  361. package/src/@core/jopiServer.ts +188 -0
  362. package/src/@core/jopiWebSite.tsx +1027 -0
  363. package/src/@core/letsEncrypt.ts +243 -0
  364. package/src/@core/linker.ts +42 -0
  365. package/src/@core/loadBalancing.ts +152 -0
  366. package/src/@core/middlewares/CorsMiddleware.ts +23 -0
  367. package/src/@core/middlewares/DdosProtection.ts +120 -0
  368. package/src/@core/middlewares/index.ts +16 -0
  369. package/src/@core/publicTools.ts +14 -0
  370. package/src/@core/routeConfig.ts +104 -0
  371. package/src/@core/searchParamFilter.ts +315 -0
  372. package/src/@core/serverFetch.ts +454 -0
  373. package/src/@core/serverImpl/server_bunjs.tsx +230 -0
  374. package/src/@core/serverImpl/server_nodejs.ts +312 -0
  375. package/src/@core/serverInstanceBuilder.ts +36 -0
  376. package/src/@core/userStores.ts +34 -0
  377. package/src/@crawler/README.md +1 -0
  378. package/src/@crawler/common.ts +275 -0
  379. package/src/@crawler/core.ts +678 -0
  380. package/src/@crawler/directFileCache.ts +69 -0
  381. package/src/@crawler/index.ts +4 -0
  382. package/src/@crawler/urlMapping.ts +67 -0
  383. package/src/@crawler/utils.ts +13 -0
  384. package/src/@generated/index.ts +134 -0
  385. package/src/@linker/arobaseTypes.ts +325 -0
  386. package/src/@linker/changeProof.ts +53 -0
  387. package/src/@linker/config.ts +46 -0
  388. package/src/@linker/engine.ts +865 -0
  389. package/src/@linker/index.ts +3 -0
  390. package/src/@linker/install.ts +39 -0
  391. package/src/@linker/modInstaller.ts +50 -0
  392. package/src/@linker/typeEvents.ts +58 -0
  393. package/src/@linker/typeRoutes.ts +255 -0
  394. package/src/@linker/typeUiComposite.ts +19 -0
  395. package/src/@loader/README.md +4 -0
  396. package/src/@loader/bunHtmlCompiler.mjs +27 -0
  397. package/src/@loader/index.ts +19 -0
  398. package/src/@loader/loader.mjs +7 -0
  399. package/src/@loader/nodeJsLoader.ts +21 -0
  400. package/src/@loader-client/README.md +2 -0
  401. package/src/@loader-client/index.ts +108 -0
  402. package/src/@loader-tools/README.md +6 -0
  403. package/src/@loader-tools/bunJsLoader.ts +33 -0
  404. package/src/@loader-tools/config.ts +142 -0
  405. package/src/@loader-tools/cssModuleCompiler.ts +76 -0
  406. package/src/@loader-tools/esBuildPlugin.ts +142 -0
  407. package/src/@loader-tools/index.ts +11 -0
  408. package/src/@loader-tools/jopin.ts +403 -0
  409. package/src/@loader-tools/nodeJsLoader.ts +119 -0
  410. package/src/@loader-tools/nodeJsResolver.ts +140 -0
  411. package/src/@loader-tools/rules.ts +45 -0
  412. package/src/@loader-tools/sourceChangesWatcher.ts +225 -0
  413. package/src/@loader-tools/tools.ts +139 -0
  414. package/src/@loader-tools/transform.ts +138 -0
  415. package/src/@loader-tools/virtualUrl.ts +57 -0
  416. package/src/@loader-types/README.md +15 -0
  417. package/src/@loader-types/extensions.d.ts +65 -0
  418. package/src/@tool-jopinb/README.md +1 -0
  419. package/src/@tool-jopinb/index.ts +11 -0
  420. package/src/@ui/README.md +3 -0
  421. package/src/@ui/components.tsx +49 -0
  422. package/src/@ui/cssModules.tsx +27 -0
  423. package/src/@ui/hooks.tsx +95 -0
  424. package/src/@ui/index.ts +13 -0
  425. package/src/@ui/internal.ts +12 -0
  426. package/src/@ui/modules.ts +100 -0
  427. package/src/@ui/objectRegistry.ts +50 -0
  428. package/src/@ui/pageController.ts +203 -0
  429. package/src/@ui/tools.ts +116 -0
  430. package/src/@uikit/README.md +1 -0
  431. package/src/@uikit/core/UiKitModule.ts +20 -0
  432. package/src/@uikit/core/index.ts +4 -0
  433. package/src/@uikit/core/jBundler_ifBrowser.ts +4 -0
  434. package/src/@uikit/core/jBundler_ifServer.ts +18 -0
  435. package/src/@uikit/forms/components.tsx +97 -0
  436. package/src/@uikit/forms/hooks.ts +38 -0
  437. package/src/@uikit/forms/index.ts +3 -0
  438. package/src/@uikit/forms/interfaces.ts +159 -0
  439. package/src/@uikit/forms/private.ts +365 -0
  440. package/src/@uikit/helpers/hooks.ts +133 -0
  441. package/src/@uikit/helpers/index.ts +2 -0
  442. package/src/@uikit/helpers/tools.ts +39 -0
  443. package/src/@uikit/index.ts +15 -0
  444. package/src/@uikit/menu/core.ts +227 -0
  445. package/src/@uikit/menu/hooks.ts +28 -0
  446. package/src/@uikit/menu/index.ts +3 -0
  447. package/src/@uikit/menu/interfaces.ts +26 -0
  448. package/src/@uikit/menu/internal.ts +218 -0
  449. package/src/@uikit/package.json +15 -0
  450. package/src/@uikit/reactRouter/hooks/jBundler_ifBrowser.tsx +59 -0
  451. package/src/@uikit/reactRouter/hooks/jBundler_ifServer.tsx +51 -0
  452. package/src/@uikit/reactRouter/index.ts +1 -0
  453. package/src/@uikit/users/hooks.ts +50 -0
  454. package/src/@uikit/users/index.ts +1 -0
  455. package/src/@uikit/variants/index.tsx +20 -0
@@ -0,0 +1,983 @@
1
+ // noinspection JSUnusedGlobalSymbols
2
+ import path from "node:path";
3
+ import fsc from "node:fs";
4
+ import * as jk_app from "jopi-toolkit/jk_app";
5
+ import * as jk_timer from "jopi-toolkit/jk_timer";
6
+ import * as jk_term from "jopi-toolkit/jk_term";
7
+ import * as jk_events from "jopi-toolkit/jk_events";
8
+ import { ServerFetch } from "./serverFetch.js";
9
+ import { getLetsEncryptCertificate } from "./letsEncrypt.js";
10
+ import { UserStore_WithLoginPassword } from "./userStores.js";
11
+ import { getBundlerConfig } from "./bundler/config.js";
12
+ import { serverInitChronos } from "./internalTools.js";
13
+ import { getInMemoryCache, initMemoryCache } from "./caches/InMemoryCache.js";
14
+ import { SimpleFileCache } from "./caches/SimpleFileCache.js";
15
+ import { ProcessUrlResult, WebSiteCrawler } from "jopijs/crawler";
16
+ import { JopiRequest } from "./jopiRequest.js";
17
+ import { WebSiteImpl, WebSiteOptions } from "./jopiWebSite.js";
18
+ import { getServer } from "./jopiServer.js";
19
+ import { HTTP_VERBS } from "./publicTools.js";
20
+ import { getPackageJsonConfig } from "jopijs/loader-tools";
21
+ import { initLinker } from "./linker.js";
22
+ import { logServer_startApp } from "./_logs.js";
23
+ serverInitChronos.start("jopiEasy lib");
24
+ class JopiApp {
25
+ _isStartAppSet = false;
26
+ startApp(importMeta, f) {
27
+ async function doStart() {
28
+ await jk_app.waitServerSideReady();
29
+ await jk_app.declareAppStarted();
30
+ let res = f(new JopiEasy());
31
+ if (res instanceof Promise)
32
+ await res;
33
+ }
34
+ if (this._isStartAppSet)
35
+ throw "App is already started";
36
+ this._isStartAppSet = true;
37
+ const logEnd = logServer_startApp.beginInfo("Starting Application");
38
+ jk_app.setApplicationMainFile(importMeta.filename);
39
+ doStart().then(logEnd);
40
+ }
41
+ }
42
+ let gWebSiteCreated = false;
43
+ export class JopiEasy {
44
+ getDefaultUrl() {
45
+ let config = getPackageJsonConfig();
46
+ if (config.webSiteListeningUrl)
47
+ return config.webSiteListeningUrl;
48
+ if (config.webSiteUrl)
49
+ return config.webSiteUrl;
50
+ throw new Error("Invalid package.json configuration. 'jopi.webSiteUrl' or 'jopi.webSiteListeningUrl' must be set");
51
+ }
52
+ create_creatWebSiteServer(url, ref) {
53
+ if (gWebSiteCreated)
54
+ throw new Error("WebSite already created");
55
+ gWebSiteCreated = true;
56
+ if (!url) {
57
+ url = this.getDefaultUrl();
58
+ }
59
+ const res = new JopiEasyWebSite_ExposePrivate(url);
60
+ if (ref)
61
+ ref.webSite = res;
62
+ return res;
63
+ }
64
+ create_webSiteDownloader(urlOrigin) {
65
+ if (gWebSiteCreated)
66
+ throw new Error("WebSite already created");
67
+ gWebSiteCreated = true;
68
+ if (!urlOrigin) {
69
+ urlOrigin = this.getDefaultUrl();
70
+ }
71
+ return new CrawlerDownloader(urlOrigin);
72
+ }
73
+ }
74
+ export class RefFor_WebSite {
75
+ webSite;
76
+ waitWebSiteReady() {
77
+ if (!this.webSite)
78
+ return Promise.reject("website not set");
79
+ return new Promise((resolve) => {
80
+ this.webSite?.on_webSiteReady(resolve);
81
+ });
82
+ }
83
+ }
84
+ export const jopiApp = new JopiApp();
85
+ //region Crawler
86
+ class CrawlerDownloader {
87
+ urlOrigin;
88
+ _options = {};
89
+ _outputDir = "www-out";
90
+ _startUrl;
91
+ _urlPrefix;
92
+ _ignoreIfAlreadyDownloaded;
93
+ _onUrlProcessed;
94
+ _filter_canIgnoreIfAlreadyCrawled;
95
+ constructor(urlOrigin) {
96
+ this.urlOrigin = urlOrigin;
97
+ const urlInfos = new URL(urlOrigin);
98
+ this._urlPrefix = urlInfos.origin;
99
+ this._outputDir = path.resolve(process.cwd(), "www_" + urlInfos.hostname);
100
+ }
101
+ /**
102
+ * Define the directory where files will be downloaded.
103
+ * If not set, that it takes the current url and the hostname.
104
+ */
105
+ set_outputDir(outputDir) {
106
+ this._outputDir = outputDir;
107
+ return this;
108
+ }
109
+ /**
110
+ * Define the start point url.
111
+ * If not set, the default is "/".
112
+ * @param url
113
+ */
114
+ set_startUrl(url) {
115
+ this._startUrl = this.normalizeUrl(url);
116
+ return this;
117
+ }
118
+ normalizeUrl(url) {
119
+ if (url.startsWith(this._urlPrefix)) {
120
+ return url.substring(this._urlPrefix.length);
121
+ }
122
+ return url;
123
+ }
124
+ /**
125
+ * Add url with must be crawled.
126
+ * Is required if these urls aren't reachable from the start point.
127
+ */
128
+ set_extraUrls(urlList) {
129
+ urlList = urlList.map(u => this.normalizeUrl(u));
130
+ this._options.scanThisUrls = [...new Set([...this._options.scanThisUrls || [], ...urlList])];
131
+ return this;
132
+ }
133
+ /**
134
+ * Allow avoiding downloading again a resource if already in cache.
135
+ * @param value
136
+ */
137
+ setOption_ignoreIfAlreadyDownloaded(value = true) {
138
+ this._ignoreIfAlreadyDownloaded = value;
139
+ return this;
140
+ }
141
+ /**
142
+ * Set a function which is called when a URL has been processed.
143
+ *
144
+ * @param listener - A function that received information about the URL and his processing state.
145
+ */
146
+ on_urlProcessed(listener) {
147
+ this._onUrlProcessed = listener;
148
+ return this;
149
+ }
150
+ /**
151
+ * Sets a filter function to determine whether a URL can be downloaded.
152
+ *
153
+ * @param filter - A function that takes the URL as a string and a boolean flag
154
+ * indicating if it is a resource, and returns a boolean indicating
155
+ * whether the URL can be downloaded.
156
+ *
157
+ * Returns true if the url can be processed.
158
+ */
159
+ setFilter_canProcessThisUrl(filter) {
160
+ this._options.canDownload = filter;
161
+ return this;
162
+ }
163
+ setFilter_canIgnoreIfAlreadyDownloaded(filter) {
164
+ if (this._ignoreIfAlreadyDownloaded === undefined) {
165
+ this._ignoreIfAlreadyDownloaded = true;
166
+ }
167
+ this._filter_canIgnoreIfAlreadyCrawled = filter;
168
+ return this;
169
+ }
170
+ async START_DOWNLOAD() {
171
+ const downloader = this;
172
+ const crawler = new WebSiteCrawler(this.urlOrigin, {
173
+ outputDir: this._outputDir,
174
+ onUrlProcessed(infos) {
175
+ switch (infos.state) {
176
+ case ProcessUrlResult.IGNORED:
177
+ console.log("👎 Website downloader, url IGNORED:", infos.sourceUrl);
178
+ break;
179
+ case ProcessUrlResult.ERROR:
180
+ console.log("❌ Website downloader, url ERROR:", infos.sourceUrl);
181
+ break;
182
+ case ProcessUrlResult.OK:
183
+ console.log("✅ Website downloader, url DOWNLOADED:", infos.sourceUrl);
184
+ break;
185
+ case ProcessUrlResult.REDIRECTED:
186
+ console.log("🚫 Website downloader, url REDIRECTED:", infos.sourceUrl);
187
+ break;
188
+ }
189
+ if (downloader._onUrlProcessed) {
190
+ downloader._onUrlProcessed(infos);
191
+ }
192
+ },
193
+ canIgnoreIfAlreadyCrawled(url, infos) {
194
+ if (!downloader._ignoreIfAlreadyDownloaded)
195
+ return false;
196
+ if (downloader._filter_canIgnoreIfAlreadyCrawled) {
197
+ return downloader._filter_canIgnoreIfAlreadyCrawled(url, infos);
198
+ }
199
+ return true;
200
+ },
201
+ ...this._options
202
+ });
203
+ console.log("Downloading website", this.urlOrigin);
204
+ await crawler.start(this._startUrl);
205
+ console.log("Download finished for", this.urlOrigin);
206
+ }
207
+ }
208
+ //endregion
209
+ //region CreateServerFetch
210
+ class CreateServerFetch {
211
+ options;
212
+ createNextStep(options) {
213
+ return new CreateServerFetch_NextStep(options);
214
+ }
215
+ /**
216
+ * The server will be call with his IP and not his hostname
217
+ * which will only be set in the headers. It's required when
218
+ * the DNS doesn't pinpoint to the god server.
219
+ */
220
+ useIp(serverOrigin, ip, options) {
221
+ let rOptions = ServerFetch.getOptionsFor_useIP(serverOrigin, ip, options);
222
+ this.options = rOptions;
223
+ return this.createNextStep(rOptions);
224
+ }
225
+ useOrigin(serverOrigin, options) {
226
+ let rOptions = ServerFetch.getOptionsFor_useOrigin(serverOrigin, options);
227
+ this.options = rOptions;
228
+ return this.createNextStep(rOptions);
229
+ }
230
+ }
231
+ class CreateServerFetch_NextStep {
232
+ options;
233
+ constructor(options) {
234
+ this.options = options;
235
+ }
236
+ set_weight(weight) {
237
+ this.options.weight = weight;
238
+ return this;
239
+ }
240
+ set_isMainServer() {
241
+ return this.set_weight(1);
242
+ }
243
+ set_isBackupServer() {
244
+ return this.set_weight(0);
245
+ }
246
+ on_beforeRequesting(handler) {
247
+ this.options.beforeRequesting = handler;
248
+ return this;
249
+ }
250
+ on_ifServerIsDown(handler) {
251
+ this.options.ifServerIsDown = async (_fetcher, data) => {
252
+ const { builder, getResult } = IfServerDownBuilder.newBuilder(data);
253
+ let r = handler(builder);
254
+ if (r instanceof Promise)
255
+ await r;
256
+ let options = getResult();
257
+ if (options) {
258
+ const res = {
259
+ newServer: ServerFetch.useAsIs(options),
260
+ newServerWeight: options?.weight
261
+ };
262
+ return res;
263
+ }
264
+ return undefined;
265
+ };
266
+ return this;
267
+ }
268
+ do_startServer(handler) {
269
+ this.options.doStartServer = handler;
270
+ return this;
271
+ }
272
+ do_stopServer(handler) {
273
+ this.options.doStopServer = handler;
274
+ return this;
275
+ }
276
+ }
277
+ class IfServerDownBuilder extends CreateServerFetch {
278
+ data;
279
+ constructor(data) {
280
+ super();
281
+ this.data = data;
282
+ }
283
+ static newBuilder(data) {
284
+ const b = new IfServerDownBuilder(data);
285
+ return { builder: b, getResult: () => b.options };
286
+ }
287
+ }
288
+ export class JopiEasyWebSite {
289
+ origin;
290
+ hostName;
291
+ webSite;
292
+ options = {};
293
+ afterHook = [];
294
+ beforeHook = [];
295
+ internals;
296
+ _isWebSiteReady = false;
297
+ fileServerOptions;
298
+ events = jk_events.defaultEventGroup;
299
+ constructor(url) {
300
+ setTimeout(async () => {
301
+ await this.initWebSiteInstance();
302
+ }, 1);
303
+ const urlInfos = new URL(url);
304
+ this.hostName = urlInfos.hostname; // 127.0.0.1
305
+ this.origin = urlInfos.origin; // https://127.0.0.1
306
+ this.internals = {
307
+ options: this.options,
308
+ origin: this.origin,
309
+ hostName: this.hostName,
310
+ afterHook: this.afterHook,
311
+ beforeHook: this.beforeHook
312
+ };
313
+ this.options.onWebSiteReady = [() => {
314
+ this._isWebSiteReady = true;
315
+ }];
316
+ if (this.origin.startsWith("https://")) {
317
+ this.internals.beforeHook.push(async () => {
318
+ if (!gIsSslCertificateDefined) {
319
+ this.internals.options.certificate = useCertificateStore("certs", this.hostName);
320
+ }
321
+ });
322
+ }
323
+ this.fileServerOptions = {
324
+ rootDir: "public",
325
+ replaceIndexHtml: true,
326
+ onNotFound: req => req.res_returnError404_NotFound()
327
+ };
328
+ this.internals.afterHook.push(async (webSite) => {
329
+ webSite.onGET("/**", req => {
330
+ return req.file_serveFromDir(this.fileServerOptions.rootDir, {
331
+ replaceIndexHtml: this.fileServerOptions.replaceIndexHtml,
332
+ onNotFound: this.fileServerOptions.onNotFound
333
+ });
334
+ });
335
+ });
336
+ }
337
+ async initWebSiteInstance() {
338
+ const onWebSiteCreate = (h) => {
339
+ this.internals.afterHook.push(h);
340
+ };
341
+ if (!this.webSite) {
342
+ await initLinker(this, onWebSiteCreate);
343
+ for (let hook of this.beforeHook)
344
+ await hook();
345
+ this.webSite = new WebSiteImpl(this.origin, this.options);
346
+ for (const hook of this.afterHook) {
347
+ try {
348
+ await hook(this.webSite);
349
+ }
350
+ catch (e) {
351
+ if (e instanceof Error) {
352
+ jk_term.logBgRed("Error when initializing website", this.origin);
353
+ jk_term.logRed(e.message);
354
+ console.log(e.stack);
355
+ }
356
+ else {
357
+ console.error("Error when initializing website", this.origin);
358
+ jk_term.logRed("|-", e.message);
359
+ }
360
+ process.exit(1);
361
+ }
362
+ }
363
+ if (!giIsCorsDisabled) {
364
+ this.webSite.enableCors([this.webSite.welcomeUrl, ...gCorsConstraints]);
365
+ }
366
+ myServer.setWebsite(this.webSite);
367
+ await autoStartServer();
368
+ }
369
+ if (this.internals.onHookWebSite) {
370
+ this.internals.onHookWebSite(this.webSite);
371
+ }
372
+ }
373
+ hook_webSite(hook) {
374
+ this.internals.onHookWebSite = hook;
375
+ return this;
376
+ }
377
+ DONE_createWebSite() {
378
+ return jopiApp;
379
+ }
380
+ add_httpCertificate() {
381
+ return new CertificateBuilder(this, this.internals);
382
+ }
383
+ fastConfigure_fileServer(options) {
384
+ this.fileServerOptions = options;
385
+ return this;
386
+ }
387
+ configure_fileServer() {
388
+ const parent = this;
389
+ const me = {
390
+ set_rootDir: (rootDir) => {
391
+ this.fileServerOptions.rootDir = rootDir;
392
+ return me;
393
+ },
394
+ set_onNotFound: (handler) => {
395
+ this.fileServerOptions.onNotFound = handler;
396
+ return me;
397
+ },
398
+ DONE_configure_fileServer: () => {
399
+ return parent;
400
+ }
401
+ };
402
+ return me;
403
+ }
404
+ configure_jwtTokenAuth() {
405
+ const builder = new JwtTokenAuth_Builder(this, this.internals);
406
+ return {
407
+ step_setPrivateKey: (privateKey) => builder.setPrivateKey_STEP(privateKey)
408
+ };
409
+ }
410
+ fastConfigure_jwtTokenAuth(privateKey, store) {
411
+ const builder = new JwtTokenAuth_Builder(this, this.internals);
412
+ let config = builder.setPrivateKey_STEP(privateKey).step_setUserStore();
413
+ if (store instanceof Array) {
414
+ config.use_simpleLoginPassword().addMany(store);
415
+ }
416
+ else {
417
+ config.use_customStore(store);
418
+ }
419
+ return this;
420
+ }
421
+ add_SseEvent(path, handler) {
422
+ this.internals.afterHook.push((webSite) => {
423
+ webSite.addSseEVent(path, handler);
424
+ });
425
+ return this;
426
+ }
427
+ configure_postCss() {
428
+ const parent = this;
429
+ const me = {
430
+ setPlugin: (handler) => {
431
+ getBundlerConfig().postCss.initializer = handler;
432
+ return me;
433
+ },
434
+ END_configure_postCss() {
435
+ return parent;
436
+ }
437
+ };
438
+ return me;
439
+ }
440
+ configure_behaviors() {
441
+ const parent = this;
442
+ const me = {
443
+ removeTrailingSlashs(value = true) {
444
+ parent.options.removeTrailingSlash = value;
445
+ return me;
446
+ },
447
+ DONE_configure_behaviors() {
448
+ return parent;
449
+ }
450
+ };
451
+ return me;
452
+ }
453
+ configure_cache() {
454
+ return new WebSite_CacheBuilder(this, this.internals);
455
+ }
456
+ configure_middlewares() {
457
+ return new WebSite_MiddlewareBuilder(this, this.internals);
458
+ }
459
+ configure_bundler() {
460
+ const parent = this;
461
+ const me = {
462
+ dontEmbed_ReactJS: () => {
463
+ me.dontEmbedThis("react", "react-dom");
464
+ return me;
465
+ },
466
+ dontEmbedThis: (...packages) => {
467
+ let config = getBundlerConfig();
468
+ if (!config.embed.dontEmbedThis)
469
+ config.embed.dontEmbedThis = [];
470
+ config.embed.dontEmbedThis.push(...packages);
471
+ return me;
472
+ },
473
+ END_configure_bundler() {
474
+ return parent;
475
+ }
476
+ };
477
+ return me;
478
+ }
479
+ configure_tailwindProcessor() {
480
+ const parent = this;
481
+ const me = {
482
+ disableTailwind: () => {
483
+ getBundlerConfig().tailwind.disable = true;
484
+ return me;
485
+ },
486
+ setGlobalCssContent: (template) => {
487
+ getBundlerConfig().tailwind.globalCssContent = template;
488
+ return me;
489
+ },
490
+ setConfig: (config) => {
491
+ getBundlerConfig().tailwind.config = config;
492
+ return me;
493
+ },
494
+ /**
495
+ * Allows adding extra-sources files to scan.
496
+ * Can also be motifs. Ex: "./myDir/*.{js,ts,jsx,tsx}"
497
+ */
498
+ addExtraSourceFiles: (...files) => {
499
+ const config = getBundlerConfig().tailwind;
500
+ if (!config.extraSourceFiles)
501
+ config.extraSourceFiles = [];
502
+ config.extraSourceFiles.push(...files);
503
+ return me;
504
+ },
505
+ setGlobalCssFilePath: (filePath) => {
506
+ const config = getBundlerConfig().tailwind;
507
+ config.globalCssFilePath = filePath;
508
+ return me;
509
+ },
510
+ END_configure_tailwindProcessor() {
511
+ return parent;
512
+ }
513
+ };
514
+ return me;
515
+ }
516
+ add_sourceServer() {
517
+ return new WebSite_AddSourceServerBuilder(this, this.internals);
518
+ }
519
+ add_specialPageHandler() {
520
+ return new WebSite_AddSpecialPageHandler(this, this.internals);
521
+ }
522
+ on_webSiteReady(listener) {
523
+ if (this._isWebSiteReady) {
524
+ listener();
525
+ return;
526
+ }
527
+ this.options.onWebSiteReady.push(listener);
528
+ return this;
529
+ }
530
+ configure_cors() {
531
+ return new WebSite_ConfigureCors(this);
532
+ }
533
+ fastConfigure_cors(allowedHosts) {
534
+ const b = new WebSite_ConfigureCors(this);
535
+ if (allowedHosts) {
536
+ allowedHosts.forEach(o => b.add_allowedHost(o));
537
+ }
538
+ return this;
539
+ }
540
+ }
541
+ class JopiEasyWebSite_ExposePrivate extends JopiEasyWebSite {
542
+ isWebSiteReady() {
543
+ return this._isWebSiteReady;
544
+ }
545
+ getInternals() {
546
+ return this.internals;
547
+ }
548
+ }
549
+ class WebSite_ConfigureCors {
550
+ webSite;
551
+ constructor(webSite) {
552
+ this.webSite = webSite;
553
+ }
554
+ add_allowedHost(hostName) {
555
+ try {
556
+ let url = new URL(hostName);
557
+ gCorsConstraints.push(url.origin);
558
+ }
559
+ catch {
560
+ throw new Error(`Invalid host name: ${hostName}. Must be a valid URL.`);
561
+ }
562
+ return this;
563
+ }
564
+ disable_cors() {
565
+ giIsCorsDisabled = true;
566
+ return this;
567
+ }
568
+ DONE_configure_cors() {
569
+ return this.webSite;
570
+ }
571
+ }
572
+ class WebSite_AddSpecialPageHandler {
573
+ webSite;
574
+ internals;
575
+ constructor(webSite, internals) {
576
+ this.webSite = webSite;
577
+ this.internals = internals;
578
+ }
579
+ END_add_specialPageHandler() {
580
+ return this.webSite;
581
+ }
582
+ on_404_NotFound(handler) {
583
+ this.internals.afterHook.push(async (webSite) => {
584
+ webSite.on404_NotFound(handler);
585
+ });
586
+ return this;
587
+ }
588
+ on_500_Error(handler) {
589
+ this.internals.afterHook.push(async (webSite) => {
590
+ webSite.on500_Error(handler);
591
+ });
592
+ return this;
593
+ }
594
+ on_401_Unauthorized(handler) {
595
+ this.internals.afterHook.push(async (webSite) => {
596
+ webSite.on401_Unauthorized(handler);
597
+ });
598
+ return this;
599
+ }
600
+ }
601
+ class WebSite_AddSourceServerBuilder extends CreateServerFetch {
602
+ webSite;
603
+ internals;
604
+ serverFetch;
605
+ constructor(webSite, internals) {
606
+ super();
607
+ this.webSite = webSite;
608
+ this.internals = internals;
609
+ this.internals.afterHook.push(async (webSite) => {
610
+ if (this.serverFetch) {
611
+ webSite.addSourceServer(this.serverFetch);
612
+ }
613
+ });
614
+ }
615
+ createNextStep(options) {
616
+ return new WebSite_AddSourceServerBuilder_NextStep(this.webSite, this.internals, options);
617
+ }
618
+ END_add_sourceServer() {
619
+ return this.webSite;
620
+ }
621
+ add_sourceServer() {
622
+ return new WebSite_AddSourceServerBuilder(this.webSite, this.internals);
623
+ }
624
+ }
625
+ class WebSite_AddSourceServerBuilder_NextStep extends CreateServerFetch_NextStep {
626
+ webSite;
627
+ internals;
628
+ constructor(webSite, internals, options) {
629
+ super(options);
630
+ this.webSite = webSite;
631
+ this.internals = internals;
632
+ this.internals.afterHook.push(async (webSite) => {
633
+ webSite.addSourceServer(ServerFetch.useAsIs(this.options));
634
+ });
635
+ }
636
+ END_add_sourceServer() {
637
+ return this.webSite;
638
+ }
639
+ add_sourceServer() {
640
+ return new WebSite_AddSourceServerBuilder(this.webSite, this.internals);
641
+ }
642
+ }
643
+ class WebSite_MiddlewareBuilder {
644
+ webSite;
645
+ internals;
646
+ constructor(webSite, internals) {
647
+ this.webSite = webSite;
648
+ this.internals = internals;
649
+ }
650
+ add_middleware(method, middleware, options) {
651
+ this.internals.afterHook.push(async (webSite) => {
652
+ webSite.addGlobalMiddleware(method, middleware, options);
653
+ });
654
+ return this;
655
+ }
656
+ add_postMiddleware(method, middleware, options) {
657
+ this.internals.afterHook.push(async (webSite) => {
658
+ webSite.addGlobalPostMiddleware(method, middleware, options);
659
+ });
660
+ return this;
661
+ }
662
+ END_configure_middlewares() {
663
+ return this.webSite;
664
+ }
665
+ }
666
+ class WebSite_CacheBuilder {
667
+ webSite;
668
+ internals;
669
+ cache;
670
+ onFakeNoUser;
671
+ rules = [];
672
+ constructor(webSite, internals) {
673
+ this.webSite = webSite;
674
+ this.internals = internals;
675
+ this.internals.afterHook.push(async (webSite) => {
676
+ webSite.setCacheRules(this.rules);
677
+ if (this.onFakeNoUser) {
678
+ webSite.setOnFakeNoUser(this.onFakeNoUser);
679
+ }
680
+ if (this.cache) {
681
+ webSite.setCache(this.cache);
682
+ }
683
+ });
684
+ }
685
+ on_fakeNoUser(listener) {
686
+ this.onFakeNoUser = listener;
687
+ return this;
688
+ }
689
+ use_inMemoryCache(options) {
690
+ if (options)
691
+ initMemoryCache(options);
692
+ this.cache = getInMemoryCache();
693
+ return this;
694
+ }
695
+ use_fileSystemCache(rootDir) {
696
+ this.cache = new SimpleFileCache(rootDir);
697
+ return this;
698
+ }
699
+ add_cacheRules(rules) {
700
+ this.rules.push(rules);
701
+ return this;
702
+ }
703
+ END_configure_cache() {
704
+ return this.webSite;
705
+ }
706
+ }
707
+ //endregion
708
+ //region Server starting
709
+ let gIsAutoStartDone = false;
710
+ async function autoStartServer() {
711
+ if (gIsAutoStartDone)
712
+ return;
713
+ gIsAutoStartDone = true;
714
+ await jk_timer.tick(5);
715
+ await myServer.startServer();
716
+ }
717
+ const myServer = getServer();
718
+ //endregion
719
+ //region Reverse proxy
720
+ class ReverseProxyBuilder {
721
+ webSite;
722
+ internals;
723
+ constructor(url, ref) {
724
+ this.webSite = new JopiEasyWebSite_ExposePrivate(url);
725
+ if (ref)
726
+ ref.webSite = this.webSite;
727
+ this.internals = this.webSite.getInternals();
728
+ this.internals.afterHook.push(async (webSite) => {
729
+ const handler = req => {
730
+ req.headers.set('X-Forwarded-Proto', req.urlInfos.protocol.replace(':', ''));
731
+ req.headers.set('X-Forwarded-Host', req.urlInfos.host);
732
+ const clientIp = req.coreServer.requestIP(req.coreRequest)?.address;
733
+ req.headers.set("X-Forwarded-For", clientIp);
734
+ return req.proxy_directProxyToServer();
735
+ };
736
+ HTTP_VERBS.forEach(verb => {
737
+ webSite.onVerb(verb, "/**", handler);
738
+ });
739
+ });
740
+ }
741
+ add_target() {
742
+ const { builder, getOptions } = ReverseProxyBuilder_AddTarget.newBuilder(this);
743
+ this.internals.afterHook.push(async (webSite) => {
744
+ let options = getOptions();
745
+ if (options) {
746
+ webSite.addSourceServer(ServerFetch.useAsIs(options));
747
+ }
748
+ });
749
+ return builder;
750
+ }
751
+ DONE_create_reverseProxy() {
752
+ return this.webSite;
753
+ }
754
+ }
755
+ class ReverseProxyBuilder_AddTarget extends CreateServerFetch {
756
+ parent;
757
+ static newBuilder(parent) {
758
+ const b = new ReverseProxyBuilder_AddTarget(parent);
759
+ return { builder: b, getOptions: () => b.options };
760
+ }
761
+ constructor(parent) {
762
+ super();
763
+ this.parent = parent;
764
+ }
765
+ DONE_add_target() {
766
+ return this.parent;
767
+ }
768
+ }
769
+ class ReverseProxyBuilder_AddTarget_NextStep extends CreateServerFetch_NextStep {
770
+ parent;
771
+ options;
772
+ constructor(parent, options) {
773
+ super(options);
774
+ this.parent = parent;
775
+ this.options = options;
776
+ }
777
+ DONE_add_target() {
778
+ return this.parent;
779
+ }
780
+ }
781
+ //endregion
782
+ //region TLS Certificates
783
+ //region CertificateBuilder
784
+ let gIsSslCertificateDefined = false;
785
+ function useCertificateStore(dirPath, hostName) {
786
+ dirPath = path.join(dirPath, hostName);
787
+ let cert = "";
788
+ let key = "";
789
+ try {
790
+ cert = path.resolve(dirPath, "certificate.crt.key");
791
+ fsc.statfsSync(cert);
792
+ }
793
+ catch {
794
+ console.error("Certificat file not found: ", cert);
795
+ }
796
+ try {
797
+ key = path.resolve(dirPath, "certificate.key");
798
+ fsc.statfsSync(key);
799
+ }
800
+ catch {
801
+ console.error("Certificat key file not found: ", key);
802
+ }
803
+ return { key, cert };
804
+ }
805
+ class CertificateBuilder {
806
+ parent;
807
+ internals;
808
+ constructor(parent, internals) {
809
+ this.parent = parent;
810
+ this.internals = internals;
811
+ }
812
+ generate_localDevCert(saveInDir = "certs") {
813
+ gIsSslCertificateDefined = true;
814
+ this.internals.beforeHook.push(async () => {
815
+ try {
816
+ this.internals.options.certificate = await myServer.createDevCertificate(this.internals.hostName, saveInDir);
817
+ }
818
+ catch {
819
+ console.error(`Can't create ssl certificate for ${this.internals.hostName}. Is mkcert tool installed ?`);
820
+ }
821
+ });
822
+ return {
823
+ DONE_add_httpCertificate: () => this.parent
824
+ };
825
+ }
826
+ use_dirStore(dirPath) {
827
+ gIsSslCertificateDefined = true;
828
+ this.internals.options.certificate = useCertificateStore(dirPath, this.internals.hostName);
829
+ return { DONE_add_httpCertificate: () => this.parent };
830
+ }
831
+ generate_letsEncryptCert(email) {
832
+ gIsSslCertificateDefined = true;
833
+ const params = { email };
834
+ this.internals.afterHook.push(async (webSite) => {
835
+ await getLetsEncryptCertificate(webSite, params);
836
+ });
837
+ return new LetsEncryptCertificateBuilder(this.parent, params);
838
+ }
839
+ }
840
+ //endregion
841
+ //region LetsEncryptCertificateBuilder
842
+ class LetsEncryptCertificateBuilder {
843
+ parent;
844
+ params;
845
+ constructor(parent, params) {
846
+ this.parent = parent;
847
+ this.params = params;
848
+ }
849
+ DONE_add_httpCertificate() {
850
+ return this.parent;
851
+ }
852
+ enable_production(value = true) {
853
+ this.params.isProduction = value;
854
+ return this;
855
+ }
856
+ disable_log() {
857
+ this.params.log = false;
858
+ return this;
859
+ }
860
+ set_certificateDir(dirPath) {
861
+ this.params.certificateDir = dirPath;
862
+ return this;
863
+ }
864
+ force_expireAfter_days(dayCount) {
865
+ this.params.expireAfter_days = dayCount;
866
+ return this;
867
+ }
868
+ force_timout_sec(value) {
869
+ this.params.timout_sec = value;
870
+ return this;
871
+ }
872
+ if_timeOutError(handler) {
873
+ this.params.onTimeoutError = handler;
874
+ return this;
875
+ }
876
+ }
877
+ //endregion
878
+ class JwtTokenAuth_Builder {
879
+ parent;
880
+ internals;
881
+ constructor(parent, internals) {
882
+ this.parent = parent;
883
+ this.internals = internals;
884
+ }
885
+ FINISH() {
886
+ return {
887
+ DONE_configure_jwtTokenAuth: () => this.parent
888
+ };
889
+ }
890
+ //region setPrivateKey_STEP (BEGIN / root)
891
+ setPrivateKey_STEP(privateKey) {
892
+ this.internals.afterHook.push(async (webSite) => {
893
+ webSite.setJwtSecret(privateKey);
894
+ });
895
+ return {
896
+ step_setUserStore: () => this.setUserStore_STEP()
897
+ };
898
+ }
899
+ //endregion
900
+ //region setUserStore_STEP
901
+ loginPasswordStore;
902
+ setUserStore_STEP() {
903
+ const self = this;
904
+ return {
905
+ use_simpleLoginPassword: () => {
906
+ this.loginPasswordStore = new UserStore_WithLoginPassword();
907
+ this.internals.afterHook.push(async (webSite) => {
908
+ this.loginPasswordStore.setAuthHandler(webSite);
909
+ });
910
+ return this.useSimpleLoginPassword_BEGIN();
911
+ },
912
+ use_customStore(store) { return self.useCustomStore_BEGIN(store); }
913
+ };
914
+ }
915
+ _setUserStore_NEXT() {
916
+ return {
917
+ stepConfigure: () => this.stepConfigure(),
918
+ DONE_setUserStore: () => this.FINISH(),
919
+ };
920
+ }
921
+ //region useCustomStore
922
+ useCustomStore_BEGIN(store) {
923
+ this.internals.afterHook.push(async (webSite) => {
924
+ webSite.setAuthHandler(store);
925
+ });
926
+ return {
927
+ DONE_use_customStore: () => this.useCustomStore_DONE()
928
+ };
929
+ }
930
+ useCustomStore_DONE() {
931
+ return this._setUserStore_NEXT();
932
+ }
933
+ //endregion
934
+ //region useSimpleLoginPassword
935
+ useSimpleLoginPassword_BEGIN() {
936
+ return this._useSimpleLoginPassword_REPEAT();
937
+ }
938
+ useSimpleLoginPassword_DONE() {
939
+ return this._setUserStore_NEXT();
940
+ }
941
+ _useSimpleLoginPassword_REPEAT() {
942
+ return {
943
+ getStoreRef: (h) => {
944
+ h(this.loginPasswordStore);
945
+ return this._useSimpleLoginPassword_REPEAT();
946
+ },
947
+ addOne: (login, password, userInfos) => this.useSimpleLoginPassword_addOne(login, password, userInfos),
948
+ addMany: (users) => this.useSimpleLoginPassword_addMany(users),
949
+ DONE_use_simpleLoginPassword: () => this.useSimpleLoginPassword_DONE()
950
+ };
951
+ }
952
+ useSimpleLoginPassword_addOne(login, password, userInfos) {
953
+ this.loginPasswordStore.add({ login, password, userInfos });
954
+ return this._useSimpleLoginPassword_REPEAT();
955
+ }
956
+ useSimpleLoginPassword_addMany(users) {
957
+ users.forEach(e => this.loginPasswordStore.add(e));
958
+ return this._useSimpleLoginPassword_REPEAT();
959
+ }
960
+ //endregion
961
+ //endregion
962
+ //region setTokenStore
963
+ stepConfigure() {
964
+ return {
965
+ set_cookieDuration: (expirationDuration_hours) => this.setTokenStore_useCookie(expirationDuration_hours),
966
+ DONE_stepConfigure: () => this.FINISH()
967
+ };
968
+ }
969
+ setTokenStore_useCookie(expirationDuration_hours = 3600) {
970
+ this.internals.afterHook.push(async (webSite) => {
971
+ webSite.setJwtTokenStore((_token, cookieValue, req) => {
972
+ req.cookie_addCookieToRes("authorization", cookieValue, { maxAge: jk_timer.ONE_HOUR * expirationDuration_hours });
973
+ });
974
+ });
975
+ return this.stepConfigure();
976
+ }
977
+ }
978
+ //endregion
979
+ //region Config
980
+ let gCorsConstraints = [];
981
+ let giIsCorsDisabled = false;
982
+ //endregion
983
+ //# sourceMappingURL=jopiEasy.js.map