@tscircuit/runframe 0.0.313 → 0.0.314
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-U2ZLCEUS.js → chunk-PC663PVG.js} +1 -1
- package/dist/preview.js +1 -1
- package/dist/runner.js +82 -72
- package/dist/standalone-preview.min.js +447 -447
- package/dist/standalone.min.js +799 -799
- package/package.json +2 -2
package/dist/preview.js
CHANGED
package/dist/runner.js
CHANGED
|
@@ -20,13 +20,62 @@ import {
|
|
|
20
20
|
buttonVariants,
|
|
21
21
|
cn,
|
|
22
22
|
linkify
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-PC663PVG.js";
|
|
24
24
|
|
|
25
25
|
// lib/components/RunFrame/RunFrame.tsx
|
|
26
26
|
import { createCircuitWebWorker } from "@tscircuit/eval/worker";
|
|
27
|
-
import { useEffect, useReducer, useRef as useRef2, useState } from "react";
|
|
28
27
|
import Debug2 from "debug";
|
|
29
28
|
import { Loader2, Play, Square } from "lucide-react";
|
|
29
|
+
import { useEffect, useReducer, useRef as useRef2, useState } from "react";
|
|
30
|
+
|
|
31
|
+
// lib/render-logging/getPhaseTimingsFromRenderEvents.ts
|
|
32
|
+
import { orderedRenderPhases } from "@tscircuit/core";
|
|
33
|
+
var getPhaseTimingsFromRenderEvents = (renderEvents) => {
|
|
34
|
+
const phaseTimings = {};
|
|
35
|
+
if (!renderEvents) return phaseTimings;
|
|
36
|
+
for (const renderPhase of orderedRenderPhases) {
|
|
37
|
+
phaseTimings[renderPhase] = 0;
|
|
38
|
+
}
|
|
39
|
+
const startEvents = /* @__PURE__ */ new Map();
|
|
40
|
+
for (const event of renderEvents) {
|
|
41
|
+
const [, , phase, eventType] = event.type.split(":");
|
|
42
|
+
if (eventType === "start") {
|
|
43
|
+
startEvents.set(`${phase}:${event.renderId}`, event);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (eventType === "end") {
|
|
47
|
+
const startEvent = startEvents.get(`${phase}:${event.renderId}`);
|
|
48
|
+
if (startEvent) {
|
|
49
|
+
const duration = event.createdAt - startEvent.createdAt;
|
|
50
|
+
phaseTimings[phase] = (phaseTimings[phase] || 0) + duration;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return phaseTimings;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
// lib/utils/getChangesBetweenFsMaps.tsx
|
|
58
|
+
var getChangesBetweenFsMaps = (fsMap1, fsMap2) => {
|
|
59
|
+
const changes = {};
|
|
60
|
+
for (const [path, oldContent] of fsMap1.entries()) {
|
|
61
|
+
const newContent = fsMap2.get(path);
|
|
62
|
+
if (newContent !== oldContent) {
|
|
63
|
+
changes[path] = {
|
|
64
|
+
old: oldContent,
|
|
65
|
+
new: newContent
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
for (const [path, newContent] of fsMap2.entries()) {
|
|
70
|
+
if (!fsMap1.has(path)) {
|
|
71
|
+
changes[path] = {
|
|
72
|
+
old: void 0,
|
|
73
|
+
new: newContent
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return changes;
|
|
78
|
+
};
|
|
30
79
|
|
|
31
80
|
// lib/components/RunFrameWithApi/store.ts
|
|
32
81
|
import { applyEditEventsToManualEditsFile } from "@tscircuit/core";
|
|
@@ -195,54 +244,20 @@ var useRunFrameStore = create()(
|
|
|
195
244
|
)
|
|
196
245
|
);
|
|
197
246
|
|
|
198
|
-
// lib/
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
for (const [path, newContent] of fsMap2.entries()) {
|
|
211
|
-
if (!fsMap1.has(path)) {
|
|
212
|
-
changes[path] = {
|
|
213
|
-
old: void 0,
|
|
214
|
-
new: newContent
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
return changes;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
// lib/render-logging/getPhaseTimingsFromRenderEvents.ts
|
|
222
|
-
import { orderedRenderPhases } from "@tscircuit/core";
|
|
223
|
-
var getPhaseTimingsFromRenderEvents = (renderEvents) => {
|
|
224
|
-
const phaseTimings = {};
|
|
225
|
-
if (!renderEvents) return phaseTimings;
|
|
226
|
-
for (const renderPhase of orderedRenderPhases) {
|
|
227
|
-
phaseTimings[renderPhase] = 0;
|
|
228
|
-
}
|
|
229
|
-
const startEvents = /* @__PURE__ */ new Map();
|
|
230
|
-
for (const event of renderEvents) {
|
|
231
|
-
const [, , phase, eventType] = event.type.split(":");
|
|
232
|
-
if (eventType === "start") {
|
|
233
|
-
startEvents.set(`${phase}:${event.renderId}`, event);
|
|
234
|
-
continue;
|
|
235
|
-
}
|
|
236
|
-
if (eventType === "end") {
|
|
237
|
-
const startEvent = startEvents.get(`${phase}:${event.renderId}`);
|
|
238
|
-
if (startEvent) {
|
|
239
|
-
const duration = event.createdAt - startEvent.createdAt;
|
|
240
|
-
phaseTimings[phase] = (phaseTimings[phase] || 0) + duration;
|
|
247
|
+
// lib/components/RunFrame/runner-store/use-runner-store.ts
|
|
248
|
+
import { create as create2 } from "zustand";
|
|
249
|
+
import { devtools as devtools2 } from "zustand/middleware";
|
|
250
|
+
var useRunnerStore = create2()(
|
|
251
|
+
devtools2(
|
|
252
|
+
(set) => ({
|
|
253
|
+
lastRunEvalVersion: void 0,
|
|
254
|
+
setLastRunEvalVersion: (version) => {
|
|
255
|
+
set({ lastRunEvalVersion: version });
|
|
241
256
|
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
257
|
+
}),
|
|
258
|
+
{ name: "runframe-runner-store" }
|
|
259
|
+
)
|
|
260
|
+
);
|
|
246
261
|
|
|
247
262
|
// lib/components/RunFrame/useMutex.tsx
|
|
248
263
|
import { useCallback, useRef } from "react";
|
|
@@ -271,21 +286,6 @@ function useMutex() {
|
|
|
271
286
|
return { runWithMutex, isLocked };
|
|
272
287
|
}
|
|
273
288
|
|
|
274
|
-
// lib/components/RunFrame/runner-store/use-runner-store.ts
|
|
275
|
-
import { create as create2 } from "zustand";
|
|
276
|
-
import { devtools as devtools2 } from "zustand/middleware";
|
|
277
|
-
var useRunnerStore = create2()(
|
|
278
|
-
devtools2(
|
|
279
|
-
(set) => ({
|
|
280
|
-
lastRunEvalVersion: void 0,
|
|
281
|
-
setLastRunEvalVersion: (version) => {
|
|
282
|
-
set({ lastRunEvalVersion: version });
|
|
283
|
-
}
|
|
284
|
-
}),
|
|
285
|
-
{ name: "runframe-runner-store" }
|
|
286
|
-
)
|
|
287
|
-
);
|
|
288
|
-
|
|
289
289
|
// lib/components/RunFrame/RunFrame.tsx
|
|
290
290
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
291
291
|
var numRenderPhases = 26;
|
|
@@ -503,6 +503,12 @@ var RunFrame = (props) => {
|
|
|
503
503
|
const lastEditEventRef = useRef2(null);
|
|
504
504
|
const dragTimeout = useRef2(null);
|
|
505
505
|
const handleEditEvent = (event) => {
|
|
506
|
+
if (!event || event === null) {
|
|
507
|
+
console.warn(
|
|
508
|
+
"[RunFrame] handleEditEvent received null or undefined event."
|
|
509
|
+
);
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
506
512
|
if (event.in_progress) {
|
|
507
513
|
lastEditEventRef.current = event;
|
|
508
514
|
if (dragTimeout.current) {
|
|
@@ -514,7 +520,8 @@ var RunFrame = (props) => {
|
|
|
514
520
|
clearTimeout(dragTimeout.current);
|
|
515
521
|
}
|
|
516
522
|
dragTimeout.current = setTimeout(() => {
|
|
517
|
-
|
|
523
|
+
const eventToSend = event || lastEditEventRef.current;
|
|
524
|
+
props.onEditEvent?.(eventToSend);
|
|
518
525
|
lastEditEventRef.current = null;
|
|
519
526
|
dragTimeout.current = null;
|
|
520
527
|
}, 100);
|
|
@@ -586,7 +593,7 @@ var RunFrame = (props) => {
|
|
|
586
593
|
};
|
|
587
594
|
|
|
588
595
|
// lib/components/RunFrameWithApi/RunFrameWithApi.tsx
|
|
589
|
-
import
|
|
596
|
+
import Debug3 from "debug";
|
|
590
597
|
|
|
591
598
|
// lib/hooks/use-edit-event-controller.ts
|
|
592
599
|
import { useState as useState2, useCallback as useCallback2, useEffect as useEffect2 } from "react";
|
|
@@ -646,8 +653,8 @@ var useEditEventController = () => {
|
|
|
646
653
|
};
|
|
647
654
|
|
|
648
655
|
// lib/components/RunFrameWithApi/RunFrameWithApi.tsx
|
|
649
|
-
import
|
|
650
|
-
import {
|
|
656
|
+
import { useEffect as useEffect3 } from "react";
|
|
657
|
+
import { applyEditEventsToManualEditsFile as applyEditEventsToManualEditsFile2 } from "@tscircuit/core";
|
|
651
658
|
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
652
659
|
var debug5 = Debug3("run-frame:RunFrameWithApi");
|
|
653
660
|
var guessEntrypoint = (files) => files.find((file) => file.includes("entrypoint.")) ?? files.find((file) => file.includes("index.")) ?? files.find((file) => file.includes("main.")) ?? files.find((file) => file.endsWith(".tsx"));
|
|
@@ -728,10 +735,13 @@ var RunFrameWithApi = (props) => {
|
|
|
728
735
|
});
|
|
729
736
|
const manualEditsFilePath = guessManualEditsFilePath(Array.from(fsMap.keys())) ?? "manual-edits.json";
|
|
730
737
|
const manualEditsFile = fsMap.get(manualEditsFilePath);
|
|
731
|
-
const updatedManualEdits =
|
|
738
|
+
const updatedManualEdits = JSON.parse(
|
|
739
|
+
manualEditsFile ?? "{}"
|
|
740
|
+
);
|
|
741
|
+
applyEditEventsToManualEditsFile2({
|
|
732
742
|
circuitJson,
|
|
733
743
|
editEvents: [ee],
|
|
734
|
-
manualEditsFile:
|
|
744
|
+
manualEditsFile: updatedManualEdits
|
|
735
745
|
});
|
|
736
746
|
fetch(`${API_BASE}/files/upsert`, {
|
|
737
747
|
method: "POST",
|
|
@@ -770,7 +780,7 @@ function useLocalStorageState(key, initialValue) {
|
|
|
770
780
|
}
|
|
771
781
|
|
|
772
782
|
// lib/components/RunFrameForCli/LeftHeader.tsx
|
|
773
|
-
import { useEffect as useEffect8, useMemo as
|
|
783
|
+
import { useEffect as useEffect8, useMemo as useMemo2, useState as useState10 } from "react";
|
|
774
784
|
|
|
775
785
|
// lib/components/RunFrameForCli/SelectSnippetDialog.tsx
|
|
776
786
|
import { useState as useState4 } from "react";
|
|
@@ -2264,7 +2274,7 @@ var RunframeCliLeftHeader = (props) => {
|
|
|
2264
2274
|
const orderDialog = useOrderDialog();
|
|
2265
2275
|
const pushEvent = useRunFrameStore((state) => state.pushEvent);
|
|
2266
2276
|
const recentEvents = useRunFrameStore((state) => state.recentEvents);
|
|
2267
|
-
const firstRenderTime =
|
|
2277
|
+
const firstRenderTime = useMemo2(() => Date.now(), []);
|
|
2268
2278
|
useEventHandler((event) => {
|
|
2269
2279
|
if (new Date(event.created_at).valueOf() < firstRenderTime + 500) return;
|
|
2270
2280
|
if (event.event_type === "FILE_UPDATED") {
|