@illuma-ai/code-sandbox 1.1.0 → 1.2.0
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/components/Workbench.d.ts +3 -2
- package/dist/hooks/useRuntime.d.ts +24 -14
- package/dist/index.cjs +82 -82
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4209 -4184
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +105 -13
- package/package.json +1 -1
- package/src/components/Workbench.tsx +133 -87
- package/src/hooks/useRuntime.ts +182 -216
- package/src/index.ts +1 -0
- package/src/types.ts +119 -14
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @see bolt.diy: app/components/workbench/Workbench.client.tsx (reference)
|
|
15
15
|
*/
|
|
16
|
+
import React from "react";
|
|
16
17
|
import "allotment/dist/style.css";
|
|
17
|
-
import type { CodeSandboxProps } from "../types";
|
|
18
|
+
import type { CodeSandboxProps, CodeSandboxHandle } from "../types";
|
|
18
19
|
/**
|
|
19
20
|
* CodeSandbox — The main entrypoint component.
|
|
20
21
|
*
|
|
@@ -25,4 +26,4 @@ import type { CodeSandboxProps } from "../types";
|
|
|
25
26
|
* A compact toolbar row contains the view toggle and (in preview mode)
|
|
26
27
|
* a URL bar with refresh button.
|
|
27
28
|
*/
|
|
28
|
-
export declare
|
|
29
|
+
export declare const CodeSandbox: React.ForwardRefExoticComponent<CodeSandboxProps & React.RefAttributes<CodeSandboxHandle>>;
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* Manages the Nodepod runtime instance and exposes reactive state
|
|
5
5
|
* for all UI components (progress, files, terminal output, preview URL).
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* The sandbox is a pure renderer — it receives files via props (initial
|
|
8
|
+
* load) and via the imperative handle (updateFiles/updateFile for live
|
|
9
|
+
* updates). It does NOT interact with any storage backend directly.
|
|
10
10
|
*
|
|
11
11
|
* Error exposure: wires the runtime's structured error system and the
|
|
12
12
|
* preview iframe's browser error capture into a unified `errors[]` array
|
|
@@ -14,24 +14,26 @@
|
|
|
14
14
|
* so the AI agent can auto-fix.
|
|
15
15
|
*/
|
|
16
16
|
import { NodepodRuntime } from "../services/runtime";
|
|
17
|
-
import type { CodeSandboxProps, FileMap, RuntimeState, SandboxError } from "../types";
|
|
17
|
+
import type { CodeSandboxProps, FileChangeStatus, FileMap, RuntimeState, SandboxError } from "../types";
|
|
18
18
|
/**
|
|
19
19
|
* Hook that manages the full Nodepod runtime lifecycle.
|
|
20
20
|
*
|
|
21
|
+
* The sandbox is a pure renderer — files come in via props or the
|
|
22
|
+
* imperative handle. No GitHub, no polling, no storage backends.
|
|
23
|
+
*
|
|
21
24
|
* @param props - CodeSandbox component props
|
|
22
|
-
* @returns Reactive runtime state + control functions
|
|
25
|
+
* @returns Reactive runtime state + control functions + imperative methods
|
|
23
26
|
*
|
|
24
27
|
* @example
|
|
25
28
|
* ```tsx
|
|
26
|
-
* // Direct files
|
|
27
|
-
* const
|
|
28
|
-
*
|
|
29
|
-
* //
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* });
|
|
29
|
+
* // Direct files (fetched from any source by the host app)
|
|
30
|
+
* const runtime = useRuntime({ files: myFiles, entryCommand: 'node server.js' });
|
|
31
|
+
*
|
|
32
|
+
* // Later, push updated files from the host:
|
|
33
|
+
* await runtime.updateFiles(newFiles);
|
|
34
|
+
*
|
|
35
|
+
* // Or update a single file:
|
|
36
|
+
* await runtime.updateFile('server.js', newContent);
|
|
35
37
|
* ```
|
|
36
38
|
*/
|
|
37
39
|
export declare function useRuntime(props: CodeSandboxProps): {
|
|
@@ -43,6 +45,14 @@ export declare function useRuntime(props: CodeSandboxProps): {
|
|
|
43
45
|
handleCloseFile: (path: string) => void;
|
|
44
46
|
handleBrowserError: (error: SandboxError) => Promise<void>;
|
|
45
47
|
restart: () => Promise<void>;
|
|
48
|
+
updateFiles: (newFiles: FileMap, options?: {
|
|
49
|
+
restartServer?: boolean;
|
|
50
|
+
}) => Promise<void>;
|
|
51
|
+
updateFile: (path: string, content: string) => Promise<void>;
|
|
52
|
+
getFiles: () => FileMap;
|
|
46
53
|
getChangedFiles: () => FileMap;
|
|
54
|
+
getFileChanges: () => Record<string, FileChangeStatus>;
|
|
55
|
+
getErrors: () => SandboxError[];
|
|
56
|
+
getState: () => RuntimeState;
|
|
47
57
|
runtime: import("react").MutableRefObject<NodepodRuntime | null>;
|
|
48
58
|
};
|