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

elk-svg

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

elk-svg - npm Package Compare versions

Comparing version 2.4.1 to 2.5.0

dist/shapes.d.ts

30

dist/elk-svg.d.ts

@@ -1,21 +0,9 @@

import type { ElkSvgInputNode } from "./input-types";
import { type Logger } from "./logger";
import type { DefaultRenderingOptions } from "./rendering-types";
import type { Shape } from "./shape-types";
export declare class ElkSvg {
private readonly renderer;
private readonly preprocessor;
constructor(options: ElkSvgOptions);
render(node: ElkSvgInputNode): void;
}
export type ElkSvgOptions = {
/**
* `svg` DOM Element.
*/
container: Element;
defaultRenderingOptions?: DefaultRenderingOptions;
classPrefix?: string;
logger?: Logger;
idAttribute?: string;
shapes?: Record<string, Shape>;
};
import type { ElkSvg } from "./types";
import { ElkSvgOptions } from "./types";
/**
*
* @param options
* @returns {@link ElkSvg} instance.
* @category Basic Usage
*/
export declare function initElkSvg(options: ElkSvgOptions): ElkSvg;
import { defaultLogger } from "./logger";
import { Preprocessor } from "./preprocess";
import { Renderer } from "./render";
import { defaultShapes } from "./shape";
export class ElkSvg {
import { defaultShapes } from "./shapes";
/**
*
* @param options
* @returns {@link ElkSvg} instance.
* @category Basic Usage
*/
export function initElkSvg(options) {
return new ElkSvgImpl(options);
}
class ElkSvgImpl {
renderer;

@@ -29,3 +38,11 @@ preprocessor;

}
/**
*
* @param id the id of elk element.
* @returns rendered DOM element or null.
*/
ref(id) {
return this.renderer.ref(id);
}
}
//# sourceMappingURL=elk-svg.js.map

@@ -1,2 +0,2 @@

import type { ElkSvgStrictEdge, ElkSvgStrictLabel, ElkSvgStrictNode, ElkSvgStrictPort } from "./strict-types";
import type { StrictEdge, StrictLabel, StrictNode, StrictPort } from "./types";
export type Flatten<T extends {

@@ -8,7 +8,7 @@ svg?: any;

};
export type FlatNode = Omit<Flatten<ElkSvgStrictNode>, "parentId"> & {
export type FlatNode = Omit<Flatten<StrictNode>, "parentId"> & {
parentId: string | null;
shapePath?: string;
};
export type FlatEdge = Flatten<ElkSvgStrictEdge> & {
export type FlatEdge = Flatten<StrictEdge> & {
x: number;

@@ -24,6 +24,6 @@ y: number;

};
export type FlatPort = Flatten<ElkSvgStrictPort> & {
export type FlatPort = Flatten<StrictPort> & {
shapePath?: string;
};
export type FlatLabel = Flatten<ElkSvgStrictLabel> & {
export type FlatLabel = Flatten<StrictLabel> & {
id: string;

@@ -30,0 +30,0 @@ };

@@ -0,5 +1,23 @@

/**
* # Documentation work in progress.
*
* ## Getting started
*
* ```
* npm install elk-svg
* ```
*
* ```
* import { initElkSvg } from "elk-svg";
*
* const container = document.querySelector("svg")
* const elkSvg = initElkSvg({ container });
* ```
*
* Initialize {@link ElkSvg} instance by calling {@link initElkSvg} function with {@link ElkSvgOptions}.
* The only required property is `container`.
*
* @packageDocumentation
*/
export * from "./elk-svg";
export * from "./rendering-types";
export * from "./strict-types";
export * from "./shape-types";
export * from "./input-types";
export * from "./types";

@@ -0,6 +1,24 @@

/**
* # Documentation work in progress.
*
* ## Getting started
*
* ```
* npm install elk-svg
* ```
*
* ```
* import { initElkSvg } from "elk-svg";
*
* const container = document.querySelector("svg")
* const elkSvg = initElkSvg({ container });
* ```
*
* Initialize {@link ElkSvg} instance by calling {@link initElkSvg} function with {@link ElkSvgOptions}.
* The only required property is `container`.
*
* @packageDocumentation
*/
export * from "./elk-svg";
export * from "./rendering-types";
export * from "./strict-types";
export * from "./shape-types";
export * from "./input-types";
export * from "./types";
//# sourceMappingURL=index.js.map

@@ -1,7 +0,2 @@

export type Logger = {
debug: (...args: any[]) => void;
info: (...args: any[]) => void;
warn: (...args: any[]) => void;
error: (...args: any[]) => void;
};
import type { Logger } from "./types";
export declare const defaultLogger: Logger;

@@ -1,3 +0,2 @@

import type { DefaultRenderingOptions } from "../rendering-types";
import type { ElkSvgStrictNode } from "../strict-types";
import type { DefaultRenderingOptions, StrictNode } from "../types";
import type { FlatResult } from "./types";

@@ -13,3 +12,3 @@ export declare class Flatter {

constructor(dro: DefaultRenderingOptions);
flat(node: ElkSvgStrictNode): FlatResult;
flat(node: StrictNode): FlatResult;
private doNode;

@@ -16,0 +15,0 @@ private doEdge;

@@ -1,2 +0,2 @@

import type { Shape } from "../../shape-types";
import type { Shape } from "../../types";
import type { FlatResult, Middleware } from "../types";

@@ -3,0 +3,0 @@ export declare class ShapePath implements Middleware {

import type { FlatElements } from "../flat-types";
import type { DefaultRenderingOptions } from "../rendering-types";
import type { Shape } from "../shape-types";
import type { ElkSvgStrictNode } from "../strict-types";
import type { DefaultRenderingOptions, Shape, StrictNode } from "../types";
export declare class Preprocessor {

@@ -9,3 +7,3 @@ private readonly dro;

constructor(dro: DefaultRenderingOptions, shapes: Record<string, Shape>);
start(node: ElkSvgStrictNode): FlatElements;
start(node: StrictNode): FlatElements;
}

@@ -0,5 +1,4 @@

import type { Classnamer } from "../classnames";
import type { FlatElements } from "../flat-types";
import type { Logger } from "../logger";
import type { Shape } from "../shape-types";
import type { Classnamer } from "../classnames";
import type { Logger, Shape } from "../types";
export declare class Renderer {

@@ -13,2 +12,3 @@ private readonly o;

render(flatElements: FlatElements): void;
ref(id: string): Element | null;
private renderElement;

@@ -15,0 +15,0 @@ private domStateless;

@@ -41,2 +41,5 @@ import { deepEqual, svg, transform } from "../utils";

}
ref(id) {
return this.domRef.getOrNull(id);
}
renderElement(type, idMarking, element) {

@@ -43,0 +46,0 @@ idMarking.delete(element.id);

import type { Classnamer } from "../classnames";
import type { FlatElementType, FlatElementTypeMap } from "../flat-types";
import type { Logger } from "../logger";
import type { Shape } from "../shape-types";
import type { Logger, Shape } from "../types";
export type Component<T extends FlatElementType> = {

@@ -6,0 +5,0 @@ key(ctx: RenderingContext<T>): any[];

@@ -1,5 +0,3 @@

import type { Point } from "./elk-types";
import type { ShapeOutput } from "./shape-types";
import type { Point, ShapeOutput } from "./types";
export declare function ntos(v: number | undefined | null | false, suffix?: string): string;
export declare function n(v: undefined | null | string | number): number;
export declare function svg<K extends keyof SVGElementTagNameMap>(name: K): SVGElementTagNameMap[K];

@@ -18,4 +16,2 @@ export declare function attr(e: Element, name: string, v: any): void;

}): void;
export declare function freezeMerge(...args: (object | null | undefined)[]): any;
export declare function elkVector(v: string): [number, number];
export declare function mapPush<K, V>(m: Map<K, V[]>, k: K, v: V): void;

@@ -22,0 +18,0 @@ export type Brand<K, T> = T & {

@@ -7,8 +7,2 @@ export function ntos(v, suffix = "") {

}
export function n(v) {
if (!v) {
return 0;
}
return typeof v === "number" ? v : parseFloat(v);
}
export function svg(name) {

@@ -50,16 +44,2 @@ return document.createElementNS("http://www.w3.org/2000/svg", name);

}
export function freezeMerge(...args) {
const r = {};
args.forEach((a) => {
Object.assign(r, a);
});
return Object.freeze(r);
}
export function elkVector(v) {
const arr = v.split(",");
if (arr.length !== 2) {
throw new Error(`invalid vector: ${v}`);
}
return arr.map(Number);
}
export function mapPush(m, k, v) {

@@ -66,0 +46,0 @@ const arr = m.get(k);

@@ -7,3 +7,4 @@ {

"test": "",
"dev": "tsc --watch"
"dev": "tsc --watch",
"docs": "typedoc"
},

@@ -29,5 +30,7 @@ "main": "dist/index.js",

"semantic-release": "^23.0.2",
"typedoc": "^0.25.13",
"typedoc-material-theme": "^1.0.2",
"typescript": "^5.4.5"
},
"version": "2.4.1"
"version": "2.5.0"
}

@@ -1,6 +0,8 @@

![NPM Version](https://img.shields.io/npm/v/elk-svg)
![NPM Version (with dist tag)](https://img.shields.io/npm/v/elk-svg/alpha)
[<img src="https://img.shields.io/npm/v/elk-svg">](https://www.npmjs.com/package/elk-svg)
# [elk-svg](https://github.com/wirekang/elk-svg)
# WIP
* SVG renderer for [ELK json format](https://eclipse.dev/elk/documentation/tooldevelopers/graphdatastructure/jsonformat.html).
* No server, no framework, zero-dependency.
## [Documentation](https://wirekang.github.io/elk-svg)

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

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

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