Skip to content

Commit

Permalink
chore: dependency update
Browse files Browse the repository at this point in the history
  • Loading branch information
imrishabh18 committed Sep 26, 2024
1 parent 347f988 commit 869fa33
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 27 deletions.
31 changes: 30 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
35 changes: 16 additions & 19 deletions src/Schematic.tsx
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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) => {
Expand Down Expand Up @@ -84,29 +81,29 @@ 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))
setTransform(
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(() => {
Expand Down
6 changes: 3 additions & 3 deletions src/lib/utils/collect-element-refs.ts
Original file line number Diff line number Diff line change
@@ -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) =>
Expand Down
6 changes: 3 additions & 3 deletions src/schematic-components/SchematicElement.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
Expand Down

0 comments on commit 869fa33

Please sign in to comment.