@bison-lab/payload-core 4.40.0 → 5.0.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 +24 -4
- package/dist/admin.mjs +5 -2
- package/dist/admin.mjs.map +1 -1
- package/dist/{capability-BVDhJV8A.d.mts → capability-CqdYCzG1.d.mts} +17 -7
- package/dist/{capability-BVDhJV8A.d.mts.map → capability-CqdYCzG1.d.mts.map} +1 -1
- package/dist/{capability-DdnN7AHB.mjs → capability-DHPE2kon.mjs} +235 -19
- package/dist/capability-DHPE2kon.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/locale-B6rUVwpg.mjs.map +1 -1
- package/dist/{locale-5z7KTvRJ.d.mts → locale-CTT3nn6T.d.mts} +5 -4
- package/dist/locale-CTT3nn6T.d.mts.map +1 -0
- package/dist/{messages-Bk1uYO3o.mjs → messages-dZV_aAnR.mjs} +2 -2
- package/dist/{messages-Bk1uYO3o.mjs.map → messages-dZV_aAnR.mjs.map} +1 -1
- package/dist/navigation.d.mts +2 -2
- package/dist/og.d.mts +1 -1
- package/dist/{published-CY5PIy5W.d.mts → published-B3etM6X5.d.mts} +2 -2
- package/dist/{published-CY5PIy5W.d.mts.map → published-B3etM6X5.d.mts.map} +1 -1
- package/dist/{published-BC8kg47c.d.mts → published-QDNmDi02.d.mts} +2 -2
- package/dist/{published-BC8kg47c.d.mts.map → published-QDNmDi02.d.mts.map} +1 -1
- package/dist/{strings-Bafwdg67.mjs → strings-Fd7kUCT7.mjs} +4 -4
- package/dist/strings-Fd7kUCT7.mjs.map +1 -0
- package/dist/theme.d.mts +2 -2
- package/dist/translate-messages-cli.mjs +3 -3
- package/dist/translate-messages-cli.mjs.map +1 -1
- package/dist/translate.d.mts +225 -3
- package/dist/translate.d.mts.map +1 -1
- package/dist/translate.mjs +238 -5
- package/dist/translate.mjs.map +1 -1
- package/package.json +7 -9
- package/dist/capability-DdnN7AHB.mjs.map +0 -1
- package/dist/locale-5z7KTvRJ.d.mts.map +0 -1
- package/dist/strings-Bafwdg67.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -33,7 +33,7 @@ lockstep.
|
|
|
33
33
|
| `@bison-lab/payload-core/taxonomy` | `facetField`, `FacetEntry` | Anywhere. What a block config imports to tag content from a taxonomy; no plugin, no React, so a browser bundle can take it (`@bison-lab/payload-blocks` main entry reaches the docs island and Storybook). |
|
|
34
34
|
| `@bison-lab/payload-core/block-thumbnails` | `captureThumbnails`, `thumbnailCss`, `NEUTRAL_THEME`, `thumbnailVersion`; the `bison-block-thumbnails` bin | Node, beside Playwright. What a site's thumbnail script imports; no Payload, no React. |
|
|
35
35
|
| `@bison-lab/payload-core/wireframe` | Deprecated: the 4.15 wireframe generator and the `bison-wireframes` bin | Node. Kept for one release so a site's script keeps working; use `./block-thumbnails`. Goes in the next major. |
|
|
36
|
-
| `@bison-lab/payload-core/translate` | `applyTranslation` / `translation`, the deprecated `autoTranslate`, `anthropicTranslator`, `translateDocument`, `translateStrings`, the settings readers and key helpers, `BisonTranslationMarker`, the test seam (`readTranslateState`, `withTranslator`), the guard and walk helpers; the `bison-translate-messages` bin | Node. What `payload.config.ts` and a seed script import (#278); no React. `@anthropic-ai/sdk` is
|
|
36
|
+
| `@bison-lab/payload-core/translate` | `applyTranslation` / `translation`, the deprecated `autoTranslate`, `anthropicTranslator`, `translateDocument`, `translateStrings`, the settings readers and key helpers, `BisonTranslationMarker`, the languages (`LIBRARY_LOCALES`, `activeLocales`, `inactiveLocaleRedirect`, `activeAlternates`), the `localizeExistingContent` migration and `isLocalizedPath`, the test seam (`readTranslateState`, `withTranslator`), the guard and walk helpers; the `bison-translate-messages` bin | Node. What `payload.config.ts` and a seed script import (#278); no React. `@anthropic-ai/sdk` is a required peer (every site has translation), imported on the first translation. |
|
|
37
37
|
| `@bison-lab/payload-core/admin` | Theme fields, the Roles and Features matrices, the Block library field, Admin nav, the Users Roles checklist, the FAQ Library list, "Translate now" (`TranslateNowMenuItem`) and the Translation key panel (`TranslationKeyPanel`) | Admin. Referenced by import-map string; `generate:importmap` writes it. |
|
|
38
38
|
| `@bison-lab/payload-core/react` | `BlockLibraryIsland`; `ThemePreview` (legacy; Theme has no preview pane) | Client. What a Block library preview route wraps its sample in. |
|
|
39
39
|
|
|
@@ -256,7 +256,9 @@ export async function up({ payload }) {
|
|
|
256
256
|
|
|
257
257
|
**3. Serve the catalogue.** A Next route around `serveFont` from
|
|
258
258
|
`@bison-lab/fonts/server`, listed in `serverExternalPackages`, at the path
|
|
259
|
-
you pass as `fontsBaseUrl` (default `/fonts`)
|
|
259
|
+
you pass as `fontsBaseUrl` (default `/fonts`), with the package's `files/`
|
|
260
|
+
folder in that route's `outputFileTracingIncludes` (see the fonts README;
|
|
261
|
+
without it a deploy answers 500 for every font).
|
|
260
262
|
|
|
261
263
|
**4. Render the published theme in the root layout.**
|
|
262
264
|
|
|
@@ -826,8 +828,9 @@ title and description (and the plugin's share image, its own setting), a
|
|
|
826
828
|
FAQ Library `question`, `answer` and `answerText`, a taxonomy term's
|
|
827
829
|
`name`, Header and Footer link labels, footer section headings and the
|
|
828
830
|
text below the logo, and a Media `alt`. Slugs, links, social URLs and
|
|
829
|
-
settings are shared.
|
|
830
|
-
|
|
831
|
+
settings are shared. Every site has `localization` (the library's
|
|
832
|
+
languages, #297), so these fields live in the `_locales` tables; a site
|
|
833
|
+
coming from one locale runs `localizeExistingContent` once.
|
|
831
834
|
`getNavigation` and `getPublishedIdentity` take the request's `locale` and
|
|
832
835
|
`fallbackLocale` (`LocaleRead`, exported from `./navigation` and
|
|
833
836
|
`./theme`). `src/__tests__/localized.test.ts` lists the localized paths.
|
|
@@ -882,6 +885,23 @@ the translator with `readTranslateState` / `withTranslator`; a test
|
|
|
882
885
|
translator still needs the switch on. See
|
|
883
886
|
[Auto-translation](https://payload.bisonlab.ai/site/auto-translate/).
|
|
884
887
|
|
|
888
|
+
### Languages (#297)
|
|
889
|
+
|
|
890
|
+
`LIBRARY_LOCALES` (English default, Spanish) is the list every site
|
|
891
|
+
carries: `applyTranslation` puts them into `localization` with
|
|
892
|
+
`withLibraryLocales`, keeping a site's own. The ticks on Settings →
|
|
893
|
+
Translation (`languages`, with a server-set `languagesChosen`; until it is
|
|
894
|
+
set the defaults apply, and a site's own declared target locales are the
|
|
895
|
+
defaults) decide which target languages are translated and live.
|
|
896
|
+
`activeLocales(payload)` caches the answer per process
|
|
897
|
+
(`ACTIVE_LOCALES_CACHE_MS`, cleared by a save in the same process) for
|
|
898
|
+
middleware; `inactiveLocaleRedirect` and `activeAlternates` are the 308 and
|
|
899
|
+
the switcher/hreflang filter; `GET /api/translation/locales` serves it to an
|
|
900
|
+
edge runtime. `localizeExistingContent` is the one-to-several locale data
|
|
901
|
+
migration: it runs the generated SQL with every `DROP COLUMN` / `DROP TYPE`
|
|
902
|
+
moved last and each moving column copied into `<table>_locales` first.
|
|
903
|
+
It also sets the default locale on the new `locale` column of `_rels` / `_texts` / `_numbers` rows whose `path` is a localized field (`isLocalizedPath` over the migration's `payload.config`), and stops when such rows exist without it. Postgres only. `pnpm --filter @bison-lab/payload-core test:postgres` runs it against a local Postgres with recorded `migrate:create` output (`src/__tests__/fixtures/localize/`); the normal suite skips it.
|
|
904
|
+
|
|
885
905
|
## No generated types
|
|
886
906
|
|
|
887
907
|
The package cannot import a site's `payload-types`, so the shapes it reads
|
package/dist/admin.mjs
CHANGED
|
@@ -7066,11 +7066,14 @@ function TranslateNowMenuItem({ sourceLocale, targetLocales = [], configured = t
|
|
|
7066
7066
|
const locale = useLocale();
|
|
7067
7067
|
const [busy, setBusy] = useState(false);
|
|
7068
7068
|
const [available, setAvailable] = useState(false);
|
|
7069
|
+
const [languages, setLanguages] = useState(targetLocales);
|
|
7069
7070
|
useEffect(() => {
|
|
7070
7071
|
if (!configured) return;
|
|
7071
7072
|
let cancelled = false;
|
|
7072
7073
|
fetch(`${config.serverURL ?? ""}${config.routes.api}/translation/available`, { credentials: "include" }).then((response) => response.ok ? response.json() : { available: false }).then((body) => {
|
|
7073
|
-
if (
|
|
7074
|
+
if (cancelled) return;
|
|
7075
|
+
setAvailable(body.available === true);
|
|
7076
|
+
if (Array.isArray(body.languages)) setLanguages(body.languages.filter((code) => typeof code === "string"));
|
|
7074
7077
|
}).catch(() => void 0);
|
|
7075
7078
|
return () => {
|
|
7076
7079
|
cancelled = true;
|
|
@@ -7082,7 +7085,7 @@ function TranslateNowMenuItem({ sourceLocale, targetLocales = [], configured = t
|
|
|
7082
7085
|
]);
|
|
7083
7086
|
if (!collectionSlug || !configured || !available) return null;
|
|
7084
7087
|
const viewing = locale && typeof locale === "object" ? locale.code : void 0;
|
|
7085
|
-
const into = viewing && viewing !== sourceLocale &&
|
|
7088
|
+
const into = viewing && viewing !== sourceLocale && languages.includes(viewing) ? viewing : void 0;
|
|
7086
7089
|
async function translate() {
|
|
7087
7090
|
if (!id || busy) return;
|
|
7088
7091
|
setBusy(true);
|