Skip to content

Commit 4a95d91

Browse files
committed
progress towards moving Shell to be a function component
1 parent 98430ee commit 4a95d91

File tree

6 files changed

+329
-953
lines changed

6 files changed

+329
-953
lines changed

packages/browser-repl/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,20 @@ const runtime = new IframeRuntime(serviceProvider);
3131
Shell is a React component with the following properties:
3232

3333
- `runtime: Runtime`: The runtime used to evaluate code.
34-
- `onOutputChanged?: (output: readonly ShellOutputEntry[]) => void`: A function called each time the output changes with an array of `ShellOutputEntryes`.
35-
- `onHistoryChanged?: (history: readonly string[]) => void`: A function called each time the history changes with an array of history entries ordered from the most recent to the oldest entry.
34+
- `onOutputChanged?: (output: ShellOutputEntry[]) => void`: A function called each time the output changes with an array of `ShellOutputEntryes`.
35+
- `onHistoryChanged?: (history: string[]) => void`: A function called each time the history changes with an array of history entries ordered from the most recent to the oldest entry.
36+
- `onEditorChanged?: (editor: EditorRef | null) => void`: A function called each time the editor ref changes. Can be used to call editor methods.
37+
- `onOperationStarted: () => void`: A function called when an operation has begun.
38+
- `onOperationEnd: () => void`: A function called when an operation has completed (both error and success).
3639
- `redactInfo?: boolean`: If set, the shell will omit or redact entries containing sensitive info from history. Defaults to `false`.
3740
- `maxOutputLength?: number`: The maxiumum number of lines to keep in the output. Defaults to `1000`.
3841
- `maxHistoryLength?: number`: The maxiumum number of lines to keep in the history. Defaults to `1000`.
39-
- `initialOutput?: readonly ShellOutputEntry[]`: An array of entries to be displayed in the output area. Can be used to restore the output between sessions, or to setup a greeting message. **Note**: new entries will not be appended to the array.
40-
- `initialHistory?: readonly string[]`: An array of history entries to prepopulate the history.
42+
- `initialEvaluate?: string|string[]`: A set of input strings to evaluate right after shell is mounted.
43+
- `inputText?: string`: Initial text for the input field.
44+
- `output?: ShellOutputEntry[]`: An array of entries to be displayed in the output area. Can be used to restore the output between sessions, or to setup a greeting message. **Note**: new entries will not be appended to the array.
45+
- `history?: readonly string[]`: An array of history entries to prepopulate the history.
4146
Can be used to restore the history between sessions. Entries must be ordered from the most recent to the oldest. Note: new entries will not be appended to the array.
47+
- `isOperationInProgress?: boolean`: Can be used to restore the value between sessions.
4248

4349
### `ShellOutputEntry`
4450

packages/browser-repl/scripts/sync-to-compass.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,23 @@ console.log({ packageDir, srcDir, libDir, destDir });
2525

2626
const compileAndCopy = debounce(
2727
function () {
28-
child_process.execFileSync('npm', ['run', 'compile'], { cwd: packageDir });
28+
try {
29+
child_process.execFileSync('npm', ['run', 'compile'], {
30+
cwd: packageDir,
31+
});
32+
} catch (err) {
33+
if (err.code) {
34+
// Spawning child process failed
35+
console.error(err.code);
36+
} else {
37+
// Child was spawned but exited with non-zero exit code
38+
// Error contains any stdout and stderr from the child
39+
const { stdout, stderr } = err;
40+
41+
console.log(stdout.toString());
42+
console.error(stderr.toString());
43+
}
44+
}
2945
fs.cpSync(libDir, destDir, { recursive: true });
3046
console.log('done.');
3147
},

0 commit comments

Comments
 (0)