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,49 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {_usePage} from "./hooks.tsx";
|
|
3
|
+
|
|
4
|
+
//region Composite
|
|
5
|
+
|
|
6
|
+
type CompositeRenderer = (name: string) => React.ReactElement;
|
|
7
|
+
|
|
8
|
+
function defaultCompositeRenderer() {
|
|
9
|
+
return <></>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function resolveCompositeRenderer(): CompositeRenderer {
|
|
13
|
+
let bound = (globalThis as any)["_JOPI_COMPOSITE_RENDERER_"];
|
|
14
|
+
if (bound) return bound as CompositeRenderer;
|
|
15
|
+
return defaultCompositeRenderer;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* -- Do not use --
|
|
20
|
+
* Allows the server part to hook the composite renderer used.
|
|
21
|
+
*/
|
|
22
|
+
export function _setCompositeRenderer(r: CompositeRenderer) {
|
|
23
|
+
gCompositeRenderer = r;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* This component allows inserting the value of a 'composite'.
|
|
28
|
+
* A composite is an extension point for your UI, it allows
|
|
29
|
+
* inserting a thing into a region of your UI by extending his
|
|
30
|
+
* content through plugins.
|
|
31
|
+
*
|
|
32
|
+
* Composites are not defined through API!!!
|
|
33
|
+
* When declaring a module, the engine scans your folder uiComposites.
|
|
34
|
+
*
|
|
35
|
+
* Example:
|
|
36
|
+
* `/modules/myModule/uiComposite/page.logInError/extA.extension.tsx`
|
|
37
|
+
* - `page.logInError` is the name of the composite you extend.
|
|
38
|
+
* - `extA` is the name of the extension point (it has no usage).
|
|
39
|
+
*
|
|
40
|
+
* Inside `extA.extension.tsx` the default export is the component to insert.
|
|
41
|
+
*/
|
|
42
|
+
export function Composite({name}: {name: string}) {
|
|
43
|
+
if (!gCompositeRenderer) gCompositeRenderer = resolveCompositeRenderer();
|
|
44
|
+
return gCompositeRenderer(name);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let gCompositeRenderer: CompositeRenderer|undefined;
|
|
48
|
+
|
|
49
|
+
//endregion
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// noinspection JSUnusedGlobalSymbols
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
export type HandlerBundleExternalCss = (importMeta: any, cssFilePath: string) => void;
|
|
6
|
+
|
|
7
|
+
export function setHandler_bundleExternalCss(listener: HandlerBundleExternalCss) {
|
|
8
|
+
gHandler_bundleExternalCss = listener;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const CssModule: React.FC<{module: any}> = ({module}) => {
|
|
12
|
+
return <style>{module.__CSS__}</style>;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export interface UseCssModuleContextProps {
|
|
16
|
+
jopiUseCssModule?: Record<string, any>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getCssModuleStyle(cssModule: undefined | Record<string, string>): string {
|
|
20
|
+
return cssModule ? cssModule.__CSS__ : "";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function mustBundleExternalCss(importMeta: any, cssFilePath: string) {
|
|
24
|
+
gHandler_bundleExternalCss(importMeta, cssFilePath);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let gHandler_bundleExternalCss: HandlerBundleExternalCss = () => {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// noinspection JSUnusedGlobalSymbols
|
|
2
|
+
|
|
3
|
+
import React, {useEffect} from "react";
|
|
4
|
+
import {PageContext, PageController, PageController_ExposePrivate} from "./pageController.ts";
|
|
5
|
+
import {CssModule, type UseCssModuleContextProps} from "./cssModules.tsx";
|
|
6
|
+
import * as jk_events from "jopi-toolkit/jk_events";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Allow getting a reference to the PageController.
|
|
10
|
+
* **USING IT MUST BE AVOIDED** since it's a technical item.
|
|
11
|
+
* It's the reason of the underscore.
|
|
12
|
+
*/
|
|
13
|
+
export function _usePage<T = any>(): PageController<T> {
|
|
14
|
+
let res = React.useContext(PageContext) as PageController<T>;
|
|
15
|
+
|
|
16
|
+
// Not wrapped inside a PageContext?
|
|
17
|
+
if (!res) {
|
|
18
|
+
res = new PageController<T>(true);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return res;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Allows setting the page title.
|
|
26
|
+
* @param title
|
|
27
|
+
*/
|
|
28
|
+
export function usePageTitle(title: string) {
|
|
29
|
+
const page = React.useContext(PageContext) as PageController;
|
|
30
|
+
if (page) page.setPageTitle(title);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function useCssModule(cssModule: undefined | Record<string, string>) {
|
|
34
|
+
if (!cssModule) return;
|
|
35
|
+
|
|
36
|
+
// Not a real CSS Module?
|
|
37
|
+
const fileHash = cssModule.__FILE_HASH__;
|
|
38
|
+
if (!fileHash) return;
|
|
39
|
+
|
|
40
|
+
const ctx = _usePage<UseCssModuleContextProps>();
|
|
41
|
+
|
|
42
|
+
// Will allow knowing if the module is already inserted for this page.
|
|
43
|
+
if (!ctx.data.jopiUseCssModule) ctx.data.jopiUseCssModule = {};
|
|
44
|
+
|
|
45
|
+
// Not already added? Then add it.
|
|
46
|
+
if (fileHash && !ctx.data.jopiUseCssModule[fileHash]) {
|
|
47
|
+
ctx.data.jopiUseCssModule![fileHash] = true;
|
|
48
|
+
|
|
49
|
+
// Will allow inlining the style inside the page.
|
|
50
|
+
ctx.addToBodyBegin(fileHash, <CssModule key={fileHash} module={cssModule}/>);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Is a subset of JopiRequest, with only browser-side compatible items.
|
|
56
|
+
*/
|
|
57
|
+
export interface ServerRequestInstance {
|
|
58
|
+
urlParts?: Record<string, any>;
|
|
59
|
+
urlInfos: URL;
|
|
60
|
+
customData: any;
|
|
61
|
+
|
|
62
|
+
user_getJwtToken(): string | undefined;
|
|
63
|
+
|
|
64
|
+
headers: Headers;
|
|
65
|
+
cookie_reqHasCookie(name: string, value?: string): boolean;
|
|
66
|
+
cookie_getReqCookie(name: string): string | undefined;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function useServerRequest(): ServerRequestInstance {
|
|
70
|
+
let page = _usePage();
|
|
71
|
+
return (page as PageController_ExposePrivate).getServerRequest();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Allows listening to an event, and automatically
|
|
76
|
+
* unregister when the component unmount.
|
|
77
|
+
*/
|
|
78
|
+
export function useEvent(evenName: string|string[], listener: (data: any) => void) {
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
if (evenName instanceof Array) {
|
|
81
|
+
evenName.forEach(e => {
|
|
82
|
+
jk_events.addListener(e, listener);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
return () => {
|
|
86
|
+
evenName.forEach(e => {
|
|
87
|
+
jk_events.removeListener(e, listener);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
jk_events.addListener(evenName, listener);
|
|
93
|
+
return () => { jk_events.removeListener(evenName, listener) };
|
|
94
|
+
}, [evenName, listener]);
|
|
95
|
+
}
|
package/src/@ui/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {isBrowser} from "jopi-toolkit/jk_what";
|
|
2
|
+
|
|
3
|
+
export * from "./tools.ts";
|
|
4
|
+
export * from "./pageController.ts";
|
|
5
|
+
export * from "./cssModules.tsx";
|
|
6
|
+
|
|
7
|
+
export * from "./components.tsx";
|
|
8
|
+
export * from "./hooks.tsx";
|
|
9
|
+
export * from "./modules.ts";
|
|
10
|
+
export * from "./objectRegistry.ts";
|
|
11
|
+
|
|
12
|
+
export const isBrowserSide = isBrowser;
|
|
13
|
+
export const isServerSide = !isBrowser;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type {ComponentAliasDef} from "./modules.ts";
|
|
2
|
+
import {PageContext, PageController} from "./pageController.ts";
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
export const gComponentAlias: Record<string, ComponentAliasDef> = {};
|
|
6
|
+
|
|
7
|
+
export function getDefaultPageController(): PageController {
|
|
8
|
+
if (!gDefaultPageController) gDefaultPageController = new PageController();
|
|
9
|
+
return gDefaultPageController!;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let gDefaultPageController: PageController|undefined;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// noinspection JSUnusedGlobalSymbols
|
|
2
|
+
|
|
3
|
+
import * as jk_events from "jopi-toolkit/jk_events";
|
|
4
|
+
import {type UiUserInfos} from "./tools.ts";
|
|
5
|
+
import React from "react";
|
|
6
|
+
import {isServerSide} from "jopi-toolkit/jk_what";
|
|
7
|
+
import {type IsObjectRegistry} from "./objectRegistry.ts";
|
|
8
|
+
import {getDefaultPageController} from "./internal.ts";
|
|
9
|
+
|
|
10
|
+
export interface ModuleInitContext_Host {
|
|
11
|
+
objectRegistry: IsObjectRegistry;
|
|
12
|
+
|
|
13
|
+
getCurrentURL(): URL;
|
|
14
|
+
getUserInfos(): UiUserInfos|undefined;
|
|
15
|
+
mustRemoveTrailingSlashs: boolean;
|
|
16
|
+
|
|
17
|
+
events: jk_events.EventGroup;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ComponentAliasDef {
|
|
21
|
+
alias: string;
|
|
22
|
+
component: React.ComponentType<any>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type UiInitializer = () => void;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* This class is what is sent as the default export function
|
|
29
|
+
* of your module `uiInit.tsx`. It allows configuring things
|
|
30
|
+
* allowing your plugin to initialize your UI.
|
|
31
|
+
*
|
|
32
|
+
* * On the server side, it's executed for each page.
|
|
33
|
+
* * On the browser side, it's executed for each browser refresh.
|
|
34
|
+
*/
|
|
35
|
+
export class ModuleInitContext {
|
|
36
|
+
public readonly objectRegistry: IsObjectRegistry;
|
|
37
|
+
public readonly events: jk_events.EventGroup;
|
|
38
|
+
public readonly isBrowserSide: boolean = !isServerSide;
|
|
39
|
+
protected readonly host: ModuleInitContext_Host;
|
|
40
|
+
|
|
41
|
+
constructor(host?: ModuleInitContext_Host) {
|
|
42
|
+
if (!host) host = getDefaultPageController();
|
|
43
|
+
this.host = host;
|
|
44
|
+
|
|
45
|
+
this.objectRegistry = host.objectRegistry;
|
|
46
|
+
this.events = host.events;
|
|
47
|
+
|
|
48
|
+
this.initialize();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
protected initialize() {
|
|
52
|
+
// Will be overridden.
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getCurrentURL(): URL {
|
|
56
|
+
return this.host.getCurrentURL();
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
addUiInitializer(priority: UiInitializer|jk_events.EventPriority, initializer?: UiInitializer|undefined) {
|
|
60
|
+
this.events.addListener("app.init.ui", priority, initializer);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
getUserInfos(): UiUserInfos|undefined {
|
|
64
|
+
return this.host.getUserInfos();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
getUserRoles(): string[] {
|
|
68
|
+
let userInfos = this.getUserInfos();
|
|
69
|
+
if (!userInfos) return [];
|
|
70
|
+
return userInfos.roles || [];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
userHasRoles(roles: string[]): boolean {
|
|
74
|
+
if (roles.length === 0) return true;
|
|
75
|
+
|
|
76
|
+
let userInfos = this.getUserInfos();
|
|
77
|
+
if (!userInfos) return false;
|
|
78
|
+
|
|
79
|
+
let userRoles = userInfos.roles;
|
|
80
|
+
if (!userRoles) return false;
|
|
81
|
+
|
|
82
|
+
return !!roles.every(role => userRoles.includes(role));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
ifUserHasRoles(roles: string[], f: (userInfos: UiUserInfos) => void): void {
|
|
86
|
+
if (this.userHasRoles(roles)) {
|
|
87
|
+
f(this.getUserInfos()!);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
ifUserLoggedIn(f: (userInfos: UiUserInfos) => void) {
|
|
92
|
+
let userInfos = this.getUserInfos();
|
|
93
|
+
if (!userInfos) return;
|
|
94
|
+
return f(userInfos);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
ifNotUserLoggedIn(f: () => Promise<void>) {
|
|
98
|
+
if (!this.getUserInfos()) f();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export interface IsObjectRegistry {
|
|
2
|
+
getObject<T>(name: string): T|undefined;
|
|
3
|
+
registerObject(name: string, instance: any): void;
|
|
4
|
+
addObjectBuilder<T>(name: string, builder: () => T): void;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
interface ObjectRegistryEntry {
|
|
8
|
+
builder?: () => any;
|
|
9
|
+
instance?: any;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class ObjectRegistry implements IsObjectRegistry {
|
|
13
|
+
private readonly r: Record<string, ObjectRegistryEntry> = {};
|
|
14
|
+
|
|
15
|
+
getObject<T>(name: string): T|undefined {
|
|
16
|
+
let entry = this.r[name];
|
|
17
|
+
if (!entry) return undefined;
|
|
18
|
+
|
|
19
|
+
if (entry.instance!==undefined) return entry.instance as T;
|
|
20
|
+
|
|
21
|
+
if (entry.builder) {
|
|
22
|
+
entry.instance = entry.builder();
|
|
23
|
+
return entry.instance as T;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
registerObject(name: string, instance: any): void {
|
|
30
|
+
let entry = this.r[name];
|
|
31
|
+
if (!entry) this.r[name] = entry = {};
|
|
32
|
+
entry.instance = instance;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
addObjectBuilder<T>(name: string, builder: () => T): void {
|
|
36
|
+
let entry = this.r[name];
|
|
37
|
+
if (!entry) this.r[name] = entry = {};
|
|
38
|
+
entry.builder = builder;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function getDefaultObjectRegistry(): IsObjectRegistry {
|
|
43
|
+
if (!gObjectRegistry) {
|
|
44
|
+
return gObjectRegistry = new ObjectRegistry();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return gObjectRegistry;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
let gObjectRegistry: ObjectRegistry|undefined;
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
// noinspection JSUnusedGlobalSymbols
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import {type ServerRequestInstance} from "./hooks.tsx";
|
|
5
|
+
import {decodeJwtToken, decodeUserInfosFromCookie, isUserInfoCookieUpdated, deleteCookie, type UiUserInfos} from "./tools.ts";
|
|
6
|
+
import * as jk_events from "jopi-toolkit/jk_events";
|
|
7
|
+
import type {ModuleInitContext_Host} from "./modules.ts";
|
|
8
|
+
import {isServerSide} from "jopi-toolkit/jk_what";
|
|
9
|
+
import {getDefaultObjectRegistry, type IsObjectRegistry, ObjectRegistry} from "./objectRegistry.ts";
|
|
10
|
+
|
|
11
|
+
export interface PageOptions {
|
|
12
|
+
pageTitle?: string;
|
|
13
|
+
head?: React.ReactNode[];
|
|
14
|
+
bodyBegin?: React.ReactNode[];
|
|
15
|
+
bodyEnd?: React.ReactNode[];
|
|
16
|
+
|
|
17
|
+
htmlProps?: Record<string, any>;
|
|
18
|
+
bodyProps?: Record<string, any>;
|
|
19
|
+
headProps?: Record<string, any>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Page controller is an object that can be accessed
|
|
24
|
+
* from any React component from the `_usePage`hook.
|
|
25
|
+
*/
|
|
26
|
+
export class PageController<T = any> implements ModuleInitContext_Host {
|
|
27
|
+
private readonly isServerSide: boolean = isServerSide;
|
|
28
|
+
private readonly usedKeys = new Set<String>();
|
|
29
|
+
protected state: PageOptions;
|
|
30
|
+
protected serverRequest?: ServerRequestInstance;
|
|
31
|
+
protected userInfos?: UiUserInfos;
|
|
32
|
+
|
|
33
|
+
public readonly events = isServerSide ? jk_events.newEventGroup() : jk_events.defaultEventGroup;
|
|
34
|
+
public readonly objectRegistry: IsObjectRegistry = isServerSide ? new ObjectRegistry() : getDefaultObjectRegistry();
|
|
35
|
+
|
|
36
|
+
constructor(public readonly isDetached = false, public readonly mustRemoveTrailingSlashs: boolean = false, options?: PageOptions) {
|
|
37
|
+
options = options || {};
|
|
38
|
+
|
|
39
|
+
this.state = {...options};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Allow storing custom data inside the page context.
|
|
44
|
+
*/
|
|
45
|
+
data: T = {} as unknown as T;
|
|
46
|
+
|
|
47
|
+
//region ModuleInitContext_Host
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Return the current page url.
|
|
51
|
+
* For server-side: correspond to the url of the request.
|
|
52
|
+
* For browser-side: is the navigateur url.
|
|
53
|
+
*/
|
|
54
|
+
public getCurrentURL(): URL {
|
|
55
|
+
if (this.serverRequest) {
|
|
56
|
+
return this.serverRequest.urlInfos;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return new URL(window.location.href);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public getUserInfos(): UiUserInfos|undefined {
|
|
63
|
+
if (isServerSide) return this.userInfos;
|
|
64
|
+
|
|
65
|
+
if (!this.userInfos) {
|
|
66
|
+
this.userInfos = decodeUserInfosFromCookie();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return this.userInfos;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//endregion
|
|
73
|
+
|
|
74
|
+
//region Page options (header/props/...)
|
|
75
|
+
|
|
76
|
+
public addToHeader(key: string, entry: React.ReactNode) {
|
|
77
|
+
if (this.isServerSide) {
|
|
78
|
+
if (!this.checkKey("h" + key)) return this;
|
|
79
|
+
if (!this.state.head) this.state.head = [entry];
|
|
80
|
+
else this.state.head.push(entry);
|
|
81
|
+
} else {
|
|
82
|
+
// No browser-side support.
|
|
83
|
+
// Why? Because React router only replaces the body.
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
public addToBodyBegin(key: string, entry: React.ReactNode) {
|
|
90
|
+
if (!this.checkKey("b" + key)) return this;
|
|
91
|
+
|
|
92
|
+
if (!this.state.bodyBegin) this.state.bodyBegin = [entry];
|
|
93
|
+
else this.state.bodyBegin.push(entry);
|
|
94
|
+
|
|
95
|
+
// Required to trigger a browser-side refresh of the body.
|
|
96
|
+
this.onStateUpdated(this.state);
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public addToBodyEnd(key: string, entry: React.ReactNode) {
|
|
101
|
+
if (!this.checkKey("e" + key)) return this;
|
|
102
|
+
|
|
103
|
+
if (!this.state.bodyEnd) this.state.bodyEnd = [entry];
|
|
104
|
+
else this.state.bodyEnd.push(entry);
|
|
105
|
+
|
|
106
|
+
// Required to trigger a browser-side refresh of the body.
|
|
107
|
+
this.onStateUpdated(this.state);
|
|
108
|
+
return this;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
public setHeadTagProps(key: string, value: any) {
|
|
112
|
+
if (this.isServerSide) {
|
|
113
|
+
if (!this.state.headProps) this.state.headProps = {};
|
|
114
|
+
this.state.headProps[key] = value;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return this;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public setHtmlTagProps(key: string, value: any) {
|
|
121
|
+
if (this.isServerSide) {
|
|
122
|
+
if (!this.state.htmlProps) this.state.htmlProps = {};
|
|
123
|
+
this.state.htmlProps[key] = value;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return this;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
public setBodyTagProps(key: string, value: any) {
|
|
130
|
+
if (this.isServerSide) {
|
|
131
|
+
if (!this.state.bodyProps) this.state.bodyProps = {};
|
|
132
|
+
this.state.bodyProps[key] = value;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
public setPageTitle(title: string) {
|
|
139
|
+
if (this.isServerSide) {
|
|
140
|
+
this.state.pageTitle = title;
|
|
141
|
+
} else {
|
|
142
|
+
document.title = title;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
private checkKey(key: string) {
|
|
149
|
+
if (this.usedKeys.has(key)) {
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
this.usedKeys.add(key);
|
|
154
|
+
return true;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
//endregion
|
|
158
|
+
|
|
159
|
+
public refreshUserInfos() {
|
|
160
|
+
if (!isServerSide && isUserInfoCookieUpdated()) {
|
|
161
|
+
this.userInfos = decodeUserInfosFromCookie();
|
|
162
|
+
jk_events.sendEvent("user.infosUpdated")
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
public logOutUser() {
|
|
167
|
+
if (!isServerSide) {
|
|
168
|
+
deleteCookie("authorization");
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
this.refreshUserInfos();
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
onStateUpdated(_state: PageOptions) {
|
|
175
|
+
// Will be dynamically replaced.
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
onRequireRefresh() {
|
|
179
|
+
// Will be dynamically replaced.
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export class PageController_ExposePrivate<T = any> extends PageController<T> {
|
|
184
|
+
getOptions(): PageOptions {
|
|
185
|
+
return this.state;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
setServerRequest(serverRequest: ServerRequestInstance) {
|
|
189
|
+
this.objectRegistry.registerObject("jopi.serverRequest", serverRequest);
|
|
190
|
+
|
|
191
|
+
this.serverRequest = serverRequest;
|
|
192
|
+
this.userInfos = decodeJwtToken(serverRequest.user_getJwtToken());
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
getServerRequest(): ServerRequestInstance {
|
|
196
|
+
return this.serverRequest!;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export type PageHook = (controller: PageController_ExposePrivate<unknown>) => void;
|
|
201
|
+
|
|
202
|
+
// Use undefined, otherwise the value is common for all requests when doing SSR.
|
|
203
|
+
export const PageContext = React.createContext<PageController<unknown>|undefined>(undefined);
|
package/src/@ui/tools.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import {isServerSide} from "jopi-toolkit/jk_what";
|
|
2
|
+
|
|
3
|
+
//region User info
|
|
4
|
+
|
|
5
|
+
export interface UiUserInfos {
|
|
6
|
+
id: string;
|
|
7
|
+
|
|
8
|
+
roles?: string[];
|
|
9
|
+
email?: string;
|
|
10
|
+
|
|
11
|
+
fullName?: string;
|
|
12
|
+
nickName?: string;
|
|
13
|
+
|
|
14
|
+
firstName?: string;
|
|
15
|
+
lastName?: string;
|
|
16
|
+
|
|
17
|
+
avatarUrl?: string;
|
|
18
|
+
|
|
19
|
+
[key: string]: any;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function decodeJwtToken(jwtToken: string|undefined): UiUserInfos|undefined {
|
|
23
|
+
if (!jwtToken) return undefined;
|
|
24
|
+
|
|
25
|
+
const parts = jwtToken.split('.');
|
|
26
|
+
if (parts.length !== 3) return undefined;
|
|
27
|
+
|
|
28
|
+
const payload = parts[1];
|
|
29
|
+
const decodedPayload = atob(payload.replace(/-/g, '+').replace(/_/g, '/'));
|
|
30
|
+
return JSON.parse(decodedPayload) as UiUserInfos;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function isUserInfoCookieUpdated(): boolean {
|
|
34
|
+
const jwtToken = decodeNavigatorCookie("authorization");
|
|
35
|
+
return jwtToken !== gAuthorizationCookiePreviousValue;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function decodeUserInfosFromCookie(): UiUserInfos|undefined {
|
|
39
|
+
if (isServerSide) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let jwtToken = decodeNavigatorCookie("authorization");
|
|
44
|
+
gAuthorizationCookiePreviousValue = jwtToken;
|
|
45
|
+
|
|
46
|
+
return decodeJwtToken(jwtToken);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let gAuthorizationCookiePreviousValue = "";
|
|
50
|
+
|
|
51
|
+
//endregion
|
|
52
|
+
|
|
53
|
+
//region Cookies
|
|
54
|
+
|
|
55
|
+
export function setCookie(name: string, value: string, maxAge?: number) {
|
|
56
|
+
if (isServerSide) return;
|
|
57
|
+
|
|
58
|
+
let cookieStr = `${name}=${value}; path=/`;
|
|
59
|
+
|
|
60
|
+
if (maxAge !== undefined) {
|
|
61
|
+
cookieStr += `; max-age=${maxAge}`;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
document.cookie = cookieStr;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function deleteCookie(name: string) {
|
|
68
|
+
if (isServerSide) return;
|
|
69
|
+
|
|
70
|
+
let current = decodeNavigatorCookie(name);
|
|
71
|
+
if (current === undefined) return;
|
|
72
|
+
|
|
73
|
+
document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`;
|
|
74
|
+
|
|
75
|
+
// Allow to be ok until document.cookie is refreshed.
|
|
76
|
+
delete gCookies![name];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Returns the value of the cookie.
|
|
81
|
+
* Works browser side and server side.
|
|
82
|
+
*
|
|
83
|
+
* @param name
|
|
84
|
+
* The name of the cookie we want.
|
|
85
|
+
*/
|
|
86
|
+
export function decodeNavigatorCookie(name: string) {
|
|
87
|
+
if (isServerSide) {
|
|
88
|
+
return "";
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let currentCookies = document.cookie;
|
|
92
|
+
|
|
93
|
+
if (gCookies) {
|
|
94
|
+
if (gCookieString !== currentCookies) {
|
|
95
|
+
gCookieString = currentCookies;
|
|
96
|
+
gCookies = undefined;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (!gCookies) {
|
|
101
|
+
gCookies = {};
|
|
102
|
+
|
|
103
|
+
currentCookies.split(';').forEach(c => {
|
|
104
|
+
c = c.trim();
|
|
105
|
+
let idx = c.indexOf("=");
|
|
106
|
+
gCookies![c.substring(0, idx)] = c.substring(idx + 1);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return gCookies![name];
|
|
111
|
+
}
|
|
112
|
+
//
|
|
113
|
+
let gCookies: undefined|Record<string, string>;
|
|
114
|
+
let gCookieString = "";
|
|
115
|
+
|
|
116
|
+
//endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
It extends ui-core with optional functionalities.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {ModuleInitContext} from "jopijs/ui";
|
|
2
|
+
import {MenuManager} from "../menu/index.ts";
|
|
3
|
+
import {getDefaultMenuManager} from "../menu/internal.ts";
|
|
4
|
+
|
|
5
|
+
export class UiKitModule extends ModuleInitContext {
|
|
6
|
+
protected override initialize() {
|
|
7
|
+
this.objectRegistry.addObjectBuilder("uikit.menuManager", () => {
|
|
8
|
+
if (this.isBrowserSide) {
|
|
9
|
+
return getDefaultMenuManager();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const mustRemoveTrailingSlashs = this.host.mustRemoveTrailingSlashs;
|
|
13
|
+
return new MenuManager(mustRemoveTrailingSlashs, this.getCurrentURL());
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getMenuManager(): MenuManager {
|
|
18
|
+
return this.objectRegistry.getObject<MenuManager>("uikit.menuManager")!;
|
|
19
|
+
}
|
|
20
|
+
}
|