refactor: remove rename-imports scripts

Update approach of dealing with file extensions differences between typescript & node.

Leverages `rewriteRelativeImportExtensions` that was added in typescript 5.7 [1], and that is recommended path by node to run typescript in the future [2]

[1] https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-7.html#path-rewriting-for-relative-paths

[2] https://nodejs.org/api/typescript.html#type-stripping
This commit is contained in:
Nathan Muir
2025-08-20 09:39:20 +12:00
parent 0aff4cc1f5
commit 758adcd502
131 changed files with 548 additions and 624 deletions

View File

@@ -34,7 +34,7 @@
"scripts": {
"start": "npm run test:watch",
"compile": "npm run clean && npm run tsc && cp ./src/index-types.d.ts ./lib/index-types.d.ts && npm run rollup",
"build": "npm run compile && cp ./src/index-types.d.ts ./lib && gulp build && node ./rename-imports.mjs",
"build": "npm run compile && cp ./src/index-types.d.ts ./lib && gulp build",
"fmt": "prettier --write .",
"fmt:check": "prettier --check .",
"test:import": "npm run build && node ./test/import-test.cjs && node ./test/import-test.mjs",
@@ -42,8 +42,8 @@
"test:build": "PARCEL_WORKER_BACKEND=process parcel build ./test/unit-tests.html --dist-dir ./test-build --target none --public-url ./ --no-source-maps",
"test:browser": "npm run test:build && mocha-headless-chrome -f ./test-build/unit-tests.html -a disable-web-security -a no-sandbox -a disable-setuid-sandbox",
"test:watch": "rm -rf ./.parcel-cache && PARCEL_WORKERS=0 parcel serve ./test/unit-tests.html ./test/manual-tests.html ./test/sandbox.html ./test/text-paths.html ./test/bunnies.html",
"test:node:canvas": "rm -rf ./.test-temp && mkdir ./.test-temp && (tsc -p ./test/tsconfig.json --outDir ./.test-temp || true) && node ./rename-imports-test.mjs && mocha './.test-temp/test/unit/**/*.js' -r ./test/node-canvas-global-setup.mjs --exit && rm -rf ./.test-temp",
"test:node:skia": "rm -rf ./.test-temp && mkdir ./.test-temp && (tsc -p ./test/tsconfig.json --outDir ./.test-temp || true) && node ./rename-imports-test.mjs && mocha './.test-temp/test/unit/**/*.js' -r ./test/node-skia-global-setup.mjs --exit && rm -rf ./.test-temp",
"test:node:canvas": "mocha -r tsx -r ./test/node-canvas-global-setup.mjs --extension ts --recursive './test/unit/' --exit",
"test:node:skia": "mocha -r tsx -r ./test/node-skia-global-setup.mjs --extension ts --recursive './test/unit/' --exit",
"test:node": "npm run test:node:canvas && npm run test:node:skia",
"tsc": "tsc --removeComments",
"rollup": "rollup -c",
@@ -110,6 +110,7 @@
"skia-canvas": "^2.0.2",
"ts-mocha": "^11.1.0",
"ts-node": "^10.9.2",
"tsx": "^4.20.4",
"typescript": "^5.9.2"
},
"keywords": [

View File

@@ -1,36 +0,0 @@
import FileHound from 'filehound';
import fs from 'fs';
const files = FileHound.create().paths('./.test-temp').ext(['js', 'ts']).find();
files.then((filePaths) => {
filePaths.forEach((filepath) => {
fs.readFile(filepath, 'utf8', (err, text) => {
if (!text.match(/import .* from/g)) {
return;
}
text = text.replace(/(import .* from\s+['"])(.*)(?=['"])/g, '$1$2.js');
if (text.match(/export .* from/g)) {
text = text.replace(/(export .* from\s+['"])(.*)(?=['"])/g, '$1$2.js');
}
if (err) throw err;
// stupid replacement back
text = text.replace("from 'canvas.js';", "from 'canvas';");
text = text.replace("from 'chai.js';", "from 'chai';");
text = text.replace("from 'skia-canvas.js';", "from 'skia-canvas';");
// Handle import("./x/y/z") syntax.
text = text.replace(/(import\s*\(\s*['"])(.*)(?=['"])/g, '$1$2.js');
fs.writeFile(filepath, text, function (err) {
if (err) {
throw err;
}
});
});
});
});
// Removed CommonJS export rewriting to keep ESM output intact

View File

@@ -1,37 +0,0 @@
import FileHound from 'filehound';
import fs from 'fs';
const files = FileHound.create().paths('./lib').ext(['js', 'ts']).find();
files.then((filePaths) => {
filePaths.forEach((filepath) => {
fs.readFile(filepath, 'utf8', (err, text) => {
if (!text.match(/import .* from/g)) {
return;
}
text = text.replace(/(import .* from\s+['"])(.*)(?=['"])/g, '$1$2.js');
if (text.match(/export .* from/g)) {
text = text.replace(/(export .* from\s+['"])(.*)(?=['"])/g, '$1$2.js');
}
if (err) throw err;
// stupid replacement back
text = text.replace(
"import * as Canvas from 'canvas.js';",
"import * as Canvas from 'canvas';"
);
// Handle import("./x/y/z") syntax.
text = text.replace(/(import\s*\(\s*['"])(.*)(?=['"])/g, '$1$2.js');
fs.writeFile(filepath, text, function (err) {
if (err) {
throw err;
}
});
});
});
});
// Removed CommonJS export rewriting to keep ESM output intact

View File

@@ -1,7 +1,7 @@
import { glob } from './Global';
import { Layer } from './Layer';
import { IFrame, AnimationFn } from './types';
import { Util } from './Util';
import { glob } from './Global.ts';
import { Layer } from './Layer.ts';
import { IFrame, AnimationFn } from './types.ts';
import { Util } from './Util.ts';
const now = (function (): () => number {
if (glob.performance && glob.performance.now) {

View File

@@ -1,6 +1,6 @@
import { Util } from './Util';
import { SceneContext, HitContext, Context } from './Context';
import { Konva } from './Global';
import { Util } from './Util.ts';
import { SceneContext, HitContext, Context } from './Context.ts';
import { Konva } from './Global.ts';
// calculate pixel ratio
let _pixelRatio;

View File

@@ -1,10 +1,10 @@
import { HitCanvas, SceneCanvas } from './Canvas';
import { SceneContext } from './Context';
import { Factory } from './Factory';
import { Node, NodeConfig } from './Node';
import { Shape } from './Shape';
import { GetSet, IRect } from './types';
import { getNumberValidator } from './Validators';
import { HitCanvas, SceneCanvas } from './Canvas.ts';
import { SceneContext } from './Context.ts';
import { Factory } from './Factory.ts';
import { Node, NodeConfig } from './Node.ts';
import { Shape } from './Shape.ts';
import { GetSet, IRect } from './types.ts';
import { getNumberValidator } from './Validators.ts';
export type ClipFuncOutput =
| void

View File

@@ -1,9 +1,9 @@
import { Util } from './Util';
import { Konva } from './Global';
import { Canvas } from './Canvas';
import { Shape } from './Shape';
import { IRect } from './types';
import type { Node } from './Node';
import { Util } from './Util.ts';
import { Konva } from './Global.ts';
import { Canvas } from './Canvas.ts';
import { Shape } from './Shape.ts';
import { IRect } from './types.ts';
import type { Node } from './Node.ts';
function simplifyArray(arr: Array<any>) {
const retArr: Array<any> = [],

View File

@@ -1,5 +1,5 @@
// enter file of limited Konva version with only core functions
export { Konva } from './_CoreInternals';
import { Konva } from './_CoreInternals';
export { Konva } from './_CoreInternals.ts';
import { Konva } from './_CoreInternals.ts';
export default Konva;

View File

@@ -1,8 +1,8 @@
import { Container } from './Container';
import { Konva } from './Global';
import { Node } from './Node';
import { Vector2d } from './types';
import { Util } from './Util';
import { Container } from './Container.ts';
import { Konva } from './Global.ts';
import { Node } from './Node.ts';
import { Vector2d } from './types.ts';
import { Util } from './Util.ts';
export const DD = {
get isDragging() {

View File

@@ -1,7 +1,7 @@
import { Node } from './Node';
import { GetSet } from './types';
import { Util } from './Util';
import { getComponentValidator } from './Validators';
import { Node } from './Node.ts';
import { GetSet } from './types.ts';
import { Util } from './Util.ts';
import { getComponentValidator } from './Validators.ts';
const GET = 'get';
const SET = 'set';

View File

@@ -1,6 +1,6 @@
import { Util } from './Util';
import { Layer } from './Layer';
import { _registerNode } from './Global';
import { Util } from './Util.ts';
import { Layer } from './Layer.ts';
import { _registerNode } from './Global.ts';
/**
* FastLayer constructor. **DEPRECATED!** Please use `Konva.Layer({ listening: false})` instead. Layers are tied to their own canvas element and are used

View File

@@ -1,8 +1,8 @@
import { Util } from './Util';
import { Container, ContainerConfig } from './Container';
import { _registerNode } from './Global';
import { Node } from './Node';
import { Shape } from './Shape';
import { Util } from './Util.ts';
import { Container, ContainerConfig } from './Container.ts';
import { _registerNode } from './Global.ts';
import { Node } from './Node.ts';
import { Shape } from './Shape.ts';
export interface GroupConfig extends ContainerConfig {}

View File

@@ -1,15 +1,15 @@
import { Util } from './Util';
import { Container, ContainerConfig } from './Container';
import { Node } from './Node';
import { Factory } from './Factory';
import { SceneCanvas, HitCanvas } from './Canvas';
import { Stage } from './Stage';
import { getBooleanValidator } from './Validators';
import { Util } from './Util.ts';
import { Container, ContainerConfig } from './Container.ts';
import { Node } from './Node.ts';
import { Factory } from './Factory.ts';
import { SceneCanvas, HitCanvas } from './Canvas.ts';
import { Stage } from './Stage.ts';
import { getBooleanValidator } from './Validators.ts';
import { GetSet, Vector2d } from './types';
import { Group } from './Group';
import { Shape, shapes } from './Shape';
import { _registerNode } from './Global';
import { GetSet, Vector2d } from './types.ts';
import { Group } from './Group.ts';
import { Shape, shapes } from './Shape.ts';
import { _registerNode } from './Global.ts';
export interface LayerConfig extends ContainerConfig {
clearBeforeDraw?: boolean;

View File

@@ -1,19 +1,19 @@
import { Canvas, HitCanvas, SceneCanvas } from './Canvas';
import { Container } from './Container';
import { Context } from './Context';
import { DD } from './DragAndDrop';
import { Factory } from './Factory';
import { Konva } from './Global';
import { Layer } from './Layer';
import { Shape } from './Shape';
import { Stage } from './Stage';
import { GetSet, IRect, Vector2d } from './types';
import { Transform, Util } from './Util';
import { Canvas, HitCanvas, SceneCanvas } from './Canvas.ts';
import { Container } from './Container.ts';
import { Context } from './Context.ts';
import { DD } from './DragAndDrop.ts';
import { Factory } from './Factory.ts';
import { Konva } from './Global.ts';
import { Layer } from './Layer.ts';
import { Shape } from './Shape.ts';
import { Stage } from './Stage.ts';
import { GetSet, IRect, Vector2d } from './types.ts';
import { Transform, Util } from './Util.ts';
import {
getBooleanValidator,
getNumberValidator,
getStringValidator,
} from './Validators';
} from './Validators.ts';
export type Filter = (this: Node, imageData: ImageData) => void;

View File

@@ -1,8 +1,8 @@
import { KonvaEventObject } from './Node';
import { Konva } from './Global';
import { KonvaEventObject } from './Node.ts';
import { Konva } from './Global.ts';
import { Shape } from './Shape';
import { Stage } from './Stage';
import { Shape } from './Shape.ts';
import { Stage } from './Stage.ts';
const Captures = new Map<number, Shape | Stage>();

View File

@@ -1,21 +1,21 @@
import { Konva } from './Global';
import { Transform, Util } from './Util';
import { Factory } from './Factory';
import { Node, NodeConfig } from './Node';
import { Konva } from './Global.ts';
import { Transform, Util } from './Util.ts';
import { Factory } from './Factory.ts';
import { Node, NodeConfig } from './Node.ts';
import {
getNumberValidator,
getNumberOrAutoValidator,
getStringValidator,
getBooleanValidator,
getStringOrGradientValidator,
} from './Validators';
} from './Validators.ts';
import { Context, SceneContext } from './Context';
import { _registerNode } from './Global';
import * as PointerEvents from './PointerEvents';
import { Context, SceneContext } from './Context.ts';
import { _registerNode } from './Global.ts';
import * as PointerEvents from './PointerEvents.ts';
import { GetSet, Vector2d } from './types';
import { HitCanvas, SceneCanvas } from './Canvas';
import { GetSet, Vector2d } from './types.ts';
import { HitCanvas, SceneCanvas } from './Canvas.ts';
// hack from here https://stackoverflow.com/questions/52667959/what-is-the-purpose-of-bivariancehack-in-typescript-types/52668133#52668133
export type ShapeConfigHandler<TTarget> = {

View File

@@ -1,14 +1,14 @@
import { Util } from './Util';
import { Factory } from './Factory';
import { Container, ContainerConfig } from './Container';
import { Konva } from './Global';
import { SceneCanvas, HitCanvas } from './Canvas';
import { GetSet, Vector2d } from './types';
import { Shape } from './Shape';
import { Layer } from './Layer';
import { DD } from './DragAndDrop';
import { _registerNode } from './Global';
import * as PointerEvents from './PointerEvents';
import { Util } from './Util.ts';
import { Factory } from './Factory.ts';
import { Container, ContainerConfig } from './Container.ts';
import { Konva } from './Global.ts';
import { SceneCanvas, HitCanvas } from './Canvas.ts';
import { GetSet, Vector2d } from './types.ts';
import { Shape } from './Shape.ts';
import { Layer } from './Layer.ts';
import { DD } from './DragAndDrop.ts';
import { _registerNode } from './Global.ts';
import * as PointerEvents from './PointerEvents.ts';
export interface StageConfig extends ContainerConfig {
container?: HTMLDivElement | string;

View File

@@ -1,8 +1,8 @@
import { Util } from './Util';
import { Animation } from './Animation';
import { Node, NodeConfig } from './Node';
import { Konva } from './Global';
import { Line } from './shapes/Line';
import { Util } from './Util.ts';
import { Animation } from './Animation.ts';
import { Node, NodeConfig } from './Node.ts';
import { Konva } from './Global.ts';
import { Line } from './shapes/Line.ts';
const blacklist = {
node: 1,

View File

@@ -1,6 +1,6 @@
import { Konva } from './Global';
import { Context } from './Context';
import { IRect, RGB, Vector2d } from './types';
import { Konva } from './Global.ts';
import { Context } from './Context.ts';
import { IRect, RGB, Vector2d } from './types.ts';
const NODE_ERROR = `Konva.js unsupported environment.

View File

@@ -1,5 +1,5 @@
import { Konva } from './Global';
import { Util } from './Util';
import { Konva } from './Global.ts';
import { Util } from './Util.ts';
function _formatValue(val: any) {
if (Util._isString(val)) {

View File

@@ -1,26 +1,26 @@
// what is core parts of Konva?
import { Konva as Global } from './Global';
import { Konva as Global } from './Global.ts';
import { Util, Transform } from './Util';
import { Node } from './Node';
import { Container } from './Container';
import { Util, Transform } from './Util.ts';
import { Node } from './Node.ts';
import { Container } from './Container.ts';
import { Stage, stages } from './Stage';
import { Stage, stages } from './Stage.ts';
import { Layer } from './Layer';
import { FastLayer } from './FastLayer';
import { Layer } from './Layer.ts';
import { FastLayer } from './FastLayer.ts';
import { Group } from './Group';
import { Group } from './Group.ts';
import { DD } from './DragAndDrop';
import { DD } from './DragAndDrop.ts';
import { Shape, shapes } from './Shape';
import { Shape, shapes } from './Shape.ts';
import { Animation } from './Animation';
import { Tween, Easings } from './Tween';
import { Animation } from './Animation.ts';
import { Tween, Easings } from './Tween.ts';
import { Context } from './Context';
import { Canvas } from './Canvas';
import { Context } from './Context.ts';
import { Canvas } from './Canvas.ts';
export const Konva = Util._assign(Global, {
Util,

View File

@@ -1,46 +1,46 @@
// we need to import core of the Konva and then extend it with all additional objects
import { Konva as Core } from './_CoreInternals';
import { Konva as Core } from './_CoreInternals.ts';
// shapes
import { Arc } from './shapes/Arc';
import { Arrow } from './shapes/Arrow';
import { Circle } from './shapes/Circle';
import { Ellipse } from './shapes/Ellipse';
import { Image } from './shapes/Image';
import { Label, Tag } from './shapes/Label';
import { Line } from './shapes/Line';
import { Path } from './shapes/Path';
import { Rect } from './shapes/Rect';
import { RegularPolygon } from './shapes/RegularPolygon';
import { Ring } from './shapes/Ring';
import { Sprite } from './shapes/Sprite';
import { Star } from './shapes/Star';
import { Text } from './shapes/Text';
import { TextPath } from './shapes/TextPath';
import { Transformer } from './shapes/Transformer';
import { Wedge } from './shapes/Wedge';
import { Arc } from './shapes/Arc.ts';
import { Arrow } from './shapes/Arrow.ts';
import { Circle } from './shapes/Circle.ts';
import { Ellipse } from './shapes/Ellipse.ts';
import { Image } from './shapes/Image.ts';
import { Label, Tag } from './shapes/Label.ts';
import { Line } from './shapes/Line.ts';
import { Path } from './shapes/Path.ts';
import { Rect } from './shapes/Rect.ts';
import { RegularPolygon } from './shapes/RegularPolygon.ts';
import { Ring } from './shapes/Ring.ts';
import { Sprite } from './shapes/Sprite.ts';
import { Star } from './shapes/Star.ts';
import { Text } from './shapes/Text.ts';
import { TextPath } from './shapes/TextPath.ts';
import { Transformer } from './shapes/Transformer.ts';
import { Wedge } from './shapes/Wedge.ts';
// filters
import { Blur } from './filters/Blur';
import { Brighten } from './filters/Brighten';
import { Contrast } from './filters/Contrast';
import { Emboss } from './filters/Emboss';
import { Enhance } from './filters/Enhance';
import { Grayscale } from './filters/Grayscale';
import { HSL } from './filters/HSL';
import { HSV } from './filters/HSV';
import { Invert } from './filters/Invert';
import { Kaleidoscope } from './filters/Kaleidoscope';
import { Mask } from './filters/Mask';
import { Noise } from './filters/Noise';
import { Pixelate } from './filters/Pixelate';
import { Posterize } from './filters/Posterize';
import { RGB } from './filters/RGB';
import { RGBA } from './filters/RGBA';
import { Sepia } from './filters/Sepia';
import { Solarize } from './filters/Solarize';
import { Threshold } from './filters/Threshold';
import { Blur } from './filters/Blur.ts';
import { Brighten } from './filters/Brighten.ts';
import { Contrast } from './filters/Contrast.ts';
import { Emboss } from './filters/Emboss.ts';
import { Enhance } from './filters/Enhance.ts';
import { Grayscale } from './filters/Grayscale.ts';
import { HSL } from './filters/HSL.ts';
import { HSV } from './filters/HSV.ts';
import { Invert } from './filters/Invert.ts';
import { Kaleidoscope } from './filters/Kaleidoscope.ts';
import { Mask } from './filters/Mask.ts';
import { Noise } from './filters/Noise.ts';
import { Pixelate } from './filters/Pixelate.ts';
import { Posterize } from './filters/Posterize.ts';
import { RGB } from './filters/RGB.ts';
import { RGBA } from './filters/RGBA.ts';
import { Sepia } from './filters/Sepia.ts';
import { Solarize } from './filters/Solarize.ts';
import { Threshold } from './filters/Threshold.ts';
export const Konva = Core.Util._assign(Core, {
Arc,

View File

@@ -1,8 +1,9 @@
import { Konva } from './_CoreInternals';
import { Konva } from './_CoreInternals.ts';
import * as Canvas from 'canvas';
const canvas = Canvas['default'] || Canvas;
// @ts-ignore
global.DOMMatrix = canvas.DOMMatrix;
Konva.Util['createCanvasElement'] = () => {

View File

@@ -1,6 +1,6 @@
import { Factory } from '../Factory';
import { Node, Filter } from '../Node';
import { getNumberValidator } from '../Validators';
import { Factory } from '../Factory.ts';
import { Node, Filter } from '../Node.ts';
import { getNumberValidator } from '../Validators.ts';
/*
the Gauss filter
master repo: https://github.com/pavelpower/kineticjsGaussFilter

View File

@@ -1,6 +1,6 @@
import { Factory } from '../Factory';
import { Node, Filter } from '../Node';
import { getNumberValidator } from '../Validators';
import { Factory } from '../Factory.ts';
import { Node, Filter } from '../Node.ts';
import { getNumberValidator } from '../Validators.ts';
/**
* Brighten Filter.

View File

@@ -1,6 +1,6 @@
import { Factory } from '../Factory';
import { Node, Filter } from '../Node';
import { getNumberValidator } from '../Validators';
import { Factory } from '../Factory.ts';
import { Node, Filter } from '../Node.ts';
import { getNumberValidator } from '../Validators.ts';
/**
* Contrast Filter.
* @function

View File

@@ -1,7 +1,7 @@
import { Factory } from '../Factory';
import { Node, Filter } from '../Node';
import { Util } from '../Util';
import { getNumberValidator } from '../Validators';
import { Factory } from '../Factory.ts';
import { Node, Filter } from '../Node.ts';
import { Util } from '../Util.ts';
import { getNumberValidator } from '../Validators.ts';
/**
* Emboss Filter.
* Pixastic Lib - Emboss filter - v0.1.0

View File

@@ -1,6 +1,6 @@
import { Factory } from '../Factory';
import { Node, Filter } from '../Node';
import { getNumberValidator } from '../Validators';
import { Factory } from '../Factory.ts';
import { Node, Filter } from '../Node.ts';
import { getNumberValidator } from '../Validators.ts';
function remap(
fromValue: number,

View File

@@ -1,4 +1,4 @@
import { Filter } from '../Node';
import { Filter } from '../Node.ts';
/**
* Grayscale Filter

View File

@@ -1,6 +1,6 @@
import { Factory } from '../Factory';
import { Node, Filter } from '../Node';
import { getNumberValidator } from '../Validators';
import { Factory } from '../Factory.ts';
import { Node, Filter } from '../Node.ts';
import { getNumberValidator } from '../Validators.ts';
Factory.addGetterSetter(
Node,

View File

@@ -1,6 +1,6 @@
import { Factory } from '../Factory';
import { Filter, Node } from '../Node';
import { getNumberValidator } from '../Validators';
import { Factory } from '../Factory.ts';
import { Filter, Node } from '../Node.ts';
import { getNumberValidator } from '../Validators.ts';
/**
* HSV Filter. Adjusts the hue, saturation and value

View File

@@ -1,4 +1,4 @@
import { Filter } from '../Node';
import { Filter } from '../Node.ts';
/**
* Invert Filter
* @function

View File

@@ -1,7 +1,7 @@
import { Factory } from '../Factory';
import { Filter, Node } from '../Node';
import { Util } from '../Util';
import { getNumberValidator } from '../Validators';
import { Factory } from '../Factory.ts';
import { Filter, Node } from '../Node.ts';
import { Util } from '../Util.ts';
import { getNumberValidator } from '../Validators.ts';
/*
* ToPolar Filter. Converts image data to polar coordinates. Performs

View File

@@ -1,6 +1,6 @@
import { Factory } from '../Factory';
import { Filter, Node } from '../Node';
import { getNumberValidator } from '../Validators';
import { Factory } from '../Factory.ts';
import { Filter, Node } from '../Node.ts';
import { getNumberValidator } from '../Validators.ts';
function pixelAt(idata, x: number, y: number) {
let idx = (y * idata.width + x) * 4;

View File

@@ -1,6 +1,6 @@
import { Factory } from '../Factory';
import { Filter, Node } from '../Node';
import { getNumberValidator } from '../Validators';
import { Factory } from '../Factory.ts';
import { Filter, Node } from '../Node.ts';
import { getNumberValidator } from '../Validators.ts';
/**
* Noise Filter. Randomly adds or substracts to the color channels

View File

@@ -1,7 +1,7 @@
import { Factory } from '../Factory';
import { Util } from '../Util';
import { Node, Filter } from '../Node';
import { getNumberValidator } from '../Validators';
import { Factory } from '../Factory.ts';
import { Util } from '../Util.ts';
import { Node, Filter } from '../Node.ts';
import { getNumberValidator } from '../Validators.ts';
/**
* Pixelate Filter. Averages groups of pixels and redraws

View File

@@ -1,6 +1,6 @@
import { Factory } from '../Factory';
import { Filter, Node } from '../Node';
import { getNumberValidator } from '../Validators';
import { Factory } from '../Factory.ts';
import { Filter, Node } from '../Node.ts';
import { getNumberValidator } from '../Validators.ts';
/**
* Posterize Filter. Adjusts the channels so that there are no more

View File

@@ -1,6 +1,6 @@
import { Factory } from '../Factory';
import { Node, Filter } from '../Node';
import { RGBComponent } from '../Validators';
import { Factory } from '../Factory.ts';
import { Node, Filter } from '../Node.ts';
import { RGBComponent } from '../Validators.ts';
/**
* RGB Filter

View File

@@ -1,6 +1,6 @@
import { Factory } from '../Factory';
import { Node, Filter } from '../Node';
import { RGBComponent } from '../Validators';
import { Factory } from '../Factory.ts';
import { Node, Filter } from '../Node.ts';
import { RGBComponent } from '../Validators.ts';
/**
* RGBA Filter

View File

@@ -1,4 +1,4 @@
import { Filter } from '../Node';
import { Filter } from '../Node.ts';
// based on https://stackoverflow.com/questions/1061093/how-is-a-sepia-tone-created

View File

@@ -1,4 +1,4 @@
import { Filter } from '../Node';
import { Filter } from '../Node.ts';
/**
* Solarize Filter
* Pixastic Lib - Solarize filter - v0.1.0

View File

@@ -1,6 +1,6 @@
import { Factory } from '../Factory';
import { Node, Filter } from '../Node';
import { getNumberValidator } from '../Validators';
import { Factory } from '../Factory.ts';
import { Node, Filter } from '../Node.ts';
import { getNumberValidator } from '../Validators.ts';
/**
* Threshold Filter. Pushes any value above the mid point to
* the max and any value below the mid point to the min.

View File

@@ -1,9 +1,10 @@
// main entry for umd build for rollup
import { Konva } from './_FullInternals';
import { Konva } from './_FullInternals.ts';
import * as Canvas from 'canvas';
const canvas = Canvas['default'] || Canvas;
// @ts-ignore
global.DOMMatrix = canvas.DOMMatrix;
const isNode = typeof global.document === 'undefined';

224
src/index-types.d.ts vendored
View File

@@ -7,25 +7,25 @@
// so here we just need to define full API of Konva manually
// filters
import { Blur } from './filters/Blur';
import { Brighten } from './filters/Brighten';
import { Contrast } from './filters/Contrast';
import { Emboss } from './filters/Emboss';
import { Enhance } from './filters/Enhance';
import { Grayscale } from './filters/Grayscale';
import { HSL } from './filters/HSL';
import { HSV } from './filters/HSV';
import { Invert } from './filters/Invert';
import { Kaleidoscope } from './filters/Kaleidoscope';
import { Mask } from './filters/Mask';
import { Noise } from './filters/Noise';
import { Pixelate } from './filters/Pixelate';
import { Posterize } from './filters/Posterize';
import { RGB } from './filters/RGB';
import { RGBA } from './filters/RGBA';
import { Sepia } from './filters/Sepia';
import { Solarize } from './filters/Solarize';
import { Threshold } from './filters/Threshold';
import { Blur } from './filters/Blur.ts';
import { Brighten } from './filters/Brighten.ts';
import { Contrast } from './filters/Contrast.ts';
import { Emboss } from './filters/Emboss.ts';
import { Enhance } from './filters/Enhance.ts';
import { Grayscale } from './filters/Grayscale.ts';
import { HSL } from './filters/HSL.ts';
import { HSV } from './filters/HSV.ts';
import { Invert } from './filters/Invert.ts';
import { Kaleidoscope } from './filters/Kaleidoscope.ts';
import { Mask } from './filters/Mask.ts';
import { Noise } from './filters/Noise.ts';
import { Pixelate } from './filters/Pixelate.ts';
import { Posterize } from './filters/Posterize.ts';
import { RGB } from './filters/RGB.ts';
import { RGBA } from './filters/RGBA.ts';
import { Sepia } from './filters/Sepia.ts';
import { Solarize } from './filters/Solarize.ts';
import { Threshold } from './filters/Threshold.ts';
declare namespace Konva {
export let enableTrace: number;
@@ -41,119 +41,121 @@ declare namespace Konva {
export const isDragReady: () => boolean;
export const getAngle: (angle: number) => number;
export type Vector2d = import('./types').Vector2d;
export type Vector2d = import('./types.ts').Vector2d;
export const Node: typeof import('./Node').Node;
export type Node = import('./Node').Node;
export type NodeConfig = import('./Node').NodeConfig;
export const Node: typeof import('./Node.ts').Node;
export type Node = import('./Node.ts').Node;
export type NodeConfig = import('./Node.ts').NodeConfig;
export type KonvaEventObject<EventType> =
import('./Node').KonvaEventObject<EventType>;
import('./Node.ts').KonvaEventObject<EventType>;
export type KonvaPointerEvent = import('./PointerEvents').KonvaPointerEvent;
export type KonvaPointerEvent =
import('./PointerEvents.ts').KonvaPointerEvent;
export type KonvaEventListener<This, EventType> =
import('./Node').KonvaEventListener<This, EventType>;
import('./Node.ts').KonvaEventListener<This, EventType>;
export const Container: typeof import('./Container').Container;
export type Container = import('./Container').Container<Node>;
export type ContainerConfig = import('./Container').ContainerConfig;
export const Container: typeof import('./Container.ts').Container;
export type Container = import('./Container.ts').Container<Node>;
export type ContainerConfig = import('./Container.ts').ContainerConfig;
export const Transform: typeof import('./Util').Transform;
export type Transform = import('./Util').Transform;
export const Transform: typeof import('./Util.ts').Transform;
export type Transform = import('./Util.ts').Transform;
export const Util: typeof import('./Util').Util;
export const Util: typeof import('./Util.ts').Util;
export const Context: typeof import('./Context').Context;
export type Context = import('./Context').Context;
export const Context: typeof import('./Context.ts').Context;
export type Context = import('./Context.ts').Context;
export const Stage: typeof import('./Stage').Stage;
export type Stage = import('./Stage').Stage;
export type StageConfig = import('./Stage').StageConfig;
export const stages: typeof import('./Stage').stages;
export const Stage: typeof import('./Stage.ts').Stage;
export type Stage = import('./Stage.ts').Stage;
export type StageConfig = import('./Stage.ts').StageConfig;
export const stages: typeof import('./Stage.ts').stages;
export const Layer: typeof import('./Layer').Layer;
export type Layer = import('./Layer').Layer;
export type LayerConfig = import('./Layer').LayerConfig;
export const Layer: typeof import('./Layer.ts').Layer;
export type Layer = import('./Layer.ts').Layer;
export type LayerConfig = import('./Layer.ts').LayerConfig;
export const FastLayer: typeof import('./FastLayer').FastLayer;
export type FastLayer = import('./FastLayer').FastLayer;
export const FastLayer: typeof import('./FastLayer.ts').FastLayer;
export type FastLayer = import('./FastLayer.ts').FastLayer;
export const Group: typeof import('./Group').Group;
export type Group = import('./Group').Group;
export type GroupConfig = import('./Group').GroupConfig;
export const Group: typeof import('./Group.ts').Group;
export type Group = import('./Group.ts').Group;
export type GroupConfig = import('./Group.ts').GroupConfig;
export const DD: typeof import('./DragAndDrop').DD;
export const DD: typeof import('./DragAndDrop.ts').DD;
export const Shape: typeof import('./Shape').Shape;
export type Shape = import('./Shape').Shape;
export type ShapeConfig = import('./Shape').ShapeConfig;
export const shapes: typeof import('./Shape').shapes;
export const Shape: typeof import('./Shape.ts').Shape;
export type Shape = import('./Shape.ts').Shape;
export type ShapeConfig = import('./Shape.ts').ShapeConfig;
export const shapes: typeof import('./Shape.ts').shapes;
export const Animation: typeof import('./Animation').Animation;
export type Animation = import('./Animation').Animation;
export const Animation: typeof import('./Animation.ts').Animation;
export type Animation = import('./Animation.ts').Animation;
export const Tween: typeof import('./Tween').Tween;
export type Tween = import('./Tween').Tween;
export type TweenConfig = import('./Tween').TweenConfig;
export const Easings: typeof import('./Tween').Easings;
export const Tween: typeof import('./Tween.ts').Tween;
export type Tween = import('./Tween.ts').Tween;
export type TweenConfig = import('./Tween.ts').TweenConfig;
export const Easings: typeof import('./Tween.ts').Easings;
export const Arc: typeof import('./shapes/Arc').Arc;
export type Arc = import('./shapes/Arc').Arc;
export type ArcConfig = import('./shapes/Arc').ArcConfig;
export const Arrow: typeof import('./shapes/Arrow').Arrow;
export type Arrow = import('./shapes/Arrow').Arrow;
export type ArrowConfig = import('./shapes/Arrow').ArrowConfig;
export const Circle: typeof import('./shapes/Circle').Circle;
export type Circle = import('./shapes/Circle').Circle;
export type CircleConfig = import('./shapes/Circle').CircleConfig;
export const Ellipse: typeof import('./shapes/Ellipse').Ellipse;
export type Ellipse = import('./shapes/Ellipse').Ellipse;
export type EllipseConfig = import('./shapes/Ellipse').EllipseConfig;
export const Image: typeof import('./shapes/Image').Image;
export type Image = import('./shapes/Image').Image;
export type ImageConfig = import('./shapes/Image').ImageConfig;
export const Label: typeof import('./shapes/Label').Label;
export type Label = import('./shapes/Label').Label;
export type LabelConfig = import('./shapes/Label').LabelConfig;
export const Tag: typeof import('./shapes/Label').Tag;
export type Tag = import('./shapes/Label').Tag;
export type TagConfig = import('./shapes/Label').TagConfig;
export const Line: typeof import('./shapes/Line').Line;
export type Line = import('./shapes/Line').Line;
export type LineConfig = import('./shapes/Line').LineConfig;
export const Path: typeof import('./shapes/Path').Path;
export type Path = import('./shapes/Path').Path;
export type PathConfig = import('./shapes/Path').PathConfig;
export const Rect: typeof import('./shapes/Rect').Rect;
export type Rect = import('./shapes/Rect').Rect;
export type RectConfig = import('./shapes/Rect').RectConfig;
export const RegularPolygon: typeof import('./shapes/RegularPolygon').RegularPolygon;
export type RegularPolygon = import('./shapes/RegularPolygon').RegularPolygon;
export const Arc: typeof import('./shapes/Arc.ts').Arc;
export type Arc = import('./shapes/Arc.ts').Arc;
export type ArcConfig = import('./shapes/Arc.ts').ArcConfig;
export const Arrow: typeof import('./shapes/Arrow.ts').Arrow;
export type Arrow = import('./shapes/Arrow.ts').Arrow;
export type ArrowConfig = import('./shapes/Arrow.ts').ArrowConfig;
export const Circle: typeof import('./shapes/Circle.ts').Circle;
export type Circle = import('./shapes/Circle.ts').Circle;
export type CircleConfig = import('./shapes/Circle.ts').CircleConfig;
export const Ellipse: typeof import('./shapes/Ellipse.ts').Ellipse;
export type Ellipse = import('./shapes/Ellipse.ts').Ellipse;
export type EllipseConfig = import('./shapes/Ellipse.ts').EllipseConfig;
export const Image: typeof import('./shapes/Image.ts').Image;
export type Image = import('./shapes/Image.ts').Image;
export type ImageConfig = import('./shapes/Image.ts').ImageConfig;
export const Label: typeof import('./shapes/Label.ts').Label;
export type Label = import('./shapes/Label.ts').Label;
export type LabelConfig = import('./shapes/Label.ts').LabelConfig;
export const Tag: typeof import('./shapes/Label.ts').Tag;
export type Tag = import('./shapes/Label.ts').Tag;
export type TagConfig = import('./shapes/Label.ts').TagConfig;
export const Line: typeof import('./shapes/Line.ts').Line;
export type Line = import('./shapes/Line.ts').Line;
export type LineConfig = import('./shapes/Line.ts').LineConfig;
export const Path: typeof import('./shapes/Path.ts').Path;
export type Path = import('./shapes/Path.ts').Path;
export type PathConfig = import('./shapes/Path.ts').PathConfig;
export const Rect: typeof import('./shapes/Rect.ts').Rect;
export type Rect = import('./shapes/Rect.ts').Rect;
export type RectConfig = import('./shapes/Rect.ts').RectConfig;
export const RegularPolygon: typeof import('./shapes/RegularPolygon.ts').RegularPolygon;
export type RegularPolygon =
import('./shapes/RegularPolygon.ts').RegularPolygon;
export type RegularPolygonConfig =
import('./shapes/RegularPolygon').RegularPolygonConfig;
export const Ring: typeof import('./shapes/Ring').Ring;
export type Ring = import('./shapes/Ring').Ring;
export type RingConfig = import('./shapes/Ring').RingConfig;
export const Sprite: typeof import('./shapes/Sprite').Sprite;
export type Sprite = import('./shapes/Sprite').Sprite;
export type SpriteConfig = import('./shapes/Sprite').SpriteConfig;
export const Star: typeof import('./shapes/Star').Star;
export type Star = import('./shapes/Star').Star;
export type StarConfig = import('./shapes/Star').StarConfig;
export const Text: typeof import('./shapes/Text').Text;
export type Text = import('./shapes/Text').Text;
export type TextConfig = import('./shapes/Text').TextConfig;
export const TextPath: typeof import('./shapes/TextPath').TextPath;
export type TextPath = import('./shapes/TextPath').TextPath;
export type TextPathConfig = import('./shapes/TextPath').TextPathConfig;
export const Transformer: typeof import('./shapes/Transformer').Transformer;
export type Transformer = import('./shapes/Transformer').Transformer;
import('./shapes/RegularPolygon.ts').RegularPolygonConfig;
export const Ring: typeof import('./shapes/Ring.ts').Ring;
export type Ring = import('./shapes/Ring.ts').Ring;
export type RingConfig = import('./shapes/Ring.ts').RingConfig;
export const Sprite: typeof import('./shapes/Sprite.ts').Sprite;
export type Sprite = import('./shapes/Sprite.ts').Sprite;
export type SpriteConfig = import('./shapes/Sprite.ts').SpriteConfig;
export const Star: typeof import('./shapes/Star.ts').Star;
export type Star = import('./shapes/Star.ts').Star;
export type StarConfig = import('./shapes/Star.ts').StarConfig;
export const Text: typeof import('./shapes/Text.ts').Text;
export type Text = import('./shapes/Text.ts').Text;
export type TextConfig = import('./shapes/Text.ts').TextConfig;
export const TextPath: typeof import('./shapes/TextPath.ts').TextPath;
export type TextPath = import('./shapes/TextPath.ts').TextPath;
export type TextPathConfig = import('./shapes/TextPath.ts').TextPathConfig;
export const Transformer: typeof import('./shapes/Transformer.ts').Transformer;
export type Transformer = import('./shapes/Transformer.ts').Transformer;
export type TransformerConfig =
import('./shapes/Transformer').TransformerConfig;
export const Wedge: typeof import('./shapes/Wedge').Wedge;
export type Wedge = import('./shapes/Wedge').Wedge;
export type WedgeConfig = import('./shapes/Wedge').WedgeConfig;
import('./shapes/Transformer.ts').TransformerConfig;
export const Wedge: typeof import('./shapes/Wedge.ts').Wedge;
export type Wedge = import('./shapes/Wedge.ts').Wedge;
export type WedgeConfig = import('./shapes/Wedge.ts').WedgeConfig;
export const Filters: {
Blur: typeof Blur;

View File

@@ -1,3 +1,3 @@
import { Konva } from './_FullInternals';
import { Konva } from './_FullInternals.ts';
export default Konva;

View File

@@ -1,10 +1,10 @@
import { Factory } from '../Factory';
import { Shape, ShapeConfig } from '../Shape';
import { Konva } from '../Global';
import { GetSet } from '../types';
import { getNumberValidator, getBooleanValidator } from '../Validators';
import { _registerNode } from '../Global';
import { Context } from '../Context';
import { Factory } from '../Factory.ts';
import { Shape, ShapeConfig } from '../Shape.ts';
import { Konva } from '../Global.ts';
import { GetSet } from '../types.ts';
import { getNumberValidator, getBooleanValidator } from '../Validators.ts';
import { _registerNode } from '../Global.ts';
import { Context } from '../Context.ts';
export interface ArcConfig extends ShapeConfig {
angle: number;

View File

@@ -1,10 +1,10 @@
import { Factory } from '../Factory';
import { Line, LineConfig } from './Line';
import { GetSet } from '../types';
import { getNumberValidator } from '../Validators';
import { _registerNode } from '../Global';
import { Path } from './Path';
import { Context } from '../Context';
import { Factory } from '../Factory.ts';
import { Line, LineConfig } from './Line.ts';
import { GetSet } from '../types.ts';
import { getNumberValidator } from '../Validators.ts';
import { _registerNode } from '../Global.ts';
import { Path } from './Path.ts';
import { Context } from '../Context.ts';
export interface ArrowConfig extends LineConfig {
points: number[];

View File

@@ -1,9 +1,9 @@
import { Factory } from '../Factory';
import { Shape, ShapeConfig } from '../Shape';
import { GetSet } from '../types';
import { getNumberValidator } from '../Validators';
import { _registerNode } from '../Global';
import { Context } from '../Context';
import { Factory } from '../Factory.ts';
import { Shape, ShapeConfig } from '../Shape.ts';
import { GetSet } from '../types.ts';
import { getNumberValidator } from '../Validators.ts';
import { _registerNode } from '../Global.ts';
import { Context } from '../Context.ts';
export interface CircleConfig extends ShapeConfig {
radius?: number;

View File

@@ -1,10 +1,10 @@
import { Factory } from '../Factory';
import { Shape, ShapeConfig } from '../Shape';
import { getNumberValidator } from '../Validators';
import { _registerNode } from '../Global';
import { Context } from '../Context';
import { Factory } from '../Factory.ts';
import { Shape, ShapeConfig } from '../Shape.ts';
import { getNumberValidator } from '../Validators.ts';
import { _registerNode } from '../Global.ts';
import { Context } from '../Context.ts';
import { GetSet, Vector2d } from '../types';
import { GetSet, Vector2d } from '../types.ts';
export interface EllipseConfig extends ShapeConfig {
radiusX: number;

View File

@@ -1,14 +1,14 @@
import { Util } from '../Util';
import { Factory } from '../Factory';
import { Shape, ShapeConfig } from '../Shape';
import { _registerNode } from '../Global';
import { Util } from '../Util.ts';
import { Factory } from '../Factory.ts';
import { Shape, ShapeConfig } from '../Shape.ts';
import { _registerNode } from '../Global.ts';
import {
getNumberOrArrayOfNumbersValidator,
getNumberValidator,
} from '../Validators';
} from '../Validators.ts';
import { GetSet, IRect } from '../types';
import { Context } from '../Context';
import { GetSet, IRect } from '../types.ts';
import { Context } from '../Context.ts';
export interface ImageConfig extends ShapeConfig {
image: CanvasImageSource | undefined;

View File

@@ -1,16 +1,16 @@
import { Factory } from '../Factory';
import { Shape, ShapeConfig } from '../Shape';
import { Group } from '../Group';
import { Context } from '../Context';
import { ContainerConfig } from '../Container';
import { Factory } from '../Factory.ts';
import { Shape, ShapeConfig } from '../Shape.ts';
import { Group } from '../Group.ts';
import { Context } from '../Context.ts';
import { ContainerConfig } from '../Container.ts';
import {
getNumberOrArrayOfNumbersValidator,
getNumberValidator,
} from '../Validators';
import { _registerNode } from '../Global';
} from '../Validators.ts';
import { _registerNode } from '../Global.ts';
import { GetSet } from '../types';
import { Text } from './Text';
import { GetSet } from '../types.ts';
import { Text } from './Text.ts';
export interface LabelConfig extends ContainerConfig {}

View File

@@ -1,10 +1,10 @@
import { Factory } from '../Factory';
import { _registerNode } from '../Global';
import { Shape, ShapeConfig } from '../Shape';
import { getNumberArrayValidator, getNumberValidator } from '../Validators';
import { Factory } from '../Factory.ts';
import { _registerNode } from '../Global.ts';
import { Shape, ShapeConfig } from '../Shape.ts';
import { getNumberArrayValidator, getNumberValidator } from '../Validators.ts';
import { Context } from '../Context';
import { GetSet } from '../types';
import { Context } from '../Context.ts';
import { GetSet } from '../types.ts';
function getControlPoints(
x0: number,

View File

@@ -1,13 +1,13 @@
import { Factory } from '../Factory';
import { _registerNode } from '../Global';
import { Shape, ShapeConfig } from '../Shape';
import { Factory } from '../Factory.ts';
import { _registerNode } from '../Global.ts';
import { Shape, ShapeConfig } from '../Shape.ts';
import {
getCubicArcLength,
getQuadraticArcLength,
t2length,
} from '../BezierFunctions';
import { GetSet, PathSegment } from '../types';
} from '../BezierFunctions.ts';
import { GetSet, PathSegment } from '../types.ts';
export interface PathConfig extends ShapeConfig {
data?: string;

View File

@@ -1,11 +1,11 @@
import { Factory } from '../Factory';
import { Shape, ShapeConfig } from '../Shape';
import { _registerNode } from '../Global';
import { Factory } from '../Factory.ts';
import { Shape, ShapeConfig } from '../Shape.ts';
import { _registerNode } from '../Global.ts';
import { Util } from '../Util';
import { GetSet } from '../types';
import { Context } from '../Context';
import { getNumberOrArrayOfNumbersValidator } from '../Validators';
import { Util } from '../Util.ts';
import { GetSet } from '../types.ts';
import { Context } from '../Context.ts';
import { getNumberOrArrayOfNumbersValidator } from '../Validators.ts';
export interface RectConfig extends ShapeConfig {
cornerRadius?: number | number[];

View File

@@ -1,13 +1,13 @@
import { Factory } from '../Factory';
import { Shape, ShapeConfig } from '../Shape';
import { GetSet, Vector2d } from '../types';
import { Factory } from '../Factory.ts';
import { Shape, ShapeConfig } from '../Shape.ts';
import { GetSet, Vector2d } from '../types.ts';
import {
getNumberOrArrayOfNumbersValidator,
getNumberValidator,
} from '../Validators';
import { _registerNode } from '../Global';
import { Context } from '../Context';
import { Util } from '../Util';
} from '../Validators.ts';
import { _registerNode } from '../Global.ts';
import { Context } from '../Context.ts';
import { Util } from '../Util.ts';
export interface RegularPolygonConfig extends ShapeConfig {
sides: number;

View File

@@ -1,9 +1,9 @@
import { Factory } from '../Factory';
import { Shape, ShapeConfig } from '../Shape';
import { GetSet } from '../types';
import { getNumberValidator } from '../Validators';
import { _registerNode } from '../Global';
import { Context } from '../Context';
import { Factory } from '../Factory.ts';
import { Shape, ShapeConfig } from '../Shape.ts';
import { GetSet } from '../types.ts';
import { getNumberValidator } from '../Validators.ts';
import { _registerNode } from '../Global.ts';
import { Context } from '../Context.ts';
export interface RingConfig extends ShapeConfig {
innerRadius: number;

View File

@@ -1,11 +1,11 @@
import { Factory } from '../Factory';
import { Context } from '../Context';
import { Shape, ShapeConfig } from '../Shape';
import { Animation } from '../Animation';
import { getNumberValidator } from '../Validators';
import { _registerNode } from '../Global';
import { Factory } from '../Factory.ts';
import { Context } from '../Context.ts';
import { Shape, ShapeConfig } from '../Shape.ts';
import { Animation } from '../Animation.ts';
import { getNumberValidator } from '../Validators.ts';
import { _registerNode } from '../Global.ts';
import { GetSet } from '../types';
import { GetSet } from '../types.ts';
export interface SpriteConfig extends ShapeConfig {
animation: string;

View File

@@ -1,10 +1,10 @@
import { Factory } from '../Factory';
import { Context } from '../Context';
import { Shape, ShapeConfig } from '../Shape';
import { getNumberValidator } from '../Validators';
import { _registerNode } from '../Global';
import { Factory } from '../Factory.ts';
import { Context } from '../Context.ts';
import { Shape, ShapeConfig } from '../Shape.ts';
import { getNumberValidator } from '../Validators.ts';
import { _registerNode } from '../Global.ts';
import { GetSet } from '../types';
import { GetSet } from '../types.ts';
export interface StarConfig extends ShapeConfig {
numPoints: number;

View File

@@ -1,17 +1,17 @@
import { Util } from '../Util';
import { Context } from '../Context';
import { Factory } from '../Factory';
import { Shape, ShapeConfig } from '../Shape';
import { Konva } from '../Global';
import { Util } from '../Util.ts';
import { Context } from '../Context.ts';
import { Factory } from '../Factory.ts';
import { Shape, ShapeConfig } from '../Shape.ts';
import { Konva } from '../Global.ts';
import {
getNumberValidator,
getStringValidator,
getNumberOrAutoValidator,
getBooleanValidator,
} from '../Validators';
import { _registerNode } from '../Global';
} from '../Validators.ts';
import { _registerNode } from '../Global.ts';
import { GetSet } from '../types';
import { GetSet } from '../types.ts';
export interface CharRenderProps {
char: string;

View File

@@ -1,13 +1,13 @@
import { Util } from '../Util';
import { Factory } from '../Factory';
import { Context } from '../Context';
import { Shape, ShapeConfig } from '../Shape';
import { Path } from './Path';
import { Text, stringToArray } from './Text';
import { getNumberValidator } from '../Validators';
import { _registerNode } from '../Global';
import { Util } from '../Util.ts';
import { Factory } from '../Factory.ts';
import { Context } from '../Context.ts';
import { Shape, ShapeConfig } from '../Shape.ts';
import { Path } from './Path.ts';
import { Text, stringToArray } from './Text.ts';
import { getNumberValidator } from '../Validators.ts';
import { _registerNode } from '../Global.ts';
import { GetSet, PathSegment, Vector2d } from '../types';
import { GetSet, PathSegment, Vector2d } from '../types.ts';
export interface TextPathConfig extends ShapeConfig {
text?: string;

View File

@@ -1,15 +1,15 @@
import { Util, Transform } from '../Util';
import { Factory } from '../Factory';
import { Node } from '../Node';
import { Shape } from '../Shape';
import { Rect } from './Rect';
import { Group } from '../Group';
import { ContainerConfig } from '../Container';
import { Konva } from '../Global';
import { getBooleanValidator, getNumberValidator } from '../Validators';
import { _registerNode } from '../Global';
import { Util, Transform } from '../Util.ts';
import { Factory } from '../Factory.ts';
import { Node } from '../Node.ts';
import { Shape } from '../Shape.ts';
import { Rect } from './Rect.ts';
import { Group } from '../Group.ts';
import { ContainerConfig } from '../Container.ts';
import { Konva } from '../Global.ts';
import { getBooleanValidator, getNumberValidator } from '../Validators.ts';
import { _registerNode } from '../Global.ts';
import { GetSet, IRect, Vector2d } from '../types';
import { GetSet, IRect, Vector2d } from '../types.ts';
export interface Box extends IRect {
rotation: number;

View File

@@ -1,11 +1,11 @@
import { Factory } from '../Factory';
import { Context } from '../Context';
import { Shape, ShapeConfig } from '../Shape';
import { Konva } from '../Global';
import { getNumberValidator } from '../Validators';
import { _registerNode } from '../Global';
import { Factory } from '../Factory.ts';
import { Context } from '../Context.ts';
import { Shape, ShapeConfig } from '../Shape.ts';
import { Konva } from '../Global.ts';
import { getNumberValidator } from '../Validators.ts';
import { _registerNode } from '../Global.ts';
import { GetSet } from '../types';
import { GetSet } from '../types.ts';
export interface WedgeConfig extends ShapeConfig {
angle: number;

View File

@@ -1,4 +1,4 @@
import { Konva } from './_CoreInternals';
import { Konva } from './_CoreInternals.ts';
import { Canvas, DOMMatrix, Image } from 'skia-canvas';
global.DOMMatrix = DOMMatrix as any;

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('Blur', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('Brighten', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('Filter Contrast', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('Emboss', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('Enhance', function () {
// ======================================================

View File

@@ -1,4 +1,4 @@
import { addStage, Konva, cloneAndCompareLayer } from '../unit/test-utils';
import { addStage, Konva, cloneAndCompareLayer } from '../unit/test-utils.ts';
describe('Filter', function () {
it('pixelRaio check', function () {

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('Grayscale', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('HSL', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('HSV', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('Invert', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('Kaleidoscope', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage, showHit } from '../unit/test-utils';
import { addStage, Konva, loadImage, showHit } from '../unit/test-utils.ts';
describe('Manual', function () {
// ======================================================

View File

@@ -1,4 +1,4 @@
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('Mask', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('Noise', function () {
// ======================================================

View File

@@ -1,5 +1,5 @@
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { cloneAndCompareLayer } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
import { cloneAndCompareLayer } from '../unit/test-utils.ts';
describe('Pixelate', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('Posterize', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('RGB', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('RGBA', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('Filter Sepia', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('Solarize', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, loadImage } from '../unit/test-utils';
import { addStage, Konva, loadImage } from '../unit/test-utils.ts';
describe('Threshold', function () {
// ======================================================

View File

@@ -1,13 +1,5 @@
export async function mochaGlobalSetup() {
// Load node-canvas polyfills on the compiled test output
// Path from this file (test/) to compiled file (.test-temp/src/...)
try {
await import(
new URL('../.test-temp/src/canvas-backend.js', import.meta.url)
);
} catch (e) {
// If not compiled yet or path missing, keep going; tests that need it will fail clearly
}
await import('../src/canvas-backend.ts');
globalThis.Path2D ??= class Path2D {
constructor(path) {

View File

@@ -1,5 +1,5 @@
export async function mochaGlobalSetup() {
await import(new URL('../.test-temp/src/skia-backend.js', import.meta.url));
await import('../src/skia-backend.ts');
globalThis.Path2D ??= class Path2D {
constructor(path) {

View File

@@ -1,3 +0,0 @@
{
"type": "commonjs"
}

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva } from './test-utils';
import { addStage, Konva } from './test-utils.ts';
describe('Animation', function () {
// ======================================================

View File

@@ -6,7 +6,7 @@ import {
createCanvas,
compareLayerAndCanvas,
assertAlmostDeepEqual,
} from './test-utils';
} from './test-utils.ts';
describe('Arc', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { addStage, Konva, cloneAndCompareLayer } from './test-utils';
import { addStage, Konva, cloneAndCompareLayer } from './test-utils.ts';
describe('Arrow', function () {
// ======================================================

View File

@@ -1,5 +1,5 @@
import { assert } from 'chai';
import { addStage, isNode, Konva } from './test-utils';
import { addStage, isNode, Konva } from './test-utils.ts';
describe('AutoDraw', function () {
// ======================================================

View File

@@ -1,7 +1,7 @@
import { assert } from 'chai';
import { Line } from '../../src/shapes/Line';
import { Line } from '../../src/shapes/Line.ts';
import { addStage, Konva, cloneAndCompareLayer } from './test-utils';
import { addStage, Konva, cloneAndCompareLayer } from './test-utils.ts';
describe('Blob', function () {
// ======================================================

View File

@@ -1,5 +1,5 @@
import { assert } from 'chai';
import { addStage, Konva } from './test-utils';
import { addStage, Konva } from './test-utils.ts';
describe('Canvas', function () {
// ======================================================

View File

@@ -6,7 +6,7 @@ import {
createCanvas,
compareLayerAndCanvas,
loadImage,
} from './test-utils';
} from './test-utils.ts';
describe('Circle', function () {
// ======================================================

View File

@@ -1,6 +1,6 @@
import { assert } from 'chai';
import { Shape } from '../../src/Shape.js';
import { addStage, Konva, compareLayers, isNode } from './test-utils';
import { addStage, Konva, compareLayers, isNode } from './test-utils.ts';
describe('Container', function () {
// ======================================================

View File

@@ -1,5 +1,5 @@
import { assert } from 'chai';
import { addStage, Konva } from './test-utils';
import { addStage, Konva } from './test-utils.ts';
describe('Context', function () {
// ======================================================

View File

@@ -8,7 +8,7 @@ import {
simulateTouchStart,
simulateTouchEnd,
simulateTouchMove,
} from './test-utils';
} from './test-utils.ts';
describe('DragAndDrop', function () {
// ======================================================

View File

@@ -9,7 +9,7 @@ import {
simulatePointerDown,
simulatePointerMove,
simulatePointerUp,
} from './test-utils';
} from './test-utils.ts';
describe('DragAndDropEvents', function () {
// ======================================================

View File

@@ -5,7 +5,7 @@ import {
Konva,
createCanvas,
compareLayerAndCanvas,
} from './test-utils';
} from './test-utils.ts';
describe('Ellipse', function () {
// ======================================================

View File

@@ -1,5 +1,5 @@
import { assert } from 'chai';
import { Konva } from './test-utils';
import { Konva } from './test-utils.ts';
describe('Global', function () {
// ======================================================

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