@aglyn/besigner-ui 1.0.0-beta.293 → 1.0.0-beta.296
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 +17 -17
- package/src/lib/components/dnd/draggable-droppable.js +17 -8
- package/src/lib/components/dnd/draggable-droppable.js.map +1 -1
- package/src/lib/components/node-leaf.js +1 -1
- package/src/lib/components/node-leaf.js.map +1 -1
- package/src/lib/components/node-outline.d.ts +0 -6
- package/src/lib/components/node-outline.js +1 -28
- package/src/lib/components/node-outline.js.map +1 -1
- package/src/lib/components/node-overlay.js +14 -65
- package/src/lib/components/node-overlay.js.map +1 -1
- package/src/lib/drafts/besigner-server-draft.d.ts +4 -1
- package/src/lib/drafts/besigner-server-draft.js +6 -3
- package/src/lib/drafts/besigner-server-draft.js.map +1 -1
- package/src/lib/utils/docs-help.generated.d.ts +1 -1
- package/src/lib/utils/docs-help.generated.js +1 -0
- package/src/lib/utils/docs-help.generated.js.map +1 -1
- package/src/lib/utils/repeat-copy.d.ts +45 -9
- package/src/lib/utils/repeat-copy.js +71 -20
- package/src/lib/utils/repeat-copy.js.map +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/components/node-overlay.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\nimport { canvas } from '@aglyn/aglyn'\nimport * as Besigner from '@aglyn/besigner'\nimport { useIsomorphicLayoutEffect } from '@aglyn/shared-ui-jsx'\nimport {\n type ElementFragmentRects,\n getElementFragmentRects,\n} from '@aglyn/shared-util-dom'\nimport {\n Popper as MuiPopper,\n type PopperProps as MuiPopperProps,\n} from '@mui/material'\nimport { observer } from 'mobx-react-lite'\nimport { forwardRef, useMemo, useState } from 'react'\nimport NodeOutline, { RepeatMemberOutline } from './node-outline'\nimport { isInlineEditWithin } from '../utils/inline-text-edit.store'\nimport { repeatCopyElementsOf } from '../utils/repeat-copy'\nimport NodeQuickActions from './node-quick-actions'\n\n/**\n * What a Popper anchors to when it is not an element. It is popper's own\n * `VirtualElement`, stated structurally: popper is a dependency of MUI's and\n * not of this package, so importing its type would make the published package\n * name a module it never declares.\n */\ninterface VirtualElement {\n getBoundingClientRect: () => DOMRect\n contextElement?: Element\n}\n\nconst outerModifiers = [\n {\n name: 'flip',\n enabled: false,\n options: {\n altBoundary: false,\n rootBoundary: 'viewport',\n padding: 0,\n },\n },\n {\n name: 'preventOverflow',\n enabled: false,\n options: {\n altAxis: false,\n altBoundary: false,\n tether: false,\n rootBoundary: 'viewport',\n padding: 0,\n },\n },\n]\n\n/** The canvas's scrolling, clipping container: what the author can see of it. */\nconst CANVAS_VIEWPORT_ID = 'aglyn:viewport-canvas'\n\n/**\n * Where the label chip and the action strip may be flipped and pushed to stay\n * in view: inside the CANVAS, measured in page coordinates.\n *\n * They were kept inside the browser's viewport, and on a phone that is the\n * VISUAL viewport — the part a pinch-zoom leaves on screen, 195px wide at 2×.\n * A strip under an element near that edge was shoved sideways to fit, 56px\n * off the element it belongs to, and only once something made the overlay\n * update; before that it sat centred. So it was off-centre \"sometimes\", and\n * stayed wherever the last update had put it as the author panned.\n *\n * The canvas is the right box anyway: it is what the author is looking at,\n * zoom does not change it, and a strip pushed inside it never ends up over a\n * side panel.\n */\nfunction innerModifiersWithin(canvas: Element | null) {\n const boundary = canvas ?? 'clippingParents'\n return [\n {\n name: 'flip',\n enabled: true,\n options: { boundary, rootBoundary: 'document', padding: 0 },\n },\n {\n name: 'preventOverflow',\n enabled: true,\n options: {\n boundary,\n rootBoundary: 'document',\n altAxis: true,\n tether: true,\n padding: 0,\n },\n },\n ]\n}\n\nconst DEFAULT_RECT = {\n top: 0,\n left: 0,\n width: 0,\n height: 0,\n} as DOMRect\n\nexport function serializeRect(rect: DOMRect): any {\n return JSON.parse(JSON.stringify(rect || DEFAULT_RECT))\n}\n\n/**\n * What the overlay draws: the element's own fragments, or — for an element a\n * repeat draws copies of — one box round the element AND its copies, with the\n * element's own box as `member`.\n */\ntype OverlayGeometry = ElementFragmentRects & {\n member?: ElementFragmentRects['union']\n}\n\n/**\n * The element and every copy a repeat draws of it, as one group (AGL-3111).\n *\n * Pointing at a copy (Sam, Jordan) targets the element it draws, and the\n * outline used to wrap that element alone — so the pointer sat on one row\n * while the box lit up another, which reads as the canvas aiming at the wrong\n * thing. The box now wraps the whole group, the element inside it is marked\n * as the one that is edited, and the copies keep their own dashed grey.\n */\nfunction withRepeatGroup(\n el: Element,\n id: string | undefined,\n own: ElementFragmentRects,\n): OverlayGeometry {\n const copies = id ? repeatCopyElementsOf(el, id) : []\n if (!copies.length) return own\n let { left, top } = own.union\n let right = own.union.left + own.union.width\n let bottom = own.union.top + own.union.height\n for (const copy of copies) {\n const box = copy.getBoundingClientRect()\n left = Math.min(left, box.left)\n top = Math.min(top, box.top)\n right = Math.max(right, box.right)\n bottom = Math.max(bottom, box.bottom)\n }\n const union = {\n ...own.union,\n left,\n top,\n x: left,\n y: top,\n width: right - left,\n height: bottom - top,\n right,\n bottom,\n }\n return { fragments: [union], union, first: own.first, member: own.union }\n}\n\nconst DEFAULT_GEOMETRY: ElementFragmentRects = {\n fragments: [DEFAULT_RECT as any],\n union: DEFAULT_RECT as any,\n first: DEFAULT_RECT as any,\n}\n\n/**\n * Whole-pixel identity of a measured geometry (AGL-2486).\n *\n * The measuring callback runs on every scroll event anywhere on the page, on\n * every resize, and on every ResizeObserver tick. Before this it called\n * `setRect(serializeRect(...))` unconditionally — a NEW object each time, so\n * scrolling a side panel re-rendered this observer and everything under it at\n * event rate even though the element had not moved. Fragment sets are larger,\n * and committing a fresh ARRAY every frame is exactly the shape that froze a\n * tab in the collaborator overlay on 2026-08-22.\n *\n * MEASURING is cheap; COMMITTING is not. Rounding first means sub-pixel\n * jitter cannot churn a render on its own. This is strictly less per-event\n * work than the single-rect code did, not more.\n */\nfunction fingerprintGeometry(geometry: OverlayGeometry): string {\n return [...geometry.fragments, ...(geometry.member ? [geometry.member] : [])]\n .map(\n (rect) =>\n `${Math.round(rect.left)},${Math.round(rect.top)},` +\n `${Math.round(rect.width)},${Math.round(rect.height)}`,\n )\n .join(';')\n}\n\nexport interface NodeOverlayProps extends Partial<MuiPopperProps> {\n variant: 'hovered' | 'selected'\n}\n\nconst NodeOverlay = observer(\n forwardRef<any, NodeOverlayProps>((props, ref) => {\n const { variant, ...rest } = props || {}\n\n const state =\n variant === 'selected'\n ? Besigner.focus.getLastSelected()\n : Besigner.focus.getHovered()\n const $id = state?.$id\n const node = canvas.getNode($id)\n\n const elementRef = Besigner.refs.get($id)\n // Node.index throws for parentless nodes (the root, or a node whose\n // parent isn't loaded) — selecting the root via the breadcrumbs must not\n // crash the overlay.\n const nodeIndex = node?.parent ? node.index : null\n /**\n * The selection chrome stands down while this node is being edited in\n * place (AGL-2486).\n *\n * This overlay paints a translucent FILL behind the node as well as an\n * outline (`node-outline.tsx`). While the author is typing, that tint is\n * the one thing standing between the in-place surface and its whole\n * promise — that the text looks exactly as it renders, on the background\n * it renders on. It is redundant during an edit anyway: the caret and the\n * toolbar already say which element is being edited.\n *\n * The geometry is no longer a second reason to suppress it: the\n * chrome below is drawn from `getClientRects()`, one outline per line\n * fragment, so a SELECTED wrapped inline run is outlined correctly too.\n * Standing the fill down during an edit remains right for its own\n * reason — the in-place surface must look exactly as it renders.\n */\n const isBeingEdited = isInlineEditWithin(elementRef?.current ?? null)\n // The SELECTION's outline stays through an edit: it is what says which\n // element is being typed into, and with it gone the author lost track of\n // the element once the toolbar opened. Only its fill and its chip stand\n // down — see `editing` below. The hover chrome stands down whole: a\n // second outline on the text under the caret says nothing new.\n const isOpen =\n Boolean(elementRef?.current) &&\n (variant === 'selected' || !isBeingEdited)\n const editing = isBeingEdited\n const [geometry, setGeometry] =\n useState<OverlayGeometry>(DEFAULT_GEOMETRY)\n const { union: rect, fragments, first, member } = geometry\n // Found once the overlay is in the document; memoised so the popper is\n // not rebuilt on every geometry commit.\n const [canvasViewport, setCanvasViewport] = useState<Element | null>(null)\n useIsomorphicLayoutEffect(() => {\n setCanvasViewport(document.getElementById(CANVAS_VIEWPORT_ID))\n }, [])\n const innerModifiers = useMemo(\n () => innerModifiersWithin(canvasViewport),\n [canvasViewport],\n )\n\n useIsomorphicLayoutEffect(() => {\n const el = elementRef?.current\n if (!el || !('getBoundingClientRect' in el)) return\n\n /**\n * The element's REAL shape, not its bounding box (AGL-2486).\n *\n * A wrapped inline run is a set of line fragments, and one rectangle\n * cannot describe it — see `getElementFragmentRects` for why the union\n * is not merely imprecise but a different shape, and why an outline\n * drawn from it misses the text on the new line. A block yields one\n * fragment that IS the bounding rect, so block geometry is unaffected.\n */\n let committed = ''\n const update = () => {\n const next = withRepeatGroup(el, $id, getElementFragmentRects(el))\n const fingerprint = fingerprintGeometry(next)\n if (fingerprint === committed) return\n committed = fingerprint\n setGeometry(next)\n }\n update()\n\n // Re-sync when the element or its shadow-DOM host resizes (covers prop\n // changes that affect layout, e.g. flexDirection column→row) and when\n // the canvas container resizes or the window resizes.\n // ResizeObserver is not in every jsdom setup, and an unguarded\n // constructor in a layout effect takes the whole overlay down with it.\n // The listeners below still carry scroll and resize. Same guard, for\n // the same reason, as `use-anchored-rect.ts`.\n const ro =\n typeof ResizeObserver === 'function' ? new ResizeObserver(update) : null\n ro?.observe(el)\n const shadowHost = (el.getRootNode() as ShadowRoot | null)?.host ?? null\n if (shadowHost) ro?.observe(shadowHost)\n window.addEventListener('resize', update, { passive: true })\n\n // Scrolling any ancestor (the canvas container, panels, or the page\n // body) shifts getBoundingClientRect() values without triggering a\n // resize — capture-phase listener catches them all.\n window.addEventListener('scroll', update, { passive: true, capture: true })\n // A pinch-zoom, a pan of the zoomed view and the on-screen keyboard\n // move the VISUAL viewport, which fires neither of the above. Where a\n // browser reports element rects against it (Safari), the overlay has\n // to re-read them or it is left where the last pan put it.\n const visual = window.visualViewport\n visual?.addEventListener('resize', update, { passive: true })\n visual?.addEventListener('scroll', update, { passive: true })\n\n return () => {\n ro?.disconnect()\n window.removeEventListener('resize', update)\n window.removeEventListener('scroll', update, { capture: true })\n visual?.removeEventListener('resize', update)\n visual?.removeEventListener('scroll', update)\n }\n // Node?.index changes when the node is reordered among siblings (e.g.\n // \"shift up\"/\"shift down\"). Reordering moves the same DOM element to a\n // new position without resizing it, so ResizeObserver won't catch it —\n // this dependency forces a rect recompute when sibling order changes.\n }, [elementRef, nodeIndex, $id])\n\n // Popper types its anchor rect as a full `DOMRect`; the measured rects\n // are plain geometry and carry no `toJSON`, which popper never calls.\n const virtualElement = useMemo<() => VirtualElement>(() => {\n return () => ({\n getBoundingClientRect: () => rect as unknown as DOMRect,\n })\n }, [rect])\n\n /**\n * Where the label chip, the quick actions and the DRAG affordance hang\n * (AGL-2486).\n *\n * They used to hang off the union rect, and a fragment set has no obvious\n * single anchor. The union corner is the wrong one: an inline run that\n * begins mid-line and wraps has a union whose left edge comes from the\n * SECOND line, so a chip placed there floats above a sibling's text\n * rather than above the element it names — and the drag handle would be\n * offered at a point the element does not occupy.\n *\n * The first fragment is where the run STARTS in reading order. It is\n * where the eye already is, it is always on the element, and for a block\n * — every one of which has exactly one fragment — it is the union, so\n * nothing moves for the overwhelming majority of nodes.\n */\n const anchorElement = useMemo<() => VirtualElement>(() => {\n return () => ({\n getBoundingClientRect: () => first as unknown as DOMRect,\n })\n }, [first])\n\n return (\n <MuiPopper\n ref={ref}\n anchorEl={virtualElement}\n placement=\"top-start\"\n modifiers={outerModifiers}\n open={isOpen}\n keepMounted\n // The anchor rect is viewport-relative; fixed positioning matches it\n // and, unlike the default absolute strategy, cannot extend the\n // document — an overlay past the fold otherwise grows the page,\n // which grows the scroll range, which moves the overlay again\n // (infinite scroll feedback).\n popperOptions={{ strategy: 'fixed' }}\n // Overlays belong to the canvas layer: rendering in place (no body\n // portal) keeps them inside the viewport's stacking context, so the\n // designer chrome (app bars, breadcrumbs) always paints above them.\n disablePortal\n // Transition\n {...rest}\n >\n <div>\n {/* One outline per line fragment, positioned relative to the\n union the popper is anchored on. A block has exactly one\n fragment and it IS the union, so it lands at 0,0 with the\n union's size — the same box, from the same numbers, as\n before AGL-2486. The chip renders once, below, so a two-line\n heading reads as one selected element with two line boxes,\n which is what a browser's own selection looks like. */}\n {fragments.map((fragment, index) => (\n <NodeOutline\n key={index}\n node={node}\n data-aglyn-fragment={index}\n style={{\n left: fragment.left - rect.left,\n top: fragment.top - rect.top,\n right: 'auto',\n bottom: 'auto',\n width: fragment.width,\n height: fragment.height,\n }}\n editing={editing}\n />\n ))}\n {member ? (\n // The element inside its repeat group, marked as the one an edit\n // changes — see `RepeatMemberOutline`.\n <RepeatMemberOutline\n style={{\n left: member.left - rect.left,\n top: member.top - rect.top,\n right: 'auto',\n bottom: 'auto',\n width: member.width,\n height: member.height,\n }}\n />\n ) : null}\n\n <MuiPopper\n // The editor's own toolbar sits where the chip and the quick\n // actions would.\n open={isOpen && !editing}\n anchorEl={anchorElement}\n placement={variant === 'hovered' ? 'top-start' : undefined}\n modifiers={innerModifiers}\n popperOptions={{ strategy: 'fixed' }}\n disablePortal\n // KeepMounted\n // transition\n sx={{\n ['&[data-popper-placement^=top] #aglyn\\\\:element-overlay-label']:\n {\n borderTopLeftRadius: 3,\n borderTopRightRadius: 3,\n borderBottomLeftRadius: 0,\n borderBottomRightRadius: 0,\n },\n ['&[data-popper-placement^=bottom] #aglyn\\\\:element-overlay-label']:\n {\n borderTopLeftRadius: 0,\n borderTopRightRadius: 0,\n borderBottomLeftRadius: 3,\n borderBottomRightRadius: 3,\n },\n }}\n >\n <NodeQuickActions\n node={node}\n variant={variant === 'selected' ? 'actions' : 'label'}\n />\n </MuiPopper>\n </div>\n </MuiPopper>\n )\n }),\n)\n\nNodeOverlay.displayName = 'NodeOverlay'\n\nexport default NodeOverlay\n"],"names":["canvas","Besigner","useIsomorphicLayoutEffect","getElementFragmentRects","Popper","MuiPopper","observer","forwardRef","useMemo","useState","NodeOutline","RepeatMemberOutline","isInlineEditWithin","repeatCopyElementsOf","NodeQuickActions","outerModifiers","name","enabled","options","altBoundary","rootBoundary","padding","altAxis","tether","CANVAS_VIEWPORT_ID","innerModifiersWithin","boundary","DEFAULT_RECT","top","left","width","height","serializeRect","rect","JSON","parse","stringify","withRepeatGroup","el","id","own","copies","length","union","right","bottom","copy","box","getBoundingClientRect","Math","min","max","x","y","fragments","first","member","DEFAULT_GEOMETRY","fingerprintGeometry","geometry","map","round","join","NodeOverlay","props","ref","variant","rest","state","focus","getLastSelected","getHovered","$id","node","getNode","elementRef","refs","get","nodeIndex","parent","index","isBeingEdited","current","isOpen","Boolean","editing","setGeometry","canvasViewport","setCanvasViewport","document","getElementById","innerModifiers","committed","update","next","fingerprint","ro","ResizeObserver","observe","shadowHost","getRootNode","host","window","addEventListener","passive","capture","visual","visualViewport","disconnect","removeEventListener","virtualElement","anchorElement","anchorEl","placement","modifiers","open","keepMounted","popperOptions","strategy","disablePortal","div","fragment","data-aglyn-fragment","style","undefined","sx","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","displayName"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,MAAM,QAAQ,eAAc;AACrC,YAAYC,cAAc,kBAAiB;AAC3C,SAASC,yBAAyB,QAAQ,uBAAsB;AAChE,SAEEC,uBAAuB,QAClB,yBAAwB;AAC/B,SACEC,UAAUC,SAAS,QAEd,gBAAe;AACtB,SAASC,QAAQ,QAAQ,kBAAiB;AAC1C,SAASC,UAAU,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACrD,OAAOC,eAAeC,mBAAmB,Q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BAEA;8BAEJ,KAAC1B;oBACC,6DAA6D;oBAC7D,iBAAiB;oBACjB8G,MAAMhC,UAAU,CAACE;oBACjB2B,UAAUD;oBACVE,WAAW/C,YAAY,YAAY,cAAc0D;oBACjDV,WAAWvB;oBACX0B,eAAe;wBAAEC,UAAU;oBAAQ;oBACnCC,aAAa;oBACb,cAAc;oBACd,aAAa;oBACbM,IAAI;wBACF,CAAC,+DAA+D,EAC9D;4BACEC,qBAAqB;4BACrBC,sBAAsB;4BACtBC,wBAAwB;4BACxBC,yBAAyB;wBAC3B;wBACF,CAAC,kEAAkE,EACjE;4BACEH,qBAAqB;4BACrBC,sBAAsB;4BACtBC,wBAAwB;4BACxBC,yBAAyB;wBAC3B;oBACJ;8BAEA,cAAA,KAACnH;wBACC2D,MAAMA;wBACNP,SAASA,YAAY,aAAa,YAAY;;;;;;AAM1D;AAGFH,YAAYmE,WAAW,GAAG;AAE1B,eAAenE,YAAW"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/components/node-overlay.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\nimport { canvas } from '@aglyn/aglyn'\nimport * as Besigner from '@aglyn/besigner'\nimport { useIsomorphicLayoutEffect } from '@aglyn/shared-ui-jsx'\nimport {\n type ElementFragmentRects,\n getElementFragmentRects,\n} from '@aglyn/shared-util-dom'\nimport {\n Popper as MuiPopper,\n type PopperProps as MuiPopperProps,\n} from '@mui/material'\nimport { observer } from 'mobx-react-lite'\nimport { forwardRef, useMemo, useState } from 'react'\nimport NodeOutline from './node-outline'\nimport { isInlineEditWithin } from '../utils/inline-text-edit.store'\nimport {\n repeatCopyElementIn,\n repeatCopyStandIns,\n} from '../utils/repeat-copy'\nimport NodeQuickActions from './node-quick-actions'\n\n/**\n * What a Popper anchors to when it is not an element. It is popper's own\n * `VirtualElement`, stated structurally: popper is a dependency of MUI's and\n * not of this package, so importing its type would make the published package\n * name a module it never declares.\n */\ninterface VirtualElement {\n getBoundingClientRect: () => DOMRect\n contextElement?: Element\n}\n\nconst outerModifiers = [\n {\n name: 'flip',\n enabled: false,\n options: {\n altBoundary: false,\n rootBoundary: 'viewport',\n padding: 0,\n },\n },\n {\n name: 'preventOverflow',\n enabled: false,\n options: {\n altAxis: false,\n altBoundary: false,\n tether: false,\n rootBoundary: 'viewport',\n padding: 0,\n },\n },\n]\n\n/** The canvas's scrolling, clipping container: what the author can see of it. */\nconst CANVAS_VIEWPORT_ID = 'aglyn:viewport-canvas'\n\n/**\n * Where the label chip and the action strip may be flipped and pushed to stay\n * in view: inside the CANVAS, measured in page coordinates.\n *\n * They were kept inside the browser's viewport, and on a phone that is the\n * VISUAL viewport — the part a pinch-zoom leaves on screen, 195px wide at 2×.\n * A strip under an element near that edge was shoved sideways to fit, 56px\n * off the element it belongs to, and only once something made the overlay\n * update; before that it sat centred. So it was off-centre \"sometimes\", and\n * stayed wherever the last update had put it as the author panned.\n *\n * The canvas is the right box anyway: it is what the author is looking at,\n * zoom does not change it, and a strip pushed inside it never ends up over a\n * side panel.\n */\nfunction innerModifiersWithin(canvas: Element | null) {\n const boundary = canvas ?? 'clippingParents'\n return [\n {\n name: 'flip',\n enabled: true,\n options: { boundary, rootBoundary: 'document', padding: 0 },\n },\n {\n name: 'preventOverflow',\n enabled: true,\n options: {\n boundary,\n rootBoundary: 'document',\n altAxis: true,\n tether: true,\n padding: 0,\n },\n },\n ]\n}\n\nconst DEFAULT_RECT = {\n top: 0,\n left: 0,\n width: 0,\n height: 0,\n} as DOMRect\n\nexport function serializeRect(rect: DOMRect): any {\n return JSON.parse(JSON.stringify(rect || DEFAULT_RECT))\n}\n\nconst DEFAULT_GEOMETRY: ElementFragmentRects = {\n fragments: [DEFAULT_RECT as any],\n union: DEFAULT_RECT as any,\n first: DEFAULT_RECT as any,\n}\n\n/**\n * Whole-pixel identity of a measured geometry (AGL-2486).\n *\n * The measuring callback runs on every scroll event anywhere on the page, on\n * every resize, and on every ResizeObserver tick. Before this it called\n * `setRect(serializeRect(...))` unconditionally — a NEW object each time, so\n * scrolling a side panel re-rendered this observer and everything under it at\n * event rate even though the element had not moved. Fragment sets are larger,\n * and committing a fresh ARRAY every frame is exactly the shape that froze a\n * tab in the collaborator overlay on 2026-08-22.\n *\n * MEASURING is cheap; COMMITTING is not. Rounding first means sub-pixel\n * jitter cannot churn a render on its own. This is strictly less per-event\n * work than the single-rect code did, not more.\n */\nfunction fingerprintGeometry(geometry: ElementFragmentRects): string {\n return geometry.fragments\n .map(\n (rect) =>\n `${Math.round(rect.left)},${Math.round(rect.top)},` +\n `${Math.round(rect.width)},${Math.round(rect.height)}`,\n )\n .join(';')\n}\n\nexport interface NodeOverlayProps extends Partial<MuiPopperProps> {\n variant: 'hovered' | 'selected'\n}\n\nconst NodeOverlay = observer(\n forwardRef<any, NodeOverlayProps>((props, ref) => {\n const { variant, ...rest } = props || {}\n\n const state =\n variant === 'selected'\n ? Besigner.focus.getLastSelected()\n : Besigner.focus.getHovered()\n const $id = state?.$id\n const node = canvas.getNode($id)\n\n const elementRef = Besigner.refs.get($id)\n // The repeat copy this hover or selection was made on, if it was: the\n // chrome goes round that copy, where the pointer is, while the node it\n // names — the element the copy draws — is what every edit changes.\n const copyId = repeatCopyStandIns.copyIdFor(variant, $id)\n // Node.index throws for parentless nodes (the root, or a node whose\n // parent isn't loaded) — selecting the root via the breadcrumbs must not\n // crash the overlay.\n const nodeIndex = node?.parent ? node.index : null\n /**\n * The selection chrome stands down while this node is being edited in\n * place (AGL-2486).\n *\n * This overlay paints a translucent FILL behind the node as well as an\n * outline (`node-outline.tsx`). While the author is typing, that tint is\n * the one thing standing between the in-place surface and its whole\n * promise — that the text looks exactly as it renders, on the background\n * it renders on. It is redundant during an edit anyway: the caret and the\n * toolbar already say which element is being edited.\n *\n * The geometry is no longer a second reason to suppress it: the\n * chrome below is drawn from `getClientRects()`, one outline per line\n * fragment, so a SELECTED wrapped inline run is outlined correctly too.\n * Standing the fill down during an edit remains right for its own\n * reason — the in-place surface must look exactly as it renders.\n */\n const isBeingEdited = isInlineEditWithin(elementRef?.current ?? null)\n // The SELECTION's outline stays through an edit: it is what says which\n // element is being typed into, and with it gone the author lost track of\n // the element once the toolbar opened. Only its fill and its chip stand\n // down — see `editing` below. The hover chrome stands down whole: a\n // second outline on the text under the caret says nothing new.\n const isOpen =\n Boolean(elementRef?.current) &&\n (variant === 'selected' || !isBeingEdited)\n const editing = isBeingEdited\n const [geometry, setGeometry] =\n useState<ElementFragmentRects>(DEFAULT_GEOMETRY)\n const { union: rect, fragments, first } = geometry\n // Found once the overlay is in the document; memoised so the popper is\n // not rebuilt on every geometry commit.\n const [canvasViewport, setCanvasViewport] = useState<Element | null>(null)\n useIsomorphicLayoutEffect(() => {\n setCanvasViewport(document.getElementById(CANVAS_VIEWPORT_ID))\n }, [])\n const innerModifiers = useMemo(\n () => innerModifiersWithin(canvasViewport),\n [canvasViewport],\n )\n\n useIsomorphicLayoutEffect(() => {\n const real = elementRef?.current\n if (!real || !('getBoundingClientRect' in real)) return\n const el = (copyId && repeatCopyElementIn(real, copyId)) || real\n\n /**\n * The element's REAL shape, not its bounding box (AGL-2486).\n *\n * A wrapped inline run is a set of line fragments, and one rectangle\n * cannot describe it — see `getElementFragmentRects` for why the union\n * is not merely imprecise but a different shape, and why an outline\n * drawn from it misses the text on the new line. A block yields one\n * fragment that IS the bounding rect, so block geometry is unaffected.\n */\n let committed = ''\n const update = () => {\n const next = getElementFragmentRects(el)\n const fingerprint = fingerprintGeometry(next)\n if (fingerprint === committed) return\n committed = fingerprint\n setGeometry(next)\n }\n update()\n\n // Re-sync when the element or its shadow-DOM host resizes (covers prop\n // changes that affect layout, e.g. flexDirection column→row) and when\n // the canvas container resizes or the window resizes.\n // ResizeObserver is not in every jsdom setup, and an unguarded\n // constructor in a layout effect takes the whole overlay down with it.\n // The listeners below still carry scroll and resize. Same guard, for\n // the same reason, as `use-anchored-rect.ts`.\n const ro =\n typeof ResizeObserver === 'function' ? new ResizeObserver(update) : null\n ro?.observe(el)\n const shadowHost = (el.getRootNode() as ShadowRoot | null)?.host ?? null\n if (shadowHost) ro?.observe(shadowHost)\n window.addEventListener('resize', update, { passive: true })\n\n // Scrolling any ancestor (the canvas container, panels, or the page\n // body) shifts getBoundingClientRect() values without triggering a\n // resize — capture-phase listener catches them all.\n window.addEventListener('scroll', update, { passive: true, capture: true })\n // A pinch-zoom, a pan of the zoomed view and the on-screen keyboard\n // move the VISUAL viewport, which fires neither of the above. Where a\n // browser reports element rects against it (Safari), the overlay has\n // to re-read them or it is left where the last pan put it.\n const visual = window.visualViewport\n visual?.addEventListener('resize', update, { passive: true })\n visual?.addEventListener('scroll', update, { passive: true })\n\n return () => {\n ro?.disconnect()\n window.removeEventListener('resize', update)\n window.removeEventListener('scroll', update, { capture: true })\n visual?.removeEventListener('resize', update)\n visual?.removeEventListener('scroll', update)\n }\n // Node?.index changes when the node is reordered among siblings (e.g.\n // \"shift up\"/\"shift down\"). Reordering moves the same DOM element to a\n // new position without resizing it, so ResizeObserver won't catch it —\n // this dependency forces a rect recompute when sibling order changes.\n }, [elementRef, nodeIndex, $id, copyId])\n\n // Popper types its anchor rect as a full `DOMRect`; the measured rects\n // are plain geometry and carry no `toJSON`, which popper never calls.\n const virtualElement = useMemo<() => VirtualElement>(() => {\n return () => ({\n getBoundingClientRect: () => rect as unknown as DOMRect,\n })\n }, [rect])\n\n /**\n * Where the label chip, the quick actions and the DRAG affordance hang\n * (AGL-2486).\n *\n * They used to hang off the union rect, and a fragment set has no obvious\n * single anchor. The union corner is the wrong one: an inline run that\n * begins mid-line and wraps has a union whose left edge comes from the\n * SECOND line, so a chip placed there floats above a sibling's text\n * rather than above the element it names — and the drag handle would be\n * offered at a point the element does not occupy.\n *\n * The first fragment is where the run STARTS in reading order. It is\n * where the eye already is, it is always on the element, and for a block\n * — every one of which has exactly one fragment — it is the union, so\n * nothing moves for the overwhelming majority of nodes.\n */\n const anchorElement = useMemo<() => VirtualElement>(() => {\n return () => ({\n getBoundingClientRect: () => first as unknown as DOMRect,\n })\n }, [first])\n\n return (\n <MuiPopper\n ref={ref}\n anchorEl={virtualElement}\n placement=\"top-start\"\n modifiers={outerModifiers}\n open={isOpen}\n keepMounted\n // The anchor rect is viewport-relative; fixed positioning matches it\n // and, unlike the default absolute strategy, cannot extend the\n // document — an overlay past the fold otherwise grows the page,\n // which grows the scroll range, which moves the overlay again\n // (infinite scroll feedback).\n popperOptions={{ strategy: 'fixed' }}\n // Overlays belong to the canvas layer: rendering in place (no body\n // portal) keeps them inside the viewport's stacking context, so the\n // designer chrome (app bars, breadcrumbs) always paints above them.\n disablePortal\n // Transition\n {...rest}\n >\n <div>\n {/* One outline per line fragment, positioned relative to the\n union the popper is anchored on. A block has exactly one\n fragment and it IS the union, so it lands at 0,0 with the\n union's size — the same box, from the same numbers, as\n before AGL-2486. The chip renders once, below, so a two-line\n heading reads as one selected element with two line boxes,\n which is what a browser's own selection looks like. */}\n {fragments.map((fragment, index) => (\n <NodeOutline\n key={index}\n node={node}\n data-aglyn-fragment={index}\n style={{\n left: fragment.left - rect.left,\n top: fragment.top - rect.top,\n right: 'auto',\n bottom: 'auto',\n width: fragment.width,\n height: fragment.height,\n }}\n editing={editing}\n />\n ))}\n <MuiPopper\n // The editor's own toolbar sits where the chip and the quick\n // actions would.\n open={isOpen && !editing}\n anchorEl={anchorElement}\n placement={variant === 'hovered' ? 'top-start' : undefined}\n modifiers={innerModifiers}\n popperOptions={{ strategy: 'fixed' }}\n disablePortal\n // KeepMounted\n // transition\n sx={{\n ['&[data-popper-placement^=top] #aglyn\\\\:element-overlay-label']:\n {\n borderTopLeftRadius: 3,\n borderTopRightRadius: 3,\n borderBottomLeftRadius: 0,\n borderBottomRightRadius: 0,\n },\n ['&[data-popper-placement^=bottom] #aglyn\\\\:element-overlay-label']:\n {\n borderTopLeftRadius: 0,\n borderTopRightRadius: 0,\n borderBottomLeftRadius: 3,\n borderBottomRightRadius: 3,\n },\n }}\n >\n <NodeQuickActions\n node={node}\n variant={variant === 'selected' ? 'actions' : 'label'}\n />\n </MuiPopper>\n </div>\n </MuiPopper>\n )\n }),\n)\n\nNodeOverlay.displayName = 'NodeOverlay'\n\nexport default NodeOverlay\n"],"names":["canvas","Besigner","useIsomorphicLayoutEffect","getElementFragmentRects","Popper","MuiPopper","observer","forwardRef","useMemo","useState","NodeOutline","isInlineEditWithin","repeatCopyElementIn","repeatCopyStandIns","NodeQuickActions","outerModifiers","name","enabled","options","altBoundary","rootBoundary","padding","altAxis","tether","CANVAS_VIEWPORT_ID","innerModifiersWithin","boundary","DEFAULT_RECT","top","left","width","height","serializeRect","rect","JSON","parse","stringify","DEFAULT_GEOMETRY","fragments","union","first","fingerprintGeometry","geometry","map","Math","round","join","NodeOverlay","props","ref","variant","rest","state","focus","getLastSelected","getHovered","$id","node","getNode","elementRef","refs","get","copyId","copyIdFor","nodeIndex","parent","index","isBeingEdited","current","isOpen","Boolean","editing","setGeometry","canvasViewport","setCanvasViewport","document","getElementById","innerModifiers","el","real","committed","update","next","fingerprint","ro","ResizeObserver","observe","shadowHost","getRootNode","host","window","addEventListener","passive","capture","visual","visualViewport","disconnect","removeEventListener","virtualElement","getBoundingClientRect","anchorElement","anchorEl","placement","modifiers","open","keepMounted","popperOptions","strategy","disablePortal","div","fragment","data-aglyn-fragment","style","right","bottom","undefined","sx","borderTopLeftRadius","borderTopRightRadius","borderBottomLeftRadius","borderBottomRightRadius","displayName"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,MAAM,QAAQ,eAAc;AACrC,YAAYC,c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AMA;wBACNsD,uBAAqB7C;wBACrB8C,OAAO;4BACLnF,MAAMiF,SAASjF,IAAI,GAAGI,KAAKJ,IAAI;4BAC/BD,KAAKkF,SAASlF,GAAG,GAAGK,KAAKL,GAAG;4BAC5BqF,OAAO;4BACPC,QAAQ;4BACRpF,OAAOgF,SAAShF,KAAK;4BACrBC,QAAQ+E,SAAS/E,MAAM;wBACzB;wBACAwC,SAASA;uBAXJL;8BAcT,KAAC7D;oBACC,6DAA6D;oBAC7D,iBAAiB;oBACjBmG,MAAMnC,UAAU,CAACE;oBACjB8B,UAAUD;oBACVE,WAAWpD,YAAY,YAAY,cAAciE;oBACjDZ,WAAW1B;oBACX6B,eAAe;wBAAEC,UAAU;oBAAQ;oBACnCC,aAAa;oBACb,cAAc;oBACd,aAAa;oBACbQ,IAAI;wBACF,CAAC,+DAA+D,EAC9D;4BACEC,qBAAqB;4BACrBC,sBAAsB;4BACtBC,wBAAwB;4BACxBC,yBAAyB;wBAC3B;wBACF,CAAC,kEAAkE,EACjE;4BACEH,qBAAqB;4BACrBC,sBAAsB;4BACtBC,wBAAwB;4BACxBC,yBAAyB;wBAC3B;oBACJ;8BAEA,cAAA,KAAC1G;wBACC2C,MAAMA;wBACNP,SAASA,YAAY,aAAa,YAAY;;;;;;AAM1D;AAGFH,YAAY0E,WAAW,GAAG;AAE1B,eAAe1E,YAAW"}
|
|
@@ -75,7 +75,10 @@ import type { BesignerDraftIds } from './besigner-draft-store';
|
|
|
75
75
|
* become authoritative again, and replaying the mirror over it would re-apply
|
|
76
76
|
* edits the draft already contains.
|
|
77
77
|
*/
|
|
78
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* The only id a draft may have. One per version, by construction. Read from
|
|
80
|
+
* the core, which an AI edit job writes the same draft through (AGL-4116).
|
|
81
|
+
*/
|
|
79
82
|
export declare const DRAFT_DOC_ID = "current";
|
|
80
83
|
export interface BesignerServerDraft {
|
|
81
84
|
nodes: ProcessableNodes;
|
|
@@ -16,7 +16,7 @@ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_wi
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/ import { Bytes, deleteDoc, doc, getDoc, serverTimestamp, setDoc } from "firebase/firestore";
|
|
19
|
-
import { decodeStoredNodes, encodeStoredNodes } from "@aglyn/aglyn";
|
|
19
|
+
import { VERSION_DRAFT_COLLECTION, VERSION_DRAFT_DOC_ID, decodeStoredNodes, encodeStoredNodes } from "@aglyn/aglyn";
|
|
20
20
|
/**
|
|
21
21
|
* THE WORKING DRAFT — server-side, shared, one per version (AGL-1152).
|
|
22
22
|
*
|
|
@@ -74,7 +74,10 @@ import { decodeStoredNodes, encodeStoredNodes } from "@aglyn/aglyn";
|
|
|
74
74
|
* draft clears the mirror exactly as saving the document does: Firestore has
|
|
75
75
|
* become authoritative again, and replaying the mirror over it would re-apply
|
|
76
76
|
* edits the draft already contains.
|
|
77
|
-
*/ /**
|
|
77
|
+
*/ /**
|
|
78
|
+
* The only id a draft may have. One per version, by construction. Read from
|
|
79
|
+
* the core, which an AI edit job writes the same draft through (AGL-4116).
|
|
80
|
+
*/ export const DRAFT_DOC_ID = VERSION_DRAFT_DOC_ID;
|
|
78
81
|
/**
|
|
79
82
|
* Epoch milliseconds from a stored stamp — a Firestore `Timestamp`, or its
|
|
80
83
|
* `{ seconds, nanoseconds }` shape once it has crossed a serialization — or
|
|
@@ -115,7 +118,7 @@ import { decodeStoredNodes, encodeStoredNodes } from "@aglyn/aglyn";
|
|
|
115
118
|
const collection = COLLECTION_OF[ids.kind];
|
|
116
119
|
if (!collection || !ids.scope || ids.scope === 'platform') return null;
|
|
117
120
|
if (!ids.docId || !ids.versionId) return null;
|
|
118
|
-
return doc(firestore, 'hosts', ids.scope, collection, ids.docId, 'versions', ids.versionId,
|
|
121
|
+
return doc(firestore, 'hosts', ids.scope, collection, ids.docId, 'versions', ids.versionId, VERSION_DRAFT_COLLECTION, DRAFT_DOC_ID);
|
|
119
122
|
}
|
|
120
123
|
/**
|
|
121
124
|
* The tree last written to each draft, by path.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/drafts/besigner-server-draft.ts"],"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\nimport {\n Bytes,\n type Firestore,\n deleteDoc,\n doc,\n getDoc,\n serverTimestamp,\n setDoc,\n} from 'firebase/firestore'\n\nimport {\n type ProcessableNodes,\n decodeStoredNodes,\n encodeStoredNodes,\n} from '@aglyn/aglyn'\nimport type { BesignerDraftIds } from './besigner-draft-store'\n\n/**\n * THE WORKING DRAFT — server-side, shared, one per version (AGL-1152).\n *\n * ## Why this exists alongside the local store\n *\n * `besigner-draft-store` is a crash net: it holds keystrokes that were never\n * saved, in this browser, and dies the moment a save succeeds. That is still\n * exactly what it should be, and nothing here changes it.\n *\n * This is the other thing asked for, and it is genuinely different: the\n * draft was originally only to save lost work, but now it is becoming a\n * working document and we want to save the working document as we make changes\n * and then publish after we are all done. So a draft here is written\n * DELIBERATELY, survives the browser, and lives until it is published.\n *\n * ## Why it is not a free version history\n *\n * The same line AGL-1256 drew still holds, and this stays on the safe side of\n * it for a structural reason rather than a promise: the document id is the\n * constant {@link DRAFT_DOC_ID}. There is no second name to write, so there is\n * no list to browse, nothing to name and nothing to choose between — you\n * cannot have more than one. Versions remain the paid feature: many of them,\n * restore points, scheduled release, variants, review cycles.\n *\n * ## Why a subcollection and not a field on the version\n *\n * The tenant reads version documents to render. A draft held as a field on one\n * would be shipped to every render of that page and billed on every read of\n * that document, to serve a value the tenant must never show. As its own\n * document it is read only by an editor that opens it, and it gets its own 1MB\n * budget rather than halving the target's.\n *\n * ## Compressed at rest, like the document it shadows\n *\n * A draft holds the WHOLE working tree, so it is the same size as the version\n * it sits beside — and that version is msgpack. Stored as a plain Firestore\n * map instead, the same tree costs about 1.4x as many bytes, which spends the\n * budget above on encoding rather than on content: the largest page on the\n * platform is 574,865 bytes as msgpack and 839,226 as a map, so its draft ran\n * at 80% of the ceiling while the version sat at 55%.\n *\n * That gap also blinded the guard meant to catch it. `measureNodeMap` sizes a\n * tree with the msgpack encoder — correctly, for the documents that use it —\n * so the editor's near-limit warning read the version's 55% for a draft write\n * that was actually at 80%, and the first thing an author would have learned\n * about the ceiling is a save that stopped working.\n *\n * ## Co-editing\n *\n * There is ONE draft per target, not one per person, which is what makes it\n * work with the live mirror rather than against it: the mirror carries\n * in-flight keystrokes between people in the room, and a draft save promotes\n * that shared state to something durable that everyone in the room — and\n * anyone who joins later, from any browser — loads next. That is why saving a\n * draft clears the mirror exactly as saving the document does: Firestore has\n * become authoritative again, and replaying the mirror over it would re-apply\n * edits the draft already contains.\n */\n\n/** The only id a draft may have. One per version, by construction. */\nexport const DRAFT_DOC_ID = 'current'\n\nexport interface BesignerServerDraft {\n nodes: ProcessableNodes\n /**\n * The stored document's version stamp when this draft was taken. What lets\n * the editor say \"someone published since you started\" honestly rather than\n * silently overwriting them (AGL-674).\n */\n baseStamp: string | null\n /** Who last wrote it — a shared draft needs to say whose work it holds. */\n updatedByUid: string | null\n updatedByEmail: string | null\n}\n\n/**\n * A draft as the store hands it back: what was written, plus WHEN.\n *\n * The time is the server's stamp, not the reader's clock. It is what the\n * editor tells an author about the draft's age, and a draft saved yesterday\n * that is described as \"less than a minute ago\" reads as work somebody is\n * doing right now — the one thing a stranded draft is not (AGL-2868).\n */\nexport interface StoredServerDraft extends BesignerServerDraft {\n /** Epoch milliseconds of the last write, or null when the document carries no stamp. */\n updatedAt: number | null\n}\n\n/**\n * Epoch milliseconds from a stored stamp — a Firestore `Timestamp`, or its\n * `{ seconds, nanoseconds }` shape once it has crossed a serialization — or\n * null for anything else. Null is an honest \"not known\", which the banner\n * renders by not naming an age at all.\n */\nfunction stampMillis(value: unknown): number | null {\n if (!value || typeof value !== 'object') return null\n const stamp = value as {\n toMillis?: () => number\n seconds?: number\n nanoseconds?: number\n }\n if (typeof stamp.toMillis === 'function') {\n try {\n const millis = stamp.toMillis()\n return Number.isFinite(millis) ? millis : null\n } catch {\n return null\n }\n }\n if (typeof stamp.seconds === 'number' && Number.isFinite(stamp.seconds)) {\n return stamp.seconds * 1000 + Math.floor((stamp.nanoseconds ?? 0) / 1e6)\n }\n return null\n}\n\n/**\n * `screen` → `screens`. The kinds that have no versioned subcollection get no\n * draft: a template IS its document, so there is nothing for a draft to sit\n * beside, and returning null here is what keeps callers from inventing a path.\n */\nconst COLLECTION_OF: Partial<Record<BesignerDraftIds['kind'], string>> = {\n screen: 'screens',\n layout: 'layouts',\n component: 'components',\n form: 'forms',\n}\n\n/**\n * The draft's document, or null when this target cannot hold one — no host\n * scope, no version, or a kind with no versions. Null is a supported answer\n * and every caller treats it as \"no draft here\", never as an error.\n */\nexport function serverDraftRef(firestore: Firestore, ids: BesignerDraftIds) {\n const collection = COLLECTION_OF[ids.kind]\n if (!collection || !ids.scope || ids.scope === 'platform') return null\n if (!ids.docId || !ids.versionId) return null\n return doc(\n firestore,\n 'hosts',\n ids.scope,\n collection,\n ids.docId,\n 'versions',\n ids.versionId,\n 'draft',\n DRAFT_DOC_ID,\n )\n}\n\n/**\n * Writes the working draft. Resolves false rather than throwing when the\n * target cannot hold one, so a caller does not have to re-derive that.\n */\n/**\n * What a draft save did.\n *\n * `unchanged` is a SUCCESS, not a failure: the draft already holds this tree.\n * Distinguished from `written` because the two deserve different words on\n * screen — \"Draft saved\" said four times over an untouched document is how a\n * reader stops believing the message (AGL-1483).\n */\nexport type ServerDraftWrite = 'written' | 'unchanged' | 'failed'\n\n/**\n * The tree last written to each draft, by path.\n *\n * Module scope, so all three editors get the check without repeating it, and\n * so it survives a re-render rather than a mount.\n *\n * A LOCAL baseline, deliberately, where `handleSave` insists on comparing\n * against the stored document. The two are guarding opposite mistakes.\n * `handleSave` must never skip a write that is needed, so a baseline that\n * lies would lose work and it re-reads to be sure. Here a stale baseline\n * only ever causes an extra identical write, which costs one document and\n * changes nothing — while reading the draft back on every click would cost a\n * Firestore read per click for a check nothing depends on.\n */\nconst lastWritten = new Map<string, string>()\n\nexport async function writeServerDraft(\n firestore: Firestore,\n ids: BesignerDraftIds,\n draft: BesignerServerDraft,\n): Promise<ServerDraftWrite> {\n const ref = serverDraftRef(firestore, ids)\n if (!ref) return 'failed'\n // Keyed on the whole payload, not just the nodes: a draft carries the base\n // stamp it was taken against, and one taken against a newer document is a\n // different draft even when the tree is identical.\n const fingerprint = JSON.stringify([\n draft.nodes,\n draft.baseStamp ?? null,\n draft.updatedByUid ?? null,\n ])\n if (lastWritten.get(ref.path) === fingerprint) return 'unchanged'\n // Compressed at rest, matching the version this shadows. `nodes` is taken\n // out of the spread rather than overwritten after it, so the plain tree can\n // never reach the write through a future edit that reorders these keys.\n const { nodes, ...rest } = draft\n const packed = encodeStoredNodes(nodes)\n // Not `merge`: a draft is the whole working tree, and merging a smaller\n // tree into a larger one would leave nodes from a previous save behind —\n // the shape of AGL-1445, where a partial write resurrects deleted content.\n await setDoc(ref, {\n ...rest,\n // `Bytes` is what the client SDK accepts for a bytes field;\n // `encodeStoredNodes` returns a bare array so it can stay Firestore-free.\n ...(packed ? { nodes: Bytes.fromUint8Array(packed) } : {}),\n updatedAt: serverTimestamp(),\n })\n lastWritten.set(ref.path, fingerprint)\n return 'written'\n}\n\nexport async function readServerDraft(\n firestore: Firestore,\n ids: BesignerDraftIds,\n): Promise<StoredServerDraft | null> {\n const ref = serverDraftRef(firestore, ids)\n if (!ref) return null\n const snapshot = await getDoc(ref)\n if (!snapshot.exists()) return null\n // `estimate`: a draft this browser wrote a moment ago can still have its\n // `serverTimestamp` pending, and the local estimate of it is a truer age\n // than none.\n const data = snapshot.data({ serverTimestamps: 'estimate' }) as Partial<\n BesignerServerDraft & { updatedAt: unknown }\n >\n // BOTH stored forms, permanently. Drafts written before compression are\n // plain maps and nothing migrates them, so a reader that understood only\n // bytes would find no tree and report the draft absent — offering an author\n // nothing where their unpublished work actually is. `decodeStoredNodes`\n // returns a plain map unchanged, so one call covers both.\n const nodes = decodeStoredNodes<ProcessableNodes>(data?.nodes)\n // A draft with no tree is not a draft. Guarding here rather than at the call\n // site because a half-written document should read as absent, not as an\n // empty canvas someone is about to publish over their page.\n if (!nodes) return null\n return {\n nodes,\n baseStamp: data.baseStamp ?? null,\n updatedByUid: data.updatedByUid ?? null,\n updatedByEmail: data.updatedByEmail ?? null,\n updatedAt: stampMillis(data.updatedAt),\n }\n}\n\n/**\n * Clears the working draft. Called when it has been PUBLISHED — the work is in\n * the document now, so a draft that outlived it would offer to restore the\n * state the author just moved past.\n */\nexport async function clearServerDraft(\n firestore: Firestore,\n ids: BesignerDraftIds,\n): Promise<void> {\n const ref = serverDraftRef(firestore, ids)\n if (!ref) return\n // Forget the fingerprint with the draft. Otherwise the next save of the\n // same tree — a publish, then an undo back to it — would report itself\n // unchanged against a draft that no longer exists.\n lastWritten.delete(ref.path)\n // Best effort: a publish that succeeded must not report failure because the\n // tidy-up afterwards did. A stale draft is offered, not applied.\n await deleteDoc(ref).catch(() => undefined)\n}\n"],"names":["Bytes","deleteDoc","doc","getDoc","serverTimestamp","setDoc","decodeStoredNodes","encodeStoredNodes","DRAFT_DOC_ID","stampMillis","value","stamp","toMillis","millis","Number","isFinite","seconds","Math","floor","nanoseconds","COLLECTION_OF","screen","layout","component","form","serverDraftRef","firestore","ids","collection","kind","scope","docId","versionId","lastWritten","Map","writeServerDraft","draft","ref","fingerprint","JSON","stringify","nodes","baseStamp","updatedByUid","get","path","rest","packed","fromUint8Array","updatedAt","set","readServerDraft","data","snapshot","exists","serverTim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;QAAEG,kBAAkB;IAAW;IAG1D,wEAAwE;IACxE,yEAAyE;IACzE,4EAA4E;IAC5E,wEAAwE;IACxE,0DAA0D;IAC1D,MAAMd,QAAQnC,kBAAoC8C,wBAAAA,KAAMX,KAAK;IAC7D,6EAA6E;IAC7E,wEAAwE;IACxE,4DAA4D;IAC5D,IAAI,CAACA,OAAO,OAAO;IACnB,OAAO;QACLA;QACAC,SAAS,GAAEU,kBAAAA,KAAKV,SAAS,YAAdU,kBAAkB;QAC7BT,YAAY,GAAES,qBAAAA,KAAKT,YAAY,YAAjBS,qBAAqB;QACnCI,cAAc,GAAEJ,uBAAAA,KAAKI,cAAc,YAAnBJ,uBAAuB;QACvCH,WAAWxC,YAAY2C,KAAKH,SAAS;IACvC;AACF;AAEA;;;;CAIC,GACD,OAAO,eAAeQ,iBACpB/B,SAAoB,EACpBC,GAAqB;IAErB,MAAMU,MAAMZ,eAAeC,WAAWC;IACtC,IAAI,CAACU,KAAK;IACV,wEAAwE;IACxE,uEAAuE;IACvE,mDAAmD;IACnDJ,YAAYyB,MAAM,CAACrB,IAAIQ,IAAI;IAC3B,4EAA4E;IAC5E,iEAAiE;IACjE,MAAM5C,UAAUoC,KAAKsB,KAAK,CAAC,IAAMC;AACnC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/drafts/besigner-server-draft.ts"],"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\nimport {\n Bytes,\n type Firestore,\n deleteDoc,\n doc,\n getDoc,\n serverTimestamp,\n setDoc,\n} from 'firebase/firestore'\n\nimport {\n type ProcessableNodes,\n VERSION_DRAFT_COLLECTION,\n VERSION_DRAFT_DOC_ID,\n decodeStoredNodes,\n encodeStoredNodes,\n} from '@aglyn/aglyn'\nimport type { BesignerDraftIds } from './besigner-draft-store'\n\n/**\n * THE WORKING DRAFT — server-side, shared, one per version (AGL-1152).\n *\n * ## Why this exists alongside the local store\n *\n * `besigner-draft-store` is a crash net: it holds keystrokes that were never\n * saved, in this browser, and dies the moment a save succeeds. That is still\n * exactly what it should be, and nothing here changes it.\n *\n * This is the other thing asked for, and it is genuinely different: the\n * draft was originally only to save lost work, but now it is becoming a\n * working document and we want to save the working document as we make changes\n * and then publish after we are all done. So a draft here is written\n * DELIBERATELY, survives the browser, and lives until it is published.\n *\n * ## Why it is not a free version history\n *\n * The same line AGL-1256 drew still holds, and this stays on the safe side of\n * it for a structural reason rather than a promise: the document id is the\n * constant {@link DRAFT_DOC_ID}. There is no second name to write, so there is\n * no list to browse, nothing to name and nothing to choose between — you\n * cannot have more than one. Versions remain the paid feature: many of them,\n * restore points, scheduled release, variants, review cycles.\n *\n * ## Why a subcollection and not a field on the version\n *\n * The tenant reads version documents to render. A draft held as a field on one\n * would be shipped to every render of that page and billed on every read of\n * that document, to serve a value the tenant must never show. As its own\n * document it is read only by an editor that opens it, and it gets its own 1MB\n * budget rather than halving the target's.\n *\n * ## Compressed at rest, like the document it shadows\n *\n * A draft holds the WHOLE working tree, so it is the same size as the version\n * it sits beside — and that version is msgpack. Stored as a plain Firestore\n * map instead, the same tree costs about 1.4x as many bytes, which spends the\n * budget above on encoding rather than on content: the largest page on the\n * platform is 574,865 bytes as msgpack and 839,226 as a map, so its draft ran\n * at 80% of the ceiling while the version sat at 55%.\n *\n * That gap also blinded the guard meant to catch it. `measureNodeMap` sizes a\n * tree with the msgpack encoder — correctly, for the documents that use it —\n * so the editor's near-limit warning read the version's 55% for a draft write\n * that was actually at 80%, and the first thing an author would have learned\n * about the ceiling is a save that stopped working.\n *\n * ## Co-editing\n *\n * There is ONE draft per target, not one per person, which is what makes it\n * work with the live mirror rather than against it: the mirror carries\n * in-flight keystrokes between people in the room, and a draft save promotes\n * that shared state to something durable that everyone in the room — and\n * anyone who joins later, from any browser — loads next. That is why saving a\n * draft clears the mirror exactly as saving the document does: Firestore has\n * become authoritative again, and replaying the mirror over it would re-apply\n * edits the draft already contains.\n */\n\n/**\n * The only id a draft may have. One per version, by construction. Read from\n * the core, which an AI edit job writes the same draft through (AGL-4116).\n */\nexport const DRAFT_DOC_ID = VERSION_DRAFT_DOC_ID\n\nexport interface BesignerServerDraft {\n nodes: ProcessableNodes\n /**\n * The stored document's version stamp when this draft was taken. What lets\n * the editor say \"someone published since you started\" honestly rather than\n * silently overwriting them (AGL-674).\n */\n baseStamp: string | null\n /** Who last wrote it — a shared draft needs to say whose work it holds. */\n updatedByUid: string | null\n updatedByEmail: string | null\n}\n\n/**\n * A draft as the store hands it back: what was written, plus WHEN.\n *\n * The time is the server's stamp, not the reader's clock. It is what the\n * editor tells an author about the draft's age, and a draft saved yesterday\n * that is described as \"less than a minute ago\" reads as work somebody is\n * doing right now — the one thing a stranded draft is not (AGL-2868).\n */\nexport interface StoredServerDraft extends BesignerServerDraft {\n /** Epoch milliseconds of the last write, or null when the document carries no stamp. */\n updatedAt: number | null\n}\n\n/**\n * Epoch milliseconds from a stored stamp — a Firestore `Timestamp`, or its\n * `{ seconds, nanoseconds }` shape once it has crossed a serialization — or\n * null for anything else. Null is an honest \"not known\", which the banner\n * renders by not naming an age at all.\n */\nfunction stampMillis(value: unknown): number | null {\n if (!value || typeof value !== 'object') return null\n const stamp = value as {\n toMillis?: () => number\n seconds?: number\n nanoseconds?: number\n }\n if (typeof stamp.toMillis === 'function') {\n try {\n const millis = stamp.toMillis()\n return Number.isFinite(millis) ? millis : null\n } catch {\n return null\n }\n }\n if (typeof stamp.seconds === 'number' && Number.isFinite(stamp.seconds)) {\n return stamp.seconds * 1000 + Math.floor((stamp.nanoseconds ?? 0) / 1e6)\n }\n return null\n}\n\n/**\n * `screen` → `screens`. The kinds that have no versioned subcollection get no\n * draft: a template IS its document, so there is nothing for a draft to sit\n * beside, and returning null here is what keeps callers from inventing a path.\n */\nconst COLLECTION_OF: Partial<Record<BesignerDraftIds['kind'], string>> = {\n screen: 'screens',\n layout: 'layouts',\n component: 'components',\n form: 'forms',\n}\n\n/**\n * The draft's document, or null when this target cannot hold one — no host\n * scope, no version, or a kind with no versions. Null is a supported answer\n * and every caller treats it as \"no draft here\", never as an error.\n */\nexport function serverDraftRef(firestore: Firestore, ids: BesignerDraftIds) {\n const collection = COLLECTION_OF[ids.kind]\n if (!collection || !ids.scope || ids.scope === 'platform') return null\n if (!ids.docId || !ids.versionId) return null\n return doc(\n firestore,\n 'hosts',\n ids.scope,\n collection,\n ids.docId,\n 'versions',\n ids.versionId,\n VERSION_DRAFT_COLLECTION,\n DRAFT_DOC_ID,\n )\n}\n\n/**\n * Writes the working draft. Resolves false rather than throwing when the\n * target cannot hold one, so a caller does not have to re-derive that.\n */\n/**\n * What a draft save did.\n *\n * `unchanged` is a SUCCESS, not a failure: the draft already holds this tree.\n * Distinguished from `written` because the two deserve different words on\n * screen — \"Draft saved\" said four times over an untouched document is how a\n * reader stops believing the message (AGL-1483).\n */\nexport type ServerDraftWrite = 'written' | 'unchanged' | 'failed'\n\n/**\n * The tree last written to each draft, by path.\n *\n * Module scope, so all three editors get the check without repeating it, and\n * so it survives a re-render rather than a mount.\n *\n * A LOCAL baseline, deliberately, where `handleSave` insists on comparing\n * against the stored document. The two are guarding opposite mistakes.\n * `handleSave` must never skip a write that is needed, so a baseline that\n * lies would lose work and it re-reads to be sure. Here a stale baseline\n * only ever causes an extra identical write, which costs one document and\n * changes nothing — while reading the draft back on every click would cost a\n * Firestore read per click for a check nothing depends on.\n */\nconst lastWritten = new Map<string, string>()\n\nexport async function writeServerDraft(\n firestore: Firestore,\n ids: BesignerDraftIds,\n draft: BesignerServerDraft,\n): Promise<ServerDraftWrite> {\n const ref = serverDraftRef(firestore, ids)\n if (!ref) return 'failed'\n // Keyed on the whole payload, not just the nodes: a draft carries the base\n // stamp it was taken against, and one taken against a newer document is a\n // different draft even when the tree is identical.\n const fingerprint = JSON.stringify([\n draft.nodes,\n draft.baseStamp ?? null,\n draft.updatedByUid ?? null,\n ])\n if (lastWritten.get(ref.path) === fingerprint) return 'unchanged'\n // Compressed at rest, matching the version this shadows. `nodes` is taken\n // out of the spread rather than overwritten after it, so the plain tree can\n // never reach the write through a future edit that reorders these keys.\n const { nodes, ...rest } = draft\n const packed = encodeStoredNodes(nodes)\n // Not `merge`: a draft is the whole working tree, and merging a smaller\n // tree into a larger one would leave nodes from a previous save behind —\n // the shape of AGL-1445, where a partial write resurrects deleted content.\n await setDoc(ref, {\n ...rest,\n // `Bytes` is what the client SDK accepts for a bytes field;\n // `encodeStoredNodes` returns a bare array so it can stay Firestore-free.\n ...(packed ? { nodes: Bytes.fromUint8Array(packed) } : {}),\n updatedAt: serverTimestamp(),\n })\n lastWritten.set(ref.path, fingerprint)\n return 'written'\n}\n\nexport async function readServerDraft(\n firestore: Firestore,\n ids: BesignerDraftIds,\n): Promise<StoredServerDraft | null> {\n const ref = serverDraftRef(firestore, ids)\n if (!ref) return null\n const snapshot = await getDoc(ref)\n if (!snapshot.exists()) return null\n // `estimate`: a draft this browser wrote a moment ago can still have its\n // `serverTimestamp` pending, and the local estimate of it is a truer age\n // than none.\n const data = snapshot.data({ serverTimestamps: 'estimate' }) as Partial<\n BesignerServerDraft & { updatedAt: unknown }\n >\n // BOTH stored forms, permanently. Drafts written before compression are\n // plain maps and nothing migrates them, so a reader that understood only\n // bytes would find no tree and report the draft absent — offering an author\n // nothing where their unpublished work actually is. `decodeStoredNodes`\n // returns a plain map unchanged, so one call covers both.\n const nodes = decodeStoredNodes<ProcessableNodes>(data?.nodes)\n // A draft with no tree is not a draft. Guarding here rather than at the call\n // site because a half-written document should read as absent, not as an\n // empty canvas someone is about to publish over their page.\n if (!nodes) return null\n return {\n nodes,\n baseStamp: data.baseStamp ?? null,\n updatedByUid: data.updatedByUid ?? null,\n updatedByEmail: data.updatedByEmail ?? null,\n updatedAt: stampMillis(data.updatedAt),\n }\n}\n\n/**\n * Clears the working draft. Called when it has been PUBLISHED — the work is in\n * the document now, so a draft that outlived it would offer to restore the\n * state the author just moved past.\n */\nexport async function clearServerDraft(\n firestore: Firestore,\n ids: BesignerDraftIds,\n): Promise<void> {\n const ref = serverDraftRef(firestore, ids)\n if (!ref) return\n // Forget the fingerprint with the draft. Otherwise the next save of the\n // same tree — a publish, then an undo back to it — would report itself\n // unchanged against a draft that no longer exists.\n lastWritten.delete(ref.path)\n // Best effort: a publish that succeeded must not report failure because the\n // tidy-up afterwards did. A stale draft is offered, not applied.\n await deleteDoc(ref).catch(() => undefined)\n}\n"],"names":["Bytes","deleteDoc","doc","getDoc","serverTimestamp","setDoc","VERSION_DRAFT_COLLECTION","VERSION_DRAFT_DOC_ID","decodeStoredNodes","encodeStoredNodes","DRAFT_DOC_ID","stampMillis","value","stamp","toMillis","millis","Number","isFinite","seconds","Math","floor","nanoseconds","COLLECTION_OF","screen","layout","component","form","serverDraftRef","firestore","ids","collection","kind","scope","docId","versionId","lastWritten","Map","writeServerDraft","draft","ref","fingerprint","JSON","stringify","nodes","baseStamp","updatedByUid","get","path","rest","packed","fromUint8Array","updatedAt","set","readServerDraft","data","snapshot","exists","serverTimestamps","updatedByEmail","clearServerDraft","delete","catch","undefined"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,KAAK,EAELC,SAAS,EACTC,GAAG,EACHC,MAAM,EACNC,eAAe,EACfC,MAAM,QACD,qBAAoB;AAE3B,SAEEC,wBAAwB,EACxBC,oBAAoB,EACpBC,iBAAiB,EACjBC,iBAAiB,QACZ,eAAc;AAGrB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyDC,GAED;;;CAGC,GACD,OAAO,MAAMC,eAAeH,qBAAo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KT,YAAY,YAAjBS,qBAAqB;QACnCI,cAAc,GAAEJ,uBAAAA,KAAKI,cAAc,YAAnBJ,uBAAuB;QACvCH,WAAWxC,YAAY2C,KAAKH,SAAS;IACvC;AACF;AAEA;;;;CAIC,GACD,OAAO,eAAeQ,iBACpB/B,SAAoB,EACpBC,GAAqB;IAErB,MAAMU,MAAMZ,eAAeC,WAAWC;IACtC,IAAI,CAACU,KAAK;IACV,wEAAwE;IACxE,uEAAuE;IACvE,mDAAmD;IACnDJ,YAAYyB,MAAM,CAACrB,IAAIQ,IAAI;IAC3B,4EAA4E;IAC5E,iEAAiE;IACjE,MAAM9C,UAAUsC,KAAKsB,KAAK,CAAC,IAAMC;AACnC"}
|
|
@@ -29,7 +29,7 @@ export declare const BESIGNER_DOCS: {
|
|
|
29
29
|
};
|
|
30
30
|
export type BesignerDocsKey = keyof typeof BESIGNER_DOCS;
|
|
31
31
|
export declare const BESIGNER_DOCS_ANCHORS: {
|
|
32
|
-
readonly besigner: readonly ["#preview-vs-canvas", "#what-you-can-do", "#the-canvas", "#hierarchy-panel", "#the-inspector", "#inline-and-rich-text", "#reusable-components", "#editing-together", "#ai-in-the-canvas", "#related"];
|
|
32
|
+
readonly besigner: readonly ["#preview-vs-canvas", "#publish-from-a-preview", "#what-you-can-do", "#the-canvas", "#hierarchy-panel", "#the-inspector", "#inline-and-rich-text", "#reusable-components", "#editing-together", "#ai-in-the-canvas", "#related"];
|
|
33
33
|
readonly bindings: readonly ["#binding-tokens", "#rename-safe-id-tokens", "#insert-a-variable", "#token-pills", "#in-the-canvas-text-editor", "#site-details", "#typed-variables", "#no-code-functions", "#functions-card", "#parameters-a-visitor-can-answer", "#a-calculator-you-lay-out", "#where-used--safety", "#workflows", "#related"];
|
|
34
34
|
readonly dragDropHierarchy: readonly ["#where-you-can-drag", "#what-a-drag-does", "#drop-zones-edges-vs-center", "#containers-vs-leaf-elements", "#containers-accept-children", "#leaf-elements-dont--dropping-on-one-makes-a-sibling", "#adding-a-new-element", "#when-a-drop-is-rejected", "#moving-an-element-without-dragging", "#multi-drag", "#tips", "#related"];
|
|
35
35
|
readonly elementCatalog: readonly ["#finding-an-element", "#element-search", "#element-detail", "#layout", "#the-pages-main-landmark", "#every-container-can-be-a-semantic-element", "#light-or-dark-whatever-the-visitor-picked", "#which-link-groups-want-to-be-a-nav", "#header-and-footer-for-your-site-chrome", "#grid", "#surface", "#accordion", "#navigation", "#where-a-link-opens", "#linking-to-a-collection-listing", "#link-container", "#tabs", "#tabs-that-go-to-another-screen", "#pagination", "#text", "#data-display", "#media", "#image", "#image-list", "#forms", "#commerce", "#members", "#input", "#related"];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/utils/docs-help.generated.ts"],"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// GENERATED FILE — do not edit. Regenerate with:\n// node tools/scripts/generate-docs-help.mjs\n// Source of truth: apps/docs/docs frontmatter + headings (AGL-602).\n\n// The besigner designer lib can't import the console constants, so it carries\n// its own generated subset of the docs help registry.\n\nexport const BESIGNER_DOCS = {\n besigner: '/building-sites/besigner/overview',\n bindings: '/building-sites/bindings/overview',\n dragDropHierarchy: '/building-sites/besigner/drag-drop-hierarchy',\n elementCatalog: '/building-sites/besigner/element-catalog',\n interactions: '/building-sites/besigner/interactions-and-custom-html',\n layouts: '/building-sites/screens-and-layouts/layouts',\n repeat: '/building-sites/besigner/repeat',\n responsiveStyling: '/building-sites/besigner/responsive-styling',\n reusableComponents: '/building-sites/besigner/reusable-components',\n seo: '/building-sites/seo/overview',\n textEditing: '/building-sites/besigner/text-editing',\n} as const satisfies Record<string, string>\n\nexport type BesignerDocsKey = keyof typeof BESIGNER_DOCS\n\nexport const BESIGNER_DOCS_ANCHORS = {\n besigner: ['#preview-vs-canvas', '#what-you-can-do', '#the-canvas', '#hierarchy-panel', '#the-inspector', '#inline-and-rich-text', '#reusable-components', '#editing-together', '#ai-in-the-canvas', '#related'],\n bindings: ['#binding-tokens', '#rename-safe-id-tokens', '#insert-a-variable', '#token-pills', '#in-the-canvas-text-editor', '#site-details', '#typed-variables', '#no-code-functions', '#functions-card', '#parameters-a-visitor-can-answer', '#a-calculator-you-lay-out', '#where-used--safety', '#workflows', '#related'],\n dragDropHierarchy: ['#where-you-can-drag', '#what-a-drag-does', '#drop-zones-edges-vs-center', '#containers-vs-leaf-elements', '#containers-accept-children', '#leaf-elements-dont--dropping-on-one-makes-a-sibling', '#adding-a-new-element', '#when-a-drop-is-rejected', '#moving-an-element-without-dragging', '#multi-drag', '#tips', '#related'],\n elementCatalog: ['#finding-an-element', '#element-search', '#element-detail', '#layout', '#the-pages-main-landmark', '#every-container-can-be-a-semantic-element', '#light-or-dark-whatever-the-visitor-picked', '#which-link-groups-want-to-be-a-nav', '#header-and-footer-for-your-site-chrome', '#grid', '#surface', '#accordion', '#navigation', '#where-a-link-opens', '#linking-to-a-collection-listing', '#link-container', '#tabs', '#tabs-that-go-to-another-screen', '#pagination', '#text', '#data-display', '#media', '#image', '#image-list', '#forms', '#commerce', '#members', '#input', '#related'],\n interactions: ['#fluent-interactions', '#interactions-belong-to-the-page-they-are-on', '#plan-availability', '#pick-the-target-by-clicking', '#interaction-cookbook', '#scroll-to-element-step', '#play-video-step', '#open-a-lightbox', '#analytics-event-step', '#analytics-event-name', '#analytics-event-parameters', '#analytics-event-delivery', '#custom-html-block', '#related'],\n layouts: ['#what-a-layout-is', '#find-a-layout', '#nested-layouts', '#layout-properties', '#restyle-the-layout-on-one-page', '#duplicate', '#generate-a-layout-with-aglyn-ai', '#used-by', '#layouts-vs-reusable-components', '#related'],\n repeat: ['#turn-it-on', '#what-repeats-the-element-or-whats-inside-it', '#fill-each-copy-in', '#see-the-copies-while-you-design', '#bound-what-renders', '#the-hundred-record-ceiling', '#what-you-cant-do', '#when-a-dataset-goes-away', '#related'],\n responsiveStyling: ['#style-per-breakpoint', '#mute-a-style', '#interaction-states', '#you-can-see-the-state-while-you-style-it', '#fields-you-dont-touch-keep-inheriting', '#states-and-breakpoints-combine', '#focus-state', '#box-stylers', '#spacing-side-names', '#spacing-units', '#spacing-steps', '#spacing-custom-amounts', '#unit-px', '#unit-rem', '#unit-em', '#unit-percent', '#unit-ch', '#unit-viewport', '#unit-small-viewport', '#style-groups', '#borders-without-css', '#picking-a-font', '#gradient-backgrounds', '#visibility-per-device-band', '#scheme-scoped-colors', '#pin-a-color-scheme', '#custom-classes', '#custom-css-sx', '#semantic-sections--theme-mode', '#edit-json-for-one-element'],\n reusableComponents: ['#promote', '#insert-instances', '#properties', '#declare-them', '#make-a-property-conditional', '#use-them', '#save-then-publish', '#fill-them-in-per-page', '#restyle-one-instance', '#override-an-attribute-on-one-instance', '#retrofit-duplicated-sections', '#detach', '#nesting', '#used-by', '#manage', '#component-details-card', '#duplicate', '#reusable-email-blocks', '#make-a-header-or-footer', '#add-one-to-an-email', '#change-a-block-in-one-email', '#emails-you-have-not-designed', '#email-theme-colors', '#copy--paste-vs-reusable-components', '#tips', '#related'],\n seo: ['#per-screen-seo', '#how-a-page-title-is-built', '#variables-so-a-title-is-not-a-copy-of-your-site-name', '#site-wide-defaults', '#site-description', '#title-separator', '#title-pattern', '#favicon', '#app-icon', '#site-social-image', '#every-icon-size-is-generated-for-you', '#your-sites-install-details-the-web-app-manifest', '#what-language-your-site-says-it-is-in', '#seo-check', '#target-keywords', '#check-one-page', '#search-engine-visibility', '#the-whole-site', '#a-single-page', '#verify-your-site-with-google-search-console', '#sitemap--robots', '#one-index-one-file-per-section', '#social-cards', '#what-each-kind-of-page-emits', '#structured-data', '#entity-card', '#entity-type', '#entity-name', '#entity-description', '#entity-website', '#entity-contact', '#entity-logo', '#address-card', '#local-businesses', '#ai-agents', '#markdown-for-any-page', '#llmstxt', '#ai-agents-card', '#openapijson', '#well-knownapi-catalog', '#crawler-access', '#analytics-integration', '#related'],\n textEditing: ['#edit-inline', '#committing', '#inline-toolbar', '#rich-text', '#the-text-attribute', '#text-field-formatting', '#remove-formatting', '#line-breaks', '#bindings-in-text', '#limits', '#wrapped-outlines', '#related'],\n} as const satisfies Partial<Record<BesignerDocsKey, readonly `#${string}`[]>>\n\ntype BesignerAnchorMap = typeof BESIGNER_DOCS_ANCHORS\n\n/** Valid heading anchors for a besigner docs page (`never` when none). */\nexport type BesignerDocsAnchor<K extends BesignerDocsKey> =\n K extends keyof BesignerAnchorMap ? BesignerAnchorMap[K][number] : never\n"],"names":["BESIGNER_DOCS","besigner","bindings","dragDropHierarchy","elementCatalog","interactions","layouts","repeat","responsiveStyling","reusableComponents","seo","textEditing","BESIGNER_DOCS_ANCHORS"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD,iDAAiD;AACjD,8CAA8C;AAC9C,oEAAoE;AAEpE,8EAA8E;AAC9E,sDAAsD;AAEtD,OAAO,MAAMA,gBAAgB;IAC3BC,UAAU;IACVC,UAAU;IACVC,mBAAmB;IACnBC,gBAAgB;IAChBC,cAAc;IACdC,SAAS;IACTC,QAAQ;IACRC,mBAAmB;IACnBC,oBAAoB;IACpBC,KAAK;IACLC,aAAa;AACf,EAA2C;AAI3C,OAAO,MAAMC,wBAAwB;IACnCX,UAAU;QAAC;QAAsB;QAAoB;QAAe;QAAoB;QAAkB;QAAyB;QAAwB;QAAqB;QAAqB;KAAW;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/utils/docs-help.generated.ts"],"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// GENERATED FILE — do not edit. Regenerate with:\n// node tools/scripts/generate-docs-help.mjs\n// Source of truth: apps/docs/docs frontmatter + headings (AGL-602).\n\n// The besigner designer lib can't import the console constants, so it carries\n// its own generated subset of the docs help registry.\n\nexport const BESIGNER_DOCS = {\n besigner: '/building-sites/besigner/overview',\n bindings: '/building-sites/bindings/overview',\n dragDropHierarchy: '/building-sites/besigner/drag-drop-hierarchy',\n elementCatalog: '/building-sites/besigner/element-catalog',\n interactions: '/building-sites/besigner/interactions-and-custom-html',\n layouts: '/building-sites/screens-and-layouts/layouts',\n repeat: '/building-sites/besigner/repeat',\n responsiveStyling: '/building-sites/besigner/responsive-styling',\n reusableComponents: '/building-sites/besigner/reusable-components',\n seo: '/building-sites/seo/overview',\n textEditing: '/building-sites/besigner/text-editing',\n} as const satisfies Record<string, string>\n\nexport type BesignerDocsKey = keyof typeof BESIGNER_DOCS\n\nexport const BESIGNER_DOCS_ANCHORS = {\n besigner: ['#preview-vs-canvas', '#publish-from-a-preview', '#what-you-can-do', '#the-canvas', '#hierarchy-panel', '#the-inspector', '#inline-and-rich-text', '#reusable-components', '#editing-together', '#ai-in-the-canvas', '#related'],\n bindings: ['#binding-tokens', '#rename-safe-id-tokens', '#insert-a-variable', '#token-pills', '#in-the-canvas-text-editor', '#site-details', '#typed-variables', '#no-code-functions', '#functions-card', '#parameters-a-visitor-can-answer', '#a-calculator-you-lay-out', '#where-used--safety', '#workflows', '#related'],\n dragDropHierarchy: ['#where-you-can-drag', '#what-a-drag-does', '#drop-zones-edges-vs-center', '#containers-vs-leaf-elements', '#containers-accept-children', '#leaf-elements-dont--dropping-on-one-makes-a-sibling', '#adding-a-new-element', '#when-a-drop-is-rejected', '#moving-an-element-without-dragging', '#multi-drag', '#tips', '#related'],\n elementCatalog: ['#finding-an-element', '#element-search', '#element-detail', '#layout', '#the-pages-main-landmark', '#every-container-can-be-a-semantic-element', '#light-or-dark-whatever-the-visitor-picked', '#which-link-groups-want-to-be-a-nav', '#header-and-footer-for-your-site-chrome', '#grid', '#surface', '#accordion', '#navigation', '#where-a-link-opens', '#linking-to-a-collection-listing', '#link-container', '#tabs', '#tabs-that-go-to-another-screen', '#pagination', '#text', '#data-display', '#media', '#image', '#image-list', '#forms', '#commerce', '#members', '#input', '#related'],\n interactions: ['#fluent-interactions', '#interactions-belong-to-the-page-they-are-on', '#plan-availability', '#pick-the-target-by-clicking', '#interaction-cookbook', '#scroll-to-element-step', '#play-video-step', '#open-a-lightbox', '#analytics-event-step', '#analytics-event-name', '#analytics-event-parameters', '#analytics-event-delivery', '#custom-html-block', '#related'],\n layouts: ['#what-a-layout-is', '#find-a-layout', '#nested-layouts', '#layout-properties', '#restyle-the-layout-on-one-page', '#duplicate', '#generate-a-layout-with-aglyn-ai', '#used-by', '#layouts-vs-reusable-components', '#related'],\n repeat: ['#turn-it-on', '#what-repeats-the-element-or-whats-inside-it', '#fill-each-copy-in', '#see-the-copies-while-you-design', '#bound-what-renders', '#the-hundred-record-ceiling', '#what-you-cant-do', '#when-a-dataset-goes-away', '#related'],\n responsiveStyling: ['#style-per-breakpoint', '#mute-a-style', '#interaction-states', '#you-can-see-the-state-while-you-style-it', '#fields-you-dont-touch-keep-inheriting', '#states-and-breakpoints-combine', '#focus-state', '#box-stylers', '#spacing-side-names', '#spacing-units', '#spacing-steps', '#spacing-custom-amounts', '#unit-px', '#unit-rem', '#unit-em', '#unit-percent', '#unit-ch', '#unit-viewport', '#unit-small-viewport', '#style-groups', '#borders-without-css', '#picking-a-font', '#gradient-backgrounds', '#visibility-per-device-band', '#scheme-scoped-colors', '#pin-a-color-scheme', '#custom-classes', '#custom-css-sx', '#semantic-sections--theme-mode', '#edit-json-for-one-element'],\n reusableComponents: ['#promote', '#insert-instances', '#properties', '#declare-them', '#make-a-property-conditional', '#use-them', '#save-then-publish', '#fill-them-in-per-page', '#restyle-one-instance', '#override-an-attribute-on-one-instance', '#retrofit-duplicated-sections', '#detach', '#nesting', '#used-by', '#manage', '#component-details-card', '#duplicate', '#reusable-email-blocks', '#make-a-header-or-footer', '#add-one-to-an-email', '#change-a-block-in-one-email', '#emails-you-have-not-designed', '#email-theme-colors', '#copy--paste-vs-reusable-components', '#tips', '#related'],\n seo: ['#per-screen-seo', '#how-a-page-title-is-built', '#variables-so-a-title-is-not-a-copy-of-your-site-name', '#site-wide-defaults', '#site-description', '#title-separator', '#title-pattern', '#favicon', '#app-icon', '#site-social-image', '#every-icon-size-is-generated-for-you', '#your-sites-install-details-the-web-app-manifest', '#what-language-your-site-says-it-is-in', '#seo-check', '#target-keywords', '#check-one-page', '#search-engine-visibility', '#the-whole-site', '#a-single-page', '#verify-your-site-with-google-search-console', '#sitemap--robots', '#one-index-one-file-per-section', '#social-cards', '#what-each-kind-of-page-emits', '#structured-data', '#entity-card', '#entity-type', '#entity-name', '#entity-description', '#entity-website', '#entity-contact', '#entity-logo', '#address-card', '#local-businesses', '#ai-agents', '#markdown-for-any-page', '#llmstxt', '#ai-agents-card', '#openapijson', '#well-knownapi-catalog', '#crawler-access', '#analytics-integration', '#related'],\n textEditing: ['#edit-inline', '#committing', '#inline-toolbar', '#rich-text', '#the-text-attribute', '#text-field-formatting', '#remove-formatting', '#line-breaks', '#bindings-in-text', '#limits', '#wrapped-outlines', '#related'],\n} as const satisfies Partial<Record<BesignerDocsKey, readonly `#${string}`[]>>\n\ntype BesignerAnchorMap = typeof BESIGNER_DOCS_ANCHORS\n\n/** Valid heading anchors for a besigner docs page (`never` when none). */\nexport type BesignerDocsAnchor<K extends BesignerDocsKey> =\n K extends keyof BesignerAnchorMap ? BesignerAnchorMap[K][number] : never\n"],"names":["BESIGNER_DOCS","besigner","bindings","dragDropHierarchy","elementCatalog","interactions","layouts","repeat","responsiveStyling","reusableComponents","seo","textEditing","BESIGNER_DOCS_ANCHORS"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD,iDAAiD;AACjD,8CAA8C;AAC9C,oEAAoE;AAEpE,8EAA8E;AAC9E,sDAAsD;AAEtD,OAAO,MAAMA,gBAAgB;IAC3BC,UAAU;IACVC,UAAU;IACVC,mBAAmB;IACnBC,gBAAgB;IAChBC,cAAc;IACdC,SAAS;IACTC,QAAQ;IACRC,mBAAmB;IACnBC,oBAAoB;IACpBC,KAAK;IACLC,aAAa;AACf,EAA2C;AAI3C,OAAO,MAAMC,wBAAwB;IACnCX,UAAU;QAAC;QAAsB;QAA2B;QAAoB;QAAe;QAAoB;QAAkB;QAAyB;QAAwB;QAAqB;QAAqB;KAAW;IAC3OC,UAAU;QAAC;QAAmB;QAA0B;QAAsB;QAAgB;QAA8B;QAAiB;QAAoB;QAAsB;QAAmB;QAAoC;QAA6B;QAAuB;QAAc;KAAW;IAC3TC,mBAAmB;QAAC;QAAuB;QAAqB;QAA+B;QAAgC;QAA+B;QAAwD;QAAyB;QAA4B;QAAuC;QAAe;QAAS;KAAW;IACrVC,gBAAgB;QAAC;QAAuB;QAAmB;QAAmB;QAAW;QAA4B;QAA8C;QAA8C;QAAuC;QAA2C;QAAS;QAAY;QAAc;QAAe;QAAuB;QAAoC;QAAmB;QAAS;QAAmC;QAAe;QAAS;QAAiB;QAAU;QAAU;QAAe;QAAU;QAAa;QAAY;QAAU;KAAW;IACnlBC,cAAc;QAAC;QAAwB;QAAgD;QAAsB;QAAgC;QAAyB;QAA2B;QAAoB;QAAoB;QAAyB;QAAyB;QAA+B;QAA6B;QAAsB;KAAW;IACxXC,SAAS;QAAC;QAAqB;QAAkB;QAAmB;QAAsB;QAAmC;QAAc;QAAoC;QAAY;QAAmC;KAAW;IACzOC,QAAQ;QAAC;QAAe;QAAgD;QAAsB;QAAoC;QAAuB;QAA+B;QAAqB;QAA6B;KAAW;IACrPC,mBAAmB;QAAC;QAAyB;QAAiB;QAAuB;QAA6C;QAA0C;QAAmC;QAAgB;QAAgB;QAAuB;QAAkB;QAAkB;QAA2B;QAAY;QAAa;QAAY;QAAiB;QAAY;QAAkB;QAAwB;QAAiB;QAAwB;QAAmB;QAAyB;QAA+B;QAAyB;QAAuB;QAAmB;QAAkB;QAAkC;KAA6B;IACzrBC,oBAAoB;QAAC;QAAY;QAAqB;QAAe;QAAiB;QAAgC;QAAa;QAAsB;QAA0B;QAAyB;QAA0C;QAAiC;QAAW;QAAY;QAAY;QAAW;QAA2B;QAAc;QAA0B;QAA4B;QAAwB;QAAgC;QAAiC;QAAuB;QAAuC;QAAS;KAAW;IAC/kBC,KAAK;QAAC;QAAmB;QAA8B;QAAyD;QAAuB;QAAqB;QAAoB;QAAkB;QAAY;QAAa;QAAsB;QAAyC;QAAoD;QAA0C;QAAc;QAAoB;QAAmB;QAA6B;QAAmB;QAAkB;QAAgD;QAAoB;QAAmC;QAAiB;QAAiC;QAAoB;QAAgB;QAAgB;QAAgB;QAAuB;QAAmB;QAAmB;QAAgB;QAAiB;QAAqB;QAAc;QAA0B;QAAY;QAAmB;QAAgB;QAA0B;QAAmB;QAA0B;KAAW;IACx+BC,aAAa;QAAC;QAAgB;QAAe;QAAmB;QAAc;QAAuB;QAA0B;QAAsB;QAAgB;QAAqB;QAAW;QAAqB;KAAW;AACvO,EAA8E"}
|
|
@@ -23,9 +23,16 @@ export declare const REPEAT_COPY_ATTR = "data-aglyn-repeat-copy";
|
|
|
23
23
|
* that is not a copy comes back as it is.
|
|
24
24
|
*/
|
|
25
25
|
export declare function repeatTemplateIdOf(id: string): string;
|
|
26
|
+
/** A repeat copy the pointer is on, and the real element it is a picture of. */
|
|
27
|
+
export interface RepeatCopyHit {
|
|
28
|
+
/** The element the copy draws: the one an edit changes. */
|
|
29
|
+
original: Aglyn.NodeSchema<any>;
|
|
30
|
+
/** The copy's own id, `rep__…`, as its rendered stamp carries it. */
|
|
31
|
+
copyId: string;
|
|
32
|
+
}
|
|
26
33
|
/**
|
|
27
|
-
* The
|
|
28
|
-
* when the pointer is not on a copy.
|
|
34
|
+
* The repeat copy under the pointer and the real element it is a picture of,
|
|
35
|
+
* or null when the pointer is not on a copy.
|
|
29
36
|
*
|
|
30
37
|
* The copies (Sam, Jordan beside the real Avery) are inert drawings: nothing
|
|
31
38
|
* in them is a document, so none of them can be selected. A click on one
|
|
@@ -33,13 +40,42 @@ export declare function repeatTemplateIdOf(id: string): string;
|
|
|
33
40
|
* change every copy at once — and the repeating element's own handlers,
|
|
34
41
|
* which the copies are drawn inside, send it there.
|
|
35
42
|
*/
|
|
36
|
-
export declare function
|
|
43
|
+
export declare function repeatCopyAt(target: EventTarget | null): RepeatCopyHit | null;
|
|
44
|
+
/** A copy the canvas outlines in place of the element it draws. */
|
|
45
|
+
export interface RepeatCopyStandIn {
|
|
46
|
+
/** The element hovered or selected. */
|
|
47
|
+
nodeId: string;
|
|
48
|
+
/** The copy of it the pointer is on, or was on when it was clicked. */
|
|
49
|
+
copyId: string;
|
|
50
|
+
}
|
|
37
51
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* card has a copy inside each copy of the card.
|
|
52
|
+
* Which copy the canvas outlines for the hovered and the selected element
|
|
53
|
+
* (AGL-3111).
|
|
41
54
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
55
|
+
* Pointing at or clicking a copy hovers or selects the element it draws, so
|
|
56
|
+
* an edit changes the element and every copy with it — but the outline goes
|
|
57
|
+
* where the pointer is: round that copy, exactly, and nothing else. It used
|
|
58
|
+
* to go round the element, or round the element and all its copies at once,
|
|
59
|
+
* and either way the box was somewhere other than the thing just clicked.
|
|
60
|
+
*
|
|
61
|
+
* Kept by the copy's id rather than its element, since the copies are drawn
|
|
62
|
+
* again whenever what they repeat is edited; and by the element's id with it.
|
|
63
|
+
* A stand-in is dropped the moment the hover or the selection moves to
|
|
64
|
+
* another element, however it moves — the hierarchy, the breadcrumbs, a
|
|
65
|
+
* shortcut — so coming back to the element later outlines the element, not
|
|
66
|
+
* a copy clicked some time before.
|
|
44
67
|
*/
|
|
45
|
-
|
|
68
|
+
declare class RepeatCopyStandIns {
|
|
69
|
+
hovered?: RepeatCopyStandIn;
|
|
70
|
+
selected?: RepeatCopyStandIn;
|
|
71
|
+
constructor();
|
|
72
|
+
private forgetUnless;
|
|
73
|
+
/** Records the copy a hover or a selection was made on, or clears it. */
|
|
74
|
+
set(variant: 'hovered' | 'selected', hit: RepeatCopyHit | null): void;
|
|
75
|
+
/** The copy to outline for `nodeId`, if the hover or selection was made on one. */
|
|
76
|
+
copyIdFor(variant: 'hovered' | 'selected', nodeId: string | undefined): string;
|
|
77
|
+
}
|
|
78
|
+
export declare const repeatCopyStandIns: RepeatCopyStandIns;
|
|
79
|
+
/** The drawn copy `copyId`, in the canvas `element` lives in, or null. */
|
|
80
|
+
export declare function repeatCopyElementIn(element: Element, copyId: string): Element | null;
|
|
81
|
+
export {};
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/ import { canvas } from "@aglyn/aglyn";
|
|
17
17
|
import { REPEAT_NODE_ID_PREFIX } from "@aglyn/aglyn/app-utils/expand-repeatables";
|
|
18
|
+
import * as Besigner from "@aglyn/besigner";
|
|
19
|
+
import { makeAutoObservable, observableRef, reaction } from "mobx";
|
|
18
20
|
const LEAF_STAMP = '[data-aglyn^="leaf:"]';
|
|
19
21
|
/** `rep__<repeating id>__<record>__<original id>`, as the expansion names a copy. */ const REPEAT_COPY_ID = new RegExp(`^${REPEAT_NODE_ID_PREFIX}.+?__\\d+__(.+)$`);
|
|
20
22
|
/** The attribute the canvas puts on each repeat copy's root, for its outline. */ export const REPEAT_COPY_ATTR = 'data-aglyn-repeat-copy';
|
|
@@ -31,38 +33,87 @@ const LEAF_STAMP = '[data-aglyn^="leaf:"]';
|
|
|
31
33
|
return current;
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
34
|
-
* The
|
|
35
|
-
* when the pointer is not on a copy.
|
|
36
|
+
* The repeat copy under the pointer and the real element it is a picture of,
|
|
37
|
+
* or null when the pointer is not on a copy.
|
|
36
38
|
*
|
|
37
39
|
* The copies (Sam, Jordan beside the real Avery) are inert drawings: nothing
|
|
38
40
|
* in them is a document, so none of them can be selected. A click on one
|
|
39
41
|
* still means something — the element it draws, the one an author edits to
|
|
40
42
|
* change every copy at once — and the repeating element's own handlers,
|
|
41
43
|
* which the copies are drawn inside, send it there.
|
|
42
|
-
*/ export function
|
|
43
|
-
var _canvas_getNode;
|
|
44
|
+
*/ export function repeatCopyAt(target) {
|
|
44
45
|
var _leaf_getAttribute;
|
|
45
46
|
const leaf = target instanceof Element ? target.closest(LEAF_STAMP) : null;
|
|
46
|
-
const
|
|
47
|
-
if (!(
|
|
48
|
-
|
|
47
|
+
const copyId = leaf == null ? void 0 : (_leaf_getAttribute = leaf.getAttribute('data-aglyn')) == null ? void 0 : _leaf_getAttribute.slice('leaf:'.length);
|
|
48
|
+
if (!(copyId == null ? void 0 : copyId.startsWith(REPEAT_NODE_ID_PREFIX))) return null;
|
|
49
|
+
const original = canvas.getNode(repeatTemplateIdOf(copyId));
|
|
50
|
+
return original ? {
|
|
51
|
+
original,
|
|
52
|
+
copyId
|
|
53
|
+
} : null;
|
|
49
54
|
}
|
|
50
55
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* card has a copy inside each copy of the card.
|
|
56
|
+
* Which copy the canvas outlines for the hovered and the selected element
|
|
57
|
+
* (AGL-3111).
|
|
54
58
|
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
|
|
59
|
+
* Pointing at or clicking a copy hovers or selects the element it draws, so
|
|
60
|
+
* an edit changes the element and every copy with it — but the outline goes
|
|
61
|
+
* where the pointer is: round that copy, exactly, and nothing else. It used
|
|
62
|
+
* to go round the element, or round the element and all its copies at once,
|
|
63
|
+
* and either way the box was somewhere other than the thing just clicked.
|
|
64
|
+
*
|
|
65
|
+
* Kept by the copy's id rather than its element, since the copies are drawn
|
|
66
|
+
* again whenever what they repeat is edited; and by the element's id with it.
|
|
67
|
+
* A stand-in is dropped the moment the hover or the selection moves to
|
|
68
|
+
* another element, however it moves — the hierarchy, the breadcrumbs, a
|
|
69
|
+
* shortcut — so coming back to the element later outlines the element, not
|
|
70
|
+
* a copy clicked some time before.
|
|
71
|
+
*/ let RepeatCopyStandIns = class RepeatCopyStandIns {
|
|
72
|
+
forgetUnless(variant, nodeId) {
|
|
73
|
+
var _this_variant;
|
|
74
|
+
if (this[variant] && ((_this_variant = this[variant]) == null ? void 0 : _this_variant.nodeId) !== nodeId) {
|
|
75
|
+
this[variant] = undefined;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** Records the copy a hover or a selection was made on, or clears it. */ set(variant, hit) {
|
|
79
|
+
const current = this[variant];
|
|
80
|
+
// Every mouseover lands here; one that changes nothing must not
|
|
81
|
+
// re-render the overlay reading it.
|
|
82
|
+
if ((current == null ? void 0 : current.nodeId) === (hit == null ? void 0 : hit.original.$id) && (current == null ? void 0 : current.copyId) === (hit == null ? void 0 : hit.copyId)) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this[variant] = hit ? {
|
|
86
|
+
nodeId: hit.original.$id,
|
|
87
|
+
copyId: hit.copyId
|
|
88
|
+
} : undefined;
|
|
89
|
+
}
|
|
90
|
+
/** The copy to outline for `nodeId`, if the hover or selection was made on one. */ copyIdFor(variant, nodeId) {
|
|
91
|
+
const standIn = this[variant];
|
|
92
|
+
return nodeId && (standIn == null ? void 0 : standIn.nodeId) === nodeId ? standIn.copyId : undefined;
|
|
93
|
+
}
|
|
94
|
+
constructor(){
|
|
95
|
+
this.hovered = undefined;
|
|
96
|
+
this.selected = undefined;
|
|
97
|
+
makeAutoObservable(this, {
|
|
98
|
+
hovered: observableRef,
|
|
99
|
+
selected: observableRef
|
|
100
|
+
});
|
|
101
|
+
reaction(()=>{
|
|
102
|
+
var _Besigner_focus_getHovered;
|
|
103
|
+
return (_Besigner_focus_getHovered = Besigner.focus.getHovered()) == null ? void 0 : _Besigner_focus_getHovered.$id;
|
|
104
|
+
}, (id)=>this.forgetUnless('hovered', id));
|
|
105
|
+
reaction(()=>{
|
|
106
|
+
var _Besigner_focus_getLastSelected;
|
|
107
|
+
return (_Besigner_focus_getLastSelected = Besigner.focus.getLastSelected()) == null ? void 0 : _Besigner_focus_getLastSelected.$id;
|
|
108
|
+
}, (id)=>this.forgetUnless('selected', id));
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
export const repeatCopyStandIns = new RepeatCopyStandIns();
|
|
112
|
+
/** The drawn copy `copyId`, in the canvas `element` lives in, or null. */ export function repeatCopyElementIn(element, copyId) {
|
|
58
113
|
const root = element.getRootNode();
|
|
59
|
-
if (!(root == null ? void 0 : root.
|
|
60
|
-
const escaped = typeof CSS !== 'undefined' && CSS.escape ? CSS.escape(
|
|
61
|
-
return
|
|
62
|
-
var _ref;
|
|
63
|
-
var _copy_getAttribute;
|
|
64
|
-
return repeatTemplateIdOf((_ref = (_copy_getAttribute = copy.getAttribute('data-aglyn')) == null ? void 0 : _copy_getAttribute.slice('leaf:'.length)) != null ? _ref : '') === id;
|
|
65
|
-
});
|
|
114
|
+
if (!(root == null ? void 0 : root.querySelector)) return null;
|
|
115
|
+
const escaped = typeof CSS !== 'undefined' && CSS.escape ? CSS.escape(copyId) : copyId;
|
|
116
|
+
return root.querySelector(`[data-aglyn="leaf:${escaped}"]`);
|
|
66
117
|
}
|
|
67
118
|
|
|
68
119
|
//# sourceMappingURL=repeat-copy.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/utils/repeat-copy.ts"],"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\nimport type * as Aglyn from '@aglyn/aglyn'\nimport { canvas } from '@aglyn/aglyn'\nimport { REPEAT_NODE_ID_PREFIX } from '@aglyn/aglyn/app-utils/expand-repeatables'\n\nconst LEAF_STAMP = '[data-aglyn^=\"leaf:\"]'\n\n/** `rep__<repeating id>__<record>__<original id>`, as the expansion names a copy. */\nconst REPEAT_COPY_ID = new RegExp(`^${REPEAT_NODE_ID_PREFIX}.+?__\\\\d+__(.+)$`)\n\n/** The attribute the canvas puts on each repeat copy's root, for its outline. */\nexport const REPEAT_COPY_ATTR = 'data-aglyn-repeat-copy'\n\n/**\n * The id of the node a repeat copy draws: the copy's id with every repeat\n * prefix taken off, so a copy inside a copy names the original too. An id\n * that is not a copy comes back as it is.\n */\nexport function repeatTemplateIdOf(id: string): string {\n let current = id\n for (let match = REPEAT_COPY_ID.exec(current); match; ) {\n current = match[1]\n match = REPEAT_COPY_ID.exec(current)\n }\n return current\n}\n\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/utils/repeat-copy.ts"],"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\nimport type * as Aglyn from '@aglyn/aglyn'\nimport { canvas } from '@aglyn/aglyn'\nimport { REPEAT_NODE_ID_PREFIX } from '@aglyn/aglyn/app-utils/expand-repeatables'\nimport * as Besigner from '@aglyn/besigner'\nimport { makeAutoObservable, observableRef, reaction } from 'mobx'\n\nconst LEAF_STAMP = '[data-aglyn^=\"leaf:\"]'\n\n/** `rep__<repeating id>__<record>__<original id>`, as the expansion names a copy. */\nconst REPEAT_COPY_ID = new RegExp(`^${REPEAT_NODE_ID_PREFIX}.+?__\\\\d+__(.+)$`)\n\n/** The attribute the canvas puts on each repeat copy's root, for its outline. */\nexport const REPEAT_COPY_ATTR = 'data-aglyn-repeat-copy'\n\n/**\n * The id of the node a repeat copy draws: the copy's id with every repeat\n * prefix taken off, so a copy inside a copy names the original too. An id\n * that is not a copy comes back as it is.\n */\nexport function repeatTemplateIdOf(id: string): string {\n let current = id\n for (let match = REPEAT_COPY_ID.exec(current); match; ) {\n current = match[1]\n match = REPEAT_COPY_ID.exec(current)\n }\n return current\n}\n\n/** A repeat copy the pointer is on, and the real element it is a picture of. */\nexport interface RepeatCopyHit {\n /** The element the copy draws: the one an edit changes. */\n original: Aglyn.NodeSchema<any>\n /** The copy's own id, `rep__…`, as its rendered stamp carries it. */\n copyId: string\n}\n\n/**\n * The repeat copy under the pointer and the real element it is a picture of,\n * or null when the pointer is not on a copy.\n *\n * The copies (Sam, Jordan beside the real Avery) are inert drawings: nothing\n * in them is a document, so none of them can be selected. A click on one\n * still means something — the element it draws, the one an author edits to\n * change every copy at once — and the repeating element's own handlers,\n * which the copies are drawn inside, send it there.\n */\nexport function repeatCopyAt(target: EventTarget | null): RepeatCopyHit | null {\n const leaf = target instanceof Element ? target.closest(LEAF_STAMP) : null\n const copyId = leaf?.getAttribute('data-aglyn')?.slice('leaf:'.length)\n if (!copyId?.startsWith(REPEAT_NODE_ID_PREFIX)) return null\n const original = canvas.getNode(repeatTemplateIdOf(copyId))\n return original ? { original, copyId } : null\n}\n\n/** A copy the canvas outlines in place of the element it draws. */\nexport interface RepeatCopyStandIn {\n /** The element hovered or selected. */\n nodeId: string\n /** The copy of it the pointer is on, or was on when it was clicked. */\n copyId: string\n}\n\n/**\n * Which copy the canvas outlines for the hovered and the selected element\n * (AGL-3111).\n *\n * Pointing at or clicking a copy hovers or selects the element it draws, so\n * an edit changes the element and every copy with it — but the outline goes\n * where the pointer is: round that copy, exactly, and nothing else. It used\n * to go round the element, or round the element and all its copies at once,\n * and either way the box was somewhere other than the thing just clicked.\n *\n * Kept by the copy's id rather than its element, since the copies are drawn\n * again whenever what they repeat is edited; and by the element's id with it.\n * A stand-in is dropped the moment the hover or the selection moves to\n * another element, however it moves — the hierarchy, the breadcrumbs, a\n * shortcut — so coming back to the element later outlines the element, not\n * a copy clicked some time before.\n */\nclass RepeatCopyStandIns {\n hovered?: RepeatCopyStandIn = undefined\n selected?: RepeatCopyStandIn = undefined\n\n constructor() {\n makeAutoObservable(this, {\n hovered: observableRef,\n selected: observableRef,\n })\n reaction(\n () => Besigner.focus.getHovered()?.$id,\n (id) => this.forgetUnless('hovered', id),\n )\n reaction(\n () => Besigner.focus.getLastSelected()?.$id,\n (id) => this.forgetUnless('selected', id),\n )\n }\n\n private forgetUnless(variant: 'hovered' | 'selected', nodeId?: string) {\n if (this[variant] && this[variant]?.nodeId !== nodeId) {\n this[variant] = undefined\n }\n }\n\n /** Records the copy a hover or a selection was made on, or clears it. */\n set(variant: 'hovered' | 'selected', hit: RepeatCopyHit | null) {\n const current = this[variant]\n // Every mouseover lands here; one that changes nothing must not\n // re-render the overlay reading it.\n if (\n current?.nodeId === hit?.original.$id &&\n current?.copyId === hit?.copyId\n ) {\n return\n }\n this[variant] = hit\n ? { nodeId: hit.original.$id, copyId: hit.copyId }\n : undefined\n }\n\n /** The copy to outline for `nodeId`, if the hover or selection was made on one. */\n copyIdFor(variant: 'hovered' | 'selected', nodeId: string | undefined) {\n const standIn = this[variant]\n return nodeId && standIn?.nodeId === nodeId ? standIn.copyId : undefined\n }\n}\n\nexport const repeatCopyStandIns = new RepeatCopyStandIns()\n\n/** The drawn copy `copyId`, in the canvas `element` lives in, or null. */\nexport function repeatCopyElementIn(\n element: Element,\n copyId: string,\n): Element | null {\n const root = element.getRootNode() as ParentNode | null\n if (!root?.querySelector) return null\n const escaped =\n typeof CSS !== 'undefined' && CSS.escape ? CSS.escape(copyId) : copyId\n return root.querySelector(`[data-aglyn=\"leaf:${escaped}\"]`)\n}\n"],"names":["canvas","REPEAT_NODE_ID_PREFIX","Besigner","makeAutoObservable","observableRef","reaction","LEAF_STAMP","REPEAT_COPY_ID","RegExp","REPEAT_COPY_ATTR","repeatTemplateIdOf","id","current","match","exec","repeatCopyAt","target","leaf","Element","closest","copyId","getAttribute","slice","length","startsWith","original","getNode","RepeatCopyStandIns","forgetUnless","variant","nodeId","undefined","set","hit","$id","copyIdFor","standIn","hovered","selected","focus","getHovered","getLastSelected","repeatCopyStandIns","repeatCopyElementIn","element","root","getRootNode","querySelector","escaped","CSS","escape"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAGD,SAASA,MAAM,QAAQ,eAAc;AACrC,SAASC,qBAAqB,QAAQ,4CAA2C;AACjF,YAAYC,cAAc,kBAAiB;AAC3C,SAASC,kBAAkB,EAAEC,aAAa,EAAEC,QAAQ,QAAQ,OAAM;AAElE,MAAMC,aAAa;AAEnB,mFAAmF,GACnF,MAAMC,iBAAiB,IAAIC,OAAO,CAAC,CAAC,EAAEP,sBAAsB,gBAAgB,CAAC;AAE7E,+EAA+E,GAC/E,OAAO,MAAMQ,mBAAmB,yBAAwB;AAExD;;;;CAIC,GACD,OAAO,SAASC,mBAAmBC,EAAU;IAC3C,IAAIC,UAAUD;IACd,IAAK,IAAIE,QAAQN,eAAeO,IAAI,CAACF,UAAUC,OAAS;QACtDD,UAAUC,KAAK,CAAC,EAAE;QAClBA,QAAQN,eAAeO,IAAI,CAACF;IAC9B;IACA,OAAOA;AACT;AAUA;;;;;;;;;CASC,GACD,OAAO,SAASG,aAAaC,MAA0B;QAEtCC;IADf,MAAMA,OAAOD,kBAAkBE,UAAUF,OAAOG,OAAO,CAACb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