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,403 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import {type ChildProcess, spawn} from "node:child_process";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import * as jk_app from "jopi-toolkit/jk_app";
|
|
5
|
+
import * as jk_fs from "jopi-toolkit/jk_fs";
|
|
6
|
+
import * as jk_os from "jopi-toolkit/jk_os";
|
|
7
|
+
import * as jk_term from "jopi-toolkit/jk_term";
|
|
8
|
+
import {SourceChangesWatcher} from "./sourceChangesWatcher.ts";
|
|
9
|
+
|
|
10
|
+
// *************************
|
|
11
|
+
const FORCE_LOG = false;
|
|
12
|
+
const VERSION = "20251118a";
|
|
13
|
+
// *************************
|
|
14
|
+
|
|
15
|
+
let mustLog = false; // Set env var JOPI_LOG to 1 to enable.
|
|
16
|
+
|
|
17
|
+
interface WatchInfos {
|
|
18
|
+
needHot: boolean;
|
|
19
|
+
needWatch: boolean;
|
|
20
|
+
needUiWatch: boolean;
|
|
21
|
+
|
|
22
|
+
hasJopiWatchTask?: boolean;
|
|
23
|
+
hasJopiBuildTask_node?: boolean;
|
|
24
|
+
hasJopiWatchTask_node?: boolean;
|
|
25
|
+
hasJopiWatchTask_bun?: boolean;
|
|
26
|
+
hasJopiBuildTask_bun?: boolean;
|
|
27
|
+
|
|
28
|
+
packageJsonFilePath?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
enum DevModType {
|
|
32
|
+
NONE = "none",
|
|
33
|
+
FULL_RELOAD = "full-reload",
|
|
34
|
+
UI_REBUILD = "ui-rebuild"
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getDevModeType(): DevModType {
|
|
38
|
+
let modFullReload = false;
|
|
39
|
+
let modUiRebuild = false;
|
|
40
|
+
|
|
41
|
+
//region Test jopi-dev
|
|
42
|
+
|
|
43
|
+
let idx = process.argv.indexOf("--jopi-dev");
|
|
44
|
+
|
|
45
|
+
if (idx!==-1) {
|
|
46
|
+
process.argv.splice(idx, 1);
|
|
47
|
+
modFullReload = true;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (process.env.JOPI_DEV === "1") {
|
|
51
|
+
modFullReload = true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//endregion
|
|
55
|
+
|
|
56
|
+
//region Test jopi-dev-ui
|
|
57
|
+
|
|
58
|
+
idx = process.argv.indexOf("--jopi-dev-ui");
|
|
59
|
+
|
|
60
|
+
if (idx!==-1) {
|
|
61
|
+
process.argv.splice(idx, 1);
|
|
62
|
+
modUiRebuild = true;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (process.env.JOPI_DEV_UI === "1") {
|
|
66
|
+
modUiRebuild = true;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
//endregion
|
|
70
|
+
|
|
71
|
+
if (modUiRebuild) return DevModType.UI_REBUILD;
|
|
72
|
+
if (modFullReload) return DevModType.FULL_RELOAD;
|
|
73
|
+
return DevModType.NONE;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export async function jopiLauncherTool(jsEngine: string) {
|
|
77
|
+
function execTask(taskName: string): Promise<void> {
|
|
78
|
+
return new Promise((resolve, reject) => {
|
|
79
|
+
let cwd = path.dirname(config.packageJsonFilePath!);
|
|
80
|
+
let cmd = isNodeJs ? "npm" : "bun";
|
|
81
|
+
const child = spawn(cmd, ["run", taskName], {stdio: "inherit", cwd, env});
|
|
82
|
+
|
|
83
|
+
child.on('exit', (code) => {
|
|
84
|
+
if (code === 0) { resolve() }
|
|
85
|
+
else { reject(new Error(`Task ${taskName} exited with code ${code}`)); }
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
child.on('error', (err) => {
|
|
89
|
+
reject(err);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function onSpawned() {
|
|
95
|
+
// Nothing to do. Keep for future usages.
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function addKnownPackages(toPreload: string[], toSearch: string[]) {
|
|
99
|
+
if (!toSearch) return;
|
|
100
|
+
|
|
101
|
+
for (const key in toSearch) {
|
|
102
|
+
if (knowPackagesToPreload.includes(key)) {
|
|
103
|
+
toPreload.push(key);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function getPreloadModules() {
|
|
109
|
+
const packageJsonPath = jk_app.findPackageJson();
|
|
110
|
+
|
|
111
|
+
if (!packageJsonPath) {
|
|
112
|
+
return [];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
const packageContent = fs.readFileSync(packageJsonPath, 'utf8');
|
|
117
|
+
const packageData = JSON.parse(packageContent);
|
|
118
|
+
|
|
119
|
+
let toPreload: string[] = [];
|
|
120
|
+
|
|
121
|
+
let jopi = packageData.jopi;
|
|
122
|
+
|
|
123
|
+
if (jopi && jopi.preload) {
|
|
124
|
+
if (Array.isArray(jopi.preload)) {
|
|
125
|
+
toPreload = [...toPreload, ...jopi.preload];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
addKnownPackages(toPreload, packageData["devDependencies"]);
|
|
130
|
+
addKnownPackages(toPreload, packageData["dependencies"]);
|
|
131
|
+
|
|
132
|
+
return toPreload;
|
|
133
|
+
|
|
134
|
+
} catch {
|
|
135
|
+
// Ignore parsing errors and continue without preload modules.
|
|
136
|
+
return [];
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
async function getConfiguration(): Promise<WatchInfos> {
|
|
141
|
+
let res: WatchInfos = {
|
|
142
|
+
needHot: false,
|
|
143
|
+
needUiWatch: gDevModeType === DevModType.UI_REBUILD,
|
|
144
|
+
needWatch: gDevModeType === DevModType.FULL_RELOAD
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
let pckJson = jk_app.findPackageJson();
|
|
148
|
+
|
|
149
|
+
if (pckJson) {
|
|
150
|
+
if (mustLog) console.log("JopiN - package.json file found at", pckJson);
|
|
151
|
+
|
|
152
|
+
res.packageJsonFilePath = pckJson;
|
|
153
|
+
|
|
154
|
+
try {
|
|
155
|
+
let json = JSON.parse(await jk_fs.readTextFromFile(pckJson));
|
|
156
|
+
let jopi: any = json["jopi"];
|
|
157
|
+
|
|
158
|
+
if (jopi) {
|
|
159
|
+
if (jopi.needUiWatch===true) {
|
|
160
|
+
res.needUiWatch = true;
|
|
161
|
+
}
|
|
162
|
+
else if (jopi.watch===true) {
|
|
163
|
+
res.needWatch = true;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (json.scripts) {
|
|
168
|
+
let scripts = json.scripts;
|
|
169
|
+
|
|
170
|
+
if (scripts.jopiWatch) res.hasJopiWatchTask = true;
|
|
171
|
+
if (scripts.jopiWatch_node) res.hasJopiWatchTask_node = true;
|
|
172
|
+
if (scripts.jopiWatch_bun) res.hasJopiWatchTask_bun = true;
|
|
173
|
+
|
|
174
|
+
if (scripts.jopiBuild_node) res.hasJopiBuildTask_node = true;
|
|
175
|
+
if (scripts.jopiBuild_bun) res.hasJopiBuildTask_bun = true;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
catch (e) {
|
|
179
|
+
console.error(e);
|
|
180
|
+
}
|
|
181
|
+
} else if (process.env.NODE_ENV !== 'production') {
|
|
182
|
+
console.warn("JopiN - package.json not found, can't enable file watching");
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
let watch = process.env.WATCH;
|
|
186
|
+
|
|
187
|
+
if (watch) {
|
|
188
|
+
switch (watch) {
|
|
189
|
+
case "0":
|
|
190
|
+
case "false":
|
|
191
|
+
case "no":
|
|
192
|
+
break;
|
|
193
|
+
case "1":
|
|
194
|
+
case "true":
|
|
195
|
+
case "yes":
|
|
196
|
+
res.needWatch = true;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return res;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const importFlag = jsEngine === "node" ? "--import" : "--preload";
|
|
205
|
+
const isNodeJs = jsEngine == "node";
|
|
206
|
+
|
|
207
|
+
mustLog = process.env.JOPI_LOG==="1" || FORCE_LOG;
|
|
208
|
+
|
|
209
|
+
if (mustLog) {
|
|
210
|
+
console.log("JopiN Lib Version:", VERSION, " - engine:", jsEngine);
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
const knowPackagesToPreload = ["jopijs"];
|
|
214
|
+
|
|
215
|
+
// Here first is node.js, second is jopi. (it's du to shebang usage).
|
|
216
|
+
let argv = process.argv.slice(2);
|
|
217
|
+
|
|
218
|
+
if (!argv.length) {
|
|
219
|
+
console.log("jopi-loader "+ VERSION +" installed at ", import.meta.dirname);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
// Catch --hot and --watch, and remove them.
|
|
224
|
+
//
|
|
225
|
+
argv = argv.filter(arg => {
|
|
226
|
+
if (arg === "--hot") {
|
|
227
|
+
config.needHot = true;
|
|
228
|
+
config.needWatch = true;
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (arg === "--watch") {
|
|
233
|
+
config.needHot = false;
|
|
234
|
+
config.needWatch = true;
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return arg !== "--watch-path";
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
let toPreload = getPreloadModules();
|
|
242
|
+
toPreload = ["jopijs/loader", ...toPreload];
|
|
243
|
+
|
|
244
|
+
let preloadArgs: string[] = [];
|
|
245
|
+
|
|
246
|
+
toPreload.forEach(pkg => {
|
|
247
|
+
preloadArgs.push(importFlag);
|
|
248
|
+
preloadArgs.push(pkg);
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
if (jsEngine==="node") {
|
|
252
|
+
preloadArgs.push("--loader", "jopijs/loader/loader.mjs");
|
|
253
|
+
preloadArgs.push("--no-warnings");
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
let cmd = jk_os.whichSync(jsEngine, jsEngine)!;
|
|
257
|
+
if (mustLog) console.log("jopiN - Using " + jsEngine + " from:", cmd);
|
|
258
|
+
let args = [...preloadArgs, ...argv];
|
|
259
|
+
|
|
260
|
+
let config = await getConfiguration();
|
|
261
|
+
|
|
262
|
+
const cwd = process.cwd();
|
|
263
|
+
let env: Record<string, string> = {...process.env} as Record<string, string>;
|
|
264
|
+
let enableFileWatcher = false;
|
|
265
|
+
|
|
266
|
+
if (config.needWatch || config.needUiWatch) {
|
|
267
|
+
env["JOPIN_BROWSER_REFRESH_ENABLED"] = "1";
|
|
268
|
+
if (config.needWatch) env["JOPI_DEV"] = "1";
|
|
269
|
+
if (config.needUiWatch) env["JOPI_DEV_UI"] = "1";
|
|
270
|
+
|
|
271
|
+
let toPrepend: string[] = [];
|
|
272
|
+
|
|
273
|
+
if (config.needWatch) {
|
|
274
|
+
if (config.needHot) {
|
|
275
|
+
toPrepend.push("--hot");
|
|
276
|
+
}
|
|
277
|
+
else {
|
|
278
|
+
//toPrepend.push("--watch");
|
|
279
|
+
enableFileWatcher = true;
|
|
280
|
+
env["JOPI_CUSTOM_WATCHER"] = "1";
|
|
281
|
+
jk_term.logBlue("JopiN - Source watching enabled.");
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
args = [...toPrepend, ...args];
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (mustLog) {
|
|
289
|
+
console.log("jopiN - Use current working dir:", cwd);
|
|
290
|
+
console.log("jopiN - Executing:", cmd, ...args);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// If dev-mode, then execute the scripts
|
|
294
|
+
// jopiWatch_node/jopiWatch_bun from package.json
|
|
295
|
+
//
|
|
296
|
+
if (gDevModeType === DevModType.FULL_RELOAD) {
|
|
297
|
+
if (config.hasJopiWatchTask) await execTask("jopiWatch");
|
|
298
|
+
if (isNodeJs && config.hasJopiWatchTask_node) await execTask("jopiWatch_node");
|
|
299
|
+
if (!isNodeJs && config.hasJopiWatchTask_bun) await execTask("jopiWatch_bun");
|
|
300
|
+
} else {
|
|
301
|
+
if (isNodeJs && config.hasJopiBuildTask_node) await execTask("jopiBuild_node");
|
|
302
|
+
if (!isNodeJs && config.hasJopiBuildTask_bun) await execTask("jopiBuild_bun");
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (enableFileWatcher) {
|
|
306
|
+
if (mustLog) console.log("Using SourceChangesWatcher");
|
|
307
|
+
|
|
308
|
+
const watcher = new SourceChangesWatcher({
|
|
309
|
+
watchDirs: [path.join(process.cwd(), "src")],
|
|
310
|
+
excludeDir: [path.join(process.cwd(), "src", "_jopiLinkerGen")],
|
|
311
|
+
isDev: true, env, cmd, args, mustLog: mustLog,
|
|
312
|
+
jsEngine
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
await watcher.start();
|
|
316
|
+
|
|
317
|
+
} else {
|
|
318
|
+
if (mustLog) console.log("Is not using SourceChangesWatcher");
|
|
319
|
+
|
|
320
|
+
spawnChild({
|
|
321
|
+
cmd, env, args, onSpawned, cwd: process.cwd(), killOnExit: false
|
|
322
|
+
});
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export interface SpawnParams {
|
|
327
|
+
env?: Record<string, string>;
|
|
328
|
+
cmd: string;
|
|
329
|
+
args: string[];
|
|
330
|
+
cwd: string;
|
|
331
|
+
killOnExit: boolean;
|
|
332
|
+
onSpawned?: (child: ChildProcess) => void;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function killAll(signalName: NodeJS.Signals) {
|
|
336
|
+
gToKill.forEach(child => {
|
|
337
|
+
if (child.killed) return;
|
|
338
|
+
|
|
339
|
+
if (gDevModeType!==DevModType.NONE) {
|
|
340
|
+
// > If dev-mode, directly do a fast hard kill.
|
|
341
|
+
child.kill('SIGKILL');
|
|
342
|
+
process.exit(0);
|
|
343
|
+
} else {
|
|
344
|
+
try {
|
|
345
|
+
child.kill(signalName);
|
|
346
|
+
}
|
|
347
|
+
catch {
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
setTimeout(() => {
|
|
351
|
+
if (!child.killed) {
|
|
352
|
+
child.kill('SIGKILL');
|
|
353
|
+
}
|
|
354
|
+
}, 1000);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function spawnChild(params: SpawnParams): void {
|
|
360
|
+
let useShell = params.cmd.endsWith('.cmd') || params.cmd.endsWith('.bat') || params.cmd.endsWith('.sh');
|
|
361
|
+
|
|
362
|
+
if (mustLog) {
|
|
363
|
+
console.log("spawnChild", {cmd: params.cmd, args: params.args, cwd: process.cwd(), useShell})
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const child = spawn(params.cmd, params.args, {
|
|
367
|
+
stdio: "inherit", shell: useShell,
|
|
368
|
+
cwd: process.cwd(),
|
|
369
|
+
env: params.env
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
gToKill.push(child);
|
|
373
|
+
|
|
374
|
+
if (params.killOnExit) {
|
|
375
|
+
child.on('exit', (code, signal) => {
|
|
376
|
+
// The current instance has stopped?
|
|
377
|
+
if (signal) process.kill(process.pid, signal);
|
|
378
|
+
else process.exit(code ?? 0);
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
child.on('error', (err) => {
|
|
382
|
+
// The current instance is in error?
|
|
383
|
+
console.error(err.message || String(err));
|
|
384
|
+
process.exit(1);
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
if (params.onSpawned) {
|
|
389
|
+
child.on('spawn', () => {
|
|
390
|
+
params.onSpawned!(child);
|
|
391
|
+
})
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// Allow a killing child process when this process exits.
|
|
396
|
+
|
|
397
|
+
process.on('SIGTERM', () => killAll("SIGTERM"));
|
|
398
|
+
process.on('SIGINT', () => killAll("SIGINT"));
|
|
399
|
+
process.on('SIGHUP', () => killAll("SIGHUP"));
|
|
400
|
+
process.on('exit', () => killAll("exit" as NodeJS.Signals));
|
|
401
|
+
|
|
402
|
+
const gDevModeType = getDevModeType();
|
|
403
|
+
const gToKill: ChildProcess[] = [];
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { ResolveHook, ResolveFnOutput } from 'node:module';
|
|
2
|
+
import nodeModule from 'node:module';
|
|
3
|
+
|
|
4
|
+
import {pathToFileURL} from "node:url";
|
|
5
|
+
import * as jk_app from "jopi-toolkit/jk_app";
|
|
6
|
+
import {getPathAliasInfo, type PathAliasInfo} from "./tools.js";
|
|
7
|
+
import fs from "node:fs/promises";
|
|
8
|
+
import path from "node:path";
|
|
9
|
+
|
|
10
|
+
//**********************************************************************************************************************
|
|
11
|
+
// NodeJS RESOLVER vs LOADER
|
|
12
|
+
//
|
|
13
|
+
// Resolver is the new Node.js API for import resolving and processing.
|
|
14
|
+
// But currently (Node v22) there is not a full support, and the old
|
|
15
|
+
// mechanism (loader) must be used for some special cases.
|
|
16
|
+
//
|
|
17
|
+
//**********************************************************************************************************************
|
|
18
|
+
|
|
19
|
+
const LOG = process.env.JOPI_LOGS === "1";
|
|
20
|
+
|
|
21
|
+
let gRequire: NodeJS.Require|undefined;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Using a loader (old API) allows doing thing not correctly supported by resolver (new API)
|
|
25
|
+
*
|
|
26
|
+
* 1- Resolving alias.
|
|
27
|
+
* Example: import myComp from "@/lib/myComp".
|
|
28
|
+
* The alias definitions are taken in the paths section of tsconfig.json.
|
|
29
|
+
*
|
|
30
|
+
* 2- Resolving import for an exposed file inside a module
|
|
31
|
+
* Exemple: import 'primereact/sidebar'
|
|
32
|
+
* where the target is import 'primereact/sidebar/index.mjs.js'
|
|
33
|
+
*/
|
|
34
|
+
export const resolveNodeJsAlias: ResolveHook = async (specifier, context, nextResolve): Promise<ResolveFnOutput> => {
|
|
35
|
+
if (!gPathAliasInfos) {
|
|
36
|
+
gPathAliasInfos = await getPathAliasInfo();
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
//region Resolve alias
|
|
40
|
+
|
|
41
|
+
if (specifier[0]==='@') {
|
|
42
|
+
let foundAlias = "";
|
|
43
|
+
|
|
44
|
+
for (const alias in gPathAliasInfos.alias) {
|
|
45
|
+
if (specifier.startsWith(alias)) {
|
|
46
|
+
if (foundAlias.length < alias.length) {
|
|
47
|
+
foundAlias = alias;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (foundAlias) {
|
|
53
|
+
if (LOG) console.log(`jopi-loader - Found alias ${foundAlias} for resource ${specifier}`);
|
|
54
|
+
|
|
55
|
+
let pathAlias = gPathAliasInfos.alias[foundAlias];
|
|
56
|
+
const resolvedPath = specifier.replace(foundAlias, pathAlias);
|
|
57
|
+
|
|
58
|
+
let filePath = resolvedPath.endsWith('.js') ? resolvedPath : `${resolvedPath}.js`;
|
|
59
|
+
filePath = jk_app.getCompiledFilePathFor(filePath);
|
|
60
|
+
|
|
61
|
+
return nextResolve(pathToFileURL(filePath).href, context);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// > Will continue on next cases.
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
//endregion
|
|
68
|
+
|
|
69
|
+
let mustProcess = specifier.includes("/");
|
|
70
|
+
|
|
71
|
+
if (mustProcess) {
|
|
72
|
+
if ((specifier[0] === '@') && specifier[1]!=='/') {
|
|
73
|
+
mustProcess = false;
|
|
74
|
+
} else if (specifier.indexOf(":")!==-1) {
|
|
75
|
+
mustProcess = false;
|
|
76
|
+
} else if (specifier.endsWith(".js") || specifier.endsWith(".mjs")) {
|
|
77
|
+
mustProcess = false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// If we are here, it means we have possibly something like:
|
|
82
|
+
// import "module/internalPath"
|
|
83
|
+
//
|
|
84
|
+
// The matter is that the extension is missing, and Node.js doesn't handle this case
|
|
85
|
+
// despite UI lib used by Vite.js or WebPack.
|
|
86
|
+
//
|
|
87
|
+
if (mustProcess) {
|
|
88
|
+
if (!gRequire) {
|
|
89
|
+
gRequire = nodeModule.createRequire(context.parentURL!);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
try {
|
|
93
|
+
// Testing nextResolve and catching exception don't work.
|
|
94
|
+
// It's why we use require.resolve to localize the package..
|
|
95
|
+
//
|
|
96
|
+
let found = gRequire.resolve(specifier);
|
|
97
|
+
|
|
98
|
+
if (found) {
|
|
99
|
+
const pkgPath = nodeModule.findPackageJSON(pathToFileURL(found));
|
|
100
|
+
|
|
101
|
+
if (pkgPath) {
|
|
102
|
+
let pkgJson = await fs.readFile(pkgPath, "utf-8");
|
|
103
|
+
const json = JSON.parse(pkgJson);
|
|
104
|
+
|
|
105
|
+
if (json.module) {
|
|
106
|
+
const oldName = specifier;
|
|
107
|
+
specifier = path.resolve(path.dirname(pkgPath), json.module);
|
|
108
|
+
if (LOG) console.log("Resolving", oldName, "to", specifier);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
} catch {
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return nextResolve(specifier, context);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
let gPathAliasInfos: PathAliasInfo|undefined;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import * as jk_app from "jopi-toolkit/jk_app";
|
|
2
|
+
import * as jk_fs from "jopi-toolkit/jk_fs";
|
|
3
|
+
import {fileURLToPath} from "node:url";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import {supportedExtensions} from "./rules.ts";
|
|
6
|
+
import {transformFile} from "./transform.ts";
|
|
7
|
+
|
|
8
|
+
//**********************************************************************************************************************
|
|
9
|
+
// NodeJS RESOLVER vs LOADER
|
|
10
|
+
//
|
|
11
|
+
// Resolver is the new Node.js API for import resolving and processing.
|
|
12
|
+
// But currently (Node v22) there is not a full support, and the old
|
|
13
|
+
// mechanism (loader) must be used for some special cases.
|
|
14
|
+
//
|
|
15
|
+
//**********************************************************************************************************************
|
|
16
|
+
|
|
17
|
+
export async function doNodeJsResolve(specifier: string, context: any, nextResolve: any) {
|
|
18
|
+
async function tryResolveFile(filePath: string, moduleName: string) {
|
|
19
|
+
if (await jk_fs.isFile(filePath)) {
|
|
20
|
+
return nextResolve(moduleName, context);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function tryResolveDirectory(url: string) {
|
|
27
|
+
const basePath = fileURLToPath(url);
|
|
28
|
+
let basename = path.basename(basePath);
|
|
29
|
+
|
|
30
|
+
let allFilesToTry = ["index.js", basename + ".cjs.js", basename + ".js"];
|
|
31
|
+
|
|
32
|
+
for (let fileToTry of allFilesToTry) {
|
|
33
|
+
const res = await tryResolveFile(path.join(basePath, fileToTry), specifier + "/" + fileToTry);
|
|
34
|
+
if (res) return res;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Will throw an error.
|
|
38
|
+
return nextResolve(specifier, context);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function tryResolveModule(url: string) {
|
|
42
|
+
const basePath = fileURLToPath(url);
|
|
43
|
+
|
|
44
|
+
const res = await tryResolveFile(basePath + ".js", specifier + ".js");
|
|
45
|
+
|
|
46
|
+
if (res) {
|
|
47
|
+
return res;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Will throw an error.
|
|
51
|
+
return nextResolve(specifier, context);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Remove what is after the "?" to be able to test the extension.
|
|
55
|
+
//
|
|
56
|
+
let idx = specifier.indexOf("?");
|
|
57
|
+
let options = "";
|
|
58
|
+
|
|
59
|
+
if (idx!==-1) {
|
|
60
|
+
options = specifier.substring(idx);
|
|
61
|
+
specifier = specifier.substring(0, idx);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (supportedExtensions.includes(path.extname(specifier))) {
|
|
65
|
+
const isRelative = specifier.startsWith("./") || specifier.startsWith("../");
|
|
66
|
+
|
|
67
|
+
let href: string;
|
|
68
|
+
|
|
69
|
+
if (!isRelative) {
|
|
70
|
+
let resolved = await nextResolve(specifier, context);
|
|
71
|
+
href = resolved.url;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
href = new URL(specifier, context.parentURL).href;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return {
|
|
78
|
+
url: href + options,
|
|
79
|
+
format: "jopi-loader",
|
|
80
|
+
shortCircuit: true
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
try {
|
|
85
|
+
return nextResolve(specifier, context);
|
|
86
|
+
} catch (e: any) {
|
|
87
|
+
if (e.code === "ERR_UNSUPPORTED_DIR_IMPORT") {
|
|
88
|
+
return await tryResolveDirectory(e.url! as string);
|
|
89
|
+
}
|
|
90
|
+
if (e.code === "ERR_MODULE_NOT_FOUND") {
|
|
91
|
+
return await tryResolveModule(e.url! as string);
|
|
92
|
+
}
|
|
93
|
+
throw e;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// noinspection JSUnusedGlobalSymbols
|
|
98
|
+
export async function doNodeJsLoad(url: string, context: any, nextLoad: any) {
|
|
99
|
+
if (context.format==="jopi-loader") {
|
|
100
|
+
let idx = url.indexOf("?");
|
|
101
|
+
let options = "";
|
|
102
|
+
|
|
103
|
+
if (idx !== -1) {
|
|
104
|
+
options = url.substring(idx + 1);
|
|
105
|
+
url = url.substring(0, idx);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Some ".js" file can be found here, du to a strange bug
|
|
109
|
+
// inside the node.js loader, where the context object seems to be reused.
|
|
110
|
+
// It doesn't go through doNodeJsResolve and directly appears here.
|
|
111
|
+
//
|
|
112
|
+
if (!supportedExtensions.includes(path.extname(url))) {
|
|
113
|
+
context.format = "module";
|
|
114
|
+
return nextLoad(url, context);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
let filePath = fileURLToPath(url);
|
|
118
|
+
|
|
119
|
+
// Occurs when it's compiled with TypeScript.
|
|
120
|
+
if (!await jk_fs.isFile(filePath)) {
|
|
121
|
+
filePath = jk_app.requireSourceOf(filePath);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
try {
|
|
125
|
+
let res = await transformFile(filePath, options);
|
|
126
|
+
|
|
127
|
+
return {
|
|
128
|
+
source: res.text,
|
|
129
|
+
format: 'module',
|
|
130
|
+
shortCircuit: true
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
catch (e: any) {
|
|
134
|
+
console.warn("jopi-loader - Error while loading:", e?.message || e);
|
|
135
|
+
throw "jopi-loader - error";
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return nextLoad(url, context);
|
|
140
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import {isBunJS} from "jopi-toolkit/jk_what";
|
|
2
|
+
|
|
3
|
+
function toFlatList(rec: Record<string, string[]>): string[] {
|
|
4
|
+
let res: string[] = [];
|
|
5
|
+
|
|
6
|
+
for (let group in rec) {
|
|
7
|
+
res = [...res, ...rec[group]]
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
return res;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function invertKeys(rec: Record<string, string[]>): Record<string, string> {
|
|
14
|
+
const res: Record<string, string> = {};
|
|
15
|
+
|
|
16
|
+
for (let key in rec) {
|
|
17
|
+
let group = rec[key];
|
|
18
|
+
group.forEach(e => {res[e] = key});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return res;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function patchForJsEngine(value: Record<any, any>) {
|
|
25
|
+
// Bun.js handle JSON specially, with care for import/require differences.
|
|
26
|
+
if (!isBunJS) {
|
|
27
|
+
value.text.push(".json");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const supportedExtensionsByGroup = patchForJsEngine({
|
|
34
|
+
css: [".css", ".scss"],
|
|
35
|
+
binary: [".jpg", ".png", ".jpeg", ".gif", ".webp", ".woff", ".woff2", ".ttf", ".avif", ".ico"],
|
|
36
|
+
|
|
37
|
+
//.json added here by patchForJsEngine if not bun.js
|
|
38
|
+
text: [".txt", ".svg", ".glsl", /*".json" added only for node.js */]
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const supportedExtensions = toFlatList(supportedExtensionsByGroup);
|
|
42
|
+
export const supportedExtensionToType = invertKeys(supportedExtensionsByGroup);
|
|
43
|
+
|
|
44
|
+
export const supportedExtensionsRegExp = new RegExp(`(${supportedExtensions.map(ext => ext.replace('.', '\\.')).join('|')})(?:\\?.*)?$`);
|
|
45
|
+
|