@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.
Files changed (91) hide show
  1. package/ReadMe.md +1 -1
  2. package/dist/core/Interpolation.d.ts +30 -0
  3. package/dist/core/Interpolation.js +200 -0
  4. package/dist/core/Scene.d.ts +94 -0
  5. package/dist/core/Scene.js +157 -0
  6. package/dist/core/Signal.d.ts +133 -0
  7. package/dist/core/Signal.js +255 -0
  8. package/dist/core/SignalUtils.d.ts +133 -0
  9. package/dist/core/SignalUtils.js +333 -0
  10. package/dist/core/ThreadScheduler.d.ts +38 -0
  11. package/dist/core/ThreadScheduler.js +74 -0
  12. package/dist/core/index.d.ts +5 -0
  13. package/dist/core/index.js +21 -0
  14. package/dist/helpers/Filters.js +1 -1
  15. package/dist/helpers/FontsList.js +18 -18
  16. package/dist/helpers/Utlis.d.ts +3 -3
  17. package/dist/helpers/Utlis.js +25 -36
  18. package/dist/helpers/index.d.ts +3 -3
  19. package/dist/index.d.ts +4 -1
  20. package/dist/index.js +4 -1
  21. package/dist/jsx-runtime.d.ts +17 -0
  22. package/dist/jsx-runtime.js +111 -0
  23. package/dist/structures/LazyCanvas.d.ts +10 -48
  24. package/dist/structures/LazyCanvas.js +17 -78
  25. package/dist/structures/components/BaseLayer.d.ts +78 -32
  26. package/dist/structures/components/BaseLayer.js +106 -37
  27. package/dist/structures/components/BezierLayer.d.ts +25 -38
  28. package/dist/structures/components/BezierLayer.js +88 -53
  29. package/dist/structures/components/{Group.d.ts → Div.d.ts} +37 -18
  30. package/dist/structures/components/Div.js +202 -0
  31. package/dist/structures/components/ImageLayer.d.ts +1 -1
  32. package/dist/structures/components/ImageLayer.js +28 -29
  33. package/dist/structures/components/LineLayer.d.ts +18 -36
  34. package/dist/structures/components/LineLayer.js +43 -45
  35. package/dist/structures/components/MorphLayer.d.ts +4 -33
  36. package/dist/structures/components/MorphLayer.js +37 -51
  37. package/dist/structures/components/Path2DLayer.d.ts +7 -35
  38. package/dist/structures/components/Path2DLayer.js +32 -41
  39. package/dist/structures/components/PolygonLayer.d.ts +3 -32
  40. package/dist/structures/components/PolygonLayer.js +37 -42
  41. package/dist/structures/components/QuadraticLayer.d.ts +25 -34
  42. package/dist/structures/components/QuadraticLayer.js +83 -47
  43. package/dist/structures/components/TextLayer.d.ts +5 -34
  44. package/dist/structures/components/TextLayer.js +88 -71
  45. package/dist/structures/components/index.d.ts +10 -11
  46. package/dist/structures/components/index.js +1 -2
  47. package/dist/structures/helpers/Exporter.d.ts +13 -4
  48. package/dist/structures/helpers/Exporter.js +82 -46
  49. package/dist/structures/helpers/Font.js +1 -17
  50. package/dist/structures/helpers/Gradient.js +35 -49
  51. package/dist/structures/helpers/Link.js +2 -14
  52. package/dist/structures/helpers/Pattern.js +10 -18
  53. package/dist/structures/helpers/index.d.ts +7 -7
  54. package/dist/structures/helpers/readers/JSONReader.d.ts +4 -4
  55. package/dist/structures/helpers/readers/JSONReader.js +44 -48
  56. package/dist/structures/helpers/readers/YAMLReader.js +11 -11
  57. package/dist/structures/managers/FontsManager.js +9 -18
  58. package/dist/structures/managers/LayersManager.d.ts +18 -28
  59. package/dist/structures/managers/LayersManager.js +14 -36
  60. package/dist/structures/managers/LayoutManager.d.ts +23 -0
  61. package/dist/structures/managers/LayoutManager.js +409 -0
  62. package/dist/structures/managers/index.d.ts +3 -5
  63. package/dist/structures/managers/index.js +1 -3
  64. package/dist/structures/managers/{RenderManager.d.ts → piplines/ClassicRenderPipeline.d.ts} +4 -30
  65. package/dist/structures/managers/piplines/ClassicRenderPipeline.js +90 -0
  66. package/dist/structures/managers/piplines/ModernRenderPipeline.d.ts +44 -0
  67. package/dist/structures/managers/piplines/ModernRenderPipeline.js +123 -0
  68. package/dist/structures/managers/piplines/index.d.ts +24 -0
  69. package/dist/structures/managers/piplines/index.js +18 -0
  70. package/dist/types/enum.d.ts +1 -2
  71. package/dist/types/enum.js +1 -2
  72. package/dist/types/index.d.ts +1 -1
  73. package/dist/types/types.d.ts +257 -107
  74. package/dist/utils/APNGEncoder.d.ts +67 -0
  75. package/dist/utils/APNGEncoder.js +205 -0
  76. package/dist/utils/DrawUtils.d.ts +9 -0
  77. package/dist/utils/DrawUtils.js +42 -0
  78. package/dist/utils/LazyUtil.js +1 -2
  79. package/dist/utils/index.d.ts +4 -0
  80. package/dist/utils/index.js +20 -0
  81. package/dist/utils/utils.d.ts +4 -7
  82. package/dist/utils/utils.js +140 -78
  83. package/package.json +61 -59
  84. package/dist/structures/components/ClearLayer.d.ts +0 -147
  85. package/dist/structures/components/ClearLayer.js +0 -158
  86. package/dist/structures/components/Group.js +0 -153
  87. package/dist/structures/managers/AnimationManager.d.ts +0 -120
  88. package/dist/structures/managers/AnimationManager.js +0 -99
  89. package/dist/structures/managers/PluginManager.d.ts +0 -230
  90. package/dist/structures/managers/PluginManager.js +0 -182
  91. 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);
@@ -73,10 +73,9 @@ export declare enum Export {
73
73
  CTX = "ctx",
74
74
  BUFFER = "buffer",
75
75
  PNG = "png",
76
- JPEG = "jpeg",
76
+ APNG = "apng",
77
77
  JPG = "jpg",
78
78
  SVG = "svg",
79
- GIF = "gif",
80
79
  WEBP = "webp",
81
80
  YAML = "yaml",
82
81
  JSON = "json"
@@ -86,10 +86,9 @@ var Export;
86
86
  Export["CTX"] = "ctx";
87
87
  Export["BUFFER"] = "buffer";
88
88
  Export["PNG"] = "png";
89
- Export["JPEG"] = "jpeg";
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";
@@ -1,2 +1,2 @@
1
1
  export type * from "./types";
2
- export * from './enum';
2
+ export * from "./enum";
@@ -1,107 +1,257 @@
1
- import { Gradient, Link, Pattern } from "../structures/helpers";
2
- import {
3
- MorphLayer,
4
- ImageLayer,
5
- TextLayer,
6
- BezierLayer,
7
- QuadraticLayer,
8
- LineLayer,
9
- ClearLayer,
10
- Path2DLayer,
11
- IMorphLayer,
12
- IBezierLayer,
13
- IClearLayer,
14
- IImageLayer,
15
- ITextLayer,
16
- IQuadraticLayer,
17
- ILineLayer,
18
- IPath2DLayer,
19
- IPolygonLayer,
20
- PolygonLayer
21
- } from "../structures/components";
22
- import {
23
- FontWeight,
24
- GradientType,
25
- TextAlign,
26
- TextBaseline,
27
- TextDirection,
28
- LineCap,
29
- LineJoin,
30
- Export,
31
- Centring,
32
- PatternType,
33
- LinkType,
34
- GlobalCompositeOperation,
35
- ColorSpace,
36
- } from "./enum";
37
-
38
- export type ScaleType = `link-w-${string}-${number}` | `link-h-${string}-${number}` | `link-x-${string}-${number}` | `link-y-${string}-${number}` | `${number}%` | `${number}px` | number | 'vw' | 'vh' | 'vmin' | 'vmax' | Link;
39
-
40
- export type StringColorType = `rgba(${number}, ${number}, ${number}, ${number})` | `rgb(${number}, ${number}, ${number})` | `hsl(${number}, ${number}%, ${number}%)` | `hsla(${number}, ${number}%, ${number}%, ${number})` | `#${string}` | string;
41
-
42
- export type ColorType = Gradient | Pattern | StringColorType;
43
-
44
- export type JSONLayer = IMorphLayer | IImageLayer | ITextLayer | IBezierLayer | IQuadraticLayer | ILineLayer | IClearLayer | IPath2DLayer | IPolygonLayer;
45
-
46
- export type AnyLayer = MorphLayer | ImageLayer | TextLayer | BezierLayer | QuadraticLayer | LineLayer | ClearLayer | Path2DLayer | PolygonLayer;
47
-
48
- export type AnyWeight = FontWeight | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
49
-
50
- export type AnyGradientType = GradientType | 'linear' | 'radial' | 'conic';
51
-
52
- export type AnyTextAlign = TextAlign | 'left' | 'right' | 'center' | 'start' | 'end';
53
-
54
- export type AnyTextBaseline = TextBaseline | 'top' | 'hanging' | 'middle' | 'alphabetic' | 'ideographic' | 'bottom';
55
-
56
- export type AnyTextDirection = TextDirection | 'ltr' | 'rtl' | 'inherit';
57
-
58
- export type AnyLineCap = LineCap | 'butt' | 'round' | 'square';
59
-
60
- export type AnyLineJoin = LineJoin | 'bevel' | 'round' | 'miter';
61
-
62
- export type AnyExport = Export | 'canvas' | 'ctx' | 'buffer' | 'svg' | 'png' | 'jpeg' | 'jpg' | 'gif' | 'webp' | 'yaml' | 'json';
63
-
64
- export type AnyCentring = Centring | 'start' | 'start-top' | 'start-bottom' | 'center' | 'center-top' | 'center-bottom' | 'end' | 'end-top' | 'end-bottom' | 'none';
65
-
66
- export type AnyPatternType = PatternType | 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
67
-
68
- export type AnyLinkType = LinkType | 'width' | 'height' | 'x' | 'y';
69
-
70
- export type AnyGlobalCompositeOperation = GlobalCompositeOperation | 'source-over' | 'source-in' | 'source-out' | 'source-atop' | 'destination-over' | 'destination-in' | 'destination-out' | 'destination-atop' | 'lighter' | 'copy' | 'xor' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity';
71
-
72
- export type AnyColorSpace = ColorSpace | 'rgb565' | 'rgba4444' | 'rgba444';
73
-
74
- export type AnyFilter = `sepia(${number}%)` | `saturate(${number}%)` | `opacity(${number}%)` | `invert(${number}%)` | `hue-rotate(${number}deg)` | `grayscale(${number}%)` | `drop-shadow(${number}px ${number}px ${number}px ${string})` | `contrast(${number}%)` | `brightness(${number}%)` | `blur(${number}px)`;
75
-
76
- export type Point = {
77
- x: ScaleType;
78
- y: ScaleType;
79
- }
80
-
81
- export type PointNumber = {
82
- x: number;
83
- y: number;
84
- };
85
-
86
- export type Extensions = 'svg' | 'png' | 'jpeg' | 'jpg' | 'gif' | 'webp' | 'yaml' | 'json';
87
-
88
- export interface Transform {
89
- rotate: number;
90
- scale: {
91
- x: number;
92
- y: number;
93
- };
94
- translate: {
95
- x: number;
96
- y: number;
97
- };
98
- matrix: DOMMatrix2DInit;
99
- }
100
-
101
- export type RadiusCorner = 'leftTop' | 'leftBottom' | 'rightTop' | 'rightBottom' | 'all';
102
-
103
- export type SubStringColor = {
104
- color: StringColorType;
105
- start: number;
106
- end: number;
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;