Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@cosmograph/cosmos

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cosmograph/cosmos - npm Package Compare versions

Comparing version 1.3.0-beta.2 to 1.3.0-beta.3

3

dist/config.d.ts

@@ -310,4 +310,5 @@ import { D3ZoomEvent } from 'd3-zoom';

randomSeed: undefined;
init(config: GraphConfigInterface<N, L>): GraphConfigInterface<N, L>;
init(config: GraphConfigInterface<N, L>): void;
deepMergeConfig<T>(current: T, next: T, key: keyof T): void;
private getConfig;
}
import regl from 'regl';
import { ColorAccessor, NumericAccessor, StringAccessor } from './config';
export declare const isFunction: <T>(a: T) => boolean;
export declare const isArray: <T>(a: unknown) => a is T[];
export declare const isObject: <T>(a: T) => boolean;
export declare const isAClassInstance: <T>(a: T) => boolean;
export declare const isPlainObject: <T>(a: T) => boolean;
export declare function getValue<T, ReturnType>(d: T, accessor: NumericAccessor<T> | StringAccessor<T> | ColorAccessor<T>, index?: number): ReturnType | null | undefined;

@@ -4,0 +9,0 @@ export declare function getString<T>(d: T, accessor: StringAccessor<T>, i?: number): string | null | undefined;

{
"name": "@cosmograph/cosmos",
"version": "1.3.0-beta.2",
"version": "1.3.0-beta.3",
"description": "GPU-based force graph layout and rendering",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -13,2 +13,3 @@ import { D3ZoomEvent } from 'd3-zoom'

} from '@/graph/variables'
import { isPlainObject } from '@/graph/helper'

@@ -368,18 +369,17 @@ export type NumericAccessor<Datum> = ((d: Datum, i?: number, ...rest: unknown[]) => number | null) | number | null | undefined

public init (config: GraphConfigInterface<N, L>): GraphConfigInterface<N, L> {
const currentConfig = this.getConfig()
const keys = Object.keys(config).map(key => key as keyof GraphConfigInterface<N, L>)
keys.forEach(key => {
if (typeof currentConfig[key] === 'object') {
(currentConfig[key] as Record<string, unknown>) = {
...currentConfig[key] as Record<string, unknown>,
...config[key] as Record<string, unknown>,
} as Record<string, unknown>
} else {
(currentConfig[key] as keyof GraphConfigInterface<N, L>) =
config[key] as keyof GraphConfigInterface<N, L>
}
})
public init (config: GraphConfigInterface<N, L>): void {
(Object.keys(config) as (keyof GraphConfigInterface<N, L>)[])
.forEach(configParameter => {
this.deepMergeConfig(this.getConfig(), config, configParameter)
})
}
return currentConfig
public deepMergeConfig <T> (current: T, next: T, key: keyof T): void {
if (isPlainObject(current[key]) && isPlainObject(next[key])) {
// eslint-disable-next-line @typescript-eslint/ban-types
(Object.keys(next[key] as Object) as (keyof T[keyof T])[])
.forEach(configParameter => {
this.deepMergeConfig(current[key], next[key], configParameter)
})
} else current[key] = next[key]
}

@@ -386,0 +386,0 @@

@@ -5,5 +5,12 @@ import { color as d3Color } from 'd3-color'

function isFunction (value: unknown): boolean {
return typeof value === 'function'
export const isFunction = <T>(a: T): boolean => typeof a === 'function'
export const isArray = <T>(a: unknown | T[]): a is T[] => Array.isArray(a)
export const isObject = <T>(a: T): boolean => (a instanceof Object)
export const isAClassInstance = <T>(a: T): boolean => {
if (a instanceof Object) {
// eslint-disable-next-line @typescript-eslint/ban-types
return (a as T & Object).constructor.name !== 'Function' && (a as T & Object).constructor.name !== 'Object'
} else return false
}
export const isPlainObject = <T>(a: T): boolean => isObject(a) && !isArray(a) && !isFunction(a) && !isAClassInstance(a)

@@ -30,3 +37,3 @@ export function getValue<T, ReturnType> (

let rgba: [number, number, number, number]
if (Array.isArray(value)) {
if (isArray(value)) {
rgba = value

@@ -33,0 +40,0 @@ } else {

@@ -754,3 +754,3 @@ import { select, Selection } from 'd3-selection'

const inputIndex = this.graph.getInputIndexBySortedIndex(index)
const hovered = inputIndex ? this.graph.getNodeByIndex(inputIndex) : undefined
const hovered = inputIndex !== undefined ? this.graph.getNodeByIndex(inputIndex) : undefined
if (this.store.hoveredNode?.node !== hovered) isMouseover = true

@@ -757,0 +757,0 @@ const pointX = pixels[2] as number

@@ -53,6 +53,5 @@ import regl from 'regl'

if (node && sortedIndex !== undefined) {
initialState[sortedIndex * 4 + 0] = node.x ??
(spaceSize ?? defaultConfigValues.spaceSize) * (store.getRandomFloat(0, 1) * (0.505 - 0.495) + 0.495)
initialState[sortedIndex * 4 + 1] = node.y ??
(spaceSize ?? defaultConfigValues.spaceSize) * (store.getRandomFloat(0, 1) * (0.505 - 0.495) + 0.495)
const space = spaceSize ?? defaultConfigValues.spaceSize
initialState[sortedIndex * 4 + 0] = node.x ?? space * store.getRandomFloat(0.495, 0.505)
initialState[sortedIndex * 4 + 1] = node.y ?? space * store.getRandomFloat(0.495, 0.505)
}

@@ -59,0 +58,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc