create-interview-cockpit 0.14.0 → 0.16.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/package.json +1 -1
- package/template/client/src/App.tsx +3 -0
- package/template/client/src/api.ts +39 -0
- package/template/client/src/browserSecurityTemplates.ts +3242 -0
- package/template/client/src/components/BrowserSecurityLabModal.tsx +1510 -0
- package/template/client/src/components/CanvasLabModal.tsx +585 -0
- package/template/client/src/components/CodeRunnerModal.tsx +406 -55
- package/template/client/src/components/LabsPanel.tsx +120 -7
- package/template/client/src/components/LinkedConvosPicker.tsx +121 -63
- package/template/client/src/components/Sidebar.tsx +125 -1
- package/template/client/src/components/WorkspaceSwitcher.tsx +36 -0
- package/template/client/src/reactLab.ts +1206 -0
- package/template/client/src/store.ts +39 -2
- package/template/client/src/types.ts +5 -1
- package/template/client/tsconfig.tsbuildinfo +1 -1
- package/template/client/vite.config.ts +15 -8
- package/template/cockpit.json +1 -1
- package/template/server/src/google-drive.ts +6 -1
- package/template/server/src/index.ts +110 -6
- package/template/server/src/storage.ts +3 -0
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@ import AiSettingsModal from "./components/AiSettingsModal";
|
|
|
10
10
|
import CodeRunnerModal from "./components/CodeRunnerModal";
|
|
11
11
|
import InfraLabModal from "./components/InfraLabModal";
|
|
12
12
|
import DeploymentLabModal from "./components/DeploymentLabModal";
|
|
13
|
+
import CanvasLabModal from "./components/CanvasLabModal";
|
|
13
14
|
import {
|
|
14
15
|
Code,
|
|
15
16
|
FlaskConical,
|
|
@@ -44,6 +45,7 @@ export default function App() {
|
|
|
44
45
|
showCodeRunner,
|
|
45
46
|
showInfraLab,
|
|
46
47
|
showDeploymentLab,
|
|
48
|
+
showCanvasLab,
|
|
47
49
|
closeCodeRunner,
|
|
48
50
|
} = useStore();
|
|
49
51
|
|
|
@@ -190,6 +192,7 @@ export default function App() {
|
|
|
190
192
|
{showCodeRunner && <CodeRunnerModal />}
|
|
191
193
|
{showInfraLab && <InfraLabModal />}
|
|
192
194
|
{showDeploymentLab && <DeploymentLabModal />}
|
|
195
|
+
{showCanvasLab && <CanvasLabModal />}
|
|
193
196
|
</div>
|
|
194
197
|
);
|
|
195
198
|
}
|
|
@@ -346,6 +346,7 @@ export async function saveCodeSnippet(
|
|
|
346
346
|
| "user"
|
|
347
347
|
| "ai"
|
|
348
348
|
| "sandbox"
|
|
349
|
+
| "browser-security"
|
|
349
350
|
| "infra"
|
|
350
351
|
| "react"
|
|
351
352
|
| "nextjs"
|
|
@@ -1084,6 +1085,44 @@ export async function readReactLabFile(
|
|
|
1084
1085
|
return body.content ?? null;
|
|
1085
1086
|
}
|
|
1086
1087
|
|
|
1088
|
+
export async function streamNextjsCommand(
|
|
1089
|
+
input: { id: string; command: string },
|
|
1090
|
+
onMessage: (message: ModuleFederationCommandStreamMessage) => void,
|
|
1091
|
+
): Promise<void> {
|
|
1092
|
+
const res = await fetch(`${BASE}/nextjs/${input.id}/command-stream`, {
|
|
1093
|
+
method: "POST",
|
|
1094
|
+
headers: { "Content-Type": "application/json" },
|
|
1095
|
+
body: JSON.stringify({ command: input.command }),
|
|
1096
|
+
});
|
|
1097
|
+
if (!res.ok || !res.body) throw new Error(`Command failed: ${res.status}`);
|
|
1098
|
+
|
|
1099
|
+
const reader = res.body.getReader();
|
|
1100
|
+
const decoder = new TextDecoder();
|
|
1101
|
+
let buffer = "";
|
|
1102
|
+
|
|
1103
|
+
const flushBuffer = () => {
|
|
1104
|
+
const parts = buffer.split("\n\n");
|
|
1105
|
+
buffer = parts.pop() ?? "";
|
|
1106
|
+
for (const part of parts) {
|
|
1107
|
+
const line = part.trim();
|
|
1108
|
+
if (!line.startsWith("data:")) continue;
|
|
1109
|
+
const payload = line.slice(5).trim();
|
|
1110
|
+
if (!payload) continue;
|
|
1111
|
+
try {
|
|
1112
|
+
onMessage(JSON.parse(payload) as ModuleFederationCommandStreamMessage);
|
|
1113
|
+
} catch {}
|
|
1114
|
+
}
|
|
1115
|
+
};
|
|
1116
|
+
|
|
1117
|
+
while (true) {
|
|
1118
|
+
const { value, done } = await reader.read();
|
|
1119
|
+
buffer += decoder.decode(value ?? new Uint8Array(), { stream: !done });
|
|
1120
|
+
flushBuffer();
|
|
1121
|
+
if (done) break;
|
|
1122
|
+
}
|
|
1123
|
+
if (buffer.trim()) flushBuffer();
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1087
1126
|
export async function stopReactLabSandbox(id: string): Promise<void> {
|
|
1088
1127
|
await fetch(`${BASE}/react-lab/${id}`, { method: "DELETE" });
|
|
1089
1128
|
}
|