@elixpo/lixsketch 5.5.7 → 5.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react/{AIRenderer-S2SKFJKT.js → AIRenderer-46WIFF2B.js} +1 -1
- package/dist/react/{EventDispatcher-RTXLMHPL.js → EventDispatcher-FP2RHJGG.js} +6 -6
- package/dist/react/{SketchEngine-V45O52WG.js → SketchEngine-WYUPJWK4.js} +5 -5
- package/dist/react/{SketchEngine-V45O52WG.js.map → SketchEngine-WYUPJWK4.js.map} +2 -2
- package/dist/react/index.js +1 -1
- package/package.json +1 -1
- package/src/SketchEngine.js +7 -4
- /package/dist/react/{AIRenderer-S2SKFJKT.js.map → AIRenderer-46WIFF2B.js.map} +0 -0
- /package/dist/react/{EventDispatcher-RTXLMHPL.js.map → EventDispatcher-FP2RHJGG.js.map} +0 -0
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import {
|
|
3
|
+
handleMouseDown as handleMouseDown3,
|
|
4
|
+
handleMouseMove as handleMouseMove3,
|
|
5
|
+
handleMouseUp as handleMouseUp3
|
|
6
|
+
} from "./chunk-6SFNWGGZ.js";
|
|
2
7
|
import {
|
|
3
8
|
enterEditMode,
|
|
4
9
|
handleTextMouseDown,
|
|
@@ -48,11 +53,6 @@ import {
|
|
|
48
53
|
handleMouseMove as handleMouseMove2,
|
|
49
54
|
handleMouseUp as handleMouseUp2
|
|
50
55
|
} from "./chunk-I6HCCIXB.js";
|
|
51
|
-
import {
|
|
52
|
-
handleMouseDown as handleMouseDown3,
|
|
53
|
-
handleMouseMove as handleMouseMove3,
|
|
54
|
-
handleMouseUp as handleMouseUp3
|
|
55
|
-
} from "./chunk-6SFNWGGZ.js";
|
|
56
56
|
import "./chunk-DNAG7ML6.js";
|
|
57
57
|
import {
|
|
58
58
|
handleMouseDown,
|
|
@@ -460,4 +460,4 @@ export {
|
|
|
460
460
|
handleMainMouseUp,
|
|
461
461
|
initEventDispatcher
|
|
462
462
|
};
|
|
463
|
-
//# sourceMappingURL=EventDispatcher-
|
|
463
|
+
//# sourceMappingURL=EventDispatcher-FP2RHJGG.js.map
|
|
@@ -193,6 +193,8 @@ var SketchEngine = class {
|
|
|
193
193
|
Frame,
|
|
194
194
|
FreehandStroke
|
|
195
195
|
};
|
|
196
|
+
const sceneSerializer = await import("./SceneSerializer-4U4B24JM.js");
|
|
197
|
+
if (sceneSerializer.initSceneSerializer) sceneSerializer.initSceneSerializer();
|
|
196
198
|
const [
|
|
197
199
|
rectangleTool,
|
|
198
200
|
circleTool,
|
|
@@ -238,7 +240,7 @@ var SketchEngine = class {
|
|
|
238
240
|
resizeShapes,
|
|
239
241
|
resizeCode
|
|
240
242
|
] = await Promise.all([
|
|
241
|
-
import("./EventDispatcher-
|
|
243
|
+
import("./EventDispatcher-FP2RHJGG.js"),
|
|
242
244
|
import("./UndoRedo-M2JZUBKN.js"),
|
|
243
245
|
import("./Selection-VVUHY5YJ.js"),
|
|
244
246
|
import("./ZoomPan-NYPDJBD5.js"),
|
|
@@ -271,12 +273,10 @@ var SketchEngine = class {
|
|
|
271
273
|
if (selection.multiSelection) window.multiSelection = selection.multiSelection;
|
|
272
274
|
if (selection.clearAllSelections) window.clearAllSelections = selection.clearAllSelections;
|
|
273
275
|
if (copyPaste.initCopyPaste) copyPaste.initCopyPaste();
|
|
274
|
-
const aiRenderer = await import("./AIRenderer-
|
|
276
|
+
const aiRenderer = await import("./AIRenderer-46WIFF2B.js");
|
|
275
277
|
if (aiRenderer.initAIRenderer) aiRenderer.initAIRenderer();
|
|
276
278
|
const graphEngine = await import("./GraphEngine-IHRVGUGG.js");
|
|
277
279
|
if (graphEngine.initGraphEngine) graphEngine.initGraphEngine();
|
|
278
|
-
const sceneSerializer = await import("./SceneSerializer-4U4B24JM.js");
|
|
279
|
-
if (sceneSerializer.initSceneSerializer) sceneSerializer.initSceneSerializer();
|
|
280
280
|
const layerOrder = await import("./LayerOrder-XCHF4MSS.js");
|
|
281
281
|
if (layerOrder.initLayerOrder) layerOrder.initLayerOrder();
|
|
282
282
|
const lixScript = await import("./LixScriptParser-JYWJX375.js");
|
|
@@ -410,4 +410,4 @@ export {
|
|
|
410
410
|
SketchEngine,
|
|
411
411
|
SketchEngine_default as default
|
|
412
412
|
};
|
|
413
|
-
//# sourceMappingURL=SketchEngine-
|
|
413
|
+
//# sourceMappingURL=SketchEngine-WYUPJWK4.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/SketchEngine.js"],
|
|
4
|
-
"sourcesContent": ["/* eslint-disable */\n/**\n * SketchEngine - Main engine entry point\n *\n * Initializes the SVG canvas, sets up global state (including RoughJS from npm),\n * then dynamically imports all tool and shape modules.\n *\n * IMPORTANT: All globals must be set BEFORE importing modules, because many\n * modules run code at the top level (e.g. `const rc = rough.svg(svg)`) that\n * depends on these globals existing.\n */\n\nimport rough from 'roughjs';\n\nclass SketchEngine {\n constructor(svgElement, options = {}) {\n if (!svgElement || svgElement.tagName !== 'svg') {\n throw new Error('SketchEngine requires an SVG element');\n }\n\n this.svg = svgElement;\n // Prevent default touch scrolling/gestures on the canvas to allow for custom pointer events\n this.svg.style.touchAction = 'none';\n\n this.options = {\n initialZoom: 1,\n minZoom: 0.4,\n maxZoom: 30,\n ...options\n };\n\n // Event callback for framework consumers (React, Vue, vanilla, VS Code, etc.)\n this.onEvent = options.onEvent || (() => {});\n\n // Public API surfaces (populated after init)\n this.scene = null;\n this.shapes = null;\n\n this._modules = {};\n this._initialized = false;\n }\n\n /**\n * Emit an event to the consumer callback.\n * @param {string} type - Event type (e.g. 'sidebar:select', 'zoom:change')\n * @param {*} data - Event payload\n */\n emit(type, data) {\n try { this.onEvent(type, data); } catch (e) { console.warn('[SketchEngine] onEvent error:', e); }\n }\n\n /**\n * Set up all the global variables that the tool/shape modules depend on.\n * Must be called BEFORE any module imports.\n */\n _initGlobals() {\n // Core SVG reference\n window.svg = this.svg;\n window.freehandCanvas = this.svg;\n\n // RoughJS from npm\n window.rough = rough;\n window.roughCanvas = rough.svg(this.svg);\n window.roughGenerator = window.roughCanvas.generator;\n\n // Shape storage\n window.shapes = window.shapes || [];\n window.currentShape = window.currentShape || null;\n window.lastMousePos = window.lastMousePos || null;\n\n // Zoom state\n window.currentZoom = this.options.initialZoom;\n window.minScale = this.options.minZoom;\n window.maxScale = this.options.maxZoom;\n window.minZoom = this.options.minZoom;\n window.maxZoom = this.options.maxZoom;\n\n // ViewBox state\n window.currentViewBox = window.currentViewBox || {\n x: 0, y: 0,\n width: window.innerWidth,\n height: window.innerHeight\n };\n\n // Tool activation flags\n window.isPaintToolActive = false;\n window.isTextToolActive = false;\n window.isCircleToolActive = false;\n window.isSquareToolActive = false;\n window.isLaserToolActive = false;\n window.isEraserToolActive = false;\n window.isImageToolActive = false;\n window.isArrowToolActive = false;\n window.isLineToolActive = false;\n window.isSelectionToolActive = true;\n window.isPanningToolActive = false;\n window.isFrameToolActive = false;\n window.isIconToolActive = false;\n window.isCodeToolActive = false;\n window.isTextInCodeMode = false;\n\n // Pan state\n window.isPanning = false;\n window.panStart = null;\n window.startCanvasX = 0;\n window.startCanvasY = 0;\n\n // Transform state\n window.currentMatrix = new DOMMatrix();\n window.currentTranslation = { x: 0, y: 0 };\n\n // Action type constants\n window.ACTION_CREATE = 'create';\n window.ACTION_DELETE = 'delete';\n window.ACTION_MODIFY = 'modify';\n window.ACTION_PASTE = 'paste';\n\n // History stacks\n window.historyStack = window.historyStack || [];\n window.redoStack = window.redoStack || [];\n\n // Sidebar element stubs \u2014 React sidebars handle UI, but legacy code\n // queries these at top level. Provide dummy elements so it doesn't crash.\n const dummyEl = document.createElement('div');\n dummyEl.classList.add('hidden');\n window.paintBrushSideBar = document.getElementById('paintBrushToolBar') || dummyEl;\n window.lineSideBar = document.getElementById('lineSideBar') || dummyEl;\n window.squareSideBar = document.getElementById('squareSideBar') || dummyEl;\n window.circleSideBar = document.getElementById('circleSideBar') || dummyEl;\n window.arrowSideBar = document.getElementById('arrowSideBar') || dummyEl;\n window.textSideBar = document.getElementById('textToolBar') || dummyEl;\n window.frameSideBar = document.getElementById('frameSideBar') || dummyEl;\n\n // Zoom control element refs\n window.zoomInBtn = document.getElementById('zoomIn') || dummyEl;\n window.zoomOutBtn = document.getElementById('zoomOut') || dummyEl;\n window.zoomPercentSpan = document.getElementById('zoomPercent') || dummyEl;\n\n // Container\n window.container = document.querySelector('.container') || document.body;\n\n // Sidebar control \u2014 bridge legacy code to consumer UI\n const engine = this;\n window.disableAllSideBars = function() {\n // Hide all legacy sidebar elements\n [window.paintBrushSideBar, window.lineSideBar, window.squareSideBar,\n window.circleSideBar, window.arrowSideBar, window.textSideBar, window.frameSideBar\n ].forEach(el => { if (el) el.classList.add('hidden'); });\n // Notify consumer via onEvent + legacy bridge\n engine.emit('sidebar:clear');\n if (window.__sketchStoreApi) {\n window.__sketchStoreApi.clearSelectedShapeSidebar();\n }\n };\n\n // toolExtraPopup \u2014 legacy UI function, no-op in React\n window.toolExtraPopup = window.toolExtraPopup || function() {};\n\n // updateUndoRedoButtons \u2014 legacy UI function, no-op in React\n window.updateUndoRedoButtons = window.updateUndoRedoButtons || function() {};\n\n // Bridge for shape selection -> consumer UI\n // Maps shape.shapeName to the sidebar key\n window.__showSidebarForShape = function(shapeName) {\n const sidebarMap = {\n 'rectangle': 'rectangle',\n 'circle': 'circle',\n 'arrow': 'arrow',\n 'line': 'line',\n 'freehandStroke': 'paintbrush',\n 'text': 'text',\n 'code': 'text',\n 'frame': 'frame',\n 'image': 'image',\n };\n const sidebar = sidebarMap[shapeName];\n // Emit to consumer callback\n engine.emit('sidebar:select', { sidebar, shapeName });\n // Legacy bridge for React\n if (sidebar && window.__sketchStoreApi) {\n window.__sketchStoreApi.setSelectedShapeSidebar(sidebar);\n }\n window.__selectedShapeIsCode = (shapeName === 'code');\n if (window.__onCodeModeChanged) window.__onCodeModeChanged(shapeName === 'code');\n };\n }\n\n /**\n * Initialize engine: set globals first, then import modules.\n */\n async init() {\n if (this._initialized) return;\n\n // CRITICAL: Set up ALL globals BEFORE importing modules\n this._initGlobals();\n\n try {\n // Import shape classes first\n const [\n { Rectangle },\n { Circle },\n { Arrow },\n { Line },\n { TextShape },\n { CodeShape },\n { ImageShape },\n { IconShape },\n { Frame },\n { FreehandStroke }\n ] = await Promise.all([\n import('./shapes/Rectangle.js'),\n import('./shapes/Circle.js'),\n import('./shapes/Arrow.js'),\n import('./shapes/Line.js'),\n import('./shapes/TextShape.js'),\n import('./shapes/CodeShape.js'),\n import('./shapes/ImageShape.js'),\n import('./shapes/IconShape.js'),\n import('./shapes/Frame.js'),\n import('./shapes/FreehandStroke.js')\n ]);\n\n // Expose shape classes globally\n window.Rectangle = Rectangle;\n window.Circle = Circle;\n window.Arrow = Arrow;\n window.Line = Line;\n window.TextShape = TextShape;\n window.CodeShape = CodeShape;\n window.ImageShape = ImageShape;\n window.IconShape = IconShape;\n window.Frame = Frame;\n window.FreehandStroke = FreehandStroke;\n\n this._modules.shapes = {\n Rectangle, Circle, Arrow, Line,\n TextShape, CodeShape, ImageShape, IconShape,\n Frame, FreehandStroke\n };\n\n // Import tool handlers (they run top-level code that reads globals)\n const [\n rectangleTool, circleTool, arrowTool, lineTool,\n textTool, codeTool, imageTool, iconTool,\n frameTool, freehandTool\n ] = await Promise.all([\n import('./tools/rectangleTool.js'),\n import('./tools/circleTool.js'),\n import('./tools/arrowTool.js'),\n import('./tools/lineTool.js'),\n import('./tools/textTool.js'),\n import('./tools/codeTool.js'),\n import('./tools/imageTool.js'),\n import('./tools/iconTool.js'),\n import('./tools/frameTool.js'),\n import('./tools/freehandTool.js')\n ]);\n\n this._modules.tools = {\n rectangleTool, circleTool, arrowTool, lineTool,\n textTool, codeTool, imageTool, iconTool,\n frameTool, freehandTool\n };\n\n // Import core modules (EventDispatcher attaches SVG listeners at top level)\n const [\n eventDispatcher, undoRedo, selection,\n zoomPan, copyPaste, eraserTrail,\n resizeShapes, resizeCode\n ] = await Promise.all([\n import('./core/EventDispatcher.js'),\n import('./core/UndoRedo.js'),\n import('./core/Selection.js'),\n import('./core/ZoomPan.js'),\n import('./core/CopyPaste.js'),\n import('./core/EraserTrail.js'),\n import('./core/ResizeShapes.js'),\n import('./core/ResizeCode.js')\n ]);\n\n this._modules.core = {\n eventDispatcher, undoRedo, selection,\n zoomPan, copyPaste, eraserTrail,\n resizeShapes, resizeCode\n };\n\n // Re-bind event listeners to the current SVG element\n if (eventDispatcher.initEventDispatcher) {\n eventDispatcher.initEventDispatcher(this.svg);\n }\n\n // Import standalone tools\n await Promise.all([\n import('./tools/eraserTool.js'),\n import('./tools/laserTool.js')\n ]);\n\n // Expose key functions globally\n if (undoRedo.undo) window.undo = undoRedo.undo;\n if (undoRedo.redo) window.redo = undoRedo.redo;\n if (undoRedo.pushCreateAction) window.pushCreateAction = undoRedo.pushCreateAction;\n if (undoRedo.pushDeleteAction) window.pushDeleteAction = undoRedo.pushDeleteAction;\n if (selection.multiSelection) window.multiSelection = selection.multiSelection;\n if (selection.clearAllSelections) window.clearAllSelections = selection.clearAllSelections;\n\n // Initialize centralized copy/paste system\n if (copyPaste.initCopyPaste) copyPaste.initCopyPaste();\n\n // Initialize AI renderer bridge\n const aiRenderer = await import('./core/AIRenderer.js');\n if (aiRenderer.initAIRenderer) aiRenderer.initAIRenderer();\n\n // Initialize graph engine bridge\n const graphEngine = await import('./core/GraphEngine.js');\n if (graphEngine.initGraphEngine) graphEngine.initGraphEngine();\n\n // Initialize scene serializer bridge\n const sceneSerializer = await import('./core/SceneSerializer.js');\n if (sceneSerializer.initSceneSerializer) sceneSerializer.initSceneSerializer();\n\n // Initialize layer ordering\n const layerOrder = await import('./core/LayerOrder.js');\n if (layerOrder.initLayerOrder) layerOrder.initLayerOrder();\n\n // Initialize LixScript programmatic diagram engine\n const lixScript = await import('./core/LixScriptParser.js');\n if (lixScript.initLixScriptBridge) lixScript.initLixScriptBridge();\n\n // \u2500\u2500 Public API surfaces \u2500\u2500\n\n // Scene operations (save, load, export, etc.)\n this.scene = window.__sceneSerializer || {\n save: sceneSerializer.saveScene,\n load: sceneSerializer.loadScene,\n download: sceneSerializer.downloadScene,\n upload: sceneSerializer.uploadScene,\n exportPNG: sceneSerializer.exportAsPNG,\n exportPDF: sceneSerializer.exportAsPDF,\n copyAsPNG: sceneSerializer.copyAsPNG,\n copyAsSVG: sceneSerializer.copyAsSVG,\n reset: sceneSerializer.resetCanvas,\n findText: sceneSerializer.findTextOnCanvas,\n };\n\n // Shape array reference\n this.shapes = window.shapes;\n\n // Undo/redo\n this.undo = undoRedo.undo || (() => {});\n this.redo = undoRedo.redo || (() => {});\n\n // LixScript execution\n this.lixscript = {\n parse: lixScript.parseLixScript || (() => null),\n execute: lixScript.executeLixScript || (lixScript.parseLixScript ? (code) => {\n const parsed = lixScript.parseLixScript(code);\n if (parsed && lixScript.resolveShapeRefs) lixScript.resolveShapeRefs(parsed);\n return parsed;\n } : (() => null)),\n };\n\n // Store module refs for advanced consumers\n this._modules.sceneSerializer = sceneSerializer;\n this._modules.lixScript = lixScript;\n\n this._initialized = true;\n console.log('[SketchEngine] Initialized successfully');\n } catch (err) {\n console.error('[SketchEngine] Initialization failed:', err);\n throw err;\n }\n }\n\n /**\n * Sync tool flags from Zustand activeTool value.\n */\n setActiveTool(toolName) {\n // Deselect current shape when switching tools\n if (window.currentShape && typeof window.currentShape.removeSelection === 'function') {\n window.currentShape.removeSelection();\n window.currentShape = null;\n }\n if (typeof window.clearAllSelections === 'function') {\n window.clearAllSelections();\n }\n if (typeof window.disableAllSideBars === 'function') {\n window.disableAllSideBars();\n }\n\n // Force cleanup eraser trail when switching tools\n if (typeof window.forceCleanupEraserTrail === 'function') {\n window.forceCleanupEraserTrail();\n }\n // Clean up any lingering icon miniature/drag state\n if (typeof window.__cleanupIconTool === 'function') {\n window.__cleanupIconTool();\n }\n\n window.isPaintToolActive = false;\n window.isSquareToolActive = false;\n window.isCircleToolActive = false;\n window.isArrowToolActive = false;\n window.isTextToolActive = false;\n window.isLaserToolActive = false;\n window.isLineToolActive = false;\n window.isEraserToolActive = false;\n window.isSelectionToolActive = false;\n window.isImageToolActive = false;\n window.isPanningToolActive = false;\n window.isFrameToolActive = false;\n window.isIconToolActive = false;\n window.isCodeToolActive = false;\n\n const flagMap = {\n select: 'isSelectionToolActive',\n pan: 'isPanningToolActive',\n rectangle: 'isSquareToolActive',\n circle: 'isCircleToolActive',\n line: 'isLineToolActive',\n arrow: 'isArrowToolActive',\n freehand: 'isPaintToolActive',\n text: 'isTextToolActive',\n code: 'isCodeToolActive',\n eraser: 'isEraserToolActive',\n laser: 'isLaserToolActive',\n image: 'isImageToolActive',\n frame: 'isFrameToolActive',\n icon: 'isIconToolActive',\n };\n\n const flag = flagMap[toolName];\n if (flag) window[flag] = true;\n\n if (toolName === 'text' && window.isTextInCodeMode) {\n window.isCodeToolActive = true;\n }\n\n // Show image source picker when image tool is activated\n if (toolName === 'image' && window.__showImageSourcePicker) {\n window.__showImageSourcePicker();\n }\n\n // Set appropriate cursor for the active tool\n const cursorMap = {\n select: 'default',\n pan: 'grab',\n rectangle: 'crosshair',\n circle: 'crosshair',\n line: 'crosshair',\n arrow: 'crosshair',\n freehand: 'crosshair',\n text: 'crosshair',\n code: 'crosshair',\n eraser: 'crosshair',\n laser: 'crosshair',\n image: 'crosshair',\n frame: 'crosshair',\n icon: 'crosshair',\n };\n if (this.svg) {\n this.svg.style.cursor = cursorMap[toolName] || 'default';\n }\n }\n\n cleanup() {\n // Remove event listeners from the SVG element\n if (this._modules.core?.eventDispatcher?.cleanupEventDispatcher) {\n this._modules.core.eventDispatcher.cleanupEventDispatcher();\n }\n window.shapes = [];\n window.currentShape = null;\n window.lastMousePos = null;\n this._modules = {};\n this._initialized = false;\n console.log('[SketchEngine] Cleaned up');\n }\n}\n\nexport { SketchEngine };\nexport default SketchEngine;\n"],
|
|
5
|
-
"mappings": ";;;AAYA,OAAO,WAAW;AAElB,I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AAA,QACR,EAAE,eAAe;AAAA,MACrB,IAAI,MAAM,QAAQ,IAAI;AAAA,QAClB,OAAO,yBAAuB;AAAA,QAC9B,OAAO,sBAAoB;AAAA,QAC3B,OAAO,qBAAmB;AAAA,QAC1B,OAAO,oBAAkB;AAAA,QACzB,OAAO,yBAAuB;AAAA,QAC9B,OAAO,yBAAuB;AAAA,QAC9B,OAAO,0BAAwB;AAAA,QAC/B,OAAO,yBAAuB;AAAA,QAC9B,OAAO,qBAAmB;AAAA,QAC1B,OAAO,8BAA4B;AAAA,MACvC,CAAC;AAGD,aAAO,YAAY;AACnB,aAAO,SAAS;AAChB,aAAO,QAAQ;AACf,aAAO,OAAO;AACd,aAAO,YAAY;AACnB,aAAO,YAAY;AACnB,aAAO,aAAa;AACpB,aAAO,YAAY;AACnB,aAAO,QAAQ;AACf,aAAO,iBAAiB;AAExB,WAAK,SAAS,SAAS;AAAA,QACnB;AAAA,QAAW;AAAA,QAAQ;AAAA,QAAO;AAAA,QAC1B;AAAA,QAAW;AAAA,QAAW;AAAA,QAAY;AAAA,QAClC;AAAA,QAAO;AAAA,MACX;
|
|
4
|
+
"sourcesContent": ["/* eslint-disable */\n/**\n * SketchEngine - Main engine entry point\n *\n * Initializes the SVG canvas, sets up global state (including RoughJS from npm),\n * then dynamically imports all tool and shape modules.\n *\n * IMPORTANT: All globals must be set BEFORE importing modules, because many\n * modules run code at the top level (e.g. `const rc = rough.svg(svg)`) that\n * depends on these globals existing.\n */\n\nimport rough from 'roughjs';\n\nclass SketchEngine {\n constructor(svgElement, options = {}) {\n if (!svgElement || svgElement.tagName !== 'svg') {\n throw new Error('SketchEngine requires an SVG element');\n }\n\n this.svg = svgElement;\n // Prevent default touch scrolling/gestures on the canvas to allow for custom pointer events\n this.svg.style.touchAction = 'none';\n\n this.options = {\n initialZoom: 1,\n minZoom: 0.4,\n maxZoom: 30,\n ...options\n };\n\n // Event callback for framework consumers (React, Vue, vanilla, VS Code, etc.)\n this.onEvent = options.onEvent || (() => {});\n\n // Public API surfaces (populated after init)\n this.scene = null;\n this.shapes = null;\n\n this._modules = {};\n this._initialized = false;\n }\n\n /**\n * Emit an event to the consumer callback.\n * @param {string} type - Event type (e.g. 'sidebar:select', 'zoom:change')\n * @param {*} data - Event payload\n */\n emit(type, data) {\n try { this.onEvent(type, data); } catch (e) { console.warn('[SketchEngine] onEvent error:', e); }\n }\n\n /**\n * Set up all the global variables that the tool/shape modules depend on.\n * Must be called BEFORE any module imports.\n */\n _initGlobals() {\n // Core SVG reference\n window.svg = this.svg;\n window.freehandCanvas = this.svg;\n\n // RoughJS from npm\n window.rough = rough;\n window.roughCanvas = rough.svg(this.svg);\n window.roughGenerator = window.roughCanvas.generator;\n\n // Shape storage\n window.shapes = window.shapes || [];\n window.currentShape = window.currentShape || null;\n window.lastMousePos = window.lastMousePos || null;\n\n // Zoom state\n window.currentZoom = this.options.initialZoom;\n window.minScale = this.options.minZoom;\n window.maxScale = this.options.maxZoom;\n window.minZoom = this.options.minZoom;\n window.maxZoom = this.options.maxZoom;\n\n // ViewBox state\n window.currentViewBox = window.currentViewBox || {\n x: 0, y: 0,\n width: window.innerWidth,\n height: window.innerHeight\n };\n\n // Tool activation flags\n window.isPaintToolActive = false;\n window.isTextToolActive = false;\n window.isCircleToolActive = false;\n window.isSquareToolActive = false;\n window.isLaserToolActive = false;\n window.isEraserToolActive = false;\n window.isImageToolActive = false;\n window.isArrowToolActive = false;\n window.isLineToolActive = false;\n window.isSelectionToolActive = true;\n window.isPanningToolActive = false;\n window.isFrameToolActive = false;\n window.isIconToolActive = false;\n window.isCodeToolActive = false;\n window.isTextInCodeMode = false;\n\n // Pan state\n window.isPanning = false;\n window.panStart = null;\n window.startCanvasX = 0;\n window.startCanvasY = 0;\n\n // Transform state\n window.currentMatrix = new DOMMatrix();\n window.currentTranslation = { x: 0, y: 0 };\n\n // Action type constants\n window.ACTION_CREATE = 'create';\n window.ACTION_DELETE = 'delete';\n window.ACTION_MODIFY = 'modify';\n window.ACTION_PASTE = 'paste';\n\n // History stacks\n window.historyStack = window.historyStack || [];\n window.redoStack = window.redoStack || [];\n\n // Sidebar element stubs \u2014 React sidebars handle UI, but legacy code\n // queries these at top level. Provide dummy elements so it doesn't crash.\n const dummyEl = document.createElement('div');\n dummyEl.classList.add('hidden');\n window.paintBrushSideBar = document.getElementById('paintBrushToolBar') || dummyEl;\n window.lineSideBar = document.getElementById('lineSideBar') || dummyEl;\n window.squareSideBar = document.getElementById('squareSideBar') || dummyEl;\n window.circleSideBar = document.getElementById('circleSideBar') || dummyEl;\n window.arrowSideBar = document.getElementById('arrowSideBar') || dummyEl;\n window.textSideBar = document.getElementById('textToolBar') || dummyEl;\n window.frameSideBar = document.getElementById('frameSideBar') || dummyEl;\n\n // Zoom control element refs\n window.zoomInBtn = document.getElementById('zoomIn') || dummyEl;\n window.zoomOutBtn = document.getElementById('zoomOut') || dummyEl;\n window.zoomPercentSpan = document.getElementById('zoomPercent') || dummyEl;\n\n // Container\n window.container = document.querySelector('.container') || document.body;\n\n // Sidebar control \u2014 bridge legacy code to consumer UI\n const engine = this;\n window.disableAllSideBars = function() {\n // Hide all legacy sidebar elements\n [window.paintBrushSideBar, window.lineSideBar, window.squareSideBar,\n window.circleSideBar, window.arrowSideBar, window.textSideBar, window.frameSideBar\n ].forEach(el => { if (el) el.classList.add('hidden'); });\n // Notify consumer via onEvent + legacy bridge\n engine.emit('sidebar:clear');\n if (window.__sketchStoreApi) {\n window.__sketchStoreApi.clearSelectedShapeSidebar();\n }\n };\n\n // toolExtraPopup \u2014 legacy UI function, no-op in React\n window.toolExtraPopup = window.toolExtraPopup || function() {};\n\n // updateUndoRedoButtons \u2014 legacy UI function, no-op in React\n window.updateUndoRedoButtons = window.updateUndoRedoButtons || function() {};\n\n // Bridge for shape selection -> consumer UI\n // Maps shape.shapeName to the sidebar key\n window.__showSidebarForShape = function(shapeName) {\n const sidebarMap = {\n 'rectangle': 'rectangle',\n 'circle': 'circle',\n 'arrow': 'arrow',\n 'line': 'line',\n 'freehandStroke': 'paintbrush',\n 'text': 'text',\n 'code': 'text',\n 'frame': 'frame',\n 'image': 'image',\n };\n const sidebar = sidebarMap[shapeName];\n // Emit to consumer callback\n engine.emit('sidebar:select', { sidebar, shapeName });\n // Legacy bridge for React\n if (sidebar && window.__sketchStoreApi) {\n window.__sketchStoreApi.setSelectedShapeSidebar(sidebar);\n }\n window.__selectedShapeIsCode = (shapeName === 'code');\n if (window.__onCodeModeChanged) window.__onCodeModeChanged(shapeName === 'code');\n };\n }\n\n /**\n * Initialize engine: set globals first, then import modules.\n */\n async init() {\n if (this._initialized) return;\n\n // CRITICAL: Set up ALL globals BEFORE importing modules\n this._initGlobals();\n\n try {\n // Import shape classes first\n const [\n { Rectangle },\n { Circle },\n { Arrow },\n { Line },\n { TextShape },\n { CodeShape },\n { ImageShape },\n { IconShape },\n { Frame },\n { FreehandStroke }\n ] = await Promise.all([\n import('./shapes/Rectangle.js'),\n import('./shapes/Circle.js'),\n import('./shapes/Arrow.js'),\n import('./shapes/Line.js'),\n import('./shapes/TextShape.js'),\n import('./shapes/CodeShape.js'),\n import('./shapes/ImageShape.js'),\n import('./shapes/IconShape.js'),\n import('./shapes/Frame.js'),\n import('./shapes/FreehandStroke.js')\n ]);\n\n // Expose shape classes globally\n window.Rectangle = Rectangle;\n window.Circle = Circle;\n window.Arrow = Arrow;\n window.Line = Line;\n window.TextShape = TextShape;\n window.CodeShape = CodeShape;\n window.ImageShape = ImageShape;\n window.IconShape = IconShape;\n window.Frame = Frame;\n window.FreehandStroke = FreehandStroke;\n\n this._modules.shapes = {\n Rectangle, Circle, Arrow, Line,\n TextShape, CodeShape, ImageShape, IconShape,\n Frame, FreehandStroke\n };\n\n // Expose restore as soon as the shape constructors are ready.\n // Tool handlers, AI/graph renderers, and LixScript are not needed\n // to deserialize a cached scene, so keeping the serializer behind\n // those chunks unnecessarily delayed first canvas paint.\n const sceneSerializer = await import('./core/SceneSerializer.js');\n if (sceneSerializer.initSceneSerializer) sceneSerializer.initSceneSerializer();\n\n // Import tool handlers (they run top-level code that reads globals)\n const [\n rectangleTool, circleTool, arrowTool, lineTool,\n textTool, codeTool, imageTool, iconTool,\n frameTool, freehandTool\n ] = await Promise.all([\n import('./tools/rectangleTool.js'),\n import('./tools/circleTool.js'),\n import('./tools/arrowTool.js'),\n import('./tools/lineTool.js'),\n import('./tools/textTool.js'),\n import('./tools/codeTool.js'),\n import('./tools/imageTool.js'),\n import('./tools/iconTool.js'),\n import('./tools/frameTool.js'),\n import('./tools/freehandTool.js')\n ]);\n\n this._modules.tools = {\n rectangleTool, circleTool, arrowTool, lineTool,\n textTool, codeTool, imageTool, iconTool,\n frameTool, freehandTool\n };\n\n // Import core modules (EventDispatcher attaches SVG listeners at top level)\n const [\n eventDispatcher, undoRedo, selection,\n zoomPan, copyPaste, eraserTrail,\n resizeShapes, resizeCode\n ] = await Promise.all([\n import('./core/EventDispatcher.js'),\n import('./core/UndoRedo.js'),\n import('./core/Selection.js'),\n import('./core/ZoomPan.js'),\n import('./core/CopyPaste.js'),\n import('./core/EraserTrail.js'),\n import('./core/ResizeShapes.js'),\n import('./core/ResizeCode.js')\n ]);\n\n this._modules.core = {\n eventDispatcher, undoRedo, selection,\n zoomPan, copyPaste, eraserTrail,\n resizeShapes, resizeCode\n };\n\n // Re-bind event listeners to the current SVG element\n if (eventDispatcher.initEventDispatcher) {\n eventDispatcher.initEventDispatcher(this.svg);\n }\n\n // Import standalone tools\n await Promise.all([\n import('./tools/eraserTool.js'),\n import('./tools/laserTool.js')\n ]);\n\n // Expose key functions globally\n if (undoRedo.undo) window.undo = undoRedo.undo;\n if (undoRedo.redo) window.redo = undoRedo.redo;\n if (undoRedo.pushCreateAction) window.pushCreateAction = undoRedo.pushCreateAction;\n if (undoRedo.pushDeleteAction) window.pushDeleteAction = undoRedo.pushDeleteAction;\n if (selection.multiSelection) window.multiSelection = selection.multiSelection;\n if (selection.clearAllSelections) window.clearAllSelections = selection.clearAllSelections;\n\n // Initialize centralized copy/paste system\n if (copyPaste.initCopyPaste) copyPaste.initCopyPaste();\n\n // Initialize AI renderer bridge\n const aiRenderer = await import('./core/AIRenderer.js');\n if (aiRenderer.initAIRenderer) aiRenderer.initAIRenderer();\n\n // Initialize graph engine bridge\n const graphEngine = await import('./core/GraphEngine.js');\n if (graphEngine.initGraphEngine) graphEngine.initGraphEngine();\n\n // Initialize layer ordering\n const layerOrder = await import('./core/LayerOrder.js');\n if (layerOrder.initLayerOrder) layerOrder.initLayerOrder();\n\n // Initialize LixScript programmatic diagram engine\n const lixScript = await import('./core/LixScriptParser.js');\n if (lixScript.initLixScriptBridge) lixScript.initLixScriptBridge();\n\n // \u2500\u2500 Public API surfaces \u2500\u2500\n\n // Scene operations (save, load, export, etc.)\n this.scene = window.__sceneSerializer || {\n save: sceneSerializer.saveScene,\n load: sceneSerializer.loadScene,\n download: sceneSerializer.downloadScene,\n upload: sceneSerializer.uploadScene,\n exportPNG: sceneSerializer.exportAsPNG,\n exportPDF: sceneSerializer.exportAsPDF,\n copyAsPNG: sceneSerializer.copyAsPNG,\n copyAsSVG: sceneSerializer.copyAsSVG,\n reset: sceneSerializer.resetCanvas,\n findText: sceneSerializer.findTextOnCanvas,\n };\n\n // Shape array reference\n this.shapes = window.shapes;\n\n // Undo/redo\n this.undo = undoRedo.undo || (() => {});\n this.redo = undoRedo.redo || (() => {});\n\n // LixScript execution\n this.lixscript = {\n parse: lixScript.parseLixScript || (() => null),\n execute: lixScript.executeLixScript || (lixScript.parseLixScript ? (code) => {\n const parsed = lixScript.parseLixScript(code);\n if (parsed && lixScript.resolveShapeRefs) lixScript.resolveShapeRefs(parsed);\n return parsed;\n } : (() => null)),\n };\n\n // Store module refs for advanced consumers\n this._modules.sceneSerializer = sceneSerializer;\n this._modules.lixScript = lixScript;\n\n this._initialized = true;\n console.log('[SketchEngine] Initialized successfully');\n } catch (err) {\n console.error('[SketchEngine] Initialization failed:', err);\n throw err;\n }\n }\n\n /**\n * Sync tool flags from Zustand activeTool value.\n */\n setActiveTool(toolName) {\n // Deselect current shape when switching tools\n if (window.currentShape && typeof window.currentShape.removeSelection === 'function') {\n window.currentShape.removeSelection();\n window.currentShape = null;\n }\n if (typeof window.clearAllSelections === 'function') {\n window.clearAllSelections();\n }\n if (typeof window.disableAllSideBars === 'function') {\n window.disableAllSideBars();\n }\n\n // Force cleanup eraser trail when switching tools\n if (typeof window.forceCleanupEraserTrail === 'function') {\n window.forceCleanupEraserTrail();\n }\n // Clean up any lingering icon miniature/drag state\n if (typeof window.__cleanupIconTool === 'function') {\n window.__cleanupIconTool();\n }\n\n window.isPaintToolActive = false;\n window.isSquareToolActive = false;\n window.isCircleToolActive = false;\n window.isArrowToolActive = false;\n window.isTextToolActive = false;\n window.isLaserToolActive = false;\n window.isLineToolActive = false;\n window.isEraserToolActive = false;\n window.isSelectionToolActive = false;\n window.isImageToolActive = false;\n window.isPanningToolActive = false;\n window.isFrameToolActive = false;\n window.isIconToolActive = false;\n window.isCodeToolActive = false;\n\n const flagMap = {\n select: 'isSelectionToolActive',\n pan: 'isPanningToolActive',\n rectangle: 'isSquareToolActive',\n circle: 'isCircleToolActive',\n line: 'isLineToolActive',\n arrow: 'isArrowToolActive',\n freehand: 'isPaintToolActive',\n text: 'isTextToolActive',\n code: 'isCodeToolActive',\n eraser: 'isEraserToolActive',\n laser: 'isLaserToolActive',\n image: 'isImageToolActive',\n frame: 'isFrameToolActive',\n icon: 'isIconToolActive',\n };\n\n const flag = flagMap[toolName];\n if (flag) window[flag] = true;\n\n if (toolName === 'text' && window.isTextInCodeMode) {\n window.isCodeToolActive = true;\n }\n\n // Show image source picker when image tool is activated\n if (toolName === 'image' && window.__showImageSourcePicker) {\n window.__showImageSourcePicker();\n }\n\n // Set appropriate cursor for the active tool\n const cursorMap = {\n select: 'default',\n pan: 'grab',\n rectangle: 'crosshair',\n circle: 'crosshair',\n line: 'crosshair',\n arrow: 'crosshair',\n freehand: 'crosshair',\n text: 'crosshair',\n code: 'crosshair',\n eraser: 'crosshair',\n laser: 'crosshair',\n image: 'crosshair',\n frame: 'crosshair',\n icon: 'crosshair',\n };\n if (this.svg) {\n this.svg.style.cursor = cursorMap[toolName] || 'default';\n }\n }\n\n cleanup() {\n // Remove event listeners from the SVG element\n if (this._modules.core?.eventDispatcher?.cleanupEventDispatcher) {\n this._modules.core.eventDispatcher.cleanupEventDispatcher();\n }\n window.shapes = [];\n window.currentShape = null;\n window.lastMousePos = null;\n this._modules = {};\n this._initialized = false;\n console.log('[SketchEngine] Cleaned up');\n }\n}\n\nexport { SketchEngine };\nexport default SketchEngine;\n"],
|
|
5
|
+
"mappings": ";;;AAYA,OAAO,WAAW;AAElB,IAAM,eAAN,MAAmB;AAAA,EACf,YAAY,YAAY,UAAU,CAAC,GAAG;AAClC,QAAI,CAAC,cAAc,WAAW,YAAY,OAAO;AAC7C,YAAM,IAAI,MAAM,sCAAsC;AAAA,IAC1D;AAEA,SAAK,MAAM;AAEX,SAAK,IAAI,MAAM,cAAc;AAE7B,SAAK,UAAU;AAAA,MACX,aAAa;AAAA,MACb,SAAS;AAAA,MACT,SAAS;AAAA,MACT,GAAG;AAAA,IACP;AAGA,SAAK,UAAU,QAAQ,YAAY,MAAM;AAAA,IAAC;AAG1C,SAAK,QAAQ;AACb,SAAK,SAAS;AAEd,SAAK,WAAW,CAAC;AACjB,SAAK,eAAe;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,KAAK,MAAM,MAAM;AACb,QAAI;AAAE,WAAK,QAAQ,MAAM,IAAI;AAAA,IAAG,SAAS,GAAG;AAAE,cAAQ,KAAK,iCAAiC,CAAC;AAAA,IAAG;AAAA,EACpG;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,eAAe;AAEX,WAAO,MAAM,KAAK;AAClB,WAAO,iBAAiB,KAAK;AAG7B,WAAO,QAAQ;AACf,WAAO,cAAc,MAAM,IAAI,KAAK,GAAG;AACvC,WAAO,iBAAiB,OAAO,YAAY;AAG3C,WAAO,SAA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AM;AAAA,MACN,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,OAAO;AAAA,MACP,OAAO;AAAA,MACP,MAAM;AAAA,IACV;AAEA,UAAM,OAAO,QAAQ,QAAQ;AAC7B,QAAI,KAAM,QAAO,IAAI,IAAI;AAEzB,QAAI,aAAa,UAAU,OAAO,kBAAkB;AAChD,aAAO,mBAAmB;AAAA,IAC9B;AAGA,QAAI,aAAa,WAAW,OAAO,yBAAyB;AACxD,aAAO,wBAAwB;AAAA,IACnC;AAGA,UAAM,YAAY;AAAA,MACd,QAAQ;AAAA,MACR,KAAK;AAAA,MACL,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,OAAO;AAAA,MACP,UAAU;AAAA,MACV,MAAM;AAAA,MACN,MAAM;AAAA,MACN,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,OAAO;AAAA,MACP,OAAO;AAAA,MACP,MAAM;AAAA,IACV;AACA,QAAI,KAAK,KAAK;AACV,WAAK,IAAI,MAAM,SAAS,UAAU,QAAQ,KAAK;AAAA,IACnD;AAAA,EACJ;AAAA,EAEA,UAAU;AAEN,QAAI,KAAK,SAAS,MAAM,iBAAiB,wBAAwB;AAC7D,WAAK,SAAS,KAAK,gBAAgB,uBAAuB;AAAA,IAC9D;AACA,WAAO,SAAS,CAAC;AACjB,WAAO,eAAe;AACtB,WAAO,eAAe;AACtB,SAAK,WAAW,CAAC;AACjB,SAAK,eAAe;AACpB,YAAQ,IAAI,2BAA2B;AAAA,EAC3C;AACJ;AAGA,IAAO,uBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/react/index.js
CHANGED
|
@@ -427,7 +427,7 @@ function useSketchEngine(svgRef, ready = true) {
|
|
|
427
427
|
setZoom: (zoom) => useSketchStore_default.setState({ zoom }),
|
|
428
428
|
getState: () => useSketchStore_default.getState()
|
|
429
429
|
};
|
|
430
|
-
const { SketchEngine } = await import("./SketchEngine-
|
|
430
|
+
const { SketchEngine } = await import("./SketchEngine-WYUPJWK4.js");
|
|
431
431
|
if (cancelled) return;
|
|
432
432
|
const engine = new SketchEngine(svgRef.current);
|
|
433
433
|
await engine.init();
|
package/package.json
CHANGED
package/src/SketchEngine.js
CHANGED
|
@@ -238,6 +238,13 @@ class SketchEngine {
|
|
|
238
238
|
Frame, FreehandStroke
|
|
239
239
|
};
|
|
240
240
|
|
|
241
|
+
// Expose restore as soon as the shape constructors are ready.
|
|
242
|
+
// Tool handlers, AI/graph renderers, and LixScript are not needed
|
|
243
|
+
// to deserialize a cached scene, so keeping the serializer behind
|
|
244
|
+
// those chunks unnecessarily delayed first canvas paint.
|
|
245
|
+
const sceneSerializer = await import('./core/SceneSerializer.js');
|
|
246
|
+
if (sceneSerializer.initSceneSerializer) sceneSerializer.initSceneSerializer();
|
|
247
|
+
|
|
241
248
|
// Import tool handlers (they run top-level code that reads globals)
|
|
242
249
|
const [
|
|
243
250
|
rectangleTool, circleTool, arrowTool, lineTool,
|
|
@@ -314,10 +321,6 @@ class SketchEngine {
|
|
|
314
321
|
const graphEngine = await import('./core/GraphEngine.js');
|
|
315
322
|
if (graphEngine.initGraphEngine) graphEngine.initGraphEngine();
|
|
316
323
|
|
|
317
|
-
// Initialize scene serializer bridge
|
|
318
|
-
const sceneSerializer = await import('./core/SceneSerializer.js');
|
|
319
|
-
if (sceneSerializer.initSceneSerializer) sceneSerializer.initSceneSerializer();
|
|
320
|
-
|
|
321
324
|
// Initialize layer ordering
|
|
322
325
|
const layerOrder = await import('./core/LayerOrder.js');
|
|
323
326
|
if (layerOrder.initLayerOrder) layerOrder.initLayerOrder();
|
|
File without changes
|
|
File without changes
|