@nmmty/lazycanvas 0.6.5 → 1.0.0-dev.10
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/ReadMe.md +1 -1
- package/dist/core/Interpolation.d.ts +30 -0
- package/dist/core/Interpolation.js +200 -0
- package/dist/core/Scene.d.ts +94 -0
- package/dist/core/Scene.js +157 -0
- package/dist/core/Signal.d.ts +133 -0
- package/dist/core/Signal.js +255 -0
- package/dist/core/SignalUtils.d.ts +133 -0
- package/dist/core/SignalUtils.js +333 -0
- package/dist/core/ThreadScheduler.d.ts +38 -0
- package/dist/core/ThreadScheduler.js +74 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.js +21 -0
- package/dist/helpers/Filters.js +1 -1
- package/dist/helpers/FontsList.js +18 -18
- package/dist/helpers/Utlis.d.ts +3 -3
- package/dist/helpers/Utlis.js +25 -36
- package/dist/helpers/index.d.ts +3 -3
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/jsx-runtime.d.ts +17 -0
- package/dist/jsx-runtime.js +111 -0
- package/dist/structures/LazyCanvas.d.ts +10 -48
- package/dist/structures/LazyCanvas.js +17 -78
- package/dist/structures/components/BaseLayer.d.ts +78 -32
- package/dist/structures/components/BaseLayer.js +106 -37
- package/dist/structures/components/BezierLayer.d.ts +25 -38
- package/dist/structures/components/BezierLayer.js +88 -53
- package/dist/structures/components/{Group.d.ts → Div.d.ts} +37 -18
- package/dist/structures/components/Div.js +202 -0
- package/dist/structures/components/ImageLayer.d.ts +1 -1
- package/dist/structures/components/ImageLayer.js +28 -29
- package/dist/structures/components/LineLayer.d.ts +18 -36
- package/dist/structures/components/LineLayer.js +43 -45
- package/dist/structures/components/MorphLayer.d.ts +4 -33
- package/dist/structures/components/MorphLayer.js +37 -51
- package/dist/structures/components/Path2DLayer.d.ts +7 -35
- package/dist/structures/components/Path2DLayer.js +32 -41
- package/dist/structures/components/PolygonLayer.d.ts +3 -32
- package/dist/structures/components/PolygonLayer.js +37 -42
- package/dist/structures/components/QuadraticLayer.d.ts +25 -34
- package/dist/structures/components/QuadraticLayer.js +83 -47
- package/dist/structures/components/TextLayer.d.ts +5 -34
- package/dist/structures/components/TextLayer.js +88 -71
- package/dist/structures/components/index.d.ts +10 -11
- package/dist/structures/components/index.js +1 -2
- package/dist/structures/helpers/Exporter.d.ts +13 -4
- package/dist/structures/helpers/Exporter.js +82 -46
- package/dist/structures/helpers/Font.js +1 -17
- package/dist/structures/helpers/Gradient.js +35 -49
- package/dist/structures/helpers/Link.js +2 -14
- package/dist/structures/helpers/Pattern.js +10 -18
- package/dist/structures/helpers/index.d.ts +7 -7
- package/dist/structures/helpers/readers/JSONReader.d.ts +4 -4
- package/dist/structures/helpers/readers/JSONReader.js +44 -48
- package/dist/structures/helpers/readers/YAMLReader.js +11 -11
- package/dist/structures/managers/FontsManager.js +9 -18
- package/dist/structures/managers/LayersManager.d.ts +18 -28
- package/dist/structures/managers/LayersManager.js +14 -36
- package/dist/structures/managers/LayoutManager.d.ts +23 -0
- package/dist/structures/managers/LayoutManager.js +409 -0
- package/dist/structures/managers/index.d.ts +3 -5
- package/dist/structures/managers/index.js +1 -3
- package/dist/structures/managers/{RenderManager.d.ts → piplines/ClassicRenderPipeline.d.ts} +4 -30
- package/dist/structures/managers/piplines/ClassicRenderPipeline.js +90 -0
- package/dist/structures/managers/piplines/ModernRenderPipeline.d.ts +44 -0
- package/dist/structures/managers/piplines/ModernRenderPipeline.js +123 -0
- package/dist/structures/managers/piplines/index.d.ts +24 -0
- package/dist/structures/managers/piplines/index.js +18 -0
- package/dist/types/enum.d.ts +1 -2
- package/dist/types/enum.js +1 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types.d.ts +257 -107
- package/dist/utils/APNGEncoder.d.ts +67 -0
- package/dist/utils/APNGEncoder.js +205 -0
- package/dist/utils/DrawUtils.d.ts +9 -0
- package/dist/utils/DrawUtils.js +42 -0
- package/dist/utils/LazyUtil.js +1 -2
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +20 -0
- package/dist/utils/utils.d.ts +4 -7
- package/dist/utils/utils.js +140 -78
- package/package.json +61 -59
- package/dist/structures/components/ClearLayer.d.ts +0 -147
- package/dist/structures/components/ClearLayer.js +0 -158
- package/dist/structures/components/Group.js +0 -153
- package/dist/structures/managers/AnimationManager.d.ts +0 -120
- package/dist/structures/managers/AnimationManager.js +0 -99
- package/dist/structures/managers/PluginManager.d.ts +0 -230
- package/dist/structures/managers/PluginManager.js +0 -182
- package/dist/structures/managers/RenderManager.js +0 -183
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModernRenderPipeline = void 0;
|
|
4
|
+
const types_1 = require("../../../types");
|
|
5
|
+
const components_1 = require("../../components");
|
|
6
|
+
const LazyUtil_1 = require("../../../utils/LazyUtil");
|
|
7
|
+
/**
|
|
8
|
+
* Class responsible for managing rendering operations, including static and animated exports.
|
|
9
|
+
*/
|
|
10
|
+
class ModernRenderPipeline {
|
|
11
|
+
/**
|
|
12
|
+
* Constructs a new RenderManager instance.
|
|
13
|
+
* @param {LazyCanvas} [lazyCanvas] - The LazyCanvas instance to use for rendering.
|
|
14
|
+
* @param {Object} [opts] - Optional settings for the RenderManager.
|
|
15
|
+
* @param {boolean} [opts.debug] - Whether debugging is enabled.
|
|
16
|
+
*/
|
|
17
|
+
constructor(lazyCanvas, opts) {
|
|
18
|
+
this.lazyCanvas = lazyCanvas;
|
|
19
|
+
this.debug = opts?.debug || false;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Renders a single layer or group of layers.
|
|
23
|
+
* @param {AnyLayer | Div} [layer] - The layer or group to render.
|
|
24
|
+
* @returns {Promise<SKRSContext2D>} The canvas rendering context after rendering.
|
|
25
|
+
*/
|
|
26
|
+
async renderLayer(layer) {
|
|
27
|
+
if (this.debug)
|
|
28
|
+
LazyUtil_1.LazyLog.log("info", `Rendering ${layer.id}...\nData:`, layer.toJSON());
|
|
29
|
+
if (layer.visible) {
|
|
30
|
+
this.lazyCanvas.ctx.globalCompositeOperation = layer.props?.globalComposite || "source-over";
|
|
31
|
+
await layer.draw(this.lazyCanvas.ctx, this.lazyCanvas.canvas, this.lazyCanvas.manager.layers, this.debug);
|
|
32
|
+
// Draw children if any (and not a Div, as Div handles its own children)
|
|
33
|
+
// Actually, if we want to support children on any layer, we should handle it here.
|
|
34
|
+
// But Div.draw already handles children.
|
|
35
|
+
// If we handle it here for Div, we get double rendering.
|
|
36
|
+
// So we skip Div.
|
|
37
|
+
const children = layer.children;
|
|
38
|
+
if (!(layer instanceof components_1.Div) && children && Array.isArray(children) && children.length > 0) {
|
|
39
|
+
const ctx = this.lazyCanvas.ctx;
|
|
40
|
+
ctx.save();
|
|
41
|
+
// Apply parent position offset
|
|
42
|
+
// LayoutManager sets position relative to parent.
|
|
43
|
+
// We need to translate context to parent's position so children are drawn relative to it.
|
|
44
|
+
// However, layer.draw() might have already drawn the layer at that position.
|
|
45
|
+
// And layer.draw() usually restores context.
|
|
46
|
+
// So we are back at parent's parent coordinate system.
|
|
47
|
+
// We need to translate to layer's position.
|
|
48
|
+
if (layer.props.position) {
|
|
49
|
+
const x = typeof layer.props.position.x === "number" ? layer.props.position.x : 0;
|
|
50
|
+
const y = typeof layer.props.position.y === "number" ? layer.props.position.y : 0;
|
|
51
|
+
ctx.translate(x, y);
|
|
52
|
+
}
|
|
53
|
+
for (const child of children) {
|
|
54
|
+
await this.renderLayer(child);
|
|
55
|
+
}
|
|
56
|
+
ctx.restore();
|
|
57
|
+
}
|
|
58
|
+
this.lazyCanvas.ctx.shadowColor = "transparent";
|
|
59
|
+
}
|
|
60
|
+
return this.lazyCanvas.ctx;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Renders all layers statically and exports the result in the specified format.
|
|
64
|
+
* @param {AnyExport} [exportType] - The export format (e.g., buffer, SVG, or context).
|
|
65
|
+
* @returns {Promise<Buffer | SKRSContext2D | string>} The rendered output in the specified format.
|
|
66
|
+
*/
|
|
67
|
+
async renderStatic(exportType) {
|
|
68
|
+
if (this.debug)
|
|
69
|
+
LazyUtil_1.LazyLog.log("info", `Rendering static...`);
|
|
70
|
+
// Wait for layout engine to be ready
|
|
71
|
+
await this.lazyCanvas.manager.layout.ready;
|
|
72
|
+
const rootLayers = this.lazyCanvas.manager.layers.toArray().filter((l) => !l.parent);
|
|
73
|
+
for (const layer of rootLayers) {
|
|
74
|
+
this.lazyCanvas.manager.layout.calculateLayout(layer, this.lazyCanvas.options.width, this.lazyCanvas.options.height, this.lazyCanvas.ctx, this.lazyCanvas.canvas);
|
|
75
|
+
}
|
|
76
|
+
for (const layer of rootLayers) {
|
|
77
|
+
await this.renderLayer(layer);
|
|
78
|
+
}
|
|
79
|
+
switch (exportType) {
|
|
80
|
+
case types_1.Export.BUFFER:
|
|
81
|
+
case "buffer":
|
|
82
|
+
case types_1.Export.SVG:
|
|
83
|
+
case "svg":
|
|
84
|
+
if ("getContent" in this.lazyCanvas.canvas) {
|
|
85
|
+
return this.lazyCanvas.canvas.getContent().toString("utf8");
|
|
86
|
+
}
|
|
87
|
+
return this.lazyCanvas.canvas.toBuffer("image/png");
|
|
88
|
+
case types_1.Export.CTX:
|
|
89
|
+
case "ctx":
|
|
90
|
+
return this.lazyCanvas.ctx;
|
|
91
|
+
default:
|
|
92
|
+
if ("getContent" in this.lazyCanvas.canvas) {
|
|
93
|
+
return this.lazyCanvas.canvas.getContent().toString("utf8");
|
|
94
|
+
}
|
|
95
|
+
return this.lazyCanvas.canvas.toBuffer("image/png");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Renders all layers and exports the result in the specified format.
|
|
100
|
+
* @param {AnyExport} [format] - The export format (e.g., buffer, context, SVG, or canvas).
|
|
101
|
+
* @returns {Promise<Buffer | SKRSContext2D | Canvas | SvgCanvas | string>} The rendered output in the specified format.
|
|
102
|
+
*/
|
|
103
|
+
async render(format) {
|
|
104
|
+
switch (format) {
|
|
105
|
+
case types_1.Export.BUFFER:
|
|
106
|
+
case "buffer":
|
|
107
|
+
return await this.renderStatic(types_1.Export.BUFFER);
|
|
108
|
+
case types_1.Export.CTX:
|
|
109
|
+
case "ctx":
|
|
110
|
+
return await this.renderStatic(types_1.Export.CTX);
|
|
111
|
+
case types_1.Export.SVG:
|
|
112
|
+
case "svg":
|
|
113
|
+
return await this.renderStatic(types_1.Export.SVG);
|
|
114
|
+
case types_1.Export.CANVAS:
|
|
115
|
+
case "canvas":
|
|
116
|
+
await this.renderStatic(this.lazyCanvas.options.exportType === "svg" ? types_1.Export.SVG : types_1.Export.BUFFER);
|
|
117
|
+
return this.lazyCanvas.canvas;
|
|
118
|
+
default:
|
|
119
|
+
return await this.renderStatic(types_1.Export.BUFFER);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.ModernRenderPipeline = ModernRenderPipeline;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { LazyCanvas } from "../../LazyCanvas";
|
|
2
|
+
import { AnyExport } from "../../../types";
|
|
3
|
+
import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
|
|
4
|
+
/**
|
|
5
|
+
* Interface representing the RenderManager.
|
|
6
|
+
*/
|
|
7
|
+
export interface IRenderManager {
|
|
8
|
+
/**
|
|
9
|
+
* The LazyCanvas instance used for rendering.
|
|
10
|
+
*/
|
|
11
|
+
lazyCanvas: LazyCanvas;
|
|
12
|
+
/**
|
|
13
|
+
* Whether debugging is enabled.
|
|
14
|
+
*/
|
|
15
|
+
debug: boolean;
|
|
16
|
+
render(format: AnyExport): Promise<Buffer | SKRSContext2D | Canvas | SvgCanvas | string>;
|
|
17
|
+
}
|
|
18
|
+
export interface RenderManagerConstructor {
|
|
19
|
+
new (lazyCanvas: LazyCanvas, opts?: {
|
|
20
|
+
debug?: boolean;
|
|
21
|
+
}): IRenderManager;
|
|
22
|
+
}
|
|
23
|
+
export * from "./ClassicRenderPipeline";
|
|
24
|
+
export * from "./ModernRenderPipeline";
|
|
@@ -0,0 +1,18 @@
|
|
|
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("./ClassicRenderPipeline"), exports);
|
|
18
|
+
__exportStar(require("./ModernRenderPipeline"), exports);
|
package/dist/types/enum.d.ts
CHANGED
package/dist/types/enum.js
CHANGED
|
@@ -86,10 +86,9 @@ var Export;
|
|
|
86
86
|
Export["CTX"] = "ctx";
|
|
87
87
|
Export["BUFFER"] = "buffer";
|
|
88
88
|
Export["PNG"] = "png";
|
|
89
|
-
Export["
|
|
89
|
+
Export["APNG"] = "apng";
|
|
90
90
|
Export["JPG"] = "jpg";
|
|
91
91
|
Export["SVG"] = "svg";
|
|
92
|
-
Export["GIF"] = "gif";
|
|
93
92
|
Export["WEBP"] = "webp";
|
|
94
93
|
Export["YAML"] = "yaml";
|
|
95
94
|
Export["JSON"] = "json";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export type * from "./types";
|
|
2
|
-
export * from
|
|
2
|
+
export * from "./enum";
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,107 +1,257 @@
|
|
|
1
|
-
import { Gradient, Link, Pattern } from "../structures/helpers";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
export type
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
export type
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
export type
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
export
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
1
|
+
import { Gradient, Link, Pattern } from "../structures/helpers";
|
|
2
|
+
import {
|
|
3
|
+
MorphLayer,
|
|
4
|
+
ImageLayer,
|
|
5
|
+
TextLayer,
|
|
6
|
+
BezierLayer,
|
|
7
|
+
QuadraticLayer,
|
|
8
|
+
LineLayer,
|
|
9
|
+
Path2DLayer,
|
|
10
|
+
IMorphLayer,
|
|
11
|
+
IBezierLayer,
|
|
12
|
+
IImageLayer,
|
|
13
|
+
ITextLayer,
|
|
14
|
+
IQuadraticLayer,
|
|
15
|
+
ILineLayer,
|
|
16
|
+
IPath2DLayer,
|
|
17
|
+
IPolygonLayer,
|
|
18
|
+
PolygonLayer,
|
|
19
|
+
} from "../structures/components";
|
|
20
|
+
import {
|
|
21
|
+
FontWeight,
|
|
22
|
+
GradientType,
|
|
23
|
+
TextAlign,
|
|
24
|
+
TextBaseline,
|
|
25
|
+
TextDirection,
|
|
26
|
+
LineCap,
|
|
27
|
+
LineJoin,
|
|
28
|
+
Export,
|
|
29
|
+
Centring,
|
|
30
|
+
PatternType,
|
|
31
|
+
LinkType,
|
|
32
|
+
GlobalCompositeOperation,
|
|
33
|
+
ColorSpace,
|
|
34
|
+
} from "./enum";
|
|
35
|
+
import {
|
|
36
|
+
Signal,
|
|
37
|
+
ThreadGenerator,
|
|
38
|
+
SignalOptions,
|
|
39
|
+
TweenConfig,
|
|
40
|
+
unwrap,
|
|
41
|
+
isSignal,
|
|
42
|
+
} from "../core/Signal";
|
|
43
|
+
|
|
44
|
+
// Utility type for signal-enabled values
|
|
45
|
+
export type Signalable<T> = T | Signal<T>;
|
|
46
|
+
|
|
47
|
+
// Re-export for convenience
|
|
48
|
+
export type { ThreadGenerator, SignalOptions, TweenConfig };
|
|
49
|
+
export { unwrap, isSignal };
|
|
50
|
+
|
|
51
|
+
// Core types with Signal support
|
|
52
|
+
export type ScaleType =
|
|
53
|
+
| `link-w-${string}-${number}`
|
|
54
|
+
| `link-h-${string}-${number}`
|
|
55
|
+
| `link-x-${string}-${number}`
|
|
56
|
+
| `link-y-${string}-${number}`
|
|
57
|
+
| `${number}%`
|
|
58
|
+
| `${number}px`
|
|
59
|
+
| number
|
|
60
|
+
| "vw"
|
|
61
|
+
| "vh"
|
|
62
|
+
| "vmin"
|
|
63
|
+
| "vmax"
|
|
64
|
+
| Link
|
|
65
|
+
| Signal<number>;
|
|
66
|
+
|
|
67
|
+
export type StringColorType =
|
|
68
|
+
| `rgba(${number}, ${number}, ${number}, ${number})`
|
|
69
|
+
| `rgb(${number}, ${number}, ${number})`
|
|
70
|
+
| `hsl(${number}, ${number}%, ${number}%)`
|
|
71
|
+
| `hsla(${number}, ${number}%, ${number}%, ${number})`
|
|
72
|
+
| `#${string}`
|
|
73
|
+
| string
|
|
74
|
+
| Signal<string>;
|
|
75
|
+
|
|
76
|
+
export type ColorType = Gradient | Pattern | StringColorType;
|
|
77
|
+
|
|
78
|
+
export type JSONLayer =
|
|
79
|
+
| IMorphLayer
|
|
80
|
+
| IImageLayer
|
|
81
|
+
| ITextLayer
|
|
82
|
+
| IBezierLayer
|
|
83
|
+
| IQuadraticLayer
|
|
84
|
+
| ILineLayer
|
|
85
|
+
| IPath2DLayer
|
|
86
|
+
| IPolygonLayer;
|
|
87
|
+
|
|
88
|
+
export type AnyLayer =
|
|
89
|
+
| MorphLayer
|
|
90
|
+
| ImageLayer
|
|
91
|
+
| TextLayer
|
|
92
|
+
| BezierLayer
|
|
93
|
+
| QuadraticLayer
|
|
94
|
+
| LineLayer
|
|
95
|
+
| Path2DLayer
|
|
96
|
+
| PolygonLayer;
|
|
97
|
+
|
|
98
|
+
export type AnyWeight = FontWeight | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
|
|
99
|
+
|
|
100
|
+
export type AnyGradientType = GradientType | "linear" | "radial" | "conic";
|
|
101
|
+
|
|
102
|
+
export type AnyTextAlign = TextAlign | "left" | "right" | "center" | "start" | "end";
|
|
103
|
+
|
|
104
|
+
export type AnyTextBaseline =
|
|
105
|
+
| TextBaseline
|
|
106
|
+
| "top"
|
|
107
|
+
| "hanging"
|
|
108
|
+
| "middle"
|
|
109
|
+
| "alphabetic"
|
|
110
|
+
| "ideographic"
|
|
111
|
+
| "bottom";
|
|
112
|
+
|
|
113
|
+
export type AnyTextDirection = TextDirection | "ltr" | "rtl" | "inherit";
|
|
114
|
+
|
|
115
|
+
export type AnyLineCap = LineCap | "butt" | "round" | "square";
|
|
116
|
+
|
|
117
|
+
export type AnyLineJoin = LineJoin | "bevel" | "round" | "miter";
|
|
118
|
+
|
|
119
|
+
export type AnyExport =
|
|
120
|
+
| Export
|
|
121
|
+
| "canvas"
|
|
122
|
+
| "ctx"
|
|
123
|
+
| "buffer"
|
|
124
|
+
| "svg"
|
|
125
|
+
| "png"
|
|
126
|
+
| "apng"
|
|
127
|
+
| "jpg"
|
|
128
|
+
| "webp"
|
|
129
|
+
| "yaml"
|
|
130
|
+
| "json";
|
|
131
|
+
|
|
132
|
+
export type AnyCentring =
|
|
133
|
+
| Centring
|
|
134
|
+
| "start"
|
|
135
|
+
| "start-top"
|
|
136
|
+
| "start-bottom"
|
|
137
|
+
| "center"
|
|
138
|
+
| "center-top"
|
|
139
|
+
| "center-bottom"
|
|
140
|
+
| "end"
|
|
141
|
+
| "end-top"
|
|
142
|
+
| "end-bottom"
|
|
143
|
+
| "none";
|
|
144
|
+
|
|
145
|
+
export type AnyPatternType = PatternType | "repeat" | "repeat-x" | "repeat-y" | "no-repeat";
|
|
146
|
+
|
|
147
|
+
export type AnyLinkType = LinkType | "width" | "height" | "x" | "y";
|
|
148
|
+
|
|
149
|
+
export type AnyGlobalCompositeOperation =
|
|
150
|
+
| GlobalCompositeOperation
|
|
151
|
+
| "source-over"
|
|
152
|
+
| "source-in"
|
|
153
|
+
| "source-out"
|
|
154
|
+
| "source-atop"
|
|
155
|
+
| "destination-over"
|
|
156
|
+
| "destination-in"
|
|
157
|
+
| "destination-out"
|
|
158
|
+
| "destination-atop"
|
|
159
|
+
| "lighter"
|
|
160
|
+
| "copy"
|
|
161
|
+
| "xor"
|
|
162
|
+
| "multiply"
|
|
163
|
+
| "screen"
|
|
164
|
+
| "overlay"
|
|
165
|
+
| "darken"
|
|
166
|
+
| "lighten"
|
|
167
|
+
| "color-dodge"
|
|
168
|
+
| "color-burn"
|
|
169
|
+
| "hard-light"
|
|
170
|
+
| "soft-light"
|
|
171
|
+
| "difference"
|
|
172
|
+
| "exclusion"
|
|
173
|
+
| "hue"
|
|
174
|
+
| "saturation"
|
|
175
|
+
| "color"
|
|
176
|
+
| "luminosity";
|
|
177
|
+
|
|
178
|
+
export type AnyColorSpace = ColorSpace | "rgb565" | "rgba4444" | "rgba444";
|
|
179
|
+
|
|
180
|
+
export type AnyFilter =
|
|
181
|
+
| `sepia(${number}%)`
|
|
182
|
+
| `saturate(${number}%)`
|
|
183
|
+
| `opacity(${number}%)`
|
|
184
|
+
| `invert(${number}%)`
|
|
185
|
+
| `hue-rotate(${number}deg)`
|
|
186
|
+
| `grayscale(${number}%)`
|
|
187
|
+
| `drop-shadow(${number}px ${number}px ${number}px ${string})`
|
|
188
|
+
| `contrast(${number}%)`
|
|
189
|
+
| `brightness(${number}%)`
|
|
190
|
+
| `blur(${number}px)`;
|
|
191
|
+
|
|
192
|
+
export type Point = {
|
|
193
|
+
x: ScaleType;
|
|
194
|
+
y: ScaleType;
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
export type PointNumber = {
|
|
198
|
+
x: number;
|
|
199
|
+
y: number;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export type Extensions = "svg" | "png" | "jpeg" | "jpg" | "gif" | "webp" | "yaml" | "json";
|
|
203
|
+
|
|
204
|
+
export interface Transform {
|
|
205
|
+
rotate?: number;
|
|
206
|
+
scale?: {
|
|
207
|
+
x: number;
|
|
208
|
+
y: number;
|
|
209
|
+
};
|
|
210
|
+
translate?: {
|
|
211
|
+
x: number;
|
|
212
|
+
y: number;
|
|
213
|
+
};
|
|
214
|
+
matrix?: DOMMatrix2DInit;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export type RadiusCorner = "leftTop" | "leftBottom" | "rightTop" | "rightBottom" | "all";
|
|
218
|
+
|
|
219
|
+
export type SubStringColor = {
|
|
220
|
+
color: StringColorType;
|
|
221
|
+
start: number;
|
|
222
|
+
end: number;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
export type StrokeOptions = {
|
|
226
|
+
width: number;
|
|
227
|
+
cap?: CanvasLineCap;
|
|
228
|
+
join?: CanvasLineJoin;
|
|
229
|
+
dashOffset?: number;
|
|
230
|
+
dash?: number[];
|
|
231
|
+
miterLimit?: number;
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
export interface ILayoutProps {
|
|
235
|
+
width?: ScaleType;
|
|
236
|
+
height?: ScaleType;
|
|
237
|
+
flexDirection?: "row" | "column" | "row-reverse" | "column-reverse";
|
|
238
|
+
justifyContent?:
|
|
239
|
+
| "flex-start"
|
|
240
|
+
| "center"
|
|
241
|
+
| "flex-end"
|
|
242
|
+
| "space-between"
|
|
243
|
+
| "space-around"
|
|
244
|
+
| "space-evenly";
|
|
245
|
+
alignItems?: "flex-start" | "center" | "flex-end" | "stretch" | "baseline";
|
|
246
|
+
flexGrow?: number;
|
|
247
|
+
flexShrink?: number;
|
|
248
|
+
flexBasis?: number | string;
|
|
249
|
+
padding?: number | number[];
|
|
250
|
+
margin?: number | number[];
|
|
251
|
+
gap?: number;
|
|
252
|
+
position?: "absolute" | "relative";
|
|
253
|
+
top?: number | string;
|
|
254
|
+
left?: number | string;
|
|
255
|
+
right?: number | string;
|
|
256
|
+
bottom?: number | string;
|
|
257
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* APNG Encoder that works directly with Uint8ClampedArray (ImageData)
|
|
3
|
+
* Much faster than encoding each frame to PNG separately
|
|
4
|
+
*/
|
|
5
|
+
export declare class APNGEncoder {
|
|
6
|
+
private frames;
|
|
7
|
+
private width;
|
|
8
|
+
private height;
|
|
9
|
+
private fps;
|
|
10
|
+
constructor(width: number, height: number, fps?: number);
|
|
11
|
+
/**
|
|
12
|
+
* Add a frame from ImageData
|
|
13
|
+
*/
|
|
14
|
+
addFrame(imageData: Uint8ClampedArray): this;
|
|
15
|
+
addFrames(...imageDatas: Uint8ClampedArray[]): this;
|
|
16
|
+
/**
|
|
17
|
+
* Encode all frames to APNG buffer
|
|
18
|
+
*/
|
|
19
|
+
encode(): Buffer;
|
|
20
|
+
/**
|
|
21
|
+
* Create IHDR chunk (image header)
|
|
22
|
+
*/
|
|
23
|
+
private createIHDR;
|
|
24
|
+
/**
|
|
25
|
+
* Create acTL chunk (animation control)
|
|
26
|
+
*/
|
|
27
|
+
private createACTL;
|
|
28
|
+
/**
|
|
29
|
+
* Create frame chunks (fcTL + fdAT or IDAT)
|
|
30
|
+
* @param frameIndex - Index of the frame (0-based)
|
|
31
|
+
* @param sequenceNumber - Global sequence number for fcTL/fdAT chunks
|
|
32
|
+
*/
|
|
33
|
+
private createFrame;
|
|
34
|
+
/**
|
|
35
|
+
* Compress ImageData using PNG filter and zlib
|
|
36
|
+
*/
|
|
37
|
+
private compressImageData;
|
|
38
|
+
/**
|
|
39
|
+
* Create IEND chunk
|
|
40
|
+
*/
|
|
41
|
+
private createIEND;
|
|
42
|
+
/**
|
|
43
|
+
* Create a PNG chunk with length, type, data, and CRC
|
|
44
|
+
*/
|
|
45
|
+
private createChunk;
|
|
46
|
+
/**
|
|
47
|
+
* Calculate CRC32 checksum
|
|
48
|
+
*/
|
|
49
|
+
private crc32;
|
|
50
|
+
/**
|
|
51
|
+
* CRC32 lookup table
|
|
52
|
+
*/
|
|
53
|
+
private crcTable;
|
|
54
|
+
/**
|
|
55
|
+
* Get number of frames
|
|
56
|
+
*/
|
|
57
|
+
getFrameCount(): number;
|
|
58
|
+
/**
|
|
59
|
+
* Clear all frames
|
|
60
|
+
*/
|
|
61
|
+
clear(): void;
|
|
62
|
+
}
|
|
63
|
+
export default APNGEncoder;
|
|
64
|
+
/**
|
|
65
|
+
* Helper function to create APNG from ImageData array
|
|
66
|
+
*/
|
|
67
|
+
export declare function createAPNG(frames: Uint8ClampedArray[], width: number, height: number, fps?: number): Buffer;
|