-
Notifications
You must be signed in to change notification settings - Fork 274
feat: server side rendering #163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* feat(ssr): Implement SSR rendering pipeline * test(ssr): make renderer tests async and use string input format * refactor: remove unused code * ci: add CLI build step to workflow * fix: lint error * refactor(build): replace custom esm import fixer with tsc-alias * feat: export resource types * feat(ssr): add non-browser rendering documentation * feat(ssr): replace JSDOM with LinkeDOM * fix: ignore unused error parameter * test(ssr): remove debug console.log from renderer test * refactor(ssr): simplify SVG serialization and DOM setup remove custom XMLSerializer implementation in favor of native outerHTML move svgo optimization to CLI level with option * fix(ssr): improve error handling and validation in renderer - Add fast fail for syntax errors - Validate template existence * Refactor: move CLI to internal SSR tests and remove CLI module This commit removes the standalone CLI module and moves examples to internal SSR tests for better integration. * Update documentation and remove CLI references Remove CLI tool documentation and references after CLI module removal, update SSR documentation, and remove teardownDOM function from exports. * Move SSR examples test files to proper location Relocate SSR example files from __tests__/ssr/examples to __tests__/unit/ssr/examples and update test file path reference. * Update project configuration and SSR test outputs Update various project files including configuration, SSR tests, and generated SVG outputs. * Add render_error type and improve type safety in SSR renderer --------- Co-authored-by: Yrom <yrom@qq.com>
Summary of ChangesHello @Aarebecca, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly extends the library's capabilities by integrating server-side rendering (SSR) support. It enables the generation of infographics as SVG strings in Node.js environments, broadening the application scope to include server-driven content creation and static site generation. The changes involve setting up a virtual DOM, adapting rendering processes for non-browser contexts, and ensuring resource handling is robust for offline rendering. Highlights
Ignored Files
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces server-side rendering (SSR) capabilities, a significant and well-executed feature. The implementation includes a new rendering pipeline for Node.js, a DOM shim using linkedom, resource preloading for a consistent output, and comprehensive tests and documentation. The code is well-structured and the approach is solid. I have a couple of suggestions to enhance maintainability and error reporting.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #163 +/- ##
===========================================
+ Coverage 31.44% 44.63% +13.19%
===========================================
Files 325 328 +3
Lines 26026 26215 +189
Branches 1433 2033 +600
===========================================
+ Hits 8184 11702 +3518
+ Misses 17839 14503 -3336
- Partials 3 10 +7
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces server-side rendering (SSR) capabilities, which is a significant feature addition. The implementation includes a DOM shim using linkedom, a new renderToString function, and comprehensive snapshot tests for various infographic examples. The changes are well-structured, with necessary adjustments in the rendering pipeline and utility functions to support a non-browser environment. My review focuses on dependency management and test code maintainability. I've identified an incorrect dev dependency and suggested an improvement for test data management. Overall, this is a solid implementation of SSR.
|
@copilot Review |
|
@Aarebecca I've opened a new pull request, #165, to work on those changes. Once the pull request is ready, I'll request review from you. |
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces server-side rendering (SSR) capabilities, which is a great addition. The implementation involves creating a DOM shim for Node.js environments and adapting the rendering logic to be environment-agnostic. The new test suite for SSR is also a good way to ensure correctness.
I've identified a couple of high-severity issues that could lead to runtime errors or incorrect output, particularly related to resource handling in the SSR renderer and text measurement logic. I've also pointed out a typing issue that could affect type safety. Please see my detailed comments for suggestions on how to address these.
Modified based on #160 and #104, fixed #68
使用方式:
注意事项:
字体采用
xml-stylesheet进行内嵌,因此需在联网环境下使用,或者系统安装相关字体。