@tscircuit/runframe 0.0.952 → 0.0.954
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-DZRMQXIQ.js → chunk-NPF4TT4U.js} +1 -1
- package/dist/preview.js +1 -1
- package/dist/runner.d.ts +8 -0
- package/dist/runner.js +39 -11
- package/dist/standalone-preview.min.js +565 -565
- package/dist/standalone.min.js +559 -559
- package/package.json +2 -2
|
@@ -1426,7 +1426,7 @@ var useErrorTelemetry = ({
|
|
|
1426
1426
|
};
|
|
1427
1427
|
|
|
1428
1428
|
// package.json
|
|
1429
|
-
var version = "0.0.
|
|
1429
|
+
var version = "0.0.953";
|
|
1430
1430
|
|
|
1431
1431
|
// lib/hooks/use-eval-versions.ts
|
|
1432
1432
|
import { useEffect as useEffect5, useMemo as useMemo2, useState as useState6 } from "react";
|
package/dist/preview.js
CHANGED
package/dist/runner.d.ts
CHANGED
|
@@ -148,6 +148,14 @@ interface RunFrameWithApiProps {
|
|
|
148
148
|
* Enable fetch proxy for the web worker (useful for standalone bundles)
|
|
149
149
|
*/
|
|
150
150
|
enableFetchProxy?: boolean;
|
|
151
|
+
/**
|
|
152
|
+
* The main component path that should be selected initially when available.
|
|
153
|
+
*/
|
|
154
|
+
initialMainComponentPath?: string;
|
|
155
|
+
/**
|
|
156
|
+
* Callback invoked whenever the selected main component path changes.
|
|
157
|
+
*/
|
|
158
|
+
onMainComponentPathChange?: (path: string) => void;
|
|
151
159
|
}
|
|
152
160
|
declare const RunFrameWithApi: (props: RunFrameWithApiProps) => react_jsx_runtime.JSX.Element;
|
|
153
161
|
|
package/dist/runner.js
CHANGED
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
useRunFrameStore,
|
|
24
24
|
useRunnerStore,
|
|
25
25
|
useStyles
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-NPF4TT4U.js";
|
|
27
27
|
|
|
28
28
|
// lib/components/RunFrame/RunFrame.tsx
|
|
29
29
|
import { createCircuitWebWorker } from "@tscircuit/eval/worker";
|
|
@@ -905,7 +905,9 @@ var RunFrameWithApi = (props) => {
|
|
|
905
905
|
);
|
|
906
906
|
const fsMap = useRunFrameStore((s) => s.fsMap);
|
|
907
907
|
const circuitJson = useRunFrameStore((s) => s.circuitJson);
|
|
908
|
-
const [componentPath, setComponentPath] = useState4(
|
|
908
|
+
const [componentPath, setComponentPath] = useState4(
|
|
909
|
+
props.initialMainComponentPath ?? ""
|
|
910
|
+
);
|
|
909
911
|
const [isLoadingFiles, setIsLoadingFiles] = useState4(true);
|
|
910
912
|
useEffect5(() => {
|
|
911
913
|
setIsLoadingFiles(true);
|
|
@@ -917,17 +919,26 @@ var RunFrameWithApi = (props) => {
|
|
|
917
919
|
return;
|
|
918
920
|
}
|
|
919
921
|
const defaultPath = window?.TSCIRCUIT_DEFAULT_MAIN_COMPONENT_PATH;
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
setComponentPath(firstMatch);
|
|
922
|
+
const candidatePaths = [props.initialMainComponentPath, defaultPath].filter(
|
|
923
|
+
(value) => Boolean(value)
|
|
924
|
+
);
|
|
925
|
+
for (const candidate of candidatePaths) {
|
|
926
|
+
if (files.includes(candidate)) {
|
|
927
|
+
setComponentPath(candidate);
|
|
928
|
+
return;
|
|
928
929
|
}
|
|
929
930
|
}
|
|
930
|
-
|
|
931
|
+
const firstMatch = files.find(
|
|
932
|
+
(file) => (file.endsWith(".tsx") || file.endsWith(".ts") || file.endsWith(".jsx") || file.endsWith(".js")) && !file.endsWith(".d.ts")
|
|
933
|
+
);
|
|
934
|
+
if (firstMatch) {
|
|
935
|
+
setComponentPath(firstMatch);
|
|
936
|
+
}
|
|
937
|
+
}, [fsMap, props.initialMainComponentPath, componentPath]);
|
|
938
|
+
useEffect5(() => {
|
|
939
|
+
if (!componentPath) return;
|
|
940
|
+
props.onMainComponentPathChange?.(componentPath);
|
|
941
|
+
}, [componentPath, props.onMainComponentPathChange]);
|
|
931
942
|
useSyncPageTitle();
|
|
932
943
|
const {
|
|
933
944
|
editEventsForRender,
|
|
@@ -1022,12 +1033,27 @@ var RunFrameWithApi = (props) => {
|
|
|
1022
1033
|
};
|
|
1023
1034
|
|
|
1024
1035
|
// lib/components/RunFrameForCli/RunFrameForCli.tsx
|
|
1036
|
+
import { useCallback as useCallback3, useState as useState5 } from "react";
|
|
1025
1037
|
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
1026
1038
|
var RunFrameForCli = (props) => {
|
|
1027
1039
|
const [shouldLoadLatestEval, setLoadLatestEval] = useLocalStorageState(
|
|
1028
1040
|
"load-latest-eval",
|
|
1029
1041
|
true
|
|
1030
1042
|
);
|
|
1043
|
+
const [initialMainComponentPath] = useState5(() => {
|
|
1044
|
+
if (typeof window === "undefined") return void 0;
|
|
1045
|
+
const params = new URLSearchParams(window.location.hash.slice(1));
|
|
1046
|
+
return params.get("main_component") ?? void 0;
|
|
1047
|
+
});
|
|
1048
|
+
const updateMainComponentHash = useCallback3((mainComponentPath) => {
|
|
1049
|
+
if (typeof window === "undefined") return;
|
|
1050
|
+
const params = new URLSearchParams(window.location.hash.slice(1));
|
|
1051
|
+
if (params.get("main_component") === mainComponentPath) return;
|
|
1052
|
+
params.set("main_component", mainComponentPath);
|
|
1053
|
+
const newHash = params.toString();
|
|
1054
|
+
const newUrl = `${window.location.pathname}${window.location.search}` + (newHash.length > 0 ? `#${newHash}` : "");
|
|
1055
|
+
window.history.replaceState(null, "", newUrl);
|
|
1056
|
+
}, []);
|
|
1031
1057
|
return /* @__PURE__ */ jsx6(
|
|
1032
1058
|
RunFrameWithApi,
|
|
1033
1059
|
{
|
|
@@ -1039,6 +1065,8 @@ var RunFrameForCli = (props) => {
|
|
|
1039
1065
|
showFilesSwitch: true,
|
|
1040
1066
|
showFileMenu: false,
|
|
1041
1067
|
enableFetchProxy: props.enableFetchProxy,
|
|
1068
|
+
initialMainComponentPath,
|
|
1069
|
+
onMainComponentPathChange: updateMainComponentHash,
|
|
1042
1070
|
leftHeaderContent: /* @__PURE__ */ jsxs5("div", { className: "rf-flex rf-items-center rf-justify-between", children: [
|
|
1043
1071
|
/* @__PURE__ */ jsx6(
|
|
1044
1072
|
FileMenuLeftHeader,
|