@fecommunity/reactpress-toolkit 3.7.0 → 4.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +107 -107
- package/dist/plugin/admin/index.d.ts +2 -0
- package/dist/plugin/admin/index.js +2 -0
- package/dist/plugin/admin/plugin-admin.d.ts +7 -1
- package/dist/plugin/client/runtime.d.ts +6 -1
- package/dist/plugin/index.d.ts +4 -0
- package/dist/plugin/index.js +5 -1
- package/dist/plugin/react/index.d.ts +1 -0
- package/dist/plugin/react/index.js +1 -0
- package/dist/theme/content/assets.js +33 -1
- package/dist/theme/extension/theme.d.ts +1 -1
- package/dist/theme/extension/theme.js +1 -1
- package/dist/theme/ssr/fetch.d.ts +3 -0
- package/dist/theme/ssr/pageProps.d.ts +5 -4
- package/dist/theme/ssr/pageProps.js +20 -3
- package/dist/theme/ssr/setting.d.ts +1 -0
- package/dist/theme/ssr/setting.js +3 -0
- package/dist/theme/ssr/templates.js +1 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/ui/components/ArchiveEmptyState.d.ts +1 -1
- package/dist/ui/components/ArchivePageLayout.d.ts +1 -1
- package/dist/ui/components/ArticleCard.d.ts +1 -1
- package/dist/ui/components/ArticleList.d.ts +1 -1
- package/dist/ui/components/BaseGlobalStyles.d.ts +1 -2
- package/dist/ui/components/LocaleSwitcher.d.ts +1 -1
- package/dist/ui/components/NavMenu.d.ts +1 -1
- package/dist/ui/components/NotFoundPanel.d.ts +1 -1
- package/dist/ui/components/PageHeader.d.ts +1 -1
- package/dist/ui/components/SiteAnalytics.d.ts +1 -1
- package/dist/ui/components/SiteBranding.d.ts +1 -2
- package/dist/ui/components/SiteDocument.d.ts +1 -1
- package/dist/ui/components/SiteDocumentFallback.d.ts +1 -1
- package/dist/ui/components/SiteLogo.d.ts +1 -2
- package/dist/ui/components/SiteSeo.d.ts +1 -1
- package/dist/ui/components/SiteTagline.d.ts +1 -2
- package/dist/ui/components/TaxonomyList.d.ts +1 -1
- package/dist/ui/components/ThemeCssVars.d.ts +1 -2
- package/dist/ui/components/ThemeLayout.d.ts +1 -1
- package/dist/ui/components/content/ArticleReader.d.ts +1 -1
- package/dist/ui/components/content/ArticleToc.d.ts +1 -1
- package/dist/ui/components/content/HtmlContent.d.ts +1 -2
- package/dist/ui/components/content/Image.d.ts +1 -1
- package/dist/ui/components/content/LocaleTime.d.ts +1 -2
- package/dist/ui/components/toolbar/LocaleToggleButton.d.ts +1 -1
- package/dist/ui/components/toolbar/ThemeToggleButton.d.ts +1 -1
- package/dist/ui/components/toolbar/ToolbarIconButton.d.ts +1 -1
- package/dist/ui/components/toolbar/icons.d.ts +7 -7
- package/dist/ui/context/LocaleContext.d.ts +1 -1
- package/dist/ui/context/ReactPressProvider.d.ts +1 -2
- package/dist/ui/context/SiteCatalogContext.d.ts +1 -1
- package/dist/ui/context/ThemeRuntimeContext.d.ts +1 -1
- package/package.json +13 -1
package/README.md
CHANGED
|
@@ -1,89 +1,89 @@
|
|
|
1
1
|
# @fecommunity/reactpress-toolkit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript toolkit for ReactPress: OpenAPI/Swagger-generated API clients, site config types, Next.js theme SSR helpers, and admin plugin registry.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Package exports (`package.json` → `exports`)
|
|
6
6
|
|
|
7
|
-
|
|
|
7
|
+
| Subpath | Purpose |
|
|
8
8
|
|--------|------|
|
|
9
|
-
| `.` |
|
|
10
|
-
| `./api` |
|
|
11
|
-
| `./api/instance` |
|
|
12
|
-
| `./types` | Swagger
|
|
13
|
-
| `./utils` |
|
|
14
|
-
| `./config` |
|
|
15
|
-
| `./theme` |
|
|
9
|
+
| `.` | Root entry: `api`, `config`, `theme`, `ui`, `plugin` namespaces and common re-exports |
|
|
10
|
+
| `./api` | HTTP client classes per resource |
|
|
11
|
+
| `./api/instance` | Default `api` instance and `createApiInstance` |
|
|
12
|
+
| `./types` | Swagger-generated request/response types |
|
|
13
|
+
| `./utils` | Framework-agnostic utilities (see module table below) |
|
|
14
|
+
| `./config` | Env vars, global defaults, `i18n` strings (`config/locales/*.json`) |
|
|
15
|
+
| `./theme` | Visitor themes: SSR data fetch, runtime, extension config types; re-exports `./ui` |
|
|
16
16
|
| `./theme/next-config` | `createReactPressNextConfig()` |
|
|
17
|
-
| `./theme/node` | Node
|
|
18
|
-
| `./ui` |
|
|
19
|
-
| `./plugin` |
|
|
20
|
-
| `./plugin/admin` |
|
|
21
|
-
| `./plugin/client` | Web/Electron API
|
|
22
|
-
| `./plugin/react` |
|
|
23
|
-
| `./plugin/dev` | Vite
|
|
17
|
+
| `./theme/node` | Node-only helpers (e.g. read theme admin locale files) |
|
|
18
|
+
| `./ui` | Unstyled theme components and hooks |
|
|
19
|
+
| `./plugin` | Admin plugin aggregate entry |
|
|
20
|
+
| `./plugin/admin` | Menu registration, permission constants |
|
|
21
|
+
| `./plugin/client` | Web/Electron API client factory (recommended) |
|
|
22
|
+
| `./plugin/react` | Same as `./plugin/client` (legacy path) |
|
|
23
|
+
| `./plugin/dev` | Vite dev port redirect, etc. |
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
**Convention:** Only top-level directories under `src/` match the exports above; implementation details live in subdirectories with thin shims at the root (e.g. `theme/node.ts` → `theme/build/node.ts`).
|
|
26
26
|
|
|
27
|
-
##
|
|
27
|
+
## Source layout
|
|
28
28
|
|
|
29
29
|
```
|
|
30
30
|
src/
|
|
31
|
-
├── api/ # OpenAPI
|
|
32
|
-
├── config/ # env
|
|
33
|
-
├── types/ # Swagger
|
|
34
|
-
├── utils/ #
|
|
31
|
+
├── api/ # OpenAPI generated (do not hand-edit business logic)
|
|
32
|
+
├── config/ # env, global, i18n + locales/
|
|
33
|
+
├── types/ # Swagger generated types
|
|
34
|
+
├── utils/ # Pure utilities (shared by theme/plugin)
|
|
35
35
|
│ ├── api-envelope.ts # unpackList / unpackOne / unpackPaginated
|
|
36
36
|
│ ├── cookie.ts # readRequestCookie
|
|
37
|
-
│ ├── date.ts # formatDate
|
|
38
|
-
│ ├── email.ts #
|
|
39
|
-
│ ├── error.ts # ApiError
|
|
37
|
+
│ ├── date.ts # formatDate, formatPublishDate*
|
|
38
|
+
│ ├── email.ts # Comment email validation
|
|
39
|
+
│ ├── error.ts # ApiError, isApiError
|
|
40
40
|
│ ├── json.ts # safeJsonParse
|
|
41
|
-
│ ├── jsonp.ts #
|
|
42
|
-
│ ├── object.ts # deepMerge
|
|
41
|
+
│ ├── jsonp.ts # Browser JSONP
|
|
42
|
+
│ ├── object.ts # deepMerge, getByPath, deepClone
|
|
43
43
|
│ ├── setting.ts # pickSiteSettings
|
|
44
|
-
│ └── string.ts # stripHtml
|
|
44
|
+
│ └── string.ts # stripHtml, truncateWords
|
|
45
45
|
├── plugin/
|
|
46
|
-
│ ├── admin/ # AdminModule
|
|
47
|
-
│ ├── client/ # createClient
|
|
48
|
-
│ ├── dev/ # devPortRedirectPlugin
|
|
49
|
-
│ └── react/ #
|
|
46
|
+
│ ├── admin/ # AdminModule, menu registration, permissions
|
|
47
|
+
│ ├── client/ # createClient, resolveApiBaseUrl
|
|
48
|
+
│ ├── dev/ # devPortRedirectPlugin, etc.
|
|
49
|
+
│ └── react/ # Re-export client only (compat)
|
|
50
50
|
├── theme/
|
|
51
|
-
│ ├── api/ # themeApi
|
|
52
|
-
│ ├── ssr/ # fetch
|
|
53
|
-
│ ├── visitor/ #
|
|
54
|
-
│ ├── content/ # SEO
|
|
55
|
-
│ ├── preview/ #
|
|
56
|
-
│ ├── createCatalogApp.js #
|
|
57
|
-
│ ├── createApp.js # Next `_app`
|
|
58
|
-
│ ├── extension/ # theme.json
|
|
51
|
+
│ ├── api/ # themeApi, axios wrapper
|
|
52
|
+
│ ├── ssr/ # fetch, static props, site meta
|
|
53
|
+
│ ├── visitor/ # Language, session, colors, runtime mods
|
|
54
|
+
│ ├── content/ # SEO, nav paths, excerpts, static asset URLs
|
|
55
|
+
│ ├── preview/ # Preview token / mods / config query params
|
|
56
|
+
│ ├── createCatalogApp.js # Full theme _app factory (no UI framework)
|
|
57
|
+
│ ├── createApp.js # Next `_app` factory (allowJs, emitted to dist)
|
|
58
|
+
│ ├── extension/ # theme.json schema, site config, shared server types
|
|
59
59
|
│ ├── node.ts # → build/node
|
|
60
60
|
│ ├── next-config.ts
|
|
61
|
-
│ └── index.ts #
|
|
61
|
+
│ └── index.ts # Public barrel
|
|
62
62
|
└── ui/
|
|
63
|
-
├── components/ #
|
|
64
|
-
├── context/ # ReactPressProvider
|
|
65
|
-
└── hooks/ #
|
|
63
|
+
├── components/ # Unstyled React components
|
|
64
|
+
├── context/ # ReactPressProvider, locale, runtime
|
|
65
|
+
└── hooks/ # Generic React hooks
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
##
|
|
68
|
+
## Install
|
|
69
69
|
|
|
70
70
|
```bash
|
|
71
71
|
pnpm add @fecommunity/reactpress-toolkit
|
|
72
72
|
```
|
|
73
73
|
|
|
74
|
-
##
|
|
74
|
+
## Quick start
|
|
75
75
|
|
|
76
|
-
### API
|
|
76
|
+
### API client
|
|
77
77
|
|
|
78
78
|
```typescript
|
|
79
79
|
import { api } from '@fecommunity/reactpress-toolkit';
|
|
80
|
-
//
|
|
80
|
+
// or
|
|
81
81
|
import { api, createApiInstance } from '@fecommunity/reactpress-toolkit/api/instance';
|
|
82
82
|
|
|
83
83
|
const articles = await api.article.findAll();
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
Custom baseURL:
|
|
87
87
|
|
|
88
88
|
```typescript
|
|
89
89
|
import { createApiInstance } from '@fecommunity/reactpress-toolkit/api/instance';
|
|
@@ -91,9 +91,9 @@ import { createApiInstance } from '@fecommunity/reactpress-toolkit/api/instance'
|
|
|
91
91
|
const customApi = createApiInstance({ baseURL: 'https://api.example.com/api' });
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
-
###
|
|
94
|
+
### Utilities (`./utils`)
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
Framework-agnostic logic belongs in `utils`; `theme` re-exports for `@fecommunity/reactpress-toolkit/theme` compatibility:
|
|
97
97
|
|
|
98
98
|
```typescript
|
|
99
99
|
import {
|
|
@@ -107,49 +107,49 @@ import {
|
|
|
107
107
|
} from '@fecommunity/reactpress-toolkit/utils';
|
|
108
108
|
```
|
|
109
109
|
|
|
110
|
-
|
|
|
110
|
+
| Module | Typical use |
|
|
111
111
|
|------|----------|
|
|
112
|
-
| `json` |
|
|
113
|
-
| `api-envelope` |
|
|
114
|
-
| `date` |
|
|
115
|
-
| `string` |
|
|
116
|
-
| `object` | theme.json
|
|
117
|
-
| `setting` |
|
|
118
|
-
| `cookie` |
|
|
119
|
-
| `email` |
|
|
112
|
+
| `json` | Parse JSON strings in settings |
|
|
113
|
+
| `api-envelope` | Unwrap Nest `TransformInterceptor` `{ data }` |
|
|
114
|
+
| `date` | Article publish date display |
|
|
115
|
+
| `string` | Strip HTML for archive excerpts, truncate |
|
|
116
|
+
| `object` | Merge theme.json config, dot-path read/write |
|
|
117
|
+
| `setting` | Map settings rows to props |
|
|
118
|
+
| `cookie` | Read `Cookie` header in SSR |
|
|
119
|
+
| `email` | Visitor comment email format |
|
|
120
120
|
|
|
121
|
-
###
|
|
121
|
+
### Admin plugins
|
|
122
122
|
|
|
123
123
|
```typescript
|
|
124
124
|
import type { AdminModule } from '@fecommunity/reactpress-toolkit/plugin/admin';
|
|
125
125
|
import { permissionsForRole } from '@fecommunity/reactpress-toolkit/plugin/admin';
|
|
126
126
|
```
|
|
127
127
|
|
|
128
|
-
### Web / Electron
|
|
128
|
+
### Web / Electron client
|
|
129
129
|
|
|
130
130
|
```typescript
|
|
131
131
|
import { createClient, resolveApiBaseUrl } from '@fecommunity/reactpress-toolkit/plugin/client';
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
-
## App
|
|
134
|
+
## App factories (`./app`)
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
Entry factories for theme `_app.tsx`, UI-framework agnostic:
|
|
137
137
|
|
|
138
|
-
|
|
|
138
|
+
| Factory | Purpose |
|
|
139
139
|
|------|------|
|
|
140
|
-
| `createThemeApp` |
|
|
141
|
-
| `createReactPressApp` |
|
|
140
|
+
| `createThemeApp` | Minimal theme (hello-world): `ReactPressProvider` + `ThemeCssVars` |
|
|
141
|
+
| `createReactPressApp` | Full theme: SSR catalog, i18n, analytics, PV; inject Ant Design etc. via `wrapContent` |
|
|
142
142
|
|
|
143
143
|
```typescript
|
|
144
144
|
import { createThemeApp } from '@fecommunity/reactpress-toolkit/app';
|
|
145
145
|
import { createReactPressApp } from '@fecommunity/reactpress-toolkit/app';
|
|
146
146
|
```
|
|
147
147
|
|
|
148
|
-
|
|
148
|
+
Also re-exported from `./theme` (legacy paths).
|
|
149
149
|
|
|
150
|
-
##
|
|
150
|
+
## Theme development (`./theme`)
|
|
151
151
|
|
|
152
|
-
Next.js
|
|
152
|
+
Next.js visitor themes should use toolkit API and SSR helpers instead of copying `lib/api.ts` per theme.
|
|
153
153
|
|
|
154
154
|
```typescript
|
|
155
155
|
import {
|
|
@@ -175,7 +175,7 @@ import themeManifest from '../theme.json';
|
|
|
175
175
|
export default createThemeApp(themeManifest);
|
|
176
176
|
```
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
**Full-featured themes** — use `createReactPressApp` (UI-framework agnostic); keep Ant Design and heavy deps in the theme:
|
|
179
179
|
|
|
180
180
|
```typescript
|
|
181
181
|
import { createReactPressApp } from '@fecommunity/reactpress-toolkit/app';
|
|
@@ -193,9 +193,9 @@ export default createReactPressApp(themeManifest, {
|
|
|
193
193
|
});
|
|
194
194
|
```
|
|
195
195
|
|
|
196
|
-
`createReactPressApp`
|
|
196
|
+
`createReactPressApp` includes: SSR site data, preview mods, SiteCatalogProvider, route progress, analytics scripts, PV reporting. **Does not** include Ant Design / cssinjs.
|
|
197
197
|
|
|
198
|
-
**REST
|
|
198
|
+
**REST providers** — avoid copying 14 provider files per theme:
|
|
199
199
|
|
|
200
200
|
```typescript
|
|
201
201
|
import { createThemeAxiosClient, createThemeProviders } from '@fecommunity/reactpress-toolkit/theme';
|
|
@@ -204,68 +204,68 @@ export const httpProvider = createThemeAxiosClient({ onError, onUnauthorized });
|
|
|
204
204
|
export const { ArticleProvider, CategoryProvider, TagProvider } = createThemeProviders(httpProvider);
|
|
205
205
|
```
|
|
206
206
|
|
|
207
|
-
|
|
207
|
+
Env: `REACTPRESS_API_URL` (SSR), `NEXT_PUBLIC_REACTPRESS_API_URL` (browser), injected by `reactpress theme dev`.
|
|
208
208
|
|
|
209
|
-
###
|
|
209
|
+
### Headless UI (`./ui`)
|
|
210
210
|
|
|
211
|
-
|
|
211
|
+
Also importable from `./theme`:
|
|
212
212
|
|
|
213
213
|
```typescript
|
|
214
214
|
import { NavMenu, ArticleList, ReactPressProvider, useLocale } from '@fecommunity/reactpress-toolkit/ui';
|
|
215
215
|
```
|
|
216
216
|
|
|
217
|
-
|
|
|
217
|
+
| Symbol | Description |
|
|
218
218
|
|------|------|
|
|
219
|
-
| `ReactPressProvider` |
|
|
220
|
-
| `useLocale` / `useThemeRuntime` / `useThemeMod` |
|
|
221
|
-
| `useToggle` / `useAsyncLoading` |
|
|
222
|
-
| `usePagination` | `[items, total]`
|
|
223
|
-
| `useReportArticleView` / `useReportPageView` |
|
|
224
|
-
| `useRouteParam` / `useNavActive` |
|
|
225
|
-
| `useWarningOnExit` |
|
|
226
|
-
| `NavMenu` |
|
|
227
|
-
| `ArticleList` |
|
|
228
|
-
| `SiteCatalogProvider` / `useSiteSetting` / `useSiteUser` |
|
|
229
|
-
| `SiteSeo` / `RouteProgress` / `SiteAnalytics` | SEO meta
|
|
230
|
-
| `ArticleReader` / `HtmlContent` / `ArticleToc` |
|
|
231
|
-
| `ImageViewer` / `LocaleTime` |
|
|
232
|
-
| `createReactPressApp` |
|
|
233
|
-
| `fetchAppBootstrap` | `_app.getInitialProps` SSR
|
|
234
|
-
|
|
235
|
-
###
|
|
236
|
-
|
|
237
|
-
`theme/extension`
|
|
219
|
+
| `ReactPressProvider` | Inject site context in `_app` |
|
|
220
|
+
| `useLocale` / `useThemeRuntime` / `useThemeMod` | Language and theme mods |
|
|
221
|
+
| `useToggle` / `useAsyncLoading` | Boolean toggle, debounced loading |
|
|
222
|
+
| `usePagination` | `[items, total]` paginated lists |
|
|
223
|
+
| `useReportArticleView` / `useReportPageView` | Article views, site PV |
|
|
224
|
+
| `useRouteParam` / `useNavActive` | Dynamic route params, nav highlight |
|
|
225
|
+
| `useWarningOnExit` | Confirm before leaving page (Next Router) |
|
|
226
|
+
| `NavMenu` | Config-driven nav via `renderLink` + Next `Link` |
|
|
227
|
+
| `ArticleList` | List renderer via `renderArticle` |
|
|
228
|
+
| `SiteCatalogProvider` / `useSiteSetting` / `useSiteUser` | Site catalog + user session |
|
|
229
|
+
| `SiteSeo` / `RouteProgress` / `SiteAnalytics` | SEO meta, progress bar, GA/Baidu |
|
|
230
|
+
| `ArticleReader` / `HtmlContent` / `ArticleToc` | Article reading, HTML, TOC |
|
|
231
|
+
| `ImageViewer` / `LocaleTime` | Image preview, localized time |
|
|
232
|
+
| `createReactPressApp` | Full theme `_app` factory |
|
|
233
|
+
| `fetchAppBootstrap` | `_app.getInitialProps` SSR data |
|
|
234
|
+
|
|
235
|
+
### Extension config types
|
|
236
|
+
|
|
237
|
+
Types and validation in `theme/extension` are shared with **server** and **web appearance settings**, e.g. `ThemeConfigurationSchema`, `resolveSiteConfig`, `PUBLIC_SETTING_KEYS`. Server example:
|
|
238
238
|
|
|
239
239
|
```typescript
|
|
240
240
|
import { PUBLIC_SETTING_KEYS, systemGlobalSettingDefaults } from '@fecommunity/reactpress-toolkit/theme';
|
|
241
241
|
import { readThemeAdminLocaleFile } from '@fecommunity/reactpress-toolkit/theme/node';
|
|
242
242
|
```
|
|
243
243
|
|
|
244
|
-
##
|
|
244
|
+
## Regenerate API from Swagger
|
|
245
245
|
|
|
246
|
-
|
|
246
|
+
From monorepo root, ensure server builds:
|
|
247
247
|
|
|
248
248
|
```bash
|
|
249
249
|
cd toolkit && pnpm run generate
|
|
250
250
|
```
|
|
251
251
|
|
|
252
|
-
|
|
252
|
+
Updates `src/api/*` and `src/types/*`.
|
|
253
253
|
|
|
254
|
-
##
|
|
254
|
+
## Build
|
|
255
255
|
|
|
256
256
|
```bash
|
|
257
257
|
cd toolkit && pnpm run build
|
|
258
258
|
```
|
|
259
259
|
|
|
260
|
-
|
|
260
|
+
Output in `dist/`; `createApp.js` is emitted via `tsc` (`allowJs`) to `dist/theme/createApp.js`.
|
|
261
261
|
|
|
262
|
-
##
|
|
262
|
+
## Scripts
|
|
263
263
|
|
|
264
|
-
|
|
|
264
|
+
| Command | Description |
|
|
265
265
|
|------|------|
|
|
266
|
-
| `pnpm run generate` |
|
|
267
|
-
| `pnpm run build` | `tsc` +
|
|
268
|
-
| `pnpm run typecheck` |
|
|
266
|
+
| `pnpm run generate` | Generate API from server Swagger |
|
|
267
|
+
| `pnpm run build` | `tsc` + copy locales |
|
|
268
|
+
| `pnpm run typecheck` | Type check only |
|
|
269
269
|
|
|
270
270
|
## License
|
|
271
271
|
|
|
@@ -15,4 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./permissions"), exports);
|
|
18
|
+
__exportStar(require("./plugin-admin"), exports);
|
|
18
19
|
__exportStar(require("./registry"), exports);
|
|
20
|
+
__exportStar(require("./slots"), exports);
|
|
@@ -3,9 +3,15 @@ export interface PluginAdminContext {
|
|
|
3
3
|
id: string;
|
|
4
4
|
config: Record<string, unknown>;
|
|
5
5
|
}
|
|
6
|
+
export interface PluginSettingsPanelProps {
|
|
7
|
+
pluginId: string;
|
|
8
|
+
config: Record<string, unknown>;
|
|
9
|
+
pluginActive: boolean;
|
|
10
|
+
}
|
|
6
11
|
/** Plugin admin entry — called once per active plugin when admin shell loads. */
|
|
7
12
|
export interface PluginAdminModule {
|
|
8
|
-
registerAdmin(registry: PluginAdminRegistry, ctx: PluginAdminContext): void | Promise<void>;
|
|
13
|
+
registerAdmin?(registry: PluginAdminRegistry, ctx: PluginAdminContext): void | Promise<void>;
|
|
14
|
+
SettingsPanel?: (props: PluginSettingsPanelProps) => unknown;
|
|
9
15
|
}
|
|
10
16
|
/** Opaque component type — React `ComponentType` lives in `@fecommunity/reactpress-toolkit/plugin/react`. */
|
|
11
17
|
export type PluginAdminSlotComponent = (props: PluginAdminSlotComponentProps<unknown>) => unknown;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
export type AppRuntime = 'web' | 'electron';
|
|
2
|
+
export type DesktopApiMode = 'local' | 'remote';
|
|
2
3
|
export interface DesktopApi {
|
|
4
|
+
getApiMode: () => Promise<DesktopApiMode>;
|
|
5
|
+
setApiMode: (mode: DesktopApiMode) => Promise<DesktopApiMode>;
|
|
3
6
|
getApiBaseUrl: () => Promise<string>;
|
|
4
|
-
setApiBaseUrl: (url: string) => Promise<
|
|
7
|
+
setApiBaseUrl: (url: string) => Promise<string>;
|
|
8
|
+
getRemoteApiBaseUrl: () => Promise<string>;
|
|
9
|
+
setRemoteApiBaseUrl: (url: string) => Promise<string>;
|
|
5
10
|
showSaveDialog: (opts: {
|
|
6
11
|
defaultPath?: string;
|
|
7
12
|
}) => Promise<string | undefined>;
|
package/dist/plugin/index.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
export * as admin from './admin';
|
|
2
2
|
export * as client from './client';
|
|
3
3
|
export * as dev from './dev';
|
|
4
|
+
export * as extension from './extension';
|
|
5
|
+
export * as server from './server';
|
|
4
6
|
/** @deprecated Use `plugin/client`; path kept for compatibility. */
|
|
5
7
|
export * as react from './react';
|
|
6
8
|
export * from './admin';
|
|
7
9
|
export * from './client';
|
|
8
10
|
export * from './dev';
|
|
11
|
+
export * from './extension';
|
|
12
|
+
export * from './server';
|
|
9
13
|
export * from './react';
|
package/dist/plugin/index.js
CHANGED
|
@@ -36,13 +36,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
36
36
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.react = exports.dev = exports.client = exports.admin = void 0;
|
|
39
|
+
exports.react = exports.server = exports.extension = exports.dev = exports.client = exports.admin = void 0;
|
|
40
40
|
exports.admin = __importStar(require("./admin"));
|
|
41
41
|
exports.client = __importStar(require("./client"));
|
|
42
42
|
exports.dev = __importStar(require("./dev"));
|
|
43
|
+
exports.extension = __importStar(require("./extension"));
|
|
44
|
+
exports.server = __importStar(require("./server"));
|
|
43
45
|
/** @deprecated Use `plugin/client`; path kept for compatibility. */
|
|
44
46
|
exports.react = __importStar(require("./react"));
|
|
45
47
|
__exportStar(require("./admin"), exports);
|
|
46
48
|
__exportStar(require("./client"), exports);
|
|
47
49
|
__exportStar(require("./dev"), exports);
|
|
50
|
+
__exportStar(require("./extension"), exports);
|
|
51
|
+
__exportStar(require("./server"), exports);
|
|
48
52
|
__exportStar(require("./react"), exports);
|
|
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
/** Stable export path: `@fecommunity/reactpress-toolkit/plugin/react`. */
|
|
18
18
|
__exportStar(require("../client"), exports);
|
|
19
|
+
__exportStar(require("./plugin-admin-ui"), exports);
|
|
@@ -10,9 +10,18 @@ const PUBLIC_PATH_ALIASES = {
|
|
|
10
10
|
'/favicon.png': '/public/favicon.png',
|
|
11
11
|
'/favicon.ico': '/public/favicon.ico',
|
|
12
12
|
};
|
|
13
|
+
/** Theme Next rewrites serve alias keys (e.g. `/logo.png`), not `/public/*` API paths. */
|
|
14
|
+
const THEME_LOCAL_PUBLIC_PATHS = Object.fromEntries(Object.entries(PUBLIC_PATH_ALIASES).map(([themePath, apiPath]) => [apiPath, themePath]));
|
|
13
15
|
function normalizePublicAssetPath(path) {
|
|
14
16
|
return PUBLIC_PATH_ALIASES[path] ?? path;
|
|
15
17
|
}
|
|
18
|
+
function toThemeServablePath(apiPath) {
|
|
19
|
+
return THEME_LOCAL_PUBLIC_PATHS[apiPath] ?? apiPath;
|
|
20
|
+
}
|
|
21
|
+
/** Paths proxied by theme `next.config` rewrites — keep relative, never bake absolute API URLs. */
|
|
22
|
+
function isThemeRewritePath(path) {
|
|
23
|
+
return path in THEME_LOCAL_PUBLIC_PATHS || path.startsWith('/public/') || path.startsWith('/uploads/');
|
|
24
|
+
}
|
|
16
25
|
/** Whether a configured asset path is likely to resolve (skip broken defaults like `/logo.png`). */
|
|
17
26
|
function isLikelyValidAssetPath(url) {
|
|
18
27
|
const trimmed = (url ?? '').trim();
|
|
@@ -44,6 +53,26 @@ function resolvePublicSiteOrigin() {
|
|
|
44
53
|
'http://localhost:3002/api';
|
|
45
54
|
return serverApi.replace(/\/api\/?$/, '').replace(/\/$/, '');
|
|
46
55
|
}
|
|
56
|
+
/** Visitor site origin — differs from API origin during SSR (theme :3001 vs API :3002). */
|
|
57
|
+
function resolveThemeSiteOrigin() {
|
|
58
|
+
if (typeof window !== 'undefined') {
|
|
59
|
+
return window.location.origin;
|
|
60
|
+
}
|
|
61
|
+
const clientSite = process.env.CLIENT_SITE_URL?.trim();
|
|
62
|
+
if (clientSite) {
|
|
63
|
+
try {
|
|
64
|
+
return new URL(clientSite).origin;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return clientSite.replace(/\/$/, '');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const clientPort = process.env.CLIENT_PORT?.trim() || process.env.PORT?.trim();
|
|
71
|
+
if (clientPort) {
|
|
72
|
+
return `http://127.0.0.1:${clientPort}`;
|
|
73
|
+
}
|
|
74
|
+
return resolvePublicSiteOrigin();
|
|
75
|
+
}
|
|
47
76
|
/** Resolve media / logo URLs for theme pages. */
|
|
48
77
|
function resolvePublicAssetUrl(url) {
|
|
49
78
|
const trimmed = (url ?? '').trim();
|
|
@@ -57,8 +86,11 @@ function resolvePublicAssetUrl(url) {
|
|
|
57
86
|
}
|
|
58
87
|
if (trimmed.startsWith('/')) {
|
|
59
88
|
const normalized = normalizePublicAssetPath(trimmed);
|
|
89
|
+
if (isThemeRewritePath(normalized)) {
|
|
90
|
+
return toThemeServablePath(normalized);
|
|
91
|
+
}
|
|
60
92
|
const origin = resolvePublicSiteOrigin();
|
|
61
|
-
const themeOrigin =
|
|
93
|
+
const themeOrigin = resolveThemeSiteOrigin();
|
|
62
94
|
if (origin === themeOrigin) {
|
|
63
95
|
return normalized;
|
|
64
96
|
}
|
|
@@ -71,7 +71,7 @@ export interface SiteThemeState {
|
|
|
71
71
|
mods: Record<string, ThemeMods>;
|
|
72
72
|
previewThemeId?: string;
|
|
73
73
|
}
|
|
74
|
-
export declare const DEFAULT_ACTIVE_THEME = "
|
|
74
|
+
export declare const DEFAULT_ACTIVE_THEME = "hello-world";
|
|
75
75
|
export declare const defaultSiteThemeState: SiteThemeState;
|
|
76
76
|
export interface GlobalSettingWithTheme {
|
|
77
77
|
zh?: unknown;
|
|
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "appearancePrimaryColorForMode", { enumerable: tr
|
|
|
19
19
|
function appearancePrimaryColor(mods, fallback = '#f44336') {
|
|
20
20
|
return (0, twentytwentyfive_vars_1.appearancePrimaryColorForMode)(mods, false, fallback);
|
|
21
21
|
}
|
|
22
|
-
exports.DEFAULT_ACTIVE_THEME = '
|
|
22
|
+
exports.DEFAULT_ACTIVE_THEME = 'hello-world';
|
|
23
23
|
exports.defaultSiteThemeState = {
|
|
24
24
|
activeTheme: exports.DEFAULT_ACTIVE_THEME,
|
|
25
25
|
installedThemes: [exports.DEFAULT_ACTIVE_THEME],
|
|
@@ -73,7 +73,10 @@ export declare function fetchTagArchive(api: ThemeApi, tag: string): Promise<{
|
|
|
73
73
|
export type ThemeArticlePage = {
|
|
74
74
|
id: string;
|
|
75
75
|
title: string;
|
|
76
|
+
slug?: string;
|
|
76
77
|
summary?: string;
|
|
78
|
+
seoDescription?: string;
|
|
79
|
+
seoKeywords?: string;
|
|
77
80
|
html?: string;
|
|
78
81
|
cover?: string;
|
|
79
82
|
publishAt?: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ThemeApi } from '../api/api';
|
|
2
2
|
import { type CarouselArticle, type ListArticle } from '../content/articleSlim';
|
|
3
3
|
import { type ArchiveTree } from '../content/archiveSlim';
|
|
4
|
-
import type { IArticle, ICategory, IKnowledge, ITag } from '../../types';
|
|
4
|
+
import type { IArticle, ICategory, IKnowledge, IPage, ITag } from '../../types';
|
|
5
5
|
export type HomePageProps = {
|
|
6
6
|
articles: ListArticle[];
|
|
7
7
|
total: number;
|
|
@@ -52,9 +52,10 @@ export declare function fetchKnowledgeChapterPageProps(api: ThemeApi, pId: strin
|
|
|
52
52
|
}>;
|
|
53
53
|
/** Site search results for `/search?keyword=`. */
|
|
54
54
|
export declare function fetchSearchPageProps(api: ThemeApi, keyword: string): Promise<SearchPageProps>;
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
export type CmsPageProps = Pick<IPage, 'id' | 'name' | 'path' | 'html' | 'toc' | 'status' | 'publishAt' | 'views'>;
|
|
56
|
+
/** CMS static page by id or path slug (admin → 页面). */
|
|
57
|
+
export declare function fetchCmsPageProps(api: ThemeApi, idOrPath: string | undefined): Promise<{
|
|
58
|
+
page: CmsPageProps | null;
|
|
58
59
|
}>;
|
|
59
60
|
/** Single article by id (full entity from API). */
|
|
60
61
|
export declare function fetchArticleDetailProps(api: ThemeApi, id: string): Promise<{
|
|
@@ -15,6 +15,7 @@ const api_data_1 = require("../api/api-data");
|
|
|
15
15
|
const articleSlim_1 = require("../content/articleSlim");
|
|
16
16
|
const archiveSlim_1 = require("../content/archiveSlim");
|
|
17
17
|
const carouselArticles_1 = require("../content/carouselArticles");
|
|
18
|
+
const assets_1 = require("../content/assets");
|
|
18
19
|
const fetch_1 = require("./fetch");
|
|
19
20
|
const DEFAULT_PAGE_SIZE = 12;
|
|
20
21
|
function fallbackCategory(value) {
|
|
@@ -128,9 +129,25 @@ async function fetchSearchPageProps(api, keyword) {
|
|
|
128
129
|
const articles = (0, api_data_1.unpackList)(response).filter((article) => article.status === 'publish');
|
|
129
130
|
return { keyword: trimmed, articles };
|
|
130
131
|
}
|
|
131
|
-
/** CMS static page by id. */
|
|
132
|
-
async function fetchCmsPageProps(api,
|
|
133
|
-
|
|
132
|
+
/** CMS static page by id or path slug (admin → 页面). */
|
|
133
|
+
async function fetchCmsPageProps(api, idOrPath) {
|
|
134
|
+
if (!idOrPath?.trim())
|
|
135
|
+
return { page: null };
|
|
136
|
+
const raw = (0, api_data_1.unpackOne)(await api.page.findById(idOrPath.trim()));
|
|
137
|
+
if (!raw || raw.status !== 'publish')
|
|
138
|
+
return { page: null };
|
|
139
|
+
return {
|
|
140
|
+
page: {
|
|
141
|
+
id: raw.id,
|
|
142
|
+
name: raw.name,
|
|
143
|
+
path: raw.path,
|
|
144
|
+
html: raw.html ? (0, assets_1.rewriteArticleHtmlAssets)(raw.html) : raw.html,
|
|
145
|
+
toc: raw.toc,
|
|
146
|
+
status: raw.status,
|
|
147
|
+
publishAt: raw.publishAt,
|
|
148
|
+
views: raw.views,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
134
151
|
}
|
|
135
152
|
/** Single article by id (full entity from API). */
|
|
136
153
|
async function fetchArticleDetailProps(api, id) {
|
|
@@ -31,6 +31,9 @@ function parseSiteMeta(row) {
|
|
|
31
31
|
siteName: String(row.systemTitle ?? 'ReactPress Site').trim() || exports.DEFAULT_SITE_META.siteName,
|
|
32
32
|
siteDescription: String(row.systemSubTitle ?? exports.DEFAULT_SITE_META.siteDescription).trim() ||
|
|
33
33
|
exports.DEFAULT_SITE_META.siteDescription,
|
|
34
|
+
siteKeywords: row.seoKeyword != null && String(row.seoKeyword).trim()
|
|
35
|
+
? String(row.seoKeyword).trim()
|
|
36
|
+
: undefined,
|
|
34
37
|
siteUrl: row.systemUrl != null ? String(row.systemUrl).trim() || undefined : undefined,
|
|
35
38
|
siteLogo: row.systemLogo != null && String(row.systemLogo).trim()
|
|
36
39
|
? String(row.systemLogo).trim()
|
|
@@ -34,7 +34,7 @@ exports.ThemeTemplate = {
|
|
|
34
34
|
exports.DEFAULT_TEMPLATE_FILES = {
|
|
35
35
|
[exports.ThemeTemplate.HOME]: 'pages/index.tsx',
|
|
36
36
|
[exports.ThemeTemplate.SINGLE]: 'pages/article/[id].tsx',
|
|
37
|
-
[exports.ThemeTemplate.PAGE]: 'pages/
|
|
37
|
+
[exports.ThemeTemplate.PAGE]: 'pages/[path].tsx',
|
|
38
38
|
[exports.ThemeTemplate.ARCHIVE_CATEGORY]: 'pages/category/[category].tsx',
|
|
39
39
|
[exports.ThemeTemplate.ARCHIVE_TAG]: 'pages/tag/[tag].tsx',
|
|
40
40
|
[exports.ThemeTemplate.SEARCH]: 'pages/search.tsx',
|
package/dist/types/index.d.ts
CHANGED
|
@@ -10,4 +10,4 @@ export interface ArchiveEmptyStateProps {
|
|
|
10
10
|
}) => React.ReactNode;
|
|
11
11
|
}
|
|
12
12
|
/** Headless empty archive/search state with optional back link slot. */
|
|
13
|
-
export declare function ArchiveEmptyState({ message, backHref, backLabel, className, renderBackLink, }: ArchiveEmptyStateProps):
|
|
13
|
+
export declare function ArchiveEmptyState({ message, backHref, backLabel, className, renderBackLink, }: ArchiveEmptyStateProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,4 +7,4 @@ export interface ArchivePageLayoutProps {
|
|
|
7
7
|
sidebarClassName?: string;
|
|
8
8
|
}
|
|
9
9
|
/** Two-column archive layout (main list + sidebar widgets). */
|
|
10
|
-
export declare function ArchivePageLayout({ main, sidebar, className, mainClassName, sidebarClassName, }: ArchivePageLayoutProps):
|
|
10
|
+
export declare function ArchivePageLayout({ main, sidebar, className, mainClassName, sidebarClassName, }: ArchivePageLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -24,4 +24,4 @@ export interface ArticleCardProps {
|
|
|
24
24
|
renderDate?: (publishAt: string) => React.ReactNode;
|
|
25
25
|
}
|
|
26
26
|
/** Headless article card — theme supplies Link markup and CSS. */
|
|
27
|
-
export declare function ArticleCard({ article, className, titleTag, showCategory, renderTitleLink, renderCategoryLink, renderDate, }: ArticleCardProps):
|
|
27
|
+
export declare function ArticleCard({ article, className, titleTag, showCategory, renderTitleLink, renderCategoryLink, renderDate, }: ArticleCardProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -11,4 +11,4 @@ export interface ArticleListProps<T extends {
|
|
|
11
11
|
/** Headless article grid/list — theme supplies markup and styles per item. */
|
|
12
12
|
export declare function ArticleList<T extends {
|
|
13
13
|
id: string;
|
|
14
|
-
}>({ articles, limit, className, empty, renderArticle, }: ArticleListProps<T>):
|
|
14
|
+
}>({ articles, limit, className, empty, renderArticle, }: ArticleListProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
export interface BaseGlobalStylesProps {
|
|
3
2
|
extra?: string;
|
|
4
3
|
}
|
|
5
4
|
/** Shared reset used by starter themes (override via `extra` CSS). */
|
|
6
|
-
export declare function BaseGlobalStyles({ extra }: BaseGlobalStylesProps):
|
|
5
|
+
export declare function BaseGlobalStyles({ extra }: BaseGlobalStylesProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,4 +7,4 @@ export interface LocaleSwitcherProps {
|
|
|
7
7
|
ariaLabel?: string;
|
|
8
8
|
}
|
|
9
9
|
/** Click to cycle locales — same control as admin and theme headers. */
|
|
10
|
-
export declare function LocaleSwitcher({ className, buttonClassName, size, ariaLabel, }: LocaleSwitcherProps): import("react").JSX.Element;
|
|
10
|
+
export declare function LocaleSwitcher({ className, buttonClassName, size, ariaLabel, }: LocaleSwitcherProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -13,4 +13,4 @@ export interface NavMenuProps {
|
|
|
13
13
|
renderLink: (props: NavMenuRenderLinkProps) => React.ReactNode;
|
|
14
14
|
}
|
|
15
15
|
/** Headless site navigation — styling via theme `renderLink` (e.g. Next.js `Link`). */
|
|
16
|
-
export declare function NavMenu({ items, activeId, className, listClassName, itemClassName, renderLink, }: NavMenuProps):
|
|
16
|
+
export declare function NavMenu({ items, activeId, className, listClassName, itemClassName, renderLink, }: NavMenuProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -8,4 +8,4 @@ export interface NotFoundPanelProps {
|
|
|
8
8
|
className?: string;
|
|
9
9
|
}
|
|
10
10
|
/** Headless 404 / not-found content block (theme supplies styles). */
|
|
11
|
-
export declare function NotFoundPanel({ title, subtitle, description, illustration, actions, className, }: NotFoundPanelProps):
|
|
11
|
+
export declare function NotFoundPanel({ title, subtitle, description, illustration, actions, className, }: NotFoundPanelProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -7,4 +7,4 @@ export interface PageHeaderProps {
|
|
|
7
7
|
descriptionClassName?: string;
|
|
8
8
|
}
|
|
9
9
|
/** Unstyled archive / page title block (WP `the_archive_title` pattern). */
|
|
10
|
-
export declare function PageHeader({ title, description, className, titleClassName, descriptionClassName, }: PageHeaderProps):
|
|
10
|
+
export declare function PageHeader({ title, description, className, titleClassName, descriptionClassName, }: PageHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,4 +2,4 @@ export interface SiteAnalyticsProps {
|
|
|
2
2
|
children?: React.ReactNode;
|
|
3
3
|
}
|
|
4
4
|
/** Inject Google Analytics / Baidu Tongji scripts from site settings. */
|
|
5
|
-
export declare function SiteAnalytics({ children }: SiteAnalyticsProps): string | number | boolean | import("react").ReactElement<
|
|
5
|
+
export declare function SiteAnalytics({ children }: SiteAnalyticsProps): string | number | bigint | boolean | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | import("react").ReactPortal | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | null;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
export interface SiteBrandingProps {
|
|
3
2
|
/** Last-resort title when customizer mod and site settings are both empty. */
|
|
4
3
|
fallback?: string;
|
|
@@ -8,4 +7,4 @@ export interface SiteBrandingProps {
|
|
|
8
7
|
/**
|
|
9
8
|
* Site title: customizer `displayTitle` when set, otherwise `systemTitle` from site settings.
|
|
10
9
|
*/
|
|
11
|
-
export declare function SiteBranding({ fallback, className, as: Tag }: SiteBrandingProps):
|
|
10
|
+
export declare function SiteBranding({ fallback, className, as: Tag }: SiteBrandingProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -17,4 +17,4 @@ export interface SiteDocumentProps {
|
|
|
17
17
|
/**
|
|
18
18
|
* WordPress-style shell: head slot + header + main + footer (like `get_header()` / `get_footer()`).
|
|
19
19
|
*/
|
|
20
|
-
export declare function SiteDocument({ head, header, footer, children, className, mainClassName, contentClassName, wrapContent, globalCss, skipBaseStyles, skipCssVars, }: SiteDocumentProps):
|
|
20
|
+
export declare function SiteDocument({ head, header, footer, children, className, mainClassName, contentClassName, wrapContent, globalCss, skipBaseStyles, skipCssVars, }: SiteDocumentProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,4 +5,4 @@ export interface SiteDocumentFallbackProps extends Omit<SiteDocumentProps, 'chil
|
|
|
5
5
|
messageClassName?: string;
|
|
6
6
|
}
|
|
7
7
|
/** Standard ISR fallback shell while on-demand pages compile. */
|
|
8
|
-
export declare function SiteDocumentFallback({ message, messageClassName, ...shell }: SiteDocumentFallbackProps):
|
|
8
|
+
export declare function SiteDocumentFallback({ message, messageClassName, ...shell }: SiteDocumentFallbackProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
export interface SiteLogoProps {
|
|
3
2
|
className?: string;
|
|
4
3
|
alt?: string;
|
|
@@ -6,4 +5,4 @@ export interface SiteLogoProps {
|
|
|
6
5
|
height?: number;
|
|
7
6
|
}
|
|
8
7
|
/** Site logo: customizer `siteLogo` when set, otherwise `systemLogo` from site settings. */
|
|
9
|
-
export declare function SiteLogo({ className, alt, width, height }: SiteLogoProps):
|
|
8
|
+
export declare function SiteLogo({ className, alt, width, height }: SiteLogoProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -10,4 +10,4 @@ export interface SiteSeoProps {
|
|
|
10
10
|
description?: string;
|
|
11
11
|
}
|
|
12
12
|
/** Inject default site meta tags from catalog `setting`. */
|
|
13
|
-
export declare function SiteSeo({ children, favicon, keywords, description }: SiteSeoProps):
|
|
13
|
+
export declare function SiteSeo({ children, favicon, keywords, description }: SiteSeoProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
export interface SiteTaglineProps {
|
|
3
2
|
/** Used when customizer tagline and site subtitle are both empty. */
|
|
4
3
|
fallback?: string;
|
|
5
4
|
className?: string;
|
|
6
5
|
}
|
|
7
6
|
/** Site tagline: customizer `displayTagline` when set, otherwise `systemSubTitle`. */
|
|
8
|
-
export declare function SiteTagline({ fallback, className }: SiteTaglineProps):
|
|
7
|
+
export declare function SiteTagline({ fallback, className }: SiteTaglineProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -22,4 +22,4 @@ export interface TaxonomyListProps {
|
|
|
22
22
|
renderLink: (props: TaxonomyListRenderLinkProps) => React.ReactNode;
|
|
23
23
|
}
|
|
24
24
|
/** Headless category/tag list (sidebar, footer, tag cloud). */
|
|
25
|
-
export declare function TaxonomyList({ items, kind, variant, currentValue, className, itemClassName, hrefFor, renderLink, }: TaxonomyListProps):
|
|
25
|
+
export declare function TaxonomyList({ items, kind, variant, currentValue, className, itemClassName, hrefFor, renderLink, }: TaxonomyListProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,4 +10,4 @@ export interface ThemeLayoutProps {
|
|
|
10
10
|
wrapContent?: boolean;
|
|
11
11
|
}
|
|
12
12
|
/** Unstyled page shell: header + main (+ optional content wrapper) + footer. */
|
|
13
|
-
export declare function ThemeLayout({ header, footer, children, className, mainClassName, contentClassName, wrapContent, }: ThemeLayoutProps):
|
|
13
|
+
export declare function ThemeLayout({ header, footer, children, className, mainClassName, contentClassName, wrapContent, }: ThemeLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -40,6 +40,6 @@ export interface ArticleReaderProps {
|
|
|
40
40
|
* Headless single-article reader — meta, cover, HTML body, optional TOC slot.
|
|
41
41
|
* Theme supplies layout shell, comments, and tag links via render props.
|
|
42
42
|
*/
|
|
43
|
-
export declare function ArticleReader({ article, className, articleClassName, containerId, locale, copyLabel, onCopy, labels, renderTags, renderFooter, children, }: ArticleReaderProps):
|
|
43
|
+
export declare function ArticleReader({ article, className, articleClassName, containerId, locale, copyLabel, onCopy, labels, renderTags, renderFooter, children, }: ArticleReaderProps): import("react/jsx-runtime").JSX.Element;
|
|
44
44
|
export { ArticleToc, HtmlContent, ImageViewer, LocaleTime, parseArticleToc };
|
|
45
45
|
export type { TocItem };
|
|
@@ -16,6 +16,6 @@ export interface ArticleTocProps {
|
|
|
16
16
|
indentStep?: number;
|
|
17
17
|
}
|
|
18
18
|
/** Headless table-of-contents for article pages. */
|
|
19
|
-
export declare function ArticleToc({ items, className, listClassName, itemClassName, activeClassName, maxHeight, title, showTitle, indentStep, }: ArticleTocProps):
|
|
19
|
+
export declare function ArticleToc({ items, className, listClassName, itemClassName, activeClassName, maxHeight, title, showTitle, indentStep, }: ArticleTocProps): import("react/jsx-runtime").JSX.Element | null;
|
|
20
20
|
/** Parse TOC JSON stored on article records. Supports legacy `[level, id, text]` tuples. */
|
|
21
21
|
export declare function parseArticleToc(raw?: string | null): TocItem[];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
export interface HtmlContentProps {
|
|
3
2
|
/** Server-rendered HTML (article body). */
|
|
4
3
|
content?: string;
|
|
@@ -13,4 +12,4 @@ export interface HtmlContentProps {
|
|
|
13
12
|
highlightCode?: boolean;
|
|
14
13
|
}
|
|
15
14
|
/** Render HTML article body with optional code highlight and copy buttons. */
|
|
16
|
-
export declare function HtmlContent({ content, className, copyLabel, copySuccessLabel, onCopy, highlightCode, }: HtmlContentProps):
|
|
15
|
+
export declare function HtmlContent({ content, className, copyLabel, copySuccessLabel, onCopy, highlightCode, }: HtmlContentProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,4 +6,4 @@ export interface ImageProps extends Omit<ImgHTMLAttributes<HTMLImageElement>, 's
|
|
|
6
6
|
size?: ImageVariant;
|
|
7
7
|
}
|
|
8
8
|
/** 按上传变体尺寸渲染 `<img>`,`url` + `size` 外其余属性透传。 */
|
|
9
|
-
export declare function Image({ url, size, alt, ...rest }: ImageProps): import("react").JSX.Element | null;
|
|
9
|
+
export declare function Image({ url, size, alt, ...rest }: ImageProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
export interface LocaleTimeProps {
|
|
3
2
|
date: string | number | Date;
|
|
4
3
|
format?: string;
|
|
@@ -7,4 +6,4 @@ export interface LocaleTimeProps {
|
|
|
7
6
|
locale?: string;
|
|
8
7
|
}
|
|
9
8
|
/** Locale-aware `<time>` — absolute date or relative timeago. */
|
|
10
|
-
export declare function LocaleTime({ date, timeago, format, locale, }: LocaleTimeProps):
|
|
9
|
+
export declare function LocaleTime({ date, timeago, format, locale, }: LocaleTimeProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,4 +5,4 @@ export interface LocaleToggleButtonProps extends Omit<ToolbarIconButtonProps, 'c
|
|
|
5
5
|
onLocaleChange: (locale: string) => void;
|
|
6
6
|
}
|
|
7
7
|
/** Click to cycle locales. Shows zh/en translation bubble icons (like theme sun/moon). */
|
|
8
|
-
export declare function LocaleToggleButton({ locale, locales, onLocaleChange, size, title, ...rest }: LocaleToggleButtonProps): import("react").JSX.Element | null;
|
|
8
|
+
export declare function LocaleToggleButton({ locale, locales, onLocaleChange, size, title, ...rest }: LocaleToggleButtonProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -4,4 +4,4 @@ export interface ThemeToggleButtonProps extends Omit<ToolbarIconButtonProps, 'ch
|
|
|
4
4
|
onToggle: () => void;
|
|
5
5
|
}
|
|
6
6
|
/** Click to switch light/dark. Shows sun in light mode, moon in dark mode. */
|
|
7
|
-
export declare function ThemeToggleButton({ isDark, onToggle, size, ...rest }: ThemeToggleButtonProps): import("react").JSX.Element;
|
|
7
|
+
export declare function ThemeToggleButton({ isDark, onToggle, size, ...rest }: ThemeToggleButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,4 +4,4 @@ export interface ToolbarIconButtonProps extends Omit<ButtonHTMLAttributes<HTMLBu
|
|
|
4
4
|
children: ReactNode;
|
|
5
5
|
size?: number;
|
|
6
6
|
}
|
|
7
|
-
export declare function ToolbarIconButton({ children, className, style, ...rest }: ToolbarIconButtonProps): import("react").JSX.Element;
|
|
7
|
+
export declare function ToolbarIconButton({ children, className, style, ...rest }: ToolbarIconButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -2,16 +2,16 @@ import type { SVGProps } from 'react';
|
|
|
2
2
|
type IconProps = Pick<SVGProps<SVGSVGElement>, 'className'> & {
|
|
3
3
|
size?: number;
|
|
4
4
|
};
|
|
5
|
-
export declare function SunIcon({ size, className }: IconProps): import("react").JSX.Element;
|
|
6
|
-
export declare function MoonIcon({ size, className }: IconProps): import("react").JSX.Element;
|
|
7
|
-
export declare function LanguagesIcon({ size, className }: IconProps): import("react").JSX.Element;
|
|
8
|
-
export declare function SearchIcon({ size, className }: IconProps): import("react").JSX.Element;
|
|
5
|
+
export declare function SunIcon({ size, className }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare function MoonIcon({ size, className }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export declare function LanguagesIcon({ size, className }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function SearchIcon({ size, className }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
/** 中文态:气泡内「中」,右下角「A」。 */
|
|
10
|
-
export declare function LocaleZhToggleIcon(props: IconProps): import("react").JSX.Element;
|
|
10
|
+
export declare function LocaleZhToggleIcon(props: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
11
11
|
/** 英文态:气泡内「A」,右下角「中」。 */
|
|
12
|
-
export declare function LocaleEnToggleIcon(props: IconProps): import("react").JSX.Element;
|
|
12
|
+
export declare function LocaleEnToggleIcon(props: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
/** Active locale — switches between zh/en translation bubble icons. */
|
|
14
14
|
export declare function LocaleActiveIcon({ locale, size, className, }: IconProps & {
|
|
15
15
|
locale: string;
|
|
16
|
-
}): import("react").JSX.Element;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
17
|
export {};
|
|
@@ -10,6 +10,6 @@ export interface LocaleProviderProps {
|
|
|
10
10
|
persistLocale?: boolean;
|
|
11
11
|
onLocaleChange?: (locale: string) => void;
|
|
12
12
|
}
|
|
13
|
-
export declare function LocaleProvider({ locale: initialLocale, locales, messages: initialMessages, catalog, children, persistLocale, onLocaleChange, }: LocaleProviderProps):
|
|
13
|
+
export declare function LocaleProvider({ locale: initialLocale, locales, messages: initialMessages, catalog, children, persistLocale, onLocaleChange, }: LocaleProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
14
14
|
export declare function useLocale(): LocaleContextValue;
|
|
15
15
|
export declare function readPersistedLocale(locales: string[], fallback: string): string;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { ReactPressProviderProps } from './types';
|
|
3
2
|
/** Wraps the theme app with locale + active theme / customizer context. */
|
|
4
|
-
export declare function ReactPressProvider({ locale, locales, messages, catalog, themeId, activeThemeId, mods, isPreview, siteMeta, children, persistLocale, onLocaleChange, }: ReactPressProviderProps):
|
|
3
|
+
export declare function ReactPressProvider({ locale, locales, messages, catalog, themeId, activeThemeId, mods, isPreview, siteMeta, children, persistLocale, onLocaleChange, }: ReactPressProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,7 +6,7 @@ export declare const SiteCatalogContext: React.Context<SiteCatalogContextValue>;
|
|
|
6
6
|
export declare function SiteCatalogProvider({ value, children, }: {
|
|
7
7
|
value: SiteCatalogContextValue;
|
|
8
8
|
children: React.ReactNode;
|
|
9
|
-
}):
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
10
|
export declare function useSiteCatalog(): {
|
|
11
11
|
categories: import("../..").ICategory[];
|
|
12
12
|
tags: import("../..").ITag[];
|
|
@@ -9,7 +9,7 @@ export interface ThemeRuntimeProviderProps {
|
|
|
9
9
|
siteMeta?: ThemeRuntimeContextValue['siteMeta'];
|
|
10
10
|
children: React.ReactNode;
|
|
11
11
|
}
|
|
12
|
-
export declare function ThemeRuntimeProvider({ themeId, activeThemeId, mods, isPreview, siteMeta, children, }: ThemeRuntimeProviderProps):
|
|
12
|
+
export declare function ThemeRuntimeProvider({ themeId, activeThemeId, mods, isPreview, siteMeta, children, }: ThemeRuntimeProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
13
13
|
export declare function useThemeRuntime(): ThemeRuntimeContextValue;
|
|
14
14
|
/** Read a single customizer mod with optional default (from `theme.json` customizer). */
|
|
15
15
|
export declare function useThemeMod(modId: string, defaultValue?: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fecommunity/reactpress-toolkit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-beta.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -79,6 +79,18 @@
|
|
|
79
79
|
"./plugin/dev": {
|
|
80
80
|
"types": "./dist/plugin/dev/index.d.ts",
|
|
81
81
|
"default": "./dist/plugin/dev/index.js"
|
|
82
|
+
},
|
|
83
|
+
"./plugin/extension": {
|
|
84
|
+
"types": "./dist/plugin/extension/index.d.ts",
|
|
85
|
+
"default": "./dist/plugin/extension/index.js"
|
|
86
|
+
},
|
|
87
|
+
"./plugin/server": {
|
|
88
|
+
"types": "./dist/plugin/server/index.d.ts",
|
|
89
|
+
"default": "./dist/plugin/server/index.js"
|
|
90
|
+
},
|
|
91
|
+
"./plugin/node": {
|
|
92
|
+
"types": "./dist/plugin/node.d.ts",
|
|
93
|
+
"default": "./dist/plugin/node.js"
|
|
82
94
|
}
|
|
83
95
|
},
|
|
84
96
|
"peerDependencies": {
|