🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

konva

Package Overview
Dependencies
Maintainers
1
Versions
240
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

konva - npm Package Compare versions

Comparing version
10.0.2
to
10.0.3
+28
-2
lib/_CoreInternals.d.ts

@@ -157,3 +157,29 @@ import { Transform } from './Util.ts';

justDragged: boolean;
readonly node: Node<import("./Node.ts").NodeConfig> | undefined;
readonly node: Node<{
x?: number;
y?: number;
width?: number;
height?: number;
visible?: boolean;
listening?: boolean;
id?: string;
name?: string;
opacity?: number;
scale?: import("./types.ts").Vector2d;
scaleX?: number;
skewX?: number;
skewY?: number;
scaleY?: number;
rotation?: number;
rotationDeg?: number;
offset?: import("./types.ts").Vector2d;
offsetX?: number;
offsetY?: number;
draggable?: boolean;
dragDistance?: number;
dragBoundFunc?: (this: Node, pos: import("./types.ts").Vector2d) => import("./types.ts").Vector2d;
preventDefault?: boolean;
globalCompositeOperation?: "" | "source-over" | "source-in" | "source-out" | "source-atop" | "destination-over" | "destination-in" | "destination-out" | "destination-atop" | "lighter" | "copy" | "xor" | "multiply" | "screen" | "overlay" | "darken" | "lighten" | "color-dodge" | "color-burn" | "hard-light" | "soft-light" | "difference" | "exclusion" | "hue" | "saturation" | "color" | "luminosity";
filters?: (string | import("./Node.ts").FilterFunction)[];
}> | undefined;
_dragElements: Map<number, {

@@ -172,3 +198,3 @@ node: Node;

shapes: {
[key: string]: Shape<import("./Shape.ts").ShapeConfig>;
[key: string]: Shape<import("./Shape.ts").ShapeConfig<{}>>;
};

@@ -175,0 +201,0 @@ Animation: typeof Animation;

@@ -163,3 +163,29 @@ import { Konva as Core } from './_CoreInternals.ts';

justDragged: boolean;
readonly node: import("./Node.ts").Node<import("./Node.ts").NodeConfig> | undefined;
readonly node: import("./Node.ts").Node<{
x?: number;
y?: number;
width?: number;
height?: number;
visible?: boolean;
listening?: boolean;
id?: string;
name?: string;
opacity?: number;
scale?: import("./types.ts").Vector2d;
scaleX?: number;
skewX?: number;
skewY?: number;
scaleY?: number;
rotation?: number;
rotationDeg?: number;
offset?: import("./types.ts").Vector2d;
offsetX?: number;
offsetY?: number;
draggable?: boolean;
dragDistance?: number;
dragBoundFunc?: (this: import("./Node.ts").Node, pos: import("./types.ts").Vector2d) => import("./types.ts").Vector2d;
preventDefault?: boolean;
globalCompositeOperation?: "" | "source-over" | "source-in" | "source-out" | "source-atop" | "destination-over" | "destination-in" | "destination-out" | "destination-atop" | "lighter" | "copy" | "xor" | "multiply" | "screen" | "overlay" | "darken" | "lighten" | "color-dodge" | "color-burn" | "hard-light" | "soft-light" | "difference" | "exclusion" | "hue" | "saturation" | "color" | "luminosity";
filters?: (string | import("./Node.ts").FilterFunction)[];
}> | undefined;
_dragElements: Map<number, {

@@ -178,3 +204,3 @@ node: import("./Node.ts").Node;

shapes: {
[key: string]: import("./Shape.ts").Shape<import("./Shape.ts").ShapeConfig>;
[key: string]: import("./Shape.ts").Shape<import("./Shape.ts").ShapeConfig<{}>>;
};

@@ -181,0 +207,0 @@ Animation: typeof import("./Animation.ts").Animation;

+2
-2

@@ -16,3 +16,3 @@ import type { HitCanvas, SceneCanvas } from './Canvas.ts';

}
export declare abstract class Container<ChildType extends Node = Node> extends Node<ContainerConfig> {
export declare abstract class Container<ChildType extends Node = Node, Config extends ContainerConfig = ContainerConfig> extends Node<Config> {
children: Array<ChildType>;

@@ -37,3 +37,3 @@ getChildren(filterFunc?: (item: Node) => boolean): ChildType[];

clone(obj?: any): this;
getAllIntersections(pos: any): Shape<import("./Shape.ts").ShapeConfig>[];
getAllIntersections(pos: any): Shape<import("./Shape.ts").ShapeConfig<{}>>[];
_clearSelfAndDescendantCache(attr?: string): void;

@@ -40,0 +40,0 @@ _setChildrenIndices(): void;

@@ -6,3 +6,29 @@ import type { Node } from './Node.ts';

justDragged: boolean;
readonly node: Node<import("./Node.ts").NodeConfig> | undefined;
readonly node: Node<{
x?: number;
y?: number;
width?: number;
height?: number;
visible?: boolean;
listening?: boolean;
id?: string;
name?: string;
opacity?: number;
scale?: Vector2d;
scaleX?: number;
skewX?: number;
skewY?: number;
scaleY?: number;
rotation?: number;
rotationDeg?: number;
offset?: Vector2d;
offsetX?: number;
offsetY?: number;
draggable?: boolean;
dragDistance?: number;
dragBoundFunc?: (this: Node, pos: Vector2d) => Vector2d;
preventDefault?: boolean;
globalCompositeOperation?: "" | "source-over" | "source-in" | "source-out" | "source-atop" | "destination-over" | "destination-in" | "destination-out" | "destination-atop" | "lighter" | "copy" | "xor" | "multiply" | "screen" | "overlay" | "darken" | "lighten" | "color-dodge" | "color-burn" | "hard-light" | "soft-light" | "difference" | "exclusion" | "hue" | "saturation" | "color" | "luminosity";
filters?: (string | import("./Node.ts").FilterFunction)[];
}> | undefined;
_dragElements: Map<number, {

@@ -9,0 +35,0 @@ node: Node;

@@ -16,3 +16,3 @@ const PI_OVER_180 = Math.PI / 180;

_global: glob,
version: '10.0.2',
version: '10.0.3',
isBrowser: detectBrowser(),

@@ -59,3 +59,3 @@ isUnminified: /param/.test(function (param) { }.toString()),

if (typeof glob.Konva !== 'undefined') {
console.error('Severa Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.');
console.error('Several Konva instances detected. It is not recommended to use multiple Konva instances in the same environment.');
}

@@ -62,0 +62,0 @@ glob.Konva = Konva;

@@ -46,3 +46,3 @@ import type { ContainerConfig } from './Container.ts';

batchDraw(): this;
getIntersection(pos: Vector2d): Shape<import("./Shape.ts").ShapeConfig> | null;
getIntersection(pos: Vector2d): Shape<import("./Shape.ts").ShapeConfig<{}>> | null;
_getIntersection(pos: Vector2d): {

@@ -49,0 +49,0 @@ shape?: Shape;

@@ -9,3 +9,3 @@ import type { Canvas } from './Canvas.ts';

import type { GetSet, IRect, Vector2d } from './types.ts';
import { Transform } from './Util.ts';
import { Transform, type AnyString } from './Util.ts';
export type FilterFunction = (this: Node, imageData: ImageData) => void;

@@ -15,4 +15,3 @@ export type Filter = FilterFunction | string;

type globalCompositeOperationType = '' | 'source-over' | 'source-in' | 'source-out' | 'source-atop' | 'destination-over' | 'destination-in' | 'destination-out' | 'destination-atop' | 'lighter' | 'copy' | 'xor' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity';
export interface NodeConfig {
[index: string]: any;
export type NodeConfig<Props extends Record<string, any> = {}> = Props & {
x?: number;

@@ -43,3 +42,3 @@ y?: number;

filters?: Filters;
}
};
type NodeEventMap = GlobalEventHandlersEventMap & {

@@ -58,2 +57,14 @@ [index: string]: any;

export type KonvaEventListener<This, EventType> = (this: This, ev: KonvaEventObject<EventType, This>) => void;
export type CanvasConfig = {
x?: number;
y?: number;
width?: number;
height?: number;
pixelRatio?: number;
imageSmoothingEnabled?: boolean;
};
export type ImageConfig = CanvasConfig & {
mimeType?: string;
quality?: number;
};
export declare abstract class Node<Config extends NodeConfig = NodeConfig> {

@@ -91,11 +102,5 @@ _id: number;

clearCache(): this;
cache(config?: {
x?: number;
y?: number;
width?: number;
height?: number;
cache(config?: CanvasConfig & {
drawBorder?: boolean;
offset?: number;
pixelRatio?: number;
imageSmoothingEnabled?: boolean;
hitCanvasPixelRatio?: number;

@@ -136,6 +141,32 @@ }): this | undefined;

destroy(): this;
getAttr<T>(attr: string): any;
getAncestors(): Node<NodeConfig>[];
getAttrs(): Config & Record<string, any>;
setAttrs(config: any): this;
getAttr<AttrConfig extends Config, K extends AnyString<keyof Config>>(attr: K): K extends keyof AttrConfig ? AttrConfig[K] : any;
getAncestors(): Node<{
x?: number;
y?: number;
width?: number;
height?: number;
visible?: boolean;
listening?: boolean;
id?: string;
name?: string;
opacity?: number;
scale?: Vector2d;
scaleX?: number;
skewX?: number;
skewY?: number;
scaleY?: number;
rotation?: number;
rotationDeg?: number;
offset?: Vector2d;
offsetX?: number;
offsetY?: number;
draggable?: boolean;
dragDistance?: number;
dragBoundFunc?: (this: Node, pos: Vector2d) => Vector2d;
preventDefault?: boolean;
globalCompositeOperation?: globalCompositeOperationType;
filters?: Filters;
}>[];
getAttrs(): Config;
setAttrs(config?: Config): this;
isListening(): any;

@@ -195,6 +226,84 @@ _isListening(relativeTo?: Node): boolean;

toJSON(): string;
getParent(): Container<Node<NodeConfig>> | null;
findAncestors(selector: string | Function, includeSelf?: boolean, stopNode?: Node): Node<NodeConfig>[];
getParent(): Container<Node<{
x?: number;
y?: number;
width?: number;
height?: number;
visible?: boolean;
listening?: boolean;
id?: string;
name?: string;
opacity?: number;
scale?: Vector2d;
scaleX?: number;
skewX?: number;
skewY?: number;
scaleY?: number;
rotation?: number;
rotationDeg?: number;
offset?: Vector2d;
offsetX?: number;
offsetY?: number;
draggable?: boolean;
dragDistance?: number;
dragBoundFunc?: (this: Node, pos: Vector2d) => Vector2d;
preventDefault?: boolean;
globalCompositeOperation?: globalCompositeOperationType;
filters?: Filters;
}>, import("./Container.ts").ContainerConfig> | null;
findAncestors(selector: string | Function, includeSelf?: boolean, stopNode?: Node): Node<{
x?: number;
y?: number;
width?: number;
height?: number;
visible?: boolean;
listening?: boolean;
id?: string;
name?: string;
opacity?: number;
scale?: Vector2d;
scaleX?: number;
skewX?: number;
skewY?: number;
scaleY?: number;
rotation?: number;
rotationDeg?: number;
offset?: Vector2d;
offsetX?: number;
offsetY?: number;
draggable?: boolean;
dragDistance?: number;
dragBoundFunc?: (this: Node, pos: Vector2d) => Vector2d;
preventDefault?: boolean;
globalCompositeOperation?: globalCompositeOperationType;
filters?: Filters;
}>[];
isAncestorOf(node: Node): boolean;
findAncestor(selector: string | Function, includeSelf?: boolean, stopNode?: Container): Node<NodeConfig>;
findAncestor(selector: string | Function, includeSelf?: boolean, stopNode?: Container): Node<{
x?: number;
y?: number;
width?: number;
height?: number;
visible?: boolean;
listening?: boolean;
id?: string;
name?: string;
opacity?: number;
scale?: Vector2d;
scaleX?: number;
skewX?: number;
skewY?: number;
scaleY?: number;
rotation?: number;
rotationDeg?: number;
offset?: Vector2d;
offsetX?: number;
offsetY?: number;
draggable?: boolean;
dragDistance?: number;
dragBoundFunc?: (this: Node, pos: Vector2d) => Vector2d;
preventDefault?: boolean;
globalCompositeOperation?: globalCompositeOperationType;
filters?: Filters;
}>;
_isMatch(selector: string | Function): any;

@@ -216,31 +325,10 @@ getLayer(): Layer | null;

_toKonvaCanvas(config: any): SceneCanvas;
toCanvas(config?: any): HTMLCanvasElement;
toDataURL(config?: {
x?: number;
y?: number;
width?: number;
height?: number;
pixelRatio?: number;
mimeType?: string;
quality?: number;
callback?: (str: string) => void;
toCanvas(config?: CanvasConfig): HTMLCanvasElement;
toDataURL(config?: ImageConfig & {
callback?: (url: string) => void;
}): string;
toImage(config?: {
x?: number;
y?: number;
width?: number;
height?: number;
pixelRatio?: number;
mimeType?: string;
quality?: number;
toImage(config?: ImageConfig & {
callback?: (img: HTMLImageElement) => void;
}): Promise<HTMLImageElement>;
toBlob(config?: {
x?: number;
y?: number;
width?: number;
height?: number;
pixelRatio?: number;
mimeType?: string;
quality?: number;
toBlob(config?: ImageConfig & {
callback?: (blob: Blob | null) => void;

@@ -261,5 +349,5 @@ }): Promise<unknown>;

removeName(name: any): this;
setAttr(attr: string, val: any): this;
setAttr<AttrConfig extends Config, K extends AnyString<keyof Config>>(attr: K, val: K extends keyof AttrConfig ? AttrConfig[K] : any): this;
_requestDraw(): void;
_setAttr(key: string, val: any): void;
_setAttr<AttrConfig extends Config, K extends AnyString<keyof Config>>(key: K, val: K extends keyof AttrConfig ? AttrConfig[K] : any): void;
_setComponentAttr(key: any, component: any, val: any): void;

@@ -342,3 +430,3 @@ _fireAndBubble(eventType: any, evt: any, compareShape?: any): void;

}
interface AnimTo extends NodeConfig {
interface AnimTo extends NodeConfig<Record<string, any>> {
onFinish?: Function;

@@ -345,0 +433,0 @@ onUpdate?: Function;

@@ -7,3 +7,3 @@ import type { KonvaEventObject } from './Node.ts';

}
export declare function getCapturedShape(pointerId: number): Shape<import("./Shape.ts").ShapeConfig> | Stage | undefined;
export declare function getCapturedShape(pointerId: number): Shape<import("./Shape.ts").ShapeConfig<{}>> | Stage | undefined;
export declare function createEvent(evt: PointerEvent): KonvaPointerEvent;

@@ -10,0 +10,0 @@ export declare function hasPointerCapture(pointerId: number, shape: Shape | Stage): boolean;

@@ -11,3 +11,3 @@ import type { NodeConfig } from './Node.ts';

export type LineCap = 'butt' | 'round' | 'square';
export interface ShapeConfig extends NodeConfig {
export type ShapeConfig<Props extends Record<string, any> = {}> = NodeConfig<Props> & {
fill?: string | CanvasGradient;

@@ -68,3 +68,3 @@ fillPatternImage?: HTMLImageElement;

perfectDrawEnabled?: boolean;
}
};
export interface ShapeGetClientRectConfig {

@@ -71,0 +71,0 @@ skipTransform?: boolean;

@@ -5,8 +5,8 @@ import type { ShapeConfig } from '../Shape.ts';

import type { Context } from '../Context.ts';
export interface RectConfig extends ShapeConfig {
export type RectConfig<Props extends Record<string, any> = {}> = ShapeConfig<Props> & {
cornerRadius?: number | number[];
}
export declare class Rect extends Shape<RectConfig> {
};
export declare class Rect<Props extends Record<string, any> = {}> extends Shape<RectConfig<Props>> {
_sceneFunc(context: Context): void;
cornerRadius: GetSet<number | number[], this>;
}

@@ -12,3 +12,9 @@ import type { Context } from '../Context.ts';

fontStyle?: string;
fontVariant?: string;
align?: string;
letterSpacing?: number;
textBaseline?: string;
textDecoration?: string;
kerningFunc?: (leftChar: string, rightChar: string) => number;
lineHeight?: number;
}

@@ -25,2 +31,3 @@ export declare class TextPath extends Shape<TextPathConfig> {

p1: Vector2d;
width: number;
}>;

@@ -27,0 +34,0 @@ partialText: string;

@@ -54,3 +54,5 @@ import { Util } from "../Util.js";

const glyphInfo = this.glyphInfo;
if (textDecoration === 'underline') {
const hasUnderline = textDecoration.indexOf('underline') !== -1;
const hasLineThrough = textDecoration.indexOf('line-through') !== -1;
if (hasUnderline) {
context.beginPath();

@@ -65,15 +67,34 @@ }

context.fillStrokeShape(this);
if (textDecoration === 'underline') {
if (hasUnderline) {
if (i === 0) {
context.moveTo(0, fontSize / 2 + 1);
}
context.lineTo(fontSize, fontSize / 2 + 1);
console.log('underline log');
context.lineTo(glyphInfo[i].width, fontSize / 2 + 1);
}
context.restore();
}
if (textDecoration === 'underline') {
if (hasUnderline) {
context.strokeStyle = fill;
context.lineWidth = fontSize / 20;
console.log('underline log');
context.stroke();
}
if (hasLineThrough) {
context.beginPath();
for (let i = 0; i < glyphInfo.length; i++) {
context.save();
const p0 = glyphInfo[i].p0;
context.translate(p0.x, p0.y);
context.rotate(glyphInfo[i].rotation);
if (i === 0) {
context.moveTo(0, 0);
}
context.lineTo(glyphInfo[i].width, 0);
context.restore();
}
context.strokeStyle = fill;
context.lineWidth = fontSize / 20;
context.stroke();
}
context.restore();

@@ -187,2 +208,3 @@ }

p1: charEndPoint,
width: width,
});

@@ -189,0 +211,0 @@ offsetToGlyph += glyphWidth;

@@ -52,7 +52,59 @@ import { Transform } from '../Util.ts';

setNode(node: Node): this;
getNode(): Node<import("../Node.ts").NodeConfig>;
getNode(): Node<{
x?: number;
y?: number;
width?: number;
height?: number;
visible?: boolean;
listening?: boolean;
id?: string;
name?: string;
opacity?: number;
scale?: Vector2d;
scaleX?: number;
skewX?: number;
skewY?: number;
scaleY?: number;
rotation?: number;
rotationDeg?: number;
offset?: Vector2d;
offsetX?: number;
offsetY?: number;
draggable?: boolean;
dragDistance?: number;
dragBoundFunc?: (this: Node, pos: Vector2d) => Vector2d;
preventDefault?: boolean;
globalCompositeOperation?: "" | "source-over" | "source-in" | "source-out" | "source-atop" | "destination-over" | "destination-in" | "destination-out" | "destination-atop" | "lighter" | "copy" | "xor" | "multiply" | "screen" | "overlay" | "darken" | "lighten" | "color-dodge" | "color-burn" | "hard-light" | "soft-light" | "difference" | "exclusion" | "hue" | "saturation" | "color" | "luminosity";
filters?: (string | import("../Node.ts").FilterFunction)[];
}>;
_getEventNamespace(): string;
setNodes(nodes?: Array<Node>): this;
_proxyDrag(node: Node): void;
getNodes(): Node<import("../Node.ts").NodeConfig>[];
getNodes(): Node<{
x?: number;
y?: number;
width?: number;
height?: number;
visible?: boolean;
listening?: boolean;
id?: string;
name?: string;
opacity?: number;
scale?: Vector2d;
scaleX?: number;
skewX?: number;
skewY?: number;
scaleY?: number;
rotation?: number;
rotationDeg?: number;
offset?: Vector2d;
offsetX?: number;
offsetY?: number;
draggable?: boolean;
dragDistance?: number;
dragBoundFunc?: (this: Node, pos: Vector2d) => Vector2d;
preventDefault?: boolean;
globalCompositeOperation?: "" | "source-over" | "source-in" | "source-out" | "source-atop" | "destination-over" | "destination-in" | "destination-out" | "destination-atop" | "lighter" | "copy" | "xor" | "multiply" | "screen" | "overlay" | "darken" | "lighten" | "color-dodge" | "color-burn" | "hard-light" | "soft-light" | "difference" | "exclusion" | "hue" | "saturation" | "color" | "luminosity";
filters?: (string | import("../Node.ts").FilterFunction)[];
}>[];
getActiveAnchor(): string | null;

@@ -59,0 +111,0 @@ detach(): void;

@@ -11,3 +11,3 @@ import type { ContainerConfig } from './Container.ts';

export declare const stages: Stage[];
export declare class Stage extends Container<Layer> {
export declare class Stage extends Container<Layer, StageConfig> {
content: HTMLDivElement;

@@ -53,3 +53,3 @@ pointerPos: Vector2d | null;

_toKonvaCanvas(config: any): SceneCanvas;
getIntersection(pos: Vector2d): Shape<import("./Shape.ts").ShapeConfig> | null;
getIntersection(pos: Vector2d): Shape<import("./Shape.ts").ShapeConfig<{}>> | null;
_resizeDOM(): void;

@@ -66,3 +66,3 @@ add(layer: Layer, ...rest: any[]): this;

_pointerover(evt: any): void;
_getTargetShape(evenType: any): Shape<import("./Shape.ts").ShapeConfig> | null;
_getTargetShape(evenType: any): Shape<import("./Shape.ts").ShapeConfig<{}>> | null;
_pointerleave(evt: any): void;

@@ -69,0 +69,0 @@ _pointerdown(evt: TouchEvent | MouseEvent | PointerEvent): void;

@@ -42,2 +42,5 @@ import { Animation } from './Animation.ts';

export interface TweenConfig extends NodeConfig {
easing?: typeof Easings[keyof typeof Easings];
yoyo?: boolean;
onReset?: Function;
onFinish?: Function;

@@ -44,0 +47,0 @@ onUpdate?: Function;

@@ -133,1 +133,2 @@ import type { Context } from './Context.ts';

};
export type AnyString<T> = T | (string & {});
{
"name": "konva",
"version": "10.0.2",
"version": "10.0.3",
"description": "HTML5 2d canvas library.",

@@ -47,3 +47,3 @@ "author": "Anton Lavrenov",

"test:browser": "npm run test:build && mocha-headless-chrome -f ./test-build/unit-tests.html -a disable-web-security -a no-sandbox -a disable-setuid-sandbox",
"test:watch": "rm -rf ./.parcel-cache && PARCEL_WORKERS=0 parcel serve ./test/unit-tests.html ./test/manual-tests.html ./test/sandbox.html ./test/text-paths.html ./test/bunnies.html",
"test:watch": "rimraf ./.parcel-cache && PARCEL_WORKERS=0 parcel serve ./test/unit-tests.html ./test/manual-tests.html ./test/sandbox.html ./test/text-paths.html ./test/bunnies.html",
"test:node:canvas": "mocha -r tsx -r ./test/node-canvas-global-setup.mjs --extension ts --recursive './test/unit/' --exit",

@@ -54,3 +54,3 @@ "test:node:skia": "mocha -r tsx -r ./test/node-skia-global-setup.mjs --extension ts --recursive './test/unit/' --exit",

"rollup": "rollup -c",
"clean": "rm -rf ./lib && rm -rf ./types && rm -rf ./cmj && rm -rf ./test-build",
"clean": "rimraf ./lib && rimraf ./types && rimraf ./cmj && rimraf ./test-build",
"watch": "rollup -c -w",

@@ -112,2 +112,3 @@ "size": "size-limit"

"process": "^0.11.10",
"rimraf": "^6.0.1",
"rollup": "^4.48.0",

@@ -114,0 +115,0 @@ "rollup-plugin-typescript2": "^0.36.0",

<p align="center">
<img src="https://konvajs.org/android-chrome-192x192.png" alt="Konva logo" height="180" />
<img src="https://konvajs.org/img/icon.png" alt="Konva logo" height="60" />
</p>

@@ -4,0 +4,0 @@

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

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