@decocms/blocks 7.77.1 → 7.77.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/blocks",
3
- "version": "7.77.1",
3
+ "version": "7.77.2",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"
@@ -540,6 +540,28 @@ describe("shouldDeferSection — admin is the source of truth", () => {
540
540
  expect(shouldDeferSection(section, 0, mkCfg(), false)).toBe(true);
541
541
  });
542
542
 
543
+ it("does NOT defer a Lazy wrapper carrying `loading: \"eager\"`", () => {
544
+ // Fresh's Lazy.tsx short-circuits on this prop and renders the inner
545
+ // section inline, so the wrapper is not a deferral at all. Decofiles
546
+ // migrated from Fresh carry it on the named `Footer` block.
547
+ const section = { ...lazyWrap({ __resolveType: "site/sections/Footer.tsx" }), loading: "eager" };
548
+ expect(shouldDeferSection(section, 0, mkCfg(), false)).toBe(false);
549
+ });
550
+
551
+ it("still defers a Lazy wrapper with `loading: \"lazy\"` or no loading prop", () => {
552
+ const inner = { __resolveType: "site/sections/Hero.tsx" };
553
+ expect(shouldDeferSection({ ...lazyWrap(inner), loading: "lazy" }, 0, mkCfg(), false)).toBe(true);
554
+ expect(shouldDeferSection(lazyWrap(inner), 0, mkCfg(), false)).toBe(true);
555
+ });
556
+
557
+ it("an eager Lazy wrapping a lazy Lazy still defers (inner wins)", () => {
558
+ const nested = {
559
+ ...lazyWrap(lazyWrap({ __resolveType: "site/sections/Hero.tsx" })),
560
+ loading: "eager",
561
+ };
562
+ expect(shouldDeferSection(nested, 0, mkCfg(), false)).toBe(true);
563
+ });
564
+
543
565
  it("renders a non-⚡ section eagerly regardless of position (default Infinity)", () => {
544
566
  const section = { __resolveType: "site/sections/SeoText.tsx" };
545
567
  // Position 5 used to auto-defer with the old foldThreshold=3 — now SSR.
@@ -1639,6 +1639,22 @@ function resolveFinalSectionKey(section: unknown, matcherCtx?: MatcherContext):
1639
1639
  * and return true if a deferral wrapper (Lazy.tsx or Deferred.tsx) is found
1640
1640
  * at any level. This is used by shouldDeferSection to determine if the CMS
1641
1641
  * editor intended this section to be deferred.
1642
+ *
1643
+ * A `Lazy` wrapper carrying `loading: "eager"` is NOT a deferral: on Deco for
1644
+ * Fresh that prop short-circuits the wrapper's own loader, which awaits the
1645
+ * inner section and renders it inline, with no FallbackWrapper —
1646
+ * `website/sections/Rendering/Lazy.tsx`:
1647
+ *
1648
+ * ```ts
1649
+ * const shouldRender = loading === "eager" || shouldForceRender({ … });
1650
+ * if (shouldRender) return { loading: "eager", section: await section() };
1651
+ * ```
1652
+ *
1653
+ * Decofiles migrated from Fresh carry that prop (a named `Footer` block whose
1654
+ * root is `Lazy.tsx` + `loading: "eager"` is the common shape), so ignoring it
1655
+ * turns a section prod server-renders into a skeleton that only materializes
1656
+ * client-side. Honouring it keeps the wrapper's meaning identical on both
1657
+ * runtimes.
1642
1658
  */
1643
1659
  function isCmsDeferralWrapped(section: unknown, matcherCtx?: MatcherContext): boolean {
1644
1660
  if (!section || typeof section !== "object") return false;
@@ -1651,6 +1667,15 @@ function isCmsDeferralWrapped(section: unknown, matcherCtx?: MatcherContext): bo
1651
1667
  if (!rt) return false;
1652
1668
 
1653
1669
  if (rt === WELL_KNOWN_TYPES.LAZY || rt === WELL_KNOWN_TYPES.DEFERRED) {
1670
+ // `loading: "eager"` cancels the deferral at this level. Keep walking
1671
+ // inward so a nested wrapper further down still counts, which is what
1672
+ // Fresh does when it awaits the inner section.
1673
+ if (current.loading === "eager") {
1674
+ const inner = current.section ?? current.sections;
1675
+ if (!inner || typeof inner !== "object" || Array.isArray(inner)) return false;
1676
+ current = inner as Record<string, unknown>;
1677
+ continue;
1678
+ }
1654
1679
  return true;
1655
1680
  }
1656
1681