@tscircuit/runframe 0.0.2947 → 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/{chunk-65VU5INM.js → chunk-T3FFIUMM.js} +1 -1
- package/dist/preview.js +1 -1
- package/dist/runner.js +164 -114
- package/dist/standalone-preview.min.js +1 -1
- package/dist/standalone.min.js +589 -589
- package/package.json +1 -1
package/dist/preview.js
CHANGED
package/dist/runner.js
CHANGED
|
@@ -43,14 +43,14 @@ import {
|
|
|
43
43
|
useRunnerStore,
|
|
44
44
|
useSchematicViewerController,
|
|
45
45
|
useStyles
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-T3FFIUMM.js";
|
|
47
47
|
|
|
48
48
|
// lib/components/RunFrame/RunFrame.tsx
|
|
49
49
|
import { createCircuitWebWorker } from "@tscircuit/eval/worker";
|
|
50
50
|
import Debug from "debug";
|
|
51
51
|
import { HTTPError } from "ky";
|
|
52
52
|
import { Loader2, Play, Square } from "lucide-react";
|
|
53
|
-
import { useEffect, useReducer, useRef as useRef2, useState } from "react";
|
|
53
|
+
import { useEffect, useMemo as useMemo2, useReducer, useRef as useRef2, useState } from "react";
|
|
54
54
|
import { ErrorBoundary } from "react-error-boundary";
|
|
55
55
|
|
|
56
56
|
// lib/components/RunFrame/RunFrameErrorFallback.tsx
|
|
@@ -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,11 +337,14 @@ 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);
|
|
343
344
|
const [componentStack, setComponentStack] = useState(null);
|
|
344
345
|
const cancelExecutionRef = useRef2(null);
|
|
346
|
+
const componentActiveRef = useRef2(true);
|
|
347
|
+
const workerCreationRef = useRef2(null);
|
|
345
348
|
const [autoroutingGraphics, setAutoroutingGraphics] = useState(null);
|
|
346
349
|
const [runCountTrigger, incRunCountTrigger] = useReducer(
|
|
347
350
|
(acc, s) => acc + 1,
|
|
@@ -356,6 +359,58 @@ var RunFrame = (props) => {
|
|
|
356
359
|
const [currentDebugOption, setCurrentDebugOption] = useState("");
|
|
357
360
|
const [showSchematicDebugGrid, setShowSchematicDebugGrid] = useState(false);
|
|
358
361
|
const [showSchematicPorts, setShowSchematicPorts] = useState(false);
|
|
362
|
+
useEffect(() => {
|
|
363
|
+
componentActiveRef.current = true;
|
|
364
|
+
return () => {
|
|
365
|
+
componentActiveRef.current = false;
|
|
366
|
+
cancelExecutionRef.current?.();
|
|
367
|
+
const pending = workerCreationRef.current;
|
|
368
|
+
void pending?.then(({ worker }) => {
|
|
369
|
+
if (!componentActiveRef.current && globalThis.runFrameWorker !== worker) {
|
|
370
|
+
return worker.kill();
|
|
371
|
+
}
|
|
372
|
+
}).catch(() => {
|
|
373
|
+
});
|
|
374
|
+
};
|
|
375
|
+
}, []);
|
|
376
|
+
const getWorker = () => {
|
|
377
|
+
if (workerCreationRef.current) return workerCreationRef.current;
|
|
378
|
+
const pending = (async () => {
|
|
379
|
+
const evalVersion = await resolveEvalVersion(
|
|
380
|
+
props.evalVersion,
|
|
381
|
+
!globalThis.runFrameWorker && props.forceLatestEvalVersion
|
|
382
|
+
);
|
|
383
|
+
const worker = globalThis.runFrameWorker ?? await createCircuitWebWorker({
|
|
384
|
+
evalVersion,
|
|
385
|
+
webWorkerBlobUrl: props.evalWebWorkerBlobUrl,
|
|
386
|
+
projectConfig: getRunFrameProjectConfig({
|
|
387
|
+
projectBaseUrl: props.projectBaseUrl || `${API_BASE}/files/static`
|
|
388
|
+
}),
|
|
389
|
+
...props.platformConfig && { platform: props.platformConfig },
|
|
390
|
+
verbose: true,
|
|
391
|
+
...props.enableFetchProxy && {
|
|
392
|
+
enableFetchProxy: props.enableFetchProxy
|
|
393
|
+
},
|
|
394
|
+
...window.TSCIRCUIT_USE_RUNFRAME_FOR_CLI && {
|
|
395
|
+
disableCdnLoading: true
|
|
396
|
+
},
|
|
397
|
+
...props.tscircuitSessionToken && {
|
|
398
|
+
tscircuitSessionToken: props.tscircuitSessionToken
|
|
399
|
+
},
|
|
400
|
+
...props.easyEdaProxyConfig && {
|
|
401
|
+
easyEdaProxyConfig: props.easyEdaProxyConfig
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
return { worker, evalVersion };
|
|
405
|
+
})();
|
|
406
|
+
workerCreationRef.current = pending;
|
|
407
|
+
const clearPending = () => {
|
|
408
|
+
if (workerCreationRef.current === pending)
|
|
409
|
+
workerCreationRef.current = null;
|
|
410
|
+
};
|
|
411
|
+
void pending.then(clearPending, clearPending);
|
|
412
|
+
return pending;
|
|
413
|
+
};
|
|
359
414
|
const activeEffectName = Object.values(activeAsyncEffects).sort(
|
|
360
415
|
(a, b) => a.startTime - b.startTime
|
|
361
416
|
)[0]?.effectName;
|
|
@@ -363,6 +418,7 @@ var RunFrame = (props) => {
|
|
|
363
418
|
props.onRunCompleted?.(payload);
|
|
364
419
|
};
|
|
365
420
|
useEffect(() => {
|
|
421
|
+
if (isStaticCircuitJson) return;
|
|
366
422
|
const handleKeyDown = (e) => {
|
|
367
423
|
if ((e.ctrlKey || e.metaKey) && e.key === "Enter" && !isRunning) {
|
|
368
424
|
e.preventDefault();
|
|
@@ -372,46 +428,23 @@ var RunFrame = (props) => {
|
|
|
372
428
|
};
|
|
373
429
|
window.addEventListener("keydown", handleKeyDown, { capture: true });
|
|
374
430
|
return () => window.removeEventListener("keydown", handleKeyDown, { capture: true });
|
|
375
|
-
}, [isRunning]);
|
|
431
|
+
}, [isRunning, isStaticCircuitJson]);
|
|
376
432
|
useEffect(() => {
|
|
433
|
+
if (isStaticCircuitJson) return;
|
|
377
434
|
let cancelled = false;
|
|
378
435
|
const load = async () => {
|
|
379
436
|
try {
|
|
380
437
|
if (!globalThis.runFrameWorker) {
|
|
381
|
-
const evalVersion = await
|
|
382
|
-
|
|
383
|
-
props.forceLatestEvalVersion
|
|
384
|
-
);
|
|
385
|
-
const worker = await createCircuitWebWorker({
|
|
386
|
-
evalVersion,
|
|
387
|
-
webWorkerBlobUrl: props.evalWebWorkerBlobUrl,
|
|
388
|
-
projectConfig: getRunFrameProjectConfig({
|
|
389
|
-
projectBaseUrl: props.projectBaseUrl || `${API_BASE}/files/static`
|
|
390
|
-
}),
|
|
391
|
-
...props.platformConfig && {
|
|
392
|
-
platform: props.platformConfig
|
|
393
|
-
},
|
|
394
|
-
verbose: true,
|
|
395
|
-
...props.enableFetchProxy && {
|
|
396
|
-
enableFetchProxy: props.enableFetchProxy
|
|
397
|
-
},
|
|
398
|
-
...window.TSCIRCUIT_USE_RUNFRAME_FOR_CLI && {
|
|
399
|
-
disableCdnLoading: true
|
|
400
|
-
},
|
|
401
|
-
...props.tscircuitSessionToken && {
|
|
402
|
-
tscircuitSessionToken: props.tscircuitSessionToken
|
|
403
|
-
},
|
|
404
|
-
...props.easyEdaProxyConfig && {
|
|
405
|
-
easyEdaProxyConfig: props.easyEdaProxyConfig
|
|
406
|
-
}
|
|
407
|
-
});
|
|
408
|
-
if (cancelled) return;
|
|
438
|
+
const { worker, evalVersion } = await getWorker();
|
|
439
|
+
if (cancelled || !componentActiveRef.current) return;
|
|
409
440
|
globalThis.runFrameWorker = worker;
|
|
410
441
|
setLastRunEvalVersion(evalVersion);
|
|
411
442
|
}
|
|
412
443
|
if (!cancelled) setDependenciesLoaded(true);
|
|
413
444
|
} catch (err) {
|
|
414
|
-
|
|
445
|
+
if (!cancelled && componentActiveRef.current) {
|
|
446
|
+
console.error("Failed to preload eval worker", err);
|
|
447
|
+
}
|
|
415
448
|
}
|
|
416
449
|
};
|
|
417
450
|
load();
|
|
@@ -419,6 +452,7 @@ var RunFrame = (props) => {
|
|
|
419
452
|
cancelled = true;
|
|
420
453
|
};
|
|
421
454
|
}, [
|
|
455
|
+
isStaticCircuitJson,
|
|
422
456
|
props.evalVersion,
|
|
423
457
|
props.evalWebWorkerBlobUrl,
|
|
424
458
|
props.forceLatestEvalVersion,
|
|
@@ -441,14 +475,14 @@ var RunFrame = (props) => {
|
|
|
441
475
|
useEffect(() => {
|
|
442
476
|
if (props.debug) Debug.enable("run-frame*");
|
|
443
477
|
}, [props.debug]);
|
|
444
|
-
const fsMap =
|
|
445
|
-
(
|
|
446
|
-
|
|
478
|
+
const fsMap = useMemo2(
|
|
479
|
+
() => props.fsMap instanceof Map ? props.fsMap : new Map(Object.entries(props.fsMap ?? {})),
|
|
480
|
+
[props.fsMap]
|
|
447
481
|
);
|
|
448
482
|
const lastFsMapRef = useRef2(null);
|
|
449
483
|
const lastEntrypointRef = useRef2(null);
|
|
484
|
+
const lastStaticResultRef = useRef2(null);
|
|
450
485
|
const {
|
|
451
|
-
isStaticCircuitJson,
|
|
452
486
|
circuitJson: circuitJsonFileParsedContent,
|
|
453
487
|
error: circuitJsonFileError
|
|
454
488
|
} = useCircuitJsonFile({
|
|
@@ -456,19 +490,50 @@ var RunFrame = (props) => {
|
|
|
456
490
|
fsMap
|
|
457
491
|
});
|
|
458
492
|
useEffect(() => {
|
|
459
|
-
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;
|
|
460
501
|
if (circuitJsonFileParsedContent) {
|
|
502
|
+
props.onRenderStarted?.();
|
|
461
503
|
setCircuitJson(circuitJsonFileParsedContent);
|
|
462
504
|
setError(null);
|
|
505
|
+
props.onCircuitJsonChange?.(circuitJsonFileParsedContent);
|
|
506
|
+
props.onInitialRender?.({ circuitJson: circuitJsonFileParsedContent });
|
|
507
|
+
emitRunCompleted(
|
|
508
|
+
buildRunCompletedPayload({ circuitJson: circuitJsonFileParsedContent })
|
|
509
|
+
);
|
|
510
|
+
props.onRenderFinished?.({ circuitJson: circuitJsonFileParsedContent });
|
|
463
511
|
} else if (circuitJsonFileError) {
|
|
512
|
+
setCircuitJson(null);
|
|
464
513
|
setError({ error: circuitJsonFileError, stack: "" });
|
|
514
|
+
const error2 = new Error(circuitJsonFileError);
|
|
515
|
+
props.onError?.(error2);
|
|
516
|
+
emitRunCompleted(buildRunCompletedPayload({ executionError: error2 }));
|
|
465
517
|
}
|
|
466
|
-
}, [
|
|
518
|
+
}, [
|
|
519
|
+
isStaticCircuitJson,
|
|
520
|
+
circuitJsonFileParsedContent,
|
|
521
|
+
circuitJsonFileError,
|
|
522
|
+
props.isLoadingFiles
|
|
523
|
+
]);
|
|
467
524
|
useEffect(() => {
|
|
468
|
-
if (props.isLoadingFiles)
|
|
469
|
-
|
|
525
|
+
if (isStaticCircuitJson || props.isLoadingFiles) {
|
|
526
|
+
autoroutingCaptureGeneration.current += 1;
|
|
527
|
+
cancelExecutionRef.current?.();
|
|
528
|
+
cancelExecutionRef.current = null;
|
|
529
|
+
setIsRunning(false);
|
|
530
|
+
setActiveAsyncEffects({});
|
|
531
|
+
if (props.isLoadingFiles) setCircuitJson(null);
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
470
534
|
const fsMapObj = fsMap instanceof Map ? Object.fromEntries(fsMap.entries()) : fsMap;
|
|
471
535
|
if (!fsMapObj || Object.keys(fsMapObj).length === 0) {
|
|
536
|
+
setCircuitJson(null);
|
|
472
537
|
setError({
|
|
473
538
|
error: "No files provided. Please provide at least one file with code to execute.",
|
|
474
539
|
stack: ""
|
|
@@ -495,50 +560,29 @@ var RunFrame = (props) => {
|
|
|
495
560
|
lastEntrypointRef.current = props.entrypoint ?? null;
|
|
496
561
|
lastRunCountTriggerRef.current = runCountTrigger;
|
|
497
562
|
setIsRunning(true);
|
|
563
|
+
let cancelled = false;
|
|
564
|
+
const captureGeneration = ++autoroutingCaptureGeneration.current;
|
|
565
|
+
const isCurrentRun = () => componentActiveRef.current && !cancelled && captureGeneration === autoroutingCaptureGeneration.current;
|
|
566
|
+
let renderResult;
|
|
498
567
|
const runWorker = async () => {
|
|
568
|
+
if (!isCurrentRun()) return;
|
|
499
569
|
debug("running render worker");
|
|
500
570
|
setError(null);
|
|
501
571
|
setRenderLog(null);
|
|
502
572
|
setActiveAsyncEffects({});
|
|
503
573
|
setSolverEvents([]);
|
|
504
574
|
setAutoroutingPhases([]);
|
|
505
|
-
const captureGeneration = ++autoroutingCaptureGeneration.current;
|
|
506
575
|
const renderLog2 = { progress: 0, debugOutputs: [] };
|
|
507
|
-
let cancelled = false;
|
|
508
576
|
cancelExecutionRef.current = () => {
|
|
509
577
|
cancelled = true;
|
|
510
578
|
};
|
|
511
|
-
const resolvedEvalVersion = await
|
|
512
|
-
|
|
513
|
-
!globalThis.runFrameWorker && props.forceLatestEvalVersion
|
|
514
|
-
);
|
|
579
|
+
const { worker, evalVersion: resolvedEvalVersion } = await getWorker();
|
|
580
|
+
if (!isCurrentRun()) return;
|
|
515
581
|
debug("resolvedEvalVersion", resolvedEvalVersion);
|
|
516
|
-
const worker = globalThis.runFrameWorker ?? await createCircuitWebWorker({
|
|
517
|
-
evalVersion: resolvedEvalVersion,
|
|
518
|
-
webWorkerBlobUrl: props.evalWebWorkerBlobUrl,
|
|
519
|
-
verbose: true,
|
|
520
|
-
projectConfig: getRunFrameProjectConfig({
|
|
521
|
-
projectBaseUrl: props.projectBaseUrl || `${API_BASE}/files/static`
|
|
522
|
-
}),
|
|
523
|
-
...props.platformConfig && {
|
|
524
|
-
platform: props.platformConfig
|
|
525
|
-
},
|
|
526
|
-
...props.enableFetchProxy && {
|
|
527
|
-
enableFetchProxy: props.enableFetchProxy
|
|
528
|
-
},
|
|
529
|
-
...window.TSCIRCUIT_USE_RUNFRAME_FOR_CLI && {
|
|
530
|
-
disableCdnLoading: true
|
|
531
|
-
},
|
|
532
|
-
...props.tscircuitSessionToken && {
|
|
533
|
-
tscircuitSessionToken: props.tscircuitSessionToken
|
|
534
|
-
},
|
|
535
|
-
...props.easyEdaProxyConfig && {
|
|
536
|
-
easyEdaProxyConfig: props.easyEdaProxyConfig
|
|
537
|
-
}
|
|
538
|
-
});
|
|
539
582
|
globalThis.runFrameWorker = worker;
|
|
540
583
|
setLastRunEvalVersion(resolvedEvalVersion);
|
|
541
584
|
await worker.clearEventListeners();
|
|
585
|
+
if (!isCurrentRun()) return;
|
|
542
586
|
if (currentDebugOption?.trim()) {
|
|
543
587
|
worker.enableDebug(currentDebugOption.replace("DEBUG=", ""));
|
|
544
588
|
}
|
|
@@ -638,48 +682,32 @@ var RunFrame = (props) => {
|
|
|
638
682
|
}
|
|
639
683
|
});
|
|
640
684
|
debug("Executing fsMap...");
|
|
641
|
-
|
|
685
|
+
await worker.executeWithFsMap({
|
|
642
686
|
entrypoint: props.entrypoint,
|
|
643
687
|
fsMap: fsMapObj2,
|
|
644
688
|
...props.mainComponentPath ? { mainComponentPath: props.mainComponentPath } : {}
|
|
645
|
-
}).then(() => {
|
|
646
|
-
return { success: true };
|
|
647
|
-
}).catch((e) => {
|
|
648
|
-
const message = e.message.replace("Error: ", "");
|
|
649
|
-
debug(`eval error: ${message}`);
|
|
650
|
-
props.onError?.(e);
|
|
651
|
-
emitRunCompleted(buildRunCompletedPayload({ executionError: e }));
|
|
652
|
-
setError({ error: message, stack: e.stack });
|
|
653
|
-
setRenderLog(null);
|
|
654
|
-
console.error(e);
|
|
655
|
-
return { success: false };
|
|
656
689
|
});
|
|
690
|
+
if (!isCurrentRun()) return;
|
|
657
691
|
debug("worker call started");
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
const $renderResult = worker.renderUntilSettled();
|
|
692
|
+
const settlement = worker.renderUntilSettled().then(
|
|
693
|
+
() => ({ success: true }),
|
|
694
|
+
(error2) => ({ success: false, error: error2 })
|
|
695
|
+
);
|
|
696
|
+
renderResult = settlement;
|
|
664
697
|
debug("waiting for initial circuit json...");
|
|
665
|
-
let circuitJson2 = await worker.getCircuitJson()
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
emitRunCompleted(buildRunCompletedPayload({ executionError: e }));
|
|
669
|
-
setError({ error: e.message, stack: e.stack });
|
|
670
|
-
setRenderLog(null);
|
|
671
|
-
setIsRunning(false);
|
|
672
|
-
setActiveAsyncEffects({});
|
|
673
|
-
return null;
|
|
674
|
-
});
|
|
675
|
-
if (!circuitJson2) return;
|
|
698
|
+
let circuitJson2 = await worker.getCircuitJson();
|
|
699
|
+
if (!isCurrentRun()) return;
|
|
700
|
+
if (!circuitJson2) throw new Error("Eval worker returned no Circuit JSON");
|
|
676
701
|
debug("got initial circuit json");
|
|
677
702
|
setCircuitJson(circuitJson2);
|
|
678
703
|
props.onCircuitJsonChange?.(circuitJson2);
|
|
679
704
|
props.onInitialRender?.({ circuitJson: circuitJson2 });
|
|
680
|
-
await
|
|
705
|
+
const settled = await settlement;
|
|
706
|
+
if (!isCurrentRun()) return;
|
|
707
|
+
if (!settled.success) throw settled.error;
|
|
681
708
|
debug("getting final circuit json");
|
|
682
709
|
circuitJson2 = await worker.getCircuitJson();
|
|
710
|
+
if (!isCurrentRun()) return;
|
|
683
711
|
props.onCircuitJsonChange?.(circuitJson2);
|
|
684
712
|
setCircuitJson(circuitJson2);
|
|
685
713
|
emitRunCompleted(buildRunCompletedPayload({ circuitJson: circuitJson2 }));
|
|
@@ -699,7 +727,29 @@ var RunFrame = (props) => {
|
|
|
699
727
|
setCurrentDebugOption("");
|
|
700
728
|
cancelExecutionRef.current = null;
|
|
701
729
|
};
|
|
702
|
-
runMutex.runWithMutex(
|
|
730
|
+
void runMutex.runWithMutex(async () => {
|
|
731
|
+
try {
|
|
732
|
+
await runWorker();
|
|
733
|
+
} finally {
|
|
734
|
+
await renderResult;
|
|
735
|
+
}
|
|
736
|
+
}).catch((failure) => {
|
|
737
|
+
if (!isCurrentRun()) return;
|
|
738
|
+
const error2 = failure instanceof Error ? failure : new Error(String(failure));
|
|
739
|
+
debug("worker execution failed", error2);
|
|
740
|
+
props.onError?.(error2);
|
|
741
|
+
emitRunCompleted(buildRunCompletedPayload({ executionError: error2 }));
|
|
742
|
+
setCircuitJson(null);
|
|
743
|
+
setError({
|
|
744
|
+
error: error2.message.replace("Error: ", ""),
|
|
745
|
+
stack: error2.stack
|
|
746
|
+
});
|
|
747
|
+
setRenderLog(null);
|
|
748
|
+
setIsRunning(false);
|
|
749
|
+
setActiveAsyncEffects({});
|
|
750
|
+
setCurrentDebugOption("");
|
|
751
|
+
cancelExecutionRef.current = null;
|
|
752
|
+
});
|
|
703
753
|
}, [
|
|
704
754
|
props.fsMap,
|
|
705
755
|
props.entrypoint,
|
|
@@ -803,7 +853,7 @@ var RunFrame = (props) => {
|
|
|
803
853
|
children: /* @__PURE__ */ jsx3(
|
|
804
854
|
CircuitJsonPreview,
|
|
805
855
|
{
|
|
806
|
-
code: fsMap.get(props.entrypoint ?? props.mainComponentPath),
|
|
856
|
+
code: fsMap.get(props.entrypoint ?? props.mainComponentPath ?? ""),
|
|
807
857
|
fsMap,
|
|
808
858
|
defaultActiveTab: props.defaultActiveTab ?? props.defaultTab,
|
|
809
859
|
defaultTab: props.defaultTab,
|
|
@@ -1050,7 +1100,7 @@ var useSyncPageTitle = () => {
|
|
|
1050
1100
|
};
|
|
1051
1101
|
|
|
1052
1102
|
// lib/components/RunFrameWithApi/RunFrameWithApi.tsx
|
|
1053
|
-
import { useCallback as useCallback4, useEffect as useEffect7, useMemo as
|
|
1103
|
+
import { useCallback as useCallback4, useEffect as useEffect7, useMemo as useMemo5, useState as useState6 } from "react";
|
|
1054
1104
|
|
|
1055
1105
|
// lib/utils/get-board-files-from-config.ts
|
|
1056
1106
|
import { projectConfig } from "@tscircuit/props";
|
|
@@ -1094,7 +1144,7 @@ import {
|
|
|
1094
1144
|
Folder,
|
|
1095
1145
|
Save
|
|
1096
1146
|
} from "lucide-react";
|
|
1097
|
-
import { useCallback as useCallback3, useEffect as useEffect6, useMemo as
|
|
1147
|
+
import { useCallback as useCallback3, useEffect as useEffect6, useMemo as useMemo4, useRef as useRef3, useState as useState5 } from "react";
|
|
1098
1148
|
|
|
1099
1149
|
// lib/components/ui/command.tsx
|
|
1100
1150
|
import * as React from "react";
|
|
@@ -1536,7 +1586,7 @@ var EnhancedFileSelectorCombobox = ({
|
|
|
1536
1586
|
}
|
|
1537
1587
|
}
|
|
1538
1588
|
}, [currentFiles, currentFile]);
|
|
1539
|
-
const recentFiles =
|
|
1589
|
+
const recentFiles = useMemo4(() => {
|
|
1540
1590
|
const validSavedFiles = recentlySavedFiles.filter(
|
|
1541
1591
|
(file2) => filteredFiles.includes(file2)
|
|
1542
1592
|
);
|
|
@@ -1853,12 +1903,12 @@ var RunFrameWithApi = (props) => {
|
|
|
1853
1903
|
const hasReceivedInitialFiles = useHasReceivedInitialFilesLoaded();
|
|
1854
1904
|
const fsMap = useRunFrameStore((s) => s.fsMap);
|
|
1855
1905
|
const recentlySavedFiles = useRunFrameStore((s) => s.recentlySavedFiles);
|
|
1856
|
-
const allFiles =
|
|
1857
|
-
const projectConfigContent =
|
|
1906
|
+
const allFiles = useMemo5(() => Array.from(fsMap.keys()), [fsMap]);
|
|
1907
|
+
const projectConfigContent = useMemo5(() => {
|
|
1858
1908
|
const rawConfig = fsMap.get("tscircuit.config.json");
|
|
1859
1909
|
return typeof rawConfig === "string" ? rawConfig : void 0;
|
|
1860
1910
|
}, [fsMap]);
|
|
1861
|
-
const boardFiles =
|
|
1911
|
+
const boardFiles = useMemo5(
|
|
1862
1912
|
() => getBoardFilesFromConfig(allFiles, projectConfigContent),
|
|
1863
1913
|
[allFiles, projectConfigContent]
|
|
1864
1914
|
);
|
|
@@ -1883,7 +1933,7 @@ var RunFrameWithApi = (props) => {
|
|
|
1883
1933
|
[setFavorites]
|
|
1884
1934
|
);
|
|
1885
1935
|
const activeFileFilter = props.fileFilter ?? DEFAULT_UI_FILE_FILTER;
|
|
1886
|
-
const visibleBoardFiles =
|
|
1936
|
+
const visibleBoardFiles = useMemo5(
|
|
1887
1937
|
() => boardFiles.filter(activeFileFilter),
|
|
1888
1938
|
[boardFiles, activeFileFilter]
|
|
1889
1939
|
);
|
|
@@ -1959,7 +2009,7 @@ var RunFrameWithApi = (props) => {
|
|
|
1959
2009
|
startPolling();
|
|
1960
2010
|
return () => stopPolling();
|
|
1961
2011
|
}, [startPolling, stopPolling]);
|
|
1962
|
-
const componentProp =
|
|
2012
|
+
const componentProp = useMemo5(
|
|
1963
2013
|
() => String(componentPath).length > 0 ? {
|
|
1964
2014
|
mainComponentPath: componentPath
|
|
1965
2015
|
} : {},
|
|
@@ -2068,7 +2118,7 @@ var RunFrameWithApi = (props) => {
|
|
|
2068
2118
|
};
|
|
2069
2119
|
|
|
2070
2120
|
// lib/components/RunFrameForCli/RunFrameForCli.tsx
|
|
2071
|
-
import { useCallback as useCallback6, useMemo as
|
|
2121
|
+
import { useCallback as useCallback6, useMemo as useMemo6, useState as useState8 } from "react";
|
|
2072
2122
|
|
|
2073
2123
|
// lib/components/RunFrameForCli/LoginDialog.tsx
|
|
2074
2124
|
import { useCallback as useCallback5, useEffect as useEffect8, useRef as useRef4, useState as useState7 } from "react";
|
|
@@ -2295,7 +2345,7 @@ var RunFrameForCli = (props) => {
|
|
|
2295
2345
|
);
|
|
2296
2346
|
const evalWebWorkerBlobUrl = props.evalWebWorkerBlobUrl ?? props.workerBlobUrl;
|
|
2297
2347
|
const cacheApiBaseUrl = props.apiBaseUrl ?? API_BASE;
|
|
2298
|
-
const platformConfig =
|
|
2348
|
+
const platformConfig = useMemo6(
|
|
2299
2349
|
() => ({
|
|
2300
2350
|
...props.platformConfig,
|
|
2301
2351
|
localCacheEngine: props.platformConfig?.localCacheEngine ?? createCliLocalCacheEngine({ apiBaseUrl: cacheApiBaseUrl })
|