@graphysdk/react-renderer 1.9.0-beta.1788545270301 → 1.9.0-beta.1788548769329
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.d.ts +4 -1
- package/dist/editable.mjs +1 -1
- package/dist/history-chords-CdevhfYn.cjs +1 -0
- package/dist/{history-chords-Bnz0bbie.js → history-chords-Ce-I6T2V.js} +22 -12
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +22 -10
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/history-chords-BurHF4pj.cjs +0 -1
|
@@ -24,7 +24,7 @@ import './history-chords.css';var gr = Object.defineProperty, Mi = (e, t) => {
|
|
|
24
24
|
});
|
|
25
25
|
return t || gr(r, Symbol.toStringTag, { value: "Module" }), r;
|
|
26
26
|
};
|
|
27
|
-
typeof window < "u" && (window.__GRAPHY_SDK__ ??= {}, window.__GRAPHY_SDK__.reactRenderer = "1.9.0-beta.
|
|
27
|
+
typeof window < "u" && (window.__GRAPHY_SDK__ ??= {}, window.__GRAPHY_SDK__.reactRenderer = "1.9.0-beta.1788548769329");
|
|
28
28
|
var xn = U(null), G = () => {
|
|
29
29
|
const e = D(xn);
|
|
30
30
|
if (!e) throw new Error("useGraph* hooks must be used inside a <GraphProvider>");
|
|
@@ -2683,7 +2683,14 @@ function jl(e, t) {
|
|
|
2683
2683
|
}, [t]), M(() => (r.registerHitTester(e, (o) => n.current(o)), () => r.unregisterHitTester(e)), [r, e]);
|
|
2684
2684
|
}
|
|
2685
2685
|
var Xl = ({ hitTest: e, input: t }) => {
|
|
2686
|
-
const r = A(() => e(t), [
|
|
2686
|
+
const r = A(() => e(t), [
|
|
2687
|
+
e,
|
|
2688
|
+
t.layer.data,
|
|
2689
|
+
t.panelRect.x,
|
|
2690
|
+
t.panelRect.y,
|
|
2691
|
+
t.panelRect.width,
|
|
2692
|
+
t.panelRect.height
|
|
2693
|
+
]);
|
|
2687
2694
|
return jl(t.layer.id, r), null;
|
|
2688
2695
|
}, ql = "graphy_root", no = () => typeof document > "u" ? null : document.getElementById(ql) ?? document.body, Jl = "_10igzta0", Zl = ({ rect: e, zIndex: t, container: r, boxRef: n, children: o, ...a }) => r === null ? null : mn(/* @__PURE__ */ s("div", {
|
|
2689
2696
|
...a,
|
|
@@ -5923,23 +5930,24 @@ var Yo = (e, t) => {
|
|
|
5923
5930
|
})
|
|
5924
5931
|
]
|
|
5925
5932
|
});
|
|
5926
|
-
}, Sg = ({ layer: e, coordSystem: t, shouldAnimateTransitions: r, isDimmed: n, dimStyle: o, formattingLocale: a }) => {
|
|
5927
|
-
const
|
|
5928
|
-
if (
|
|
5929
|
-
const
|
|
5930
|
-
return
|
|
5933
|
+
}, Sg = ({ layer: e, coordSystem: t, shouldAnimateTransitions: r, isDimmed: n, dimStyle: o, formattingLocale: a, panelRect: i }) => {
|
|
5934
|
+
const l = de(), c = sd(e.id), { colorScheme: u } = G(), d = T(e), v = l(e.geom, t.type);
|
|
5935
|
+
if (v === null) return null;
|
|
5936
|
+
const g = yt(v.render);
|
|
5937
|
+
return g.overlay ? null : /* @__PURE__ */ s("g", {
|
|
5931
5938
|
style: n ? {
|
|
5932
5939
|
opacity: o.opacity,
|
|
5933
5940
|
...o.saturation === void 0 ? {} : { filter: `saturate(${o.saturation})` }
|
|
5934
5941
|
} : void 0,
|
|
5935
|
-
children:
|
|
5942
|
+
children: g.fn({
|
|
5936
5943
|
layer: e,
|
|
5937
5944
|
coordSystem: t,
|
|
5938
5945
|
shouldAnimateTransitions: r,
|
|
5939
5946
|
formattingLocale: a,
|
|
5940
|
-
intro:
|
|
5941
|
-
|
|
5942
|
-
|
|
5947
|
+
intro: c,
|
|
5948
|
+
panelRect: i,
|
|
5949
|
+
colorScheme: u,
|
|
5950
|
+
styleReaders: d
|
|
5943
5951
|
})
|
|
5944
5952
|
});
|
|
5945
5953
|
};
|
|
@@ -6120,6 +6128,7 @@ var Rg = 4, Cg = ({ renderer: e, layer: t, matchedLayer: r, overlayCandidates: n
|
|
|
6120
6128
|
coordSystem: t,
|
|
6121
6129
|
shouldAnimateTransitions: r,
|
|
6122
6130
|
formattingLocale: o,
|
|
6131
|
+
panelRect: n,
|
|
6123
6132
|
colorScheme: u,
|
|
6124
6133
|
styleReaders: T(e)
|
|
6125
6134
|
}, v = i ? yt(i.render) : null, g = e.spatialKind === "render-hit-test", h = Og(e);
|
|
@@ -6133,7 +6142,8 @@ var Rg = 4, Cg = ({ renderer: e, layer: t, matchedLayer: r, overlayCandidates: n
|
|
|
6133
6142
|
shouldAnimateTransitions: r,
|
|
6134
6143
|
isDimmed: l?.composition.isDimmed ?? !1,
|
|
6135
6144
|
dimStyle: c,
|
|
6136
|
-
formattingLocale: o
|
|
6145
|
+
formattingLocale: o,
|
|
6146
|
+
panelRect: n
|
|
6137
6147
|
}),
|
|
6138
6148
|
g && !v?.overlay && i?.hitTest && /* @__PURE__ */ s(Xl, {
|
|
6139
6149
|
hitTest: i.hitTest,
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const l=require("./history-chords-BurHF4pj.cjs"),z=require("./dev.utils-C5W6wbHd.cjs");let y=require("@graphysdk/viz-engine"),c=require("react"),a=require("react/jsx-runtime"),Y=require("zustand"),O=require("zustand/vanilla"),P=require("clsx");P=l.__toESM(P,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",le="_1a5iqpb4",ce="_1a5iqpb5";var K=({errors:e})=>{const[t,...r]=e;return(0,a.jsxs)("div",{role:"alert",className:oe,children:[(0,a.jsx)("strong",{className:ie,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:le,children:e.code}),(0,a.jsx)("p",{className:ce,children:e.message}),e.suggestion&&(0,a.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 c.Component{constructor(...e){super(...e),this.state={caughtDiagnostic:null}}static getDerivedStateFromError(e){return{caughtDiagnostic:(0,y.buildDiagnostic)(e)}}componentDidCatch(e,t){const r=(0,y.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,a.jsx)(K,{errors:[e]});const{forcedErrors:t,children:r}=this.props;return t&&t.length>0?(0,a.jsx)(K,{errors:t}):r}},Q=e=>typeof e=="object"&&"geom"in e&&"render"in e,ue=e=>{const t=(0,y.resolveDefinition)(e);return t instanceof y.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,y.findAnnotation)(t.annotations,e.id)!==null,F=[],he=()=>(0,O.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,y.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,O.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(l.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}`,f=d.get(m);f?f.count+=1:d.set(m,{geom:u.geom,coord:u.coord,count:1})}const i=[];for(const{geom:u,coord:m,count:f}of d.values())f<2||i.push({kind:"user-input",severity:"warning",code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple render-only overrides register ('${u}', '${m}') (${f} 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:i}}function Ce(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 xe(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||l.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 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 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||!l.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 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 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||!l.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 compiled layer carries the `byKey` index the overlay's `pushHover` resolves against."}))}return d}var ke=e=>(0,O.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:i,onChange:u,onError:m,onWarnings:f})=>{const x=l.useLatestRef(u),j=l.useLatestRef(m),q=l.useLatestRef(f),[{session:p,compileBus:h}]=(0,c.useState)(()=>{const n=(0,y.createCompiler)({plugins:o});return{session:new y.GraphCompilationSession(n),compileBus:fe(n)}}),[g]=(0,c.useState)(()=>Ee(o??[])),S=(0,c.useRef)(null),[k]=(0,c.useState)(je),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 v=ke(n.compiled);v.subscribe(k.notify),T.current=v,k.notify()}return null},[k]),[I,D]=(0,c.useState)(()=>{const n=p.compile({input:e,data:t,customPalettes:r,colorScheme:s});return S.current=n,b(_(n))}),G=(0,c.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,i)]:n.warnings,[d,i]),E=(0,c.useCallback)(n=>{n.length!==0&&(L(n),j.current?.(n))},[j]),R=(0,c.useCallback)(n=>{n.length!==0&&(L(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=p.update({input:e,data:t,customPalettes:r,colorScheme:s});if(!n)return;n.sealedInput&&x.current?.(n.sealedInput);const v=_(n.result);D(b(v)),v&&E(v),R(G(n.result)),v||h.emit({kind:n.inputChanged?"input":"data"})},[e,t,r,s,p,h,_,E,R,b,G,x]);const N=(0,c.useCallback)(n=>{D(v=>v===null?v: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 v of n)w(v);return n.some(v=>!!v.compiled)},[w]),M=(0,c.useCallback)((n,v)=>{C(p.applyCommand(n,v))},[p,C]),re=(0,c.useCallback)(()=>{C(p.seal())},[p,C]),B=(0,c.useCallback)(()=>C(p.undo()),[p,C]),A=(0,c.useCallback)(()=>C(p.redo()),[p,C]),se=(0,c.useMemo)(()=>({stack:p.history,undo:B,redo:A}),[p,B,A]),ne=(0,c.useCallback)(()=>T.current?.getState().compiled??null,[]);return{store:T.current,dispatch:M,seal:re,history:se,subscribe:k.subscribe,getCompiled:ne,compileBus:h,compileErrors:I}},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:i,onWarnings:u,customPalettes:m,colorScheme:f="light",themeOverrides:x=_e,children:j})=>{const[q]=(0,c.useState)(()=>l.createGeomRendererResolver(r.filter(Q))),p=(0,c.useId)(),[h]=(0,c.useState)(()=>(0,y.createAnchorResolver)(r)),[g]=(0,c.useState)(()=>he()),{store:S,dispatch:k,seal:T,history:b,subscribe:_,getCompiled:I,compileBus:D,compileErrors:G}=Ne({input:t,data:e,customPalettes:m,colorScheme:f,plugins:r,resolveRenderer:q,anchorResolver:h,onChange:d,onError:i,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(J(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:p,store:S,selectionStore:g,commands:E,history:b,formattingLocale:s,compileBus:D,colorScheme:f,themeOverrides:x,anchorResolver:h}:null,[p,S,g,E,b,s,D,f,x,h]);return(0,a.jsx)(X,{forcedErrors:G,onError:i,resetKeys:[t,e],children:R?(0,a.jsx)(l.GraphContext.Provider,{value:R,children:(0,a.jsx)(l.GeomRendererResolverProvider,{value:q,children:j})}):null})};function De(e){const t=(0,y.createGraphyBuilder)(e);return{...t,GraphProvider:s=>(0,a.jsx)(Z,{...s,plugins:t.plugins})}}var Ie=({children:e,...t})=>(0,a.jsx)("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",pointerEvents:"none",...t,children:e}),we="drqe3u0",He="drqe3u1",Me="drqe3u2",$e="drqe3u3",H="drqe3u4",Pe="drqe3u5",Le="drqe3u6",Ke="drqe3u7",$="drqe3u8",Oe="drqe3u9",Be="drqe3ua";var Ae="drqe3uc",Ye="drqe3ud",Ue="drqe3ue",Fe="drqe3uf";var Ve="drqe3uh",We="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"},ze=({width:e=380,style:t,className:r}={})=>{const{compileBus:s}=l.useGraphContext(),[o]=(0,c.useState)(()=>ve()),[d,i]=(0,c.useState)(!1),[u,m]=(0,c.useState)(y.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 f=(0,Y.useStore)(o,h=>h.lastCompile),x=(0,Y.useStore)(o,h=>h.history),j=s.getCacheStats(),q=f===null&&x.length===0,p=()=>{m(h=>{const g=!h;return(0,y.setCompilerCachingEnabled)(g),g})};return(0,a.jsxs)("div",{className:(0,P.default)(Be,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:Ue,children:q?"production: stats disabled":f?`last: ${f.label} · ${te(f.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:p,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"})]}),!d&&!q&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Xe,{delta:f?.stages,cumulative:j}),(0,a.jsx)(Qe,{entries:x})]})]})},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:$e,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:y.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:Pe,children:[(0,a.jsx)("span",{className:ee[o],"aria-hidden":!0})," ",r]}),(0,a.jsx)("td",{className:o==="ran"?W.ran:W.dim,children:s?.misses??0}),(0,a.jsx)("td",{className:$,children:s?.hits??0}),(0,a.jsx)("td",{className:$,children:t[r].misses}),(0,a.jsx)("td",{className:$,children:t[r].hits})]},r)})})]}),Qe=({entries:e})=>e.length===0?null:(0,a.jsxs)("div",{className:Ye,children:[(0,a.jsx)("div",{className:We,children:"recent compiles"}),e.map(t=>{const r=Ze(t.stages,d=>d.misses>0),s=y.COMPILER_STAGE_KEYS.length,o=r===0?"cached":"ran";return(0,a.jsxs)("div",{className:Le,children:[(0,a.jsx)("span",{className:ee[o],"aria-hidden":!0}),(0,a.jsx)("span",{className:Ke,title:t.label,children:t.label}),(0,a.jsxs)("span",{className:Oe,children:[r,"/",s," ran · ",te(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 y.COMPILER_STAGE_KEYS)t(e[s])&&(r+=1);return r},te=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]),i=(0,c.useSyncExternalStore)(o,d,d);return(0,c.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,c.useEffect)(()=>{const o=st(r);if(!s||!o)return;const d=i=>{if(!nt(i)||i.defaultPrevented||ot(i.target))return;const u=l.resolveHistoryStep(i);if(!u)return;const m=e.current;m&&(u==="undo"?m.undo():m.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=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=X;exports.GraphErrorPanel=K;exports.GraphProvider=Z;exports.GraphRenderer=l.GraphRenderer;exports.HoverProvider=l.HoverProvider;exports.TextMeasurerProvider=l.TextMeasurerProvider;exports.ThemeProvider=l.ThemeProvider;exports.UnitSpaceSvg=Ie;exports.createGraphyKit=De;exports.darkTheme=l.darkTheme;exports.defineGeomRenderer=l.defineGeomRenderer;exports.lightTheme=l.lightTheme;exports.lightenCss=l.lightenCss;exports.pruneSelection=J;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=z.vars;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./index.css');const l=require("./history-chords-CdevhfYn.cjs"),z=require("./dev.utils-C5W6wbHd.cjs");let y=require("@graphysdk/viz-engine"),c=require("react"),a=require("react/jsx-runtime"),Y=require("zustand"),O=require("zustand/vanilla"),P=require("clsx");P=l.__toESM(P,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",le="_1a5iqpb4",ce="_1a5iqpb5";var K=({errors:e})=>{const[t,...r]=e;return(0,a.jsxs)("div",{role:"alert",className:oe,children:[(0,a.jsx)("strong",{className:ie,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:le,children:e.code}),(0,a.jsx)("p",{className:ce,children:e.message}),e.suggestion&&(0,a.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 c.Component{constructor(...e){super(...e),this.state={caughtDiagnostic:null}}static getDerivedStateFromError(e){return{caughtDiagnostic:(0,y.buildDiagnostic)(e)}}componentDidCatch(e,t){const r=(0,y.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,a.jsx)(K,{errors:[e]});const{forcedErrors:t,children:r}=this.props;return t&&t.length>0?(0,a.jsx)(K,{errors:t}):r}},Q=e=>typeof e=="object"&&"geom"in e&&"render"in e,ue=e=>{const t=(0,y.resolveDefinition)(e);return t instanceof y.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,y.findAnnotation)(t.annotations,e.id)!==null,F=[],he=()=>(0,O.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,y.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,O.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(l.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}`,f=d.get(m);f?f.count+=1:d.set(m,{geom:u.geom,coord:u.coord,count:1})}const i=[];for(const{geom:u,coord:m,count:f}of d.values())f<2||i.push({kind:"user-input",severity:"warning",code:"DUPLICATE_REGISTERED_TYPE",message:`Multiple render-only overrides register ('${u}', '${m}') (${f} 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:i}}function Ce(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 xe(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||l.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 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 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||!l.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 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 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||!l.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 compiled layer carries the `byKey` index the overlay's `pushHover` resolves against."}))}return d}var ke=e=>(0,O.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:i,onChange:u,onError:m,onWarnings:f})=>{const x=l.useLatestRef(u),j=l.useLatestRef(m),q=l.useLatestRef(f),[{session:p,compileBus:h}]=(0,c.useState)(()=>{const n=(0,y.createCompiler)({plugins:o});return{session:new y.GraphCompilationSession(n),compileBus:fe(n)}}),[g]=(0,c.useState)(()=>Ee(o??[])),S=(0,c.useRef)(null),[k]=(0,c.useState)(je),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 v=ke(n.compiled);v.subscribe(k.notify),T.current=v,k.notify()}return null},[k]),[I,D]=(0,c.useState)(()=>{const n=p.compile({input:e,data:t,customPalettes:r,colorScheme:s});return S.current=n,b(_(n))}),G=(0,c.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,i)]:n.warnings,[d,i]),E=(0,c.useCallback)(n=>{n.length!==0&&(L(n),j.current?.(n))},[j]),R=(0,c.useCallback)(n=>{n.length!==0&&(L(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=p.update({input:e,data:t,customPalettes:r,colorScheme:s});if(!n)return;n.sealedInput&&x.current?.(n.sealedInput);const v=_(n.result);D(b(v)),v&&E(v),R(G(n.result)),v||h.emit({kind:n.inputChanged?"input":"data"})},[e,t,r,s,p,h,_,E,R,b,G,x]);const N=(0,c.useCallback)(n=>{D(v=>v===null?v: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 v of n)w(v);return n.some(v=>!!v.compiled)},[w]),M=(0,c.useCallback)((n,v)=>{C(p.applyCommand(n,v))},[p,C]),re=(0,c.useCallback)(()=>{C(p.seal())},[p,C]),B=(0,c.useCallback)(()=>C(p.undo()),[p,C]),A=(0,c.useCallback)(()=>C(p.redo()),[p,C]),se=(0,c.useMemo)(()=>({stack:p.history,undo:B,redo:A}),[p,B,A]),ne=(0,c.useCallback)(()=>T.current?.getState().compiled??null,[]);return{store:T.current,dispatch:M,seal:re,history:se,subscribe:k.subscribe,getCompiled:ne,compileBus:h,compileErrors:I}},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:i,onWarnings:u,customPalettes:m,colorScheme:f="light",themeOverrides:x=_e,children:j})=>{const[q]=(0,c.useState)(()=>l.createGeomRendererResolver(r.filter(Q))),p=(0,c.useId)(),[h]=(0,c.useState)(()=>(0,y.createAnchorResolver)(r)),[g]=(0,c.useState)(()=>he()),{store:S,dispatch:k,seal:T,history:b,subscribe:_,getCompiled:I,compileBus:D,compileErrors:G}=Ne({input:t,data:e,customPalettes:m,colorScheme:f,plugins:r,resolveRenderer:q,anchorResolver:h,onChange:d,onError:i,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(J(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:p,store:S,selectionStore:g,commands:E,history:b,formattingLocale:s,compileBus:D,colorScheme:f,themeOverrides:x,anchorResolver:h}:null,[p,S,g,E,b,s,D,f,x,h]);return(0,a.jsx)(X,{forcedErrors:G,onError:i,resetKeys:[t,e],children:R?(0,a.jsx)(l.GraphContext.Provider,{value:R,children:(0,a.jsx)(l.GeomRendererResolverProvider,{value:q,children:j})}):null})};function De(e){const t=(0,y.createGraphyBuilder)(e);return{...t,GraphProvider:s=>(0,a.jsx)(Z,{...s,plugins:t.plugins})}}var Ie=({children:e,...t})=>(0,a.jsx)("svg",{viewBox:"0 0 1 1",preserveAspectRatio:"none",width:"100%",height:"100%",pointerEvents:"none",...t,children:e}),we="drqe3u0",He="drqe3u1",Me="drqe3u2",$e="drqe3u3",H="drqe3u4",Pe="drqe3u5",Le="drqe3u6",Ke="drqe3u7",$="drqe3u8",Oe="drqe3u9",Be="drqe3ua";var Ae="drqe3uc",Ye="drqe3ud",Ue="drqe3ue",Fe="drqe3uf";var Ve="drqe3uh",We="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"},ze=({width:e=380,style:t,className:r}={})=>{const{compileBus:s}=l.useGraphContext(),[o]=(0,c.useState)(()=>ve()),[d,i]=(0,c.useState)(!1),[u,m]=(0,c.useState)(y.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 f=(0,Y.useStore)(o,h=>h.lastCompile),x=(0,Y.useStore)(o,h=>h.history),j=s.getCacheStats(),q=f===null&&x.length===0,p=()=>{m(h=>{const g=!h;return(0,y.setCompilerCachingEnabled)(g),g})};return(0,a.jsxs)("div",{className:(0,P.default)(Be,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:Ue,children:q?"production: stats disabled":f?`last: ${f.label} · ${te(f.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:p,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"})]}),!d&&!q&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Xe,{delta:f?.stages,cumulative:j}),(0,a.jsx)(Qe,{entries:x})]})]})},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:$e,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:y.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:Pe,children:[(0,a.jsx)("span",{className:ee[o],"aria-hidden":!0})," ",r]}),(0,a.jsx)("td",{className:o==="ran"?W.ran:W.dim,children:s?.misses??0}),(0,a.jsx)("td",{className:$,children:s?.hits??0}),(0,a.jsx)("td",{className:$,children:t[r].misses}),(0,a.jsx)("td",{className:$,children:t[r].hits})]},r)})})]}),Qe=({entries:e})=>e.length===0?null:(0,a.jsxs)("div",{className:Ye,children:[(0,a.jsx)("div",{className:We,children:"recent compiles"}),e.map(t=>{const r=Ze(t.stages,d=>d.misses>0),s=y.COMPILER_STAGE_KEYS.length,o=r===0?"cached":"ran";return(0,a.jsxs)("div",{className:Le,children:[(0,a.jsx)("span",{className:ee[o],"aria-hidden":!0}),(0,a.jsx)("span",{className:Ke,title:t.label,children:t.label}),(0,a.jsxs)("span",{className:Oe,children:[r,"/",s," ran · ",te(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 y.COMPILER_STAGE_KEYS)t(e[s])&&(r+=1);return r},te=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]),i=(0,c.useSyncExternalStore)(o,d,d);return(0,c.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,c.useEffect)(()=>{const o=st(r);if(!s||!o)return;const d=i=>{if(!nt(i)||i.defaultPrevented||ot(i.target))return;const u=l.resolveHistoryStep(i);if(!u)return;const m=e.current;m&&(u==="undo"?m.undo():m.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=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=X;exports.GraphErrorPanel=K;exports.GraphProvider=Z;exports.GraphRenderer=l.GraphRenderer;exports.HoverProvider=l.HoverProvider;exports.TextMeasurerProvider=l.TextMeasurerProvider;exports.ThemeProvider=l.ThemeProvider;exports.UnitSpaceSvg=Ie;exports.createGraphyKit=De;exports.darkTheme=l.darkTheme;exports.defineGeomRenderer=l.defineGeomRenderer;exports.lightTheme=l.lightTheme;exports.lightenCss=l.lightenCss;exports.pruneSelection=J;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=z.vars;
|
package/dist/index.d.ts
CHANGED
|
@@ -392,10 +392,11 @@ export declare interface GeomRenderContract<G extends GeomName | string = string
|
|
|
392
392
|
* Render-side spatial query for a `'render-hit-test'` layer whose geometry is precomputed into the
|
|
393
393
|
* compiled spec (sankey ribbons, treemap tiles, voronoi cells). A
|
|
394
394
|
* **factory**: given the render input it returns the per-cursor {@link RenderHitTester};
|
|
395
|
-
* the renderer memoizes the factory on `layer.data
|
|
396
|
-
* per-move query allocates nothing. The author writes no hook;
|
|
397
|
-
* behalf. The cursor arrives in panel-local `[0,1]` with a
|
|
398
|
-
* in. Returns the declared identity key of the observation
|
|
395
|
+
* the renderer memoizes the factory on `layer.data` and the panel pixel frame, so the read runs once
|
|
396
|
+
* per data or panel-size change and the per-move query allocates nothing. The author writes no hook;
|
|
397
|
+
* the renderer registers the tester on its behalf. The cursor arrives in panel-local `[0,1]` with a
|
|
398
|
+
* top-left origin — the frame the geom paints in. Returns the declared identity key of the observation
|
|
399
|
+
* under the cursor, or `null` for a miss.
|
|
399
400
|
*/
|
|
400
401
|
hitTest?: (input: GeomRenderInput<G, C>) => RenderHitTester;
|
|
401
402
|
/** Panel-space anchor for a matched observation; required when the def highlights via overlay-anchor. */
|
|
@@ -425,6 +426,12 @@ declare interface GeomRenderInput<G extends GeomName | string = string, C extend
|
|
|
425
426
|
shouldAnimateTransitions: boolean;
|
|
426
427
|
formattingLocale: Locale;
|
|
427
428
|
intro?: LayerIntroPlan | null;
|
|
429
|
+
/**
|
|
430
|
+
* The panel's pixel rect — the data rectangle geoms paint into, already inset from axes and chrome.
|
|
431
|
+
* Same frame hover and highlight receive. Width and height are the paint size; x/y are already
|
|
432
|
+
* applied by the geom-layers SVG, so marks are placed in local `0…width` / `0…height`.
|
|
433
|
+
*/
|
|
434
|
+
panelRect: GraphLayout['panel'];
|
|
428
435
|
}
|
|
429
436
|
|
|
430
437
|
/**
|
|
@@ -624,7 +631,10 @@ export declare const GraphRenderer: (props: GraphRendererProps) => JSX.Element;
|
|
|
624
631
|
export declare interface GraphRendererProps {
|
|
625
632
|
/** Controls how the graph responds to its container size. Defaults to filling the parent container. */
|
|
626
633
|
sizing?: GraphSizing;
|
|
627
|
-
/**
|
|
634
|
+
/**
|
|
635
|
+
* Callback invoked when the graph's container is resized. Fires in every sizing mode. Reports the
|
|
636
|
+
* container, not the panel.
|
|
637
|
+
*/
|
|
628
638
|
onResize?: ResizeObserverOnResize;
|
|
629
639
|
/**
|
|
630
640
|
* Animation settings. A boolean disables/enables animations globally, an object tunes the intro
|
|
@@ -746,12 +756,11 @@ export declare interface HeadlineSlotProps {
|
|
|
746
756
|
|
|
747
757
|
/**
|
|
748
758
|
* The input a geom's {@link GeomRenderContract.renderHighlight} receives: the matched-subset layer plus
|
|
749
|
-
* the
|
|
750
|
-
*
|
|
751
|
-
*
|
|
759
|
+
* the full source layer (context the subset can't see, like a stack's silhouette). A superset of
|
|
760
|
+
* {@link GeomRenderInput}, so a geom that doesn't override `renderHighlight` still paints through the
|
|
761
|
+
* plain `render`.
|
|
752
762
|
*/
|
|
753
763
|
declare interface HighlightRenderInput<G extends GeomName | string = string, C extends CoordKind = CoordKind> extends GeomRenderInput<G, C> {
|
|
754
|
-
panelRect: GraphLayout['panel'];
|
|
755
764
|
/** The full layer `layer` was filtered from — for context the subset can't see, like a stack's silhouette. */
|
|
756
765
|
sourceLayer: CompiledLayerOf<G>;
|
|
757
766
|
}
|
|
@@ -835,7 +844,10 @@ declare type HoverStoreState = HoverSlice & HoverStoreActions;
|
|
|
835
844
|
export declare interface InteractiveOverlayApi {
|
|
836
845
|
/** Feeds the hovered observation's identity key into the unified hover store — the push path. */
|
|
837
846
|
pushHover: GeomHoverPush;
|
|
838
|
-
/**
|
|
847
|
+
/**
|
|
848
|
+
* The panel's on-screen rect in client pixels, so the overlay can place its marks. Distinct from
|
|
849
|
+
* {@link GeomRenderInput.panelRect} (layout pixels).
|
|
850
|
+
*/
|
|
839
851
|
panelRect: ScreenRect;
|
|
840
852
|
}
|
|
841
853
|
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Ct as wt, Ft as te, M as It, Mt as Dt, Nt as $t, O as xt, Pt as ce, St as de, Tt as Ht, X as Mt, Y as Pt, _ as Lt, _t as le, a as Kt, bt as ue, ct as Bt, gt as K, i as Ot, it as At, j as jt, jt as Yt, k as Ft, lt as Ut, mt as Wt, n as Vt, pt as Xt, r as Qt, rt as zt, s as Jt, t as me, tt as Zt, vt as er, wt as tr, xt as rr, yt as A } from "./history-chords-
|
|
1
|
+
import { Ct as wt, Ft as te, M as It, Mt as Dt, Nt as $t, O as xt, Pt as ce, St as de, Tt as Ht, X as Mt, Y as Pt, _ as Lt, _t as le, a as Kt, bt as ue, ct as Bt, gt as K, i as Ot, it as At, j as jt, jt as Yt, k as Ft, lt as Ut, mt as Wt, n as Vt, pt as Xt, r as Qt, rt as zt, s as Jt, t as me, tt as Zt, vt as er, wt as tr, xt as rr, yt as A } from "./history-chords-Ce-I6T2V.js";
|
|
2
2
|
import { f as sr, t as ge } from "./dev.utils-HBVa4Fj9.js";
|
|
3
3
|
import { COMPILER_STAGE_KEYS as j, Geom as he, GraphCompilationSession as pe, areEditTargetsEqual as fe, buildDiagnostic as W, createAnchorResolver as ve, createCompiler as ye, createGraphyBuilder as be, findAnnotation as Se, isCompilerCachingEnabled as Ee, resolveDefinition as Te, setCompilerCachingEnabled as Ce } from "@graphysdk/viz-engine";
|
|
4
4
|
import { Component as Ne, useCallback as f, useEffect as $, useId as Re, useImperativeHandle as qe, useMemo as P, useRef as V, useState as C, useSyncExternalStore as Ge } from "react";
|
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.1788548769329",
|
|
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.1788548769329"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"@tiptap/core": "^3.0.0",
|