freestyle-sandboxes 0.0.63 → 0.0.64

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/inde.d.cts CHANGED
@@ -180,7 +180,7 @@ declare class FreestyleSandboxes {
180
180
  * ephemeral so you should call this function every time you need a url. Do
181
181
  * not store the url in your database!
182
182
  */
183
- requestDevServer({ repoUrl, repoId, baseId, }: {
183
+ requestDevServer(options: {
184
184
  /**
185
185
  * @deprecated
186
186
  */
@@ -188,10 +188,11 @@ declare class FreestyleSandboxes {
188
188
  repoId?: string;
189
189
  repo?: string;
190
190
  baseId?: string;
191
+ devCommand?: string;
191
192
  }): Promise<{
192
193
  mcpEphemeralUrl: any;
193
194
  ephemeralUrl: string;
194
- codeServerUrl: string;
195
+ codeServerUrl: any;
195
196
  url: string;
196
197
  isNew: boolean;
197
198
  devCommandRunning: boolean;
package/dist/inde.d.mts CHANGED
@@ -180,7 +180,7 @@ declare class FreestyleSandboxes {
180
180
  * ephemeral so you should call this function every time you need a url. Do
181
181
  * not store the url in your database!
182
182
  */
183
- requestDevServer({ repoUrl, repoId, baseId, }: {
183
+ requestDevServer(options: {
184
184
  /**
185
185
  * @deprecated
186
186
  */
@@ -188,10 +188,11 @@ declare class FreestyleSandboxes {
188
188
  repoId?: string;
189
189
  repo?: string;
190
190
  baseId?: string;
191
+ devCommand?: string;
191
192
  }): Promise<{
192
193
  mcpEphemeralUrl: any;
193
194
  ephemeralUrl: string;
194
- codeServerUrl: string;
195
+ codeServerUrl: any;
195
196
  url: string;
196
197
  isNew: boolean;
197
198
  devCommandRunning: boolean;
package/dist/index.cjs CHANGED
@@ -777,30 +777,25 @@ ${response.error.message}`);
777
777
  * ephemeral so you should call this function every time you need a url. Do
778
778
  * not store the url in your database!
779
779
  */
780
- async requestDevServer({
781
- repoUrl,
782
- repoId,
783
- baseId
784
- }) {
785
- function formatHook(serverUrl, repoUrl2) {
786
- const hook = serverUrl + "/__freestyle_dev_server/update/git?repo=" + encodeURIComponent(repoUrl2);
780
+ async requestDevServer(options) {
781
+ function formatHook(serverUrl, repoUrl) {
782
+ const hook = serverUrl + "/__freestyle_dev_server/update/git?repo=" + encodeURIComponent(repoUrl);
787
783
  return hook;
788
784
  }
789
785
  const response = await handleEphemeralDevServer({
790
786
  client: this.client,
791
787
  body: {
788
+ ...options,
792
789
  // @ts-ignore
793
- repo: repoUrl,
794
- repoId,
795
- baseId
790
+ repo: options.repoUrl
796
791
  }
797
792
  });
798
793
  if (response.data.isNew) {
799
- const rId = repoId || repoUrl.split("/").at(-1);
794
+ const rId = options.repoId || options.repoUrl.split("/").at(-1);
800
795
  await this.createGitTrigger({
801
796
  repoId: rId,
802
797
  action: {
803
- endpoint: formatHook(response.data?.url, repoUrl || `https://git.freestyle.sh/${rId}`),
798
+ endpoint: formatHook(response.data?.url, options.repoUrl || `https://git.freestyle.sh/${rId}`),
804
799
  action: "webhook"
805
800
  },
806
801
  trigger: {
@@ -815,9 +810,9 @@ ${response.error.message}`);
815
810
  ...response.data,
816
811
  // @ts-ignore
817
812
  mcpEphemeralUrl: response.data.mcpEphemeralUrl || response.data.url + "/mcp",
818
- // @ts-ignore
819
813
  ephemeralUrl: response.data.ephemeralUrl ?? response.data.url,
820
- codeServerUrl: response.data.ephemeralUrl + "/__freestyle_code_server/?folder=/template"
814
+ // @ts-ignore
815
+ codeServerUrl: response.data.codeServerUrl ?? response.data.ephemeralUrl + "/__freestyle_code_server/?folder=/template"
821
816
  };
822
817
  }
823
818
  }
package/dist/index.d.cts CHANGED
@@ -180,7 +180,7 @@ declare class FreestyleSandboxes {
180
180
  * ephemeral so you should call this function every time you need a url. Do
181
181
  * not store the url in your database!
182
182
  */
183
- requestDevServer({ repoUrl, repoId, baseId, }: {
183
+ requestDevServer(options: {
184
184
  /**
185
185
  * @deprecated
186
186
  */
@@ -188,10 +188,11 @@ declare class FreestyleSandboxes {
188
188
  repoId?: string;
189
189
  repo?: string;
190
190
  baseId?: string;
191
+ devCommand?: string;
191
192
  }): Promise<{
192
193
  mcpEphemeralUrl: any;
193
194
  ephemeralUrl: string;
194
- codeServerUrl: string;
195
+ codeServerUrl: any;
195
196
  url: string;
196
197
  isNew: boolean;
197
198
  devCommandRunning: boolean;
package/dist/index.d.mts CHANGED
@@ -180,7 +180,7 @@ declare class FreestyleSandboxes {
180
180
  * ephemeral so you should call this function every time you need a url. Do
181
181
  * not store the url in your database!
182
182
  */
183
- requestDevServer({ repoUrl, repoId, baseId, }: {
183
+ requestDevServer(options: {
184
184
  /**
185
185
  * @deprecated
186
186
  */
@@ -188,10 +188,11 @@ declare class FreestyleSandboxes {
188
188
  repoId?: string;
189
189
  repo?: string;
190
190
  baseId?: string;
191
+ devCommand?: string;
191
192
  }): Promise<{
192
193
  mcpEphemeralUrl: any;
193
194
  ephemeralUrl: string;
194
- codeServerUrl: string;
195
+ codeServerUrl: any;
195
196
  url: string;
196
197
  isNew: boolean;
197
198
  devCommandRunning: boolean;
package/dist/index.mjs CHANGED
@@ -775,30 +775,25 @@ ${response.error.message}`);
775
775
  * ephemeral so you should call this function every time you need a url. Do
776
776
  * not store the url in your database!
777
777
  */
778
- async requestDevServer({
779
- repoUrl,
780
- repoId,
781
- baseId
782
- }) {
783
- function formatHook(serverUrl, repoUrl2) {
784
- const hook = serverUrl + "/__freestyle_dev_server/update/git?repo=" + encodeURIComponent(repoUrl2);
778
+ async requestDevServer(options) {
779
+ function formatHook(serverUrl, repoUrl) {
780
+ const hook = serverUrl + "/__freestyle_dev_server/update/git?repo=" + encodeURIComponent(repoUrl);
785
781
  return hook;
786
782
  }
787
783
  const response = await handleEphemeralDevServer({
788
784
  client: this.client,
789
785
  body: {
786
+ ...options,
790
787
  // @ts-ignore
791
- repo: repoUrl,
792
- repoId,
793
- baseId
788
+ repo: options.repoUrl
794
789
  }
795
790
  });
796
791
  if (response.data.isNew) {
797
- const rId = repoId || repoUrl.split("/").at(-1);
792
+ const rId = options.repoId || options.repoUrl.split("/").at(-1);
798
793
  await this.createGitTrigger({
799
794
  repoId: rId,
800
795
  action: {
801
- endpoint: formatHook(response.data?.url, repoUrl || `https://git.freestyle.sh/${rId}`),
796
+ endpoint: formatHook(response.data?.url, options.repoUrl || `https://git.freestyle.sh/${rId}`),
802
797
  action: "webhook"
803
798
  },
804
799
  trigger: {
@@ -813,9 +808,9 @@ ${response.error.message}`);
813
808
  ...response.data,
814
809
  // @ts-ignore
815
810
  mcpEphemeralUrl: response.data.mcpEphemeralUrl || response.data.url + "/mcp",
816
- // @ts-ignore
817
811
  ephemeralUrl: response.data.ephemeralUrl ?? response.data.url,
818
- codeServerUrl: response.data.ephemeralUrl + "/__freestyle_code_server/?folder=/template"
812
+ // @ts-ignore
813
+ codeServerUrl: response.data.codeServerUrl ?? response.data.ephemeralUrl + "/__freestyle_code_server/?folder=/template"
819
814
  };
820
815
  }
821
816
  }
@@ -52,15 +52,6 @@ function FreestyleDevServerInner({
52
52
  refetchInterval: 1e3
53
53
  });
54
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]);
64
55
  const [wasLoaded, setWasLoaded] = React.useState(false);
65
56
  const [iframeLoaded, setIframeLoaded] = React.useState(false);
66
57
  React.useMemo(() => {
@@ -69,9 +60,13 @@ function FreestyleDevServerInner({
69
60
  }
70
61
  }, [isLoading, data?.devCommandRunning]);
71
62
  React.useEffect(() => {
72
- ref.current?.addEventListener("load", () => {
63
+ function loadHandle() {
73
64
  setIframeLoaded(true);
74
- });
65
+ }
66
+ ref.current?.addEventListener("load", loadHandle);
67
+ return () => {
68
+ ref.current?.removeEventListener("load", loadHandle);
69
+ };
75
70
  }, [ref]);
76
71
  if (isLoading) {
77
72
  return loadingComponent({
@@ -50,15 +50,6 @@ function FreestyleDevServerInner({
50
50
  refetchInterval: 1e3
51
51
  });
52
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]);
62
53
  const [wasLoaded, setWasLoaded] = React.useState(false);
63
54
  const [iframeLoaded, setIframeLoaded] = React.useState(false);
64
55
  React.useMemo(() => {
@@ -67,9 +58,13 @@ function FreestyleDevServerInner({
67
58
  }
68
59
  }, [isLoading, data?.devCommandRunning]);
69
60
  React.useEffect(() => {
70
- ref.current?.addEventListener("load", () => {
61
+ function loadHandle() {
71
62
  setIframeLoaded(true);
72
- });
63
+ }
64
+ ref.current?.addEventListener("load", loadHandle);
65
+ return () => {
66
+ ref.current?.removeEventListener("load", loadHandle);
67
+ };
73
68
  }, [ref]);
74
69
  if (isLoading) {
75
70
  return loadingComponent({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "freestyle-sandboxes",
3
- "version": "0.0.63",
3
+ "version": "0.0.64",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
package/src/index.ts CHANGED
@@ -797,17 +797,14 @@ export class FreestyleSandboxes {
797
797
  * ephemeral so you should call this function every time you need a url. Do
798
798
  * not store the url in your database!
799
799
  */
800
- async requestDevServer({
801
- repoUrl,
802
- repoId,
803
- baseId,
804
- }: {
800
+ async requestDevServer(options: {
805
801
  /**
806
802
  * @deprecated
807
803
  */
808
804
  repoUrl?: string,
809
805
  repoId?: string, repo?: string,
810
806
  baseId?: string,
807
+ devCommand?: string,
811
808
  }) {
812
809
  function formatHook(serverUrl: string, repoUrl: string) {
813
810
  const hook =
@@ -820,20 +817,19 @@ export class FreestyleSandboxes {
820
817
  const response = await sandbox_openapi.handleEphemeralDevServer({
821
818
  client: this.client,
822
819
  body: {
820
+ ...options,
823
821
  // @ts-ignore
824
- repo: repoUrl,
825
- repoId: repoId,
826
- baseId: baseId
822
+ repo: options.repoUrl,
827
823
  },
828
824
  });
829
825
 
830
826
  if (response.data.isNew) {
831
- const rId = repoId || repoUrl.split("/").at(-1)!;
827
+ const rId = options.repoId || options.repoUrl.split("/").at(-1)!;
832
828
 
833
829
  await this.createGitTrigger({
834
830
  repoId: rId,
835
831
  action: {
836
- endpoint: formatHook(response.data?.url!, repoUrl || `https://git.freestyle.sh/${rId}`),
832
+ endpoint: formatHook(response.data?.url!, options.repoUrl || `https://git.freestyle.sh/${rId}`),
837
833
  action: "webhook"
838
834
  },
839
835
  trigger: {
@@ -850,9 +846,9 @@ export class FreestyleSandboxes {
850
846
  // @ts-ignore
851
847
  mcpEphemeralUrl:
852
848
  (response.data as any).mcpEphemeralUrl || response.data.url + "/mcp",
853
- // @ts-ignore
854
849
  ephemeralUrl: response.data.ephemeralUrl ?? response.data.url,
855
- codeServerUrl: response.data.ephemeralUrl + "/__freestyle_code_server/?folder=/template",
850
+ // @ts-ignore
851
+ codeServerUrl: response.data.codeServerUrl ?? response.data.ephemeralUrl + "/__freestyle_code_server/?folder=/template",
856
852
  };
857
853
  }
858
854
  }
@@ -84,21 +84,7 @@ function FreestyleDevServerInner({
84
84
  refetchInterval: 1000,
85
85
  });
86
86
 
87
- // keep reloading the iframe because there's a bug where the websocket
88
- // connection to the dev server is closed every 1 minute
89
87
  const ref = React.useRef<HTMLIFrameElement>(null);
90
- React.useEffect(() => {
91
- if (!data?.ephemeralUrl) return;
92
-
93
- const interval = setInterval(() => {
94
- if (ref.current) {
95
- ref.current.src = data.ephemeralUrl;
96
- }
97
- }, 45 * 1000);
98
-
99
- return () => clearInterval(interval);
100
- }, [data?.ephemeralUrl]);
101
-
102
88
  const [wasLoaded, setWasLoaded] = React.useState(false);
103
89
  const [iframeLoaded, setIframeLoaded] = React.useState(false);
104
90
 
@@ -109,9 +95,14 @@ function FreestyleDevServerInner({
109
95
  }, [isLoading, data?.devCommandRunning]);
110
96
 
111
97
  React.useEffect(() => {
112
- ref.current?.addEventListener("load", () => {
98
+ function loadHandle() {
113
99
  setIframeLoaded(true);
114
- });
100
+ }
101
+
102
+ ref.current?.addEventListener("load", loadHandle);
103
+ return () => {
104
+ ref.current?.removeEventListener("load", loadHandle);
105
+ };
115
106
  }, [ref]);
116
107
 
117
108
  if (isLoading) {