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.
@@ -5,7 +5,7 @@ import { Transform } from 'stream';
5
5
  import { EventEmitter } from 'events';
6
6
  import { ServerResponse, IncomingMessage } from 'http';
7
7
  import { WorkerOptions } from 'worker_threads';
8
- import { F as FreestyleExecuteScriptParamsConfiguration } from '../types.gen-CZUnqmzP.js';
8
+ import { F as FreestyleExecuteScriptParamsConfiguration } from '../types.gen-CIf3ciN7.js';
9
9
  import 'node:http';
10
10
 
11
11
  // Type definitions for pino-std-serializers 2.4
@@ -5,7 +5,7 @@ import { Transform } from 'stream';
5
5
  import { EventEmitter } from 'events';
6
6
  import { ServerResponse, IncomingMessage } from 'http';
7
7
  import { WorkerOptions } from 'worker_threads';
8
- import { F as FreestyleExecuteScriptParamsConfiguration } from '../types.gen-CZUnqmzP.js';
8
+ import { F as FreestyleExecuteScriptParamsConfiguration } from '../types.gen-CIf3ciN7.js';
9
9
  import 'node:http';
10
10
 
11
11
  // Type definitions for pino-std-serializers 2.4
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+
3
+ type RequestDevServerActions = {
4
+ requestDevServer: (args: {
5
+ repoUrl: string;
6
+ }) => Promise<{
7
+ ephemeralUrl: string;
8
+ devCommandRunning: boolean;
9
+ installCommandRunning: boolean;
10
+ }>;
11
+ };
12
+
13
+ declare function DefaultLoadingComponent({ installCommandRunning, }: {
14
+ devCommandRunning: boolean;
15
+ installCommandRunning: boolean;
16
+ serverStarting: boolean;
17
+ }): any;
18
+ declare function FreestyleDevServer({ repoUrl, loadingComponent, actions, }: {
19
+ repoUrl: string;
20
+ loadingComponent?: (props: {
21
+ devCommandRunning: boolean;
22
+ installCommandRunning: boolean;
23
+ serverStarting: boolean;
24
+ }) => React.ReactNode;
25
+ actions: RequestDevServerActions;
26
+ }): any;
27
+
28
+ export { DefaultLoadingComponent, FreestyleDevServer };
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+
3
+ type RequestDevServerActions = {
4
+ requestDevServer: (args: {
5
+ repoUrl: string;
6
+ }) => Promise<{
7
+ ephemeralUrl: string;
8
+ devCommandRunning: boolean;
9
+ installCommandRunning: boolean;
10
+ }>;
11
+ };
12
+
13
+ declare function DefaultLoadingComponent({ installCommandRunning, }: {
14
+ devCommandRunning: boolean;
15
+ installCommandRunning: boolean;
16
+ serverStarting: boolean;
17
+ }): any;
18
+ declare function FreestyleDevServer({ repoUrl, loadingComponent, actions, }: {
19
+ repoUrl: string;
20
+ loadingComponent?: (props: {
21
+ devCommandRunning: boolean;
22
+ installCommandRunning: boolean;
23
+ serverStarting: boolean;
24
+ }) => React.ReactNode;
25
+ actions: RequestDevServerActions;
26
+ }): any;
27
+
28
+ export { DefaultLoadingComponent, FreestyleDevServer };
@@ -0,0 +1,83 @@
1
+ 'use strict';
2
+
3
+ var reactQuery = require('@tanstack/react-query');
4
+ var React = require('react');
5
+
6
+ const queryClient = new reactQuery.QueryClient();
7
+ function DefaultLoadingComponent({
8
+ installCommandRunning
9
+ }) {
10
+ let loadingText = "Starting container...";
11
+ if (installCommandRunning) {
12
+ loadingText = "Installing dependencies...";
13
+ } else {
14
+ loadingText = "Starting dev server...";
15
+ }
16
+ return /* @__PURE__ */ React.createElement(
17
+ "div",
18
+ {
19
+ style: {
20
+ display: "flex",
21
+ flexDirection: "column",
22
+ alignItems: "center",
23
+ justifyContent: "center",
24
+ height: "100%"
25
+ }
26
+ },
27
+ loadingText
28
+ );
29
+ }
30
+ function FreestyleDevServer({
31
+ repoUrl,
32
+ loadingComponent,
33
+ actions
34
+ }) {
35
+ return /* @__PURE__ */ React.createElement(reactQuery.QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React.createElement(
36
+ FreestyleDevServerInner,
37
+ {
38
+ loadingComponent: loadingComponent ?? DefaultLoadingComponent,
39
+ repoUrl,
40
+ actions
41
+ }
42
+ ));
43
+ }
44
+ function FreestyleDevServerInner({
45
+ repoUrl,
46
+ loadingComponent,
47
+ actions: { requestDevServer }
48
+ }) {
49
+ const { data, isLoading } = reactQuery.useQuery({
50
+ queryKey: ["dev-server", repoUrl],
51
+ queryFn: async () => await requestDevServer({ repoUrl }),
52
+ refetchInterval: 1e3
53
+ });
54
+ if (isLoading) {
55
+ return loadingComponent({
56
+ devCommandRunning: false,
57
+ installCommandRunning: false,
58
+ serverStarting: true
59
+ });
60
+ }
61
+ if (!data?.devCommandRunning) {
62
+ return loadingComponent({
63
+ devCommandRunning: data?.devCommandRunning ?? false,
64
+ installCommandRunning: data?.installCommandRunning ?? false,
65
+ serverStarting: false
66
+ });
67
+ }
68
+ return /* @__PURE__ */ React.createElement(
69
+ "iframe",
70
+ {
71
+ sandbox: "allow-scripts allow-same-origin allow-forms",
72
+ src: data.ephemeralUrl,
73
+ style: {
74
+ width: "100%",
75
+ height: "100%",
76
+ border: "none"
77
+ }
78
+ }
79
+ );
80
+ }
81
+
82
+ exports.DefaultLoadingComponent = DefaultLoadingComponent;
83
+ exports.FreestyleDevServer = FreestyleDevServer;
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+
3
+ type RequestDevServerActions = {
4
+ requestDevServer: (args: {
5
+ repoUrl: string;
6
+ }) => Promise<{
7
+ ephemeralUrl: string;
8
+ devCommandRunning: boolean;
9
+ installCommandRunning: boolean;
10
+ }>;
11
+ };
12
+
13
+ declare function DefaultLoadingComponent({ installCommandRunning, }: {
14
+ devCommandRunning: boolean;
15
+ installCommandRunning: boolean;
16
+ serverStarting: boolean;
17
+ }): any;
18
+ declare function FreestyleDevServer({ repoUrl, loadingComponent, actions, }: {
19
+ repoUrl: string;
20
+ loadingComponent?: (props: {
21
+ devCommandRunning: boolean;
22
+ installCommandRunning: boolean;
23
+ serverStarting: boolean;
24
+ }) => React.ReactNode;
25
+ actions: RequestDevServerActions;
26
+ }): any;
27
+
28
+ export { DefaultLoadingComponent, FreestyleDevServer };
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+
3
+ type RequestDevServerActions = {
4
+ requestDevServer: (args: {
5
+ repoUrl: string;
6
+ }) => Promise<{
7
+ ephemeralUrl: string;
8
+ devCommandRunning: boolean;
9
+ installCommandRunning: boolean;
10
+ }>;
11
+ };
12
+
13
+ declare function DefaultLoadingComponent({ installCommandRunning, }: {
14
+ devCommandRunning: boolean;
15
+ installCommandRunning: boolean;
16
+ serverStarting: boolean;
17
+ }): any;
18
+ declare function FreestyleDevServer({ repoUrl, loadingComponent, actions, }: {
19
+ repoUrl: string;
20
+ loadingComponent?: (props: {
21
+ devCommandRunning: boolean;
22
+ installCommandRunning: boolean;
23
+ serverStarting: boolean;
24
+ }) => React.ReactNode;
25
+ actions: RequestDevServerActions;
26
+ }): any;
27
+
28
+ export { DefaultLoadingComponent, FreestyleDevServer };
@@ -0,0 +1,80 @@
1
+ import { QueryClient, QueryClientProvider, useQuery } from '@tanstack/react-query';
2
+ import React from 'react';
3
+
4
+ const queryClient = new QueryClient();
5
+ function DefaultLoadingComponent({
6
+ installCommandRunning
7
+ }) {
8
+ let loadingText = "Starting container...";
9
+ if (installCommandRunning) {
10
+ loadingText = "Installing dependencies...";
11
+ } else {
12
+ loadingText = "Starting dev server...";
13
+ }
14
+ return /* @__PURE__ */ React.createElement(
15
+ "div",
16
+ {
17
+ style: {
18
+ display: "flex",
19
+ flexDirection: "column",
20
+ alignItems: "center",
21
+ justifyContent: "center",
22
+ height: "100%"
23
+ }
24
+ },
25
+ loadingText
26
+ );
27
+ }
28
+ function FreestyleDevServer({
29
+ repoUrl,
30
+ loadingComponent,
31
+ actions
32
+ }) {
33
+ return /* @__PURE__ */ React.createElement(QueryClientProvider, { client: queryClient }, /* @__PURE__ */ React.createElement(
34
+ FreestyleDevServerInner,
35
+ {
36
+ loadingComponent: loadingComponent ?? DefaultLoadingComponent,
37
+ repoUrl,
38
+ actions
39
+ }
40
+ ));
41
+ }
42
+ function FreestyleDevServerInner({
43
+ repoUrl,
44
+ loadingComponent,
45
+ actions: { requestDevServer }
46
+ }) {
47
+ const { data, isLoading } = useQuery({
48
+ queryKey: ["dev-server", repoUrl],
49
+ queryFn: async () => await requestDevServer({ repoUrl }),
50
+ refetchInterval: 1e3
51
+ });
52
+ if (isLoading) {
53
+ return loadingComponent({
54
+ devCommandRunning: false,
55
+ installCommandRunning: false,
56
+ serverStarting: true
57
+ });
58
+ }
59
+ if (!data?.devCommandRunning) {
60
+ return loadingComponent({
61
+ devCommandRunning: data?.devCommandRunning ?? false,
62
+ installCommandRunning: data?.installCommandRunning ?? false,
63
+ serverStarting: false
64
+ });
65
+ }
66
+ return /* @__PURE__ */ React.createElement(
67
+ "iframe",
68
+ {
69
+ sandbox: "allow-scripts allow-same-origin allow-forms",
70
+ src: data.ephemeralUrl,
71
+ style: {
72
+ width: "100%",
73
+ height: "100%",
74
+ border: "none"
75
+ }
76
+ }
77
+ );
78
+ }
79
+
80
+ export { DefaultLoadingComponent, FreestyleDevServer };