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,133 @@
|
|
|
1
|
+
// noinspection JSUnusedGlobalSymbols
|
|
2
|
+
|
|
3
|
+
import React, {useEffect, useState} from "react";
|
|
4
|
+
|
|
5
|
+
import {isServerSide} from "jopi-toolkit/jk_what";
|
|
6
|
+
import {useEvent, useServerRequest} from "jopijs/ui";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Allow refreshing the React component.
|
|
10
|
+
*/
|
|
11
|
+
export function useRefresh() {
|
|
12
|
+
const [_, setCount] = useState(0);
|
|
13
|
+
return () => setCount(old => old + 1);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function useRefreshOnEvent(evenName: string|string[]) {
|
|
17
|
+
const [_, setCounter] = useState(0);
|
|
18
|
+
useEvent(evenName, () => { setCounter(prev => prev + 1) });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function useEventValue<T = any>(evenName: string|string[], defaultProvider?: T | (() => T)): T|undefined {
|
|
22
|
+
const [value, setValue] = useState<T|undefined>(defaultProvider);
|
|
23
|
+
|
|
24
|
+
useEvent(evenName, (data) => {
|
|
25
|
+
setValue(data)
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Allow submitting a form.
|
|
33
|
+
*
|
|
34
|
+
* @param onFormReturns
|
|
35
|
+
* A function which is called when the form call returns positively.
|
|
36
|
+
* @param url
|
|
37
|
+
* An optional url to url.
|
|
38
|
+
* @returns
|
|
39
|
+
* Return an array of two elements:
|
|
40
|
+
* - Set function allowing to submit the form.
|
|
41
|
+
* It takes in arg the event sent by Form.onSubmit
|
|
42
|
+
* - Set value of the form, or undefined if not submit.
|
|
43
|
+
*/
|
|
44
|
+
export function useFormSubmit<T = any>(onFormReturns?: (data: T) => void, url?: string): UseFormSubmitResponse<T> {
|
|
45
|
+
if (isServerSide) {
|
|
46
|
+
return [() => {}, undefined, false]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const [state, setState] = useState<T|undefined>(undefined);
|
|
50
|
+
const [isSending, setIsSending] = useState(false);
|
|
51
|
+
|
|
52
|
+
async function f(e: React.FormEvent<HTMLFormElement>) {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
url = url || window.location.href;
|
|
55
|
+
|
|
56
|
+
const formData = new FormData(e.currentTarget);
|
|
57
|
+
setIsSending(true);
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
const response = await fetch(url!, {
|
|
61
|
+
method: 'POST',
|
|
62
|
+
body: formData,
|
|
63
|
+
credentials: 'include'
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
if (response.ok) {
|
|
67
|
+
let v = await response.json() as T;
|
|
68
|
+
setState(v);
|
|
69
|
+
if (onFormReturns) onFormReturns(v);
|
|
70
|
+
} else {
|
|
71
|
+
console.error("useFormSubmit - Not 200 response", response);
|
|
72
|
+
}
|
|
73
|
+
} catch (e) {
|
|
74
|
+
console.error("useFormSubmit - Network error", e);
|
|
75
|
+
}
|
|
76
|
+
finally {
|
|
77
|
+
setIsSending(false);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return [f, state, isSending];
|
|
82
|
+
}
|
|
83
|
+
//
|
|
84
|
+
type UseFormSubmitResponse<T> = [
|
|
85
|
+
(e: React.FormEvent<HTMLFormElement>) => void,
|
|
86
|
+
T | undefined,
|
|
87
|
+
boolean
|
|
88
|
+
];
|
|
89
|
+
|
|
90
|
+
export function useSendJsonData<T = any>(onFormReturns?: (data: T) => void, url?: string): UseSendPostDataResponse<T> {
|
|
91
|
+
if (isServerSide) {
|
|
92
|
+
return [() => {}, undefined, false]
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const [state, setState] = useState<T|undefined>(undefined);
|
|
96
|
+
const [isSending, setIsSending] = useState(false);
|
|
97
|
+
|
|
98
|
+
async function f(data: T) {
|
|
99
|
+
url = url || window.location.href;
|
|
100
|
+
|
|
101
|
+
try {
|
|
102
|
+
setIsSending(true);
|
|
103
|
+
|
|
104
|
+
const response = await fetch(url!, {
|
|
105
|
+
method: 'POST',
|
|
106
|
+
headers: {'Content-Type': 'application/json'},
|
|
107
|
+
body: JSON.stringify(data),
|
|
108
|
+
credentials: 'include'
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
if (response.ok) {
|
|
112
|
+
let v = await response.json() as T;
|
|
113
|
+
setState(v);
|
|
114
|
+
if (onFormReturns) onFormReturns(v);
|
|
115
|
+
} else {
|
|
116
|
+
console.error("useSendPostData - Not 200 response", response);
|
|
117
|
+
}
|
|
118
|
+
} catch (e) {
|
|
119
|
+
console.error("useSendPostData - Network error", e);
|
|
120
|
+
}
|
|
121
|
+
finally {
|
|
122
|
+
setIsSending(false);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return [f, state, isSending];
|
|
127
|
+
}
|
|
128
|
+
//
|
|
129
|
+
type UseSendPostDataResponse<T> = [
|
|
130
|
+
(data: T) => void
|
|
131
|
+
, T | undefined,
|
|
132
|
+
boolean
|
|
133
|
+
];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export type UiText = string | React.ReactNode;
|
|
4
|
+
|
|
5
|
+
export function ucFirst(text: string): string {
|
|
6
|
+
return text.charAt(0).toUpperCase() + text.slice(1);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function IfTrue(cond: any, value: React.ReactNode) {
|
|
10
|
+
if (cond) return value;
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function UseIfDefined(value: any) {
|
|
15
|
+
if (value) return value;
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function IfFalse(cond: any, value: React.ReactNode) {
|
|
20
|
+
if (!cond) return value;
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function sendFormData(url: string, formData: FormData): Promise<Response> {
|
|
25
|
+
return fetch(url!, {
|
|
26
|
+
method: 'POST',
|
|
27
|
+
body: formData,
|
|
28
|
+
credentials: 'include'
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function sendJsonData(url: string, data: any): Promise<Response> {
|
|
33
|
+
return fetch(url!, {
|
|
34
|
+
method: 'POST',
|
|
35
|
+
headers: {'Content-Type': 'application/json'},
|
|
36
|
+
body: JSON.stringify(data),
|
|
37
|
+
credentials: 'include'
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {isBrowser} from "jopi-toolkit/jk_what";
|
|
2
|
+
|
|
3
|
+
// Expose all his item to simplify things.
|
|
4
|
+
export * from "jopijs/ui";
|
|
5
|
+
|
|
6
|
+
export * from "./helpers/index.ts";
|
|
7
|
+
export * from "./forms/index.ts";
|
|
8
|
+
export * from "./users/index.ts";
|
|
9
|
+
export * from "./menu/index.ts";
|
|
10
|
+
export * from "./core/index.ts";
|
|
11
|
+
export * from "./reactRouter/index.ts";
|
|
12
|
+
export * from "./variants/index.tsx";
|
|
13
|
+
|
|
14
|
+
export const isBrowserSide = isBrowser;
|
|
15
|
+
export const isServerSide = !isBrowser;
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import {HierarchyBuilder} from "./internal.ts";
|
|
2
|
+
import * as jk_events from "jopi-toolkit/jk_events";
|
|
3
|
+
|
|
4
|
+
import {ucFirst} from "../helpers/tools.ts";
|
|
5
|
+
import type {MenuItem} from "./interfaces.ts";
|
|
6
|
+
|
|
7
|
+
type MenuBuilder = (menu: AppMenu) => void;
|
|
8
|
+
|
|
9
|
+
export class MenuManager {
|
|
10
|
+
private isInvalid = true;
|
|
11
|
+
private allMenus: Record<string, AppMenu> = {};
|
|
12
|
+
private readonly menuBuilders: Record<string, MenuBuilder[]> = {};
|
|
13
|
+
|
|
14
|
+
constructor(private readonly mustRemoveTrailingSlashs: boolean, private readonly forceURL?: URL) {
|
|
15
|
+
jk_events.addListener("user.infosUpdated", () => {
|
|
16
|
+
this.invalidateMenus(true);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
jk_events.addListener("app.router.locationUpdated", () => {
|
|
20
|
+
this.updateActiveItems();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private getUrlPathName(): string {
|
|
25
|
+
let url = (this.forceURL || new URL(window.location.href)).pathname;
|
|
26
|
+
if (!url.endsWith("/")) url += "/";
|
|
27
|
+
return url;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getMenuItems(name: string): MenuItem[] {
|
|
31
|
+
if (this.isInvalid) {
|
|
32
|
+
this.buildAllMenu();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
let menu = this.allMenus[name];
|
|
36
|
+
|
|
37
|
+
if (!menu) {
|
|
38
|
+
if (this.menuBuilders[name]) {
|
|
39
|
+
this.buildAllMenu();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (menu) {
|
|
44
|
+
const items = menu.value.items;
|
|
45
|
+
if (!items) return [];
|
|
46
|
+
return items as MenuItem[];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private isActiveItemSearched = false;
|
|
53
|
+
|
|
54
|
+
private buildAllMenu() {
|
|
55
|
+
function checkItem(item: MenuItem, breadcrumb: string[]) {
|
|
56
|
+
if (item.title) {
|
|
57
|
+
breadcrumb = breadcrumb ? [...breadcrumb, item.title!] : [item.title!];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (item.breadcrumb===undefined) {
|
|
61
|
+
item.breadcrumb = breadcrumb;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
item.reactKey = "R" + (gReactKey++) + "_"
|
|
65
|
+
|
|
66
|
+
if (item.items) {
|
|
67
|
+
for (const child of item.items) {
|
|
68
|
+
checkItem(child, breadcrumb);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
this.isInvalid = false;
|
|
74
|
+
|
|
75
|
+
for (let menuName in this.menuBuilders) {
|
|
76
|
+
let builders = this.menuBuilders[menuName];
|
|
77
|
+
|
|
78
|
+
const menu = new AppMenu({key: menuName});
|
|
79
|
+
menu.setNormalizer(this.mustRemoveTrailingSlashs ? menuNormalizer_removeTrailingSlash : menuNormalizer_addTrailingSlash);
|
|
80
|
+
this.allMenus[menuName] = menu;
|
|
81
|
+
|
|
82
|
+
for (const builder of builders) {
|
|
83
|
+
builder(menu);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
checkItem(menu.value, []);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
this.updateActiveItems();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
private updateActiveItems() {
|
|
93
|
+
this.isActiveItemSearched = true;
|
|
94
|
+
|
|
95
|
+
//region Reset menu items
|
|
96
|
+
|
|
97
|
+
function reset(item: MenuItem) {
|
|
98
|
+
item.isActive = false;
|
|
99
|
+
|
|
100
|
+
if (item.items) {
|
|
101
|
+
for (const child of item.items) {
|
|
102
|
+
reset(child);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
for (let menuName in this.allMenus) {
|
|
108
|
+
// Will force rebuilding.
|
|
109
|
+
const menu = this.getMenuItems(menuName);
|
|
110
|
+
if (menu) menu.forEach(reset);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//endregion
|
|
114
|
+
|
|
115
|
+
for (const menuName in this.allMenus) {
|
|
116
|
+
this.searchMatchingMenuItem(menuName);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
public getMatchingMenuItem(forceRefresh: boolean = false): MenuItem|undefined {
|
|
121
|
+
if (this.isInvalid) {
|
|
122
|
+
this.buildAllMenu();
|
|
123
|
+
}
|
|
124
|
+
else if (!this.isActiveItemSearched || forceRefresh) {
|
|
125
|
+
this.updateActiveItems();
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return gMenuActiveItem;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
private searchMatchingMenuItem(menuName?: string): MenuItem|undefined {
|
|
132
|
+
function checkItem(item: MenuItem): boolean {
|
|
133
|
+
item.isActive = false;
|
|
134
|
+
let isActive = item.url===pathName;
|
|
135
|
+
|
|
136
|
+
if (isActive) {
|
|
137
|
+
matchingMenuItem = item;
|
|
138
|
+
|
|
139
|
+
if (gMenuActiveItem!==item) {
|
|
140
|
+
gMenuActiveItem = item;
|
|
141
|
+
jk_events.sendEvent("app.menu.activeItemChanged", {menuName, menuItem: item});
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (item.items) {
|
|
146
|
+
for (const child of item.items) {
|
|
147
|
+
if (checkItem(child)) {
|
|
148
|
+
isActive = true;
|
|
149
|
+
break;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
item.isActive = isActive;
|
|
155
|
+
return isActive;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
let pathName = this.getUrlPathName();
|
|
159
|
+
|
|
160
|
+
if (this.mustRemoveTrailingSlashs) {
|
|
161
|
+
if (pathName.endsWith("/")) {
|
|
162
|
+
pathName = pathName.slice(0, -1);
|
|
163
|
+
}
|
|
164
|
+
} else {
|
|
165
|
+
if (!pathName.endsWith("/")) {
|
|
166
|
+
pathName += "/";
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
let matchingMenuItem: MenuItem|undefined;
|
|
171
|
+
|
|
172
|
+
if (menuName) {
|
|
173
|
+
const menu = this.allMenus[menuName];
|
|
174
|
+
if (menu) checkItem(menu.value);
|
|
175
|
+
} else {
|
|
176
|
+
for (const key in this.allMenus) {
|
|
177
|
+
const menu = this.allMenus[key];
|
|
178
|
+
checkItem(menu.value);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return matchingMenuItem;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
addMenuBuilder(menuName: string, builder: (menu: AppMenu) => void) {
|
|
186
|
+
let builders = this.menuBuilders[menuName];
|
|
187
|
+
if (!builders) this.menuBuilders[menuName] = [builder];
|
|
188
|
+
else builders.push(builder);
|
|
189
|
+
|
|
190
|
+
this.invalidateMenus();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
invalidateMenus(force = false) {
|
|
194
|
+
if (this.isInvalid) {
|
|
195
|
+
if (!force) return;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
this.isInvalid = true;
|
|
199
|
+
this.allMenus = {};
|
|
200
|
+
|
|
201
|
+
jk_events.sendEvent("app.menu.invalided", this);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export class AppMenu extends HierarchyBuilder<MenuItem> {
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function normalizeMenuItem(item: MenuItem) {
|
|
209
|
+
if (!item.title) {
|
|
210
|
+
if (item.key) {
|
|
211
|
+
item.title = ucFirst(item.key);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function menuNormalizer_addTrailingSlash(item: MenuItem) {
|
|
217
|
+
normalizeMenuItem(item);
|
|
218
|
+
if (item.url && !item.url.endsWith("/")) item.url += "/";
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function menuNormalizer_removeTrailingSlash(item: MenuItem) {
|
|
222
|
+
normalizeMenuItem(item);
|
|
223
|
+
if (item.url && item.url.endsWith("/")) item.url = item.url.slice(0, -1);;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
let gReactKey = 0;
|
|
227
|
+
let gMenuActiveItem: MenuItem|undefined;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import {MenuManager} from "./core.ts";
|
|
2
|
+
import {type MenuItem} from "./interfaces.ts";
|
|
3
|
+
import {isServerSide} from "jopi-toolkit/jk_what";
|
|
4
|
+
import {_usePage, useEvent} from "jopijs/ui";
|
|
5
|
+
import {useState} from "react";
|
|
6
|
+
|
|
7
|
+
export function useMenuManager(): MenuManager {
|
|
8
|
+
return _usePage().objectRegistry.getObject<MenuManager>("uikit.menuManager")!
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function useMatchingMenuItem(): MenuItem|undefined {
|
|
12
|
+
return useMenuManager().getMatchingMenuItem();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function useMenu(name: string): MenuItem[] {
|
|
16
|
+
const menuManager = useMenuManager();
|
|
17
|
+
if (isServerSide) return menuManager.getMenuItems(name);
|
|
18
|
+
|
|
19
|
+
// Will refresh one menu change.
|
|
20
|
+
const [_, setCount] = useState(0);
|
|
21
|
+
|
|
22
|
+
useEvent(["app.menu.invalided", "app.menu.activeItemChanged"], () => {
|
|
23
|
+
console.log("useMenu - Refreshing menu", name);
|
|
24
|
+
setCount(count => count + 1)
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
return menuManager.getMenuItems(name);
|
|
28
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
export enum MenuName {
|
|
4
|
+
LEFT_MENU = "layout.left",
|
|
5
|
+
RIGHT_MENU = "layout.right",
|
|
6
|
+
TOP_MENU = "layout.top"
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface MenuItem {
|
|
10
|
+
key: string;
|
|
11
|
+
items?: MenuItem[];
|
|
12
|
+
|
|
13
|
+
title?: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
icon?: any;
|
|
16
|
+
isActive?: boolean;
|
|
17
|
+
|
|
18
|
+
breadcrumb?: string[] | React.FunctionComponent<unknown>;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Is used as a key for React key calculation.
|
|
22
|
+
*/
|
|
23
|
+
reactKey?: string;
|
|
24
|
+
|
|
25
|
+
[key: string]: any;
|
|
26
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import {MenuManager} from "./core.ts";
|
|
2
|
+
|
|
3
|
+
//region HierarchyBuilder
|
|
4
|
+
|
|
5
|
+
export interface WithKeyAndItems<T> {
|
|
6
|
+
key: string;
|
|
7
|
+
items?: (T & WithKeyAndItems<T>)[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class HierarchyBuilder<T extends WithKeyAndItems<T>> {
|
|
11
|
+
private normalizer: ((v: T) => void)|undefined;
|
|
12
|
+
|
|
13
|
+
constructor(private readonly root: T, public readonly offset = -1, public readonly parentItems?: T[]) {
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
setNormalizer(f: (v: T) => void) {
|
|
17
|
+
this.normalizer = f;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get value(): T {
|
|
21
|
+
return this.root;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
set value(value: Omit<T, 'key' | 'items'>) {
|
|
25
|
+
for (let entry in value) {
|
|
26
|
+
if (value.hasOwnProperty(entry)) {
|
|
27
|
+
(this.root as any)[entry] = (value as any)[entry];
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (this.normalizer) {
|
|
32
|
+
this.applyNormalizer(this.root);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Return a HierarchyBuilder on the selected item.
|
|
38
|
+
|
|
39
|
+
* @param keys string[]
|
|
40
|
+
* Traverse the hierarchy to search the item with the corresponding key.
|
|
41
|
+
* If it doesn't exist, create it.
|
|
42
|
+
*
|
|
43
|
+
* @param keys (e: T) => boolean
|
|
44
|
+
* Search an element in the direct item of the element.
|
|
45
|
+
* Returns a detached HierarchyBuilder if not found.
|
|
46
|
+
*/
|
|
47
|
+
selectItem(keys: string[]|((e: T) => boolean)): HierarchyBuilder<T> {
|
|
48
|
+
if (keys instanceof Array) {
|
|
49
|
+
let keyOffset = 0;
|
|
50
|
+
const maxKeyOffset = keys.length;
|
|
51
|
+
if (!maxKeyOffset) return this;
|
|
52
|
+
|
|
53
|
+
let selected = this.root;
|
|
54
|
+
let selectedOffset = -1;
|
|
55
|
+
let selectedParent = this.parentItems;
|
|
56
|
+
|
|
57
|
+
while (true) {
|
|
58
|
+
if (keyOffset === maxKeyOffset) {
|
|
59
|
+
const n = new HierarchyBuilder(selected, selectedOffset, selectedParent);
|
|
60
|
+
n.normalizer = this.normalizer;
|
|
61
|
+
return n;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const key = keys[keyOffset++];
|
|
65
|
+
if (!selected.items) selected.items = [];
|
|
66
|
+
|
|
67
|
+
let isFound = false;
|
|
68
|
+
selectedParent = selected.items;
|
|
69
|
+
|
|
70
|
+
let entryOffset = 0;
|
|
71
|
+
|
|
72
|
+
for (let entry of selected.items) {
|
|
73
|
+
if (entry.key===key) {
|
|
74
|
+
selected = entry;
|
|
75
|
+
selectedOffset = entryOffset;
|
|
76
|
+
isFound = true;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
entryOffset++;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (!isFound) {
|
|
84
|
+
selectedOffset = selected.items!.length;
|
|
85
|
+
selected.items!.push(selected = this.normalize({key} as T));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
} else {
|
|
89
|
+
if (this.root.items) {
|
|
90
|
+
let entryOffset = 0;
|
|
91
|
+
|
|
92
|
+
for (let entry of this.root.items!) {
|
|
93
|
+
if (keys(entry)) {
|
|
94
|
+
const n = new HierarchyBuilder<T>(entry, entryOffset, this.parentItems);
|
|
95
|
+
n.normalizer = this.normalizer;
|
|
96
|
+
return n;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
entryOffset++;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return gDetachedHierarchyBuilder as unknown as HierarchyBuilder<T>;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
normalize(entry: T): T {
|
|
108
|
+
if (this.normalizer) this.applyNormalizer(entry);
|
|
109
|
+
return entry;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
parentAddBefore(entry: T) {
|
|
113
|
+
if (this.parentItems && this.offset >= 0) {
|
|
114
|
+
if (this.normalizer) this.applyNormalizer(entry);
|
|
115
|
+
this.parentItems.splice(this.offset, 0, entry);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
parentAddAfter(entry: T) {
|
|
120
|
+
if (this.parentItems && this.offset >= 0) {
|
|
121
|
+
if (this.normalizer) this.applyNormalizer(entry);
|
|
122
|
+
this.parentItems.splice(this.offset + 1, 0, entry);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
parentWrap(entry: T) {
|
|
127
|
+
if (this.parentItems && this.offset >= 0) {
|
|
128
|
+
if (this.normalizer) this.applyNormalizer(entry);
|
|
129
|
+
this.parentItems.splice(this.offset + 1, 0, entry);
|
|
130
|
+
this.parentItems.splice(this.offset, 0, entry);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
append(entry: T) {
|
|
135
|
+
if (this.normalizer) {
|
|
136
|
+
this.applyNormalizer(entry);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
if (!this.root.items) {
|
|
140
|
+
this.root.items = [entry];
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
let alreadyExists = this.root.items.find(e => e.key === entry.key);
|
|
144
|
+
|
|
145
|
+
if (alreadyExists) {
|
|
146
|
+
for (let key in entry) {
|
|
147
|
+
if (entry.hasOwnProperty(key)) {
|
|
148
|
+
(alreadyExists as any)[key] = (entry as any)[key];
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
this.root.items.push(entry);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
prepend(entry: T) {
|
|
158
|
+
if (this.normalizer) {
|
|
159
|
+
this.applyNormalizer(entry);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (!this.root.items) {
|
|
163
|
+
this.root.items = [entry];
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
let alreadyExists = this.root.items.find(e => e.key === entry.key);
|
|
167
|
+
|
|
168
|
+
if (alreadyExists) {
|
|
169
|
+
for (let key in entry) {
|
|
170
|
+
if (entry.hasOwnProperty(key)) {
|
|
171
|
+
(alreadyExists as any)[key] = (entry as any)[key];
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
this.root.items.splice(0, 0, entry);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Search an element in the current items by applying a filter function.
|
|
182
|
+
* Returns the first corresponding entry.
|
|
183
|
+
*/
|
|
184
|
+
searchFirstEntry(filter: (e: T) => boolean): T|undefined {
|
|
185
|
+
for (let entry of this.root.items!) {
|
|
186
|
+
if (filter(entry)) return entry;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return undefined;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
private applyNormalizer(entry: T) {
|
|
193
|
+
if (this.normalizer) {
|
|
194
|
+
this.normalizer(entry);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (entry.items) {
|
|
198
|
+
for (let item of entry.items) {
|
|
199
|
+
this.applyNormalizer(item);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const gDetachedHierarchyBuilder = new HierarchyBuilder({key: ""});
|
|
206
|
+
|
|
207
|
+
//endregion
|
|
208
|
+
|
|
209
|
+
export function getDefaultMenuManager(): MenuManager {
|
|
210
|
+
if (!gMenuManager) {
|
|
211
|
+
let mustRemoveTrailingSlashs = (window as any)["__JOPI_OPTIONS__"].removeTrailingSlashs === true
|
|
212
|
+
gMenuManager = new MenuManager(mustRemoveTrailingSlashs);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return gMenuManager;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
let gMenuManager: MenuManager|undefined;
|