@sketchmark/plugin-circuit 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/LICENSE +21 -0
- package/README.md +52 -0
- package/dist/index.cjs +833 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +830 -0
- package/dist/index.js.map +1 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) sketchmark contributors
|
|
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,52 @@
|
|
|
1
|
+
# @sketchmark/plugin-circuit
|
|
2
|
+
|
|
3
|
+
Primitive circuit diagrams for Sketchmark.
|
|
4
|
+
|
|
5
|
+
This first release stays draw-focused. It compiles `ckt.*` commands into ordinary Sketchmark groups, `path` nodes, `circle` nodes, and `text` nodes, so the core renderer does not need circuit-specific logic.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install sketchmark @sketchmark/plugin-circuit
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { render } from "sketchmark";
|
|
17
|
+
import { circuit } from "@sketchmark/plugin-circuit";
|
|
18
|
+
|
|
19
|
+
render({
|
|
20
|
+
container: document.getElementById("diagram")!,
|
|
21
|
+
dsl: `
|
|
22
|
+
diagram
|
|
23
|
+
ckt.port vin x=80 y=140 label="Vin"
|
|
24
|
+
ckt.comp r1 kind=resistor x=220 y=140 label="R1" value="10k"
|
|
25
|
+
ckt.comp c1 kind=capacitor x=380 y=140 orient=v label="C1" value="100n"
|
|
26
|
+
ckt.comp gnd kind=ground x=380 y=260
|
|
27
|
+
ckt.port vout x=520 y=140 label="Vout"
|
|
28
|
+
|
|
29
|
+
ckt.wire w1 from=vin to=r1.left
|
|
30
|
+
ckt.wire w2 from=r1.right to=vout
|
|
31
|
+
ckt.wire w3 from=r1.right to=c1.top
|
|
32
|
+
ckt.wire w4 from=c1.bottom to=gnd.top
|
|
33
|
+
end
|
|
34
|
+
`.trim(),
|
|
35
|
+
plugins: [circuit()],
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Supported Commands
|
|
40
|
+
|
|
41
|
+
- `ckt.comp <id> kind=<resistor|capacitor|inductor|diode|source|ground|switch> x=<n> y=<n> [label="..."] [label-dx=<n>] [label-dy=<n>]`
|
|
42
|
+
- `ckt.port <id> x=<n> y=<n> [label="..."] [label-dx=<n>] [label-dy=<n>]`
|
|
43
|
+
- `ckt.junction <id> x=<n> y=<n> [label="..."] [label-dx=<n>] [label-dy=<n>]`
|
|
44
|
+
- `ckt.wire <id> from=<ref> to=<ref> [mode=straight|hv|vh|auto] [label="..."] [label-dx=<n>] [label-dy=<n>]`
|
|
45
|
+
|
|
46
|
+
## Notes
|
|
47
|
+
|
|
48
|
+
- `ckt.comp`, `ckt.port`, and `ckt.junction` use `x` / `y` as their center point in circuit space.
|
|
49
|
+
- The plugin auto-inserts `layout absolute` if the diagram does not declare a layout yet.
|
|
50
|
+
- If a diagram already declares a layout, it must be `layout absolute`.
|
|
51
|
+
- Wire refs can target ports and junctions directly, or component pins like `r1.left`, `r1.right`, `c1.top`, `c1.bottom`, or `d1.anode`.
|
|
52
|
+
- This version does not do validation, simulation, or automatic circuit solving.
|