@tscircuit/core 0.0.104 → 0.0.106
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.d.ts +10 -2
- package/dist/index.js +32 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactElement } from 'react';
|
|
1
|
+
import React, { ReactElement } from 'react';
|
|
2
2
|
import * as zod from 'zod';
|
|
3
3
|
import { ZodType, z } from 'zod';
|
|
4
4
|
import { SchSymbol, BaseSymbolName } from 'schematic-symbols';
|
|
@@ -73,6 +73,7 @@ declare class Circuit {
|
|
|
73
73
|
render(): void;
|
|
74
74
|
getSoup(): AnyCircuitElement[];
|
|
75
75
|
getCircuitJson(): AnyCircuitElement[];
|
|
76
|
+
toJson(): AnyCircuitElement[];
|
|
76
77
|
getSvg(options: {
|
|
77
78
|
view: "pcb";
|
|
78
79
|
layer?: string;
|
|
@@ -4598,6 +4599,13 @@ declare class FabricationNotePath extends PrimitiveComponent<typeof fabricationN
|
|
|
4598
4599
|
doInitialPcbPrimitiveRender(): void;
|
|
4599
4600
|
}
|
|
4600
4601
|
|
|
4602
|
+
declare const useRenderedCircuit: (reactElements: React.ReactElement) => {
|
|
4603
|
+
isLoading: boolean;
|
|
4604
|
+
error?: Error | null;
|
|
4605
|
+
circuit?: Circuit;
|
|
4606
|
+
circuitJson?: AnyCircuitElement[];
|
|
4607
|
+
};
|
|
4608
|
+
|
|
4601
4609
|
declare global {
|
|
4602
4610
|
namespace JSX {
|
|
4603
4611
|
interface IntrinsicElements {
|
|
@@ -4644,4 +4652,4 @@ declare global {
|
|
|
4644
4652
|
}
|
|
4645
4653
|
}
|
|
4646
4654
|
|
|
4647
|
-
export { Board, Capacitor, Chip, Circuit, Constraint, Diode, FabricationNotePath, FabricationNoteText, Footprint, Group, Hole, type IRenderable, Jumper, Keepout, Led, Net, NormalComponent, PlatedHole, Port, PrimitiveComponent, Project, Renderable, Resistor, SilkscreenPath, SilkscreenText, SmtPad, Trace, TraceHint };
|
|
4655
|
+
export { Board, Capacitor, Chip, Circuit, Constraint, Diode, FabricationNotePath, FabricationNoteText, Footprint, Group, Hole, type IRenderable, Jumper, Keepout, Led, Net, NormalComponent, PlatedHole, Port, PrimitiveComponent, Project, Renderable, Resistor, SilkscreenPath, SilkscreenText, SmtPad, Trace, TraceHint, useRenderedCircuit };
|
package/dist/index.js
CHANGED
|
@@ -3868,6 +3868,9 @@ var Circuit = class {
|
|
|
3868
3868
|
getCircuitJson() {
|
|
3869
3869
|
return this.getSoup();
|
|
3870
3870
|
}
|
|
3871
|
+
toJson() {
|
|
3872
|
+
return this.getSoup();
|
|
3873
|
+
}
|
|
3871
3874
|
async getSvg(options) {
|
|
3872
3875
|
const circuitToSvg = await import("circuit-to-svg").catch((e) => {
|
|
3873
3876
|
throw new Error(
|
|
@@ -3897,6 +3900,33 @@ var Circuit = class {
|
|
|
3897
3900
|
};
|
|
3898
3901
|
var Project = Circuit;
|
|
3899
3902
|
|
|
3903
|
+
// lib/hooks/use-rendered-circuit.ts
|
|
3904
|
+
import React from "react";
|
|
3905
|
+
var useRenderedCircuit = (reactElements) => {
|
|
3906
|
+
const [isLoading, setIsLoading] = React.useState(true);
|
|
3907
|
+
const [error, setError] = React.useState(null);
|
|
3908
|
+
const [circuit, setCircuit] = React.useState();
|
|
3909
|
+
const [circuitJson, setCircuitJson] = React.useState();
|
|
3910
|
+
React.useEffect(() => {
|
|
3911
|
+
setIsLoading(true);
|
|
3912
|
+
setError(null);
|
|
3913
|
+
if (reactElements) {
|
|
3914
|
+
setTimeout(() => {
|
|
3915
|
+
try {
|
|
3916
|
+
const circuit2 = new Circuit();
|
|
3917
|
+
circuit2.add(reactElements);
|
|
3918
|
+
setCircuit(circuit2);
|
|
3919
|
+
setCircuitJson(circuit2.toJson());
|
|
3920
|
+
} catch (error2) {
|
|
3921
|
+
setError(error2);
|
|
3922
|
+
}
|
|
3923
|
+
setIsLoading(false);
|
|
3924
|
+
}, 1);
|
|
3925
|
+
}
|
|
3926
|
+
}, [reactElements]);
|
|
3927
|
+
return { isLoading, error, circuit, circuitJson };
|
|
3928
|
+
};
|
|
3929
|
+
|
|
3900
3930
|
// lib/register-catalogue.ts
|
|
3901
3931
|
extendCatalogue(components_exports);
|
|
3902
3932
|
extendCatalogue({
|
|
@@ -3929,5 +3959,6 @@ export {
|
|
|
3929
3959
|
SilkscreenText,
|
|
3930
3960
|
SmtPad,
|
|
3931
3961
|
Trace,
|
|
3932
|
-
TraceHint
|
|
3962
|
+
TraceHint,
|
|
3963
|
+
useRenderedCircuit
|
|
3933
3964
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.106",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@tscircuit/infgrid-ijump-astar": "^0.0.21",
|
|
40
40
|
"@tscircuit/math-utils": "^0.0.4",
|
|
41
41
|
"@tscircuit/props": "^0.0.68",
|
|
42
|
-
"@tscircuit/soup-util": "^0.0.
|
|
42
|
+
"@tscircuit/soup-util": "^0.0.32",
|
|
43
43
|
"circuit-json": "^0.0.83",
|
|
44
44
|
"circuit-json-to-connectivity-map": "^0.0.17",
|
|
45
45
|
"@tscircuit/footprinter": "^0.0.66",
|