@elytracms/next 0.0.65 → 0.0.67

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 CHANGED
@@ -5,8 +5,8 @@ import { ComponentImplementations, ResolveBinding, RelationTarget } from '@elytr
5
5
  export { ComponentImplementations, RenderAsset } from '@elytracms/core/runtime-renderer';
6
6
  import { ResolvePageResult, ResolvedAsset, Perspective, ContentClient, CacheTags, ContentDocumentSource, ResolvedDocument } from '@elytracms/core/content';
7
7
  export { Perspective } from '@elytracms/core/content';
8
- import { LocaleConfig, Locale, RouteRecord, RedirectRecord, CollectionDef, CmsDocument } from '@elytracms/core/cms-core';
9
- export { CmsDocument, CollectionDef, FieldDef, Locale, LocaleConfig, RedirectRecord, RouteRecord, documentSchema, localeConfigSchema, redirectRecordSchema, routeRecordSchema } from '@elytracms/core/cms-core';
8
+ import { LocaleConfig, Locale, RouteRecord, RedirectRecord, CollectionDef } from '@elytracms/core/cms-core';
9
+ export { CmsDocument, CollectionDef, FieldDef, Locale, LocaleConfig, RedirectRecord, RouteRecord, documentSchema, fallbackHomeRoutes, localeConfigSchema, mergeRouteRecords, redirectRecordSchema, routeRecordSchema } from '@elytracms/core/cms-core';
10
10
  import { ComponentNode } from '@elytracms/core/project-graph';
11
11
  export { ComponentNode } from '@elytracms/core/project-graph';
12
12
  import { AssetRecord, PersistenceAdapter } from '@elytracms/core/persistence';
@@ -359,18 +359,7 @@ interface StaticContentData {
359
359
  */
360
360
  sources?: readonly CanvasDataSource[];
361
361
  }
362
- /**
363
- * Merge stored route records with derived fallback routes (EC-177 gap 2):
364
- * stored records win per pattern+locale; fallback routes only fill patterns
365
- * the stored set does not cover. Never XOR — the first stored route must not
366
- * drop the implicit per-locale home-page fallback (or vice versa).
367
- *
368
- * Coverage rules mirror the router's locale matching (EC-018/019): a stored
369
- * locale-agnostic route (no `locale`) covers its pattern for every locale; a
370
- * locale-specific stored route covers only that locale, so fallbacks for the
371
- * other locales still apply.
372
- */
373
- declare function mergeRouteRecords(stored: readonly RouteRecord[], fallback: readonly RouteRecord[]): RouteRecord[];
362
+
374
363
  /**
375
364
  * Assemble a `ContentSource` from plain prefetched data — the pure half of
376
365
  * {@link createContentSnapshot}, shared with hosts that fetched the data
@@ -949,6 +938,13 @@ interface ElytraImageProps {
949
938
  /** Quality (1–100) forwarded to `next/image`; Next defaults to 75. */
950
939
  quality?: number;
951
940
  className?: string;
941
+ /**
942
+ * Loading strategy forwarded to `next/image` (EC-428/NK-026). `'eager'` opts an
943
+ * image out of lazy-loading without the preload `priority` implies. Next throws
944
+ * on `priority` + `loading='lazy'` together, so {@link ElytraImage} drops `lazy`
945
+ * when `priority` is set (priority wins) — delivery never crashes.
946
+ */
947
+ loading?: 'eager' | 'lazy';
952
948
  /**
953
949
  * Custom `next/image` loader (e.g. from {@link createAssetImageLoader})
954
950
  * when assets sit behind a transforming CDN. Omit for the v1 default:
@@ -1461,14 +1457,7 @@ interface DeliverySnapshotPayload {
1461
1457
  documents: unknown[];
1462
1458
  assets: unknown[];
1463
1459
  }
1464
- /**
1465
- * Implicit fallback route table (EC-187): `/` → the first `page`-collection
1466
- * document (lowest id), once per configured locale. Merged UNDER the stored
1467
- * records. The delivery snapshot is already perspective-filtered server-side,
1468
- * so in draft mode this correctly previews the draft home even when
1469
- * unpublished.
1470
- */
1471
- declare function fallbackHomeRoutes(documents: readonly CmsDocument[], locales: LocaleConfig): RouteRecord[];
1460
+
1472
1461
  /**
1473
1462
  * Assemble a fetched delivery-snapshot payload into a `ContentSource` — the
1474
1463
  * pure half of {@link loadLiveContent}, exported so the parsing/assembly rules
@@ -1547,4 +1536,4 @@ declare function evaluatePreviewRequest(requestUrl: string | URL, expectedToken:
1547
1536
  */
1548
1537
  declare const PACKAGE = "@elytracms/next";
1549
1538
 
1550
- export { type AssetImageLoaderOptions, type BindingPayloads, type CacheWrapper, type CacheWrapperOptions, type CachedEntry, type CanvasCacheOptions, type CanvasContentRequest, type CanvasDataSource, type CanvasPageOutcome, type CanvasPayloadContext, type CanvasPayloadsFactory, CanvasRenderer, type CanvasRendererProps, type CanvasRequestInfo, type CanvasRoute, type CanvasRouteOptions, type CanvasRouteProps, type CanvasSitemapOptions, type CanvasSitemapResult, type ContentSnapshot, type ContentSnapshotOptions, type ContentSource, type CreateCanvasSitemapOptions, type DefineHostComponentsOptions, ELYTRA_HOST_ENV_KEYS, type ElytraHost, type ElytraHostEnv, type ElytraHostImageOptions, type ElytraHostOptions, ElytraImage, type ElytraImageAsset, type ElytraImageProps, type GlobalsConventions, type HostCanvasRouteOptions, type HostComponent, type HostComponents, type LiveContentOptions, type LoadGlobalsOptions, type MaterializeSourcePayloadsInput, type MaterializedSourcePayloads, type NextImagePrimitiveOptions, PACKAGE, type PreviewEvaluation, type PreviewRouteHandlers, type PreviewRouteOptions, REVALIDATE_SIGNATURE_HEADER, type ResolveCanvasPageOptions, type ResolveGlobalsOptions, type ResolvedLink, type ResolvedNavEntry, type ResolvedNavLink, type RevalidateEvaluation, type RevalidatePayload, type RevalidateRouteHandlers, type RevalidateRouteOptions, type SiteGlobals, type SitemapParamsProvider, type SitemapRouteContext, type SitemapSkippedRoute, type SourcePayloadError, type StaticContentData, assembleLiveSource, canvasPageMetadata, canvasSitemapEntries, collectBindingSourceIds, collectionCacheTag, createAssetImageLoader, createBindingResolver, createCanvasRoute, createCanvasSitemap, createContentSnapshot, createElytraHost, createPreviewDisableRoute, createPreviewRoute, createRevalidateRoute, createStaticContentSource, defaultBindingPayloads, defineHostComponents, docCacheTag, elytraHostImage, evaluatePreviewRequest, evaluateRevalidateRequest, fallbackHomeRoutes, firstBlockFullBleed, isSourcePayloadError, loadCachedEntry, loadLiveContent, materializeSourcePayloads, mergeCacheTags, mergeRouteRecords, nextCacheTags, nextImagePrimitive, pathFromSlug, projectSweepTag, resolveCanvasPage, resolveGlobals, resolveHostEnv, resolvePayloadToken, revalidatePayloadSchema, routeCacheTag, safeRedirectTarget, scopeCacheTag, signRevalidateBody, sourcePayloadError, splitLocalePath };
1539
+ export { type AssetImageLoaderOptions, type BindingPayloads, type CacheWrapper, type CacheWrapperOptions, type CachedEntry, type CanvasCacheOptions, type CanvasContentRequest, type CanvasDataSource, type CanvasPageOutcome, type CanvasPayloadContext, type CanvasPayloadsFactory, CanvasRenderer, type CanvasRendererProps, type CanvasRequestInfo, type CanvasRoute, type CanvasRouteOptions, type CanvasRouteProps, type CanvasSitemapOptions, type CanvasSitemapResult, type ContentSnapshot, type ContentSnapshotOptions, type ContentSource, type CreateCanvasSitemapOptions, type DefineHostComponentsOptions, ELYTRA_HOST_ENV_KEYS, type ElytraHost, type ElytraHostEnv, type ElytraHostImageOptions, type ElytraHostOptions, ElytraImage, type ElytraImageAsset, type ElytraImageProps, type GlobalsConventions, type HostCanvasRouteOptions, type HostComponent, type HostComponents, type LiveContentOptions, type LoadGlobalsOptions, type MaterializeSourcePayloadsInput, type MaterializedSourcePayloads, type NextImagePrimitiveOptions, PACKAGE, type PreviewEvaluation, type PreviewRouteHandlers, type PreviewRouteOptions, REVALIDATE_SIGNATURE_HEADER, type ResolveCanvasPageOptions, type ResolveGlobalsOptions, type ResolvedLink, type ResolvedNavEntry, type ResolvedNavLink, type RevalidateEvaluation, type RevalidatePayload, type RevalidateRouteHandlers, type RevalidateRouteOptions, type SiteGlobals, type SitemapParamsProvider, type SitemapRouteContext, type SitemapSkippedRoute, type SourcePayloadError, type StaticContentData, assembleLiveSource, canvasPageMetadata, canvasSitemapEntries, collectBindingSourceIds, collectionCacheTag, createAssetImageLoader, createBindingResolver, createCanvasRoute, createCanvasSitemap, createContentSnapshot, createElytraHost, createPreviewDisableRoute, createPreviewRoute, createRevalidateRoute, createStaticContentSource, defaultBindingPayloads, defineHostComponents, docCacheTag, elytraHostImage, evaluatePreviewRequest, evaluateRevalidateRequest, firstBlockFullBleed, isSourcePayloadError, loadCachedEntry, loadLiveContent, materializeSourcePayloads, mergeCacheTags, nextCacheTags, nextImagePrimitive, pathFromSlug, projectSweepTag, resolveCanvasPage, resolveGlobals, resolveHostEnv, resolvePayloadToken, revalidatePayloadSchema, routeCacheTag, safeRedirectTarget, scopeCacheTag, signRevalidateBody, sourcePayloadError, splitLocalePath };
package/dist/index.js CHANGED
@@ -4,8 +4,8 @@ import { basePrimitives, getImplementation, renderComposition, ImageManifest, se
4
4
  import { isValidElement } from 'react';
5
5
  import { jsx, Fragment } from 'react/jsx-runtime';
6
6
  import { cacheTags, isSectionSourceId, parseCmsSourceQueryConfig, listQueryOfCmsConfig, isDocumentHistory, resolvedAsset, createContentClient, createContentContext } from '@elytracms/core/content';
7
- import { documentKey, splitPath, hierarchyMount, composePath, documentSchema, redirectRecordSchema } from '@elytracms/core/cms-core';
8
- export { documentSchema, localeConfigSchema, redirectRecordSchema, routeRecordSchema } from '@elytracms/core/cms-core';
7
+ import { documentKey, splitPath, hierarchyMount, composePath, mergeRouteRecords, fallbackHomeRoutes, documentSchema, redirectRecordSchema } from '@elytracms/core/cms-core';
8
+ export { documentSchema, fallbackHomeRoutes, localeConfigSchema, mergeRouteRecords, redirectRecordSchema, routeRecordSchema } from '@elytracms/core/cms-core';
9
9
  import { revalidateTag, unstable_cache } from 'next/cache';
10
10
  import { draftMode } from 'next/headers';
11
11
  import { redirect, notFound, permanentRedirect } from 'next/navigation';
@@ -220,23 +220,6 @@ function materializeSourcePayloads(input) {
220
220
  return { payloads, tags };
221
221
  }
222
222
  var DEFAULT_LOCALES = { default: "en", locales: ["en"] };
223
- function patternKey(pattern) {
224
- return "/" + splitPath(pattern).join("/");
225
- }
226
- function mergeRouteRecords(stored, fallback) {
227
- const agnostic = /* @__PURE__ */ new Set();
228
- const localized = /* @__PURE__ */ new Set();
229
- for (const route of stored) {
230
- if (route.locale === void 0) agnostic.add(patternKey(route.pattern));
231
- else localized.add(`${route.locale}|${patternKey(route.pattern)}`);
232
- }
233
- const covered = (route) => {
234
- const key = patternKey(route.pattern);
235
- if (agnostic.has(key)) return true;
236
- return route.locale !== void 0 && localized.has(`${route.locale}|${key}`);
237
- };
238
- return [...stored, ...fallback.filter((route) => !covered(route))];
239
- }
240
223
  function createStaticContentSource(data) {
241
224
  const locales = data.locales ?? DEFAULT_LOCALES;
242
225
  const routes = data.routes ?? [];
@@ -835,12 +818,21 @@ function createRevalidateRoute(options) {
835
818
  }
836
819
  };
837
820
  }
821
+ var LQIP_MAX_EDGE = 24;
822
+ function fitLqipLongEdge(width, height) {
823
+ const scale = Math.min(1, LQIP_MAX_EDGE / Math.max(width, height));
824
+ return { width: Math.max(1, Math.round(width * scale)), height: Math.max(1, Math.round(height * scale)) };
825
+ }
826
+ function scaledLqipBlur(lqip, width, height) {
827
+ const { width: lqipW, height: lqipH } = fitLqipLongEdge(width, height);
828
+ const svg = `<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 ${lqipW * 40} ${lqipH * 40}'><filter id='b' color-interpolation-filters='sRGB'><feGaussianBlur stdDeviation='20'/><feColorMatrix values='1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 100 -1' result='s'/><feFlood x='0' y='0' width='100%' height='100%'/><feComposite operator='out' in='s'/><feComposite in2='SourceGraphic'/><feGaussianBlur stdDeviation='20'/></filter><image width='100%' height='100%' x='0' y='0' preserveAspectRatio='none' style='filter:url(#b)' href='${lqip}'/></svg>`;
829
+ return `data:image/svg+xml;base64,${btoa(svg)}`;
830
+ }
838
831
  function ElytraImage(props) {
839
- const { asset, sizes, priority, quality, className, loader } = props;
832
+ const { asset, sizes, priority, quality, className, loader, loading } = props;
840
833
  if (!asset || asset.url.length === 0) return null;
841
834
  const alt = asset.alt ?? "";
842
835
  const objectPosition = asset.focalPoint ? `${asset.focalPoint.x * 100}% ${asset.focalPoint.y * 100}%` : void 0;
843
- const blur = asset.lqip ? { placeholder: "blur", blurDataURL: asset.lqip } : {};
844
836
  if (asset.width === null || asset.height === null) {
845
837
  return /* @__PURE__ */ jsx(
846
838
  "img",
@@ -853,6 +845,9 @@ function ElytraImage(props) {
853
845
  }
854
846
  );
855
847
  }
848
+ const blurDataURL = asset.lqip == null ? null : asset.lqip.startsWith("data:image/svg") ? asset.lqip : scaledLqipBlur(asset.lqip, asset.width, asset.height);
849
+ const blur = blurDataURL ? { placeholder: "blur", blurDataURL } : {};
850
+ const loadingProp = priority && loading === "lazy" ? void 0 : loading;
856
851
  return /* @__PURE__ */ jsx(
857
852
  NextImage,
858
853
  {
@@ -863,6 +858,7 @@ function ElytraImage(props) {
863
858
  height: asset.height,
864
859
  ...sizes !== void 0 ? { sizes } : {},
865
860
  ...priority !== void 0 ? { priority } : {},
861
+ ...loadingProp !== void 0 ? { loading: loadingProp } : {},
866
862
  ...quality !== void 0 ? { quality } : {},
867
863
  ...className !== void 0 ? { className } : {},
868
864
  ...loader !== void 0 ? { loader } : {},
@@ -903,13 +899,14 @@ function nextImagePrimitive(options = {}) {
903
899
  };
904
900
  }
905
901
  function elytraHostImage(options = {}) {
906
- return ({ asset, alt, className, priority, sizes }) => /* @__PURE__ */ jsx(
902
+ return ({ asset, alt, className, priority, sizes, loading }) => /* @__PURE__ */ jsx(
907
903
  ElytraImage,
908
904
  {
909
905
  asset: { ...asset, alt },
910
906
  ...className !== void 0 ? { className } : {},
911
907
  ...priority ? { priority: true } : {},
912
908
  ...sizes !== void 0 ? { sizes } : {},
909
+ ...loading !== void 0 ? { loading } : {},
913
910
  ...options.loader !== void 0 ? { loader: options.loader } : {},
914
911
  ...options.quality !== void 0 ? { quality: options.quality } : {}
915
912
  }
@@ -989,16 +986,6 @@ function parseSources(rows) {
989
986
  }
990
987
  return sources;
991
988
  }
992
- function fallbackHomeRoutes(documents, locales) {
993
- const homePage = [...documents].filter((doc) => doc.collection === "page").sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0)[0];
994
- if (!homePage) return [];
995
- return locales.locales.map((locale) => ({
996
- id: `r-live-home-${locale}`,
997
- pattern: "/",
998
- locale,
999
- document: { collection: "page", id: homePage.id }
1000
- }));
1001
- }
1002
989
  function assembleLiveSource(payload, options, perspective) {
1003
990
  const locales = options.locales;
1004
991
  const documents = parseDocuments(payload.documents);
@@ -1310,6 +1297,6 @@ function createElytraHost(options) {
1310
1297
  }
1311
1298
  var PACKAGE = "@elytracms/next";
1312
1299
 
1313
- export { CanvasRenderer, ELYTRA_HOST_ENV_KEYS, ElytraImage, PACKAGE, REVALIDATE_SIGNATURE_HEADER, assembleLiveSource, canvasPageMetadata, canvasSitemapEntries, collectBindingSourceIds, collectionCacheTag, createAssetImageLoader, createBindingResolver, createCanvasRoute, createCanvasSitemap, createContentSnapshot, createElytraHost, createPreviewDisableRoute, createPreviewRoute, createRevalidateRoute, createStaticContentSource, defaultBindingPayloads, defineHostComponents, docCacheTag, elytraHostImage, evaluatePreviewRequest, evaluateRevalidateRequest, fallbackHomeRoutes, firstBlockFullBleed, isSourcePayloadError, loadCachedEntry, loadLiveContent, materializeSourcePayloads, mergeCacheTags, mergeRouteRecords, nextCacheTags, nextImagePrimitive, pathFromSlug, projectSweepTag, resolveCanvasPage, resolveGlobals, resolveHostEnv, resolvePayloadToken, revalidatePayloadSchema, routeCacheTag, safeRedirectTarget, scopeCacheTag, signRevalidateBody, sourcePayloadError, splitLocalePath };
1300
+ export { CanvasRenderer, ELYTRA_HOST_ENV_KEYS, ElytraImage, PACKAGE, REVALIDATE_SIGNATURE_HEADER, assembleLiveSource, canvasPageMetadata, canvasSitemapEntries, collectBindingSourceIds, collectionCacheTag, createAssetImageLoader, createBindingResolver, createCanvasRoute, createCanvasSitemap, createContentSnapshot, createElytraHost, createPreviewDisableRoute, createPreviewRoute, createRevalidateRoute, createStaticContentSource, defaultBindingPayloads, defineHostComponents, docCacheTag, elytraHostImage, evaluatePreviewRequest, evaluateRevalidateRequest, firstBlockFullBleed, isSourcePayloadError, loadCachedEntry, loadLiveContent, materializeSourcePayloads, mergeCacheTags, nextCacheTags, nextImagePrimitive, pathFromSlug, projectSweepTag, resolveCanvasPage, resolveGlobals, resolveHostEnv, resolvePayloadToken, revalidatePayloadSchema, routeCacheTag, safeRedirectTarget, scopeCacheTag, signRevalidateBody, sourcePayloadError, splitLocalePath };
1314
1301
  //# sourceMappingURL=index.js.map
1315
1302
  //# sourceMappingURL=index.js.map