@fecommunity/reactpress-toolkit 3.0.4 → 3.1.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/README.md +194 -309
- 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 +88 -0
- package/dist/app/createReactPressApp.js +262 -0
- package/dist/app/createThemeApp.d.ts +6 -0
- package/dist/app/createThemeApp.js +47 -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/registry.d.ts +62 -0
- package/dist/plugin/admin/registry.js +79 -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/index.d.ts +9 -0
- package/dist/plugin/index.js +48 -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/runtime.d.ts +18 -0
- package/dist/plugin/react/runtime.js +30 -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 +17 -0
- package/dist/theme/build/next-config.js +100 -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 +5 -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 +10 -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 +8 -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 +7 -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 +2 -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 +15 -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 +9 -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 +3 -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 +129 -16
- package/LICENSE +0 -21
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.THEME_ISR_REVALIDATE_SECONDS = void 0;
|
|
4
|
+
exports.withApiRetry = withApiRetry;
|
|
5
|
+
exports.fetchThemeCatalog = fetchThemeCatalog;
|
|
6
|
+
exports.sanitizeNextProps = sanitizeNextProps;
|
|
7
|
+
exports.themeStaticProps = themeStaticProps;
|
|
8
|
+
exports.resolveStaticVisitorContext = resolveStaticVisitorContext;
|
|
9
|
+
exports.fetchCategoryIndex = fetchCategoryIndex;
|
|
10
|
+
exports.fetchTagIndex = fetchTagIndex;
|
|
11
|
+
exports.fetchSiteSettings = fetchSiteSettings;
|
|
12
|
+
exports.createDefaultVisitorContext = createDefaultVisitorContext;
|
|
13
|
+
exports.fetchVisitorContext = fetchVisitorContext;
|
|
14
|
+
exports.fetchSiteMeta = fetchSiteMeta;
|
|
15
|
+
exports.fetchCategoryArchive = fetchCategoryArchive;
|
|
16
|
+
exports.fetchTagArchive = fetchTagArchive;
|
|
17
|
+
exports.fetchSingleArticle = fetchSingleArticle;
|
|
18
|
+
exports.fetchSearchArticles = fetchSearchArticles;
|
|
19
|
+
exports.withThemeStaticProps = withThemeStaticProps;
|
|
20
|
+
exports.createArchiveGetStaticProps = createArchiveGetStaticProps;
|
|
21
|
+
exports.fetchArticlePageProps = fetchArticlePageProps;
|
|
22
|
+
const api_1 = require("./api");
|
|
23
|
+
const api_data_1 = require("./api-data");
|
|
24
|
+
const format_1 = require("./format");
|
|
25
|
+
const json_1 = require("./json");
|
|
26
|
+
const locale_1 = require("./locale");
|
|
27
|
+
const runtime_1 = require("./runtime");
|
|
28
|
+
const setting_1 = require("./setting");
|
|
29
|
+
const static_1 = require("./static");
|
|
30
|
+
/** Default ISR interval for theme list/home pages. */
|
|
31
|
+
exports.THEME_ISR_REVALIDATE_SECONDS = 60;
|
|
32
|
+
function isConnectionRefused(error) {
|
|
33
|
+
const err = error;
|
|
34
|
+
return err?.code === 'ECONNREFUSED' || err?.cause?.code === 'ECONNREFUSED';
|
|
35
|
+
}
|
|
36
|
+
/** Retry SSR API calls while the dev server is still starting (ECONNREFUSED). */
|
|
37
|
+
async function withApiRetry(fn, attempts = 8, delayMs = 400) {
|
|
38
|
+
let lastError;
|
|
39
|
+
for (let i = 0; i < attempts; i += 1) {
|
|
40
|
+
try {
|
|
41
|
+
return await fn();
|
|
42
|
+
}
|
|
43
|
+
catch (error) {
|
|
44
|
+
lastError = error;
|
|
45
|
+
if (!isConnectionRefused(error) || i >= attempts - 1) {
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
await new Promise((resolve) => {
|
|
49
|
+
setTimeout(resolve, delayMs);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
throw lastError;
|
|
54
|
+
}
|
|
55
|
+
/** Articles, categories, and tags for home / toolkit demo pages. */
|
|
56
|
+
async function fetchThemeCatalog(api) {
|
|
57
|
+
return withApiRetry(async () => {
|
|
58
|
+
const [articlesResponse, categoriesResponse, tagsResponse] = await Promise.all([
|
|
59
|
+
api.article.findAll(),
|
|
60
|
+
api.category.findAll(),
|
|
61
|
+
api.tag.findAll(),
|
|
62
|
+
]);
|
|
63
|
+
return {
|
|
64
|
+
articles: (0, api_data_1.unpackPaginated)(articlesResponse),
|
|
65
|
+
categories: (0, api_data_1.unpackList)(categoriesResponse),
|
|
66
|
+
tags: (0, api_data_1.unpackList)(tagsResponse),
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/** Strip `undefined` values so Next.js can serialize `getStaticProps` results. */
|
|
71
|
+
function sanitizeNextProps(props) {
|
|
72
|
+
return JSON.parse(JSON.stringify(props));
|
|
73
|
+
}
|
|
74
|
+
function themeStaticProps(props, revalidate = exports.THEME_ISR_REVALIDATE_SECONDS) {
|
|
75
|
+
return { props: sanitizeNextProps(props), revalidate };
|
|
76
|
+
}
|
|
77
|
+
let staticVisitorContextPromise = null;
|
|
78
|
+
let staticVisitorContextKey = '';
|
|
79
|
+
/** Visitor context for `getStaticProps` — `_app.getInitialProps` does not run on SSR for static pages. */
|
|
80
|
+
async function resolveStaticVisitorContext() {
|
|
81
|
+
const themeId = process.env.REACTPRESS_THEME_ID?.trim() || 'starter-theme';
|
|
82
|
+
const honorPreview = process.env.REACTPRESS_HONOR_PREVIEW === '1';
|
|
83
|
+
const cacheKey = `${themeId}:${honorPreview ? '1' : '0'}`;
|
|
84
|
+
if (staticVisitorContextPromise && staticVisitorContextKey === cacheKey) {
|
|
85
|
+
return staticVisitorContextPromise;
|
|
86
|
+
}
|
|
87
|
+
staticVisitorContextKey = cacheKey;
|
|
88
|
+
staticVisitorContextPromise = (async () => {
|
|
89
|
+
try {
|
|
90
|
+
return await fetchVisitorContext(api_1.themeApi, { themeId, honorPreview });
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
const code = error?.code
|
|
94
|
+
?? error?.cause?.code;
|
|
95
|
+
if (code !== 'ECONNREFUSED') {
|
|
96
|
+
console.error('[reactpress] resolveStaticVisitorContext failed', error);
|
|
97
|
+
}
|
|
98
|
+
return createDefaultVisitorContext(themeId);
|
|
99
|
+
}
|
|
100
|
+
})();
|
|
101
|
+
return staticVisitorContextPromise;
|
|
102
|
+
}
|
|
103
|
+
/** All categories — `getStaticProps` for `pages/category/index.tsx`. */
|
|
104
|
+
async function fetchCategoryIndex(api) {
|
|
105
|
+
return { categories: (0, api_data_1.unpackList)(await api.category.findAll()) };
|
|
106
|
+
}
|
|
107
|
+
/** All tags — `getStaticProps` for `pages/tag/index.tsx`. */
|
|
108
|
+
async function fetchTagIndex(api) {
|
|
109
|
+
return { tags: (0, api_data_1.unpackList)(await api.tag.findAll()) };
|
|
110
|
+
}
|
|
111
|
+
/** Site settings for about/footer pages (`getStaticProps`). */
|
|
112
|
+
async function fetchSiteSettings(api, schema) {
|
|
113
|
+
const rows = (0, api_data_1.unpackList)(await api.setting.findAll());
|
|
114
|
+
return (0, format_1.pickSiteSettings)(rows, schema);
|
|
115
|
+
}
|
|
116
|
+
/** Safe defaults when API is unreachable (still wraps pages in Provider). */
|
|
117
|
+
function createDefaultVisitorContext(themeId, partial = {}) {
|
|
118
|
+
return {
|
|
119
|
+
locale: 'zh',
|
|
120
|
+
locales: ['zh', 'en'],
|
|
121
|
+
messages: {},
|
|
122
|
+
catalog: {},
|
|
123
|
+
themeId,
|
|
124
|
+
activeThemeId: themeId,
|
|
125
|
+
mods: {},
|
|
126
|
+
isPreview: false,
|
|
127
|
+
siteMeta: setting_1.DEFAULT_SITE_META,
|
|
128
|
+
...partial,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
async function fetchVisitorContext(api, options) {
|
|
132
|
+
if (!api?.setting?.findAll) {
|
|
133
|
+
throw new Error('fetchVisitorContext: invalid ThemeApi instance');
|
|
134
|
+
}
|
|
135
|
+
return withApiRetry(async () => {
|
|
136
|
+
const row = (0, setting_1.unwrapSetting)(await api.setting.findAll());
|
|
137
|
+
const localeState = (0, locale_1.parseSiteLocale)(row?.i18n, {
|
|
138
|
+
locale: options.locale,
|
|
139
|
+
fallbackLocale: options.fallbackLocale,
|
|
140
|
+
preferredLocale: options.preferredLocale,
|
|
141
|
+
acceptLanguage: options.acceptLanguage,
|
|
142
|
+
});
|
|
143
|
+
const globalSetting = (0, json_1.safeJsonParse)(row?.globalSetting, {});
|
|
144
|
+
const runtime = (0, runtime_1.resolveThemeRuntime)(globalSetting, {
|
|
145
|
+
themeId: options.themeId,
|
|
146
|
+
honorPreview: options.honorPreview,
|
|
147
|
+
});
|
|
148
|
+
const siteMeta = (0, setting_1.parseSiteMeta)(row);
|
|
149
|
+
return {
|
|
150
|
+
locale: localeState.locale,
|
|
151
|
+
locales: localeState.locales,
|
|
152
|
+
messages: localeState.messages,
|
|
153
|
+
catalog: localeState.catalog,
|
|
154
|
+
themeId: runtime.themeId,
|
|
155
|
+
activeThemeId: runtime.activeThemeId,
|
|
156
|
+
mods: runtime.mods,
|
|
157
|
+
isPreview: runtime.isPreview,
|
|
158
|
+
siteMeta,
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/** Common site meta from the Setting row (`systemTitle`, `systemSubTitle`, …). */
|
|
163
|
+
async function fetchSiteMeta(api) {
|
|
164
|
+
return withApiRetry(async () => {
|
|
165
|
+
const row = (0, setting_1.unwrapSetting)(await api.setting.findAll());
|
|
166
|
+
return (0, setting_1.parseSiteMeta)(row);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
/** Category archive — `getStaticProps` for `pages/category/[category].tsx`. */
|
|
170
|
+
async function fetchCategoryArchive(api, category) {
|
|
171
|
+
const [articlesResponse, categoriesResponse] = await Promise.all([
|
|
172
|
+
api.article.findArticlesByCategory(category),
|
|
173
|
+
api.category.findAll(),
|
|
174
|
+
]);
|
|
175
|
+
return {
|
|
176
|
+
category,
|
|
177
|
+
articles: (0, api_data_1.unpackPaginated)(articlesResponse),
|
|
178
|
+
categories: (0, api_data_1.unpackList)(categoriesResponse),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/** Tag archive — `getStaticProps` for `pages/tag/[tag].tsx`. */
|
|
182
|
+
async function fetchTagArchive(api, tag) {
|
|
183
|
+
const [articlesResponse, tagsResponse] = await Promise.all([
|
|
184
|
+
api.article.findArticlesByTag(tag),
|
|
185
|
+
api.tag.findAll(),
|
|
186
|
+
]);
|
|
187
|
+
return {
|
|
188
|
+
tag,
|
|
189
|
+
articles: (0, api_data_1.unpackPaginated)(articlesResponse),
|
|
190
|
+
tags: (0, api_data_1.unpackList)(tagsResponse),
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
/** Single article — `getStaticProps` for `pages/article/[id].tsx`. */
|
|
194
|
+
async function fetchSingleArticle(api, id) {
|
|
195
|
+
const articleResponse = await api.article.findById(id);
|
|
196
|
+
return { article: (0, api_data_1.unpackOne)(articleResponse) };
|
|
197
|
+
}
|
|
198
|
+
/** Site search — `getServerSideProps` / `getStaticProps` helper. */
|
|
199
|
+
async function fetchSearchArticles(api, keyword) {
|
|
200
|
+
if (!keyword.trim()) {
|
|
201
|
+
return { query: '', articles: [] };
|
|
202
|
+
}
|
|
203
|
+
const searchResponse = await api.search.searchArticle({
|
|
204
|
+
query: { keyword: keyword.trim() },
|
|
205
|
+
});
|
|
206
|
+
return {
|
|
207
|
+
query: keyword.trim(),
|
|
208
|
+
articles: (0, api_data_1.unpackList)(searchResponse),
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Wrap `getStaticProps` fetchers with consistent logging and ISR fallback props.
|
|
213
|
+
*/
|
|
214
|
+
async function withThemeStaticProps(label, fetchFn, fallback) {
|
|
215
|
+
const reactPress = await resolveStaticVisitorContext();
|
|
216
|
+
try {
|
|
217
|
+
const data = await withApiRetry(fetchFn);
|
|
218
|
+
return themeStaticProps({ ...data, reactPress });
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
console.error(`[reactpress] ${label}`, error);
|
|
222
|
+
const props = typeof fallback === 'function' ? fallback(error) : fallback;
|
|
223
|
+
return themeStaticProps({ ...props, reactPress });
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
/** Factory for category/tag archive pages — removes duplicated `getStaticProps` boilerplate. */
|
|
227
|
+
function createArchiveGetStaticProps(kind, fetchArchive, emptyFallback) {
|
|
228
|
+
return async (ctx) => {
|
|
229
|
+
const slug = ctx.params?.[kind];
|
|
230
|
+
if (typeof slug !== 'string' || !slug)
|
|
231
|
+
return (0, static_1.themeNotFound)();
|
|
232
|
+
return withThemeStaticProps(`fetch ${kind} archive failed`, () => fetchArchive(api_1.themeApi, slug), () => emptyFallback(slug));
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/** Standard on-demand article page props. */
|
|
236
|
+
async function fetchArticlePageProps(api, id) {
|
|
237
|
+
if (!id)
|
|
238
|
+
return { article: null };
|
|
239
|
+
const data = await fetchSingleArticle(api, id);
|
|
240
|
+
return { article: data.article ?? null };
|
|
241
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Format article `publishAt` for theme templates (SSR-safe). */
|
|
2
|
+
export declare function formatPublishDate(value: string | Date | null | undefined, options?: Intl.DateTimeFormatOptions, locale?: string): string;
|
|
3
|
+
/** Short numeric date (`YYYY-MM-DD`) via toolkit utils. */
|
|
4
|
+
export declare function formatPublishDateShort(value: string | Date | null | undefined): string;
|
|
5
|
+
export type SettingRow = {
|
|
6
|
+
key: string;
|
|
7
|
+
value?: unknown;
|
|
8
|
+
[field: string]: unknown;
|
|
9
|
+
};
|
|
10
|
+
/** Map global settings rows to a props object by key. */
|
|
11
|
+
export declare function pickSiteSettings<T extends Record<string, {
|
|
12
|
+
key: string;
|
|
13
|
+
default: string;
|
|
14
|
+
}>>(settings: SettingRow[], schema: T): {
|
|
15
|
+
[K in keyof T]: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.formatPublishDate = formatPublishDate;
|
|
4
|
+
exports.formatPublishDateShort = formatPublishDateShort;
|
|
5
|
+
exports.pickSiteSettings = pickSiteSettings;
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
/** Format article `publishAt` for theme templates (SSR-safe). */
|
|
8
|
+
function formatPublishDate(value, options = {
|
|
9
|
+
year: 'numeric',
|
|
10
|
+
month: 'long',
|
|
11
|
+
day: 'numeric',
|
|
12
|
+
}, locale = 'en-US') {
|
|
13
|
+
if (value == null || value === '')
|
|
14
|
+
return '';
|
|
15
|
+
try {
|
|
16
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
17
|
+
if (Number.isNaN(date.getTime()))
|
|
18
|
+
return '';
|
|
19
|
+
return date.toLocaleDateString(locale, options);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return '';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/** Short numeric date (`YYYY-MM-DD`) via toolkit utils. */
|
|
26
|
+
function formatPublishDateShort(value) {
|
|
27
|
+
if (value == null || value === '')
|
|
28
|
+
return '';
|
|
29
|
+
try {
|
|
30
|
+
const date = value instanceof Date ? value : new Date(value);
|
|
31
|
+
if (Number.isNaN(date.getTime()))
|
|
32
|
+
return '';
|
|
33
|
+
return (0, utils_1.formatDate)(date, 'YYYY-MM-DD');
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return '';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** Map global settings rows to a props object by key. */
|
|
40
|
+
function pickSiteSettings(settings, schema) {
|
|
41
|
+
const out = {};
|
|
42
|
+
for (const prop of Object.keys(schema)) {
|
|
43
|
+
const { key, default: fallback } = schema[prop];
|
|
44
|
+
const row = settings.find((s) => s.key === key);
|
|
45
|
+
out[prop] = row?.value != null ? String(row.value) : fallback;
|
|
46
|
+
}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type AxiosInstance } from 'axios';
|
|
2
|
+
export interface ThemeApiEnvelope<T = unknown> {
|
|
3
|
+
statusCode: number;
|
|
4
|
+
success: boolean;
|
|
5
|
+
msg: string | null;
|
|
6
|
+
data: T;
|
|
7
|
+
}
|
|
8
|
+
export interface CreateThemeAxiosClientOptions {
|
|
9
|
+
baseURL?: string;
|
|
10
|
+
timeout?: number;
|
|
11
|
+
getAccessToken?: () => string | null;
|
|
12
|
+
onError?: (message: string, status?: number) => void;
|
|
13
|
+
onUnauthorized?: () => void;
|
|
14
|
+
unwrapEnvelope?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Legacy theme env vars plus toolkit defaults. */
|
|
17
|
+
export declare function resolveThemeAxiosBaseUrl(): string;
|
|
18
|
+
/** Encode dynamic path segments (e.g. Chinese tag names) for Node fetch / axios. */
|
|
19
|
+
export declare function encodeAxiosUrlPath(url: string): string;
|
|
20
|
+
export declare function createThemeAxiosClient(options?: CreateThemeAxiosClientOptions): AxiosInstance;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.resolveThemeAxiosBaseUrl = resolveThemeAxiosBaseUrl;
|
|
7
|
+
exports.encodeAxiosUrlPath = encodeAxiosUrlPath;
|
|
8
|
+
exports.createThemeAxiosClient = createThemeAxiosClient;
|
|
9
|
+
const axios_1 = __importDefault(require("axios"));
|
|
10
|
+
const authSession_1 = require("./authSession");
|
|
11
|
+
const api_1 = require("./api");
|
|
12
|
+
/** Legacy theme env vars plus toolkit defaults. */
|
|
13
|
+
function resolveThemeAxiosBaseUrl() {
|
|
14
|
+
if (process.env.SERVER_API_URL) {
|
|
15
|
+
return process.env.SERVER_API_URL;
|
|
16
|
+
}
|
|
17
|
+
if (process.env.SERVER_SITE_URL) {
|
|
18
|
+
return `${process.env.SERVER_SITE_URL}/api`;
|
|
19
|
+
}
|
|
20
|
+
return (0, api_1.resolveThemeApiBaseUrl)();
|
|
21
|
+
}
|
|
22
|
+
/** Encode dynamic path segments (e.g. Chinese tag names) for Node fetch / axios. */
|
|
23
|
+
function encodeAxiosUrlPath(url) {
|
|
24
|
+
const qIndex = url.indexOf('?');
|
|
25
|
+
const pathname = qIndex === -1 ? url : url.slice(0, qIndex);
|
|
26
|
+
const search = qIndex === -1 ? '' : url.slice(qIndex);
|
|
27
|
+
const encodedPath = pathname
|
|
28
|
+
.split('/')
|
|
29
|
+
.map((segment) => {
|
|
30
|
+
if (!segment)
|
|
31
|
+
return segment;
|
|
32
|
+
try {
|
|
33
|
+
return encodeURIComponent(decodeURIComponent(segment));
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return encodeURIComponent(segment);
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
.join('/');
|
|
40
|
+
return encodedPath + search;
|
|
41
|
+
}
|
|
42
|
+
function createThemeAxiosClient(options = {}) {
|
|
43
|
+
const isBrowser = typeof window !== 'undefined';
|
|
44
|
+
const { baseURL = resolveThemeAxiosBaseUrl(), timeout = 60000, getAccessToken = authSession_1.getStoredAccessToken, onError, onUnauthorized, unwrapEnvelope = true, } = options;
|
|
45
|
+
const client = axios_1.default.create({ baseURL, timeout });
|
|
46
|
+
client.interceptors.request.use((config) => {
|
|
47
|
+
if (config.url) {
|
|
48
|
+
config.url = encodeAxiosUrlPath(config.url);
|
|
49
|
+
}
|
|
50
|
+
if (isBrowser) {
|
|
51
|
+
const token = getAccessToken();
|
|
52
|
+
if (config.headers && token) {
|
|
53
|
+
config.headers.Authorization = `Bearer ${token}`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return config;
|
|
57
|
+
}, () => {
|
|
58
|
+
throw new Error('Failed to send request');
|
|
59
|
+
});
|
|
60
|
+
client.interceptors.response.use((response) => {
|
|
61
|
+
if (!unwrapEnvelope) {
|
|
62
|
+
return response;
|
|
63
|
+
}
|
|
64
|
+
const payload = response.data;
|
|
65
|
+
if (!payload?.success) {
|
|
66
|
+
onError?.(payload?.msg || 'Request failed');
|
|
67
|
+
return Promise.reject({
|
|
68
|
+
statusCode: payload?.statusCode,
|
|
69
|
+
message: payload?.msg,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
return payload.data;
|
|
73
|
+
}, (err) => {
|
|
74
|
+
const status = err?.response?.status;
|
|
75
|
+
const msg = err?.response?.data?.msg;
|
|
76
|
+
if (status === 401) {
|
|
77
|
+
onUnauthorized?.();
|
|
78
|
+
onError?.(msg || 'Unauthorized');
|
|
79
|
+
}
|
|
80
|
+
else if (status) {
|
|
81
|
+
onError?.(msg || 'Server error', status);
|
|
82
|
+
}
|
|
83
|
+
return Promise.reject({
|
|
84
|
+
statusCode: status,
|
|
85
|
+
message: msg,
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
return client;
|
|
89
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export type { ThemeApi } from './api/api';
|
|
2
|
+
export { createThemeApi, getThemeApiBaseUrl, resolveThemeApiBaseUrl, themeApi, } from './api/api';
|
|
3
|
+
export type { ApiEnvelope } from '../utils/api-envelope';
|
|
4
|
+
export { unpackList, unpackOne, unpackPaginated, unpackPaginatedPair, } from '../utils/api-envelope';
|
|
5
|
+
export { isLikelyValidAssetPath, isLikelyValidHeaderLogoPath, resolvePublicAssetUrl, rewriteArticleHtmlAssets } from './content/assets';
|
|
6
|
+
export type { ArchiveExcerptMode, ResolveArchiveExcerptOptions } from './content/excerpt';
|
|
7
|
+
export { resolveArchiveExcerpt, stripHtml, truncateWords, } from './content/excerpt';
|
|
8
|
+
export type { AppBootstrapResult, FetchAppBootstrapOptions } from './ssr/bootstrap';
|
|
9
|
+
export { createDefaultAppBootstrap, fetchAppBootstrap, fetchArchives, fetchCmsPage, fetchKnowledgeDetail, fetchKnowledgeList, fetchPublishedPages, fetchRecommendArticles, } from './ssr/bootstrap';
|
|
10
|
+
export type { SlimBootstrapOptions } from './ssr/slimBootstrap';
|
|
11
|
+
export { createBootstrapSlimmer, slimAppBootstrapForRoute, } from './ssr/slimBootstrap';
|
|
12
|
+
export type { CarouselArticle, ListArticle, } from './content/articleSlim';
|
|
13
|
+
export { slimArticleForCarousel, slimArticleForList, slimArticlesForCarousel, slimArticlesForList, } from './content/articleSlim';
|
|
14
|
+
export type { ArchiveArticle, ArchiveTree } from './content/archiveSlim';
|
|
15
|
+
export { countArchiveArticles, formatArchiveDay, slimArchiveTree, sortedArchiveYears, } from './content/archiveSlim';
|
|
16
|
+
export type { ResolveCarouselArticlesOptions } from './content/carouselArticles';
|
|
17
|
+
export { resolveCarouselArticles } from './content/carouselArticles';
|
|
18
|
+
export type { CategoryArchivePageProps, HomePageProps, KnowledgeIndexPageProps, SearchPageProps, TagArchivePageProps, } from './ssr/pageProps';
|
|
19
|
+
export { fetchArchivesPageProps, fetchArticleDetailProps, fetchCategoryArchivePageProps, fetchCmsPageProps, fetchHomePageProps, fetchKnowledgeBookPageProps, fetchKnowledgeChapterPageProps, fetchKnowledgeIndexPageProps, fetchSearchPageProps, fetchTagArchivePageProps, } from './ssr/pageProps';
|
|
20
|
+
export type { FetchVisitorContextOptions, ThemeArchiveKind, VisitorContextProps } from './ssr/fetch';
|
|
21
|
+
export { createArchiveGetStaticProps, createDefaultVisitorContext, fetchArticlePageProps, fetchCategoryArchive, fetchCategoryIndex, fetchSearchArticles, fetchSingleArticle, fetchSiteMeta, fetchSiteSettings, fetchTagArchive, fetchTagIndex, fetchThemeCatalog, fetchVisitorContext, resolveStaticVisitorContext, sanitizeNextProps, THEME_ISR_REVALIDATE_SECONDS, themeStaticProps, withApiRetry, withThemeStaticProps, } from './ssr/fetch';
|
|
22
|
+
export type { SettingRow } from '../utils/setting';
|
|
23
|
+
export { formatPublishDate, formatPublishDateShort, } from '../utils/date';
|
|
24
|
+
export { pickSiteSettings } from '../utils/setting';
|
|
25
|
+
export { safeJsonParse } from '../utils/json';
|
|
26
|
+
export type { ImageVariant } from '../utils/image';
|
|
27
|
+
export { resolveImageUrl } from '../utils/image';
|
|
28
|
+
export type { ThemeSessionUser, } from './visitor/authSession';
|
|
29
|
+
export { ADMIN_AUTH_STORAGE_KEY, clearThemeSession, getStoredAccessToken, persistThemeSession, resolveStoredUser, THEME_TOKEN_STORAGE_KEY, THEME_USER_STORAGE_KEY, } from './visitor/authSession';
|
|
30
|
+
export type { ThemeColorMode } from './visitor/colorMode';
|
|
31
|
+
export { applyColorModeClass, buildColorModeInitScript, COLOR_MODE_STORAGE_KEY, colorModeInitScript, persistColorMode, resolveClientThemeMode, resolveInitialColorModeState, resolvePreferredColorMode, } from './visitor/colorMode';
|
|
32
|
+
export { DEFAULT_VISITOR_LOCALES, LEGACY_LOCALE_STORAGE_KEY, persistVisitorLocale, readBrowserCookie, readRequestCookie, resolveVisitorLocale, VISITOR_LOCALE_COOKIE, } from './visitor/visitorLocale';
|
|
33
|
+
export type { CommentAuthor } from './visitor/commentAuthor';
|
|
34
|
+
export { COMMENT_AUTHOR_STORAGE_KEY, COMMENT_EMAIL_REGEXP, getCommentEmailError, isValidCommentAuthor, isValidCommentEmail, persistCommentAuthor, readCommentAuthor, } from './visitor/commentAuthor';
|
|
35
|
+
export type { SiteTitleSource } from './content/seo';
|
|
36
|
+
export { getPageTitle, getSiteTitle } from './content/seo';
|
|
37
|
+
export { jsonp } from '../utils/jsonp';
|
|
38
|
+
export type { CreateThemeAxiosClientOptions, ThemeApiEnvelope, } from './api/httpClient';
|
|
39
|
+
export { createThemeAxiosClient, encodeAxiosUrlPath, resolveThemeAxiosBaseUrl, } from './api/httpClient';
|
|
40
|
+
export type { LocaleCatalog, LocaleMessages, ParseSiteLocaleOptions, SiteLocaleState, } from './visitor/locale';
|
|
41
|
+
export { createTranslator, parseSiteLocale, resolveRequestLocale, } from './visitor/locale';
|
|
42
|
+
export { mergeVisitorI18n, slimVisitorI18nForSsr } from './visitor/i18n';
|
|
43
|
+
export type { NavItem } from './content/nav';
|
|
44
|
+
export { articlePath, categoryPath, getNavActiveId, tagPath, } from './content/nav';
|
|
45
|
+
export type { ResolveThemeRuntimeOptions, ThemeRuntime } from './visitor/runtime';
|
|
46
|
+
export { resolveThemeRuntime } from './visitor/runtime';
|
|
47
|
+
export type { SiteMeta } from './ssr/setting';
|
|
48
|
+
export { DEFAULT_SITE_META, parseSiteMeta, unwrapSetting } from './ssr/setting';
|
|
49
|
+
export { createThemeProviders } from './providers';
|
|
50
|
+
export type { ThemeProviders } from './providers';
|
|
51
|
+
export type { CreateThemeHttpStackOptions } from './providers/setup';
|
|
52
|
+
export { createThemeHttpStack } from './providers/setup';
|
|
53
|
+
export { defaultModsFromManifest } from './visitor/appearance';
|
|
54
|
+
export type ThemeManifestRef = {
|
|
55
|
+
id: string;
|
|
56
|
+
};
|
|
57
|
+
export * from './extension';
|
|
58
|
+
export { themeNotFound, themeOnDemandPaths, themeStaticNotFound } from './ssr/static';
|
|
59
|
+
export type { ThemeManifestLike, ThemeTemplateSlug } from './ssr/templates';
|
|
60
|
+
export { DEFAULT_TEMPLATE_FILES, resolveTemplateFiles, ThemeTemplate } from './ssr/templates';
|
|
61
|
+
/** Headless theme UI — also available from `@fecommunity/reactpress-toolkit/ui`. */
|
|
62
|
+
export type { ArchiveEmptyStateProps, ArchivePageLayoutProps, ArticleCardArticle, ArticleCardLinkProps, ArticleCardProps, ArticleListProps, BaseGlobalStylesProps, LocaleContextValue, LocaleProviderProps, LocaleSwitcherProps, NavMenuProps, NavMenuRenderLinkProps, NotFoundPanelProps, PageHeaderProps, ReactPressProviderProps, SiteBrandingProps, SiteDocumentFallbackProps, SiteDocumentProps, SiteLogoProps, SiteTaglineProps, TaxonomyItem, TaxonomyListProps, TaxonomyListRenderLinkProps, TaxonomyListVariant, ThemeLayoutProps, ThemeRuntimeContextValue, ThemeRuntimeProviderProps, SiteCatalogContextValue, SiteCatalogSiteConfig, SiteConfigNav, SiteSeoProps, SiteAnalyticsProps, } from '../ui';
|
|
63
|
+
export { ArchiveEmptyState, ArchivePageLayout, ArticleCard, ArticleList, BaseGlobalStyles, LocaleProvider, LocaleSwitcher, NavMenu, NotFoundPanel, PageHeader, ReactPressProvider, readPersistedLocale, SiteBranding, SiteDocument, SiteDocumentFallback, SiteLogo, SiteTagline, TaxonomyList, ThemeCssVars, ThemeLayout, ThemeRuntimeProvider, useActiveThemeId, useIsThemePreview, useLocale, useAsyncLoading, useForceUpdate, useNavActive, usePagination, useReportArticleView, useReportPageView, useRouteParam, useToggle, useWarningOnExit, useSiteMeta, useThemeId, useThemeMod, useThemeModBool, useThemeRuntime, SiteCatalogContext, SiteCatalogProvider, SiteSeo, SiteAnalytics, useSiteCatalog, useSiteSetting, useSiteUser, useColorMode, useSiteConfig, } from '../ui';
|