@elytracms/next 0.0.96 → 0.0.98
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/dist/index.d.ts +16 -1
- package/dist/index.js +40 -11
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1415,7 +1415,16 @@ interface NextImageOptions {
|
|
|
1415
1415
|
*
|
|
1416
1416
|
* Which entry fills the role is decided by core's one registration rule (the first
|
|
1417
1417
|
* valid claimant — `ComponentRegistry.roleComponent('image')`), so the swap can
|
|
1418
|
-
* never land on a different entry than the one the registry resolves.
|
|
1418
|
+
* never land on a different entry than the one the registry resolves.
|
|
1419
|
+
*
|
|
1420
|
+
* It registers the list BEFORE `createElytraHost` resolves the entry through the config
|
|
1421
|
+
* gate, so it must not be the first place a broken list is read (EC-678): the
|
|
1422
|
+
* registration never throws — a malformed manifest is a located finding, and the gate
|
|
1423
|
+
* reads the same registration — so a broken list comes back from here unchanged and the
|
|
1424
|
+
* host's boot throws the gate's LOCATED error (`invalid-config-shape at
|
|
1425
|
+
* components.N.manifest.props.p: …`), the same one `elytra doctor` `config-valid` and the
|
|
1426
|
+
* studio report. (Measured on `6310b7b4`: a prop that was not a field-def threw here,
|
|
1427
|
+
* unlocated, before the gate ran.) Use it on
|
|
1419
1428
|
* the DELIVERY side only (the studio's canvas runs on Vite, where `next/image`
|
|
1420
1429
|
* does not exist) — the scaffold's host seam file does it in one line:
|
|
1421
1430
|
*
|
|
@@ -2014,6 +2023,12 @@ interface DeliverySnapshotPayload {
|
|
|
2014
2023
|
*/
|
|
2015
2024
|
redirectIssues?: unknown[];
|
|
2016
2025
|
documents: unknown[];
|
|
2026
|
+
/**
|
|
2027
|
+
* EC-670 — the stored documents the deployment withheld because it could not unfold them
|
|
2028
|
+
* (`invalid-stored-document` issues: a folded value whose payload does not parse). Absent
|
|
2029
|
+
* from a deployment older than EC-670, whose snapshot rejected altogether instead.
|
|
2030
|
+
*/
|
|
2031
|
+
documentIssues?: unknown[];
|
|
2017
2032
|
assets: unknown[];
|
|
2018
2033
|
}
|
|
2019
2034
|
/**
|
package/dist/index.js
CHANGED
|
@@ -2,9 +2,11 @@ import { registerComponents, createRenderContext, renderDocumentBodyItems, docum
|
|
|
2
2
|
import { isBlockSequenceValueShape } from '@elytracms/core/rich-text';
|
|
3
3
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
4
4
|
import { cacheTags, isDocumentHistory, assetWithoutUrlIssue, assetMetaDriftIssue, resolvedAsset, parseDeliveredDocuments, parseDeliveredRedirects, createContentClient, createContentContext } from '@elytracms/core/content';
|
|
5
|
-
import { DEFAULT_SEO_FIELD, parseLocaleConfig, documentKey, readLiveRedirects, SEO_SUBFIELDS, splitLocalePath, DRAFT_PERSPECTIVE, splitPath, localeUrlPath, variantOf, DRAFT_VARIANT, createRouter, presentationBodyFields } from '@elytracms/core/cms-core';
|
|
5
|
+
import { DEFAULT_SEO_FIELD, parseLocaleConfig, documentKey, readLiveRedirects, SEO_SUBFIELDS, splitLocalePath, DRAFT_PERSPECTIVE, splitPath, localeUrlPath, variantOf, DRAFT_VARIANT, createRouter, deliverCompositionProps, presentationBodyFields } from '@elytracms/core/cms-core';
|
|
6
6
|
export { DRAFT_PERSPECTIVE, documentSchema, localeConfigSchema, localeUrlPath, parseLocaleConfig, redirectRecordSchema, resolveLocale, routeRecordSchema, splitLocalePath, textDirection, variantOf } from '@elytracms/core/cms-core';
|
|
7
7
|
import { assetMetaLens, assetMetaDrift, assetReadLocale, redirectRecordKind } from '@elytracms/core/persistence';
|
|
8
|
+
import { propFieldLookupOf } from '@elytracms/core/component-registry';
|
|
9
|
+
export { defineComponent } from '@elytracms/core/component-registry';
|
|
8
10
|
import { revalidateTag, cacheTag } from 'next/cache';
|
|
9
11
|
import { draftMode } from 'next/headers';
|
|
10
12
|
import { redirect, notFound, permanentRedirect } from 'next/navigation';
|
|
@@ -15,7 +17,6 @@ import { INGEST_MAX_BODY_BYTES, readIngestPayload, INGEST_RECEIVER_PATH, signedI
|
|
|
15
17
|
import NextImage from 'next/image';
|
|
16
18
|
import { normalizeImageSource } from '@elytracms/components';
|
|
17
19
|
import { projectFrontendUrl, resolveProject } from '@elytracms/core/studio-core';
|
|
18
|
-
export { defineComponent } from '@elytracms/core/component-registry';
|
|
19
20
|
export { z } from 'zod';
|
|
20
21
|
|
|
21
22
|
// src/components.ts
|
|
@@ -358,6 +359,28 @@ function presentationFor(source, result) {
|
|
|
358
359
|
const body = presentationBodyFields(collection);
|
|
359
360
|
return body.length > 0 ? { body: [...body] } : void 0;
|
|
360
361
|
}
|
|
362
|
+
function projectPageProps(result, registry) {
|
|
363
|
+
const document = result.document;
|
|
364
|
+
if (!document) return result;
|
|
365
|
+
const lookupManifest = registry ? propFieldLookupOf((id) => registry.getManifest(id)) : void 0;
|
|
366
|
+
const issues = [];
|
|
367
|
+
let projected;
|
|
368
|
+
for (const [name, value] of Object.entries(document)) {
|
|
369
|
+
const delivered = deliverCompositionProps(
|
|
370
|
+
value,
|
|
371
|
+
{ path: [name], collectionId: document.collection, documentId: document.id },
|
|
372
|
+
issues,
|
|
373
|
+
lookupManifest
|
|
374
|
+
);
|
|
375
|
+
if (delivered !== value) (projected ??= { ...document })[name] = delivered;
|
|
376
|
+
}
|
|
377
|
+
if (!projected && issues.length === 0) return result;
|
|
378
|
+
return {
|
|
379
|
+
...result,
|
|
380
|
+
...projected ? { document: projected } : {},
|
|
381
|
+
issues: [...result.issues, ...issues]
|
|
382
|
+
};
|
|
383
|
+
}
|
|
361
384
|
function populatePageRelations(body, client, registry) {
|
|
362
385
|
if (!registry) return { relations: {}, docKeys: [] };
|
|
363
386
|
const refKeys = /* @__PURE__ */ new Set();
|
|
@@ -422,18 +445,19 @@ function populatePageLinks(body, client, registry) {
|
|
|
422
445
|
async function resolveCanvasPage(source, url, perspective, options = {}) {
|
|
423
446
|
const { locale, path } = splitLocalePath(url, source.locales);
|
|
424
447
|
const client = source.client({ perspective, locale });
|
|
425
|
-
const
|
|
426
|
-
if (
|
|
448
|
+
const resolved = client.resolvePage(path);
|
|
449
|
+
if (resolved.status === "redirect" && resolved.redirect) {
|
|
427
450
|
return {
|
|
428
451
|
kind: "redirect",
|
|
429
|
-
target:
|
|
430
|
-
permanent:
|
|
431
|
-
tags:
|
|
452
|
+
target: resolved.redirect.target,
|
|
453
|
+
permanent: resolved.redirect.permanent,
|
|
454
|
+
tags: resolved.tags
|
|
432
455
|
};
|
|
433
456
|
}
|
|
434
|
-
if (
|
|
435
|
-
return { kind: "not-found", tags:
|
|
457
|
+
if (resolved.status !== "ok") {
|
|
458
|
+
return { kind: "not-found", tags: resolved.tags };
|
|
436
459
|
}
|
|
460
|
+
const result = projectPageProps(resolved, options.registry);
|
|
437
461
|
const presentation = presentationFor(source, result);
|
|
438
462
|
const body = pageBodyOf(result, presentation);
|
|
439
463
|
const allAssets = source.assets?.(locale) ?? [];
|
|
@@ -1050,7 +1074,9 @@ function withNextImage(components, options = {}) {
|
|
|
1050
1074
|
const image = registerComponents(list).registry.roleComponent("image");
|
|
1051
1075
|
if (!image) return list;
|
|
1052
1076
|
const implementation = createNextImage(options);
|
|
1053
|
-
return list.map(
|
|
1077
|
+
return list.map(
|
|
1078
|
+
(entry) => entry?.manifest === image ? { manifest: entry.manifest, implementation } : entry
|
|
1079
|
+
);
|
|
1054
1080
|
}
|
|
1055
1081
|
function elytraHostImage(options = {}) {
|
|
1056
1082
|
return ({ asset, alt, className, priority, sizes, loading }) => /* @__PURE__ */ jsx(
|
|
@@ -1111,7 +1137,10 @@ async function runConvexQuery(fetchImpl, convexUrl, path, args) {
|
|
|
1111
1137
|
}
|
|
1112
1138
|
function assembleLiveSource(payload, options, perspective) {
|
|
1113
1139
|
const locales = options.locales;
|
|
1114
|
-
const { documents, issues: documentIssues } = parseDeliveredDocuments(
|
|
1140
|
+
const { documents, issues: documentIssues } = parseDeliveredDocuments(
|
|
1141
|
+
payload.documents,
|
|
1142
|
+
payload.documentIssues ?? []
|
|
1143
|
+
);
|
|
1115
1144
|
const delivered = parseDeliveredRedirects(payload.redirects ?? [], payload.redirectIssues ?? []);
|
|
1116
1145
|
const sourceIssues = [...documentIssues, ...delivered.issues];
|
|
1117
1146
|
const routes = [...options.routes];
|