@graphysdk/react-renderer 1.9.0-beta.1789576170858 → 1.9.0-beta.1789633145847
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/README.md +2 -2
- package/dist/editable.cjs +1 -1
- package/dist/editable.d.ts +6 -6
- package/dist/editable.mjs +19 -19
- package/dist/{history-chords-BROoCmI1.js → history-chords-Bu0I5FG1.js} +1 -1
- package/dist/{history-chords-DdVy1Mdn.cjs → history-chords-DeVbcR29.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +16 -16
- package/dist/index.mjs +284 -274
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const c=require("./history-chords-DdVy1Mdn.cjs"),se=require("./theme.contract.css-Dd-73-Je.cjs");let m=require("@graphysdk/viz-engine"),l=require("react"),a=require("react/jsx-runtime"),A=require("zustand"),B=require("zustand/vanilla"),$=require("clsx");$=c.__toESM($,1);var ne="_1a5iqpb0",oe="_1a5iqpb1";var ae="_1a5iqpb3",ie="_1a5iqpb4",ce="_1a5iqpb5";var L=({errors:e})=>{const[t,...r]=e;return(0,a.jsxs)("div",{role:"alert",className:ne,children:[(0,a.jsx)("strong",{className:oe,children:"This chart could not be rendered."}),t&&(0,a.jsx)(U,{diagnostic:t}),r.length>0&&(0,a.jsx)("ul",{className:"_1a5iqpb2",children:r.map((s,o)=>(0,a.jsx)("li",{children:(0,a.jsx)(U,{diagnostic:s})},`${s.code}-${o}`))})]})},U=({diagnostic:e})=>(0,a.jsxs)("div",{className:ae,children:[(0,a.jsx)("span",{className:ie,children:e.code}),(0,a.jsx)("p",{className:ce,children:e.message}),e.suggestion&&(0,a.jsx)("p",{className:"_1a5iqpb6",children:e.suggestion})]});function le(e=[],t=[]){return e.length===t.length&&e.every((r,s)=>Object.is(r,t[s]))}var W=class extends l.Component{constructor(...e){super(...e),this.state={caughtDiagnostic:null}}static getDerivedStateFromError(e){return{caughtDiagnostic:(0,m.buildDiagnostic)(e)}}componentDidCatch(e,t){const r=(0,m.buildDiagnostic)(e);c.logDiagnostics([r]),this.props.onError?.([r]),console.error("Chart render component stack:",t.componentStack)}componentDidUpdate(e){this.state.caughtDiagnostic&&!le(e.resetKeys,this.props.resetKeys)&&this.setState({caughtDiagnostic:null})}render(){const{caughtDiagnostic:e}=this.state;if(e)return(0,a.jsx)(L,{errors:[e]});const{forcedErrors:t,children:r}=this.props;return t&&t.length>0?(0,a.jsx)(L,{errors:t}):r}},z=e=>typeof e=="object"&&"geom"in e&&"render"in e,de=e=>{const t=(0,m.resolveDefinition)(e);return t instanceof m.Geom?t:null},X=(e,t)=>{const r=e.filter(s=>ue(s,t));return r.length===e.length?e:r},ue=(e,t)=>e.kind==="annotation"?(0,m.findAnnotation)(t.annotations,e.id)!==null:e.kind==="observations"||e.kind==="layer"&&e.layerId!==void 0?(0,m.findLayerById)(t.layers,e.layerId)!==void 0:!0,Y=[],he=()=>(0,B.createStore)(e=>({selection:Y,setSelection:t=>e(r=>ge(r.selection,t)?r:{selection:t}),clearSelection:()=>e(t=>t.selection.length===0?t:{selection:Y})})),ge=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((r,s)=>{const o=t[s];return o!==void 0&&(0,m.areEditTargetsEqual)(r,o)}),me=process.env.NODE_ENV!=="production",pe=5,fe=e=>{if(!me)return{emit:()=>{},subscribe:()=>ye,getLastTrigger:()=>null,getLastCompile:()=>null,getCacheStats:()=>e.getCacheStats()};const t=new Set;let r=null;return{emit:s=>{const o=e.getLastCompile();if(o){r=s;for(const d of t)d(s,o)}},subscribe:s=>(t.add(s),()=>{t.delete(s)}),getLastTrigger:()=>r,getLastCompile:()=>e.getLastCompile(),getCacheStats:()=>e.getCacheStats()}},ve=()=>(0,B.createStore)(e=>({lastCompile:null,history:[],nextId:1,lastSnapshot:null,recordCompile:(t,r)=>e(s=>{if(s.lastSnapshot===r)return s;const o={id:s.nextId,label:Se(t),stages:r.stages,durationMs:r.durationMs};return{lastCompile:o,history:be(s.history,o,pe),nextId:s.nextId+1,lastSnapshot:r}})})),ye=()=>{},Se=e=>{switch(e.kind){case"init":return"init";case"input":return"input change";case"data":return"data change";case"command":return e.command.metadata.description}},be=(e,t,r)=>{const s=e.length>=r?e.length-(r-1):0;return[...e.slice(s),t]};function Ee(e){const t=e.filter(z),r=new Set([...Object.keys(c.BUILT_IN_GEOM_RENDERERS),...t.map(u=>u.geom)]),s=[],o=new Set;for(const u of e){const g=de(u);g===null||r.has(g.type)||o.has(g.type)||(o.add(g.type),s.push({kind:"user-input",severity:"error",code:"MISSING_GEOM_RENDERER",message:`Custom geom '${g.type}' is registered but has no renderer.`,context:{requested:g.type,kind:"geom-renderer"},suggestion:`Add a render half for it: \`defineGeomRenderer(${g.type}Geom, { coord, render })\`, then include it in \`plugins\`.`}))}const d=new Map;for(const u of t){if("definition"in u)continue;const g=`${u.geom}|${u.coord}`,p=d.get(g);p?p.count+=1:d.set(g,{geom:u.geom,coord:u.coord,count:1})}const i=[];for(const{geom:u,coord:g,count:p}of d.values())p<2||i.push({kind:"user-input",severity:"warning",code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple render-only overrides register ('${u}', '${g}') (${p} entries); the last in the array wins.`,context:{requested:`${u}@${g}`,kind:"geom-renderer"},suggestion:`Keep a single render-only override for ('${u}', '${g}').`});return{errors:s,warnings:i}}function xe(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const i of s)t(i.geom,r.type)!==null||o.has(i.geom)||(o.add(i.geom),d.push({kind:"user-input",severity:"warning",code:"MISSING_GEOM_RENDERER",message:`No renderer for geom '${i.geom}' under ${r.type} coords; the layer is not painted.`,context:{requested:i.geom,kind:"geom-renderer"},suggestion:`Register a renderer for ('${i.geom}', '${r.type}') via \`defineGeomRenderer\`.`}));return d}function Te(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const i of s){if(i.interactive===!1||i.spatialKind!=="render-hit-test"||o.has(i.geom))continue;const u=t(i.geom,r.type);u===null||u.hitTest||c.isOverlayHosted(u)||(o.add(i.geom),d.push({kind:"user-input",severity:"warning",code:"MISSING_RENDER_HIT_TEST",message:`Geom '${i.geom}' declares spatialKind 'render-hit-test' but its renderer provides no hit-test; the layer has no hover.`,context:{requested:i.geom,kind:"geom-renderer"},suggestion:`Add a \`hitTest\` factory (precomputed geometry) or an overlay render (\`{ fn, options: { overlay: true } }\`, live simulation) to the renderer for ('${i.geom}', '${r.type}').`}))}return d}function Ce(e){const t=new Set,r=[];for(const s of e.layers){const o=s.identityKey;s.interactive!==!1&&(s.spatialKind!=="render-hit-test"||typeof o!="object"||t.has(s.geom)||s.data.hasVariable(o.variable)||(t.add(s.geom),r.push({kind:"user-input",severity:"warning",code:"RENDER_HIT_TEST_IDENTITY",message:`Geom '${s.geom}' keys its identity on '${o.variable}', a column its compile output does not emit; its hover lookup is empty.`,context:{requested:s.geom,kind:"geom-renderer"},suggestion:`Emit the '${o.variable}' column from the geom's \`compile()\`, or point \`identityKey\` at a column it does emit.`})))}return r}function Re(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const i of s){if(i.interactive===!1||i.spatialKind!=="render-hit-test"||o.has(i.geom))continue;const u=t(i.geom,r.type);u===null||!u.hitTest||!c.isOverlayHosted(u)||(o.add(i.geom),d.push({kind:"user-input",severity:"warning",code:"CONFLICTING_RENDER_HIT_TEST",message:`Geom '${i.geom}' declares both a \`hitTest\` factory and an overlay render; these are alternatives, so only the overlay is used.`,context:{requested:i.geom,kind:"geom-renderer"},suggestion:"Keep one: a `hitTest` factory for precomputed geometry, OR an overlay render (`{ fn, options: { overlay: true } }`) for a live simulation."}))}return d}function Ge(e,t){const r=new Set,s=[];for(const o of e.layers)o.interactive!==!1&&(o.spatialKind!=="render-hit-test"||r.has(o.geom)||t.hasCapability(o.geom)||(r.add(o.geom),s.push({kind:"user-input",severity:"warning",code:"MISSING_ANCHOR_CAPABILITY",message:`Geom '${o.geom}' declares no \`resolveAnchorPosition\`; its observations cannot be annotated, so the editor overlay paints no creation trigger on them.`,context:{requested:o.geom,kind:"geom-renderer"},suggestion:"Implement `resolveAnchorPosition(observation, context)` on the geom, returning the normalised panel position an annotation on that observation belongs at."})));return s}function qe(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const i of s){if(i.interactive===!1||i.spatialKind==="render-hit-test"||o.has(i.geom))continue;const u=t(i.geom,r.type);u===null||!c.isOverlayHosted(u)||(o.add(i.geom),d.push({kind:"user-input",severity:"warning",code:"OVERLAY_REQUIRES_RENDER_HIT_TEST",message:`Geom '${i.geom}' declares an overlay render but its layer's spatialKind is '${i.spatialKind}', not 'render-hit-test'; the overlay's push-path hover resolves to nothing.`,context:{requested:i.geom,kind:"geom-renderer"},suggestion:"Have the geom's manifest yield spatialKind 'render-hit-test' so the scene layer carries the `byKey` index the overlay's `pushHover` resolves against."}))}return d}var ke=e=>(0,B.createStore)(t=>({scene:e,setScene:r=>t(s=>s.scene===r?s:{scene:r})})),Ne=({input:e,data:t,customPalettes:r,colorScheme:s,plugins:o,resolveRenderer:d,anchorResolver:i,onChange:u,onError:g,onWarnings:p})=>{const T=c.useLatestRef(u),k=c.useLatestRef(g),G=c.useLatestRef(p),[{session:f,compileBus:h}]=(0,l.useState)(()=>{const n=(0,m.createCompiler)({plugins:o});return{session:new m.GraphCompilationSession(n),compileBus:fe(n)}}),[y]=(0,l.useState)(()=>Ee(o??[])),S=(0,l.useRef)(null),[N]=(0,l.useState)(_e),C=(0,l.useRef)(null),b=(0,l.useCallback)(n=>y.errors.length===0?n:[...y.errors,...n??[]],[y]),j=(0,l.useCallback)(n=>{if(!n.ok)return n.errors;if(C.current)C.current.getState().setScene(n.scene);else{const v=ke(n.scene);v.subscribe(N.notify),C.current=v,N.notify()}return null},[N]),[I,D]=(0,l.useState)(()=>{const n=f.compile({input:e,data:t,customPalettes:r,colorScheme:s});return S.current=n,b(j(n))}),q=(0,l.useCallback)(n=>n.ok?[...n.warnings,...xe(n.scene,d),...Te(n.scene,d),...Ce(n.scene),...Re(n.scene,d),...qe(n.scene,d),...Ge(n.scene,i)]:n.warnings,[d,i]),E=(0,l.useCallback)(n=>{n.length!==0&&(c.logDiagnostics(n),k.current?.(n))},[k]),R=(0,l.useCallback)(n=>{n.length!==0&&(c.logDiagnostics(n),G.current?.(n))},[G]);(0,l.useEffect)(()=>{const n=S.current;n&&(E([...y.errors,...n.ok?[]:n.errors]),R([...y.warnings,...q(n)]),n.ok&&h.emit({kind:"init"}))},[h,E,R,y,q]),(0,l.useEffect)(()=>{const n=f.update({input:e,data:t,customPalettes:r,colorScheme:s});if(!n)return;n.sealedInput&&T.current?.(n.sealedInput);const v=j(n.result);D(b(v)),v&&E(v),R(q(n.result)),v||h.emit({kind:n.inputChanged?"input":"data"})},[e,t,r,s,f,h,j,E,R,b,q,T]);const _=(0,l.useCallback)(n=>{D(v=>v===null?v:b(null)),R(q(n))},[b,R,q]),w=(0,l.useCallback)(n=>{n.scene&&C.current?.getState().setScene(n.scene),n.result&&_(n.result),n.command&&h.emit({kind:"command",command:n.command}),n.input&&T.current?.(n.input),n.errors&&E([...n.errors])},[_,h,T,E]),x=(0,l.useCallback)(n=>{for(const v of n)w(v);return n.some(v=>!!v.scene)},[w]),M=(0,l.useCallback)((n,v)=>{x(f.applyCommand(n,v))},[f,x]),ee=(0,l.useCallback)(()=>{x(f.seal())},[f,x]),O=(0,l.useCallback)(()=>x(f.undo()),[f,x]),K=(0,l.useCallback)(()=>x(f.redo()),[f,x]),te=(0,l.useMemo)(()=>({stack:f.history,undo:O,redo:K}),[f,O,K]),re=(0,l.useCallback)(()=>C.current?.getState().scene??null,[]);return{store:C.current,dispatch:M,seal:ee,history:te,subscribe:N.subscribe,getScene:re,compileBus:h,compileErrors:I}},_e=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),notify:()=>e.forEach(t=>t())}},Q=({data:e,input:t,plugins:r=[],formattingLocale:s,handleRef:o,onChange:d,onError:i,onWarnings:u,customPalettes:g,colorScheme:p="light",children:T})=>{const[k]=(0,l.useState)(()=>c.createGeomRendererResolver(r.filter(z))),G=(0,l.useId)(),[f]=(0,l.useState)(()=>(0,m.createAnchorResolver)(r)),[h]=(0,l.useState)(()=>he()),y=(0,l.useMemo)(()=>(0,m.createStyleResolver)({colorScheme:p}),[p]),{store:S,dispatch:N,seal:C,history:b,subscribe:j,getScene:I,compileBus:D,compileErrors:q}=Ne({input:t,data:e,customPalettes:g,colorScheme:p,plugins:r,resolveRenderer:k,anchorResolver:f,onChange:d,onError:i,onWarnings:u});(0,l.useEffect)(()=>{if(S)return S.subscribe((_,w)=>{if(_.scene.spec===w.scene.spec)return;const{selection:x,setSelection:M}=h.getState();x.length!==0&&M(X(x,_.scene.spec))})},[S,h]);const E=(0,l.useMemo)(()=>({dispatch:N,seal:C}),[N,C]);(0,l.useImperativeHandle)(o,()=>({commands:E,undo:b.undo,redo:b.redo,subscribe:j,getScene:I,getSelection:()=>h.getState().selection,setSelection:_=>h.getState().setSelection(_),subscribeSelection:h.subscribe}),[E,b,j,I,h]);const R=(0,l.useMemo)(()=>S?{chartId:G,store:S,selectionStore:h,commands:E,history:b,formattingLocale:s,compileBus:D,colorScheme:p,styleResolver:y,anchorResolver:f}:null,[G,S,h,E,b,s,D,p,y,f]);return(0,a.jsx)(W,{forcedErrors:q,onError:i,resetKeys:[t,e],children:R?(0,a.jsx)(c.GraphContext.Provider,{value:R,children:(0,a.jsx)(c.GeomRendererResolverProvider,{value:k,children:T})}):null})};function je(e){const t=(0,m.createGraphyBuilder)(e);return{...t,GraphProvider:s=>(0,a.jsx)(Q,{...s,plugins:t.plugins})}}var De=({children:e,...t})=>(0,a.jsx)("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",pointerEvents:"none",...t,children:e}),Ie=({box:e,children:t})=>(0,a.jsx)("svg",{x:(0,m.toPercent)(e.x0),y:(0,m.toPercent)(e.y0),width:(0,m.toPercent)(e.x1-e.x0),height:(0,m.toPercent)(e.y1-e.y0),overflow:"hidden",pointerEvents:"none",children:t}),we="drqe3u0",He="drqe3u1",Me="drqe3u2",Pe="drqe3u3",H="drqe3u4",$e="drqe3u5",Le="drqe3u6",Be="drqe3u7",P="drqe3u8",Oe="drqe3u9",Ke="drqe3ua";var Ae="drqe3uc",Ue="drqe3ud",Ye="drqe3ue",Fe="drqe3uf";var Ve="drqe3uh",We="drqe3ui",F={enabled:"drqe3uk drqe3uj",disabled:"drqe3ul drqe3uj"},V={ran:"drqe3un drqe3um",dim:"drqe3uo drqe3um"},J={ran:"drqe3uq drqe3up",cached:"drqe3ur drqe3up",untouched:"drqe3us drqe3up"},ze=({width:e=380,style:t,className:r}={})=>{const{compileBus:s}=c.useGraphContext(),[o]=(0,l.useState)(()=>ve()),[d,i]=(0,l.useState)(!1),[u,g]=(0,l.useState)(m.isCompilerCachingEnabled);(0,l.useEffect)(()=>{const{recordCompile:h}=o.getState(),y=s.getLastTrigger(),S=s.getLastCompile();return y&&S&&h(y,S),s.subscribe(h)},[o,s]);const p=(0,A.useStore)(o,h=>h.lastCompile),T=(0,A.useStore)(o,h=>h.history),k=s.getCacheStats(),G=p===null&&T.length===0,f=()=>{g(h=>{const y=!h;return(0,m.setCompilerCachingEnabled)(y),y})};return(0,a.jsxs)("div",{className:(0,$.default)(Ke,r),style:{width:e,...t},children:[(0,a.jsxs)("div",{className:we,children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:He,children:"compile cache"}),(0,a.jsx)("div",{className:Ye,children:G?"production: stats disabled":p?`last: ${p.label} · ${Z(p.durationMs)}`:"awaiting first compile…"})]}),(0,a.jsx)("button",{type:"button",onClick:()=>i(h=>!h),className:Fe,children:d?"▾":"▴"})]}),!d&&(0,a.jsxs)("div",{className:"drqe3ub",children:[(0,a.jsxs)("button",{type:"button",onClick:f,className:u?F.enabled:F.disabled,"aria-pressed":u,children:["cache ",u?"enabled":"disabled"]}),(0,a.jsx)("span",{className:"drqe3ug",children:"next compile reflects this toggle"})]}),!d&&!G&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Xe,{delta:p?.stages,cumulative:k}),(0,a.jsx)(Qe,{entries:T})]})]})},Xe=({delta:e,cumulative:t})=>(0,a.jsxs)("table",{className:Me,children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:Ve,children:[(0,a.jsx)("th",{className:Pe,children:"stage"}),(0,a.jsx)("th",{className:H,children:"Δ miss"}),(0,a.jsx)("th",{className:H,children:"Δ hit"}),(0,a.jsx)("th",{className:H,children:"total miss"}),(0,a.jsx)("th",{className:H,children:"total hit"})]})}),(0,a.jsx)("tbody",{children:m.COMPILER_STAGE_KEYS.map(r=>{const s=e?.[r],o=Je(s);return(0,a.jsxs)("tr",{className:Ae,children:[(0,a.jsxs)("td",{className:$e,children:[(0,a.jsx)("span",{className:J[o],"aria-hidden":!0})," ",r]}),(0,a.jsx)("td",{className:o==="ran"?V.ran:V.dim,children:s?.misses??0}),(0,a.jsx)("td",{className:P,children:s?.hits??0}),(0,a.jsx)("td",{className:P,children:t[r].misses}),(0,a.jsx)("td",{className:P,children:t[r].hits})]},r)})})]}),Qe=({entries:e})=>e.length===0?null:(0,a.jsxs)("div",{className:Ue,children:[(0,a.jsx)("div",{className:We,children:"recent compiles"}),e.map(t=>{const r=Ze(t.stages,d=>d.misses>0),s=m.COMPILER_STAGE_KEYS.length,o=r===0?"cached":"ran";return(0,a.jsxs)("div",{className:Le,children:[(0,a.jsx)("span",{className:J[o],"aria-hidden":!0}),(0,a.jsx)("span",{className:Be,title:t.label,children:t.label}),(0,a.jsxs)("span",{className:Oe,children:[r,"/",s," ran · ",Z(t.durationMs)]})]},t.id)})]}),Je=e=>!e||e.hits===0&&e.misses===0?"untouched":e.misses>0?"ran":"cached",Ze=(e,t)=>{let r=0;for(const s of m.COMPILER_STAGE_KEYS)t(e[s])&&(r+=1);return r},Z=e=>e>=10?`${e.toFixed(0)}ms`:`${e.toFixed(2)}ms`,et=()=>{const{history:e}=c.useGraphContext(),{stack:t,undo:r,redo:s}=e,o=(0,l.useCallback)(u=>t.subscribe(u),[t]),d=(0,l.useCallback)(()=>t.getSnapshot(),[t]),i=(0,l.useSyncExternalStore)(o,d,d);return(0,l.useMemo)(()=>({...i,undo:r,redo:s}),[i,r,s])},tt=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]),rt=(e,t={})=>{const{target:r,enabled:s=!0}=t;(0,l.useEffect)(()=>{const o=st(r);if(!s||!o)return;const d=i=>{if(!nt(i)||i.defaultPrevented||ot(i.target))return;const u=c.resolveHistoryStep(i);if(!u)return;const g=e.current;g&&(u==="undo"?g.undo():g.redo())&&i.preventDefault()};return o.addEventListener("keydown",d),()=>o.removeEventListener("keydown",d)},[e,r,s])},st=e=>e===void 0?window:e!==null&&"current"in e?e.current:e,nt=e=>"key"in e,ot=e=>e instanceof HTMLInputElement?!tt.has(e.type):e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA":!1;exports.BrandMark=c.BrandMark;exports.CanvasTextMeasurer=c.CanvasTextMeasurer;exports.DefaultFooter=c.DefaultFooter;exports.DefaultGrid=c.DefaultGrid;exports.DefaultHeader=c.DefaultHeader;exports.DefaultSwatch=c.DefaultSwatch;exports.DefaultTooltip=c.DefaultTooltip;exports.DevToolsPanel=ze;exports.GRAPH_MODES=c.GRAPH_MODES;exports.GraphErrorBoundary=W;exports.GraphErrorPanel=L;exports.GraphProvider=Q;exports.GraphRenderer=c.GraphRenderer;exports.HoverProvider=c.HoverProvider;exports.TextMeasurerProvider=c.TextMeasurerProvider;exports.ThemeProvider=c.ThemeProvider;exports.UnitBoxSvg=Ie;exports.UnitSpaceSvg=De;exports.createGraphyKit=je;exports.darkTheme=c.darkTheme;exports.defineGeomRenderer=c.defineGeomRenderer;exports.lightTheme=c.lightTheme;exports.lightenCss=c.lightenCss;exports.pruneSelection=X;exports.resolveBrandMarkVisual=c.resolveBrandMarkVisual;exports.stampGridEditTarget=c.stampGridEditTarget;exports.useElementScreenRect=c.useElementScreenRect;exports.useGeomHitTest=c.useGeomHitTest;exports.useGeomHover=c.useGeomHover;exports.useGraphCommands=c.useGraphCommands;exports.useGraphHandle=c.useGraphHandle;exports.useGraphHistory=et;exports.useGraphHistoryShortcuts=rt;exports.useGraphSelection=c.useGraphSelection;exports.useGuidesTakePress=c.useGuidesTakePress;exports.useHandleScene=c.useHandleScene;exports.useHoverState=c.useHoverState;exports.useSceneSelector=c.useSceneSelector;exports.useStyleReaderTree=c.useStyleReaderTree;exports.useStyleReaders=c.useStyleReaders;exports.useStyleResolver=c.useStyleResolver;exports.useTextMeasurer=c.useTextMeasurer;exports.vars=se.vars;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const c=require("./history-chords-DeVbcR29.cjs"),se=require("./theme.contract.css-Dd-73-Je.cjs");let m=require("@graphysdk/viz-engine"),d=require("react"),a=require("react/jsx-runtime"),U=require("zustand"),B=require("zustand/vanilla"),$=require("clsx");$=c.__toESM($,1);var ne="_1a5iqpb0",oe="_1a5iqpb1";var ae="_1a5iqpb3",ie="_1a5iqpb4",ce="_1a5iqpb5";var L=({errors:e})=>{const[t,...s]=e;return(0,a.jsxs)("div",{role:"alert",className:ne,children:[(0,a.jsx)("strong",{className:oe,children:"This chart could not be rendered."}),t&&(0,a.jsx)(Y,{diagnostic:t}),s.length>0&&(0,a.jsx)("ul",{className:"_1a5iqpb2",children:s.map((r,o)=>(0,a.jsx)("li",{children:(0,a.jsx)(Y,{diagnostic:r})},`${r.code}-${o}`))})]})},Y=({diagnostic:e})=>(0,a.jsxs)("div",{className:ae,children:[(0,a.jsx)("span",{className:ie,children:e.code}),(0,a.jsx)("p",{className:ce,children:e.message}),e.suggestion&&(0,a.jsx)("p",{className:"_1a5iqpb6",children:e.suggestion})]});function le(e=[],t=[]){return e.length===t.length&&e.every((s,r)=>Object.is(s,t[r]))}var z=class extends d.Component{constructor(...e){super(...e),this.state={caughtDiagnostic:null}}static getDerivedStateFromError(e){return{caughtDiagnostic:(0,m.buildDiagnostic)(e)}}componentDidCatch(e,t){const s=(0,m.buildDiagnostic)(e);c.logDiagnostics([s]),this.props.onError?.([s]),console.error("Chart render component stack:",t.componentStack)}componentDidUpdate(e){this.state.caughtDiagnostic&&!le(e.resetKeys,this.props.resetKeys)&&this.setState({caughtDiagnostic:null})}render(){const{caughtDiagnostic:e}=this.state;if(e)return(0,a.jsx)(L,{errors:[e]});const{forcedErrors:t,children:s}=this.props;return t&&t.length>0?(0,a.jsx)(L,{errors:t}):s}},X=e=>typeof e=="object"&&"geom"in e&&"render"in e,de=e=>{const t=(0,m.resolveDefinition)(e);return t instanceof m.Geom?t:null},Q=(e,t)=>{const s=e.filter(r=>ue(r,t));return s.length===e.length?e:s},ue=(e,t)=>e.kind==="annotation"?(0,m.findAnnotation)(t.annotations,e.id)!==null:e.kind==="observations"||e.kind==="layer"&&e.layerId!==void 0?(0,m.findLayerById)(t.layers,e.layerId)!==void 0:!0,F=[],he=()=>(0,B.createStore)(e=>({selection:F,setSelection:t=>e(s=>ge(s.selection,t)?s:{selection:t}),clearSelection:()=>e(t=>t.selection.length===0?t:{selection:F})})),ge=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((s,r)=>{const o=t[r];return o!==void 0&&(0,m.areEditTargetsEqual)(s,o)}),me=process.env.NODE_ENV!=="production",pe=5,ve=e=>{if(!me)return{emit:()=>{},subscribe:()=>ye,getLastTrigger:()=>null,getLastCompile:()=>null,getCacheStats:()=>e.getCacheStats()};const t=new Set;let s=null;return{emit:r=>{const o=e.getLastCompile();if(o){s=r;for(const l of t)l(r,o)}},subscribe:r=>(t.add(r),()=>{t.delete(r)}),getLastTrigger:()=>s,getLastCompile:()=>e.getLastCompile(),getCacheStats:()=>e.getCacheStats()}},fe=()=>(0,B.createStore)(e=>({lastCompile:null,history:[],nextId:1,lastSnapshot:null,recordCompile:(t,s)=>e(r=>{if(r.lastSnapshot===s)return r;const o={id:r.nextId,label:Se(t),stages:s.stages,stageDurationsMs:s.stageDurationsMs,durationMs:s.durationMs};return{lastCompile:o,history:be(r.history,o,pe),nextId:r.nextId+1,lastSnapshot:s}})})),ye=()=>{},Se=e=>{switch(e.kind){case"init":return"init";case"spec":return"spec change";case"data":return"data change";case"command":return e.command.metadata.description}},be=(e,t,s)=>{const r=e.length>=s?e.length-(s-1):0;return[...e.slice(r),t]};function Ee(e){const t=e.filter(X),s=new Set([...Object.keys(c.BUILT_IN_GEOM_RENDERERS),...t.map(u=>u.geom)]),r=[],o=new Set;for(const u of e){const g=de(u);g===null||s.has(g.type)||o.has(g.type)||(o.add(g.type),r.push({kind:"user-input",severity:"error",code:"MISSING_GEOM_RENDERER",message:`Custom geom '${g.type}' is registered but has no renderer.`,context:{requested:g.type,kind:"geom-renderer"},suggestion:`Add a render half for it: \`defineGeomRenderer(${g.type}Geom, { coord, render })\`, then include it in \`plugins\`.`}))}const l=new Map;for(const u of t){if("definition"in u)continue;const g=`${u.geom}|${u.coord}`,p=l.get(g);p?p.count+=1:l.set(g,{geom:u.geom,coord:u.coord,count:1})}const i=[];for(const{geom:u,coord:g,count:p}of l.values())p<2||i.push({kind:"user-input",severity:"warning",code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple render-only overrides register ('${u}', '${g}') (${p} entries); the last in the array wins.`,context:{requested:`${u}@${g}`,kind:"geom-renderer"},suggestion:`Keep a single render-only override for ('${u}', '${g}').`});return{errors:r,warnings:i}}function xe(e,t){const{coordSystem:s,layers:r}=e,o=new Set,l=[];for(const i of r)t(i.geom,s.type)!==null||o.has(i.geom)||(o.add(i.geom),l.push({kind:"user-input",severity:"warning",code:"MISSING_GEOM_RENDERER",message:`No renderer for geom '${i.geom}' under ${s.type} coords; the layer is not painted.`,context:{requested:i.geom,kind:"geom-renderer"},suggestion:`Register a renderer for ('${i.geom}', '${s.type}') via \`defineGeomRenderer\`.`}));return l}function Te(e,t){const{coordSystem:s,layers:r}=e,o=new Set,l=[];for(const i of r){if(i.interactive===!1||i.spatialKind!=="render-hit-test"||o.has(i.geom))continue;const u=t(i.geom,s.type);u===null||u.hitTest||c.isOverlayHosted(u)||(o.add(i.geom),l.push({kind:"user-input",severity:"warning",code:"MISSING_RENDER_HIT_TEST",message:`Geom '${i.geom}' declares spatialKind 'render-hit-test' but its renderer provides no hit-test; the layer has no hover.`,context:{requested:i.geom,kind:"geom-renderer"},suggestion:`Add a \`hitTest\` factory (precomputed geometry) or an overlay render (\`{ fn, options: { overlay: true } }\`, live simulation) to the renderer for ('${i.geom}', '${s.type}').`}))}return l}function Ce(e){const t=new Set,s=[];for(const r of e.layers){const o=r.identityKey;r.interactive!==!1&&(r.spatialKind!=="render-hit-test"||typeof o!="object"||t.has(r.geom)||r.data.hasVariable(o.variable)||(t.add(r.geom),s.push({kind:"user-input",severity:"warning",code:"RENDER_HIT_TEST_IDENTITY",message:`Geom '${r.geom}' keys its identity on '${o.variable}', a column its compile output does not emit; its hover lookup is empty.`,context:{requested:r.geom,kind:"geom-renderer"},suggestion:`Emit the '${o.variable}' column from the geom's \`compile()\`, or point \`identityKey\` at a column it does emit.`})))}return s}function Re(e,t){const{coordSystem:s,layers:r}=e,o=new Set,l=[];for(const i of r){if(i.interactive===!1||i.spatialKind!=="render-hit-test"||o.has(i.geom))continue;const u=t(i.geom,s.type);u===null||!u.hitTest||!c.isOverlayHosted(u)||(o.add(i.geom),l.push({kind:"user-input",severity:"warning",code:"CONFLICTING_RENDER_HIT_TEST",message:`Geom '${i.geom}' declares both a \`hitTest\` factory and an overlay render; these are alternatives, so only the overlay is used.`,context:{requested:i.geom,kind:"geom-renderer"},suggestion:"Keep one: a `hitTest` factory for precomputed geometry, OR an overlay render (`{ fn, options: { overlay: true } }`) for a live simulation."}))}return l}function Ge(e,t){const s=new Set,r=[];for(const o of e.layers)o.interactive!==!1&&(o.spatialKind!=="render-hit-test"||s.has(o.geom)||t.hasCapability(o.geom)||(s.add(o.geom),r.push({kind:"user-input",severity:"warning",code:"MISSING_ANCHOR_CAPABILITY",message:`Geom '${o.geom}' declares no \`resolveAnchorPosition\`; its observations cannot be annotated, so the editor overlay paints no creation trigger on them.`,context:{requested:o.geom,kind:"geom-renderer"},suggestion:"Implement `resolveAnchorPosition(observation, context)` on the geom, returning the normalised panel position an annotation on that observation belongs at."})));return r}function qe(e,t){const{coordSystem:s,layers:r}=e,o=new Set,l=[];for(const i of r){if(i.interactive===!1||i.spatialKind==="render-hit-test"||o.has(i.geom))continue;const u=t(i.geom,s.type);u===null||!c.isOverlayHosted(u)||(o.add(i.geom),l.push({kind:"user-input",severity:"warning",code:"OVERLAY_REQUIRES_RENDER_HIT_TEST",message:`Geom '${i.geom}' declares an overlay render but its layer's spatialKind is '${i.spatialKind}', not 'render-hit-test'; the overlay's push-path hover resolves to nothing.`,context:{requested:i.geom,kind:"geom-renderer"},suggestion:"Have the geom's manifest yield spatialKind 'render-hit-test' so the scene layer carries the `byKey` index the overlay's `pushHover` resolves against."}))}return l}var ke=e=>(0,B.createStore)(t=>({scene:e,setScene:s=>t(r=>r.scene===s?r:{scene:s})})),Ne=({spec:e,data:t,customPalettes:s,colorScheme:r,plugins:o,resolveRenderer:l,anchorResolver:i,onSpecChange:u,onError:g,onWarnings:p})=>{const T=c.useLatestRef(u),k=c.useLatestRef(g),G=c.useLatestRef(p),[{session:v,compileBus:h}]=(0,d.useState)(()=>{const n=(0,m.createCompiler)({plugins:o});return{session:new m.GraphCompilationSession(n),compileBus:ve(n)}}),[y]=(0,d.useState)(()=>Ee(o??[])),S=(0,d.useRef)(null),[N]=(0,d.useState)(je),C=(0,d.useRef)(null),b=(0,d.useCallback)(n=>y.errors.length===0?n:[...y.errors,...n??[]],[y]),_=(0,d.useCallback)(n=>{if(!n.ok)return n.errors;if(C.current)C.current.getState().setScene(n.scene);else{const f=ke(n.scene);f.subscribe(N.notify),C.current=f,N.notify()}return null},[N]),[w,D]=(0,d.useState)(()=>{const n=v.compile({spec:e,data:t,customPalettes:s,colorScheme:r});return S.current=n,b(_(n))}),q=(0,d.useCallback)(n=>n.ok?[...n.warnings,...xe(n.scene,l),...Te(n.scene,l),...Ce(n.scene),...Re(n.scene,l),...qe(n.scene,l),...Ge(n.scene,i)]:n.warnings,[l,i]),E=(0,d.useCallback)(n=>{n.length!==0&&(c.logDiagnostics(n),k.current?.(n))},[k]),R=(0,d.useCallback)(n=>{n.length!==0&&(c.logDiagnostics(n),G.current?.(n))},[G]);(0,d.useEffect)(()=>{const n=S.current;n&&(E([...y.errors,...n.ok?[]:n.errors]),R([...y.warnings,...q(n)]),n.ok&&h.emit({kind:"init"}))},[h,E,R,y,q]),(0,d.useEffect)(()=>{const n=v.update({spec:e,data:t,customPalettes:s,colorScheme:r});if(!n)return;n.committedSpec&&T.current?.(n.committedSpec);const f=_(n.result);D(b(f)),f&&E(f),R(q(n.result)),f||h.emit({kind:n.specChanged?"spec":"data"})},[e,t,s,r,v,h,_,E,R,b,q,T]);const j=(0,d.useCallback)(n=>{D(f=>f===null?f:b(null)),R(q(n))},[b,R,q]),H=(0,d.useCallback)(n=>{n.scene&&C.current?.getState().setScene(n.scene),n.result&&j(n.result),n.command&&h.emit({kind:"command",command:n.command}),n.spec&&T.current?.(n.spec),n.errors&&E([...n.errors])},[j,h,T,E]),x=(0,d.useCallback)(n=>{for(const f of n)H(f);return n.some(f=>!!f.scene)},[H]),P=(0,d.useCallback)((n,f)=>{x(v.applyCommand(n,f))},[v,x]),ee=(0,d.useCallback)(()=>{x(v.commit())},[v,x]),K=(0,d.useCallback)(()=>x(v.undo()),[v,x]),A=(0,d.useCallback)(()=>x(v.redo()),[v,x]),te=(0,d.useMemo)(()=>({stack:v.history,undo:K,redo:A}),[v,K,A]),re=(0,d.useCallback)(()=>C.current?.getState().scene??null,[]);return{store:C.current,dispatch:P,commit:ee,history:te,subscribe:N.subscribe,getScene:re,compileBus:h,compileErrors:w}},je=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),notify:()=>e.forEach(t=>t())}},J=({data:e,spec:t,plugins:s=[],formattingLocale:r,handleRef:o,onSpecChange:l,onError:i,onWarnings:u,customPalettes:g,colorScheme:p="light",children:T})=>{const[k]=(0,d.useState)(()=>c.createGeomRendererResolver(s.filter(X))),G=(0,d.useId)(),[v]=(0,d.useState)(()=>(0,m.createAnchorResolver)(s)),[h]=(0,d.useState)(()=>he()),y=(0,d.useMemo)(()=>(0,m.createStyleResolver)({colorScheme:p}),[p]),{store:S,dispatch:N,commit:C,history:b,subscribe:_,getScene:w,compileBus:D,compileErrors:q}=Ne({spec:t,data:e,customPalettes:g,colorScheme:p,plugins:s,resolveRenderer:k,anchorResolver:v,onSpecChange:l,onError:i,onWarnings:u});(0,d.useEffect)(()=>{if(S)return S.subscribe((j,H)=>{if(j.scene.spec===H.scene.spec)return;const{selection:x,setSelection:P}=h.getState();x.length!==0&&P(Q(x,j.scene.spec))})},[S,h]);const E=(0,d.useMemo)(()=>({dispatch:N,commit:C}),[N,C]);(0,d.useImperativeHandle)(o,()=>({commands:E,undo:b.undo,redo:b.redo,subscribe:_,getScene:w,getSelection:()=>h.getState().selection,setSelection:j=>h.getState().setSelection(j),subscribeSelection:h.subscribe}),[E,b,_,w,h]);const R=(0,d.useMemo)(()=>S?{chartId:G,store:S,selectionStore:h,commands:E,history:b,formattingLocale:r,compileBus:D,colorScheme:p,styleResolver:y,anchorResolver:v}:null,[G,S,h,E,b,r,D,p,y,v]);return(0,a.jsx)(z,{forcedErrors:q,onError:i,resetKeys:[t,e],children:R?(0,a.jsx)(c.GraphContext.Provider,{value:R,children:(0,a.jsx)(c.GeomRendererResolverProvider,{value:k,children:T})}):null})};function _e(e){const t=(0,m.createGraphyBuilder)(e);return{...t,GraphProvider:r=>(0,a.jsx)(J,{...r,plugins:t.plugins})}}var De=({children:e,...t})=>(0,a.jsx)("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",pointerEvents:"none",...t,children:e}),Ie=({box:e,children:t})=>(0,a.jsx)("svg",{x:(0,m.toPercent)(e.x0),y:(0,m.toPercent)(e.y0),width:(0,m.toPercent)(e.x1-e.x0),height:(0,m.toPercent)(e.y1-e.y0),overflow:"hidden",pointerEvents:"none",children:t}),we="drqe3u0",He="drqe3u1",Me="drqe3u2",Pe="drqe3u3",I="drqe3u4",$e="drqe3u5",Le="drqe3u6",Be="drqe3u7",M="drqe3u8",Oe="drqe3u9",Ke="drqe3ua";var Ae="drqe3uc",Ue="drqe3ud",Ye="drqe3ue",Fe="drqe3uf";var Ve="drqe3uh",We="drqe3ui",V={enabled:"drqe3uk drqe3uj",disabled:"drqe3ul drqe3uj"},W={ran:"drqe3un drqe3um",dim:"drqe3uo drqe3um"},Z={ran:"drqe3uq drqe3up",cached:"drqe3ur drqe3up",untouched:"drqe3us drqe3up"},ze=({width:e=440,style:t,className:s}={})=>{const{compileBus:r}=c.useGraphContext(),[o]=(0,d.useState)(()=>fe()),[l,i]=(0,d.useState)(!1),[u,g]=(0,d.useState)(m.isCompilerCachingEnabled);(0,d.useEffect)(()=>{const{recordCompile:h}=o.getState(),y=r.getLastTrigger(),S=r.getLastCompile();return y&&S&&h(y,S),r.subscribe(h)},[o,r]);const p=(0,U.useStore)(o,h=>h.lastCompile),T=(0,U.useStore)(o,h=>h.history),k=r.getCacheStats(),G=p===null&&T.length===0,v=()=>{g(h=>{const y=!h;return(0,m.setCompilerCachingEnabled)(y),y})};return(0,a.jsxs)("div",{className:(0,$.default)(Ke,s),style:{width:e,...t},children:[(0,a.jsxs)("div",{className:we,children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:He,children:"compile cache"}),(0,a.jsx)("div",{className:Ye,children:G?"production: stats disabled":p?`last: ${p.label} · ${O(p.durationMs)}`:"awaiting first compile…"})]}),(0,a.jsx)("button",{type:"button",onClick:()=>i(h=>!h),className:Fe,children:l?"▾":"▴"})]}),!l&&(0,a.jsxs)("div",{className:"drqe3ub",children:[(0,a.jsxs)("button",{type:"button",onClick:v,className:u?V.enabled:V.disabled,"aria-pressed":u,children:["cache ",u?"enabled":"disabled"]}),(0,a.jsx)("span",{className:"drqe3ug",children:"next compile reflects this toggle"})]}),!l&&!G&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Xe,{delta:p?.stages,durations:p?.stageDurationsMs,cumulative:k}),(0,a.jsx)(Qe,{entries:T})]})]})},Xe=({delta:e,durations:t,cumulative:s})=>(0,a.jsxs)("table",{className:Me,children:[(0,a.jsx)("thead",{children:(0,a.jsxs)("tr",{className:Ve,children:[(0,a.jsx)("th",{className:Pe,children:"stage"}),(0,a.jsx)("th",{className:I,children:"time"}),(0,a.jsx)("th",{className:I,children:"Δ miss"}),(0,a.jsx)("th",{className:I,children:"Δ hit"}),(0,a.jsx)("th",{className:I,children:"total miss"}),(0,a.jsx)("th",{className:I,children:"total hit"})]})}),(0,a.jsx)("tbody",{children:m.COMPILER_STAGE_KEYS.map(r=>{const o=e?.[r],l=Je(o);return(0,a.jsxs)("tr",{className:Ae,children:[(0,a.jsxs)("td",{className:$e,children:[(0,a.jsx)("span",{className:Z[l],"aria-hidden":!0})," ",r]}),(0,a.jsx)("td",{className:M,children:t===void 0||l==="untouched"?"—":O(t[r])}),(0,a.jsx)("td",{className:l==="ran"?W.ran:W.dim,children:o?.misses??0}),(0,a.jsx)("td",{className:M,children:o?.hits??0}),(0,a.jsx)("td",{className:M,children:s[r].misses}),(0,a.jsx)("td",{className:M,children:s[r].hits})]},r)})})]}),Qe=({entries:e})=>e.length===0?null:(0,a.jsxs)("div",{className:Ue,children:[(0,a.jsx)("div",{className:We,children:"recent compiles"}),e.map(t=>{const s=Ze(t.stages,l=>l.misses>0),r=m.COMPILER_STAGE_KEYS.length,o=s===0?"cached":"ran";return(0,a.jsxs)("div",{className:Le,children:[(0,a.jsx)("span",{className:Z[o],"aria-hidden":!0}),(0,a.jsx)("span",{className:Be,title:t.label,children:t.label}),(0,a.jsxs)("span",{className:Oe,children:[s,"/",r," ran · ",O(t.durationMs)]})]},t.id)})]}),Je=e=>!e||e.hits===0&&e.misses===0?"untouched":e.misses>0?"ran":"cached",Ze=(e,t)=>{let s=0;for(const r of m.COMPILER_STAGE_KEYS)t(e[r])&&(s+=1);return s},O=e=>e<.1?"<0.1ms":e>=10?`${e.toFixed(0)}ms`:`${e.toFixed(2)}ms`,et=()=>{const{history:e}=c.useGraphContext(),{stack:t,undo:s,redo:r}=e,o=(0,d.useCallback)(u=>t.subscribe(u),[t]),l=(0,d.useCallback)(()=>t.getSnapshot(),[t]),i=(0,d.useSyncExternalStore)(o,l,l);return(0,d.useMemo)(()=>({...i,undo:s,redo:r}),[i,s,r])},tt=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]),rt=(e,t={})=>{const{target:s,enabled:r=!0}=t;(0,d.useEffect)(()=>{const o=st(s);if(!r||!o)return;const l=i=>{if(!nt(i)||i.defaultPrevented||ot(i.target))return;const u=c.resolveHistoryStep(i);if(!u)return;const g=e.current;g&&(u==="undo"?g.undo():g.redo())&&i.preventDefault()};return o.addEventListener("keydown",l),()=>o.removeEventListener("keydown",l)},[e,s,r])},st=e=>e===void 0?window:e!==null&&"current"in e?e.current:e,nt=e=>"key"in e,ot=e=>e instanceof HTMLInputElement?!tt.has(e.type):e instanceof HTMLElement?e.isContentEditable||e.tagName==="TEXTAREA":!1;exports.BrandMark=c.BrandMark;exports.CanvasTextMeasurer=c.CanvasTextMeasurer;exports.DefaultFooter=c.DefaultFooter;exports.DefaultGrid=c.DefaultGrid;exports.DefaultHeader=c.DefaultHeader;exports.DefaultSwatch=c.DefaultSwatch;exports.DefaultTooltip=c.DefaultTooltip;exports.DevToolsPanel=ze;exports.GRAPH_MODES=c.GRAPH_MODES;exports.GraphErrorBoundary=z;exports.GraphErrorPanel=L;exports.GraphProvider=J;exports.GraphRenderer=c.GraphRenderer;exports.HoverProvider=c.HoverProvider;exports.TextMeasurerProvider=c.TextMeasurerProvider;exports.ThemeProvider=c.ThemeProvider;exports.UnitBoxSvg=Ie;exports.UnitSpaceSvg=De;exports.createGraphyKit=_e;exports.darkTheme=c.darkTheme;exports.defineGeomRenderer=c.defineGeomRenderer;exports.lightTheme=c.lightTheme;exports.lightenCss=c.lightenCss;exports.pruneSelection=Q;exports.resolveBrandMarkVisual=c.resolveBrandMarkVisual;exports.stampGridEditTarget=c.stampGridEditTarget;exports.useElementScreenRect=c.useElementScreenRect;exports.useGeomHitTest=c.useGeomHitTest;exports.useGeomHover=c.useGeomHover;exports.useGraphCommands=c.useGraphCommands;exports.useGraphHandle=c.useGraphHandle;exports.useGraphHistory=et;exports.useGraphHistoryShortcuts=rt;exports.useGraphSelection=c.useGraphSelection;exports.useGuidesTakePress=c.useGuidesTakePress;exports.useHandleScene=c.useHandleScene;exports.useHoverState=c.useHoverState;exports.useSceneSelector=c.useSceneSelector;exports.useStyleReaderTree=c.useStyleReaderTree;exports.useStyleReaders=c.useStyleReaders;exports.useStyleResolver=c.useStyleResolver;exports.useTextMeasurer=c.useTextMeasurer;exports.vars=se.vars;
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { ComponentType } from 'react';
|
|
|
9
9
|
import { CoordSystem } from '@graphysdk/viz-engine';
|
|
10
10
|
import { CreateGraphyBuilderOptions } from '@graphysdk/viz-engine';
|
|
11
11
|
import { CSSProperties } from 'react';
|
|
12
|
-
import {
|
|
12
|
+
import { CustomPalettes } from '@graphysdk/viz-engine';
|
|
13
13
|
import { Data } from '@graphysdk/viz-engine';
|
|
14
14
|
import { DispatchOptions } from '@graphysdk/viz-engine';
|
|
15
15
|
import { EdgeSizes } from '@graphysdk/viz-engine';
|
|
@@ -46,6 +46,7 @@ import { RefObject } from 'react';
|
|
|
46
46
|
import { RenderHitTester } from '@graphysdk/viz-engine';
|
|
47
47
|
import { ResolvedHeadlineSize } from '@graphysdk/viz-engine';
|
|
48
48
|
import { ResolvedSourceStyle } from '@graphysdk/viz-engine';
|
|
49
|
+
import { ResolvedSpec } from '@graphysdk/viz-engine';
|
|
49
50
|
import { ResolvedTextStyle } from '@graphysdk/viz-engine';
|
|
50
51
|
import { ScaledPositionAestheticKey } from '@graphysdk/viz-engine';
|
|
51
52
|
import { Scene } from '@graphysdk/viz-engine';
|
|
@@ -53,7 +54,6 @@ import { SceneLayer } from '@graphysdk/viz-engine';
|
|
|
53
54
|
import { SceneLayerFor } from '@graphysdk/viz-engine';
|
|
54
55
|
import { SourceContent } from '@graphysdk/viz-engine';
|
|
55
56
|
import { Spec } from '@graphysdk/viz-engine';
|
|
56
|
-
import { SpecInput } from '@graphysdk/viz-engine';
|
|
57
57
|
import { StoreApi } from 'zustand';
|
|
58
58
|
import { StyleReadersForLayer } from '@graphysdk/viz-engine';
|
|
59
59
|
import { StyleReaderTree } from '@graphysdk/viz-engine';
|
|
@@ -234,7 +234,7 @@ export declare const DevToolsPanel: ({ width, style, className }?: DevToolsPanel
|
|
|
234
234
|
* bounded log of recent compiles and the cumulative hit/miss counters.
|
|
235
235
|
*/
|
|
236
236
|
export declare interface DevToolsPanelProps {
|
|
237
|
-
/** Panel width in pixels. Defaults to
|
|
237
|
+
/** Panel width in pixels. Defaults to 440. */
|
|
238
238
|
width?: number;
|
|
239
239
|
/** Style override merged onto the outer wrapper. */
|
|
240
240
|
style?: CSSProperties;
|
|
@@ -472,12 +472,12 @@ export declare interface GraphCommands {
|
|
|
472
472
|
/** Applies a command to the provider's live spec. */
|
|
473
473
|
dispatch: (command: Command, options?: DispatchOptions) => void;
|
|
474
474
|
/**
|
|
475
|
-
* Closes a run of `{ transient: true }` dispatches and fires `
|
|
475
|
+
* Closes a run of `{ transient: true }` dispatches and fires `onSpecChange` once for it. Call it when
|
|
476
476
|
* the gesture ends — pointer up, blur. Forgetting only delays the notification rather than
|
|
477
477
|
* corrupting undo: the run covers one {@link EditTarget}, and the next committed dispatch, undo,
|
|
478
478
|
* redo or external change closes it.
|
|
479
479
|
*/
|
|
480
|
-
|
|
480
|
+
commit: () => void;
|
|
481
481
|
}
|
|
482
482
|
|
|
483
483
|
/**
|
|
@@ -588,16 +588,16 @@ export declare type GraphMode = (typeof GRAPH_MODES)[keyof typeof GRAPH_MODES];
|
|
|
588
588
|
* render-throw from a renderer component — converge on a single {@link GraphErrorBoundary} that shows
|
|
589
589
|
* the error in place, so a broken chart never blanks the page.
|
|
590
590
|
*/
|
|
591
|
-
export declare const GraphProvider: ({ data,
|
|
591
|
+
export declare const GraphProvider: ({ data, spec, plugins, formattingLocale, handleRef, onSpecChange, onError, onWarnings, customPalettes, colorScheme, children, }: GraphProviderProps) => JSX.Element;
|
|
592
592
|
|
|
593
|
-
/** Props for {@link GraphProvider}: the data and spec
|
|
593
|
+
/** Props for {@link GraphProvider}: the data and spec to compile, plus color scheme, locale and plugin wiring. */
|
|
594
594
|
export declare interface GraphProviderProps {
|
|
595
595
|
data: Data;
|
|
596
|
-
|
|
596
|
+
spec: Spec;
|
|
597
597
|
/**
|
|
598
598
|
* Custom geoms, stats, and transforms (and their render halves) registered for this graph. Seeds
|
|
599
599
|
* the compiler and builds the per-provider render resolver from one array. Construction-time config,
|
|
600
|
-
* frozen at mount — change the registered set by remounting (React `key`); `data`/`
|
|
600
|
+
* frozen at mount — change the registered set by remounting (React `key`); `data`/`spec`/`colorScheme`
|
|
601
601
|
* stay reactive.
|
|
602
602
|
*/
|
|
603
603
|
plugins?: readonly Plugin_2[];
|
|
@@ -607,13 +607,13 @@ export declare interface GraphProviderProps {
|
|
|
607
607
|
* hooks can't reach. `useGraphHistoryShortcuts` binds the undo/redo chords to one.
|
|
608
608
|
*/
|
|
609
609
|
handleRef?: Ref<GraphHandle>;
|
|
610
|
-
|
|
610
|
+
onSpecChange?: (next: Spec) => void;
|
|
611
611
|
/** Fires with the compile failure(s) whenever a compile/recompile/dispatch produces errors. */
|
|
612
612
|
onError?: (errors: VizDiagnostic[]) => void;
|
|
613
613
|
/** Fires with any warnings a successful compile produced. */
|
|
614
614
|
onWarnings?: (warnings: VizDiagnostic[]) => void;
|
|
615
615
|
colorScheme?: ColorScheme;
|
|
616
|
-
customPalettes?:
|
|
616
|
+
customPalettes?: CustomPalettes;
|
|
617
617
|
children: ReactNode;
|
|
618
618
|
}
|
|
619
619
|
|
|
@@ -667,7 +667,7 @@ export declare type GraphSizing = {
|
|
|
667
667
|
};
|
|
668
668
|
|
|
669
669
|
/**
|
|
670
|
-
* Region overrides for `GraphRenderer`. A slot replaces how one region paints; the viz-engine `
|
|
670
|
+
* Region overrides for `GraphRenderer`. A slot replaces how one region paints; the viz-engine `ResolvedSpec`
|
|
671
671
|
* still owns whether a region exists and what data it receives, and an override gets the same
|
|
672
672
|
* render-ready props as its default.
|
|
673
673
|
*
|
|
@@ -917,7 +917,7 @@ declare interface OverlayAnchorInput<G extends GeomName | string = string, C ext
|
|
|
917
917
|
* cannot place, and a target whose annotation failed to resolve has to stay selected for the user to
|
|
918
918
|
* be able to repair it.
|
|
919
919
|
*/
|
|
920
|
-
export declare const pruneSelection: (selection: readonly EditTarget[], spec:
|
|
920
|
+
export declare const pruneSelection: (selection: readonly EditTarget[], spec: ResolvedSpec) => readonly EditTarget[];
|
|
921
921
|
|
|
922
922
|
export { RenderHitTester }
|
|
923
923
|
|
|
@@ -1206,14 +1206,14 @@ export declare function useGeomHover(layerId: string): GeomHoverPush;
|
|
|
1206
1206
|
*
|
|
1207
1207
|
* @example
|
|
1208
1208
|
* ```tsx
|
|
1209
|
-
* const { dispatch,
|
|
1209
|
+
* const { dispatch, commit } = useGraphCommands();
|
|
1210
1210
|
*
|
|
1211
1211
|
* const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
1212
1212
|
* const rule = style.graph({ borderRadius: event.target.valueAsNumber });
|
|
1213
1213
|
* dispatch(new SetStyleRuleCommand({ list: 'defaults', rule, id: 'frame-radius' }), { transient: true });
|
|
1214
1214
|
* };
|
|
1215
1215
|
*
|
|
1216
|
-
* const handlePointerUp = () =>
|
|
1216
|
+
* const handlePointerUp = () => commit();
|
|
1217
1217
|
*
|
|
1218
1218
|
* <input type="range" onChange={handleChange} onPointerUp={handlePointerUp}
|
|
1219
1219
|
* />
|
|
@@ -1257,7 +1257,7 @@ export declare const useGraphHistory: () => GraphHistory;
|
|
|
1257
1257
|
* useGraphHistoryShortcuts(handleRef);
|
|
1258
1258
|
*
|
|
1259
1259
|
* return (
|
|
1260
|
-
* <GraphProvider
|
|
1260
|
+
* <GraphProvider spec={input} data={data} handleRef={handleRef}>
|
|
1261
1261
|
* <GraphRenderer mode="editable" />
|
|
1262
1262
|
* </GraphProvider>
|
|
1263
1263
|
* );
|