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,678 @@
|
|
|
1
|
+
/// <reference path="../@core/cheerio.d.ts" />
|
|
2
|
+
|
|
3
|
+
import {DirectFileCache} from "./directFileCache.ts";
|
|
4
|
+
import {UrlMapping} from "./urlMapping.ts";
|
|
5
|
+
import * as cheerio from 'cheerio';
|
|
6
|
+
import {getErrorMessage} from "jopi-toolkit/jk_tools";
|
|
7
|
+
|
|
8
|
+
// @ts-ignore no ts definition
|
|
9
|
+
import parseCssUrls from "css-url-parser";
|
|
10
|
+
import {applyDefaults, tick} from "./utils.ts";
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
type CrawlerCache, type CrawlerFetchResponse,
|
|
14
|
+
type OnCrawlingFinishedInfos, ProcessUrlResult, UrlSortTools, type WebSiteCrawlerOptions
|
|
15
|
+
} from "./common.ts";
|
|
16
|
+
|
|
17
|
+
interface UrlGroup {
|
|
18
|
+
url: string;
|
|
19
|
+
stack?: string[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export class WebSiteCrawler {
|
|
23
|
+
private readonly urlDone: string[] = [];
|
|
24
|
+
|
|
25
|
+
private readonly newWebSite_basePath: string;
|
|
26
|
+
private readonly newWebSite_lcBasePath: string;
|
|
27
|
+
private readonly newWebSite_urlInfos: URL;
|
|
28
|
+
|
|
29
|
+
private readonly requiredPrefix: string;
|
|
30
|
+
private readonly requiredPrefix2: string;
|
|
31
|
+
|
|
32
|
+
private isStarted = false;
|
|
33
|
+
|
|
34
|
+
private readonly options: WebSiteCrawlerOptions;
|
|
35
|
+
private readonly cache?: CrawlerCache;
|
|
36
|
+
|
|
37
|
+
private currentGroup: UrlGroup = {url:"", stack:[]};
|
|
38
|
+
private readonly groupStack: UrlGroup[] = [];
|
|
39
|
+
|
|
40
|
+
private urlCount: number = 1;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Create a new crawler instance.
|
|
44
|
+
*
|
|
45
|
+
* @param sourceWebSite
|
|
46
|
+
* The url of the website to crawl.
|
|
47
|
+
* @param options
|
|
48
|
+
* Options for complex cases.
|
|
49
|
+
*/
|
|
50
|
+
constructor(sourceWebSite: string, options?: WebSiteCrawlerOptions) {
|
|
51
|
+
options = applyDefaults(options, {
|
|
52
|
+
requireRelocatableUrl: true,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
options = this.options = {...options};
|
|
56
|
+
|
|
57
|
+
let newWebSiteUrl = new URL(options.newWebSiteUrl || sourceWebSite).origin;
|
|
58
|
+
this.newWebSite_basePath = newWebSiteUrl;
|
|
59
|
+
this.newWebSite_lcBasePath = newWebSiteUrl.toLowerCase();
|
|
60
|
+
|
|
61
|
+
const urlInfos = new URL(newWebSiteUrl);
|
|
62
|
+
this.newWebSite_urlInfos = urlInfos;
|
|
63
|
+
|
|
64
|
+
this.requiredPrefix = urlInfos.origin + "/";
|
|
65
|
+
this.requiredPrefix2 = "//" + urlInfos.hostname;
|
|
66
|
+
|
|
67
|
+
let sourceWebSiteOrigin = new URL(sourceWebSite).origin;
|
|
68
|
+
|
|
69
|
+
if (sourceWebSiteOrigin!==newWebSiteUrl) {
|
|
70
|
+
if (!options.rewriteThisUrls) options.rewriteThisUrls = [];
|
|
71
|
+
|
|
72
|
+
// Allow rewriting the url.
|
|
73
|
+
if (!options.rewriteThisUrls.includes(sourceWebSiteOrigin)) {
|
|
74
|
+
options.rewriteThisUrls.push(sourceWebSiteOrigin);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!options.urlMapping) {
|
|
79
|
+
options.urlMapping = new UrlMapping(sourceWebSite);
|
|
80
|
+
} else {
|
|
81
|
+
if (!options.rewriteThisUrls) options.rewriteThisUrls = [];
|
|
82
|
+
|
|
83
|
+
const knownOrigin = options.urlMapping.getKnownOrigins();
|
|
84
|
+
|
|
85
|
+
knownOrigin.forEach(origin => {
|
|
86
|
+
if (!options.rewriteThisUrls!.includes(origin)) {
|
|
87
|
+
options.rewriteThisUrls!.push(origin);
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (options.cache) {
|
|
93
|
+
this.cache = options.cache;
|
|
94
|
+
}
|
|
95
|
+
else if (options.outputDir) {
|
|
96
|
+
this.cache = new DirectFileCache(options.outputDir);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Start the processing
|
|
102
|
+
*/
|
|
103
|
+
public async start(entryPoint?: string): Promise<OnCrawlingFinishedInfos> {
|
|
104
|
+
if (!entryPoint) {
|
|
105
|
+
entryPoint = this.newWebSite_basePath;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const newGroup = {url: entryPoint, stack: []};
|
|
109
|
+
this.groupStack.push(newGroup);
|
|
110
|
+
this.currentGroup = newGroup;
|
|
111
|
+
|
|
112
|
+
if (this.options.scanThisUrls) {
|
|
113
|
+
for (let i = 0; i < this.options.scanThisUrls.length; i++) {
|
|
114
|
+
this.pushUrl(this.options.scanThisUrls[i]);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
await this.processStack();
|
|
119
|
+
|
|
120
|
+
const finishedInfos: OnCrawlingFinishedInfos = {
|
|
121
|
+
remainingStack: this.groupStack.map(g => g.url)
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
if (this.options.onFinished) {
|
|
125
|
+
this.options.onFinished(finishedInfos);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return finishedInfos;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Take an url and clean this url.
|
|
133
|
+
* - Resolve relative url.
|
|
134
|
+
* - Exclude special url ("mailto:", "tel:", ...)
|
|
135
|
+
* - Exclude anchor url (starts with #).
|
|
136
|
+
*/
|
|
137
|
+
private _cleanUpUrl(url: string | null): string | null {
|
|
138
|
+
return this.cleanUpUrlAux(url, false);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Is like cleanUpUrl but with a special case for CSS.
|
|
143
|
+
*
|
|
144
|
+
* Url in CSS is related to the dir of the CSS file.
|
|
145
|
+
* If I have "myImage.jpg" then it's https//my/css/dir/myImage.jpg.
|
|
146
|
+
*/
|
|
147
|
+
private cleanUpCssUrl(url: string, baseUrl: string): string | null {
|
|
148
|
+
return this.cleanUpUrlAux(url, true, baseUrl);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
private cleanUpUrlAux(url: string | null, isCss: boolean, currentUrl?: string): string | null {
|
|
152
|
+
if (!url) return null;
|
|
153
|
+
|
|
154
|
+
url = url.trim();
|
|
155
|
+
if (!url) return null;
|
|
156
|
+
|
|
157
|
+
if (url[0] === '#') return null;
|
|
158
|
+
|
|
159
|
+
// Convert to an absolute url.
|
|
160
|
+
if (!url.includes("://")) {
|
|
161
|
+
if (url[0]==="?") {
|
|
162
|
+
let currentUrl = this.currentGroup.url;
|
|
163
|
+
let idx = currentUrl.indexOf("?");
|
|
164
|
+
if (idx!==-1) currentUrl = currentUrl.substring(0, idx);
|
|
165
|
+
url = currentUrl + url;
|
|
166
|
+
}
|
|
167
|
+
else if (url.includes(":")) {
|
|
168
|
+
if (url.startsWith("data:")) return null;
|
|
169
|
+
if (url.startsWith("javascript:")) return null;
|
|
170
|
+
if (url.startsWith("mailto:")) return null;
|
|
171
|
+
if (url.startsWith("tel:")) return null;
|
|
172
|
+
if (url.startsWith("sms:")) return null;
|
|
173
|
+
if (url.startsWith("ftp:")) return null;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (url.startsWith("//")) {
|
|
177
|
+
if (!url.toLowerCase().startsWith(this.requiredPrefix2)) return null;
|
|
178
|
+
url = this.newWebSite_urlInfos.protocol + url;
|
|
179
|
+
} else if (url[0] === "/") {
|
|
180
|
+
url = resolveRelativeUrl(url, this.newWebSite_urlInfos);
|
|
181
|
+
} else {
|
|
182
|
+
if (isCss) {
|
|
183
|
+
url = resolveRelativeUrl(url, new URL(currentUrl!));
|
|
184
|
+
} else {
|
|
185
|
+
url = resolveRelativeUrl(url, this.newWebSite_urlInfos);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
} else {
|
|
189
|
+
url = this.rewriteSourceSiteUrl(url);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (!url.toLowerCase().startsWith(this.requiredPrefix)) {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return url.trim();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Is called when we want to add an url to the processing queue.
|
|
201
|
+
* A call to cleanUpUrl must have been done before.
|
|
202
|
+
*/
|
|
203
|
+
private pushUrl(url: string | null): string {
|
|
204
|
+
if (!url) return "";
|
|
205
|
+
|
|
206
|
+
url = this._cleanUpUrl(url);
|
|
207
|
+
if (!url) return "";
|
|
208
|
+
|
|
209
|
+
if (this.urlDone.includes(url)) return url;
|
|
210
|
+
this.urlDone.push(url);
|
|
211
|
+
|
|
212
|
+
if (this.options.canDownload) {
|
|
213
|
+
if (!this.options.canDownload(url.substring(this.requiredPrefix.length), this.isResource(url))) {
|
|
214
|
+
return url;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (!this.currentGroup.stack) this.currentGroup.stack = [];
|
|
219
|
+
this.currentGroup.stack.push(url);
|
|
220
|
+
|
|
221
|
+
return url;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private async processStack(): Promise<void> {
|
|
225
|
+
if (this.isStarted) return;
|
|
226
|
+
this.isStarted = true;
|
|
227
|
+
|
|
228
|
+
while (true) {
|
|
229
|
+
const group = this.groupStack.shift();
|
|
230
|
+
if (!group) break;
|
|
231
|
+
|
|
232
|
+
if (!await this.processGroup(group)) break;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
this.isStarted = false;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* Will fetch an url and process the result.
|
|
240
|
+
* If the result is HTML, it will be analyzed.
|
|
241
|
+
* Also, if it's CSS.
|
|
242
|
+
*/
|
|
243
|
+
private async processGroup(group: UrlGroup): Promise<boolean> {
|
|
244
|
+
this.currentGroup = group;
|
|
245
|
+
|
|
246
|
+
// Process the group main url.
|
|
247
|
+
const processResponse = await this.processUrl(group.url);
|
|
248
|
+
|
|
249
|
+
// Process the resource inside the group.
|
|
250
|
+
if (group.stack) {
|
|
251
|
+
let isResource: string[]|undefined;
|
|
252
|
+
let isNotResource: string[]|undefined;
|
|
253
|
+
|
|
254
|
+
group.stack.forEach(url => {
|
|
255
|
+
if (this.isResource(url)) {
|
|
256
|
+
if (!isResource) isResource = [];
|
|
257
|
+
isResource.push(url);
|
|
258
|
+
} else {
|
|
259
|
+
if (!isNotResource) isNotResource = [];
|
|
260
|
+
isNotResource.push(url);
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
group.stack = undefined;
|
|
265
|
+
|
|
266
|
+
// Stack the pages coming from the resources.
|
|
267
|
+
if (isNotResource) {
|
|
268
|
+
if ((isNotResource.length>1) && this.options.sortPagesToDownload) {
|
|
269
|
+
const sortTools = new UrlSortTools(isNotResource);
|
|
270
|
+
this.options.sortPagesToDownload(sortTools);
|
|
271
|
+
isNotResource = sortTools.result();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
isNotResource.forEach(url => {
|
|
275
|
+
this.groupStack.push({url});
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
// Process the resources now.
|
|
280
|
+
// Allow the page to be completely loaded.
|
|
281
|
+
//
|
|
282
|
+
while (isResource) {
|
|
283
|
+
const resources = isResource;
|
|
284
|
+
isResource = undefined;
|
|
285
|
+
|
|
286
|
+
for (let i = 0; i < resources.length; i++) {
|
|
287
|
+
const resUrl = resources[i];
|
|
288
|
+
const resState = await this.processUrl(resUrl);
|
|
289
|
+
|
|
290
|
+
if (this.options.onResourceDownloaded) {
|
|
291
|
+
this.options.onResourceDownloaded(resUrl, resState);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
// Come from CSS.
|
|
296
|
+
if (group.stack) {
|
|
297
|
+
isResource = group.stack;
|
|
298
|
+
group.stack = undefined;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
if (this.options.onPageFullyDownloaded) {
|
|
304
|
+
const res = this.options.onPageFullyDownloaded(group.url, processResponse);
|
|
305
|
+
if (res instanceof Promise) await res;
|
|
306
|
+
if (res===false) return false;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
return true;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
private isResource(u: string) {
|
|
313
|
+
const url = new URL(u);
|
|
314
|
+
u = url.pathname;
|
|
315
|
+
|
|
316
|
+
let idx = u.lastIndexOf(".");
|
|
317
|
+
if (idx===-1) return false;
|
|
318
|
+
let ext = u.substring(idx);
|
|
319
|
+
|
|
320
|
+
return gExtensionForResourceType.includes(ext);
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
private async processUrl(sourceUrl: string): Promise<ProcessUrlResult> {
|
|
324
|
+
const sendSignal = (state: ProcessUrlResult) => {
|
|
325
|
+
if (this.options.onUrlProcessed) {
|
|
326
|
+
const date = Date.now();
|
|
327
|
+
const elapsed = date - now;
|
|
328
|
+
|
|
329
|
+
const cacheKey = this.cache?.getKey(transformedUrl);
|
|
330
|
+
|
|
331
|
+
this.options.onUrlProcessed({
|
|
332
|
+
sourceUrl, requestedByUrl,
|
|
333
|
+
state, retryCount,
|
|
334
|
+
transformedUrl,
|
|
335
|
+
localUrl,
|
|
336
|
+
cacheKey,
|
|
337
|
+
urlCount: this.urlCount,
|
|
338
|
+
date, elapsed
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
return state;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
let retryCount = 0;
|
|
346
|
+
const localUrl = sourceUrl.substring(this.newWebSite_basePath.length);
|
|
347
|
+
|
|
348
|
+
const now = Date.now();
|
|
349
|
+
const partialUrl = sourceUrl.substring(this.newWebSite_basePath.length);
|
|
350
|
+
const requestedByUrl = this.currentGroup.url;
|
|
351
|
+
|
|
352
|
+
const mappingResult = this.options.urlMapping!.resolveURL(partialUrl);
|
|
353
|
+
if (!mappingResult) return ProcessUrlResult.IGNORED;
|
|
354
|
+
|
|
355
|
+
let transformedUrl = sourceUrl;
|
|
356
|
+
|
|
357
|
+
if (this.cache) {
|
|
358
|
+
transformedUrl = this.transformFoundUrl(sourceUrl, false);
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
if (this.cache && this.options.canIgnoreIfAlreadyCrawled) {
|
|
362
|
+
const isInCache = await this.cache.hasInCache(transformedUrl, requestedByUrl)
|
|
363
|
+
|
|
364
|
+
if (isInCache && this.options.canIgnoreIfAlreadyCrawled(
|
|
365
|
+
sourceUrl.substring(this.newWebSite_basePath.length), {sourceUrl: mappingResult.url})) {
|
|
366
|
+
return sendSignal(ProcessUrlResult.IGNORED);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
if (mappingResult.wakeUpServer) {
|
|
371
|
+
await mappingResult.wakeUpServer();
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
this.urlCount++;
|
|
375
|
+
|
|
376
|
+
if (this.options.pauseDuration_ms) {
|
|
377
|
+
await tick(this.options.pauseDuration_ms);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
while (true) {
|
|
381
|
+
try {
|
|
382
|
+
let res: CrawlerFetchResponse;
|
|
383
|
+
|
|
384
|
+
if (this.options.doFetch) {
|
|
385
|
+
res = await this.options.doFetch(this, mappingResult.url, requestedByUrl);
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
// noinspection JSUnusedGlobalSymbols
|
|
389
|
+
res = await fetch(mappingResult.url, {
|
|
390
|
+
// > This option allows avoiding SSL certificate check.
|
|
391
|
+
|
|
392
|
+
// @ts-ignore
|
|
393
|
+
rejectUnauthorized: false,
|
|
394
|
+
|
|
395
|
+
requestCert: false,
|
|
396
|
+
|
|
397
|
+
tls: {
|
|
398
|
+
rejectUnauthorized: false,
|
|
399
|
+
checkServerIdentity: () => { return undefined }
|
|
400
|
+
},
|
|
401
|
+
|
|
402
|
+
// Allow avoiding automatic redirections.
|
|
403
|
+
// @ts-ignore
|
|
404
|
+
redirect: 'manual',
|
|
405
|
+
|
|
406
|
+
headers: {
|
|
407
|
+
"referer": requestedByUrl
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
//verbose: true
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
if (res.status !== 200) {
|
|
415
|
+
if (res.status >= 300 && res.status < 400) {
|
|
416
|
+
const location = res.headers.get("Location");
|
|
417
|
+
if (location) this.pushUrl(location);
|
|
418
|
+
return sendSignal(ProcessUrlResult.REDIRECTED);
|
|
419
|
+
} else {
|
|
420
|
+
let canContinue = false;
|
|
421
|
+
|
|
422
|
+
if (this.options.onInvalidResponseCodeFound) {
|
|
423
|
+
let what = this.options.onInvalidResponseCodeFound(sourceUrl, retryCount, res);
|
|
424
|
+
if (what instanceof Promise) what = await what;
|
|
425
|
+
canContinue = what;
|
|
426
|
+
} else if (retryCount < 3) {
|
|
427
|
+
// Retry 3 times, with a longer pause each time.
|
|
428
|
+
await tick(1000 * retryCount);
|
|
429
|
+
canContinue = true;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
if (!canContinue) {
|
|
433
|
+
return sendSignal(ProcessUrlResult.ERROR);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
retryCount++;
|
|
437
|
+
|
|
438
|
+
// Will retry automatically.
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
const contentType = res.headers.get("content-type");
|
|
444
|
+
|
|
445
|
+
if (contentType) {
|
|
446
|
+
if (contentType.startsWith("text/html")) {
|
|
447
|
+
let html = await res.text();
|
|
448
|
+
|
|
449
|
+
if (this.options.rewriteHtmlBeforeProcessing) {
|
|
450
|
+
let res = this.options.rewriteHtmlBeforeProcessing(html, sourceUrl.substring(this.newWebSite_basePath.length), mappingResult.url);
|
|
451
|
+
if (res instanceof Promise) res = await res;
|
|
452
|
+
html = res;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
html = await this.processHtml(html);
|
|
456
|
+
|
|
457
|
+
if (this.options.rewriteHtmlBeforeStoring) {
|
|
458
|
+
let res = this.options.rewriteHtmlBeforeStoring(html, sourceUrl.substring(this.newWebSite_basePath.length), mappingResult.url);
|
|
459
|
+
if (res instanceof Promise) res = await res;
|
|
460
|
+
html = res;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
res = new Response(html, {status: 200, headers: res.headers});
|
|
464
|
+
} else if (contentType.startsWith("text/css")) {
|
|
465
|
+
const content = await res.text();
|
|
466
|
+
const cssUrls = parseCssUrls(content) as string[];
|
|
467
|
+
|
|
468
|
+
if (cssUrls.length) {
|
|
469
|
+
cssUrls.forEach(u => {
|
|
470
|
+
const cleanedUrl = this.cleanUpCssUrl(u, sourceUrl);
|
|
471
|
+
if (cleanedUrl) this.pushUrl(cleanedUrl);
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
res = new Response(content, {status: 200, headers: res.headers});
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
if (this.cache) {
|
|
480
|
+
let hRes = new Response(res.body, {status: res.status, headers: res.headers});
|
|
481
|
+
await this.cache.addToCache(transformedUrl, hRes, requestedByUrl);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
return sendSignal(ProcessUrlResult.OK);
|
|
485
|
+
}
|
|
486
|
+
catch (e: any) {
|
|
487
|
+
console.error("Crawler - Error while fetching:", sourceUrl);
|
|
488
|
+
console.error("|--> Message:", getErrorMessage(e));
|
|
489
|
+
console.log(e);
|
|
490
|
+
|
|
491
|
+
return sendSignal(ProcessUrlResult.ERROR);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Process an HTML file, which consiste:
|
|
498
|
+
* - Extracting the url.
|
|
499
|
+
* - Replacing this url inside the HTML to convert them.
|
|
500
|
+
*/
|
|
501
|
+
private async processHtml(html: string): Promise<string> {
|
|
502
|
+
// Extract all url and rewrite them inside the html.
|
|
503
|
+
// Will emit calls to addUrl for each url found.
|
|
504
|
+
|
|
505
|
+
const $ = cheerio.load(html);
|
|
506
|
+
|
|
507
|
+
$("img, script, iframe, source").each((_i, node) => {
|
|
508
|
+
let url = node.attribs["src"];
|
|
509
|
+
|
|
510
|
+
if (url) {
|
|
511
|
+
url = this.pushUrl(url);
|
|
512
|
+
if (url.length) node.attribs["src"] = this.transformFoundUrl(url);
|
|
513
|
+
}
|
|
514
|
+
});
|
|
515
|
+
|
|
516
|
+
$("a, link").each((_i, node) => {
|
|
517
|
+
let url = node.attribs["href"];
|
|
518
|
+
|
|
519
|
+
if (url) {
|
|
520
|
+
url = this.pushUrl(url);
|
|
521
|
+
if (url.length) {
|
|
522
|
+
node.attribs["href"] = this.transformFoundUrl(url);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
$("img").each((_i, node) => {
|
|
528
|
+
let srcset = node.attribs["srcset"];
|
|
529
|
+
if (!srcset) return;
|
|
530
|
+
|
|
531
|
+
const parts = srcset.split(",");
|
|
532
|
+
let newSrcset = "";
|
|
533
|
+
|
|
534
|
+
parts.forEach(p => {
|
|
535
|
+
p = p.trim();
|
|
536
|
+
const idx = p.indexOf(" ");
|
|
537
|
+
if (idx === -1) return;
|
|
538
|
+
|
|
539
|
+
let url = p.substring(0, idx);
|
|
540
|
+
const size = p.substring(idx + 1);
|
|
541
|
+
|
|
542
|
+
let newUrl = this.pushUrl(url);
|
|
543
|
+
if (url.length) url = newUrl;
|
|
544
|
+
|
|
545
|
+
url = this.transformFoundUrl(url);
|
|
546
|
+
newSrcset += "," + url + " " + size;
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
node.attribs["srcset"] = newSrcset.substring(1);
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
html = $.html();
|
|
553
|
+
|
|
554
|
+
// Security for residual urls.
|
|
555
|
+
if (html.includes(this.newWebSite_basePath + "/"))
|
|
556
|
+
html = html.replaceAll(this.newWebSite_basePath, "")
|
|
557
|
+
if (html.includes(this.newWebSite_basePath))
|
|
558
|
+
html = html.replaceAll(this.newWebSite_basePath, "/")
|
|
559
|
+
|
|
560
|
+
return html;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
/**
|
|
564
|
+
* Allow rewriting the url from a source site (where we take our pages)
|
|
565
|
+
* to transform this url to a local url (our website).
|
|
566
|
+
*/
|
|
567
|
+
rewriteSourceSiteUrl(url: string): string {
|
|
568
|
+
if (this.options.rewriteThisUrls) {
|
|
569
|
+
for (let i=0; i<this.options.rewriteThisUrls.length; i++) {
|
|
570
|
+
const prefix = this.options.rewriteThisUrls[i];
|
|
571
|
+
|
|
572
|
+
if (url.startsWith(prefix)) {
|
|
573
|
+
url = this.newWebSite_basePath + url.substring(prefix.length);
|
|
574
|
+
return url;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
return url;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Allow transforming an url found by the HTML parser.
|
|
584
|
+
*/
|
|
585
|
+
transformFoundUrl(url: string, enableRelocatable: boolean = true) {
|
|
586
|
+
if (this.options.transformUrl) {
|
|
587
|
+
url = this.options.transformUrl(url, {
|
|
588
|
+
crawler: this,
|
|
589
|
+
comeFromPage: this.currentGroup.url!,
|
|
590
|
+
requireRelocatableUrl: this.options.requireRelocatableUrl!
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
if (enableRelocatable && this.options.requireRelocatableUrl) {
|
|
595
|
+
url = this.urlTool_buildFileSystemUrl(url);
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
return url;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/**
|
|
602
|
+
* Clean up the url to make it compatible with the file-system.
|
|
603
|
+
* Will remove the query-string and the anchors part.
|
|
604
|
+
* And make url relatif (with "../.." as a prefix).
|
|
605
|
+
*
|
|
606
|
+
* Why does relatif url are required?
|
|
607
|
+
* For example, I have a HTML page: file://folderA/webSiteRoot/myPage/index.html
|
|
608
|
+
* And now a css: /my/css/folder/style.css
|
|
609
|
+
* Here the final url will be: file://folderA/webSiteRoot/myPage/my/css/folder/style.css
|
|
610
|
+
* and not: file://folderA/webSiteRoot/my/css/folder/style.css
|
|
611
|
+
* It's why my/css/folder/style.css
|
|
612
|
+
* must be transformed as ../my/css/folder/style.css
|
|
613
|
+
* (only inside this page)
|
|
614
|
+
*/
|
|
615
|
+
urlTool_buildFileSystemUrl(url: string): string {
|
|
616
|
+
// Allow to not always check.
|
|
617
|
+
if (!this.options.requireRelocatableUrl) return url;
|
|
618
|
+
|
|
619
|
+
let idx = url.indexOf("?");
|
|
620
|
+
if (idx !== -1) url = url.substring(0, idx);
|
|
621
|
+
|
|
622
|
+
idx = url.indexOf("#");
|
|
623
|
+
if (idx !== -1) url = url.substring(0, idx);
|
|
624
|
+
|
|
625
|
+
// > If not a file, then it a directory.
|
|
626
|
+
// Transform it to be a /index.html file.
|
|
627
|
+
|
|
628
|
+
if (url.endsWith("/")) {
|
|
629
|
+
url += "index.html";
|
|
630
|
+
} else {
|
|
631
|
+
const lastSlash = url.lastIndexOf("/");
|
|
632
|
+
const lastSegment = lastSlash === -1 ? url : url.substring(lastSlash + 1);
|
|
633
|
+
|
|
634
|
+
if (!lastSegment.includes(".")) {
|
|
635
|
+
url += "/index.html";
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
// Make the url relatif.
|
|
640
|
+
//
|
|
641
|
+
if (url.startsWith(this.newWebSite_lcBasePath)) {
|
|
642
|
+
url = url.substring(this.newWebSite_lcBasePath.length + 1);
|
|
643
|
+
|
|
644
|
+
let currentUrl = this.currentGroup.url.substring(this.newWebSite_lcBasePath.length + 1);
|
|
645
|
+
if (!currentUrl) return url;
|
|
646
|
+
if (url === currentUrl) return url;
|
|
647
|
+
|
|
648
|
+
let backCount = currentUrl.split("/").length;
|
|
649
|
+
if (currentUrl.endsWith("/")) backCount--;
|
|
650
|
+
|
|
651
|
+
for (let i = 0; i < backCount; i++) url = "../" + url;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
return url;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
function resolveRelativeUrl(url: string, baseUrl: URL): string {
|
|
659
|
+
if (url[0]==="/") {
|
|
660
|
+
if (url[1]==="/") {
|
|
661
|
+
const urlInfos = new URL(url);
|
|
662
|
+
urlInfos.protocol = baseUrl.protocol;
|
|
663
|
+
urlInfos.port = baseUrl.port;
|
|
664
|
+
return urlInfos.toString();
|
|
665
|
+
} else {
|
|
666
|
+
return baseUrl.toString() + url.substring(1);
|
|
667
|
+
}
|
|
668
|
+
} else if (url[0]===".") {
|
|
669
|
+
return new URL(url, baseUrl).toString();
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
return url;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
const gExtensionForResourceType = [
|
|
676
|
+
".css", ".js", ".jpg", ".png", ".jpeg", ".gif", ".svg", ".webp",
|
|
677
|
+
".woff", ".woff2", ".ttf", ".txt", ".avif", ".ico"
|
|
678
|
+
];
|