@2112-lab/central-plant 0.1.4 → 0.1.6

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 (88) hide show
  1. package/dist/bundle/index.js +33146 -1
  2. package/dist/cjs/_virtual/_rollupPluginBabelHelpers.js +432 -1
  3. package/dist/cjs/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1448 -1
  4. package/dist/cjs/node_modules/three/examples/jsm/controls/OrbitControls.js +1853 -1
  5. package/dist/cjs/node_modules/three/examples/jsm/exporters/GLTFExporter.js +3537 -1
  6. package/dist/cjs/node_modules/three/examples/jsm/exporters/OBJExporter.js +305 -1
  7. package/dist/cjs/node_modules/three/examples/jsm/exporters/PLYExporter.js +542 -1
  8. package/dist/cjs/node_modules/three/examples/jsm/exporters/STLExporter.js +218 -1
  9. package/dist/cjs/node_modules/three/examples/jsm/loaders/DRACOLoader.js +683 -1
  10. package/dist/cjs/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4811 -1
  11. package/dist/cjs/node_modules/three/examples/jsm/loaders/RGBELoader.js +480 -1
  12. package/dist/cjs/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +309 -1
  13. package/dist/cjs/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +120 -1
  14. package/dist/cjs/src/analysis/analysis.js +560 -1
  15. package/dist/cjs/src/analysis/testing.js +958 -1
  16. package/dist/cjs/src/core/centralPlant.js +1149 -1
  17. package/dist/cjs/src/core/debugLogger.js +175 -1
  18. package/dist/cjs/src/core/mathUtils.js +574 -1
  19. package/dist/cjs/src/core/nameUtils.js +93 -1
  20. package/dist/cjs/src/data/export.js +716 -1
  21. package/dist/cjs/src/data/import.js +380 -1
  22. package/dist/cjs/src/data/numerics.js +522 -1
  23. package/dist/cjs/src/helpers/sceneHelper.js +572 -1
  24. package/dist/cjs/src/index.js +69 -1
  25. package/dist/cjs/src/managers/components/animationManager.js +123 -1
  26. package/dist/cjs/src/managers/components/componentManager.js +332 -1
  27. package/dist/cjs/src/managers/components/pathfindingManager.js +1441 -1
  28. package/dist/cjs/src/managers/controls/TransformControls.js +1063 -1
  29. package/dist/cjs/src/managers/controls/cameraControlsManager.js +79 -1
  30. package/dist/cjs/src/managers/controls/dragDropManager.js +1026 -1
  31. package/dist/cjs/src/managers/controls/keyboardControlsManager.js +395 -1
  32. package/dist/cjs/src/managers/controls/transformControlsManager.js +1807 -1
  33. package/dist/cjs/src/managers/environment/environmentManager.js +714 -1
  34. package/dist/cjs/src/managers/environment/textureConfig.js +229 -1
  35. package/dist/cjs/src/managers/scene/sceneExportManager.js +264 -1
  36. package/dist/cjs/src/managers/scene/sceneInitializationManager.js +346 -1
  37. package/dist/cjs/src/managers/scene/sceneOperationsManager.js +1509 -1
  38. package/dist/cjs/src/managers/scene/sceneTooltipsManager.js +661 -1
  39. package/dist/cjs/src/managers/system/disposalManager.js +444 -1
  40. package/dist/cjs/src/managers/system/hotReloadManager.js +291 -1
  41. package/dist/cjs/src/managers/system/performanceMonitor.js +863 -1
  42. package/dist/cjs/src/rendering/modelPreloader.js +369 -1
  43. package/dist/cjs/src/rendering/rendering2D.js +631 -1
  44. package/dist/cjs/src/rendering/rendering3D.js +685 -1
  45. package/dist/esm/_virtual/_rollupPluginBabelHelpers.js +396 -1
  46. package/dist/esm/node_modules/@2112-lab/pathfinder/dist/index.esm.js +1444 -1
  47. package/dist/esm/node_modules/three/examples/jsm/controls/OrbitControls.js +1849 -1
  48. package/dist/esm/node_modules/three/examples/jsm/exporters/GLTFExporter.js +3533 -1
  49. package/dist/esm/node_modules/three/examples/jsm/exporters/OBJExporter.js +301 -1
  50. package/dist/esm/node_modules/three/examples/jsm/exporters/PLYExporter.js +538 -1
  51. package/dist/esm/node_modules/three/examples/jsm/exporters/STLExporter.js +214 -1
  52. package/dist/esm/node_modules/three/examples/jsm/loaders/DRACOLoader.js +679 -1
  53. package/dist/esm/node_modules/three/examples/jsm/loaders/GLTFLoader.js +4807 -1
  54. package/dist/esm/node_modules/three/examples/jsm/loaders/RGBELoader.js +476 -1
  55. package/dist/esm/node_modules/three/examples/jsm/renderers/CSS2DRenderer.js +304 -1
  56. package/dist/esm/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js +116 -1
  57. package/dist/esm/src/analysis/analysis.js +536 -1
  58. package/dist/esm/src/analysis/testing.js +954 -1
  59. package/dist/esm/src/core/centralPlant.js +1144 -1
  60. package/dist/esm/src/core/debugLogger.js +167 -1
  61. package/dist/esm/src/core/mathUtils.js +570 -1
  62. package/dist/esm/src/core/nameUtils.js +87 -1
  63. package/dist/esm/src/data/export.js +712 -1
  64. package/dist/esm/src/data/import.js +356 -1
  65. package/dist/esm/src/data/numerics.js +518 -1
  66. package/dist/esm/src/helpers/sceneHelper.js +547 -1
  67. package/dist/esm/src/index.js +35 -1
  68. package/dist/esm/src/managers/components/animationManager.js +119 -1
  69. package/dist/esm/src/managers/components/componentManager.js +328 -1
  70. package/dist/esm/src/managers/components/pathfindingManager.js +1417 -1
  71. package/dist/esm/src/managers/controls/TransformControls.js +1057 -1
  72. package/dist/esm/src/managers/controls/cameraControlsManager.js +75 -1
  73. package/dist/esm/src/managers/controls/dragDropManager.js +1002 -1
  74. package/dist/esm/src/managers/controls/keyboardControlsManager.js +371 -1
  75. package/dist/esm/src/managers/controls/transformControlsManager.js +1782 -1
  76. package/dist/esm/src/managers/environment/environmentManager.js +690 -1
  77. package/dist/esm/src/managers/environment/textureConfig.js +202 -1
  78. package/dist/esm/src/managers/scene/sceneExportManager.js +260 -1
  79. package/dist/esm/src/managers/scene/sceneInitializationManager.js +322 -1
  80. package/dist/esm/src/managers/scene/sceneOperationsManager.js +1485 -1
  81. package/dist/esm/src/managers/scene/sceneTooltipsManager.js +637 -1
  82. package/dist/esm/src/managers/system/disposalManager.js +440 -1
  83. package/dist/esm/src/managers/system/hotReloadManager.js +287 -1
  84. package/dist/esm/src/managers/system/performanceMonitor.js +858 -1
  85. package/dist/esm/src/rendering/modelPreloader.js +364 -1
  86. package/dist/esm/src/rendering/rendering2D.js +627 -1
  87. package/dist/esm/src/rendering/rendering3D.js +661 -1
  88. package/package.json +1 -1
@@ -1 +1,631 @@
1
- "use strict";Object.defineProperty(exports,"t",{value:!0});var t=require("../../_virtual/_rollupPluginBabelHelpers.js"),i=function(){return t.createClass(function i(n){var e=this;t.classCallCheck(this,i),t.defineProperty(this,"draw",{line:function(t,i,n,r){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};e.ctx&&(e.save(),e.setStyles(o),e.ctx.beginPath(),e.ctx.moveTo(t,i),e.ctx.lineTo(n,r),e.ctx.stroke(),e.restore())},rect:function(t,i,n,r){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{};e.ctx&&(e.save(),e.setStyles(o),o.fillStyle&&e.ctx.fillRect(t,i,n,r),o.strokeStyle&&e.ctx.strokeRect(t,i,n,r),e.restore())},circle:function(t,i,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};e.ctx&&(e.save(),e.setStyles(r),e.ctx.beginPath(),e.ctx.arc(t,i,n,0,2*Math.PI),r.fillStyle&&e.ctx.fill(),r.strokeStyle&&e.ctx.stroke(),e.restore())},ellipse:function(t,i,n,r){var o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};e.ctx&&(e.save(),e.setStyles(s),e.ctx.beginPath(),e.ctx.ellipse(t,i,n,r,o,0,2*Math.PI),s.fillStyle&&e.ctx.fill(),s.strokeStyle&&e.ctx.stroke(),e.restore())},polygon:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(e.ctx&&!(t.length<3)){e.save(),e.setStyles(i),e.ctx.beginPath(),e.ctx.moveTo(t[0][0],t[0][1]);for(var n=1;n<t.length;n++)e.ctx.lineTo(t[n][0],t[n][1]);e.ctx.closePath(),i.fillStyle&&e.ctx.fill(),i.strokeStyle&&e.ctx.stroke(),e.restore()}},bezierCurve:function(t,i,n,r,o,s,u,a){var h=arguments.length>8&&void 0!==arguments[8]?arguments[8]:{};e.ctx&&(e.save(),e.setStyles(h),e.ctx.beginPath(),e.ctx.moveTo(t,i),e.ctx.bezierCurveTo(n,r,o,s,u,a),e.ctx.stroke(),e.restore())},text:function(t,i,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};e.ctx&&(e.save(),e.setStyles(r),r.fillStyle&&e.ctx.fillText(t,i,n),r.strokeStyle&&e.ctx.strokeText(t,i,n),e.restore())},image:function(t,i,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null;e.ctx&&t&&(r&&o?e.ctx.drawImage(t,i,n,r,o):e.ctx.drawImage(t,i,n))}}),t.defineProperty(this,"transform",{translate:function(t,i){e.ctx&&e.ctx.translate(t,i)},rotate:function(t){e.ctx&&e.ctx.rotate(t)},scale:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t;e.ctx&&e.ctx.scale(t,i)},transform:function(t,i,n,r,o,s){e.ctx&&e.ctx.transform(t,i,n,r,o,s)},setTransform:function(t,i,n,r,o,s){e.ctx&&e.ctx.setTransform(t,i,n,r,o,s)},resetTransform:function(){e.ctx&&e.ctx.resetTransform()}}),t.defineProperty(this,"gradient",{linear:function(t,i,n,r,o){if(!e.ctx)return null;var s=e.ctx.createLinearGradient(t,i,n,r);return o.forEach(function(t){s.addColorStop(t.offset,t.color)}),s},radial:function(t,i,n,r,o,s,u){if(!e.ctx)return null;var a=e.ctx.createRadialGradient(t,i,n,r,o,s);return u.forEach(function(t){a.addColorStop(t.offset,t.color)}),a}}),t.defineProperty(this,"pattern",{fromImage:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"repeat";return e.ctx&&t?e.ctx.createPattern(t,i):null},fromCanvas:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"repeat";return e.ctx&&t?e.ctx.createPattern(t,i):null}}),t.defineProperty(this,"path",{begin:function(){e.ctx&&e.ctx.beginPath()},close:function(){e.ctx&&e.ctx.closePath()},moveTo:function(t,i){e.ctx&&e.ctx.moveTo(t,i)},lineTo:function(t,i){e.ctx&&e.ctx.lineTo(t,i)},arc:function(t,i,n,r,o){var s=arguments.length>5&&void 0!==arguments[5]&&arguments[5];e.ctx&&e.ctx.arc(t,i,n,r,o,s)},quadraticCurveTo:function(t,i,n,r){e.ctx&&e.ctx.quadraticCurveTo(t,i,n,r)},bezierCurveTo:function(t,i,n,r,o,s){e.ctx&&e.ctx.bezierCurveTo(t,i,n,r,o,s)},fill:function(){e.ctx&&e.ctx.fill()},stroke:function(){e.ctx&&e.ctx.stroke()},clip:function(){e.ctx&&e.ctx.clip()}}),t.defineProperty(this,"measure",{textWidth:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!e.ctx)return 0;if(i){var n=e.ctx.font;e.ctx.font=i;var r=e.ctx.measureText(t).width;return e.ctx.font=n,r}return e.ctx.measureText(t).width},textMetrics:function(t){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(!e.ctx)return null;if(i){var n=e.ctx.font;e.ctx.font=i;var r=e.ctx.measureText(t);return e.ctx.font=n,r}return e.ctx.measureText(t)}}),t.defineProperty(this,"export",{toDataURL:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image/png",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.92;return e.canvas?e.canvas.toDataURL(t,i):""},toBlob:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"image/png",i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:.92;return e.canvas?new Promise(function(n){e.canvas.toBlob(n,t,i)}):Promise.resolve(null)}}),this.canvas=n,this.ctx=null==n?void 0:n.getContext("2d"),this.width=(null==n?void 0:n.width)||800,this.height=(null==n?void 0:n.height)||600,this.pixelRatio=window.devicePixelRatio||1,this.state={transforms:[],styles:[]},this.setupCanvas()},[{key:"setupCanvas",value:function(){this.canvas&&this.ctx&&(this.canvas.width=this.width*this.pixelRatio,this.canvas.height=this.height*this.pixelRatio,this.ctx.scale(this.pixelRatio,this.pixelRatio),this.canvas.style.width=this.width+"px",this.canvas.style.height=this.height+"px")}},{key:"clear",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.ctx&&(t?(this.ctx.fillStyle=t,this.ctx.fillRect(0,0,this.width,this.height)):this.ctx.clearRect(0,0,this.width,this.height))}},{key:"save",value:function(){this.ctx&&(this.ctx.save(),this.state.transforms.push(this.ctx.getTransform()),this.state.styles.push({fillStyle:this.ctx.fillStyle,strokeStyle:this.ctx.strokeStyle,lineWidth:this.ctx.lineWidth,font:this.ctx.font,textAlign:this.ctx.textAlign,textBaseline:this.ctx.textBaseline}))}},{key:"restore",value:function(){this.ctx&&(this.ctx.restore(),this.state.transforms.pop(),this.state.styles.pop())}},{key:"setStyles",value:function(t){var i=this;this.ctx&&Object.keys(t).forEach(function(n){void 0!==i.ctx[n]&&(i.ctx[n]=t[n])})}},{key:"resize",value:function(t,i){this.width=t,this.height=i,this.setupCanvas()}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height,pixelRatio:this.pixelRatio}}},{key:"dispose",value:function(){this.state.transforms=[],this.state.styles=[],this.canvas=null,this.ctx=null}}])}();exports.Rendering2D=i;
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
6
+
7
+ /**
8
+ * Rendering2D
9
+ * Handles 2D rendering operations, canvas drawing, and 2D graphics utilities
10
+ */
11
+
12
+ var Rendering2D = /*#__PURE__*/function () {
13
+ function Rendering2D(_canvas) {
14
+ var _this = this;
15
+ _rollupPluginBabelHelpers.classCallCheck(this, Rendering2D);
16
+ /**
17
+ * Drawing primitives
18
+ */
19
+ _rollupPluginBabelHelpers.defineProperty(this, "draw", {
20
+ /**
21
+ * Draw a line
22
+ * @param {number} x1 - Start X
23
+ * @param {number} y1 - Start Y
24
+ * @param {number} x2 - End X
25
+ * @param {number} y2 - End Y
26
+ * @param {Object} style - Line style
27
+ */
28
+ line: function line(x1, y1, x2, y2) {
29
+ var style = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
30
+ if (!_this.ctx) return;
31
+ _this.save();
32
+ _this.setStyles(style);
33
+ _this.ctx.beginPath();
34
+ _this.ctx.moveTo(x1, y1);
35
+ _this.ctx.lineTo(x2, y2);
36
+ _this.ctx.stroke();
37
+ _this.restore();
38
+ },
39
+ /**
40
+ * Draw a rectangle
41
+ * @param {number} x - X position
42
+ * @param {number} y - Y position
43
+ * @param {number} width - Width
44
+ * @param {number} height - Height
45
+ * @param {Object} style - Rectangle style
46
+ */
47
+ rect: function rect(x, y, width, height) {
48
+ var style = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
49
+ if (!_this.ctx) return;
50
+ _this.save();
51
+ _this.setStyles(style);
52
+ if (style.fillStyle) {
53
+ _this.ctx.fillRect(x, y, width, height);
54
+ }
55
+ if (style.strokeStyle) {
56
+ _this.ctx.strokeRect(x, y, width, height);
57
+ }
58
+ _this.restore();
59
+ },
60
+ /**
61
+ * Draw a circle
62
+ * @param {number} x - Center X
63
+ * @param {number} y - Center Y
64
+ * @param {number} radius - Radius
65
+ * @param {Object} style - Circle style
66
+ */
67
+ circle: function circle(x, y, radius) {
68
+ var style = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
69
+ if (!_this.ctx) return;
70
+ _this.save();
71
+ _this.setStyles(style);
72
+ _this.ctx.beginPath();
73
+ _this.ctx.arc(x, y, radius, 0, 2 * Math.PI);
74
+ if (style.fillStyle) {
75
+ _this.ctx.fill();
76
+ }
77
+ if (style.strokeStyle) {
78
+ _this.ctx.stroke();
79
+ }
80
+ _this.restore();
81
+ },
82
+ /**
83
+ * Draw an ellipse
84
+ * @param {number} x - Center X
85
+ * @param {number} y - Center Y
86
+ * @param {number} radiusX - X radius
87
+ * @param {number} radiusY - Y radius
88
+ * @param {number} rotation - Rotation in radians
89
+ * @param {Object} style - Ellipse style
90
+ */
91
+ ellipse: function ellipse(x, y, radiusX, radiusY) {
92
+ var rotation = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
93
+ var style = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
94
+ if (!_this.ctx) return;
95
+ _this.save();
96
+ _this.setStyles(style);
97
+ _this.ctx.beginPath();
98
+ _this.ctx.ellipse(x, y, radiusX, radiusY, rotation, 0, 2 * Math.PI);
99
+ if (style.fillStyle) {
100
+ _this.ctx.fill();
101
+ }
102
+ if (style.strokeStyle) {
103
+ _this.ctx.stroke();
104
+ }
105
+ _this.restore();
106
+ },
107
+ /**
108
+ * Draw a polygon
109
+ * @param {Array} points - Array of [x, y] points
110
+ * @param {Object} style - Polygon style
111
+ */
112
+ polygon: function polygon(points) {
113
+ var style = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
114
+ if (!_this.ctx || points.length < 3) return;
115
+ _this.save();
116
+ _this.setStyles(style);
117
+ _this.ctx.beginPath();
118
+ _this.ctx.moveTo(points[0][0], points[0][1]);
119
+ for (var i = 1; i < points.length; i++) {
120
+ _this.ctx.lineTo(points[i][0], points[i][1]);
121
+ }
122
+ _this.ctx.closePath();
123
+ if (style.fillStyle) {
124
+ _this.ctx.fill();
125
+ }
126
+ if (style.strokeStyle) {
127
+ _this.ctx.stroke();
128
+ }
129
+ _this.restore();
130
+ },
131
+ /**
132
+ * Draw a bezier curve
133
+ * @param {number} x1 - Start X
134
+ * @param {number} y1 - Start Y
135
+ * @param {number} cp1x - Control point 1 X
136
+ * @param {number} cp1y - Control point 1 Y
137
+ * @param {number} cp2x - Control point 2 X
138
+ * @param {number} cp2y - Control point 2 Y
139
+ * @param {number} x2 - End X
140
+ * @param {number} y2 - End Y
141
+ * @param {Object} style - Curve style
142
+ */
143
+ bezierCurve: function bezierCurve(x1, y1, cp1x, cp1y, cp2x, cp2y, x2, y2) {
144
+ var style = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : {};
145
+ if (!_this.ctx) return;
146
+ _this.save();
147
+ _this.setStyles(style);
148
+ _this.ctx.beginPath();
149
+ _this.ctx.moveTo(x1, y1);
150
+ _this.ctx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x2, y2);
151
+ _this.ctx.stroke();
152
+ _this.restore();
153
+ },
154
+ /**
155
+ * Draw text
156
+ * @param {string} text - Text to draw
157
+ * @param {number} x - X position
158
+ * @param {number} y - Y position
159
+ * @param {Object} style - Text style
160
+ */
161
+ text: function text(_text, x, y) {
162
+ var style = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
163
+ if (!_this.ctx) return;
164
+ _this.save();
165
+ _this.setStyles(style);
166
+ if (style.fillStyle) {
167
+ _this.ctx.fillText(_text, x, y);
168
+ }
169
+ if (style.strokeStyle) {
170
+ _this.ctx.strokeText(_text, x, y);
171
+ }
172
+ _this.restore();
173
+ },
174
+ /**
175
+ * Draw an image
176
+ * @param {HTMLImageElement} image - Image to draw
177
+ * @param {number} x - X position
178
+ * @param {number} y - Y position
179
+ * @param {number} width - Width (optional)
180
+ * @param {number} height - Height (optional)
181
+ */
182
+ image: function image(_image, x, y) {
183
+ var width = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
184
+ var height = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : null;
185
+ if (!_this.ctx || !_image) return;
186
+ if (width && height) {
187
+ _this.ctx.drawImage(_image, x, y, width, height);
188
+ } else {
189
+ _this.ctx.drawImage(_image, x, y);
190
+ }
191
+ }
192
+ });
193
+ /**
194
+ * Transform operations
195
+ */
196
+ _rollupPluginBabelHelpers.defineProperty(this, "transform", {
197
+ /**
198
+ * Translate coordinate system
199
+ * @param {number} x - X offset
200
+ * @param {number} y - Y offset
201
+ */
202
+ translate: function translate(x, y) {
203
+ if (!_this.ctx) return;
204
+ _this.ctx.translate(x, y);
205
+ },
206
+ /**
207
+ * Rotate coordinate system
208
+ * @param {number} angle - Rotation angle in radians
209
+ */
210
+ rotate: function rotate(angle) {
211
+ if (!_this.ctx) return;
212
+ _this.ctx.rotate(angle);
213
+ },
214
+ /**
215
+ * Scale coordinate system
216
+ * @param {number} x - X scale factor
217
+ * @param {number} y - Y scale factor
218
+ */
219
+ scale: function scale(x) {
220
+ var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : x;
221
+ if (!_this.ctx) return;
222
+ _this.ctx.scale(x, y);
223
+ },
224
+ /**
225
+ * Apply transformation matrix
226
+ * @param {number} a - Horizontal scaling
227
+ * @param {number} b - Horizontal skewing
228
+ * @param {number} c - Vertical skewing
229
+ * @param {number} d - Vertical scaling
230
+ * @param {number} e - Horizontal translation
231
+ * @param {number} f - Vertical translation
232
+ */
233
+ transform: function transform(a, b, c, d, e, f) {
234
+ if (!_this.ctx) return;
235
+ _this.ctx.transform(a, b, c, d, e, f);
236
+ },
237
+ /**
238
+ * Set transformation matrix
239
+ * @param {number} a - Horizontal scaling
240
+ * @param {number} b - Horizontal skewing
241
+ * @param {number} c - Vertical skewing
242
+ * @param {number} d - Vertical scaling
243
+ * @param {number} e - Horizontal translation
244
+ * @param {number} f - Vertical translation
245
+ */
246
+ setTransform: function setTransform(a, b, c, d, e, f) {
247
+ if (!_this.ctx) return;
248
+ _this.ctx.setTransform(a, b, c, d, e, f);
249
+ },
250
+ /**
251
+ * Reset transformation matrix to identity
252
+ */
253
+ resetTransform: function resetTransform() {
254
+ if (!_this.ctx) return;
255
+ _this.ctx.resetTransform();
256
+ }
257
+ });
258
+ /**
259
+ * Gradient utilities
260
+ */
261
+ _rollupPluginBabelHelpers.defineProperty(this, "gradient", {
262
+ /**
263
+ * Create linear gradient
264
+ * @param {number} x1 - Start X
265
+ * @param {number} y1 - Start Y
266
+ * @param {number} x2 - End X
267
+ * @param {number} y2 - End Y
268
+ * @param {Array} colorStops - Array of {offset, color} objects
269
+ * @returns {CanvasGradient} Linear gradient
270
+ */
271
+ linear: function linear(x1, y1, x2, y2, colorStops) {
272
+ if (!_this.ctx) return null;
273
+ var gradient = _this.ctx.createLinearGradient(x1, y1, x2, y2);
274
+ colorStops.forEach(function (stop) {
275
+ gradient.addColorStop(stop.offset, stop.color);
276
+ });
277
+ return gradient;
278
+ },
279
+ /**
280
+ * Create radial gradient
281
+ * @param {number} x1 - Inner circle center X
282
+ * @param {number} y1 - Inner circle center Y
283
+ * @param {number} r1 - Inner circle radius
284
+ * @param {number} x2 - Outer circle center X
285
+ * @param {number} y2 - Outer circle center Y
286
+ * @param {number} r2 - Outer circle radius
287
+ * @param {Array} colorStops - Array of {offset, color} objects
288
+ * @returns {CanvasGradient} Radial gradient
289
+ */
290
+ radial: function radial(x1, y1, r1, x2, y2, r2, colorStops) {
291
+ if (!_this.ctx) return null;
292
+ var gradient = _this.ctx.createRadialGradient(x1, y1, r1, x2, y2, r2);
293
+ colorStops.forEach(function (stop) {
294
+ gradient.addColorStop(stop.offset, stop.color);
295
+ });
296
+ return gradient;
297
+ }
298
+ });
299
+ /**
300
+ * Pattern utilities
301
+ */
302
+ _rollupPluginBabelHelpers.defineProperty(this, "pattern", {
303
+ /**
304
+ * Create pattern from image
305
+ * @param {HTMLImageElement} image - Source image
306
+ * @param {string} repetition - 'repeat', 'repeat-x', 'repeat-y', 'no-repeat'
307
+ * @returns {CanvasPattern} Pattern
308
+ */
309
+ fromImage: function fromImage(image) {
310
+ var repetition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'repeat';
311
+ if (!_this.ctx || !image) return null;
312
+ return _this.ctx.createPattern(image, repetition);
313
+ },
314
+ /**
315
+ * Create pattern from canvas
316
+ * @param {HTMLCanvasElement} canvas - Source canvas
317
+ * @param {string} repetition - 'repeat', 'repeat-x', 'repeat-y', 'no-repeat'
318
+ * @returns {CanvasPattern} Pattern
319
+ */
320
+ fromCanvas: function fromCanvas(canvas) {
321
+ var repetition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'repeat';
322
+ if (!_this.ctx || !canvas) return null;
323
+ return _this.ctx.createPattern(canvas, repetition);
324
+ }
325
+ });
326
+ /**
327
+ * Path utilities
328
+ */
329
+ _rollupPluginBabelHelpers.defineProperty(this, "path", {
330
+ /**
331
+ * Begin new path
332
+ */
333
+ begin: function begin() {
334
+ if (!_this.ctx) return;
335
+ _this.ctx.beginPath();
336
+ },
337
+ /**
338
+ * Close current path
339
+ */
340
+ close: function close() {
341
+ if (!_this.ctx) return;
342
+ _this.ctx.closePath();
343
+ },
344
+ /**
345
+ * Move to point
346
+ * @param {number} x - X coordinate
347
+ * @param {number} y - Y coordinate
348
+ */
349
+ moveTo: function moveTo(x, y) {
350
+ if (!_this.ctx) return;
351
+ _this.ctx.moveTo(x, y);
352
+ },
353
+ /**
354
+ * Line to point
355
+ * @param {number} x - X coordinate
356
+ * @param {number} y - Y coordinate
357
+ */
358
+ lineTo: function lineTo(x, y) {
359
+ if (!_this.ctx) return;
360
+ _this.ctx.lineTo(x, y);
361
+ },
362
+ /**
363
+ * Arc to point
364
+ * @param {number} x - Center X
365
+ * @param {number} y - Center Y
366
+ * @param {number} radius - Arc radius
367
+ * @param {number} startAngle - Start angle in radians
368
+ * @param {number} endAngle - End angle in radians
369
+ * @param {boolean} counterclockwise - Arc direction
370
+ */
371
+ arc: function arc(x, y, radius, startAngle, endAngle) {
372
+ var counterclockwise = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
373
+ if (!_this.ctx) return;
374
+ _this.ctx.arc(x, y, radius, startAngle, endAngle, counterclockwise);
375
+ },
376
+ /**
377
+ * Quadratic curve to point
378
+ * @param {number} cpx - Control point X
379
+ * @param {number} cpy - Control point Y
380
+ * @param {number} x - End X
381
+ * @param {number} y - End Y
382
+ */
383
+ quadraticCurveTo: function quadraticCurveTo(cpx, cpy, x, y) {
384
+ if (!_this.ctx) return;
385
+ _this.ctx.quadraticCurveTo(cpx, cpy, x, y);
386
+ },
387
+ /**
388
+ * Bezier curve to point
389
+ * @param {number} cp1x - Control point 1 X
390
+ * @param {number} cp1y - Control point 1 Y
391
+ * @param {number} cp2x - Control point 2 X
392
+ * @param {number} cp2y - Control point 2 Y
393
+ * @param {number} x - End X
394
+ * @param {number} y - End Y
395
+ */
396
+ bezierCurveTo: function bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y) {
397
+ if (!_this.ctx) return;
398
+ _this.ctx.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
399
+ },
400
+ /**
401
+ * Fill current path
402
+ */
403
+ fill: function fill() {
404
+ if (!_this.ctx) return;
405
+ _this.ctx.fill();
406
+ },
407
+ /**
408
+ * Stroke current path
409
+ */
410
+ stroke: function stroke() {
411
+ if (!_this.ctx) return;
412
+ _this.ctx.stroke();
413
+ },
414
+ /**
415
+ * Clip to current path
416
+ */
417
+ clip: function clip() {
418
+ if (!_this.ctx) return;
419
+ _this.ctx.clip();
420
+ }
421
+ });
422
+ /**
423
+ * Measurement utilities
424
+ */
425
+ _rollupPluginBabelHelpers.defineProperty(this, "measure", {
426
+ /**
427
+ * Measure text width
428
+ * @param {string} text - Text to measure
429
+ * @param {string} font - Font specification
430
+ * @returns {number} Text width in pixels
431
+ */
432
+ textWidth: function textWidth(text) {
433
+ var font = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
434
+ if (!_this.ctx) return 0;
435
+ if (font) {
436
+ var oldFont = _this.ctx.font;
437
+ _this.ctx.font = font;
438
+ var width = _this.ctx.measureText(text).width;
439
+ _this.ctx.font = oldFont;
440
+ return width;
441
+ }
442
+ return _this.ctx.measureText(text).width;
443
+ },
444
+ /**
445
+ * Get text metrics
446
+ * @param {string} text - Text to measure
447
+ * @param {string} font - Font specification
448
+ * @returns {TextMetrics} Text metrics object
449
+ */
450
+ textMetrics: function textMetrics(text) {
451
+ var font = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
452
+ if (!_this.ctx) return null;
453
+ if (font) {
454
+ var oldFont = _this.ctx.font;
455
+ _this.ctx.font = font;
456
+ var metrics = _this.ctx.measureText(text);
457
+ _this.ctx.font = oldFont;
458
+ return metrics;
459
+ }
460
+ return _this.ctx.measureText(text);
461
+ }
462
+ });
463
+ /**
464
+ * Export utilities
465
+ */
466
+ _rollupPluginBabelHelpers.defineProperty(this, "export", {
467
+ /**
468
+ * Get canvas as data URL
469
+ * @param {string} type - Image type ('image/png', 'image/jpeg', etc.)
470
+ * @param {number} quality - Quality for lossy formats (0-1)
471
+ * @returns {string} Data URL
472
+ */
473
+ toDataURL: function toDataURL() {
474
+ var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'image/png';
475
+ var quality = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.92;
476
+ if (!_this.canvas) return '';
477
+ return _this.canvas.toDataURL(type, quality);
478
+ },
479
+ /**
480
+ * Get canvas as blob
481
+ * @param {string} type - Image type
482
+ * @param {number} quality - Quality for lossy formats
483
+ * @returns {Promise<Blob>} Canvas blob
484
+ */
485
+ toBlob: function toBlob() {
486
+ var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'image/png';
487
+ var quality = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0.92;
488
+ if (!_this.canvas) return Promise.resolve(null);
489
+ return new Promise(function (resolve) {
490
+ _this.canvas.toBlob(resolve, type, quality);
491
+ });
492
+ }
493
+ });
494
+ this.canvas = _canvas;
495
+ this.ctx = _canvas === null || _canvas === void 0 ? void 0 : _canvas.getContext('2d');
496
+ this.width = (_canvas === null || _canvas === void 0 ? void 0 : _canvas.width) || 800;
497
+ this.height = (_canvas === null || _canvas === void 0 ? void 0 : _canvas.height) || 600;
498
+ this.pixelRatio = window.devicePixelRatio || 1;
499
+ this.state = {
500
+ transforms: [],
501
+ styles: []
502
+ };
503
+ this.setupCanvas();
504
+ }
505
+
506
+ /**
507
+ * Setup canvas for high DPI displays
508
+ */
509
+ return _rollupPluginBabelHelpers.createClass(Rendering2D, [{
510
+ key: "setupCanvas",
511
+ value: function setupCanvas() {
512
+ if (!this.canvas || !this.ctx) return;
513
+
514
+ // Set actual size in memory (scaled for DPI)
515
+ this.canvas.width = this.width * this.pixelRatio;
516
+ this.canvas.height = this.height * this.pixelRatio;
517
+
518
+ // Scale the drawing context back to logical size
519
+ this.ctx.scale(this.pixelRatio, this.pixelRatio);
520
+
521
+ // Set display size (CSS pixels)
522
+ this.canvas.style.width = this.width + 'px';
523
+ this.canvas.style.height = this.height + 'px';
524
+ }
525
+
526
+ /**
527
+ * Clear the entire canvas
528
+ * @param {string} color - Optional background color
529
+ */
530
+ }, {
531
+ key: "clear",
532
+ value: function clear() {
533
+ var color = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
534
+ if (!this.ctx) return;
535
+ if (color) {
536
+ this.ctx.fillStyle = color;
537
+ this.ctx.fillRect(0, 0, this.width, this.height);
538
+ } else {
539
+ this.ctx.clearRect(0, 0, this.width, this.height);
540
+ }
541
+ }
542
+
543
+ /**
544
+ * Save current drawing state
545
+ */
546
+ }, {
547
+ key: "save",
548
+ value: function save() {
549
+ if (!this.ctx) return;
550
+ this.ctx.save();
551
+ this.state.transforms.push(this.ctx.getTransform());
552
+ this.state.styles.push({
553
+ fillStyle: this.ctx.fillStyle,
554
+ strokeStyle: this.ctx.strokeStyle,
555
+ lineWidth: this.ctx.lineWidth,
556
+ font: this.ctx.font,
557
+ textAlign: this.ctx.textAlign,
558
+ textBaseline: this.ctx.textBaseline
559
+ });
560
+ }
561
+
562
+ /**
563
+ * Restore previous drawing state
564
+ */
565
+ }, {
566
+ key: "restore",
567
+ value: function restore() {
568
+ if (!this.ctx) return;
569
+ this.ctx.restore();
570
+ this.state.transforms.pop();
571
+ this.state.styles.pop();
572
+ }
573
+
574
+ /**
575
+ * Set drawing styles
576
+ * @param {Object} styles - Style properties
577
+ */
578
+ }, {
579
+ key: "setStyles",
580
+ value: function setStyles(styles) {
581
+ var _this2 = this;
582
+ if (!this.ctx) return;
583
+ Object.keys(styles).forEach(function (key) {
584
+ if (_this2.ctx[key] !== undefined) {
585
+ _this2.ctx[key] = styles[key];
586
+ }
587
+ });
588
+ }
589
+ }, {
590
+ key: "resize",
591
+ value:
592
+ /**
593
+ * Resize canvas
594
+ * @param {number} width - New width
595
+ * @param {number} height - New height
596
+ */
597
+ function resize(width, height) {
598
+ this.width = width;
599
+ this.height = height;
600
+ this.setupCanvas();
601
+ }
602
+
603
+ /**
604
+ * Get canvas dimensions
605
+ * @returns {Object} Canvas dimensions
606
+ */
607
+ }, {
608
+ key: "getDimensions",
609
+ value: function getDimensions() {
610
+ return {
611
+ width: this.width,
612
+ height: this.height,
613
+ pixelRatio: this.pixelRatio
614
+ };
615
+ }
616
+
617
+ /**
618
+ * Dispose of rendering manager
619
+ */
620
+ }, {
621
+ key: "dispose",
622
+ value: function dispose() {
623
+ this.state.transforms = [];
624
+ this.state.styles = [];
625
+ this.canvas = null;
626
+ this.ctx = null;
627
+ }
628
+ }]);
629
+ }();
630
+
631
+ exports.Rendering2D = Rendering2D;