first commit

This commit is contained in:
Ichitux
2026-04-05 03:08:53 +02:00
commit 1082d36c12
28015 changed files with 3767672 additions and 0 deletions

24
node_modules/konva/lib/Animation.d.ts generated vendored Normal file
View File

@@ -0,0 +1,24 @@
import { Layer } from './Layer.js';
import { IFrame, AnimationFn } from './types.js';
export declare class Animation {
func: AnimationFn;
id: number;
layers: Layer[];
frame: IFrame;
constructor(func: AnimationFn, layers?: any);
setLayers(layers: null | Layer | Layer[]): this;
getLayers(): Layer[];
addLayer(layer: Layer): boolean;
isRunning(): boolean;
start(): this;
stop(): this;
_updateFrameObject(time: number): void;
static animations: Array<Animation>;
static animIdCounter: number;
static animRunning: boolean;
static _addAnimation(anim: any): void;
static _removeAnimation(anim: any): void;
static _runFrames(): void;
static _animationLoop(): void;
static _handleAnimation(): void;
}

146
node_modules/konva/lib/Animation.js generated vendored Normal file
View File

@@ -0,0 +1,146 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Animation = void 0;
const Global_1 = require("./Global");
const Util_1 = require("./Util");
const now = (function () {
if (Global_1.glob.performance && Global_1.glob.performance.now) {
return function () {
return Global_1.glob.performance.now();
};
}
return function () {
return new Date().getTime();
};
})();
class Animation {
constructor(func, layers) {
this.id = Animation.animIdCounter++;
this.frame = {
time: 0,
timeDiff: 0,
lastTime: now(),
frameRate: 0,
};
this.func = func;
this.setLayers(layers);
}
setLayers(layers) {
let lays = [];
if (layers) {
lays = Array.isArray(layers) ? layers : [layers];
}
this.layers = lays;
return this;
}
getLayers() {
return this.layers;
}
addLayer(layer) {
const layers = this.layers;
const len = layers.length;
for (let n = 0; n < len; n++) {
if (layers[n]._id === layer._id) {
return false;
}
}
this.layers.push(layer);
return true;
}
isRunning() {
const a = Animation;
const animations = a.animations;
const len = animations.length;
for (let n = 0; n < len; n++) {
if (animations[n].id === this.id) {
return true;
}
}
return false;
}
start() {
this.stop();
this.frame.timeDiff = 0;
this.frame.lastTime = now();
Animation._addAnimation(this);
return this;
}
stop() {
Animation._removeAnimation(this);
return this;
}
_updateFrameObject(time) {
this.frame.timeDiff = time - this.frame.lastTime;
this.frame.lastTime = time;
this.frame.time += this.frame.timeDiff;
this.frame.frameRate = 1000 / this.frame.timeDiff;
}
static _addAnimation(anim) {
this.animations.push(anim);
this._handleAnimation();
}
static _removeAnimation(anim) {
const id = anim.id;
const animations = this.animations;
const len = animations.length;
for (let n = 0; n < len; n++) {
if (animations[n].id === id) {
this.animations.splice(n, 1);
break;
}
}
}
static _runFrames() {
const layerHash = {};
const animations = this.animations;
for (let n = 0; n < animations.length; n++) {
const anim = animations[n];
const layers = anim.layers;
const func = anim.func;
anim._updateFrameObject(now());
const layersLen = layers.length;
let needRedraw;
if (func) {
needRedraw = func.call(anim, anim.frame) !== false;
}
else {
needRedraw = true;
}
if (!needRedraw) {
continue;
}
for (let i = 0; i < layersLen; i++) {
const layer = layers[i];
if (layer._id !== undefined) {
layerHash[layer._id] = layer;
}
}
}
for (const key in layerHash) {
if (!layerHash.hasOwnProperty(key)) {
continue;
}
layerHash[key].batchDraw();
}
}
static _animationLoop() {
const Anim = Animation;
if (Anim.animations.length) {
Anim._runFrames();
Util_1.Util.requestAnimFrame(Anim._animationLoop);
}
else {
Anim.animRunning = false;
}
}
static _handleAnimation() {
if (!this.animRunning) {
this.animRunning = true;
Util_1.Util.requestAnimFrame(this._animationLoop);
}
}
}
exports.Animation = Animation;
Animation.animations = [];
Animation.animIdCounter = 0;
Animation.animRunning = false;

6
node_modules/konva/lib/BezierFunctions.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
export declare const tValues: number[][];
export declare const cValues: number[][];
export declare const binomialCoefficients: number[][];
export declare const getCubicArcLength: (xs: number[], ys: number[], t: number) => number;
export declare const getQuadraticArcLength: (xs: number[], ys: number[], t: number) => number;
export declare const t2length: (length: number, totalLength: number, func: (t: number) => number) => number;

790
node_modules/konva/lib/BezierFunctions.js generated vendored Normal file
View File

@@ -0,0 +1,790 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.t2length = exports.getQuadraticArcLength = exports.getCubicArcLength = exports.binomialCoefficients = exports.cValues = exports.tValues = void 0;
exports.tValues = [
[],
[],
[
-0.5773502691896257645091487805019574556476,
0.5773502691896257645091487805019574556476,
],
[
0, -0.7745966692414833770358530799564799221665,
0.7745966692414833770358530799564799221665,
],
[
-0.3399810435848562648026657591032446872005,
0.3399810435848562648026657591032446872005,
-0.8611363115940525752239464888928095050957,
0.8611363115940525752239464888928095050957,
],
[
0, -0.5384693101056830910363144207002088049672,
0.5384693101056830910363144207002088049672,
-0.9061798459386639927976268782993929651256,
0.9061798459386639927976268782993929651256,
],
[
0.6612093864662645136613995950199053470064,
-0.6612093864662645136613995950199053470064,
-0.2386191860831969086305017216807119354186,
0.2386191860831969086305017216807119354186,
-0.9324695142031520278123015544939946091347,
0.9324695142031520278123015544939946091347,
],
[
0, 0.4058451513773971669066064120769614633473,
-0.4058451513773971669066064120769614633473,
-0.7415311855993944398638647732807884070741,
0.7415311855993944398638647732807884070741,
-0.9491079123427585245261896840478512624007,
0.9491079123427585245261896840478512624007,
],
[
-0.1834346424956498049394761423601839806667,
0.1834346424956498049394761423601839806667,
-0.5255324099163289858177390491892463490419,
0.5255324099163289858177390491892463490419,
-0.7966664774136267395915539364758304368371,
0.7966664774136267395915539364758304368371,
-0.9602898564975362316835608685694729904282,
0.9602898564975362316835608685694729904282,
],
[
0, -0.8360311073266357942994297880697348765441,
0.8360311073266357942994297880697348765441,
-0.9681602395076260898355762029036728700494,
0.9681602395076260898355762029036728700494,
-0.3242534234038089290385380146433366085719,
0.3242534234038089290385380146433366085719,
-0.6133714327005903973087020393414741847857,
0.6133714327005903973087020393414741847857,
],
[
-0.1488743389816312108848260011297199846175,
0.1488743389816312108848260011297199846175,
-0.4333953941292471907992659431657841622,
0.4333953941292471907992659431657841622,
-0.6794095682990244062343273651148735757692,
0.6794095682990244062343273651148735757692,
-0.8650633666889845107320966884234930485275,
0.8650633666889845107320966884234930485275,
-0.9739065285171717200779640120844520534282,
0.9739065285171717200779640120844520534282,
],
[
0, -0.2695431559523449723315319854008615246796,
0.2695431559523449723315319854008615246796,
-0.5190961292068118159257256694586095544802,
0.5190961292068118159257256694586095544802,
-0.7301520055740493240934162520311534580496,
0.7301520055740493240934162520311534580496,
-0.8870625997680952990751577693039272666316,
0.8870625997680952990751577693039272666316,
-0.9782286581460569928039380011228573907714,
0.9782286581460569928039380011228573907714,
],
[
-0.1252334085114689154724413694638531299833,
0.1252334085114689154724413694638531299833,
-0.3678314989981801937526915366437175612563,
0.3678314989981801937526915366437175612563,
-0.587317954286617447296702418940534280369,
0.587317954286617447296702418940534280369,
-0.7699026741943046870368938332128180759849,
0.7699026741943046870368938332128180759849,
-0.9041172563704748566784658661190961925375,
0.9041172563704748566784658661190961925375,
-0.9815606342467192506905490901492808229601,
0.9815606342467192506905490901492808229601,
],
[
0, -0.2304583159551347940655281210979888352115,
0.2304583159551347940655281210979888352115,
-0.4484927510364468528779128521276398678019,
0.4484927510364468528779128521276398678019,
-0.6423493394403402206439846069955156500716,
0.6423493394403402206439846069955156500716,
-0.8015780907333099127942064895828598903056,
0.8015780907333099127942064895828598903056,
-0.9175983992229779652065478365007195123904,
0.9175983992229779652065478365007195123904,
-0.9841830547185881494728294488071096110649,
0.9841830547185881494728294488071096110649,
],
[
-0.1080549487073436620662446502198347476119,
0.1080549487073436620662446502198347476119,
-0.3191123689278897604356718241684754668342,
0.3191123689278897604356718241684754668342,
-0.5152486363581540919652907185511886623088,
0.5152486363581540919652907185511886623088,
-0.6872929048116854701480198030193341375384,
0.6872929048116854701480198030193341375384,
-0.8272013150697649931897947426503949610397,
0.8272013150697649931897947426503949610397,
-0.928434883663573517336391139377874264477,
0.928434883663573517336391139377874264477,
-0.986283808696812338841597266704052801676,
0.986283808696812338841597266704052801676,
],
[
0, -0.2011940939974345223006283033945962078128,
0.2011940939974345223006283033945962078128,
-0.3941513470775633698972073709810454683627,
0.3941513470775633698972073709810454683627,
-0.5709721726085388475372267372539106412383,
0.5709721726085388475372267372539106412383,
-0.7244177313601700474161860546139380096308,
0.7244177313601700474161860546139380096308,
-0.8482065834104272162006483207742168513662,
0.8482065834104272162006483207742168513662,
-0.9372733924007059043077589477102094712439,
0.9372733924007059043077589477102094712439,
-0.9879925180204854284895657185866125811469,
0.9879925180204854284895657185866125811469,
],
[
-0.0950125098376374401853193354249580631303,
0.0950125098376374401853193354249580631303,
-0.281603550779258913230460501460496106486,
0.281603550779258913230460501460496106486,
-0.45801677765722738634241944298357757354,
0.45801677765722738634241944298357757354,
-0.6178762444026437484466717640487910189918,
0.6178762444026437484466717640487910189918,
-0.7554044083550030338951011948474422683538,
0.7554044083550030338951011948474422683538,
-0.8656312023878317438804678977123931323873,
0.8656312023878317438804678977123931323873,
-0.9445750230732325760779884155346083450911,
0.9445750230732325760779884155346083450911,
-0.9894009349916499325961541734503326274262,
0.9894009349916499325961541734503326274262,
],
[
0, -0.1784841814958478558506774936540655574754,
0.1784841814958478558506774936540655574754,
-0.3512317634538763152971855170953460050405,
0.3512317634538763152971855170953460050405,
-0.5126905370864769678862465686295518745829,
0.5126905370864769678862465686295518745829,
-0.6576711592166907658503022166430023351478,
0.6576711592166907658503022166430023351478,
-0.7815140038968014069252300555204760502239,
0.7815140038968014069252300555204760502239,
-0.8802391537269859021229556944881556926234,
0.8802391537269859021229556944881556926234,
-0.9506755217687677612227169578958030214433,
0.9506755217687677612227169578958030214433,
-0.9905754753144173356754340199406652765077,
0.9905754753144173356754340199406652765077,
],
[
-0.0847750130417353012422618529357838117333,
0.0847750130417353012422618529357838117333,
-0.2518862256915055095889728548779112301628,
0.2518862256915055095889728548779112301628,
-0.4117511614628426460359317938330516370789,
0.4117511614628426460359317938330516370789,
-0.5597708310739475346078715485253291369276,
0.5597708310739475346078715485253291369276,
-0.6916870430603532078748910812888483894522,
0.6916870430603532078748910812888483894522,
-0.8037049589725231156824174550145907971032,
0.8037049589725231156824174550145907971032,
-0.8926024664975557392060605911271455154078,
0.8926024664975557392060605911271455154078,
-0.9558239495713977551811958929297763099728,
0.9558239495713977551811958929297763099728,
-0.9915651684209309467300160047061507702525,
0.9915651684209309467300160047061507702525,
],
[
0, -0.1603586456402253758680961157407435495048,
0.1603586456402253758680961157407435495048,
-0.3165640999636298319901173288498449178922,
0.3165640999636298319901173288498449178922,
-0.4645707413759609457172671481041023679762,
0.4645707413759609457172671481041023679762,
-0.6005453046616810234696381649462392798683,
0.6005453046616810234696381649462392798683,
-0.7209661773352293786170958608237816296571,
0.7209661773352293786170958608237816296571,
-0.8227146565371428249789224867127139017745,
0.8227146565371428249789224867127139017745,
-0.9031559036148179016426609285323124878093,
0.9031559036148179016426609285323124878093,
-0.960208152134830030852778840687651526615,
0.960208152134830030852778840687651526615,
-0.9924068438435844031890176702532604935893,
0.9924068438435844031890176702532604935893,
],
[
-0.0765265211334973337546404093988382110047,
0.0765265211334973337546404093988382110047,
-0.227785851141645078080496195368574624743,
0.227785851141645078080496195368574624743,
-0.3737060887154195606725481770249272373957,
0.3737060887154195606725481770249272373957,
-0.5108670019508270980043640509552509984254,
0.5108670019508270980043640509552509984254,
-0.6360536807265150254528366962262859367433,
0.6360536807265150254528366962262859367433,
-0.7463319064601507926143050703556415903107,
0.7463319064601507926143050703556415903107,
-0.8391169718222188233945290617015206853296,
0.8391169718222188233945290617015206853296,
-0.9122344282513259058677524412032981130491,
0.9122344282513259058677524412032981130491,
-0.963971927277913791267666131197277221912,
0.963971927277913791267666131197277221912,
-0.9931285991850949247861223884713202782226,
0.9931285991850949247861223884713202782226,
],
[
0, -0.1455618541608950909370309823386863301163,
0.1455618541608950909370309823386863301163,
-0.288021316802401096600792516064600319909,
0.288021316802401096600792516064600319909,
-0.4243421202074387835736688885437880520964,
0.4243421202074387835736688885437880520964,
-0.551618835887219807059018796724313286622,
0.551618835887219807059018796724313286622,
-0.667138804197412319305966669990339162597,
0.667138804197412319305966669990339162597,
-0.7684399634756779086158778513062280348209,
0.7684399634756779086158778513062280348209,
-0.8533633645833172836472506385875676702761,
0.8533633645833172836472506385875676702761,
-0.9200993341504008287901871337149688941591,
0.9200993341504008287901871337149688941591,
-0.9672268385663062943166222149076951614246,
0.9672268385663062943166222149076951614246,
-0.9937521706203895002602420359379409291933,
0.9937521706203895002602420359379409291933,
],
[
-0.0697392733197222212138417961186280818222,
0.0697392733197222212138417961186280818222,
-0.2078604266882212854788465339195457342156,
0.2078604266882212854788465339195457342156,
-0.3419358208920842251581474204273796195591,
0.3419358208920842251581474204273796195591,
-0.4693558379867570264063307109664063460953,
0.4693558379867570264063307109664063460953,
-0.5876404035069115929588769276386473488776,
0.5876404035069115929588769276386473488776,
-0.6944872631866827800506898357622567712673,
0.6944872631866827800506898357622567712673,
-0.7878168059792081620042779554083515213881,
0.7878168059792081620042779554083515213881,
-0.8658125777203001365364256370193787290847,
0.8658125777203001365364256370193787290847,
-0.9269567721871740005206929392590531966353,
0.9269567721871740005206929392590531966353,
-0.9700604978354287271239509867652687108059,
0.9700604978354287271239509867652687108059,
-0.994294585482399292073031421161298980393,
0.994294585482399292073031421161298980393,
],
[
0, -0.1332568242984661109317426822417661370104,
0.1332568242984661109317426822417661370104,
-0.264135680970344930533869538283309602979,
0.264135680970344930533869538283309602979,
-0.390301038030290831421488872880605458578,
0.390301038030290831421488872880605458578,
-0.5095014778460075496897930478668464305448,
0.5095014778460075496897930478668464305448,
-0.6196098757636461563850973116495956533871,
0.6196098757636461563850973116495956533871,
-0.7186613631319501944616244837486188483299,
0.7186613631319501944616244837486188483299,
-0.8048884016188398921511184069967785579414,
0.8048884016188398921511184069967785579414,
-0.8767523582704416673781568859341456716389,
0.8767523582704416673781568859341456716389,
-0.9329710868260161023491969890384229782357,
0.9329710868260161023491969890384229782357,
-0.9725424712181152319560240768207773751816,
0.9725424712181152319560240768207773751816,
-0.9947693349975521235239257154455743605736,
0.9947693349975521235239257154455743605736,
],
[
-0.0640568928626056260850430826247450385909,
0.0640568928626056260850430826247450385909,
-0.1911188674736163091586398207570696318404,
0.1911188674736163091586398207570696318404,
-0.3150426796961633743867932913198102407864,
0.3150426796961633743867932913198102407864,
-0.4337935076260451384870842319133497124524,
0.4337935076260451384870842319133497124524,
-0.5454214713888395356583756172183723700107,
0.5454214713888395356583756172183723700107,
-0.6480936519369755692524957869107476266696,
0.6480936519369755692524957869107476266696,
-0.7401241915785543642438281030999784255232,
0.7401241915785543642438281030999784255232,
-0.8200019859739029219539498726697452080761,
0.8200019859739029219539498726697452080761,
-0.8864155270044010342131543419821967550873,
0.8864155270044010342131543419821967550873,
-0.9382745520027327585236490017087214496548,
0.9382745520027327585236490017087214496548,
-0.9747285559713094981983919930081690617411,
0.9747285559713094981983919930081690617411,
-0.9951872199970213601799974097007368118745,
0.9951872199970213601799974097007368118745,
],
];
exports.cValues = [
[],
[],
[1.0, 1.0],
[
0.8888888888888888888888888888888888888888,
0.5555555555555555555555555555555555555555,
0.5555555555555555555555555555555555555555,
],
[
0.6521451548625461426269360507780005927646,
0.6521451548625461426269360507780005927646,
0.3478548451374538573730639492219994072353,
0.3478548451374538573730639492219994072353,
],
[
0.5688888888888888888888888888888888888888,
0.4786286704993664680412915148356381929122,
0.4786286704993664680412915148356381929122,
0.2369268850561890875142640407199173626432,
0.2369268850561890875142640407199173626432,
],
[
0.3607615730481386075698335138377161116615,
0.3607615730481386075698335138377161116615,
0.4679139345726910473898703439895509948116,
0.4679139345726910473898703439895509948116,
0.1713244923791703450402961421727328935268,
0.1713244923791703450402961421727328935268,
],
[
0.4179591836734693877551020408163265306122,
0.3818300505051189449503697754889751338783,
0.3818300505051189449503697754889751338783,
0.2797053914892766679014677714237795824869,
0.2797053914892766679014677714237795824869,
0.1294849661688696932706114326790820183285,
0.1294849661688696932706114326790820183285,
],
[
0.3626837833783619829651504492771956121941,
0.3626837833783619829651504492771956121941,
0.3137066458778872873379622019866013132603,
0.3137066458778872873379622019866013132603,
0.2223810344533744705443559944262408844301,
0.2223810344533744705443559944262408844301,
0.1012285362903762591525313543099621901153,
0.1012285362903762591525313543099621901153,
],
[
0.3302393550012597631645250692869740488788,
0.1806481606948574040584720312429128095143,
0.1806481606948574040584720312429128095143,
0.0812743883615744119718921581105236506756,
0.0812743883615744119718921581105236506756,
0.3123470770400028400686304065844436655987,
0.3123470770400028400686304065844436655987,
0.2606106964029354623187428694186328497718,
0.2606106964029354623187428694186328497718,
],
[
0.295524224714752870173892994651338329421,
0.295524224714752870173892994651338329421,
0.2692667193099963550912269215694693528597,
0.2692667193099963550912269215694693528597,
0.2190863625159820439955349342281631924587,
0.2190863625159820439955349342281631924587,
0.1494513491505805931457763396576973324025,
0.1494513491505805931457763396576973324025,
0.0666713443086881375935688098933317928578,
0.0666713443086881375935688098933317928578,
],
[
0.272925086777900630714483528336342189156,
0.2628045445102466621806888698905091953727,
0.2628045445102466621806888698905091953727,
0.2331937645919904799185237048431751394317,
0.2331937645919904799185237048431751394317,
0.1862902109277342514260976414316558916912,
0.1862902109277342514260976414316558916912,
0.1255803694649046246346942992239401001976,
0.1255803694649046246346942992239401001976,
0.0556685671161736664827537204425485787285,
0.0556685671161736664827537204425485787285,
],
[
0.2491470458134027850005624360429512108304,
0.2491470458134027850005624360429512108304,
0.2334925365383548087608498989248780562594,
0.2334925365383548087608498989248780562594,
0.2031674267230659217490644558097983765065,
0.2031674267230659217490644558097983765065,
0.160078328543346226334652529543359071872,
0.160078328543346226334652529543359071872,
0.1069393259953184309602547181939962242145,
0.1069393259953184309602547181939962242145,
0.047175336386511827194615961485017060317,
0.047175336386511827194615961485017060317,
],
[
0.2325515532308739101945895152688359481566,
0.2262831802628972384120901860397766184347,
0.2262831802628972384120901860397766184347,
0.2078160475368885023125232193060527633865,
0.2078160475368885023125232193060527633865,
0.1781459807619457382800466919960979955128,
0.1781459807619457382800466919960979955128,
0.1388735102197872384636017768688714676218,
0.1388735102197872384636017768688714676218,
0.0921214998377284479144217759537971209236,
0.0921214998377284479144217759537971209236,
0.0404840047653158795200215922009860600419,
0.0404840047653158795200215922009860600419,
],
[
0.2152638534631577901958764433162600352749,
0.2152638534631577901958764433162600352749,
0.2051984637212956039659240656612180557103,
0.2051984637212956039659240656612180557103,
0.1855383974779378137417165901251570362489,
0.1855383974779378137417165901251570362489,
0.1572031671581935345696019386238421566056,
0.1572031671581935345696019386238421566056,
0.1215185706879031846894148090724766259566,
0.1215185706879031846894148090724766259566,
0.0801580871597602098056332770628543095836,
0.0801580871597602098056332770628543095836,
0.0351194603317518630318328761381917806197,
0.0351194603317518630318328761381917806197,
],
[
0.2025782419255612728806201999675193148386,
0.1984314853271115764561183264438393248186,
0.1984314853271115764561183264438393248186,
0.1861610000155622110268005618664228245062,
0.1861610000155622110268005618664228245062,
0.1662692058169939335532008604812088111309,
0.1662692058169939335532008604812088111309,
0.1395706779261543144478047945110283225208,
0.1395706779261543144478047945110283225208,
0.1071592204671719350118695466858693034155,
0.1071592204671719350118695466858693034155,
0.0703660474881081247092674164506673384667,
0.0703660474881081247092674164506673384667,
0.0307532419961172683546283935772044177217,
0.0307532419961172683546283935772044177217,
],
[
0.1894506104550684962853967232082831051469,
0.1894506104550684962853967232082831051469,
0.1826034150449235888667636679692199393835,
0.1826034150449235888667636679692199393835,
0.1691565193950025381893120790303599622116,
0.1691565193950025381893120790303599622116,
0.1495959888165767320815017305474785489704,
0.1495959888165767320815017305474785489704,
0.1246289712555338720524762821920164201448,
0.1246289712555338720524762821920164201448,
0.0951585116824927848099251076022462263552,
0.0951585116824927848099251076022462263552,
0.0622535239386478928628438369943776942749,
0.0622535239386478928628438369943776942749,
0.0271524594117540948517805724560181035122,
0.0271524594117540948517805724560181035122,
],
[
0.1794464703562065254582656442618856214487,
0.1765627053669926463252709901131972391509,
0.1765627053669926463252709901131972391509,
0.1680041021564500445099706637883231550211,
0.1680041021564500445099706637883231550211,
0.1540457610768102880814315948019586119404,
0.1540457610768102880814315948019586119404,
0.1351363684685254732863199817023501973721,
0.1351363684685254732863199817023501973721,
0.1118838471934039710947883856263559267358,
0.1118838471934039710947883856263559267358,
0.0850361483171791808835353701910620738504,
0.0850361483171791808835353701910620738504,
0.0554595293739872011294401653582446605128,
0.0554595293739872011294401653582446605128,
0.0241483028685479319601100262875653246916,
0.0241483028685479319601100262875653246916,
],
[
0.1691423829631435918406564701349866103341,
0.1691423829631435918406564701349866103341,
0.1642764837458327229860537764659275904123,
0.1642764837458327229860537764659275904123,
0.1546846751262652449254180038363747721932,
0.1546846751262652449254180038363747721932,
0.1406429146706506512047313037519472280955,
0.1406429146706506512047313037519472280955,
0.1225552067114784601845191268002015552281,
0.1225552067114784601845191268002015552281,
0.1009420441062871655628139849248346070628,
0.1009420441062871655628139849248346070628,
0.0764257302548890565291296776166365256053,
0.0764257302548890565291296776166365256053,
0.0497145488949697964533349462026386416808,
0.0497145488949697964533349462026386416808,
0.0216160135264833103133427102664524693876,
0.0216160135264833103133427102664524693876,
],
[
0.1610544498487836959791636253209167350399,
0.1589688433939543476499564394650472016787,
0.1589688433939543476499564394650472016787,
0.152766042065859666778855400897662998461,
0.152766042065859666778855400897662998461,
0.1426067021736066117757461094419029724756,
0.1426067021736066117757461094419029724756,
0.1287539625393362276755157848568771170558,
0.1287539625393362276755157848568771170558,
0.1115666455473339947160239016817659974813,
0.1115666455473339947160239016817659974813,
0.0914900216224499994644620941238396526609,
0.0914900216224499994644620941238396526609,
0.0690445427376412265807082580060130449618,
0.0690445427376412265807082580060130449618,
0.0448142267656996003328381574019942119517,
0.0448142267656996003328381574019942119517,
0.0194617882297264770363120414644384357529,
0.0194617882297264770363120414644384357529,
],
[
0.1527533871307258506980843319550975934919,
0.1527533871307258506980843319550975934919,
0.1491729864726037467878287370019694366926,
0.1491729864726037467878287370019694366926,
0.1420961093183820513292983250671649330345,
0.1420961093183820513292983250671649330345,
0.1316886384491766268984944997481631349161,
0.1316886384491766268984944997481631349161,
0.118194531961518417312377377711382287005,
0.118194531961518417312377377711382287005,
0.1019301198172404350367501354803498761666,
0.1019301198172404350367501354803498761666,
0.0832767415767047487247581432220462061001,
0.0832767415767047487247581432220462061001,
0.0626720483341090635695065351870416063516,
0.0626720483341090635695065351870416063516,
0.040601429800386941331039952274932109879,
0.040601429800386941331039952274932109879,
0.0176140071391521183118619623518528163621,
0.0176140071391521183118619623518528163621,
],
[
0.1460811336496904271919851476833711882448,
0.1445244039899700590638271665537525436099,
0.1445244039899700590638271665537525436099,
0.1398873947910731547221334238675831108927,
0.1398873947910731547221334238675831108927,
0.132268938633337461781052574496775604329,
0.132268938633337461781052574496775604329,
0.1218314160537285341953671771257335983563,
0.1218314160537285341953671771257335983563,
0.1087972991671483776634745780701056420336,
0.1087972991671483776634745780701056420336,
0.0934444234560338615532897411139320884835,
0.0934444234560338615532897411139320884835,
0.0761001136283793020170516533001831792261,
0.0761001136283793020170516533001831792261,
0.0571344254268572082836358264724479574912,
0.0571344254268572082836358264724479574912,
0.0369537897708524937999506682993296661889,
0.0369537897708524937999506682993296661889,
0.0160172282577743333242246168584710152658,
0.0160172282577743333242246168584710152658,
],
[
0.1392518728556319933754102483418099578739,
0.1392518728556319933754102483418099578739,
0.1365414983460151713525738312315173965863,
0.1365414983460151713525738312315173965863,
0.1311735047870623707329649925303074458757,
0.1311735047870623707329649925303074458757,
0.1232523768105124242855609861548144719594,
0.1232523768105124242855609861548144719594,
0.1129322960805392183934006074217843191142,
0.1129322960805392183934006074217843191142,
0.1004141444428809649320788378305362823508,
0.1004141444428809649320788378305362823508,
0.0859416062170677274144436813727028661891,
0.0859416062170677274144436813727028661891,
0.0697964684245204880949614189302176573987,
0.0697964684245204880949614189302176573987,
0.0522933351526832859403120512732112561121,
0.0522933351526832859403120512732112561121,
0.0337749015848141547933022468659129013491,
0.0337749015848141547933022468659129013491,
0.0146279952982722006849910980471854451902,
0.0146279952982722006849910980471854451902,
],
[
0.1336545721861061753514571105458443385831,
0.132462039404696617371642464703316925805,
0.132462039404696617371642464703316925805,
0.1289057221880821499785953393997936532597,
0.1289057221880821499785953393997936532597,
0.1230490843067295304675784006720096548158,
0.1230490843067295304675784006720096548158,
0.1149966402224113649416435129339613014914,
0.1149966402224113649416435129339613014914,
0.1048920914645414100740861850147438548584,
0.1048920914645414100740861850147438548584,
0.0929157660600351474770186173697646486034,
0.0929157660600351474770186173697646486034,
0.0792814117767189549228925247420432269137,
0.0792814117767189549228925247420432269137,
0.0642324214085258521271696151589109980391,
0.0642324214085258521271696151589109980391,
0.0480376717310846685716410716320339965612,
0.0480376717310846685716410716320339965612,
0.0309880058569794443106942196418845053837,
0.0309880058569794443106942196418845053837,
0.0134118594871417720813094934586150649766,
0.0134118594871417720813094934586150649766,
],
[
0.1279381953467521569740561652246953718517,
0.1279381953467521569740561652246953718517,
0.1258374563468282961213753825111836887264,
0.1258374563468282961213753825111836887264,
0.121670472927803391204463153476262425607,
0.121670472927803391204463153476262425607,
0.1155056680537256013533444839067835598622,
0.1155056680537256013533444839067835598622,
0.1074442701159656347825773424466062227946,
0.1074442701159656347825773424466062227946,
0.0976186521041138882698806644642471544279,
0.0976186521041138882698806644642471544279,
0.086190161531953275917185202983742667185,
0.086190161531953275917185202983742667185,
0.0733464814110803057340336152531165181193,
0.0733464814110803057340336152531165181193,
0.0592985849154367807463677585001085845412,
0.0592985849154367807463677585001085845412,
0.0442774388174198061686027482113382288593,
0.0442774388174198061686027482113382288593,
0.0285313886289336631813078159518782864491,
0.0285313886289336631813078159518782864491,
0.0123412297999871995468056670700372915759,
0.0123412297999871995468056670700372915759,
],
];
exports.binomialCoefficients = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]];
const getCubicArcLength = (xs, ys, t) => {
let sum;
let correctedT;
const n = 20;
const z = t / 2;
sum = 0;
for (let i = 0; i < n; i++) {
correctedT = z * exports.tValues[n][i] + z;
sum += exports.cValues[n][i] * BFunc(xs, ys, correctedT);
}
return z * sum;
};
exports.getCubicArcLength = getCubicArcLength;
const getQuadraticArcLength = (xs, ys, t) => {
if (t === undefined) {
t = 1;
}
const ax = xs[0] - 2 * xs[1] + xs[2];
const ay = ys[0] - 2 * ys[1] + ys[2];
const bx = 2 * xs[1] - 2 * xs[0];
const by = 2 * ys[1] - 2 * ys[0];
const A = 4 * (ax * ax + ay * ay);
const B = 4 * (ax * bx + ay * by);
const C = bx * bx + by * by;
if (A === 0) {
return (t * Math.sqrt(Math.pow(xs[2] - xs[0], 2) + Math.pow(ys[2] - ys[0], 2)));
}
const b = B / (2 * A);
const c = C / A;
const u = t + b;
const k = c - b * b;
const uuk = u * u + k > 0 ? Math.sqrt(u * u + k) : 0;
const bbk = b * b + k > 0 ? Math.sqrt(b * b + k) : 0;
const term = b + Math.sqrt(b * b + k) !== 0
? k * Math.log(Math.abs((u + uuk) / (b + bbk)))
: 0;
return (Math.sqrt(A) / 2) * (u * uuk - b * bbk + term);
};
exports.getQuadraticArcLength = getQuadraticArcLength;
function BFunc(xs, ys, t) {
const xbase = getDerivative(1, t, xs);
const ybase = getDerivative(1, t, ys);
const combined = xbase * xbase + ybase * ybase;
return Math.sqrt(combined);
}
const getDerivative = (derivative, t, vs) => {
const n = vs.length - 1;
let _vs;
let value;
if (n === 0) {
return 0;
}
if (derivative === 0) {
value = 0;
for (let k = 0; k <= n; k++) {
value +=
exports.binomialCoefficients[n][k] *
Math.pow(1 - t, n - k) *
Math.pow(t, k) *
vs[k];
}
return value;
}
else {
_vs = new Array(n);
for (let k = 0; k < n; k++) {
_vs[k] = n * (vs[k + 1] - vs[k]);
}
return getDerivative(derivative - 1, t, _vs);
}
};
const t2length = (length, totalLength, func) => {
let error = 1;
let t = length / totalLength;
let step = (length - func(t)) / totalLength;
let numIterations = 0;
while (error > 0.001) {
const increasedTLength = func(t + step);
const increasedTError = Math.abs(length - increasedTLength) / totalLength;
if (increasedTError < error) {
error = increasedTError;
t += step;
}
else {
const decreasedTLength = func(t - step);
const decreasedTError = Math.abs(length - decreasedTLength) / totalLength;
if (decreasedTError < error) {
error = decreasedTError;
t -= step;
}
else {
step /= 2;
}
}
numIterations++;
if (numIterations > 500) {
break;
}
}
return t;
};
exports.t2length = t2length;

33
node_modules/konva/lib/Canvas.d.ts generated vendored Normal file
View File

@@ -0,0 +1,33 @@
import { Context } from './Context.js';
interface ICanvasConfig {
width?: number;
height?: number;
pixelRatio?: number;
willReadFrequently?: boolean;
}
export declare class Canvas {
pixelRatio: number;
_canvas: HTMLCanvasElement;
context: Context;
width: number;
height: number;
isCache: boolean;
constructor(config: ICanvasConfig);
getContext(): Context;
getPixelRatio(): number;
setPixelRatio(pixelRatio: any): void;
setWidth(width: any): void;
setHeight(height: any): void;
getWidth(): number;
getHeight(): number;
setSize(width: any, height: any): void;
toDataURL(mimeType: any, quality: any): string;
}
export declare class SceneCanvas extends Canvas {
constructor(config?: ICanvasConfig);
}
export declare class HitCanvas extends Canvas {
hitCanvas: boolean;
constructor(config?: ICanvasConfig);
}
export {};

113
node_modules/konva/lib/Canvas.js generated vendored Normal file
View File

@@ -0,0 +1,113 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HitCanvas = exports.SceneCanvas = exports.Canvas = void 0;
const Util_1 = require("./Util");
const Context_1 = require("./Context");
const Global_1 = require("./Global");
let _pixelRatio;
function getDevicePixelRatio() {
if (_pixelRatio) {
return _pixelRatio;
}
const canvas = Util_1.Util.createCanvasElement();
const context = canvas.getContext('2d');
_pixelRatio = (function () {
const devicePixelRatio = Global_1.Konva._global.devicePixelRatio || 1, backingStoreRatio = context.webkitBackingStorePixelRatio ||
context.mozBackingStorePixelRatio ||
context.msBackingStorePixelRatio ||
context.oBackingStorePixelRatio ||
context.backingStorePixelRatio ||
1;
return devicePixelRatio / backingStoreRatio;
})();
Util_1.Util.releaseCanvas(canvas);
return _pixelRatio;
}
class Canvas {
constructor(config) {
this.pixelRatio = 1;
this.width = 0;
this.height = 0;
this.isCache = false;
const conf = config || {};
const pixelRatio = conf.pixelRatio || Global_1.Konva.pixelRatio || getDevicePixelRatio();
this.pixelRatio = pixelRatio;
this._canvas = Util_1.Util.createCanvasElement();
this._canvas.style.padding = '0';
this._canvas.style.margin = '0';
this._canvas.style.border = '0';
this._canvas.style.background = 'transparent';
this._canvas.style.position = 'absolute';
this._canvas.style.top = '0';
this._canvas.style.left = '0';
}
getContext() {
return this.context;
}
getPixelRatio() {
return this.pixelRatio;
}
setPixelRatio(pixelRatio) {
const previousRatio = this.pixelRatio;
this.pixelRatio = pixelRatio;
this.setSize(this.getWidth() / previousRatio, this.getHeight() / previousRatio);
}
setWidth(width) {
this.width = this._canvas.width = width * this.pixelRatio;
this._canvas.style.width = width + 'px';
const pixelRatio = this.pixelRatio, _context = this.getContext()._context;
_context.scale(pixelRatio, pixelRatio);
}
setHeight(height) {
this.height = this._canvas.height = height * this.pixelRatio;
this._canvas.style.height = height + 'px';
const pixelRatio = this.pixelRatio, _context = this.getContext()._context;
_context.scale(pixelRatio, pixelRatio);
}
getWidth() {
return this.width;
}
getHeight() {
return this.height;
}
setSize(width, height) {
this.setWidth(width || 0);
this.setHeight(height || 0);
}
toDataURL(mimeType, quality) {
try {
return this._canvas.toDataURL(mimeType, quality);
}
catch (e) {
try {
return this._canvas.toDataURL();
}
catch (err) {
Util_1.Util.error('Unable to get data URL. ' +
err.message +
' For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html.');
return '';
}
}
}
}
exports.Canvas = Canvas;
class SceneCanvas extends Canvas {
constructor(config = { width: 0, height: 0, willReadFrequently: false }) {
super(config);
this.context = new Context_1.SceneContext(this, {
willReadFrequently: config.willReadFrequently,
});
this.setSize(config.width, config.height);
}
}
exports.SceneCanvas = SceneCanvas;
class HitCanvas extends Canvas {
constructor(config = { width: 0, height: 0 }) {
super(config);
this.hitCanvas = true;
this.context = new Context_1.HitContext(this);
this.setSize(config.width, config.height);
}
}
exports.HitCanvas = HitCanvas;

53
node_modules/konva/lib/Container.d.ts generated vendored Normal file
View File

@@ -0,0 +1,53 @@
import { HitCanvas, SceneCanvas } from './Canvas.js';
import { SceneContext } from './Context.js';
import { Node, NodeConfig } from './Node.js';
import { Shape } from './Shape.js';
import { GetSet, IRect } from './types.js';
export type ClipFuncOutput = void | [Path2D | CanvasFillRule] | [Path2D, CanvasFillRule];
export interface ContainerConfig extends NodeConfig {
clearBeforeDraw?: boolean;
clipFunc?: (ctx: SceneContext) => ClipFuncOutput;
clipX?: number;
clipY?: number;
clipWidth?: number;
clipHeight?: number;
}
export declare abstract class Container<ChildType extends Node = Node> extends Node<ContainerConfig> {
children: Array<ChildType>;
getChildren(filterFunc?: (item: Node) => boolean): ChildType[];
hasChildren(): boolean;
removeChildren(): this;
destroyChildren(): this;
abstract _validateAdd(node: Node): void;
add(...children: ChildType[]): this;
destroy(): this;
find<ChildNode extends Node>(selector: any): Array<ChildNode>;
findOne<ChildNode extends Node = Node>(selector: string | Function): ChildNode | undefined;
_generalFind<ChildNode extends Node>(selector: string | Function, findOne: boolean): ChildNode[];
private _descendants;
toObject(): {
attrs: any;
className: string;
children?: Array<any>;
};
isAncestorOf(node: Node): boolean;
clone(obj?: any): this;
getAllIntersections(pos: any): Shape<import("./Shape.js").ShapeConfig>[];
_clearSelfAndDescendantCache(attr?: string): void;
_setChildrenIndices(): void;
drawScene(can?: SceneCanvas, top?: Node, bufferCanvas?: SceneCanvas): this;
drawHit(can?: HitCanvas, top?: Node): this;
_drawChildren(drawMethod: any, canvas: any, top: any, bufferCanvas?: any): void;
getClientRect(config?: {
skipTransform?: boolean;
skipShadow?: boolean;
skipStroke?: boolean;
relativeTo?: Container<Node>;
}): IRect;
clip: GetSet<IRect, this>;
clipX: GetSet<number, this>;
clipY: GetSet<number, this>;
clipWidth: GetSet<number, this>;
clipHeight: GetSet<number, this>;
clipFunc: GetSet<(ctx: CanvasRenderingContext2D, shape: Container) => ClipFuncOutput, this>;
}

320
node_modules/konva/lib/Container.js generated vendored Normal file
View File

@@ -0,0 +1,320 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Container = void 0;
const Factory_1 = require("./Factory");
const Node_1 = require("./Node");
const Validators_1 = require("./Validators");
class Container extends Node_1.Node {
constructor() {
super(...arguments);
this.children = [];
}
getChildren(filterFunc) {
const children = this.children || [];
if (filterFunc) {
return children.filter(filterFunc);
}
return children;
}
hasChildren() {
return this.getChildren().length > 0;
}
removeChildren() {
this.getChildren().forEach((child) => {
child.parent = null;
child.index = 0;
child.remove();
});
this.children = [];
this._requestDraw();
return this;
}
destroyChildren() {
this.getChildren().forEach((child) => {
child.parent = null;
child.index = 0;
child.destroy();
});
this.children = [];
this._requestDraw();
return this;
}
add(...children) {
if (children.length === 0) {
return this;
}
if (children.length > 1) {
for (let i = 0; i < children.length; i++) {
this.add(children[i]);
}
return this;
}
const child = children[0];
if (child.getParent()) {
child.moveTo(this);
return this;
}
this._validateAdd(child);
child.index = this.getChildren().length;
child.parent = this;
child._clearCaches();
this.getChildren().push(child);
this._fire('add', {
child: child,
});
this._requestDraw();
return this;
}
destroy() {
if (this.hasChildren()) {
this.destroyChildren();
}
super.destroy();
return this;
}
find(selector) {
return this._generalFind(selector, false);
}
findOne(selector) {
const result = this._generalFind(selector, true);
return result.length > 0 ? result[0] : undefined;
}
_generalFind(selector, findOne) {
const retArr = [];
this._descendants((node) => {
const valid = node._isMatch(selector);
if (valid) {
retArr.push(node);
}
if (valid && findOne) {
return true;
}
return false;
});
return retArr;
}
_descendants(fn) {
let shouldStop = false;
const children = this.getChildren();
for (const child of children) {
shouldStop = fn(child);
if (shouldStop) {
return true;
}
if (!child.hasChildren()) {
continue;
}
shouldStop = child._descendants(fn);
if (shouldStop) {
return true;
}
}
return false;
}
toObject() {
const obj = Node_1.Node.prototype.toObject.call(this);
obj.children = [];
this.getChildren().forEach((child) => {
obj.children.push(child.toObject());
});
return obj;
}
isAncestorOf(node) {
let parent = node.getParent();
while (parent) {
if (parent._id === this._id) {
return true;
}
parent = parent.getParent();
}
return false;
}
clone(obj) {
const node = Node_1.Node.prototype.clone.call(this, obj);
this.getChildren().forEach(function (no) {
node.add(no.clone());
});
return node;
}
getAllIntersections(pos) {
const arr = [];
this.find('Shape').forEach((shape) => {
if (shape.isVisible() && shape.intersects(pos)) {
arr.push(shape);
}
});
return arr;
}
_clearSelfAndDescendantCache(attr) {
var _a;
super._clearSelfAndDescendantCache(attr);
if (this.isCached()) {
return;
}
(_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (node) {
node._clearSelfAndDescendantCache(attr);
});
}
_setChildrenIndices() {
var _a;
(_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child, n) {
child.index = n;
});
this._requestDraw();
}
drawScene(can, top, bufferCanvas) {
const layer = this.getLayer(), canvas = can || (layer && layer.getCanvas()), context = canvas && canvas.getContext(), cachedCanvas = this._getCanvasCache(), cachedSceneCanvas = cachedCanvas && cachedCanvas.scene;
const caching = canvas && canvas.isCache;
if (!this.isVisible() && !caching) {
return this;
}
if (cachedSceneCanvas) {
context.save();
const m = this.getAbsoluteTransform(top).getMatrix();
context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
this._drawCachedSceneCanvas(context);
context.restore();
}
else {
this._drawChildren('drawScene', canvas, top, bufferCanvas);
}
return this;
}
drawHit(can, top) {
if (!this.shouldDrawHit(top)) {
return this;
}
const layer = this.getLayer(), canvas = can || (layer && layer.hitCanvas), context = canvas && canvas.getContext(), cachedCanvas = this._getCanvasCache(), cachedHitCanvas = cachedCanvas && cachedCanvas.hit;
if (cachedHitCanvas) {
context.save();
const m = this.getAbsoluteTransform(top).getMatrix();
context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
this._drawCachedHitCanvas(context);
context.restore();
}
else {
this._drawChildren('drawHit', canvas, top);
}
return this;
}
_drawChildren(drawMethod, canvas, top, bufferCanvas) {
var _a;
const context = canvas && canvas.getContext(), clipWidth = this.clipWidth(), clipHeight = this.clipHeight(), clipFunc = this.clipFunc(), hasClip = (typeof clipWidth === 'number' && typeof clipHeight === 'number') ||
clipFunc;
const selfCache = top === this;
if (hasClip) {
context.save();
const transform = this.getAbsoluteTransform(top);
let m = transform.getMatrix();
context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
context.beginPath();
let clipArgs;
if (clipFunc) {
clipArgs = clipFunc.call(this, context, this);
}
else {
const clipX = this.clipX();
const clipY = this.clipY();
context.rect(clipX || 0, clipY || 0, clipWidth, clipHeight);
}
context.clip.apply(context, clipArgs);
m = transform.copy().invert().getMatrix();
context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
}
const hasComposition = !selfCache &&
this.globalCompositeOperation() !== 'source-over' &&
drawMethod === 'drawScene';
if (hasComposition) {
context.save();
context._applyGlobalCompositeOperation(this);
}
(_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
child[drawMethod](canvas, top, bufferCanvas);
});
if (hasComposition) {
context.restore();
}
if (hasClip) {
context.restore();
}
}
getClientRect(config = {}) {
var _a;
const skipTransform = config.skipTransform;
const relativeTo = config.relativeTo;
let minX, minY, maxX, maxY;
let selfRect = {
x: Infinity,
y: Infinity,
width: 0,
height: 0,
};
const that = this;
(_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child) {
if (!child.visible()) {
return;
}
const rect = child.getClientRect({
relativeTo: that,
skipShadow: config.skipShadow,
skipStroke: config.skipStroke,
});
if (rect.width === 0 && rect.height === 0) {
return;
}
if (minX === undefined) {
minX = rect.x;
minY = rect.y;
maxX = rect.x + rect.width;
maxY = rect.y + rect.height;
}
else {
minX = Math.min(minX, rect.x);
minY = Math.min(minY, rect.y);
maxX = Math.max(maxX, rect.x + rect.width);
maxY = Math.max(maxY, rect.y + rect.height);
}
});
const shapes = this.find('Shape');
let hasVisible = false;
for (let i = 0; i < shapes.length; i++) {
const shape = shapes[i];
if (shape._isVisible(this)) {
hasVisible = true;
break;
}
}
if (hasVisible && minX !== undefined) {
selfRect = {
x: minX,
y: minY,
width: maxX - minX,
height: maxY - minY,
};
}
else {
selfRect = {
x: 0,
y: 0,
width: 0,
height: 0,
};
}
if (!skipTransform) {
return this._transformedRect(selfRect, relativeTo);
}
return selfRect;
}
}
exports.Container = Container;
Factory_1.Factory.addComponentsGetterSetter(Container, 'clip', [
'x',
'y',
'width',
'height',
]);
Factory_1.Factory.addGetterSetter(Container, 'clipX', undefined, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Container, 'clipY', undefined, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Container, 'clipWidth', undefined, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Container, 'clipHeight', undefined, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Container, 'clipFunc');

93
node_modules/konva/lib/Context.d.ts generated vendored Normal file
View File

@@ -0,0 +1,93 @@
import { Canvas } from './Canvas.js';
import { Shape } from './Shape.js';
import { IRect } from './types.js';
import type { Node } from './Node.js';
declare const CONTEXT_PROPERTIES: readonly ["fillStyle", "strokeStyle", "shadowColor", "shadowBlur", "shadowOffsetX", "shadowOffsetY", "letterSpacing", "lineCap", "lineDashOffset", "lineJoin", "lineWidth", "miterLimit", "direction", "font", "textAlign", "textBaseline", "globalAlpha", "globalCompositeOperation", "imageSmoothingEnabled"];
interface ExtendedCanvasRenderingContext2D extends CanvasRenderingContext2D {
letterSpacing: string;
}
export declare class Context {
canvas: Canvas;
_context: CanvasRenderingContext2D;
traceArr: Array<string>;
constructor(canvas: Canvas);
fillShape(shape: Shape): void;
_fill(shape: Shape): void;
strokeShape(shape: Shape): void;
_stroke(shape: Shape): void;
fillStrokeShape(shape: Shape): void;
getTrace(relaxed?: boolean, rounded?: boolean): string;
clearTrace(): void;
_trace(str: any): void;
reset(): void;
getCanvas(): Canvas;
clear(bounds?: IRect): void;
_applyLineCap(shape: Shape): void;
_applyOpacity(shape: Node): void;
_applyLineJoin(shape: Shape): void;
setAttr(attr: string, val: any): void;
arc(x: number, y: number, radius: number, startAngle: number, endAngle: number, counterClockwise?: boolean): void;
arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
beginPath(): void;
bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
clearRect(x: number, y: number, width: number, height: number): void;
clip(fillRule?: CanvasFillRule): void;
clip(path: Path2D, fillRule?: CanvasFillRule): void;
closePath(): void;
createImageData(width: any, height: any): ImageData | undefined;
createLinearGradient(x0: number, y0: number, x1: number, y1: number): CanvasGradient;
createPattern(image: CanvasImageSource, repetition: string | null): CanvasPattern | null;
createRadialGradient(x0: number, y0: number, r0: number, x1: number, y1: number, r1: number): CanvasGradient;
drawImage(image: CanvasImageSource, sx: number, sy: number, sWidth?: number, sHeight?: number, dx?: number, dy?: number, dWidth?: number, dHeight?: number): void;
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
isPointInPath(x: number, y: number, path?: Path2D, fillRule?: CanvasFillRule): boolean;
fill(fillRule?: CanvasFillRule): void;
fill(path: Path2D, fillRule?: CanvasFillRule): void;
fillRect(x: number, y: number, width: number, height: number): void;
strokeRect(x: number, y: number, width: number, height: number): void;
fillText(text: string, x: number, y: number, maxWidth?: number): void;
measureText(text: string): TextMetrics;
getImageData(sx: number, sy: number, sw: number, sh: number): ImageData;
lineTo(x: number, y: number): void;
moveTo(x: number, y: number): void;
rect(x: number, y: number, width: number, height: number): void;
roundRect(x: number, y: number, width: number, height: number, radii: number | DOMPointInit | (number | DOMPointInit)[]): void;
putImageData(imageData: ImageData, dx: number, dy: number): void;
quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
restore(): void;
rotate(angle: number): void;
save(): void;
scale(x: number, y: number): void;
setLineDash(segments: number[]): void;
getLineDash(): number[];
setTransform(a: number, b: number, c: number, d: number, e: number, f: number): void;
stroke(path2d?: Path2D): void;
strokeText(text: string, x: number, y: number, maxWidth?: number): void;
transform(a: number, b: number, c: number, d: number, e: number, f: number): void;
translate(x: number, y: number): void;
_enableTrace(): void;
_applyGlobalCompositeOperation(node: any): void;
}
type CanvasContextProps = Pick<ExtendedCanvasRenderingContext2D, (typeof CONTEXT_PROPERTIES)[number]>;
export interface Context extends CanvasContextProps {
}
export declare class SceneContext extends Context {
constructor(canvas: Canvas, { willReadFrequently }?: {
willReadFrequently?: boolean | undefined;
});
_fillColor(shape: Shape): void;
_fillPattern(shape: Shape): void;
_fillLinearGradient(shape: Shape): void;
_fillRadialGradient(shape: Shape): void;
_fill(shape: any): void;
_strokeLinearGradient(shape: any): void;
_stroke(shape: any): void;
_applyShadow(shape: any): void;
}
export declare class HitContext extends Context {
constructor(canvas: Canvas);
_fill(shape: Shape): void;
strokeShape(shape: Shape): void;
_stroke(shape: any): void;
}
export {};

541
node_modules/konva/lib/Context.js generated vendored Normal file
View File

@@ -0,0 +1,541 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HitContext = exports.SceneContext = exports.Context = void 0;
const Util_1 = require("./Util");
const Global_1 = require("./Global");
function simplifyArray(arr) {
const retArr = [], len = arr.length, util = Util_1.Util;
for (let n = 0; n < len; n++) {
let val = arr[n];
if (util._isNumber(val)) {
val = Math.round(val * 1000) / 1000;
}
else if (!util._isString(val)) {
val = val + '';
}
retArr.push(val);
}
return retArr;
}
const COMMA = ',', OPEN_PAREN = '(', CLOSE_PAREN = ')', OPEN_PAREN_BRACKET = '([', CLOSE_BRACKET_PAREN = '])', SEMICOLON = ';', DOUBLE_PAREN = '()', EQUALS = '=', CONTEXT_METHODS = [
'arc',
'arcTo',
'beginPath',
'bezierCurveTo',
'clearRect',
'clip',
'closePath',
'createLinearGradient',
'createPattern',
'createRadialGradient',
'drawImage',
'ellipse',
'fill',
'fillText',
'getImageData',
'createImageData',
'lineTo',
'moveTo',
'putImageData',
'quadraticCurveTo',
'rect',
'roundRect',
'restore',
'rotate',
'save',
'scale',
'setLineDash',
'setTransform',
'stroke',
'strokeText',
'transform',
'translate',
];
const CONTEXT_PROPERTIES = [
'fillStyle',
'strokeStyle',
'shadowColor',
'shadowBlur',
'shadowOffsetX',
'shadowOffsetY',
'letterSpacing',
'lineCap',
'lineDashOffset',
'lineJoin',
'lineWidth',
'miterLimit',
'direction',
'font',
'textAlign',
'textBaseline',
'globalAlpha',
'globalCompositeOperation',
'imageSmoothingEnabled',
];
const traceArrMax = 100;
class Context {
constructor(canvas) {
this.canvas = canvas;
if (Global_1.Konva.enableTrace) {
this.traceArr = [];
this._enableTrace();
}
}
fillShape(shape) {
if (shape.fillEnabled()) {
this._fill(shape);
}
}
_fill(shape) {
}
strokeShape(shape) {
if (shape.hasStroke()) {
this._stroke(shape);
}
}
_stroke(shape) {
}
fillStrokeShape(shape) {
if (shape.attrs.fillAfterStrokeEnabled) {
this.strokeShape(shape);
this.fillShape(shape);
}
else {
this.fillShape(shape);
this.strokeShape(shape);
}
}
getTrace(relaxed, rounded) {
let traceArr = this.traceArr, len = traceArr.length, str = '', n, trace, method, args;
for (n = 0; n < len; n++) {
trace = traceArr[n];
method = trace.method;
if (method) {
args = trace.args;
str += method;
if (relaxed) {
str += DOUBLE_PAREN;
}
else {
if (Util_1.Util._isArray(args[0])) {
str += OPEN_PAREN_BRACKET + args.join(COMMA) + CLOSE_BRACKET_PAREN;
}
else {
if (rounded) {
args = args.map((a) => typeof a === 'number' ? Math.floor(a) : a);
}
str += OPEN_PAREN + args.join(COMMA) + CLOSE_PAREN;
}
}
}
else {
str += trace.property;
if (!relaxed) {
str += EQUALS + trace.val;
}
}
str += SEMICOLON;
}
return str;
}
clearTrace() {
this.traceArr = [];
}
_trace(str) {
let traceArr = this.traceArr, len;
traceArr.push(str);
len = traceArr.length;
if (len >= traceArrMax) {
traceArr.shift();
}
}
reset() {
const pixelRatio = this.getCanvas().getPixelRatio();
this.setTransform(1 * pixelRatio, 0, 0, 1 * pixelRatio, 0, 0);
}
getCanvas() {
return this.canvas;
}
clear(bounds) {
const canvas = this.getCanvas();
if (bounds) {
this.clearRect(bounds.x || 0, bounds.y || 0, bounds.width || 0, bounds.height || 0);
}
else {
this.clearRect(0, 0, canvas.getWidth() / canvas.pixelRatio, canvas.getHeight() / canvas.pixelRatio);
}
}
_applyLineCap(shape) {
const lineCap = shape.attrs.lineCap;
if (lineCap) {
this.setAttr('lineCap', lineCap);
}
}
_applyOpacity(shape) {
const absOpacity = shape.getAbsoluteOpacity();
if (absOpacity !== 1) {
this.setAttr('globalAlpha', absOpacity);
}
}
_applyLineJoin(shape) {
const lineJoin = shape.attrs.lineJoin;
if (lineJoin) {
this.setAttr('lineJoin', lineJoin);
}
}
setAttr(attr, val) {
this._context[attr] = val;
}
arc(x, y, radius, startAngle, endAngle, counterClockwise) {
this._context.arc(x, y, radius, startAngle, endAngle, counterClockwise);
}
arcTo(x1, y1, x2, y2, radius) {
this._context.arcTo(x1, y1, x2, y2, radius);
}
beginPath() {
this._context.beginPath();
}
bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
this._context.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
}
clearRect(x, y, width, height) {
this._context.clearRect(x, y, width, height);
}
clip(...args) {
this._context.clip.apply(this._context, args);
}
closePath() {
this._context.closePath();
}
createImageData(width, height) {
const a = arguments;
if (a.length === 2) {
return this._context.createImageData(width, height);
}
else if (a.length === 1) {
return this._context.createImageData(width);
}
}
createLinearGradient(x0, y0, x1, y1) {
return this._context.createLinearGradient(x0, y0, x1, y1);
}
createPattern(image, repetition) {
return this._context.createPattern(image, repetition);
}
createRadialGradient(x0, y0, r0, x1, y1, r1) {
return this._context.createRadialGradient(x0, y0, r0, x1, y1, r1);
}
drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) {
const a = arguments, _context = this._context;
if (a.length === 3) {
_context.drawImage(image, sx, sy);
}
else if (a.length === 5) {
_context.drawImage(image, sx, sy, sWidth, sHeight);
}
else if (a.length === 9) {
_context.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
}
}
ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise) {
this._context.ellipse(x, y, radiusX, radiusY, rotation, startAngle, endAngle, counterclockwise);
}
isPointInPath(x, y, path, fillRule) {
if (path) {
return this._context.isPointInPath(path, x, y, fillRule);
}
return this._context.isPointInPath(x, y, fillRule);
}
fill(...args) {
this._context.fill.apply(this._context, args);
}
fillRect(x, y, width, height) {
this._context.fillRect(x, y, width, height);
}
strokeRect(x, y, width, height) {
this._context.strokeRect(x, y, width, height);
}
fillText(text, x, y, maxWidth) {
if (maxWidth) {
this._context.fillText(text, x, y, maxWidth);
}
else {
this._context.fillText(text, x, y);
}
}
measureText(text) {
return this._context.measureText(text);
}
getImageData(sx, sy, sw, sh) {
return this._context.getImageData(sx, sy, sw, sh);
}
lineTo(x, y) {
this._context.lineTo(x, y);
}
moveTo(x, y) {
this._context.moveTo(x, y);
}
rect(x, y, width, height) {
this._context.rect(x, y, width, height);
}
roundRect(x, y, width, height, radii) {
this._context.roundRect(x, y, width, height, radii);
}
putImageData(imageData, dx, dy) {
this._context.putImageData(imageData, dx, dy);
}
quadraticCurveTo(cpx, cpy, x, y) {
this._context.quadraticCurveTo(cpx, cpy, x, y);
}
restore() {
this._context.restore();
}
rotate(angle) {
this._context.rotate(angle);
}
save() {
this._context.save();
}
scale(x, y) {
this._context.scale(x, y);
}
setLineDash(segments) {
if (this._context.setLineDash) {
this._context.setLineDash(segments);
}
else if ('mozDash' in this._context) {
this._context['mozDash'] = segments;
}
else if ('webkitLineDash' in this._context) {
this._context['webkitLineDash'] = segments;
}
}
getLineDash() {
return this._context.getLineDash();
}
setTransform(a, b, c, d, e, f) {
this._context.setTransform(a, b, c, d, e, f);
}
stroke(path2d) {
if (path2d) {
this._context.stroke(path2d);
}
else {
this._context.stroke();
}
}
strokeText(text, x, y, maxWidth) {
this._context.strokeText(text, x, y, maxWidth);
}
transform(a, b, c, d, e, f) {
this._context.transform(a, b, c, d, e, f);
}
translate(x, y) {
this._context.translate(x, y);
}
_enableTrace() {
let that = this, len = CONTEXT_METHODS.length, origSetter = this.setAttr, n, args;
const func = function (methodName) {
let origMethod = that[methodName], ret;
that[methodName] = function () {
args = simplifyArray(Array.prototype.slice.call(arguments, 0));
ret = origMethod.apply(that, arguments);
that._trace({
method: methodName,
args: args,
});
return ret;
};
};
for (n = 0; n < len; n++) {
func(CONTEXT_METHODS[n]);
}
that.setAttr = function () {
origSetter.apply(that, arguments);
const prop = arguments[0];
let val = arguments[1];
if (prop === 'shadowOffsetX' ||
prop === 'shadowOffsetY' ||
prop === 'shadowBlur') {
val = val / this.canvas.getPixelRatio();
}
that._trace({
property: prop,
val: val,
});
};
}
_applyGlobalCompositeOperation(node) {
const op = node.attrs.globalCompositeOperation;
const def = !op || op === 'source-over';
if (!def) {
this.setAttr('globalCompositeOperation', op);
}
}
}
exports.Context = Context;
CONTEXT_PROPERTIES.forEach(function (prop) {
Object.defineProperty(Context.prototype, prop, {
get() {
return this._context[prop];
},
set(val) {
this._context[prop] = val;
},
});
});
class SceneContext extends Context {
constructor(canvas, { willReadFrequently = false } = {}) {
super(canvas);
this._context = canvas._canvas.getContext('2d', {
willReadFrequently,
});
}
_fillColor(shape) {
const fill = shape.fill();
this.setAttr('fillStyle', fill);
shape._fillFunc(this);
}
_fillPattern(shape) {
this.setAttr('fillStyle', shape._getFillPattern());
shape._fillFunc(this);
}
_fillLinearGradient(shape) {
const grd = shape._getLinearGradient();
if (grd) {
this.setAttr('fillStyle', grd);
shape._fillFunc(this);
}
}
_fillRadialGradient(shape) {
const grd = shape._getRadialGradient();
if (grd) {
this.setAttr('fillStyle', grd);
shape._fillFunc(this);
}
}
_fill(shape) {
const hasColor = shape.fill(), fillPriority = shape.getFillPriority();
if (hasColor && fillPriority === 'color') {
this._fillColor(shape);
return;
}
const hasPattern = shape.getFillPatternImage();
if (hasPattern && fillPriority === 'pattern') {
this._fillPattern(shape);
return;
}
const hasLinearGradient = shape.getFillLinearGradientColorStops();
if (hasLinearGradient && fillPriority === 'linear-gradient') {
this._fillLinearGradient(shape);
return;
}
const hasRadialGradient = shape.getFillRadialGradientColorStops();
if (hasRadialGradient && fillPriority === 'radial-gradient') {
this._fillRadialGradient(shape);
return;
}
if (hasColor) {
this._fillColor(shape);
}
else if (hasPattern) {
this._fillPattern(shape);
}
else if (hasLinearGradient) {
this._fillLinearGradient(shape);
}
else if (hasRadialGradient) {
this._fillRadialGradient(shape);
}
}
_strokeLinearGradient(shape) {
const start = shape.getStrokeLinearGradientStartPoint(), end = shape.getStrokeLinearGradientEndPoint(), colorStops = shape.getStrokeLinearGradientColorStops(), grd = this.createLinearGradient(start.x, start.y, end.x, end.y);
if (colorStops) {
for (let n = 0; n < colorStops.length; n += 2) {
grd.addColorStop(colorStops[n], colorStops[n + 1]);
}
this.setAttr('strokeStyle', grd);
}
}
_stroke(shape) {
const dash = shape.dash(), strokeScaleEnabled = shape.getStrokeScaleEnabled();
if (shape.hasStroke()) {
if (!strokeScaleEnabled) {
this.save();
const pixelRatio = this.getCanvas().getPixelRatio();
this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
}
this._applyLineCap(shape);
if (dash && shape.dashEnabled()) {
this.setLineDash(dash);
this.setAttr('lineDashOffset', shape.dashOffset());
}
this.setAttr('lineWidth', shape.strokeWidth());
if (!shape.getShadowForStrokeEnabled()) {
this.setAttr('shadowColor', 'rgba(0,0,0,0)');
}
const hasLinearGradient = shape.getStrokeLinearGradientColorStops();
if (hasLinearGradient) {
this._strokeLinearGradient(shape);
}
else {
this.setAttr('strokeStyle', shape.stroke());
}
shape._strokeFunc(this);
if (!strokeScaleEnabled) {
this.restore();
}
}
}
_applyShadow(shape) {
var _a, _b, _c;
const color = (_a = shape.getShadowRGBA()) !== null && _a !== void 0 ? _a : 'black', blur = (_b = shape.getShadowBlur()) !== null && _b !== void 0 ? _b : 5, offset = (_c = shape.getShadowOffset()) !== null && _c !== void 0 ? _c : {
x: 0,
y: 0,
}, scale = shape.getAbsoluteScale(), ratio = this.canvas.getPixelRatio(), scaleX = scale.x * ratio, scaleY = scale.y * ratio;
this.setAttr('shadowColor', color);
this.setAttr('shadowBlur', blur * Math.min(Math.abs(scaleX), Math.abs(scaleY)));
this.setAttr('shadowOffsetX', offset.x * scaleX);
this.setAttr('shadowOffsetY', offset.y * scaleY);
}
}
exports.SceneContext = SceneContext;
class HitContext extends Context {
constructor(canvas) {
super(canvas);
this._context = canvas._canvas.getContext('2d', {
willReadFrequently: true,
});
}
_fill(shape) {
this.save();
this.setAttr('fillStyle', shape.colorKey);
shape._fillFuncHit(this);
this.restore();
}
strokeShape(shape) {
if (shape.hasHitStroke()) {
this._stroke(shape);
}
}
_stroke(shape) {
if (shape.hasHitStroke()) {
const strokeScaleEnabled = shape.getStrokeScaleEnabled();
if (!strokeScaleEnabled) {
this.save();
const pixelRatio = this.getCanvas().getPixelRatio();
this.setTransform(pixelRatio, 0, 0, pixelRatio, 0, 0);
}
this._applyLineCap(shape);
const hitStrokeWidth = shape.hitStrokeWidth();
const strokeWidth = hitStrokeWidth === 'auto' ? shape.strokeWidth() : hitStrokeWidth;
this.setAttr('lineWidth', strokeWidth);
this.setAttr('strokeStyle', shape.colorKey);
shape._strokeFuncHit(this);
if (!strokeScaleEnabled) {
this.restore();
}
}
}
}
exports.HitContext = HitContext;

3
node_modules/konva/lib/Core.d.ts generated vendored Normal file
View File

@@ -0,0 +1,3 @@
export { Konva } from './_CoreInternals.js';
import { Konva } from './_CoreInternals.js';
export default Konva;

7
node_modules/konva/lib/Core.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Konva = void 0;
var _CoreInternals_1 = require("./_CoreInternals");
Object.defineProperty(exports, "Konva", { enumerable: true, get: function () { return _CoreInternals_1.Konva; } });
const _CoreInternals_2 = require("./_CoreInternals");
module.exports = _CoreInternals_2.Konva;

17
node_modules/konva/lib/DragAndDrop.d.ts generated vendored Normal file
View File

@@ -0,0 +1,17 @@
import { Node } from './Node.js';
import { Vector2d } from './types.js';
export declare const DD: {
readonly isDragging: boolean;
justDragged: boolean;
readonly node: Node<import("./Node.js").NodeConfig> | undefined;
_dragElements: Map<number, {
node: Node;
startPointerPos: Vector2d;
offset: Vector2d;
pointerId?: number;
dragStatus: "ready" | "dragging" | "stopped";
}>;
_drag(evt: any): void;
_endDragBefore(evt?: any): void;
_endDragAfter(evt: any): void;
};

113
node_modules/konva/lib/DragAndDrop.js generated vendored Normal file
View File

@@ -0,0 +1,113 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DD = void 0;
const Global_1 = require("./Global");
const Util_1 = require("./Util");
exports.DD = {
get isDragging() {
let flag = false;
exports.DD._dragElements.forEach((elem) => {
if (elem.dragStatus === 'dragging') {
flag = true;
}
});
return flag;
},
justDragged: false,
get node() {
let node;
exports.DD._dragElements.forEach((elem) => {
node = elem.node;
});
return node;
},
_dragElements: new Map(),
_drag(evt) {
const nodesToFireEvents = [];
exports.DD._dragElements.forEach((elem, key) => {
const { node } = elem;
const stage = node.getStage();
stage.setPointersPositions(evt);
if (elem.pointerId === undefined) {
elem.pointerId = Util_1.Util._getFirstPointerId(evt);
}
const pos = stage._changedPointerPositions.find((pos) => pos.id === elem.pointerId);
if (!pos) {
return;
}
if (elem.dragStatus !== 'dragging') {
const dragDistance = node.dragDistance();
const distance = Math.max(Math.abs(pos.x - elem.startPointerPos.x), Math.abs(pos.y - elem.startPointerPos.y));
if (distance < dragDistance) {
return;
}
node.startDrag({ evt });
if (!node.isDragging()) {
return;
}
}
node._setDragPosition(evt, elem);
nodesToFireEvents.push(node);
});
nodesToFireEvents.forEach((node) => {
node.fire('dragmove', {
type: 'dragmove',
target: node,
evt: evt,
}, true);
});
},
_endDragBefore(evt) {
const drawNodes = [];
exports.DD._dragElements.forEach((elem) => {
const { node } = elem;
const stage = node.getStage();
if (evt) {
stage.setPointersPositions(evt);
}
const pos = stage._changedPointerPositions.find((pos) => pos.id === elem.pointerId);
if (!pos) {
return;
}
if (elem.dragStatus === 'dragging' || elem.dragStatus === 'stopped') {
exports.DD.justDragged = true;
Global_1.Konva._mouseListenClick = false;
Global_1.Konva._touchListenClick = false;
Global_1.Konva._pointerListenClick = false;
elem.dragStatus = 'stopped';
}
const drawNode = elem.node.getLayer() ||
(elem.node instanceof Global_1.Konva['Stage'] && elem.node);
if (drawNode && drawNodes.indexOf(drawNode) === -1) {
drawNodes.push(drawNode);
}
});
drawNodes.forEach((drawNode) => {
drawNode.draw();
});
},
_endDragAfter(evt) {
exports.DD._dragElements.forEach((elem, key) => {
if (elem.dragStatus === 'stopped') {
elem.node.fire('dragend', {
type: 'dragend',
target: elem.node,
evt: evt,
}, true);
}
if (elem.dragStatus !== 'dragging') {
exports.DD._dragElements.delete(key);
}
});
},
};
if (Global_1.Konva.isBrowser) {
window.addEventListener('mouseup', exports.DD._endDragBefore, true);
window.addEventListener('touchend', exports.DD._endDragBefore, true);
window.addEventListener('touchcancel', exports.DD._endDragBefore, true);
window.addEventListener('mousemove', exports.DD._drag);
window.addEventListener('touchmove', exports.DD._drag);
window.addEventListener('mouseup', exports.DD._endDragAfter, false);
window.addEventListener('touchend', exports.DD._endDragAfter, false);
window.addEventListener('touchcancel', exports.DD._endDragAfter, false);
}

22
node_modules/konva/lib/Factory.d.ts generated vendored Normal file
View File

@@ -0,0 +1,22 @@
import { Node } from './Node.js';
import { GetSet } from './types.js';
type EnforceString<T> = T extends string ? T : never;
type Constructor = abstract new (...args: any) => any;
type Attr<T extends Constructor> = EnforceString<keyof InstanceType<T>>;
type AfterFunc<T extends Constructor> = (this: InstanceType<T>) => void;
type ExtractGetSet<T> = T extends GetSet<infer U, any> ? U : never;
type Value<T extends Constructor, U extends Attr<T>> = ExtractGetSet<InstanceType<T>[U]>;
type ValidatorFunc<T> = (val: ExtractGetSet<T>, attr: string) => T;
type ExtractComponents<T extends Constructor, U extends Attr<T>> = Value<T, U> extends Record<string, any> ? EnforceString<keyof Value<T, U>>[] : never;
export declare const Factory: {
addGetterSetter<T extends Constructor, U extends Attr<T>>(constructor: T, attr: U, def?: Value<T, U>, validator?: ValidatorFunc<Value<T, U>>, after?: AfterFunc<T>): void;
addGetter<T extends Constructor, U extends Attr<T>>(constructor: T, attr: U, def?: Value<T, U>): void;
addSetter<T extends Constructor, U extends Attr<T>>(constructor: T, attr: U, validator?: ValidatorFunc<Value<T, U>>, after?: AfterFunc<T>): void;
overWriteSetter<T extends Constructor, U extends Attr<T>>(constructor: T, attr: U, validator?: ValidatorFunc<Value<T, U>>, after?: AfterFunc<T>): void;
addComponentsGetterSetter<T extends Constructor, U extends Attr<T>>(constructor: T, attr: U, components: ExtractComponents<T, U>, validator?: ValidatorFunc<Value<T, U>>, after?: AfterFunc<T>): void;
addOverloadedGetterSetter<T extends Constructor, U extends Attr<T>>(constructor: T, attr: U): void;
addDeprecatedGetterSetter<T extends Constructor, U extends Attr<T>>(constructor: T, attr: U, def: Value<T, U>, validator: ValidatorFunc<Value<T, U>>): void;
backCompat<T extends Constructor>(constructor: T, methods: Record<string, string>): void;
afterSetFilter(this: Node): void;
};
export {};

126
node_modules/konva/lib/Factory.js generated vendored Normal file
View File

@@ -0,0 +1,126 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Factory = void 0;
const Util_1 = require("./Util");
const Validators_1 = require("./Validators");
const GET = 'get';
const SET = 'set';
exports.Factory = {
addGetterSetter(constructor, attr, def, validator, after) {
exports.Factory.addGetter(constructor, attr, def);
exports.Factory.addSetter(constructor, attr, validator, after);
exports.Factory.addOverloadedGetterSetter(constructor, attr);
},
addGetter(constructor, attr, def) {
const method = GET + Util_1.Util._capitalize(attr);
constructor.prototype[method] =
constructor.prototype[method] ||
function () {
const val = this.attrs[attr];
return val === undefined ? def : val;
};
},
addSetter(constructor, attr, validator, after) {
const method = SET + Util_1.Util._capitalize(attr);
if (!constructor.prototype[method]) {
exports.Factory.overWriteSetter(constructor, attr, validator, after);
}
},
overWriteSetter(constructor, attr, validator, after) {
const method = SET + Util_1.Util._capitalize(attr);
constructor.prototype[method] = function (val) {
if (validator && val !== undefined && val !== null) {
val = validator.call(this, val, attr);
}
this._setAttr(attr, val);
if (after) {
after.call(this);
}
return this;
};
},
addComponentsGetterSetter(constructor, attr, components, validator, after) {
const len = components.length, capitalize = Util_1.Util._capitalize, getter = GET + capitalize(attr), setter = SET + capitalize(attr);
constructor.prototype[getter] = function () {
const ret = {};
for (let n = 0; n < len; n++) {
const component = components[n];
ret[component] = this.getAttr(attr + capitalize(component));
}
return ret;
};
const basicValidator = (0, Validators_1.getComponentValidator)(components);
constructor.prototype[setter] = function (val) {
const oldVal = this.attrs[attr];
if (validator) {
val = validator.call(this, val, attr);
}
if (basicValidator) {
basicValidator.call(this, val, attr);
}
for (const key in val) {
if (!val.hasOwnProperty(key)) {
continue;
}
this._setAttr(attr + capitalize(key), val[key]);
}
if (!val) {
components.forEach((component) => {
this._setAttr(attr + capitalize(component), undefined);
});
}
this._fireChangeEvent(attr, oldVal, val);
if (after) {
after.call(this);
}
return this;
};
exports.Factory.addOverloadedGetterSetter(constructor, attr);
},
addOverloadedGetterSetter(constructor, attr) {
const capitalizedAttr = Util_1.Util._capitalize(attr), setter = SET + capitalizedAttr, getter = GET + capitalizedAttr;
constructor.prototype[attr] = function () {
if (arguments.length) {
this[setter](arguments[0]);
return this;
}
return this[getter]();
};
},
addDeprecatedGetterSetter(constructor, attr, def, validator) {
Util_1.Util.error('Adding deprecated ' + attr);
const method = GET + Util_1.Util._capitalize(attr);
const message = attr +
' property is deprecated and will be removed soon. Look at Konva change log for more information.';
constructor.prototype[method] = function () {
Util_1.Util.error(message);
const val = this.attrs[attr];
return val === undefined ? def : val;
};
exports.Factory.addSetter(constructor, attr, validator, function () {
Util_1.Util.error(message);
});
exports.Factory.addOverloadedGetterSetter(constructor, attr);
},
backCompat(constructor, methods) {
Util_1.Util.each(methods, function (oldMethodName, newMethodName) {
const method = constructor.prototype[newMethodName];
const oldGetter = GET + Util_1.Util._capitalize(oldMethodName);
const oldSetter = SET + Util_1.Util._capitalize(oldMethodName);
function deprecated() {
method.apply(this, arguments);
Util_1.Util.error('"' +
oldMethodName +
'" method is deprecated and will be removed soon. Use ""' +
newMethodName +
'" instead.');
}
constructor.prototype[oldMethodName] = deprecated;
constructor.prototype[oldGetter] = deprecated;
constructor.prototype[oldSetter] = deprecated;
});
},
afterSetFilter() {
this._filterUpToDate = false;
},
};

4
node_modules/konva/lib/FastLayer.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import { Layer } from './Layer.js';
export declare class FastLayer extends Layer {
constructor(attrs: any);
}

16
node_modules/konva/lib/FastLayer.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FastLayer = void 0;
const Util_1 = require("./Util");
const Layer_1 = require("./Layer");
const Global_1 = require("./Global");
class FastLayer extends Layer_1.Layer {
constructor(attrs) {
super(attrs);
this.listening(false);
Util_1.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.');
}
}
exports.FastLayer = FastLayer;
FastLayer.prototype.nodeType = 'FastLayer';
(0, Global_1._registerNode)(FastLayer);

36
node_modules/konva/lib/Global.d.ts generated vendored Normal file
View File

@@ -0,0 +1,36 @@
export declare const glob: any;
export declare const Konva: {
_global: any;
version: string;
isBrowser: boolean;
isUnminified: boolean;
dblClickWindow: number;
getAngle(angle: number): number;
enableTrace: boolean;
pointerEventsEnabled: boolean;
autoDrawEnabled: boolean;
hitOnDragEnabled: boolean;
capturePointerEventsEnabled: boolean;
_mouseListenClick: boolean;
_touchListenClick: boolean;
_pointerListenClick: boolean;
_mouseInDblClickWindow: boolean;
_touchInDblClickWindow: boolean;
_pointerInDblClickWindow: boolean;
_mouseDblClickPointerId: null;
_touchDblClickPointerId: null;
_pointerDblClickPointerId: null;
_fixTextRendering: boolean;
pixelRatio: number;
dragDistance: number;
angleDeg: boolean;
showWarnings: boolean;
dragButtons: number[];
isDragging(): any;
isTransforming(): any;
isDragReady(): boolean;
releaseCanvasOnDestroy: boolean;
document: any;
_injectGlobal(Konva: any): void;
};
export declare const _registerNode: (NodeClass: any) => void;

66
node_modules/konva/lib/Global.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports._registerNode = exports.Konva = exports.glob = void 0;
const PI_OVER_180 = Math.PI / 180;
function detectBrowser() {
return (typeof window !== 'undefined' &&
({}.toString.call(window) === '[object Window]' ||
{}.toString.call(window) === '[object global]'));
}
exports.glob = typeof global !== 'undefined'
? global
: typeof window !== 'undefined'
? window
: typeof WorkerGlobalScope !== 'undefined'
? self
: {};
exports.Konva = {
_global: exports.glob,
version: '9.3.22',
isBrowser: detectBrowser(),
isUnminified: /param/.test(function (param) { }.toString()),
dblClickWindow: 400,
getAngle(angle) {
return exports.Konva.angleDeg ? angle * PI_OVER_180 : angle;
},
enableTrace: false,
pointerEventsEnabled: true,
autoDrawEnabled: true,
hitOnDragEnabled: false,
capturePointerEventsEnabled: false,
_mouseListenClick: false,
_touchListenClick: false,
_pointerListenClick: false,
_mouseInDblClickWindow: false,
_touchInDblClickWindow: false,
_pointerInDblClickWindow: false,
_mouseDblClickPointerId: null,
_touchDblClickPointerId: null,
_pointerDblClickPointerId: null,
_fixTextRendering: false,
pixelRatio: (typeof window !== 'undefined' && window.devicePixelRatio) || 1,
dragDistance: 3,
angleDeg: true,
showWarnings: true,
dragButtons: [0, 1],
isDragging() {
return exports.Konva['DD'].isDragging;
},
isTransforming() {
var _a;
return (_a = exports.Konva['Transformer']) === null || _a === void 0 ? void 0 : _a.isTransforming();
},
isDragReady() {
return !!exports.Konva['DD'].node;
},
releaseCanvasOnDestroy: true,
document: exports.glob.document,
_injectGlobal(Konva) {
exports.glob.Konva = Konva;
},
};
const _registerNode = (NodeClass) => {
exports.Konva[NodeClass.prototype.getClassName()] = NodeClass;
};
exports._registerNode = _registerNode;
exports.Konva._injectGlobal(exports.Konva);

8
node_modules/konva/lib/Group.d.ts generated vendored Normal file
View File

@@ -0,0 +1,8 @@
import { Container, ContainerConfig } from './Container.js';
import { Node } from './Node.js';
import { Shape } from './Shape.js';
export interface GroupConfig extends ContainerConfig {
}
export declare class Group extends Container<Group | Shape> {
_validateAdd(child: Node): void;
}

17
node_modules/konva/lib/Group.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Group = void 0;
const Util_1 = require("./Util");
const Container_1 = require("./Container");
const Global_1 = require("./Global");
class Group extends Container_1.Container {
_validateAdd(child) {
const type = child.getType();
if (type !== 'Group' && type !== 'Shape') {
Util_1.Util.throw('You may only add groups and shapes to groups.');
}
}
}
exports.Group = Group;
Group.prototype.nodeType = 'Group';
(0, Global_1._registerNode)(Group);

61
node_modules/konva/lib/Layer.d.ts generated vendored Normal file
View File

@@ -0,0 +1,61 @@
import { Container, ContainerConfig } from './Container.js';
import { Node } from './Node.js';
import { SceneCanvas, HitCanvas } from './Canvas.js';
import { Stage } from './Stage.js';
import { GetSet, Vector2d } from './types.js';
import { Group } from './Group.js';
import { Shape } from './Shape.js';
export interface LayerConfig extends ContainerConfig {
clearBeforeDraw?: boolean;
hitGraphEnabled?: boolean;
imageSmoothingEnabled?: boolean;
}
export declare class Layer extends Container<Group | Shape> {
canvas: SceneCanvas;
hitCanvas: HitCanvas;
_waitingForDraw: boolean;
constructor(config?: LayerConfig);
createPNGStream(): any;
getCanvas(): SceneCanvas;
getNativeCanvasElement(): HTMLCanvasElement;
getHitCanvas(): HitCanvas;
getContext(): import("./Context.js").Context;
clear(bounds?: any): this;
setZIndex(index: number): this;
moveToTop(): boolean;
moveUp(): boolean;
moveDown(): boolean;
moveToBottom(): boolean;
getLayer(): this;
remove(): this;
getStage(): Stage;
setSize({ width, height }: {
width: any;
height: any;
}): this;
_validateAdd(child: any): void;
_toKonvaCanvas(config: any): SceneCanvas;
_checkVisibility(): void;
_setSmoothEnabled(): void;
getWidth(): number | undefined;
setWidth(): void;
getHeight(): number | undefined;
setHeight(): void;
batchDraw(): this;
getIntersection(pos: Vector2d): Shape<import("./Shape.js").ShapeConfig> | null;
_getIntersection(pos: Vector2d): {
shape?: Shape;
antialiased?: boolean;
};
drawScene(can?: SceneCanvas, top?: Node, bufferCanvas?: SceneCanvas): this;
drawHit(can?: HitCanvas, top?: Node): this;
enableHitGraph(): this;
disableHitGraph(): this;
setHitGraphEnabled(val: any): void;
getHitGraphEnabled(val: any): boolean;
toggleHitCanvas(): void;
destroy(): this;
hitGraphEnabled: GetSet<boolean, this>;
clearBeforeDraw: GetSet<boolean, this>;
imageSmoothingEnabled: GetSet<boolean, this>;
}

309
node_modules/konva/lib/Layer.js generated vendored Normal file
View File

@@ -0,0 +1,309 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Layer = void 0;
const Util_1 = require("./Util");
const Container_1 = require("./Container");
const Node_1 = require("./Node");
const Factory_1 = require("./Factory");
const Canvas_1 = require("./Canvas");
const Validators_1 = require("./Validators");
const Shape_1 = require("./Shape");
const Global_1 = require("./Global");
const HASH = '#', BEFORE_DRAW = 'beforeDraw', DRAW = 'draw', INTERSECTION_OFFSETS = [
{ x: 0, y: 0 },
{ x: -1, y: -1 },
{ x: 1, y: -1 },
{ x: 1, y: 1 },
{ x: -1, y: 1 },
], INTERSECTION_OFFSETS_LEN = INTERSECTION_OFFSETS.length;
class Layer extends Container_1.Container {
constructor(config) {
super(config);
this.canvas = new Canvas_1.SceneCanvas();
this.hitCanvas = new Canvas_1.HitCanvas({
pixelRatio: 1,
});
this._waitingForDraw = false;
this.on('visibleChange.konva', this._checkVisibility);
this._checkVisibility();
this.on('imageSmoothingEnabledChange.konva', this._setSmoothEnabled);
this._setSmoothEnabled();
}
createPNGStream() {
const c = this.canvas._canvas;
return c.createPNGStream();
}
getCanvas() {
return this.canvas;
}
getNativeCanvasElement() {
return this.canvas._canvas;
}
getHitCanvas() {
return this.hitCanvas;
}
getContext() {
return this.getCanvas().getContext();
}
clear(bounds) {
this.getContext().clear(bounds);
this.getHitCanvas().getContext().clear(bounds);
return this;
}
setZIndex(index) {
super.setZIndex(index);
const stage = this.getStage();
if (stage && stage.content) {
stage.content.removeChild(this.getNativeCanvasElement());
if (index < stage.children.length - 1) {
stage.content.insertBefore(this.getNativeCanvasElement(), stage.children[index + 1].getCanvas()._canvas);
}
else {
stage.content.appendChild(this.getNativeCanvasElement());
}
}
return this;
}
moveToTop() {
Node_1.Node.prototype.moveToTop.call(this);
const stage = this.getStage();
if (stage && stage.content) {
stage.content.removeChild(this.getNativeCanvasElement());
stage.content.appendChild(this.getNativeCanvasElement());
}
return true;
}
moveUp() {
const moved = Node_1.Node.prototype.moveUp.call(this);
if (!moved) {
return false;
}
const stage = this.getStage();
if (!stage || !stage.content) {
return false;
}
stage.content.removeChild(this.getNativeCanvasElement());
if (this.index < stage.children.length - 1) {
stage.content.insertBefore(this.getNativeCanvasElement(), stage.children[this.index + 1].getCanvas()._canvas);
}
else {
stage.content.appendChild(this.getNativeCanvasElement());
}
return true;
}
moveDown() {
if (Node_1.Node.prototype.moveDown.call(this)) {
const stage = this.getStage();
if (stage) {
const children = stage.children;
if (stage.content) {
stage.content.removeChild(this.getNativeCanvasElement());
stage.content.insertBefore(this.getNativeCanvasElement(), children[this.index + 1].getCanvas()._canvas);
}
}
return true;
}
return false;
}
moveToBottom() {
if (Node_1.Node.prototype.moveToBottom.call(this)) {
const stage = this.getStage();
if (stage) {
const children = stage.children;
if (stage.content) {
stage.content.removeChild(this.getNativeCanvasElement());
stage.content.insertBefore(this.getNativeCanvasElement(), children[1].getCanvas()._canvas);
}
}
return true;
}
return false;
}
getLayer() {
return this;
}
remove() {
const _canvas = this.getNativeCanvasElement();
Node_1.Node.prototype.remove.call(this);
if (_canvas && _canvas.parentNode && Util_1.Util._isInDocument(_canvas)) {
_canvas.parentNode.removeChild(_canvas);
}
return this;
}
getStage() {
return this.parent;
}
setSize({ width, height }) {
this.canvas.setSize(width, height);
this.hitCanvas.setSize(width, height);
this._setSmoothEnabled();
return this;
}
_validateAdd(child) {
const type = child.getType();
if (type !== 'Group' && type !== 'Shape') {
Util_1.Util.throw('You may only add groups and shapes to a layer.');
}
}
_toKonvaCanvas(config) {
config = config || {};
config.width = config.width || this.getWidth();
config.height = config.height || this.getHeight();
config.x = config.x !== undefined ? config.x : this.x();
config.y = config.y !== undefined ? config.y : this.y();
return Node_1.Node.prototype._toKonvaCanvas.call(this, config);
}
_checkVisibility() {
const visible = this.visible();
if (visible) {
this.canvas._canvas.style.display = 'block';
}
else {
this.canvas._canvas.style.display = 'none';
}
}
_setSmoothEnabled() {
this.getContext()._context.imageSmoothingEnabled =
this.imageSmoothingEnabled();
}
getWidth() {
if (this.parent) {
return this.parent.width();
}
}
setWidth() {
Util_1.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.');
}
getHeight() {
if (this.parent) {
return this.parent.height();
}
}
setHeight() {
Util_1.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.');
}
batchDraw() {
if (!this._waitingForDraw) {
this._waitingForDraw = true;
Util_1.Util.requestAnimFrame(() => {
this.draw();
this._waitingForDraw = false;
});
}
return this;
}
getIntersection(pos) {
if (!this.isListening() || !this.isVisible()) {
return null;
}
let spiralSearchDistance = 1;
let continueSearch = false;
while (true) {
for (let i = 0; i < INTERSECTION_OFFSETS_LEN; i++) {
const intersectionOffset = INTERSECTION_OFFSETS[i];
const obj = this._getIntersection({
x: pos.x + intersectionOffset.x * spiralSearchDistance,
y: pos.y + intersectionOffset.y * spiralSearchDistance,
});
const shape = obj.shape;
if (shape) {
return shape;
}
continueSearch = !!obj.antialiased;
if (!obj.antialiased) {
break;
}
}
if (continueSearch) {
spiralSearchDistance += 1;
}
else {
return null;
}
}
}
_getIntersection(pos) {
const ratio = this.hitCanvas.pixelRatio;
const p = this.hitCanvas.context.getImageData(Math.round(pos.x * ratio), Math.round(pos.y * ratio), 1, 1).data;
const p3 = p[3];
if (p3 === 255) {
const colorKey = Util_1.Util._rgbToHex(p[0], p[1], p[2]);
const shape = Shape_1.shapes[HASH + colorKey];
if (shape) {
return {
shape: shape,
};
}
return {
antialiased: true,
};
}
else if (p3 > 0) {
return {
antialiased: true,
};
}
return {};
}
drawScene(can, top, bufferCanvas) {
const layer = this.getLayer(), canvas = can || (layer && layer.getCanvas());
this._fire(BEFORE_DRAW, {
node: this,
});
if (this.clearBeforeDraw()) {
canvas.getContext().clear();
}
Container_1.Container.prototype.drawScene.call(this, canvas, top, bufferCanvas);
this._fire(DRAW, {
node: this,
});
return this;
}
drawHit(can, top) {
const layer = this.getLayer(), canvas = can || (layer && layer.hitCanvas);
if (layer && layer.clearBeforeDraw()) {
layer.getHitCanvas().getContext().clear();
}
Container_1.Container.prototype.drawHit.call(this, canvas, top);
return this;
}
enableHitGraph() {
this.hitGraphEnabled(true);
return this;
}
disableHitGraph() {
this.hitGraphEnabled(false);
return this;
}
setHitGraphEnabled(val) {
Util_1.Util.warn('hitGraphEnabled method is deprecated. Please use layer.listening() instead.');
this.listening(val);
}
getHitGraphEnabled(val) {
Util_1.Util.warn('hitGraphEnabled method is deprecated. Please use layer.listening() instead.');
return this.listening();
}
toggleHitCanvas() {
if (!this.parent || !this.parent['content']) {
return;
}
const parent = this.parent;
const added = !!this.hitCanvas._canvas.parentNode;
if (added) {
parent.content.removeChild(this.hitCanvas._canvas);
}
else {
parent.content.appendChild(this.hitCanvas._canvas);
}
}
destroy() {
Util_1.Util.releaseCanvas(this.getNativeCanvasElement(), this.getHitCanvas()._canvas);
return super.destroy();
}
}
exports.Layer = Layer;
Layer.prototype.nodeType = 'Layer';
(0, Global_1._registerNode)(Layer);
Factory_1.Factory.addGetterSetter(Layer, 'imageSmoothingEnabled', true);
Factory_1.Factory.addGetterSetter(Layer, 'clearBeforeDraw', true);
Factory_1.Factory.addGetterSetter(Layer, 'hitGraphEnabled', true, (0, Validators_1.getBooleanValidator)());

335
node_modules/konva/lib/Node.d.ts generated vendored Normal file
View File

@@ -0,0 +1,335 @@
import { Canvas, SceneCanvas } from './Canvas.js';
import { Container } from './Container.js';
import { Context } from './Context.js';
import { Layer } from './Layer.js';
import { Shape } from './Shape.js';
import { Stage } from './Stage.js';
import { GetSet, IRect, Vector2d } from './types.js';
import { Transform } from './Util.js';
export type Filter = (this: Node, imageData: ImageData) => void;
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;
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?: Array<Filter>;
}
type NodeEventMap = GlobalEventHandlersEventMap & {
[index: string]: any;
};
export interface KonvaEventObject<EventType, This = Node> {
type: string;
target: Shape | Stage;
evt: EventType;
pointerId: number;
currentTarget: This;
cancelBubble: boolean;
child?: Node;
}
export type KonvaEventListener<This, EventType> = (this: This, ev: KonvaEventObject<EventType, This>) => void;
export declare abstract class Node<Config extends NodeConfig = NodeConfig> {
_id: number;
eventListeners: {
[index: string]: Array<{
name: string;
handler: Function;
}>;
};
attrs: any;
index: number;
_allEventListeners: null | Array<Function>;
parent: Container | null;
_cache: Map<string, any>;
_attachedDepsListeners: Map<string, boolean>;
_lastPos: Vector2d | null;
_attrsAffectingSize: string[];
_batchingTransformChange: boolean;
_needClearTransformCache: boolean;
_filterUpToDate: boolean;
_isUnderCache: boolean;
nodeType: string;
className: string;
_dragEventId: number | null;
_shouldFireChangeEvents: boolean;
constructor(config?: Config);
hasChildren(): boolean;
_clearCache(attr?: string): void;
_getCache(attr: string, privateGetter: Function): any;
_calculate(name: string, deps: Array<string>, getter: Function): any;
_getCanvasCache(): any;
_clearSelfAndDescendantCache(attr?: string): void;
clearCache(): this;
cache(config?: {
x?: number;
y?: number;
width?: number;
height?: number;
drawBorder?: boolean;
offset?: number;
pixelRatio?: number;
imageSmoothingEnabled?: boolean;
hitCanvasPixelRatio?: number;
}): this | undefined;
isCached(): boolean;
abstract drawScene(canvas?: Canvas, top?: Node, bufferCanvas?: Canvas): void;
abstract drawHit(canvas?: Canvas, top?: Node): void;
getClientRect(config?: {
skipTransform?: boolean;
skipShadow?: boolean;
skipStroke?: boolean;
relativeTo?: Container;
}): {
x: number;
y: number;
width: number;
height: number;
};
_transformedRect(rect: IRect, top?: Node | null): {
x: number;
y: number;
width: number;
height: number;
};
_drawCachedSceneCanvas(context: Context): void;
_drawCachedHitCanvas(context: Context): void;
_getCachedSceneCanvas(): any;
on<K extends keyof NodeEventMap>(evtStr: K, handler: KonvaEventListener<this, NodeEventMap[K]>): void | this;
off(evtStr?: string, callback?: Function): this;
dispatchEvent(evt: any): this;
addEventListener(type: string, handler: (e: Event) => void): this;
removeEventListener(type: string): this;
_delegate(event: string, selector: string, handler: (e: Event) => void): void;
remove(): this;
_clearCaches(): void;
_remove(): void;
destroy(): this;
getAttr<T>(attr: string): any;
getAncestors(): Node<NodeConfig>[];
getAttrs(): Config & Record<string, any>;
setAttrs(config: any): this;
isListening(): any;
_isListening(relativeTo?: Node): boolean;
isVisible(): any;
_isVisible(relativeTo?: Node): boolean;
shouldDrawHit(top?: Node, skipDragCheck?: boolean): any;
show(): this;
hide(): this;
getZIndex(): number;
getAbsoluteZIndex(): number;
getDepth(): number;
_batchTransformChanges(func: any): void;
setPosition(pos: Vector2d): this;
getPosition(): {
x: number;
y: number;
};
getRelativePointerPosition(): {
x: number;
y: number;
} | null;
getAbsolutePosition(top?: Node): {
x: number;
y: number;
};
setAbsolutePosition(pos: Vector2d): this;
_setTransform(trans: any): void;
_clearTransform(): {
x: number;
y: number;
rotation: number;
scaleX: number;
scaleY: number;
offsetX: number;
offsetY: number;
skewX: number;
skewY: number;
};
move(change: Vector2d): this;
_eachAncestorReverse(func: any, top: any): void;
rotate(theta: number): this;
moveToTop(): boolean;
moveUp(): boolean;
moveDown(): boolean;
moveToBottom(): boolean;
setZIndex(zIndex: any): this;
getAbsoluteOpacity(): any;
_getAbsoluteOpacity(): number;
moveTo(newContainer: any): this;
toObject(): {
attrs: Config & Record<string, any>;
className: string;
children?: Array<any>;
};
toJSON(): string;
getParent(): Container<Node<NodeConfig>> | null;
findAncestors(selector: string | Function, includeSelf?: boolean, stopNode?: Node): Node<NodeConfig>[];
isAncestorOf(node: Node): boolean;
findAncestor(selector: string | Function, includeSelf?: boolean, stopNode?: Container): Node<NodeConfig>;
_isMatch(selector: string | Function): any;
getLayer(): Layer | null;
getStage(): Stage | null;
_getStage(): Stage | null;
fire(eventType: string, evt?: any, bubble?: boolean): this;
getAbsoluteTransform(top?: Node | null): Transform;
_getAbsoluteTransform(top?: Node): Transform;
getAbsoluteScale(top?: Node): {
x: number;
y: number;
};
getAbsoluteRotation(): number;
getTransform(): Transform;
_getTransform(): Transform;
clone(obj?: any): any;
_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;
}): string;
toImage(config?: {
x?: number;
y?: number;
width?: number;
height?: number;
pixelRatio?: number;
mimeType?: string;
quality?: number;
callback?: (img: HTMLImageElement) => void;
}): Promise<unknown>;
toBlob(config?: {
x?: number;
y?: number;
width?: number;
height?: number;
pixelRatio?: number;
mimeType?: string;
quality?: number;
callback?: (blob: Blob | null) => void;
}): Promise<unknown>;
setSize(size: any): this;
getSize(): {
width: number;
height: number;
};
getClassName(): string;
getType(): string;
getDragDistance(): number;
_off(type: any, name?: any, callback?: any): void;
_fireChangeEvent(attr: any, oldVal: any, newVal: any): void;
addName(name: string): this;
hasName(name: any): boolean;
removeName(name: any): this;
setAttr(attr: string, val: any): this;
_requestDraw(): void;
_setAttr(key: string, val: any): void;
_setComponentAttr(key: any, component: any, val: any): void;
_fireAndBubble(eventType: any, evt: any, compareShape?: any): void;
_getProtoListeners(eventType: any): any;
_fire(eventType: any, evt: any): void;
draw(): this;
_createDragElement(evt: any): void;
startDrag(evt?: any, bubbleEvent?: boolean): void;
_setDragPosition(evt: any, elem: any): void;
stopDrag(evt?: any): void;
setDraggable(draggable: any): void;
isDragging(): boolean;
_listenDrag(): void;
_dragChange(): void;
_dragCleanup(): void;
isClientRectOnScreen(margin?: {
x: number;
y: number;
}): boolean;
preventDefault: GetSet<boolean, this>;
blue: GetSet<number, this>;
brightness: GetSet<number, this>;
contrast: GetSet<number, this>;
blurRadius: GetSet<number, this>;
luminance: GetSet<number, this>;
green: GetSet<number, this>;
alpha: GetSet<number, this>;
hue: GetSet<number, this>;
kaleidoscopeAngle: GetSet<number, this>;
kaleidoscopePower: GetSet<number, this>;
levels: GetSet<number, this>;
noise: GetSet<number, this>;
pixelSize: GetSet<number, this>;
red: GetSet<number, this>;
saturation: GetSet<number, this>;
threshold: GetSet<number, this>;
value: GetSet<number, this>;
dragBoundFunc: GetSet<(this: Node, pos: Vector2d, event: any) => Vector2d, this>;
draggable: GetSet<boolean, this>;
dragDistance: GetSet<number, this>;
embossBlend: GetSet<boolean, this>;
embossDirection: GetSet<string, this>;
embossStrength: GetSet<number, this>;
embossWhiteLevel: GetSet<number, this>;
enhance: GetSet<number, this>;
filters: GetSet<Filter[], this>;
position: GetSet<Vector2d, this>;
absolutePosition: GetSet<Vector2d, this>;
size: GetSet<{
width: number;
height: number;
}, this>;
id: GetSet<string, this>;
listening: GetSet<boolean, this>;
name: GetSet<string, this>;
offset: GetSet<Vector2d, this>;
offsetX: GetSet<number, this>;
offsetY: GetSet<number, this>;
opacity: GetSet<number, this>;
rotation: GetSet<number, this>;
zIndex: GetSet<number, this>;
scale: GetSet<Vector2d, this>;
scaleX: GetSet<number, this>;
scaleY: GetSet<number, this>;
skew: GetSet<Vector2d, this>;
skewX: GetSet<number, this>;
skewY: GetSet<number, this>;
to: (params: AnimTo) => void;
transformsEnabled: GetSet<string, this>;
visible: GetSet<boolean, this>;
width: GetSet<number, this>;
height: GetSet<number, this>;
x: GetSet<number, this>;
y: GetSet<number, this>;
globalCompositeOperation: GetSet<globalCompositeOperationType, this>;
static create(data: any, container?: any): any;
static _createNode(obj: any, container?: any): any;
}
interface AnimTo extends NodeConfig {
onFinish?: Function;
onUpdate?: Function;
duration?: number;
}
export {};

1448
node_modules/konva/lib/Node.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

11
node_modules/konva/lib/PointerEvents.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
import { KonvaEventObject } from './Node.js';
import { Shape } from './Shape.js';
import { Stage } from './Stage.js';
export interface KonvaPointerEvent extends KonvaEventObject<PointerEvent> {
pointerId: number;
}
export declare function getCapturedShape(pointerId: number): Shape<import("./Shape.js").ShapeConfig> | Stage | undefined;
export declare function createEvent(evt: PointerEvent): KonvaPointerEvent;
export declare function hasPointerCapture(pointerId: number, shape: Shape | Stage): boolean;
export declare function setPointerCapture(pointerId: number, shape: Shape | Stage): void;
export declare function releaseCapture(pointerId: number, target?: Shape | Stage): void;

44
node_modules/konva/lib/PointerEvents.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getCapturedShape = getCapturedShape;
exports.createEvent = createEvent;
exports.hasPointerCapture = hasPointerCapture;
exports.setPointerCapture = setPointerCapture;
exports.releaseCapture = releaseCapture;
const Global_1 = require("./Global");
const Captures = new Map();
const SUPPORT_POINTER_EVENTS = Global_1.Konva._global['PointerEvent'] !== undefined;
function getCapturedShape(pointerId) {
return Captures.get(pointerId);
}
function createEvent(evt) {
return {
evt,
pointerId: evt.pointerId,
};
}
function hasPointerCapture(pointerId, shape) {
return Captures.get(pointerId) === shape;
}
function setPointerCapture(pointerId, shape) {
releaseCapture(pointerId);
const stage = shape.getStage();
if (!stage)
return;
Captures.set(pointerId, shape);
if (SUPPORT_POINTER_EVENTS) {
shape._fire('gotpointercapture', createEvent(new PointerEvent('gotpointercapture')));
}
}
function releaseCapture(pointerId, target) {
const shape = Captures.get(pointerId);
if (!shape)
return;
const stage = shape.getStage();
if (stage && stage.content) {
}
Captures.delete(pointerId);
if (SUPPORT_POINTER_EVENTS) {
shape._fire('lostpointercapture', createEvent(new PointerEvent('lostpointercapture')));
}
}

193
node_modules/konva/lib/Shape.d.ts generated vendored Normal file
View File

@@ -0,0 +1,193 @@
import { Node, NodeConfig } from './Node.js';
import { Context } from './Context.js';
import { GetSet, Vector2d } from './types.js';
import { HitCanvas, SceneCanvas } from './Canvas.js';
export type ShapeConfigHandler<TTarget> = {
bivarianceHack(ctx: Context, shape: TTarget): void;
}['bivarianceHack'];
export type LineJoin = 'round' | 'bevel' | 'miter';
export type LineCap = 'butt' | 'round' | 'square';
export interface ShapeConfig extends NodeConfig {
fill?: string | CanvasGradient;
fillPatternImage?: HTMLImageElement;
fillPatternX?: number;
fillPatternY?: number;
fillPatternOffset?: Vector2d;
fillPatternOffsetX?: number;
fillPatternOffsetY?: number;
fillPatternScale?: Vector2d;
fillPatternScaleX?: number;
fillPatternScaleY?: number;
fillPatternRotation?: number;
fillPatternRepeat?: string;
fillLinearGradientStartPoint?: Vector2d;
fillLinearGradientStartPointX?: number;
fillLinearGradientStartPointY?: number;
fillLinearGradientEndPoint?: Vector2d;
fillLinearGradientEndPointX?: number;
fillLinearGradientEndPointY?: number;
fillLinearGradientColorStops?: Array<number | string>;
fillRadialGradientStartPoint?: Vector2d;
fillRadialGradientStartPointX?: number;
fillRadialGradientStartPointY?: number;
fillRadialGradientEndPoint?: Vector2d;
fillRadialGradientEndPointX?: number;
fillRadialGradientEndPointY?: number;
fillRadialGradientStartRadius?: number;
fillRadialGradientEndRadius?: number;
fillRadialGradientColorStops?: Array<number | string>;
fillEnabled?: boolean;
fillPriority?: string;
fillRule?: CanvasFillRule;
stroke?: string | CanvasGradient;
strokeWidth?: number;
fillAfterStrokeEnabled?: boolean;
hitStrokeWidth?: number | string;
strokeScaleEnabled?: boolean;
strokeHitEnabled?: boolean;
strokeEnabled?: boolean;
lineJoin?: LineJoin;
lineCap?: LineCap;
sceneFunc?: (con: Context, shape: Shape) => void;
hitFunc?: (con: Context, shape: Shape) => void;
shadowColor?: string;
shadowBlur?: number;
shadowOffset?: Vector2d;
shadowOffsetX?: number;
shadowOffsetY?: number;
shadowOpacity?: number;
shadowEnabled?: boolean;
shadowForStrokeEnabled?: boolean;
dash?: number[];
dashOffset?: number;
dashEnabled?: boolean;
perfectDrawEnabled?: boolean;
}
export interface ShapeGetClientRectConfig {
skipTransform?: boolean;
skipShadow?: boolean;
skipStroke?: boolean;
relativeTo?: Node;
}
export type FillFuncOutput = void | [Path2D | CanvasFillRule] | [Path2D, CanvasFillRule];
export declare const shapes: {
[key: string]: Shape;
};
export declare class Shape<Config extends ShapeConfig = ShapeConfig> extends Node<Config> {
_centroid: boolean;
colorKey: string;
_fillFunc: (ctx: Context) => FillFuncOutput;
_strokeFunc: (ctx: Context) => void;
_fillFuncHit: (ctx: Context) => void;
_strokeFuncHit: (ctx: Context) => void;
constructor(config?: Config);
getContext(): Context;
getCanvas(): SceneCanvas;
getSceneFunc(): any;
getHitFunc(): any;
hasShadow(): any;
_hasShadow(): boolean;
_getFillPattern(): any;
__getFillPattern(): CanvasPattern | null | undefined;
_getLinearGradient(): any;
__getLinearGradient(): CanvasGradient | undefined;
_getRadialGradient(): any;
__getRadialGradient(): CanvasGradient | undefined;
getShadowRGBA(): any;
_getShadowRGBA(): string | undefined;
hasFill(): any;
hasStroke(): any;
hasHitStroke(): any;
intersects(point: Vector2d): boolean;
destroy(): this;
_useBufferCanvas(forceFill?: boolean): boolean;
setStrokeHitEnabled(val: number): void;
getStrokeHitEnabled(): boolean;
getSelfRect(): {
x: number;
y: number;
width: number;
height: number;
};
getClientRect(config?: ShapeGetClientRectConfig): {
width: number;
height: number;
x: number;
y: number;
};
drawScene(can?: SceneCanvas, top?: Node, bufferCanvas?: SceneCanvas): this;
drawHit(can?: HitCanvas, top?: Node, skipDragCheck?: boolean): this;
drawHitFromCache(alphaThreshold?: number): this;
hasPointerCapture(pointerId: number): boolean;
setPointerCapture(pointerId: number): void;
releaseCapture(pointerId: number): void;
draggable: GetSet<boolean, this>;
embossBlend: GetSet<boolean, this>;
dash: GetSet<number[], this>;
dashEnabled: GetSet<boolean, this>;
dashOffset: GetSet<number, this>;
fill: GetSet<string | CanvasGradient, this>;
fillEnabled: GetSet<boolean, this>;
fillLinearGradientColorStops: GetSet<Array<number | string>, this>;
fillLinearGradientStartPoint: GetSet<Vector2d, this>;
fillLinearGradientStartPointX: GetSet<number, this>;
fillLinearGradientStartPointY: GetSet<number, this>;
fillLinearGradientEndPoint: GetSet<Vector2d, this>;
fillLinearGradientEndPointX: GetSet<number, this>;
fillLinearGradientEndPointY: GetSet<number, this>;
fillLinearRadialStartPoint: GetSet<Vector2d, this>;
fillLinearRadialStartPointX: GetSet<number, this>;
fillLinearRadialStartPointY: GetSet<number, this>;
fillLinearRadialEndPoint: GetSet<Vector2d, this>;
fillLinearRadialEndPointX: GetSet<number, this>;
fillLinearRadialEndPointY: GetSet<number, this>;
fillPatternImage: GetSet<HTMLImageElement | HTMLCanvasElement, this>;
fillRadialGradientStartRadius: GetSet<number, this>;
fillRadialGradientEndRadius: GetSet<number, this>;
fillRadialGradientColorStops: GetSet<Array<number | string>, this>;
fillRadialGradientStartPoint: GetSet<Vector2d, this>;
fillRadialGradientStartPointX: GetSet<number, this>;
fillRadialGradientStartPointY: GetSet<number, this>;
fillRadialGradientEndPoint: GetSet<Vector2d, this>;
fillRadialGradientEndPointX: GetSet<number, this>;
fillRadialGradientEndPointY: GetSet<number, this>;
fillPatternOffset: GetSet<Vector2d, this>;
fillPatternOffsetX: GetSet<number, this>;
fillPatternOffsetY: GetSet<number, this>;
fillPatternRepeat: GetSet<string, this>;
fillPatternRotation: GetSet<number, this>;
fillPatternScale: GetSet<Vector2d, this>;
fillPatternScaleX: GetSet<number, this>;
fillPatternScaleY: GetSet<number, this>;
fillPatternX: GetSet<number, this>;
fillPatternY: GetSet<number, this>;
fillPriority: GetSet<string, this>;
hitFunc: GetSet<ShapeConfigHandler<this>, this>;
lineCap: GetSet<LineCap, this>;
lineJoin: GetSet<LineJoin, this>;
perfectDrawEnabled: GetSet<boolean, this>;
sceneFunc: GetSet<ShapeConfigHandler<this>, this>;
shadowColor: GetSet<string, this>;
shadowEnabled: GetSet<boolean, this>;
shadowForStrokeEnabled: GetSet<boolean, this>;
shadowOffset: GetSet<Vector2d, this>;
shadowOffsetX: GetSet<number, this>;
shadowOffsetY: GetSet<number, this>;
shadowOpacity: GetSet<number, this>;
shadowBlur: GetSet<number, this>;
stroke: GetSet<string | CanvasGradient, this>;
strokeEnabled: GetSet<boolean, this>;
fillAfterStrokeEnabled: GetSet<boolean, this>;
strokeScaleEnabled: GetSet<boolean, this>;
strokeHitEnabled: GetSet<boolean, this>;
strokeWidth: GetSet<number, this>;
hitStrokeWidth: GetSet<number | 'auto', this>;
strokeLinearGradientStartPoint: GetSet<Vector2d, this>;
strokeLinearGradientEndPoint: GetSet<Vector2d, this>;
strokeLinearGradientColorStops: GetSet<Array<number | string>, this>;
strokeLinearGradientStartPointX: GetSet<number, this>;
strokeLinearGradientStartPointY: GetSet<number, this>;
strokeLinearGradientEndPointX: GetSet<number, this>;
strokeLinearGradientEndPointY: GetSet<number, this>;
fillRule: GetSet<CanvasFillRule, this>;
}

546
node_modules/konva/lib/Shape.js generated vendored Normal file
View File

@@ -0,0 +1,546 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Shape = exports.shapes = void 0;
const Global_1 = require("./Global");
const Util_1 = require("./Util");
const Factory_1 = require("./Factory");
const Node_1 = require("./Node");
const Validators_1 = require("./Validators");
const Global_2 = require("./Global");
const PointerEvents = require("./PointerEvents");
const HAS_SHADOW = 'hasShadow';
const SHADOW_RGBA = 'shadowRGBA';
const patternImage = 'patternImage';
const linearGradient = 'linearGradient';
const radialGradient = 'radialGradient';
let dummyContext;
function getDummyContext() {
if (dummyContext) {
return dummyContext;
}
dummyContext = Util_1.Util.createCanvasElement().getContext('2d');
return dummyContext;
}
exports.shapes = {};
function _fillFunc(context) {
const fillRule = this.attrs.fillRule;
if (fillRule) {
context.fill(fillRule);
}
else {
context.fill();
}
}
function _strokeFunc(context) {
context.stroke();
}
function _fillFuncHit(context) {
const fillRule = this.attrs.fillRule;
if (fillRule) {
context.fill(fillRule);
}
else {
context.fill();
}
}
function _strokeFuncHit(context) {
context.stroke();
}
function _clearHasShadowCache() {
this._clearCache(HAS_SHADOW);
}
function _clearGetShadowRGBACache() {
this._clearCache(SHADOW_RGBA);
}
function _clearFillPatternCache() {
this._clearCache(patternImage);
}
function _clearLinearGradientCache() {
this._clearCache(linearGradient);
}
function _clearRadialGradientCache() {
this._clearCache(radialGradient);
}
class Shape extends Node_1.Node {
constructor(config) {
super(config);
let key;
while (true) {
key = Util_1.Util.getRandomColor();
if (key && !(key in exports.shapes)) {
break;
}
}
this.colorKey = key;
exports.shapes[key] = this;
}
getContext() {
Util_1.Util.warn('shape.getContext() method is deprecated. Please do not use it.');
return this.getLayer().getContext();
}
getCanvas() {
Util_1.Util.warn('shape.getCanvas() method is deprecated. Please do not use it.');
return this.getLayer().getCanvas();
}
getSceneFunc() {
return this.attrs.sceneFunc || this['_sceneFunc'];
}
getHitFunc() {
return this.attrs.hitFunc || this['_hitFunc'];
}
hasShadow() {
return this._getCache(HAS_SHADOW, this._hasShadow);
}
_hasShadow() {
return (this.shadowEnabled() &&
this.shadowOpacity() !== 0 &&
!!(this.shadowColor() ||
this.shadowBlur() ||
this.shadowOffsetX() ||
this.shadowOffsetY()));
}
_getFillPattern() {
return this._getCache(patternImage, this.__getFillPattern);
}
__getFillPattern() {
if (this.fillPatternImage()) {
const ctx = getDummyContext();
const pattern = ctx.createPattern(this.fillPatternImage(), this.fillPatternRepeat() || 'repeat');
if (pattern && pattern.setTransform) {
const tr = new Util_1.Transform();
tr.translate(this.fillPatternX(), this.fillPatternY());
tr.rotate(Global_1.Konva.getAngle(this.fillPatternRotation()));
tr.scale(this.fillPatternScaleX(), this.fillPatternScaleY());
tr.translate(-1 * this.fillPatternOffsetX(), -1 * this.fillPatternOffsetY());
const m = tr.getMatrix();
const matrix = typeof DOMMatrix === 'undefined'
? {
a: m[0],
b: m[1],
c: m[2],
d: m[3],
e: m[4],
f: m[5],
}
: new DOMMatrix(m);
pattern.setTransform(matrix);
}
return pattern;
}
}
_getLinearGradient() {
return this._getCache(linearGradient, this.__getLinearGradient);
}
__getLinearGradient() {
const colorStops = this.fillLinearGradientColorStops();
if (colorStops) {
const ctx = getDummyContext();
const start = this.fillLinearGradientStartPoint();
const end = this.fillLinearGradientEndPoint();
const grd = ctx.createLinearGradient(start.x, start.y, end.x, end.y);
for (let n = 0; n < colorStops.length; n += 2) {
grd.addColorStop(colorStops[n], colorStops[n + 1]);
}
return grd;
}
}
_getRadialGradient() {
return this._getCache(radialGradient, this.__getRadialGradient);
}
__getRadialGradient() {
const colorStops = this.fillRadialGradientColorStops();
if (colorStops) {
const ctx = getDummyContext();
const start = this.fillRadialGradientStartPoint();
const end = this.fillRadialGradientEndPoint();
const grd = ctx.createRadialGradient(start.x, start.y, this.fillRadialGradientStartRadius(), end.x, end.y, this.fillRadialGradientEndRadius());
for (let n = 0; n < colorStops.length; n += 2) {
grd.addColorStop(colorStops[n], colorStops[n + 1]);
}
return grd;
}
}
getShadowRGBA() {
return this._getCache(SHADOW_RGBA, this._getShadowRGBA);
}
_getShadowRGBA() {
if (!this.hasShadow()) {
return;
}
const rgba = Util_1.Util.colorToRGBA(this.shadowColor());
if (rgba) {
return ('rgba(' +
rgba.r +
',' +
rgba.g +
',' +
rgba.b +
',' +
rgba.a * (this.shadowOpacity() || 1) +
')');
}
}
hasFill() {
return this._calculate('hasFill', [
'fillEnabled',
'fill',
'fillPatternImage',
'fillLinearGradientColorStops',
'fillRadialGradientColorStops',
], () => {
return (this.fillEnabled() &&
!!(this.fill() ||
this.fillPatternImage() ||
this.fillLinearGradientColorStops() ||
this.fillRadialGradientColorStops()));
});
}
hasStroke() {
return this._calculate('hasStroke', [
'strokeEnabled',
'strokeWidth',
'stroke',
'strokeLinearGradientColorStops',
], () => {
return (this.strokeEnabled() &&
this.strokeWidth() &&
!!(this.stroke() || this.strokeLinearGradientColorStops()));
});
}
hasHitStroke() {
const width = this.hitStrokeWidth();
if (width === 'auto') {
return this.hasStroke();
}
return this.strokeEnabled() && !!width;
}
intersects(point) {
const stage = this.getStage();
if (!stage) {
return false;
}
const bufferHitCanvas = stage.bufferHitCanvas;
bufferHitCanvas.getContext().clear();
this.drawHit(bufferHitCanvas, undefined, true);
const p = bufferHitCanvas.context.getImageData(Math.round(point.x), Math.round(point.y), 1, 1).data;
return p[3] > 0;
}
destroy() {
Node_1.Node.prototype.destroy.call(this);
delete exports.shapes[this.colorKey];
delete this.colorKey;
return this;
}
_useBufferCanvas(forceFill) {
var _a;
const perfectDrawEnabled = (_a = this.attrs.perfectDrawEnabled) !== null && _a !== void 0 ? _a : true;
if (!perfectDrawEnabled) {
return false;
}
const hasFill = forceFill || this.hasFill();
const hasStroke = this.hasStroke();
const isTransparent = this.getAbsoluteOpacity() !== 1;
if (hasFill && hasStroke && isTransparent) {
return true;
}
const hasShadow = this.hasShadow();
const strokeForShadow = this.shadowForStrokeEnabled();
if (hasFill && hasStroke && hasShadow && strokeForShadow) {
return true;
}
return false;
}
setStrokeHitEnabled(val) {
Util_1.Util.warn('strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead.');
if (val) {
this.hitStrokeWidth('auto');
}
else {
this.hitStrokeWidth(0);
}
}
getStrokeHitEnabled() {
if (this.hitStrokeWidth() === 0) {
return false;
}
else {
return true;
}
}
getSelfRect() {
const size = this.size();
return {
x: this._centroid ? -size.width / 2 : 0,
y: this._centroid ? -size.height / 2 : 0,
width: size.width,
height: size.height,
};
}
getClientRect(config = {}) {
let hasCachedParent = false;
let parent = this.getParent();
while (parent) {
if (parent.isCached()) {
hasCachedParent = true;
break;
}
parent = parent.getParent();
}
const skipTransform = config.skipTransform;
const relativeTo = config.relativeTo || (hasCachedParent && this.getStage()) || undefined;
const fillRect = this.getSelfRect();
const applyStroke = !config.skipStroke && this.hasStroke();
const strokeWidth = (applyStroke && this.strokeWidth()) || 0;
const fillAndStrokeWidth = fillRect.width + strokeWidth;
const fillAndStrokeHeight = fillRect.height + strokeWidth;
const applyShadow = !config.skipShadow && this.hasShadow();
const shadowOffsetX = applyShadow ? this.shadowOffsetX() : 0;
const shadowOffsetY = applyShadow ? this.shadowOffsetY() : 0;
const preWidth = fillAndStrokeWidth + Math.abs(shadowOffsetX);
const preHeight = fillAndStrokeHeight + Math.abs(shadowOffsetY);
const blurRadius = (applyShadow && this.shadowBlur()) || 0;
const width = preWidth + blurRadius * 2;
const height = preHeight + blurRadius * 2;
const rect = {
width: width,
height: height,
x: -(strokeWidth / 2 + blurRadius) +
Math.min(shadowOffsetX, 0) +
fillRect.x,
y: -(strokeWidth / 2 + blurRadius) +
Math.min(shadowOffsetY, 0) +
fillRect.y,
};
if (!skipTransform) {
return this._transformedRect(rect, relativeTo);
}
return rect;
}
drawScene(can, top, bufferCanvas) {
const layer = this.getLayer();
const canvas = can || layer.getCanvas(), context = canvas.getContext(), cachedCanvas = this._getCanvasCache(), drawFunc = this.getSceneFunc(), hasShadow = this.hasShadow();
let stage;
const skipBuffer = false;
const cachingSelf = top === this;
if (!this.isVisible() && !cachingSelf) {
return this;
}
if (cachedCanvas) {
context.save();
const m = this.getAbsoluteTransform(top).getMatrix();
context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
this._drawCachedSceneCanvas(context);
context.restore();
return this;
}
if (!drawFunc) {
return this;
}
context.save();
if (this._useBufferCanvas() && !skipBuffer) {
stage = this.getStage();
const bc = bufferCanvas || stage.bufferCanvas;
const bufferContext = bc.getContext();
bufferContext.clear();
bufferContext.save();
bufferContext._applyLineJoin(this);
const o = this.getAbsoluteTransform(top).getMatrix();
bufferContext.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
drawFunc.call(this, bufferContext, this);
bufferContext.restore();
const ratio = bc.pixelRatio;
if (hasShadow) {
context._applyShadow(this);
}
context._applyOpacity(this);
context._applyGlobalCompositeOperation(this);
context.drawImage(bc._canvas, bc.x || 0, bc.y || 0, bc.width / ratio, bc.height / ratio);
}
else {
context._applyLineJoin(this);
if (!cachingSelf) {
const o = this.getAbsoluteTransform(top).getMatrix();
context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
context._applyOpacity(this);
context._applyGlobalCompositeOperation(this);
}
if (hasShadow) {
context._applyShadow(this);
}
drawFunc.call(this, context, this);
}
context.restore();
return this;
}
drawHit(can, top, skipDragCheck = false) {
if (!this.shouldDrawHit(top, skipDragCheck)) {
return this;
}
const layer = this.getLayer(), canvas = can || layer.hitCanvas, context = canvas && canvas.getContext(), drawFunc = this.hitFunc() || this.sceneFunc(), cachedCanvas = this._getCanvasCache(), cachedHitCanvas = cachedCanvas && cachedCanvas.hit;
if (!this.colorKey) {
Util_1.Util.warn('Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()');
}
if (cachedHitCanvas) {
context.save();
const m = this.getAbsoluteTransform(top).getMatrix();
context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
this._drawCachedHitCanvas(context);
context.restore();
return this;
}
if (!drawFunc) {
return this;
}
context.save();
context._applyLineJoin(this);
const selfCache = this === top;
if (!selfCache) {
const o = this.getAbsoluteTransform(top).getMatrix();
context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
}
drawFunc.call(this, context, this);
context.restore();
return this;
}
drawHitFromCache(alphaThreshold = 0) {
const cachedCanvas = this._getCanvasCache(), sceneCanvas = this._getCachedSceneCanvas(), hitCanvas = cachedCanvas.hit, hitContext = hitCanvas.getContext(), hitWidth = hitCanvas.getWidth(), hitHeight = hitCanvas.getHeight();
hitContext.clear();
hitContext.drawImage(sceneCanvas._canvas, 0, 0, hitWidth, hitHeight);
try {
const hitImageData = hitContext.getImageData(0, 0, hitWidth, hitHeight);
const hitData = hitImageData.data;
const len = hitData.length;
const rgbColorKey = Util_1.Util._hexToRgb(this.colorKey);
for (let i = 0; i < len; i += 4) {
const alpha = hitData[i + 3];
if (alpha > alphaThreshold) {
hitData[i] = rgbColorKey.r;
hitData[i + 1] = rgbColorKey.g;
hitData[i + 2] = rgbColorKey.b;
hitData[i + 3] = 255;
}
else {
hitData[i + 3] = 0;
}
}
hitContext.putImageData(hitImageData, 0, 0);
}
catch (e) {
Util_1.Util.error('Unable to draw hit graph from cached scene canvas. ' + e.message);
}
return this;
}
hasPointerCapture(pointerId) {
return PointerEvents.hasPointerCapture(pointerId, this);
}
setPointerCapture(pointerId) {
PointerEvents.setPointerCapture(pointerId, this);
}
releaseCapture(pointerId) {
PointerEvents.releaseCapture(pointerId, this);
}
}
exports.Shape = Shape;
Shape.prototype._fillFunc = _fillFunc;
Shape.prototype._strokeFunc = _strokeFunc;
Shape.prototype._fillFuncHit = _fillFuncHit;
Shape.prototype._strokeFuncHit = _strokeFuncHit;
Shape.prototype._centroid = false;
Shape.prototype.nodeType = 'Shape';
(0, Global_2._registerNode)(Shape);
Shape.prototype.eventListeners = {};
Shape.prototype.on.call(Shape.prototype, 'shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearHasShadowCache);
Shape.prototype.on.call(Shape.prototype, 'shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva', _clearGetShadowRGBACache);
Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva', _clearFillPatternCache);
Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva', _clearLinearGradientCache);
Shape.prototype.on.call(Shape.prototype, 'fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva', _clearRadialGradientCache);
Factory_1.Factory.addGetterSetter(Shape, 'stroke', undefined, (0, Validators_1.getStringOrGradientValidator)());
Factory_1.Factory.addGetterSetter(Shape, 'strokeWidth', 2, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Shape, 'fillAfterStrokeEnabled', false);
Factory_1.Factory.addGetterSetter(Shape, 'hitStrokeWidth', 'auto', (0, Validators_1.getNumberOrAutoValidator)());
Factory_1.Factory.addGetterSetter(Shape, 'strokeHitEnabled', true, (0, Validators_1.getBooleanValidator)());
Factory_1.Factory.addGetterSetter(Shape, 'perfectDrawEnabled', true, (0, Validators_1.getBooleanValidator)());
Factory_1.Factory.addGetterSetter(Shape, 'shadowForStrokeEnabled', true, (0, Validators_1.getBooleanValidator)());
Factory_1.Factory.addGetterSetter(Shape, 'lineJoin');
Factory_1.Factory.addGetterSetter(Shape, 'lineCap');
Factory_1.Factory.addGetterSetter(Shape, 'sceneFunc');
Factory_1.Factory.addGetterSetter(Shape, 'hitFunc');
Factory_1.Factory.addGetterSetter(Shape, 'dash');
Factory_1.Factory.addGetterSetter(Shape, 'dashOffset', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Shape, 'shadowColor', undefined, (0, Validators_1.getStringValidator)());
Factory_1.Factory.addGetterSetter(Shape, 'shadowBlur', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Shape, 'shadowOpacity', 1, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addComponentsGetterSetter(Shape, 'shadowOffset', ['x', 'y']);
Factory_1.Factory.addGetterSetter(Shape, 'shadowOffsetX', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Shape, 'shadowOffsetY', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternImage');
Factory_1.Factory.addGetterSetter(Shape, 'fill', undefined, (0, Validators_1.getStringOrGradientValidator)());
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternX', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternY', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientColorStops');
Factory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientColorStops');
Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientStartRadius', 0);
Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientEndRadius', 0);
Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientColorStops');
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternRepeat', 'repeat');
Factory_1.Factory.addGetterSetter(Shape, 'fillEnabled', true);
Factory_1.Factory.addGetterSetter(Shape, 'strokeEnabled', true);
Factory_1.Factory.addGetterSetter(Shape, 'shadowEnabled', true);
Factory_1.Factory.addGetterSetter(Shape, 'dashEnabled', true);
Factory_1.Factory.addGetterSetter(Shape, 'strokeScaleEnabled', true);
Factory_1.Factory.addGetterSetter(Shape, 'fillPriority', 'color');
Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillPatternOffset', ['x', 'y']);
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternOffsetX', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternOffsetY', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillPatternScale', ['x', 'y']);
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternScaleX', 1, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternScaleY', 1, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientStartPoint', [
'x',
'y',
]);
Factory_1.Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientStartPoint', [
'x',
'y',
]);
Factory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointX', 0);
Factory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointX', 0);
Factory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientStartPointY', 0);
Factory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientStartPointY', 0);
Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillLinearGradientEndPoint', [
'x',
'y',
]);
Factory_1.Factory.addComponentsGetterSetter(Shape, 'strokeLinearGradientEndPoint', [
'x',
'y',
]);
Factory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointX', 0);
Factory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointX', 0);
Factory_1.Factory.addGetterSetter(Shape, 'fillLinearGradientEndPointY', 0);
Factory_1.Factory.addGetterSetter(Shape, 'strokeLinearGradientEndPointY', 0);
Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientStartPoint', [
'x',
'y',
]);
Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointX', 0);
Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientStartPointY', 0);
Factory_1.Factory.addComponentsGetterSetter(Shape, 'fillRadialGradientEndPoint', [
'x',
'y',
]);
Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointX', 0);
Factory_1.Factory.addGetterSetter(Shape, 'fillRadialGradientEndPointY', 0);
Factory_1.Factory.addGetterSetter(Shape, 'fillPatternRotation', 0);
Factory_1.Factory.addGetterSetter(Shape, 'fillRule', undefined, (0, Validators_1.getStringValidator)());
Factory_1.Factory.backCompat(Shape, {
dashArray: 'dash',
getDashArray: 'getDash',
setDashArray: 'getDash',
drawFunc: 'sceneFunc',
getDrawFunc: 'getSceneFunc',
setDrawFunc: 'setSceneFunc',
drawHitFunc: 'hitFunc',
getDrawHitFunc: 'getHitFunc',
setDrawHitFunc: 'setHitFunc',
});

85
node_modules/konva/lib/Stage.d.ts generated vendored Normal file
View File

@@ -0,0 +1,85 @@
import { Container, ContainerConfig } from './Container.js';
import { SceneCanvas, HitCanvas } from './Canvas.js';
import { GetSet, Vector2d } from './types.js';
import { Shape } from './Shape.js';
import { Layer } from './Layer.js';
export interface StageConfig extends ContainerConfig {
container?: HTMLDivElement | string;
}
export declare const stages: Stage[];
export declare class Stage extends Container<Layer> {
content: HTMLDivElement;
pointerPos: Vector2d | null;
_pointerPositions: (Vector2d & {
id?: number;
})[];
_changedPointerPositions: (Vector2d & {
id: number;
})[];
bufferCanvas: SceneCanvas;
bufferHitCanvas: HitCanvas;
_mouseTargetShape: Shape;
_touchTargetShape: Shape;
_pointerTargetShape: Shape;
_mouseClickStartShape: Shape;
_touchClickStartShape: Shape;
_pointerClickStartShape: Shape;
_mouseClickEndShape: Shape;
_touchClickEndShape: Shape;
_pointerClickEndShape: Shape;
_mouseDblTimeout: any;
_touchDblTimeout: any;
_pointerDblTimeout: any;
constructor(config: StageConfig);
_validateAdd(child: any): void;
_checkVisibility(): void;
setContainer(container: any): this;
shouldDrawHit(): boolean;
clear(): this;
clone(obj?: any): this;
destroy(): this;
getPointerPosition(): Vector2d | null;
_getPointerById(id?: number): (Vector2d & {
id?: number;
}) | undefined;
getPointersPositions(): (Vector2d & {
id?: number;
})[];
getStage(): this;
getContent(): HTMLDivElement;
_toKonvaCanvas(config: any): SceneCanvas;
getIntersection(pos: Vector2d): Shape<import("./Shape.js").ShapeConfig> | null;
_resizeDOM(): void;
add(layer: Layer, ...rest: any[]): this;
getParent(): null;
getLayer(): null;
hasPointerCapture(pointerId: number): boolean;
setPointerCapture(pointerId: number): void;
releaseCapture(pointerId: number): void;
getLayers(): Layer[];
_bindContentEvents(): void;
_pointerenter(evt: PointerEvent): void;
_pointerover(evt: any): void;
_getTargetShape(evenType: any): Shape<import("./Shape.js").ShapeConfig> | null;
_pointerleave(evt: any): void;
_pointerdown(evt: TouchEvent | MouseEvent | PointerEvent): void;
_pointermove(evt: TouchEvent | MouseEvent | PointerEvent): void;
_pointerup(evt: any): void;
_contextmenu(evt: any): void;
_wheel(evt: any): void;
_pointercancel(evt: PointerEvent): void;
_lostpointercapture(evt: PointerEvent): void;
setPointersPositions(evt: any): void;
_setPointerPosition(evt: any): void;
_getContentPosition(): {
top: number;
left: number;
scaleX: number;
scaleY: number;
};
_buildDOM(): void;
cache(): this;
clearCache(): this;
batchDraw(): this;
container: GetSet<HTMLDivElement, this>;
}

705
node_modules/konva/lib/Stage.js generated vendored Normal file
View File

@@ -0,0 +1,705 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Stage = exports.stages = void 0;
const Util_1 = require("./Util");
const Factory_1 = require("./Factory");
const Container_1 = require("./Container");
const Global_1 = require("./Global");
const Canvas_1 = require("./Canvas");
const DragAndDrop_1 = require("./DragAndDrop");
const Global_2 = require("./Global");
const PointerEvents = require("./PointerEvents");
const STAGE = 'Stage', STRING = 'string', PX = 'px', MOUSEOUT = 'mouseout', MOUSELEAVE = 'mouseleave', MOUSEOVER = 'mouseover', MOUSEENTER = 'mouseenter', MOUSEMOVE = 'mousemove', MOUSEDOWN = 'mousedown', MOUSEUP = 'mouseup', POINTERMOVE = 'pointermove', POINTERDOWN = 'pointerdown', POINTERUP = 'pointerup', POINTERCANCEL = 'pointercancel', LOSTPOINTERCAPTURE = 'lostpointercapture', POINTEROUT = 'pointerout', POINTERLEAVE = 'pointerleave', POINTEROVER = 'pointerover', POINTERENTER = 'pointerenter', CONTEXTMENU = 'contextmenu', TOUCHSTART = 'touchstart', TOUCHEND = 'touchend', TOUCHMOVE = 'touchmove', TOUCHCANCEL = 'touchcancel', WHEEL = 'wheel', MAX_LAYERS_NUMBER = 5, EVENTS = [
[MOUSEENTER, '_pointerenter'],
[MOUSEDOWN, '_pointerdown'],
[MOUSEMOVE, '_pointermove'],
[MOUSEUP, '_pointerup'],
[MOUSELEAVE, '_pointerleave'],
[TOUCHSTART, '_pointerdown'],
[TOUCHMOVE, '_pointermove'],
[TOUCHEND, '_pointerup'],
[TOUCHCANCEL, '_pointercancel'],
[MOUSEOVER, '_pointerover'],
[WHEEL, '_wheel'],
[CONTEXTMENU, '_contextmenu'],
[POINTERDOWN, '_pointerdown'],
[POINTERMOVE, '_pointermove'],
[POINTERUP, '_pointerup'],
[POINTERCANCEL, '_pointercancel'],
[POINTERLEAVE, '_pointerleave'],
[LOSTPOINTERCAPTURE, '_lostpointercapture'],
];
const EVENTS_MAP = {
mouse: {
[POINTEROUT]: MOUSEOUT,
[POINTERLEAVE]: MOUSELEAVE,
[POINTEROVER]: MOUSEOVER,
[POINTERENTER]: MOUSEENTER,
[POINTERMOVE]: MOUSEMOVE,
[POINTERDOWN]: MOUSEDOWN,
[POINTERUP]: MOUSEUP,
[POINTERCANCEL]: 'mousecancel',
pointerclick: 'click',
pointerdblclick: 'dblclick',
},
touch: {
[POINTEROUT]: 'touchout',
[POINTERLEAVE]: 'touchleave',
[POINTEROVER]: 'touchover',
[POINTERENTER]: 'touchenter',
[POINTERMOVE]: TOUCHMOVE,
[POINTERDOWN]: TOUCHSTART,
[POINTERUP]: TOUCHEND,
[POINTERCANCEL]: TOUCHCANCEL,
pointerclick: 'tap',
pointerdblclick: 'dbltap',
},
pointer: {
[POINTEROUT]: POINTEROUT,
[POINTERLEAVE]: POINTERLEAVE,
[POINTEROVER]: POINTEROVER,
[POINTERENTER]: POINTERENTER,
[POINTERMOVE]: POINTERMOVE,
[POINTERDOWN]: POINTERDOWN,
[POINTERUP]: POINTERUP,
[POINTERCANCEL]: POINTERCANCEL,
pointerclick: 'pointerclick',
pointerdblclick: 'pointerdblclick',
},
};
const getEventType = (type) => {
if (type.indexOf('pointer') >= 0) {
return 'pointer';
}
if (type.indexOf('touch') >= 0) {
return 'touch';
}
return 'mouse';
};
const getEventsMap = (eventType) => {
const type = getEventType(eventType);
if (type === 'pointer') {
return Global_1.Konva.pointerEventsEnabled && EVENTS_MAP.pointer;
}
if (type === 'touch') {
return EVENTS_MAP.touch;
}
if (type === 'mouse') {
return EVENTS_MAP.mouse;
}
};
function checkNoClip(attrs = {}) {
if (attrs.clipFunc || attrs.clipWidth || attrs.clipHeight) {
Util_1.Util.warn('Stage does not support clipping. Please use clip for Layers or Groups.');
}
return attrs;
}
const NO_POINTERS_MESSAGE = `Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);`;
exports.stages = [];
class Stage extends Container_1.Container {
constructor(config) {
super(checkNoClip(config));
this._pointerPositions = [];
this._changedPointerPositions = [];
this._buildDOM();
this._bindContentEvents();
exports.stages.push(this);
this.on('widthChange.konva heightChange.konva', this._resizeDOM);
this.on('visibleChange.konva', this._checkVisibility);
this.on('clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva', () => {
checkNoClip(this.attrs);
});
this._checkVisibility();
}
_validateAdd(child) {
const isLayer = child.getType() === 'Layer';
const isFastLayer = child.getType() === 'FastLayer';
const valid = isLayer || isFastLayer;
if (!valid) {
Util_1.Util.throw('You may only add layers to the stage.');
}
}
_checkVisibility() {
if (!this.content) {
return;
}
const style = this.visible() ? '' : 'none';
this.content.style.display = style;
}
setContainer(container) {
if (typeof container === STRING) {
let id;
if (container.charAt(0) === '.') {
const className = container.slice(1);
container = document.getElementsByClassName(className)[0];
}
else {
if (container.charAt(0) !== '#') {
id = container;
}
else {
id = container.slice(1);
}
container = document.getElementById(id);
}
if (!container) {
throw 'Can not find container in document with id ' + id;
}
}
this._setAttr('container', container);
if (this.content) {
if (this.content.parentElement) {
this.content.parentElement.removeChild(this.content);
}
container.appendChild(this.content);
}
return this;
}
shouldDrawHit() {
return true;
}
clear() {
const layers = this.children, len = layers.length;
for (let n = 0; n < len; n++) {
layers[n].clear();
}
return this;
}
clone(obj) {
if (!obj) {
obj = {};
}
obj.container =
typeof document !== 'undefined' && document.createElement('div');
return Container_1.Container.prototype.clone.call(this, obj);
}
destroy() {
super.destroy();
const content = this.content;
if (content && Util_1.Util._isInDocument(content)) {
this.container().removeChild(content);
}
const index = exports.stages.indexOf(this);
if (index > -1) {
exports.stages.splice(index, 1);
}
Util_1.Util.releaseCanvas(this.bufferCanvas._canvas, this.bufferHitCanvas._canvas);
return this;
}
getPointerPosition() {
const pos = this._pointerPositions[0] || this._changedPointerPositions[0];
if (!pos) {
Util_1.Util.warn(NO_POINTERS_MESSAGE);
return null;
}
return {
x: pos.x,
y: pos.y,
};
}
_getPointerById(id) {
return this._pointerPositions.find((p) => p.id === id);
}
getPointersPositions() {
return this._pointerPositions;
}
getStage() {
return this;
}
getContent() {
return this.content;
}
_toKonvaCanvas(config) {
config = config || {};
config.x = config.x || 0;
config.y = config.y || 0;
config.width = config.width || this.width();
config.height = config.height || this.height();
const canvas = new Canvas_1.SceneCanvas({
width: config.width,
height: config.height,
pixelRatio: config.pixelRatio || 1,
});
const _context = canvas.getContext()._context;
const layers = this.children;
if (config.x || config.y) {
_context.translate(-1 * config.x, -1 * config.y);
}
layers.forEach(function (layer) {
if (!layer.isVisible()) {
return;
}
const layerCanvas = layer._toKonvaCanvas(config);
_context.drawImage(layerCanvas._canvas, config.x, config.y, layerCanvas.getWidth() / layerCanvas.getPixelRatio(), layerCanvas.getHeight() / layerCanvas.getPixelRatio());
});
return canvas;
}
getIntersection(pos) {
if (!pos) {
return null;
}
const layers = this.children, len = layers.length, end = len - 1;
for (let n = end; n >= 0; n--) {
const shape = layers[n].getIntersection(pos);
if (shape) {
return shape;
}
}
return null;
}
_resizeDOM() {
const width = this.width();
const height = this.height();
if (this.content) {
this.content.style.width = width + PX;
this.content.style.height = height + PX;
}
this.bufferCanvas.setSize(width, height);
this.bufferHitCanvas.setSize(width, height);
this.children.forEach((layer) => {
layer.setSize({ width, height });
layer.draw();
});
}
add(layer, ...rest) {
if (arguments.length > 1) {
for (let i = 0; i < arguments.length; i++) {
this.add(arguments[i]);
}
return this;
}
super.add(layer);
const length = this.children.length;
if (length > MAX_LAYERS_NUMBER) {
Util_1.Util.warn('The stage has ' +
length +
' layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group.');
}
layer.setSize({ width: this.width(), height: this.height() });
layer.draw();
if (Global_1.Konva.isBrowser) {
this.content.appendChild(layer.canvas._canvas);
}
return this;
}
getParent() {
return null;
}
getLayer() {
return null;
}
hasPointerCapture(pointerId) {
return PointerEvents.hasPointerCapture(pointerId, this);
}
setPointerCapture(pointerId) {
PointerEvents.setPointerCapture(pointerId, this);
}
releaseCapture(pointerId) {
PointerEvents.releaseCapture(pointerId, this);
}
getLayers() {
return this.children;
}
_bindContentEvents() {
if (!Global_1.Konva.isBrowser) {
return;
}
EVENTS.forEach(([event, methodName]) => {
this.content.addEventListener(event, (evt) => {
this[methodName](evt);
}, { passive: false });
});
}
_pointerenter(evt) {
this.setPointersPositions(evt);
const events = getEventsMap(evt.type);
if (events) {
this._fire(events.pointerenter, {
evt: evt,
target: this,
currentTarget: this,
});
}
}
_pointerover(evt) {
this.setPointersPositions(evt);
const events = getEventsMap(evt.type);
if (events) {
this._fire(events.pointerover, {
evt: evt,
target: this,
currentTarget: this,
});
}
}
_getTargetShape(evenType) {
let shape = this[evenType + 'targetShape'];
if (shape && !shape.getStage()) {
shape = null;
}
return shape;
}
_pointerleave(evt) {
const events = getEventsMap(evt.type);
const eventType = getEventType(evt.type);
if (!events) {
return;
}
this.setPointersPositions(evt);
const targetShape = this._getTargetShape(eventType);
const eventsEnabled = !(Global_1.Konva.isDragging() || Global_1.Konva.isTransforming()) || Global_1.Konva.hitOnDragEnabled;
if (targetShape && eventsEnabled) {
targetShape._fireAndBubble(events.pointerout, { evt: evt });
targetShape._fireAndBubble(events.pointerleave, { evt: evt });
this._fire(events.pointerleave, {
evt: evt,
target: this,
currentTarget: this,
});
this[eventType + 'targetShape'] = null;
}
else if (eventsEnabled) {
this._fire(events.pointerleave, {
evt: evt,
target: this,
currentTarget: this,
});
this._fire(events.pointerout, {
evt: evt,
target: this,
currentTarget: this,
});
}
this.pointerPos = null;
this._pointerPositions = [];
}
_pointerdown(evt) {
const events = getEventsMap(evt.type);
const eventType = getEventType(evt.type);
if (!events) {
return;
}
this.setPointersPositions(evt);
let triggeredOnShape = false;
this._changedPointerPositions.forEach((pos) => {
const shape = this.getIntersection(pos);
DragAndDrop_1.DD.justDragged = false;
Global_1.Konva['_' + eventType + 'ListenClick'] = true;
if (!shape || !shape.isListening()) {
this[eventType + 'ClickStartShape'] = undefined;
return;
}
if (Global_1.Konva.capturePointerEventsEnabled) {
shape.setPointerCapture(pos.id);
}
this[eventType + 'ClickStartShape'] = shape;
shape._fireAndBubble(events.pointerdown, {
evt: evt,
pointerId: pos.id,
});
triggeredOnShape = true;
const isTouch = evt.type.indexOf('touch') >= 0;
if (shape.preventDefault() && evt.cancelable && isTouch) {
evt.preventDefault();
}
});
if (!triggeredOnShape) {
this._fire(events.pointerdown, {
evt: evt,
target: this,
currentTarget: this,
pointerId: this._pointerPositions[0].id,
});
}
}
_pointermove(evt) {
const events = getEventsMap(evt.type);
const eventType = getEventType(evt.type);
if (!events) {
return;
}
if (Global_1.Konva.isDragging() && DragAndDrop_1.DD.node.preventDefault() && evt.cancelable) {
evt.preventDefault();
}
this.setPointersPositions(evt);
const eventsEnabled = !(Global_1.Konva.isDragging() || Global_1.Konva.isTransforming()) || Global_1.Konva.hitOnDragEnabled;
if (!eventsEnabled) {
return;
}
const processedShapesIds = {};
let triggeredOnShape = false;
const targetShape = this._getTargetShape(eventType);
this._changedPointerPositions.forEach((pos) => {
const shape = (PointerEvents.getCapturedShape(pos.id) ||
this.getIntersection(pos));
const pointerId = pos.id;
const event = { evt: evt, pointerId };
const differentTarget = targetShape !== shape;
if (differentTarget && targetShape) {
targetShape._fireAndBubble(events.pointerout, { ...event }, shape);
targetShape._fireAndBubble(events.pointerleave, { ...event }, shape);
}
if (shape) {
if (processedShapesIds[shape._id]) {
return;
}
processedShapesIds[shape._id] = true;
}
if (shape && shape.isListening()) {
triggeredOnShape = true;
if (differentTarget) {
shape._fireAndBubble(events.pointerover, { ...event }, targetShape);
shape._fireAndBubble(events.pointerenter, { ...event }, targetShape);
this[eventType + 'targetShape'] = shape;
}
shape._fireAndBubble(events.pointermove, { ...event });
}
else {
if (targetShape) {
this._fire(events.pointerover, {
evt: evt,
target: this,
currentTarget: this,
pointerId,
});
this[eventType + 'targetShape'] = null;
}
}
});
if (!triggeredOnShape) {
this._fire(events.pointermove, {
evt: evt,
target: this,
currentTarget: this,
pointerId: this._changedPointerPositions[0].id,
});
}
}
_pointerup(evt) {
const events = getEventsMap(evt.type);
const eventType = getEventType(evt.type);
if (!events) {
return;
}
this.setPointersPositions(evt);
const clickStartShape = this[eventType + 'ClickStartShape'];
const clickEndShape = this[eventType + 'ClickEndShape'];
const processedShapesIds = {};
let triggeredOnShape = false;
this._changedPointerPositions.forEach((pos) => {
const shape = (PointerEvents.getCapturedShape(pos.id) ||
this.getIntersection(pos));
if (shape) {
shape.releaseCapture(pos.id);
if (processedShapesIds[shape._id]) {
return;
}
processedShapesIds[shape._id] = true;
}
const pointerId = pos.id;
const event = { evt: evt, pointerId };
let fireDblClick = false;
if (Global_1.Konva['_' + eventType + 'InDblClickWindow']) {
fireDblClick = true;
clearTimeout(this[eventType + 'DblTimeout']);
}
else if (!DragAndDrop_1.DD.justDragged) {
Global_1.Konva['_' + eventType + 'InDblClickWindow'] = true;
clearTimeout(this[eventType + 'DblTimeout']);
}
this[eventType + 'DblTimeout'] = setTimeout(function () {
Global_1.Konva['_' + eventType + 'InDblClickWindow'] = false;
}, Global_1.Konva.dblClickWindow);
if (shape && shape.isListening()) {
triggeredOnShape = true;
this[eventType + 'ClickEndShape'] = shape;
shape._fireAndBubble(events.pointerup, { ...event });
if (Global_1.Konva['_' + eventType + 'ListenClick'] &&
clickStartShape &&
clickStartShape === shape) {
shape._fireAndBubble(events.pointerclick, { ...event });
if (fireDblClick && clickEndShape && clickEndShape === shape) {
shape._fireAndBubble(events.pointerdblclick, { ...event });
}
}
}
else {
this[eventType + 'ClickEndShape'] = null;
if (Global_1.Konva['_' + eventType + 'ListenClick']) {
this._fire(events.pointerclick, {
evt: evt,
target: this,
currentTarget: this,
pointerId,
});
}
if (fireDblClick) {
this._fire(events.pointerdblclick, {
evt: evt,
target: this,
currentTarget: this,
pointerId,
});
}
}
});
if (!triggeredOnShape) {
this._fire(events.pointerup, {
evt: evt,
target: this,
currentTarget: this,
pointerId: this._changedPointerPositions[0].id,
});
}
Global_1.Konva['_' + eventType + 'ListenClick'] = false;
if (evt.cancelable && eventType !== 'touch' && eventType !== 'pointer') {
evt.preventDefault();
}
}
_contextmenu(evt) {
this.setPointersPositions(evt);
const shape = this.getIntersection(this.getPointerPosition());
if (shape && shape.isListening()) {
shape._fireAndBubble(CONTEXTMENU, { evt: evt });
}
else {
this._fire(CONTEXTMENU, {
evt: evt,
target: this,
currentTarget: this,
});
}
}
_wheel(evt) {
this.setPointersPositions(evt);
const shape = this.getIntersection(this.getPointerPosition());
if (shape && shape.isListening()) {
shape._fireAndBubble(WHEEL, { evt: evt });
}
else {
this._fire(WHEEL, {
evt: evt,
target: this,
currentTarget: this,
});
}
}
_pointercancel(evt) {
this.setPointersPositions(evt);
const shape = PointerEvents.getCapturedShape(evt.pointerId) ||
this.getIntersection(this.getPointerPosition());
if (shape) {
shape._fireAndBubble(POINTERUP, PointerEvents.createEvent(evt));
}
PointerEvents.releaseCapture(evt.pointerId);
}
_lostpointercapture(evt) {
PointerEvents.releaseCapture(evt.pointerId);
}
setPointersPositions(evt) {
const contentPosition = this._getContentPosition();
let x = null, y = null;
evt = evt ? evt : window.event;
if (evt.touches !== undefined) {
this._pointerPositions = [];
this._changedPointerPositions = [];
Array.prototype.forEach.call(evt.touches, (touch) => {
this._pointerPositions.push({
id: touch.identifier,
x: (touch.clientX - contentPosition.left) / contentPosition.scaleX,
y: (touch.clientY - contentPosition.top) / contentPosition.scaleY,
});
});
Array.prototype.forEach.call(evt.changedTouches || evt.touches, (touch) => {
this._changedPointerPositions.push({
id: touch.identifier,
x: (touch.clientX - contentPosition.left) / contentPosition.scaleX,
y: (touch.clientY - contentPosition.top) / contentPosition.scaleY,
});
});
}
else {
x = (evt.clientX - contentPosition.left) / contentPosition.scaleX;
y = (evt.clientY - contentPosition.top) / contentPosition.scaleY;
this.pointerPos = {
x: x,
y: y,
};
this._pointerPositions = [{ x, y, id: Util_1.Util._getFirstPointerId(evt) }];
this._changedPointerPositions = [
{ x, y, id: Util_1.Util._getFirstPointerId(evt) },
];
}
}
_setPointerPosition(evt) {
Util_1.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.');
this.setPointersPositions(evt);
}
_getContentPosition() {
if (!this.content || !this.content.getBoundingClientRect) {
return {
top: 0,
left: 0,
scaleX: 1,
scaleY: 1,
};
}
const rect = this.content.getBoundingClientRect();
return {
top: rect.top,
left: rect.left,
scaleX: rect.width / this.content.clientWidth || 1,
scaleY: rect.height / this.content.clientHeight || 1,
};
}
_buildDOM() {
this.bufferCanvas = new Canvas_1.SceneCanvas({
width: this.width(),
height: this.height(),
});
this.bufferHitCanvas = new Canvas_1.HitCanvas({
pixelRatio: 1,
width: this.width(),
height: this.height(),
});
if (!Global_1.Konva.isBrowser) {
return;
}
const container = this.container();
if (!container) {
throw 'Stage has no container. A container is required.';
}
container.innerHTML = '';
this.content = document.createElement('div');
this.content.style.position = 'relative';
this.content.style.userSelect = 'none';
this.content.className = 'konvajs-content';
this.content.setAttribute('role', 'presentation');
container.appendChild(this.content);
this._resizeDOM();
}
cache() {
Util_1.Util.warn('Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.');
return this;
}
clearCache() {
return this;
}
batchDraw() {
this.getChildren().forEach(function (layer) {
layer.batchDraw();
});
return this;
}
}
exports.Stage = Stage;
Stage.prototype.nodeType = STAGE;
(0, Global_2._registerNode)(Stage);
Factory_1.Factory.addGetterSetter(Stage, 'container');
if (Global_1.Konva.isBrowser) {
document.addEventListener('visibilitychange', () => {
exports.stages.forEach((stage) => {
stage.batchDraw();
});
});
}

86
node_modules/konva/lib/Tween.d.ts generated vendored Normal file
View File

@@ -0,0 +1,86 @@
import { Animation } from './Animation.js';
import { Node, NodeConfig } from './Node.js';
declare class TweenEngine {
prop: string;
propFunc: Function;
begin: number;
_pos: number;
duration: number;
prevPos: number;
yoyo: boolean;
_time: number;
_position: number;
_startTime: number;
_finish: number;
func: Function;
_change: number;
state: number;
onPlay: Function;
onReverse: Function;
onPause: Function;
onReset: Function;
onFinish: Function;
onUpdate: Function;
constructor(prop: any, propFunc: any, func: any, begin: any, finish: any, duration: any, yoyo: any);
fire(str: any): void;
setTime(t: any): void;
getTime(): number;
setPosition(p: any): void;
getPosition(t: any): any;
play(): void;
reverse(): void;
seek(t: any): void;
reset(): void;
finish(): void;
update(): void;
onEnterFrame(): void;
pause(): void;
getTimer(): number;
}
export interface TweenConfig extends NodeConfig {
onFinish?: Function;
onUpdate?: Function;
duration?: number;
node: Node;
}
export declare class Tween {
static attrs: {};
static tweens: {};
node: Node;
anim: Animation;
tween: TweenEngine;
_id: number;
onFinish: Function | undefined;
onReset: Function | undefined;
onUpdate: Function | undefined;
constructor(config: TweenConfig);
_addAttr(key: any, end: any): void;
_tweenFunc(i: any): void;
_addListeners(): void;
play(): this;
reverse(): this;
reset(): this;
seek(t: any): this;
pause(): this;
finish(): this;
destroy(): void;
}
export declare const Easings: {
BackEaseIn(t: any, b: any, c: any, d: any): any;
BackEaseOut(t: any, b: any, c: any, d: any): any;
BackEaseInOut(t: any, b: any, c: any, d: any): any;
ElasticEaseIn(t: any, b: any, c: any, d: any, a: any, p: any): any;
ElasticEaseOut(t: any, b: any, c: any, d: any, a: any, p: any): any;
ElasticEaseInOut(t: any, b: any, c: any, d: any, a: any, p: any): any;
BounceEaseOut(t: any, b: any, c: any, d: any): any;
BounceEaseIn(t: any, b: any, c: any, d: any): any;
BounceEaseInOut(t: any, b: any, c: any, d: any): any;
EaseIn(t: any, b: any, c: any, d: any): any;
EaseOut(t: any, b: any, c: any, d: any): any;
EaseInOut(t: any, b: any, c: any, d: any): any;
StrongEaseIn(t: any, b: any, c: any, d: any): any;
StrongEaseOut(t: any, b: any, c: any, d: any): any;
StrongEaseInOut(t: any, b: any, c: any, d: any): any;
Linear(t: any, b: any, c: any, d: any): any;
};
export {};

535
node_modules/konva/lib/Tween.js generated vendored Normal file
View File

@@ -0,0 +1,535 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Easings = exports.Tween = void 0;
const Util_1 = require("./Util");
const Animation_1 = require("./Animation");
const Node_1 = require("./Node");
const Global_1 = require("./Global");
const blacklist = {
node: 1,
duration: 1,
easing: 1,
onFinish: 1,
yoyo: 1,
}, PAUSED = 1, PLAYING = 2, REVERSING = 3, colorAttrs = ['fill', 'stroke', 'shadowColor'];
let idCounter = 0;
class TweenEngine {
constructor(prop, propFunc, func, begin, finish, duration, yoyo) {
this.prop = prop;
this.propFunc = propFunc;
this.begin = begin;
this._pos = begin;
this.duration = duration;
this._change = 0;
this.prevPos = 0;
this.yoyo = yoyo;
this._time = 0;
this._position = 0;
this._startTime = 0;
this._finish = 0;
this.func = func;
this._change = finish - this.begin;
this.pause();
}
fire(str) {
const handler = this[str];
if (handler) {
handler();
}
}
setTime(t) {
if (t > this.duration) {
if (this.yoyo) {
this._time = this.duration;
this.reverse();
}
else {
this.finish();
}
}
else if (t < 0) {
if (this.yoyo) {
this._time = 0;
this.play();
}
else {
this.reset();
}
}
else {
this._time = t;
this.update();
}
}
getTime() {
return this._time;
}
setPosition(p) {
this.prevPos = this._pos;
this.propFunc(p);
this._pos = p;
}
getPosition(t) {
if (t === undefined) {
t = this._time;
}
return this.func(t, this.begin, this._change, this.duration);
}
play() {
this.state = PLAYING;
this._startTime = this.getTimer() - this._time;
this.onEnterFrame();
this.fire('onPlay');
}
reverse() {
this.state = REVERSING;
this._time = this.duration - this._time;
this._startTime = this.getTimer() - this._time;
this.onEnterFrame();
this.fire('onReverse');
}
seek(t) {
this.pause();
this._time = t;
this.update();
this.fire('onSeek');
}
reset() {
this.pause();
this._time = 0;
this.update();
this.fire('onReset');
}
finish() {
this.pause();
this._time = this.duration;
this.update();
this.fire('onFinish');
}
update() {
this.setPosition(this.getPosition(this._time));
this.fire('onUpdate');
}
onEnterFrame() {
const t = this.getTimer() - this._startTime;
if (this.state === PLAYING) {
this.setTime(t);
}
else if (this.state === REVERSING) {
this.setTime(this.duration - t);
}
}
pause() {
this.state = PAUSED;
this.fire('onPause');
}
getTimer() {
return new Date().getTime();
}
}
class Tween {
constructor(config) {
const that = this, node = config.node, nodeId = node._id, easing = config.easing || exports.Easings.Linear, yoyo = !!config.yoyo;
let duration, key;
if (typeof config.duration === 'undefined') {
duration = 0.3;
}
else if (config.duration === 0) {
duration = 0.001;
}
else {
duration = config.duration;
}
this.node = node;
this._id = idCounter++;
const layers = node.getLayer() ||
(node instanceof Global_1.Konva['Stage'] ? node.getLayers() : null);
if (!layers) {
Util_1.Util.error('Tween constructor have `node` that is not in a layer. Please add node into layer first.');
}
this.anim = new Animation_1.Animation(function () {
that.tween.onEnterFrame();
}, layers);
this.tween = new TweenEngine(key, function (i) {
that._tweenFunc(i);
}, easing, 0, 1, duration * 1000, yoyo);
this._addListeners();
if (!Tween.attrs[nodeId]) {
Tween.attrs[nodeId] = {};
}
if (!Tween.attrs[nodeId][this._id]) {
Tween.attrs[nodeId][this._id] = {};
}
if (!Tween.tweens[nodeId]) {
Tween.tweens[nodeId] = {};
}
for (key in config) {
if (blacklist[key] === undefined) {
this._addAttr(key, config[key]);
}
}
this.reset();
this.onFinish = config.onFinish;
this.onReset = config.onReset;
this.onUpdate = config.onUpdate;
}
_addAttr(key, end) {
const node = this.node, nodeId = node._id;
let diff, len, trueEnd, trueStart, endRGBA;
const tweenId = Tween.tweens[nodeId][key];
if (tweenId) {
delete Tween.attrs[nodeId][tweenId][key];
}
let start = node.getAttr(key);
if (Util_1.Util._isArray(end)) {
diff = [];
len = Math.max(end.length, start.length);
if (key === 'points' && end.length !== start.length) {
if (end.length > start.length) {
trueStart = start;
start = Util_1.Util._prepareArrayForTween(start, end, node.closed());
}
else {
trueEnd = end;
end = Util_1.Util._prepareArrayForTween(end, start, node.closed());
}
}
if (key.indexOf('fill') === 0) {
for (let n = 0; n < len; n++) {
if (n % 2 === 0) {
diff.push(end[n] - start[n]);
}
else {
const startRGBA = Util_1.Util.colorToRGBA(start[n]);
endRGBA = Util_1.Util.colorToRGBA(end[n]);
start[n] = startRGBA;
diff.push({
r: endRGBA.r - startRGBA.r,
g: endRGBA.g - startRGBA.g,
b: endRGBA.b - startRGBA.b,
a: endRGBA.a - startRGBA.a,
});
}
}
}
else {
for (let n = 0; n < len; n++) {
diff.push(end[n] - start[n]);
}
}
}
else if (colorAttrs.indexOf(key) !== -1) {
start = Util_1.Util.colorToRGBA(start);
endRGBA = Util_1.Util.colorToRGBA(end);
diff = {
r: endRGBA.r - start.r,
g: endRGBA.g - start.g,
b: endRGBA.b - start.b,
a: endRGBA.a - start.a,
};
}
else {
diff = end - start;
}
Tween.attrs[nodeId][this._id][key] = {
start: start,
diff: diff,
end: end,
trueEnd: trueEnd,
trueStart: trueStart,
};
Tween.tweens[nodeId][key] = this._id;
}
_tweenFunc(i) {
const node = this.node, attrs = Tween.attrs[node._id][this._id];
let key, attr, start, diff, newVal, n, len, end;
for (key in attrs) {
attr = attrs[key];
start = attr.start;
diff = attr.diff;
end = attr.end;
if (Util_1.Util._isArray(start)) {
newVal = [];
len = Math.max(start.length, end.length);
if (key.indexOf('fill') === 0) {
for (n = 0; n < len; n++) {
if (n % 2 === 0) {
newVal.push((start[n] || 0) + diff[n] * i);
}
else {
newVal.push('rgba(' +
Math.round(start[n].r + diff[n].r * i) +
',' +
Math.round(start[n].g + diff[n].g * i) +
',' +
Math.round(start[n].b + diff[n].b * i) +
',' +
(start[n].a + diff[n].a * i) +
')');
}
}
}
else {
for (n = 0; n < len; n++) {
newVal.push((start[n] || 0) + diff[n] * i);
}
}
}
else if (colorAttrs.indexOf(key) !== -1) {
newVal =
'rgba(' +
Math.round(start.r + diff.r * i) +
',' +
Math.round(start.g + diff.g * i) +
',' +
Math.round(start.b + diff.b * i) +
',' +
(start.a + diff.a * i) +
')';
}
else {
newVal = start + diff * i;
}
node.setAttr(key, newVal);
}
}
_addListeners() {
this.tween.onPlay = () => {
this.anim.start();
};
this.tween.onReverse = () => {
this.anim.start();
};
this.tween.onPause = () => {
this.anim.stop();
};
this.tween.onFinish = () => {
const node = this.node;
const attrs = Tween.attrs[node._id][this._id];
if (attrs.points && attrs.points.trueEnd) {
node.setAttr('points', attrs.points.trueEnd);
}
if (this.onFinish) {
this.onFinish.call(this);
}
};
this.tween.onReset = () => {
const node = this.node;
const attrs = Tween.attrs[node._id][this._id];
if (attrs.points && attrs.points.trueStart) {
node.points(attrs.points.trueStart);
}
if (this.onReset) {
this.onReset();
}
};
this.tween.onUpdate = () => {
if (this.onUpdate) {
this.onUpdate.call(this);
}
};
}
play() {
this.tween.play();
return this;
}
reverse() {
this.tween.reverse();
return this;
}
reset() {
this.tween.reset();
return this;
}
seek(t) {
this.tween.seek(t * 1000);
return this;
}
pause() {
this.tween.pause();
return this;
}
finish() {
this.tween.finish();
return this;
}
destroy() {
const nodeId = this.node._id, thisId = this._id, attrs = Tween.tweens[nodeId];
this.pause();
if (this.anim) {
this.anim.stop();
}
for (const key in attrs) {
delete Tween.tweens[nodeId][key];
}
delete Tween.attrs[nodeId][thisId];
if (Tween.tweens[nodeId]) {
if (Object.keys(Tween.tweens[nodeId]).length === 0) {
delete Tween.tweens[nodeId];
}
if (Object.keys(Tween.attrs[nodeId]).length === 0) {
delete Tween.attrs[nodeId];
}
}
}
}
exports.Tween = Tween;
Tween.attrs = {};
Tween.tweens = {};
Node_1.Node.prototype.to = function (params) {
const onFinish = params.onFinish;
params.node = this;
params.onFinish = function () {
this.destroy();
if (onFinish) {
onFinish();
}
};
const tween = new Tween(params);
tween.play();
};
exports.Easings = {
BackEaseIn(t, b, c, d) {
const s = 1.70158;
return c * (t /= d) * t * ((s + 1) * t - s) + b;
},
BackEaseOut(t, b, c, d) {
const s = 1.70158;
return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
},
BackEaseInOut(t, b, c, d) {
let s = 1.70158;
if ((t /= d / 2) < 1) {
return (c / 2) * (t * t * (((s *= 1.525) + 1) * t - s)) + b;
}
return (c / 2) * ((t -= 2) * t * (((s *= 1.525) + 1) * t + s) + 2) + b;
},
ElasticEaseIn(t, b, c, d, a, p) {
let s = 0;
if (t === 0) {
return b;
}
if ((t /= d) === 1) {
return b + c;
}
if (!p) {
p = d * 0.3;
}
if (!a || a < Math.abs(c)) {
a = c;
s = p / 4;
}
else {
s = (p / (2 * Math.PI)) * Math.asin(c / a);
}
return (-(a *
Math.pow(2, 10 * (t -= 1)) *
Math.sin(((t * d - s) * (2 * Math.PI)) / p)) + b);
},
ElasticEaseOut(t, b, c, d, a, p) {
let s = 0;
if (t === 0) {
return b;
}
if ((t /= d) === 1) {
return b + c;
}
if (!p) {
p = d * 0.3;
}
if (!a || a < Math.abs(c)) {
a = c;
s = p / 4;
}
else {
s = (p / (2 * Math.PI)) * Math.asin(c / a);
}
return (a * Math.pow(2, -10 * t) * Math.sin(((t * d - s) * (2 * Math.PI)) / p) +
c +
b);
},
ElasticEaseInOut(t, b, c, d, a, p) {
let s = 0;
if (t === 0) {
return b;
}
if ((t /= d / 2) === 2) {
return b + c;
}
if (!p) {
p = d * (0.3 * 1.5);
}
if (!a || a < Math.abs(c)) {
a = c;
s = p / 4;
}
else {
s = (p / (2 * Math.PI)) * Math.asin(c / a);
}
if (t < 1) {
return (-0.5 *
(a *
Math.pow(2, 10 * (t -= 1)) *
Math.sin(((t * d - s) * (2 * Math.PI)) / p)) +
b);
}
return (a *
Math.pow(2, -10 * (t -= 1)) *
Math.sin(((t * d - s) * (2 * Math.PI)) / p) *
0.5 +
c +
b);
},
BounceEaseOut(t, b, c, d) {
if ((t /= d) < 1 / 2.75) {
return c * (7.5625 * t * t) + b;
}
else if (t < 2 / 2.75) {
return c * (7.5625 * (t -= 1.5 / 2.75) * t + 0.75) + b;
}
else if (t < 2.5 / 2.75) {
return c * (7.5625 * (t -= 2.25 / 2.75) * t + 0.9375) + b;
}
else {
return c * (7.5625 * (t -= 2.625 / 2.75) * t + 0.984375) + b;
}
},
BounceEaseIn(t, b, c, d) {
return c - exports.Easings.BounceEaseOut(d - t, 0, c, d) + b;
},
BounceEaseInOut(t, b, c, d) {
if (t < d / 2) {
return exports.Easings.BounceEaseIn(t * 2, 0, c, d) * 0.5 + b;
}
else {
return exports.Easings.BounceEaseOut(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;
}
},
EaseIn(t, b, c, d) {
return c * (t /= d) * t + b;
},
EaseOut(t, b, c, d) {
return -c * (t /= d) * (t - 2) + b;
},
EaseInOut(t, b, c, d) {
if ((t /= d / 2) < 1) {
return (c / 2) * t * t + b;
}
return (-c / 2) * (--t * (t - 2) - 1) + b;
},
StrongEaseIn(t, b, c, d) {
return c * (t /= d) * t * t * t * t + b;
},
StrongEaseOut(t, b, c, d) {
return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
},
StrongEaseInOut(t, b, c, d) {
if ((t /= d / 2) < 1) {
return (c / 2) * t * t * t * t * t + b;
}
return (c / 2) * ((t -= 2) * t * t * t * t + 2) + b;
},
Linear(t, b, c, d) {
return (c * t) / d + b;
},
};

131
node_modules/konva/lib/Util.d.ts generated vendored Normal file
View File

@@ -0,0 +1,131 @@
import { Context } from './Context.js';
import { IRect, RGB, Vector2d } from './types.js';
export declare class Transform {
m: Array<number>;
dirty: boolean;
constructor(m?: number[]);
reset(): void;
copy(): Transform;
copyInto(tr: Transform): void;
point(point: Vector2d): {
x: number;
y: number;
};
translate(x: number, y: number): this;
scale(sx: number, sy: number): this;
rotate(rad: number): this;
getTranslation(): {
x: number;
y: number;
};
skew(sx: number, sy: number): this;
multiply(matrix: Transform): this;
invert(): this;
getMatrix(): number[];
decompose(): {
x: number;
y: number;
rotation: number;
scaleX: number;
scaleY: number;
skewX: number;
skewY: number;
};
}
export declare const Util: {
_isElement(obj: any): obj is Element;
_isFunction(obj: any): boolean;
_isPlainObject(obj: any): boolean;
_isArray(obj: any): obj is Array<any>;
_isNumber(obj: any): obj is number;
_isString(obj: any): obj is string;
_isBoolean(obj: any): obj is boolean;
isObject(val: any): val is object;
isValidSelector(selector: any): boolean;
_sign(number: number): 1 | -1;
requestAnimFrame(callback: Function): void;
createCanvasElement(): HTMLCanvasElement;
createImageElement(): HTMLImageElement;
_isInDocument(el: any): boolean;
_urlToImage(url: string, callback: Function): void;
_rgbToHex(r: number, g: number, b: number): string;
_hexToRgb(hex: string): RGB;
getRandomColor(): string;
getRGB(color: string): RGB;
colorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_namedColorToRBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | null;
_rgbColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_rgbaColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_hex8ColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_hex6ColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_hex4ColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_hex3ColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_hslColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
haveIntersection(r1: IRect, r2: IRect): boolean;
cloneObject<Any>(obj: Any): Any;
cloneArray(arr: Array<any>): any[];
degToRad(deg: number): number;
radToDeg(rad: number): number;
_degToRad(deg: number): number;
_radToDeg(rad: number): number;
_getRotation(radians: number): number;
_capitalize(str: string): string;
throw(str: string): never;
error(str: string): void;
warn(str: string): void;
each(obj: object, func: Function): void;
_inRange(val: number, left: number, right: number): boolean;
_getProjectionToSegment(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): any[];
_getProjectionToLine(pt: Vector2d, line: Array<Vector2d>, isClosed: boolean): Vector2d;
_prepareArrayForTween(startArray: any, endArray: any, isClosed: any): number[];
_prepareToStringify<T>(obj: any): T | null;
_assign<T, U>(target: T, source: U): T & U;
_getFirstPointerId(evt: any): any;
releaseCanvas(...canvases: HTMLCanvasElement[]): void;
drawRoundedRectPath(context: Context, width: number, height: number, cornerRadius: number | number[]): void;
};

806
node_modules/konva/lib/Util.js generated vendored Normal file
View File

@@ -0,0 +1,806 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Util = exports.Transform = void 0;
const Global_1 = require("./Global");
class Transform {
constructor(m = [1, 0, 0, 1, 0, 0]) {
this.dirty = false;
this.m = (m && m.slice()) || [1, 0, 0, 1, 0, 0];
}
reset() {
this.m[0] = 1;
this.m[1] = 0;
this.m[2] = 0;
this.m[3] = 1;
this.m[4] = 0;
this.m[5] = 0;
}
copy() {
return new Transform(this.m);
}
copyInto(tr) {
tr.m[0] = this.m[0];
tr.m[1] = this.m[1];
tr.m[2] = this.m[2];
tr.m[3] = this.m[3];
tr.m[4] = this.m[4];
tr.m[5] = this.m[5];
}
point(point) {
const m = this.m;
return {
x: m[0] * point.x + m[2] * point.y + m[4],
y: m[1] * point.x + m[3] * point.y + m[5],
};
}
translate(x, y) {
this.m[4] += this.m[0] * x + this.m[2] * y;
this.m[5] += this.m[1] * x + this.m[3] * y;
return this;
}
scale(sx, sy) {
this.m[0] *= sx;
this.m[1] *= sx;
this.m[2] *= sy;
this.m[3] *= sy;
return this;
}
rotate(rad) {
const c = Math.cos(rad);
const s = Math.sin(rad);
const m11 = this.m[0] * c + this.m[2] * s;
const m12 = this.m[1] * c + this.m[3] * s;
const m21 = this.m[0] * -s + this.m[2] * c;
const m22 = this.m[1] * -s + this.m[3] * c;
this.m[0] = m11;
this.m[1] = m12;
this.m[2] = m21;
this.m[3] = m22;
return this;
}
getTranslation() {
return {
x: this.m[4],
y: this.m[5],
};
}
skew(sx, sy) {
const m11 = this.m[0] + this.m[2] * sy;
const m12 = this.m[1] + this.m[3] * sy;
const m21 = this.m[2] + this.m[0] * sx;
const m22 = this.m[3] + this.m[1] * sx;
this.m[0] = m11;
this.m[1] = m12;
this.m[2] = m21;
this.m[3] = m22;
return this;
}
multiply(matrix) {
const m11 = this.m[0] * matrix.m[0] + this.m[2] * matrix.m[1];
const m12 = this.m[1] * matrix.m[0] + this.m[3] * matrix.m[1];
const m21 = this.m[0] * matrix.m[2] + this.m[2] * matrix.m[3];
const m22 = this.m[1] * matrix.m[2] + this.m[3] * matrix.m[3];
const dx = this.m[0] * matrix.m[4] + this.m[2] * matrix.m[5] + this.m[4];
const dy = this.m[1] * matrix.m[4] + this.m[3] * matrix.m[5] + this.m[5];
this.m[0] = m11;
this.m[1] = m12;
this.m[2] = m21;
this.m[3] = m22;
this.m[4] = dx;
this.m[5] = dy;
return this;
}
invert() {
const d = 1 / (this.m[0] * this.m[3] - this.m[1] * this.m[2]);
const m0 = this.m[3] * d;
const m1 = -this.m[1] * d;
const m2 = -this.m[2] * d;
const m3 = this.m[0] * d;
const m4 = d * (this.m[2] * this.m[5] - this.m[3] * this.m[4]);
const m5 = d * (this.m[1] * this.m[4] - this.m[0] * this.m[5]);
this.m[0] = m0;
this.m[1] = m1;
this.m[2] = m2;
this.m[3] = m3;
this.m[4] = m4;
this.m[5] = m5;
return this;
}
getMatrix() {
return this.m;
}
decompose() {
const a = this.m[0];
const b = this.m[1];
const c = this.m[2];
const d = this.m[3];
const e = this.m[4];
const f = this.m[5];
const delta = a * d - b * c;
const result = {
x: e,
y: f,
rotation: 0,
scaleX: 0,
scaleY: 0,
skewX: 0,
skewY: 0,
};
if (a != 0 || b != 0) {
const r = Math.sqrt(a * a + b * b);
result.rotation = b > 0 ? Math.acos(a / r) : -Math.acos(a / r);
result.scaleX = r;
result.scaleY = delta / r;
result.skewX = (a * c + b * d) / delta;
result.skewY = 0;
}
else if (c != 0 || d != 0) {
const s = Math.sqrt(c * c + d * d);
result.rotation =
Math.PI / 2 - (d > 0 ? Math.acos(-c / s) : -Math.acos(c / s));
result.scaleX = delta / s;
result.scaleY = s;
result.skewX = 0;
result.skewY = (a * c + b * d) / delta;
}
else {
}
result.rotation = exports.Util._getRotation(result.rotation);
return result;
}
}
exports.Transform = Transform;
const OBJECT_ARRAY = '[object Array]', OBJECT_NUMBER = '[object Number]', OBJECT_STRING = '[object String]', OBJECT_BOOLEAN = '[object Boolean]', PI_OVER_DEG180 = Math.PI / 180, DEG180_OVER_PI = 180 / Math.PI, HASH = '#', EMPTY_STRING = '', ZERO = '0', KONVA_WARNING = 'Konva warning: ', KONVA_ERROR = 'Konva error: ', RGB_PAREN = 'rgb(', COLORS = {
aliceblue: [240, 248, 255],
antiquewhite: [250, 235, 215],
aqua: [0, 255, 255],
aquamarine: [127, 255, 212],
azure: [240, 255, 255],
beige: [245, 245, 220],
bisque: [255, 228, 196],
black: [0, 0, 0],
blanchedalmond: [255, 235, 205],
blue: [0, 0, 255],
blueviolet: [138, 43, 226],
brown: [165, 42, 42],
burlywood: [222, 184, 135],
cadetblue: [95, 158, 160],
chartreuse: [127, 255, 0],
chocolate: [210, 105, 30],
coral: [255, 127, 80],
cornflowerblue: [100, 149, 237],
cornsilk: [255, 248, 220],
crimson: [220, 20, 60],
cyan: [0, 255, 255],
darkblue: [0, 0, 139],
darkcyan: [0, 139, 139],
darkgoldenrod: [184, 132, 11],
darkgray: [169, 169, 169],
darkgreen: [0, 100, 0],
darkgrey: [169, 169, 169],
darkkhaki: [189, 183, 107],
darkmagenta: [139, 0, 139],
darkolivegreen: [85, 107, 47],
darkorange: [255, 140, 0],
darkorchid: [153, 50, 204],
darkred: [139, 0, 0],
darksalmon: [233, 150, 122],
darkseagreen: [143, 188, 143],
darkslateblue: [72, 61, 139],
darkslategray: [47, 79, 79],
darkslategrey: [47, 79, 79],
darkturquoise: [0, 206, 209],
darkviolet: [148, 0, 211],
deeppink: [255, 20, 147],
deepskyblue: [0, 191, 255],
dimgray: [105, 105, 105],
dimgrey: [105, 105, 105],
dodgerblue: [30, 144, 255],
firebrick: [178, 34, 34],
floralwhite: [255, 255, 240],
forestgreen: [34, 139, 34],
fuchsia: [255, 0, 255],
gainsboro: [220, 220, 220],
ghostwhite: [248, 248, 255],
gold: [255, 215, 0],
goldenrod: [218, 165, 32],
gray: [128, 128, 128],
green: [0, 128, 0],
greenyellow: [173, 255, 47],
grey: [128, 128, 128],
honeydew: [240, 255, 240],
hotpink: [255, 105, 180],
indianred: [205, 92, 92],
indigo: [75, 0, 130],
ivory: [255, 255, 240],
khaki: [240, 230, 140],
lavender: [230, 230, 250],
lavenderblush: [255, 240, 245],
lawngreen: [124, 252, 0],
lemonchiffon: [255, 250, 205],
lightblue: [173, 216, 230],
lightcoral: [240, 128, 128],
lightcyan: [224, 255, 255],
lightgoldenrodyellow: [250, 250, 210],
lightgray: [211, 211, 211],
lightgreen: [144, 238, 144],
lightgrey: [211, 211, 211],
lightpink: [255, 182, 193],
lightsalmon: [255, 160, 122],
lightseagreen: [32, 178, 170],
lightskyblue: [135, 206, 250],
lightslategray: [119, 136, 153],
lightslategrey: [119, 136, 153],
lightsteelblue: [176, 196, 222],
lightyellow: [255, 255, 224],
lime: [0, 255, 0],
limegreen: [50, 205, 50],
linen: [250, 240, 230],
magenta: [255, 0, 255],
maroon: [128, 0, 0],
mediumaquamarine: [102, 205, 170],
mediumblue: [0, 0, 205],
mediumorchid: [186, 85, 211],
mediumpurple: [147, 112, 219],
mediumseagreen: [60, 179, 113],
mediumslateblue: [123, 104, 238],
mediumspringgreen: [0, 250, 154],
mediumturquoise: [72, 209, 204],
mediumvioletred: [199, 21, 133],
midnightblue: [25, 25, 112],
mintcream: [245, 255, 250],
mistyrose: [255, 228, 225],
moccasin: [255, 228, 181],
navajowhite: [255, 222, 173],
navy: [0, 0, 128],
oldlace: [253, 245, 230],
olive: [128, 128, 0],
olivedrab: [107, 142, 35],
orange: [255, 165, 0],
orangered: [255, 69, 0],
orchid: [218, 112, 214],
palegoldenrod: [238, 232, 170],
palegreen: [152, 251, 152],
paleturquoise: [175, 238, 238],
palevioletred: [219, 112, 147],
papayawhip: [255, 239, 213],
peachpuff: [255, 218, 185],
peru: [205, 133, 63],
pink: [255, 192, 203],
plum: [221, 160, 203],
powderblue: [176, 224, 230],
purple: [128, 0, 128],
rebeccapurple: [102, 51, 153],
red: [255, 0, 0],
rosybrown: [188, 143, 143],
royalblue: [65, 105, 225],
saddlebrown: [139, 69, 19],
salmon: [250, 128, 114],
sandybrown: [244, 164, 96],
seagreen: [46, 139, 87],
seashell: [255, 245, 238],
sienna: [160, 82, 45],
silver: [192, 192, 192],
skyblue: [135, 206, 235],
slateblue: [106, 90, 205],
slategray: [119, 128, 144],
slategrey: [119, 128, 144],
snow: [255, 255, 250],
springgreen: [0, 255, 127],
steelblue: [70, 130, 180],
tan: [210, 180, 140],
teal: [0, 128, 128],
thistle: [216, 191, 216],
transparent: [255, 255, 255, 0],
tomato: [255, 99, 71],
turquoise: [64, 224, 208],
violet: [238, 130, 238],
wheat: [245, 222, 179],
white: [255, 255, 255],
whitesmoke: [245, 245, 245],
yellow: [255, 255, 0],
yellowgreen: [154, 205, 5],
}, RGB_REGEX = /rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/;
let animQueue = [];
const req = (typeof requestAnimationFrame !== 'undefined' && requestAnimationFrame) ||
function (f) {
setTimeout(f, 60);
};
exports.Util = {
_isElement(obj) {
return !!(obj && obj.nodeType == 1);
},
_isFunction(obj) {
return !!(obj && obj.constructor && obj.call && obj.apply);
},
_isPlainObject(obj) {
return !!obj && obj.constructor === Object;
},
_isArray(obj) {
return Object.prototype.toString.call(obj) === OBJECT_ARRAY;
},
_isNumber(obj) {
return (Object.prototype.toString.call(obj) === OBJECT_NUMBER &&
!isNaN(obj) &&
isFinite(obj));
},
_isString(obj) {
return Object.prototype.toString.call(obj) === OBJECT_STRING;
},
_isBoolean(obj) {
return Object.prototype.toString.call(obj) === OBJECT_BOOLEAN;
},
isObject(val) {
return val instanceof Object;
},
isValidSelector(selector) {
if (typeof selector !== 'string') {
return false;
}
const firstChar = selector[0];
return (firstChar === '#' ||
firstChar === '.' ||
firstChar === firstChar.toUpperCase());
},
_sign(number) {
if (number === 0) {
return 1;
}
if (number > 0) {
return 1;
}
else {
return -1;
}
},
requestAnimFrame(callback) {
animQueue.push(callback);
if (animQueue.length === 1) {
req(function () {
const queue = animQueue;
animQueue = [];
queue.forEach(function (cb) {
cb();
});
});
}
},
createCanvasElement() {
const canvas = document.createElement('canvas');
try {
canvas.style = canvas.style || {};
}
catch (e) { }
return canvas;
},
createImageElement() {
return document.createElement('img');
},
_isInDocument(el) {
while ((el = el.parentNode)) {
if (el == document) {
return true;
}
}
return false;
},
_urlToImage(url, callback) {
const imageObj = exports.Util.createImageElement();
imageObj.onload = function () {
callback(imageObj);
};
imageObj.src = url;
},
_rgbToHex(r, g, b) {
return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
},
_hexToRgb(hex) {
hex = hex.replace(HASH, EMPTY_STRING);
const bigint = parseInt(hex, 16);
return {
r: (bigint >> 16) & 255,
g: (bigint >> 8) & 255,
b: bigint & 255,
};
},
getRandomColor() {
let randColor = ((Math.random() * 0xffffff) << 0).toString(16);
while (randColor.length < 6) {
randColor = ZERO + randColor;
}
return HASH + randColor;
},
getRGB(color) {
let rgb;
if (color in COLORS) {
rgb = COLORS[color];
return {
r: rgb[0],
g: rgb[1],
b: rgb[2],
};
}
else if (color[0] === HASH) {
return this._hexToRgb(color.substring(1));
}
else if (color.substr(0, 4) === RGB_PAREN) {
rgb = RGB_REGEX.exec(color.replace(/ /g, ''));
return {
r: parseInt(rgb[1], 10),
g: parseInt(rgb[2], 10),
b: parseInt(rgb[3], 10),
};
}
else {
return {
r: 0,
g: 0,
b: 0,
};
}
},
colorToRGBA(str) {
str = str || 'black';
return (exports.Util._namedColorToRBA(str) ||
exports.Util._hex3ColorToRGBA(str) ||
exports.Util._hex4ColorToRGBA(str) ||
exports.Util._hex6ColorToRGBA(str) ||
exports.Util._hex8ColorToRGBA(str) ||
exports.Util._rgbColorToRGBA(str) ||
exports.Util._rgbaColorToRGBA(str) ||
exports.Util._hslColorToRGBA(str));
},
_namedColorToRBA(str) {
const c = COLORS[str.toLowerCase()];
if (!c) {
return null;
}
return {
r: c[0],
g: c[1],
b: c[2],
a: 1,
};
},
_rgbColorToRGBA(str) {
if (str.indexOf('rgb(') === 0) {
str = str.match(/rgb\(([^)]+)\)/)[1];
const parts = str.split(/ *, */).map(Number);
return {
r: parts[0],
g: parts[1],
b: parts[2],
a: 1,
};
}
},
_rgbaColorToRGBA(str) {
if (str.indexOf('rgba(') === 0) {
str = str.match(/rgba\(([^)]+)\)/)[1];
const parts = str.split(/ *, */).map((n, index) => {
if (n.slice(-1) === '%') {
return index === 3 ? parseInt(n) / 100 : (parseInt(n) / 100) * 255;
}
return Number(n);
});
return {
r: parts[0],
g: parts[1],
b: parts[2],
a: parts[3],
};
}
},
_hex8ColorToRGBA(str) {
if (str[0] === '#' && str.length === 9) {
return {
r: parseInt(str.slice(1, 3), 16),
g: parseInt(str.slice(3, 5), 16),
b: parseInt(str.slice(5, 7), 16),
a: parseInt(str.slice(7, 9), 16) / 0xff,
};
}
},
_hex6ColorToRGBA(str) {
if (str[0] === '#' && str.length === 7) {
return {
r: parseInt(str.slice(1, 3), 16),
g: parseInt(str.slice(3, 5), 16),
b: parseInt(str.slice(5, 7), 16),
a: 1,
};
}
},
_hex4ColorToRGBA(str) {
if (str[0] === '#' && str.length === 5) {
return {
r: parseInt(str[1] + str[1], 16),
g: parseInt(str[2] + str[2], 16),
b: parseInt(str[3] + str[3], 16),
a: parseInt(str[4] + str[4], 16) / 0xff,
};
}
},
_hex3ColorToRGBA(str) {
if (str[0] === '#' && str.length === 4) {
return {
r: parseInt(str[1] + str[1], 16),
g: parseInt(str[2] + str[2], 16),
b: parseInt(str[3] + str[3], 16),
a: 1,
};
}
},
_hslColorToRGBA(str) {
if (/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(str)) {
const [_, ...hsl] = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(str);
const h = Number(hsl[0]) / 360;
const s = Number(hsl[1]) / 100;
const l = Number(hsl[2]) / 100;
let t2;
let t3;
let val;
if (s === 0) {
val = l * 255;
return {
r: Math.round(val),
g: Math.round(val),
b: Math.round(val),
a: 1,
};
}
if (l < 0.5) {
t2 = l * (1 + s);
}
else {
t2 = l + s - l * s;
}
const t1 = 2 * l - t2;
const rgb = [0, 0, 0];
for (let i = 0; i < 3; i++) {
t3 = h + (1 / 3) * -(i - 1);
if (t3 < 0) {
t3++;
}
if (t3 > 1) {
t3--;
}
if (6 * t3 < 1) {
val = t1 + (t2 - t1) * 6 * t3;
}
else if (2 * t3 < 1) {
val = t2;
}
else if (3 * t3 < 2) {
val = t1 + (t2 - t1) * (2 / 3 - t3) * 6;
}
else {
val = t1;
}
rgb[i] = val * 255;
}
return {
r: Math.round(rgb[0]),
g: Math.round(rgb[1]),
b: Math.round(rgb[2]),
a: 1,
};
}
},
haveIntersection(r1, r2) {
return !(r2.x > r1.x + r1.width ||
r2.x + r2.width < r1.x ||
r2.y > r1.y + r1.height ||
r2.y + r2.height < r1.y);
},
cloneObject(obj) {
const retObj = {};
for (const key in obj) {
if (this._isPlainObject(obj[key])) {
retObj[key] = this.cloneObject(obj[key]);
}
else if (this._isArray(obj[key])) {
retObj[key] = this.cloneArray(obj[key]);
}
else {
retObj[key] = obj[key];
}
}
return retObj;
},
cloneArray(arr) {
return arr.slice(0);
},
degToRad(deg) {
return deg * PI_OVER_DEG180;
},
radToDeg(rad) {
return rad * DEG180_OVER_PI;
},
_degToRad(deg) {
exports.Util.warn('Util._degToRad is removed. Please use public Util.degToRad instead.');
return exports.Util.degToRad(deg);
},
_radToDeg(rad) {
exports.Util.warn('Util._radToDeg is removed. Please use public Util.radToDeg instead.');
return exports.Util.radToDeg(rad);
},
_getRotation(radians) {
return Global_1.Konva.angleDeg ? exports.Util.radToDeg(radians) : radians;
},
_capitalize(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
},
throw(str) {
throw new Error(KONVA_ERROR + str);
},
error(str) {
console.error(KONVA_ERROR + str);
},
warn(str) {
if (!Global_1.Konva.showWarnings) {
return;
}
console.warn(KONVA_WARNING + str);
},
each(obj, func) {
for (const key in obj) {
func(key, obj[key]);
}
},
_inRange(val, left, right) {
return left <= val && val < right;
},
_getProjectionToSegment(x1, y1, x2, y2, x3, y3) {
let x, y, dist;
const pd2 = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
if (pd2 == 0) {
x = x1;
y = y1;
dist = (x3 - x2) * (x3 - x2) + (y3 - y2) * (y3 - y2);
}
else {
const u = ((x3 - x1) * (x2 - x1) + (y3 - y1) * (y2 - y1)) / pd2;
if (u < 0) {
x = x1;
y = y1;
dist = (x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3);
}
else if (u > 1.0) {
x = x2;
y = y2;
dist = (x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3);
}
else {
x = x1 + u * (x2 - x1);
y = y1 + u * (y2 - y1);
dist = (x - x3) * (x - x3) + (y - y3) * (y - y3);
}
}
return [x, y, dist];
},
_getProjectionToLine(pt, line, isClosed) {
const pc = exports.Util.cloneObject(pt);
let dist = Number.MAX_VALUE;
line.forEach(function (p1, i) {
if (!isClosed && i === line.length - 1) {
return;
}
const p2 = line[(i + 1) % line.length];
const proj = exports.Util._getProjectionToSegment(p1.x, p1.y, p2.x, p2.y, pt.x, pt.y);
const px = proj[0], py = proj[1], pdist = proj[2];
if (pdist < dist) {
pc.x = px;
pc.y = py;
dist = pdist;
}
});
return pc;
},
_prepareArrayForTween(startArray, endArray, isClosed) {
const start = [], end = [];
if (startArray.length > endArray.length) {
const temp = endArray;
endArray = startArray;
startArray = temp;
}
for (let n = 0; n < startArray.length; n += 2) {
start.push({
x: startArray[n],
y: startArray[n + 1],
});
}
for (let n = 0; n < endArray.length; n += 2) {
end.push({
x: endArray[n],
y: endArray[n + 1],
});
}
const newStart = [];
end.forEach(function (point) {
const pr = exports.Util._getProjectionToLine(point, start, isClosed);
newStart.push(pr.x);
newStart.push(pr.y);
});
return newStart;
},
_prepareToStringify(obj) {
let desc;
obj.visitedByCircularReferenceRemoval = true;
for (const key in obj) {
if (!(obj.hasOwnProperty(key) && obj[key] && typeof obj[key] == 'object')) {
continue;
}
desc = Object.getOwnPropertyDescriptor(obj, key);
if (obj[key].visitedByCircularReferenceRemoval ||
exports.Util._isElement(obj[key])) {
if (desc.configurable) {
delete obj[key];
}
else {
return null;
}
}
else if (exports.Util._prepareToStringify(obj[key]) === null) {
if (desc.configurable) {
delete obj[key];
}
else {
return null;
}
}
}
delete obj.visitedByCircularReferenceRemoval;
return obj;
},
_assign(target, source) {
for (const key in source) {
target[key] = source[key];
}
return target;
},
_getFirstPointerId(evt) {
if (!evt.touches) {
return evt.pointerId || 999;
}
else {
return evt.changedTouches[0].identifier;
}
},
releaseCanvas(...canvases) {
if (!Global_1.Konva.releaseCanvasOnDestroy)
return;
canvases.forEach((c) => {
c.width = 0;
c.height = 0;
});
},
drawRoundedRectPath(context, width, height, cornerRadius) {
let topLeft = 0;
let topRight = 0;
let bottomLeft = 0;
let bottomRight = 0;
if (typeof cornerRadius === 'number') {
topLeft =
topRight =
bottomLeft =
bottomRight =
Math.min(cornerRadius, width / 2, height / 2);
}
else {
topLeft = Math.min(cornerRadius[0] || 0, width / 2, height / 2);
topRight = Math.min(cornerRadius[1] || 0, width / 2, height / 2);
bottomRight = Math.min(cornerRadius[2] || 0, width / 2, height / 2);
bottomLeft = Math.min(cornerRadius[3] || 0, width / 2, height / 2);
}
context.moveTo(topLeft, 0);
context.lineTo(width - topRight, 0);
context.arc(width - topRight, topRight, topRight, (Math.PI * 3) / 2, 0, false);
context.lineTo(width, height - bottomRight);
context.arc(width - bottomRight, height - bottomRight, bottomRight, 0, Math.PI / 2, false);
context.lineTo(bottomLeft, height);
context.arc(bottomLeft, height - bottomLeft, bottomLeft, Math.PI / 2, Math.PI, false);
context.lineTo(0, topLeft);
context.arc(topLeft, topLeft, topLeft, Math.PI, (Math.PI * 3) / 2, false);
},
};

11
node_modules/konva/lib/Validators.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
export declare function RGBComponent(val: number): number;
export declare function alphaComponent(val: number): number;
export declare function getNumberValidator<T>(): ((val: T, attr: string) => T) | undefined;
export declare function getNumberOrArrayOfNumbersValidator<T>(noOfElements: number): ((val: T, attr: string) => T) | undefined;
export declare function getNumberOrAutoValidator<T>(): ((val: T, attr: string) => T) | undefined;
export declare function getStringValidator<T>(): ((val: T, attr: string) => T) | undefined;
export declare function getStringOrGradientValidator<T>(): ((val: T, attr: string) => T) | undefined;
export declare function getFunctionValidator<T>(): ((val: T, attr: string) => T) | undefined;
export declare function getNumberArrayValidator<T>(): ((val: T, attr: string) => T) | undefined;
export declare function getBooleanValidator<T>(): ((val: T, attr: string) => T) | undefined;
export declare function getComponentValidator<T>(components: string[]): ((val: T, attr: string) => T) | undefined;

191
node_modules/konva/lib/Validators.js generated vendored Normal file
View File

@@ -0,0 +1,191 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RGBComponent = RGBComponent;
exports.alphaComponent = alphaComponent;
exports.getNumberValidator = getNumberValidator;
exports.getNumberOrArrayOfNumbersValidator = getNumberOrArrayOfNumbersValidator;
exports.getNumberOrAutoValidator = getNumberOrAutoValidator;
exports.getStringValidator = getStringValidator;
exports.getStringOrGradientValidator = getStringOrGradientValidator;
exports.getFunctionValidator = getFunctionValidator;
exports.getNumberArrayValidator = getNumberArrayValidator;
exports.getBooleanValidator = getBooleanValidator;
exports.getComponentValidator = getComponentValidator;
const Global_1 = require("./Global");
const Util_1 = require("./Util");
function _formatValue(val) {
if (Util_1.Util._isString(val)) {
return '"' + val + '"';
}
if (Object.prototype.toString.call(val) === '[object Number]') {
return val;
}
if (Util_1.Util._isBoolean(val)) {
return val;
}
return Object.prototype.toString.call(val);
}
function RGBComponent(val) {
if (val > 255) {
return 255;
}
else if (val < 0) {
return 0;
}
return Math.round(val);
}
function alphaComponent(val) {
if (val > 1) {
return 1;
}
else if (val < 0.0001) {
return 0.0001;
}
return val;
}
function getNumberValidator() {
if (Global_1.Konva.isUnminified) {
return function (val, attr) {
if (!Util_1.Util._isNumber(val)) {
Util_1.Util.warn(_formatValue(val) +
' is a not valid value for "' +
attr +
'" attribute. The value should be a number.');
}
return val;
};
}
}
function getNumberOrArrayOfNumbersValidator(noOfElements) {
if (Global_1.Konva.isUnminified) {
return function (val, attr) {
let isNumber = Util_1.Util._isNumber(val);
let isValidArray = Util_1.Util._isArray(val) && val.length == noOfElements;
if (!isNumber && !isValidArray) {
Util_1.Util.warn(_formatValue(val) +
' is a not valid value for "' +
attr +
'" attribute. The value should be a number or Array<number>(' +
noOfElements +
')');
}
return val;
};
}
}
function getNumberOrAutoValidator() {
if (Global_1.Konva.isUnminified) {
return function (val, attr) {
const isNumber = Util_1.Util._isNumber(val);
const isAuto = val === 'auto';
if (!(isNumber || isAuto)) {
Util_1.Util.warn(_formatValue(val) +
' is a not valid value for "' +
attr +
'" attribute. The value should be a number or "auto".');
}
return val;
};
}
}
function getStringValidator() {
if (Global_1.Konva.isUnminified) {
return function (val, attr) {
if (!Util_1.Util._isString(val)) {
Util_1.Util.warn(_formatValue(val) +
' is a not valid value for "' +
attr +
'" attribute. The value should be a string.');
}
return val;
};
}
}
function getStringOrGradientValidator() {
if (Global_1.Konva.isUnminified) {
return function (val, attr) {
const isString = Util_1.Util._isString(val);
const isGradient = Object.prototype.toString.call(val) === '[object CanvasGradient]' ||
(val && val['addColorStop']);
if (!(isString || isGradient)) {
Util_1.Util.warn(_formatValue(val) +
' is a not valid value for "' +
attr +
'" attribute. The value should be a string or a native gradient.');
}
return val;
};
}
}
function getFunctionValidator() {
if (Global_1.Konva.isUnminified) {
return function (val, attr) {
if (!Util_1.Util._isFunction(val)) {
Util_1.Util.warn(_formatValue(val) +
' is a not valid value for "' +
attr +
'" attribute. The value should be a function.');
}
return val;
};
}
}
function getNumberArrayValidator() {
if (Global_1.Konva.isUnminified) {
return function (val, attr) {
const TypedArray = Int8Array ? Object.getPrototypeOf(Int8Array) : null;
if (TypedArray && val instanceof TypedArray) {
return val;
}
if (!Util_1.Util._isArray(val)) {
Util_1.Util.warn(_formatValue(val) +
' is a not valid value for "' +
attr +
'" attribute. The value should be a array of numbers.');
}
else {
val.forEach(function (item) {
if (!Util_1.Util._isNumber(item)) {
Util_1.Util.warn('"' +
attr +
'" attribute has non numeric element ' +
item +
'. Make sure that all elements are numbers.');
}
});
}
return val;
};
}
}
function getBooleanValidator() {
if (Global_1.Konva.isUnminified) {
return function (val, attr) {
const isBool = val === true || val === false;
if (!isBool) {
Util_1.Util.warn(_formatValue(val) +
' is a not valid value for "' +
attr +
'" attribute. The value should be a boolean.');
}
return val;
};
}
}
function getComponentValidator(components) {
if (Global_1.Konva.isUnminified) {
return function (val, attr) {
if (val === undefined || val === null) {
return val;
}
if (!Util_1.Util.isObject(val)) {
Util_1.Util.warn(_formatValue(val) +
' is a not valid value for "' +
attr +
'" attribute. The value should be an object with properties ' +
components);
}
return val;
};
}
}

194
node_modules/konva/lib/_CoreInternals.d.ts generated vendored Normal file
View File

@@ -0,0 +1,194 @@
import { Transform } from './Util.js';
import { Node } from './Node.js';
import { Container } from './Container.js';
import { Stage } from './Stage.js';
import { Layer } from './Layer.js';
import { FastLayer } from './FastLayer.js';
import { Group } from './Group.js';
import { Shape } from './Shape.js';
import { Animation } from './Animation.js';
import { Tween } from './Tween.js';
import { Context } from './Context.js';
import { Canvas } from './Canvas.js';
export declare const Konva: {
_global: any;
version: string;
isBrowser: boolean;
isUnminified: boolean;
dblClickWindow: number;
getAngle(angle: number): number;
enableTrace: boolean;
pointerEventsEnabled: boolean;
autoDrawEnabled: boolean;
hitOnDragEnabled: boolean;
capturePointerEventsEnabled: boolean;
_mouseListenClick: boolean;
_touchListenClick: boolean;
_pointerListenClick: boolean;
_mouseInDblClickWindow: boolean;
_touchInDblClickWindow: boolean;
_pointerInDblClickWindow: boolean;
_mouseDblClickPointerId: null;
_touchDblClickPointerId: null;
_pointerDblClickPointerId: null;
_fixTextRendering: boolean;
pixelRatio: number;
dragDistance: number;
angleDeg: boolean;
showWarnings: boolean;
dragButtons: number[];
isDragging(): any;
isTransforming(): any;
isDragReady(): boolean;
releaseCanvasOnDestroy: boolean;
document: any;
_injectGlobal(Konva: any): void;
} & {
Util: {
_isElement(obj: any): obj is Element;
_isFunction(obj: any): boolean;
_isPlainObject(obj: any): boolean;
_isArray(obj: any): obj is Array<any>;
_isNumber(obj: any): obj is number;
_isString(obj: any): obj is string;
_isBoolean(obj: any): obj is boolean;
isObject(val: any): val is object;
isValidSelector(selector: any): boolean;
_sign(number: number): 1 | -1;
requestAnimFrame(callback: Function): void;
createCanvasElement(): HTMLCanvasElement;
createImageElement(): HTMLImageElement;
_isInDocument(el: any): boolean;
_urlToImage(url: string, callback: Function): void;
_rgbToHex(r: number, g: number, b: number): string;
_hexToRgb(hex: string): import("./types.js").RGB;
getRandomColor(): string;
getRGB(color: string): import("./types.js").RGB;
colorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_namedColorToRBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | null;
_rgbColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_rgbaColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_hex8ColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_hex6ColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_hex4ColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_hex3ColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_hslColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
haveIntersection(r1: import("./types").IRect, r2: import("./types.js").IRect): boolean;
cloneObject<Any>(obj: Any): Any;
cloneArray(arr: Array<any>): any[];
degToRad(deg: number): number;
radToDeg(rad: number): number;
_degToRad(deg: number): number;
_radToDeg(rad: number): number;
_getRotation(radians: number): number;
_capitalize(str: string): string;
throw(str: string): never;
error(str: string): void;
warn(str: string): void;
each(obj: object, func: Function): void;
_inRange(val: number, left: number, right: number): boolean;
_getProjectionToSegment(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): any[];
_getProjectionToLine(pt: import("./types").Vector2d, line: Array<import("./types").Vector2d>, isClosed: boolean): import("./types.js").Vector2d;
_prepareArrayForTween(startArray: any, endArray: any, isClosed: any): number[];
_prepareToStringify<T>(obj: any): T | null;
_assign<T, U>(target: T, source: U): T & U;
_getFirstPointerId(evt: any): any;
releaseCanvas(...canvases: HTMLCanvasElement[]): void;
drawRoundedRectPath(context: Context, width: number, height: number, cornerRadius: number | number[]): void;
};
Transform: typeof Transform;
Node: typeof Node;
Container: typeof Container;
Stage: typeof Stage;
stages: Stage[];
Layer: typeof Layer;
FastLayer: typeof FastLayer;
Group: typeof Group;
DD: {
readonly isDragging: boolean;
justDragged: boolean;
readonly node: Node<import("./Node.js").NodeConfig> | undefined;
_dragElements: Map<number, {
node: Node;
startPointerPos: import("./types.js").Vector2d;
offset: import("./types.js").Vector2d;
pointerId?: number;
dragStatus: "ready" | "dragging" | "stopped";
}>;
_drag(evt: any): void;
_endDragBefore(evt?: any): void;
_endDragAfter(evt: any): void;
};
Shape: typeof Shape;
shapes: {
[key: string]: Shape<import("./Shape.js").ShapeConfig>;
};
Animation: typeof Animation;
Tween: typeof Tween;
Easings: {
BackEaseIn(t: any, b: any, c: any, d: any): any;
BackEaseOut(t: any, b: any, c: any, d: any): any;
BackEaseInOut(t: any, b: any, c: any, d: any): any;
ElasticEaseIn(t: any, b: any, c: any, d: any, a: any, p: any): any;
ElasticEaseOut(t: any, b: any, c: any, d: any, a: any, p: any): any;
ElasticEaseInOut(t: any, b: any, c: any, d: any, a: any, p: any): any;
BounceEaseOut(t: any, b: any, c: any, d: any): any;
BounceEaseIn(t: any, b: any, c: any, d: any): any;
BounceEaseInOut(t: any, b: any, c: any, d: any): any;
EaseIn(t: any, b: any, c: any, d: any): any;
EaseOut(t: any, b: any, c: any, d: any): any;
EaseInOut(t: any, b: any, c: any, d: any): any;
StrongEaseIn(t: any, b: any, c: any, d: any): any;
StrongEaseOut(t: any, b: any, c: any, d: any): any;
StrongEaseInOut(t: any, b: any, c: any, d: any): any;
Linear(t: any, b: any, c: any, d: any): any;
};
Context: typeof Context;
Canvas: typeof Canvas;
};
export default Konva;

37
node_modules/konva/lib/_CoreInternals.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Konva = void 0;
const Global_1 = require("./Global");
const Util_1 = require("./Util");
const Node_1 = require("./Node");
const Container_1 = require("./Container");
const Stage_1 = require("./Stage");
const Layer_1 = require("./Layer");
const FastLayer_1 = require("./FastLayer");
const Group_1 = require("./Group");
const DragAndDrop_1 = require("./DragAndDrop");
const Shape_1 = require("./Shape");
const Animation_1 = require("./Animation");
const Tween_1 = require("./Tween");
const Context_1 = require("./Context");
const Canvas_1 = require("./Canvas");
exports.Konva = Util_1.Util._assign(Global_1.Konva, {
Util: Util_1.Util,
Transform: Util_1.Transform,
Node: Node_1.Node,
Container: Container_1.Container,
Stage: Stage_1.Stage,
stages: Stage_1.stages,
Layer: Layer_1.Layer,
FastLayer: FastLayer_1.FastLayer,
Group: Group_1.Group,
DD: DragAndDrop_1.DD,
Shape: Shape_1.Shape,
shapes: Shape_1.shapes,
Animation: Animation_1.Animation,
Tween: Tween_1.Tween,
Easings: Tween_1.Easings,
Context: Context_1.Context,
Canvas: Canvas_1.Canvas,
});
exports.default = exports.Konva;

238
node_modules/konva/lib/_FullInternals.d.ts generated vendored Normal file
View File

@@ -0,0 +1,238 @@
import { Arc } from './shapes/Arc.js';
import { Arrow } from './shapes/Arrow.js';
import { Circle } from './shapes/Circle.js';
import { Ellipse } from './shapes/Ellipse.js';
import { Image } from './shapes/Image.js';
import { Label, Tag } from './shapes/Label.js';
import { Line } from './shapes/Line.js';
import { Path } from './shapes/Path.js';
import { Rect } from './shapes/Rect.js';
import { RegularPolygon } from './shapes/RegularPolygon.js';
import { Ring } from './shapes/Ring.js';
import { Sprite } from './shapes/Sprite.js';
import { Star } from './shapes/Star.js';
import { Text } from './shapes/Text.js';
import { TextPath } from './shapes/TextPath.js';
import { Transformer } from './shapes/Transformer.js';
import { Wedge } from './shapes/Wedge.js';
export declare const Konva: {
_global: any;
version: string;
isBrowser: boolean;
isUnminified: boolean;
dblClickWindow: number;
getAngle(angle: number): number;
enableTrace: boolean;
pointerEventsEnabled: boolean;
autoDrawEnabled: boolean;
hitOnDragEnabled: boolean;
capturePointerEventsEnabled: boolean;
_mouseListenClick: boolean;
_touchListenClick: boolean;
_pointerListenClick: boolean;
_mouseInDblClickWindow: boolean;
_touchInDblClickWindow: boolean;
_pointerInDblClickWindow: boolean;
_mouseDblClickPointerId: null;
_touchDblClickPointerId: null;
_pointerDblClickPointerId: null;
_fixTextRendering: boolean;
pixelRatio: number;
dragDistance: number;
angleDeg: boolean;
showWarnings: boolean;
dragButtons: number[];
isDragging(): any;
isTransforming(): any;
isDragReady(): boolean;
releaseCanvasOnDestroy: boolean;
document: any;
_injectGlobal(Konva: any): void;
} & {
Util: {
_isElement(obj: any): obj is Element;
_isFunction(obj: any): boolean;
_isPlainObject(obj: any): boolean;
_isArray(obj: any): obj is Array<any>;
_isNumber(obj: any): obj is number;
_isString(obj: any): obj is string;
_isBoolean(obj: any): obj is boolean;
isObject(val: any): val is object;
isValidSelector(selector: any): boolean;
_sign(number: number): 1 | -1;
requestAnimFrame(callback: Function): void;
createCanvasElement(): HTMLCanvasElement;
createImageElement(): HTMLImageElement;
_isInDocument(el: any): boolean;
_urlToImage(url: string, callback: Function): void;
_rgbToHex(r: number, g: number, b: number): string;
_hexToRgb(hex: string): import("./types.js").RGB;
getRandomColor(): string;
getRGB(color: string): import("./types.js").RGB;
colorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_namedColorToRBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | null;
_rgbColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_rgbaColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_hex8ColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_hex6ColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_hex4ColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_hex3ColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
_hslColorToRGBA(str: string): {
r: number;
g: number;
b: number;
a: number;
} | undefined;
haveIntersection(r1: import("./types").IRect, r2: import("./types.js").IRect): boolean;
cloneObject<Any>(obj: Any): Any;
cloneArray(arr: Array<any>): any[];
degToRad(deg: number): number;
radToDeg(rad: number): number;
_degToRad(deg: number): number;
_radToDeg(rad: number): number;
_getRotation(radians: number): number;
_capitalize(str: string): string;
throw(str: string): never;
error(str: string): void;
warn(str: string): void;
each(obj: object, func: Function): void;
_inRange(val: number, left: number, right: number): boolean;
_getProjectionToSegment(x1: any, y1: any, x2: any, y2: any, x3: any, y3: any): any[];
_getProjectionToLine(pt: import("./types").Vector2d, line: Array<import("./types").Vector2d>, isClosed: boolean): import("./types.js").Vector2d;
_prepareArrayForTween(startArray: any, endArray: any, isClosed: any): number[];
_prepareToStringify<T>(obj: any): T | null;
_assign<T, U>(target: T, source: U): T & U;
_getFirstPointerId(evt: any): any;
releaseCanvas(...canvases: HTMLCanvasElement[]): void;
drawRoundedRectPath(context: import("./Context.js").Context, width: number, height: number, cornerRadius: number | number[]): void;
};
Transform: typeof import("./Util.js").Transform;
Node: typeof import("./Node.js").Node;
Container: typeof import("./Container.js").Container;
Stage: typeof import("./Stage.js").Stage;
stages: import("./Stage.js").Stage[];
Layer: typeof import("./Layer.js").Layer;
FastLayer: typeof import("./FastLayer.js").FastLayer;
Group: typeof import("./Group.js").Group;
DD: {
readonly isDragging: boolean;
justDragged: boolean;
readonly node: import("./Node").Node<import("./Node.js").NodeConfig> | undefined;
_dragElements: Map<number, {
node: import("./Node.js").Node;
startPointerPos: import("./types.js").Vector2d;
offset: import("./types.js").Vector2d;
pointerId?: number;
dragStatus: "ready" | "dragging" | "stopped";
}>;
_drag(evt: any): void;
_endDragBefore(evt?: any): void;
_endDragAfter(evt: any): void;
};
Shape: typeof import("./Shape.js").Shape;
shapes: {
[key: string]: import("./Shape").Shape<import("./Shape.js").ShapeConfig>;
};
Animation: typeof import("./Animation.js").Animation;
Tween: typeof import("./Tween.js").Tween;
Easings: {
BackEaseIn(t: any, b: any, c: any, d: any): any;
BackEaseOut(t: any, b: any, c: any, d: any): any;
BackEaseInOut(t: any, b: any, c: any, d: any): any;
ElasticEaseIn(t: any, b: any, c: any, d: any, a: any, p: any): any;
ElasticEaseOut(t: any, b: any, c: any, d: any, a: any, p: any): any;
ElasticEaseInOut(t: any, b: any, c: any, d: any, a: any, p: any): any;
BounceEaseOut(t: any, b: any, c: any, d: any): any;
BounceEaseIn(t: any, b: any, c: any, d: any): any;
BounceEaseInOut(t: any, b: any, c: any, d: any): any;
EaseIn(t: any, b: any, c: any, d: any): any;
EaseOut(t: any, b: any, c: any, d: any): any;
EaseInOut(t: any, b: any, c: any, d: any): any;
StrongEaseIn(t: any, b: any, c: any, d: any): any;
StrongEaseOut(t: any, b: any, c: any, d: any): any;
StrongEaseInOut(t: any, b: any, c: any, d: any): any;
Linear(t: any, b: any, c: any, d: any): any;
};
Context: typeof import("./Context.js").Context;
Canvas: typeof import("./Canvas.js").Canvas;
} & {
Arc: typeof Arc;
Arrow: typeof Arrow;
Circle: typeof Circle;
Ellipse: typeof Ellipse;
Image: typeof Image;
Label: typeof Label;
Tag: typeof Tag;
Line: typeof Line;
Path: typeof Path;
Rect: typeof Rect;
RegularPolygon: typeof RegularPolygon;
Ring: typeof Ring;
Sprite: typeof Sprite;
Star: typeof Star;
Text: typeof Text;
TextPath: typeof TextPath;
Transformer: typeof Transformer;
Wedge: typeof Wedge;
Filters: {
Blur: import("./Node.js").Filter;
Brighten: import("./Node.js").Filter;
Contrast: import("./Node.js").Filter;
Emboss: import("./Node.js").Filter;
Enhance: import("./Node.js").Filter;
Grayscale: import("./Node.js").Filter;
HSL: import("./Node.js").Filter;
HSV: import("./Node.js").Filter;
Invert: import("./Node.js").Filter;
Kaleidoscope: import("./Node.js").Filter;
Mask: import("./Node.js").Filter;
Noise: import("./Node.js").Filter;
Pixelate: import("./Node.js").Filter;
Posterize: import("./Node.js").Filter;
RGB: import("./Node.js").Filter;
RGBA: import("./Node.js").Filter;
Sepia: import("./Node.js").Filter;
Solarize: import("./Node.js").Filter;
Threshold: import("./Node.js").Filter;
};
};

81
node_modules/konva/lib/_FullInternals.js generated vendored Normal file
View File

@@ -0,0 +1,81 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Konva = void 0;
const _CoreInternals_1 = require("./_CoreInternals");
const Arc_1 = require("./shapes/Arc");
const Arrow_1 = require("./shapes/Arrow");
const Circle_1 = require("./shapes/Circle");
const Ellipse_1 = require("./shapes/Ellipse");
const Image_1 = require("./shapes/Image");
const Label_1 = require("./shapes/Label");
const Line_1 = require("./shapes/Line");
const Path_1 = require("./shapes/Path");
const Rect_1 = require("./shapes/Rect");
const RegularPolygon_1 = require("./shapes/RegularPolygon");
const Ring_1 = require("./shapes/Ring");
const Sprite_1 = require("./shapes/Sprite");
const Star_1 = require("./shapes/Star");
const Text_1 = require("./shapes/Text");
const TextPath_1 = require("./shapes/TextPath");
const Transformer_1 = require("./shapes/Transformer");
const Wedge_1 = require("./shapes/Wedge");
const Blur_1 = require("./filters/Blur");
const Brighten_1 = require("./filters/Brighten");
const Contrast_1 = require("./filters/Contrast");
const Emboss_1 = require("./filters/Emboss");
const Enhance_1 = require("./filters/Enhance");
const Grayscale_1 = require("./filters/Grayscale");
const HSL_1 = require("./filters/HSL");
const HSV_1 = require("./filters/HSV");
const Invert_1 = require("./filters/Invert");
const Kaleidoscope_1 = require("./filters/Kaleidoscope");
const Mask_1 = require("./filters/Mask");
const Noise_1 = require("./filters/Noise");
const Pixelate_1 = require("./filters/Pixelate");
const Posterize_1 = require("./filters/Posterize");
const RGB_1 = require("./filters/RGB");
const RGBA_1 = require("./filters/RGBA");
const Sepia_1 = require("./filters/Sepia");
const Solarize_1 = require("./filters/Solarize");
const Threshold_1 = require("./filters/Threshold");
exports.Konva = _CoreInternals_1.Konva.Util._assign(_CoreInternals_1.Konva, {
Arc: Arc_1.Arc,
Arrow: Arrow_1.Arrow,
Circle: Circle_1.Circle,
Ellipse: Ellipse_1.Ellipse,
Image: Image_1.Image,
Label: Label_1.Label,
Tag: Label_1.Tag,
Line: Line_1.Line,
Path: Path_1.Path,
Rect: Rect_1.Rect,
RegularPolygon: RegularPolygon_1.RegularPolygon,
Ring: Ring_1.Ring,
Sprite: Sprite_1.Sprite,
Star: Star_1.Star,
Text: Text_1.Text,
TextPath: TextPath_1.TextPath,
Transformer: Transformer_1.Transformer,
Wedge: Wedge_1.Wedge,
Filters: {
Blur: Blur_1.Blur,
Brighten: Brighten_1.Brighten,
Contrast: Contrast_1.Contrast,
Emboss: Emboss_1.Emboss,
Enhance: Enhance_1.Enhance,
Grayscale: Grayscale_1.Grayscale,
HSL: HSL_1.HSL,
HSV: HSV_1.HSV,
Invert: Invert_1.Invert,
Kaleidoscope: Kaleidoscope_1.Kaleidoscope,
Mask: Mask_1.Mask,
Noise: Noise_1.Noise,
Pixelate: Pixelate_1.Pixelate,
Posterize: Posterize_1.Posterize,
RGB: RGB_1.RGB,
RGBA: RGBA_1.RGBA,
Sepia: Sepia_1.Sepia,
Solarize: Solarize_1.Solarize,
Threshold: Threshold_1.Threshold,
},
});

2
node_modules/konva/lib/filters/Blur.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const Blur: Filter;

239
node_modules/konva/lib/filters/Blur.js generated vendored Normal file
View File

@@ -0,0 +1,239 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Blur = void 0;
const Factory_1 = require("../Factory");
const Node_1 = require("../Node");
const Validators_1 = require("../Validators");
function BlurStack() {
this.r = 0;
this.g = 0;
this.b = 0;
this.a = 0;
this.next = null;
}
const mul_table = [
512, 512, 456, 512, 328, 456, 335, 512, 405, 328, 271, 456, 388, 335, 292,
512, 454, 405, 364, 328, 298, 271, 496, 456, 420, 388, 360, 335, 312, 292,
273, 512, 482, 454, 428, 405, 383, 364, 345, 328, 312, 298, 284, 271, 259,
496, 475, 456, 437, 420, 404, 388, 374, 360, 347, 335, 323, 312, 302, 292,
282, 273, 265, 512, 497, 482, 468, 454, 441, 428, 417, 405, 394, 383, 373,
364, 354, 345, 337, 328, 320, 312, 305, 298, 291, 284, 278, 271, 265, 259,
507, 496, 485, 475, 465, 456, 446, 437, 428, 420, 412, 404, 396, 388, 381,
374, 367, 360, 354, 347, 341, 335, 329, 323, 318, 312, 307, 302, 297, 292,
287, 282, 278, 273, 269, 265, 261, 512, 505, 497, 489, 482, 475, 468, 461,
454, 447, 441, 435, 428, 422, 417, 411, 405, 399, 394, 389, 383, 378, 373,
368, 364, 359, 354, 350, 345, 341, 337, 332, 328, 324, 320, 316, 312, 309,
305, 301, 298, 294, 291, 287, 284, 281, 278, 274, 271, 268, 265, 262, 259,
257, 507, 501, 496, 491, 485, 480, 475, 470, 465, 460, 456, 451, 446, 442,
437, 433, 428, 424, 420, 416, 412, 408, 404, 400, 396, 392, 388, 385, 381,
377, 374, 370, 367, 363, 360, 357, 354, 350, 347, 344, 341, 338, 335, 332,
329, 326, 323, 320, 318, 315, 312, 310, 307, 304, 302, 299, 297, 294, 292,
289, 287, 285, 282, 280, 278, 275, 273, 271, 269, 267, 265, 263, 261, 259,
];
const shg_table = [
9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 17, 17,
17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 19,
19, 19, 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
20, 20, 20, 20, 20, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
24, 24, 24, 24, 24, 24, 24,
];
function filterGaussBlurRGBA(imageData, radius) {
const pixels = imageData.data, width = imageData.width, height = imageData.height;
let p, yi, yw, r_sum, g_sum, b_sum, a_sum, r_out_sum, g_out_sum, b_out_sum, a_out_sum, r_in_sum, g_in_sum, b_in_sum, a_in_sum, pr, pg, pb, pa, rbs;
const div = radius + radius + 1, widthMinus1 = width - 1, heightMinus1 = height - 1, radiusPlus1 = radius + 1, sumFactor = (radiusPlus1 * (radiusPlus1 + 1)) / 2, stackStart = new BlurStack(), mul_sum = mul_table[radius], shg_sum = shg_table[radius];
let stackEnd = null, stack = stackStart, stackIn = null, stackOut = null;
for (let i = 1; i < div; i++) {
stack = stack.next = new BlurStack();
if (i === radiusPlus1) {
stackEnd = stack;
}
}
stack.next = stackStart;
yw = yi = 0;
for (let y = 0; y < height; y++) {
r_in_sum =
g_in_sum =
b_in_sum =
a_in_sum =
r_sum =
g_sum =
b_sum =
a_sum =
0;
r_out_sum = radiusPlus1 * (pr = pixels[yi]);
g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]);
b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]);
a_out_sum = radiusPlus1 * (pa = pixels[yi + 3]);
r_sum += sumFactor * pr;
g_sum += sumFactor * pg;
b_sum += sumFactor * pb;
a_sum += sumFactor * pa;
stack = stackStart;
for (let i = 0; i < radiusPlus1; i++) {
stack.r = pr;
stack.g = pg;
stack.b = pb;
stack.a = pa;
stack = stack.next;
}
for (let i = 1; i < radiusPlus1; i++) {
p = yi + ((widthMinus1 < i ? widthMinus1 : i) << 2);
r_sum += (stack.r = pr = pixels[p]) * (rbs = radiusPlus1 - i);
g_sum += (stack.g = pg = pixels[p + 1]) * rbs;
b_sum += (stack.b = pb = pixels[p + 2]) * rbs;
a_sum += (stack.a = pa = pixels[p + 3]) * rbs;
r_in_sum += pr;
g_in_sum += pg;
b_in_sum += pb;
a_in_sum += pa;
stack = stack.next;
}
stackIn = stackStart;
stackOut = stackEnd;
for (let x = 0; x < width; x++) {
pixels[yi + 3] = pa = (a_sum * mul_sum) >> shg_sum;
if (pa !== 0) {
pa = 255 / pa;
pixels[yi] = ((r_sum * mul_sum) >> shg_sum) * pa;
pixels[yi + 1] = ((g_sum * mul_sum) >> shg_sum) * pa;
pixels[yi + 2] = ((b_sum * mul_sum) >> shg_sum) * pa;
}
else {
pixels[yi] = pixels[yi + 1] = pixels[yi + 2] = 0;
}
r_sum -= r_out_sum;
g_sum -= g_out_sum;
b_sum -= b_out_sum;
a_sum -= a_out_sum;
r_out_sum -= stackIn.r;
g_out_sum -= stackIn.g;
b_out_sum -= stackIn.b;
a_out_sum -= stackIn.a;
p = (yw + ((p = x + radius + 1) < widthMinus1 ? p : widthMinus1)) << 2;
r_in_sum += stackIn.r = pixels[p];
g_in_sum += stackIn.g = pixels[p + 1];
b_in_sum += stackIn.b = pixels[p + 2];
a_in_sum += stackIn.a = pixels[p + 3];
r_sum += r_in_sum;
g_sum += g_in_sum;
b_sum += b_in_sum;
a_sum += a_in_sum;
stackIn = stackIn.next;
r_out_sum += pr = stackOut.r;
g_out_sum += pg = stackOut.g;
b_out_sum += pb = stackOut.b;
a_out_sum += pa = stackOut.a;
r_in_sum -= pr;
g_in_sum -= pg;
b_in_sum -= pb;
a_in_sum -= pa;
stackOut = stackOut.next;
yi += 4;
}
yw += width;
}
for (let x = 0; x < width; x++) {
g_in_sum =
b_in_sum =
a_in_sum =
r_in_sum =
g_sum =
b_sum =
a_sum =
r_sum =
0;
yi = x << 2;
r_out_sum = radiusPlus1 * (pr = pixels[yi]);
g_out_sum = radiusPlus1 * (pg = pixels[yi + 1]);
b_out_sum = radiusPlus1 * (pb = pixels[yi + 2]);
a_out_sum = radiusPlus1 * (pa = pixels[yi + 3]);
r_sum += sumFactor * pr;
g_sum += sumFactor * pg;
b_sum += sumFactor * pb;
a_sum += sumFactor * pa;
stack = stackStart;
for (let i = 0; i < radiusPlus1; i++) {
stack.r = pr;
stack.g = pg;
stack.b = pb;
stack.a = pa;
stack = stack.next;
}
let yp = width;
for (let i = 1; i <= radius; i++) {
yi = (yp + x) << 2;
r_sum += (stack.r = pr = pixels[yi]) * (rbs = radiusPlus1 - i);
g_sum += (stack.g = pg = pixels[yi + 1]) * rbs;
b_sum += (stack.b = pb = pixels[yi + 2]) * rbs;
a_sum += (stack.a = pa = pixels[yi + 3]) * rbs;
r_in_sum += pr;
g_in_sum += pg;
b_in_sum += pb;
a_in_sum += pa;
stack = stack.next;
if (i < heightMinus1) {
yp += width;
}
}
yi = x;
stackIn = stackStart;
stackOut = stackEnd;
for (let y = 0; y < height; y++) {
p = yi << 2;
pixels[p + 3] = pa = (a_sum * mul_sum) >> shg_sum;
if (pa > 0) {
pa = 255 / pa;
pixels[p] = ((r_sum * mul_sum) >> shg_sum) * pa;
pixels[p + 1] = ((g_sum * mul_sum) >> shg_sum) * pa;
pixels[p + 2] = ((b_sum * mul_sum) >> shg_sum) * pa;
}
else {
pixels[p] = pixels[p + 1] = pixels[p + 2] = 0;
}
r_sum -= r_out_sum;
g_sum -= g_out_sum;
b_sum -= b_out_sum;
a_sum -= a_out_sum;
r_out_sum -= stackIn.r;
g_out_sum -= stackIn.g;
b_out_sum -= stackIn.b;
a_out_sum -= stackIn.a;
p =
(x +
((p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1) * width) <<
2;
r_sum += r_in_sum += stackIn.r = pixels[p];
g_sum += g_in_sum += stackIn.g = pixels[p + 1];
b_sum += b_in_sum += stackIn.b = pixels[p + 2];
a_sum += a_in_sum += stackIn.a = pixels[p + 3];
stackIn = stackIn.next;
r_out_sum += pr = stackOut.r;
g_out_sum += pg = stackOut.g;
b_out_sum += pb = stackOut.b;
a_out_sum += pa = stackOut.a;
r_in_sum -= pr;
g_in_sum -= pg;
b_in_sum -= pb;
a_in_sum -= pa;
stackOut = stackOut.next;
yi += width;
}
}
}
const Blur = function Blur(imageData) {
const radius = Math.round(this.blurRadius());
if (radius > 0) {
filterGaussBlurRGBA(imageData, radius);
}
};
exports.Blur = Blur;
Factory_1.Factory.addGetterSetter(Node_1.Node, 'blurRadius', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);

2
node_modules/konva/lib/filters/Brighten.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const Brighten: Filter;

16
node_modules/konva/lib/filters/Brighten.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Brighten = void 0;
const Factory_1 = require("../Factory");
const Node_1 = require("../Node");
const Validators_1 = require("../Validators");
const Brighten = function (imageData) {
const brightness = this.brightness() * 255, data = imageData.data, len = data.length;
for (let i = 0; i < len; i += 4) {
data[i] += brightness;
data[i + 1] += brightness;
data[i + 2] += brightness;
}
};
exports.Brighten = Brighten;
Factory_1.Factory.addGetterSetter(Node_1.Node, 'brightness', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);

2
node_modules/konva/lib/filters/Contrast.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const Contrast: Filter;

39
node_modules/konva/lib/filters/Contrast.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Contrast = void 0;
const Factory_1 = require("../Factory");
const Node_1 = require("../Node");
const Validators_1 = require("../Validators");
const Contrast = function (imageData) {
const adjust = Math.pow((this.contrast() + 100) / 100, 2);
const data = imageData.data, nPixels = data.length;
let red = 150, green = 150, blue = 150;
for (let i = 0; i < nPixels; i += 4) {
red = data[i];
green = data[i + 1];
blue = data[i + 2];
red /= 255;
red -= 0.5;
red *= adjust;
red += 0.5;
red *= 255;
green /= 255;
green -= 0.5;
green *= adjust;
green += 0.5;
green *= 255;
blue /= 255;
blue -= 0.5;
blue *= adjust;
blue += 0.5;
blue *= 255;
red = red < 0 ? 0 : red > 255 ? 255 : red;
green = green < 0 ? 0 : green > 255 ? 255 : green;
blue = blue < 0 ? 0 : blue > 255 ? 255 : blue;
data[i] = red;
data[i + 1] = green;
data[i + 2] = blue;
}
};
exports.Contrast = Contrast;
Factory_1.Factory.addGetterSetter(Node_1.Node, 'contrast', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);

2
node_modules/konva/lib/filters/Emboss.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const Emboss: Filter;

107
node_modules/konva/lib/filters/Emboss.js generated vendored Normal file
View File

@@ -0,0 +1,107 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Emboss = void 0;
const Factory_1 = require("../Factory");
const Node_1 = require("../Node");
const Util_1 = require("../Util");
const Validators_1 = require("../Validators");
const Emboss = function (imageData) {
const strength = this.embossStrength() * 10, greyLevel = this.embossWhiteLevel() * 255, direction = this.embossDirection(), blend = this.embossBlend(), data = imageData.data, w = imageData.width, h = imageData.height, w4 = w * 4;
let dirY = 0, dirX = 0, y = h;
switch (direction) {
case 'top-left':
dirY = -1;
dirX = -1;
break;
case 'top':
dirY = -1;
dirX = 0;
break;
case 'top-right':
dirY = -1;
dirX = 1;
break;
case 'right':
dirY = 0;
dirX = 1;
break;
case 'bottom-right':
dirY = 1;
dirX = 1;
break;
case 'bottom':
dirY = 1;
dirX = 0;
break;
case 'bottom-left':
dirY = 1;
dirX = -1;
break;
case 'left':
dirY = 0;
dirX = -1;
break;
default:
Util_1.Util.error('Unknown emboss direction: ' + direction);
}
do {
const offsetY = (y - 1) * w4;
let otherY = dirY;
if (y + otherY < 1) {
otherY = 0;
}
if (y + otherY > h) {
otherY = 0;
}
const offsetYOther = (y - 1 + otherY) * w * 4;
let x = w;
do {
const offset = offsetY + (x - 1) * 4;
let otherX = dirX;
if (x + otherX < 1) {
otherX = 0;
}
if (x + otherX > w) {
otherX = 0;
}
const offsetOther = offsetYOther + (x - 1 + otherX) * 4;
const dR = data[offset] - data[offsetOther];
const dG = data[offset + 1] - data[offsetOther + 1];
const dB = data[offset + 2] - data[offsetOther + 2];
let dif = dR;
const absDif = dif > 0 ? dif : -dif;
const absG = dG > 0 ? dG : -dG;
const absB = dB > 0 ? dB : -dB;
if (absG > absDif) {
dif = dG;
}
if (absB > absDif) {
dif = dB;
}
dif *= strength;
if (blend) {
const r = data[offset] + dif;
const g = data[offset + 1] + dif;
const b = data[offset + 2] + dif;
data[offset] = r > 255 ? 255 : r < 0 ? 0 : r;
data[offset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
data[offset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
}
else {
let grey = greyLevel - dif;
if (grey < 0) {
grey = 0;
}
else if (grey > 255) {
grey = 255;
}
data[offset] = data[offset + 1] = data[offset + 2] = grey;
}
} while (--x);
} while (--y);
};
exports.Emboss = Emboss;
Factory_1.Factory.addGetterSetter(Node_1.Node, 'embossStrength', 0.5, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);
Factory_1.Factory.addGetterSetter(Node_1.Node, 'embossWhiteLevel', 0.5, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);
Factory_1.Factory.addGetterSetter(Node_1.Node, 'embossDirection', 'top-left', undefined, Factory_1.Factory.afterSetFilter);
Factory_1.Factory.addGetterSetter(Node_1.Node, 'embossBlend', false, undefined, Factory_1.Factory.afterSetFilter);

2
node_modules/konva/lib/filters/Enhance.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const Enhance: Filter;

88
node_modules/konva/lib/filters/Enhance.js generated vendored Normal file
View File

@@ -0,0 +1,88 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Enhance = void 0;
const Factory_1 = require("../Factory");
const Node_1 = require("../Node");
const Validators_1 = require("../Validators");
function remap(fromValue, fromMin, fromMax, toMin, toMax) {
const fromRange = fromMax - fromMin, toRange = toMax - toMin;
if (fromRange === 0) {
return toMin + toRange / 2;
}
if (toRange === 0) {
return toMin;
}
let toValue = (fromValue - fromMin) / fromRange;
toValue = toRange * toValue + toMin;
return toValue;
}
const Enhance = function (imageData) {
const data = imageData.data, nSubPixels = data.length;
let rMin = data[0], rMax = rMin, r, gMin = data[1], gMax = gMin, g, bMin = data[2], bMax = bMin, b;
const enhanceAmount = this.enhance();
if (enhanceAmount === 0) {
return;
}
for (let i = 0; i < nSubPixels; i += 4) {
r = data[i + 0];
if (r < rMin) {
rMin = r;
}
else if (r > rMax) {
rMax = r;
}
g = data[i + 1];
if (g < gMin) {
gMin = g;
}
else if (g > gMax) {
gMax = g;
}
b = data[i + 2];
if (b < bMin) {
bMin = b;
}
else if (b > bMax) {
bMax = b;
}
}
if (rMax === rMin) {
rMax = 255;
rMin = 0;
}
if (gMax === gMin) {
gMax = 255;
gMin = 0;
}
if (bMax === bMin) {
bMax = 255;
bMin = 0;
}
let rGoalMax, rGoalMin, gGoalMax, gGoalMin, bGoalMax, bGoalMin;
if (enhanceAmount > 0) {
rGoalMax = rMax + enhanceAmount * (255 - rMax);
rGoalMin = rMin - enhanceAmount * (rMin - 0);
gGoalMax = gMax + enhanceAmount * (255 - gMax);
gGoalMin = gMin - enhanceAmount * (gMin - 0);
bGoalMax = bMax + enhanceAmount * (255 - bMax);
bGoalMin = bMin - enhanceAmount * (bMin - 0);
}
else {
const rMid = (rMax + rMin) * 0.5;
rGoalMax = rMax + enhanceAmount * (rMax - rMid);
rGoalMin = rMin + enhanceAmount * (rMin - rMid);
const gMid = (gMax + gMin) * 0.5;
gGoalMax = gMax + enhanceAmount * (gMax - gMid);
gGoalMin = gMin + enhanceAmount * (gMin - gMid);
const bMid = (bMax + bMin) * 0.5;
bGoalMax = bMax + enhanceAmount * (bMax - bMid);
bGoalMin = bMin + enhanceAmount * (bMin - bMid);
}
for (let i = 0; i < nSubPixels; i += 4) {
data[i + 0] = remap(data[i + 0], rMin, rMax, rGoalMin, rGoalMax);
data[i + 1] = remap(data[i + 1], gMin, gMax, gGoalMin, gGoalMax);
data[i + 2] = remap(data[i + 2], bMin, bMax, bGoalMin, bGoalMax);
}
};
exports.Enhance = Enhance;
Factory_1.Factory.addGetterSetter(Node_1.Node, 'enhance', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);

2
node_modules/konva/lib/filters/Grayscale.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const Grayscale: Filter;

13
node_modules/konva/lib/filters/Grayscale.js generated vendored Normal file
View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Grayscale = void 0;
const Grayscale = function (imageData) {
const data = imageData.data, len = data.length;
for (let i = 0; i < len; i += 4) {
const brightness = 0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2];
data[i] = brightness;
data[i + 1] = brightness;
data[i + 2] = brightness;
}
};
exports.Grayscale = Grayscale;

2
node_modules/konva/lib/filters/HSL.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const HSL: Filter;

28
node_modules/konva/lib/filters/HSL.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HSL = void 0;
const Factory_1 = require("../Factory");
const Node_1 = require("../Node");
const Validators_1 = require("../Validators");
Factory_1.Factory.addGetterSetter(Node_1.Node, 'hue', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);
Factory_1.Factory.addGetterSetter(Node_1.Node, 'saturation', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);
Factory_1.Factory.addGetterSetter(Node_1.Node, 'luminance', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);
const HSL = function (imageData) {
const data = imageData.data, nPixels = data.length, v = 1, s = Math.pow(2, this.saturation()), h = Math.abs(this.hue() + 360) % 360, l = this.luminance() * 127;
const vsu = v * s * Math.cos((h * Math.PI) / 180), vsw = v * s * Math.sin((h * Math.PI) / 180);
const rr = 0.299 * v + 0.701 * vsu + 0.167 * vsw, rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw, rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw;
const gr = 0.299 * v - 0.299 * vsu - 0.328 * vsw, gg = 0.587 * v + 0.413 * vsu + 0.035 * vsw, gb = 0.114 * v - 0.114 * vsu + 0.293 * vsw;
const br = 0.299 * v - 0.3 * vsu + 1.25 * vsw, bg = 0.587 * v - 0.586 * vsu - 1.05 * vsw, bb = 0.114 * v + 0.886 * vsu - 0.2 * vsw;
let r, g, b, a;
for (let i = 0; i < nPixels; i += 4) {
r = data[i + 0];
g = data[i + 1];
b = data[i + 2];
a = data[i + 3];
data[i + 0] = rr * r + rg * g + rb * b + l;
data[i + 1] = gr * r + gg * g + gb * b + l;
data[i + 2] = br * r + bg * g + bb * b + l;
data[i + 3] = a;
}
};
exports.HSL = HSL;

2
node_modules/konva/lib/filters/HSV.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const HSV: Filter;

27
node_modules/konva/lib/filters/HSV.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HSV = void 0;
const Factory_1 = require("../Factory");
const Node_1 = require("../Node");
const Validators_1 = require("../Validators");
const HSV = function (imageData) {
const data = imageData.data, nPixels = data.length, v = Math.pow(2, this.value()), s = Math.pow(2, this.saturation()), h = Math.abs(this.hue() + 360) % 360;
const vsu = v * s * Math.cos((h * Math.PI) / 180), vsw = v * s * Math.sin((h * Math.PI) / 180);
const rr = 0.299 * v + 0.701 * vsu + 0.167 * vsw, rg = 0.587 * v - 0.587 * vsu + 0.33 * vsw, rb = 0.114 * v - 0.114 * vsu - 0.497 * vsw;
const gr = 0.299 * v - 0.299 * vsu - 0.328 * vsw, gg = 0.587 * v + 0.413 * vsu + 0.035 * vsw, gb = 0.114 * v - 0.114 * vsu + 0.293 * vsw;
const br = 0.299 * v - 0.3 * vsu + 1.25 * vsw, bg = 0.587 * v - 0.586 * vsu - 1.05 * vsw, bb = 0.114 * v + 0.886 * vsu - 0.2 * vsw;
for (let i = 0; i < nPixels; i += 4) {
const r = data[i + 0];
const g = data[i + 1];
const b = data[i + 2];
const a = data[i + 3];
data[i + 0] = rr * r + rg * g + rb * b;
data[i + 1] = gr * r + gg * g + gb * b;
data[i + 2] = br * r + bg * g + bb * b;
data[i + 3] = a;
}
};
exports.HSV = HSV;
Factory_1.Factory.addGetterSetter(Node_1.Node, 'hue', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);
Factory_1.Factory.addGetterSetter(Node_1.Node, 'saturation', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);
Factory_1.Factory.addGetterSetter(Node_1.Node, 'value', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);

2
node_modules/konva/lib/filters/Invert.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const Invert: Filter;

12
node_modules/konva/lib/filters/Invert.js generated vendored Normal file
View File

@@ -0,0 +1,12 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Invert = void 0;
const Invert = function (imageData) {
const data = imageData.data, len = data.length;
for (let i = 0; i < len; i += 4) {
data[i] = 255 - data[i];
data[i + 1] = 255 - data[i + 1];
data[i + 2] = 255 - data[i + 2];
}
};
exports.Invert = Invert;

2
node_modules/konva/lib/filters/Kaleidoscope.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const Kaleidoscope: Filter;

137
node_modules/konva/lib/filters/Kaleidoscope.js generated vendored Normal file
View File

@@ -0,0 +1,137 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Kaleidoscope = void 0;
const Factory_1 = require("../Factory");
const Node_1 = require("../Node");
const Util_1 = require("../Util");
const Validators_1 = require("../Validators");
const ToPolar = function (src, dst, opt) {
const srcPixels = src.data, dstPixels = dst.data, xSize = src.width, ySize = src.height, xMid = opt.polarCenterX || xSize / 2, yMid = opt.polarCenterY || ySize / 2;
let rMax = Math.sqrt(xMid * xMid + yMid * yMid);
let x = xSize - xMid;
let y = ySize - yMid;
const rad = Math.sqrt(x * x + y * y);
rMax = rad > rMax ? rad : rMax;
const rSize = ySize, tSize = xSize;
const conversion = ((360 / tSize) * Math.PI) / 180;
for (let theta = 0; theta < tSize; theta += 1) {
const sin = Math.sin(theta * conversion);
const cos = Math.cos(theta * conversion);
for (let radius = 0; radius < rSize; radius += 1) {
x = Math.floor(xMid + ((rMax * radius) / rSize) * cos);
y = Math.floor(yMid + ((rMax * radius) / rSize) * sin);
let i = (y * xSize + x) * 4;
const r = srcPixels[i + 0];
const g = srcPixels[i + 1];
const b = srcPixels[i + 2];
const a = srcPixels[i + 3];
i = (theta + radius * xSize) * 4;
dstPixels[i + 0] = r;
dstPixels[i + 1] = g;
dstPixels[i + 2] = b;
dstPixels[i + 3] = a;
}
}
};
const FromPolar = function (src, dst, opt) {
const srcPixels = src.data, dstPixels = dst.data, xSize = src.width, ySize = src.height, xMid = opt.polarCenterX || xSize / 2, yMid = opt.polarCenterY || ySize / 2;
let rMax = Math.sqrt(xMid * xMid + yMid * yMid);
let x = xSize - xMid;
let y = ySize - yMid;
const rad = Math.sqrt(x * x + y * y);
rMax = rad > rMax ? rad : rMax;
const rSize = ySize, tSize = xSize, phaseShift = opt.polarRotation || 0;
let x1, y1;
for (x = 0; x < xSize; x += 1) {
for (y = 0; y < ySize; y += 1) {
const dx = x - xMid;
const dy = y - yMid;
const radius = (Math.sqrt(dx * dx + dy * dy) * rSize) / rMax;
let theta = ((Math.atan2(dy, dx) * 180) / Math.PI + 360 + phaseShift) % 360;
theta = (theta * tSize) / 360;
x1 = Math.floor(theta);
y1 = Math.floor(radius);
let i = (y1 * xSize + x1) * 4;
const r = srcPixels[i + 0];
const g = srcPixels[i + 1];
const b = srcPixels[i + 2];
const a = srcPixels[i + 3];
i = (y * xSize + x) * 4;
dstPixels[i + 0] = r;
dstPixels[i + 1] = g;
dstPixels[i + 2] = b;
dstPixels[i + 3] = a;
}
}
};
const Kaleidoscope = function (imageData) {
const xSize = imageData.width, ySize = imageData.height;
let x, y, xoff, i, r, g, b, a, srcPos, dstPos;
let power = Math.round(this.kaleidoscopePower());
const angle = Math.round(this.kaleidoscopeAngle());
const offset = Math.floor((xSize * (angle % 360)) / 360);
if (power < 1) {
return;
}
const tempCanvas = Util_1.Util.createCanvasElement();
tempCanvas.width = xSize;
tempCanvas.height = ySize;
const scratchData = tempCanvas
.getContext('2d')
.getImageData(0, 0, xSize, ySize);
Util_1.Util.releaseCanvas(tempCanvas);
ToPolar(imageData, scratchData, {
polarCenterX: xSize / 2,
polarCenterY: ySize / 2,
});
let minSectionSize = xSize / Math.pow(2, power);
while (minSectionSize <= 8) {
minSectionSize = minSectionSize * 2;
power -= 1;
}
minSectionSize = Math.ceil(minSectionSize);
let sectionSize = minSectionSize;
let xStart = 0, xEnd = sectionSize, xDelta = 1;
if (offset + minSectionSize > xSize) {
xStart = sectionSize;
xEnd = 0;
xDelta = -1;
}
for (y = 0; y < ySize; y += 1) {
for (x = xStart; x !== xEnd; x += xDelta) {
xoff = Math.round(x + offset) % xSize;
srcPos = (xSize * y + xoff) * 4;
r = scratchData.data[srcPos + 0];
g = scratchData.data[srcPos + 1];
b = scratchData.data[srcPos + 2];
a = scratchData.data[srcPos + 3];
dstPos = (xSize * y + x) * 4;
scratchData.data[dstPos + 0] = r;
scratchData.data[dstPos + 1] = g;
scratchData.data[dstPos + 2] = b;
scratchData.data[dstPos + 3] = a;
}
}
for (y = 0; y < ySize; y += 1) {
sectionSize = Math.floor(minSectionSize);
for (i = 0; i < power; i += 1) {
for (x = 0; x < sectionSize + 1; x += 1) {
srcPos = (xSize * y + x) * 4;
r = scratchData.data[srcPos + 0];
g = scratchData.data[srcPos + 1];
b = scratchData.data[srcPos + 2];
a = scratchData.data[srcPos + 3];
dstPos = (xSize * y + sectionSize * 2 - x - 1) * 4;
scratchData.data[dstPos + 0] = r;
scratchData.data[dstPos + 1] = g;
scratchData.data[dstPos + 2] = b;
scratchData.data[dstPos + 3] = a;
}
sectionSize *= 2;
}
}
FromPolar(scratchData, imageData, { polarRotation: 0 });
};
exports.Kaleidoscope = Kaleidoscope;
Factory_1.Factory.addGetterSetter(Node_1.Node, 'kaleidoscopePower', 2, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);
Factory_1.Factory.addGetterSetter(Node_1.Node, 'kaleidoscopeAngle', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);

2
node_modules/konva/lib/filters/Mask.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const Mask: Filter;

145
node_modules/konva/lib/filters/Mask.js generated vendored Normal file
View File

@@ -0,0 +1,145 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Mask = void 0;
const Factory_1 = require("../Factory");
const Node_1 = require("../Node");
const Validators_1 = require("../Validators");
function pixelAt(idata, x, y) {
let idx = (y * idata.width + x) * 4;
const d = [];
d.push(idata.data[idx++], idata.data[idx++], idata.data[idx++], idata.data[idx++]);
return d;
}
function rgbDistance(p1, p2) {
return Math.sqrt(Math.pow(p1[0] - p2[0], 2) +
Math.pow(p1[1] - p2[1], 2) +
Math.pow(p1[2] - p2[2], 2));
}
function rgbMean(pTab) {
const m = [0, 0, 0];
for (let i = 0; i < pTab.length; i++) {
m[0] += pTab[i][0];
m[1] += pTab[i][1];
m[2] += pTab[i][2];
}
m[0] /= pTab.length;
m[1] /= pTab.length;
m[2] /= pTab.length;
return m;
}
function backgroundMask(idata, threshold) {
const rgbv_no = pixelAt(idata, 0, 0);
const rgbv_ne = pixelAt(idata, idata.width - 1, 0);
const rgbv_so = pixelAt(idata, 0, idata.height - 1);
const rgbv_se = pixelAt(idata, idata.width - 1, idata.height - 1);
const thres = threshold || 10;
if (rgbDistance(rgbv_no, rgbv_ne) < thres &&
rgbDistance(rgbv_ne, rgbv_se) < thres &&
rgbDistance(rgbv_se, rgbv_so) < thres &&
rgbDistance(rgbv_so, rgbv_no) < thres) {
const mean = rgbMean([rgbv_ne, rgbv_no, rgbv_se, rgbv_so]);
const mask = [];
for (let i = 0; i < idata.width * idata.height; i++) {
const d = rgbDistance(mean, [
idata.data[i * 4],
idata.data[i * 4 + 1],
idata.data[i * 4 + 2],
]);
mask[i] = d < thres ? 0 : 255;
}
return mask;
}
}
function applyMask(idata, mask) {
for (let i = 0; i < idata.width * idata.height; i++) {
idata.data[4 * i + 3] = mask[i];
}
}
function erodeMask(mask, sw, sh) {
const weights = [1, 1, 1, 1, 0, 1, 1, 1, 1];
const side = Math.round(Math.sqrt(weights.length));
const halfSide = Math.floor(side / 2);
const maskResult = [];
for (let y = 0; y < sh; y++) {
for (let x = 0; x < sw; x++) {
const so = y * sw + x;
let a = 0;
for (let cy = 0; cy < side; cy++) {
for (let cx = 0; cx < side; cx++) {
const scy = y + cy - halfSide;
const scx = x + cx - halfSide;
if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) {
const srcOff = scy * sw + scx;
const wt = weights[cy * side + cx];
a += mask[srcOff] * wt;
}
}
}
maskResult[so] = a === 255 * 8 ? 255 : 0;
}
}
return maskResult;
}
function dilateMask(mask, sw, sh) {
const weights = [1, 1, 1, 1, 1, 1, 1, 1, 1];
const side = Math.round(Math.sqrt(weights.length));
const halfSide = Math.floor(side / 2);
const maskResult = [];
for (let y = 0; y < sh; y++) {
for (let x = 0; x < sw; x++) {
const so = y * sw + x;
let a = 0;
for (let cy = 0; cy < side; cy++) {
for (let cx = 0; cx < side; cx++) {
const scy = y + cy - halfSide;
const scx = x + cx - halfSide;
if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) {
const srcOff = scy * sw + scx;
const wt = weights[cy * side + cx];
a += mask[srcOff] * wt;
}
}
}
maskResult[so] = a >= 255 * 4 ? 255 : 0;
}
}
return maskResult;
}
function smoothEdgeMask(mask, sw, sh) {
const weights = [1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9, 1 / 9];
const side = Math.round(Math.sqrt(weights.length));
const halfSide = Math.floor(side / 2);
const maskResult = [];
for (let y = 0; y < sh; y++) {
for (let x = 0; x < sw; x++) {
const so = y * sw + x;
let a = 0;
for (let cy = 0; cy < side; cy++) {
for (let cx = 0; cx < side; cx++) {
const scy = y + cy - halfSide;
const scx = x + cx - halfSide;
if (scy >= 0 && scy < sh && scx >= 0 && scx < sw) {
const srcOff = scy * sw + scx;
const wt = weights[cy * side + cx];
a += mask[srcOff] * wt;
}
}
}
maskResult[so] = a;
}
}
return maskResult;
}
const Mask = function (imageData) {
const threshold = this.threshold();
let mask = backgroundMask(imageData, threshold);
if (mask) {
mask = erodeMask(mask, imageData.width, imageData.height);
mask = dilateMask(mask, imageData.width, imageData.height);
mask = smoothEdgeMask(mask, imageData.width, imageData.height);
applyMask(imageData, mask);
}
return imageData;
};
exports.Mask = Mask;
Factory_1.Factory.addGetterSetter(Node_1.Node, 'threshold', 0, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);

2
node_modules/konva/lib/filters/Noise.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const Noise: Filter;

16
node_modules/konva/lib/filters/Noise.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Noise = void 0;
const Factory_1 = require("../Factory");
const Node_1 = require("../Node");
const Validators_1 = require("../Validators");
const Noise = function (imageData) {
const amount = this.noise() * 255, data = imageData.data, nPixels = data.length, half = amount / 2;
for (let i = 0; i < nPixels; i += 4) {
data[i + 0] += half - 2 * half * Math.random();
data[i + 1] += half - 2 * half * Math.random();
data[i + 2] += half - 2 * half * Math.random();
}
};
exports.Noise = Noise;
Factory_1.Factory.addGetterSetter(Node_1.Node, 'noise', 0.2, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);

2
node_modules/konva/lib/filters/Pixelate.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const Pixelate: Filter;

64
node_modules/konva/lib/filters/Pixelate.js generated vendored Normal file
View File

@@ -0,0 +1,64 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Pixelate = void 0;
const Factory_1 = require("../Factory");
const Util_1 = require("../Util");
const Node_1 = require("../Node");
const Validators_1 = require("../Validators");
const Pixelate = function (imageData) {
let pixelSize = Math.ceil(this.pixelSize()), width = imageData.width, height = imageData.height, nBinsX = Math.ceil(width / pixelSize), nBinsY = Math.ceil(height / pixelSize), data = imageData.data;
if (pixelSize <= 0) {
Util_1.Util.error('pixelSize value can not be <= 0');
return;
}
for (let xBin = 0; xBin < nBinsX; xBin += 1) {
for (let yBin = 0; yBin < nBinsY; yBin += 1) {
let red = 0;
let green = 0;
let blue = 0;
let alpha = 0;
const xBinStart = xBin * pixelSize;
const xBinEnd = xBinStart + pixelSize;
const yBinStart = yBin * pixelSize;
const yBinEnd = yBinStart + pixelSize;
let pixelsInBin = 0;
for (let x = xBinStart; x < xBinEnd; x += 1) {
if (x >= width) {
continue;
}
for (let y = yBinStart; y < yBinEnd; y += 1) {
if (y >= height) {
continue;
}
const i = (width * y + x) * 4;
red += data[i + 0];
green += data[i + 1];
blue += data[i + 2];
alpha += data[i + 3];
pixelsInBin += 1;
}
}
red = red / pixelsInBin;
green = green / pixelsInBin;
blue = blue / pixelsInBin;
alpha = alpha / pixelsInBin;
for (let x = xBinStart; x < xBinEnd; x += 1) {
if (x >= width) {
continue;
}
for (let y = yBinStart; y < yBinEnd; y += 1) {
if (y >= height) {
continue;
}
const i = (width * y + x) * 4;
data[i + 0] = red;
data[i + 1] = green;
data[i + 2] = blue;
data[i + 3] = alpha;
}
}
}
}
};
exports.Pixelate = Pixelate;
Factory_1.Factory.addGetterSetter(Node_1.Node, 'pixelSize', 8, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);

2
node_modules/konva/lib/filters/Posterize.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const Posterize: Filter;

14
node_modules/konva/lib/filters/Posterize.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Posterize = void 0;
const Factory_1 = require("../Factory");
const Node_1 = require("../Node");
const Validators_1 = require("../Validators");
const Posterize = function (imageData) {
const levels = Math.round(this.levels() * 254) + 1, data = imageData.data, len = data.length, scale = 255 / levels;
for (let i = 0; i < len; i += 1) {
data[i] = Math.floor(data[i] / scale) * scale;
}
};
exports.Posterize = Posterize;
Factory_1.Factory.addGetterSetter(Node_1.Node, 'levels', 0.5, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);

2
node_modules/konva/lib/filters/RGB.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const RGB: Filter;

42
node_modules/konva/lib/filters/RGB.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RGB = void 0;
const Factory_1 = require("../Factory");
const Node_1 = require("../Node");
const Validators_1 = require("../Validators");
const RGB = function (imageData) {
const data = imageData.data, nPixels = data.length, red = this.red(), green = this.green(), blue = this.blue();
for (let i = 0; i < nPixels; i += 4) {
const brightness = (0.34 * data[i] + 0.5 * data[i + 1] + 0.16 * data[i + 2]) / 255;
data[i] = brightness * red;
data[i + 1] = brightness * green;
data[i + 2] = brightness * blue;
data[i + 3] = data[i + 3];
}
};
exports.RGB = RGB;
Factory_1.Factory.addGetterSetter(Node_1.Node, 'red', 0, function (val) {
this._filterUpToDate = false;
if (val > 255) {
return 255;
}
else if (val < 0) {
return 0;
}
else {
return Math.round(val);
}
});
Factory_1.Factory.addGetterSetter(Node_1.Node, 'green', 0, function (val) {
this._filterUpToDate = false;
if (val > 255) {
return 255;
}
else if (val < 0) {
return 0;
}
else {
return Math.round(val);
}
});
Factory_1.Factory.addGetterSetter(Node_1.Node, 'blue', 0, Validators_1.RGBComponent, Factory_1.Factory.afterSetFilter);

2
node_modules/konva/lib/filters/RGBA.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const RGBA: Filter;

53
node_modules/konva/lib/filters/RGBA.js generated vendored Normal file
View File

@@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RGBA = void 0;
const Factory_1 = require("../Factory");
const Node_1 = require("../Node");
const Validators_1 = require("../Validators");
const RGBA = function (imageData) {
const data = imageData.data, nPixels = data.length, red = this.red(), green = this.green(), blue = this.blue(), alpha = this.alpha();
for (let i = 0; i < nPixels; i += 4) {
const ia = 1 - alpha;
data[i] = red * alpha + data[i] * ia;
data[i + 1] = green * alpha + data[i + 1] * ia;
data[i + 2] = blue * alpha + data[i + 2] * ia;
}
};
exports.RGBA = RGBA;
Factory_1.Factory.addGetterSetter(Node_1.Node, 'red', 0, function (val) {
this._filterUpToDate = false;
if (val > 255) {
return 255;
}
else if (val < 0) {
return 0;
}
else {
return Math.round(val);
}
});
Factory_1.Factory.addGetterSetter(Node_1.Node, 'green', 0, function (val) {
this._filterUpToDate = false;
if (val > 255) {
return 255;
}
else if (val < 0) {
return 0;
}
else {
return Math.round(val);
}
});
Factory_1.Factory.addGetterSetter(Node_1.Node, 'blue', 0, Validators_1.RGBComponent, Factory_1.Factory.afterSetFilter);
Factory_1.Factory.addGetterSetter(Node_1.Node, 'alpha', 1, function (val) {
this._filterUpToDate = false;
if (val > 1) {
return 1;
}
else if (val < 0) {
return 0;
}
else {
return val;
}
});

2
node_modules/konva/lib/filters/Sepia.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const Sepia: Filter;

15
node_modules/konva/lib/filters/Sepia.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Sepia = void 0;
const Sepia = function (imageData) {
const data = imageData.data, nPixels = data.length;
for (let i = 0; i < nPixels; i += 4) {
const r = data[i + 0];
const g = data[i + 1];
const b = data[i + 2];
data[i + 0] = Math.min(255, r * 0.393 + g * 0.769 + b * 0.189);
data[i + 1] = Math.min(255, r * 0.349 + g * 0.686 + b * 0.168);
data[i + 2] = Math.min(255, r * 0.272 + g * 0.534 + b * 0.131);
}
};
exports.Sepia = Sepia;

2
node_modules/konva/lib/filters/Solarize.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const Solarize: Filter;

30
node_modules/konva/lib/filters/Solarize.js generated vendored Normal file
View File

@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Solarize = void 0;
const Solarize = function (imageData) {
const data = imageData.data, w = imageData.width, h = imageData.height, w4 = w * 4;
let y = h;
do {
const offsetY = (y - 1) * w4;
let x = w;
do {
const offset = offsetY + (x - 1) * 4;
let r = data[offset];
let g = data[offset + 1];
let b = data[offset + 2];
if (r > 127) {
r = 255 - r;
}
if (g > 127) {
g = 255 - g;
}
if (b > 127) {
b = 255 - b;
}
data[offset] = r;
data[offset + 1] = g;
data[offset + 2] = b;
} while (--x);
} while (--y);
};
exports.Solarize = Solarize;

2
node_modules/konva/lib/filters/Threshold.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Filter } from '../Node.js';
export declare const Threshold: Filter;

14
node_modules/konva/lib/filters/Threshold.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Threshold = void 0;
const Factory_1 = require("../Factory");
const Node_1 = require("../Node");
const Validators_1 = require("../Validators");
const Threshold = function (imageData) {
const level = this.threshold() * 255, data = imageData.data, len = data.length;
for (let i = 0; i < len; i += 1) {
data[i] = data[i] < level ? 0 : 255;
}
};
exports.Threshold = Threshold;
Factory_1.Factory.addGetterSetter(Node_1.Node, 'threshold', 0.5, (0, Validators_1.getNumberValidator)(), Factory_1.Factory.afterSetFilter);

2
node_modules/konva/lib/index-node.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Konva } from './_FullInternals.js';
export default Konva;

21
node_modules/konva/lib/index-node.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const _FullInternals_1 = require("./_FullInternals");
const Canvas = require("canvas");
const canvas = Canvas['default'] || Canvas;
global.DOMMatrix = canvas.DOMMatrix;
const isNode = typeof global.document === 'undefined';
if (isNode) {
_FullInternals_1.Konva.Util['createCanvasElement'] = () => {
const node = canvas.createCanvas(300, 300);
if (!node['style']) {
node['style'] = {};
}
return node;
};
_FullInternals_1.Konva.Util.createImageElement = () => {
const node = new canvas.Image();
return node;
};
}
module.exports = _FullInternals_1.Konva;

181
node_modules/konva/lib/index-types.d.ts generated vendored Normal file
View File

@@ -0,0 +1,181 @@
// the purpose of that file is very stupid
// I was not able to generate correct typescript declarations from the main source code
// because right now Konva is an object. Typescript can not define types from object like this:
// const stage : Konva.Stage = new Konva.Stage();
// we can convert Konva to namespace
// but I was not able to find a way to extend it
// so here we just need to define full API of Konva manually
// filters
import { Blur } from './filters/Blur.js';
import { Brighten } from './filters/Brighten.js';
import { Contrast } from './filters/Contrast.js';
import { Emboss } from './filters/Emboss.js';
import { Enhance } from './filters/Enhance.js';
import { Grayscale } from './filters/Grayscale.js';
import { HSL } from './filters/HSL.js';
import { HSV } from './filters/HSV.js';
import { Invert } from './filters/Invert.js';
import { Kaleidoscope } from './filters/Kaleidoscope.js';
import { Mask } from './filters/Mask.js';
import { Noise } from './filters/Noise.js';
import { Pixelate } from './filters/Pixelate.js';
import { Posterize } from './filters/Posterize.js';
import { RGB } from './filters/RGB.js';
import { RGBA } from './filters/RGBA.js';
import { Sepia } from './filters/Sepia.js';
import { Solarize } from './filters/Solarize.js';
import { Threshold } from './filters/Threshold.js';
declare namespace Konva {
export let enableTrace: number;
export let pixelRatio: number;
export let autoDrawEnabled: boolean;
export let dragDistance: number;
export let angleDeg: boolean;
export let showWarnings: boolean;
export let capturePointerEventsEnabled: boolean;
export let dragButtons: Array<number>;
export let hitOnDragEnabled: boolean;
export const isDragging: () => boolean;
export const isDragReady: () => boolean;
export const getAngle: (angle: number) => number;
export type Vector2d = import('./types.js').Vector2d;
export const Node: typeof import('./Node.js').Node;
export type Node = import('./Node.js').Node;
export type NodeConfig = import('./Node.js').NodeConfig;
export type KonvaEventObject<EventType> =
import('./Node.js').KonvaEventObject<EventType>;
export type KonvaPointerEvent = import('./PointerEvents.js').KonvaPointerEvent;
export type KonvaEventListener<This, EventType> =
import('./Node.js').KonvaEventListener<This, EventType>;
export const Container: typeof import('./Container.js').Container;
export type Container = import('./Container.js').Container<Node>;
export type ContainerConfig = import('./Container.js').ContainerConfig;
export const Transform: typeof import('./Util.js').Transform;
export type Transform = import('./Util.js').Transform;
export const Util: typeof import('./Util.js').Util;
export const Context: typeof import('./Context.js').Context;
export type Context = import('./Context.js').Context;
export const Stage: typeof import('./Stage.js').Stage;
export type Stage = import('./Stage.js').Stage;
export type StageConfig = import('./Stage.js').StageConfig;
export const stages: typeof import('./Stage.js').stages;
export const Layer: typeof import('./Layer.js').Layer;
export type Layer = import('./Layer.js').Layer;
export type LayerConfig = import('./Layer.js').LayerConfig;
export const FastLayer: typeof import('./FastLayer.js').FastLayer;
export type FastLayer = import('./FastLayer.js').FastLayer;
export const Group: typeof import('./Group.js').Group;
export type Group = import('./Group.js').Group;
export type GroupConfig = import('./Group.js').GroupConfig;
export const DD: typeof import('./DragAndDrop.js').DD;
export const Shape: typeof import('./Shape.js').Shape;
export type Shape = import('./Shape.js').Shape;
export type ShapeConfig = import('./Shape.js').ShapeConfig;
export const shapes: typeof import('./Shape.js').shapes;
export const Animation: typeof import('./Animation.js').Animation;
export type Animation = import('./Animation.js').Animation;
export const Tween: typeof import('./Tween.js').Tween;
export type Tween = import('./Tween.js').Tween;
export type TweenConfig = import('./Tween.js').TweenConfig;
export const Easings: typeof import('./Tween.js').Easings;
export const Arc: typeof import('./shapes/Arc.js').Arc;
export type Arc = import('./shapes/Arc.js').Arc;
export type ArcConfig = import('./shapes/Arc.js').ArcConfig;
export const Arrow: typeof import('./shapes/Arrow.js').Arrow;
export type Arrow = import('./shapes/Arrow.js').Arrow;
export type ArrowConfig = import('./shapes/Arrow.js').ArrowConfig;
export const Circle: typeof import('./shapes/Circle.js').Circle;
export type Circle = import('./shapes/Circle.js').Circle;
export type CircleConfig = import('./shapes/Circle.js').CircleConfig;
export const Ellipse: typeof import('./shapes/Ellipse.js').Ellipse;
export type Ellipse = import('./shapes/Ellipse.js').Ellipse;
export type EllipseConfig = import('./shapes/Ellipse.js').EllipseConfig;
export const Image: typeof import('./shapes/Image.js').Image;
export type Image = import('./shapes/Image.js').Image;
export type ImageConfig = import('./shapes/Image.js').ImageConfig;
export const Label: typeof import('./shapes/Label.js').Label;
export type Label = import('./shapes/Label.js').Label;
export type LabelConfig = import('./shapes/Label.js').LabelConfig;
export const Tag: typeof import('./shapes/Label.js').Tag;
export type Tag = import('./shapes/Label.js').Tag;
export type TagConfig = import('./shapes/Label.js').TagConfig;
export const Line: typeof import('./shapes/Line.js').Line;
export type Line = import('./shapes/Line.js').Line;
export type LineConfig = import('./shapes/Line.js').LineConfig;
export const Path: typeof import('./shapes/Path.js').Path;
export type Path = import('./shapes/Path.js').Path;
export type PathConfig = import('./shapes/Path.js').PathConfig;
export const Rect: typeof import('./shapes/Rect.js').Rect;
export type Rect = import('./shapes/Rect.js').Rect;
export type RectConfig = import('./shapes/Rect.js').RectConfig;
export const RegularPolygon: typeof import('./shapes/RegularPolygon.js').RegularPolygon;
export type RegularPolygon = import('./shapes/RegularPolygon.js').RegularPolygon;
export type RegularPolygonConfig =
import('./shapes/RegularPolygon.js').RegularPolygonConfig;
export const Ring: typeof import('./shapes/Ring.js').Ring;
export type Ring = import('./shapes/Ring.js').Ring;
export type RingConfig = import('./shapes/Ring.js').RingConfig;
export const Sprite: typeof import('./shapes/Sprite.js').Sprite;
export type Sprite = import('./shapes/Sprite.js').Sprite;
export type SpriteConfig = import('./shapes/Sprite.js').SpriteConfig;
export const Star: typeof import('./shapes/Star.js').Star;
export type Star = import('./shapes/Star.js').Star;
export type StarConfig = import('./shapes/Star.js').StarConfig;
export const Text: typeof import('./shapes/Text.js').Text;
export type Text = import('./shapes/Text.js').Text;
export type TextConfig = import('./shapes/Text.js').TextConfig;
export const TextPath: typeof import('./shapes/TextPath.js').TextPath;
export type TextPath = import('./shapes/TextPath.js').TextPath;
export type TextPathConfig = import('./shapes/TextPath.js').TextPathConfig;
export const Transformer: typeof import('./shapes/Transformer.js').Transformer;
export type Transformer = import('./shapes/Transformer.js').Transformer;
export type TransformerConfig =
import('./shapes/Transformer.js').TransformerConfig;
export const Wedge: typeof import('./shapes/Wedge.js').Wedge;
export type Wedge = import('./shapes/Wedge.js').Wedge;
export type WedgeConfig = import('./shapes/Wedge.js').WedgeConfig;
export const Filters: {
Blur: typeof Blur;
Brighten: typeof Brighten;
Contrast: typeof Contrast;
Emboss: typeof Emboss;
Enhance: typeof Enhance;
Grayscale: typeof Grayscale;
HSL: typeof HSL;
HSV: typeof HSV;
Invert: typeof Invert;
Kaleidoscope: typeof Kaleidoscope;
Mask: typeof Mask;
Noise: typeof Noise;
Pixelate: typeof Pixelate;
Posterize: typeof Posterize;
RGB: typeof RGB;
RGBA: typeof RGBA;
Sepia: typeof Sepia;
Solarize: typeof Solarize;
Threshold: typeof Threshold;
};
}
export default Konva;

2
node_modules/konva/lib/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Konva } from './_FullInternals.js';
export default Konva;

4
node_modules/konva/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const _FullInternals_1 = require("./_FullInternals");
module.exports = _FullInternals_1.Konva;

26
node_modules/konva/lib/shapes/Arc.d.ts generated vendored Normal file
View File

@@ -0,0 +1,26 @@
import { Shape, ShapeConfig } from '../Shape.js';
import { GetSet } from '../types.js';
import { Context } from '../Context.js';
export interface ArcConfig extends ShapeConfig {
angle: number;
innerRadius: number;
outerRadius: number;
clockwise?: boolean;
}
export declare class Arc extends Shape<ArcConfig> {
_sceneFunc(context: Context): void;
getWidth(): number;
getHeight(): number;
setWidth(width: number): void;
setHeight(height: number): void;
getSelfRect(): {
x: number;
y: number;
width: number;
height: number;
};
innerRadius: GetSet<number, this>;
outerRadius: GetSet<number, this>;
angle: GetSet<number, this>;
clockwise: GetSet<boolean, this>;
}

64
node_modules/konva/lib/shapes/Arc.js generated vendored Normal file
View File

@@ -0,0 +1,64 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Arc = void 0;
const Factory_1 = require("../Factory");
const Shape_1 = require("../Shape");
const Global_1 = require("../Global");
const Validators_1 = require("../Validators");
const Global_2 = require("../Global");
class Arc extends Shape_1.Shape {
_sceneFunc(context) {
const angle = Global_1.Konva.getAngle(this.angle()), clockwise = this.clockwise();
context.beginPath();
context.arc(0, 0, this.outerRadius(), 0, angle, clockwise);
context.arc(0, 0, this.innerRadius(), angle, 0, !clockwise);
context.closePath();
context.fillStrokeShape(this);
}
getWidth() {
return this.outerRadius() * 2;
}
getHeight() {
return this.outerRadius() * 2;
}
setWidth(width) {
this.outerRadius(width / 2);
}
setHeight(height) {
this.outerRadius(height / 2);
}
getSelfRect() {
const innerRadius = this.innerRadius();
const outerRadius = this.outerRadius();
const clockwise = this.clockwise();
const angle = Global_1.Konva.getAngle(clockwise ? 360 - this.angle() : this.angle());
const boundLeftRatio = Math.cos(Math.min(angle, Math.PI));
const boundRightRatio = 1;
const boundTopRatio = Math.sin(Math.min(Math.max(Math.PI, angle), (3 * Math.PI) / 2));
const boundBottomRatio = Math.sin(Math.min(angle, Math.PI / 2));
const boundLeft = boundLeftRatio * (boundLeftRatio > 0 ? innerRadius : outerRadius);
const boundRight = boundRightRatio * (boundRightRatio > 0 ? outerRadius : innerRadius);
const boundTop = boundTopRatio * (boundTopRatio > 0 ? innerRadius : outerRadius);
const boundBottom = boundBottomRatio * (boundBottomRatio > 0 ? outerRadius : innerRadius);
return {
x: boundLeft,
y: clockwise ? -1 * boundBottom : boundTop,
width: boundRight - boundLeft,
height: boundBottom - boundTop,
};
}
}
exports.Arc = Arc;
Arc.prototype._centroid = true;
Arc.prototype.className = 'Arc';
Arc.prototype._attrsAffectingSize = [
'innerRadius',
'outerRadius',
'angle',
'clockwise',
];
(0, Global_2._registerNode)(Arc);
Factory_1.Factory.addGetterSetter(Arc, 'innerRadius', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Arc, 'outerRadius', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Arc, 'angle', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Arc, 'clockwise', false, (0, Validators_1.getBooleanValidator)());

26
node_modules/konva/lib/shapes/Arrow.d.ts generated vendored Normal file
View File

@@ -0,0 +1,26 @@
import { Line, LineConfig } from './Line.js';
import { GetSet } from '../types.js';
import { Context } from '../Context.js';
export interface ArrowConfig extends LineConfig {
points: number[];
tension?: number;
closed?: boolean;
pointerLength?: number;
pointerWidth?: number;
pointerAtBeginning?: boolean;
pointerAtEnding?: boolean;
}
export declare class Arrow extends Line<ArrowConfig> {
_sceneFunc(ctx: Context): void;
__fillStroke(ctx: Context): void;
getSelfRect(): {
x: number;
y: number;
width: number;
height: number;
};
pointerLength: GetSet<number, this>;
pointerWidth: GetSet<number, this>;
pointerAtEnding: GetSet<boolean, this>;
pointerAtBeginning: GetSet<boolean, this>;
}

103
node_modules/konva/lib/shapes/Arrow.js generated vendored Normal file
View File

@@ -0,0 +1,103 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Arrow = void 0;
const Factory_1 = require("../Factory");
const Line_1 = require("./Line");
const Validators_1 = require("../Validators");
const Global_1 = require("../Global");
const Path_1 = require("./Path");
class Arrow extends Line_1.Line {
_sceneFunc(ctx) {
super._sceneFunc(ctx);
const PI2 = Math.PI * 2;
const points = this.points();
let tp = points;
const fromTension = this.tension() !== 0 && points.length > 4;
if (fromTension) {
tp = this.getTensionPoints();
}
const length = this.pointerLength();
const n = points.length;
let dx, dy;
if (fromTension) {
const lp = [
tp[tp.length - 4],
tp[tp.length - 3],
tp[tp.length - 2],
tp[tp.length - 1],
points[n - 2],
points[n - 1],
];
const lastLength = Path_1.Path.calcLength(tp[tp.length - 4], tp[tp.length - 3], 'C', lp);
const previous = Path_1.Path.getPointOnQuadraticBezier(Math.min(1, 1 - length / lastLength), lp[0], lp[1], lp[2], lp[3], lp[4], lp[5]);
dx = points[n - 2] - previous.x;
dy = points[n - 1] - previous.y;
}
else {
dx = points[n - 2] - points[n - 4];
dy = points[n - 1] - points[n - 3];
}
const radians = (Math.atan2(dy, dx) + PI2) % PI2;
const width = this.pointerWidth();
if (this.pointerAtEnding()) {
ctx.save();
ctx.beginPath();
ctx.translate(points[n - 2], points[n - 1]);
ctx.rotate(radians);
ctx.moveTo(0, 0);
ctx.lineTo(-length, width / 2);
ctx.lineTo(-length, -width / 2);
ctx.closePath();
ctx.restore();
this.__fillStroke(ctx);
}
if (this.pointerAtBeginning()) {
ctx.save();
ctx.beginPath();
ctx.translate(points[0], points[1]);
if (fromTension) {
dx = (tp[0] + tp[2]) / 2 - points[0];
dy = (tp[1] + tp[3]) / 2 - points[1];
}
else {
dx = points[2] - points[0];
dy = points[3] - points[1];
}
ctx.rotate((Math.atan2(-dy, -dx) + PI2) % PI2);
ctx.moveTo(0, 0);
ctx.lineTo(-length, width / 2);
ctx.lineTo(-length, -width / 2);
ctx.closePath();
ctx.restore();
this.__fillStroke(ctx);
}
}
__fillStroke(ctx) {
const isDashEnabled = this.dashEnabled();
if (isDashEnabled) {
this.attrs.dashEnabled = false;
ctx.setLineDash([]);
}
ctx.fillStrokeShape(this);
if (isDashEnabled) {
this.attrs.dashEnabled = true;
}
}
getSelfRect() {
const lineRect = super.getSelfRect();
const offset = this.pointerWidth() / 2;
return {
x: lineRect.x,
y: lineRect.y - offset,
width: lineRect.width,
height: lineRect.height + offset * 2,
};
}
}
exports.Arrow = Arrow;
Arrow.prototype.className = 'Arrow';
(0, Global_1._registerNode)(Arrow);
Factory_1.Factory.addGetterSetter(Arrow, 'pointerLength', 10, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Arrow, 'pointerWidth', 10, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Arrow, 'pointerAtBeginning', false);
Factory_1.Factory.addGetterSetter(Arrow, 'pointerAtEnding', true);

14
node_modules/konva/lib/shapes/Circle.d.ts generated vendored Normal file
View File

@@ -0,0 +1,14 @@
import { Shape, ShapeConfig } from '../Shape.js';
import { GetSet } from '../types.js';
import { Context } from '../Context.js';
export interface CircleConfig extends ShapeConfig {
radius?: number;
}
export declare class Circle extends Shape<CircleConfig> {
_sceneFunc(context: Context): void;
getWidth(): number;
getHeight(): number;
setWidth(width: number): void;
setHeight(height: number): void;
radius: GetSet<number, this>;
}

37
node_modules/konva/lib/shapes/Circle.js generated vendored Normal file
View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Circle = void 0;
const Factory_1 = require("../Factory");
const Shape_1 = require("../Shape");
const Validators_1 = require("../Validators");
const Global_1 = require("../Global");
class Circle extends Shape_1.Shape {
_sceneFunc(context) {
context.beginPath();
context.arc(0, 0, this.attrs.radius || 0, 0, Math.PI * 2, false);
context.closePath();
context.fillStrokeShape(this);
}
getWidth() {
return this.radius() * 2;
}
getHeight() {
return this.radius() * 2;
}
setWidth(width) {
if (this.radius() !== width / 2) {
this.radius(width / 2);
}
}
setHeight(height) {
if (this.radius() !== height / 2) {
this.radius(height / 2);
}
}
}
exports.Circle = Circle;
Circle.prototype._centroid = true;
Circle.prototype.className = 'Circle';
Circle.prototype._attrsAffectingSize = ['radius'];
(0, Global_1._registerNode)(Circle);
Factory_1.Factory.addGetterSetter(Circle, 'radius', 0, (0, Validators_1.getNumberValidator)());

17
node_modules/konva/lib/shapes/Ellipse.d.ts generated vendored Normal file
View File

@@ -0,0 +1,17 @@
import { Shape, ShapeConfig } from '../Shape.js';
import { Context } from '../Context.js';
import { GetSet, Vector2d } from '../types.js';
export interface EllipseConfig extends ShapeConfig {
radiusX: number;
radiusY: number;
}
export declare class Ellipse extends Shape<EllipseConfig> {
_sceneFunc(context: Context): void;
getWidth(): number;
getHeight(): number;
setWidth(width: number): void;
setHeight(height: number): void;
radius: GetSet<Vector2d, this>;
radiusX: GetSet<number, this>;
radiusY: GetSet<number, this>;
}

41
node_modules/konva/lib/shapes/Ellipse.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Ellipse = void 0;
const Factory_1 = require("../Factory");
const Shape_1 = require("../Shape");
const Validators_1 = require("../Validators");
const Global_1 = require("../Global");
class Ellipse extends Shape_1.Shape {
_sceneFunc(context) {
const rx = this.radiusX(), ry = this.radiusY();
context.beginPath();
context.save();
if (rx !== ry) {
context.scale(1, ry / rx);
}
context.arc(0, 0, rx, 0, Math.PI * 2, false);
context.restore();
context.closePath();
context.fillStrokeShape(this);
}
getWidth() {
return this.radiusX() * 2;
}
getHeight() {
return this.radiusY() * 2;
}
setWidth(width) {
this.radiusX(width / 2);
}
setHeight(height) {
this.radiusY(height / 2);
}
}
exports.Ellipse = Ellipse;
Ellipse.prototype.className = 'Ellipse';
Ellipse.prototype._centroid = true;
Ellipse.prototype._attrsAffectingSize = ['radiusX', 'radiusY'];
(0, Global_1._registerNode)(Ellipse);
Factory_1.Factory.addComponentsGetterSetter(Ellipse, 'radius', ['x', 'y']);
Factory_1.Factory.addGetterSetter(Ellipse, 'radiusX', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Ellipse, 'radiusY', 0, (0, Validators_1.getNumberValidator)());

28
node_modules/konva/lib/shapes/Image.d.ts generated vendored Normal file
View File

@@ -0,0 +1,28 @@
import { Shape, ShapeConfig } from '../Shape.js';
import { GetSet, IRect } from '../types.js';
import { Context } from '../Context.js';
export interface ImageConfig extends ShapeConfig {
image: CanvasImageSource | undefined;
crop?: IRect;
cornerRadius?: number | number[];
}
export declare class Image extends Shape<ImageConfig> {
private _loadListener;
constructor(attrs: ImageConfig);
_setImageLoad(): void;
_removeImageLoad(image: any): void;
destroy(): this;
_useBufferCanvas(): boolean;
_sceneFunc(context: Context): void;
_hitFunc(context: Context): void;
getWidth(): any;
getHeight(): any;
static fromURL(url: string, callback: (img: Image) => void, onError?: OnErrorEventHandler): void;
image: GetSet<CanvasImageSource | undefined, this>;
crop: GetSet<IRect, this>;
cropX: GetSet<number, this>;
cropY: GetSet<number, this>;
cropWidth: GetSet<number, this>;
cropHeight: GetSet<number, this>;
cornerRadius: GetSet<number | number[], this>;
}

134
node_modules/konva/lib/shapes/Image.js generated vendored Normal file
View File

@@ -0,0 +1,134 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Image = void 0;
const Util_1 = require("../Util");
const Factory_1 = require("../Factory");
const Shape_1 = require("../Shape");
const Global_1 = require("../Global");
const Validators_1 = require("../Validators");
class Image extends Shape_1.Shape {
constructor(attrs) {
super(attrs);
this._loadListener = () => {
this._requestDraw();
};
this.on('imageChange.konva', (props) => {
this._removeImageLoad(props.oldVal);
this._setImageLoad();
});
this._setImageLoad();
}
_setImageLoad() {
const image = this.image();
if (image && image.complete) {
return;
}
if (image && image.readyState === 4) {
return;
}
if (image && image['addEventListener']) {
image['addEventListener']('load', this._loadListener);
}
}
_removeImageLoad(image) {
if (image && image['removeEventListener']) {
image['removeEventListener']('load', this._loadListener);
}
}
destroy() {
this._removeImageLoad(this.image());
super.destroy();
return this;
}
_useBufferCanvas() {
const hasCornerRadius = !!this.cornerRadius();
const hasShadow = this.hasShadow();
if (hasCornerRadius && hasShadow) {
return true;
}
return super._useBufferCanvas(true);
}
_sceneFunc(context) {
const width = this.getWidth();
const height = this.getHeight();
const cornerRadius = this.cornerRadius();
const image = this.attrs.image;
let params;
if (image) {
const cropWidth = this.attrs.cropWidth;
const cropHeight = this.attrs.cropHeight;
if (cropWidth && cropHeight) {
params = [
image,
this.cropX(),
this.cropY(),
cropWidth,
cropHeight,
0,
0,
width,
height,
];
}
else {
params = [image, 0, 0, width, height];
}
}
if (this.hasFill() || this.hasStroke() || cornerRadius) {
context.beginPath();
cornerRadius
? Util_1.Util.drawRoundedRectPath(context, width, height, cornerRadius)
: context.rect(0, 0, width, height);
context.closePath();
context.fillStrokeShape(this);
}
if (image) {
if (cornerRadius) {
context.clip();
}
context.drawImage.apply(context, params);
}
}
_hitFunc(context) {
const width = this.width(), height = this.height(), cornerRadius = this.cornerRadius();
context.beginPath();
if (!cornerRadius) {
context.rect(0, 0, width, height);
}
else {
Util_1.Util.drawRoundedRectPath(context, width, height, cornerRadius);
}
context.closePath();
context.fillStrokeShape(this);
}
getWidth() {
var _a, _b;
return (_a = this.attrs.width) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.width;
}
getHeight() {
var _a, _b;
return (_a = this.attrs.height) !== null && _a !== void 0 ? _a : (_b = this.image()) === null || _b === void 0 ? void 0 : _b.height;
}
static fromURL(url, callback, onError = null) {
const img = Util_1.Util.createImageElement();
img.onload = function () {
const image = new Image({
image: img,
});
callback(image);
};
img.onerror = onError;
img.crossOrigin = 'Anonymous';
img.src = url;
}
}
exports.Image = Image;
Image.prototype.className = 'Image';
(0, Global_1._registerNode)(Image);
Factory_1.Factory.addGetterSetter(Image, 'cornerRadius', 0, (0, Validators_1.getNumberOrArrayOfNumbersValidator)(4));
Factory_1.Factory.addGetterSetter(Image, 'image');
Factory_1.Factory.addComponentsGetterSetter(Image, 'crop', ['x', 'y', 'width', 'height']);
Factory_1.Factory.addGetterSetter(Image, 'cropX', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Image, 'cropY', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Image, 'cropWidth', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Image, 'cropHeight', 0, (0, Validators_1.getNumberValidator)());

38
node_modules/konva/lib/shapes/Label.d.ts generated vendored Normal file
View File

@@ -0,0 +1,38 @@
import { Shape, ShapeConfig } from '../Shape.js';
import { Group } from '../Group.js';
import { Context } from '../Context.js';
import { ContainerConfig } from '../Container.js';
import { GetSet } from '../types.js';
import { Text } from './Text.js';
export interface LabelConfig extends ContainerConfig {
}
declare const NONE = "none";
export declare class Label extends Group {
constructor(config?: LabelConfig);
getText(): Text;
getTag(): Tag;
_addListeners(text: any): void;
getWidth(): number;
getHeight(): number;
_sync(): void;
}
export interface TagConfig extends ShapeConfig {
pointerDirection?: string;
pointerWidth?: number;
pointerHeight?: number;
cornerRadius?: number | Array<number>;
}
export declare class Tag extends Shape<TagConfig> {
_sceneFunc(context: Context): void;
getSelfRect(): {
x: number;
y: number;
width: number;
height: number;
};
pointerDirection: GetSet<'left' | 'up' | 'right' | 'down' | typeof NONE, this>;
pointerWidth: GetSet<number, this>;
pointerHeight: GetSet<number, this>;
cornerRadius: GetSet<number, this>;
}
export {};

178
node_modules/konva/lib/shapes/Label.js generated vendored Normal file
View File

@@ -0,0 +1,178 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tag = exports.Label = void 0;
const Factory_1 = require("../Factory");
const Shape_1 = require("../Shape");
const Group_1 = require("../Group");
const Validators_1 = require("../Validators");
const Global_1 = require("../Global");
const ATTR_CHANGE_LIST = [
'fontFamily',
'fontSize',
'fontStyle',
'padding',
'lineHeight',
'text',
'width',
'height',
'pointerDirection',
'pointerWidth',
'pointerHeight',
], CHANGE_KONVA = 'Change.konva', NONE = 'none', UP = 'up', RIGHT = 'right', DOWN = 'down', LEFT = 'left', attrChangeListLen = ATTR_CHANGE_LIST.length;
class Label extends Group_1.Group {
constructor(config) {
super(config);
this.on('add.konva', function (evt) {
this._addListeners(evt.child);
this._sync();
});
}
getText() {
return this.find('Text')[0];
}
getTag() {
return this.find('Tag')[0];
}
_addListeners(text) {
let that = this, n;
const func = function () {
that._sync();
};
for (n = 0; n < attrChangeListLen; n++) {
text.on(ATTR_CHANGE_LIST[n] + CHANGE_KONVA, func);
}
}
getWidth() {
return this.getText().width();
}
getHeight() {
return this.getText().height();
}
_sync() {
let text = this.getText(), tag = this.getTag(), width, height, pointerDirection, pointerWidth, x, y, pointerHeight;
if (text && tag) {
width = text.width();
height = text.height();
pointerDirection = tag.pointerDirection();
pointerWidth = tag.pointerWidth();
pointerHeight = tag.pointerHeight();
x = 0;
y = 0;
switch (pointerDirection) {
case UP:
x = width / 2;
y = -1 * pointerHeight;
break;
case RIGHT:
x = width + pointerWidth;
y = height / 2;
break;
case DOWN:
x = width / 2;
y = height + pointerHeight;
break;
case LEFT:
x = -1 * pointerWidth;
y = height / 2;
break;
}
tag.setAttrs({
x: -1 * x,
y: -1 * y,
width: width,
height: height,
});
text.setAttrs({
x: -1 * x,
y: -1 * y,
});
}
}
}
exports.Label = Label;
Label.prototype.className = 'Label';
(0, Global_1._registerNode)(Label);
class Tag extends Shape_1.Shape {
_sceneFunc(context) {
const width = this.width(), height = this.height(), pointerDirection = this.pointerDirection(), pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), cornerRadius = this.cornerRadius();
let topLeft = 0;
let topRight = 0;
let bottomLeft = 0;
let bottomRight = 0;
if (typeof cornerRadius === 'number') {
topLeft =
topRight =
bottomLeft =
bottomRight =
Math.min(cornerRadius, width / 2, height / 2);
}
else {
topLeft = Math.min(cornerRadius[0] || 0, width / 2, height / 2);
topRight = Math.min(cornerRadius[1] || 0, width / 2, height / 2);
bottomRight = Math.min(cornerRadius[2] || 0, width / 2, height / 2);
bottomLeft = Math.min(cornerRadius[3] || 0, width / 2, height / 2);
}
context.beginPath();
context.moveTo(topLeft, 0);
if (pointerDirection === UP) {
context.lineTo((width - pointerWidth) / 2, 0);
context.lineTo(width / 2, -1 * pointerHeight);
context.lineTo((width + pointerWidth) / 2, 0);
}
context.lineTo(width - topRight, 0);
context.arc(width - topRight, topRight, topRight, (Math.PI * 3) / 2, 0, false);
if (pointerDirection === RIGHT) {
context.lineTo(width, (height - pointerHeight) / 2);
context.lineTo(width + pointerWidth, height / 2);
context.lineTo(width, (height + pointerHeight) / 2);
}
context.lineTo(width, height - bottomRight);
context.arc(width - bottomRight, height - bottomRight, bottomRight, 0, Math.PI / 2, false);
if (pointerDirection === DOWN) {
context.lineTo((width + pointerWidth) / 2, height);
context.lineTo(width / 2, height + pointerHeight);
context.lineTo((width - pointerWidth) / 2, height);
}
context.lineTo(bottomLeft, height);
context.arc(bottomLeft, height - bottomLeft, bottomLeft, Math.PI / 2, Math.PI, false);
if (pointerDirection === LEFT) {
context.lineTo(0, (height + pointerHeight) / 2);
context.lineTo(-1 * pointerWidth, height / 2);
context.lineTo(0, (height - pointerHeight) / 2);
}
context.lineTo(0, topLeft);
context.arc(topLeft, topLeft, topLeft, Math.PI, (Math.PI * 3) / 2, false);
context.closePath();
context.fillStrokeShape(this);
}
getSelfRect() {
let x = 0, y = 0, pointerWidth = this.pointerWidth(), pointerHeight = this.pointerHeight(), direction = this.pointerDirection(), width = this.width(), height = this.height();
if (direction === UP) {
y -= pointerHeight;
height += pointerHeight;
}
else if (direction === DOWN) {
height += pointerHeight;
}
else if (direction === LEFT) {
x -= pointerWidth * 1.5;
width += pointerWidth;
}
else if (direction === RIGHT) {
width += pointerWidth * 1.5;
}
return {
x: x,
y: y,
width: width,
height: height,
};
}
}
exports.Tag = Tag;
Tag.prototype.className = 'Tag';
(0, Global_1._registerNode)(Tag);
Factory_1.Factory.addGetterSetter(Tag, 'pointerDirection', NONE);
Factory_1.Factory.addGetterSetter(Tag, 'pointerWidth', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Tag, 'pointerHeight', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Tag, 'cornerRadius', 0, (0, Validators_1.getNumberOrArrayOfNumbersValidator)(4));

28
node_modules/konva/lib/shapes/Line.d.ts generated vendored Normal file
View File

@@ -0,0 +1,28 @@
import { Shape, ShapeConfig } from '../Shape.js';
import { Context } from '../Context.js';
import { GetSet } from '../types.js';
export interface LineConfig extends ShapeConfig {
points?: number[] | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
tension?: number;
closed?: boolean;
bezier?: boolean;
}
export declare class Line<Config extends LineConfig = LineConfig> extends Shape<Config> {
constructor(config?: Config);
_sceneFunc(context: Context): void;
getTensionPoints(): any;
_getTensionPoints(): number[];
_getTensionPointsClosed(): number[];
getWidth(): number;
getHeight(): number;
getSelfRect(): {
x: number;
y: number;
width: number;
height: number;
};
closed: GetSet<boolean, this>;
bezier: GetSet<boolean, this>;
tension: GetSet<number, this>;
points: GetSet<number[], this>;
}

160
node_modules/konva/lib/shapes/Line.js generated vendored Normal file
View File

@@ -0,0 +1,160 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Line = void 0;
const Factory_1 = require("../Factory");
const Global_1 = require("../Global");
const Shape_1 = require("../Shape");
const Validators_1 = require("../Validators");
function getControlPoints(x0, y0, x1, y1, x2, y2, t) {
const d01 = Math.sqrt(Math.pow(x1 - x0, 2) + Math.pow(y1 - y0, 2)), d12 = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)), fa = (t * d01) / (d01 + d12), fb = (t * d12) / (d01 + d12), p1x = x1 - fa * (x2 - x0), p1y = y1 - fa * (y2 - y0), p2x = x1 + fb * (x2 - x0), p2y = y1 + fb * (y2 - y0);
return [p1x, p1y, p2x, p2y];
}
function expandPoints(p, tension) {
const len = p.length, allPoints = [];
for (let n = 2; n < len - 2; n += 2) {
const cp = getControlPoints(p[n - 2], p[n - 1], p[n], p[n + 1], p[n + 2], p[n + 3], tension);
if (isNaN(cp[0])) {
continue;
}
allPoints.push(cp[0]);
allPoints.push(cp[1]);
allPoints.push(p[n]);
allPoints.push(p[n + 1]);
allPoints.push(cp[2]);
allPoints.push(cp[3]);
}
return allPoints;
}
class Line extends Shape_1.Shape {
constructor(config) {
super(config);
this.on('pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva', function () {
this._clearCache('tensionPoints');
});
}
_sceneFunc(context) {
const points = this.points(), length = points.length, tension = this.tension(), closed = this.closed(), bezier = this.bezier();
if (!length) {
return;
}
let n = 0;
context.beginPath();
context.moveTo(points[0], points[1]);
if (tension !== 0 && length > 4) {
const tp = this.getTensionPoints();
const len = tp.length;
n = closed ? 0 : 4;
if (!closed) {
context.quadraticCurveTo(tp[0], tp[1], tp[2], tp[3]);
}
while (n < len - 2) {
context.bezierCurveTo(tp[n++], tp[n++], tp[n++], tp[n++], tp[n++], tp[n++]);
}
if (!closed) {
context.quadraticCurveTo(tp[len - 2], tp[len - 1], points[length - 2], points[length - 1]);
}
}
else if (bezier) {
n = 2;
while (n < length) {
context.bezierCurveTo(points[n++], points[n++], points[n++], points[n++], points[n++], points[n++]);
}
}
else {
for (n = 2; n < length; n += 2) {
context.lineTo(points[n], points[n + 1]);
}
}
if (closed) {
context.closePath();
context.fillStrokeShape(this);
}
else {
context.strokeShape(this);
}
}
getTensionPoints() {
return this._getCache('tensionPoints', this._getTensionPoints);
}
_getTensionPoints() {
if (this.closed()) {
return this._getTensionPointsClosed();
}
else {
return expandPoints(this.points(), this.tension());
}
}
_getTensionPointsClosed() {
const p = this.points(), len = p.length, tension = this.tension(), firstControlPoints = getControlPoints(p[len - 2], p[len - 1], p[0], p[1], p[2], p[3], tension), lastControlPoints = getControlPoints(p[len - 4], p[len - 3], p[len - 2], p[len - 1], p[0], p[1], tension), middle = expandPoints(p, tension), tp = [firstControlPoints[2], firstControlPoints[3]]
.concat(middle)
.concat([
lastControlPoints[0],
lastControlPoints[1],
p[len - 2],
p[len - 1],
lastControlPoints[2],
lastControlPoints[3],
firstControlPoints[0],
firstControlPoints[1],
p[0],
p[1],
]);
return tp;
}
getWidth() {
return this.getSelfRect().width;
}
getHeight() {
return this.getSelfRect().height;
}
getSelfRect() {
let points = this.points();
if (points.length < 4) {
return {
x: points[0] || 0,
y: points[1] || 0,
width: 0,
height: 0,
};
}
if (this.tension() !== 0) {
points = [
points[0],
points[1],
...this._getTensionPoints(),
points[points.length - 2],
points[points.length - 1],
];
}
else {
points = this.points();
}
let minX = points[0];
let maxX = points[0];
let minY = points[1];
let maxY = points[1];
let x, y;
for (let i = 0; i < points.length / 2; i++) {
x = points[i * 2];
y = points[i * 2 + 1];
minX = Math.min(minX, x);
maxX = Math.max(maxX, x);
minY = Math.min(minY, y);
maxY = Math.max(maxY, y);
}
return {
x: minX,
y: minY,
width: maxX - minX,
height: maxY - minY,
};
}
}
exports.Line = Line;
Line.prototype.className = 'Line';
Line.prototype._attrsAffectingSize = ['points', 'bezier', 'tension'];
(0, Global_1._registerNode)(Line);
Factory_1.Factory.addGetterSetter(Line, 'closed', false);
Factory_1.Factory.addGetterSetter(Line, 'bezier', false);
Factory_1.Factory.addGetterSetter(Line, 'tension', 0, (0, Validators_1.getNumberValidator)());
Factory_1.Factory.addGetterSetter(Line, 'points', [], (0, Validators_1.getNumberArrayValidator)());

49
node_modules/konva/lib/shapes/Path.d.ts generated vendored Normal file
View File

@@ -0,0 +1,49 @@
import { Shape, ShapeConfig } from '../Shape.js';
import { GetSet, PathSegment } from '../types.js';
export interface PathConfig extends ShapeConfig {
data?: string;
}
export declare class Path extends Shape<PathConfig> {
dataArray: PathSegment[];
pathLength: number;
constructor(config?: PathConfig);
_readDataAttribute(): void;
_sceneFunc(context: any): void;
getSelfRect(): {
x: number;
y: number;
width: number;
height: number;
};
getLength(): number;
getPointAtLength(length: number): {
x: number;
y: number;
} | null;
data: GetSet<string, this>;
static getLineLength(x1: any, y1: any, x2: any, y2: any): number;
static getPathLength(dataArray: PathSegment[]): number;
static getPointAtLengthOfDataArray(length: number, dataArray: PathSegment[]): {
x: number;
y: number;
} | null;
static getPointOnLine(dist: number, P1x: number, P1y: number, P2x: number, P2y: number, fromX?: number, fromY?: number): {
x: number;
y: number;
};
static getPointOnCubicBezier(pct: number, P1x: number, P1y: number, P2x: number, P2y: number, P3x: number, P3y: number, P4x: number, P4y: number): {
x: number;
y: number;
};
static getPointOnQuadraticBezier(pct: any, P1x: any, P1y: any, P2x: any, P2y: any, P3x: any, P3y: any): {
x: number;
y: number;
};
static getPointOnEllipticalArc(cx: number, cy: number, rx: number, ry: number, theta: number, psi: number): {
x: number;
y: number;
};
static parsePathData(data: any): PathSegment[];
static calcLength(x: any, y: any, cmd: any, points: any): any;
static convertEndpointToCenterParameterization(x1: number, y1: number, x2: number, y2: number, fa: number, fs: number, rx: number, ry: number, psiDeg: number): number[];
}

Some files were not shown because too many files have changed in this diff Show More