playermap_graph 0.1.9 → 0.2.0
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/index.es.js +4 -4
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -3827,8 +3827,8 @@ const hP = (r, e, n) => r.document ? r : {
|
|
|
3827
3827
|
displayName: "Intuition Testnet"
|
|
3828
3828
|
},
|
|
3829
3829
|
base: {
|
|
3830
|
-
url: "https://
|
|
3831
|
-
displayName: "Intuition
|
|
3830
|
+
url: "https://mainnet.intuition.sh/v1/graphql",
|
|
3831
|
+
displayName: "Intuition Mainnet"
|
|
3832
3832
|
}
|
|
3833
3833
|
}, bc = (r) => new iv(pM[r].url), rv = (r) => ({
|
|
3834
3834
|
id: r.term_id,
|
|
@@ -4099,8 +4099,8 @@ const hP = (r, e, n) => r.document ? r : {
|
|
|
4099
4099
|
module: ub
|
|
4100
4100
|
},
|
|
4101
4101
|
base: {
|
|
4102
|
-
url: "https://
|
|
4103
|
-
displayName: "
|
|
4102
|
+
url: "https://mainnet.intuition.sh/v1/graphql",
|
|
4103
|
+
displayName: "Intuition Mainnet",
|
|
4104
4104
|
module: ub
|
|
4105
4105
|
}
|
|
4106
4106
|
}, LJ = (r) => {
|
package/dist/index.umd.js
CHANGED
|
@@ -169,7 +169,7 @@ ${String(r)}`)}catch(e){return e}},gb=r=>{if(typeof r!="object"||r===null)throw
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
`,s={_and:[]};r.subject&&s._and.push({subject:{label:{_ilike:`%${r.subject}%`}}}),r.predicate&&s._and.push({predicate:{label:{_ilike:`%${r.predicate}%`}}}),r.object&&s._and.push({object:{label:{_ilike:`%${r.object}%`}}});const o={where:s._and.length>0?s:{}};try{return(await n.request(i,o)).triples}catch(a){throw console.error("Error executing search query:",a),a}}},Symbol.toStringTag,{value:"Module"})),bb={baseSepolia:{url:"https://testnet.intuition.sh/v1/graphql",displayName:"Intuition Testnet"},base:{url:"https://
|
|
172
|
+
`,s={_and:[]};r.subject&&s._and.push({subject:{label:{_ilike:`%${r.subject}%`}}}),r.predicate&&s._and.push({predicate:{label:{_ilike:`%${r.predicate}%`}}}),r.object&&s._and.push({object:{label:{_ilike:`%${r.object}%`}}});const o={where:s._and.length>0?s:{}};try{return(await n.request(i,o)).triples}catch(a){throw console.error("Error executing search query:",a),a}}},Symbol.toStringTag,{value:"Module"})),bb={baseSepolia:{url:"https://testnet.intuition.sh/v1/graphql",displayName:"Intuition Testnet"},base:{url:"https://mainnet.intuition.sh/v1/graphql",displayName:"Intuition Mainnet"}},Ga=r=>new Cm(bb[r].url),Rm=r=>({id:r.term_id,subject:{id:r.subject.term_id,label:r.subject.label,type:r.subject.type,image:r.subject.image},predicate:{id:r.predicate.term_id,label:r.predicate.label,type:r.predicate.type},object:{id:r.object.term_id,label:r.object.label,type:r.object.type,image:r.object.image}}),lP=async(r,e="base")=>{const n=Ga(e);let i;i=Rr`
|
|
173
173
|
query GetAtom($atomId: String!) {
|
|
174
174
|
atoms(where: { term_id: { _eq: $atomId } }) {
|
|
175
175
|
term_id
|
|
@@ -309,7 +309,7 @@ ${String(r)}`)}catch(e){return e}},gb=r=>{if(typeof r!="object"||r===null)throw
|
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
|
-
`,a={batchSize:n,objectId:String(r)};try{const c=(await i.request(s,a)).triples,h=[...new Set(c.map(m=>m.subject.term_id))].map(m=>i.request(o,{subjectId:m})),f=(await Promise.all(h)).flatMap(m=>m.triples);return[...c,...f].map(Rm)}catch(l){return console.error("Error fetching agent-specific triples:",l),Sb(e).then(c=>c.filter(u=>u.subject.term_id===r||u.object.term_id===r||u.predicate.term_id===r)).catch(c=>{throw console.error("Fallback fetch also failed:",c),l})}},wb=Object.freeze(Object.defineProperty({__proto__:null,ENDPOINTS:bb,createClient:Ga,fetchAtomDetails:lP,fetchTriples:Sb,fetchTriplesForAgent:Tb,fetchTriplesForNode:cP,searchTriples:uP},Symbol.toStringTag,{value:"Module"})),Va={railsMockApi:{url:"https://api-i7n.thp-lab.org/api/v1/graph",displayName:"[OffChain] Playground API",module:aP},baseSepolia:{url:"https://testnet.intuition.sh/v1/graphql",displayName:"Base Testnet",module:wb},base:{url:"https://
|
|
312
|
+
`,a={batchSize:n,objectId:String(r)};try{const c=(await i.request(s,a)).triples,h=[...new Set(c.map(m=>m.subject.term_id))].map(m=>i.request(o,{subjectId:m})),f=(await Promise.all(h)).flatMap(m=>m.triples);return[...c,...f].map(Rm)}catch(l){return console.error("Error fetching agent-specific triples:",l),Sb(e).then(c=>c.filter(u=>u.subject.term_id===r||u.object.term_id===r||u.predicate.term_id===r)).catch(c=>{throw console.error("Fallback fetch also failed:",c),l})}},wb=Object.freeze(Object.defineProperty({__proto__:null,ENDPOINTS:bb,createClient:Ga,fetchAtomDetails:lP,fetchTriples:Sb,fetchTriplesForAgent:Tb,fetchTriplesForNode:cP,searchTriples:uP},Symbol.toStringTag,{value:"Module"})),Va={railsMockApi:{url:"https://api-i7n.thp-lab.org/api/v1/graph",displayName:"[OffChain] Playground API",module:aP},baseSepolia:{url:"https://testnet.intuition.sh/v1/graphql",displayName:"Base Testnet",module:wb},base:{url:"https://mainnet.intuition.sh/v1/graphql",displayName:"Intuition Mainnet",module:wb}},hP=r=>{if(!Va[r])throw new Error(`Endpoint '${r}' is not defined.`);return new Cm(Va[r].url)},zh=r=>{if(!Va[r]||!Va[r].module)throw new Error(`No module defined for endpoint '${r}'.`);return Va[r].module},Gh=async(r="base")=>{const e=zh(r);try{return e.fetchTriples(r)}catch(n){throw console.error(`Error fetching triples for endpoint ${r}:`,n),n}},Mb=async(r,e="base")=>{const n=zh(e);try{return n.fetchTriplesForNode(r,e)}catch(i){throw console.error(`Error fetching triples for node ${r} with endpoint ${e}:`,i),i}},Eb=async(r,e="base")=>{const n=zh(e);try{return n.fetchAtomDetails(r,e)}catch(i){throw console.error(`Error fetching atom details for ${r} with endpoint ${e}:`,i),i}},$o=async(r,e="base")=>{const n=zh(e);try{return n.searchTriples(r,e)}catch(i){throw console.error(`Error searching triples with endpoint ${e}:`,i),i}},Ab=async(r,e="baseSepolia",n=1e3)=>Tb(r,e,n),Vh=({triple:r,endpoint:e,onClose:n})=>{var m;const[i,s]=_e.useState(null),[o,a]=_e.useState(null),[l,c]=_e.useState(!1),[u,h]=_e.useState(null);_e.useEffect(()=>{if(!r)return;c(!0),h(null),a(null),(async()=>{try{const g=(await Gh(e)).filter(x=>{var b,v,T;return x.id===r.id||((b=x.subject)==null?void 0:b.id)===r.id||((v=x.predicate)==null?void 0:v.id)===r.id||((T=x.object)==null?void 0:T.id)===r.id});if(s(g),r.id){const x=await Eb(r.id,e);a(x)}}catch(y){console.error("Error fetching sidebar data:",y),h("Failed to fetch data")}finally{c(!1)}})()},[r,e]);const d=_=>`${(_/1e18).toFixed(4)} ETH`;if(!r)return null;const f=(_,y=4,g=4)=>!_||_.length<=y+g?_:`${_.slice(0,y)}...${_.slice(-g)}`,p=async _=>{try{await navigator.clipboard.writeText(_)}catch(y){console.error("Error copying ID:",y)}};return J.jsxs("div",{style:{background:"#18181b",borderRadius:"10px",border:"2px solid #ffd32a",padding:"24px",boxShadow:"0 8px 30px rgba(0, 0, 0, 0.5)",color:"#fff",maxWidth:"400px",width:"100%"},children:[J.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"24px"},children:[J.jsx("h2",{style:{margin:0,fontSize:"24px",color:"#ffd32a",fontWeight:"bold",letterSpacing:"0.5px"},children:r.label||"No Label"}),J.jsx("button",{onClick:n,style:{background:"none",border:"none",color:"#ffd32a",fontSize:"24px",cursor:"pointer",padding:"4px",lineHeight:1},children:"×"})]}),o&&o.image&&J.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"24px 0"},children:J.jsx("img",{src:o.image,alt:o.label||"Node image",style:{width:"120px",height:"120px",borderRadius:"50%",objectFit:"cover",border:"3px solid #ffd32a",boxShadow:"0 4px 12px rgba(0,0,0,0.2)"}})}),l&&J.jsx("div",{style:{textAlign:"center",padding:"20px",color:"#ffd32a"},children:"Loading..."}),u&&J.jsx("div",{style:{color:"#ff4444",padding:"12px",background:"rgba(255,68,68,0.1)",borderRadius:"8px",marginBottom:"16px"},children:u}),o&&J.jsxs("div",{style:{background:"#232326",borderRadius:"8px",padding:"16px",marginBottom:"24px"},children:[J.jsx("h4",{style:{color:"#ffd32a",margin:"0 0 16px 0",fontSize:"18px",fontWeight:"bold"},children:"Atom Info"}),J.jsxs("div",{style:{display:"grid",gap:"12px"},children:[J.jsxs("div",{children:[J.jsx("span",{style:{color:"#ffd32a",fontWeight:"bold"},children:"ID:"})," ",J.jsx("span",{style:{cursor:"pointer",textDecoration:"underline",color:"#ffd32a"},onClick:()=>p(o.term_id),title:`Cliquer pour copier: ${o.term_id}`,children:f(o.term_id)})]}),J.jsxs("div",{children:[J.jsx("span",{style:{color:"#ffd32a",fontWeight:"bold"},children:"Label:"})," ",o.label]}),J.jsxs("div",{children:[J.jsx("span",{style:{color:"#ffd32a",fontWeight:"bold"},children:"Type:"})," ",o.type]}),J.jsxs("div",{children:[J.jsx("span",{style:{color:"#ffd32a",fontWeight:"bold"},children:"Creator:"})," ",J.jsx("span",{style:{cursor:"pointer",textDecoration:"underline",color:"#ffd32a"},onClick:()=>p(o.creator_id),title:`Cliquer pour copier: ${o.creator_id}`,children:f(o.creator_id)})]}),J.jsxs("div",{children:[J.jsx("span",{style:{color:"#ffd32a",fontWeight:"bold"},children:"Vault Shares:"})," ",d(((m=o.vault)==null?void 0:m.total_shares)||0)]})]})]}),i&&i.length>0&&J.jsxs("div",{style:{background:"#232326",borderRadius:"8px",padding:"16px"},children:[J.jsx("h4",{style:{color:"#ffd32a",margin:"0 0 16px 0",fontSize:"18px",fontWeight:"bold"},children:"Related Data"}),J.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:i.map(_=>{var y,g,x;return J.jsxs("div",{style:{padding:"12px",background:"#18181b",borderRadius:"6px",border:"1px solid #ffd32a33"},children:[J.jsxs("div",{children:[J.jsx("span",{style:{color:"#ffd32a",fontWeight:"bold"},children:"Subject:"})," ",(y=_.subject)==null?void 0:y.label]}),J.jsxs("div",{children:[J.jsx("span",{style:{color:"#ffd32a",fontWeight:"bold"},children:"Predicate:"})," ",(g=_.predicate)==null?void 0:g.label]}),J.jsxs("div",{children:[J.jsx("span",{style:{color:"#ffd32a",fontWeight:"bold"},children:"Object:"})," ",(x=_.object)==null?void 0:x.label]})]},_.id)})})]}),!l&&!(i!=null&&i.length)&&J.jsx("div",{style:{textAlign:"center",padding:"20px",color:"#888",background:"#232326",borderRadius:"8px"},children:"No additional related data found."})]})},Cb=({graphData:r,onNodeClick:e,onBack:n,onForward:i,selectedTriple:s,endpoint:o,disableNodeDetailsSidebar:a=!1})=>{const l=_e.useRef(),c=_e.useRef(),[u,h]=_e.useState({width:100,height:100});return _e.useEffect(()=>{const d=()=>{l.current&&h({width:l.current.clientWidth,height:l.current.clientHeight})};return d(),window.addEventListener("resize",d),()=>window.removeEventListener("resize",d)},[]),_e.useEffect(()=>{if(c.current&&u.width>0&&u.height>0){const d=ko()(c.current);d.width(u.width).height(u.height).graphData(r).nodeLabel(f=>f.label||f.id).nodeAutoColorBy("group"),e&&d.onNodeClick(f=>{e(f)})}},[r,e,u]),J.jsxs("div",{ref:l,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden"},children:[J.jsx("div",{ref:c,style:{width:"100%",height:"100%"}}),J.jsxs("div",{style:{position:"absolute",bottom:20,left:20,zIndex:100},children:[J.jsx("button",{onClick:n,style:{background:"#ffd32a",color:"#18181b",border:"none",borderRadius:8,padding:"10px 20px",marginRight:10,cursor:"pointer",fontWeight:"bold"},children:"Back"}),J.jsx("button",{onClick:i,style:{background:"#ffd32a",color:"#18181b",border:"none",borderRadius:8,padding:"10px 20px",cursor:"pointer",fontWeight:"bold"},children:"Forward"})]}),s&&!a&&J.jsx("div",{style:{position:"absolute",top:80,right:30,width:350,zIndex:9999,maxHeight:"80vh",background:"#18181b",borderRadius:"10px",border:"3px solid #ffd32a",boxShadow:"0 8px 30px rgba(0, 0, 0, 0.5)",overflowY:"auto"},children:J.jsx(Vh,{triple:s,endpoint:o,onClose:()=>e(null)})})]})},Rb=()=>{const[r,e]=_e.useState([]),n=200;_e.useEffect(()=>{let s;const o=()=>{const a=Date.now()/1e3,l=[];for(let c=0;c<3;c++){const u=a*.8+c*2*Math.PI/3;l.push({x:Math.cos(u)*150+200,y:Math.sin(u)*150+200,color:"#00fff2"})}for(let c=0;c<3;c++){const u=-a*1.2+c*2*Math.PI/3;l.push({x:Math.cos(u)*100+200,y:Math.sin(u)*100+200,color:"#ff00ff"})}for(let c=0;c<3;c++){const u=a*1.5+c*2*Math.PI/3;l.push({x:Math.cos(u)*50+200,y:Math.sin(u)*50+200,color:"#ffff00"})}e(l),s=requestAnimationFrame(o)};return o(),()=>cancelAnimationFrame(s)},[]);const i=r.flatMap((s,o)=>r.slice(o+1).map((a,l)=>{const c=a.x-s.x,u=a.y-s.y,h=Math.sqrt(c*c+u*u);if(h<n){const d=1-h/n;return{x1:s.x,y1:s.y,x2:a.x,y2:a.y,opacity:d*.8,gradient:`link-gradient-${o}-${l}`,color1:s.color,color2:a.color}}return null}).filter(Boolean));return J.jsxs("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",background:"rgba(0, 0, 0, 0.9)",zIndex:1e3,overflow:"hidden"},children:[J.jsxs("div",{style:{position:"relative",width:"400px",height:"400px",display:"flex",flexDirection:"column",alignItems:"center"},children:[J.jsxs("svg",{width:"400",height:"400",children:[J.jsx("defs",{children:i.map(s=>J.jsxs("linearGradient",{id:s.gradient,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[J.jsx("stop",{offset:"0%",stopColor:s.color1,stopOpacity:s.opacity}),J.jsx("stop",{offset:"100%",stopColor:s.color2,stopOpacity:s.opacity})]},s.gradient))}),i.map((s,o)=>J.jsx("line",{x1:s.x1,y1:s.y1,x2:s.x2,y2:s.y2,stroke:`url(#${s.gradient})`,strokeWidth:"3",style:{filter:"brightness(1.5) blur(1px)"}},o))]}),J.jsx("div",{style:{color:"#00fff2",fontSize:"40px",fontFamily:"sans-serif",letterSpacing:"-2px",textShadow:`
|
|
313
313
|
0 0 5px #00fff2,
|
|
314
314
|
0 0 10px #00fff2,
|
|
315
315
|
0 0 20px #00fff2,
|