@tscircuit/schematic-viewer 1.2.12 → 1.2.13

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.
@@ -1,9 +1,10 @@
1
- import type { StorybookConfig } from "@storybook/nextjs"
1
+ import type { StorybookConfig } from "@storybook/react-vite"
2
+
2
3
  const config: StorybookConfig = {
3
4
  stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
4
5
  addons: [],
5
6
  framework: {
6
- name: "@storybook/nextjs",
7
+ name: "@storybook/react-vite",
7
8
  options: {},
8
9
  },
9
10
  docs: {},
package/dist/index.d.ts CHANGED
@@ -1,12 +1,16 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { AnySoupElement } from '@tscircuit/soup';
3
+
1
4
  interface SchematicProps {
2
5
  children?: any;
3
6
  /** @deprecated use soup */
4
7
  elements?: any;
5
- soup?: any;
8
+ soup?: AnySoupElement[];
6
9
  style?: any;
7
10
  showTable?: boolean;
11
+ _soupPostProcessor?: (soup: AnySoupElement[]) => AnySoupElement[];
8
12
  }
9
- declare const Schematic: (props: SchematicProps) => JSX.Element;
10
- declare const SchematicWithoutContext: ({ children, elements: initialElements, soup: initialSoup, style, showTable, }: SchematicProps) => JSX.Element;
13
+ declare const Schematic: (props: SchematicProps) => react_jsx_runtime.JSX.Element;
14
+ declare const SchematicWithoutContext: ({ children, elements: initialElements, soup: initialSoup, style, showTable, _soupPostProcessor, }: SchematicProps) => react_jsx_runtime.JSX.Element;
11
15
 
12
16
  export { Schematic, SchematicProps, SchematicWithoutContext };
package/dist/index.js CHANGED
@@ -941,47 +941,62 @@ module.exports = __toCommonJS(src_exports);
941
941
  // src/Schematic.tsx
942
942
  var import_react9 = require("react");
943
943
 
944
- // node_modules/zustand/esm/vanilla.js
944
+ // node_modules/zustand/esm/vanilla.mjs
945
+ var import_meta = {};
945
946
  var createStoreImpl = (createState) => {
946
947
  let state;
947
948
  const listeners = /* @__PURE__ */ new Set();
948
949
  const setState = (partial, replace) => {
949
950
  const nextState = typeof partial === "function" ? partial(state) : partial;
950
- if (nextState !== state) {
951
+ if (!Object.is(nextState, state)) {
951
952
  const previousState = state;
952
- state = replace ? nextState : Object.assign({}, state, nextState);
953
+ state = (replace != null ? replace : typeof nextState !== "object" || nextState === null) ? nextState : Object.assign({}, state, nextState);
953
954
  listeners.forEach((listener) => listener(state, previousState));
954
955
  }
955
956
  };
956
957
  const getState = () => state;
958
+ const getInitialState = () => initialState;
957
959
  const subscribe = (listener) => {
958
960
  listeners.add(listener);
959
961
  return () => listeners.delete(listener);
960
962
  };
961
- const destroy = () => listeners.clear();
962
- const api = { setState, getState, subscribe, destroy };
963
- state = createState(
964
- setState,
965
- getState,
966
- api
967
- );
963
+ const destroy = () => {
964
+ if ((import_meta.env ? import_meta.env.MODE : void 0) !== "production") {
965
+ console.warn(
966
+ "[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."
967
+ );
968
+ }
969
+ listeners.clear();
970
+ };
971
+ const api = { setState, getState, getInitialState, subscribe, destroy };
972
+ const initialState = state = createState(setState, getState, api);
968
973
  return api;
969
974
  };
970
975
  var createStore = (createState) => createState ? createStoreImpl(createState) : createStoreImpl;
971
976
 
972
- // node_modules/zustand/esm/index.js
973
- var import_react = require("react");
974
- var import_with_selector = __toESM(require_with_selector());
977
+ // node_modules/zustand/esm/index.mjs
978
+ var import_react = __toESM(require("react"), 1);
979
+ var import_with_selector = __toESM(require_with_selector(), 1);
980
+ var import_meta2 = {};
981
+ var { useDebugValue } = import_react.default;
975
982
  var { useSyncExternalStoreWithSelector } = import_with_selector.default;
976
- function useStore(api, selector = api.getState, equalityFn) {
983
+ var didWarnAboutEqualityFn = false;
984
+ var identity = (arg) => arg;
985
+ function useStore(api, selector = identity, equalityFn) {
986
+ if ((import_meta2.env ? import_meta2.env.MODE : void 0) !== "production" && equalityFn && !didWarnAboutEqualityFn) {
987
+ console.warn(
988
+ "[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"
989
+ );
990
+ didWarnAboutEqualityFn = true;
991
+ }
977
992
  const slice = useSyncExternalStoreWithSelector(
978
993
  api.subscribe,
979
994
  api.getState,
980
- api.getServerState || api.getState,
995
+ api.getServerState || api.getInitialState,
981
996
  selector,
982
997
  equalityFn
983
998
  );
984
- (0, import_react.useDebugValue)(slice);
999
+ useDebugValue(slice);
985
1000
  return slice;
986
1001
  }
987
1002
 
@@ -1814,7 +1829,10 @@ var SchematicBug = ({ component: { source, schematic } }) => {
1814
1829
  d: `M ${-bugw / 2} ${-bugh / 2} L ${bugw / 2} ${-bugh / 2} L ${bugw / 2} ${bugh / 2} L ${-bugw / 2} ${bugh / 2}Z`
1815
1830
  },
1816
1831
  ...port_indices.map((portNum) => {
1817
- const pos = (0, import_builder2.getPortPosition)(port_arrangement, portNum);
1832
+ const pos = (0, import_builder2.getPortPosition)(
1833
+ { ...port_arrangement, pin_spacing: schematic.pin_spacing },
1834
+ portNum
1835
+ );
1818
1836
  const x2 = pos.side === "left" ? -bugw / 2 : pos.side === "right" ? bugw / 2 : pos.x;
1819
1837
  const y2 = pos.side === "top" ? bugh / 2 : pos.side === "bottom" ? -bugh / 2 : pos.y;
1820
1838
  return {
@@ -2216,7 +2234,8 @@ var SchematicWithoutContext = ({
2216
2234
  elements: initialElements,
2217
2235
  soup: initialSoup,
2218
2236
  style,
2219
- showTable = false
2237
+ showTable = false,
2238
+ _soupPostProcessor
2220
2239
  }) => {
2221
2240
  initialSoup = initialSoup ?? initialElements ?? [];
2222
2241
  const [elements, setElements] = (0, import_react9.useState)(initialSoup ?? []);
@@ -2261,6 +2280,9 @@ var SchematicWithoutContext = ({
2261
2280
  }
2262
2281
  const projectBuilder = (0, import_builder3.createProjectBuilder)();
2263
2282
  (import_react_fiber.createRoot ?? import_react_fiber.default.createRoot)().render(children, projectBuilder).then(async (elements2) => {
2283
+ if (_soupPostProcessor) {
2284
+ elements2 = _soupPostProcessor(elements2);
2285
+ }
2264
2286
  setElementsAndCamera(elements2);
2265
2287
  }).catch((e) => {
2266
2288
  console.error("ERROR RENDERING CIRCUIT");