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
package/README.md ADDED
@@ -0,0 +1,134 @@
1
+ ## What is Jopi Rewrite?
2
+
3
+ Jopi Rewrite is a Bun.js framework, with Node.js compatibility, for building ultra-fast websites using React.js.
4
+
5
+ Its operating principle is very similar to Next.js:
6
+ * On the server side, React.js is used to generate the HTML of pages, which are search-engine friendly (Google, Bing, ...). On the browser side, the generated HTML is automatically replaced by its fully interactive equivalent.
7
+ * Pages and APIs (GET/POST/...) are defined by placing files in directories whose names correspond directly to the URL structure.
8
+
9
+ The goal of Jopi Rewrite is simplicity: to be able to create an application without drowning in technical details. That's why Jopi Rewrite is not just a server, but also a framework. It is minimalist, but with very useful additions:
10
+
11
+ * **Tailwind already configured and enabled**. As well as **React HMR integration** so that any UI code change is instantly reflected in the browser.
12
+ * Inclusion of a **Docker script** to quickly convert your project into a very lightweight Docker VM.
13
+ * Built-in **JWT authentication** with the ability to easily create a user directory: a minimalist system that is easy to understand and extend for your own needs.
14
+ * **User role-based security** is included. It allows limiting access to certain resources and customizing behavior according to user roles.
15
+ * An **cache system** that makes your site as fast as a static site. You have full control over this cache, which can be global, per-user, to distinguish desktop/mobile, ...
16
+ * Creating an SSL certificate (for https) is trivial: Jopi **generates development certificates** (local machine) and also handles **Let's Encrypt**: with automatic renewal and no connection loss.
17
+ * Simple but powerful **module system** to organize your application and reuse module between your apps.
18
+
19
+ ## Application organization
20
+
21
+ ### Application structure
22
+
23
+ A typical application looks like this in terms of folders.
24
+
25
+ **Example Jopi project**
26
+ ```
27
+ |- node_modules/
28
+ |- package.json
29
+ |- tsconfig.json < If you use node.js / typescript
30
+ |- src/
31
+ |- mod_moduleA < Code is always divided into modules
32
+ |- mod_moduleB
33
+ |- @alias < Allows sharing between modules
34
+ |- @routes/admin < Define items bound to urls
35
+ |- page.tsx < Bound to http://mysite/admin
36
+ |- onPOST.ts < Catch all POST call to this url
37
+ |- config.ts < If you want to configure some options
38
+ |- pageNeedRole_admin.cond < You can also use special file names
39
+ |- postNeedRole_write.cond < to avoid using config.ts
40
+ ```
41
+
42
+ As noted in the comments, there are two particularities: code is always divided into modules, while folders beginning with an at sign are used by code generation mechanisms. Notably the `@alias` folder which allows sharing elements between modules.
43
+
44
+ ### The power of a modular application
45
+
46
+ The module organization allows clear separations between different aspects of your code, and above all it allows reusing/sharing code blocks between multiple applications, while facilitating division of work in a team. For example, one module manages the site structure, another handles authentication, and a third adds pages for the products sold.
47
+
48
+ Modules can share dependencies with other modules thanks to powerful alias mechanisms. For example a module defines a component MyComp, which becomes accessible to all modules by importing `import MyComp from @/uiBlocks/MyComp`.
49
+
50
+ Jopi's module system has the major advantage of being compatible with code pruning performed by JavasScript Bundlers, avoid common pitfalls with low-coupled code.
51
+
52
+ The module system is based on a set of mechanisms:
53
+ * **Events / listeners** — This mechanism lets modules communicate via a flexible "notify when this happens" system.
54
+ * **Composites** — This mechanism allows React components to have content enriched by modules. For example, so that a module can add content to a toolbar.
55
+ * **Sharing React.js components** — Modules can share React components, which are automatically registered in the global namespace. Also, a module can replace a shared component with its own version.
56
+
57
+ ### Server-only code, browser-only code?
58
+
59
+ To be fast, Jopi does not include code analysis and server-side code removal. However, a very useful mechanism compensates for this: whenever the token **jopiBundler_ifServer** is encountered, it is replaced by the token **jopiBundler_ifBrowser**. Thus `import * as myLib from "./jopiBundler_ifServer.ts"` becomes `import * as myLib from "./jopiBundler_ifBrowser.ts"` when Jopi creates the JavaScript for the browser.
60
+
61
+ Besides being performant, this mechanism is easier to use while offering interesting possibilities.
62
+
63
+ Internally, Jopi Rewrite uses a library called **Jopi Toolkit**. This library gathers a set of tools not specific to Jopi Rewrite and usable in independent projects. This library also uses the translation mechanism (jopiBundler_ifServer to jopiBundler_ifBrowser) so that all server code is automatically removed or replaced by a browser-specific part.
64
+
65
+ ## Cookbook
66
+
67
+ The documentation is organized as a cookbook: you want to do this, here is how.
68
+
69
+ ### Basics
70
+
71
+ [Start a new project.](_doc/basic/new_project.md)
72
+ [The 4 initialization files.](_doc/basic/init_files.md)
73
+
74
+ [Bind a page to a url.](_doc/basic/bind_page_to_url.md)
75
+ [Use parameterized urls.](_doc/basic/use_parametred_url.md)
76
+ [Use catch-all urls.](_doc/basic/use_catchall_url.md)
77
+ [Override an existing route.](_doc/basic/override_an_existing_route.md)
78
+ [The 'public' dir](_doc/basic/the_public_dir.md)
79
+
80
+ [Enable developer mode.](_doc/basic/enable_developper_mode.md)
81
+ [Enable HTTPS.](_doc/basic/enable_https.md)
82
+ [Enable CORS.](_doc/basic/use_cors_middleware.md)
83
+ [Manage trailing slashs.](_doc/basic/manage_trailing_slashs.md)
84
+
85
+ [Use a middleware.](_doc/basic/use_middleware.md)
86
+ [Use with a reverse-proxy.](_doc/basic/use_with_reverse_proxy.md)
87
+ [Use the page cache.](_doc/basic/use_page_cache.md)
88
+
89
+ [Define 401, 404 and 500 error pages](_doc/basic/define_error_pages.md)
90
+
91
+ ### React pages
92
+
93
+ [Use React Server Side.](_doc/react/what_is_react_ssr.md)
94
+ [Use Tailwind CSS.](_doc/react/use_tailwind_css.md)
95
+
96
+ [Import a CSS file.](_doc/react/import_css.md)
97
+ [Use a CSS module.](_doc/react/use_css_modules.md)
98
+ [Import an image.](_doc/react/import_image.md)
99
+
100
+ [Change the page title.](_doc/react/set_page_title.md)
101
+ [Use menus.](_doc/react/use_menus.md)
102
+
103
+ ### Using modules
104
+
105
+ [Create a module.](_doc/module/create_a_module.md)
106
+
107
+ [Share React components.](_doc/module/sharing_react_components.md)
108
+ [Replace an already shared component.](_doc/module/replace_shared_component.md)
109
+
110
+ [Use composites.](_doc/module/use_composites.md)
111
+ [Communicate between modules.](_doc/module/communicate_between_modules.md)
112
+
113
+ ### Responding to a request
114
+
115
+ [Create a JSON response](_doc/request/json_response.md)
116
+ [Create an HTML response with React](_doc/request/returns_html_with_react.md)
117
+
118
+ [Get received input data.](_doc/request/get_received_data.md)
119
+ [Handle received files.](_doc/request/manage_received_files.md)
120
+ [Validate input data.](_doc/request/check_received_data.md)
121
+ [Return files.](_doc/request/return_files.md)
122
+
123
+ ### Users and roles
124
+
125
+ [Define a user store.](_doc/users/user_data_store.md)
126
+ [Authenticate a user.](_doc/users/login_the_user.md)
127
+
128
+ [Know the user and their roles.](_doc/users/known_user_and_roles.md)
129
+ [Restrict access by roles.](_doc/users/limit_access_to_roles.md)
130
+
131
+ ### Other
132
+
133
+ [Using fetch and auto-starting server](_doc/others/use_fetch_and_autostart.md)
134
+ [Crawling a website to a flat one](_doc/others/crawling_to_flat_website.md)
package/bin/jopib.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {useEngine} from "jopijs/tool-jopinb";
4
+ useEngine("bun");
package/bin/jopin.js ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env node
2
+
3
+ import {useEngine} from "jopijs/tool-jopinb";
4
+ useEngine("node");
@@ -0,0 +1,2 @@
1
+ export declare const logBundler: import("jopi-toolkit/jk_logs").Logger;
2
+ export declare const logServer_refresh: import("jopi-toolkit/jk_logs").Logger;
@@ -0,0 +1,4 @@
1
+ import { getLogger } from "jopi-toolkit/jk_logs";
2
+ export const logBundler = getLogger("jopi.bundler");
3
+ export const logServer_refresh = getLogger("refresh", logBundler);
4
+ //# sourceMappingURL=_logs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_logs.js","sourceRoot":"","sources":["../../src/@bundler/_logs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAE/C,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC,cAAc,CAAC,CAAC;AACpD,MAAM,CAAC,MAAM,iBAAiB,GAAG,SAAS,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,34 @@
1
+ import * as jk_fs from "jopi-toolkit/jk_fs";
2
+ import * as jk_events from "jopi-toolkit/jk_events";
3
+ import { isReactHMR } from "jopijs/loader-client";
4
+ import { esBuildBundle } from "./esbuild.js";
5
+ async function createBundle(params) {
6
+ const config = params.config;
7
+ // Load the metadata generated.
8
+ const metaDataFilePath = jk_fs.join(params.genDir, "esbuildMeta.json");
9
+ process.env.JOPI_BUNLDER_ESBUILD = "1";
10
+ try {
11
+ await esBuildBundle({
12
+ metaDataFilePath,
13
+ dontEmbed: config.embed.dontEmbedThis,
14
+ ...params
15
+ });
16
+ }
17
+ finally {
18
+ delete process.env.JOPI_BUNLDER_ESBUILD;
19
+ }
20
+ }
21
+ jk_events.addListener("@jopi.bundler.createBundle", jk_events.EventPriority.veryLow, async (params) => {
22
+ // For React HMR, creating the full bundle is not required
23
+ // and will only slow down the startup.
24
+ //
25
+ if (isReactHMR())
26
+ return;
27
+ // Will compile all the pages.
28
+ await createBundle(params);
29
+ });
30
+ jk_events.addListener("@jopi.bundler.createBundleForPage", jk_events.EventPriority.veryLow, async (params) => {
31
+ // Will compile only the selected page, because of params values.
32
+ await createBundle(params);
33
+ });
34
+ //# sourceMappingURL=core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/@bundler/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAE3C,KAAK,UAAU,YAAY,CAAC,MAA0B;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAE7B,+BAA+B;IAC/B,MAAM,gBAAgB,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAEvE,OAAO,CAAC,GAAG,CAAC,oBAAoB,GAAG,GAAG,CAAC;IAEvC,IAAI,CAAC;QACD,MAAM,aAAa,CAAC;YAChB,gBAAgB;YAChB,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,aAAa;YAErC,GAAG,MAAM;SACZ,CAAC,CAAC;IACP,CAAC;YACO,CAAC;QACL,OAAO,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;IAC5C,CAAC;AACL,CAAC;AAED,SAAS,CAAC,WAAW,CAAC,4BAA4B,EAAE,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,MAA0B,EAAE,EAAE;IACtH,0DAA0D;IAC1D,uCAAuC;IACvC,EAAE;IACF,IAAI,UAAU,EAAE;QAAE,OAAO;IAEzB,8BAA8B;IAC9B,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC;AAEH,SAAS,CAAC,WAAW,CAAC,mCAAmC,EAAE,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,KAAK,EAAE,MAA0B,EAAE,EAAE;IAC7H,iEAAiE;IACjE,MAAM,YAAY,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { CreateBundleParams } from "../@core/index.ts";
2
+ export interface EsBuildParams extends CreateBundleParams {
3
+ metaDataFilePath: string;
4
+ dontEmbed: string[] | undefined;
5
+ }
6
+ export declare function esBuildBundle(params: EsBuildParams): Promise<void>;
@@ -0,0 +1,111 @@
1
+ import esbuild, {} from "esbuild";
2
+ import * as jk_fs from "jopi-toolkit/jk_fs";
3
+ import * as n_what from "jopi-toolkit/jk_what";
4
+ import { jopiReplaceText, jopiLoaderPlugin, jopiDetectRebuild } from "./plugins.js";
5
+ import { applyTailwindProcessor } from "./tailwind.js";
6
+ export async function esBuildBundle(params) {
7
+ // To know: will generate:
8
+ // * Some files out/page_xxxx.js, where each page is an "page.tsx".
9
+ // * Some files out/page_xxxx.css with the CSS specific to this page.
10
+ const buildOptions = {
11
+ entryPoints: params.entryPoints,
12
+ bundle: true,
13
+ outdir: params.outputDir,
14
+ external: params.dontEmbed,
15
+ // Allows generating relative url
16
+ // without the full website name.
17
+ //
18
+ publicPath: "/_bundle/",
19
+ platform: 'browser',
20
+ format: 'esm',
21
+ target: "es2020",
22
+ splitting: true,
23
+ plugins: [
24
+ jopiLoaderPlugin,
25
+ jopiReplaceText()
26
+ ],
27
+ loader: {
28
+ ".css": "css",
29
+ ".scss": "css",
30
+ // Polices
31
+ '.woff': 'file',
32
+ '.woff2': 'file',
33
+ '.ttf': 'file',
34
+ '.eot': 'file',
35
+ // Images
36
+ '.jpg': 'file',
37
+ '.jpeg': 'file',
38
+ '.png': 'file',
39
+ '.svg': 'file',
40
+ '.gif': 'file',
41
+ '.webp': 'file',
42
+ // Media
43
+ '.mp3': 'file',
44
+ '.mp4': 'file',
45
+ // Others
46
+ '.html': 'text',
47
+ '.md': 'text'
48
+ },
49
+ minify: true,
50
+ //minify: false,
51
+ sourcemap: true,
52
+ // Will trigger an error on collision detection.
53
+ allowOverwrite: false,
54
+ // Produce metadata about the build.
55
+ metafile: true
56
+ };
57
+ // Note: each page is compiled one time.
58
+ // Once compiled, the watch mode will refresh it.
59
+ //
60
+ if (params.singlePageMode) {
61
+ buildOptions.publicPath += params.pageKey + '/';
62
+ buildOptions.entryPoints = [params.pageScript];
63
+ buildOptions.outdir = jk_fs.join(buildOptions.outdir, params.pageKey);
64
+ buildOptions.plugins?.push(jopiDetectRebuild(params));
65
+ }
66
+ await applyTailwindProcessor(params);
67
+ const context = await esbuild.context(buildOptions);
68
+ let result = await context.rebuild();
69
+ if (params.singlePageMode) {
70
+ try {
71
+ // Will allows the page to be automatically updated.
72
+ await context.watch({
73
+ delay: n_what.isNodeJS ? 100 : 0
74
+ });
75
+ }
76
+ catch {
77
+ process.exit(1);
78
+ }
79
+ }
80
+ // >>> Resolve virtual urls
81
+ // The url is formed before the bundle is done.
82
+ // It's why we don't know the final url of the resource
83
+ // which is a processed and transformed resource, especially
84
+ // for CSS files, which content is resolving his dependencies.
85
+ if (params.virtualUrlMap) {
86
+ const allMeta = result.metafile;
87
+ if (allMeta.outputs) {
88
+ for (const outputFilePath in allMeta.outputs) {
89
+ const ext = jk_fs.extname(outputFilePath);
90
+ if ([".js", ".ts", ".tsx", ".jsx", ".mjs", ".cjs"].includes(ext))
91
+ continue;
92
+ const metaValue = allMeta.outputs[outputFilePath];
93
+ if (metaValue.inputs) {
94
+ const inputs = metaValue.inputs;
95
+ for (let inputFilePath of Object.keys(inputs)) {
96
+ const key = jk_fs.resolve(inputFilePath);
97
+ const entry = params.virtualUrlMap.find(e => e.sourceFile === key);
98
+ // Don't override if already set because the next
99
+ // entry can be a resource using our entry, so it
100
+ // will be overridden.
101
+ //
102
+ if (entry && !entry.bundleFile) {
103
+ entry.bundleFile = jk_fs.resolve(outputFilePath);
104
+ }
105
+ }
106
+ }
107
+ }
108
+ }
109
+ }
110
+ }
111
+ //# sourceMappingURL=esbuild.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esbuild.js","sourceRoot":"","sources":["../../src/@bundler/esbuild.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAkB,MAAM,SAAS,CAAC;AAClD,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAC,eAAe,EAAE,gBAAgB,EAAE,iBAAiB,EAAC,MAAM,cAAc,CAAC;AAClF,OAAO,EAAC,sBAAsB,EAAC,MAAM,eAAe,CAAC;AAOrD,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,MAAqB;IACrD,0BAA0B;IAC1B,mEAAmE;IACnE,qEAAqE;IAErE,MAAM,YAAY,GAAyB;QACvC,WAAW,EAAE,MAAM,CAAC,WAAW;QAE/B,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,MAAM,CAAC,SAAS;QACxB,QAAQ,EAAG,MAAM,CAAC,SAAS;QAE3B,iCAAiC;QACjC,iCAAiC;QACjC,EAAE;QACF,UAAU,EAAE,WAAW;QAEvB,QAAQ,EAAE,SAAS;QACnB,MAAM,EAAE,KAAK;QACb,MAAM,EAAE,QAAQ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C,UAAU,KAAK,GAAG,CAAC,CAAC;wBAEnE,iDAAiD;wBACjD,iDAAiD;wBACjD,sBAAsB;wBACtB,EAAE;wBACF,IAAI,KAAK,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;4BAC7B,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;wBACrD,CAAC;oBACL,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;IACL,CAAC;AACL,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { getGlobalCssFileContent } from "./tailwind.ts";
2
+ import "./core.ts";
@@ -0,0 +1,3 @@
1
+ export { getGlobalCssFileContent } from "./tailwind.js";
2
+ import "./core.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/@bundler/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,uBAAuB,EAAC,MAAM,eAAe,CAAC;AAEtD,OAAO,WAAW,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { type Plugin } from "esbuild";
2
+ import type { EsBuildParams } from "./esbuild.ts";
3
+ /**
4
+ * This plugin allows replacing some text entries according to rules.
5
+ */
6
+ export declare function jopiReplaceText(): Plugin;
7
+ export declare function jopiDetectRebuild(params: EsBuildParams): Plugin;
8
+ /**
9
+ * Allows managing custom import:
10
+ * * Importing CSS modules (.module.css)
11
+ * * Import with ?raw and ?inline
12
+ */
13
+ export declare const jopiLoaderPlugin: Plugin;
@@ -0,0 +1,145 @@
1
+ import {} from "esbuild";
2
+ import fs from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { applyTailwindProcessor } from "./tailwind.js";
5
+ import * as jk_events from "jopi-toolkit/jk_events";
6
+ import { installEsBuildPlugins } from "jopijs/loader-tools";
7
+ import MagicString from 'magic-string';
8
+ import { SourceMapConsumer, SourceMapGenerator } from "source-map";
9
+ import { logServer_refresh } from "./_logs.js";
10
+ /**
11
+ * This plugin allows replacing some text entries according to rules.
12
+ */
13
+ export function jopiReplaceText() {
14
+ async function getExistingSourceMap(filePath, source) {
15
+ const sourceMapCommentMatch = source.match(/\/\/# sourceMappingURL=(.+)$/m);
16
+ if (!sourceMapCommentMatch)
17
+ return null;
18
+ const sourceMapUrl = sourceMapCommentMatch[1];
19
+ if (sourceMapUrl.startsWith('data:application/json;base64,')) {
20
+ const base64Content = sourceMapUrl.replace('data:application/json;base64,', '');
21
+ return Buffer.from(base64Content, 'base64').toString('utf8');
22
+ }
23
+ else {
24
+ const sourceMapPath = path.resolve(path.dirname(filePath), sourceMapUrl);
25
+ try {
26
+ return await fs.readFile(sourceMapPath, 'utf8');
27
+ }
28
+ catch {
29
+ return null;
30
+ }
31
+ }
32
+ }
33
+ return {
34
+ name: "jopi-replace-text",
35
+ setup(build) {
36
+ build.onLoad({ filter: /\.(tsx|jsx|js)$/ }, async (args) => {
37
+ const oldContent = await fs.readFile(args.path, 'utf8');
38
+ let newContent = oldContent.replace("jBundler_ifServer", "jBundler_ifBrowser");
39
+ if (newContent === oldContent)
40
+ return undefined;
41
+ const useSourceMap = !!build.initialOptions.sourcemap;
42
+ if (!useSourceMap) {
43
+ let loader = path.extname(args.path).toLowerCase().substring(1);
44
+ return { contents: newContent, loader: loader };
45
+ }
46
+ const existingSourceMap = await getExistingSourceMap(args.path, oldContent);
47
+ const magic = new MagicString(oldContent, { filename: args.path });
48
+ magic.replace("jBundler_ifServer", "jBundler_ifBrowser");
49
+ const map = magic.generateMap({
50
+ file: args.path,
51
+ source: path.basename(args.path),
52
+ includeContent: true,
53
+ hires: true
54
+ });
55
+ let finalMap;
56
+ // Will merge the existing and final source-map.
57
+ //
58
+ if (existingSourceMap) {
59
+ const consumerExisting = await new SourceMapConsumer(existingSourceMap);
60
+ const generator = SourceMapGenerator.fromSourceMap(consumerExisting);
61
+ const consumerNew = await new SourceMapConsumer(JSON.parse(map.toString()));
62
+ consumerNew.eachMapping((mapping) => {
63
+ if (mapping.originalLine != null && mapping.originalColumn != null) {
64
+ generator.addMapping({
65
+ source: mapping.source || path.basename(args.path),
66
+ original: { line: mapping.originalLine, column: mapping.originalColumn },
67
+ generated: { line: mapping.generatedLine, column: mapping.generatedColumn },
68
+ name: mapping.name,
69
+ });
70
+ }
71
+ });
72
+ consumerNew.sources.forEach((source) => {
73
+ const content = consumerNew.sourceContentFor(source, true);
74
+ if (content) {
75
+ generator.setSourceContent(source, content);
76
+ }
77
+ });
78
+ finalMap = JSON.stringify(generator.toJSON());
79
+ consumerNew.destroy();
80
+ consumerExisting.destroy();
81
+ }
82
+ else {
83
+ finalMap = map.toString();
84
+ }
85
+ newContent = magic.toString() +
86
+ `\n//# sourceMappingURL=data:application/json;base64,${Buffer.from(finalMap).toString('base64')}`;
87
+ let loader = path.extname(args.path).toLowerCase().substring(1);
88
+ return { contents: newContent, loader: loader };
89
+ });
90
+ }
91
+ };
92
+ }
93
+ export function jopiDetectRebuild(params) {
94
+ // Allow avoiding behaviors with TypeScript compiler doing some late works.
95
+ //
96
+ let isEnabled = false;
97
+ setTimeout(() => { isEnabled = true; }, 2000);
98
+ return {
99
+ name: "jopi-detect-rebuild",
100
+ setup(build) {
101
+ build.onStart(async () => {
102
+ // isEnabled is automatically set to true after 2 seconds.
103
+ // It allows avoiding some behaviors with false calls from EsBuild.
104
+ // (probably caused by the dev-tools, including TypeScript compiler)
105
+ //
106
+ if (!isEnabled)
107
+ return;
108
+ if (params.singlePageMode) {
109
+ logServer_refresh.info("Refreshing page " + params.pageRoute);
110
+ }
111
+ // Rebuild Tailwind.
112
+ // - Single page mode: rebuild only the local tailwind.
113
+ // - Global mode: never occurs.
114
+ //
115
+ if (params.requireTailwind) {
116
+ await applyTailwindProcessor(params);
117
+ }
118
+ if (params.singlePageMode) {
119
+ // This event will execute Jopi Linker.
120
+ await jk_events.sendAsyncEvent("@jopi.bundler.watch.beforeRebuild");
121
+ }
122
+ });
123
+ build.onEnd(async () => {
124
+ if (!isEnabled)
125
+ return;
126
+ if (params.singlePageMode) {
127
+ // This event will execute trigger the SSE event that refreshes the browser.
128
+ await jk_events.sendAsyncEvent("@jopi.bundler.watch.afterRebuild");
129
+ }
130
+ });
131
+ }
132
+ };
133
+ }
134
+ /**
135
+ * Allows managing custom import:
136
+ * * Importing CSS modules (.module.css)
137
+ * * Import with ?raw and ?inline
138
+ */
139
+ export const jopiLoaderPlugin = {
140
+ name: "jopi-loader",
141
+ setup(build) {
142
+ installEsBuildPlugins(build);
143
+ },
144
+ };
145
+ //# sourceMappingURL=plugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../src/@bundler/plugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAC,sBAAsB,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,KAAK,SAAS,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAC,qBAAqB,EAAC,MAAM,qBAAqB,CAAC;AAC1D,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,EAAC,iBAAiB,EAAE,kBAAkB,EAAC,MAAM,YAAY,CAAC;AACjE,OAAO,EAAC,iBAAiB,EAAC,MAAM,YAAY,CAAC;AAE7C;;GAEG;AACH,MAAM,UAAU,eAAe;IAC3B,KAAK,UAAU,oBAAoB,CAAC,QAAgB,EAAE,MAAc;QAChE,MAAM,qBAAqB,GAAG,MAAM,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAC5E,IAAI,CAAC,qBAAqB;YAAE,OAAO,IAAI,CAAC;QAExC,MAAM,YAAY,GAAG,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAE9C,IAAI,YAAY,CAAC,UAAU,CAAC,+BAA+B,CAAC,EAAE,CAAC;YAC3D,MAAM,aAAa,GAAG,YAAY,CAAC,OAAO,CAAC,+BAA+B,EAAE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CAAC;IAE7C,OAAO;QACH,IAAI,EAAE,qBAAqB;QAE3B,KAAK,CAAC,KAAK;YACP,KAAK,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE;gBACrB,0DAA0D;gBAC1D,mEAAmE;gBACnE,oEAAoE;gBACpE,EAAE;gBACF,IAAI,CAAC,SAAS;oBAAE,OAAO;gBAEvB,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;oBACxB,iBAAiB,CAAC,IAAI,CAAC,kBAAkB,GAAG,MAAM,CAAC,SAAS,CAAC,CAAC;gBAClE,CAAC;gBAED,oBAAoB;gBACpB,uDAAuD;gBACvD,+BAA+B;gBAC/B,EAAE;gBACF,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;oBACzB,MAAM,sBAAsB,CAAC,MAAM,CAAC,CAAC;gBACzC,CAAC;gBAED,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;oBACxB,uCAAuC;oBACvC,MAAM,SAAS,CAAC,cAAc,CAAC,mCAAmC,CAAC,CAAC;gBACxE,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,KAAK,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE;gBACnB,IAAI,CAAC,SAAS;oBAAE,OAAO;gBAEvB,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;oBACxB,4EAA4E;oBAC5E,MAAM,SAAS,CAAC,cAAc,CAAC,kCAAkC,CAAC,CAAC;gBACvE,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC;KACJ,CAAA;AACL,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAW;IACpC,IAAI,EAAE,aAAa;IACnB,KAAK,CAAC,KAAK;QACP,qBAAqB,CAAC,KAAqC,CAAC,CAAA;IAChE,CAAC;CACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { BundlerConfig, CreateBundleParams } from "jopijs";
2
+ export declare function applyTailwindProcessor(params: CreateBundleParams): Promise<void>;
3
+ export declare function getGlobalCssFileContent(config: BundlerConfig): Promise<string>;
@@ -0,0 +1,119 @@
1
+ import * as jk_app from "jopi-toolkit/jk_app";
2
+ import * as jk_fs from "jopi-toolkit/jk_fs";
3
+ import path from "node:path";
4
+ import fs from "node:fs/promises";
5
+ import postcss from "postcss";
6
+ import tailwindPostcss from "@tailwindcss/postcss";
7
+ export async function applyTailwindProcessor(params) {
8
+ function append(text) {
9
+ return fs.appendFile(outFilePath, "\n" + text + "\n", "utf-8");
10
+ }
11
+ let sourceFiles = params.entryPoints;
12
+ let genDir = params.genDir;
13
+ // >>> Tailwind transform
14
+ if (params.singlePageMode) {
15
+ genDir = jk_fs.join(genDir, params.pageKey);
16
+ sourceFiles = [genDir + ".jsx"];
17
+ }
18
+ const outFilePath = path.resolve(genDir, "tailwind.css");
19
+ if (await jk_fs.isFile(outFilePath)) {
20
+ await jk_fs.unlink(outFilePath);
21
+ }
22
+ // Assure the file exists.
23
+ await jk_fs.writeTextToFile(outFilePath, "");
24
+ let postCss = await applyPostCss(params, sourceFiles);
25
+ if (postCss)
26
+ await append(postCss);
27
+ }
28
+ /**
29
+ * Generate Tailwind CSS file a list of source files and returns the CSS or undefined.
30
+ */
31
+ async function applyPostCss(params, sourceFiles) {
32
+ if (!sourceFiles.length)
33
+ return "";
34
+ const bundlerConfig = params.config;
35
+ let plugins = [];
36
+ let config = bundlerConfig.tailwind.config || {};
37
+ if (!config.content)
38
+ config.content = sourceFiles;
39
+ else
40
+ config.content = [...sourceFiles, ...config.content];
41
+ if (bundlerConfig.tailwind.extraSourceFiles) {
42
+ if (!config.content)
43
+ config.content = [];
44
+ config.content = [...config.content, ...bundlerConfig.tailwind.extraSourceFiles];
45
+ }
46
+ let tailwindPlugin = bundlerConfig.tailwind.disable ? undefined : tailwindPostcss({ config });
47
+ if (bundlerConfig.postCss.initializer) {
48
+ plugins = bundlerConfig.postCss.initializer(sourceFiles, tailwindPlugin);
49
+ }
50
+ else if (tailwindPlugin) {
51
+ plugins = [tailwindPlugin];
52
+ }
53
+ else {
54
+ return undefined;
55
+ }
56
+ if (!plugins.length)
57
+ return undefined;
58
+ let globalCssContent = await getGlobalCssFileContent(bundlerConfig);
59
+ try {
60
+ const processor = postcss(plugins);
61
+ const result = await processor.process(globalCssContent, {
62
+ // Setting 'from' allows resolving correctly the node_modules resolving.
63
+ from: params.outputDir
64
+ });
65
+ return result.css;
66
+ }
67
+ catch (e) {
68
+ console.error("Error while compiling for Tailwind:", e);
69
+ return undefined;
70
+ }
71
+ }
72
+ export async function getGlobalCssFileContent(config) {
73
+ if (config.tailwind.globalCssContent) {
74
+ return config.tailwind.globalCssContent;
75
+ }
76
+ if (config.tailwind.globalCssFilePath) {
77
+ if (!await jk_fs.isFile(config.tailwind.globalCssFilePath)) {
78
+ throw new Error(`Tailwind - File not found where resolving 'global.css': ${config.tailwind.globalCssFilePath}`);
79
+ }
80
+ return jk_fs.readTextFromFile(config.tailwind.globalCssFilePath);
81
+ }
82
+ let found = await getTailwindTemplateFromShadCnConfig();
83
+ if (found)
84
+ return found;
85
+ let rootDir = jk_fs.dirname(jk_app.findPackageJson());
86
+ if (await jk_fs.isFile(jk_fs.join(rootDir, "global.css"))) {
87
+ return jk_fs.readTextFromFile(jk_fs.join(rootDir, "global.css"));
88
+ }
89
+ return `@import "tailwindcss";`;
90
+ }
91
+ /**
92
+ * Get Tailwind template CSS file from Shadcn config file (components.json).
93
+ * See: https://ui.shadcn.com/docs/components-json
94
+ */
95
+ async function getTailwindTemplateFromShadCnConfig() {
96
+ const pkgJsonPath = jk_app.findPackageJson();
97
+ if (!pkgJsonPath)
98
+ return undefined;
99
+ let filePath = path.join(path.dirname(pkgJsonPath), "components.json");
100
+ if (!await jk_fs.isFile(filePath))
101
+ return undefined;
102
+ try {
103
+ let asText = jk_fs.readTextFromFileSync(filePath);
104
+ let asJSON = JSON.parse(asText);
105
+ let tailwindConfig = asJSON.tailwind;
106
+ if (!tailwindConfig)
107
+ return undefined;
108
+ let tailwindCssTemplate = tailwindConfig.css;
109
+ if (!tailwindCssTemplate)
110
+ return undefined;
111
+ let fullPath = path.resolve(path.dirname(pkgJsonPath), tailwindCssTemplate);
112
+ return jk_fs.readTextFromFileSync(fullPath);
113
+ }
114
+ catch (e) {
115
+ console.error("Error reading Shadcn config file:", e);
116
+ return undefined;
117
+ }
118
+ }
119
+ //# sourceMappingURL=tailwind.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind.js","sourceRoot":"","sources":["../../src/@bundler/tailwind.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,qBAAqB,CAAC;AAC9C,OAAO,KAAK,KAAK,MAAM,oBAAoB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,eAAe,MAAM,sBAAsB,CAAC;AAEnD,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,MAA0B;IACnE,SAAS,MAAM,CAAC,IAAY;QACxB,OAAO,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;IAED,IAAI,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IACrC,IAAI,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;IAE3B,yBAAyB;IAEzB,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;QACxB,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,OAAQ,CAAC,CAAC;QAC7C,WAAW,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACpC,CAAC;IAED,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAEzD,IAAI,MAAM,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;QAClC,MAAM,KAAK,CAAC,MAAM,CA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