@meonode/canvas 1.0.0-beta.1

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 (65) hide show
  1. package/CONTRIBUTING.md +75 -0
  2. package/LICENSE +21 -0
  3. package/Readme.md +382 -0
  4. package/dist/cjs/canvas/canvas.helper.d.ts +57 -0
  5. package/dist/cjs/canvas/canvas.helper.d.ts.map +1 -0
  6. package/dist/cjs/canvas/canvas.helper.js +239 -0
  7. package/dist/cjs/canvas/canvas.helper.js.map +1 -0
  8. package/dist/cjs/canvas/canvas.type.d.ts +657 -0
  9. package/dist/cjs/canvas/canvas.type.d.ts.map +1 -0
  10. package/dist/cjs/canvas/grid.canvas.util.d.ts +39 -0
  11. package/dist/cjs/canvas/grid.canvas.util.d.ts.map +1 -0
  12. package/dist/cjs/canvas/grid.canvas.util.js +263 -0
  13. package/dist/cjs/canvas/grid.canvas.util.js.map +1 -0
  14. package/dist/cjs/canvas/image.canvas.util.d.ts +34 -0
  15. package/dist/cjs/canvas/image.canvas.util.d.ts.map +1 -0
  16. package/dist/cjs/canvas/image.canvas.util.js +310 -0
  17. package/dist/cjs/canvas/image.canvas.util.js.map +1 -0
  18. package/dist/cjs/canvas/layout.canvas.util.d.ts +123 -0
  19. package/dist/cjs/canvas/layout.canvas.util.d.ts.map +1 -0
  20. package/dist/cjs/canvas/layout.canvas.util.js +785 -0
  21. package/dist/cjs/canvas/layout.canvas.util.js.map +1 -0
  22. package/dist/cjs/canvas/root.canvas.util.d.ts +42 -0
  23. package/dist/cjs/canvas/root.canvas.util.d.ts.map +1 -0
  24. package/dist/cjs/canvas/root.canvas.util.js +140 -0
  25. package/dist/cjs/canvas/root.canvas.util.js.map +1 -0
  26. package/dist/cjs/canvas/text.canvas.util.d.ts +148 -0
  27. package/dist/cjs/canvas/text.canvas.util.d.ts.map +1 -0
  28. package/dist/cjs/canvas/text.canvas.util.js +1112 -0
  29. package/dist/cjs/canvas/text.canvas.util.js.map +1 -0
  30. package/dist/cjs/constant/common.const.d.ts +37 -0
  31. package/dist/cjs/constant/common.const.d.ts.map +1 -0
  32. package/dist/cjs/constant/common.const.js +51 -0
  33. package/dist/cjs/constant/common.const.js.map +1 -0
  34. package/dist/cjs/index.d.ts +7 -0
  35. package/dist/cjs/index.d.ts.map +1 -0
  36. package/dist/cjs/index.js +31 -0
  37. package/dist/cjs/index.js.map +1 -0
  38. package/dist/esm/canvas/canvas.helper.d.ts +57 -0
  39. package/dist/esm/canvas/canvas.helper.d.ts.map +1 -0
  40. package/dist/esm/canvas/canvas.helper.js +214 -0
  41. package/dist/esm/canvas/canvas.type.d.ts +657 -0
  42. package/dist/esm/canvas/canvas.type.d.ts.map +1 -0
  43. package/dist/esm/canvas/grid.canvas.util.d.ts +39 -0
  44. package/dist/esm/canvas/grid.canvas.util.d.ts.map +1 -0
  45. package/dist/esm/canvas/grid.canvas.util.js +259 -0
  46. package/dist/esm/canvas/image.canvas.util.d.ts +34 -0
  47. package/dist/esm/canvas/image.canvas.util.d.ts.map +1 -0
  48. package/dist/esm/canvas/image.canvas.util.js +306 -0
  49. package/dist/esm/canvas/layout.canvas.util.d.ts +123 -0
  50. package/dist/esm/canvas/layout.canvas.util.d.ts.map +1 -0
  51. package/dist/esm/canvas/layout.canvas.util.js +777 -0
  52. package/dist/esm/canvas/root.canvas.util.d.ts +42 -0
  53. package/dist/esm/canvas/root.canvas.util.d.ts.map +1 -0
  54. package/dist/esm/canvas/root.canvas.util.js +116 -0
  55. package/dist/esm/canvas/text.canvas.util.d.ts +148 -0
  56. package/dist/esm/canvas/text.canvas.util.d.ts.map +1 -0
  57. package/dist/esm/canvas/text.canvas.util.js +1108 -0
  58. package/dist/esm/constant/common.const.d.ts +37 -0
  59. package/dist/esm/constant/common.const.d.ts.map +1 -0
  60. package/dist/esm/constant/common.const.js +23 -0
  61. package/dist/esm/index.d.ts +7 -0
  62. package/dist/esm/index.d.ts.map +1 -0
  63. package/dist/esm/index.js +7 -0
  64. package/dist/meonode-canvas-1.0.0-beta.1.tgz +0 -0
  65. package/package.json +79 -0
@@ -0,0 +1,123 @@
1
+ import { type CanvasRenderingContext2D } from 'skia-canvas';
2
+ import type { BaseProps, BoxProps } from '../canvas/canvas.type.js';
3
+ import { Node } from '../constant/common.const.js';
4
+ /**
5
+ * @class BoxNode
6
+ * @classdesc Base node class for rendering rectangular boxes with layout, styling, and children.
7
+ * It uses the Yoga layout engine for positioning and sizing.
8
+ */
9
+ export declare class BoxNode {
10
+ /**
11
+ * @property {Partial<BoxProps>} initialProps - Original props passed to the constructor before any modifications.
12
+ */
13
+ initialProps: Partial<BoxProps>;
14
+ /**
15
+ * @property {Node} node - The Yoga layout engine node.
16
+ */
17
+ node: Node;
18
+ /**
19
+ * @property {BoxNode[]} children - Child nodes.
20
+ */
21
+ children: BoxNode[];
22
+ /**
23
+ * @property {BoxProps & BaseProps} props - Current props including defaults and inherited values.
24
+ */
25
+ props: BoxProps & BaseProps;
26
+ /**
27
+ * @property {string} name - Node type name.
28
+ */
29
+ readonly name?: string;
30
+ /**
31
+ * @property {string} key - Unique node identifier.
32
+ */
33
+ key?: string;
34
+ /**
35
+ * Creates a new BoxNode instance
36
+ * @param props - Initial box properties and styling
37
+ */
38
+ constructor(props?: BoxProps & BaseProps);
39
+ /**
40
+ * Processes and appends any children passed in the initial props.
41
+ */
42
+ processInitialChildren(): void;
43
+ /**
44
+ * Inherits styles from the parent node.
45
+ * @param {BoxProps & BaseProps} parentProps - Parent node properties to inherit from.
46
+ */
47
+ protected resolveInheritedStyles(parentProps: BoxProps & BaseProps): void;
48
+ /**
49
+ * Applies node type-specific default values after inheritance.
50
+ */
51
+ protected applyDefaults(): void;
52
+ /**
53
+ * Appends a child node at the specified index.
54
+ * @param {BoxNode} child - Child node to append.
55
+ * @param index - Index to insert child at
56
+ */
57
+ protected appendChild(child: BoxNode, index: number): void;
58
+ /**
59
+ * Performs final layout adjustments recursively after the main layout calculation.
60
+ * @returns {boolean} Whether any node was marked as dirty during finalization.
61
+ */
62
+ finalizeLayout(): boolean;
63
+ /**
64
+ * Hook for subclasses to update layout based on computed size.
65
+ */
66
+ protected updateLayoutBasedOnComputedSize(): void;
67
+ /**
68
+ * Applies layout properties to the Yoga node.
69
+ * @param props - Box properties containing layout values
70
+ */
71
+ protected setLayout(props: BoxProps): void;
72
+ /**
73
+ * Renders the node and its children to the canvas.
74
+ * @param {CanvasRenderingContext2D} ctx - Canvas rendering context (from skia-canvas).
75
+ * @param {number} offsetX - X offset for rendering.
76
+ * @param {number} offsetY - Y offset for rendering.
77
+ */
78
+ render(ctx: CanvasRenderingContext2D, offsetX?: number, offsetY?: number): void;
79
+ /**
80
+ * Renders the node's visual content including background fills, shadows, and borders.
81
+ * This is an internal method used by the render() pipeline.
82
+ *
83
+ * @param ctx - The skia-canvas 2D rendering context to draw into
84
+ * @param x - The absolute x-coordinate where drawing should begin
85
+ * @param y - The absolute y-coordinate where drawing should begin
86
+ * @param width - The width of the content area to render
87
+ * @param height - The height of the content area to render
88
+ */
89
+ protected _renderContent(ctx: CanvasRenderingContext2D, x: number, y: number, width: number, height: number): void;
90
+ }
91
+ /**
92
+ * Creates a new BoxNode instance.
93
+ * @param {BoxProps} props - Box properties and configuration.
94
+ * @returns {BoxNode} New BoxNode instance.
95
+ */
96
+ export declare const Box: (props: BoxProps) => BoxNode;
97
+ /**
98
+ * @class ColumnNode
99
+ * Node class for vertical column layout
100
+ */
101
+ export declare class ColumnNode extends BoxNode {
102
+ constructor(props?: BoxProps & BaseProps);
103
+ }
104
+ /**
105
+ * Creates a new ColumnNode instance.
106
+ * @param {BoxProps} props - Column properties and configuration.
107
+ * @returns {ColumnNode} New ColumnNode instance.
108
+ */
109
+ export declare const Column: (props: BoxProps) => ColumnNode;
110
+ /**
111
+ * @class RowNode
112
+ * @classdesc Node class for horizontal row layout.
113
+ */
114
+ export declare class RowNode extends BoxNode {
115
+ constructor(props?: BoxProps & BaseProps);
116
+ }
117
+ /**
118
+ * Creates a new RowNode instance.
119
+ * @param {BoxProps} props - Row properties and configuration.
120
+ * @returns {RowNode} New RowNode instance.
121
+ */
122
+ export declare const Row: (props: BoxProps) => RowNode;
123
+ //# sourceMappingURL=layout.canvas.util.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.canvas.util.d.ts","sourceRoot":"","sources":["../../../src/canvas/layout.canvas.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,KAAK,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAEnE,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAkB,MAAM,yBAAyB,CAAA;AAGlF,OAAa,EAAS,IAAI,EAAE,MAAM,4BAA4B,CAAA;AAE9D;;;;GAIG;AACH,qBAAa,OAAO;IAClB;;OAEG;IACH,YAAY,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;IAC/B;;OAEG;IACH,IAAI,EAAE,IAAI,CAAA;IACV;;OAEG;IACH,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB;;OAEG;IACH,KAAK,EAAE,QAAQ,GAAG,SAAS,CAAA;IAC3B;;OAEG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAA;IACtB;;OAEG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;;OAGG;gBACS,KAAK,GAAE,QAAQ,GAAG,SAAc;IAqB5C;;OAEG;IACI,sBAAsB;IAW7B;;;OAGG;IACH,SAAS,CAAC,sBAAsB,CAAC,WAAW,EAAE,QAAQ,GAAG,SAAS;IAkClE;;OAEG;IACH,SAAS,CAAC,aAAa,IAAI,IAAI;IAI/B;;;;OAIG;IACH,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM;IAanD;;;OAGG;IACI,cAAc;IAiBrB;;OAEG;IACH,SAAS,CAAC,+BAA+B;IAIzC;;;OAGG;IACH,SAAS,CAAC,SAAS,CAAC,KAAK,EAAE,QAAQ;IAqInC;;;;;OAKG;IACH,MAAM,CAAC,GAAG,EAAE,wBAAwB,EAAE,OAAO,SAAI,EAAE,OAAO,SAAI;IAqK9D;;;;;;;;;OASG;IACH,SAAS,CAAC,cAAc,CAAC,GAAG,EAAE,wBAAwB,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CA6R5G;AAED;;;;GAIG;AACH,eAAO,MAAM,GAAG,GAAI,OAAO,QAAQ,YAAuB,CAAA;AAE1D;;;GAGG;AACH,qBAAa,UAAW,SAAQ,OAAO;gBACzB,KAAK,GAAE,QAAQ,GAAG,SAAc;CAS7C;AAED;;;;GAIG;AACH,eAAO,MAAM,MAAM,GAAI,OAAO,QAAQ,eAA0B,CAAA;AAEhE;;;GAGG;AACH,qBAAa,OAAQ,SAAQ,OAAO;gBACtB,KAAK,GAAE,QAAQ,GAAG,SAAc;CAS7C;AAED;;;;GAIG;AACH,eAAO,MAAM,GAAG,GAAI,OAAO,QAAQ,YAAuB,CAAA"}