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.
- package/README.md +134 -0
- package/bin/jopib.js +4 -0
- package/bin/jopin.js +4 -0
- package/dist/@bundler/_logs.d.ts +2 -0
- package/dist/@bundler/_logs.js +4 -0
- package/dist/@bundler/_logs.js.map +1 -0
- package/dist/@bundler/core.d.ts +1 -0
- package/dist/@bundler/core.js +34 -0
- package/dist/@bundler/core.js.map +1 -0
- package/dist/@bundler/esbuild.d.ts +6 -0
- package/dist/@bundler/esbuild.js +111 -0
- package/dist/@bundler/esbuild.js.map +1 -0
- package/dist/@bundler/index.d.ts +2 -0
- package/dist/@bundler/index.js +3 -0
- package/dist/@bundler/index.js.map +1 -0
- package/dist/@bundler/plugins.d.ts +13 -0
- package/dist/@bundler/plugins.js +145 -0
- package/dist/@bundler/plugins.js.map +1 -0
- package/dist/@bundler/tailwind.d.ts +3 -0
- package/dist/@bundler/tailwind.js +119 -0
- package/dist/@bundler/tailwind.js.map +1 -0
- package/dist/@core/PageComponent.d.ts +6 -0
- package/dist/@core/PageComponent.js +10 -0
- package/dist/@core/PageComponent.js.map +1 -0
- package/dist/@core/_logs.d.ts +7 -0
- package/dist/@core/_logs.js +9 -0
- package/dist/@core/_logs.js.map +1 -0
- package/dist/@core/automaticStartStop.d.ts +25 -0
- package/dist/@core/automaticStartStop.js +106 -0
- package/dist/@core/automaticStartStop.js.map +1 -0
- package/dist/@core/browserCacheControl.d.ts +21 -0
- package/dist/@core/browserCacheControl.js +17 -0
- package/dist/@core/browserCacheControl.js.map +1 -0
- package/dist/@core/bundler/bundler.d.ts +22 -0
- package/dist/@core/bundler/bundler.js +90 -0
- package/dist/@core/bundler/bundler.js.map +1 -0
- package/dist/@core/bundler/common.d.ts +2 -0
- package/dist/@core/bundler/common.js +17 -0
- package/dist/@core/bundler/common.js.map +1 -0
- package/dist/@core/bundler/config.d.ts +20 -0
- package/dist/@core/bundler/config.js +11 -0
- package/dist/@core/bundler/config.js.map +1 -0
- package/dist/@core/bundler/extraContent.d.ts +6 -0
- package/dist/@core/bundler/extraContent.js +27 -0
- package/dist/@core/bundler/extraContent.js.map +1 -0
- package/dist/@core/bundler/pagesGenerator.d.ts +1 -0
- package/dist/@core/bundler/pagesGenerator.js +173 -0
- package/dist/@core/bundler/pagesGenerator.js.map +1 -0
- package/dist/@core/bundler/server.d.ts +8 -0
- package/dist/@core/bundler/server.js +35 -0
- package/dist/@core/bundler/server.js.map +1 -0
- package/dist/@core/caches/InMemoryCache.d.ts +35 -0
- package/dist/@core/caches/InMemoryCache.js +353 -0
- package/dist/@core/caches/InMemoryCache.js.map +1 -0
- package/dist/@core/caches/SimpleFileCache.d.ts +18 -0
- package/dist/@core/caches/SimpleFileCache.js +171 -0
- package/dist/@core/caches/SimpleFileCache.js.map +1 -0
- package/dist/@core/caches/cache.d.ts +36 -0
- package/dist/@core/caches/cache.js +33 -0
- package/dist/@core/caches/cache.js.map +1 -0
- package/dist/@core/caches/webSiteMirrorCache.d.ts +16 -0
- package/dist/@core/caches/webSiteMirrorCache.js +81 -0
- package/dist/@core/caches/webSiteMirrorCache.js.map +1 -0
- package/dist/@core/gzip.d.ts +4 -0
- package/dist/@core/gzip.js +31 -0
- package/dist/@core/gzip.js.map +1 -0
- package/dist/@core/index.d.ts +18 -0
- package/dist/@core/index.js +19 -0
- package/dist/@core/index.js.map +1 -0
- package/dist/@core/internalTools.d.ts +14 -0
- package/dist/@core/internalTools.js +79 -0
- package/dist/@core/internalTools.js.map +1 -0
- package/dist/@core/jQuery.d.ts +5 -0
- package/dist/@core/jQuery.js +18 -0
- package/dist/@core/jQuery.js.map +1 -0
- package/dist/@core/jopiEasy.d.ts +287 -0
- package/dist/@core/jopiEasy.js +983 -0
- package/dist/@core/jopiEasy.js.map +1 -0
- package/dist/@core/jopiRequest.d.ts +269 -0
- package/dist/@core/jopiRequest.js +1060 -0
- package/dist/@core/jopiRequest.js.map +1 -0
- package/dist/@core/jopiServer.d.ts +77 -0
- package/dist/@core/jopiServer.js +100 -0
- package/dist/@core/jopiServer.js.map +1 -0
- package/dist/@core/jopiWebSite.d.ts +319 -0
- package/dist/@core/jopiWebSite.js +653 -0
- package/dist/@core/jopiWebSite.js.map +1 -0
- package/dist/@core/letsEncrypt.d.ts +25 -0
- package/dist/@core/letsEncrypt.js +189 -0
- package/dist/@core/letsEncrypt.js.map +1 -0
- package/dist/@core/linker.d.ts +4 -0
- package/dist/@core/linker.js +37 -0
- package/dist/@core/linker.js.map +1 -0
- package/dist/@core/loadBalancing.d.ts +18 -0
- package/dist/@core/loadBalancing.js +126 -0
- package/dist/@core/loadBalancing.js.map +1 -0
- package/dist/@core/middlewares/CorsMiddleware.d.ts +5 -0
- package/dist/@core/middlewares/CorsMiddleware.js +15 -0
- package/dist/@core/middlewares/CorsMiddleware.js.map +1 -0
- package/dist/@core/middlewares/DdosProtection.d.ts +42 -0
- package/dist/@core/middlewares/DdosProtection.js +62 -0
- package/dist/@core/middlewares/DdosProtection.js.map +1 -0
- package/dist/@core/middlewares/index.d.ts +10 -0
- package/dist/@core/middlewares/index.js +14 -0
- package/dist/@core/middlewares/index.js.map +1 -0
- package/dist/@core/publicTools.d.ts +8 -0
- package/dist/@core/publicTools.js +11 -0
- package/dist/@core/publicTools.js.map +1 -0
- package/dist/@core/routeConfig.d.ts +48 -0
- package/dist/@core/routeConfig.js +102 -0
- package/dist/@core/routeConfig.js.map +1 -0
- package/dist/@core/searchParamFilter.d.ts +70 -0
- package/dist/@core/searchParamFilter.js +212 -0
- package/dist/@core/searchParamFilter.js.map +1 -0
- package/dist/@core/serverFetch.d.ts +122 -0
- package/dist/@core/serverFetch.js +312 -0
- package/dist/@core/serverFetch.js.map +1 -0
- package/dist/@core/serverImpl/server_bunjs.d.ts +29 -0
- package/dist/@core/serverImpl/server_bunjs.js +180 -0
- package/dist/@core/serverImpl/server_bunjs.js.map +1 -0
- package/dist/@core/serverImpl/server_nodejs.d.ts +22 -0
- package/dist/@core/serverImpl/server_nodejs.js +235 -0
- package/dist/@core/serverImpl/server_nodejs.js.map +1 -0
- package/dist/@core/serverInstanceBuilder.d.ts +17 -0
- package/dist/@core/serverInstanceBuilder.js +14 -0
- package/dist/@core/serverInstanceBuilder.js.map +1 -0
- package/dist/@core/userStores.d.ts +13 -0
- package/dist/@core/userStores.js +20 -0
- package/dist/@core/userStores.js.map +1 -0
- package/dist/@crawler/common.d.ts +203 -0
- package/dist/@crawler/common.js +68 -0
- package/dist/@crawler/common.js.map +1 -0
- package/dist/@crawler/core.d.ts +87 -0
- package/dist/@crawler/core.js +586 -0
- package/dist/@crawler/core.js.map +1 -0
- package/dist/@crawler/directFileCache.d.ts +10 -0
- package/dist/@crawler/directFileCache.js +60 -0
- package/dist/@crawler/directFileCache.js.map +1 -0
- package/dist/@crawler/index.d.ts +4 -0
- package/dist/@crawler/index.js +5 -0
- package/dist/@crawler/index.js.map +1 -0
- package/dist/@crawler/urlMapping.d.ts +21 -0
- package/dist/@crawler/urlMapping.js +52 -0
- package/dist/@crawler/urlMapping.js.map +1 -0
- package/dist/@crawler/utils.d.ts +6 -0
- package/dist/@crawler/utils.js +13 -0
- package/dist/@crawler/utils.js.map +1 -0
- package/dist/@generated/index.d.ts +29 -0
- package/dist/@generated/index.js +93 -0
- package/dist/@generated/index.js.map +1 -0
- package/dist/@linker/arobaseTypes.d.ts +50 -0
- package/dist/@linker/arobaseTypes.js +235 -0
- package/dist/@linker/arobaseTypes.js.map +1 -0
- package/dist/@linker/changeProof.d.ts +5 -0
- package/dist/@linker/changeProof.js +50 -0
- package/dist/@linker/changeProof.js.map +1 -0
- package/dist/@linker/config.d.ts +2 -0
- package/dist/@linker/config.js +40 -0
- package/dist/@linker/config.js.map +1 -0
- package/dist/@linker/engine.d.ts +156 -0
- package/dist/@linker/engine.js +665 -0
- package/dist/@linker/engine.js.map +1 -0
- package/dist/@linker/index.d.ts +3 -0
- package/dist/@linker/index.js +4 -0
- package/dist/@linker/index.js.map +1 -0
- package/dist/@linker/install.d.ts +4 -0
- package/dist/@linker/install.js +42 -0
- package/dist/@linker/install.js.map +1 -0
- package/dist/@linker/modInstaller.d.ts +10 -0
- package/dist/@linker/modInstaller.js +38 -0
- package/dist/@linker/modInstaller.js.map +1 -0
- package/dist/@linker/typeEvents.d.ts +9 -0
- package/dist/@linker/typeEvents.js +48 -0
- package/dist/@linker/typeEvents.js.map +1 -0
- package/dist/@linker/typeRoutes.d.ts +23 -0
- package/dist/@linker/typeRoutes.js +197 -0
- package/dist/@linker/typeRoutes.js.map +1 -0
- package/dist/@linker/typeUiComposite.d.ts +6 -0
- package/dist/@linker/typeUiComposite.js +16 -0
- package/dist/@linker/typeUiComposite.js.map +1 -0
- package/dist/@loader/index.d.ts +1 -0
- package/dist/@loader/index.js +17 -0
- package/dist/@loader/index.js.map +1 -0
- package/dist/@loader/nodeJsLoader.d.ts +2 -0
- package/dist/@loader/nodeJsLoader.js +19 -0
- package/dist/@loader/nodeJsLoader.js.map +1 -0
- package/dist/@loader-client/index.d.ts +33 -0
- package/dist/@loader-client/index.js +98 -0
- package/dist/@loader-client/index.js.map +1 -0
- package/dist/@loader-tools/bunJsLoader.d.ts +1 -0
- package/dist/@loader-tools/bunJsLoader.js +28 -0
- package/dist/@loader-tools/bunJsLoader.js.map +1 -0
- package/dist/@loader-tools/config.d.ts +49 -0
- package/dist/@loader-tools/config.js +79 -0
- package/dist/@loader-tools/config.js.map +1 -0
- package/dist/@loader-tools/cssModuleCompiler.d.ts +5 -0
- package/dist/@loader-tools/cssModuleCompiler.js +65 -0
- package/dist/@loader-tools/cssModuleCompiler.js.map +1 -0
- package/dist/@loader-tools/esBuildPlugin.d.ts +5 -0
- package/dist/@loader-tools/esBuildPlugin.js +113 -0
- package/dist/@loader-tools/esBuildPlugin.js.map +1 -0
- package/dist/@loader-tools/index.d.ts +9 -0
- package/dist/@loader-tools/index.js +10 -0
- package/dist/@loader-tools/index.js.map +1 -0
- package/dist/@loader-tools/jopin.d.ts +10 -0
- package/dist/@loader-tools/jopin.js +331 -0
- package/dist/@loader-tools/jopin.js.map +1 -0
- package/dist/@loader-tools/nodeJsLoader.d.ts +13 -0
- package/dist/@loader-tools/nodeJsLoader.js +101 -0
- package/dist/@loader-tools/nodeJsLoader.js.map +1 -0
- package/dist/@loader-tools/nodeJsResolver.d.ts +2 -0
- package/dist/@loader-tools/nodeJsResolver.js +117 -0
- package/dist/@loader-tools/nodeJsResolver.js.map +1 -0
- package/dist/@loader-tools/rules.d.ts +3 -0
- package/dist/@loader-tools/rules.js +33 -0
- package/dist/@loader-tools/rules.js.map +1 -0
- package/dist/@loader-tools/sourceChangesWatcher.d.ts +39 -0
- package/dist/@loader-tools/sourceChangesWatcher.js +182 -0
- package/dist/@loader-tools/sourceChangesWatcher.js.map +1 -0
- package/dist/@loader-tools/tools.d.ts +21 -0
- package/dist/@loader-tools/tools.js +113 -0
- package/dist/@loader-tools/tools.js.map +1 -0
- package/dist/@loader-tools/transform.d.ts +5 -0
- package/dist/@loader-tools/transform.js +114 -0
- package/dist/@loader-tools/transform.js.map +1 -0
- package/dist/@loader-tools/virtualUrl.d.ts +9 -0
- package/dist/@loader-tools/virtualUrl.js +40 -0
- package/dist/@loader-tools/virtualUrl.js.map +1 -0
- package/dist/@tool-jopinb/index.d.ts +1 -0
- package/dist/@tool-jopinb/index.js +9 -0
- package/dist/@tool-jopinb/index.js.map +1 -0
- package/dist/@ui/components.d.ts +27 -0
- package/dist/@ui/components.js +42 -0
- package/dist/@ui/components.js.map +1 -0
- package/dist/@ui/cssModules.d.ts +11 -0
- package/dist/@ui/cssModules.js +17 -0
- package/dist/@ui/cssModules.js.map +1 -0
- package/dist/@ui/hooks.d.ts +31 -0
- package/dist/@ui/hooks.js +71 -0
- package/dist/@ui/hooks.js.map +1 -0
- package/dist/@ui/index.d.ts +9 -0
- package/dist/@ui/index.js +11 -0
- package/dist/@ui/index.js.map +1 -0
- package/dist/@ui/internal.d.ts +4 -0
- package/dist/@ui/internal.js +10 -0
- package/dist/@ui/internal.js.map +1 -0
- package/dist/@ui/modules.d.ts +41 -0
- package/dist/@ui/modules.js +74 -0
- package/dist/@ui/modules.js.map +1 -0
- package/dist/@ui/objectRegistry.d.ts +12 -0
- package/dist/@ui/objectRegistry.js +35 -0
- package/dist/@ui/objectRegistry.js.map +1 -0
- package/dist/@ui/pageController.d.ts +61 -0
- package/dist/@ui/pageController.js +166 -0
- package/dist/@ui/pageController.js.map +1 -0
- package/dist/@ui/tools.d.ts +24 -0
- package/dist/@ui/tools.js +78 -0
- package/dist/@ui/tools.js.map +1 -0
- package/dist/@uikit/core/UiKitModule.d.ts +6 -0
- package/dist/@uikit/core/UiKitModule.js +18 -0
- package/dist/@uikit/core/UiKitModule.js.map +1 -0
- package/dist/@uikit/core/index.d.ts +1 -0
- package/dist/@uikit/core/index.js +4 -0
- package/dist/@uikit/core/index.js.map +1 -0
- package/dist/@uikit/core/jBundler_ifBrowser.d.ts +1 -0
- package/dist/@uikit/core/jBundler_ifBrowser.js +5 -0
- package/dist/@uikit/core/jBundler_ifBrowser.js.map +1 -0
- package/dist/@uikit/core/jBundler_ifServer.d.ts +6 -0
- package/dist/@uikit/core/jBundler_ifServer.js +17 -0
- package/dist/@uikit/core/jBundler_ifServer.js.map +1 -0
- package/dist/@uikit/forms/components.d.ts +18 -0
- package/dist/@uikit/forms/components.js +69 -0
- package/dist/@uikit/forms/components.js.map +1 -0
- package/dist/@uikit/forms/hooks.d.ts +4 -0
- package/dist/@uikit/forms/hooks.js +31 -0
- package/dist/@uikit/forms/hooks.js.map +1 -0
- package/dist/@uikit/forms/index.d.ts +3 -0
- package/dist/@uikit/forms/index.js +4 -0
- package/dist/@uikit/forms/index.js.map +1 -0
- package/dist/@uikit/forms/interfaces.d.ts +101 -0
- package/dist/@uikit/forms/interfaces.js +4 -0
- package/dist/@uikit/forms/interfaces.js.map +1 -0
- package/dist/@uikit/forms/private.d.ts +40 -0
- package/dist/@uikit/forms/private.js +307 -0
- package/dist/@uikit/forms/private.js.map +1 -0
- package/dist/@uikit/helpers/hooks.d.ts +33 -0
- package/dist/@uikit/helpers/hooks.js +107 -0
- package/dist/@uikit/helpers/hooks.js.map +1 -0
- package/dist/@uikit/helpers/index.d.ts +2 -0
- package/dist/@uikit/helpers/index.js +3 -0
- package/dist/@uikit/helpers/index.js.map +1 -0
- package/dist/@uikit/helpers/tools.d.ts +8 -0
- package/dist/@uikit/helpers/tools.js +35 -0
- package/dist/@uikit/helpers/tools.js.map +1 -0
- package/dist/@uikit/index.d.ts +10 -0
- package/dist/@uikit/index.js +13 -0
- package/dist/@uikit/index.js.map +1 -0
- package/dist/@uikit/menu/core.d.ts +21 -0
- package/dist/@uikit/menu/core.js +191 -0
- package/dist/@uikit/menu/core.js.map +1 -0
- package/dist/@uikit/menu/hooks.d.ts +5 -0
- package/dist/@uikit/menu/hooks.js +24 -0
- package/dist/@uikit/menu/hooks.js.map +1 -0
- package/dist/@uikit/menu/index.d.ts +3 -0
- package/dist/@uikit/menu/index.js +4 -0
- package/dist/@uikit/menu/index.js.map +1 -0
- package/dist/@uikit/menu/interfaces.d.ts +20 -0
- package/dist/@uikit/menu/interfaces.js +8 -0
- package/dist/@uikit/menu/interfaces.js.map +1 -0
- package/dist/@uikit/menu/internal.d.ts +40 -0
- package/dist/@uikit/menu/internal.js +191 -0
- package/dist/@uikit/menu/internal.js.map +1 -0
- package/dist/@uikit/reactRouter/hooks/jBundler_ifBrowser.d.ts +18 -0
- package/dist/@uikit/reactRouter/hooks/jBundler_ifBrowser.js +40 -0
- package/dist/@uikit/reactRouter/hooks/jBundler_ifBrowser.js.map +1 -0
- package/dist/@uikit/reactRouter/hooks/jBundler_ifServer.d.ts +28 -0
- package/dist/@uikit/reactRouter/hooks/jBundler_ifServer.js +35 -0
- package/dist/@uikit/reactRouter/hooks/jBundler_ifServer.js.map +1 -0
- package/dist/@uikit/reactRouter/index.d.ts +1 -0
- package/dist/@uikit/reactRouter/index.js +2 -0
- package/dist/@uikit/reactRouter/index.js.map +1 -0
- package/dist/@uikit/users/hooks.d.ts +10 -0
- package/dist/@uikit/users/hooks.js +39 -0
- package/dist/@uikit/users/hooks.js.map +1 -0
- package/dist/@uikit/users/index.d.ts +1 -0
- package/dist/@uikit/users/index.js +2 -0
- package/dist/@uikit/users/index.js.map +1 -0
- package/dist/@uikit/variants/index.d.ts +7 -0
- package/dist/@uikit/variants/index.js +16 -0
- package/dist/@uikit/variants/index.js.map +1 -0
- package/package.json +115 -0
- package/src/@bundler/README.md +1 -0
- package/src/@bundler/_logs.ts +4 -0
- package/src/@bundler/core.ts +41 -0
- package/src/@bundler/esbuild.ts +141 -0
- package/src/@bundler/index.ts +3 -0
- package/src/@bundler/plugins.ts +163 -0
- package/src/@bundler/tailwind.ts +139 -0
- package/src/@core/PageComponent.tsx +25 -0
- package/src/@core/README.md +1 -0
- package/src/@core/_logs.ts +11 -0
- package/src/@core/automaticStartStop.ts +132 -0
- package/src/@core/browserCacheControl.ts +40 -0
- package/src/@core/bundler/bundler.ts +128 -0
- package/src/@core/bundler/common.ts +18 -0
- package/src/@core/bundler/config.ts +37 -0
- package/src/@core/bundler/extraContent.ts +30 -0
- package/src/@core/bundler/pagesGenerator.ts +194 -0
- package/src/@core/bundler/server.ts +41 -0
- package/src/@core/caches/InMemoryCache.ts +483 -0
- package/src/@core/caches/SimpleFileCache.ts +205 -0
- package/src/@core/caches/cache.ts +77 -0
- package/src/@core/caches/webSiteMirrorCache.ts +90 -0
- package/src/@core/cheerio.d.ts +332 -0
- package/src/@core/gzip.ts +33 -0
- package/src/@core/index.ts +23 -0
- package/src/@core/internalTools.ts +95 -0
- package/src/@core/jQuery.ts +22 -0
- package/src/@core/jopiEasy.ts +1285 -0
- package/src/@core/jopiRequest.tsx +1279 -0
- package/src/@core/jopiServer.ts +188 -0
- package/src/@core/jopiWebSite.tsx +1027 -0
- package/src/@core/letsEncrypt.ts +243 -0
- package/src/@core/linker.ts +42 -0
- package/src/@core/loadBalancing.ts +152 -0
- package/src/@core/middlewares/CorsMiddleware.ts +23 -0
- package/src/@core/middlewares/DdosProtection.ts +120 -0
- package/src/@core/middlewares/index.ts +16 -0
- package/src/@core/publicTools.ts +14 -0
- package/src/@core/routeConfig.ts +104 -0
- package/src/@core/searchParamFilter.ts +315 -0
- package/src/@core/serverFetch.ts +454 -0
- package/src/@core/serverImpl/server_bunjs.tsx +230 -0
- package/src/@core/serverImpl/server_nodejs.ts +312 -0
- package/src/@core/serverInstanceBuilder.ts +36 -0
- package/src/@core/userStores.ts +34 -0
- package/src/@crawler/README.md +1 -0
- package/src/@crawler/common.ts +275 -0
- package/src/@crawler/core.ts +678 -0
- package/src/@crawler/directFileCache.ts +69 -0
- package/src/@crawler/index.ts +4 -0
- package/src/@crawler/urlMapping.ts +67 -0
- package/src/@crawler/utils.ts +13 -0
- package/src/@generated/index.ts +134 -0
- package/src/@linker/arobaseTypes.ts +325 -0
- package/src/@linker/changeProof.ts +53 -0
- package/src/@linker/config.ts +46 -0
- package/src/@linker/engine.ts +865 -0
- package/src/@linker/index.ts +3 -0
- package/src/@linker/install.ts +39 -0
- package/src/@linker/modInstaller.ts +50 -0
- package/src/@linker/typeEvents.ts +58 -0
- package/src/@linker/typeRoutes.ts +255 -0
- package/src/@linker/typeUiComposite.ts +19 -0
- package/src/@loader/README.md +4 -0
- package/src/@loader/bunHtmlCompiler.mjs +27 -0
- package/src/@loader/index.ts +19 -0
- package/src/@loader/loader.mjs +7 -0
- package/src/@loader/nodeJsLoader.ts +21 -0
- package/src/@loader-client/README.md +2 -0
- package/src/@loader-client/index.ts +108 -0
- package/src/@loader-tools/README.md +6 -0
- package/src/@loader-tools/bunJsLoader.ts +33 -0
- package/src/@loader-tools/config.ts +142 -0
- package/src/@loader-tools/cssModuleCompiler.ts +76 -0
- package/src/@loader-tools/esBuildPlugin.ts +142 -0
- package/src/@loader-tools/index.ts +11 -0
- package/src/@loader-tools/jopin.ts +403 -0
- package/src/@loader-tools/nodeJsLoader.ts +119 -0
- package/src/@loader-tools/nodeJsResolver.ts +140 -0
- package/src/@loader-tools/rules.ts +45 -0
- package/src/@loader-tools/sourceChangesWatcher.ts +225 -0
- package/src/@loader-tools/tools.ts +139 -0
- package/src/@loader-tools/transform.ts +138 -0
- package/src/@loader-tools/virtualUrl.ts +57 -0
- package/src/@loader-types/README.md +15 -0
- package/src/@loader-types/extensions.d.ts +65 -0
- package/src/@tool-jopinb/README.md +1 -0
- package/src/@tool-jopinb/index.ts +11 -0
- package/src/@ui/README.md +3 -0
- package/src/@ui/components.tsx +49 -0
- package/src/@ui/cssModules.tsx +27 -0
- package/src/@ui/hooks.tsx +95 -0
- package/src/@ui/index.ts +13 -0
- package/src/@ui/internal.ts +12 -0
- package/src/@ui/modules.ts +100 -0
- package/src/@ui/objectRegistry.ts +50 -0
- package/src/@ui/pageController.ts +203 -0
- package/src/@ui/tools.ts +116 -0
- package/src/@uikit/README.md +1 -0
- package/src/@uikit/core/UiKitModule.ts +20 -0
- package/src/@uikit/core/index.ts +4 -0
- package/src/@uikit/core/jBundler_ifBrowser.ts +4 -0
- package/src/@uikit/core/jBundler_ifServer.ts +18 -0
- package/src/@uikit/forms/components.tsx +97 -0
- package/src/@uikit/forms/hooks.ts +38 -0
- package/src/@uikit/forms/index.ts +3 -0
- package/src/@uikit/forms/interfaces.ts +159 -0
- package/src/@uikit/forms/private.ts +365 -0
- package/src/@uikit/helpers/hooks.ts +133 -0
- package/src/@uikit/helpers/index.ts +2 -0
- package/src/@uikit/helpers/tools.ts +39 -0
- package/src/@uikit/index.ts +15 -0
- package/src/@uikit/menu/core.ts +227 -0
- package/src/@uikit/menu/hooks.ts +28 -0
- package/src/@uikit/menu/index.ts +3 -0
- package/src/@uikit/menu/interfaces.ts +26 -0
- package/src/@uikit/menu/internal.ts +218 -0
- package/src/@uikit/package.json +15 -0
- package/src/@uikit/reactRouter/hooks/jBundler_ifBrowser.tsx +59 -0
- package/src/@uikit/reactRouter/hooks/jBundler_ifServer.tsx +51 -0
- package/src/@uikit/reactRouter/index.ts +1 -0
- package/src/@uikit/users/hooks.ts +50 -0
- package/src/@uikit/users/index.ts +1 -0
- package/src/@uikit/variants/index.tsx +20 -0
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
// noinspection JSUnusedGlobalSymbols
|
|
2
|
+
|
|
3
|
+
import {type SendingBody} from "./jopiWebSite.tsx";
|
|
4
|
+
import type {LoadBalancer} from "./loadBalancing.ts";
|
|
5
|
+
import {AutomaticStartStop} from "./automaticStartStop.js";
|
|
6
|
+
import {JopiRequest} from "./jopiRequest.js";
|
|
7
|
+
import {isNodeJS} from "jopi-toolkit/jk_what";
|
|
8
|
+
|
|
9
|
+
export interface ServerDownResult<T> {
|
|
10
|
+
newServer?: ServerFetch<T>,
|
|
11
|
+
newServerWeight?: number;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface FetchOptions {
|
|
15
|
+
headers?: Headers;
|
|
16
|
+
method?: string;
|
|
17
|
+
verbose?: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ServerFetchOptions<T> {
|
|
21
|
+
/**
|
|
22
|
+
* Allow automatically removing the trailing slashs for the website root.
|
|
23
|
+
* If I have http://127.0.0.1/, then it's begun http://127.0.0.1
|
|
24
|
+
* Default value is false.
|
|
25
|
+
*/
|
|
26
|
+
removeRootTrailingSlash?: boolean;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Is called before a request.
|
|
30
|
+
* Is used to start the server if we are doing headless.
|
|
31
|
+
*/
|
|
32
|
+
beforeRequesting?: (url: string, fetchOptions: FetchOptions, data: T)=>void|Promise<void>;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Is called if we detect that the server is down.
|
|
36
|
+
* Allow starting a script which will restart the server
|
|
37
|
+
* or send a mal to the admin.
|
|
38
|
+
*
|
|
39
|
+
* @returns
|
|
40
|
+
* true if we can retry the call.
|
|
41
|
+
* false if we can't.
|
|
42
|
+
*/
|
|
43
|
+
ifServerIsDown?: (fetcher: ServerFetch<T>, data: T)=>Promise<ServerDownResult<T>|undefined>;
|
|
44
|
+
|
|
45
|
+
headers?: Headers;
|
|
46
|
+
userDefaultHeaders?: boolean;
|
|
47
|
+
cookies?: { [key: string]: string };
|
|
48
|
+
verbose?: boolean;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* The public URL of the website.
|
|
52
|
+
* It's the url that he must use to build the url in his content.
|
|
53
|
+
* It's not the url of the server where he can be reached.
|
|
54
|
+
*
|
|
55
|
+
* Setting a public url will allow automatically setting the X-Forwarded-Host and X-Forwarded-Proto headers.
|
|
56
|
+
*/
|
|
57
|
+
publicUrl?: string | URL;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* An object which will be sent to beforeRequesting.
|
|
61
|
+
* Will also be where ifServerIsDown can store his state.
|
|
62
|
+
*/
|
|
63
|
+
data? :T;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Allow rewriting the url for complex cases.
|
|
67
|
+
*/
|
|
68
|
+
rewriteUrl?: (url: string, headers: Headers, fetcher: ServerFetch<any>)=>URL;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Allow rewriting a redirection.
|
|
72
|
+
*/
|
|
73
|
+
translateRedirect?: (url: string)=>URL;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* The weight of this server, if using inside a load balancer.
|
|
77
|
+
*/
|
|
78
|
+
weight?: number;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* If set, then will be called to start the start.
|
|
82
|
+
* The resulting value is the number of seconds to wait for inactivity.
|
|
83
|
+
*/
|
|
84
|
+
doStartServer?: (data: any)=>Promise<number>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* If set, then will be called to stop the server when not need anymore.
|
|
88
|
+
*/
|
|
89
|
+
doStopServer?: (data: any)=>Promise<void>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export class ServerFetch<T> {
|
|
93
|
+
private readonly options: ServerFetchOptions<T>;
|
|
94
|
+
private lastURL: string | undefined;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The load-balancer will attach himself if this instance
|
|
98
|
+
* is used by a load balancer.
|
|
99
|
+
*/
|
|
100
|
+
public loadBalancer?: LoadBalancer;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Create an instance that translates urls from an origin to a destination.
|
|
104
|
+
* Ex: http://127.0.0.1 --> https://www.mywebiste.com
|
|
105
|
+
* Ex: https://my-server.com --> https://134.555.666.66:7890 (with hostname: my-server.com)
|
|
106
|
+
*
|
|
107
|
+
* @param publicUrl
|
|
108
|
+
* The origin of our current website.
|
|
109
|
+
* @param targetUrl
|
|
110
|
+
* The origin of the target website.
|
|
111
|
+
* @param hostName
|
|
112
|
+
* Must be set if toOrigin use an IP and not a hostname.
|
|
113
|
+
* (will set the Host header)
|
|
114
|
+
* @param options
|
|
115
|
+
* Options for the ServerFetch instance.
|
|
116
|
+
*/
|
|
117
|
+
static fromTo<T>(publicUrl: string, targetUrl: string, hostName?: string, options?: ServerFetchOptions<T>): ServerFetch<T> {
|
|
118
|
+
return new ServerFetch<T>(ServerFetch.getOptionsFor_fromTo(publicUrl, targetUrl, hostName, options));
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static getOptionsFor_fromTo<T>(publicUrl: string, targetUrl: string, hostName?: string, options?: ServerFetchOptions<T>): ServerFetchOptions<T> {
|
|
122
|
+
const uPublicUrl = new URL(publicUrl);
|
|
123
|
+
const uTargetUrl = new URL(targetUrl);
|
|
124
|
+
targetUrl = uTargetUrl.toString().slice(0, -1);
|
|
125
|
+
|
|
126
|
+
if (!hostName) hostName = uTargetUrl.hostname;
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
...options,
|
|
130
|
+
|
|
131
|
+
rewriteUrl(url: string, headers: Headers) {
|
|
132
|
+
const urlInfos = new URL(url);
|
|
133
|
+
urlInfos.port = uTargetUrl.port;
|
|
134
|
+
urlInfos.protocol = uTargetUrl.protocol;
|
|
135
|
+
urlInfos.hostname = uTargetUrl.hostname;
|
|
136
|
+
|
|
137
|
+
if (hostName) {
|
|
138
|
+
headers.set('Host', hostName);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return urlInfos;
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
translateRedirect(url: string) {
|
|
145
|
+
if (url[0]==="/") {
|
|
146
|
+
url = targetUrl + url;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const urlInfos = new URL(url);
|
|
150
|
+
urlInfos.port = uPublicUrl.port;
|
|
151
|
+
urlInfos.protocol = uPublicUrl.protocol;
|
|
152
|
+
urlInfos.hostname = uPublicUrl.hostname;
|
|
153
|
+
|
|
154
|
+
return urlInfos;
|
|
155
|
+
}
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
static useOrigin<T>(serverOrigin: string, options?: ServerFetchOptions<T>) {
|
|
160
|
+
return new ServerFetch<T>(ServerFetch.getOptionsFor_useOrigin(serverOrigin, options));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
static useIP<T>(serverOrigin: string, ip: string, options?: ServerFetchOptions<T>) {
|
|
164
|
+
return new ServerFetch<T>(ServerFetch.getOptionsFor_useIP(serverOrigin, ip, options));
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
static getOptionsFor_useOrigin<T>(serverOrigin: string, options?: ServerFetchOptions<T>): ServerFetchOptions<T> {
|
|
168
|
+
const urlOrigin = new URL(serverOrigin);
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
...options,
|
|
172
|
+
|
|
173
|
+
rewriteUrl(url: string) {
|
|
174
|
+
const urlInfos = new URL(url);
|
|
175
|
+
urlInfos.port = urlOrigin.port;
|
|
176
|
+
urlInfos.protocol = urlOrigin.protocol;
|
|
177
|
+
urlInfos.hostname = urlOrigin.hostname;
|
|
178
|
+
|
|
179
|
+
return urlInfos;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
static getOptionsFor_useIP<T>(serverOrigin: string, ip: string, options?: ServerFetchOptions<T>): ServerFetchOptions<T> {
|
|
185
|
+
let urlOrigin = new URL(serverOrigin);
|
|
186
|
+
let hostName = urlOrigin.hostname;
|
|
187
|
+
urlOrigin.hostname = ip;
|
|
188
|
+
|
|
189
|
+
return {
|
|
190
|
+
...options,
|
|
191
|
+
|
|
192
|
+
rewriteUrl(url: string, headers: Headers) {
|
|
193
|
+
const urlInfos = new URL(url);
|
|
194
|
+
urlInfos.port = urlOrigin.port;
|
|
195
|
+
urlInfos.protocol = urlOrigin.protocol;
|
|
196
|
+
urlInfos.hostname = urlOrigin.hostname;
|
|
197
|
+
|
|
198
|
+
if (hostName) {
|
|
199
|
+
headers.set('Host', hostName);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return urlInfos;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
static useAsIs<T>(options?: ServerFetchOptions<T>) {
|
|
208
|
+
return new ServerFetch<T>(options);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
protected constructor(options?: ServerFetchOptions<T>|undefined) {
|
|
212
|
+
options = options || {};
|
|
213
|
+
this.options = options;
|
|
214
|
+
|
|
215
|
+
if (!options.data) options.data = {} as T;
|
|
216
|
+
if (!options.headers) options.headers = new Headers();
|
|
217
|
+
if (options.userDefaultHeaders !== false) this.useDefaultHeaders();
|
|
218
|
+
|
|
219
|
+
this.compileCookies();
|
|
220
|
+
|
|
221
|
+
if (options.doStartServer) {
|
|
222
|
+
let autoStartStop = new AutomaticStartStop({
|
|
223
|
+
onStart: options.doStartServer!,
|
|
224
|
+
onStop: options.doStopServer!
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
if (options.beforeRequesting) {
|
|
228
|
+
const beforeRequesting = options.beforeRequesting;
|
|
229
|
+
const doStart = options.doStartServer!;
|
|
230
|
+
|
|
231
|
+
options.beforeRequesting = async (url, fetchOptions, data) => {
|
|
232
|
+
await autoStartStop.start();
|
|
233
|
+
return beforeRequesting(url, fetchOptions, data);
|
|
234
|
+
}
|
|
235
|
+
} else {
|
|
236
|
+
options.beforeRequesting = () => autoStartStop.start();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (options.publicUrl) {
|
|
241
|
+
const url = new URL(options.publicUrl);
|
|
242
|
+
options.headers.set('X-Forwarded-Proto', url.protocol.replace(':', ''));
|
|
243
|
+
options.headers.set('X-Forwarded-Host', url.host);
|
|
244
|
+
|
|
245
|
+
let ignorePort = false;
|
|
246
|
+
|
|
247
|
+
if (url.protocol === 'http:') {
|
|
248
|
+
if (!url.port || (url.port === "80")) {
|
|
249
|
+
ignorePort = true;
|
|
250
|
+
}
|
|
251
|
+
} else {
|
|
252
|
+
if (!url.port || (url.port === "443")) {
|
|
253
|
+
ignorePort = true;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (!ignorePort) {
|
|
258
|
+
options.headers.set('X-Forwarded-Port', url.port);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
async checkIfServerOk(): Promise<boolean> {
|
|
264
|
+
if (!this.lastURL) return false;
|
|
265
|
+
let url = new URL(this.lastURL);
|
|
266
|
+
url.pathname = "/";
|
|
267
|
+
|
|
268
|
+
const res = await this.fetch("GET", url);
|
|
269
|
+
return res.status < 500;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
private useDefaultHeaders() {
|
|
273
|
+
const headers = this.options.headers!;
|
|
274
|
+
|
|
275
|
+
const json = {
|
|
276
|
+
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
|
277
|
+
|
|
278
|
+
"connection": "keep-alive",
|
|
279
|
+
"cache-control": "max-age=0",
|
|
280
|
+
"dnt": "1",
|
|
281
|
+
"upgrade-insecure-requests": "1",
|
|
282
|
+
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36",
|
|
283
|
+
"sec-fetch-mode": "navigate",
|
|
284
|
+
"sec-fetch-dest": "document",
|
|
285
|
+
"accept-encoding": "gzip, deflate, br, zstd",
|
|
286
|
+
"accept-language": "fr-FR,fr;q=0.9,en-US;q=0.8,en;q=0.7,es;q=0.6",
|
|
287
|
+
"sec-ch-ua": "\"Not)A;Brand\";v=\"8\", \"Chromium\";v=\"138\", \"Google Chrome\";v=\"138\"",
|
|
288
|
+
"sec-ch-ua-mobile": "?0",
|
|
289
|
+
"sec-ch-ua-platform": "\"macOS\"",
|
|
290
|
+
"sec-fetch-site": "none",
|
|
291
|
+
"sec-fetch-user": "?1"
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
for (const [key, value] of Object.entries(json)) {
|
|
295
|
+
headers.set(key, value);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
private compileCookies() {
|
|
300
|
+
if (!this.options.cookies) return;
|
|
301
|
+
let cookies = '';
|
|
302
|
+
|
|
303
|
+
for (const [name, value] of Object.entries(this.options.cookies)) {
|
|
304
|
+
cookies += `;${name}=${value}`;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (cookies) {
|
|
308
|
+
this.options.headers?.set("Cookies", cookies.substring(1));
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Allow directly proxy a request as if we were directly asking the target server.
|
|
314
|
+
*/
|
|
315
|
+
async directProxy(req: JopiRequest): Promise<Response> {
|
|
316
|
+
return this.doFetch(req.method, req.urlInfos.href, req.body, req.headers);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
async fetchWith(req: JopiRequest) {
|
|
320
|
+
return this.doFetch(req.method, req.urlInfos.href, req.body, req.headers);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
async fetch(method: string, url: URL, body?: SendingBody, headers?: Headers) {
|
|
324
|
+
return this.doFetch(method, url.toString(), body, headers);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
async fetch2(method: string, url: string, body?: SendingBody, headers?: Headers) {
|
|
328
|
+
return this.doFetch(method, url, body, headers);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
normalizeUrl(urlInfos: URL): string {
|
|
332
|
+
// To known: urlInfos.toString() always add a "/" at the end of the root.
|
|
333
|
+
// new URL("http://127.0.0.1") --> http://127.0.0.1/
|
|
334
|
+
|
|
335
|
+
if (urlInfos.pathname.length<=1 && this.options.removeRootTrailingSlash) {
|
|
336
|
+
return urlInfos.origin;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
return urlInfos.href;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Allow fetching some content.
|
|
344
|
+
*/
|
|
345
|
+
private async doFetch(method: string, url: string, body?: SendingBody, headers?: Headers): Promise<Response> {
|
|
346
|
+
const bckURL = url;
|
|
347
|
+
|
|
348
|
+
if (!headers) {
|
|
349
|
+
if (this.options.headers) headers = this.options.headers;
|
|
350
|
+
else headers = new Headers();
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// Avoid some protections using the referer.
|
|
354
|
+
//headers.delete("Referer");
|
|
355
|
+
|
|
356
|
+
if (this.options.rewriteUrl) {
|
|
357
|
+
let urlInfos = this.options.rewriteUrl(url, headers, this);
|
|
358
|
+
url = this.normalizeUrl(urlInfos);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const fetchOptions: any = {
|
|
362
|
+
method: method,
|
|
363
|
+
headers: headers,
|
|
364
|
+
verbose: this.options.verbose,
|
|
365
|
+
|
|
366
|
+
// Allow avoiding automatic redirections.
|
|
367
|
+
// @ts-ignore
|
|
368
|
+
redirect: 'manual',
|
|
369
|
+
|
|
370
|
+
body: body,
|
|
371
|
+
|
|
372
|
+
// Allow avoiding SSL certificate check.
|
|
373
|
+
//
|
|
374
|
+
rejectUnauthorized: false,
|
|
375
|
+
requestCert: false,
|
|
376
|
+
|
|
377
|
+
tls: {
|
|
378
|
+
rejectUnauthorized: false,
|
|
379
|
+
checkServerIdentity: () => { return undefined }
|
|
380
|
+
},
|
|
381
|
+
|
|
382
|
+
// Required by node.js
|
|
383
|
+
duplex: "half"
|
|
384
|
+
};
|
|
385
|
+
|
|
386
|
+
if (this.options.beforeRequesting) {
|
|
387
|
+
const res = this.options.beforeRequesting(url, fetchOptions, this.options.data!);
|
|
388
|
+
if (res instanceof Promise) await res;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
this.lastURL = url;
|
|
392
|
+
|
|
393
|
+
try {
|
|
394
|
+
let r = await fetch(url, fetchOptions);
|
|
395
|
+
|
|
396
|
+
if (r.status >= 300 && r.status < 400) {
|
|
397
|
+
let location = r.headers.get('location');
|
|
398
|
+
|
|
399
|
+
if (location) {
|
|
400
|
+
if (this.options.translateRedirect) {
|
|
401
|
+
location = this.normalizeUrl(this.options.translateRedirect(location));
|
|
402
|
+
r.headers.set('Location', location);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
r = new Response(null, {status: r.status, headers: r.headers});
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
if (this.options.verbose) {
|
|
410
|
+
console.log(`Fetched [${r.status}]`, url);
|
|
411
|
+
if (!r.body) console.log("Response hasn't a body");
|
|
412
|
+
const ct = r.headers.get("content-length");
|
|
413
|
+
if (ct !== undefined && ct === '0') console.log(`Response content-length: ${length}`);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
// The response is received gzipped but is deflated.
|
|
417
|
+
// It's why his content-length and content-encoding must be reset.
|
|
418
|
+
if (isNodeJS) {
|
|
419
|
+
let headers = new Headers(r.headers);
|
|
420
|
+
headers.delete("content-length");
|
|
421
|
+
headers.delete("content-encoding");
|
|
422
|
+
r = new Response(r.body, {headers: headers, status: r.status});
|
|
423
|
+
} else {
|
|
424
|
+
r.headers.delete("content-encoding");
|
|
425
|
+
r.headers.delete("content-encoding");
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
return r;
|
|
429
|
+
} catch(e) {
|
|
430
|
+
if (this.options.ifServerIsDown) {
|
|
431
|
+
// Allow we to know there is something fishy.
|
|
432
|
+
const result = await this.options.ifServerIsDown(this, this.options.data!);
|
|
433
|
+
|
|
434
|
+
// We can retry to send the request?
|
|
435
|
+
if (result && result.newServer) {
|
|
436
|
+
if (this.loadBalancer) {
|
|
437
|
+
this.loadBalancer.replaceServer(this, result.newServer, result.newServerWeight);
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
return result.newServer.doFetch(method, bckURL, body, headers);
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
// 521: Web Server Is Down.
|
|
445
|
+
return new Response(null, { status: 521 });
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
// Allow disabling ssl certificate verification.
|
|
451
|
+
//
|
|
452
|
+
if (isNodeJS) {
|
|
453
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
454
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import type {CoreServer, SseEvent, SseEventController, WebSocketConnectionInfos} from "../jopiServer.ts";
|
|
2
|
+
import {
|
|
3
|
+
type HttpMethod, type JopiWebSocket,
|
|
4
|
+
SBPE_DirectSendThisResponseException , type WebSiteImpl, type WebSiteRouteInfos
|
|
5
|
+
} from "../jopiWebSite.tsx";
|
|
6
|
+
import type {ServerInstanceBuilder} from "../serverInstanceBuilder.ts";
|
|
7
|
+
import React from "react";
|
|
8
|
+
import * as jk_fs from "jopi-toolkit/jk_fs";
|
|
9
|
+
import {getBundleDirPath} from "../bundler/common.ts";
|
|
10
|
+
import {hasJopiDevUiFlag} from "jopijs/loader-client";
|
|
11
|
+
import {addBrowserCacheControlHeaders, type TryReturnFileParams} from "../browserCacheControl.ts";
|
|
12
|
+
|
|
13
|
+
//region SSE Events
|
|
14
|
+
|
|
15
|
+
interface SseClient {
|
|
16
|
+
controller: ReadableStreamDefaultController,
|
|
17
|
+
me: any
|
|
18
|
+
keepAliveInterval?: Timer
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface BunSseEvent extends SseEvent {
|
|
22
|
+
clients: SseClient[];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Is called when a client connects through a GET request.
|
|
27
|
+
*/
|
|
28
|
+
export async function onSseEvent(sseEvent: SseEvent): Promise<Response> {
|
|
29
|
+
// Serve a reference for this client.
|
|
30
|
+
// To know: stream can't be used because it's not initialized yet.
|
|
31
|
+
const me: {client?: SseClient} = { };
|
|
32
|
+
|
|
33
|
+
const stream = new ReadableStream({
|
|
34
|
+
/**
|
|
35
|
+
* Is called when starting to read the stream.
|
|
36
|
+
*/
|
|
37
|
+
start(streamController) {
|
|
38
|
+
const nodeSseEvent = sseEvent as BunSseEvent;
|
|
39
|
+
|
|
40
|
+
// Occurs only one time.
|
|
41
|
+
if (!nodeSseEvent.clients) {
|
|
42
|
+
nodeSseEvent.clients = [];
|
|
43
|
+
|
|
44
|
+
let sseController: SseEventController = {
|
|
45
|
+
send(eventName: string, data: string) {
|
|
46
|
+
let toSend = `event: ${eventName}\ndata: ${ JSON.stringify({message: data}) }\n\n`;
|
|
47
|
+
const encoder = new TextEncoder();
|
|
48
|
+
const encodedData = encoder.encode(toSend);
|
|
49
|
+
|
|
50
|
+
nodeSseEvent.clients.forEach(e => {
|
|
51
|
+
e.controller.enqueue(encodedData);
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
close() {
|
|
56
|
+
console.log("SSE close by API");
|
|
57
|
+
|
|
58
|
+
nodeSseEvent.clients.forEach(e => {
|
|
59
|
+
e.controller.close();
|
|
60
|
+
clearInterval(e.keepAliveInterval);
|
|
61
|
+
e.keepAliveInterval = undefined;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
nodeSseEvent.clients = [];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
nodeSseEvent.handler(sseController);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Allow avoiding a bug where the stream is closed.
|
|
72
|
+
// Come from bun or chrome?
|
|
73
|
+
//
|
|
74
|
+
const timer = setInterval(() => {
|
|
75
|
+
try { client.controller.enqueue(`event: echo\ndata: echo\n\n`); }
|
|
76
|
+
catch {}
|
|
77
|
+
}, 2000);
|
|
78
|
+
|
|
79
|
+
const client: SseClient = {controller: streamController, me, keepAliveInterval: timer};
|
|
80
|
+
me.client = client;
|
|
81
|
+
|
|
82
|
+
nodeSseEvent.clients.push(client);
|
|
83
|
+
|
|
84
|
+
const initialData = sseEvent.getWelcomeMessage();
|
|
85
|
+
|
|
86
|
+
const encoder = new TextEncoder();
|
|
87
|
+
streamController.enqueue(encoder.encode(`data: ${initialData}\n\n`));
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
cancel() {
|
|
91
|
+
clearInterval(me.client!.keepAliveInterval);
|
|
92
|
+
|
|
93
|
+
const nodeSseEvent = sseEvent as BunSseEvent;
|
|
94
|
+
nodeSseEvent.clients = nodeSseEvent.clients.filter(e => e.me !== me);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
throw new SBPE_DirectSendThisResponseException(
|
|
99
|
+
new Response(stream, {
|
|
100
|
+
headers: {
|
|
101
|
+
'Content-Type': 'text/event-stream',
|
|
102
|
+
'Cache-Control': 'no-cache',
|
|
103
|
+
'Connection': 'keep-alive'
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
//endregion
|
|
110
|
+
|
|
111
|
+
//region ServerInstanceProvider
|
|
112
|
+
|
|
113
|
+
export class BunJsServerInstanceBuilder implements ServerInstanceBuilder {
|
|
114
|
+
private bunServer?: Bun.Server<unknown>;
|
|
115
|
+
private serverOptions?: any;
|
|
116
|
+
private serverRoutes: any = {};
|
|
117
|
+
private readonly isReactHmrEnabled: boolean;
|
|
118
|
+
|
|
119
|
+
private readonly pageToBuild: Record<string, string> = {};
|
|
120
|
+
|
|
121
|
+
constructor(private readonly webSite: WebSiteImpl) {
|
|
122
|
+
this.isReactHmrEnabled = hasJopiDevUiFlag();
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
addRoute(verb: HttpMethod, path: string, route: WebSiteRouteInfos) {
|
|
126
|
+
if (!this.serverRoutes[path]) {
|
|
127
|
+
this.serverRoutes[path] = {};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
const webSite = this.webSite;
|
|
131
|
+
|
|
132
|
+
this.serverRoutes[path][verb] = (req: Bun.BunRequest, server: Bun.Server<unknown>) => {
|
|
133
|
+
const urlInfos = new URL(req.url);
|
|
134
|
+
return webSite.processRequest(route.handler, req.params, route, urlInfos, req, server);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
addWsRoute(path: string, handler: (ws: JopiWebSocket, infos: WebSocketConnectionInfos) => void) {
|
|
139
|
+
//TODO
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
addSseEVent(path: string, eventInfos: SseEvent): void {
|
|
143
|
+
eventInfos = {...eventInfos};
|
|
144
|
+
|
|
145
|
+
this.addRoute("GET", path, {
|
|
146
|
+
route: path,
|
|
147
|
+
|
|
148
|
+
handler: async _ => {
|
|
149
|
+
return onSseEvent(eventInfos);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async tryReturnFile(params: TryReturnFileParams): Promise<Response|undefined> {
|
|
155
|
+
let stats = params.validationInfos.fileState;
|
|
156
|
+
if (!stats) return undefined;
|
|
157
|
+
|
|
158
|
+
if (stats?.isFile()) {
|
|
159
|
+
const headers: any = {};
|
|
160
|
+
if (params.contentEncoding) headers["content-encoding"] = params.contentEncoding;
|
|
161
|
+
addBrowserCacheControlHeaders(headers, params);
|
|
162
|
+
|
|
163
|
+
return new Response(Bun.file(params.filePath), {status: 200, headers});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
addPage(path: string, pageKey: string, reactComponent: React.FC<any>, routeInfos: WebSiteRouteInfos) {
|
|
170
|
+
if (this.isReactHmrEnabled) {
|
|
171
|
+
this.pageToBuild[path] = pageKey;
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
routeInfos.handler = async (req) => {
|
|
176
|
+
return await req.react_fromPage(pageKey, reactComponent);
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
routeInfos.handler = this.webSite.applyMiddlewares("GET", path, routeInfos.handler, true);
|
|
180
|
+
this.addRoute("GET", path, routeInfos);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
updateTlsCertificate(certificate: any) {
|
|
184
|
+
this.serverOptions.tls = certificate;
|
|
185
|
+
|
|
186
|
+
// Will reload without breaking the current connections.
|
|
187
|
+
// @ts-ignore
|
|
188
|
+
this.bunServer.reload(this.serverOptions);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
async buildPage(path: string, pageKey: string): Promise<void> {
|
|
192
|
+
const genDir = getBundleDirPath(this.webSite);
|
|
193
|
+
const htmlFilePath = jk_fs.join(genDir, pageKey + ".html");
|
|
194
|
+
|
|
195
|
+
if (!this.serverRoutes[path]) this.serverRoutes[path] = {};
|
|
196
|
+
this.serverRoutes[path]["GET"] = (await import(htmlFilePath)).default;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
async startServer(params: { port: number; tls: any }): Promise<CoreServer> {
|
|
200
|
+
const options = {
|
|
201
|
+
port: String(params.port),
|
|
202
|
+
tls: params.tls,
|
|
203
|
+
routes: this.serverRoutes,
|
|
204
|
+
|
|
205
|
+
fetch: async (req: Request) => {
|
|
206
|
+
const urlInfos = new URL(req.url);
|
|
207
|
+
return await this.webSite.processRequest(undefined, {}, undefined, urlInfos, req, this.bunServer!);
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
development: this.isReactHmrEnabled && {
|
|
211
|
+
// Enable browser hot reloading in development
|
|
212
|
+
hmr: true,
|
|
213
|
+
// Echo console logs from the browser to the server
|
|
214
|
+
console: true,
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
for (let path in this.pageToBuild) {
|
|
219
|
+
let pageKey = this.pageToBuild[path];
|
|
220
|
+
await this.buildPage(path, pageKey);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
this.serverOptions = options;
|
|
224
|
+
|
|
225
|
+
// @ts-ignore
|
|
226
|
+
return this.bunServer = Bun.serve(options);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
//endregion
|