Clean up JS-WASM interop: move terminal APIs to xtermConsole.ts#189
Clean up JS-WASM interop: move terminal APIs to xtermConsole.ts#189LittleLittleCloud merged 7 commits intomainfrom
Conversation
…SM interop Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>
Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>
🚀 Preview DeploymentA preview build has been generated for this PR from CI run #19662571470! Download the artifact: To view the preview locally:
🌐 Live Preview URL: https://bba7c35e.razorconsole.pages.dev The live preview will be automatically updated when you push new |
LittleLittleCloud
left a comment
There was a problem hiding this comment.
@copilot fix comments
…move unused componentRenderer.ts Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors the JS-WASM interop layer to establish clearer separation of concerns between terminal manipulation APIs and .NET runtime initialization. Previously, main.js re-exported all terminal functions from xterm-interop.js, creating tight coupling between the WASM runtime and terminal management.
Key Changes
- Consolidated terminal APIs: All xterm.js operations (init, write, clear, dispose, attachKeyListener) plus WASM interop functions (registerComponent, handleKeyboardEvent) are now centralized in
xtermConsole.tsand exposed viawindow.razorConsoleTerminal - Simplified main.js: Reduced to a single export (
createRuntimeAndGetExports) that returns WASM assembly exports, with all other APIs delegating towindow.razorConsoleTerminal - Removed unused files: Deleted
xterm-interop.js(functionality moved) andcomponentRenderer.ts(unused)
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| website/src/services/componentRenderer.ts | Removed unused Blazor component preview renderer service |
| website/src/lib/xtermConsole.ts | Added registerTerminalInstance, getTerminalInstance, WASM interop functions (registerComponent, handleKeyboardEvent), and dynamic import of main.js for WASM exports |
| website/src/components/XTermPreview.tsx | Updated imports from "razor-console" to "@/lib/xtermConsole" to use refactored API |
| website/package-lock.json | Removed unused WASM-related dependencies: vite-plugin-wasm, vite-plugin-top-level-await, @swc/core, @rollup/plugin-virtual, and uuid |
| src/RazorConsole.Website/wwwroot/xterm-interop.js | Deleted - all terminal API functionality migrated to xtermConsole.ts |
| src/RazorConsole.Website/wwwroot/main.js | Refactored to export only createRuntimeAndGetExports; terminal APIs now accessed via window.razorConsoleTerminal |
| src/RazorConsole.Website/wwwroot/main.d.ts | Updated type definitions to reflect new API surface: single createRuntimeAndGetExports export returning WasmExports interface |
Files not reviewed (1)
- website/package-lock.json: Language not supported
Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>
|
@copilot get this error in preview deploy Error: Failed to load WASM module from /wasm/wwwroot/main.js: Failed to fetch dynamically imported module: https://5d965bf9.razorconsole.pages.dev/wasm/wwwroot/main.js |
Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>
Fixed the WASM module loading issue. The problem was using a dynamic import from |
…tion Co-authored-by: LittleLittleCloud <16876986+LittleLittleCloud@users.noreply.github.com>
xtermConsole.tsfile inwebsite/src/lib/with all terminal-related APIs (renamed fromterminalInterop.ts)registerComponentandhandleKeyboardEventfrom main.js to xtermConsole.tsmain.jsto only exportcreateRuntimeAndGetExportsmain.jsto create dotnet instance only once usinggetDotnetInstance()helpercomponentRenderer.tsXTermPreview.tsxto import all APIs from@/lib/xtermConsolemain.d.tsto reflect the reduced API surfacerazor-consolepackage instead of dynamic import to avoid runtime fetch issuesWasmExportsinterface frommain.d.tsinstead of local type definitionOriginal prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.