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,312 @@
|
|
|
1
|
+
import http from "node:http";
|
|
2
|
+
import https from "node:https";
|
|
3
|
+
import {WebSocketServer} from "ws";
|
|
4
|
+
import * as jk_fs from "jopi-toolkit/jk_fs";
|
|
5
|
+
import fs from "node:fs";
|
|
6
|
+
import {addBrowserCacheControlHeaders, type TryReturnFileParams} from "../browserCacheControl.ts";
|
|
7
|
+
|
|
8
|
+
import type {
|
|
9
|
+
CoreServer,
|
|
10
|
+
ServerSocketAddress,
|
|
11
|
+
SseEvent,
|
|
12
|
+
SseEventController,
|
|
13
|
+
StartServerOptions,
|
|
14
|
+
WebSocketConnectionInfos
|
|
15
|
+
} from "../jopiServer.ts";
|
|
16
|
+
import type {
|
|
17
|
+
HttpMethod,
|
|
18
|
+
JopiWebSocket,
|
|
19
|
+
JopiWsRouteHandler,
|
|
20
|
+
WebSiteImpl,
|
|
21
|
+
WebSiteRouteInfos
|
|
22
|
+
} from "../jopiWebSite.tsx";
|
|
23
|
+
import {SBPE_MustReturnWithoutResponseException} from "../jopiWebSite.tsx";
|
|
24
|
+
import type {ServerInstanceBuilder} from "../serverInstanceBuilder.ts";
|
|
25
|
+
import {addRoute, createRouter, findRoute, type RouterContext} from "rou3";
|
|
26
|
+
import React from "react";
|
|
27
|
+
|
|
28
|
+
class NodeServerInstance implements CoreServer {
|
|
29
|
+
private readonly server: http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>;
|
|
30
|
+
|
|
31
|
+
constructor(private options: StartServerOptions) {
|
|
32
|
+
let isHttps = options.tls !== undefined;
|
|
33
|
+
|
|
34
|
+
async function handler(req: http.IncomingMessage, res: http.ServerResponse) {
|
|
35
|
+
const headers = new Headers(req.headers as any);
|
|
36
|
+
|
|
37
|
+
const method = req.method!;
|
|
38
|
+
const body = (method == "GET" || method === "HEAD") ? undefined : jk_fs.nodeStreamToWebStream(req);
|
|
39
|
+
|
|
40
|
+
// req doesn't allow knowing if we are http or https.
|
|
41
|
+
// TODO BUG: https
|
|
42
|
+
const webReq = new Request((isHttps ? "https://" : "http://") + req.headers.host! + req.url!, {
|
|
43
|
+
body, headers, method,
|
|
44
|
+
// @ts-ignore
|
|
45
|
+
duplex: "half"
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// @ts-ignore
|
|
49
|
+
webReq.nodeJsReq = req;
|
|
50
|
+
// @ts-ignore
|
|
51
|
+
webReq.nodeJsRes = res;
|
|
52
|
+
|
|
53
|
+
let webRes = reqFetch(webReq);
|
|
54
|
+
if (webRes instanceof Promise) webRes = await webRes;
|
|
55
|
+
if (webRes===undefined) return;
|
|
56
|
+
|
|
57
|
+
let resHeaders = webRes.headers;
|
|
58
|
+
let asJson: any = {};
|
|
59
|
+
resHeaders.forEach((value, key) => asJson[key] = value);
|
|
60
|
+
|
|
61
|
+
res.writeHead(webRes.status, asJson);
|
|
62
|
+
|
|
63
|
+
if (webRes.body) {
|
|
64
|
+
const asNodeStream = jk_fs.webStreamToNodeStream(webRes.body);
|
|
65
|
+
asNodeStream.pipe(res);
|
|
66
|
+
} else {
|
|
67
|
+
res.end("");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const reqFetch = options.fetch;
|
|
72
|
+
|
|
73
|
+
if (options.tls) {
|
|
74
|
+
let key = "", cert = "";
|
|
75
|
+
|
|
76
|
+
if (options.tls instanceof Array) {
|
|
77
|
+
for (const tls of options.tls) {
|
|
78
|
+
key += tls.key;
|
|
79
|
+
cert += tls.cert;
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
key = options.tls.key;
|
|
83
|
+
cert = options.tls.cert;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
this.server = https.createServer({key, cert}, handler);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
this.server = http.createServer(handler);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const onWebSocketConnection = options.onWebSocketConnection;
|
|
93
|
+
|
|
94
|
+
if (onWebSocketConnection) {
|
|
95
|
+
const wss = new WebSocketServer({ server: this.server });
|
|
96
|
+
|
|
97
|
+
wss.on('connection', (ws, req) => {
|
|
98
|
+
onWebSocketConnection(ws as unknown as WebSocket, {
|
|
99
|
+
url: "https://" + req.headers.host! + req.url!,
|
|
100
|
+
headers: new Headers(req.headers as any)
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
requestIP(req: Request): ServerSocketAddress | null {
|
|
107
|
+
// @ts-ignore
|
|
108
|
+
let nodeReq: http.IncomingMessage = req.nodeJsReq;
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
address: nodeReq.socket.remoteAddress!,
|
|
112
|
+
port: nodeReq.socket.remotePort!,
|
|
113
|
+
family: nodeReq.socket.remoteFamily as "IPv4" | "IPv6"
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async stop(_closeActiveConnections: boolean): Promise<void> {
|
|
118
|
+
this.server.close();
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
timeout(_req: Request, _seconds: number): void {
|
|
122
|
+
// Timeout is managed globally for all the requests.
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
start() {
|
|
126
|
+
this.server.listen(this.options.port);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
//region SSE Events
|
|
131
|
+
|
|
132
|
+
interface NodeSseEvent extends SseEvent {
|
|
133
|
+
clients: http.ServerResponse[];
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export async function onSseEvent(sseEvent: SseEvent, rawReq: any): Promise<Response> {
|
|
137
|
+
const req = rawReq.nodeJsReq as unknown as http.IncomingMessage;
|
|
138
|
+
const res = rawReq.nodeJsRes as unknown as http.ServerResponse;
|
|
139
|
+
|
|
140
|
+
res.writeHead(200, {
|
|
141
|
+
'Content-Type': 'text/event-stream',
|
|
142
|
+
'Cache-Control': 'no-cache',
|
|
143
|
+
'Connection': 'keep-alive'
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
res.write(`data: ${sseEvent.getWelcomeMessage()}\n\n`);
|
|
147
|
+
|
|
148
|
+
const nodeSseEvent = sseEvent as NodeSseEvent;
|
|
149
|
+
|
|
150
|
+
if (!nodeSseEvent.clients) {
|
|
151
|
+
nodeSseEvent.clients = [];
|
|
152
|
+
|
|
153
|
+
let controller: SseEventController = {
|
|
154
|
+
send(eventName: string, data: string) {
|
|
155
|
+
let toSend = `event: ${eventName}\ndata: ${ JSON.stringify({message: data}) }\n\n`;
|
|
156
|
+
nodeSseEvent.clients.forEach(res => { res.write(toSend) });
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
close() {
|
|
160
|
+
nodeSseEvent.clients.forEach(res => {
|
|
161
|
+
if (!res.closed) {
|
|
162
|
+
res.end();
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
nodeSseEvent.clients = [];
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
nodeSseEvent.handler(controller);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
nodeSseEvent.clients.push(res);
|
|
174
|
+
|
|
175
|
+
req.on('close', () => {
|
|
176
|
+
nodeSseEvent.clients = nodeSseEvent.clients.filter(client => client !== res);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
// Allow bubbling up.
|
|
180
|
+
throw new SBPE_MustReturnWithoutResponseException();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
//endregion
|
|
184
|
+
|
|
185
|
+
//region ServerInstanceProvider
|
|
186
|
+
|
|
187
|
+
export class NodeJsServerInstanceBuilder implements ServerInstanceBuilder {
|
|
188
|
+
private readonly router: RouterContext<WebSiteRouteInfos> = createRouter<WebSiteRouteInfos>();
|
|
189
|
+
private readonly wsRouter: RouterContext<JopiWsRouteHandler> = createRouter<JopiWsRouteHandler>();
|
|
190
|
+
|
|
191
|
+
constructor(private readonly webSite: WebSiteImpl) {
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
addRoute(verb: HttpMethod, path: string, routeInfos: WebSiteRouteInfos) {
|
|
195
|
+
addRoute(this.router, verb, path, routeInfos);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
addWsRoute(path: string, handler: (ws: JopiWebSocket, infos: WebSocketConnectionInfos) => void) {
|
|
199
|
+
addRoute(this.wsRouter, "ws", path, handler);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
addSseEVent(path: string, handler: SseEvent): void {
|
|
203
|
+
handler = {...handler};
|
|
204
|
+
|
|
205
|
+
this.addRoute("GET", path, {
|
|
206
|
+
route: path,
|
|
207
|
+
|
|
208
|
+
handler: async req => {
|
|
209
|
+
return onSseEvent(handler, req.coreRequest);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
async startServer(params: { port: number; tls: any }): Promise<CoreServer> {
|
|
215
|
+
async function doFetch(req: Request): Promise<Response|undefined> {
|
|
216
|
+
const urlInfos = new URL(req.url);
|
|
217
|
+
const matched = findRoute(router, req.method, urlInfos.pathname);
|
|
218
|
+
|
|
219
|
+
if (matched) {
|
|
220
|
+
return await webSite.processRequest(matched.data.handler, matched.params, matched.data, urlInfos, req, server!);
|
|
221
|
+
} else {
|
|
222
|
+
return await webSite.processRequest(undefined, {}, undefined, urlInfos, req, server!);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const webSite = this.webSite;
|
|
227
|
+
const router = this.router;
|
|
228
|
+
|
|
229
|
+
const server = new NodeServerInstance({
|
|
230
|
+
port: String(params.port),
|
|
231
|
+
tls: params.tls,
|
|
232
|
+
fetch: doFetch,
|
|
233
|
+
|
|
234
|
+
onWebSocketConnection: (ws: WebSocket, infos: WebSocketConnectionInfos) => {
|
|
235
|
+
//const urlInfos = new URL(infos.url);
|
|
236
|
+
|
|
237
|
+
//const jws = new JopiWebSocket(this.webSite, server, ws);
|
|
238
|
+
//TODO
|
|
239
|
+
//webSite.declareNewWebSocketConnection(jws, infos, urlInfos);
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
server.start();
|
|
244
|
+
|
|
245
|
+
return server;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
updateTlsCertificate(certificate: any) {
|
|
249
|
+
// Not available for node.js
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
addPage(path: string, pageKey: string, reactComponent: React.FC<any>, routeInfos: WebSiteRouteInfos) {
|
|
253
|
+
const mustRemoveTrailingSlashs = this.webSite.mustRemoveTrailingSlashs;
|
|
254
|
+
|
|
255
|
+
routeInfos.handler = async (req) => {
|
|
256
|
+
let path = req.urlInfos.pathname;
|
|
257
|
+
|
|
258
|
+
if (path!=="/") {
|
|
259
|
+
// Node.js router don't distinguish url ending with / and without.
|
|
260
|
+
// It's why we must check it.
|
|
261
|
+
//
|
|
262
|
+
if (mustRemoveTrailingSlashs) {
|
|
263
|
+
if (path.endsWith("/")) {
|
|
264
|
+
req.urlInfos.pathname = req.urlInfos.pathname.slice(0, -1);
|
|
265
|
+
let redirectUrl = req.urlInfos.href;
|
|
266
|
+
return Response.redirect(redirectUrl, 302);
|
|
267
|
+
}
|
|
268
|
+
} else {
|
|
269
|
+
if (!path.endsWith("/")) {
|
|
270
|
+
req.urlInfos.pathname += "/";
|
|
271
|
+
let redirectUrl = req.urlInfos.href;
|
|
272
|
+
return Response.redirect(redirectUrl, 302);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return req.react_fromPage(pageKey, reactComponent);
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
routeInfos.handler = this.webSite.applyMiddlewares("GET", path, routeInfos.handler, true);
|
|
281
|
+
this.addRoute("GET", path, routeInfos);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
async tryReturnFile(params: TryReturnFileParams): Promise<Response|undefined> {
|
|
285
|
+
let stats = params.validationInfos.fileState;
|
|
286
|
+
if (!stats) return undefined;
|
|
287
|
+
|
|
288
|
+
// @ts-ignore
|
|
289
|
+
const nodeJsRes = params.req.coreRequest.nodeJsRes as http.ServerResponse;
|
|
290
|
+
|
|
291
|
+
const headers: any = {
|
|
292
|
+
"content-type": jk_fs.getMimeTypeFromName(params.filePath),
|
|
293
|
+
"content-length": stats.size
|
|
294
|
+
};
|
|
295
|
+
|
|
296
|
+
if (params.contentEncoding) {
|
|
297
|
+
headers["content-encoding"] = params.contentEncoding;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
addBrowserCacheControlHeaders(headers, params);
|
|
301
|
+
|
|
302
|
+
// Envoyer les headers
|
|
303
|
+
nodeJsRes.writeHead(200, headers);
|
|
304
|
+
|
|
305
|
+
const readStream = fs.createReadStream(params.filePath);
|
|
306
|
+
readStream.pipe(nodeJsRes);
|
|
307
|
+
|
|
308
|
+
throw new SBPE_MustReturnWithoutResponseException();
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
//endregion
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type {CoreServer, SseEvent, WebSocketConnectionInfos} from "./jopiServer.ts";
|
|
2
|
+
import {isBunJS} from "jopi-toolkit/jk_what";
|
|
3
|
+
import {BunJsServerInstanceBuilder} from "./serverImpl/server_bunjs.tsx";
|
|
4
|
+
import {NodeJsServerInstanceBuilder} from "./serverImpl/server_nodejs.ts";
|
|
5
|
+
import {
|
|
6
|
+
type HttpMethod,
|
|
7
|
+
JopiWebSocket,
|
|
8
|
+
WebSiteImpl,
|
|
9
|
+
type WebSiteRouteInfos
|
|
10
|
+
} from "./jopiWebSite.tsx";
|
|
11
|
+
import React from "react";
|
|
12
|
+
import type {TryReturnFileParams} from "./browserCacheControl.ts";
|
|
13
|
+
|
|
14
|
+
export interface ServerInstanceBuilder {
|
|
15
|
+
addRoute(verb: HttpMethod, path: string, routeInfos: WebSiteRouteInfos): void;
|
|
16
|
+
|
|
17
|
+
addWsRoute(path: string, handler: (ws: JopiWebSocket, infos: WebSocketConnectionInfos) => void): void;
|
|
18
|
+
|
|
19
|
+
addSseEVent(path: string, handler: SseEvent): void;
|
|
20
|
+
|
|
21
|
+
startServer(params: { port: number; tls: any }): Promise<CoreServer>;
|
|
22
|
+
|
|
23
|
+
updateTlsCertificate(certificate: any): void;
|
|
24
|
+
|
|
25
|
+
addPage(path: string, pageKey: string, reactComponent: React.FC<any>, routeInfos: WebSiteRouteInfos): void;
|
|
26
|
+
|
|
27
|
+
tryReturnFile(params: TryReturnFileParams): Promise<Response|undefined>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function getNewServerInstanceBuilder(webSite: WebSiteImpl): ServerInstanceBuilder {
|
|
31
|
+
if (isBunJS) {
|
|
32
|
+
return new BunJsServerInstanceBuilder(webSite);
|
|
33
|
+
} else {
|
|
34
|
+
return new NodeJsServerInstanceBuilder(webSite);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {type UserInfos, type WebSite} from "./jopiWebSite.tsx";
|
|
2
|
+
|
|
3
|
+
export interface UserLoginPassword {
|
|
4
|
+
login: string;
|
|
5
|
+
password: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface UserInfos_WithLoginPassword extends UserLoginPassword {
|
|
9
|
+
userInfos: UserInfos;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class UserStore_WithLoginPassword {
|
|
13
|
+
public readonly users: UserInfos_WithLoginPassword[] = [];
|
|
14
|
+
|
|
15
|
+
add(infos: UserInfos_WithLoginPassword) {
|
|
16
|
+
this.users.push(infos);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
setAuthHandler(webSite: WebSite) {
|
|
20
|
+
webSite.setAuthHandler<UserLoginPassword>(loginInfo => {
|
|
21
|
+
let foundUser = this.users.find(e => e.login===loginInfo.login);
|
|
22
|
+
|
|
23
|
+
if (!foundUser) {
|
|
24
|
+
return {isOk: false, errorMessage: "Unknown user"};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (loginInfo.password!==foundUser.password) {
|
|
28
|
+
return {isOk: false, errorMessage: "Wrong password"};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return {isOk: true, userInfos: foundUser.userInfos};
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Contains the crawler engine to crawl / download / transform a website.
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import {UrlMapping} from "./urlMapping.ts";
|
|
2
|
+
import type {WebSiteCrawler} from "./core.ts";
|
|
3
|
+
|
|
4
|
+
export interface CrawlerCache {
|
|
5
|
+
hasInCache(url: string, requestedByUrl: string): Promise<boolean>;
|
|
6
|
+
addToCache(url: string, response: Response, requestedByUrl: string): Promise<void>;
|
|
7
|
+
getKey(url: string): string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface CrawlerTransformUrlInfos {
|
|
11
|
+
/**
|
|
12
|
+
* The local url of the page from which this url has been found.
|
|
13
|
+
*/
|
|
14
|
+
comeFromPage: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The instance of the crawler.
|
|
18
|
+
*/
|
|
19
|
+
crawler: WebSiteCrawler;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* If true, this mean we need a final url which is ok with
|
|
23
|
+
* opening the page directly from the file-system.
|
|
24
|
+
*/
|
|
25
|
+
requireRelocatableUrl: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface CrawlerCanIgnoreIfAlreadyCrawled {
|
|
29
|
+
/**
|
|
30
|
+
* The url which will be fetched.
|
|
31
|
+
*/
|
|
32
|
+
sourceUrl: string;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface WebSiteCrawlerOptions {
|
|
36
|
+
/**
|
|
37
|
+
* If set, then will save the page inside this directory.
|
|
38
|
+
* Warning: will replace the cache value.
|
|
39
|
+
*/
|
|
40
|
+
outputDir?: string;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Allow using a cache to save the HTML pages and resource
|
|
44
|
+
* and get theses that are already in the cache.
|
|
45
|
+
*/
|
|
46
|
+
cache?: CrawlerCache;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* If defined, then allow rewriting an url found by the HTML analyzer.
|
|
50
|
+
*
|
|
51
|
+
* @param url
|
|
52
|
+
* The url found, converted to local site url.
|
|
53
|
+
* @param infos
|
|
54
|
+
* Information about the context.
|
|
55
|
+
*/
|
|
56
|
+
transformUrl?(url: string, infos: CrawlerTransformUrlInfos): string;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Is called when an URL is found and the content is HTML.
|
|
60
|
+
* Allow altering the HTML which will be processed or post-process URL.
|
|
61
|
+
*/
|
|
62
|
+
rewriteHtmlBeforeProcessing?: (html: string, url: string, sourceUrl: string) => string|Promise<string>;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Is called when an URL is found and the content is HTML.
|
|
66
|
+
* Allow altering the final HTML.
|
|
67
|
+
* Is called after URL extraction.
|
|
68
|
+
*/
|
|
69
|
+
rewriteHtmlBeforeStoring?: (html: string, url: string, sourceUrl: string) => string|Promise<string>;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Allow ignoring an entry if already crawled.
|
|
73
|
+
* The function takes and url (without a base path) and
|
|
74
|
+
* returns true if the page can be ignored, or false if it must crawl.
|
|
75
|
+
*/
|
|
76
|
+
canIgnoreIfAlreadyCrawled?: (url: string, infos: CrawlerCanIgnoreIfAlreadyCrawled) => boolean;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Alter the final HTML to make the URL relocatable.
|
|
80
|
+
* This means we can copy and paste the website without attachement to the website name.
|
|
81
|
+
* Default is true.
|
|
82
|
+
*/
|
|
83
|
+
requireRelocatableUrl?: boolean;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* A list of url which must be replaced.
|
|
87
|
+
* If one of these urls is found as an url prefix,
|
|
88
|
+
* then replace it by the baseUrl.
|
|
89
|
+
*/
|
|
90
|
+
rewriteThisUrls?: string[];
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A list of urls to scan.
|
|
94
|
+
* Allow including forgotten urls (which mainly come from CSS or JavaScript).
|
|
95
|
+
* Ex: ["/my-style.css"].
|
|
96
|
+
*/
|
|
97
|
+
scanThisUrls?: string[];
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* A mapper that allows knowing where to get data.
|
|
101
|
+
* Allow things like:
|
|
102
|
+
* "/documentation/docA" --> "https://my-docsite.local/documentaiton/docA".
|
|
103
|
+
* "/blog/my-blog-entry" --> "https://my-blog.local/my-blog-entry".
|
|
104
|
+
*/
|
|
105
|
+
urlMapping?: UrlMapping;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The url of the new website, if downloading.
|
|
109
|
+
*/
|
|
110
|
+
newWebSiteUrl?: string;
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Allow the crawler to do a pause between two call to the server.
|
|
114
|
+
* The default value is 0: no pause.
|
|
115
|
+
*/
|
|
116
|
+
pauseDuration_ms?: number;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Is called once a page is entirely downloaded.
|
|
120
|
+
* This means the page himself and all the links starting from this page.
|
|
121
|
+
* Will allow stopping the downloading by returning false.
|
|
122
|
+
*/
|
|
123
|
+
onPageFullyDownloaded?: (url: string, state: ProcessUrlResult) => void|undefined|boolean|Promise<boolean>;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Is called when a resource is downloaded (.js, .css, .png, ...)
|
|
127
|
+
*/
|
|
128
|
+
onResourceDownloaded?(url: string, state: ProcessUrlResult): void;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Allow sorting (and filtering) the pages we must download.
|
|
132
|
+
* The main use case is to prioritize some pages when there is a large breadcrumb/pager/menu.
|
|
133
|
+
*/
|
|
134
|
+
sortPagesToDownload?(allUrls: UrlSortTools): void;
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Is called when a resource returns a code which isn't 200 (ok) or a redirect.
|
|
138
|
+
* Return true if retry to download, false to stop.
|
|
139
|
+
*/
|
|
140
|
+
onInvalidResponseCodeFound?: (url: string, retryCount: number, response: CrawlerFetchResponse) => boolean|Promise<boolean>;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Is called to know if this url can be downloaded.
|
|
144
|
+
*
|
|
145
|
+
* @param url
|
|
146
|
+
* The local url of the page (ex: /my-page).
|
|
147
|
+
* @param isResource
|
|
148
|
+
* true is the url is pointing to a resource (.css,.png,...)
|
|
149
|
+
* false otherwise.
|
|
150
|
+
*/
|
|
151
|
+
canDownload?(url: string, isResource: boolean): boolean;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Is called when a URL is processed.
|
|
155
|
+
* Allow building stats or listing all urls found.
|
|
156
|
+
*/
|
|
157
|
+
onUrlProcessed?(infos: UrlProcessedInfos): void;
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Is called when the crawling is finished.
|
|
161
|
+
* @param infos
|
|
162
|
+
*/
|
|
163
|
+
onFinished?(infos: OnCrawlingFinishedInfos): void;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Allow replacing the fetch function with our own fetch.
|
|
167
|
+
*/
|
|
168
|
+
doFetch?: CrawlerFetch;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export type CrawlerFetch = (crawler: WebSiteCrawler, url: string, referer: string) => Promise<CrawlerFetchResponse>;
|
|
172
|
+
|
|
173
|
+
export interface CrawlerFetchResponse {
|
|
174
|
+
status: number;
|
|
175
|
+
headers: Headers;
|
|
176
|
+
body: ReadableStream<Uint8Array> | null;
|
|
177
|
+
text(): Promise<string>;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export interface OnCrawlingFinishedInfos {
|
|
181
|
+
remainingStack: string[]
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface UrlProcessedInfos {
|
|
185
|
+
sourceUrl: string;
|
|
186
|
+
urlCount: number;
|
|
187
|
+
localUrl: string;
|
|
188
|
+
transformedUrl: string;
|
|
189
|
+
requestedByUrl: string;
|
|
190
|
+
state: ProcessUrlResult;
|
|
191
|
+
retryCount: number;
|
|
192
|
+
|
|
193
|
+
date: number;
|
|
194
|
+
elapsed: number;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* The path inside the cache.
|
|
198
|
+
*/
|
|
199
|
+
cacheKey?: string;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export enum ProcessUrlResult {
|
|
203
|
+
/**
|
|
204
|
+
* The resource has been downloaded.
|
|
205
|
+
*/
|
|
206
|
+
OK = "ok",
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* The resource was a redirection.
|
|
210
|
+
*/
|
|
211
|
+
REDIRECTED = "redirected",
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* An error occurred while processing the resource
|
|
215
|
+
* or the resources is an error page.
|
|
216
|
+
*/
|
|
217
|
+
ERROR = "error",
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* The resource has been ignored.
|
|
221
|
+
* Probably because it was already downloaded.
|
|
222
|
+
*/
|
|
223
|
+
IGNORED = "ignored"
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export class UrlSortTools {
|
|
227
|
+
constructor(allUrls: string[]) {
|
|
228
|
+
this.allUrl = allUrls;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Remove the urls for which the filter response true
|
|
233
|
+
* and return an array with the extracted urls.
|
|
234
|
+
*/
|
|
235
|
+
remove(filter: (url: string) => boolean): UrlSortTools {
|
|
236
|
+
const removed: string[] = [];
|
|
237
|
+
const others: string[] = [];
|
|
238
|
+
|
|
239
|
+
this.allUrl.forEach(url => {
|
|
240
|
+
if (filter(url)) removed.push(url);
|
|
241
|
+
else others.push(url);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
this.removed = removed;
|
|
245
|
+
this.allUrl = others;
|
|
246
|
+
|
|
247
|
+
return this;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
sortAsc(): UrlSortTools {
|
|
251
|
+
this.allUrl = this.allUrl.sort();
|
|
252
|
+
return this;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
addRemovedBefore(): UrlSortTools {
|
|
256
|
+
if (!this.removed) return this;
|
|
257
|
+
this.allUrl = [...this.removed, ...this.allUrl];
|
|
258
|
+
this.removed = undefined;
|
|
259
|
+
return this;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
addRemovedAfter(): UrlSortTools {
|
|
263
|
+
if (!this.removed) return this;
|
|
264
|
+
this.allUrl = [...this.allUrl, ...this.removed];
|
|
265
|
+
this.removed = undefined;
|
|
266
|
+
return this;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
result(): string[] {
|
|
270
|
+
return this.allUrl;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
removed?: string[];
|
|
274
|
+
allUrl: string[];
|
|
275
|
+
}
|