freestyle-sandboxes 0.0.45 → 0.0.47
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/ai/inde.d.cts +71 -0
- package/dist/ai/inde.d.mts +71 -0
- package/dist/ai/index.d.cts +1 -1
- package/dist/ai/index.d.mts +1 -1
- package/dist/expo/inde.d.cts +6 -0
- package/dist/expo/inde.d.mts +6 -0
- package/dist/inde.d.cts +192 -0
- package/dist/inde.d.mts +192 -0
- package/dist/index.cjs +160 -49
- package/dist/index.d.cts +83 -47
- package/dist/index.d.mts +83 -47
- package/dist/index.mjs +160 -49
- package/dist/langgraph/inde.d.cts +2162 -0
- package/dist/langgraph/inde.d.mts +2162 -0
- package/dist/langgraph/index.d.cts +1 -1
- package/dist/langgraph/index.d.mts +1 -1
- package/dist/mastra/inde.d.cts +2623 -0
- package/dist/mastra/inde.d.mts +2623 -0
- package/dist/mastra/index.d.cts +1 -1
- package/dist/mastra/index.d.mts +1 -1
- package/dist/react/dev-server/index..d.cts +28 -0
- package/dist/react/dev-server/index..d.mts +28 -0
- package/dist/react/dev-server/index.cjs +83 -0
- package/dist/react/dev-server/index.d.cts +28 -0
- package/dist/react/dev-server/index.d.mts +28 -0
- package/dist/react/dev-server/index.mjs +80 -0
- package/dist/types.gen-CIf3ciN7.d.ts +807 -0
- package/dist/utils/inde.d.cts +10 -0
- package/dist/utils/inde.d.mts +10 -0
- package/dist/utils/index.d.cts +1 -1
- package/dist/utils/index.d.mts +1 -1
- package/openapi/types.gen.ts +27 -6
- package/openapi.json +4649 -1
- package/package.json +14 -2
- package/src/index.ts +222 -105
- package/src/react/dev-server/index.tsx +111 -0
- package/src/react/dev-server/types.ts +5 -0
- package/tsconfig.json +1 -1
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import {
|
|
2
|
+
QueryClient,
|
|
3
|
+
QueryClientProvider,
|
|
4
|
+
useQuery,
|
|
5
|
+
} from "@tanstack/react-query";
|
|
6
|
+
import { RequestDevServerActions } from "./types";
|
|
7
|
+
import React from "react";
|
|
8
|
+
|
|
9
|
+
const queryClient = new QueryClient();
|
|
10
|
+
|
|
11
|
+
export function DefaultLoadingComponent({
|
|
12
|
+
installCommandRunning,
|
|
13
|
+
}: {
|
|
14
|
+
devCommandRunning: boolean;
|
|
15
|
+
installCommandRunning: boolean;
|
|
16
|
+
serverStarting: boolean;
|
|
17
|
+
}) {
|
|
18
|
+
let loadingText = "Starting container...";
|
|
19
|
+
|
|
20
|
+
if (installCommandRunning) {
|
|
21
|
+
loadingText = "Installing dependencies...";
|
|
22
|
+
} else {
|
|
23
|
+
loadingText = "Starting dev server...";
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<div
|
|
28
|
+
style={{
|
|
29
|
+
display: "flex",
|
|
30
|
+
flexDirection: "column",
|
|
31
|
+
alignItems: "center",
|
|
32
|
+
justifyContent: "center",
|
|
33
|
+
height: "100%",
|
|
34
|
+
}}
|
|
35
|
+
>
|
|
36
|
+
{loadingText}
|
|
37
|
+
</div>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function FreestyleDevServer({
|
|
42
|
+
repoUrl,
|
|
43
|
+
loadingComponent,
|
|
44
|
+
actions,
|
|
45
|
+
}: {
|
|
46
|
+
repoUrl: string;
|
|
47
|
+
loadingComponent?: (props: {
|
|
48
|
+
devCommandRunning: boolean;
|
|
49
|
+
installCommandRunning: boolean;
|
|
50
|
+
serverStarting: boolean;
|
|
51
|
+
}) => React.ReactNode;
|
|
52
|
+
actions: RequestDevServerActions;
|
|
53
|
+
}) {
|
|
54
|
+
return (
|
|
55
|
+
<QueryClientProvider client={queryClient}>
|
|
56
|
+
<FreestyleDevServerInner
|
|
57
|
+
loadingComponent={loadingComponent ?? DefaultLoadingComponent}
|
|
58
|
+
repoUrl={repoUrl}
|
|
59
|
+
actions={actions}
|
|
60
|
+
/>
|
|
61
|
+
</QueryClientProvider>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function FreestyleDevServerInner({
|
|
66
|
+
repoUrl,
|
|
67
|
+
loadingComponent,
|
|
68
|
+
actions: { requestDevServer },
|
|
69
|
+
}: {
|
|
70
|
+
repoUrl: string;
|
|
71
|
+
loadingComponent: (props: {
|
|
72
|
+
devCommandRunning: boolean;
|
|
73
|
+
installCommandRunning: boolean;
|
|
74
|
+
serverStarting: boolean;
|
|
75
|
+
}) => React.ReactNode;
|
|
76
|
+
actions: RequestDevServerActions;
|
|
77
|
+
}) {
|
|
78
|
+
const { data, isLoading } = useQuery({
|
|
79
|
+
queryKey: ["dev-server", repoUrl],
|
|
80
|
+
queryFn: async () => await requestDevServer({ repoUrl: repoUrl }),
|
|
81
|
+
refetchInterval: 1000,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
if (isLoading) {
|
|
85
|
+
return loadingComponent({
|
|
86
|
+
devCommandRunning: false,
|
|
87
|
+
installCommandRunning: false,
|
|
88
|
+
serverStarting: true,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (!data?.devCommandRunning) {
|
|
93
|
+
return loadingComponent({
|
|
94
|
+
devCommandRunning: data?.devCommandRunning ?? false,
|
|
95
|
+
installCommandRunning: data?.installCommandRunning ?? false,
|
|
96
|
+
serverStarting: false,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<iframe
|
|
102
|
+
sandbox="allow-scripts allow-same-origin allow-forms"
|
|
103
|
+
src={data.ephemeralUrl}
|
|
104
|
+
style={{
|
|
105
|
+
width: "100%",
|
|
106
|
+
height: "100%",
|
|
107
|
+
border: "none",
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
}
|