From 846783f7d3fd4cfbd2c94569c1b06921bc9b3c6a Mon Sep 17 00:00:00 2001 From: Kacper Wojciechowski <39823706+jog1t@users.noreply.github.com> Date: Tue, 14 Jan 2025 01:15:10 +0100 Subject: [PATCH] feat(hub): actor repl --- frontend/apps/hub/index.html | 2 - frontend/apps/hub/package.json | 8 +- .../hub/src/components/repl/repl-input.tsx | 91 +++++++++ .../apps/hub/src/components/repl/repl-log.tsx | 121 ++++++++++++ .../hub/src/components/repl/repl-schema.ts | 57 ++++++ .../hub/src/components/repl/repl-state.tsx | 167 +++++++++++++++++ .../apps/hub/src/components/repl/repl.tsx | 55 ++++++ .../hub/src/components/repl/repl.worker.ts | 147 +++++++++++++++ .../components/actors/actor-rpc-tab.tsx | 32 ++-- .../components/actors/actor-state-tab.tsx | 10 +- .../actors/actors-actor-details.tsx | 21 ++- .../project/queries/actors/query-options.ts | 65 ++++++- frontend/packages/components/package.json | 3 +- .../components/src/code-mirror/index.tsx | 47 +++++ frontend/packages/components/src/code.tsx | 52 +---- .../packages/components/src/ui/typography.tsx | 177 +++++------------- frontend/packages/components/vite.config.ts | 4 + sdks/actor/manager-protocol/package.json | 2 +- 18 files changed, 830 insertions(+), 231 deletions(-) create mode 100644 frontend/apps/hub/src/components/repl/repl-input.tsx create mode 100644 frontend/apps/hub/src/components/repl/repl-log.tsx create mode 100644 frontend/apps/hub/src/components/repl/repl-schema.ts create mode 100644 frontend/apps/hub/src/components/repl/repl-state.tsx create mode 100644 frontend/apps/hub/src/components/repl/repl.tsx create mode 100644 frontend/apps/hub/src/components/repl/repl.worker.ts create mode 100644 frontend/packages/components/src/code-mirror/index.tsx diff --git a/frontend/apps/hub/index.html b/frontend/apps/hub/index.html index 26d32a47b2..ff1d3b1a87 100644 --- a/frontend/apps/hub/index.html +++ b/frontend/apps/hub/index.html @@ -1,8 +1,6 @@
- - diff --git a/frontend/apps/hub/package.json b/frontend/apps/hub/package.json index a1211deeee..979edf6a21 100644 --- a/frontend/apps/hub/package.json +++ b/frontend/apps/hub/package.json @@ -15,7 +15,8 @@ "@fortawesome/free-solid-svg-icons": "^6.5.2", "@fortawesome/react-fontawesome": "^0.2.2", "@hookform/resolvers": "^3.3.4", - "@rivet-gg/actor-protocol": "workspace:*", + "@rivet-gg/actor-client": "*", + "@rivet-gg/actor-protocol": "*", "@rivet-gg/api": "file:vendor/rivet-gg-api.tgz", "@rivet-gg/api-ee": "file:vendor/rivet-gg-api-ee.tgz", "@rivet-gg/components": "workspace:*", @@ -31,12 +32,13 @@ "@tanstack/router-zod-adapter": "^1.81.5", "@types/bcryptjs": "^2.4.6", "bcryptjs": "^2.4.3", + "esast-util-from-js": "^2.0.1", "file-saver": "^2.0.5", "framer-motion": "^11.2.11", "lodash": "^4.17.21", "posthog-js": "^1.144.2", - "react": "*", - "react-dom": "*", + "react": "^19.0.0", + "react-dom": "^19.0.0", "react-hook-form": "^7.51.1", "react-konami-code": "^2.3.0", "react-turnstile": "^1.1.3", diff --git a/frontend/apps/hub/src/components/repl/repl-input.tsx b/frontend/apps/hub/src/components/repl/repl-input.tsx new file mode 100644 index 0000000000..0083e3ac1e --- /dev/null +++ b/frontend/apps/hub/src/components/repl/repl-input.tsx @@ -0,0 +1,91 @@ +import { + CodeMirror, + type CodeMirrorRef, + type CompletionContext, + EditorView, + External, + defaultKeymap, + javascript, + javascriptLanguage, + keymap, +} from "@rivet-gg/components/code-mirror"; +import { forwardRef } from "react"; + +const deleteBgTheme = EditorView.theme({ + ".cm-content": { padding: 0 }, +}); + +interface ReplInputProps { + rpcs: string[]; + onRun: (code: string) => void; +} + +export const ReplInput = forwardRef
+ You can call all defined RPCs here:{" "}
+ {rpcs.map((rpc, index) => (
+ {rpc}
+ {index < rpcs.length - 1 ? ", " : ""}
+
+ Press Shift+Enter to run your command.
+
- No RPCs found. -
- ) : ( -