@nmmty/lazycanvas 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/helpers/Filters.d.ts +10 -10
- package/dist/helpers/Fonts.d.ts +1 -1
- package/dist/helpers/FontsList.d.ts +1 -1
- package/dist/helpers/FontsList.js +19 -19
- package/dist/index.d.ts +11 -20
- package/dist/index.js +40 -47
- package/dist/structures/LazyCanvas.d.ts +126 -19
- package/dist/structures/LazyCanvas.js +100 -35
- package/dist/structures/components/BaseLayer.d.ts +188 -38
- package/dist/structures/components/BaseLayer.js +88 -41
- package/dist/structures/components/BezierLayer.d.ts +108 -21
- package/dist/structures/components/BezierLayer.js +73 -24
- package/dist/structures/components/ClearLayer.d.ts +120 -17
- package/dist/structures/components/ClearLayer.js +83 -22
- package/dist/structures/components/Group.d.ts +86 -18
- package/dist/structures/components/Group.js +69 -29
- package/dist/structures/components/ImageLayer.d.ts +85 -12
- package/dist/structures/components/ImageLayer.js +52 -39
- package/dist/structures/components/LineLayer.d.ts +111 -18
- package/dist/structures/components/LineLayer.js +58 -21
- package/dist/structures/components/MorphLayer.d.ts +109 -21
- package/dist/structures/components/MorphLayer.js +53 -25
- package/dist/structures/components/Path2DLayer.d.ts +191 -0
- package/dist/structures/components/Path2DLayer.js +318 -0
- package/dist/structures/components/QuadraticLayer.d.ts +108 -22
- package/dist/structures/components/QuadraticLayer.js +65 -30
- package/dist/structures/components/TextLayer.d.ts +201 -40
- package/dist/structures/components/TextLayer.js +99 -47
- package/dist/structures/components/index.d.ts +10 -0
- package/dist/structures/components/index.js +26 -0
- package/dist/structures/helpers/Exporter.d.ts +52 -0
- package/dist/structures/helpers/Exporter.js +168 -0
- package/dist/structures/helpers/Font.d.ts +64 -10
- package/dist/structures/helpers/Font.js +38 -11
- package/dist/structures/helpers/Gradient.d.ts +96 -9
- package/dist/structures/helpers/Gradient.js +48 -17
- package/dist/structures/helpers/Link.d.ts +52 -8
- package/dist/structures/helpers/Link.js +42 -11
- package/dist/structures/helpers/Pattern.d.ts +52 -7
- package/dist/structures/helpers/Pattern.js +45 -40
- package/dist/structures/helpers/index.d.ts +6 -0
- package/dist/structures/helpers/index.js +22 -0
- package/dist/structures/helpers/readers/JSONReader.d.ts +49 -0
- package/dist/structures/helpers/readers/JSONReader.js +172 -0
- package/dist/structures/helpers/readers/SVGReader.d.ts +20 -0
- package/dist/structures/helpers/readers/SVGReader.js +577 -0
- package/dist/structures/helpers/readers/YAMLReader.d.ts +0 -0
- package/dist/structures/helpers/readers/YAMLReader.js +1 -0
- package/dist/structures/managers/AnimationManager.d.ts +96 -20
- package/dist/structures/managers/AnimationManager.js +54 -26
- package/dist/structures/managers/FontsManager.d.ts +76 -32
- package/dist/structures/managers/FontsManager.js +70 -45
- package/dist/structures/managers/LayersManager.d.ts +84 -32
- package/dist/structures/managers/LayersManager.js +66 -28
- package/dist/structures/managers/RenderManager.d.ts +60 -6
- package/dist/structures/managers/RenderManager.js +120 -40
- package/dist/types/enum.d.ts +11 -6
- package/dist/types/enum.js +17 -12
- package/dist/types/index.d.ts +2 -19
- package/dist/types/index.js +17 -0
- package/dist/utils/LazyUtil.js +2 -2
- package/dist/utils/utils.d.ts +10 -9
- package/dist/utils/utils.js +159 -164
- package/package.json +4 -5
package/dist/types/enum.d.ts
CHANGED
|
@@ -67,17 +67,17 @@ export declare enum LineJoin {
|
|
|
67
67
|
Miter = "miter"
|
|
68
68
|
}
|
|
69
69
|
export declare enum Export {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
export declare enum SaveFormat {
|
|
70
|
+
CANVAS = "canvas",
|
|
71
|
+
CTX = "ctx",
|
|
72
|
+
BUFFER = "buffer",
|
|
75
73
|
PNG = "png",
|
|
76
74
|
JPEG = "jpeg",
|
|
77
75
|
JPG = "jpg",
|
|
78
76
|
SVG = "svg",
|
|
79
77
|
GIF = "gif",
|
|
80
|
-
WEBP = "webp"
|
|
78
|
+
WEBP = "webp",
|
|
79
|
+
YAML = "yaml",
|
|
80
|
+
JSON = "json"
|
|
81
81
|
}
|
|
82
82
|
export declare enum Centring {
|
|
83
83
|
Start = "start",
|
|
@@ -136,3 +136,8 @@ export declare enum ColorSpace {
|
|
|
136
136
|
RGBA4444 = "rgba4444",
|
|
137
137
|
RGBA444 = "rgba444"
|
|
138
138
|
}
|
|
139
|
+
export declare enum FillType {
|
|
140
|
+
Solid = "solid",
|
|
141
|
+
Gradient = "gradient",
|
|
142
|
+
Pattern = "pattern"
|
|
143
|
+
}
|
package/dist/types/enum.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ColorSpace = exports.GlobalCompositeOperation = exports.LinkType = exports.PatternType = exports.Centring = exports.
|
|
3
|
+
exports.FillType = exports.ColorSpace = exports.GlobalCompositeOperation = exports.LinkType = exports.PatternType = exports.Centring = exports.Export = exports.LineJoin = exports.LineCap = exports.TextDirection = exports.TextBaseline = exports.TextAlign = exports.FontWeight = exports.GradientType = exports.LayerScaleType = exports.LayerType = void 0;
|
|
4
4
|
var LayerType;
|
|
5
5
|
(function (LayerType) {
|
|
6
6
|
LayerType["Base"] = "base";
|
|
@@ -80,19 +80,18 @@ var LineJoin;
|
|
|
80
80
|
})(LineJoin || (exports.LineJoin = LineJoin = {}));
|
|
81
81
|
var Export;
|
|
82
82
|
(function (Export) {
|
|
83
|
-
Export["
|
|
84
|
-
Export["SVG"] = "svg";
|
|
83
|
+
Export["CANVAS"] = "canvas";
|
|
85
84
|
Export["CTX"] = "ctx";
|
|
85
|
+
Export["BUFFER"] = "buffer";
|
|
86
|
+
Export["PNG"] = "png";
|
|
87
|
+
Export["JPEG"] = "jpeg";
|
|
88
|
+
Export["JPG"] = "jpg";
|
|
89
|
+
Export["SVG"] = "svg";
|
|
90
|
+
Export["GIF"] = "gif";
|
|
91
|
+
Export["WEBP"] = "webp";
|
|
92
|
+
Export["YAML"] = "yaml";
|
|
93
|
+
Export["JSON"] = "json";
|
|
86
94
|
})(Export || (exports.Export = Export = {}));
|
|
87
|
-
var SaveFormat;
|
|
88
|
-
(function (SaveFormat) {
|
|
89
|
-
SaveFormat["PNG"] = "png";
|
|
90
|
-
SaveFormat["JPEG"] = "jpeg";
|
|
91
|
-
SaveFormat["JPG"] = "jpg";
|
|
92
|
-
SaveFormat["SVG"] = "svg";
|
|
93
|
-
SaveFormat["GIF"] = "gif";
|
|
94
|
-
SaveFormat["WEBP"] = "webp";
|
|
95
|
-
})(SaveFormat || (exports.SaveFormat = SaveFormat = {}));
|
|
96
95
|
var Centring;
|
|
97
96
|
(function (Centring) {
|
|
98
97
|
Centring["Start"] = "start";
|
|
@@ -155,3 +154,9 @@ var ColorSpace;
|
|
|
155
154
|
ColorSpace["RGBA4444"] = "rgba4444";
|
|
156
155
|
ColorSpace["RGBA444"] = "rgba444";
|
|
157
156
|
})(ColorSpace || (exports.ColorSpace = ColorSpace = {}));
|
|
157
|
+
var FillType;
|
|
158
|
+
(function (FillType) {
|
|
159
|
+
FillType["Solid"] = "solid";
|
|
160
|
+
FillType["Gradient"] = "gradient";
|
|
161
|
+
FillType["Pattern"] = "pattern";
|
|
162
|
+
})(FillType || (exports.FillType = FillType = {}));
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
export type * from "./types";
|
|
2
|
-
export
|
|
3
|
-
export type * from "./components/TextLayer";
|
|
4
|
-
export type * from "./components/ImageLayer";
|
|
5
|
-
export type * from "./components/MorphLayer";
|
|
6
|
-
export type * from "./components/BezierLayer";
|
|
7
|
-
export type * from "./components/QuadraticLayer";
|
|
8
|
-
export type * from "./components/LineLayer";
|
|
9
|
-
export type * from "./components/Group";
|
|
10
|
-
export type * from "./components/ClearLayer";
|
|
11
|
-
export type * from "./helpers/Font";
|
|
12
|
-
export type * from "./helpers/Gradient";
|
|
13
|
-
export type * from "./helpers/Pattern";
|
|
14
|
-
export type * from "./helpers/Link";
|
|
15
|
-
export type * from "./managers/LayersManager";
|
|
16
|
-
export type * from "./managers/RenderManager";
|
|
17
|
-
export type * from "./managers/FontsManager";
|
|
18
|
-
export type * from "./managers/AnimationManager";
|
|
19
|
-
export type * from "./LazyCanvas";
|
|
1
|
+
export type * from "./types";
|
|
2
|
+
export * from './enum';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./enum"), exports);
|
package/dist/utils/LazyUtil.js
CHANGED
|
@@ -13,10 +13,10 @@ class LazyLog {
|
|
|
13
13
|
static log(type = "none", ...message) {
|
|
14
14
|
switch (type) {
|
|
15
15
|
case "info":
|
|
16
|
-
console.log("[LazyCanvas] [INFO]
|
|
16
|
+
console.log("[LazyCanvas] [INFO]", ...message);
|
|
17
17
|
break;
|
|
18
18
|
case "warn":
|
|
19
|
-
console.warn("[LazyCanvas] [WARN]
|
|
19
|
+
console.warn("[LazyCanvas] [WARN]", ...message);
|
|
20
20
|
break;
|
|
21
21
|
default:
|
|
22
22
|
console.log(...message);
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Gradient } from "../structures/helpers
|
|
4
|
-
import { Canvas, SKRSContext2D } from "@napi-rs/canvas";
|
|
5
|
-
import { Pattern } from "../structures/helpers/Pattern";
|
|
1
|
+
import type { AnyCentring, AnyLayer, AnyTextAlign, ColorType, PointNumber, ScaleType, Transform } from "../types";
|
|
2
|
+
import { LayerType } from "../types";
|
|
3
|
+
import { Gradient, Pattern } from "../structures/helpers";
|
|
4
|
+
import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
|
|
6
5
|
import { LayersManager } from "../structures/managers/LayersManager";
|
|
6
|
+
import { Group } from "../structures/components";
|
|
7
7
|
export declare function generateID(type: string): string;
|
|
8
8
|
export declare function isColor(v: ColorType): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
9
9
|
export declare function parseHex(v: string): string;
|
|
10
|
-
export declare function parseColor(v: ColorType): string |
|
|
11
|
-
export declare function parseToNormal(v: ScaleType, ctx: SKRSContext2D, canvas: Canvas, layer?: {
|
|
10
|
+
export declare function parseColor(v: ColorType): string | Gradient | Pattern;
|
|
11
|
+
export declare function parseToNormal(v: ScaleType, ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, layer?: {
|
|
12
12
|
width: number;
|
|
13
13
|
height: number;
|
|
14
14
|
}, options?: {
|
|
15
15
|
vertical?: boolean;
|
|
16
16
|
layer?: boolean;
|
|
17
17
|
}, manager?: LayersManager): number;
|
|
18
|
-
export declare function parser(ctx: SKRSContext2D, canvas: Canvas, manager?: LayersManager): {
|
|
18
|
+
export declare function parser(ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, manager?: LayersManager): {
|
|
19
19
|
parse(v: ScaleType, layer?: {
|
|
20
20
|
width: number;
|
|
21
21
|
height: number;
|
|
@@ -51,7 +51,6 @@ export declare function transform(ctx: SKRSContext2D, transform: Transform, laye
|
|
|
51
51
|
fontSize: number;
|
|
52
52
|
multiline: boolean;
|
|
53
53
|
}): void;
|
|
54
|
-
export declare function saveFile(buffer: any, extension: AnySaveFormat, name: string): Promise<void>;
|
|
55
54
|
export declare function generateRandomName(): string;
|
|
56
55
|
export declare function isImageUrlValid(src: string): boolean;
|
|
57
56
|
export declare function centring(centring: AnyCentring, type: LayerType, width: number, height: number, x: number, y: number): {
|
|
@@ -74,3 +73,5 @@ export declare function getBoundingBoxBezier(points: PointNumber[], steps?: numb
|
|
|
74
73
|
width: number;
|
|
75
74
|
height: number;
|
|
76
75
|
};
|
|
76
|
+
export declare function resize(value: ScaleType, ratio: number): number | string;
|
|
77
|
+
export declare function resizeLayers(layers: Array<AnyLayer | Group>, ratio: number): (AnyLayer | Group)[];
|