@elixpo/lixsketch 4.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.
Files changed (54) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +169 -0
  3. package/fonts/fonts.css +29 -0
  4. package/fonts/lixCode.ttf +0 -0
  5. package/fonts/lixDefault.ttf +0 -0
  6. package/fonts/lixDocs.ttf +0 -0
  7. package/fonts/lixFancy.ttf +0 -0
  8. package/fonts/lixFont.woff2 +0 -0
  9. package/package.json +49 -0
  10. package/src/SketchEngine.js +473 -0
  11. package/src/core/AIRenderer.js +1390 -0
  12. package/src/core/CopyPaste.js +655 -0
  13. package/src/core/EraserTrail.js +234 -0
  14. package/src/core/EventDispatcher.js +371 -0
  15. package/src/core/GraphEngine.js +150 -0
  16. package/src/core/GraphMathParser.js +231 -0
  17. package/src/core/GraphRenderer.js +255 -0
  18. package/src/core/LayerOrder.js +91 -0
  19. package/src/core/LixScriptParser.js +1299 -0
  20. package/src/core/MermaidFlowchartRenderer.js +475 -0
  21. package/src/core/MermaidSequenceParser.js +197 -0
  22. package/src/core/MermaidSequenceRenderer.js +479 -0
  23. package/src/core/ResizeCode.js +175 -0
  24. package/src/core/ResizeShapes.js +318 -0
  25. package/src/core/SceneSerializer.js +778 -0
  26. package/src/core/Selection.js +1861 -0
  27. package/src/core/SnapGuides.js +273 -0
  28. package/src/core/UndoRedo.js +1358 -0
  29. package/src/core/ZoomPan.js +258 -0
  30. package/src/core/ai-system-prompt.js +663 -0
  31. package/src/index.js +69 -0
  32. package/src/shapes/Arrow.js +1979 -0
  33. package/src/shapes/Circle.js +751 -0
  34. package/src/shapes/CodeShape.js +244 -0
  35. package/src/shapes/Frame.js +1460 -0
  36. package/src/shapes/FreehandStroke.js +724 -0
  37. package/src/shapes/IconShape.js +265 -0
  38. package/src/shapes/ImageShape.js +270 -0
  39. package/src/shapes/Line.js +738 -0
  40. package/src/shapes/Rectangle.js +794 -0
  41. package/src/shapes/TextShape.js +225 -0
  42. package/src/tools/arrowTool.js +581 -0
  43. package/src/tools/circleTool.js +619 -0
  44. package/src/tools/codeTool.js +2103 -0
  45. package/src/tools/eraserTool.js +131 -0
  46. package/src/tools/frameTool.js +241 -0
  47. package/src/tools/freehandTool.js +620 -0
  48. package/src/tools/iconTool.js +1344 -0
  49. package/src/tools/imageTool.js +1323 -0
  50. package/src/tools/laserTool.js +317 -0
  51. package/src/tools/lineTool.js +502 -0
  52. package/src/tools/rectangleTool.js +544 -0
  53. package/src/tools/textTool.js +1823 -0
  54. package/src/utils/imageCompressor.js +107 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ayushman Bhattacharya
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,169 @@
1
+ # @lixsketch/engine
2
+
3
+ Open-source SVG whiteboard engine with a hand-drawn aesthetic. The core drawing engine behind [LixSketch](https://sketch.elixpo.com).
4
+
5
+ Build your own whiteboard, diagramming tool, or collaborative canvas with a few lines of code.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @lixsketch/engine
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```html
16
+ <svg id="my-canvas" xmlns="http://www.w3.org/2000/svg" width="100%" height="100vh"></svg>
17
+
18
+ <script type="module">
19
+ import { createSketchEngine, TOOLS } from '@lixsketch/engine';
20
+
21
+ const svg = document.getElementById('my-canvas');
22
+ svg.setAttribute('viewBox', `0 0 ${window.innerWidth} ${window.innerHeight}`);
23
+
24
+ const engine = createSketchEngine(svg, {
25
+ initialZoom: 1,
26
+ minZoom: 0.4,
27
+ maxZoom: 30,
28
+ onEvent: (type, data) => {
29
+ console.log('Engine event:', type, data);
30
+ },
31
+ });
32
+
33
+ await engine.init();
34
+ engine.setActiveTool(TOOLS.RECTANGLE);
35
+ </script>
36
+ ```
37
+
38
+ ## API
39
+
40
+ ### `createSketchEngine(svgElement, options?)`
41
+
42
+ Creates a new engine instance.
43
+
44
+ **Options:**
45
+ | Option | Type | Default | Description |
46
+ |--------|------|---------|-------------|
47
+ | `initialZoom` | `number` | `1` | Starting zoom level |
48
+ | `minZoom` | `number` | `0.4` | Minimum zoom |
49
+ | `maxZoom` | `number` | `30` | Maximum zoom |
50
+ | `onEvent` | `function` | `() => {}` | Callback for engine events |
51
+
52
+ ### Engine Instance
53
+
54
+ ```javascript
55
+ await engine.init(); // Initialize (required before use)
56
+ engine.setActiveTool('rectangle'); // Switch tool
57
+ engine.undo(); // Undo last action
58
+ engine.redo(); // Redo last undone action
59
+ engine.shapes; // Array of all shapes on canvas
60
+ engine.cleanup(); // Destroy and clean up
61
+ ```
62
+
63
+ ### Scene Operations
64
+
65
+ ```javascript
66
+ const sceneData = engine.scene.save('My Diagram'); // Serialize to JSON
67
+ engine.scene.load(sceneData); // Load from JSON
68
+ engine.scene.download('export'); // Download as .lixsketch
69
+ engine.scene.reset(); // Clear canvas
70
+ engine.scene.exportPNG(); // Export as PNG
71
+ engine.scene.exportPDF(); // Export as PDF (print)
72
+ engine.scene.copyAsPNG(); // Copy PNG to clipboard
73
+ engine.scene.copyAsSVG(); // Copy SVG to clipboard
74
+ ```
75
+
76
+ ### LixScript (Programmatic Diagrams)
77
+
78
+ ```javascript
79
+ engine.lixscript.execute(`
80
+ rect start at 200, 60 size 200x65 {
81
+ stroke: #4A90D9
82
+ label: "Start"
83
+ }
84
+
85
+ rect end at start.x, start.bottom + 150 size 200x65 {
86
+ stroke: #2ECC71
87
+ label: "End"
88
+ }
89
+
90
+ arrow a1 from start.bottom to end.top {
91
+ stroke: #e0e0e0
92
+ }
93
+ `);
94
+ ```
95
+
96
+ ### Events
97
+
98
+ The `onEvent` callback receives:
99
+
100
+ | Event | Data | Description |
101
+ |-------|------|-------------|
102
+ | `sidebar:select` | `{ sidebar, shapeName }` | Shape selected, show properties UI |
103
+ | `sidebar:clear` | - | Selection cleared |
104
+ | `zoom:change` | `number` | Zoom level changed |
105
+
106
+ ### Available Tools
107
+
108
+ ```javascript
109
+ import { TOOLS } from '@lixsketch/engine';
110
+
111
+ TOOLS.SELECT // Selection/move tool
112
+ TOOLS.PAN // Pan/hand tool
113
+ TOOLS.RECTANGLE // Rectangle drawing
114
+ TOOLS.CIRCLE // Circle/ellipse drawing
115
+ TOOLS.LINE // Line drawing
116
+ TOOLS.ARROW // Arrow drawing
117
+ TOOLS.FREEHAND // Freehand brush
118
+ TOOLS.TEXT // Text placement
119
+ TOOLS.CODE // Code block
120
+ TOOLS.ERASER // Eraser
121
+ TOOLS.LASER // Laser pointer
122
+ TOOLS.IMAGE // Image insertion
123
+ TOOLS.FRAME // Frame/artboard
124
+ TOOLS.ICON // Icon insertion
125
+ ```
126
+
127
+ ### Shape Classes
128
+
129
+ All shape classes are exported for advanced use:
130
+
131
+ ```javascript
132
+ import {
133
+ Rectangle, Circle, Arrow, Line,
134
+ TextShape, CodeShape, ImageShape,
135
+ IconShape, Frame, FreehandStroke
136
+ } from '@lixsketch/engine';
137
+ ```
138
+
139
+ ## Fonts
140
+
141
+ Optional hand-drawn fonts for the authentic LixSketch look:
142
+
143
+ ```javascript
144
+ import '@lixsketch/engine/fonts';
145
+ ```
146
+
147
+ ## File Format
148
+
149
+ The `.lixsketch` format is JSON:
150
+
151
+ ```json
152
+ {
153
+ "format": "lixsketch",
154
+ "version": 1,
155
+ "name": "My Diagram",
156
+ "shapes": [...]
157
+ }
158
+ ```
159
+
160
+ Files are fully interoperable between the web app, VS Code extension, and any custom integration.
161
+
162
+ ## Requirements
163
+
164
+ - Browser environment with DOM (or DOM-compatible like VS Code Webview)
165
+ - SVG support
166
+
167
+ ## License
168
+
169
+ MIT
@@ -0,0 +1,29 @@
1
+ @font-face {
2
+ font-family: 'lixCode';
3
+ src: url('./lixCode.ttf') format('truetype');
4
+ font-display: swap;
5
+ }
6
+
7
+ @font-face {
8
+ font-family: 'lixDefault';
9
+ src: url('./lixDefault.ttf') format('truetype');
10
+ font-display: swap;
11
+ }
12
+
13
+ @font-face {
14
+ font-family: 'lixDocs';
15
+ src: url('./lixDocs.ttf') format('truetype');
16
+ font-display: swap;
17
+ }
18
+
19
+ @font-face {
20
+ font-family: 'lixFancy';
21
+ src: url('./lixFancy.ttf') format('truetype');
22
+ font-display: swap;
23
+ }
24
+
25
+ @font-face {
26
+ font-family: 'lixFont';
27
+ src: url('./lixFont.woff2') format('woff2');
28
+ font-display: swap;
29
+ }
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@elixpo/lixsketch",
3
+ "version": "4.5.8",
4
+ "description": "Open-source SVG whiteboard engine with hand-drawn aesthetics — the core of LixSketch",
5
+ "type": "module",
6
+ "main": "src/index.js",
7
+ "exports": {
8
+ ".": "./src/index.js",
9
+ "./src/*": "./src/*",
10
+ "./fonts": "./fonts/fonts.css",
11
+ "./fonts/*": "./fonts/*"
12
+ },
13
+ "files": [
14
+ "src/",
15
+ "fonts/",
16
+ "README.md"
17
+ ],
18
+ "keywords": [
19
+ "whiteboard",
20
+ "canvas",
21
+ "svg",
22
+ "diagram",
23
+ "drawing",
24
+ "roughjs",
25
+ "sketch",
26
+ "excalidraw-alternative",
27
+ "infinite-canvas",
28
+ "framework"
29
+ ],
30
+ "author": {
31
+ "name": "Ayushman Bhattacharya",
32
+ "email": "ayushman@myceli.ai",
33
+ "url": "https://github.com/elixpo"
34
+ },
35
+ "license": "MIT",
36
+ "homepage": "https://sketch.elixpo.com",
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/elixpo/elixposketch.git",
40
+ "directory": "packages/engine"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/elixpo/elixposketch/issues"
44
+ },
45
+ "dependencies": {
46
+ "roughjs": "^4.6.6",
47
+ "perfect-freehand": "^1.2.3"
48
+ }
49
+ }