freestyle-sandboxes 0.0.47 → 0.0.48

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.
@@ -51,6 +51,16 @@ function FreestyleDevServerInner({
51
51
  queryFn: async () => await requestDevServer({ repoUrl }),
52
52
  refetchInterval: 1e3
53
53
  });
54
+ const ref = React.useRef(null);
55
+ React.useEffect(() => {
56
+ if (!data?.ephemeralUrl) return;
57
+ const interval = setInterval(() => {
58
+ if (ref.current) {
59
+ ref.current.src = data.ephemeralUrl;
60
+ }
61
+ }, 45 * 1e3);
62
+ return () => clearInterval(interval);
63
+ }, [data?.ephemeralUrl]);
54
64
  if (isLoading) {
55
65
  return loadingComponent({
56
66
  devCommandRunning: false,
@@ -68,6 +78,7 @@ function FreestyleDevServerInner({
68
78
  return /* @__PURE__ */ React.createElement(
69
79
  "iframe",
70
80
  {
81
+ ref,
71
82
  sandbox: "allow-scripts allow-same-origin allow-forms",
72
83
  src: data.ephemeralUrl,
73
84
  style: {
@@ -49,6 +49,16 @@ function FreestyleDevServerInner({
49
49
  queryFn: async () => await requestDevServer({ repoUrl }),
50
50
  refetchInterval: 1e3
51
51
  });
52
+ const ref = React.useRef(null);
53
+ React.useEffect(() => {
54
+ if (!data?.ephemeralUrl) return;
55
+ const interval = setInterval(() => {
56
+ if (ref.current) {
57
+ ref.current.src = data.ephemeralUrl;
58
+ }
59
+ }, 45 * 1e3);
60
+ return () => clearInterval(interval);
61
+ }, [data?.ephemeralUrl]);
52
62
  if (isLoading) {
53
63
  return loadingComponent({
54
64
  devCommandRunning: false,
@@ -66,6 +76,7 @@ function FreestyleDevServerInner({
66
76
  return /* @__PURE__ */ React.createElement(
67
77
  "iframe",
68
78
  {
79
+ ref,
69
80
  sandbox: "allow-scripts allow-same-origin allow-forms",
70
81
  src: data.ephemeralUrl,
71
82
  style: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "freestyle-sandboxes",
3
- "version": "0.0.47",
3
+ "version": "0.0.48",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -81,6 +81,21 @@ function FreestyleDevServerInner({
81
81
  refetchInterval: 1000,
82
82
  });
83
83
 
84
+ // keep reloading the iframe because there's a bug where the websocket
85
+ // connection to the dev server is closed every 1 minute
86
+ const ref = React.useRef<HTMLIFrameElement>(null);
87
+ React.useEffect(() => {
88
+ if (!data?.ephemeralUrl) return;
89
+
90
+ const interval = setInterval(() => {
91
+ if (ref.current) {
92
+ ref.current.src = data.ephemeralUrl;
93
+ }
94
+ }, 45 * 1000);
95
+
96
+ return () => clearInterval(interval);
97
+ }, [data?.ephemeralUrl]);
98
+
84
99
  if (isLoading) {
85
100
  return loadingComponent({
86
101
  devCommandRunning: false,
@@ -99,6 +114,7 @@ function FreestyleDevServerInner({
99
114
 
100
115
  return (
101
116
  <iframe
117
+ ref={ref}
102
118
  sandbox="allow-scripts allow-same-origin allow-forms"
103
119
  src={data.ephemeralUrl}
104
120
  style={{