feat(JitViewer): add JitViewer component#996
Merged
Merged
Conversation
Reviewer's GuideAdds a new BootstrapBlazor JitViewer component that wraps a JS-based JIT viewer library, wires it up via JS interop, and includes its styling and static assets. Sequence diagram for JitViewer component JS interop lifecyclesequenceDiagram
participant DotNet as JitViewer
participant JSInterop as JSRuntime
participant JSModule as JitViewer_js
participant JV as window_JitViewer_viewer
Note over DotNet,JSModule: Initial render
DotNet->>DotNet: InvokeInitAsync()
DotNet->>JSInterop: InvokeVoidAsync(init, Id, Interop, GetOptions())
JSInterop->>JSModule: init(id, invoke, options)
JSModule->>JSModule: setOptions(options)
JSModule->>JV: createViewer({ target: el, ...options })
JV->>JV: mount()
Note over JSModule,JV: Theme change from document
JSModule->>JV: setTheme(e.theme)
Note over DotNet,JSModule: Parameter change after first render
DotNet->>DotNet: OnParametersSet() sets _invoke = true
DotNet->>JSModule: OnAfterRenderAsync() calls update(id, GetOptions())
JSModule->>JSModule: setOptions(options)
JSModule->>JV: setTheme(options.theme)
JSModule->>JV: setLocale(options.locale)
JSModule->>JV: setFile(options.file, options.fileName)
Note over DotNet,JSModule: Component disposal
DotNet->>JSModule: dispose(id)
JSModule->>JV: destroy()
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The options object sent from the C# component (
File,FileName,Locale,Theme, etc.) uses PascalCase but the JS module expects camelCase properties (file,fileName,locale,theme), so either align the property names inGetOptions()or normalize them inJitViewer.razor.jsto avoid runtime issues. - In
JitViewer.razor.js, thechanged.bb.themeevent handler registered ininitis never removed indispose, which can lead to memory leaks; consider storing and detaching the handler when disposing the viewer. - The
updatefunction inJitViewer.razor.jscomparesdata.optionswith the newoptionsbut never updatesdata.optionsafter applying changes, so subsequent updates always compare against the original options; you may want to syncdata.optionsto the latest options after updating the viewer.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The options object sent from the C# component (`File`, `FileName`, `Locale`, `Theme`, etc.) uses PascalCase but the JS module expects camelCase properties (`file`, `fileName`, `locale`, `theme`), so either align the property names in `GetOptions()` or normalize them in `JitViewer.razor.js` to avoid runtime issues.
- In `JitViewer.razor.js`, the `changed.bb.theme` event handler registered in `init` is never removed in `dispose`, which can lead to memory leaks; consider storing and detaching the handler when disposing the viewer.
- The `update` function in `JitViewer.razor.js` compares `data.options` with the new `options` but never updates `data.options` after applying changes, so subsequent updates always compare against the original options; you may want to sync `data.options` to the latest options after updating the viewer.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link issues
fixes #972
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Add a new JitViewer UI component and supporting assets for client-side JIT file preview.
New Features: