@codefrydev/svg-engine 0.1.0
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/README.md +57 -0
- package/dist/chunk-KRCGD3CL.js +2794 -0
- package/dist/editor.cjs +5864 -0
- package/dist/editor.d.cts +77 -0
- package/dist/editor.d.ts +77 -0
- package/dist/editor.js +3060 -0
- package/dist/index.cjs +2829 -0
- package/dist/index.d.cts +28 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +24 -0
- package/dist/types-BTYLCn9x.d.cts +100 -0
- package/dist/types-BTYLCn9x.d.ts +100 -0
- package/dist/wc.cjs +1 -0
- package/dist/wc.d.cts +151 -0
- package/dist/wc.d.ts +151 -0
- package/dist/wc.iife.js +354 -0
- package/dist/wc.js +1 -0
- package/package.json +59 -0
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# `@codefrydev/svg-engine`
|
|
2
|
+
|
|
3
|
+
React SVG diagram renderer and editor (library + optional web component bundle).
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @codefrydev/svg-engine
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peers: `react` and `react-dom` ≥ 18.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
**Read-only**
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { Renderer } from "@codefrydev/svg-engine";
|
|
19
|
+
|
|
20
|
+
<Renderer elements={elements} className="w-full h-[400px]" />
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Editor**
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { Editor } from "@codefrydev/svg-engine/editor";
|
|
27
|
+
|
|
28
|
+
<Editor preset="mechanics" />
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Presets include `mechanics`, `circuit`, `thermo`, `optical`, `magnetism`, `light`, `waves`, `waveOscillation`, `rotation`, `graph`, `electrostatics`, `chemistry`, `mechanical` (see `presets` export from `@codefrydev/svg-engine/editor`).
|
|
32
|
+
|
|
33
|
+
**Custom element types**
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import { registerRenderer } from "@codefrydev/svg-engine";
|
|
37
|
+
|
|
38
|
+
registerRenderer("my_box", (el) => (
|
|
39
|
+
<rect x={el.x1} y={el.y1} width={80} height={40} fill="#fde68a" stroke="#92400e" />
|
|
40
|
+
));
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Tailwind
|
|
44
|
+
|
|
45
|
+
Editor UI uses Tailwind classes. Point your Tailwind `content` at this package’s `dist` files (e.g. `./node_modules/@codefrydev/svg-engine/dist/**/*.{js,cjs,mjs}`) so utilities are generated.
|
|
46
|
+
|
|
47
|
+
## Web component (`@codefrydev/svg-engine/wc`)
|
|
48
|
+
|
|
49
|
+
Loads React-included IIFE/ESM; registers `<codefrydev-svg-engine>` (editor) and `<codefrydev-svg-engine-prev>` (preview). CDN: `https://unpkg.com/@codefrydev/svg-engine/dist/wc.iife.js`. Host page still needs Tailwind (or equivalent) for editor chrome.
|
|
50
|
+
|
|
51
|
+
## Develop
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npm run typecheck
|
|
55
|
+
npm run build # lib + wc
|
|
56
|
+
cd examples/playground && npm run dev
|
|
57
|
+
```
|