From 869fa336423bf214741f7f9da6d52f81eb549432 Mon Sep 17 00:00:00 2001 From: Rishabh Gupta Date: Thu, 26 Sep 2024 19:56:44 +0530 Subject: [PATCH 1/2] chore: dependency update --- package-lock.json | 31 +++++++++++++++- package.json | 2 +- src/Schematic.tsx | 35 +++++++++---------- src/lib/utils/collect-element-refs.ts | 6 ++-- src/schematic-components/SchematicElement.tsx | 6 ++-- 5 files changed, 53 insertions(+), 27 deletions(-) diff --git a/package-lock.json b/package-lock.json index b672427..eda6177 100644 --- a/package-lock.json +++ b/package-lock.json @@ -34,13 +34,13 @@ "@tscircuit/builder": "^1.5.126", "@tscircuit/react-fiber": "^1.1.29", "@tscircuit/routing": "^1.3.0", - "@tscircuit/soup": "^0.0.41", "@tscircuit/table-viewer": "^0.0.6", "@types/node": "^18.6.0", "@types/react": "^18.0.15", "@vitejs/plugin-react": "^4.3.0", "ava": "^4.3.1", "chromatic": "^11.5.5", + "circuit-json": "^0.0.82", "esbuild": "^0.20.2", "esbuild-register": "^3.5.0", "next": "^14.2.3", @@ -7818,6 +7818,7 @@ "version": "0.0.41", "resolved": "https://registry.npmjs.org/@tscircuit/soup/-/soup-0.0.41.tgz", "integrity": "sha512-fhJeq3EWnL4KGF8WgbHgb8Cx5/q44/hp3qQxTHDz5Z0cWZgXWM8sf88pWpLFsZejIgO3DWBgjQrlADzyll8A7w==", + "peer": true, "dependencies": { "convert-units": "^2.3.4", "zod": "^3.23.6" @@ -10072,6 +10073,34 @@ "safe-buffer": "^5.0.1" } }, + "node_modules/circuit-json": { + "version": "0.0.82", + "resolved": "https://registry.npmjs.org/circuit-json/-/circuit-json-0.0.82.tgz", + "integrity": "sha512-YyPOLz+pzVgiUkzq/mFfmfhRpa2hM/rgAgOzTBHQYGtzOaXGeQceHcM9aCGmnCz6pMhk1vYkZzuBrzv4XpLazg==", + "dev": true, + "dependencies": { + "nanoid": "^5.0.7", + "zod": "^3.23.6" + } + }, + "node_modules/circuit-json/node_modules/nanoid": { + "version": "5.0.7", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-5.0.7.tgz", + "integrity": "sha512-oLxFY2gd2IqnjcYyOXD8XGCftpGtZP2AbHbOkthDkvRywH5ayNtPVy9YlOPcHckXzbLTCHpkb7FB+yuxKV13pQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "bin": { + "nanoid": "bin/nanoid.js" + }, + "engines": { + "node": "^18 || >=20" + } + }, "node_modules/citty": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/citty/-/citty-0.1.6.tgz", diff --git a/package.json b/package.json index 6375255..1e0b5bf 100644 --- a/package.json +++ b/package.json @@ -38,13 +38,13 @@ "@tscircuit/builder": "^1.5.126", "@tscircuit/react-fiber": "^1.1.29", "@tscircuit/routing": "^1.3.0", - "@tscircuit/soup": "^0.0.41", "@tscircuit/table-viewer": "^0.0.6", "@types/node": "^18.6.0", "@types/react": "^18.0.15", "@vitejs/plugin-react": "^4.3.0", "ava": "^4.3.1", "chromatic": "^11.5.5", + "circuit-json": "^0.0.82", "esbuild": "^0.20.2", "esbuild-register": "^3.5.0", "next": "^14.2.3", diff --git a/src/Schematic.tsx b/src/Schematic.tsx index 4334074..9556cda 100644 --- a/src/Schematic.tsx +++ b/src/Schematic.tsx @@ -1,24 +1,21 @@ -import { useCallback, useEffect, useState } from "react" -import { ContextProviders, ProjectComponent } from "schematic-components" -import { SuperGrid, toMMSI } from "react-supergrid" import { AnyElement, createProjectBuilder, createProjectFromElements, findBoundsAndCenter, - transformSchematicElement, } from "@tscircuit/builder" -import * as builder1 from "@tscircuit/builder" import TscReactFiber, { createRoot } from "@tscircuit/react-fiber" -import { SchematicElement } from "schematic-components/SchematicElement" -import { collectElementRefs } from "lib/utils/collect-element-refs" -import { useMouseMatrixTransform } from "use-mouse-matrix-transform" -import { ErrorBoundary as TypedErrorBoundary } from "react-error-boundary" -import { identity, compose, scale, translate } from "transformation-matrix" +import { AnyCircuitElement } from "circuit-json" import { useGlobalStore } from "lib/render-context" +import { useCallback, useEffect, useState } from "react" +import { ErrorBoundary as TypedErrorBoundary } from "react-error-boundary" +import { SuperGrid, toMMSI } from "react-supergrid" import useMeasure from "react-use-measure" +import { ContextProviders } from "schematic-components" +import { SchematicElement } from "schematic-components/SchematicElement" +import { compose, scale, translate } from "transformation-matrix" +import { useMouseMatrixTransform } from "use-mouse-matrix-transform" import { TableViewer } from "./schematic-components/TableViewer" -import { AnySoupElement } from "@tscircuit/soup" const ErrorBoundary = TypedErrorBoundary as any @@ -41,13 +38,13 @@ export interface SchematicProps { /** @deprecated use soup */ elements?: any - soup?: AnySoupElement[] + soup?: AnyCircuitElement[] style?: any showTable?: boolean - _soupPostProcessor?: (soup: AnySoupElement[]) => AnySoupElement[] + _soupPostProcessor?: (soup: AnyCircuitElement[]) => AnyCircuitElement[] } export const Schematic = (props: SchematicProps) => { @@ -84,17 +81,17 @@ export const SchematicWithoutContext = ({ const elmBounds = (ref.current as HTMLDivElement).getBoundingClientRect() const { center, width, height } = elements.some((e) => - e.type.startsWith("schematic_") + e.type.startsWith("schematic_"), ) ? findBoundsAndCenter( - elements.filter((e) => e.type.startsWith("schematic_")) + elements.filter((e) => e.type.startsWith("schematic_")), ) : { center: { x: 0, y: 0 }, width: 0.001, height: 0.001 } const scaleFactor = Math.min( (elmBounds.width ?? 0) / width, (elmBounds.height ?? 0) / height, - 100 + 100, ) setElements(elements) setProject(createProjectFromElements(elements)) @@ -102,11 +99,11 @@ export const SchematicWithoutContext = ({ compose( translate((elmBounds.width ?? 0) / 2, (elmBounds.height ?? 0) / 2), scale(scaleFactor, -scaleFactor, 0, 0), - translate(-center.x, -center.y) - ) + translate(-center.x, -center.y), + ), ) }, - [setElements, setTransform] + [setElements, setTransform], ) useEffect(() => { diff --git a/src/lib/utils/collect-element-refs.ts b/src/lib/utils/collect-element-refs.ts index 8089b4d..d6537b0 100644 --- a/src/lib/utils/collect-element-refs.ts +++ b/src/lib/utils/collect-element-refs.ts @@ -1,8 +1,8 @@ -import { AnySoupElement, SourcePort } from "@tscircuit/soup" +import { AnyCircuitElement, SourcePort } from "circuit-json" export const collectElementRefs = ( - elm: AnySoupElement, - allElms: AnySoupElement[] + elm: AnyCircuitElement, + allElms: AnyCircuitElement[] ) => { const source_port = allElms.find( (e) => diff --git a/src/schematic-components/SchematicElement.tsx b/src/schematic-components/SchematicElement.tsx index 3e5ca53..8d7ce3e 100644 --- a/src/schematic-components/SchematicElement.tsx +++ b/src/schematic-components/SchematicElement.tsx @@ -1,4 +1,4 @@ -import { AnySoupElement } from "@tscircuit/soup" +import { AnyCircuitElement } from "circuit-json" import { collectElementRefs } from "lib/utils/collect-element-refs" import SchematicBox from "./SchematicBox" import SchematicComponent from "./SchematicComponent" @@ -16,8 +16,8 @@ export const SchematicElement = ({ element, allElements, }: { - element: AnySoupElement - allElements: AnySoupElement[] + element: AnyCircuitElement + allElements: AnyCircuitElement[] }) => { // A lot of the split logic for element types into a project is here: // https://github.com/tscircuit/builder/blob/7e7bef9c0aadd11999795003b8986f0d244c111f/src/lib/project/create-project-from-elements.ts#L13 From 105828cadcd9162b62eefa51ad1a621ba51b0c78 Mon Sep 17 00:00:00 2001 From: Rishabh Gupta Date: Thu, 26 Sep 2024 20:52:25 +0530 Subject: [PATCH 2/2] type fix --- src/stories/led-circuit-builder.stories.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stories/led-circuit-builder.stories.tsx b/src/stories/led-circuit-builder.stories.tsx index 3280b28..094924f 100644 --- a/src/stories/led-circuit-builder.stories.tsx +++ b/src/stories/led-circuit-builder.stories.tsx @@ -95,7 +95,7 @@ const $soup = pb export const LEDCircuitBuilder = () => { const soup = useMaybePromise($soup) if (!soup) return null - return + return } export default {