@tscircuit/schematic-viewer 2.0.56 → 2.0.57
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/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
- package/.github/workflows/bun-formatcheck.yml +0 -26
- package/.github/workflows/bun-pver-release.yml +0 -59
- package/.github/workflows/bun-typecheck.yml +0 -26
- package/.github/workflows/on-merge-inform-release-tracker.yml +0 -24
- package/CLAUDE.md +0 -1
- package/biome.json +0 -56
- package/bun.lockb +0 -0
- package/cosmos.config.json +0 -3
- package/cosmos.decorator.tsx +0 -3
- package/docs/circuit-to-svg-metadata.md +0 -151
- package/docs/dragndrop-spec.md +0 -39
- package/examples/example1-resistor-and-capacitor.fixture.tsx +0 -16
- package/examples/example10-groups-view-schematic-groups.fixture.tsx +0 -76
- package/examples/example11-automatic-grouping-view-schematic-groups.fixture.tsx +0 -109
- package/examples/example12-spice-boost-converter.fixture.tsx +0 -78
- package/examples/example13-disablegroups.fixture.tsx +0 -30
- package/examples/example14-schematic-component-click.fixture.tsx +0 -46
- package/examples/example15-analog-simulation-viewer.fixture.tsx +0 -145
- package/examples/example16-no-analog-simulation.fixture.tsx +0 -13
- package/examples/example17-schematic-ports.fixture.tsx +0 -49
- package/examples/example18-live-toggle.fixture.tsx +0 -60
- package/examples/example2-small-circuit.fixture.tsx +0 -48
- package/examples/example3-small-circuit-without-debug-grid.fixture.tsx +0 -44
- package/examples/example4-reset-edit-events.fixture.tsx +0 -57
- package/examples/example5-circuit-json-rerender.fixture.tsx +0 -110
- package/examples/example6-click-to-interact.fixture.tsx +0 -36
- package/examples/example7-schematic-viewer-fix-snapping.fixture.tsx +0 -123
- package/examples/example8-color-overrides.fixture.tsx +0 -52
- package/examples/example9-spice-rc-charging-voltage-divider.fixture.tsx +0 -77
- package/index.html +0 -12
- package/lib/components/AnalogSimulationViewer.tsx +0 -300
- package/lib/components/ControlledSchematicViewer.tsx +0 -40
- package/lib/components/EditIcon.tsx +0 -46
- package/lib/components/GridIcon.tsx +0 -45
- package/lib/components/MouseTracker.tsx +0 -257
- package/lib/components/SchematicComponentMouseTarget.tsx +0 -189
- package/lib/components/SchematicPortMouseTarget.tsx +0 -224
- package/lib/components/SchematicViewer.tsx +0 -583
- package/lib/components/SpiceIcon.tsx +0 -14
- package/lib/components/SpicePlot.tsx +0 -221
- package/lib/components/SpiceSimulationIcon.tsx +0 -32
- package/lib/components/SpiceSimulationOverlay.tsx +0 -250
- package/lib/components/ViewMenu.tsx +0 -218
- package/lib/components/ViewMenuIcon.tsx +0 -47
- package/lib/dev/render-to-circuit-json.ts +0 -8
- package/lib/hooks/use-resize-handling.ts +0 -35
- package/lib/hooks/useChangeSchematicComponentLocationsInSvg.ts +0 -117
- package/lib/hooks/useChangeSchematicTracesForMovedComponents.ts +0 -121
- package/lib/hooks/useComponentDragging.ts +0 -251
- package/lib/hooks/useLocalStorage.ts +0 -63
- package/lib/hooks/useMouseEventsOverBoundingBox.ts +0 -74
- package/lib/hooks/useSchematicGroupsOverlay.ts +0 -364
- package/lib/hooks/useSpiceSimulation.ts +0 -149
- package/lib/index.ts +0 -4
- package/lib/types/edit-events.ts +0 -16
- package/lib/types/eecircuit-engine.d.ts +0 -147
- package/lib/utils/debug.ts +0 -9
- package/lib/utils/get-component-offset-due-to-events.ts +0 -43
- package/lib/utils/spice-utils.ts +0 -128
- package/lib/utils/z-index-map.ts +0 -11
- package/lib/workers/spice-simulation.worker.ts +0 -51
- package/scripts/build-worker-blob-url.ts +0 -55
- package/src/main.tsx +0 -21
- package/tsconfig.json +0 -33
- package/tsup-webworker.config.ts +0 -13
- package/vite.config.js +0 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/schematic-viewer",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.57",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"format": "biome format --write .",
|
|
14
14
|
"format:check": "biome format ."
|
|
15
15
|
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
16
19
|
"devDependencies": {
|
|
17
20
|
"@biomejs/biome": "^1.9.4",
|
|
18
21
|
"@types/bun": "latest",
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
|
|
2
|
-
name: Format Check
|
|
3
|
-
|
|
4
|
-
on:
|
|
5
|
-
push:
|
|
6
|
-
branches: [main]
|
|
7
|
-
pull_request:
|
|
8
|
-
branches: [main]
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
format-check:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v4
|
|
16
|
-
|
|
17
|
-
- name: Setup bun
|
|
18
|
-
uses: oven-sh/setup-bun@v2
|
|
19
|
-
with:
|
|
20
|
-
bun-version: latest
|
|
21
|
-
|
|
22
|
-
- name: Install dependencies
|
|
23
|
-
run: bun install
|
|
24
|
-
|
|
25
|
-
- name: Run format check
|
|
26
|
-
run: bun run format:check
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
|
|
2
|
-
name: Publish to npm
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches:
|
|
6
|
-
- main
|
|
7
|
-
workflow_dispatch:
|
|
8
|
-
|
|
9
|
-
env:
|
|
10
|
-
UPSTREAM_REPO: "runframe" # for example: "eval"
|
|
11
|
-
PACKAGE_NAMES: "@tscircuit/schematic-viewer" # comma-separated list, e.g. "@tscircuit/core,@tscircuit/props"
|
|
12
|
-
|
|
13
|
-
jobs:
|
|
14
|
-
publish:
|
|
15
|
-
runs-on: ubuntu-latest
|
|
16
|
-
steps:
|
|
17
|
-
- uses: actions/checkout@v4
|
|
18
|
-
with:
|
|
19
|
-
token: ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
|
|
20
|
-
- name: Setup bun
|
|
21
|
-
uses: oven-sh/setup-bun@v2
|
|
22
|
-
with:
|
|
23
|
-
bun-version: latest
|
|
24
|
-
- uses: actions/setup-node@v3
|
|
25
|
-
with:
|
|
26
|
-
node-version: 20
|
|
27
|
-
registry-url: https://registry.npmjs.org/
|
|
28
|
-
- run: npm install -g pver
|
|
29
|
-
- run: bun install --frozen-lockfile
|
|
30
|
-
- run: bun run build
|
|
31
|
-
- run: pver release
|
|
32
|
-
env:
|
|
33
|
-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
34
|
-
GITHUB_TOKEN: ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}
|
|
35
|
-
- name: Trigger upstream repo update
|
|
36
|
-
if: env.UPSTREAM_REPO && env.PACKAGE_NAMES
|
|
37
|
-
run: |
|
|
38
|
-
curl -X POST \
|
|
39
|
-
-H "Accept: application/vnd.github.v3+json" \
|
|
40
|
-
-H "Authorization: token ${{ secrets.TSCIRCUIT_BOT_GITHUB_TOKEN }}" \
|
|
41
|
-
-H "Content-Type: application/json" \
|
|
42
|
-
"https://api.github.com/repos/tscircuit/${{ env.UPSTREAM_REPO }}/actions/workflows/update-package.yml/dispatches" \
|
|
43
|
-
-d "{\"ref\":\"main\",\"inputs\":{\"package_names\":\"${{ env.PACKAGE_NAMES }}\"}}"
|
|
44
|
-
- name: Notify release-tracker of version update
|
|
45
|
-
# Continue-on-error just in case the tracker is down
|
|
46
|
-
continue-on-error: true
|
|
47
|
-
run: |
|
|
48
|
-
VERSION=$(node -p "require('./package.json').version")
|
|
49
|
-
PACKAGE_JSON=$(cat package.json)
|
|
50
|
-
curl -X POST https://release-tracker.tscircuit.com/release_events/create \
|
|
51
|
-
-H "Content-Type: application/json" \
|
|
52
|
-
-d "{
|
|
53
|
-
\"event\": {
|
|
54
|
-
\"event_type\": \"versions_updated\",
|
|
55
|
-
\"repo\": \"tscircuit/schematic-viewer\",
|
|
56
|
-
\"version\": \"$VERSION\",
|
|
57
|
-
\"package_json\": $PACKAGE_JSON
|
|
58
|
-
}
|
|
59
|
-
}"
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
# Created using @tscircuit/plop (npm install -g @tscircuit/plop)
|
|
2
|
-
name: Type Check
|
|
3
|
-
|
|
4
|
-
on:
|
|
5
|
-
push:
|
|
6
|
-
branches: [main]
|
|
7
|
-
pull_request:
|
|
8
|
-
branches: [main]
|
|
9
|
-
|
|
10
|
-
jobs:
|
|
11
|
-
type-check:
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
|
|
14
|
-
steps:
|
|
15
|
-
- uses: actions/checkout@v3
|
|
16
|
-
|
|
17
|
-
- name: Setup bun
|
|
18
|
-
uses: oven-sh/setup-bun@v1
|
|
19
|
-
with:
|
|
20
|
-
bun-version: latest
|
|
21
|
-
|
|
22
|
-
- name: Install dependencies
|
|
23
|
-
run: bun i
|
|
24
|
-
|
|
25
|
-
- name: Run type check
|
|
26
|
-
run: bunx tsc --noEmit
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
name: Release Tracker - Feature Merge
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
pull_request:
|
|
5
|
-
types: [closed]
|
|
6
|
-
|
|
7
|
-
jobs:
|
|
8
|
-
track-feature-merge:
|
|
9
|
-
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main'
|
|
10
|
-
runs-on: ubuntu-latest
|
|
11
|
-
steps:
|
|
12
|
-
- name: Send feature merge event
|
|
13
|
-
continue-on-error: true
|
|
14
|
-
run: |
|
|
15
|
-
FEATURE_NAME=$(echo "${{ github.event.pull_request.user.login }}: ${{ github.event.pull_request.title }} #${{ github.event.pull_request.number }}" | jq -R .)
|
|
16
|
-
curl -X POST https://release-tracker.tscircuit.com/release_events/create \
|
|
17
|
-
-H "Content-Type: application/json" \
|
|
18
|
-
-d "{
|
|
19
|
-
\"event\": {
|
|
20
|
-
\"event_type\": \"feature_merged\",
|
|
21
|
-
\"repo\": \"tscircuit/schematic-viewer\",
|
|
22
|
-
\"feature_name\": $FEATURE_NAME
|
|
23
|
-
}
|
|
24
|
-
}"
|
package/CLAUDE.md
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
- Use `bun`/`bunx` instead of `npm`/`npx`
|
package/biome.json
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://biomejs.dev/schemas/1.9.3/schema.json",
|
|
3
|
-
"organizeImports": {
|
|
4
|
-
"enabled": true
|
|
5
|
-
},
|
|
6
|
-
"formatter": {
|
|
7
|
-
"enabled": true,
|
|
8
|
-
"indentStyle": "space"
|
|
9
|
-
},
|
|
10
|
-
"files": {
|
|
11
|
-
"ignore": ["cosmos-export", "dist", "package.json"]
|
|
12
|
-
},
|
|
13
|
-
"javascript": {
|
|
14
|
-
"formatter": {
|
|
15
|
-
"jsxQuoteStyle": "double",
|
|
16
|
-
"quoteProperties": "asNeeded",
|
|
17
|
-
"trailingCommas": "all",
|
|
18
|
-
"semicolons": "asNeeded",
|
|
19
|
-
"arrowParentheses": "always",
|
|
20
|
-
"bracketSpacing": true,
|
|
21
|
-
"bracketSameLine": false
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"linter": {
|
|
25
|
-
"enabled": true,
|
|
26
|
-
"rules": {
|
|
27
|
-
"recommended": true,
|
|
28
|
-
"suspicious": {
|
|
29
|
-
"noExplicitAny": "off"
|
|
30
|
-
},
|
|
31
|
-
"complexity": {
|
|
32
|
-
"noForEach": "off"
|
|
33
|
-
},
|
|
34
|
-
"correctness": {
|
|
35
|
-
"useExhaustiveDependencies": "off"
|
|
36
|
-
},
|
|
37
|
-
"a11y": {
|
|
38
|
-
"useKeyWithClickEvents": "off",
|
|
39
|
-
"noSvgWithoutTitle": "off"
|
|
40
|
-
},
|
|
41
|
-
"style": {
|
|
42
|
-
"noUselessElse": "off",
|
|
43
|
-
"noNonNullAssertion": "off",
|
|
44
|
-
"useNumberNamespace": "off",
|
|
45
|
-
"useFilenamingConvention": {
|
|
46
|
-
"level": "error",
|
|
47
|
-
"options": {
|
|
48
|
-
"strictCase": true,
|
|
49
|
-
"requireAscii": true,
|
|
50
|
-
"filenameCases": ["kebab-case", "export"]
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
package/bun.lockb
DELETED
|
Binary file
|
package/cosmos.config.json
DELETED
package/cosmos.decorator.tsx
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
# circuit-to-svg
|
|
2
|
-
|
|
3
|
-
Circuit to SVG is a library that's used for converting Circuit JSON into an SVG.
|
|
4
|
-
|
|
5
|
-
Circuit to SVG attaches metadata, classes and ids to the SVG elements to allow
|
|
6
|
-
for interaction.
|
|
7
|
-
|
|
8
|
-
## Metadata
|
|
9
|
-
|
|
10
|
-
- `<g data-circuit-json-type="schematic_component" data-schematic-component-id="..."` - The id of the schematic component, the
|
|
11
|
-
group contains all the relevant elements for the component.
|
|
12
|
-
- `<g data-circuit-json-type="schematic_trace" data-schematic-trace-id="..."` - The id of the schematic trace, the
|
|
13
|
-
group contains all the relevant elements for the trace.
|
|
14
|
-
|
|
15
|
-
## Example
|
|
16
|
-
|
|
17
|
-
Let's consider the following example:
|
|
18
|
-
|
|
19
|
-
```tsx
|
|
20
|
-
const MyCircuit = () => (
|
|
21
|
-
<board width="10mm" height="10mm">
|
|
22
|
-
<resistor name="R1" resistance={1000} schX={-2} />
|
|
23
|
-
<capacitor name="C1" capacitance="1uF" schX={2} />
|
|
24
|
-
<trace from=".R1 .pin2" to=".C1 .pin1" />
|
|
25
|
-
</board>
|
|
26
|
-
)
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
Will become the following SVG:
|
|
30
|
-
|
|
31
|
-
```svg
|
|
32
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="1728" height="421" style="background-color: rgb(245, 241, 237)" data-real-to-screen-transform="matrix(264.7769766545,0,0,-264.7769766545,861.6939778772,210.5)">
|
|
33
|
-
<style>
|
|
34
|
-
.boundary {
|
|
35
|
-
fill: rgb(245, 241, 237);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.schematic-boundary {
|
|
39
|
-
fill: none;
|
|
40
|
-
stroke: #fff;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.component {
|
|
44
|
-
fill: none;
|
|
45
|
-
stroke: rgb(132, 0, 0);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.chip {
|
|
49
|
-
fill: rgb(255, 255, 194);
|
|
50
|
-
stroke: rgb(132, 0, 0);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.component-pin {
|
|
54
|
-
fill: none;
|
|
55
|
-
stroke: rgb(132, 0, 0);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.trace:hover {
|
|
59
|
-
filter: invert(1);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.trace:hover .trace-crossing-outline {
|
|
63
|
-
opacity: 0;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.text {
|
|
67
|
-
font-family: sans-serif;
|
|
68
|
-
fill: rgb(0, 150, 0);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.pin-number {
|
|
72
|
-
fill: rgb(169, 0, 0);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.port-label {
|
|
76
|
-
fill: rgb(0, 100, 100);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.component-name {
|
|
80
|
-
fill: rgb(0, 100, 100);
|
|
81
|
-
}
|
|
82
|
-
</style>
|
|
83
|
-
<rect class="boundary" x="0" y="0" width="1728" height="421"></rect>
|
|
84
|
-
<g class="grid">
|
|
85
|
-
<line x1="-197.41392874079997" y1="421.0000000000242" x2="-197.41392874079997" y2="-2.4243718144134618e-11" stroke="rgb(181, 181, 181)" stroke-width="2.647769766545" stroke-opacity="0.5"></line>
|
|
86
|
-
<line x1="67.36304791370003" y1="421.0000000000242" x2="67.36304791370003" y2="-2.4243718144134618e-11" stroke="rgb(181, 181, 181)" stroke-width="2.647769766545" stroke-opacity="0.5"></line>
|
|
87
|
-
<line x1="332.14002456820003" y1="421.0000000000242" x2="332.14002456820003" y2="-2.4243718144134618e-11" stroke="rgb(181, 181, 181)" stroke-width="2.647769766545" stroke-opacity="0.5"></line>
|
|
88
|
-
<line x1="596.9170012227" y1="421.0000000000242" x2="596.9170012227" y2="-2.4243718144134618e-11" stroke="rgb(181, 181, 181)" stroke-width="2.647769766545" stroke-opacity="0.5"></line>
|
|
89
|
-
<line x1="861.6939778772" y1="421.0000000000242" x2="861.6939778772" y2="-2.4243718144134618e-11" stroke="rgb(181, 181, 181)" stroke-width="2.647769766545" stroke-opacity="0.5"></line>
|
|
90
|
-
<line x1="1126.4709545317" y1="421.0000000000242" x2="1126.4709545317" y2="-2.4243718144134618e-11" stroke="rgb(181, 181, 181)" stroke-width="2.647769766545" stroke-opacity="0.5"></line>
|
|
91
|
-
<line x1="1391.2479311862" y1="421.0000000000242" x2="1391.2479311862" y2="-2.4243718144134618e-11" stroke="rgb(181, 181, 181)" stroke-width="2.647769766545" stroke-opacity="0.5"></line>
|
|
92
|
-
<line x1="1656.0249078407" y1="421.0000000000242" x2="1656.0249078407" y2="-2.4243718144134618e-11" stroke="rgb(181, 181, 181)" stroke-width="2.647769766545" stroke-opacity="0.5"></line>
|
|
93
|
-
<line x1="1920.8018844952" y1="421.0000000000242" x2="1920.8018844952" y2="-2.4243718144134618e-11" stroke="rgb(181, 181, 181)" stroke-width="2.647769766545" stroke-opacity="0.5"></line>
|
|
94
|
-
<line x1="31.938350863210758" y1="475.2769766545" x2="1696.0616491367432" y2="475.2769766545" stroke="rgb(181, 181, 181)" stroke-width="2.647769766545" stroke-opacity="0.5"></line>
|
|
95
|
-
<line x1="31.938350863210758" y1="210.5" x2="1696.0616491367432" y2="210.5" stroke="rgb(181, 181, 181)" stroke-width="2.647769766545" stroke-opacity="0.5"></line>
|
|
96
|
-
<line x1="31.938350863210758" y1="-54.276976654500004" x2="1696.0616491367432" y2="-54.276976654500004" stroke="rgb(181, 181, 181)" stroke-width="2.647769766545" stroke-opacity="0.5"></line>
|
|
97
|
-
<text x="-199.91392874079997" y="470.2769766545" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">-4,-1</text>
|
|
98
|
-
<text x="-199.91392874079997" y="205.5" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">-4,0</text>
|
|
99
|
-
<text x="-199.91392874079997" y="-59.276976654500004" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">-4,1</text>
|
|
100
|
-
<text x="64.86304791370003" y="470.2769766545" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">-3,-1</text>
|
|
101
|
-
<text x="64.86304791370003" y="205.5" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">-3,0</text>
|
|
102
|
-
<text x="64.86304791370003" y="-59.276976654500004" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">-3,1</text>
|
|
103
|
-
<text x="329.64002456820003" y="470.2769766545" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">-2,-1</text>
|
|
104
|
-
<text x="329.64002456820003" y="205.5" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">-2,0</text>
|
|
105
|
-
<text x="329.64002456820003" y="-59.276976654500004" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">-2,1</text>
|
|
106
|
-
<text x="594.4170012227" y="470.2769766545" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">-1,-1</text>
|
|
107
|
-
<text x="594.4170012227" y="205.5" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">-1,0</text>
|
|
108
|
-
<text x="594.4170012227" y="-59.276976654500004" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">-1,1</text>
|
|
109
|
-
<text x="859.1939778772" y="470.2769766545" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">0,-1</text>
|
|
110
|
-
<text x="859.1939778772" y="205.5" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">0,0</text>
|
|
111
|
-
<text x="859.1939778772" y="-59.276976654500004" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">0,1</text>
|
|
112
|
-
<text x="1123.9709545317" y="470.2769766545" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">1,-1</text>
|
|
113
|
-
<text x="1123.9709545317" y="205.5" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">1,0</text>
|
|
114
|
-
<text x="1123.9709545317" y="-59.276976654500004" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">1,1</text>
|
|
115
|
-
<text x="1388.7479311862" y="470.2769766545" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">2,-1</text>
|
|
116
|
-
<text x="1388.7479311862" y="205.5" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">2,0</text>
|
|
117
|
-
<text x="1388.7479311862" y="-59.276976654500004" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">2,1</text>
|
|
118
|
-
<text x="1653.5249078407" y="470.2769766545" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">3,-1</text>
|
|
119
|
-
<text x="1653.5249078407" y="205.5" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">3,0</text>
|
|
120
|
-
<text x="1653.5249078407" y="-59.276976654500004" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">3,1</text>
|
|
121
|
-
<text x="1918.3018844952" y="470.2769766545" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">4,-1</text>
|
|
122
|
-
<text x="1918.3018844952" y="205.5" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">4,0</text>
|
|
123
|
-
<text x="1918.3018844952" y="-59.276976654500004" fill="rgb(181, 181, 181)" font-size="52.955395330900004" fill-opacity="0.5" text-anchor="middle" dominant-baseline="middle" font-family="sans-serif">4,1</text>
|
|
124
|
-
</g>
|
|
125
|
-
<g data-circuit-json-type="schematic_component" data-schematic-component-id="schematic_component_0" style="">
|
|
126
|
-
<rect class="component-overlay" x="196.61371724601327" y="174.45583073493046" width="280.2222914667798" height="70.05559272496805" fill="transparent"></rect>
|
|
127
|
-
<path d="M 196.61371724601327 209.48362709741448 L 266.66928349328373 209.48362709741448" stroke="rgb(132, 0, 0)" fill="none" stroke-width="5.29553953309px"></path>
|
|
128
|
-
<path d="M 406.78041598782505 209.48362709741448 L 476.83600871279305 209.48362709741448" stroke="rgb(132, 0, 0)" fill="none" stroke-width="5.29553953309px"></path>
|
|
129
|
-
<path d="M 336.7248232628566 244.5114234598985 L 406.78038951012707 244.5114234598985 L 406.78038951012707 174.45583073493046 L 266.6692305378881 174.45583073493046 L 266.6692305378881 244.5114234598985 L 336.72482326285615 244.5114234598985" stroke="rgb(132, 0, 0)" fill="none" stroke-width="5.29553953309px"></path>
|
|
130
|
-
<text x="331.762770331863" y="263.45486577694686" dominant-baseline="hanging" text-anchor="middle" font-family="sans-serif" font-size="47.659855797809996px">R1</text>
|
|
131
|
-
<text x="332.0174857834045" y="131.06743655760317" dominant-baseline="auto" text-anchor="middle" font-family="sans-serif" font-size="47.659855797809996px">1kΩ</text>
|
|
132
|
-
<circle cx="190.80453685591092" cy="209.38931353832953" r="5.29553953309px" stroke-width="5.29553953309px" fill="none" stroke="rgb(132, 0, 0)"></circle>
|
|
133
|
-
<circle cx="473.4755122804894" cy="209.2446129205882" r="5.29553953309px" stroke-width="5.29553953309px" fill="none" stroke="rgb(132, 0, 0)"></circle>
|
|
134
|
-
</g>
|
|
135
|
-
<g data-circuit-json-type="schematic_component" data-schematic-component-id="schematic_component_1" style="">
|
|
136
|
-
<rect class="component-overlay" x="1249.4875293817756" y="131.78175188522167" width="280.22229146678" height="140.11113249454112" fill="transparent"></rect>
|
|
137
|
-
<path d="M 1529.7098208485556 201.83731813249176 L 1410.6153608759655 201.83731813249176" stroke="rgb(132, 0, 0)" fill="none" stroke-width="5.29553953309px"></path>
|
|
138
|
-
<path d="M 1368.5820158320637 201.83731813249176 L 1249.4875293817756 201.83731813249176" stroke="rgb(132, 0, 0)" fill="none" stroke-width="5.29553953309px"></path>
|
|
139
|
-
<path d="M 1410.6153608759655 271.8928843797628 L 1410.6153608759655 131.78175188522167" stroke="rgb(132, 0, 0)" fill="none" stroke-width="5.29553953309px"></path>
|
|
140
|
-
<path d="M 1368.5820158320637 271.8928843797628 L 1368.5820158320637 131.78175188522167" stroke="rgb(132, 0, 0)" fill="none" stroke-width="5.29553953309px"></path>
|
|
141
|
-
<text x="1387.8417077700283" y="308.4697849218618" dominant-baseline="hanging" text-anchor="middle" font-family="sans-serif" font-size="47.659855797809996px">C1</text>
|
|
142
|
-
<text x="1390.2284074375918" y="86.05251741268826" dominant-baseline="auto" text-anchor="middle" font-family="sans-serif" font-size="47.659855797809996px">1µF</text>
|
|
143
|
-
<circle cx="1245.3003992283566" cy="201.5983039556664" r="5.29553953309px" stroke-width="5.29553953309px" fill="none" stroke="rgb(132, 0, 0)"></circle>
|
|
144
|
-
<circle cx="1537.1954631440433" cy="201.74300457340775" r="5.29553953309px" stroke-width="5.29553953309px" fill="none" stroke="rgb(132, 0, 0)"></circle>
|
|
145
|
-
</g>
|
|
146
|
-
<g class="trace" data-circuit-json-type="schematic_trace" data-schematic-trace-id="schematic_trace_0">
|
|
147
|
-
<path d="M 473.47551228048934 209.2446129205882 L 1205.5838527301817 209.2446129205882 L 1245.3003992283566 209.2446129205882 L 1245.3003992283566 201.59830395566638" class="trace-invisible-hover-outline" stroke="rgb(0, 150, 0)" fill="none" stroke-width="42.36431626472px" stroke-linecap="round" opacity="0" stroke-linejoin="round"></path>
|
|
148
|
-
<path d="M 473.47551228048934 209.2446129205882 L 1205.5838527301817 209.2446129205882 L 1245.3003992283566 209.2446129205882 L 1245.3003992283566 201.59830395566638" stroke="rgb(0, 150, 0)" fill="none" stroke-width="5.29553953309px" stroke-linecap="round" stroke-linejoin="round"></path>
|
|
149
|
-
</g>
|
|
150
|
-
</svg>
|
|
151
|
-
```
|
package/docs/dragndrop-spec.md
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# Drag and Drop Feature Specification
|
|
2
|
-
|
|
3
|
-
Drag'n'drop allows users to move schematic components inside the schematic
|
|
4
|
-
viewer.
|
|
5
|
-
|
|
6
|
-
It uses the "edit event architecture" to manage edits. Here's how it works:
|
|
7
|
-
|
|
8
|
-
- When the user starts dragging a component, there is an `activeEditEvent` that
|
|
9
|
-
specifies the component to be moved
|
|
10
|
-
- When the user releases the mouse button, the `activeEditEvent` is committed
|
|
11
|
-
via the `onEditEvent` callback
|
|
12
|
-
- The schematic viewer applies any edit events passed to it via the `editEvents`
|
|
13
|
-
prop
|
|
14
|
-
|
|
15
|
-
## Types
|
|
16
|
-
|
|
17
|
-
The following is an excerpt from the types of the `@tscircuit/props` package,
|
|
18
|
-
which should be imported.
|
|
19
|
-
|
|
20
|
-
```tsx
|
|
21
|
-
export interface BaseManualEditEvent {
|
|
22
|
-
edit_event_id: string
|
|
23
|
-
in_progress?: boolean
|
|
24
|
-
created_at: number
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export interface EditSchematicComponentLocationEvent
|
|
28
|
-
extends BaseManualEditEvent {
|
|
29
|
-
edit_event_type: "edit_schematic_component_location"
|
|
30
|
-
schematic_component_id: string
|
|
31
|
-
original_center: { x: number; y: number }
|
|
32
|
-
new_center: { x: number; y: number }
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type ManualEditEvent =
|
|
36
|
-
| EditPcbComponentLocationEvent
|
|
37
|
-
| EditTraceHintEvent
|
|
38
|
-
| EditSchematicComponentLocationEvent
|
|
39
|
-
```
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { ControlledSchematicViewer } from "lib/components/ControlledSchematicViewer"
|
|
2
|
-
import { renderToCircuitJson } from "lib/dev/render-to-circuit-json"
|
|
3
|
-
|
|
4
|
-
export default () => (
|
|
5
|
-
<ControlledSchematicViewer
|
|
6
|
-
circuitJson={renderToCircuitJson(
|
|
7
|
-
<board width="10mm" height="10mm">
|
|
8
|
-
<resistor name="R1" resistance={1000} schX={-2} />
|
|
9
|
-
<capacitor name="C1" capacitance="1uF" schX={2} />
|
|
10
|
-
<trace from=".R1 .pin2" to=".C1 .pin1" />
|
|
11
|
-
</board>,
|
|
12
|
-
)}
|
|
13
|
-
containerStyle={{ height: "100%" }}
|
|
14
|
-
debugGrid
|
|
15
|
-
/>
|
|
16
|
-
)
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { SchematicViewer } from "lib/components/SchematicViewer"
|
|
2
|
-
import { renderToCircuitJson } from "lib/dev/render-to-circuit-json"
|
|
3
|
-
|
|
4
|
-
const circuitJson = renderToCircuitJson(
|
|
5
|
-
<board>
|
|
6
|
-
<group schX={-10} schY={10} name="Alpha Node">
|
|
7
|
-
<resistor resistance="1k" footprint="0402" name="R1" schX={3} />
|
|
8
|
-
<capacitor capacitance="1000pF" footprint="0402" name="C1" schX={-3} />
|
|
9
|
-
<trace from=".R1 > .pin1" to=".C1 > .pin1" />
|
|
10
|
-
</group>
|
|
11
|
-
|
|
12
|
-
<group schX={15} schY={-5} name="Blue Bridge">
|
|
13
|
-
<resistor resistance="4.7k" footprint="0603" name="R2" schX={2} />
|
|
14
|
-
<capacitor capacitance="220nF" footprint="0603" name="C2" schX={-2} />
|
|
15
|
-
<trace from=".R2 > .pin1" to=".C2 > .pin1" />
|
|
16
|
-
</group>
|
|
17
|
-
|
|
18
|
-
<group schX={-20} schY={-15} name="Copper Point">
|
|
19
|
-
<resistor resistance="10k" footprint="0805" name="R3" schX={1} />
|
|
20
|
-
</group>
|
|
21
|
-
|
|
22
|
-
<group schX={5} schY={20} name="Echo Ridge">
|
|
23
|
-
<capacitor capacitance="10uF" footprint="0805" name="C4" schX={-1} />
|
|
24
|
-
</group>
|
|
25
|
-
|
|
26
|
-
<group schX={12} schY={12} name="Delta Gate">
|
|
27
|
-
<resistor resistance="220" footprint="0402" name="R5" schX={3} />
|
|
28
|
-
<capacitor capacitance="470pF" footprint="0402" name="C5" schX={-3} />
|
|
29
|
-
<trace from=".R5 > .pin1" to=".C5 > .pin1" />
|
|
30
|
-
</group>
|
|
31
|
-
|
|
32
|
-
<group schX={-8} schY={-8} name="Flux Node">
|
|
33
|
-
<resistor resistance="330" footprint="0603" name="R6" schX={2} />
|
|
34
|
-
</group>
|
|
35
|
-
|
|
36
|
-
<group schX={18} schY={-12} name="Silver Pad">
|
|
37
|
-
<capacitor capacitance="1uF" footprint="0603" name="C7" schX={-2} />
|
|
38
|
-
</group>
|
|
39
|
-
|
|
40
|
-
<group schX={-14} schY={6} name="Gamma Port">
|
|
41
|
-
<resistor resistance="5.6k" footprint="0402" name="R8" schX={2} />
|
|
42
|
-
<capacitor capacitance="330pF" footprint="0402" name="C8" schX={-2} />
|
|
43
|
-
<trace from=".R8 > .pin1" to=".C8 > .pin1" />
|
|
44
|
-
</group>
|
|
45
|
-
|
|
46
|
-
{/* Nested group example */}
|
|
47
|
-
<group schX={-5} schY={-18} name="Orion Hub">
|
|
48
|
-
<resistor resistance="2k" footprint="0402" name="R9" schX={2} />
|
|
49
|
-
<capacitor capacitance="2.2uF" footprint="0603" name="C9" schX={-2} />
|
|
50
|
-
<trace from=".R9 > .pin1" to=".C9 > .pin1" />
|
|
51
|
-
|
|
52
|
-
<group schX={3} schY={-3} name="Nova Cell">
|
|
53
|
-
<resistor resistance="6.8k" footprint="0402" name="R10" schX={1} />
|
|
54
|
-
<capacitor capacitance="150pF" footprint="0402" name="C10" schX={-1} />
|
|
55
|
-
<trace from=".R10 > .pin1" to=".C10 > .pin1" />
|
|
56
|
-
</group>
|
|
57
|
-
</group>
|
|
58
|
-
</board>,
|
|
59
|
-
)
|
|
60
|
-
|
|
61
|
-
export default () => {
|
|
62
|
-
return (
|
|
63
|
-
<div style={{ position: "relative", height: "100%" }}>
|
|
64
|
-
<SchematicViewer
|
|
65
|
-
circuitJson={circuitJson}
|
|
66
|
-
containerStyle={{
|
|
67
|
-
width: "100vw",
|
|
68
|
-
height: "100vh",
|
|
69
|
-
backgroundColor: "#f8f9fa",
|
|
70
|
-
}}
|
|
71
|
-
debugGrid={false}
|
|
72
|
-
editingEnabled={false}
|
|
73
|
-
/>
|
|
74
|
-
</div>
|
|
75
|
-
)
|
|
76
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import { SchematicViewer } from "lib/components/SchematicViewer"
|
|
2
|
-
import { renderToCircuitJson } from "lib/dev/render-to-circuit-json"
|
|
3
|
-
|
|
4
|
-
const circuitJson = renderToCircuitJson(
|
|
5
|
-
<board width="60mm" height="40mm">
|
|
6
|
-
{/* Multiple Resistors - Will form "Resistors" group */}
|
|
7
|
-
<group name="Resistors">
|
|
8
|
-
<resistor name="R1" resistance={1000} schX={-15} schY={5} />
|
|
9
|
-
<resistor name="R2" resistance={2200} schX={-10} schY={5} />
|
|
10
|
-
<resistor name="R3" resistance={4700} schX={-5} schY={5} />
|
|
11
|
-
<resistor name="R4" resistance={330} schX={0} schY={8} />
|
|
12
|
-
<resistor name="R5" resistance={220} schX={5} schY={8} />
|
|
13
|
-
</group>
|
|
14
|
-
|
|
15
|
-
{/* Multiple Capacitors - Will form "Capacitors" group */}
|
|
16
|
-
<group name="Capacitors">
|
|
17
|
-
<capacitor name="C1" capacitance="100uF" schX={-15} schY={0} />
|
|
18
|
-
<capacitor name="C2" capacitance="10uF" schX={-10} schY={0} />
|
|
19
|
-
<capacitor name="C3" capacitance="1uF" schX={-5} schY={0} />
|
|
20
|
-
<capacitor name="C4" capacitance="100nF" schX={0} schY={0} />
|
|
21
|
-
</group>
|
|
22
|
-
|
|
23
|
-
{/* Multiple ICs/Chips - Will form "Chips" group */}
|
|
24
|
-
<group name="Chips">
|
|
25
|
-
<chip
|
|
26
|
-
name="U1"
|
|
27
|
-
footprint="soic8"
|
|
28
|
-
schX={10}
|
|
29
|
-
schY={5}
|
|
30
|
-
pinLabels={{
|
|
31
|
-
"1": "VIN",
|
|
32
|
-
"2": "GND",
|
|
33
|
-
"3": "EN",
|
|
34
|
-
"4": "VOUT",
|
|
35
|
-
}}
|
|
36
|
-
/>
|
|
37
|
-
<chip
|
|
38
|
-
name="U2"
|
|
39
|
-
footprint="soic14"
|
|
40
|
-
schX={15}
|
|
41
|
-
schY={5}
|
|
42
|
-
pinLabels={{
|
|
43
|
-
"1": "IN",
|
|
44
|
-
"2": "OUT",
|
|
45
|
-
"3": "VCC",
|
|
46
|
-
"4": "GND",
|
|
47
|
-
}}
|
|
48
|
-
/>
|
|
49
|
-
<chip
|
|
50
|
-
name="U3"
|
|
51
|
-
footprint="sot23"
|
|
52
|
-
schX={20}
|
|
53
|
-
schY={5}
|
|
54
|
-
pinLabels={{
|
|
55
|
-
"1": "A",
|
|
56
|
-
"2": "B",
|
|
57
|
-
"3": "C",
|
|
58
|
-
}}
|
|
59
|
-
/>
|
|
60
|
-
</group>
|
|
61
|
-
|
|
62
|
-
{/* Multiple LEDs - Will form "Leds" group */}
|
|
63
|
-
<group name="Leds">
|
|
64
|
-
<led name="LED1" schX={10} schY={0} />
|
|
65
|
-
<led name="LED2" schX={15} schY={0} />
|
|
66
|
-
<led name="LED3" schX={20} schY={0} />
|
|
67
|
-
</group>
|
|
68
|
-
|
|
69
|
-
{/* Multiple Inductors - Will form "Inductors" group */}
|
|
70
|
-
<group name="Inductors">
|
|
71
|
-
<inductor name="L1" inductance="100uH" schX={-15} schY={-5} />
|
|
72
|
-
<inductor name="L2" inductance="22uH" schX={-10} schY={-5} />
|
|
73
|
-
</group>
|
|
74
|
-
|
|
75
|
-
{/* Multiple Diodes - Will form "Diodes" group */}
|
|
76
|
-
<group name="Diodes">
|
|
77
|
-
<diode name="D1" schX={-5} schY={-5} />
|
|
78
|
-
<diode name="D2" schX={0} schY={-5} />
|
|
79
|
-
</group>
|
|
80
|
-
|
|
81
|
-
{/* Some connections */}
|
|
82
|
-
<trace from=".R1 .pin2" to=".R2 .pin1" />
|
|
83
|
-
<trace from=".R2 .pin2" to=".R3 .pin1" />
|
|
84
|
-
<trace from=".C1 .pin1" to=".U1 .pin1" />
|
|
85
|
-
<trace from=".C2 .pin1" to=".U2 .pin3" />
|
|
86
|
-
<trace from=".U1 .pin4" to=".LED1 .pin1" />
|
|
87
|
-
<trace from=".U2 .pin2" to=".LED2 .pin1" />
|
|
88
|
-
<trace from=".R4 .pin1" to=".LED1 .pin2" />
|
|
89
|
-
<trace from=".R5 .pin1" to=".LED2 .pin2" />
|
|
90
|
-
<trace from=".L1 .pin1" to=".D1 .pin1" />
|
|
91
|
-
<trace from=".L2 .pin1" to=".D2 .pin1" />
|
|
92
|
-
</board>,
|
|
93
|
-
)
|
|
94
|
-
export default () => {
|
|
95
|
-
return (
|
|
96
|
-
<div style={{ position: "relative", height: "100%" }}>
|
|
97
|
-
<SchematicViewer
|
|
98
|
-
circuitJson={circuitJson}
|
|
99
|
-
containerStyle={{
|
|
100
|
-
width: "100%",
|
|
101
|
-
height: "100%",
|
|
102
|
-
backgroundColor: "#f8f9fa",
|
|
103
|
-
}}
|
|
104
|
-
debugGrid={false}
|
|
105
|
-
editingEnabled={false}
|
|
106
|
-
/>
|
|
107
|
-
</div>
|
|
108
|
-
)
|
|
109
|
-
}
|