@tscircuit/runframe 0.0.440 → 0.0.442

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.
@@ -1092,7 +1092,7 @@ var RenderLogViewer = ({
1092
1092
  };
1093
1093
 
1094
1094
  // package.json
1095
- var version = "0.0.439";
1095
+ var version = "0.0.441";
1096
1096
 
1097
1097
  // lib/components/CircuitJsonPreview/CircuitJsonPreview.tsx
1098
1098
  import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
@@ -1717,6 +1717,7 @@ import { QueryClient, QueryClientProvider } from "react-query";
1717
1717
 
1718
1718
  // lib/components/OrderDialog/InitialOrder.tsx
1719
1719
  import { Loader2 as Loader22 } from "lucide-react";
1720
+ import { GitHubLogoIcon as GitHubLogoIcon2 } from "@radix-ui/react-icons";
1720
1721
  import { useEffect as useEffect3, useState as useState6 } from "react";
1721
1722
 
1722
1723
  // lib/components/OrderDialog/VendorQuoteCard.tsx
@@ -1833,12 +1834,12 @@ var createOrderQuote = async (packageReleaseId) => {
1833
1834
  }
1834
1835
  }).json();
1835
1836
  return order_quote_id;
1836
- } catch (err) {
1837
- if (err instanceof HTTPError) {
1838
- const errorBody = await err.response.json();
1839
- throw new Error(errorBody.message || err.message);
1837
+ } catch (error) {
1838
+ if (error instanceof HTTPError) {
1839
+ const errorBody = await error.response.json();
1840
+ throw errorBody;
1840
1841
  }
1841
- throw err;
1842
+ throw error;
1842
1843
  }
1843
1844
  };
1844
1845
  var getOrderQuote = async (orderQuoteId) => {
@@ -1854,12 +1855,7 @@ var getOrderQuote = async (orderQuoteId) => {
1854
1855
  var useCreateOrderQuote = (packageReleaseId) => {
1855
1856
  return useMutation({
1856
1857
  mutationFn: async () => {
1857
- try {
1858
- return await createOrderQuote(packageReleaseId);
1859
- } catch (error) {
1860
- console.error("Error creating order quote:", error);
1861
- throw error instanceof Error ? error : new Error("Failed to create order quote");
1862
- }
1858
+ return await createOrderQuote(packageReleaseId);
1863
1859
  }
1864
1860
  });
1865
1861
  };
@@ -1897,14 +1893,14 @@ var useOrderQuotePolling = (orderQuoteId) => {
1897
1893
  import { Fragment as Fragment3, jsx as jsx19, jsxs as jsxs15 } from "react/jsx-runtime";
1898
1894
  var InitialOrderScreen = ({
1899
1895
  onCancel,
1900
- packageReleaseId
1896
+ packageReleaseId,
1897
+ signIn
1901
1898
  }) => {
1902
1899
  const [selectedShippingCarrier, setSelectedShippingCarrier] = useState6(null);
1903
1900
  const {
1904
1901
  mutate: createOrderQuote2,
1905
1902
  data: orderQuoteId,
1906
- error: createOrderQuoteError,
1907
- isError
1903
+ error: createOrderQuoteError
1908
1904
  } = useCreateOrderQuote(packageReleaseId);
1909
1905
  const { data: orderQuote } = useOrderQuotePolling(orderQuoteId);
1910
1906
  const redirectToStripeCheckout = async (orderQuoteId2) => {
@@ -1929,10 +1925,14 @@ var InitialOrderScreen = ({
1929
1925
  useEffect3(() => {
1930
1926
  createOrderQuote2();
1931
1927
  }, [packageReleaseId, createOrderQuote2]);
1928
+ const isNoTokenError = (createOrderQuoteError?.error_code?.includes("no_token") || orderQuote?.error?.error_code?.includes("no_token")) && signIn;
1929
+ if (isNoTokenError) {
1930
+ return /* @__PURE__ */ jsx19(SignInView, { signIn });
1931
+ }
1932
1932
  return /* @__PURE__ */ jsxs15("div", { className: "rf-max-w-lg rf-mx-auto rf-bg-white rf-rounded-2xl rf-py-8 rf-flex rf-flex-col rf-gap-3", children: [
1933
1933
  /* @__PURE__ */ jsx19("h2", { className: "rf-text-3xl rf-font-bold rf-text-center", children: "Order PCB" }),
1934
- (!orderQuoteId || !orderQuote || !orderQuote?.is_completed) && !isError && /* @__PURE__ */ jsx19(LoadingMessage, { message: "Fetching quotes..." }),
1935
- (createOrderQuoteError || orderQuote?.error || isError) && /* @__PURE__ */ jsx19(
1934
+ (!orderQuoteId || !orderQuote || orderQuote?.is_processing && !orderQuote?.error) && /* @__PURE__ */ jsx19(LoadingMessage, { message: "Fetching quotes..." }),
1935
+ (createOrderQuoteError || orderQuote?.error) && /* @__PURE__ */ jsx19(
1936
1936
  ErrorMessage,
1937
1937
  {
1938
1938
  message: createOrderQuoteError?.message || orderQuote?.error?.message || "Failed to fetch quotes"
@@ -1989,6 +1989,16 @@ var LoadingMessage = ({ message }) => /* @__PURE__ */ jsxs15("div", { className:
1989
1989
  /* @__PURE__ */ jsx19("p", { className: "rf-text-gray-600", children: message })
1990
1990
  ] });
1991
1991
  var ErrorMessage = ({ message }) => /* @__PURE__ */ jsx19("div", { className: "rf-text-red-600 rf-text-center rf-py-12", children: message });
1992
+ var SignInView = ({ signIn }) => /* @__PURE__ */ jsxs15("div", { className: "rf-max-w-lg rf-mx-auto rf-bg-white rf-rounded-2xl rf-py-8 rf-flex rf-flex-col rf-gap-3", children: [
1993
+ /* @__PURE__ */ jsx19("h2", { className: "rf-text-3xl rf-font-bold rf-text-center", children: "Order PCB" }),
1994
+ /* @__PURE__ */ jsxs15("div", { className: "rf-flex rf-flex-col rf-items-center rf-gap-4 rf-py-8", children: [
1995
+ /* @__PURE__ */ jsx19("p", { className: "rf-text-gray-600", children: "Please sign in to continue" }),
1996
+ /* @__PURE__ */ jsxs15(Button, { onClick: signIn, className: "rf-flex rf-items-center rf-gap-2", children: [
1997
+ /* @__PURE__ */ jsx19(GitHubLogoIcon2, { className: "rf-w-5 rf-h-5" }),
1998
+ "Sign in with GitHub"
1999
+ ] })
2000
+ ] })
2001
+ ] });
1992
2002
 
1993
2003
  // lib/components/OrderDialog/OrderDialog.tsx
1994
2004
  import { jsx as jsx20 } from "react/jsx-runtime";
@@ -1999,7 +2009,8 @@ var OrderDialog = ({
1999
2009
  stage,
2000
2010
  setStage,
2001
2011
  circuitJson,
2002
- packageReleaseId
2012
+ packageReleaseId,
2013
+ signIn
2003
2014
  }) => {
2004
2015
  return /* @__PURE__ */ jsx20(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx20(
2005
2016
  Dialog,
@@ -2012,7 +2023,9 @@ var OrderDialog = ({
2012
2023
  InitialOrderScreen,
2013
2024
  {
2014
2025
  onCancel: onClose,
2015
- packageReleaseId: packageReleaseId ?? ""
2026
+ packageReleaseId: packageReleaseId ?? "",
2027
+ signIn: signIn ?? (() => {
2028
+ })
2016
2029
  }
2017
2030
  ) }) })
2018
2031
  }
@@ -2025,12 +2038,14 @@ var CliOrderDialog = ({
2025
2038
  isOpen,
2026
2039
  onClose,
2027
2040
  stage,
2028
- setStage
2041
+ setStage,
2042
+ signIn
2029
2043
  }) => {
2030
2044
  const circuitJson = useRunFrameStore((state) => state.circuitJson);
2031
2045
  return /* @__PURE__ */ jsx21(
2032
2046
  OrderDialog,
2033
2047
  {
2048
+ signIn,
2034
2049
  isOpen,
2035
2050
  onClose,
2036
2051
  stage,
@@ -2042,6 +2057,7 @@ var CliOrderDialog = ({
2042
2057
 
2043
2058
  // lib/components/OrderDialog/useOrderDialog.tsx
2044
2059
  import { useState as useState7 } from "react";
2060
+ import { jsx as jsx22 } from "react/jsx-runtime";
2045
2061
  var useOrderDialogCli = () => {
2046
2062
  const [isOpen, setIsOpen] = useState7(false);
2047
2063
  const [stage, setStage] = useState7("initial");
@@ -2058,7 +2074,7 @@ var useOrderDialogCli = () => {
2058
2074
  OrderDialog: CliOrderDialog
2059
2075
  };
2060
2076
  };
2061
- var useOrderDialog = () => {
2077
+ var useOrderDialog = (signIn) => {
2062
2078
  useStyles();
2063
2079
  const [isOpen, setIsOpen] = useState7(false);
2064
2080
  const [stage, setStage] = useState7("initial");
@@ -2072,7 +2088,7 @@ var useOrderDialog = () => {
2072
2088
  open: () => setIsOpen(true),
2073
2089
  close: handleClose,
2074
2090
  setStage,
2075
- OrderDialog
2091
+ OrderDialog: (props) => /* @__PURE__ */ jsx22(OrderDialog, { ...props, signIn })
2076
2092
  };
2077
2093
  };
2078
2094
 
package/dist/preview.d.ts CHANGED
@@ -2,7 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import { ManualEditEvent } from '@tscircuit/props';
3
3
  import { CircuitJson, AnyCircuitElement } from 'circuit-json';
4
4
  import * as react from 'react';
5
- import { ComponentProps } from 'react';
5
+ import { ComponentProps, FC } from 'react';
6
6
  import { PCBViewer } from '@tscircuit/pcb-viewer';
7
7
  export { PCBViewer as PcbViewer } from '@tscircuit/pcb-viewer';
8
8
  export { CadViewer } from '@tscircuit/3d-viewer';
@@ -87,21 +87,24 @@ declare const PcbViewerWithContainerHeight: ({ containerClassName, ...props }: {
87
87
  containerClassName?: string;
88
88
  } & ComponentProps<typeof PCBViewer>) => react_jsx_runtime.JSX.Element;
89
89
 
90
- interface OrderDialogProps {
90
+ interface CliOrderDialogProps {
91
91
  isOpen: boolean;
92
92
  onClose: () => void;
93
93
  stage: "initial" | "progress" | "checkout";
94
94
  setStage: (stage: "initial" | "progress" | "checkout") => void;
95
- circuitJson?: CircuitJson;
96
- packageReleaseId?: string;
95
+ signIn?: () => void;
97
96
  }
98
97
 
99
- interface CliOrderDialogProps {
98
+ interface OrderDialogProps {
100
99
  isOpen: boolean;
101
100
  onClose: () => void;
102
101
  stage: "initial" | "progress" | "checkout";
103
102
  setStage: (stage: "initial" | "progress" | "checkout") => void;
103
+ circuitJson?: CircuitJson;
104
+ packageReleaseId?: string;
105
+ signIn?: () => void;
104
106
  }
107
+ declare const OrderDialog: FC<OrderDialogProps>;
105
108
 
106
109
  type OrderStage = "initial" | "progress" | "checkout";
107
110
  declare const useOrderDialogCli: () => {
@@ -112,13 +115,13 @@ declare const useOrderDialogCli: () => {
112
115
  setStage: react.Dispatch<react.SetStateAction<OrderStage>>;
113
116
  OrderDialog: react.FC<CliOrderDialogProps>;
114
117
  };
115
- declare const useOrderDialog: () => {
118
+ declare const useOrderDialog: (signIn: () => void) => {
116
119
  isOpen: boolean;
117
120
  stage: OrderStage;
118
121
  open: () => void;
119
122
  close: () => void;
120
123
  setStage: react.Dispatch<react.SetStateAction<OrderStage>>;
121
- OrderDialog: react.FC<OrderDialogProps>;
124
+ OrderDialog: (props: Omit<Parameters<typeof OrderDialog>[0], "signIn">) => react_jsx_runtime.JSX.Element;
122
125
  };
123
126
 
124
127
  export { BomTable, CircuitJsonPreview, PcbViewerWithContainerHeight, type PreviewContentProps, type TabId, linkify, useOrderDialog, useOrderDialogCli };
package/dist/preview.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  linkify,
9
9
  useOrderDialog,
10
10
  useOrderDialogCli
11
- } from "./chunk-6PJZCBDT.js";
11
+ } from "./chunk-MP2RYG4Y.js";
12
12
  export {
13
13
  BomTable,
14
14
  CadViewer,
package/dist/runner.js CHANGED
@@ -26,7 +26,7 @@ import {
26
26
  useOrderDialog,
27
27
  useOrderDialogCli,
28
28
  useRunFrameStore
29
- } from "./chunk-6PJZCBDT.js";
29
+ } from "./chunk-MP2RYG4Y.js";
30
30
 
31
31
  // lib/components/RunFrame/RunFrame.tsx
32
32
  import { createCircuitWebWorker } from "@tscircuit/eval/worker";