@tscircuit/runframe 0.0.402 → 0.0.404
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/{chunk-4CPXFF2B.js → chunk-LAPOUJI2.js} +40 -19
- package/dist/preview.js +1 -1
- package/dist/runner.js +1 -1
- package/dist/standalone-preview.min.js +1 -1
- package/dist/standalone.min.js +349 -349
- package/package.json +2 -2
|
@@ -1092,7 +1092,7 @@ var RenderLogViewer = ({
|
|
|
1092
1092
|
};
|
|
1093
1093
|
|
|
1094
1094
|
// package.json
|
|
1095
|
-
var version = "0.0.
|
|
1095
|
+
var version = "0.0.403";
|
|
1096
1096
|
|
|
1097
1097
|
// lib/components/CircuitJsonPreview/CircuitJsonPreview.tsx
|
|
1098
1098
|
import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
@@ -1788,15 +1788,24 @@ var registryKy = {
|
|
|
1788
1788
|
import { useMutation } from "react-query";
|
|
1789
1789
|
|
|
1790
1790
|
// lib/api/order-quotes.ts
|
|
1791
|
+
import { HTTPError } from "ky";
|
|
1791
1792
|
var createOrderQuote = async (packageReleaseId) => {
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1793
|
+
try {
|
|
1794
|
+
const { order_quote_id } = await registryKy.post("order_quotes/create", {
|
|
1795
|
+
json: {
|
|
1796
|
+
package_release_id: packageReleaseId,
|
|
1797
|
+
vendor_name: "jlcpcb"
|
|
1798
|
+
// TODO: Remove this once we have more vendor
|
|
1799
|
+
}
|
|
1800
|
+
}).json();
|
|
1801
|
+
return order_quote_id;
|
|
1802
|
+
} catch (err) {
|
|
1803
|
+
if (err instanceof HTTPError) {
|
|
1804
|
+
const errorBody = await err.response.json();
|
|
1805
|
+
throw new Error(errorBody.message || err.message);
|
|
1797
1806
|
}
|
|
1798
|
-
|
|
1799
|
-
|
|
1807
|
+
throw err;
|
|
1808
|
+
}
|
|
1800
1809
|
};
|
|
1801
1810
|
var getOrderQuote = async (orderQuoteId) => {
|
|
1802
1811
|
const { order_quote } = await registryKy.get(`order_quotes/get`, {
|
|
@@ -1808,10 +1817,17 @@ var getOrderQuote = async (orderQuoteId) => {
|
|
|
1808
1817
|
};
|
|
1809
1818
|
|
|
1810
1819
|
// lib/hooks/use-create-order-quote.ts
|
|
1811
|
-
var useCreateOrderQuote = () => {
|
|
1812
|
-
return useMutation(
|
|
1813
|
-
(
|
|
1814
|
-
|
|
1820
|
+
var useCreateOrderQuote = (packageReleaseId) => {
|
|
1821
|
+
return useMutation({
|
|
1822
|
+
mutationFn: async () => {
|
|
1823
|
+
try {
|
|
1824
|
+
return await createOrderQuote(packageReleaseId);
|
|
1825
|
+
} catch (error) {
|
|
1826
|
+
console.error("Error creating order quote:", error);
|
|
1827
|
+
throw error instanceof Error ? error : new Error("Failed to create order quote");
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
});
|
|
1815
1831
|
};
|
|
1816
1832
|
|
|
1817
1833
|
// lib/hooks/use-order-quote-polling.ts
|
|
@@ -1820,7 +1836,7 @@ var useOrderQuotePolling = (orderQuoteId) => {
|
|
|
1820
1836
|
const {
|
|
1821
1837
|
data: orderQuote,
|
|
1822
1838
|
error,
|
|
1823
|
-
status
|
|
1839
|
+
status: status2
|
|
1824
1840
|
} = useQuery(
|
|
1825
1841
|
["getOrderQuote", orderQuoteId],
|
|
1826
1842
|
() => getOrderQuote(orderQuoteId),
|
|
@@ -1837,7 +1853,7 @@ var useOrderQuotePolling = (orderQuoteId) => {
|
|
|
1837
1853
|
}
|
|
1838
1854
|
);
|
|
1839
1855
|
return {
|
|
1840
|
-
status:
|
|
1856
|
+
status: status2 === "loading" ? "loading" : status2 === "error" ? "error" : "success",
|
|
1841
1857
|
data: orderQuote ?? null,
|
|
1842
1858
|
error: error instanceof Error ? error : null
|
|
1843
1859
|
};
|
|
@@ -1855,8 +1871,13 @@ var InitialOrderScreen = ({
|
|
|
1855
1871
|
const [selectedShippingIdx, setSelectedShippingIdx] = useState6(
|
|
1856
1872
|
null
|
|
1857
1873
|
);
|
|
1858
|
-
const {
|
|
1859
|
-
|
|
1874
|
+
const {
|
|
1875
|
+
mutate: createOrderQuote2,
|
|
1876
|
+
data: orderQuoteId,
|
|
1877
|
+
error: createOrderQuoteError,
|
|
1878
|
+
isError
|
|
1879
|
+
} = useCreateOrderQuote(packageReleaseId);
|
|
1880
|
+
const { data: orderQuote } = useOrderQuotePolling(orderQuoteId);
|
|
1860
1881
|
const redirectToStripeCheckout = async (orderQuoteId2) => {
|
|
1861
1882
|
const stripeCheckoutBaseUrl = getWindowVar(
|
|
1862
1883
|
"TSCIRCUIT_STRIPE_CHECKOUT_BASE_URL"
|
|
@@ -1867,15 +1888,15 @@ var InitialOrderScreen = ({
|
|
|
1867
1888
|
setSelectedShippingIdx(null);
|
|
1868
1889
|
}, [selectedVendorIdx]);
|
|
1869
1890
|
useEffect3(() => {
|
|
1870
|
-
createOrderQuote2(
|
|
1891
|
+
createOrderQuote2();
|
|
1871
1892
|
}, [packageReleaseId, createOrderQuote2]);
|
|
1872
1893
|
return /* @__PURE__ */ jsxs15("div", { className: "rf-max-w-lg rf-mx-auto rf-bg-white rf-rounded-2xl rf-p-8 rf-flex rf-flex-col rf-gap-3", children: [
|
|
1873
1894
|
/* @__PURE__ */ jsx19("h2", { className: "rf-text-3xl rf-font-bold rf-text-center rf-mb-8", children: "Order PCB \u2013 Choose a Vendor" }),
|
|
1874
1895
|
/* @__PURE__ */ jsx19("div", { className: "rf-mb-4 rf-text-gray-700 rf-text-center", children: "Select a quote from below, then pick a shipping method." }),
|
|
1875
|
-
|
|
1896
|
+
!orderQuoteId && !isError ? /* @__PURE__ */ jsxs15("div", { className: "rf-flex rf-flex-col rf-items-center rf-gap-2 rf-my-12", children: [
|
|
1876
1897
|
/* @__PURE__ */ jsx19(Loader22, { className: "rf-animate-spin rf-w-8 rf-h-8 rf-text-gray-400" }),
|
|
1877
1898
|
/* @__PURE__ */ jsx19("p", { className: "rf-text-gray-600", children: "Fetching quotes..." })
|
|
1878
|
-
] }) :
|
|
1899
|
+
] }) : createOrderQuoteError && isError ? /* @__PURE__ */ jsx19("div", { className: "rf-text-red-600 rf-text-center rf-py-12", children: JSON.stringify(createOrderQuoteError.message) }) : orderQuote?.error ? /* @__PURE__ */ jsx19("div", { className: "rf-text-red-600 rf-text-center rf-py-12", children: orderQuote?.error?.message || "Failed to fetch quotes" }) : !orderQuote ? /* @__PURE__ */ jsx19("div", { className: "rf-text-red-600 rf-text-center rf-py-12", children: "No quotes available." }) : !orderQuote.is_completed ? /* @__PURE__ */ jsxs15("div", { className: "rf-flex rf-flex-col rf-items-center rf-gap-2 rf-my-12", children: [
|
|
1879
1900
|
/* @__PURE__ */ jsx19(Loader22, { className: "rf-animate-spin rf-w-8 rf-h-8 rf-text-gray-400" }),
|
|
1880
1901
|
/* @__PURE__ */ jsx19("p", { className: "rf-text-gray-600", children: "Calculating quote..." })
|
|
1881
1902
|
] }) : /* @__PURE__ */ jsx19(
|
package/dist/preview.js
CHANGED
package/dist/runner.js
CHANGED