Skip to content
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

refactor(web): clean up deprecated plugin api v1 #1286

Merged
merged 1 commit into from
Nov 28, 2024

Conversation

airslice
Copy link
Contributor

@airslice airslice commented Nov 28, 2024

Overview

Since we decide to make Visualizer more as an independent product, there's no need to keep the deprecated plugin apis, clean up them also help to make the auto complete more clear.

What I've done

  • Remove the deprecated related from plugin API.

What I haven't done

How I tested

Which point I want you to review particularly

Memo

Summary by CodeRabbit

  • New Features

    • Streamlined the visualizer plugin API by removing deprecated properties and hooks, enhancing clarity and functionality.
    • Introduced a refined CommonReearth type, improving the structure of the API.
  • Bug Fixes

    • Eliminated deprecated warnings and associated logic, reducing potential confusion for developers.
  • Chores

    • Removed unused files and hooks to simplify the codebase.

Copy link

coderabbitai bot commented Nov 28, 2024

Walkthrough

This pull request involves the removal of deprecated features from the Re:Earth visualizer plugin API. Specifically, the useDeprecated hook and associated variables were eliminated, simplifying the component's functionality. Additionally, the commonReearth function was updated to remove deprecated properties and streamline its return structure. The pluginAPIv1Types.ts file, which contained outdated type definitions, was also deleted. Overall, these changes focus on cleaning up the codebase by removing obsolete elements.

Changes

File Path Change Summary
web/src/beta/features/Visualizer/Crust/Plugins/hooks/index.ts Removed useDeprecated hook and associated variables (deprecated, cameraDeprecated, etc.).
web/src/beta/features/Visualizer/Crust/Plugins/hooks/useDeprecated.ts Deleted the useDeprecated.ts file, which managed deprecation warnings for the plugin API.
web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/commonReearth.ts Updated commonReearth function to remove deprecated parameters and properties, refined return type.
web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/pluginAPIv1Types.ts Deleted the pluginAPIv1Types.ts file, which contained outdated TypeScript type definitions.

Possibly related PRs

Suggested labels

web

Suggested reviewers

  • mkumbobeaty
  • pyshx

🐰 In a world where features fade,
The deprecated ones have now been laid.
With hooks removed and types all gone,
A cleaner codebase carries on!
So hop along, let's code anew,
In the Re:Earth visualizer, bright and true! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

netlify bot commented Nov 28, 2024

Deploy Preview for reearth-web ready!

Name Link
🔨 Latest commit 08f5c5d
🔍 Latest deploy log https://app.netlify.com/sites/reearth-web/deploys/6747cc6db3cf2a0008fe3d1f
😎 Deploy Preview https://deploy-preview-1286--reearth-web.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (2)
web/src/beta/features/Visualizer/Crust/Plugins/hooks/index.ts (1)

Line range hint 341-350: Consider documenting the global API exposure

The exposure of the plugin API through window.reearth is a critical integration point. Consider adding a code comment explaining the purpose and implications of this global exposure for developers.

  // expose plugin API for developers
+ // This global exposure allows external plugins to interact with the Re:Earth visualizer
+ // Note: The API is cleaned up when the component unmounts
  useEffect(() => {
    window.reearth = value.reearth;
    return () => {
      window.reearth = undefined;
    };
  }, [value]);
web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/commonReearth.ts (1)

13-17: Consider namespacing the global reearth property to prevent potential conflicts

Adding reearth to the global window object can lead to potential naming conflicts or unintended side effects, especially if other scripts define the same global property. To mitigate this risk, consider namespacing or encapsulating the property within a unique object or module to avoid polluting the global namespace.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 58c184f and 08f5c5d.

📒 Files selected for processing (4)
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/index.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useDeprecated.ts (0 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/commonReearth.ts (7 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/pluginAPIv1Types.ts (0 hunks)
💤 Files with no reviewable changes (2)
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useDeprecated.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/pluginAPIv1Types.ts
🔇 Additional comments (4)
web/src/beta/features/Visualizer/Crust/Plugins/hooks/index.ts (2)

234-234: LGTM: Extension list functionality properly integrated

The addition of getExtensionList to the reearth API object is consistent with the dependency array updates and properly integrates with the extension management system.


Line range hint 1-350: Verify the removal of deprecated API usage

The deprecated features have been cleanly removed. Let's verify there are no remaining references to these deprecated APIs in the codebase.

✅ Verification successful

✅ Deprecated API features have been successfully removed

The verification shows that all deprecated plugin API features have been cleanly removed from the codebase. The only remaining references to "deprecated" are:

  • In test setup file (web/src/test/setup.ts) related to browser API mocking
  • In changelog entries documenting the removal of deprecated features
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining references to deprecated API features

# Check for any remaining references to useDeprecated
echo "Checking for useDeprecated references..."
rg -l "useDeprecated|deprecated" --type ts --type tsx

# Check for any remaining v1 plugin API types
echo "Checking for v1 plugin API type references..."
rg -l "pluginAPIv1" --type ts --type tsx

# Check for specific deprecated properties that were removed
echo "Checking for specific deprecated properties..."
rg -l "cameraDeprecated|layersDeprecated|sketchDeprecated" --type ts --type tsx

Length of output: 557


Script:

#!/bin/bash
# Description: Search for any remaining references to deprecated API features with correct file type flags

# Check for any remaining references to useDeprecated
echo "Checking for useDeprecated references..."
rg -l "useDeprecated|deprecated"

# Check for any remaining v1 plugin API types
echo "Checking for v1 plugin API type references..."
rg -l "pluginAPIv1"

# Check for specific deprecated properties that were removed
echo "Checking for specific deprecated properties..."
rg -l "cameraDeprecated|layersDeprecated|sketchDeprecated"

# Additional check for any remaining deprecated imports or usages
echo "Checking for deprecated imports and usages..."
rg "import.*deprecated|from.*deprecated" 

Length of output: 648


Script:

#!/bin/bash
# Let's check the actual content of files that contain "deprecated" to ensure they're not related to the plugin API

echo "Checking content of web/src/test/setup.ts..."
cat web/src/test/setup.ts

echo "Checking CHANGELOG.md entries for deprecated API removal..."
rg "deprecated" CHANGELOG.md -C 2

echo "Checking for any remaining plugin-related deprecated features..."
rg -g "web/src/beta/features/Visualizer/**" "deprecated" -i

Length of output: 2059

web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/commonReearth.ts (2)

94-94: Inclusion of getExtensionList parameter aligns with updated API

The addition of getExtensionList to the function parameters ensures that the extension.list property is available, consistent with the updated CommonReearth type.


Line range hint 172-343: Refactoring of commonReearth return structure effectively removes deprecated properties

The refactored commonReearth function's return structure removes deprecated properties and simplifies the API, enhancing clarity and maintainability. The current properties and methods are properly exposed, aligning with the updated CommonReearth type.

@airslice airslice merged commit 07b4d29 into main Nov 28, 2024
18 checks passed
@airslice airslice deleted the refactor/remove-plugin-api-v1 branch November 28, 2024 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant