@tscircuit/runframe 0.0.2948 → 0.0.2949
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/runner.js +34 -7
- package/dist/standalone.min.js +466 -466
- package/package.json +1 -1
package/dist/runner.js
CHANGED
|
@@ -140,12 +140,12 @@ var useCircuitJsonFile = ({
|
|
|
140
140
|
mainComponentPath,
|
|
141
141
|
fsMap
|
|
142
142
|
}) => {
|
|
143
|
+
const isStaticCircuitJson = mainComponentPath != null && isCircuitJsonFile(mainComponentPath);
|
|
144
|
+
const circuitJsonContent = mainComponentPath ? fsMap.get(mainComponentPath) : void 0;
|
|
143
145
|
return useMemo(() => {
|
|
144
|
-
const isStaticCircuitJson = mainComponentPath != null && isCircuitJsonFile(mainComponentPath);
|
|
145
146
|
if (!isStaticCircuitJson) {
|
|
146
147
|
return { isStaticCircuitJson: false, circuitJson: null, error: null };
|
|
147
148
|
}
|
|
148
|
-
const circuitJsonContent = fsMap.get(mainComponentPath);
|
|
149
149
|
if (!circuitJsonContent) {
|
|
150
150
|
return {
|
|
151
151
|
isStaticCircuitJson: true,
|
|
@@ -163,7 +163,7 @@ var useCircuitJsonFile = ({
|
|
|
163
163
|
error: `Failed to parse circuit.json: ${e instanceof Error ? e.message : String(e)}`
|
|
164
164
|
};
|
|
165
165
|
}
|
|
166
|
-
}, [mainComponentPath,
|
|
166
|
+
}, [mainComponentPath, circuitJsonContent]);
|
|
167
167
|
};
|
|
168
168
|
|
|
169
169
|
// lib/utils/getChangesBetweenFsMaps.tsx
|
|
@@ -337,6 +337,7 @@ var resolveEvalVersion = async (evalVersionProp, forceLatest) => {
|
|
|
337
337
|
};
|
|
338
338
|
var RunFrame = (props) => {
|
|
339
339
|
useStyles();
|
|
340
|
+
const isStaticCircuitJson = props.mainComponentPath != null && isCircuitJsonFile(props.mainComponentPath);
|
|
340
341
|
const circuitJson = useRunFrameStore((s) => s.circuitJson);
|
|
341
342
|
const setCircuitJson = useRunFrameStore((s) => s.setCircuitJson);
|
|
342
343
|
const [error, setError] = useState(null);
|
|
@@ -417,6 +418,7 @@ var RunFrame = (props) => {
|
|
|
417
418
|
props.onRunCompleted?.(payload);
|
|
418
419
|
};
|
|
419
420
|
useEffect(() => {
|
|
421
|
+
if (isStaticCircuitJson) return;
|
|
420
422
|
const handleKeyDown = (e) => {
|
|
421
423
|
if ((e.ctrlKey || e.metaKey) && e.key === "Enter" && !isRunning) {
|
|
422
424
|
e.preventDefault();
|
|
@@ -426,8 +428,9 @@ var RunFrame = (props) => {
|
|
|
426
428
|
};
|
|
427
429
|
window.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
428
430
|
return () => window.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
429
|
-
}, [isRunning]);
|
|
431
|
+
}, [isRunning, isStaticCircuitJson]);
|
|
430
432
|
useEffect(() => {
|
|
433
|
+
if (isStaticCircuitJson) return;
|
|
431
434
|
let cancelled = false;
|
|
432
435
|
const load = async () => {
|
|
433
436
|
try {
|
|
@@ -449,6 +452,7 @@ var RunFrame = (props) => {
|
|
|
449
452
|
cancelled = true;
|
|
450
453
|
};
|
|
451
454
|
}, [
|
|
455
|
+
isStaticCircuitJson,
|
|
452
456
|
props.evalVersion,
|
|
453
457
|
props.evalWebWorkerBlobUrl,
|
|
454
458
|
props.forceLatestEvalVersion,
|
|
@@ -477,8 +481,8 @@ var RunFrame = (props) => {
|
|
|
477
481
|
);
|
|
478
482
|
const lastFsMapRef = useRef2(null);
|
|
479
483
|
const lastEntrypointRef = useRef2(null);
|
|
484
|
+
const lastStaticResultRef = useRef2(null);
|
|
480
485
|
const {
|
|
481
|
-
isStaticCircuitJson,
|
|
482
486
|
circuitJson: circuitJsonFileParsedContent,
|
|
483
487
|
error: circuitJsonFileError
|
|
484
488
|
} = useCircuitJsonFile({
|
|
@@ -486,14 +490,37 @@ var RunFrame = (props) => {
|
|
|
486
490
|
fsMap
|
|
487
491
|
});
|
|
488
492
|
useEffect(() => {
|
|
489
|
-
if (!isStaticCircuitJson)
|
|
493
|
+
if (!isStaticCircuitJson) {
|
|
494
|
+
lastStaticResultRef.current = null;
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
if (props.isLoadingFiles) return;
|
|
498
|
+
const result = circuitJsonFileParsedContent ?? circuitJsonFileError;
|
|
499
|
+
if (result === lastStaticResultRef.current) return;
|
|
500
|
+
lastStaticResultRef.current = result;
|
|
490
501
|
if (circuitJsonFileParsedContent) {
|
|
502
|
+
props.onRenderStarted?.();
|
|
491
503
|
setCircuitJson(circuitJsonFileParsedContent);
|
|
492
504
|
setError(null);
|
|
505
|
+
props.onCircuitJsonChange?.(circuitJsonFileParsedContent);
|
|
506
|
+
props.onInitialRender?.({ circuitJson: circuitJsonFileParsedContent });
|
|
507
|
+
emitRunCompleted(
|
|
508
|
+
buildRunCompletedPayload({ circuitJson: circuitJsonFileParsedContent })
|
|
509
|
+
);
|
|
510
|
+
props.onRenderFinished?.({ circuitJson: circuitJsonFileParsedContent });
|
|
493
511
|
} else if (circuitJsonFileError) {
|
|
512
|
+
setCircuitJson(null);
|
|
494
513
|
setError({ error: circuitJsonFileError, stack: "" });
|
|
514
|
+
const error2 = new Error(circuitJsonFileError);
|
|
515
|
+
props.onError?.(error2);
|
|
516
|
+
emitRunCompleted(buildRunCompletedPayload({ executionError: error2 }));
|
|
495
517
|
}
|
|
496
|
-
}, [
|
|
518
|
+
}, [
|
|
519
|
+
isStaticCircuitJson,
|
|
520
|
+
circuitJsonFileParsedContent,
|
|
521
|
+
circuitJsonFileError,
|
|
522
|
+
props.isLoadingFiles
|
|
523
|
+
]);
|
|
497
524
|
useEffect(() => {
|
|
498
525
|
if (isStaticCircuitJson || props.isLoadingFiles) {
|
|
499
526
|
autoroutingCaptureGeneration.current += 1;
|