@fecommunity/reactpress-toolkit 3.0.4 → 3.7.0
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/LICENSE +1 -1
- package/README.md +194 -309
- package/dist/.source-fingerprint-toolkit +1 -0
- package/dist/admin/index.d.ts +2 -0
- package/dist/admin/index.js +18 -0
- package/dist/admin/permissions.d.ts +5 -0
- package/dist/admin/permissions.js +33 -0
- package/dist/admin/registry.d.ts +62 -0
- package/dist/admin/registry.js +79 -0
- package/dist/api/HttpClient.d.ts +2 -2
- package/dist/api/HttpClient.js +1 -1
- package/dist/api/Smtp.d.ts +17 -0
- package/dist/api/Smtp.js +15 -0
- package/dist/api/instance.d.ts +1 -1
- package/dist/api/instance.js +3 -3
- package/dist/app/createReactPressApp.d.ts +8 -0
- package/dist/app/createReactPressApp.js +265 -0
- package/dist/app/createThemeApp.d.ts +8 -0
- package/dist/app/createThemeApp.js +51 -0
- package/dist/app/devChunkRecovery.d.ts +2 -0
- package/dist/app/devChunkRecovery.js +68 -0
- package/dist/app/index.d.ts +39 -0
- package/dist/app/index.js +11 -0
- package/dist/config/env.js +29 -15
- package/dist/config/global.d.ts +7 -1
- package/dist/config/global.js +9 -3
- package/dist/config/i18n.js +27 -11
- package/dist/config/index.d.ts +3 -3
- package/dist/config/index.js +6 -5
- package/dist/{locales → config/locales}/en.json +31 -3
- package/dist/{locales → config/locales}/zh.json +31 -3
- package/dist/dev/index.d.ts +3 -0
- package/dist/dev/index.js +12 -0
- package/dist/dev/portRedirect.d.ts +20 -0
- package/dist/dev/portRedirect.js +93 -0
- package/dist/dev/vitePortRedirectPlugin.d.ts +24 -0
- package/dist/dev/vitePortRedirectPlugin.js +40 -0
- package/dist/extension/branding-mods.d.ts +10 -0
- package/dist/extension/branding-mods.js +65 -0
- package/dist/extension/configuration/defaults.d.ts +3 -0
- package/dist/extension/configuration/defaults.js +32 -0
- package/dist/extension/configuration/formily.d.ts +10 -0
- package/dist/extension/configuration/formily.js +170 -0
- package/dist/extension/configuration/index.d.ts +7 -0
- package/dist/extension/configuration/index.js +28 -0
- package/dist/extension/configuration/paths.d.ts +4 -0
- package/dist/extension/configuration/paths.js +50 -0
- package/dist/extension/configuration/presets/twentytwentyfive.d.ts +7 -0
- package/dist/extension/configuration/presets/twentytwentyfive.js +94 -0
- package/dist/extension/configuration/resolve.d.ts +24 -0
- package/dist/extension/configuration/resolve.js +98 -0
- package/dist/extension/configuration/types.d.ts +68 -0
- package/dist/extension/configuration/types.js +3 -0
- package/dist/extension/configuration/validate.d.ts +8 -0
- package/dist/extension/configuration/validate.js +21 -0
- package/dist/extension/index.d.ts +9 -0
- package/dist/extension/index.js +35 -0
- package/dist/extension/manifest-normalize.d.ts +5 -0
- package/dist/extension/manifest-normalize.js +75 -0
- package/dist/extension/node.d.ts +2 -0
- package/dist/extension/node.js +6 -0
- package/dist/extension/presets/twentytwentyfive-appearance.d.ts +10 -0
- package/dist/extension/presets/twentytwentyfive-appearance.js +193 -0
- package/dist/extension/presets/twentytwentyfive-customizer.d.ts +19 -0
- package/dist/extension/presets/twentytwentyfive-customizer.js +199 -0
- package/dist/extension/preview.d.ts +46 -0
- package/dist/extension/preview.js +92 -0
- package/dist/extension/site-notices.d.ts +19 -0
- package/dist/extension/site-notices.js +88 -0
- package/dist/extension/site-settings.d.ts +37 -0
- package/dist/extension/site-settings.js +144 -0
- package/dist/extension/theme-admin-locale.d.ts +11 -0
- package/dist/extension/theme-admin-locale.io.d.ts +2 -0
- package/dist/extension/theme-admin-locale.io.js +54 -0
- package/dist/extension/theme-admin-locale.js +81 -0
- package/dist/extension/theme.d.ts +89 -0
- package/dist/extension/theme.js +93 -0
- package/dist/extension/twentytwentyfive-vars.d.ts +7 -0
- package/dist/extension/twentytwentyfive-vars.js +100 -0
- package/dist/index.d.ts +15 -7
- package/dist/index.js +44 -22
- package/dist/plugin/admin/index.d.ts +2 -0
- package/dist/plugin/admin/index.js +18 -0
- package/dist/plugin/admin/permissions.d.ts +5 -0
- package/dist/plugin/admin/permissions.js +33 -0
- package/dist/plugin/admin/plugin-admin.d.ts +37 -0
- package/dist/plugin/admin/plugin-admin.js +41 -0
- package/dist/plugin/admin/registry.d.ts +62 -0
- package/dist/plugin/admin/registry.js +79 -0
- package/dist/plugin/admin/slots.d.ts +36 -0
- package/dist/plugin/admin/slots.js +16 -0
- package/dist/plugin/client/client.d.ts +14 -0
- package/dist/plugin/client/client.js +95 -0
- package/dist/plugin/client/index.d.ts +4 -0
- package/dist/plugin/client/index.js +11 -0
- package/dist/plugin/client/runtime.d.ts +18 -0
- package/dist/plugin/client/runtime.js +30 -0
- package/dist/plugin/dev/index.d.ts +4 -0
- package/dist/plugin/dev/index.js +16 -0
- package/dist/plugin/dev/portRedirect.d.ts +26 -0
- package/dist/plugin/dev/portRedirect.js +111 -0
- package/dist/plugin/dev/vitePortRedirectPlugin.d.ts +24 -0
- package/dist/plugin/dev/vitePortRedirectPlugin.js +40 -0
- package/dist/plugin/extension/index.d.ts +4 -0
- package/dist/plugin/extension/index.js +20 -0
- package/dist/plugin/extension/plugin-admin-locale.d.ts +21 -0
- package/dist/plugin/extension/plugin-admin-locale.io.d.ts +2 -0
- package/dist/plugin/extension/plugin-admin-locale.io.js +54 -0
- package/dist/plugin/extension/plugin-admin-locale.js +60 -0
- package/dist/plugin/extension/plugin.d.ts +82 -0
- package/dist/plugin/extension/plugin.js +146 -0
- package/dist/plugin/extension/security.d.ts +7 -0
- package/dist/plugin/extension/security.js +74 -0
- package/dist/plugin/extension/validate.d.ts +8 -0
- package/dist/plugin/extension/validate.js +55 -0
- package/dist/plugin/index.d.ts +9 -0
- package/dist/plugin/index.js +48 -0
- package/dist/plugin/node.d.ts +2 -0
- package/dist/plugin/node.js +6 -0
- package/dist/plugin/react/client.d.ts +14 -0
- package/dist/plugin/react/client.js +95 -0
- package/dist/plugin/react/index.d.ts +2 -0
- package/dist/plugin/react/index.js +18 -0
- package/dist/plugin/react/plugin-admin-ui.d.ts +23 -0
- package/dist/plugin/react/plugin-admin-ui.js +38 -0
- package/dist/plugin/react/runtime.d.ts +18 -0
- package/dist/plugin/react/runtime.js +30 -0
- package/dist/plugin/server/hook-reject.d.ts +12 -0
- package/dist/plugin/server/hook-reject.js +39 -0
- package/dist/plugin/server/index.d.ts +2 -0
- package/dist/plugin/server/index.js +18 -0
- package/dist/plugin/server/types.d.ts +34 -0
- package/dist/plugin/server/types.js +3 -0
- package/dist/primitives/AntdStyleTransitionFix.d.ts +2 -0
- package/dist/primitives/AntdStyleTransitionFix.js +16 -0
- package/dist/primitives/Badge.d.ts +7 -0
- package/dist/primitives/Badge.js +9 -0
- package/dist/primitives/Button.d.ts +10 -0
- package/dist/primitives/Button.js +38 -0
- package/dist/primitives/ColorModeToggle.d.ts +8 -0
- package/dist/primitives/ColorModeToggle.js +13 -0
- package/dist/primitives/IconButton.d.ts +7 -0
- package/dist/primitives/IconButton.js +13 -0
- package/dist/primitives/ScrollToTarget.d.ts +9 -0
- package/dist/primitives/ScrollToTarget.js +48 -0
- package/dist/primitives/Separator.d.ts +7 -0
- package/dist/primitives/Separator.js +9 -0
- package/dist/primitives/Skeleton.d.ts +7 -0
- package/dist/primitives/Skeleton.js +9 -0
- package/dist/primitives/Slot.d.ts +10 -0
- package/dist/primitives/Slot.js +25 -0
- package/dist/primitives/Spinner.d.ts +6 -0
- package/dist/primitives/Spinner.js +9 -0
- package/dist/primitives/animation/ConditionTransition.d.ts +8 -0
- package/dist/primitives/animation/ConditionTransition.js +13 -0
- package/dist/primitives/animation/ListTrail.d.ts +10 -0
- package/dist/primitives/animation/ListTrail.js +14 -0
- package/dist/primitives/animation/Opacity.d.ts +3 -0
- package/dist/primitives/animation/Opacity.js +10 -0
- package/dist/primitives/animation/Spring.d.ts +9 -0
- package/dist/primitives/animation/Spring.js +29 -0
- package/dist/primitives/animation/index.d.ts +7 -0
- package/dist/primitives/animation/index.js +11 -0
- package/dist/primitives/cn.d.ts +4 -0
- package/dist/primitives/cn.js +7 -0
- package/dist/primitives/icons.d.ts +4 -0
- package/dist/primitives/icons.js +15 -0
- package/dist/primitives/index.d.ts +22 -0
- package/dist/primitives/index.js +44 -0
- package/dist/react/client.d.ts +14 -0
- package/dist/react/client.js +95 -0
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.js +11 -0
- package/dist/react/runtime.d.ts +18 -0
- package/dist/react/runtime.js +30 -0
- package/dist/theme/antdDocument.d.ts +18 -0
- package/dist/theme/antdDocument.js +59 -0
- package/dist/theme/api/api-data.d.ts +2 -0
- package/dist/theme/api/api-data.js +8 -0
- package/dist/theme/api/api.d.ts +28 -0
- package/dist/theme/api/api.js +27 -0
- package/dist/theme/api/httpClient.d.ts +24 -0
- package/dist/theme/api/httpClient.js +83 -0
- package/dist/theme/api/json.d.ts +1 -0
- package/dist/theme/api/json.js +5 -0
- package/dist/theme/api/jsonp.d.ts +1 -0
- package/dist/theme/api/jsonp.js +5 -0
- package/dist/theme/api-data.d.ts +12 -0
- package/dist/theme/api-data.js +22 -0
- package/dist/theme/api.d.ts +28 -0
- package/dist/theme/api.js +27 -0
- package/dist/theme/appearance.d.ts +4 -0
- package/dist/theme/appearance.js +16 -0
- package/dist/theme/assets.d.ts +2 -0
- package/dist/theme/assets.js +27 -0
- package/dist/theme/authSession.d.ts +16 -0
- package/dist/theme/authSession.js +92 -0
- package/dist/theme/build/antdDocument.d.ts +145 -0
- package/dist/theme/build/antdDocument.js +70 -0
- package/dist/theme/build/next-config.d.ts +15 -0
- package/dist/theme/build/next-config.js +63 -0
- package/dist/theme/build/node.d.ts +2 -0
- package/dist/theme/build/node.js +6 -0
- package/dist/theme/colorMode.d.ts +12 -0
- package/dist/theme/colorMode.js +45 -0
- package/dist/theme/commentAuthor.d.ts +17 -0
- package/dist/theme/commentAuthor.js +48 -0
- package/dist/theme/content/archiveSlim.d.ts +7 -0
- package/dist/theme/content/archiveSlim.js +38 -0
- package/dist/theme/content/articleSlim.d.ts +10 -0
- package/dist/theme/content/articleSlim.js +35 -0
- package/dist/theme/content/assets.d.ts +8 -0
- package/dist/theme/content/assets.js +74 -0
- package/dist/theme/content/carouselArticles.d.ts +10 -0
- package/dist/theme/content/carouselArticles.js +39 -0
- package/dist/theme/content/excerpt.d.ts +15 -0
- package/dist/theme/content/excerpt.js +42 -0
- package/dist/theme/content/nav.d.ts +10 -0
- package/dist/theme/content/nav.js +30 -0
- package/dist/theme/content/seo.d.ts +6 -0
- package/dist/theme/content/seo.js +12 -0
- package/dist/theme/createAntdApp.d.ts +106 -0
- package/dist/theme/createAntdApp.js +175 -0
- package/dist/theme/createApp.d.ts +10 -0
- package/dist/theme/createApp.js +141 -0
- package/dist/theme/createCatalogApp.d.ts +108 -0
- package/dist/theme/createCatalogApp.js +168 -0
- package/dist/theme/customizer.d.ts +1 -0
- package/dist/theme/customizer.js +5 -0
- package/dist/theme/excerpt.d.ts +16 -0
- package/dist/theme/excerpt.js +31 -0
- package/dist/theme/extension/branding-mods.d.ts +10 -0
- package/dist/theme/extension/branding-mods.js +65 -0
- package/dist/theme/extension/configuration/defaults.d.ts +3 -0
- package/dist/theme/extension/configuration/defaults.js +32 -0
- package/dist/theme/extension/configuration/formily.d.ts +10 -0
- package/dist/theme/extension/configuration/formily.js +170 -0
- package/dist/theme/extension/configuration/index.d.ts +7 -0
- package/dist/theme/extension/configuration/index.js +28 -0
- package/dist/theme/extension/configuration/paths.d.ts +1 -0
- package/dist/theme/extension/configuration/paths.js +7 -0
- package/dist/theme/extension/configuration/presets/twentytwentyfive.d.ts +7 -0
- package/dist/theme/extension/configuration/presets/twentytwentyfive.js +94 -0
- package/dist/theme/extension/configuration/resolve.d.ts +24 -0
- package/dist/theme/extension/configuration/resolve.js +98 -0
- package/dist/theme/extension/configuration/types.d.ts +68 -0
- package/dist/theme/extension/configuration/types.js +3 -0
- package/dist/theme/extension/configuration/validate.d.ts +8 -0
- package/dist/theme/extension/configuration/validate.js +21 -0
- package/dist/theme/extension/index.d.ts +11 -0
- package/dist/theme/extension/index.js +38 -0
- package/dist/theme/extension/manifest-normalize.d.ts +5 -0
- package/dist/theme/extension/manifest-normalize.js +75 -0
- package/dist/theme/extension/presets/twentytwentyfive-appearance.d.ts +10 -0
- package/dist/theme/extension/presets/twentytwentyfive-appearance.js +193 -0
- package/dist/theme/extension/preview.d.ts +46 -0
- package/dist/theme/extension/preview.js +92 -0
- package/dist/theme/extension/site-notices.d.ts +19 -0
- package/dist/theme/extension/site-notices.js +88 -0
- package/dist/theme/extension/site-settings.d.ts +37 -0
- package/dist/theme/extension/site-settings.js +144 -0
- package/dist/theme/extension/siteNav.d.ts +18 -0
- package/dist/theme/extension/siteNav.js +17 -0
- package/dist/theme/extension/theme-admin-locale.d.ts +11 -0
- package/dist/theme/extension/theme-admin-locale.io.d.ts +2 -0
- package/dist/theme/extension/theme-admin-locale.io.js +54 -0
- package/dist/theme/extension/theme-admin-locale.js +68 -0
- package/dist/theme/extension/theme.d.ts +89 -0
- package/dist/theme/extension/theme.js +93 -0
- package/dist/theme/extension/twentytwentyfive-vars.d.ts +9 -0
- package/dist/theme/extension/twentytwentyfive-vars.js +103 -0
- package/dist/theme/fetch.d.ts +134 -0
- package/dist/theme/fetch.js +241 -0
- package/dist/theme/format.d.ts +16 -0
- package/dist/theme/format.js +48 -0
- package/dist/theme/httpClient.d.ts +20 -0
- package/dist/theme/httpClient.js +89 -0
- package/dist/theme/index.d.ts +63 -0
- package/dist/theme/index.js +226 -0
- package/dist/theme/json.d.ts +1 -0
- package/dist/theme/json.js +17 -0
- package/dist/theme/jsonp.d.ts +8 -0
- package/dist/theme/jsonp.js +27 -0
- package/dist/theme/locale.d.ts +23 -0
- package/dist/theme/locale.js +55 -0
- package/dist/theme/nav.d.ts +10 -0
- package/dist/theme/nav.js +30 -0
- package/dist/theme/next-config.d.ts +2 -0
- package/dist/theme/next-config.js +18 -0
- package/dist/theme/node.d.ts +2 -0
- package/dist/theme/node.js +18 -0
- package/dist/theme/preview/preview-config.d.ts +13 -0
- package/dist/theme/preview/preview-config.js +65 -0
- package/dist/theme/preview/preview-draft.d.ts +19 -0
- package/dist/theme/preview/preview-draft.js +51 -0
- package/dist/theme/preview/preview-mods.d.ts +16 -0
- package/dist/theme/preview/preview-mods.js +78 -0
- package/dist/theme/preview-config.d.ts +13 -0
- package/dist/theme/preview-config.js +65 -0
- package/dist/theme/preview-draft.d.ts +19 -0
- package/dist/theme/preview-draft.js +51 -0
- package/dist/theme/preview-mods.d.ts +16 -0
- package/dist/theme/preview-mods.js +78 -0
- package/dist/theme/providers/index.d.ts +118 -0
- package/dist/theme/providers/index.js +251 -0
- package/dist/theme/providers/setup.d.ts +124 -0
- package/dist/theme/providers/setup.js +29 -0
- package/dist/theme/runtime.d.ts +18 -0
- package/dist/theme/runtime.js +19 -0
- package/dist/theme/seo.d.ts +6 -0
- package/dist/theme/seo.js +12 -0
- package/dist/theme/server.d.ts +65 -0
- package/dist/theme/server.js +177 -0
- package/dist/theme/setting.d.ts +12 -0
- package/dist/theme/setting.js +42 -0
- package/dist/theme/ssr/bootstrap.d.ts +48 -0
- package/dist/theme/ssr/bootstrap.js +112 -0
- package/dist/theme/ssr/fetch.d.ts +134 -0
- package/dist/theme/ssr/fetch.js +264 -0
- package/dist/theme/ssr/format.d.ts +3 -0
- package/dist/theme/ssr/format.js +8 -0
- package/dist/theme/ssr/pageProps.d.ts +62 -0
- package/dist/theme/ssr/pageProps.js +138 -0
- package/dist/theme/ssr/setting.d.ts +12 -0
- package/dist/theme/ssr/setting.js +42 -0
- package/dist/theme/ssr/slimBootstrap.d.ts +11 -0
- package/dist/theme/ssr/slimBootstrap.js +75 -0
- package/dist/theme/ssr/static.d.ts +10 -0
- package/dist/theme/ssr/static.js +17 -0
- package/dist/theme/ssr/templates.d.ts +35 -0
- package/dist/theme/ssr/templates.js +50 -0
- package/dist/theme/static.d.ts +10 -0
- package/dist/theme/static.js +17 -0
- package/dist/theme/templates.d.ts +27 -0
- package/dist/theme/templates.js +38 -0
- package/dist/theme/ui-optional.d.ts +1 -0
- package/dist/theme/ui-optional.js +21 -0
- package/dist/theme/visitor/appearance.d.ts +4 -0
- package/dist/theme/visitor/appearance.js +16 -0
- package/dist/theme/visitor/authSession.d.ts +16 -0
- package/dist/theme/visitor/authSession.js +92 -0
- package/dist/theme/visitor/colorMode.d.ts +17 -0
- package/dist/theme/visitor/colorMode.js +59 -0
- package/dist/theme/visitor/commentAuthor.d.ts +16 -0
- package/dist/theme/visitor/commentAuthor.js +45 -0
- package/dist/theme/visitor/i18n.d.ts +4 -0
- package/dist/theme/visitor/i18n.js +28 -0
- package/dist/theme/visitor/locale.d.ts +23 -0
- package/dist/theme/visitor/locale.js +72 -0
- package/dist/theme/visitor/runtime.d.ts +18 -0
- package/dist/theme/visitor/runtime.js +19 -0
- package/dist/theme/visitor/visitorLocale.d.ts +11 -0
- package/dist/theme/visitor/visitorLocale.js +56 -0
- package/dist/theme/visitorLocale.d.ts +6 -0
- package/dist/theme/visitorLocale.js +39 -0
- package/dist/types/index.d.ts +79 -68
- package/dist/ui/AntdStyleTransitionFix.d.ts +5 -0
- package/dist/ui/AntdStyleTransitionFix.js +16 -0
- package/dist/ui/ArchiveEmptyState.d.ts +13 -0
- package/dist/ui/ArchiveEmptyState.js +8 -0
- package/dist/ui/ArchivePageLayout.d.ts +10 -0
- package/dist/ui/ArchivePageLayout.js +8 -0
- package/dist/ui/ArticleCard.d.ts +27 -0
- package/dist/ui/ArticleCard.js +16 -0
- package/dist/ui/ArticleList.d.ts +14 -0
- package/dist/ui/ArticleList.js +16 -0
- package/dist/ui/BaseGlobalStyles.d.ts +5 -0
- package/dist/ui/BaseGlobalStyles.js +18 -0
- package/dist/ui/LocaleSwitcher.d.ts +7 -0
- package/dist/ui/LocaleSwitcher.js +15 -0
- package/dist/ui/NavMenu.d.ts +16 -0
- package/dist/ui/NavMenu.js +8 -0
- package/dist/ui/NotFoundPanel.d.ts +11 -0
- package/dist/ui/NotFoundPanel.js +8 -0
- package/dist/ui/PageHeader.d.ts +10 -0
- package/dist/ui/PageHeader.js +8 -0
- package/dist/ui/SiteBranding.d.ts +10 -0
- package/dist/ui/SiteBranding.js +14 -0
- package/dist/ui/SiteDocument.d.ts +20 -0
- package/dist/ui/SiteDocument.js +13 -0
- package/dist/ui/SiteDocumentFallback.d.ts +8 -0
- package/dist/ui/SiteDocumentFallback.js +9 -0
- package/dist/ui/SiteLogo.d.ts +6 -0
- package/dist/ui/SiteLogo.js +16 -0
- package/dist/ui/SiteTagline.d.ts +7 -0
- package/dist/ui/SiteTagline.js +15 -0
- package/dist/ui/TaxonomyList.d.ts +25 -0
- package/dist/ui/TaxonomyList.js +30 -0
- package/dist/ui/ThemeCssVars.d.ts +2 -0
- package/dist/ui/ThemeCssVars.js +85 -0
- package/dist/ui/ThemeLayout.d.ts +13 -0
- package/dist/ui/ThemeLayout.js +11 -0
- package/dist/ui/components/AntdStyleTransitionFix.d.ts +5 -0
- package/dist/ui/components/AntdStyleTransitionFix.js +16 -0
- package/dist/ui/components/ArchiveEmptyState.d.ts +13 -0
- package/dist/ui/components/ArchiveEmptyState.js +8 -0
- package/dist/ui/components/ArchivePageLayout.d.ts +10 -0
- package/dist/ui/components/ArchivePageLayout.js +8 -0
- package/dist/ui/components/ArticleCard.d.ts +27 -0
- package/dist/ui/components/ArticleCard.js +16 -0
- package/dist/ui/components/ArticleList.d.ts +14 -0
- package/dist/ui/components/ArticleList.js +16 -0
- package/dist/ui/components/BaseGlobalStyles.d.ts +6 -0
- package/dist/ui/components/BaseGlobalStyles.js +18 -0
- package/dist/ui/components/LocaleSwitcher.d.ts +10 -0
- package/dist/ui/components/LocaleSwitcher.js +11 -0
- package/dist/ui/components/NavMenu.d.ts +16 -0
- package/dist/ui/components/NavMenu.js +8 -0
- package/dist/ui/components/NotFoundPanel.d.ts +11 -0
- package/dist/ui/components/NotFoundPanel.js +8 -0
- package/dist/ui/components/PageHeader.d.ts +10 -0
- package/dist/ui/components/PageHeader.js +8 -0
- package/dist/ui/components/RouteProgress.d.ts +9 -0
- package/dist/ui/components/RouteProgress.js +40 -0
- package/dist/ui/components/SiteAnalytics.d.ts +5 -0
- package/dist/ui/components/SiteAnalytics.js +42 -0
- package/dist/ui/components/SiteBranding.d.ts +11 -0
- package/dist/ui/components/SiteBranding.js +14 -0
- package/dist/ui/components/SiteDocument.d.ts +20 -0
- package/dist/ui/components/SiteDocument.js +13 -0
- package/dist/ui/components/SiteDocumentFallback.d.ts +8 -0
- package/dist/ui/components/SiteDocumentFallback.js +9 -0
- package/dist/ui/components/SiteLogo.d.ts +9 -0
- package/dist/ui/components/SiteLogo.js +23 -0
- package/dist/ui/components/SiteSeo.d.ts +13 -0
- package/dist/ui/components/SiteSeo.js +19 -0
- package/dist/ui/components/SiteTagline.d.ts +8 -0
- package/dist/ui/components/SiteTagline.js +15 -0
- package/dist/ui/components/TaxonomyList.d.ts +25 -0
- package/dist/ui/components/TaxonomyList.js +30 -0
- package/dist/ui/components/ThemeCssVars.d.ts +3 -0
- package/dist/ui/components/ThemeCssVars.js +85 -0
- package/dist/ui/components/ThemeLayout.d.ts +13 -0
- package/dist/ui/components/ThemeLayout.js +11 -0
- package/dist/ui/components/content/ArticleReader.d.ts +45 -0
- package/dist/ui/components/content/ArticleReader.js +23 -0
- package/dist/ui/components/content/ArticleToc.d.ts +21 -0
- package/dist/ui/components/content/ArticleToc.js +75 -0
- package/dist/ui/components/content/HtmlContent.d.ts +16 -0
- package/dist/ui/components/content/HtmlContent.js +237 -0
- package/dist/ui/components/content/Image.d.ts +9 -0
- package/dist/ui/components/content/Image.js +13 -0
- package/dist/ui/components/content/ImageViewer.d.ts +8 -0
- package/dist/ui/components/content/ImageViewer.js +33 -0
- package/dist/ui/components/content/LocaleTime.d.ts +10 -0
- package/dist/ui/components/content/LocaleTime.js +63 -0
- package/dist/ui/components/content/index.d.ts +14 -0
- package/dist/ui/components/content/index.js +18 -0
- package/dist/ui/components/toolbar/LocaleToggleButton.d.ts +8 -0
- package/dist/ui/components/toolbar/LocaleToggleButton.js +18 -0
- package/dist/ui/components/toolbar/ThemeToggleButton.d.ts +7 -0
- package/dist/ui/components/toolbar/ThemeToggleButton.js +10 -0
- package/dist/ui/components/toolbar/ToolbarIconButton.d.ts +7 -0
- package/dist/ui/components/toolbar/ToolbarIconButton.js +22 -0
- package/dist/ui/components/toolbar/constants.d.ts +5 -0
- package/dist/ui/components/toolbar/constants.js +8 -0
- package/dist/ui/components/toolbar/icons.d.ts +17 -0
- package/dist/ui/components/toolbar/icons.js +44 -0
- package/dist/ui/components/toolbar/index.d.ts +9 -0
- package/dist/ui/components/toolbar/index.js +25 -0
- package/dist/ui/components/toolbar/locale-label.d.ts +3 -0
- package/dist/ui/components/toolbar/locale-label.js +19 -0
- package/dist/ui/context/LocaleContext.d.ts +15 -0
- package/dist/ui/context/LocaleContext.js +59 -0
- package/dist/ui/context/ReactPressProvider.d.ts +4 -0
- package/dist/ui/context/ReactPressProvider.js +10 -0
- package/dist/ui/context/SiteCatalogContext.d.ts +41 -0
- package/dist/ui/context/SiteCatalogContext.js +60 -0
- package/dist/ui/context/ThemeRuntimeContext.d.ts +21 -0
- package/dist/ui/context/ThemeRuntimeContext.js +59 -0
- package/dist/ui/context/index.d.ts +8 -0
- package/dist/ui/context/index.js +26 -0
- package/dist/ui/context/siteCatalogTypes.d.ts +64 -0
- package/dist/ui/context/siteCatalogTypes.js +20 -0
- package/dist/ui/context/types.d.ts +34 -0
- package/dist/ui/context/types.js +2 -0
- package/dist/ui/hooks/index.d.ts +12 -0
- package/dist/ui/hooks/index.js +29 -0
- package/dist/ui/hooks/useAsyncLoading.d.ts +4 -0
- package/dist/ui/hooks/useAsyncLoading.js +31 -0
- package/dist/ui/hooks/useForceUpdate.d.ts +2 -0
- package/dist/ui/hooks/useForceUpdate.js +11 -0
- package/dist/ui/hooks/useNavActive.d.ts +5 -0
- package/dist/ui/hooks/useNavActive.js +11 -0
- package/dist/ui/hooks/usePagination.d.ts +34 -0
- package/dist/ui/hooks/usePagination.js +55 -0
- package/dist/ui/hooks/useReportArticleView.d.ts +4 -0
- package/dist/ui/hooks/useReportArticleView.js +40 -0
- package/dist/ui/hooks/useReportPageView.d.ts +11 -0
- package/dist/ui/hooks/useReportPageView.js +28 -0
- package/dist/ui/hooks/useRouteParam.d.ts +5 -0
- package/dist/ui/hooks/useRouteParam.js +15 -0
- package/dist/ui/hooks/useToggle.d.ts +2 -0
- package/dist/ui/hooks/useToggle.js +17 -0
- package/dist/ui/hooks/useWarningOnExit.d.ts +5 -0
- package/dist/ui/hooks/useWarningOnExit.js +59 -0
- package/dist/ui/index.d.ts +43 -0
- package/dist/ui/index.js +87 -0
- package/dist/utils/api-envelope.d.ts +14 -0
- package/dist/utils/api-envelope.js +31 -0
- package/dist/utils/clipboard.d.ts +2 -0
- package/dist/utils/clipboard.js +24 -0
- package/dist/utils/cookie.d.ts +2 -0
- package/dist/utils/cookie.js +15 -0
- package/dist/utils/date.d.ts +4 -0
- package/dist/utils/date.js +45 -0
- package/dist/utils/email.d.ts +3 -0
- package/dist/utils/email.js +9 -0
- package/dist/utils/error.d.ts +7 -0
- package/dist/utils/error.js +26 -0
- package/dist/utils/image.d.ts +7 -0
- package/dist/utils/image.js +34 -0
- package/dist/utils/index.d.ts +15 -33
- package/dist/utils/index.js +37 -57
- package/dist/utils/json.d.ts +2 -0
- package/dist/utils/json.js +18 -0
- package/dist/utils/jsonp.d.ts +8 -0
- package/dist/utils/jsonp.js +27 -0
- package/dist/utils/object.d.ts +7 -0
- package/dist/utils/object.js +63 -0
- package/dist/utils/setting.d.ts +12 -0
- package/dist/utils/setting.js +13 -0
- package/dist/utils/string.d.ts +4 -0
- package/dist/utils/string.js +15 -0
- package/dist/utils/viewport.d.ts +3 -0
- package/dist/utils/viewport.js +14 -0
- package/package.json +141 -12
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createApiInstance } from '../../api/instance';
|
|
2
|
+
export declare class ApiError extends Error {
|
|
3
|
+
code: number;
|
|
4
|
+
constructor(code: number, message: string);
|
|
5
|
+
}
|
|
6
|
+
export interface ClientOptions {
|
|
7
|
+
baseURL?: string;
|
|
8
|
+
getAccessToken?: () => string | null | undefined;
|
|
9
|
+
onUnauthorized?: () => void;
|
|
10
|
+
}
|
|
11
|
+
export type ReactPressClient = ReturnType<typeof createApiInstance>;
|
|
12
|
+
/** Single factory for web / theme / plugins — wraps generated API modules. */
|
|
13
|
+
export declare function createClient(options?: ClientOptions): ReactPressClient;
|
|
14
|
+
export declare function getDefaultApiBaseUrl(): string;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiError = void 0;
|
|
4
|
+
exports.createClient = createClient;
|
|
5
|
+
exports.getDefaultApiBaseUrl = getDefaultApiBaseUrl;
|
|
6
|
+
const instance_1 = require("../../api/instance");
|
|
7
|
+
class ApiError extends Error {
|
|
8
|
+
constructor(code, message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = 'ApiError';
|
|
11
|
+
this.code = code;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.ApiError = ApiError;
|
|
15
|
+
function readApiMessage(value) {
|
|
16
|
+
if (typeof value === 'string') {
|
|
17
|
+
const trimmed = value.trim();
|
|
18
|
+
return trimmed ? trimmed : null;
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(value)) {
|
|
21
|
+
const parts = value
|
|
22
|
+
.map((item) => readApiMessage(item))
|
|
23
|
+
.filter((item) => Boolean(item));
|
|
24
|
+
return parts.length ? parts.join(', ') : null;
|
|
25
|
+
}
|
|
26
|
+
if (value && typeof value === 'object') {
|
|
27
|
+
const payload = value;
|
|
28
|
+
return readApiMessage(payload.message) ?? readApiMessage(payload.msg);
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
function rejectApiError(status, payload) {
|
|
33
|
+
if (typeof payload.code === 'number' && payload.code !== 0) {
|
|
34
|
+
return Promise.reject(new ApiError(payload.code, readApiMessage(payload.message) ?? 'Request failed'));
|
|
35
|
+
}
|
|
36
|
+
const message = readApiMessage(payload.msg) ?? readApiMessage(payload.message);
|
|
37
|
+
if (message) {
|
|
38
|
+
return Promise.reject(new ApiError(Number(payload.statusCode ?? status ?? 500), message));
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
function attachInterceptors(http, options) {
|
|
43
|
+
http.instance.interceptors.request.use((config) => {
|
|
44
|
+
const token = options.getAccessToken?.();
|
|
45
|
+
if (token && config.headers) {
|
|
46
|
+
config.headers.Authorization = `Bearer ${token}`;
|
|
47
|
+
}
|
|
48
|
+
return config;
|
|
49
|
+
});
|
|
50
|
+
http.instance.interceptors.response.use((response) => {
|
|
51
|
+
const body = response.data;
|
|
52
|
+
if (!body || typeof body !== 'object')
|
|
53
|
+
return response;
|
|
54
|
+
if (typeof body.code === 'number') {
|
|
55
|
+
if (body.code !== 0) {
|
|
56
|
+
throw new ApiError(body.code, readApiMessage(body.message) ?? 'Request failed');
|
|
57
|
+
}
|
|
58
|
+
response.data = body.data;
|
|
59
|
+
return response;
|
|
60
|
+
}
|
|
61
|
+
if (typeof body.success === 'boolean') {
|
|
62
|
+
if (!body.success) {
|
|
63
|
+
throw new ApiError(Number(body.statusCode ?? 500), readApiMessage(body.msg) ?? 'Request failed');
|
|
64
|
+
}
|
|
65
|
+
response.data = body.data;
|
|
66
|
+
return response;
|
|
67
|
+
}
|
|
68
|
+
return response;
|
|
69
|
+
}, (error) => {
|
|
70
|
+
const status = error?.response?.status;
|
|
71
|
+
if (status === 401) {
|
|
72
|
+
options.onUnauthorized?.();
|
|
73
|
+
}
|
|
74
|
+
const body = error?.response?.data;
|
|
75
|
+
if (body && typeof body === 'object') {
|
|
76
|
+
const rejected = rejectApiError(status, body);
|
|
77
|
+
if (rejected)
|
|
78
|
+
return rejected;
|
|
79
|
+
}
|
|
80
|
+
return Promise.reject(error);
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/** Single factory for web / theme / plugins — wraps generated API modules. */
|
|
84
|
+
function createClient(options = {}) {
|
|
85
|
+
const baseURL = options.baseURL ?? 'http://localhost:3002/api';
|
|
86
|
+
const client = (0, instance_1.createApiInstance)({ baseURL });
|
|
87
|
+
attachInterceptors(client.article.http, options);
|
|
88
|
+
return client;
|
|
89
|
+
}
|
|
90
|
+
function getDefaultApiBaseUrl() {
|
|
91
|
+
if (typeof process !== 'undefined' && process.env?.SERVER_API_URL) {
|
|
92
|
+
return process.env.SERVER_API_URL;
|
|
93
|
+
}
|
|
94
|
+
return 'http://localhost:3002/api';
|
|
95
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { ClientOptions, ReactPressClient } from './client';
|
|
2
|
+
export { ApiError, createClient, getDefaultApiBaseUrl } from './client';
|
|
3
|
+
export type { AppRuntime, DesktopApi } from './runtime';
|
|
4
|
+
export { getDesktopApi, getRuntime, resolveApiBaseUrl, } from './runtime';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveApiBaseUrl = exports.getRuntime = exports.getDesktopApi = exports.getDefaultApiBaseUrl = exports.createClient = exports.ApiError = void 0;
|
|
4
|
+
var client_1 = require("./client");
|
|
5
|
+
Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return client_1.ApiError; } });
|
|
6
|
+
Object.defineProperty(exports, "createClient", { enumerable: true, get: function () { return client_1.createClient; } });
|
|
7
|
+
Object.defineProperty(exports, "getDefaultApiBaseUrl", { enumerable: true, get: function () { return client_1.getDefaultApiBaseUrl; } });
|
|
8
|
+
var runtime_1 = require("./runtime");
|
|
9
|
+
Object.defineProperty(exports, "getDesktopApi", { enumerable: true, get: function () { return runtime_1.getDesktopApi; } });
|
|
10
|
+
Object.defineProperty(exports, "getRuntime", { enumerable: true, get: function () { return runtime_1.getRuntime; } });
|
|
11
|
+
Object.defineProperty(exports, "resolveApiBaseUrl", { enumerable: true, get: function () { return runtime_1.resolveApiBaseUrl; } });
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type AppRuntime = 'web' | 'electron';
|
|
2
|
+
export interface DesktopApi {
|
|
3
|
+
getApiBaseUrl: () => Promise<string>;
|
|
4
|
+
setApiBaseUrl: (url: string) => Promise<void>;
|
|
5
|
+
showSaveDialog: (opts: {
|
|
6
|
+
defaultPath?: string;
|
|
7
|
+
}) => Promise<string | undefined>;
|
|
8
|
+
openExternal: (url: string) => Promise<void>;
|
|
9
|
+
platform: NodeJS.Platform;
|
|
10
|
+
}
|
|
11
|
+
declare global {
|
|
12
|
+
interface Window {
|
|
13
|
+
reactpressDesktop?: DesktopApi;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export declare function getRuntime(): AppRuntime;
|
|
17
|
+
export declare function getDesktopApi(): DesktopApi | undefined;
|
|
18
|
+
export declare function resolveApiBaseUrl(fallback: string): Promise<string>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRuntime = getRuntime;
|
|
4
|
+
exports.getDesktopApi = getDesktopApi;
|
|
5
|
+
exports.resolveApiBaseUrl = resolveApiBaseUrl;
|
|
6
|
+
function getRuntime() {
|
|
7
|
+
if (typeof window !== 'undefined' && window.reactpressDesktop) {
|
|
8
|
+
return 'electron';
|
|
9
|
+
}
|
|
10
|
+
return 'web';
|
|
11
|
+
}
|
|
12
|
+
function getDesktopApi() {
|
|
13
|
+
if (typeof window === 'undefined')
|
|
14
|
+
return undefined;
|
|
15
|
+
return window.reactpressDesktop;
|
|
16
|
+
}
|
|
17
|
+
async function resolveApiBaseUrl(fallback) {
|
|
18
|
+
const desktop = getDesktopApi();
|
|
19
|
+
if (desktop) {
|
|
20
|
+
try {
|
|
21
|
+
const url = await desktop.getApiBaseUrl();
|
|
22
|
+
if (url)
|
|
23
|
+
return url;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// fall through
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return fallback;
|
|
30
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { DevPortRedirectOptions, DevPortRole } from './portRedirect';
|
|
2
|
+
export { isUnifiedNginxEntryEnabled } from './portRedirect';
|
|
3
|
+
export { buildDevPortRedirectUrl, isDirectDevPortAccess, isNginxDevRedirectEnabled, isThemePreviewDevPort, resolveDevPortRole, resolveNginxEntryUrl, shouldRedirectDevPortToNginx, THEME_PREVIEW_DEV_PORTS, } from './portRedirect';
|
|
4
|
+
export { devPortRedirectPlugin } from './vitePortRedirectPlugin';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.devPortRedirectPlugin = exports.THEME_PREVIEW_DEV_PORTS = exports.shouldRedirectDevPortToNginx = exports.resolveNginxEntryUrl = exports.resolveDevPortRole = exports.isThemePreviewDevPort = exports.isNginxDevRedirectEnabled = exports.isDirectDevPortAccess = exports.buildDevPortRedirectUrl = exports.isUnifiedNginxEntryEnabled = void 0;
|
|
4
|
+
var portRedirect_1 = require("./portRedirect");
|
|
5
|
+
Object.defineProperty(exports, "isUnifiedNginxEntryEnabled", { enumerable: true, get: function () { return portRedirect_1.isUnifiedNginxEntryEnabled; } });
|
|
6
|
+
var portRedirect_2 = require("./portRedirect");
|
|
7
|
+
Object.defineProperty(exports, "buildDevPortRedirectUrl", { enumerable: true, get: function () { return portRedirect_2.buildDevPortRedirectUrl; } });
|
|
8
|
+
Object.defineProperty(exports, "isDirectDevPortAccess", { enumerable: true, get: function () { return portRedirect_2.isDirectDevPortAccess; } });
|
|
9
|
+
Object.defineProperty(exports, "isNginxDevRedirectEnabled", { enumerable: true, get: function () { return portRedirect_2.isNginxDevRedirectEnabled; } });
|
|
10
|
+
Object.defineProperty(exports, "isThemePreviewDevPort", { enumerable: true, get: function () { return portRedirect_2.isThemePreviewDevPort; } });
|
|
11
|
+
Object.defineProperty(exports, "resolveDevPortRole", { enumerable: true, get: function () { return portRedirect_2.resolveDevPortRole; } });
|
|
12
|
+
Object.defineProperty(exports, "resolveNginxEntryUrl", { enumerable: true, get: function () { return portRedirect_2.resolveNginxEntryUrl; } });
|
|
13
|
+
Object.defineProperty(exports, "shouldRedirectDevPortToNginx", { enumerable: true, get: function () { return portRedirect_2.shouldRedirectDevPortToNginx; } });
|
|
14
|
+
Object.defineProperty(exports, "THEME_PREVIEW_DEV_PORTS", { enumerable: true, get: function () { return portRedirect_2.THEME_PREVIEW_DEV_PORTS; } });
|
|
15
|
+
var vitePortRedirectPlugin_1 = require("./vitePortRedirectPlugin");
|
|
16
|
+
Object.defineProperty(exports, "devPortRedirectPlugin", { enumerable: true, get: function () { return vitePortRedirectPlugin_1.devPortRedirectPlugin; } });
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Admin theme preview pool — must not redirect to nginx visitor (active theme). */
|
|
2
|
+
export declare const THEME_PREVIEW_DEV_PORTS: number[];
|
|
3
|
+
export type DevPortRole = 'visitor' | 'admin' | 'api' | 'preview';
|
|
4
|
+
export declare function isThemePreviewDevPort(port: number): boolean;
|
|
5
|
+
export declare function resolveDevPortRole(directPort: number): DevPortRole;
|
|
6
|
+
/** Unified nginx entry (:80) — dev (`REACTPRESS_NGINX_ENTRY_URL`) or prod (`NGINX_ENTRY_URL`). */
|
|
7
|
+
export declare function isUnifiedNginxEntryEnabled(): boolean;
|
|
8
|
+
/** @deprecated Use {@link isUnifiedNginxEntryEnabled} */
|
|
9
|
+
export declare function isNginxDevRedirectEnabled(): boolean;
|
|
10
|
+
export declare function resolveNginxEntryUrl(): string;
|
|
11
|
+
export declare function isDirectDevPortAccess(host: string | null | undefined, port: number): boolean;
|
|
12
|
+
export interface DevPortRedirectOptions {
|
|
13
|
+
host?: string | null;
|
|
14
|
+
method?: string;
|
|
15
|
+
accept?: string | null;
|
|
16
|
+
directPort: number;
|
|
17
|
+
pathname?: string;
|
|
18
|
+
skipPathPrefixes?: string[];
|
|
19
|
+
}
|
|
20
|
+
export declare function shouldRedirectDevPortToNginx(options: DevPortRedirectOptions): boolean;
|
|
21
|
+
export declare function buildDevPortRedirectUrl(options: {
|
|
22
|
+
directPort: number;
|
|
23
|
+
pathname?: string;
|
|
24
|
+
search?: string;
|
|
25
|
+
nginxEntryUrl?: string;
|
|
26
|
+
}): string;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.THEME_PREVIEW_DEV_PORTS = void 0;
|
|
4
|
+
exports.isThemePreviewDevPort = isThemePreviewDevPort;
|
|
5
|
+
exports.resolveDevPortRole = resolveDevPortRole;
|
|
6
|
+
exports.isUnifiedNginxEntryEnabled = isUnifiedNginxEntryEnabled;
|
|
7
|
+
exports.isNginxDevRedirectEnabled = isNginxDevRedirectEnabled;
|
|
8
|
+
exports.resolveNginxEntryUrl = resolveNginxEntryUrl;
|
|
9
|
+
exports.isDirectDevPortAccess = isDirectDevPortAccess;
|
|
10
|
+
exports.shouldRedirectDevPortToNginx = shouldRedirectDevPortToNginx;
|
|
11
|
+
exports.buildDevPortRedirectUrl = buildDevPortRedirectUrl;
|
|
12
|
+
const DEFAULT_NGINX_PORT = 80;
|
|
13
|
+
/** Admin theme preview pool — must not redirect to nginx visitor (active theme). */
|
|
14
|
+
exports.THEME_PREVIEW_DEV_PORTS = [3003, 3004, 3005, 3006, 3007, 3008];
|
|
15
|
+
function isThemePreviewDevPort(port) {
|
|
16
|
+
return Number.isInteger(port) && exports.THEME_PREVIEW_DEV_PORTS.includes(port);
|
|
17
|
+
}
|
|
18
|
+
function readPortEnv(key, fallback) {
|
|
19
|
+
const raw = process.env[key]?.trim();
|
|
20
|
+
if (!raw)
|
|
21
|
+
return fallback;
|
|
22
|
+
const parsed = parseInt(raw, 10);
|
|
23
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
24
|
+
}
|
|
25
|
+
function resolveDevPortRole(directPort) {
|
|
26
|
+
if (isThemePreviewDevPort(directPort))
|
|
27
|
+
return 'preview';
|
|
28
|
+
const apiPort = readPortEnv('SERVER_PORT', 3002);
|
|
29
|
+
const adminPort = readPortEnv('WEB_ADMIN_PORT', 3000);
|
|
30
|
+
if (directPort === apiPort)
|
|
31
|
+
return 'api';
|
|
32
|
+
if (directPort === adminPort)
|
|
33
|
+
return 'admin';
|
|
34
|
+
return 'visitor';
|
|
35
|
+
}
|
|
36
|
+
/** Unified nginx entry (:80) — dev (`REACTPRESS_NGINX_ENTRY_URL`) or prod (`NGINX_ENTRY_URL`). */
|
|
37
|
+
function isUnifiedNginxEntryEnabled() {
|
|
38
|
+
return Boolean(process.env.REACTPRESS_NGINX_ENTRY_URL?.trim() || process.env.NGINX_ENTRY_URL?.trim());
|
|
39
|
+
}
|
|
40
|
+
/** @deprecated Use {@link isUnifiedNginxEntryEnabled} */
|
|
41
|
+
function isNginxDevRedirectEnabled() {
|
|
42
|
+
return isUnifiedNginxEntryEnabled();
|
|
43
|
+
}
|
|
44
|
+
function resolveNginxEntryUrl() {
|
|
45
|
+
const override = process.env.REACTPRESS_NGINX_ENTRY_URL?.trim();
|
|
46
|
+
if (override) {
|
|
47
|
+
return override.replace(/\/$/, '');
|
|
48
|
+
}
|
|
49
|
+
const rawPort = process.env.NGINX_PORT?.trim();
|
|
50
|
+
const port = rawPort ? parseInt(rawPort, 10) : DEFAULT_NGINX_PORT;
|
|
51
|
+
if (Number.isFinite(port) && port > 0 && port !== DEFAULT_NGINX_PORT) {
|
|
52
|
+
return `http://localhost:${port}`;
|
|
53
|
+
}
|
|
54
|
+
return 'http://localhost';
|
|
55
|
+
}
|
|
56
|
+
function isDirectDevPortAccess(host, port) {
|
|
57
|
+
if (!host || !Number.isFinite(port) || port <= 0)
|
|
58
|
+
return false;
|
|
59
|
+
const normalized = host.toLowerCase();
|
|
60
|
+
return (normalized === `localhost:${port}` ||
|
|
61
|
+
normalized === `127.0.0.1:${port}` ||
|
|
62
|
+
normalized === `[::1]:${port}`);
|
|
63
|
+
}
|
|
64
|
+
function acceptsHtmlNavigation(accept) {
|
|
65
|
+
if (!accept)
|
|
66
|
+
return false;
|
|
67
|
+
return accept.includes('text/html');
|
|
68
|
+
}
|
|
69
|
+
function shouldRedirectDevPortToNginx(options) {
|
|
70
|
+
if (process.env.REACTPRESS_SKIP_DEV_PORT_REDIRECT === '1')
|
|
71
|
+
return false;
|
|
72
|
+
if (isThemePreviewDevPort(options.directPort))
|
|
73
|
+
return false;
|
|
74
|
+
if (!isUnifiedNginxEntryEnabled())
|
|
75
|
+
return false;
|
|
76
|
+
const method = (options.method || 'GET').toUpperCase();
|
|
77
|
+
if (method !== 'GET' && method !== 'HEAD')
|
|
78
|
+
return false;
|
|
79
|
+
if (!isDirectDevPortAccess(options.host, options.directPort))
|
|
80
|
+
return false;
|
|
81
|
+
if (!acceptsHtmlNavigation(options.accept))
|
|
82
|
+
return false;
|
|
83
|
+
const pathname = options.pathname || '/';
|
|
84
|
+
if (options.skipPathPrefixes?.some((prefix) => pathname.startsWith(prefix))) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
function buildDevPortRedirectUrl(options) {
|
|
90
|
+
const entry = (options.nginxEntryUrl || resolveNginxEntryUrl()).replace(/\/$/, '');
|
|
91
|
+
const pathname = options.pathname || '/';
|
|
92
|
+
const search = options.search || '';
|
|
93
|
+
const role = resolveDevPortRole(options.directPort);
|
|
94
|
+
if (role === 'api') {
|
|
95
|
+
if (pathname === '/' || pathname === '') {
|
|
96
|
+
return `${entry}/api${search}`;
|
|
97
|
+
}
|
|
98
|
+
return `${entry}${pathname}${search}`;
|
|
99
|
+
}
|
|
100
|
+
if (role === 'admin') {
|
|
101
|
+
let adminPath = pathname;
|
|
102
|
+
if (!adminPath.startsWith('/admin')) {
|
|
103
|
+
adminPath = adminPath === '/' ? '/admin/' : `/admin${adminPath.startsWith('/') ? adminPath : `/${adminPath}`}`;
|
|
104
|
+
}
|
|
105
|
+
return `${entry}${adminPath}${search}`;
|
|
106
|
+
}
|
|
107
|
+
if (role === 'preview') {
|
|
108
|
+
return `${entry}${pathname}${search}`;
|
|
109
|
+
}
|
|
110
|
+
return `${entry}${pathname}${search}`;
|
|
111
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
type DevServer = {
|
|
2
|
+
middlewares: {
|
|
3
|
+
use: (handler: (req: DevRequest, res: DevResponse, next: () => void) => void) => void;
|
|
4
|
+
};
|
|
5
|
+
};
|
|
6
|
+
type DevRequest = {
|
|
7
|
+
url?: string;
|
|
8
|
+
method?: string;
|
|
9
|
+
headers: {
|
|
10
|
+
host?: string;
|
|
11
|
+
accept?: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
type DevResponse = {
|
|
15
|
+
statusCode: number;
|
|
16
|
+
setHeader: (name: string, value: string) => void;
|
|
17
|
+
end: () => void;
|
|
18
|
+
};
|
|
19
|
+
/** Redirect direct :3000 browser hits to nginx entry when REACTPRESS_NGINX_ENTRY_URL is set. */
|
|
20
|
+
export declare function devPortRedirectPlugin(port: number): {
|
|
21
|
+
name: string;
|
|
22
|
+
configureServer(server: DevServer): void;
|
|
23
|
+
};
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.devPortRedirectPlugin = devPortRedirectPlugin;
|
|
4
|
+
const portRedirect_1 = require("./portRedirect");
|
|
5
|
+
const VITE_DEV_SKIP_PREFIXES = ['/@vite', '/@fs', '/@id', '/node_modules'];
|
|
6
|
+
function createRedirectMiddleware(port) {
|
|
7
|
+
return (req, res, next) => {
|
|
8
|
+
const url = req.url || '/';
|
|
9
|
+
const pathname = url.split('?')[0] || '/';
|
|
10
|
+
const search = url.includes('?') ? url.slice(url.indexOf('?')) : '';
|
|
11
|
+
if (!(0, portRedirect_1.shouldRedirectDevPortToNginx)({
|
|
12
|
+
host: req.headers.host,
|
|
13
|
+
method: req.method,
|
|
14
|
+
accept: req.headers.accept,
|
|
15
|
+
directPort: port,
|
|
16
|
+
pathname,
|
|
17
|
+
skipPathPrefixes: VITE_DEV_SKIP_PREFIXES,
|
|
18
|
+
})) {
|
|
19
|
+
next();
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const target = (0, portRedirect_1.buildDevPortRedirectUrl)({
|
|
23
|
+
directPort: port,
|
|
24
|
+
pathname,
|
|
25
|
+
search,
|
|
26
|
+
});
|
|
27
|
+
res.statusCode = 302;
|
|
28
|
+
res.setHeader('Location', target);
|
|
29
|
+
res.end();
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/** Redirect direct :3000 browser hits to nginx entry when REACTPRESS_NGINX_ENTRY_URL is set. */
|
|
33
|
+
function devPortRedirectPlugin(port) {
|
|
34
|
+
return {
|
|
35
|
+
name: 'reactpress-dev-port-redirect',
|
|
36
|
+
configureServer(server) {
|
|
37
|
+
server.middlewares.use(createRedirectMiddleware(port));
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./plugin"), exports);
|
|
18
|
+
__exportStar(require("./plugin-admin-locale"), exports);
|
|
19
|
+
__exportStar(require("./security"), exports);
|
|
20
|
+
__exportStar(require("./validate"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getNestedLocaleString, getNestedLocaleValue } from '../../utils/object';
|
|
2
|
+
/** Admin copy shipped with the plugin (`locales/{locale}.json`). */
|
|
3
|
+
export type PluginAdminLocaleMessages = Record<string, unknown>;
|
|
4
|
+
export declare const PLUGIN_LOCALE_DIR = "locales";
|
|
5
|
+
export { getNestedLocaleString, getNestedLocaleValue };
|
|
6
|
+
type PluginSchemaProperty = {
|
|
7
|
+
type?: string;
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
properties?: Record<string, PluginSchemaProperty>;
|
|
11
|
+
items?: PluginSchemaProperty | PluginSchemaProperty[];
|
|
12
|
+
};
|
|
13
|
+
export type PluginSettingsSchema = Record<string, unknown> & {
|
|
14
|
+
title?: string;
|
|
15
|
+
description?: string;
|
|
16
|
+
properties?: Record<string, PluginSchemaProperty>;
|
|
17
|
+
};
|
|
18
|
+
/** Resolve admin copy from plugin locale bundle; falls back to manifest text. */
|
|
19
|
+
export declare function resolvePluginAdminLocaleText(messages: PluginAdminLocaleMessages | null | undefined, dotPath: string, fallback?: string): string;
|
|
20
|
+
/** Apply plugin admin locale messages to settings JSON Schema titles/descriptions. */
|
|
21
|
+
export declare function localizePluginSettingsSchemaWithLocale(schema: PluginSettingsSchema | null | undefined, messages: PluginAdminLocaleMessages | null | undefined): PluginSettingsSchema | null;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.readPluginAdminLocaleFile = readPluginAdminLocaleFile;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const plugin_admin_locale_1 = require("./plugin-admin-locale");
|
|
40
|
+
function readPluginAdminLocaleFile(pluginDir, locale) {
|
|
41
|
+
const safeLocale = /^[a-z]{2}(?:-[a-z]{2})?$/i.test(locale) ? locale : 'en';
|
|
42
|
+
const filePath = path.join(pluginDir, plugin_admin_locale_1.PLUGIN_LOCALE_DIR, `${safeLocale}.json`);
|
|
43
|
+
if (!fs.existsSync(filePath))
|
|
44
|
+
return null;
|
|
45
|
+
try {
|
|
46
|
+
const raw = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
47
|
+
return raw && typeof raw === 'object' && !Array.isArray(raw)
|
|
48
|
+
? raw
|
|
49
|
+
: null;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNestedLocaleValue = exports.getNestedLocaleString = exports.PLUGIN_LOCALE_DIR = void 0;
|
|
4
|
+
exports.resolvePluginAdminLocaleText = resolvePluginAdminLocaleText;
|
|
5
|
+
exports.localizePluginSettingsSchemaWithLocale = localizePluginSettingsSchemaWithLocale;
|
|
6
|
+
const object_1 = require("../../utils/object");
|
|
7
|
+
Object.defineProperty(exports, "getNestedLocaleString", { enumerable: true, get: function () { return object_1.getNestedLocaleString; } });
|
|
8
|
+
Object.defineProperty(exports, "getNestedLocaleValue", { enumerable: true, get: function () { return object_1.getNestedLocaleValue; } });
|
|
9
|
+
exports.PLUGIN_LOCALE_DIR = 'locales';
|
|
10
|
+
/** Resolve admin copy from plugin locale bundle; falls back to manifest text. */
|
|
11
|
+
function resolvePluginAdminLocaleText(messages, dotPath, fallback) {
|
|
12
|
+
const fromLocale = messages ? (0, object_1.getNestedLocaleString)(messages, dotPath) : undefined;
|
|
13
|
+
if (fromLocale)
|
|
14
|
+
return fromLocale;
|
|
15
|
+
return fallback?.trim() ?? '';
|
|
16
|
+
}
|
|
17
|
+
function localizeSchemaField(field, pathParts, resolve) {
|
|
18
|
+
if (typeof field.title === 'string') {
|
|
19
|
+
field.title = resolve([...pathParts, 'title'].join('.'), field.title);
|
|
20
|
+
}
|
|
21
|
+
if (typeof field.description === 'string') {
|
|
22
|
+
field.description = resolve([...pathParts, 'description'].join('.'), field.description);
|
|
23
|
+
}
|
|
24
|
+
if (field.properties) {
|
|
25
|
+
for (const [key, child] of Object.entries(field.properties)) {
|
|
26
|
+
localizeSchemaField(child, [...pathParts, key], resolve);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
const items = field.items;
|
|
30
|
+
if (items && typeof items === 'object' && !Array.isArray(items)) {
|
|
31
|
+
const itemSchema = items;
|
|
32
|
+
if (itemSchema.properties) {
|
|
33
|
+
for (const [key, child] of Object.entries(itemSchema.properties)) {
|
|
34
|
+
localizeSchemaField(child, [...pathParts, 'items', key], resolve);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
localizeSchemaField(itemSchema, [...pathParts, 'items'], resolve);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Apply plugin admin locale messages to settings JSON Schema titles/descriptions. */
|
|
43
|
+
function localizePluginSettingsSchemaWithLocale(schema, messages) {
|
|
44
|
+
if (!schema)
|
|
45
|
+
return null;
|
|
46
|
+
const out = structuredClone(schema);
|
|
47
|
+
const resolve = (dotPath, fallback) => resolvePluginAdminLocaleText(messages, `settings.${dotPath}`, fallback);
|
|
48
|
+
if (typeof out.title === 'string') {
|
|
49
|
+
out.title = resolve('title', out.title);
|
|
50
|
+
}
|
|
51
|
+
if (typeof out.description === 'string') {
|
|
52
|
+
out.description = resolve('description', out.description);
|
|
53
|
+
}
|
|
54
|
+
if (out.properties) {
|
|
55
|
+
for (const [key, field] of Object.entries(out.properties)) {
|
|
56
|
+
localizeSchemaField(field, [key], resolve);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/** WordPress-style plugin manifest and site plugin state (shared by server / web). */
|
|
2
|
+
import type { AdminSlotId } from '../admin/slots';
|
|
3
|
+
export interface PluginServerManifest {
|
|
4
|
+
module: string;
|
|
5
|
+
hooks?: {
|
|
6
|
+
subscribe?: string[];
|
|
7
|
+
provide?: string[];
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export interface PluginAdminMenuManifest {
|
|
11
|
+
parent?: string;
|
|
12
|
+
title: string;
|
|
13
|
+
path: string;
|
|
14
|
+
permission?: string;
|
|
15
|
+
sort?: number;
|
|
16
|
+
}
|
|
17
|
+
/** Declarative admin UI — mirrors `server.hooks.subscribe` for Admin slots. */
|
|
18
|
+
export interface PluginAdminSlotsManifest {
|
|
19
|
+
/** Built-in slot ids this plugin mounts UI into (see `AdminSlotIds`). */
|
|
20
|
+
subscribe?: AdminSlotId[];
|
|
21
|
+
}
|
|
22
|
+
export interface PluginAdminManifest {
|
|
23
|
+
/** @deprecated Use convention `admin/index.ts`; declared slots drive loading. */
|
|
24
|
+
entry?: string;
|
|
25
|
+
slots?: PluginAdminSlotsManifest;
|
|
26
|
+
menu?: PluginAdminMenuManifest;
|
|
27
|
+
}
|
|
28
|
+
export interface PluginSettingsManifest {
|
|
29
|
+
schema?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
export interface PluginCapabilities {
|
|
32
|
+
headless?: boolean;
|
|
33
|
+
network?: boolean;
|
|
34
|
+
filesystem?: boolean;
|
|
35
|
+
database?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface PluginManifest {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
version: string;
|
|
41
|
+
description?: string;
|
|
42
|
+
author?: string;
|
|
43
|
+
requires?: string;
|
|
44
|
+
requiresPlugins?: string[];
|
|
45
|
+
server?: PluginServerManifest;
|
|
46
|
+
admin?: PluginAdminManifest;
|
|
47
|
+
settings?: PluginSettingsManifest;
|
|
48
|
+
permissions?: string[];
|
|
49
|
+
capabilities?: PluginCapabilities;
|
|
50
|
+
}
|
|
51
|
+
export interface PluginEntryMeta {
|
|
52
|
+
version: string;
|
|
53
|
+
source: 'local' | 'npm';
|
|
54
|
+
config?: Record<string, unknown>;
|
|
55
|
+
activatedAt?: string;
|
|
56
|
+
npm?: {
|
|
57
|
+
spec: string;
|
|
58
|
+
resolvedVersion?: string;
|
|
59
|
+
packageName?: string;
|
|
60
|
+
installedAt?: string;
|
|
61
|
+
};
|
|
62
|
+
loadError?: string;
|
|
63
|
+
}
|
|
64
|
+
export interface SitePluginState {
|
|
65
|
+
installedPlugins: string[];
|
|
66
|
+
activePlugins: string[];
|
|
67
|
+
entries: Record<string, PluginEntryMeta>;
|
|
68
|
+
}
|
|
69
|
+
export declare const defaultSitePluginState: SitePluginState;
|
|
70
|
+
export interface GlobalSettingWithPlugins {
|
|
71
|
+
theme?: unknown;
|
|
72
|
+
plugins?: SitePluginState;
|
|
73
|
+
[key: string]: unknown;
|
|
74
|
+
}
|
|
75
|
+
export declare function isValidPluginId(id: string): boolean;
|
|
76
|
+
export declare function parsePluginManifest(raw: unknown): PluginManifest | null;
|
|
77
|
+
export declare function getPluginStateFromGlobalSetting(raw: unknown): SitePluginState;
|
|
78
|
+
export declare function mergePluginStateIntoGlobalSetting(raw: unknown, patch: Partial<SitePluginState>): GlobalSettingWithPlugins;
|
|
79
|
+
/** Conventional admin module path relative to plugin package root. */
|
|
80
|
+
export declare const PLUGIN_ADMIN_MODULE_CONVENTION = "admin/index";
|
|
81
|
+
/** Whether manifest declares admin UI (slot and/or settings menu). */
|
|
82
|
+
export declare function pluginManifestHasAdminUI(admin: PluginAdminManifest | undefined): boolean;
|