@aglyn/aglyn-node-renderer 1.0.0-beta.249 → 1.0.0-beta.252

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": "@aglyn/aglyn-node-renderer",
3
- "version": "1.0.0-beta.249",
3
+ "version": "1.0.0-beta.252",
4
4
  "license": "Apache-2.0",
5
5
  "homepage": "https://aglyn.com",
6
6
  "repository": {
@@ -24,12 +24,12 @@
24
24
  "./package.json": "./package.json"
25
25
  },
26
26
  "dependencies": {
27
- "@aglyn/aglyn": "1.0.0-beta.249",
28
- "@aglyn/shared-data-types": "1.0.0-beta.249",
29
- "@aglyn/shared-ui-jsx": "1.0.0-beta.249",
30
- "@aglyn/shared-ui-theme": "1.0.0-beta.249",
31
- "@aglyn/shared-util-tools": "1.0.0-beta.249",
32
- "@aglyn/shared-util-vendor": "1.0.0-beta.249",
27
+ "@aglyn/aglyn": "1.0.0-beta.252",
28
+ "@aglyn/shared-data-types": "1.0.0-beta.252",
29
+ "@aglyn/shared-ui-jsx": "1.0.0-beta.252",
30
+ "@aglyn/shared-ui-theme": "1.0.0-beta.252",
31
+ "@aglyn/shared-util-tools": "1.0.0-beta.252",
32
+ "@aglyn/shared-util-vendor": "1.0.0-beta.252",
33
33
  "mobx-react-lite": "^5.1.0",
34
34
  "react-is": "^19.3.0"
35
35
  },
@@ -68,6 +68,16 @@ import type * as Aglyn from '@aglyn/aglyn';
68
68
  * mounted by a client-side navigation renders at once and can never be left
69
69
  * empty.
70
70
  *
71
+ * ## A scheme change releases it (AGL-3772)
72
+ *
73
+ * The held HTML was styled in the scheme the server rendered, and it cannot
74
+ * follow the theme: nothing in it re-renders. A dark device that sent no
75
+ * `Sec-CH-Prefers-Color-Scheme` hint gets a light server render that turns
76
+ * dark after hydration (see the tenant middleware), and a visitor can flip
77
+ * the scheme from the switcher at any time. Either way, a hold rendered in
78
+ * one scheme is released as soon as the active scheme is another, so every
79
+ * subtree re-renders against the theme the visitor actually has.
80
+ *
71
81
  * ## Interaction before release
72
82
  *
73
83
  * Nothing is released on a press: that would replace the element under the
@@ -92,9 +102,10 @@ export declare function markTreeHydrated(): void;
92
102
  /**
93
103
  * Should this leaf render its root with {@link HELD_SERVER_HTML} instead of
94
104
  * its children? True only from a hydration render of an `eligible` leaf that
95
- * is far from the viewport, until it comes near.
105
+ * is far from the viewport, until it comes near or the active `scheme` stops
106
+ * being the one it was hydrated in.
96
107
  */
97
- export declare function useHeldServerHtml(eligible: boolean, nodeId: string): boolean;
108
+ export declare function useHeldServerHtml(eligible: boolean, nodeId: string, scheme: string): boolean;
98
109
  /**
99
110
  * Is every node in this subtree a component that declared `lazyHydration`?
100
111
  * Cached per node OBJECT: a published page's tree does not change under it,
@@ -17,7 +17,7 @@
17
17
  import { components } from "@aglyn/aglyn/aglyn";
18
18
  import { FEATURE_FLAG } from "@aglyn/aglyn/foundation/constants/shared";
19
19
  import { isNamespacedComponentId } from "@aglyn/aglyn/plugin-manager/plugin-contributions";
20
- import { useCallback, useState, useSyncExternalStore } from "react";
20
+ import { useCallback, useEffect, useState, useSyncExternalStore } from "react";
21
21
  /**
22
22
  * Static subtrees of a published page skip hydration until the visitor
23
23
  * nears them (AGL-3581).
@@ -71,6 +71,16 @@ import { useCallback, useState, useSyncExternalStore } from "react";
71
71
  * mounted by a client-side navigation renders at once and can never be left
72
72
  * empty.
73
73
  *
74
+ * ## A scheme change releases it (AGL-3772)
75
+ *
76
+ * The held HTML was styled in the scheme the server rendered, and it cannot
77
+ * follow the theme: nothing in it re-renders. A dark device that sent no
78
+ * `Sec-CH-Prefers-Color-Scheme` hint gets a light server render that turns
79
+ * dark after hydration (see the tenant middleware), and a visitor can flip
80
+ * the scheme from the switcher at any time. Either way, a hold rendered in
81
+ * one scheme is released as soon as the active scheme is another, so every
82
+ * subtree re-renders against the theme the visitor actually has.
83
+ *
74
84
  * ## Interaction before release
75
85
  *
76
86
  * Nothing is released on a press: that would replace the element under the
@@ -161,9 +171,20 @@ function nearViewport(element) {
161
171
  /**
162
172
  * Should this leaf render its root with {@link HELD_SERVER_HTML} instead of
163
173
  * its children? True only from a hydration render of an `eligible` leaf that
164
- * is far from the viewport, until it comes near.
165
- */ export function useHeldServerHtml(eligible, nodeId) {
166
- const [held] = useState(()=>eligible && !treeHydrated && typeof document !== 'undefined' && holdIfFar(nodeId));
174
+ * is far from the viewport, until it comes near or the active `scheme` stops
175
+ * being the one it was hydrated in.
176
+ */ export function useHeldServerHtml(eligible, nodeId, scheme) {
177
+ // The scheme the held HTML was rendered in, or null for no hold.
178
+ const [heldScheme] = useState(()=>eligible && !treeHydrated && typeof document !== 'undefined' && holdIfFar(nodeId) ? scheme : null);
179
+ const stale = heldScheme !== null && heldScheme !== scheme;
180
+ // Released for good rather than only while the schemes differ: holding
181
+ // again after the children rendered would empty the element.
182
+ useEffect(()=>{
183
+ if (stale) release(nodeId);
184
+ }, [
185
+ stale,
186
+ nodeId
187
+ ]);
167
188
  const subscribe = useCallback((listener)=>{
168
189
  const hold = holds.get(nodeId);
169
190
  if (!hold) return ()=>undefined;
@@ -181,7 +202,7 @@ function nearViewport(element) {
181
202
  var _holds_get;
182
203
  return (_ref = (_holds_get = holds.get(nodeId)) == null ? void 0 : _holds_get.released) != null ? _ref : false;
183
204
  }, ()=>false);
184
- return held && !released;
205
+ return heldScheme !== null && !stale && !released;
185
206
  }
186
207
  const staticSubtrees = new WeakMap();
187
208
  function declares(componentId, flag) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn-node-renderer/src/lib/components/deferred-hydration.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Type-only, for the reason in `stem.tsx`.\nimport type * as Aglyn from '@aglyn/aglyn'\nimport { components } from '@aglyn/aglyn/aglyn'\nimport { FEATURE_FLAG } from '@aglyn/aglyn/foundation/constants/shared'\nimport { isNamespacedComponentId } from '@aglyn/aglyn/plugin-manager/plugin-contributions'\nimport { useCallback, useState, useSyncExternalStore } from 'react'\n\n/**\n * Static subtrees of a published page skip hydration until the visitor\n * nears them (AGL-3581).\n *\n * ## What it does\n *\n * A published page arrives as complete server HTML, and before this every\n * node of it hydrated at once: on `aglyn.com/` that was ~600 elements and the\n * largest single long task of the load. Most of them are copy, images and\n * layout — nothing a visitor operates — so hydrating them buys nothing until\n * the visitor reaches them.\n *\n * While the page hydrates, a static subtree that is not near the viewport\n * renders its root element with `dangerouslySetInnerHTML` in place of its\n * children. React hydrates that root and treats its contents as markup it\n * does not own, so the server's HTML stays exactly as it is — painted,\n * selectable, links working natively — and none of it costs hydration. When\n * the subtree comes within {@link NEAR_VIEWPORT_PX} of the viewport the\n * children render, and React builds them on the client in place of the held\n * markup: the same HTML, now live.\n *\n * ## Why not a Suspense boundary\n *\n * A boundary that suspends during hydration would keep the server HTML and\n * hydrate it in place, which is the textbook mechanism. React 19.2's server\n * renderer outlines every boundary over 500 bytes once the shell passes its\n * progressive chunk size (12.8 KB, not configurable through Next): each one\n * ships in a hidden `<div>` revealed by an inline script on a later animation\n * frame. That is content missing from first paint, a layout shift when it\n * appears, nothing at all in a background tab, and markup a non-rendering\n * crawler reads as hidden. A held root changes nothing in the server HTML.\n *\n * ## Which subtrees\n *\n * Every component in the subtree declares `flags.lazyHydration` — nothing in\n * it responds to the visitor before hydration beyond what HTML does on its\n * own — so the safe answer is the default: an element without the flag keeps\n * its whole ancestry hydrating now. The subtree's ROOT also declares\n * `flags.childrenInRoot`, the contract that lets it take\n * `dangerouslySetInnerHTML` instead of its children.\n *\n * A subtree near the viewport at hydration is not held, and its children\n * hydrate normally — each of them then decides for itself. So a page-wide\n * static wrapper does not hold the whole page: it hydrates, and the sections\n * inside it that are further down are what wait.\n *\n * ## Only during hydration\n *\n * The decision is taken once, when the leaf first renders, and only if that\n * render is part of the tree's first commit (see `treeHydrated`). A subtree\n * mounted by a client-side navigation renders at once and can never be left\n * empty.\n *\n * ## Interaction before release\n *\n * Nothing is released on a press: that would replace the element under the\n * visitor's finger between `pointerdown` and `click`, and the click would be\n * lost. The held HTML already does what a static element does — a link\n * navigates, text selects, focus moves.\n *\n * ## Fails open\n *\n * If the leaf's element is not in the document, or the browser has no\n * `IntersectionObserver`, nothing is held: the worst case is the old\n * behavior.\n */\n\n/** How far outside the viewport a held subtree renders, in pixels. */\nexport const NEAR_VIEWPORT_PX = 600\n\nconst LEAF_ATTRIBUTE = 'data-aglyn'\nconst LEAF_PREFIX = 'leaf:'\n\n/** The empty markup a held root is given, and React leaves alone. */\nexport const HELD_SERVER_HTML = Object.freeze({ __html: '' })\n\ninterface Hold {\n released: boolean\n readonly listeners: Set<() => void>\n}\n\nconst holds = new Map<string, Hold>()\nlet observer: IntersectionObserver | null = null\n\nfunction release(nodeId: string): void {\n const hold = holds.get(nodeId)\n if (!hold || hold.released) return\n hold.released = true\n for (const listener of [...hold.listeners]) listener()\n}\n\nfunction nearViewportObserver(): IntersectionObserver | null {\n if (observer) return observer\n if (typeof IntersectionObserver !== 'function') return null\n observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n if (!entry.isIntersecting) continue\n observer?.unobserve(entry.target)\n const value = entry.target.getAttribute(LEAF_ATTRIBUTE) ?? ''\n release(value.slice(LEAF_PREFIX.length))\n }\n },\n { rootMargin: `${NEAR_VIEWPORT_PX}px 0px` },\n )\n return observer\n}\n\nfunction findLeafElement(nodeId: string): Element | null {\n try {\n // A quoted attribute value needs only its quote and backslash escaped.\n const value = `${LEAF_PREFIX}${nodeId}`.replace(/[\"\\\\]/g, '\\\\$&')\n return document.querySelector(`[${LEAF_ATTRIBUTE}=\"${value}\"]`)\n } catch {\n return null\n }\n}\n\nfunction nearViewport(element: Element): boolean {\n const { top, bottom } = element.getBoundingClientRect()\n return (\n bottom >= -NEAR_VIEWPORT_PX && top <= window.innerHeight + NEAR_VIEWPORT_PX\n )\n}\n\n/**\n * Hold this node's server HTML? Idempotent per node, because React may run a\n * render's state initializer more than once before it commits.\n */\nfunction holdIfFar(nodeId: string): boolean {\n const existing = holds.get(nodeId)\n if (existing) return !existing.released\n const element = findLeafElement(nodeId)\n const io = element ? nearViewportObserver() : null\n if (!element || !io || nearViewport(element)) return false\n holds.set(nodeId, { released: false, listeners: new Set() })\n io.observe(element)\n return true\n}\n\n/**\n * Has the published tree committed its first render? Until it has, every\n * leaf rendering on the client is hydrating. Set from `TreeRoot`'s effect,\n * which runs after the whole first commit — so it is false for every leaf of\n * the hydration and true for anything a later navigation mounts.\n *\n * A module flag rather than `useSyncExternalStore`'s server snapshot: a store\n * whose client and server snapshots differ makes React re-render every\n * component reading it right after hydration, which here would be every leaf\n * on the page — the work this module exists to avoid.\n */\nlet treeHydrated = false\n\n/** Called by `TreeRoot` once its first commit has landed. */\nexport function markTreeHydrated(): void {\n treeHydrated = true\n}\n\n/**\n * Should this leaf render its root with {@link HELD_SERVER_HTML} instead of\n * its children? True only from a hydration render of an `eligible` leaf that\n * is far from the viewport, until it comes near.\n */\nexport function useHeldServerHtml(eligible: boolean, nodeId: string): boolean {\n const [held] = useState(\n () =>\n eligible &&\n !treeHydrated &&\n typeof document !== 'undefined' &&\n holdIfFar(nodeId),\n )\n const subscribe = useCallback(\n (listener: () => void) => {\n const hold = holds.get(nodeId)\n if (!hold) return () => undefined\n hold.listeners.add(listener)\n return () => {\n hold.listeners.delete(listener)\n }\n },\n [nodeId],\n )\n // Both snapshots read `false` for a leaf that holds nothing, so no leaf is\n // re-rendered for having read this store.\n const released = useSyncExternalStore(\n subscribe,\n () => holds.get(nodeId)?.released ?? false,\n () => false,\n )\n return held && !released\n}\n\nconst staticSubtrees = new WeakMap<object, boolean>()\n\nfunction declares(\n componentId: string | undefined,\n flag: 'lazyHydration' | 'childrenInRoot',\n): boolean {\n if (!componentId || isNamespacedComponentId(componentId)) return false\n const value = components.getSchema(componentId)?.flags?.[flag] ?? 0\n return Boolean(value & FEATURE_FLAG.ENABLED)\n}\n\n/**\n * Is every node in this subtree a component that declared `lazyHydration`?\n * Cached per node OBJECT: a published page's tree does not change under it,\n * and the editor, whose tree does, never turns deferral on.\n */\nexport function isLazyHydrationSubtree(node: Aglyn.NodeSchema<any>): boolean {\n const cached = staticSubtrees.get(node)\n if (cached !== undefined) return cached\n let answer = declares(node.componentId, 'lazyHydration')\n if (answer) {\n for (const child of (node.children ?? []) as Aglyn.NodeSchema<any>[]) {\n if (!child || !isLazyHydrationSubtree(child)) {\n answer = false\n break\n }\n }\n }\n staticSubtrees.set(node, answer)\n return answer\n}\n\n/** May this node hold its server HTML: a static subtree under a plain root? */\nexport function mayHoldServerHtml(\n node: Aglyn.NodeSchema<any> | undefined,\n): boolean {\n return Boolean(\n node?.children?.length &&\n declares(node.componentId, 'childrenInRoot') &&\n isLazyHydrationSubtree(node),\n )\n}\n\n/** Test seam: forget every hold, and that the tree ever hydrated. */\nexport function resetDeferredHydrationForTests(): void {\n treeHydrated = false\n holds.clear()\n observer?.disconnect()\n observer = null\n}\n"],"names":["components","FEATURE_FLAG","isNamespacedComponentId","useCallback","useState","useSyncExternalStore","NEAR_VIEWPORT_PX","LEAF_ATTRIBUTE","LEAF_PREFIX","HELD_SERVER_HTML","Object","freeze","__html","holds","Map","observer","release","nodeId","hold","get","released","listener","listeners","nearViewportObserver","IntersectionObserver","entries","entry","isIntersecting","unobserve","target","value","getAttribute","slice","length","rootMargin","findLeafElement","replace","document","querySelector","nearViewport","element","top","bottom","getBoundingClientRect","window","innerHeight","holdIfFar","existing","io","set","Set","observe","treeHydrated","markTreeHydrated","useHeldServerHtml","eligible","held","subscribe","undefined","add","delete","staticSubtrees","WeakMap","declares","componentId","flag","getSchema","flags","Boolean","ENABLED","isLazyHydrationSubtree","node","cached","answer","child","children","mayHoldServerHtml","resetDeferredHydrationForTests","clear","disconnect"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,2CAA2C;AAE3C,SAASA,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,YAAY,QAAQ,2CAA0C;AACvE,SAASC,uBAAuB,QAAQ,mDAAkD;AAC1F,SAASC,WAAW,EAAEC,QAAQ,EAAEC,oBAAoB,QAAQ,QAAO;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiEC,GAED,oEAAoE,GACpE,OAAO,MAAMC,mBAAmB,IAAG;AAEnC,MAAMC,iBAAiB;AACvB,MAAMC,cAAc;AAEpB,mEAAmE,GACnE,OAAO,MAAMC,mBAAmBC,OAAOC,MAAM,CAAC;IAAEC,QAAQ;AAAG,GAAE;AAO7D,MAAMC,QAAQ,IAAIC;AAClB,IAAIC,WAAwC;AAE5C,SAASC,QAAQC,MAAc;IAC7B,MAAMC,OAAOL,MAAMM,GAAG,CAACF;IACvB,IAAI,CAACC,QAAQA,KAAKE,QAAQ,EAAE;IAC5BF,KAAKE,QAAQ,GAAG;IAChB,KAAK,MAAMC,YAAY;WAAIH,KAAKI,SAAS;KAAC,CAAED;AAC9C;AAEA,SAASE;IACP,IAAIR,UAAU,OAAOA;IACrB,IAAI,OAAOS,yBAAyB,YAAY,OAAO;IACvDT,WAAW,IAAIS,qBACb,CAACC;QACC,KAAK,MAAMC,SAASD,QAAS;gBAGbC;YAFd,IAAI,CAACA,MAAMC,cAAc,EAAE;YAC3BZ,4BAAAA,SAAUa,SAAS,CAACF,MAAMG,MAAM;YAChC,MAAMC,SAAQJ,6BAAAA,MAAMG,MAAM,CAACE,YAAY,CAACxB,2BAA1BmB,6BAA6C;YAC3DV,QAAQc,MAAME,KAAK,CAACxB,YA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AKP,WAAW,EAAE,qBAC3BM,uBAAuBC;AAE7B;AAEA,mEAAmE,GACnE,OAAO,SAASM;IACdzB,eAAe;IACfvC,MAAMiE,KAAK;IACX/D,4BAAAA,SAAUgE,UAAU;IACpBhE,WAAW;AACb"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn-node-renderer/src/lib/components/deferred-hydration.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Type-only, for the reason in `stem.tsx`.\nimport type * as Aglyn from '@aglyn/aglyn'\nimport { components } from '@aglyn/aglyn/aglyn'\nimport { FEATURE_FLAG } from '@aglyn/aglyn/foundation/constants/shared'\nimport { isNamespacedComponentId } from '@aglyn/aglyn/plugin-manager/plugin-contributions'\nimport {\n useCallback,\n useEffect,\n useState,\n useSyncExternalStore,\n} from 'react'\n\n/**\n * Static subtrees of a published page skip hydration until the visitor\n * nears them (AGL-3581).\n *\n * ## What it does\n *\n * A published page arrives as complete server HTML, and before this every\n * node of it hydrated at once: on `aglyn.com/` that was ~600 elements and the\n * largest single long task of the load. Most of them are copy, images and\n * layout — nothing a visitor operates — so hydrating them buys nothing until\n * the visitor reaches them.\n *\n * While the page hydrates, a static subtree that is not near the viewport\n * renders its root element with `dangerouslySetInnerHTML` in place of its\n * children. React hydrates that root and treats its contents as markup it\n * does not own, so the server's HTML stays exactly as it is — painted,\n * selectable, links working natively — and none of it costs hydration. When\n * the subtree comes within {@link NEAR_VIEWPORT_PX} of the viewport the\n * children render, and React builds them on the client in place of the held\n * markup: the same HTML, now live.\n *\n * ## Why not a Suspense boundary\n *\n * A boundary that suspends during hydration would keep the server HTML and\n * hydrate it in place, which is the textbook mechanism. React 19.2's server\n * renderer outlines every boundary over 500 bytes once the shell passes its\n * progressive chunk size (12.8 KB, not configurable through Next): each one\n * ships in a hidden `<div>` revealed by an inline script on a later animation\n * frame. That is content missing from first paint, a layout shift when it\n * appears, nothing at all in a background tab, and markup a non-rendering\n * crawler reads as hidden. A held root changes nothing in the server HTML.\n *\n * ## Which subtrees\n *\n * Every component in the subtree declares `flags.lazyHydration` — nothing in\n * it responds to the visitor before hydration beyond what HTML does on its\n * own — so the safe answer is the default: an element without the flag keeps\n * its whole ancestry hydrating now. The subtree's ROOT also declares\n * `flags.childrenInRoot`, the contract that lets it take\n * `dangerouslySetInnerHTML` instead of its children.\n *\n * A subtree near the viewport at hydration is not held, and its children\n * hydrate normally — each of them then decides for itself. So a page-wide\n * static wrapper does not hold the whole page: it hydrates, and the sections\n * inside it that are further down are what wait.\n *\n * ## Only during hydration\n *\n * The decision is taken once, when the leaf first renders, and only if that\n * render is part of the tree's first commit (see `treeHydrated`). A subtree\n * mounted by a client-side navigation renders at once and can never be left\n * empty.\n *\n * ## A scheme change releases it (AGL-3772)\n *\n * The held HTML was styled in the scheme the server rendered, and it cannot\n * follow the theme: nothing in it re-renders. A dark device that sent no\n * `Sec-CH-Prefers-Color-Scheme` hint gets a light server render that turns\n * dark after hydration (see the tenant middleware), and a visitor can flip\n * the scheme from the switcher at any time. Either way, a hold rendered in\n * one scheme is released as soon as the active scheme is another, so every\n * subtree re-renders against the theme the visitor actually has.\n *\n * ## Interaction before release\n *\n * Nothing is released on a press: that would replace the element under the\n * visitor's finger between `pointerdown` and `click`, and the click would be\n * lost. The held HTML already does what a static element does — a link\n * navigates, text selects, focus moves.\n *\n * ## Fails open\n *\n * If the leaf's element is not in the document, or the browser has no\n * `IntersectionObserver`, nothing is held: the worst case is the old\n * behavior.\n */\n\n/** How far outside the viewport a held subtree renders, in pixels. */\nexport const NEAR_VIEWPORT_PX = 600\n\nconst LEAF_ATTRIBUTE = 'data-aglyn'\nconst LEAF_PREFIX = 'leaf:'\n\n/** The empty markup a held root is given, and React leaves alone. */\nexport const HELD_SERVER_HTML = Object.freeze({ __html: '' })\n\ninterface Hold {\n released: boolean\n readonly listeners: Set<() => void>\n}\n\nconst holds = new Map<string, Hold>()\nlet observer: IntersectionObserver | null = null\n\nfunction release(nodeId: string): void {\n const hold = holds.get(nodeId)\n if (!hold || hold.released) return\n hold.released = true\n for (const listener of [...hold.listeners]) listener()\n}\n\nfunction nearViewportObserver(): IntersectionObserver | null {\n if (observer) return observer\n if (typeof IntersectionObserver !== 'function') return null\n observer = new IntersectionObserver(\n (entries) => {\n for (const entry of entries) {\n if (!entry.isIntersecting) continue\n observer?.unobserve(entry.target)\n const value = entry.target.getAttribute(LEAF_ATTRIBUTE) ?? ''\n release(value.slice(LEAF_PREFIX.length))\n }\n },\n { rootMargin: `${NEAR_VIEWPORT_PX}px 0px` },\n )\n return observer\n}\n\nfunction findLeafElement(nodeId: string): Element | null {\n try {\n // A quoted attribute value needs only its quote and backslash escaped.\n const value = `${LEAF_PREFIX}${nodeId}`.replace(/[\"\\\\]/g, '\\\\$&')\n return document.querySelector(`[${LEAF_ATTRIBUTE}=\"${value}\"]`)\n } catch {\n return null\n }\n}\n\nfunction nearViewport(element: Element): boolean {\n const { top, bottom } = element.getBoundingClientRect()\n return (\n bottom >= -NEAR_VIEWPORT_PX && top <= window.innerHeight + NEAR_VIEWPORT_PX\n )\n}\n\n/**\n * Hold this node's server HTML? Idempotent per node, because React may run a\n * render's state initializer more than once before it commits.\n */\nfunction holdIfFar(nodeId: string): boolean {\n const existing = holds.get(nodeId)\n if (existing) return !existing.released\n const element = findLeafElement(nodeId)\n const io = element ? nearViewportObserver() : null\n if (!element || !io || nearViewport(element)) return false\n holds.set(nodeId, { released: false, listeners: new Set() })\n io.observe(element)\n return true\n}\n\n/**\n * Has the published tree committed its first render? Until it has, every\n * leaf rendering on the client is hydrating. Set from `TreeRoot`'s effect,\n * which runs after the whole first commit — so it is false for every leaf of\n * the hydration and true for anything a later navigation mounts.\n *\n * A module flag rather than `useSyncExternalStore`'s server snapshot: a store\n * whose client and server snapshots differ makes React re-render every\n * component reading it right after hydration, which here would be every leaf\n * on the page — the work this module exists to avoid.\n */\nlet treeHydrated = false\n\n/** Called by `TreeRoot` once its first commit has landed. */\nexport function markTreeHydrated(): void {\n treeHydrated = true\n}\n\n/**\n * Should this leaf render its root with {@link HELD_SERVER_HTML} instead of\n * its children? True only from a hydration render of an `eligible` leaf that\n * is far from the viewport, until it comes near or the active `scheme` stops\n * being the one it was hydrated in.\n */\nexport function useHeldServerHtml(\n eligible: boolean,\n nodeId: string,\n scheme: string,\n): boolean {\n // The scheme the held HTML was rendered in, or null for no hold.\n const [heldScheme] = useState(() =>\n eligible &&\n !treeHydrated &&\n typeof document !== 'undefined' &&\n holdIfFar(nodeId)\n ? scheme\n : null,\n )\n const stale = heldScheme !== null && heldScheme !== scheme\n // Released for good rather than only while the schemes differ: holding\n // again after the children rendered would empty the element.\n useEffect(() => {\n if (stale) release(nodeId)\n }, [stale, nodeId])\n const subscribe = useCallback(\n (listener: () => void) => {\n const hold = holds.get(nodeId)\n if (!hold) return () => undefined\n hold.listeners.add(listener)\n return () => {\n hold.listeners.delete(listener)\n }\n },\n [nodeId],\n )\n // Both snapshots read `false` for a leaf that holds nothing, so no leaf is\n // re-rendered for having read this store.\n const released = useSyncExternalStore(\n subscribe,\n () => holds.get(nodeId)?.released ?? false,\n () => false,\n )\n return heldScheme !== null && !stale && !released\n}\n\nconst staticSubtrees = new WeakMap<object, boolean>()\n\nfunction declares(\n componentId: string | undefined,\n flag: 'lazyHydration' | 'childrenInRoot',\n): boolean {\n if (!componentId || isNamespacedComponentId(componentId)) return false\n const value = components.getSchema(componentId)?.flags?.[flag] ?? 0\n return Boolean(value & FEATURE_FLAG.ENABLED)\n}\n\n/**\n * Is every node in this subtree a component that declared `lazyHydration`?\n * Cached per node OBJECT: a published page's tree does not change under it,\n * and the editor, whose tree does, never turns deferral on.\n */\nexport function isLazyHydrationSubtree(node: Aglyn.NodeSchema<any>): boolean {\n const cached = staticSubtrees.get(node)\n if (cached !== undefined) return cached\n let answer = declares(node.componentId, 'lazyHydration')\n if (answer) {\n for (const child of (node.children ?? []) as Aglyn.NodeSchema<any>[]) {\n if (!child || !isLazyHydrationSubtree(child)) {\n answer = false\n break\n }\n }\n }\n staticSubtrees.set(node, answer)\n return answer\n}\n\n/** May this node hold its server HTML: a static subtree under a plain root? */\nexport function mayHoldServerHtml(\n node: Aglyn.NodeSchema<any> | undefined,\n): boolean {\n return Boolean(\n node?.children?.length &&\n declares(node.componentId, 'childrenInRoot') &&\n isLazyHydrationSubtree(node),\n )\n}\n\n/** Test seam: forget every hold, and that the tree ever hydrated. */\nexport function resetDeferredHydrationForTests(): void {\n treeHydrated = false\n holds.clear()\n observer?.disconnect()\n observer = null\n}\n"],"names":["components","FEATURE_FLAG","isNamespacedComponentId","useCallback","useEffect","useState","useSyncExternalStore","NEAR_VIEWPORT_PX","LEAF_ATTRIBUTE","LEAF_PREFIX","HELD_SERVER_HTML","Object","freeze","__html","holds","Map","observer","release","nodeId","hold","get","released","listener","listeners","nearViewportObserver","IntersectionObserver","entries","entry","isIntersecting","unobserve","target","value","getAttribute","slice","length","rootMargin","findLeafElement","replace","document","querySelector","nearViewport","element","top","bottom","getBoundingClientRect","window","innerHeight","holdIfFar","existing","io","set","Set","observe","treeHydrated","markTreeHydrated","useHeldServerHtml","eligible","scheme","heldScheme","stale","subscribe","undefined","add","delete","staticSubtrees","WeakMap","declares","componentId","flag","getSchema","flags","Boolean","ENABLED","isLazyHydrationSubtree","node","cached","answer","child","children","mayHoldServerHtml","resetDeferredHydrationForTests","clear","disconnect"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,2CAA2C;AAE3C,SAASA,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,YAAY,QAAQ,2CAA0C;AACvE,SAASC,uBAAu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EAAmE,GACnE,OAAO,SAASM;IACd3B,eAAe;IACfvC,MAAMmE,KAAK;IACXjE,4BAAAA,SAAUkE,UAAU;IACpBlE,WAAW;AACb"}
@@ -250,7 +250,7 @@ export const Leaf = observer(/*#__PURE__*/ forwardRef((props, ref)=>{
250
250
  // tree that asked for it — the published page — and decided once, on the
251
251
  // leaf's first render. See `deferred-hydration.tsx`.
252
252
  const deferHydration = useContext(DeferredHydrationContext);
253
- const holdServerHtml = useHeldServerHtml(deferHydration && !offForSite && mayHoldServerHtml(node), (_ref3 = node == null ? void 0 : node.$id) != null ? _ref3 : '');
253
+ const holdServerHtml = useHeldServerHtml(deferHydration && !offForSite && mayHoldServerHtml(node), (_ref3 = node == null ? void 0 : node.$id) != null ? _ref3 : '', activeScheme);
254
254
  // Each realm element hydrates in a boundary of its own (AGL-3390), so one
255
255
  // waiting for its bundle holds only itself. Rendered on the server too:
256
256
  // the browser's tree has to have the same boundary to hydrate into.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn-node-renderer/src/lib/components/leaf.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2023 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Type-only, with every value this file reads named below (AGL-2486's rule,\n// applied to the render path's hottest file): a VALUE namespace import of the\n// core barrel is opaque to a bundler — it cannot know which exports are read,\n// so every module the barrel reaches is pinned into the published page's first\n// load.\nimport type * as Aglyn from '@aglyn/aglyn'\nimport { components } from '@aglyn/aglyn/aglyn'\nimport { sanitizeAuthorSx } from '@aglyn/aglyn/app-utils/author-css'\nimport { pinRampedTypographySx } from '@aglyn/aglyn/app-utils/responsive-typography-sx'\nimport {\n NODE_HIDE_IF_PROP,\n NODE_HIDE_UNLESS_PROP,\n} from '@aglyn/aglyn/app-utils/reusable-component-keys'\nimport {\n NODE_ANIMATION_DELAY_PROP,\n NODE_ANIMATION_DURATION_PROP,\n NODE_ANIMATION_EASE_PROP,\n NODE_ANIMATION_PROP,\n NODE_ANIMATION_REPEAT_PROP,\n NODE_ANIMATION_STAGGER_PROP,\n NODE_ANIMATION_STAGGER_STEP_PROP,\n NODE_ANIMATION_TRIGGER_PROP,\n resolveElementAnimation,\n} from '@aglyn/aglyn/app-utils/element-animation'\nimport {\n EnabledPluginsContext,\n isSwitchedOffForRenderedSite,\n} from '@aglyn/aglyn/app-utils/enabled-plugins-context'\nimport { NodeIdentityContext } from '@aglyn/aglyn/app-utils/node-identity'\nimport {\n NODE_COLOR_SCHEME_PROP,\n resolveElementColorScheme,\n} from '@aglyn/aglyn/app-utils/element-color-scheme'\nimport { FEATURE_FLAG } from '@aglyn/aglyn/foundation/constants/shared'\n// Deep import, NOT the barrel: `@aglyn/shared-ui-jsx`'s index re-exports the\n// Pages Router hooks (`next/router`), the inline SVG icon set and the whole\n// ~12,000-module MDI catalog, none of which a rendered node needs. This file\n// is on every published page, so the barrel's reach is that page's reach.\nimport { AglynText } from '@aglyn/shared-ui-jsx/components/aglyn-text'\nimport {\n styled,\n ThemeProvider,\n useSiteSchemeThemes,\n useTheme,\n} from '@aglyn/shared-ui-theme'\nimport { mergeSxProps } from '@aglyn/shared-ui-theme'\nimport { observer } from 'mobx-react-lite'\nimport { isNamespacedComponentId } from '@aglyn/aglyn/plugin-manager/plugin-contributions'\nimport { RealmElementsContext } from '@aglyn/aglyn/app-utils/realm-elements-context'\nimport {\n Children,\n cloneElement,\n forwardRef,\n type HTMLAttributes,\n isValidElement,\n type ReactElement,\n type ReactNode,\n Suspense,\n use,\n useContext,\n} from 'react'\nimport { isValidElementType } from 'react-is'\nimport RendererComponents from '../contexts/renderer-components'\nimport { LeafSxTransformContext } from '../contexts/leaf-sx-transform'\nimport { RealmBoundaryContext } from '../contexts/realm-boundary'\nimport { DeferredHydrationContext } from '../contexts/deferred-hydration'\nimport {\n HELD_SERVER_HTML,\n mayHoldServerHtml,\n useHeldServerHtml,\n} from './deferred-hydration'\nimport { resolvePaletteVarsSx, resolveSchemeSx } from '../utils/scheme-sx'\n\nconst DefaultComponent = styled('div')({})\n\n/** Leaf props with any `children` a resolved prop carried, for a held root. */\nfunction withoutChildren<T extends Record<string, unknown>>(\n props: T,\n): Omit<T, 'children'> {\n const { children: _children, ...rest } = props\n return rest\n}\n\ntype AnyNode = { $id?: unknown; children?: unknown[] } | null | undefined\n\n/**\n * The node `kid` renders the subtree of, when `kid` is the `<Branch>` for\n * the node with `$id` — matched by id, not identity, because a leaf\n * component may render a resolved COPY of the node (the besigner's does)\n * while the Branch carries the original.\n */\nfunction ownBranchNode(\n kid: unknown,\n $id: unknown,\n BranchComponent: unknown,\n): AnyNode {\n if (!isValidElement(kid) || kid.type !== BranchComponent) return undefined\n const branchNode = (kid.props as { node?: AnyNode })?.node\n return branchNode?.$id === $id ? branchNode : undefined\n}\n\n/**\n * A positional component's children: one React child per node child, in the\n * place the `<Branch>` would have taken, with everything else a leaf\n * component put beside it kept (AGL-3660).\n *\n * The published page hands `Leaf` the Branch alone, so this is exactly the\n * per-child Stems. The besigner hands it the Branch plus what it draws around\n * the element's own children — a repeat's preview copies and badge — and,\n * for a repeat, the Branch inside a context provider. Dropping those (which\n * is what this path did before) erased a repeat's preview from any\n * positional element; keeping the Branch whole would undo the very split\n * this path exists for. So a wrapper around the Branch is applied to each\n * child instead, and the extras follow.\n *\n * The children are read off the node the BRANCH carries. The besigner's\n * render copy is a spread of its canvas node, and a canvas node's `children`\n * is a getter on its class that a spread drops — read off the copy, a\n * positional element inside a repeat, or on a record page, had no children.\n *\n * A leaf rendered with no Branch among its children gets its own node's\n * children, as it always did.\n */\nfunction spreadPositionalChildren(\n children: unknown,\n node: AnyNode,\n toStems: (childNodes: unknown[]) => ReactElement[],\n BranchComponent: unknown,\n): ReactNode[] {\n let placed = false\n const out = Children.toArray(children as ReactNode).flatMap((kid) => {\n const own = ownBranchNode(kid, node?.$id, BranchComponent)\n if (own) {\n placed = true\n return toStems(own.children ?? [])\n }\n const wrapped = isValidElement(kid)\n ? ownBranchNode(\n (kid.props as { children?: unknown })?.children,\n node?.$id,\n BranchComponent,\n )\n : undefined\n if (wrapped) {\n placed = true\n return toStems(wrapped.children ?? []).map((stem) =>\n cloneElement(kid as ReactElement, { key: stem.key }, stem),\n )\n }\n return [kid]\n })\n return placed ? out : toStems(node?.children ?? [])\n}\n\nexport interface LeafProps extends HTMLAttributes<any> {\n children?: any\n node: Aglyn.NodeSchema\n sx?: JSX.SxProps\n}\n\nexport const Leaf = observer(\n forwardRef<any, LeafProps>((props, ref) => {\n const { children, node, sx, className, style, ...rest } = props\n\n // Pull sx/className/style out of the node's props so the spreads below\n // can never clobber the merged values composed explicitly afterwards\n // (AGL-569: `props.sx` used to overwrite the node-level sx entirely).\n //\n // The visibility directives (AGL-1314) come out here too. The compose\n // step consumes and strips them, so a rendered page never carries one —\n // but the component EDITOR renders definition nodes ungrafted, on\n // purpose (the author has to see and select the part a page will hide),\n // and there the raw `hideIf` would spread onto the element as an\n // unknown `hideif` DOM attribute.\n const {\n sx: propsSx,\n className: propsClassName,\n style: propsStyle,\n [NODE_HIDE_IF_PROP]: _hideIf,\n [NODE_HIDE_UNLESS_PROP]: _hideUnless,\n // Element animation (AGL-2486): the reserved animation props come\n // out here for the same reason the visibility directives above do —\n // they are directives to the RENDERER, and spreading them onto the\n // element would land `aglynanimation=\"slide-up\"` as an unknown DOM\n // attribute. Destructured rather than `delete`d after the fact so the\n // `none` case is stripped too (it resolves to no animation, but it is\n // still a prop an author saved) and so the props object keeps one\n // shape.\n [NODE_ANIMATION_PROP]: _animation,\n [NODE_ANIMATION_TRIGGER_PROP]: _animationTrigger,\n [NODE_ANIMATION_DURATION_PROP]: _animationDuration,\n [NODE_ANIMATION_DELAY_PROP]: _animationDelay,\n [NODE_ANIMATION_REPEAT_PROP]: _animationRepeat,\n [NODE_ANIMATION_EASE_PROP]: _animationEase,\n [NODE_ANIMATION_STAGGER_PROP]: _animationStagger,\n [NODE_ANIMATION_STAGGER_STEP_PROP]: _animationStaggerStep,\n // A pinned color scheme (AGL-3284) is a directive to the renderer, like\n // the two groups above: consumed below, never handed to the component.\n [NODE_COLOR_SCHEME_PROP]: _colorScheme,\n ...resolvedProps\n } = (node?.resolvedProps ?? node?.props ?? {}) as Record<string, any>\n\n // Resolves to a class, a `data-` attribute and two custom properties; the\n // keyframes themselves live in the tenant's stylesheet, so this costs no\n // JS on any surface. The besigner canvas never ships that stylesheet\n // (same posture as the AGL-562 hidden class), so an author sees the\n // element in its normal, selectable, un-animated state while editing.\n const animation = resolveElementAnimation({\n [NODE_ANIMATION_PROP]: _animation,\n [NODE_ANIMATION_TRIGGER_PROP]: _animationTrigger,\n [NODE_ANIMATION_DURATION_PROP]: _animationDuration,\n [NODE_ANIMATION_DELAY_PROP]: _animationDelay,\n [NODE_ANIMATION_REPEAT_PROP]: _animationRepeat,\n [NODE_ANIMATION_EASE_PROP]: _animationEase,\n [NODE_ANIMATION_STAGGER_PROP]: _animationStagger,\n [NODE_ANIMATION_STAGGER_STEP_PROP]: _animationStaggerStep,\n })\n // A component whose first-party plugin does not run on the rendered site\n // is drawn exactly as an unregistered one is (AGL-3033): the registry is\n // process-global and outlives the site that loaded the bundle, and the\n // site's own browser never loads it. Its schema goes with it, so the\n // void-element and positional flags cannot tell the server a different\n // story from the client either.\n const enabledPlugins = useContext(EnabledPluginsContext)\n const registeredSchema = components.getSchema(node?.componentId)\n const offForSite = isSwitchedOffForRenderedSite(\n registeredSchema?.pluginId,\n enabledPlugins,\n )\n const Factory = offForSite ? undefined : components.getFactory(node?.componentId)\n // A signed marketplace plugin's element (AGL-3390) renders on the server,\n // and the browser registers its component a moment later. Inside the\n // element's own boundary (below) it waits for that load rather than\n // hydrating the server's HTML as an unregistered element, which would\n // not match it.\n const realmElement = isNamespacedComponentId(node?.componentId)\n const realmBoundary = useContext(RealmBoundaryContext)\n const realmLoadFor = useContext(RealmElementsContext)\n if (realmElement && realmBoundary === node?.$id && !Factory && !offForSite) {\n const loading = realmLoadFor?.(node.componentId)\n if (loading) use(loading)\n }\n const Component = isValidElementType(Factory) ? Factory : DefaultComponent\n\n // Self-closing components (AGL-579): a component whose schema flags it\n // selfClosing renders a void DOM element (e.g. Image -> <img>), and React\n // throws during SSR when ANY children value reaches one — even the empty\n // `[undefined, false]` the JSX below always produces. Rendering the whole\n // page 500s off one image node (blog covers, AGL-579), so honor the flag\n // here: no JSX children, and strip a stray `children` prop too.\n const schema = offForSite ? undefined : registeredSchema\n const selfClosing = Boolean(\n (schema?.flags?.selfClosing ?? 0) & FEATURE_FLAG.ENABLED,\n )\n if (selfClosing) delete resolvedProps['children']\n\n const textContent = selfClosing ? null : resolvedProps?.['children']\n\n const mergedClassName =\n [propsClassName, node?.className, className, animation?.className]\n .filter(Boolean)\n .join(' ') || undefined\n // The animation's custom properties go in FIRST so an author who typed\n // `--aglyn-anim-duration` into the Custom CSS tab still wins.\n const mergedStyle =\n animation || propsStyle || style\n ? { ...animation?.style, ...propsStyle, ...style }\n : undefined\n\n // Canvas-only hook (AGL-581): the besigner provides a transform that\n // re-targets viewport media queries at the artboard device width.\n // Undefined everywhere else, keeping the tenant path unchanged.\n const transformSx = useContext(LeafSxTransformContext)\n // The Stem and Branch this tree renders with, for a positional element's\n // children below. Read here rather than through a Consumer so the node's\n // `children` are read in THIS observer's render and tracked by it: a\n // child added on the canvas has to re-render the element it went into.\n const { StemComponent, BranchComponent } = useContext(RendererComponents)\n // Scheme-scoped styles (AGL-588): sites swap a single-mode theme for\n // light/dark (tenant HostThemeProvider, canvas useAglynSiteTheme), so\n // '@scheme dark' sx slices resolve here against the ACTIVE theme's\n // palette mode — the one signal that is correct in both places.\n const theme = useTheme() as {\n palette?: { mode?: string } & Record<string, unknown>\n } | null\n const activeScheme = theme?.palette?.mode === 'dark' ? 'dark' : 'light'\n // \"Always light\" / \"Always dark\" (AGL-3284). When the pinned scheme is not\n // the active one, the element re-renders itself under the site's theme\n // for that scheme, so its OWN sx — not only its descendants' — resolves\n // palette tokens and `@scheme dark` slices for the pinned scheme. The\n // inner render then sees the pinned scheme as active and takes the plain\n // path; the mode check below is what guarantees that, because a site with\n // one theme for both schemes (a single `fallback`) hands back a theme\n // whose mode never changes, and re-wrapping it would never terminate.\n // No provider (an email render, a bare test) means nothing to force.\n // Every hook above runs on both paths, so the early return keeps the\n // hook order stable when an author flips the setting.\n const pinnedScheme = resolveElementColorScheme(_colorScheme)\n const schemeThemes = useSiteSchemeThemes()\n const forcedTheme =\n pinnedScheme && pinnedScheme !== activeScheme && schemeThemes\n ? schemeThemes(pinnedScheme)\n : undefined\n // A static subtree far from the viewport keeps its server HTML through\n // hydration and renders when the visitor nears it (AGL-3581). Only on a\n // tree that asked for it — the published page — and decided once, on the\n // leaf's first render. See `deferred-hydration.tsx`.\n const deferHydration = useContext(DeferredHydrationContext)\n const holdServerHtml = useHeldServerHtml(\n deferHydration && !offForSite && mayHoldServerHtml(node),\n node?.$id ?? '',\n )\n // Each realm element hydrates in a boundary of its own (AGL-3390), so one\n // waiting for its bundle holds only itself. Rendered on the server too:\n // the browser's tree has to have the same boundary to hydrate into.\n if (realmElement && realmBoundary !== node?.$id) {\n return (\n <Suspense fallback={null}>\n <RealmBoundaryContext.Provider value={node?.$id}>\n <Leaf {...props} ref={ref} />\n </RealmBoundaryContext.Provider>\n </Suspense>\n )\n }\n if (forcedTheme && forcedTheme.palette?.mode === pinnedScheme) {\n return (\n <ThemeProvider theme={forcedTheme}>\n <Leaf {...props} ref={ref} />\n </ThemeProvider>\n )\n }\n // MUI array composition: later entries win on key conflicts, so the\n // node-level sx (Styles panel output) overrides props.sx.\n //\n // Palette token references (AGL-1331): the Background Fill field\n // persists a token-bound gradient stop as\n // `var(--mui-palette-primary-main, #00B0FF)`, because `backgroundImage`\n // is NOT one of the sx keys MUI resolves against the palette. They are\n // substituted here, against the site theme, so the canvas cannot pick\n // up the console's `--mui-palette-*` and the tenant (whose theme has no\n // CSS variables at all) still tracks palette changes. Values carrying\n // no reference come back by identity.\n // Author CSS (AGL-1725): `node.sx` is the Styles panel's output, and it\n // is free text — `backgroundImage` is a first-class field and the Custom\n // CSS tab is free-solo, so any property and any value can be typed. On a\n // published site that lands in the visitor's document as a real `url()`,\n // which no input validator and no lint rule can see. Scrubbed HERE, at\n // the last point before the merge, so it also catches values already\n // stored; `sx` and `props.sx` are OUR components' own styles and are\n // deliberately left alone. The scrub is scheme-only and returns its\n // input by identity when nothing is refused, so the overwhelmingly\n // common case (no `url()` at all) costs one walk and no new object.\n // Responsive type ramp: LAST of the three sx passes, and it has to be —\n // it moves a scalar `fontSize` into the `xs` slice so the author's\n // explicit size sorts after the variant's `responsiveFontSizes` at-rules,\n // and the scheme pass above is what collapses a dark-scheme slice down\n // into that same top level. Running it earlier would leave a dark\n // override's font size unpinned.\n //\n // A pinned element paints its scheme's page background and text color\n // (AGL-3284), UNDER every other style so an author's own background wins.\n // Without it an \"Always dark\" band with no background of its own is\n // light text on the light page behind it, and text that sets no color\n // inherits the page's dark body color. `color-scheme` makes the browser's\n // own controls and scrollbars inside the band match. Only a pinned\n // element carries this, so an unpinned one renders exactly as before —\n // and so does a pinned one on a surface with no site themes to pin to.\n const authorSx = sanitizeAuthorSx(node?.sx)\n const composedSx = pinRampedTypographySx(\n resolvePaletteVarsSx(\n resolveSchemeSx(\n pinnedScheme && schemeThemes\n ? mergeSxProps(\n {\n colorScheme: pinnedScheme,\n color: 'text.primary',\n bgcolor: 'background.default',\n } as any,\n sx as any,\n propsSx as any,\n authorSx as any,\n )\n : mergeSxProps(sx as any, propsSx as any, authorSx as any),\n activeScheme,\n ),\n theme?.palette,\n ),\n )\n /**\n * Author visibility — the eye on the hierarchy row.\n *\n * LAST, and deliberately so. It has to override the element's own\n * display, not replace it: an author who hides a Stack laid out with\n * `display: flex` gets that flex back the moment they show it again,\n * because the stored style was never touched. Writing `display: none`\n * into `node.sx` would have destroyed the value it overwrote, and there\n * would be nothing left to restore.\n *\n * The same rule on both surfaces. A hidden element is absent from the\n * published page and from the canvas — \"hidden\" that still renders in the\n * editor is a preview of a page nobody will ever see.\n */\n const mergedSx = node?.hidden\n ? mergeSxProps(composedSx as any, { display: 'none' } as any)\n : composedSx\n\n // Shared leaf attributes; self-closing components must receive NO\n // children at all (AGL-579) — a separate element expression keeps the\n // childless case genuinely childless instead of `[undefined, false]`.\n const leafProps = {\n ref,\n 'data-aglyn': `leaf:${node?.$id}`,\n // Before the spreads: the animation trigger/repeat attributes are ours,\n // but an element that genuinely declared one of these should win.\n ...animation?.attributes,\n ...resolvedProps,\n ...rest,\n className: mergedClassName,\n style: mergedStyle,\n sx: transformSx\n ? (transformSx(mergedSx, node?.$id) as typeof mergedSx)\n : mergedSx,\n }\n\n // Node identity (AGL-659): components get their node id through a\n // context rather than a prop, so a block can look up the server-seeded\n // slice of `pageData` that belongs to IT — two grids on one page have\n // different queries and must not share a seed. Nothing is added to any\n // component's props, so no unknown attribute reaches the DOM.\n // Positional children (AGL-1237): a component that splits its children\n // by index — MUI's Accordion is `[summary, ...rest]` — must receive one\n // React child per node child. The default single `<Branch>` element reads\n // as ONE child to `Children.toArray`, so the first slot swallowed the\n // whole subtree and every later slot got nothing. MUI's Stack counts its\n // children the same way to place its divider between them (AGL-3660).\n const positional = Boolean(\n (schema?.flags?.positionalChildren ?? 0) & FEATURE_FLAG.ENABLED,\n )\n const positionalChildren =\n positional && !holdServerHtml && !selfClosing\n ? spreadPositionalChildren(\n children,\n node as AnyNode,\n (childNodes) =>\n childNodes.map((child: any, key: number) => (\n <StemComponent key={child?.$id ?? key} node={child} />\n )),\n BranchComponent,\n )\n : null\n\n const element = holdServerHtml ? (\n // The root hydrates; its contents stay the server's until released.\n <Component\n {...withoutChildren(leafProps)}\n dangerouslySetInnerHTML={HELD_SERVER_HTML}\n suppressHydrationWarning\n />\n ) : selfClosing ? (\n <Component {...leafProps} />\n ) : positional ? (\n <Component {...leafProps}>\n {positionalChildren}\n {textContent != null && (\n <AglynText>{textContent as any}</AglynText>\n )}\n </Component>\n ) : (\n <Component {...leafProps}>\n {children}\n\n {textContent != null && (\n <AglynText>{textContent as any}</AglynText>\n )}\n </Component>\n )\n\n return (\n <NodeIdentityContext.Provider value={node?.$id ?? ''}>\n {element}\n </NodeIdentityContext.Provider>\n )\n }),\n)\nLeaf.displayName = 'Leaf'\nLeaf['aglyn'] = true\n\nexport default Leaf\n"],"names":["components","sanitizeAuthorSx","pinRampedTypographySx","NODE_HIDE_IF_PROP","NODE_HIDE_UNLESS_PROP","NODE_ANIMATION_DELAY_PROP","NODE_ANIMATION_DURATION_PROP","NODE_ANIMATION_EASE_PROP","NODE_ANIMATION_PROP","NODE_ANIMATION_REPEAT_PROP","NODE_ANIMATION_STAGGER_PROP","NODE_ANIMATION_STAGGER_STEP_PROP","NODE_ANIMATION_TRIGGER_PROP","resolveElementAnimation","EnabledPluginsContext","isSwitchedOffForRenderedSite","NodeIdentityContext","NODE_COLOR_SCHEME_PROP","resolveElementColorScheme","FEATURE_FLAG","AglynText","styled","ThemeProvider","useSiteSchemeThemes","useTheme","mergeSxProps","observer","isNamespacedComponentId","RealmElementsContext","Children","cloneElement","forwardRef","isValidElement","Suspense","use","useContext","isValidElementType","RendererComponents","LeafSxTransformContext","RealmBoundaryContext","DeferredHydrationContext","HELD_SERVER_HTML","mayHoldServerHtml","useHeldServerHtml","resolvePaletteVarsSx","resolveSchemeSx","DefaultComponent","withoutChildren","props","children","_children","rest","ownBranchNode","kid","$id","BranchComponent","type","undefined","branchNode","node","spreadPositionalChildren","toStems","placed","out","toArray","flatMap","own","wrapped","map","stem","key","Leaf","ref","schema","theme","forcedTheme","sx","className","style","resolvedProps","propsSx","propsClassName","propsStyle","_hideIf","_hideUnless","_animation","_animationTrigger","_animationDuration","_animationDelay","_animationRepeat","_animationEase","_animationStagger","_animationStaggerStep","_colorScheme","animation","enabledPlugins","registeredSchema","getSchema","componentId","offForSite","pluginId","Factory","getFactory","realmElement","realmBoundary","realmLoadFor","loading","Component","selfClosing","Boolean","flags","ENABLED","textContent","mergedClassName","filter","join","mergedStyle","transformSx","StemComponent","activeScheme","palette","mode","pinnedScheme","schemeThemes","deferHydration","holdServerHtml","fallback","Provider","value","authorSx","composedSx","colorScheme","color","bgcolor","mergedSx","hidden","display","leafProps","attributes","positional","positionalChildren","childNodes","child","element","dangerouslySetInnerHTML","suppressHydrationWarning","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,4EAA4E;AAC5E,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,QAAQ;;;;;AAER,SAASA,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,gBAAgB,QAAQ,oCAAmC;AACpE,SAASC,qBAAqB,QAAQ,kDAAiD;AACvF,SACEC,iBAAiB,EACjBC,qBAAqB,QAChB,iDAAgD;AACvD,SACEC,yBAAyB,EACzBC,4BAA4B,EAC5BC,wBAAwB,EACxBC,mBAAmB,EACnBC,0BAA0B,EAC1BC,2BAA2B,EAC3BC,gCAAgC,EAChCC,2BAA2B,EAC3BC,uBAAuB,QAClB,2CAA0C;AACjD,SACEC,qBAAqB,EACrBC,4BAA4B,QACvB,iDAAgD;AACvD,SAASC,mBAAmB,QAAQ,uCAAsC;AAC1E,SACEC,sBAAsB,EACtBC,yBAAyB,QACpB,8CAA6C;AACpD,SAASC,YAAY,QAAQ,2CAA0C;AACvE,6EAA6E;AAC7E,4EAA4E;AAC5E,6EAA6E;AAC7E,0EAA0E;AAC1E,SAASC,SAAS,QAAQ,6CAA4C;AACtE,SACEC,MAAM,EACNC,aAAa,EACbC,mBAAmB,EACnBC,QAAQ,QACH,yBAAwB;AAC/B,SAASC,YAAY,QAAQ,yBAAwB;AACrD,SAASC,QAAQ,QAAQ,kBAAiB;A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AA,iBAAAA,OAAQqC,KAAK,qBAAbrC,eAAemE,kBAAkB,oBAAI,KAAKzH,aAAa4F,OAAO;IAEjE,MAAM6B,qBACJD,cAAc,CAACd,kBAAkB,CAACjB,cAC9BhD,yBACEX,UACAU,MACA,CAACkF,aACCA,WAAWzE,GAAG,CAAC,CAAC0E,OAAYxE;;iCAC1B,KAACgD;gBAAsC3D,MAAMmF;uBAAzBA,yBAAAA,MAAOxF,GAAG,mBAAIgB;YAEtCf,mBAEF;IAEN,MAAMwF,UAAUlB,iBACd,oEAAoE;kBACpE,KAAClB,wBACK5D,gBAAgB0F;QACpBO,yBAAyBvG;QACzBwG,wBAAwB;UAExBrC,4BACF,KAACD,wBAAc8B,cACbE,2BACF,MAAChC,wBAAc8B;;YACZG;YACA5B,eAAe,sBACd,KAAC5F;0BAAW4F;;;wBAIhB,MAACL,wBAAc8B;;YACZxF;YAEA+D,eAAe,sBACd,KAAC5F;0BAAW4F;;;;IAKlB,qBACE,KAAChG,oBAAoB+G,QAAQ;QAACC,KAAK,WAAErE,wBAAAA,KAAML,GAAG,oBAAI;kBAC/CyF;;AAGP,IACD;AACDxE,KAAK2E,WAAW,GAAG;AACnB3E,IAAI,CAAC,QAAQ,GAAG;AAEhB,eAAeA,KAAI"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn-node-renderer/src/lib/components/leaf.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2023 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n// Type-only, with every value this file reads named below (AGL-2486's rule,\n// applied to the render path's hottest file): a VALUE namespace import of the\n// core barrel is opaque to a bundler — it cannot know which exports are read,\n// so every module the barrel reaches is pinned into the published page's first\n// load.\nimport type * as Aglyn from '@aglyn/aglyn'\nimport { components } from '@aglyn/aglyn/aglyn'\nimport { sanitizeAuthorSx } from '@aglyn/aglyn/app-utils/author-css'\nimport { pinRampedTypographySx } from '@aglyn/aglyn/app-utils/responsive-typography-sx'\nimport {\n NODE_HIDE_IF_PROP,\n NODE_HIDE_UNLESS_PROP,\n} from '@aglyn/aglyn/app-utils/reusable-component-keys'\nimport {\n NODE_ANIMATION_DELAY_PROP,\n NODE_ANIMATION_DURATION_PROP,\n NODE_ANIMATION_EASE_PROP,\n NODE_ANIMATION_PROP,\n NODE_ANIMATION_REPEAT_PROP,\n NODE_ANIMATION_STAGGER_PROP,\n NODE_ANIMATION_STAGGER_STEP_PROP,\n NODE_ANIMATION_TRIGGER_PROP,\n resolveElementAnimation,\n} from '@aglyn/aglyn/app-utils/element-animation'\nimport {\n EnabledPluginsContext,\n isSwitchedOffForRenderedSite,\n} from '@aglyn/aglyn/app-utils/enabled-plugins-context'\nimport { NodeIdentityContext } from '@aglyn/aglyn/app-utils/node-identity'\nimport {\n NODE_COLOR_SCHEME_PROP,\n resolveElementColorScheme,\n} from '@aglyn/aglyn/app-utils/element-color-scheme'\nimport { FEATURE_FLAG } from '@aglyn/aglyn/foundation/constants/shared'\n// Deep import, NOT the barrel: `@aglyn/shared-ui-jsx`'s index re-exports the\n// Pages Router hooks (`next/router`), the inline SVG icon set and the whole\n// ~12,000-module MDI catalog, none of which a rendered node needs. This file\n// is on every published page, so the barrel's reach is that page's reach.\nimport { AglynText } from '@aglyn/shared-ui-jsx/components/aglyn-text'\nimport {\n styled,\n ThemeProvider,\n useSiteSchemeThemes,\n useTheme,\n} from '@aglyn/shared-ui-theme'\nimport { mergeSxProps } from '@aglyn/shared-ui-theme'\nimport { observer } from 'mobx-react-lite'\nimport { isNamespacedComponentId } from '@aglyn/aglyn/plugin-manager/plugin-contributions'\nimport { RealmElementsContext } from '@aglyn/aglyn/app-utils/realm-elements-context'\nimport {\n Children,\n cloneElement,\n forwardRef,\n type HTMLAttributes,\n isValidElement,\n type ReactElement,\n type ReactNode,\n Suspense,\n use,\n useContext,\n} from 'react'\nimport { isValidElementType } from 'react-is'\nimport RendererComponents from '../contexts/renderer-components'\nimport { LeafSxTransformContext } from '../contexts/leaf-sx-transform'\nimport { RealmBoundaryContext } from '../contexts/realm-boundary'\nimport { DeferredHydrationContext } from '../contexts/deferred-hydration'\nimport {\n HELD_SERVER_HTML,\n mayHoldServerHtml,\n useHeldServerHtml,\n} from './deferred-hydration'\nimport { resolvePaletteVarsSx, resolveSchemeSx } from '../utils/scheme-sx'\n\nconst DefaultComponent = styled('div')({})\n\n/** Leaf props with any `children` a resolved prop carried, for a held root. */\nfunction withoutChildren<T extends Record<string, unknown>>(\n props: T,\n): Omit<T, 'children'> {\n const { children: _children, ...rest } = props\n return rest\n}\n\ntype AnyNode = { $id?: unknown; children?: unknown[] } | null | undefined\n\n/**\n * The node `kid` renders the subtree of, when `kid` is the `<Branch>` for\n * the node with `$id` — matched by id, not identity, because a leaf\n * component may render a resolved COPY of the node (the besigner's does)\n * while the Branch carries the original.\n */\nfunction ownBranchNode(\n kid: unknown,\n $id: unknown,\n BranchComponent: unknown,\n): AnyNode {\n if (!isValidElement(kid) || kid.type !== BranchComponent) return undefined\n const branchNode = (kid.props as { node?: AnyNode })?.node\n return branchNode?.$id === $id ? branchNode : undefined\n}\n\n/**\n * A positional component's children: one React child per node child, in the\n * place the `<Branch>` would have taken, with everything else a leaf\n * component put beside it kept (AGL-3660).\n *\n * The published page hands `Leaf` the Branch alone, so this is exactly the\n * per-child Stems. The besigner hands it the Branch plus what it draws around\n * the element's own children — a repeat's preview copies and badge — and,\n * for a repeat, the Branch inside a context provider. Dropping those (which\n * is what this path did before) erased a repeat's preview from any\n * positional element; keeping the Branch whole would undo the very split\n * this path exists for. So a wrapper around the Branch is applied to each\n * child instead, and the extras follow.\n *\n * The children are read off the node the BRANCH carries. The besigner's\n * render copy is a spread of its canvas node, and a canvas node's `children`\n * is a getter on its class that a spread drops — read off the copy, a\n * positional element inside a repeat, or on a record page, had no children.\n *\n * A leaf rendered with no Branch among its children gets its own node's\n * children, as it always did.\n */\nfunction spreadPositionalChildren(\n children: unknown,\n node: AnyNode,\n toStems: (childNodes: unknown[]) => ReactElement[],\n BranchComponent: unknown,\n): ReactNode[] {\n let placed = false\n const out = Children.toArray(children as ReactNode).flatMap((kid) => {\n const own = ownBranchNode(kid, node?.$id, BranchComponent)\n if (own) {\n placed = true\n return toStems(own.children ?? [])\n }\n const wrapped = isValidElement(kid)\n ? ownBranchNode(\n (kid.props as { children?: unknown })?.children,\n node?.$id,\n BranchComponent,\n )\n : undefined\n if (wrapped) {\n placed = true\n return toStems(wrapped.children ?? []).map((stem) =>\n cloneElement(kid as ReactElement, { key: stem.key }, stem),\n )\n }\n return [kid]\n })\n return placed ? out : toStems(node?.children ?? [])\n}\n\nexport interface LeafProps extends HTMLAttributes<any> {\n children?: any\n node: Aglyn.NodeSchema\n sx?: JSX.SxProps\n}\n\nexport const Leaf = observer(\n forwardRef<any, LeafProps>((props, ref) => {\n const { children, node, sx, className, style, ...rest } = props\n\n // Pull sx/className/style out of the node's props so the spreads below\n // can never clobber the merged values composed explicitly afterwards\n // (AGL-569: `props.sx` used to overwrite the node-level sx entirely).\n //\n // The visibility directives (AGL-1314) come out here too. The compose\n // step consumes and strips them, so a rendered page never carries one —\n // but the component EDITOR renders definition nodes ungrafted, on\n // purpose (the author has to see and select the part a page will hide),\n // and there the raw `hideIf` would spread onto the element as an\n // unknown `hideif` DOM attribute.\n const {\n sx: propsSx,\n className: propsClassName,\n style: propsStyle,\n [NODE_HIDE_IF_PROP]: _hideIf,\n [NODE_HIDE_UNLESS_PROP]: _hideUnless,\n // Element animation (AGL-2486): the reserved animation props come\n // out here for the same reason the visibility directives above do —\n // they are directives to the RENDERER, and spreading them onto the\n // element would land `aglynanimation=\"slide-up\"` as an unknown DOM\n // attribute. Destructured rather than `delete`d after the fact so the\n // `none` case is stripped too (it resolves to no animation, but it is\n // still a prop an author saved) and so the props object keeps one\n // shape.\n [NODE_ANIMATION_PROP]: _animation,\n [NODE_ANIMATION_TRIGGER_PROP]: _animationTrigger,\n [NODE_ANIMATION_DURATION_PROP]: _animationDuration,\n [NODE_ANIMATION_DELAY_PROP]: _animationDelay,\n [NODE_ANIMATION_REPEAT_PROP]: _animationRepeat,\n [NODE_ANIMATION_EASE_PROP]: _animationEase,\n [NODE_ANIMATION_STAGGER_PROP]: _animationStagger,\n [NODE_ANIMATION_STAGGER_STEP_PROP]: _animationStaggerStep,\n // A pinned color scheme (AGL-3284) is a directive to the renderer, like\n // the two groups above: consumed below, never handed to the component.\n [NODE_COLOR_SCHEME_PROP]: _colorScheme,\n ...resolvedProps\n } = (node?.resolvedProps ?? node?.props ?? {}) as Record<string, any>\n\n // Resolves to a class, a `data-` attribute and two custom properties; the\n // keyframes themselves live in the tenant's stylesheet, so this costs no\n // JS on any surface. The besigner canvas never ships that stylesheet\n // (same posture as the AGL-562 hidden class), so an author sees the\n // element in its normal, selectable, un-animated state while editing.\n const animation = resolveElementAnimation({\n [NODE_ANIMATION_PROP]: _animation,\n [NODE_ANIMATION_TRIGGER_PROP]: _animationTrigger,\n [NODE_ANIMATION_DURATION_PROP]: _animationDuration,\n [NODE_ANIMATION_DELAY_PROP]: _animationDelay,\n [NODE_ANIMATION_REPEAT_PROP]: _animationRepeat,\n [NODE_ANIMATION_EASE_PROP]: _animationEase,\n [NODE_ANIMATION_STAGGER_PROP]: _animationStagger,\n [NODE_ANIMATION_STAGGER_STEP_PROP]: _animationStaggerStep,\n })\n // A component whose first-party plugin does not run on the rendered site\n // is drawn exactly as an unregistered one is (AGL-3033): the registry is\n // process-global and outlives the site that loaded the bundle, and the\n // site's own browser never loads it. Its schema goes with it, so the\n // void-element and positional flags cannot tell the server a different\n // story from the client either.\n const enabledPlugins = useContext(EnabledPluginsContext)\n const registeredSchema = components.getSchema(node?.componentId)\n const offForSite = isSwitchedOffForRenderedSite(\n registeredSchema?.pluginId,\n enabledPlugins,\n )\n const Factory = offForSite ? undefined : components.getFactory(node?.componentId)\n // A signed marketplace plugin's element (AGL-3390) renders on the server,\n // and the browser registers its component a moment later. Inside the\n // element's own boundary (below) it waits for that load rather than\n // hydrating the server's HTML as an unregistered element, which would\n // not match it.\n const realmElement = isNamespacedComponentId(node?.componentId)\n const realmBoundary = useContext(RealmBoundaryContext)\n const realmLoadFor = useContext(RealmElementsContext)\n if (realmElement && realmBoundary === node?.$id && !Factory && !offForSite) {\n const loading = realmLoadFor?.(node.componentId)\n if (loading) use(loading)\n }\n const Component = isValidElementType(Factory) ? Factory : DefaultComponent\n\n // Self-closing components (AGL-579): a component whose schema flags it\n // selfClosing renders a void DOM element (e.g. Image -> <img>), and React\n // throws during SSR when ANY children value reaches one — even the empty\n // `[undefined, false]` the JSX below always produces. Rendering the whole\n // page 500s off one image node (blog covers, AGL-579), so honor the flag\n // here: no JSX children, and strip a stray `children` prop too.\n const schema = offForSite ? undefined : registeredSchema\n const selfClosing = Boolean(\n (schema?.flags?.selfClosing ?? 0) & FEATURE_FLAG.ENABLED,\n )\n if (selfClosing) delete resolvedProps['children']\n\n const textContent = selfClosing ? null : resolvedProps?.['children']\n\n const mergedClassName =\n [propsClassName, node?.className, className, animation?.className]\n .filter(Boolean)\n .join(' ') || undefined\n // The animation's custom properties go in FIRST so an author who typed\n // `--aglyn-anim-duration` into the Custom CSS tab still wins.\n const mergedStyle =\n animation || propsStyle || style\n ? { ...animation?.style, ...propsStyle, ...style }\n : undefined\n\n // Canvas-only hook (AGL-581): the besigner provides a transform that\n // re-targets viewport media queries at the artboard device width.\n // Undefined everywhere else, keeping the tenant path unchanged.\n const transformSx = useContext(LeafSxTransformContext)\n // The Stem and Branch this tree renders with, for a positional element's\n // children below. Read here rather than through a Consumer so the node's\n // `children` are read in THIS observer's render and tracked by it: a\n // child added on the canvas has to re-render the element it went into.\n const { StemComponent, BranchComponent } = useContext(RendererComponents)\n // Scheme-scoped styles (AGL-588): sites swap a single-mode theme for\n // light/dark (tenant HostThemeProvider, canvas useAglynSiteTheme), so\n // '@scheme dark' sx slices resolve here against the ACTIVE theme's\n // palette mode — the one signal that is correct in both places.\n const theme = useTheme() as {\n palette?: { mode?: string } & Record<string, unknown>\n } | null\n const activeScheme = theme?.palette?.mode === 'dark' ? 'dark' : 'light'\n // \"Always light\" / \"Always dark\" (AGL-3284). When the pinned scheme is not\n // the active one, the element re-renders itself under the site's theme\n // for that scheme, so its OWN sx — not only its descendants' — resolves\n // palette tokens and `@scheme dark` slices for the pinned scheme. The\n // inner render then sees the pinned scheme as active and takes the plain\n // path; the mode check below is what guarantees that, because a site with\n // one theme for both schemes (a single `fallback`) hands back a theme\n // whose mode never changes, and re-wrapping it would never terminate.\n // No provider (an email render, a bare test) means nothing to force.\n // Every hook above runs on both paths, so the early return keeps the\n // hook order stable when an author flips the setting.\n const pinnedScheme = resolveElementColorScheme(_colorScheme)\n const schemeThemes = useSiteSchemeThemes()\n const forcedTheme =\n pinnedScheme && pinnedScheme !== activeScheme && schemeThemes\n ? schemeThemes(pinnedScheme)\n : undefined\n // A static subtree far from the viewport keeps its server HTML through\n // hydration and renders when the visitor nears it (AGL-3581). Only on a\n // tree that asked for it — the published page — and decided once, on the\n // leaf's first render. See `deferred-hydration.tsx`.\n const deferHydration = useContext(DeferredHydrationContext)\n const holdServerHtml = useHeldServerHtml(\n deferHydration && !offForSite && mayHoldServerHtml(node),\n node?.$id ?? '',\n activeScheme,\n )\n // Each realm element hydrates in a boundary of its own (AGL-3390), so one\n // waiting for its bundle holds only itself. Rendered on the server too:\n // the browser's tree has to have the same boundary to hydrate into.\n if (realmElement && realmBoundary !== node?.$id) {\n return (\n <Suspense fallback={null}>\n <RealmBoundaryContext.Provider value={node?.$id}>\n <Leaf {...props} ref={ref} />\n </RealmBoundaryContext.Provider>\n </Suspense>\n )\n }\n if (forcedTheme && forcedTheme.palette?.mode === pinnedScheme) {\n return (\n <ThemeProvider theme={forcedTheme}>\n <Leaf {...props} ref={ref} />\n </ThemeProvider>\n )\n }\n // MUI array composition: later entries win on key conflicts, so the\n // node-level sx (Styles panel output) overrides props.sx.\n //\n // Palette token references (AGL-1331): the Background Fill field\n // persists a token-bound gradient stop as\n // `var(--mui-palette-primary-main, #00B0FF)`, because `backgroundImage`\n // is NOT one of the sx keys MUI resolves against the palette. They are\n // substituted here, against the site theme, so the canvas cannot pick\n // up the console's `--mui-palette-*` and the tenant (whose theme has no\n // CSS variables at all) still tracks palette changes. Values carrying\n // no reference come back by identity.\n // Author CSS (AGL-1725): `node.sx` is the Styles panel's output, and it\n // is free text — `backgroundImage` is a first-class field and the Custom\n // CSS tab is free-solo, so any property and any value can be typed. On a\n // published site that lands in the visitor's document as a real `url()`,\n // which no input validator and no lint rule can see. Scrubbed HERE, at\n // the last point before the merge, so it also catches values already\n // stored; `sx` and `props.sx` are OUR components' own styles and are\n // deliberately left alone. The scrub is scheme-only and returns its\n // input by identity when nothing is refused, so the overwhelmingly\n // common case (no `url()` at all) costs one walk and no new object.\n // Responsive type ramp: LAST of the three sx passes, and it has to be —\n // it moves a scalar `fontSize` into the `xs` slice so the author's\n // explicit size sorts after the variant's `responsiveFontSizes` at-rules,\n // and the scheme pass above is what collapses a dark-scheme slice down\n // into that same top level. Running it earlier would leave a dark\n // override's font size unpinned.\n //\n // A pinned element paints its scheme's page background and text color\n // (AGL-3284), UNDER every other style so an author's own background wins.\n // Without it an \"Always dark\" band with no background of its own is\n // light text on the light page behind it, and text that sets no color\n // inherits the page's dark body color. `color-scheme` makes the browser's\n // own controls and scrollbars inside the band match. Only a pinned\n // element carries this, so an unpinned one renders exactly as before —\n // and so does a pinned one on a surface with no site themes to pin to.\n const authorSx = sanitizeAuthorSx(node?.sx)\n const composedSx = pinRampedTypographySx(\n resolvePaletteVarsSx(\n resolveSchemeSx(\n pinnedScheme && schemeThemes\n ? mergeSxProps(\n {\n colorScheme: pinnedScheme,\n color: 'text.primary',\n bgcolor: 'background.default',\n } as any,\n sx as any,\n propsSx as any,\n authorSx as any,\n )\n : mergeSxProps(sx as any, propsSx as any, authorSx as any),\n activeScheme,\n ),\n theme?.palette,\n ),\n )\n /**\n * Author visibility — the eye on the hierarchy row.\n *\n * LAST, and deliberately so. It has to override the element's own\n * display, not replace it: an author who hides a Stack laid out with\n * `display: flex` gets that flex back the moment they show it again,\n * because the stored style was never touched. Writing `display: none`\n * into `node.sx` would have destroyed the value it overwrote, and there\n * would be nothing left to restore.\n *\n * The same rule on both surfaces. A hidden element is absent from the\n * published page and from the canvas — \"hidden\" that still renders in the\n * editor is a preview of a page nobody will ever see.\n */\n const mergedSx = node?.hidden\n ? mergeSxProps(composedSx as any, { display: 'none' } as any)\n : composedSx\n\n // Shared leaf attributes; self-closing components must receive NO\n // children at all (AGL-579) — a separate element expression keeps the\n // childless case genuinely childless instead of `[undefined, false]`.\n const leafProps = {\n ref,\n 'data-aglyn': `leaf:${node?.$id}`,\n // Before the spreads: the animation trigger/repeat attributes are ours,\n // but an element that genuinely declared one of these should win.\n ...animation?.attributes,\n ...resolvedProps,\n ...rest,\n className: mergedClassName,\n style: mergedStyle,\n sx: transformSx\n ? (transformSx(mergedSx, node?.$id) as typeof mergedSx)\n : mergedSx,\n }\n\n // Node identity (AGL-659): components get their node id through a\n // context rather than a prop, so a block can look up the server-seeded\n // slice of `pageData` that belongs to IT — two grids on one page have\n // different queries and must not share a seed. Nothing is added to any\n // component's props, so no unknown attribute reaches the DOM.\n // Positional children (AGL-1237): a component that splits its children\n // by index — MUI's Accordion is `[summary, ...rest]` — must receive one\n // React child per node child. The default single `<Branch>` element reads\n // as ONE child to `Children.toArray`, so the first slot swallowed the\n // whole subtree and every later slot got nothing. MUI's Stack counts its\n // children the same way to place its divider between them (AGL-3660).\n const positional = Boolean(\n (schema?.flags?.positionalChildren ?? 0) & FEATURE_FLAG.ENABLED,\n )\n const positionalChildren =\n positional && !holdServerHtml && !selfClosing\n ? spreadPositionalChildren(\n children,\n node as AnyNode,\n (childNodes) =>\n childNodes.map((child: any, key: number) => (\n <StemComponent key={child?.$id ?? key} node={child} />\n )),\n BranchComponent,\n )\n : null\n\n const element = holdServerHtml ? (\n // The root hydrates; its contents stay the server's until released.\n <Component\n {...withoutChildren(leafProps)}\n dangerouslySetInnerHTML={HELD_SERVER_HTML}\n suppressHydrationWarning\n />\n ) : selfClosing ? (\n <Component {...leafProps} />\n ) : positional ? (\n <Component {...leafProps}>\n {positionalChildren}\n {textContent != null && (\n <AglynText>{textContent as any}</AglynText>\n )}\n </Component>\n ) : (\n <Component {...leafProps}>\n {children}\n\n {textContent != null && (\n <AglynText>{textContent as any}</AglynText>\n )}\n </Component>\n )\n\n return (\n <NodeIdentityContext.Provider value={node?.$id ?? ''}>\n {element}\n </NodeIdentityContext.Provider>\n )\n }),\n)\nLeaf.displayName = 'Leaf'\nLeaf['aglyn'] = true\n\nexport default Leaf\n"],"names":["components","sanitizeAuthorSx","pinRampedTypographySx","NODE_HIDE_IF_PROP","NODE_HIDE_UNLESS_PROP","NODE_ANIMATION_DELAY_PROP","NODE_ANIMATION_DURATION_PROP","NODE_ANIMATION_EASE_PROP","NODE_ANIMATION_PROP","NODE_ANIMATION_REPEAT_PROP","NODE_ANIMATION_STAGGER_PROP","NODE_ANIMATION_STAGGER_STEP_PROP","NODE_ANIMATION_TRIGGER_PROP","resolveElementAnimation","EnabledPluginsContext","isSwitchedOffForRenderedSite","NodeIdentityContext","NODE_COLOR_SCHEME_PROP","resolveElementColorScheme","FEATURE_FLAG","AglynText","styled","ThemeProvider","useSiteSchemeThemes","useTheme","mergeSxProps","observer","isNamespacedComponentId","RealmElementsContext","Children","cloneElement","forwardRef","isValidElement","Suspense","use","useContext","isValidElementType","RendererComponents","LeafSxTransformContext","RealmBoundaryContext","DeferredHydrationContext","HELD_SERVER_HTML","mayHoldServerHtml","useHeldServerHtml","resolvePaletteVarsSx","resolveSchemeSx","DefaultComponent","withoutChildren","props","children","_children","rest","ownBranchNode","kid","$id","BranchComponent","type","undefined","branchNode","node","spreadPositionalChildren","toStems","placed","out","toArray","flatMap","own","wrapped","map","stem","key","Leaf","ref","schema","theme","forcedTheme","sx","className","style","resolvedProps","propsSx","propsClassName","propsStyle","_hideIf","_hideUnless","_animation","_animationTrigger","_animationDuration","_animationDelay","_animationRepeat","_animationEase","_animationStagger","_animationStaggerStep","_colorScheme","animation","enabledPlugins","registeredSchema","getSchema","componentId","offForSite","pluginId","Factory","getFactory","realmElement","realmBoundary","realmLoadFor","loading","Component","selfClosing","Boolean","flags","ENABLED","textContent","mergedClassName","filter","join","mergedStyle","transformSx","StemComponent","activeScheme","palette","mode","pinnedScheme","schemeThemes","deferHydration","holdServerHtml","fallback","Provider","value","authorSx","composedSx","colorScheme","color","bgcolor","mergedSx","hidden","display","leafProps","attributes","positional","positionalChildren","childNodes","child","element","dangerouslySetInnerHTML","suppressHydrationWarning","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,4EAA4E;AAC5E,8EAA8E;AAC9E,8EAA8E;AAC9E,+EAA+E;AAC/E,QAAQ;;;;;AAER,SAASA,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,gBAAgB,QAAQ,oCAAmC;AACpE,SAASC,qBAAqB,QAAQ,kDAAiD;AACvF,SACEC,iBAAiB,EACjBC,qBAAqB,QAChB,iDAAgD;AACvD,SACEC,yBAAyB,EACzBC,4BAA4B,EAC5BC,wBAAwB,EACxBC,mBAAmB,EACnBC,0BAA0B,EAC1BC,2BAA2B,EAC3BC,gCAAgC,EAChCC,2BAA2B,EAC3BC,uBAAuB,QAClB,2CAA0C;AACjD,SACEC,qBAAqB,EACrBC,4BAA4B,QACvB,iDAAgD;AACvD,SAASC,mBAAmB,QAAQ,uCAAsC;AAC1E,SACEC,sBAAsB,EACtBC,yBAAyB,QACpB,8CAA6C;AACpD,SAASC,YAAY,QAAQ,2CAA0C;AACvE,6EAA6E;AAC7E,4EAA4E;AAC5E,6EAA6E;AAC7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