@graphysdk/react-renderer 1.9.0-beta.1788780809119 → 1.9.0-beta.1788784687575
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/editable.cjs +1 -1
- package/dist/editable.mjs +1 -1
- package/dist/{history-chords-DEguzjPn.js → history-chords-B6gL7Ye8.js} +1158 -1145
- package/dist/history-chords-CWlqrwO3.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +48 -51
- package/package.json +2 -2
- package/dist/history-chords-lLtDj1lQ.cjs +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const c=require("./history-chords-lLtDj1lQ.cjs"),z=require("./dev.utils-C5W6wbHd.cjs");let p=require("@graphysdk/viz-engine"),l=require("react"),i=require("react/jsx-runtime"),U=require("zustand"),K=require("zustand/vanilla"),$=require("clsx");$=c.__toESM($,1);function L(e){for(const t of e)(t.severity==="error"?console.error:console.warn)(`[graphy] ${t.code}: ${t.message}`,t)}var oe="_1a5iqpb0",ie="_1a5iqpb1";var ae="_1a5iqpb3",ce="_1a5iqpb4",le="_1a5iqpb5";var B=({errors:e})=>{const[t,...r]=e;return(0,i.jsxs)("div",{role:"alert",className:oe,children:[(0,i.jsx)("strong",{className:ie,children:"This chart could not be rendered."}),t&&(0,i.jsx)(Y,{diagnostic:t}),r.length>0&&(0,i.jsx)("ul",{className:"_1a5iqpb2",children:r.map((s,o)=>(0,i.jsx)("li",{children:(0,i.jsx)(Y,{diagnostic:s})},`${s.code}-${o}`))})]})},Y=({diagnostic:e})=>(0,i.jsxs)("div",{className:ae,children:[(0,i.jsx)("span",{className:ce,children:e.code}),(0,i.jsx)("p",{className:le,children:e.message}),e.suggestion&&(0,i.jsx)("p",{className:"_1a5iqpb6",children:e.suggestion})]});function de(e=[],t=[]){return e.length===t.length&&e.every((r,s)=>Object.is(r,t[s]))}var X=class extends l.Component{constructor(...e){super(...e),this.state={caughtDiagnostic:null}}static getDerivedStateFromError(e){return{caughtDiagnostic:(0,p.buildDiagnostic)(e)}}componentDidCatch(e,t){const r=(0,p.buildDiagnostic)(e);L([r]),this.props.onError?.([r]),console.error("Chart render component stack:",t.componentStack)}componentDidUpdate(e){this.state.caughtDiagnostic&&!de(e.resetKeys,this.props.resetKeys)&&this.setState({caughtDiagnostic:null})}render(){const{caughtDiagnostic:e}=this.state;if(e)return(0,i.jsx)(B,{errors:[e]});const{forcedErrors:t,children:r}=this.props;return t&&t.length>0?(0,i.jsx)(B,{errors:t}):r}},Q=e=>typeof e=="object"&&"geom"in e&&"render"in e,ue=e=>{const t=(0,p.resolveDefinition)(e);return t instanceof p.Geom?t:null},J=(e,t)=>{const r=e.filter(s=>me(s,t));return r.length===e.length?e:r},me=(e,t)=>e.kind!=="annotation"?!0:(0,p.findAnnotation)(t.annotations,e.id)!==null,F=[],he=()=>(0,K.createStore)(e=>({selection:F,setSelection:t=>e(r=>ge(r.selection,t)?r:{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((r,s)=>{const o=t[s];return o!==void 0&&(0,p.areEditTargetsEqual)(r,o)}),pe=5,fe=e=>{if(!z.IS_DEV)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,K.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(Q),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 m=ue(u);m===null||r.has(m.type)||o.has(m.type)||(o.add(m.type),s.push({kind:"user-input",severity:"error",code:"MISSING_GEOM_RENDERER",message:`Custom geom '${m.type}' is registered but has no renderer.`,context:{requested:m.type,kind:"geom-renderer"},suggestion:`Add a render half for it: \`defineGeomRenderer(${m.type}Geom, { coord, render })\`, then include it in \`plugins\`.`}))}const d=new Map;for(const u of t){if("definition"in u)continue;const m=`${u.geom}|${u.coord}`,v=d.get(m);v?v.count+=1:d.set(m,{geom:u.geom,coord:u.coord,count:1})}const a=[];for(const{geom:u,coord:m,count:v}of d.values())v<2||a.push({kind:"user-input",severity:"warning",code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple render-only overrides register ('${u}', '${m}') (${v} entries); the last in the array wins.`,context:{requested:`${u}@${m}`,kind:"geom-renderer"},suggestion:`Keep a single render-only override for ('${u}', '${m}').`});return{errors:s,warnings:a}}function Ce(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const a of s)t(a.geom,r.type)!==null||o.has(a.geom)||(o.add(a.geom),d.push({kind:"user-input",severity:"warning",code:"MISSING_GEOM_RENDERER",message:`No renderer for geom '${a.geom}' under ${r.type} coords; the layer is not painted.`,context:{requested:a.geom,kind:"geom-renderer"},suggestion:`Register a renderer for ('${a.geom}', '${r.type}') via \`defineGeomRenderer\`.`}));return d}function xe(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const a of s){if(a.interactive===!1||a.spatialKind!=="render-hit-test"||o.has(a.geom))continue;const u=t(a.geom,r.type);u===null||u.hitTest||c.isOverlayHosted(u)||(o.add(a.geom),d.push({kind:"user-input",severity:"warning",code:"MISSING_RENDER_HIT_TEST",message:`Geom '${a.geom}' declares spatialKind 'render-hit-test' but its renderer provides no hit-test; the layer has no hover.`,context:{requested:a.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 ('${a.geom}', '${r.type}').`}))}return d}function Te(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 a of s){if(a.interactive===!1||a.spatialKind!=="render-hit-test"||o.has(a.geom))continue;const u=t(a.geom,r.type);u===null||!u.hitTest||!c.isOverlayHosted(u)||(o.add(a.geom),d.push({kind:"user-input",severity:"warning",code:"CONFLICTING_RENDER_HIT_TEST",message:`Geom '${a.geom}' declares both a \`hitTest\` factory and an overlay render; these are alternatives, so only the overlay is used.`,context:{requested:a.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 qe(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 Ge(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const a of s){if(a.interactive===!1||a.spatialKind==="render-hit-test"||o.has(a.geom))continue;const u=t(a.geom,r.type);u===null||!c.isOverlayHosted(u)||(o.add(a.geom),d.push({kind:"user-input",severity:"warning",code:"OVERLAY_REQUIRES_RENDER_HIT_TEST",message:`Geom '${a.geom}' declares an overlay render but its layer's spatialKind is '${a.spatialKind}', not 'render-hit-test'; the overlay's push-path hover resolves to nothing.`,context:{requested:a.geom,kind:"geom-renderer"},suggestion:"Have the geom's manifest yield spatialKind 'render-hit-test' so the compiled layer carries the `byKey` index the overlay's `pushHover` resolves against."}))}return d}var ke=e=>(0,K.createStore)(t=>({compiled:e,setCompiled:r=>t(s=>s.compiled===r?s:{compiled:r})})),Ne=({input:e,data:t,customPalettes:r,colorScheme:s,plugins:o,resolveRenderer:d,anchorResolver:a,onChange:u,onError:m,onWarnings:v})=>{const x=c.useLatestRef(u),j=c.useLatestRef(m),q=c.useLatestRef(v),[{session:f,compileBus:h}]=(0,l.useState)(()=>{const n=(0,p.createCompiler)({plugins:o});return{session:new p.GraphCompilationSession(n),compileBus:fe(n)}}),[g]=(0,l.useState)(()=>Ee(o??[])),S=(0,l.useRef)(null),[k]=(0,l.useState)(je),T=(0,l.useRef)(null),b=(0,l.useCallback)(n=>g.errors.length===0?n:[...g.errors,...n??[]],[g]),_=(0,l.useCallback)(n=>{if(!n.ok)return n.errors;if(T.current)T.current.getState().setCompiled(n.compiled);else{const y=ke(n.compiled);y.subscribe(k.notify),T.current=y,k.notify()}return null},[k]),[D,w]=(0,l.useState)(()=>{const n=f.compile({input:e,data:t,customPalettes:r,colorScheme:s});return S.current=n,b(_(n))}),G=(0,l.useCallback)(n=>n.ok?[...n.warnings,...Ce(n.compiled,d),...xe(n.compiled,d),...Te(n.compiled),...Re(n.compiled,d),...Ge(n.compiled,d),...qe(n.compiled,a)]:n.warnings,[d,a]),E=(0,l.useCallback)(n=>{n.length!==0&&(L(n),j.current?.(n))},[j]),R=(0,l.useCallback)(n=>{n.length!==0&&(L(n),q.current?.(n))},[q]);(0,l.useEffect)(()=>{const n=S.current;n&&(E([...g.errors,...n.ok?[]:n.errors]),R([...g.warnings,...G(n)]),n.ok&&h.emit({kind:"init"}))},[h,E,R,g,G]),(0,l.useEffect)(()=>{const n=f.update({input:e,data:t,customPalettes:r,colorScheme:s});if(!n)return;n.sealedInput&&x.current?.(n.sealedInput);const y=_(n.result);w(b(y)),y&&E(y),R(G(n.result)),y||h.emit({kind:n.inputChanged?"input":"data"})},[e,t,r,s,f,h,_,E,R,b,G,x]);const N=(0,l.useCallback)(n=>{w(y=>y===null?y:b(null)),R(G(n))},[b,R,G]),I=(0,l.useCallback)(n=>{n.compiled&&T.current?.getState().setCompiled(n.compiled),n.result&&N(n.result),n.command&&h.emit({kind:"command",command:n.command}),n.input&&x.current?.(n.input),n.errors&&E([...n.errors])},[N,h,x,E]),C=(0,l.useCallback)(n=>{for(const y of n)I(y);return n.some(y=>!!y.compiled)},[I]),M=(0,l.useCallback)((n,y)=>{C(f.applyCommand(n,y))},[f,C]),re=(0,l.useCallback)(()=>{C(f.seal())},[f,C]),O=(0,l.useCallback)(()=>C(f.undo()),[f,C]),A=(0,l.useCallback)(()=>C(f.redo()),[f,C]),se=(0,l.useMemo)(()=>({stack:f.history,undo:O,redo:A}),[f,O,A]),ne=(0,l.useCallback)(()=>T.current?.getState().compiled??null,[]);return{store:T.current,dispatch:M,seal:re,history:se,subscribe:k.subscribe,getCompiled:ne,compileBus:h,compileErrors:D}},je=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),notify:()=>e.forEach(t=>t())}},_e={},Z=({data:e,input:t,plugins:r=[],formattingLocale:s,handleRef:o,onChange:d,onError:a,onWarnings:u,customPalettes:m,colorScheme:v="light",themeOverrides:x=_e,children:j})=>{const[q]=(0,l.useState)(()=>c.createGeomRendererResolver(r.filter(Q))),f=(0,l.useId)(),[h]=(0,l.useState)(()=>(0,p.createAnchorResolver)(r)),[g]=(0,l.useState)(()=>he()),{store:S,dispatch:k,seal:T,history:b,subscribe:_,getCompiled:D,compileBus:w,compileErrors:G}=Ne({input:t,data:e,customPalettes:m,colorScheme:v,plugins:r,resolveRenderer:q,anchorResolver:h,onChange:d,onError:a,onWarnings:u});(0,l.useEffect)(()=>{if(S)return S.subscribe((N,I)=>{if(N.compiled.spec===I.compiled.spec)return;const{selection:C,setSelection:M}=g.getState();C.length!==0&&M(J(C,N.compiled.spec))})},[S,g]);const E=(0,l.useMemo)(()=>({dispatch:k,seal:T}),[k,T]);(0,l.useImperativeHandle)(o,()=>({commands:E,undo:b.undo,redo:b.redo,subscribe:_,getCompiled:D,getSelection:()=>g.getState().selection,setSelection:N=>g.getState().setSelection(N),subscribeSelection:g.subscribe}),[E,b,_,D,g]);const R=(0,l.useMemo)(()=>S?{chartId:f,store:S,selectionStore:g,commands:E,history:b,formattingLocale:s,compileBus:w,colorScheme:v,themeOverrides:x,anchorResolver:h}:null,[f,S,g,E,b,s,w,v,x,h]);return(0,i.jsx)(X,{forcedErrors:G,onError:a,resetKeys:[t,e],children:R?(0,i.jsx)(c.GraphContext.Provider,{value:R,children:(0,i.jsx)(c.GeomRendererResolverProvider,{value:q,children:j})}):null})};function we(e){const t=(0,p.createGraphyBuilder)(e);return{...t,GraphProvider:s=>(0,i.jsx)(Z,{...s,plugins:t.plugins})}}var De=({children:e,...t})=>(0,i.jsx)("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",pointerEvents:"none",...t,children:e}),Ie=({box:e,children:t})=>(0,i.jsx)("svg",{x:(0,p.toPercent)(e.x0),y:(0,p.toPercent)(e.y0),width:(0,p.toPercent)(e.x1-e.x0),height:(0,p.toPercent)(e.y1-e.y0),overflow:"hidden",pointerEvents:"none",children:t}),He="drqe3u0",Me="drqe3u1",Pe="drqe3u2",$e="drqe3u3",H="drqe3u4",Le="drqe3u5",Be="drqe3u6",Ke="drqe3u7",P="drqe3u8",Oe="drqe3u9",Ae="drqe3ua";var Ue="drqe3uc",Ye="drqe3ud",Fe="drqe3ue",Ve="drqe3uf";var We="drqe3uh",ze="drqe3ui",V={enabled:"drqe3uk drqe3uj",disabled:"drqe3ul drqe3uj"},W={ran:"drqe3un drqe3um",dim:"drqe3uo drqe3um"},ee={ran:"drqe3uq drqe3up",cached:"drqe3ur drqe3up",untouched:"drqe3us drqe3up"},Xe=({width:e=380,style:t,className:r}={})=>{const{compileBus:s}=c.useGraphContext(),[o]=(0,l.useState)(()=>ve()),[d,a]=(0,l.useState)(!1),[u,m]=(0,l.useState)(p.isCompilerCachingEnabled);(0,l.useEffect)(()=>{const{recordCompile:h}=o.getState(),g=s.getLastTrigger(),S=s.getLastCompile();return g&&S&&h(g,S),s.subscribe(h)},[o,s]);const v=(0,U.useStore)(o,h=>h.lastCompile),x=(0,U.useStore)(o,h=>h.history),j=s.getCacheStats(),q=v===null&&x.length===0,f=()=>{m(h=>{const g=!h;return(0,p.setCompilerCachingEnabled)(g),g})};return(0,i.jsxs)("div",{className:(0,$.default)(Ae,r),style:{width:e,...t},children:[(0,i.jsxs)("div",{className:He,children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:Me,children:"compile cache"}),(0,i.jsx)("div",{className:Fe,children:q?"production: stats disabled":v?`last: ${v.label} · ${te(v.durationMs)}`:"awaiting first compile…"})]}),(0,i.jsx)("button",{type:"button",onClick:()=>a(h=>!h),className:Ve,children:d?"▾":"▴"})]}),!d&&(0,i.jsxs)("div",{className:"drqe3ub",children:[(0,i.jsxs)("button",{type:"button",onClick:f,className:u?V.enabled:V.disabled,"aria-pressed":u,children:["cache ",u?"enabled":"disabled"]}),(0,i.jsx)("span",{className:"drqe3ug",children:"next compile reflects this toggle"})]}),!d&&!q&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(Qe,{delta:v?.stages,cumulative:j}),(0,i.jsx)(Je,{entries:x})]})]})},Qe=({delta:e,cumulative:t})=>(0,i.jsxs)("table",{className:Pe,children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{className:We,children:[(0,i.jsx)("th",{className:$e,children:"stage"}),(0,i.jsx)("th",{className:H,children:"Δ miss"}),(0,i.jsx)("th",{className:H,children:"Δ hit"}),(0,i.jsx)("th",{className:H,children:"total miss"}),(0,i.jsx)("th",{className:H,children:"total hit"})]})}),(0,i.jsx)("tbody",{children:p.COMPILER_STAGE_KEYS.map(r=>{const s=e?.[r],o=Ze(s);return(0,i.jsxs)("tr",{className:Ue,children:[(0,i.jsxs)("td",{className:Le,children:[(0,i.jsx)("span",{className:ee[o],"aria-hidden":!0})," ",r]}),(0,i.jsx)("td",{className:o==="ran"?W.ran:W.dim,children:s?.misses??0}),(0,i.jsx)("td",{className:P,children:s?.hits??0}),(0,i.jsx)("td",{className:P,children:t[r].misses}),(0,i.jsx)("td",{className:P,children:t[r].hits})]},r)})})]}),Je=({entries:e})=>e.length===0?null:(0,i.jsxs)("div",{className:Ye,children:[(0,i.jsx)("div",{className:ze,children:"recent compiles"}),e.map(t=>{const r=et(t.stages,d=>d.misses>0),s=p.COMPILER_STAGE_KEYS.length,o=r===0?"cached":"ran";return(0,i.jsxs)("div",{className:Be,children:[(0,i.jsx)("span",{className:ee[o],"aria-hidden":!0}),(0,i.jsx)("span",{className:Ke,title:t.label,children:t.label}),(0,i.jsxs)("span",{className:Oe,children:[r,"/",s," ran · ",te(t.durationMs)]})]},t.id)})]}),Ze=e=>!e||e.hits===0&&e.misses===0?"untouched":e.misses>0?"ran":"cached",et=(e,t)=>{let r=0;for(const s of p.COMPILER_STAGE_KEYS)t(e[s])&&(r+=1);return r},te=e=>e>=10?`${e.toFixed(0)}ms`:`${e.toFixed(2)}ms`,tt=()=>{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]),a=(0,l.useSyncExternalStore)(o,d,d);return(0,l.useMemo)(()=>({...a,undo:r,redo:s}),[a,r,s])},rt=new Set(["button","checkbox","color","file","hidden","image","radio","range","reset","submit"]),st=(e,t={})=>{const{target:r,enabled:s=!0}=t;(0,l.useEffect)(()=>{const o=nt(r);if(!s||!o)return;const d=a=>{if(!ot(a)||a.defaultPrevented||it(a.target))return;const u=c.resolveHistoryStep(a);if(!u)return;const m=e.current;m&&(u==="undo"?m.undo():m.redo())&&a.preventDefault()};return o.addEventListener("keydown",d),()=>o.removeEventListener("keydown",d)},[e,r,s])},nt=e=>e===void 0?window:e!==null&&"current"in e?e.current:e,ot=e=>"key"in e,it=e=>e instanceof HTMLInputElement?!rt.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=Xe;exports.GraphErrorBoundary=X;exports.GraphErrorPanel=B;exports.GraphProvider=Z;exports.GraphRenderer=c.GraphRenderer;exports.HoverProvider=c.HoverProvider;exports.TextMeasurerProvider=c.TextMeasurerProvider;exports.ThemeProvider=c.ThemeProvider;exports.UnitBoxSvg=Ie;exports.UnitSpaceSvg=De;exports.createGraphyKit=we;exports.darkTheme=c.darkTheme;exports.defineGeomRenderer=c.defineGeomRenderer;exports.lightTheme=c.lightTheme;exports.lightenCss=c.lightenCss;exports.pruneSelection=J;exports.resolveBrandMarkVisual=c.resolveBrandMarkVisual;exports.useCompiledSelector=c.useCompiledSelector;exports.useElementScreenRect=c.useElementScreenRect;exports.useGeomHitTest=c.useGeomHitTest;exports.useGeomHover=c.useGeomHover;exports.useGraphCommands=c.useGraphCommands;exports.useGraphHandle=c.useGraphHandle;exports.useGraphHistory=tt;exports.useGraphHistoryShortcuts=st;exports.useGraphSelection=c.useGraphSelection;exports.useHandleCompiled=c.useHandleCompiled;exports.useHoverState=c.useHoverState;exports.useStyleReaders=c.useStyleReaders;exports.useTextMeasurer=c.useTextMeasurer;exports.vars=z.vars;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const l=require("./history-chords-CWlqrwO3.cjs"),W=require("./dev.utils-C5W6wbHd.cjs");let p=require("@graphysdk/viz-engine"),c=require("react"),i=require("react/jsx-runtime"),A=require("zustand"),B=require("zustand/vanilla"),$=require("clsx");$=l.__toESM($,1);var ne="_1a5iqpb0",oe="_1a5iqpb1";var ie="_1a5iqpb3",ae="_1a5iqpb4",le="_1a5iqpb5";var L=({errors:e})=>{const[t,...r]=e;return(0,i.jsxs)("div",{role:"alert",className:ne,children:[(0,i.jsx)("strong",{className:oe,children:"This chart could not be rendered."}),t&&(0,i.jsx)(U,{diagnostic:t}),r.length>0&&(0,i.jsx)("ul",{className:"_1a5iqpb2",children:r.map((s,o)=>(0,i.jsx)("li",{children:(0,i.jsx)(U,{diagnostic:s})},`${s.code}-${o}`))})]})},U=({diagnostic:e})=>(0,i.jsxs)("div",{className:ie,children:[(0,i.jsx)("span",{className:ae,children:e.code}),(0,i.jsx)("p",{className:le,children:e.message}),e.suggestion&&(0,i.jsx)("p",{className:"_1a5iqpb6",children:e.suggestion})]});function ce(e=[],t=[]){return e.length===t.length&&e.every((r,s)=>Object.is(r,t[s]))}var z=class extends c.Component{constructor(...e){super(...e),this.state={caughtDiagnostic:null}}static getDerivedStateFromError(e){return{caughtDiagnostic:(0,p.buildDiagnostic)(e)}}componentDidCatch(e,t){const r=(0,p.buildDiagnostic)(e);l.logDiagnostics([r]),this.props.onError?.([r]),console.error("Chart render component stack:",t.componentStack)}componentDidUpdate(e){this.state.caughtDiagnostic&&!ce(e.resetKeys,this.props.resetKeys)&&this.setState({caughtDiagnostic:null})}render(){const{caughtDiagnostic:e}=this.state;if(e)return(0,i.jsx)(L,{errors:[e]});const{forcedErrors:t,children:r}=this.props;return t&&t.length>0?(0,i.jsx)(L,{errors:t}):r}},X=e=>typeof e=="object"&&"geom"in e&&"render"in e,de=e=>{const t=(0,p.resolveDefinition)(e);return t instanceof p.Geom?t:null},Q=(e,t)=>{const r=e.filter(s=>ue(s,t));return r.length===e.length?e:r},ue=(e,t)=>e.kind!=="annotation"?!0:(0,p.findAnnotation)(t.annotations,e.id)!==null,Y=[],me=()=>(0,B.createStore)(e=>({selection:Y,setSelection:t=>e(r=>he(r.selection,t)?r:{selection:t}),clearSelection:()=>e(t=>t.selection.length===0?t:{selection:Y})})),he=(e,t)=>e===t?!0:e.length!==t.length?!1:e.every((r,s)=>{const o=t[s];return o!==void 0&&(0,p.areEditTargetsEqual)(r,o)}),ge=5,pe=e=>{if(!W.IS_DEV)return{emit:()=>{},subscribe:()=>ve,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()}},fe=()=>(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:ye(t),stages:r.stages,durationMs:r.durationMs};return{lastCompile:o,history:Se(s.history,o,ge),nextId:s.nextId+1,lastSnapshot:r}})})),ve=()=>{},ye=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}},Se=(e,t,r)=>{const s=e.length>=r?e.length-(r-1):0;return[...e.slice(s),t]};function be(e){const t=e.filter(X),r=new Set([...Object.keys(l.BUILT_IN_GEOM_RENDERERS),...t.map(u=>u.geom)]),s=[],o=new Set;for(const u of e){const m=de(u);m===null||r.has(m.type)||o.has(m.type)||(o.add(m.type),s.push({kind:"user-input",severity:"error",code:"MISSING_GEOM_RENDERER",message:`Custom geom '${m.type}' is registered but has no renderer.`,context:{requested:m.type,kind:"geom-renderer"},suggestion:`Add a render half for it: \`defineGeomRenderer(${m.type}Geom, { coord, render })\`, then include it in \`plugins\`.`}))}const d=new Map;for(const u of t){if("definition"in u)continue;const m=`${u.geom}|${u.coord}`,v=d.get(m);v?v.count+=1:d.set(m,{geom:u.geom,coord:u.coord,count:1})}const a=[];for(const{geom:u,coord:m,count:v}of d.values())v<2||a.push({kind:"user-input",severity:"warning",code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple render-only overrides register ('${u}', '${m}') (${v} entries); the last in the array wins.`,context:{requested:`${u}@${m}`,kind:"geom-renderer"},suggestion:`Keep a single render-only override for ('${u}', '${m}').`});return{errors:s,warnings:a}}function Ee(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const a of s)t(a.geom,r.type)!==null||o.has(a.geom)||(o.add(a.geom),d.push({kind:"user-input",severity:"warning",code:"MISSING_GEOM_RENDERER",message:`No renderer for geom '${a.geom}' under ${r.type} coords; the layer is not painted.`,context:{requested:a.geom,kind:"geom-renderer"},suggestion:`Register a renderer for ('${a.geom}', '${r.type}') via \`defineGeomRenderer\`.`}));return d}function Ce(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const a of s){if(a.interactive===!1||a.spatialKind!=="render-hit-test"||o.has(a.geom))continue;const u=t(a.geom,r.type);u===null||u.hitTest||l.isOverlayHosted(u)||(o.add(a.geom),d.push({kind:"user-input",severity:"warning",code:"MISSING_RENDER_HIT_TEST",message:`Geom '${a.geom}' declares spatialKind 'render-hit-test' but its renderer provides no hit-test; the layer has no hover.`,context:{requested:a.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 ('${a.geom}', '${r.type}').`}))}return d}function xe(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 Te(e,t){const{coordSystem:r,layers:s}=e,o=new Set,d=[];for(const a of s){if(a.interactive===!1||a.spatialKind!=="render-hit-test"||o.has(a.geom))continue;const u=t(a.geom,r.type);u===null||!u.hitTest||!l.isOverlayHosted(u)||(o.add(a.geom),d.push({kind:"user-input",severity:"warning",code:"CONFLICTING_RENDER_HIT_TEST",message:`Geom '${a.geom}' declares both a \`hitTest\` factory and an overlay render; these are alternatives, so only the overlay is used.`,context:{requested:a.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 Re(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 a of s){if(a.interactive===!1||a.spatialKind==="render-hit-test"||o.has(a.geom))continue;const u=t(a.geom,r.type);u===null||!l.isOverlayHosted(u)||(o.add(a.geom),d.push({kind:"user-input",severity:"warning",code:"OVERLAY_REQUIRES_RENDER_HIT_TEST",message:`Geom '${a.geom}' declares an overlay render but its layer's spatialKind is '${a.spatialKind}', not 'render-hit-test'; the overlay's push-path hover resolves to nothing.`,context:{requested:a.geom,kind:"geom-renderer"},suggestion:"Have the geom's manifest yield spatialKind 'render-hit-test' so the compiled layer carries the `byKey` index the overlay's `pushHover` resolves against."}))}return d}var Ge=e=>(0,B.createStore)(t=>({compiled:e,setCompiled:r=>t(s=>s.compiled===r?s:{compiled:r})})),ke=({input:e,data:t,customPalettes:r,colorScheme:s,plugins:o,resolveRenderer:d,anchorResolver:a,onChange:u,onError:m,onWarnings:v})=>{const x=l.useLatestRef(u),j=l.useLatestRef(m),q=l.useLatestRef(v),[{session:f,compileBus:h}]=(0,c.useState)(()=>{const n=(0,p.createCompiler)({plugins:o});return{session:new p.GraphCompilationSession(n),compileBus:pe(n)}}),[g]=(0,c.useState)(()=>be(o??[])),S=(0,c.useRef)(null),[k]=(0,c.useState)(Ne),T=(0,c.useRef)(null),b=(0,c.useCallback)(n=>g.errors.length===0?n:[...g.errors,...n??[]],[g]),_=(0,c.useCallback)(n=>{if(!n.ok)return n.errors;if(T.current)T.current.getState().setCompiled(n.compiled);else{const y=Ge(n.compiled);y.subscribe(k.notify),T.current=y,k.notify()}return null},[k]),[I,D]=(0,c.useState)(()=>{const n=f.compile({input:e,data:t,customPalettes:r,colorScheme:s});return S.current=n,b(_(n))}),G=(0,c.useCallback)(n=>n.ok?[...n.warnings,...Ee(n.compiled,d),...Ce(n.compiled,d),...xe(n.compiled),...Te(n.compiled,d),...qe(n.compiled,d),...Re(n.compiled,a)]:n.warnings,[d,a]),E=(0,c.useCallback)(n=>{n.length!==0&&(l.logDiagnostics(n),j.current?.(n))},[j]),R=(0,c.useCallback)(n=>{n.length!==0&&(l.logDiagnostics(n),q.current?.(n))},[q]);(0,c.useEffect)(()=>{const n=S.current;n&&(E([...g.errors,...n.ok?[]:n.errors]),R([...g.warnings,...G(n)]),n.ok&&h.emit({kind:"init"}))},[h,E,R,g,G]),(0,c.useEffect)(()=>{const n=f.update({input:e,data:t,customPalettes:r,colorScheme:s});if(!n)return;n.sealedInput&&x.current?.(n.sealedInput);const y=_(n.result);D(b(y)),y&&E(y),R(G(n.result)),y||h.emit({kind:n.inputChanged?"input":"data"})},[e,t,r,s,f,h,_,E,R,b,G,x]);const N=(0,c.useCallback)(n=>{D(y=>y===null?y:b(null)),R(G(n))},[b,R,G]),w=(0,c.useCallback)(n=>{n.compiled&&T.current?.getState().setCompiled(n.compiled),n.result&&N(n.result),n.command&&h.emit({kind:"command",command:n.command}),n.input&&x.current?.(n.input),n.errors&&E([...n.errors])},[N,h,x,E]),C=(0,c.useCallback)(n=>{for(const y of n)w(y);return n.some(y=>!!y.compiled)},[w]),M=(0,c.useCallback)((n,y)=>{C(f.applyCommand(n,y))},[f,C]),te=(0,c.useCallback)(()=>{C(f.seal())},[f,C]),K=(0,c.useCallback)(()=>C(f.undo()),[f,C]),O=(0,c.useCallback)(()=>C(f.redo()),[f,C]),re=(0,c.useMemo)(()=>({stack:f.history,undo:K,redo:O}),[f,K,O]),se=(0,c.useCallback)(()=>T.current?.getState().compiled??null,[]);return{store:T.current,dispatch:M,seal:te,history:re,subscribe:k.subscribe,getCompiled:se,compileBus:h,compileErrors:I}},Ne=()=>{const e=new Set;return{subscribe:t=>(e.add(t),()=>{e.delete(t)}),notify:()=>e.forEach(t=>t())}},je={},J=({data:e,input:t,plugins:r=[],formattingLocale:s,handleRef:o,onChange:d,onError:a,onWarnings:u,customPalettes:m,colorScheme:v="light",themeOverrides:x=je,children:j})=>{const[q]=(0,c.useState)(()=>l.createGeomRendererResolver(r.filter(X))),f=(0,c.useId)(),[h]=(0,c.useState)(()=>(0,p.createAnchorResolver)(r)),[g]=(0,c.useState)(()=>me()),{store:S,dispatch:k,seal:T,history:b,subscribe:_,getCompiled:I,compileBus:D,compileErrors:G}=ke({input:t,data:e,customPalettes:m,colorScheme:v,plugins:r,resolveRenderer:q,anchorResolver:h,onChange:d,onError:a,onWarnings:u});(0,c.useEffect)(()=>{if(S)return S.subscribe((N,w)=>{if(N.compiled.spec===w.compiled.spec)return;const{selection:C,setSelection:M}=g.getState();C.length!==0&&M(Q(C,N.compiled.spec))})},[S,g]);const E=(0,c.useMemo)(()=>({dispatch:k,seal:T}),[k,T]);(0,c.useImperativeHandle)(o,()=>({commands:E,undo:b.undo,redo:b.redo,subscribe:_,getCompiled:I,getSelection:()=>g.getState().selection,setSelection:N=>g.getState().setSelection(N),subscribeSelection:g.subscribe}),[E,b,_,I,g]);const R=(0,c.useMemo)(()=>S?{chartId:f,store:S,selectionStore:g,commands:E,history:b,formattingLocale:s,compileBus:D,colorScheme:v,themeOverrides:x,anchorResolver:h}:null,[f,S,g,E,b,s,D,v,x,h]);return(0,i.jsx)(z,{forcedErrors:G,onError:a,resetKeys:[t,e],children:R?(0,i.jsx)(l.GraphContext.Provider,{value:R,children:(0,i.jsx)(l.GeomRendererResolverProvider,{value:q,children:j})}):null})};function _e(e){const t=(0,p.createGraphyBuilder)(e);return{...t,GraphProvider:s=>(0,i.jsx)(J,{...s,plugins:t.plugins})}}var De=({children:e,...t})=>(0,i.jsx)("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",pointerEvents:"none",...t,children:e}),Ie=({box:e,children:t})=>(0,i.jsx)("svg",{x:(0,p.toPercent)(e.x0),y:(0,p.toPercent)(e.y0),width:(0,p.toPercent)(e.x1-e.x0),height:(0,p.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",Ke="drqe3u9",Oe="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"},Z={ran:"drqe3uq drqe3up",cached:"drqe3ur drqe3up",untouched:"drqe3us drqe3up"},ze=({width:e=380,style:t,className:r}={})=>{const{compileBus:s}=l.useGraphContext(),[o]=(0,c.useState)(()=>fe()),[d,a]=(0,c.useState)(!1),[u,m]=(0,c.useState)(p.isCompilerCachingEnabled);(0,c.useEffect)(()=>{const{recordCompile:h}=o.getState(),g=s.getLastTrigger(),S=s.getLastCompile();return g&&S&&h(g,S),s.subscribe(h)},[o,s]);const v=(0,A.useStore)(o,h=>h.lastCompile),x=(0,A.useStore)(o,h=>h.history),j=s.getCacheStats(),q=v===null&&x.length===0,f=()=>{m(h=>{const g=!h;return(0,p.setCompilerCachingEnabled)(g),g})};return(0,i.jsxs)("div",{className:(0,$.default)(Oe,r),style:{width:e,...t},children:[(0,i.jsxs)("div",{className:we,children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:He,children:"compile cache"}),(0,i.jsx)("div",{className:Ye,children:q?"production: stats disabled":v?`last: ${v.label} · ${ee(v.durationMs)}`:"awaiting first compile…"})]}),(0,i.jsx)("button",{type:"button",onClick:()=>a(h=>!h),className:Fe,children:d?"▾":"▴"})]}),!d&&(0,i.jsxs)("div",{className:"drqe3ub",children:[(0,i.jsxs)("button",{type:"button",onClick:f,className:u?F.enabled:F.disabled,"aria-pressed":u,children:["cache ",u?"enabled":"disabled"]}),(0,i.jsx)("span",{className:"drqe3ug",children:"next compile reflects this toggle"})]}),!d&&!q&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(Xe,{delta:v?.stages,cumulative:j}),(0,i.jsx)(Qe,{entries:x})]})]})},Xe=({delta:e,cumulative:t})=>(0,i.jsxs)("table",{className:Me,children:[(0,i.jsx)("thead",{children:(0,i.jsxs)("tr",{className:Ve,children:[(0,i.jsx)("th",{className:Pe,children:"stage"}),(0,i.jsx)("th",{className:H,children:"Δ miss"}),(0,i.jsx)("th",{className:H,children:"Δ hit"}),(0,i.jsx)("th",{className:H,children:"total miss"}),(0,i.jsx)("th",{className:H,children:"total hit"})]})}),(0,i.jsx)("tbody",{children:p.COMPILER_STAGE_KEYS.map(r=>{const s=e?.[r],o=Je(s);return(0,i.jsxs)("tr",{className:Ae,children:[(0,i.jsxs)("td",{className:$e,children:[(0,i.jsx)("span",{className:Z[o],"aria-hidden":!0})," ",r]}),(0,i.jsx)("td",{className:o==="ran"?V.ran:V.dim,children:s?.misses??0}),(0,i.jsx)("td",{className:P,children:s?.hits??0}),(0,i.jsx)("td",{className:P,children:t[r].misses}),(0,i.jsx)("td",{className:P,children:t[r].hits})]},r)})})]}),Qe=({entries:e})=>e.length===0?null:(0,i.jsxs)("div",{className:Ue,children:[(0,i.jsx)("div",{className:We,children:"recent compiles"}),e.map(t=>{const r=Ze(t.stages,d=>d.misses>0),s=p.COMPILER_STAGE_KEYS.length,o=r===0?"cached":"ran";return(0,i.jsxs)("div",{className:Le,children:[(0,i.jsx)("span",{className:Z[o],"aria-hidden":!0}),(0,i.jsx)("span",{className:Be,title:t.label,children:t.label}),(0,i.jsxs)("span",{className:Ke,children:[r,"/",s," ran · ",ee(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 p.COMPILER_STAGE_KEYS)t(e[s])&&(r+=1);return r},ee=e=>e>=10?`${e.toFixed(0)}ms`:`${e.toFixed(2)}ms`,et=()=>{const{history:e}=l.useGraphContext(),{stack:t,undo:r,redo:s}=e,o=(0,c.useCallback)(u=>t.subscribe(u),[t]),d=(0,c.useCallback)(()=>t.getSnapshot(),[t]),a=(0,c.useSyncExternalStore)(o,d,d);return(0,c.useMemo)(()=>({...a,undo:r,redo:s}),[a,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,c.useEffect)(()=>{const o=st(r);if(!s||!o)return;const d=a=>{if(!nt(a)||a.defaultPrevented||ot(a.target))return;const u=l.resolveHistoryStep(a);if(!u)return;const m=e.current;m&&(u==="undo"?m.undo():m.redo())&&a.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=l.BrandMark;exports.CanvasTextMeasurer=l.CanvasTextMeasurer;exports.DefaultFooter=l.DefaultFooter;exports.DefaultGrid=l.DefaultGrid;exports.DefaultHeader=l.DefaultHeader;exports.DefaultSwatch=l.DefaultSwatch;exports.DefaultTooltip=l.DefaultTooltip;exports.DevToolsPanel=ze;exports.GraphErrorBoundary=z;exports.GraphErrorPanel=L;exports.GraphProvider=J;exports.GraphRenderer=l.GraphRenderer;exports.HoverProvider=l.HoverProvider;exports.TextMeasurerProvider=l.TextMeasurerProvider;exports.ThemeProvider=l.ThemeProvider;exports.UnitBoxSvg=Ie;exports.UnitSpaceSvg=De;exports.createGraphyKit=_e;exports.darkTheme=l.darkTheme;exports.defineGeomRenderer=l.defineGeomRenderer;exports.lightTheme=l.lightTheme;exports.lightenCss=l.lightenCss;exports.pruneSelection=Q;exports.resolveBrandMarkVisual=l.resolveBrandMarkVisual;exports.useCompiledSelector=l.useCompiledSelector;exports.useElementScreenRect=l.useElementScreenRect;exports.useGeomHitTest=l.useGeomHitTest;exports.useGeomHover=l.useGeomHover;exports.useGraphCommands=l.useGraphCommands;exports.useGraphHandle=l.useGraphHandle;exports.useGraphHistory=et;exports.useGraphHistoryShortcuts=rt;exports.useGraphSelection=l.useGraphSelection;exports.useHandleCompiled=l.useHandleCompiled;exports.useHoverState=l.useHoverState;exports.useStyleReaders=l.useStyleReaders;exports.useTextMeasurer=l.useTextMeasurer;exports.vars=W.vars;
|
package/dist/index.mjs
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { Ct as
|
|
1
|
+
import { Ct as kt, Ft as re, It as A, M as Dt, Mt as $t, Nt as xt, O as Ht, Pt as de, St as le, Tt as Mt, X as Pt, Y as Lt, _ as Bt, _t as ue, a as Kt, bt as me, ct as Ot, gt as K, i as At, it as jt, j as Yt, jt as Ft, k as Ut, lt as Wt, mt as Vt, n as Xt, pt as Qt, r as zt, rt as Jt, s as Zt, t as ge, tt as er, vt as tr, wt as rr, xt as nr, yt as j } from "./history-chords-B6gL7Ye8.js";
|
|
2
2
|
import { f as or, t as he } from "./dev.utils-HBVa4Fj9.js";
|
|
3
3
|
import { COMPILER_STAGE_KEYS as Y, Geom as pe, GraphCompilationSession as fe, areEditTargetsEqual as ve, buildDiagnostic as V, createAnchorResolver as ye, createCompiler as Se, createGraphyBuilder as be, findAnnotation as Ee, isCompilerCachingEnabled as Te, resolveDefinition as Ce, setCompilerCachingEnabled as Ne, toPercent as M } from "@graphysdk/viz-engine";
|
|
4
|
-
import { Component as Re, useCallback as f, useEffect as $, useId as qe, useImperativeHandle as
|
|
5
|
-
import { Fragment as
|
|
4
|
+
import { Component as Re, useCallback as f, useEffect as $, useId as qe, useImperativeHandle as Ge, useMemo as L, useRef as X, useState as C, useSyncExternalStore as we } from "react";
|
|
5
|
+
import { Fragment as Ie, jsx as d, jsxs as v } from "react/jsx-runtime";
|
|
6
6
|
import { useStore as Q } from "zustand";
|
|
7
7
|
import { createStore as F } from "zustand/vanilla";
|
|
8
|
-
import
|
|
9
|
-
import './index.css';
|
|
10
|
-
for (const t of e) (t.severity === "error" ? console.error : console.warn)(`[graphy] ${t.code}: ${t.message}`, t);
|
|
11
|
-
}
|
|
12
|
-
var Ie = "_1a5iqpb0", De = "_1a5iqpb1";
|
|
8
|
+
import _e from "clsx";
|
|
9
|
+
import './index.css';var ke = "_1a5iqpb0", De = "_1a5iqpb1";
|
|
13
10
|
var $e = "_1a5iqpb3", xe = "_1a5iqpb4", He = "_1a5iqpb5";
|
|
14
11
|
var z = ({ errors: e }) => {
|
|
15
12
|
const [t, ...r] = e;
|
|
16
13
|
return /* @__PURE__ */ v("div", {
|
|
17
14
|
role: "alert",
|
|
18
|
-
className:
|
|
15
|
+
className: ke,
|
|
19
16
|
children: [
|
|
20
17
|
/* @__PURE__ */ d("strong", {
|
|
21
18
|
className: De,
|
|
@@ -298,29 +295,29 @@ var rt = (e) => F((t) => ({
|
|
|
298
295
|
compiled: e,
|
|
299
296
|
setCompiled: (r) => t((n) => n.compiled === r ? n : { compiled: r })
|
|
300
297
|
})), nt = ({ input: e, data: t, customPalettes: r, colorScheme: n, plugins: o, resolveRenderer: a, anchorResolver: i, onChange: c, onError: l, onWarnings: h }) => {
|
|
301
|
-
const T = K(c),
|
|
298
|
+
const T = K(c), _ = K(l), q = K(h), [{ session: g, compileBus: u }] = C(() => {
|
|
302
299
|
const s = Se({ plugins: o });
|
|
303
300
|
return {
|
|
304
301
|
session: new fe(s),
|
|
305
302
|
compileBus: Ye(s)
|
|
306
303
|
};
|
|
307
|
-
}), [m] = C(() => Xe(o ?? [])), y = X(null), [
|
|
304
|
+
}), [m] = C(() => Xe(o ?? [])), y = X(null), [w] = C(st), N = X(null), S = f((s) => m.errors.length === 0 ? s : [...m.errors, ...s ?? []], [m]), k = f((s) => {
|
|
308
305
|
if (!s.ok) return s.errors;
|
|
309
306
|
if (N.current) N.current.getState().setCompiled(s.compiled);
|
|
310
307
|
else {
|
|
311
308
|
const p = rt(s.compiled);
|
|
312
|
-
p.subscribe(
|
|
309
|
+
p.subscribe(w.notify), N.current = p, w.notify();
|
|
313
310
|
}
|
|
314
311
|
return null;
|
|
315
|
-
}, [
|
|
312
|
+
}, [w]), [x, D] = C(() => {
|
|
316
313
|
const s = g.compile({
|
|
317
314
|
input: e,
|
|
318
315
|
data: t,
|
|
319
316
|
customPalettes: r,
|
|
320
317
|
colorScheme: n
|
|
321
318
|
});
|
|
322
|
-
return y.current = s, S(
|
|
323
|
-
}),
|
|
319
|
+
return y.current = s, S(k(s));
|
|
320
|
+
}), G = f((s) => s.ok ? [
|
|
324
321
|
...s.warnings,
|
|
325
322
|
...Qe(s.compiled, a),
|
|
326
323
|
...ze(s.compiled, a),
|
|
@@ -329,19 +326,19 @@ var rt = (e) => F((t) => ({
|
|
|
329
326
|
...tt(s.compiled, a),
|
|
330
327
|
...et(s.compiled, i)
|
|
331
328
|
] : s.warnings, [a, i]), b = f((s) => {
|
|
332
|
-
s.length !== 0 && (A(s),
|
|
333
|
-
}, [
|
|
329
|
+
s.length !== 0 && (A(s), _.current?.(s));
|
|
330
|
+
}, [_]), R = f((s) => {
|
|
334
331
|
s.length !== 0 && (A(s), q.current?.(s));
|
|
335
332
|
}, [q]);
|
|
336
333
|
$(() => {
|
|
337
334
|
const s = y.current;
|
|
338
|
-
s && (b([...m.errors, ...s.ok ? [] : s.errors]), R([...m.warnings, ...
|
|
335
|
+
s && (b([...m.errors, ...s.ok ? [] : s.errors]), R([...m.warnings, ...G(s)]), s.ok && u.emit({ kind: "init" }));
|
|
339
336
|
}, [
|
|
340
337
|
u,
|
|
341
338
|
b,
|
|
342
339
|
R,
|
|
343
340
|
m,
|
|
344
|
-
|
|
341
|
+
G
|
|
345
342
|
]), $(() => {
|
|
346
343
|
const s = g.update({
|
|
347
344
|
input: e,
|
|
@@ -351,8 +348,8 @@ var rt = (e) => F((t) => ({
|
|
|
351
348
|
});
|
|
352
349
|
if (!s) return;
|
|
353
350
|
s.sealedInput && T.current?.(s.sealedInput);
|
|
354
|
-
const p =
|
|
355
|
-
D(S(p)), p && b(p), R(
|
|
351
|
+
const p = k(s.result);
|
|
352
|
+
D(S(p)), p && b(p), R(G(s.result)), p || u.emit({ kind: s.inputChanged ? "input" : "data" });
|
|
356
353
|
}, [
|
|
357
354
|
e,
|
|
358
355
|
t,
|
|
@@ -360,26 +357,26 @@ var rt = (e) => F((t) => ({
|
|
|
360
357
|
n,
|
|
361
358
|
g,
|
|
362
359
|
u,
|
|
363
|
-
|
|
360
|
+
k,
|
|
364
361
|
b,
|
|
365
362
|
R,
|
|
366
363
|
S,
|
|
367
|
-
|
|
364
|
+
G,
|
|
368
365
|
T
|
|
369
366
|
]);
|
|
370
|
-
const
|
|
371
|
-
D((p) => p === null ? p : S(null)), R(
|
|
367
|
+
const I = f((s) => {
|
|
368
|
+
D((p) => p === null ? p : S(null)), R(G(s));
|
|
372
369
|
}, [
|
|
373
370
|
S,
|
|
374
371
|
R,
|
|
375
|
-
|
|
372
|
+
G
|
|
376
373
|
]), H = f((s) => {
|
|
377
|
-
s.compiled && N.current?.getState().setCompiled(s.compiled), s.result &&
|
|
374
|
+
s.compiled && N.current?.getState().setCompiled(s.compiled), s.result && I(s.result), s.command && u.emit({
|
|
378
375
|
kind: "command",
|
|
379
376
|
command: s.command
|
|
380
377
|
}), s.input && T.current?.(s.input), s.errors && b([...s.errors]);
|
|
381
378
|
}, [
|
|
382
|
-
|
|
379
|
+
I,
|
|
383
380
|
u,
|
|
384
381
|
T,
|
|
385
382
|
b
|
|
@@ -404,7 +401,7 @@ var rt = (e) => F((t) => ({
|
|
|
404
401
|
dispatch: B,
|
|
405
402
|
seal: ie,
|
|
406
403
|
history: ae,
|
|
407
|
-
subscribe:
|
|
404
|
+
subscribe: w.subscribe,
|
|
408
405
|
getCompiled: ce,
|
|
409
406
|
compileBus: u,
|
|
410
407
|
compileErrors: x
|
|
@@ -417,8 +414,8 @@ var rt = (e) => F((t) => ({
|
|
|
417
414
|
}),
|
|
418
415
|
notify: () => e.forEach((t) => t())
|
|
419
416
|
};
|
|
420
|
-
}, ot = {}, it = ({ data: e, input: t, plugins: r = [], formattingLocale: n, handleRef: o, onChange: a, onError: i, onWarnings: c, customPalettes: l, colorScheme: h = "light", themeOverrides: T = ot, children:
|
|
421
|
-
const [q] = C(() => ue(r.filter(ne))), g = qe(), [u] = C(() => ye(r)), [m] = C(() => Oe()), { store: y, dispatch:
|
|
417
|
+
}, ot = {}, it = ({ data: e, input: t, plugins: r = [], formattingLocale: n, handleRef: o, onChange: a, onError: i, onWarnings: c, customPalettes: l, colorScheme: h = "light", themeOverrides: T = ot, children: _ }) => {
|
|
418
|
+
const [q] = C(() => ue(r.filter(ne))), g = qe(), [u] = C(() => ye(r)), [m] = C(() => Oe()), { store: y, dispatch: w, seal: N, history: S, subscribe: k, getCompiled: x, compileBus: D, compileErrors: G } = nt({
|
|
422
419
|
input: t,
|
|
423
420
|
data: e,
|
|
424
421
|
customPalettes: l,
|
|
@@ -432,29 +429,29 @@ var rt = (e) => F((t) => ({
|
|
|
432
429
|
});
|
|
433
430
|
$(() => {
|
|
434
431
|
if (y)
|
|
435
|
-
return y.subscribe((
|
|
436
|
-
if (
|
|
432
|
+
return y.subscribe((I, H) => {
|
|
433
|
+
if (I.compiled.spec === H.compiled.spec) return;
|
|
437
434
|
const { selection: E, setSelection: B } = m.getState();
|
|
438
|
-
E.length !== 0 && B(Be(E,
|
|
435
|
+
E.length !== 0 && B(Be(E, I.compiled.spec));
|
|
439
436
|
});
|
|
440
437
|
}, [y, m]);
|
|
441
438
|
const b = L(() => ({
|
|
442
|
-
dispatch:
|
|
439
|
+
dispatch: w,
|
|
443
440
|
seal: N
|
|
444
|
-
}), [
|
|
445
|
-
|
|
441
|
+
}), [w, N]);
|
|
442
|
+
Ge(o, () => ({
|
|
446
443
|
commands: b,
|
|
447
444
|
undo: S.undo,
|
|
448
445
|
redo: S.redo,
|
|
449
|
-
subscribe:
|
|
446
|
+
subscribe: k,
|
|
450
447
|
getCompiled: x,
|
|
451
448
|
getSelection: () => m.getState().selection,
|
|
452
|
-
setSelection: (
|
|
449
|
+
setSelection: (I) => m.getState().setSelection(I),
|
|
453
450
|
subscribeSelection: m.subscribe
|
|
454
451
|
}), [
|
|
455
452
|
b,
|
|
456
453
|
S,
|
|
457
|
-
|
|
454
|
+
k,
|
|
458
455
|
x,
|
|
459
456
|
m
|
|
460
457
|
]);
|
|
@@ -482,14 +479,14 @@ var rt = (e) => F((t) => ({
|
|
|
482
479
|
u
|
|
483
480
|
]);
|
|
484
481
|
return /* @__PURE__ */ d(Pe, {
|
|
485
|
-
forcedErrors:
|
|
482
|
+
forcedErrors: G,
|
|
486
483
|
onError: i,
|
|
487
484
|
resetKeys: [t, e],
|
|
488
485
|
children: R ? /* @__PURE__ */ d(de.Provider, {
|
|
489
486
|
value: R,
|
|
490
487
|
children: /* @__PURE__ */ d(le, {
|
|
491
488
|
value: q,
|
|
492
|
-
children:
|
|
489
|
+
children: _
|
|
493
490
|
})
|
|
494
491
|
}) : null
|
|
495
492
|
});
|
|
@@ -538,14 +535,14 @@ var bt = "drqe3uh", Et = "drqe3ui", ee = {
|
|
|
538
535
|
const { recordCompile: u } = o.getState(), m = n.getLastTrigger(), y = n.getLastCompile();
|
|
539
536
|
return m && y && u(m, y), n.subscribe(u);
|
|
540
537
|
}, [o, n]);
|
|
541
|
-
const h = Q(o, (u) => u.lastCompile), T = Q(o, (u) => u.history),
|
|
538
|
+
const h = Q(o, (u) => u.lastCompile), T = Q(o, (u) => u.history), _ = n.getCacheStats(), q = h === null && T.length === 0, g = () => {
|
|
542
539
|
l((u) => {
|
|
543
540
|
const m = !u;
|
|
544
541
|
return Ne(m), m;
|
|
545
542
|
});
|
|
546
543
|
};
|
|
547
544
|
return /* @__PURE__ */ v("div", {
|
|
548
|
-
className:
|
|
545
|
+
className: _e(pt, r),
|
|
549
546
|
style: {
|
|
550
547
|
width: e,
|
|
551
548
|
...t
|
|
@@ -579,9 +576,9 @@ var bt = "drqe3uh", Et = "drqe3ui", ee = {
|
|
|
579
576
|
children: "next compile reflects this toggle"
|
|
580
577
|
})]
|
|
581
578
|
}),
|
|
582
|
-
!a && !q && /* @__PURE__ */ v(
|
|
579
|
+
!a && !q && /* @__PURE__ */ v(Ie, { children: [/* @__PURE__ */ d(Tt, {
|
|
583
580
|
delta: h?.stages,
|
|
584
|
-
cumulative:
|
|
581
|
+
cumulative: _
|
|
585
582
|
}), /* @__PURE__ */ d(Ct, { entries: T })] })
|
|
586
583
|
]
|
|
587
584
|
});
|
|
@@ -683,7 +680,7 @@ var bt = "drqe3uh", Et = "drqe3ui", ee = {
|
|
|
683
680
|
for (const n of Y) t(e[n]) && (r += 1);
|
|
684
681
|
return r;
|
|
685
682
|
}, oe = (e) => e >= 10 ? `${e.toFixed(0)}ms` : `${e.toFixed(2)}ms`, fr = () => {
|
|
686
|
-
const { history: e } = re(), { stack: t, undo: r, redo: n } = e, o = f((c) => t.subscribe(c), [t]), a = f(() => t.getSnapshot(), [t]), i =
|
|
683
|
+
const { history: e } = re(), { stack: t, undo: r, redo: n } = e, o = f((c) => t.subscribe(c), [t]), a = f(() => t.getSnapshot(), [t]), i = we(o, a, a);
|
|
687
684
|
return L(() => ({
|
|
688
685
|
...i,
|
|
689
686
|
undo: r,
|
|
@@ -707,10 +704,10 @@ var bt = "drqe3uh", Et = "drqe3ui", ee = {
|
|
|
707
704
|
]), vr = (e, t = {}) => {
|
|
708
705
|
const { target: r, enabled: n = !0 } = t;
|
|
709
706
|
$(() => {
|
|
710
|
-
const o =
|
|
707
|
+
const o = Gt(r);
|
|
711
708
|
if (!n || !o) return;
|
|
712
709
|
const a = (i) => {
|
|
713
|
-
if (!
|
|
710
|
+
if (!wt(i) || i.defaultPrevented || It(i.target)) return;
|
|
714
711
|
const c = ge(i);
|
|
715
712
|
if (!c) return;
|
|
716
713
|
const l = e.current;
|
|
@@ -722,7 +719,7 @@ var bt = "drqe3uh", Et = "drqe3ui", ee = {
|
|
|
722
719
|
r,
|
|
723
720
|
n
|
|
724
721
|
]);
|
|
725
|
-
},
|
|
722
|
+
}, Gt = (e) => e === void 0 ? window : e !== null && "current" in e ? e.current : e, wt = (e) => "key" in e, It = (e) => e instanceof HTMLInputElement ? !qt.has(e.type) : e instanceof HTMLElement ? e.isContentEditable || e.tagName === "TEXTAREA" : !1;
|
|
726
723
|
export {
|
|
727
724
|
Yt as BrandMark,
|
|
728
725
|
Mt as CanvasTextMeasurer,
|
|
@@ -737,7 +734,7 @@ export {
|
|
|
737
734
|
it as GraphProvider,
|
|
738
735
|
Kt as GraphRenderer,
|
|
739
736
|
Vt as HoverProvider,
|
|
740
|
-
|
|
737
|
+
kt as TextMeasurerProvider,
|
|
741
738
|
er as ThemeProvider,
|
|
742
739
|
hr as UnitBoxSvg,
|
|
743
740
|
gr as UnitSpaceSvg,
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"visualization",
|
|
12
12
|
"renderer"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.9.0-beta.
|
|
14
|
+
"version": "1.9.0-beta.1788784687575",
|
|
15
15
|
"type": "module",
|
|
16
16
|
"sideEffects": [
|
|
17
17
|
"**/*.css.ts",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"react-colorful": "^5.6.1",
|
|
56
56
|
"react-intl": "^8.1.3",
|
|
57
57
|
"zustand": "^5.0.12",
|
|
58
|
-
"@graphysdk/viz-engine": "1.9.0-beta.
|
|
58
|
+
"@graphysdk/viz-engine": "1.9.0-beta.1788784687575"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@tiptap/core": "^3.0.0",
|