@cosmograph/cosmograph
Advanced tools
Comparing version
@@ -1,2 +0,2 @@ | ||
import{Graph as i}from"@cosmograph/cosmos";import{MosaicDBCoordinator as t}from"../duckdb/mosaic-coordinator.js";import{CosmographConfigManager as e}from"./config/manager.js";import{defaultBackgroundColor as s}from"./config/defaults.js";import{Labels as o}from"./components/labels/index.js";import"@uwdata/mosaic-core";import"@uwdata/mosaic-sql";import{PointSelectionClient as n}from"./selection-clients/point-selection-client.js";import{CosmographCrossfilter as a}from"./managers/crossfilter.js";import{CosmographDataUploader as r}from"./managers/data-uploader.js";import{CosmographEventManager as l}from"./managers/event-manager.js";import{attribution as d}from"./components/attribution.js";import{RectangularSelect as c}from"./components/area-select/rectangular/index.js";import{convertArrowToObject as h}from"../utils/utils.js";import{cosmographLog as m}from"../utils/log.js";import{Tables as u}from"../enum.js";import{havePointsLayout as g,getPointIndicesByIds as _,getPointIdsByIndices as v,getPointsByIndices as p,getPointIndicesByExactValues as f,getPointIndicesByNumericValue as b}from"./graph-utils/points.js";import{getPointIndicesByLinksExactValues as C,getPointIndicesByLinksNumericValue as y,getLinksByPointIds as P,getLinksByPointIndices as E}from"./graph-utils/links.js";import{summarize as w}from"./graph-utils/misc.js";import{registerInternalApi as S}from"./internal.js";import T from"./style.module.css.js";class k{constructor(i,t,s){var d;this._eventTarget=new EventTarget,this._dbReadinessPromise=null,this._stats={pointsCount:0,linksCount:0,pointsSummary:void 0,linksSummary:void 0},this._initializeLabels=()=>{const i=this._cosmosElement.querySelector("canvas");i&&(this._labels=new o(this._internalApi,i))},this._initializeClients=()=>{var i;this._selectionClient=new n(this._internalApi),null===(i=this._dbCoordinator)||void 0===i||i.connect(this._selectionClient)},this._dropLocalTables=async i=>{var t,e;this._dbCoordinator&&(i||await(null===(t=this._dbCoordinator.internalDB)||void 0===t?void 0:t.dropTable(u.Points)),await(null===(e=this._dbCoordinator.internalDB)||void 0===e?void 0:e.dropTable(u.Links)))},this._containerElement=i,this._internalApi=this._initializeInternalApi(this),S(this,this._internalApi),m("Initialization..."),this._initializeDB(s),this._eventManager=new l(this._internalApi),this._configManager=new e(this._internalApi),this._dataUploader=new r(this._internalApi),this._crossfilter=new a(this._internalApi),this._rectangularSelection=new c(this._internalApi),this._disableSimulation=null!==(d=t.disableSimulation)&&void 0!==d?d:null,this._initializeHTMLElements(),this.setConfig(t)}_initializeInternalApi(i){return{get public(){return i},get labels(){return i._labels},get cosmos(){return i._cosmos},get eventManager(){return i._eventManager},get configManager(){return i._configManager},get dataUploader(){return i._dataUploader},get rectangularSelection(){return i._rectangularSelection},get crossfilter(){return i._crossfilter},get selectionClient(){return i._selectionClient},get dbCoordinator(){return i._dbCoordinator},get containerElement(){return i._containerElement},get cosmosElement(){return i._cosmosElement},dropLocalTables:async t=>await i._dropLocalTables(t),updateMessage:t=>i._updateMessage(t),initializeLabels:()=>i._initializeLabels(),initializeCosmos:()=>i._initializeCosmos(),updateStats:async()=>i._updateStats(),dbReady:async()=>i._dbReady(),addEventListener:(t,e)=>{i._eventTarget.addEventListener(t,e,{passive:!0})},removeEventListener:(t,e)=>{i._eventTarget.removeEventListener(t,e,{passive:!0})},dispatchEvent:t=>i._eventTarget.dispatchEvent(t)}}_initializeDB(i){this._dbReadinessPromise=t.create(i).then((t=>{this._dbCoordinator=t,t?(this._initializeClients(),this._messageDivElement.innerText="👩🏻🚀 Cosmograph is ready, load your data!"):this._messageDivElement.innerText=i?"🚨 Couldn't create coordinator for specified DuckDB connection. Please check your external DuckDB instance configuration and try to initialize Cosmograph again.":"🚨 Failed to fetch DuckDB-Wasm bundles. Please try to initialize Cosmograph again."}))}_initializeHTMLElements(){var i,t;this._containerElement.classList.add(T.cosmograph),null===(i=this._containerElement)||void 0===i||i.style.setProperty("--cosmograph-text-color","#ffffff"),this._cosmosElement=document.createElement("div"),this._cosmosElement.style.width="100%",this._cosmosElement.style.height="100%",null===(t=this._cosmosElement)||void 0===t||t.style.setProperty("backgroundColor",s),this._containerElement.appendChild(this._cosmosElement),this._addAttribution(),this._addMessageElement()}_addAttribution(){var i;this._attributionDivElement=document.createElement("div"),this._attributionDivElement.classList.add(T.attribution),this._attributionDivElement.onclick=()=>{var i;return null===(i=window.open("https://cosmograph.app/","_blank"))||void 0===i?void 0:i.focus()};const t=(new DOMParser).parseFromString(d,"image/svg+xml").firstChild;null===(i=this._attributionDivElement)||void 0===i||i.appendChild(t),this._containerElement.appendChild(this._attributionDivElement)}_addMessageElement(){this._messageDivElement=document.createElement("div"),this._messageDivElement.classList.add(T.message),this._messageDivElement.innerText="🚀 Initializing Cosmograph...",this._containerElement.appendChild(this._messageDivElement)}async _initializeCosmos(){const{config:t}=this;this._cosmos&&this._cosmos.destroy();const e=await g(this._dbCoordinator,this.pointsTableName,t);this._disableSimulation=!!t.disableSimulation||!1!==t.disableSimulation&&(!t.links||e),this._configManager.cosmosConfig.disableSimulation=this._disableSimulation,this._cosmos=new i(this._cosmosElement,this._configManager.cosmosConfig),this._internalApi.dispatchEvent(new CustomEvent("cosmosInitialized"))}_updateMessage(i){this._messageDivElement&&(null===i?this._messageDivElement.style.display="none":(this._messageDivElement.style.display="block",this._messageDivElement.innerText=i))}async _updateStats(){var i,t,e,s,o,n;this._stats={pointsCount:null!==(t=null===(i=this._cosmos)||void 0===i?void 0:i.graph.pointsNumber)&&void 0!==t?t:0,linksCount:null!==(s=null===(e=this._cosmos)||void 0===e?void 0:e.graph.linksNumber)&&void 0!==s?s:0,pointsSummary:await w(this._dbCoordinator,this.pointsTableName),linksSummary:(null===(n=null===(o=this._cosmos)||void 0===o?void 0:o.graph)||void 0===n?void 0:n.linksNumber)?await w(this._dbCoordinator,this.linksTableName):void 0}}async _dbReady(){if(this._dbReadinessPromise)return await this._dbReadinessPromise}async dataUploaded(){return await this._configManager.dataReady()}get config(){return this._configManager.config}get stats(){return this._stats}get crossfilter(){return this._crossfilter.filtered}get progress(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.progress}get isSimulationRunning(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.isSimulationRunning}get pointDegrees(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.graph.degree}get maxPointSize(){var i,t;return null!==(t=null===(i=this._cosmos)||void 0===i?void 0:i.maxPointSize)&&void 0!==t?t:0}get activePointColorStrategy(){return this._configManager.activePointColorStrategy}get activePointSizeStrategy(){return this._configManager.activePointSizeStrategy}get focusedPointIndex(){var i;return null!==(i=this.config.focusedPointIndex)&&void 0!==i?i:this._focusedPointIndex}get rescaleXFn(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.getScaleX()}get rescaleYFn(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.getScaleY()}get linksTableName(){var i;return(null===(i=this._dbCoordinator)||void 0===i?void 0:i.internalDB)||"string"!=typeof this.config.links?u.Links:this.config.links}get pointsTableName(){var i;return(null===(i=this._dbCoordinator)||void 0===i?void 0:i.internalDB)||"string"!=typeof this.config.points?u.Points:this.config.points}async getActivePointColorFn(){return await this._configManager.configUpdated(),this._configManager.activePointColorFn}async getActivePointSizeFn(){return await this._configManager.configUpdated(),this._configManager.activePointSizeFn}async getActiveLinkColorFn(){return await this._configManager.configUpdated(),this._configManager.activeLinkColorFn}async getActiveLinkWidthFn(){return await this._configManager.configUpdated(),this._configManager.activeLinkWidthFn}setConfig(i){this._configManager.setConfig(i)}captureScreenshot(i="cosmograph-screenshot.png"){var t;const e=null===(t=this._cosmosElement)||void 0===t?void 0:t.querySelector("canvas");if(!e)return;const s=document.createElement("a");s.download=i,s.href=e.toDataURL("image/png"),s.click()}focusPoint(i){var t;null===(t=this._cosmos)||void 0===t||t.setFocusedPointByIndex(i)}getPointPositions(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.getPointPositions()}getClusterPositions(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.getClusterPositions()}activateRectSelection(){this._rectangularSelection.enable()}deactivateRectSelection(){this._rectangularSelection.disable()}getSelectedPointIndices(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.getSelectedIndices()}selectPointsInRect(i){if(!this._cosmos||!i)return;const t=this._cosmos.getPointsInRange(i);this.selectPoints(Array.from(t))}selectPoints(i){var t,e;i&&i.length?null===(t=this._selectionClient)||void 0===t||t.publish(i):null===(e=this._selectionClient)||void 0===e||e.publish(void 0)}selectPoint(i,t=!1){var e,s;if(this._cosmos)if(void 0!==i){let s=[i];t&&(s=s.concat(this._cosmos.getAdjacentIndices(i))),null===(e=this._selectionClient)||void 0===e||e.publish(s)}else null===(s=this._selectionClient)||void 0===s||s.publish(void 0)}unselectPoints(){var i;this._cosmos&&(null===(i=this._selectionClient)||void 0===i||i.publish(void 0))}setFocusedPointByIndex(i){var t,e;this._cosmos&&!this.config.focusedPointIndex&&(this._focusedPointIndex=i,null===(t=this._cosmos)||void 0===t||t.setFocusedPointByIndex(i),null===(e=this._labels)||void 0===e||e.render())}start(i=1){var t;!0!==this._disableSimulation&&(null===(t=this._cosmos)||void 0===t||t.start(i))}pause(){var i;!0!==this._disableSimulation&&(null===(i=this._cosmos)||void 0===i||i.pause())}restart(){var i;!0!==this._disableSimulation&&(null===(i=this._cosmos)||void 0===i||i.restart())}step(){var i;null===(i=this._cosmos)||void 0===i||i.step()}setZoomLevel(i,t=0){var e;null===(e=this._cosmos)||void 0===e||e.setZoomLevel(i,t)}getZoomLevel(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.getZoomLevel()}zoomToPoint(i,t,e,s){var o;null===(o=this._cosmos)||void 0===o||o.zoomToPointByIndex(i,t,e,s)}fitView(i=this.config.fitViewDuration,t=this.config.fitViewPadding){var e;null===(e=this._cosmos)||void 0===e||e.fitView(i,t)}fitViewByIndices(i,t=this.config.fitViewDuration,e=this.config.fitViewPadding){var s;null===(s=this._cosmos)||void 0===s||s.fitViewByPointIndices(i,t,e)}fitViewByCoordinates(i,t=this.config.fitViewDuration,e=this.config.fitViewPadding){var s;null===(s=this._cosmos)||void 0===s||s.fitViewByPointPositions(i,t,e)}getConnectedPointIndices(i){var t;return null===(t=this._cosmos)||void 0===t?void 0:t.getAdjacentIndices(i)}spaceToScreenPosition(i){var t;return null===(t=this._cosmos)||void 0===t?void 0:t.spaceToScreenPosition(i)}screenToSpacePosition(i){var t;return null===(t=this._cosmos)||void 0===t?void 0:t.spaceToScreenPosition(i)}spaceToScreenRadius(i){var t;return null===(t=this._cosmos)||void 0===t?void 0:t.spaceToScreenRadius(i)}getPointRadiusByIndex(i){var t;return null===(t=this._cosmos)||void 0===t?void 0:t.getPointRadiusByIndex(i)}getSampledPointPositionsMap(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.getSampledPointPositionsMap()}async getPointIndicesByIds(i){if(this._dbCoordinator&&this.stats.pointsCount&&i.length)return await _(this._dbCoordinator,this.pointsTableName,this.config,i)}async getPointIdsByIndices(i){if(this._dbCoordinator&&this.stats.pointsCount&&i.length)return await v(this._dbCoordinator,this.pointsTableName,this.config,i)}async getPointsByIndices(i){if(this._dbCoordinator&&this.stats.pointsCount&&i.length)return await p(this._dbCoordinator,this.pointsTableName,this.config.pointIndexBy,i)}async getPointIndicesByExactValues(i,t){if(this._dbCoordinator&&this.stats.pointsCount)return t.length?await f(this._dbCoordinator,this.pointsTableName,this.config,i,t):[]}async getPointIndicesByNumericValue(i,t,e){if(this._dbCoordinator&&this.stats.pointsCount)return t?await b(this._dbCoordinator,this.pointsTableName,this.config,i,t,e):[]}async getPointIndicesByLinksExactValues(i,t){if(this._dbCoordinator&&this.stats.linksCount)return t.length?await C(this._dbCoordinator,this.linksTableName,this.config,i,t):[]}async getPointIndicesByLinksNumericValue(i,t,e){if(this._dbCoordinator&&this.stats.linksCount)return t?await y(this._dbCoordinator,this.linksTableName,this.config,i,t,e):[]}async getLinksByPointIds(i){if(this._dbCoordinator&&this.stats.linksCount&&i.length)return await P(this._dbCoordinator,this.pointsTableName,this.config,i)}async getLinksByPointIndices(i){if(this._dbCoordinator&&this.stats.linksCount&&i.length)return await E(this._dbCoordinator,this.pointsTableName,this.config,i)}convertCosmographDataToObject(i){return h(i)}flattenPositions(i){var t;return null===(t=this._cosmos)||void 0===t?void 0:t.flatten(i)}pair(i){var t;return null===(t=this._cosmos)||void 0===t?void 0:t.pair(i)}async reset(i=!0){var t,e;i&&(this._configManager.resetCosmographConfig(),this._messageDivElement.innerText="👩🏻🚀 Cosmograph is ready, load your data!",this._messageDivElement.style.display="block"),null===(t=this._labels)||void 0===t||t.clear(),this._configManager.clearCosmosBuffers(),await this._dropLocalTables(),null===(e=this._dbCoordinator)||void 0===e||e.clearCache(),this._stats={pointsCount:0,linksCount:0,pointsSummary:void 0,linksSummary:void 0},this._internalApi.dispatchEvent(new CustomEvent("dataUploaded"))}async destroy(){var i,t,e;null===(i=this._cosmos)||void 0===i||i.destroy(),await this._dropLocalTables(),await(null===(t=this._dbCoordinator)||void 0===t?void 0:t.destroy()),this._containerElement.innerHTML="",null===(e=this._labels)||void 0===e||e.destroy()}}export{k as Cosmograph}; | ||
import{Graph as i}from"@cosmograph/cosmos";import{MosaicDBCoordinator as t}from"../duckdb/mosaic-coordinator.js";import{CosmographConfigManager as e}from"./config/manager.js";import{defaultBackgroundColor as s}from"./config/defaults.js";import{Labels as o}from"./components/labels/index.js";import"@uwdata/mosaic-core";import"@uwdata/mosaic-sql";import{PointSelectionClient as n}from"./selection-clients/point-selection-client.js";import{CosmographCrossfilter as a}from"./managers/crossfilter.js";import{CosmographDataUploader as r}from"./managers/data-uploader.js";import{CosmographEventManager as l}from"./managers/event-manager.js";import{attribution as d}from"./components/attribution.js";import{RectangularSelect as c}from"./components/area-select/rectangular/index.js";import{convertArrowToObject as h}from"../utils/utils.js";import{cosmographLog as m}from"../utils/log.js";import{Tables as u}from"../enum.js";import{havePointsLayout as g,getPointIndicesByIds as _,getPointIdsByIndices as v,getPointsByIndices as p,getPointIndicesByExactValues as f,getPointIndicesByNumericValue as b}from"./graph-utils/points.js";import{getPointIndicesByLinksExactValues as C,getPointIndicesByLinksNumericValue as y,getLinksByPointIds as P,getLinksByPointIndices as E}from"./graph-utils/links.js";import{summarize as w}from"./graph-utils/misc.js";import{registerInternalApi as S}from"./internal.js";import T from"./style.module.css.js";class k{constructor(i,t,s){var d;this._eventTarget=new EventTarget,this._dbReadinessPromise=null,this._stats={pointsCount:0,linksCount:0,pointsSummary:void 0,linksSummary:void 0},this._initializeLabels=()=>{const i=this._cosmosElement.querySelector("canvas");i&&(this._labels=new o(this._internalApi,i))},this._initializeClients=()=>{var i;this._selectionClient=new n(this._internalApi),null===(i=this._dbCoordinator)||void 0===i||i.connect(this._selectionClient)},this._dropLocalTables=async i=>{var t,e;this._dbCoordinator&&(i||await(null===(t=this._dbCoordinator.internalDB)||void 0===t?void 0:t.dropTable(u.Points)),await(null===(e=this._dbCoordinator.internalDB)||void 0===e?void 0:e.dropTable(u.Links)))},this._containerElement=i,this._internalApi=this._initializeInternalApi(this),S(this,this._internalApi),m("Initialization..."),this._initializeDB(s),this._eventManager=new l(this._internalApi),this._configManager=new e(this._internalApi),this._dataUploader=new r(this._internalApi),this._crossfilter=new a(this._internalApi),this._rectangularSelection=new c(this._internalApi),this._disableSimulation=null!==(d=t.disableSimulation)&&void 0!==d?d:null,this._initializeHTMLElements(),this.setConfig(t)}_initializeInternalApi(i){return{get public(){return i},get labels(){return i._labels},get cosmos(){return i._cosmos},get eventManager(){return i._eventManager},get configManager(){return i._configManager},get dataUploader(){return i._dataUploader},get rectangularSelection(){return i._rectangularSelection},get crossfilter(){return i._crossfilter},get selectionClient(){return i._selectionClient},get dbCoordinator(){return i._dbCoordinator},get containerElement(){return i._containerElement},get cosmosElement(){return i._cosmosElement},get config(){return i._configManager.config},dropLocalTables:async t=>await i._dropLocalTables(t),updateMessage:t=>i._updateMessage(t),initializeLabels:()=>i._initializeLabels(),initializeCosmos:()=>i._initializeCosmos(),updateStats:async()=>i._updateStats(),dbReady:async()=>i._dbReady(),addEventListener:(t,e)=>{i._eventTarget.addEventListener(t,e,{passive:!0})},removeEventListener:(t,e)=>{i._eventTarget.removeEventListener(t,e,{passive:!0})},dispatchEvent:t=>i._eventTarget.dispatchEvent(t)}}_initializeDB(i){this._dbReadinessPromise=t.create(i).then((t=>{this._dbCoordinator=t,t?(this._initializeClients(),this._messageDivElement.innerText="👩🏻🚀 Cosmograph is ready, load your data!"):this._messageDivElement.innerText=i?"🚨 Couldn't create coordinator for specified DuckDB connection. Please check your external DuckDB instance configuration and try to initialize Cosmograph again.":"🚨 Failed to fetch DuckDB-Wasm bundles. Please try to initialize Cosmograph again."}))}_initializeHTMLElements(){var i,t;this._containerElement.classList.add(T.cosmograph),null===(i=this._containerElement)||void 0===i||i.style.setProperty("--cosmograph-text-color","#ffffff"),this._cosmosElement=document.createElement("div"),this._cosmosElement.style.width="100%",this._cosmosElement.style.height="100%",null===(t=this._cosmosElement)||void 0===t||t.style.setProperty("backgroundColor",s),this._containerElement.appendChild(this._cosmosElement),this._addAttribution(),this._addMessageElement()}_addAttribution(){var i;this._attributionDivElement=document.createElement("div"),this._attributionDivElement.classList.add(T.attribution),this._attributionDivElement.onclick=()=>{var i;return null===(i=window.open("https://cosmograph.app/","_blank"))||void 0===i?void 0:i.focus()};const t=(new DOMParser).parseFromString(d,"image/svg+xml").firstChild;null===(i=this._attributionDivElement)||void 0===i||i.appendChild(t),this._containerElement.appendChild(this._attributionDivElement)}_addMessageElement(){this._messageDivElement=document.createElement("div"),this._messageDivElement.classList.add(T.message),this._messageDivElement.innerText="🚀 Initializing Cosmograph...",this._containerElement.appendChild(this._messageDivElement)}async _initializeCosmos(){const{_config:t}=this;this._cosmos&&this._cosmos.destroy();const e=await g(this._dbCoordinator,this.pointsTableName,t);this._disableSimulation=!!t.disableSimulation||!1!==t.disableSimulation&&(!t.links||e),this._configManager.cosmosConfig.disableSimulation=this._disableSimulation,this._cosmos=new i(this._cosmosElement,this._configManager.cosmosConfig)}_updateMessage(i){this._messageDivElement&&(null===i?this._messageDivElement.style.display="none":(this._messageDivElement.style.display="block",this._messageDivElement.innerText=i))}async _updateStats(){var i,t,e,s,o,n;this._stats={pointsCount:null!==(t=null===(i=this._cosmos)||void 0===i?void 0:i.graph.pointsNumber)&&void 0!==t?t:0,linksCount:null!==(s=null===(e=this._cosmos)||void 0===e?void 0:e.graph.linksNumber)&&void 0!==s?s:0,pointsSummary:await w(this._dbCoordinator,this.pointsTableName),linksSummary:(null===(n=null===(o=this._cosmos)||void 0===o?void 0:o.graph)||void 0===n?void 0:n.linksNumber)?await w(this._dbCoordinator,this.linksTableName):void 0}}async _dbReady(){if(this._dbReadinessPromise)return await this._dbReadinessPromise}async dataUploaded(){return await this._configManager.dataReady()}get _config(){return this._configManager.config}get stats(){return this._stats}get crossfilter(){return this._crossfilter.filtered}get progress(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.progress}get isSimulationRunning(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.isSimulationRunning}get pointDegrees(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.graph.degree}get maxPointSize(){var i,t;return null!==(t=null===(i=this._cosmos)||void 0===i?void 0:i.maxPointSize)&&void 0!==t?t:0}get activePointColorStrategy(){return this._configManager.activePointColorStrategy}get activePointSizeStrategy(){return this._configManager.activePointSizeStrategy}get focusedPointIndex(){var i;return null!==(i=this._config.focusedPointIndex)&&void 0!==i?i:this._focusedPointIndex}get rescaleXFn(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.getScaleX()}get rescaleYFn(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.getScaleY()}get linksTableName(){var i;return(null===(i=this._dbCoordinator)||void 0===i?void 0:i.internalDB)||"string"!=typeof this._config.links?u.Links:this._config.links}get pointsTableName(){var i;return(null===(i=this._dbCoordinator)||void 0===i?void 0:i.internalDB)||"string"!=typeof this._config.points?u.Points:this._config.points}async getConfig(){return await this._configManager.configUpdated(),this._configManager.config}async getActivePointColorFn(){return await this._configManager.configUpdated(),this._configManager.activePointColorFn}async getActivePointSizeFn(){return await this._configManager.configUpdated(),this._configManager.activePointSizeFn}async getActiveLinkColorFn(){return await this._configManager.configUpdated(),this._configManager.activeLinkColorFn}async getActiveLinkWidthFn(){return await this._configManager.configUpdated(),this._configManager.activeLinkWidthFn}setConfig(i){this._configManager.setConfig(i)}captureScreenshot(i="cosmograph-screenshot.png"){var t;const e=null===(t=this._cosmosElement)||void 0===t?void 0:t.querySelector("canvas");if(!e)return;const s=document.createElement("a");s.download=i,s.href=e.toDataURL("image/png"),s.click()}focusPoint(i){var t;null===(t=this._cosmos)||void 0===t||t.setFocusedPointByIndex(i)}getPointPositions(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.getPointPositions()}getClusterPositions(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.getClusterPositions()}activateRectSelection(){this._rectangularSelection.enable()}deactivateRectSelection(){this._rectangularSelection.disable()}getSelectedPointIndices(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.getSelectedIndices()}selectPointsInRect(i){if(!this._cosmos||!i)return;const t=this._cosmos.getPointsInRange(i);this.selectPoints(Array.from(t))}selectPoints(i){var t,e;i&&i.length?null===(t=this._selectionClient)||void 0===t||t.publish(i):null===(e=this._selectionClient)||void 0===e||e.publish(void 0)}selectPoint(i,t=!1){var e,s;if(this._cosmos)if(void 0!==i){let s=[i];t&&(s=s.concat(this._cosmos.getAdjacentIndices(i))),null===(e=this._selectionClient)||void 0===e||e.publish(s)}else null===(s=this._selectionClient)||void 0===s||s.publish(void 0)}unselectPoints(){var i;this._cosmos&&(null===(i=this._selectionClient)||void 0===i||i.publish(void 0))}setFocusedPointByIndex(i){var t,e;this._cosmos&&!this._config.focusedPointIndex&&(this._focusedPointIndex=i,null===(t=this._cosmos)||void 0===t||t.setFocusedPointByIndex(i),null===(e=this._labels)||void 0===e||e.render())}start(i=1){var t;!0!==this._disableSimulation&&(null===(t=this._cosmos)||void 0===t||t.start(i))}pause(){var i;!0!==this._disableSimulation&&(null===(i=this._cosmos)||void 0===i||i.pause())}restart(){var i;!0!==this._disableSimulation&&(null===(i=this._cosmos)||void 0===i||i.restart())}step(){var i;null===(i=this._cosmos)||void 0===i||i.step()}setZoomLevel(i,t=0){var e;null===(e=this._cosmos)||void 0===e||e.setZoomLevel(i,t)}getZoomLevel(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.getZoomLevel()}zoomToPoint(i,t,e,s){var o;null===(o=this._cosmos)||void 0===o||o.zoomToPointByIndex(i,t,e,s)}fitView(i=this._config.fitViewDuration,t=this._config.fitViewPadding){var e;null===(e=this._cosmos)||void 0===e||e.fitView(i,t)}fitViewByIndices(i,t=this._config.fitViewDuration,e=this._config.fitViewPadding){var s;null===(s=this._cosmos)||void 0===s||s.fitViewByPointIndices(i,t,e)}fitViewByCoordinates(i,t=this._config.fitViewDuration,e=this._config.fitViewPadding){var s;null===(s=this._cosmos)||void 0===s||s.fitViewByPointPositions(i,t,e)}getConnectedPointIndices(i){var t;return null===(t=this._cosmos)||void 0===t?void 0:t.getAdjacentIndices(i)}spaceToScreenPosition(i){var t;return null===(t=this._cosmos)||void 0===t?void 0:t.spaceToScreenPosition(i)}screenToSpacePosition(i){var t;return null===(t=this._cosmos)||void 0===t?void 0:t.spaceToScreenPosition(i)}spaceToScreenRadius(i){var t;return null===(t=this._cosmos)||void 0===t?void 0:t.spaceToScreenRadius(i)}getPointRadiusByIndex(i){var t;return null===(t=this._cosmos)||void 0===t?void 0:t.getPointRadiusByIndex(i)}getSampledPointPositionsMap(){var i;return null===(i=this._cosmos)||void 0===i?void 0:i.getSampledPointPositionsMap()}async getPointIndicesByIds(i){if(this._dbCoordinator&&this.stats.pointsCount&&i.length)return await _(this._dbCoordinator,this.pointsTableName,this._config,i)}async getPointIdsByIndices(i){if(this._dbCoordinator&&this.stats.pointsCount&&i.length)return await v(this._dbCoordinator,this.pointsTableName,this._config,i)}async getPointsByIndices(i){if(this._dbCoordinator&&this.stats.pointsCount&&i.length)return await p(this._dbCoordinator,this.pointsTableName,this._config.pointIndexBy,i)}async getPointIndicesByExactValues(i,t){if(this._dbCoordinator&&this.stats.pointsCount)return t.length?await f(this._dbCoordinator,this.pointsTableName,this._config,i,t):[]}async getPointIndicesByNumericValue(i,t,e){if(this._dbCoordinator&&this.stats.pointsCount)return t?await b(this._dbCoordinator,this.pointsTableName,this._config,i,t,e):[]}async getPointIndicesByLinksExactValues(i,t){if(this._dbCoordinator&&this.stats.linksCount)return t.length?await C(this._dbCoordinator,this.linksTableName,this._config,i,t):[]}async getPointIndicesByLinksNumericValue(i,t,e){if(this._dbCoordinator&&this.stats.linksCount)return t?await y(this._dbCoordinator,this.linksTableName,this._config,i,t,e):[]}async getLinksByPointIds(i){if(this._dbCoordinator&&this.stats.linksCount&&i.length)return await P(this._dbCoordinator,this.pointsTableName,this._config,i)}async getLinksByPointIndices(i){if(this._dbCoordinator&&this.stats.linksCount&&i.length)return await E(this._dbCoordinator,this.pointsTableName,this._config,i)}convertCosmographDataToObject(i){return h(i)}flattenPositions(i){var t;return null===(t=this._cosmos)||void 0===t?void 0:t.flatten(i)}pair(i){var t;return null===(t=this._cosmos)||void 0===t?void 0:t.pair(i)}async reset(i=!0){var t,e;i&&(this._configManager.resetCosmographConfig(),this._messageDivElement.innerText="👩🏻🚀 Cosmograph is ready, load your data!",this._messageDivElement.style.display="block"),null===(t=this._labels)||void 0===t||t.clear(),this._configManager.clearCosmosBuffers(),await this._dropLocalTables(),null===(e=this._dbCoordinator)||void 0===e||e.clearCache(),this._stats={pointsCount:0,linksCount:0,pointsSummary:void 0,linksSummary:void 0},this._internalApi.dispatchEvent(new CustomEvent("dataUploaded"))}async destroy(){var i,t,e;null===(i=this._cosmos)||void 0===i||i.destroy(),await this._dropLocalTables(),await(null===(t=this._dbCoordinator)||void 0===t?void 0:t.destroy()),this._containerElement.innerHTML="",null===(e=this._labels)||void 0===e||e.destroy()}}export{k as Cosmograph}; | ||
//# sourceMappingURL=index.js.map |
@@ -9,3 +9,3 @@ import { Cosmograph } from "../../../cosmograph"; | ||
constructor(cosmograph: Cosmograph, targetElement: HTMLElement, userConfig?: CosmographButtonFitViewConfigInterface); | ||
setConfig(userConfig: CosmographButtonFitViewConfigInterface): void; | ||
setConfig(userConfig?: CosmographButtonFitViewConfigInterface): void; | ||
remove(): void; | ||
@@ -12,0 +12,0 @@ private _handleClick; |
@@ -1,2 +0,2 @@ | ||
import{Button as i,merge as t}from"@cosmograph/ui";import{getInternalApi as n}from"../../../cosmograph/internal.js";import{defaultCosmographButtonFitViewConfig as o}from"./config.js";class s{constructor(t,o,s){this._handleClick=()=>{var i,t;null===(t=(i=this._config).onClick)||void 0===t||t.call(i),this._internalApi.public.fitView(this._config.duration,this._config.padding)},this._show=()=>{this._fitViewButton.show()},this._internalApi=n(t),this._fitViewButton=new i(o),this._internalApi.addEventListener("graphRebuilt",this._show),this.setConfig(null!=s?s:{})}setConfig(i){this._config=t(o,null!=i?i:{}),this._uiButtonConfig={...this._config,onClick:this._handleClick},this._fitViewButton.setConfig(this._uiButtonConfig)}remove(){this._fitViewButton.destroy(),this._internalApi.removeEventListener("graphRebuilt",this._show)}}export{s as CosmographButtonFitView}; | ||
import{Button as i,merge as t}from"@cosmograph/ui";import{getInternalApi as o}from"../../../cosmograph/internal.js";import{defaultCosmographButtonFitViewConfig as n}from"./config.js";class s{constructor(t,n,s={}){this._handleClick=()=>{var i,t;null===(t=(i=this._config).onClick)||void 0===t||t.call(i),this._internalApi.public.fitView(this._config.duration,this._config.padding)},this._show=()=>{this._fitViewButton.show()},this._internalApi=o(t),this._fitViewButton=new i(n),this._internalApi.addEventListener("graphRebuilt",this._show),this.setConfig(s)}setConfig(i={}){this._config=t(n,i),this._uiButtonConfig={...this._config,onClick:this._handleClick},this._fitViewButton.setConfig(this._uiButtonConfig)}remove(){this._fitViewButton.destroy(),this._internalApi.removeEventListener("graphRebuilt",this._show)}}export{s as CosmographButtonFitView}; | ||
//# sourceMappingURL=index.js.map |
@@ -8,3 +8,3 @@ import { Cosmograph } from "../../../cosmograph"; | ||
constructor(cosmograph: Cosmograph, targetElement: HTMLElement, userConfig?: CosmographButtonPlayPauseConfigInterface); | ||
setConfig(userConfig: CosmographButtonPlayPauseConfigInterface): Promise<void>; | ||
setConfig(userConfig?: CosmographButtonPlayPauseConfigInterface): Promise<void>; | ||
remove(): void; | ||
@@ -11,0 +11,0 @@ private _update; |
@@ -1,2 +0,2 @@ | ||
import{Button as i,merge as t}from"@cosmograph/ui";import{getInternalApi as n}from"../../../cosmograph/internal.js";import{defaultCosmographButtonPlayPauseConfig as s}from"./config.js";import{playSVG as o,pauseSVG as e}from"./variables.js";class a{constructor(t,e,a){this._config=s,this._onSimulationEndHandler=()=>{this._update()},this._onCosmosInitializedHandler=()=>{this._update()},this._internalApi=n(t),this._playPauseButton=new i(e,{iconSvg:o}),this._internalApi.addEventListener("onSimulationEnd",this._onSimulationEndHandler),this._internalApi.addEventListener("graphRebuilt",this._onCosmosInitializedHandler),this.setConfig(null!=a?a:{})}async setConfig(i){this._config=t(s,i),this._config.onClick=()=>{var t;null===(t=null==i?void 0:i.onClick)||void 0===t||t.call(i),this._internalApi.public.isSimulationRunning?this._internalApi.public.pause():1===this._internalApi.public.progress?this._internalApi.public.start():this._internalApi.public.restart(),this._update()},this._update()}remove(){this._playPauseButton.destroy(),this._internalApi.removeEventListener("onSimulationEnd",this._onSimulationEndHandler),this._internalApi.removeEventListener("graphRebuilt",this._onCosmosInitializedHandler)}_update(){if(!this._internalApi.cosmos)return;!0===this._internalApi.cosmos.config.disableSimulation?this._playPauseButton.hide():this._playPauseButton.show(),this._config.iconSvg=this._internalApi.public.isSimulationRunning?e:o,this._playPauseButton.setConfig(this._config)}}export{a as CosmographButtonPlayPause}; | ||
import{Button as i,merge as t}from"@cosmograph/ui";import{getInternalApi as n}from"../../../cosmograph/internal.js";import{defaultCosmographButtonPlayPauseConfig as s}from"./config.js";import{playSVG as o,pauseSVG as e}from"./variables.js";class a{constructor(t,e,a={}){this._config=s,this._onSimulationEndHandler=()=>{this._update()},this._onCosmosInitializedHandler=()=>{this._update()},this._internalApi=n(t),this._playPauseButton=new i(e,{iconSvg:o}),this._internalApi.addEventListener("onSimulationEnd",this._onSimulationEndHandler),this._internalApi.addEventListener("graphRebuilt",this._onCosmosInitializedHandler),this.setConfig(a)}async setConfig(i={}){this._config=t(s,i),this._config.onClick=()=>{var t;null===(t=null==i?void 0:i.onClick)||void 0===t||t.call(i),this._internalApi.public.isSimulationRunning?this._internalApi.public.pause():1===this._internalApi.public.progress?this._internalApi.public.start():this._internalApi.public.restart(),this._update()},this._update()}remove(){this._playPauseButton.destroy(),this._internalApi.removeEventListener("onSimulationEnd",this._onSimulationEndHandler),this._internalApi.removeEventListener("graphRebuilt",this._onCosmosInitializedHandler)}_update(){if(!this._internalApi.cosmos)return;!0===this._internalApi.cosmos.config.disableSimulation?this._playPauseButton.hide():this._playPauseButton.show(),this._config.iconSvg=this._internalApi.public.isSimulationRunning?e:o,this._playPauseButton.setConfig(this._config)}}export{a as CosmographButtonPlayPause}; | ||
//# sourceMappingURL=index.js.map |
@@ -9,3 +9,3 @@ import { Cosmograph } from "../../../cosmograph"; | ||
constructor(cosmograph: Cosmograph, targetElement: HTMLElement, userConfig?: CosmographButtonSelectAreaConfigInterface); | ||
setConfig(userConfig: CosmographButtonSelectAreaConfigInterface): void; | ||
setConfig(userConfig?: CosmographButtonSelectAreaConfigInterface): void; | ||
remove(): void; | ||
@@ -12,0 +12,0 @@ private _show; |
@@ -1,2 +0,2 @@ | ||
import{merge as e,Button as t}from"@cosmograph/ui";import{getInternalApi as i}from"../../../cosmograph/internal.js";import{defaultCosmographButtonSelectAreaConfig as n}from"./config.js";class r{constructor(r,s,a){this._show=()=>{this._selectAreaButton.show()},this._internalApi=i(r),this._config=e(n,a),this._config.onClick=()=>{var e;null===(e=null==a?void 0:a.onClick)||void 0===e||e.call(a),this._internalApi.public.activateRectSelection()},this._selectAreaButton=new t(s,this._config),this._areaSelectedHandler=()=>{this._internalApi.public.deactivateRectSelection()},this._internalApi.addEventListener("graphRebuilt",this._show),this._internalApi.addEventListener("areaSelected",this._areaSelectedHandler)}setConfig(t){this._config=e(n,null!=t?t:{})}remove(){this._selectAreaButton.destroy(),this._internalApi.removeEventListener("graphRebuilt",this._show),this._internalApi.removeEventListener("areaSelected",this._areaSelectedHandler)}}export{r as CosmographButtonSelectArea}; | ||
import{merge as e,Button as t}from"@cosmograph/ui";import{getInternalApi as i}from"../../../cosmograph/internal.js";import{defaultCosmographButtonSelectAreaConfig as n}from"./config.js";class r{constructor(r,s,a={}){this._show=()=>{this._selectAreaButton.show()},this._internalApi=i(r),this._config=e(n,a),this._config.onClick=()=>{var e;null===(e=null==a?void 0:a.onClick)||void 0===e||e.call(a),this._internalApi.public.activateRectSelection()},this._selectAreaButton=new t(s,this._config),this._areaSelectedHandler=()=>{this._internalApi.public.deactivateRectSelection()},this._internalApi.addEventListener("graphRebuilt",this._show),this._internalApi.addEventListener("areaSelected",this._areaSelectedHandler)}setConfig(t={}){this._config=e(n,t)}remove(){this._selectAreaButton.destroy(),this._internalApi.removeEventListener("graphRebuilt",this._show),this._internalApi.removeEventListener("areaSelected",this._areaSelectedHandler)}}export{r as CosmographButtonSelectArea}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@cosmograph/cosmograph", | ||
"version": "2.0.0-beta.17", | ||
"version": "2.0.0-beta.18", | ||
"description": "Cosmograph: The fastest web-based graph visualization library", | ||
@@ -12,3 +12,3 @@ "author": "cosmograph-org", | ||
"@cosmograph/cosmos": "2.0.0-beta.23", | ||
"@cosmograph/ui": "2.0.0-beta.17", | ||
"@cosmograph/ui": "2.0.0-beta.18", | ||
"@duckdb/duckdb-wasm": "1.29.1-dev115.0", | ||
@@ -15,0 +15,0 @@ "@interacta/css-labels": "^0.1.2", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
490434
0.03%0
-100%+ Added
- Removed
Updated