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): plugin API v2.0.0 #1009

Merged
merged 43 commits into from
Aug 2, 2024
Merged

refactor(web): plugin API v2.0.0 #1009

merged 43 commits into from
Aug 2, 2024

Conversation

airslice
Copy link
Contributor

@airslice airslice commented Jun 5, 2024

Overview

This PR

  • Made a new interface as Plugain API v2.0.0.
  • Fix several errors around the plugin API.
  • Using latest alpha version of core.

What I've done

What I haven't done

How I tested

Which point I want you to review particularly

Memo

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a new utility for structured and type-safe event management.
    • Added an onFlyTo prop in the BlockWrapper component for flexible handling of fly-to actions.
    • Enhanced modal functionality with an optional clickBgToClose property for improved user interaction.
  • Changes

    • Updated package versions for improved stability and performance.
    • Renamed the pluginBlockPropertyItems prop to propertyItemsForPluginBlock for clarity in multiple components.
    • Specified the package manager and version in the project configuration for better dependency management.

Copy link

netlify bot commented Jun 5, 2024

Deploy Preview for reearth-web ready!

Name Link
🔨 Latest commit fc86588
🔍 Latest deploy log https://app.netlify.com/sites/reearth-web/deploys/66ac2f025280c40008f0489f
😎 Deploy Preview https://deploy-preview-1009--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.

@github-actions github-actions bot added the web label Jun 5, 2024
@airslice airslice changed the title chore(web): use viewer property refactor(web): use viewer property Jun 25, 2024
@airslice airslice changed the title refactor(web): use viewer property refactor(web): plugin API v2.0.0 Jul 12, 2024
Copy link

coderabbitai bot commented Jul 26, 2024

Walkthrough

Recent updates enhance the web application's functionality by refining dependency management and improving component interactions. Key changes include version updates for the @apollo/client and @reearth/core packages, the introduction of a new utility for event handling, and enhancements to modal and component properties for clearer interaction. These refinements contribute to improved maintainability, clarity for developers, and an overall better user experience.

Changes

Files Change Summary
web/package.json Updated @apollo/client from 3.11.1 to 3.11.2, @reearth/core from 0.0.7-beta.1 to 0.0.7-alpha.6; added "packageManager": "yarn@1.22.1".
web/src/beta/features/Visualizer/Crust/Plugins/utils/events.ts Introduced a new file for event handling utilities, including types and functions for managing custom events, enhancing type safety and structure.
web/src/beta/features/Visualizer/Crust/Plugins/Plugin/ModalContainer/index.tsx Added optional property clickBgToClose to PluginModalInfo type; modified handleModalClose to support this new functionality.
web/src/beta/features/Visualizer/Crust/Plugins/Plugin/PopupContainer/index.tsx Changed import of PopupPosition type from ../../plugin_types to ../../pluginAPI/types, indicating a shift in organizational structure.
web/src/beta/features/Visualizer/Crust/StoryPanel/Block/index.tsx Renamed prop pluginBlockPropertyItems to propertyItemsForPluginBlock for clarity in StoryBlockComponent.
web/src/beta/features/Visualizer/shared/components/BlockWrapper/index.tsx Renamed pluginBlockPropertyItems to propertyItemsForPluginBlock; added onFlyTo prop; removed local handleFlyTo function for simplicity.

Poem

🐰 In a garden of code we frolic and play,
With props and new hooks, we dance through the day.
Each change a fresh bloom, a gift we can see,
In our plugin patchwork, how joyful we'll be!
So here’s to the tweaks that make magic unfold,
A tale of improvement, in laughter retold! 🐇✨


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

@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: 15

Outside diff range, codebase verification and nitpick comments (2)
web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/layers.ts (1)

66-76: Consider adding detailed documentation for the options parameter.

The LayersEvents type is correctly defined, but adding more detailed documentation for the options parameter in the on method would improve clarity.

web/src/beta/features/Visualizer/Crust/Plugins/hooks/useLayers.ts (1)

10-28: Issues found in useLayers hook initialization

The useLayers hook is not correctly initialized with all the necessary properties in the following files:

  • web/src/beta/features/Editor/hooks/index.ts: Missing mapRef, selectedLayer, selectedFeature, onLayerEdit, onLayerVisibility, and onLayerLoad.
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/index.ts: Missing onLayerLoad.

Please ensure that all required properties are passed to the useLayers hook.

Analysis chain

Verify the correctness of useLayers hook initialization.

Ensure that the useLayers hook is correctly initialized with the necessary properties (mapRef, selectedLayer, selectedFeature, onLayerEdit, onLayerVisibility, onLayerLoad).

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `useLayers` hook initialization.

# Test: Search for the usage of `useLayers` in the codebase. Expect: Correct initialization and usage.
rg --type ts $'useLayers'

Length of output: 1981


Script:

#!/bin/bash
# Extract lines where `useLayers` is used in the identified files for verification

# Extract lines from `web/src/beta/features/Editor/hooks/index.ts`
rg -A 5 'useLayers' web/src/beta/features/Editor/hooks/index.ts

# Extract lines from `web/src/beta/features/Visualizer/Crust/Plugins/hooks/index.ts`
rg -A 5 'useLayers' web/src/beta/features/Visualizer/Crust/Plugins/hooks/index.ts

Length of output: 767

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 2ccc95a and c781570.

Files ignored due to path filters (1)
  • web/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (55)
  • web/package.json (2 hunks)
  • web/src/beta/features/Editor/Visualizer/hooks.ts (5 hunks)
  • web/src/beta/features/Editor/Visualizer/index.tsx (3 hunks)
  • web/src/beta/features/PluginPlayground/Viewer/hooks.ts (3 hunks)
  • web/src/beta/features/PluginPlayground/Viewer/index.tsx (1 hunks)
  • web/src/beta/features/Published/hooks.ts (3 hunks)
  • web/src/beta/features/Published/index.tsx (2 hunks)
  • web/src/beta/features/Published/types.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/Plugin/ModalContainer/index.tsx (2 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/Plugin/PopupContainer/index.tsx (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/Plugin/hooks/index.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/Plugin/hooks/usePluginAPI.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/Plugin/index.tsx (3 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/PluginFrame/SafeIFrame/hooks.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/PluginFrame/hooks.ts (3 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/index.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useCamera.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useCommonEvents.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useData.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useDeprecated.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useExtension.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useLayers.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useSketch.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useTimeline.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useViewer.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/commonReearth.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/constaint.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/exposedReearth.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/pluginAPIv1Types.ts (6 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/camera.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/common.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/data.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/engine.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/extension.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/globe.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/index.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/layers.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/modal.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/popup.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/reearth.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/sketch.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/timeline.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/ui.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/viewer.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/storybook.tsx (2 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/types.ts (3 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/usePluginInstances.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/utils/events.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Widgets/index.tsx (3 hunks)
  • web/src/beta/features/Visualizer/Crust/context.ts (2 hunks)
  • web/src/beta/features/Visualizer/Crust/hooks.tsx (1 hunks)
  • web/src/beta/features/Visualizer/Crust/index.tsx (11 hunks)
  • web/src/beta/features/Visualizer/Crust/theme/index.ts (2 hunks)
  • web/src/beta/features/Visualizer/Crust/types.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/utils.ts (2 hunks)
Files not processed due to max files limit (11)
  • web/src/beta/features/Visualizer/hooks.ts
  • web/src/beta/features/Visualizer/index.tsx
  • web/src/beta/features/Visualizer/shared/components/BlockWrapper/index.tsx
  • web/src/beta/features/Visualizer/utils/index.ts
  • web/src/beta/features/Visualizer/utils/useOverriddenProperty.test.ts
  • web/src/beta/features/Visualizer/utils/useOverriddenProperty.ts
  • web/src/beta/types/index.ts
  • web/src/beta/types/sceneProperty.ts
  • web/src/beta/utils/convert-object.test.ts
  • web/src/beta/utils/convert-object.ts
  • web/src/beta/utils/value.ts
Files skipped from review due to trivial changes (11)
  • web/src/beta/features/PluginPlayground/Viewer/index.tsx
  • web/src/beta/features/Published/types.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/Plugin/PopupContainer/index.tsx
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useData.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/constaint.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/engine.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/index.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/usePluginInstances.ts
  • web/src/beta/features/Visualizer/Crust/Widgets/index.tsx
  • web/src/beta/features/Visualizer/Crust/hooks.tsx
  • web/src/beta/features/Visualizer/Crust/types.ts
Additional context used
Biome
web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/timeline.ts

[error] 9-9: void is confusing inside a union type.

Unsafe fix: Use undefined instead.

(lint/suspicious/noConfusingVoidType)

web/src/beta/features/Visualizer/Crust/Plugins/utils/events.ts

[error] 88-88: Avoid the use of spread (...) syntax on accumulators.

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

(lint/performance/noAccumulatingSpread)

web/src/beta/features/Visualizer/Crust/Plugins/hooks/index.ts

[error] 357-357: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

Additional comments not posted (173)
web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/common.ts (2)

1-5: LGTM!

The LatLngHeight type is well-defined and straightforward. No issues found.


7-12: LGTM!

The GeoRect type is well-defined and straightforward. No issues found.

web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/globe.ts (1)

1-9: LGTM!

The GlobalThis type is well-defined and straightforward. No issues found.

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

1-3: LGTM!

The Data type is well-defined and straightforward. No issues found.


5-11: LGTM!

The ClientStorage type is well-defined and straightforward. No issues found.

web/src/beta/features/PluginPlayground/Viewer/hooks.ts (3)

4-4: LGTM! The import statement is correct.

The import statement for ViewerProperty aligns with the changes described in the PR summary.


20-22: LGTM! The declaration of viewerProperty is correct.

The declaration of viewerProperty as ViewerProperty improves type safety and clarity.


38-38: LGTM! The return statement is correct.

The return statement includes viewerProperty instead of sceneProperty, aligning with the changes described in the PR summary.

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

1-20: Ensure consistent method parameter types and optionality.

The show method's options parameter has optional properties, but the resize method's parameters are not consistently marked as optional.

Ensure that the resize method parameters should be optional if intended.

-    width: string | number | undefined,
-    height: string | number | undefined,
+    width?: string | number,
+    height?: string | number,

27-37: Ensure event handling methods are type-safe.

The on and off methods are well-defined, but ensure that callback parameters are correctly typed.

The event handling methods are correctly typed and consistent with best practices.

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

1-21: Ensure consistent method parameter types and optionality.

The show and update methods' options parameters have optional properties, but ensure that all optional properties are consistently marked.

The method parameters are well-defined and consistent with best practices.


27-37: Ensure event handling methods are type-safe.

The on and off methods are well-defined, but ensure that callback parameters are correctly typed.

The event handling methods are correctly typed and consistent with best practices.

web/src/beta/features/Published/index.tsx (2)

14-25: Ensure consistency with new API.

The destructured properties now include viewerProperty, widgetThemeOptions, and initialCamera. Ensure that these properties are correctly utilized within the component.

The changes are consistent with the new API and enhance the component's functionality.


43-49: Ensure correct prop passing to Visualizer component.

The Published component now passes widgetThemeOptions, viewerProperty, and initialCamera to the Visualizer component. Ensure that the Visualizer component handles these props correctly.

The props are correctly passed to the Visualizer component, enhancing its functionality.

web/src/beta/features/Visualizer/Crust/utils.ts (2)

1-1: Import statements updated correctly.

The import statements have been updated to include useCallback and useRef from React, which are essential for the new useGet function.


40-44: New utility function useGet added.

The useGet function is well-implemented, using useRef to maintain a reference to the value and useCallback to return a memoized function that provides the current value. This ensures consistency across re-renders without causing additional renders.

web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/popup.ts (5)

1-13: Type PopupPosition declared correctly.

The PopupPosition type defines various positions for the popup, covering all possible placement options.


15-21: Type PopupOffset declared correctly.

The PopupOffset type allows for specifying offsets as either a number or an object with mainAxis, crossAxis, and alignmentAxis properties.


23-43: Type Popup declared correctly.

The Popup type defines the structure and behavior of a popup, including methods for showing, posting messages, updating, closing, and managing events.


45-47: Type PopupEventType declared correctly.

The PopupEventType type defines the possible events for the popup, currently only including the close event.


49-59: Type PopupEvents declared correctly.

The PopupEvents type defines methods for adding and removing event listeners for popup events.

web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/timeline.ts (4)

1-22: Type Timeline declared correctly.

The Timeline type defines the structure and behavior of a timeline, including properties for time management, playback control, and event handling.

Tools
Biome

[error] 9-9: void is confusing inside a union type.

Unsafe fix: Use undefined instead.

(lint/suspicious/noConfusingVoidType)


24-33: Type TimelineCommitter declared correctly.

The TimelineCommitter type defines the source of a timeline commit, allowing for various sources such as widgetContext, pluginAPI, and others.


35-38: Type TimelineEventType declared correctly.

The TimelineEventType type defines the possible events for the timeline, including tick and commit.


40-50: Type TimelineEvents declared correctly.

The TimelineEvents type defines methods for adding and removing event listeners for timeline events.

web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/sketch.ts (5)

3-3: LGTM!

The type definition for SketchAppearance looks good.


4-8: LGTM!

The type definition for SketchEventProps looks good.


10-18: LGTM!

The type definition for SketchType looks good.


20-27: LGTM!

The type definition for Sketch looks good.


29-54: LGTM!

The type definitions for SketchOptions, SketchEventType, and SketchEvents look good.

web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/extension.ts (6)

4-11: LGTM!

The type definition for Extension looks good.


13-21: LGTM!

The type definition for Block looks good.


23-34: LGTM!

The type definition for Widget looks good.


36-43: LGTM!

The type definition for PluginExtensionInstance looks good.


45-60: LGTM!

The type definitions for ExtensionEventType and ExtensionEvents look good.


62-65: LGTM!

The type definition for ExtensionMessage looks good.

web/src/beta/features/Visualizer/Crust/Plugins/Plugin/ModalContainer/index.tsx (2)

14-14: LGTM!

The addition of the clickBgToClose property in PluginModalInfo looks good.


31-34: LGTM!

The modification of the handleModalClose function looks good.

web/src/beta/features/Visualizer/Crust/theme/index.ts (3)

20-23: LGTM! The renaming enhances clarity.

The type SceneThemeOptions has been appropriately renamed to WidgetThemeOptions to reflect the new context.


41-43: LGTM! The function signature update ensures consistency.

The function usePublishTheme has been updated to use WidgetThemeOptions instead of SceneThemeOptions, aligning with the new type declaration.


Line range hint 45-78:
LGTM! The function signature update ensures consistency.

The function publishTheme has been updated to use WidgetThemeOptions instead of SceneThemeOptions, aligning with the new type declaration.

web/src/beta/features/Visualizer/Crust/Plugins/hooks/useSketch.ts (2)

1-7: LGTM! The import statements are correct.

The import statements correctly bring in necessary hooks and types for the functionality of the file.


9-77: LGTM! The hook is well-structured and the logic is correct.

The default export function effectively manages sketch tool operations using various hooks and utility functions.

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

Line range hint 41-55:
LGTM! The changes enhance clarity and type safety.

The Props type has been updated to replace sceneProperty with viewerProperty and overrideSceneProperty with overrideViewerProperty, improving clarity and type safety.


72-78: LGTM! The changes enhance the structure and functionality.

The Context type has been updated to replace overrideSceneProperty with overrideViewerProperty and add various event properties, providing a more comprehensive event handling mechanism.

web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/layers.ts (3)

14-14: LGTM!

The LayerId type alias is correctly defined as a string.


16-57: Ensure consistency in method signatures.

The Layers type is well-defined, but ensure that all methods consistently use the same parameter naming conventions and types. For example, delete and override methods are optional while others are not. Consider making this consistent if possible.


59-64: LGTM!

The LayersEventType is correctly defined with appropriate event types and their corresponding argument types.

web/src/beta/features/Visualizer/Crust/Plugins/Plugin/index.tsx (3)

1-1: Stylistic change in import syntax.

The change from import type { RefObject } to import { type RefObject } is primarily stylistic and does not affect functionality.


Line range hint 28-28:
LGTM!

The removal of onWidgetMove from destructured props in the Plugin component aligns with the updated Props type definition.


7-7: Verify the impact of removing onWidgetMove.

The onWidgetMove property has been removed from the Props type definition. Ensure that this removal does not affect other parts of the codebase where onWidgetMove might be used.

web/src/beta/features/Visualizer/Crust/context.ts (2)

12-25: LGTM!

The useWidgetContext function has been correctly updated to include viewerProperty and initialCamera parameters, ensuring the memoized value recalculates when these inputs change.


Line range hint 31-53:
LGTM!

The widgetContextFromMapRef function has been correctly updated to include viewerProperty and initialCamera parameters, enhancing context handling and flexibility in camera settings.

web/src/beta/features/Visualizer/Crust/Plugins/utils/events.ts (2)

107-117: LGTM!

The useEmit function is well-structured and follows React hooks rules.


81-104: LGTM!

The mergeEvents function is well-structured and follows best practices.

Tools
Biome

[error] 88-88: Avoid the use of spread (...) syntax on accumulators.

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

(lint/performance/noAccumulatingSpread)

web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/camera.ts (5)

51-58: LGTM!

The CameraPosition type declaration is comprehensive and follows best practices.


60-68: LGTM!

The LookAtDestination type declaration is comprehensive and follows best practices.


70-74: LGTM!

The CameraMoveOptions type declaration is comprehensive and follows best practices.


105-115: LGTM!

The CameraEvents type declaration is comprehensive and follows best practices.


33-35: Specify parameter types for rotation methods.

The rotateAround, rotateRight, and orbit methods should have more specific parameter types, such as number for the radian parameter.

readonly rotateAround: (radian: number) => void;
readonly rotateRight: (radian: number) => void;
readonly orbit: (radian: number) => void;

Likely invalid or redundant comment.

web/src/beta/features/Visualizer/Crust/Plugins/hooks/useTimeline.ts (3)

63-130: LGTM!

The getTimeline function is well-structured and follows best practices.


39-50: LGTM!

The timelineEventsOn function is well-structured and follows best practices.


52-60: LGTM!

The timelineEventsOff function is well-structured and follows best practices.

web/src/beta/features/Editor/Visualizer/index.tsx (2)

114-120: Verify the correct usage of viewerProperty and initialCamera in the JSX block.

Ensure that viewerProperty and initialCamera are correctly passed as props to the Visualizer component. Verify that their values are correctly managed and utilized within the component.

Verification successful

Verified the correct usage of viewerProperty and initialCamera in the JSX block.

Both viewerProperty and initialCamera are correctly passed as props to the Visualizer component and are properly managed within the component.

  • viewerProperty is used in web/src/beta/features/Visualizer/index.tsx and other related files.
  • initialCamera is also used in web/src/beta/features/Visualizer/index.tsx and other related files.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct usage of `viewerProperty` and `initialCamera` in the JSX block.

# Test: Search for the usage of `viewerProperty` and `initialCamera` in the `Visualizer` component. Expect: Correct integration and usage.
rg --type tsx -A 5 $'viewerProperty'
rg --type tsx -A 5 $'initialCamera'

Length of output: 126


Script:

#!/bin/bash
# Description: Verify the correct usage of `viewerProperty` and `initialCamera` in the JSX block.

# Test: Search for the usage of `viewerProperty` and `initialCamera` in the `Visualizer` component. Expect: Correct integration and usage.
rg -A 5 'viewerProperty'
rg -A 5 'initialCamera'

Length of output: 31688


Line range hint 65-74:
Verify the correct usage of viewerProperty and initialCamera.

Ensure that viewerProperty and initialCamera are correctly integrated and used within the custom hook. Verify that their values are correctly managed and passed to the relevant components.

Verification successful

Verification successful: viewerProperty and initialCamera are correctly integrated and used within the codebase.

The properties viewerProperty and initialCamera are correctly managed and passed to the relevant components across various files, ensuring proper integration and usage.

  • viewerProperty is used in index.tsx, hooks.ts, context.ts, and other related files.
  • initialCamera is used in index.tsx, hooks.ts, context.ts, and other related files.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correct usage of `viewerProperty` and `initialCamera`.

# Test: Search for the usage of `viewerProperty` and `initialCamera` in the codebase. Expect: Correct integration and usage.
rg --type tsx -A 5 $'viewerProperty'
rg --type tsx -A 5 $'initialCamera'

Length of output: 126


Script:

#!/bin/bash
# Description: Verify the correct usage of `viewerProperty` and `initialCamera`.

# Test: Search for the usage of `viewerProperty` and `initialCamera` in the codebase. Expect: Correct integration and usage.
rg -A 5 'viewerProperty'
rg -A 5 'initialCamera'

Length of output: 31688

web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/viewer.ts (19)

23-26: Verify the correctness of LayerSelectWithRectEnd type.

Ensure that all properties (features, isClick) are correctly defined and used.

Verification successful

The LayerSelectWithRectEnd type is correctly defined and used.

The properties features and isClick are appropriately defined and utilized in the codebase.

  • The features property is of type PickedFeature[] | undefined, and PickedFeature is correctly defined as an extension of ComputedFeature.
  • The isClick property is a boolean and is used correctly in the context of event handling and function parameters.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `LayerSelectWithRectEnd` type.

# Test: Search for the usage of `LayerSelectWithRectEnd` in the codebase. Expect: Correct integration and usage.
rg --type ts $'LayerSelectWithRectEnd'

Length of output: 1979


Script:

#!/bin/bash
# Find the definition of PickedFeature
rg --type ts 'type PickedFeature' -A 5

# Examine the usages of LayerSelectWithRectEnd in detail
rg --type ts 'LayerSelectWithRectEnd' -A 10

Length of output: 17969


72-75: Verify the correctness of Env type.

Ensure that all properties (inEditor, isBuilt) are correctly defined and used.

Verification successful

The Env type is correctly defined and used.

The properties inEditor and isBuilt are appropriately integrated and utilized across the codebase.

  • inEditor is used in files such as index.tsx, Crust/index.tsx, Widgets/index.tsx, commonReearth.ts, and more.
  • isBuilt is used in files such as index.tsx, shared/types.ts, Crust/index.tsx, commonReearth.ts, and more.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `Env` type.

# Test: Search for the usage of `Env` in the codebase. Expect: Correct integration and usage.
rg --type ts $'Env'

Length of output: 801


Script:

#!/bin/bash
# Description: Verify the usage of `inEditor` and `isBuilt` properties of `Env` type.

# Search for occurrences of `inEditor` in the codebase.
rg --type ts 'inEditor'

# Search for occurrences of `isBuilt` in the codebase.
rg --type ts 'isBuilt'

Length of output: 10740


77-106: Verify the correctness of Tools type.

Ensure that all methods (getLocationFromScreenCoordinate, getScreenCoordinateFromPosition, getTerrainHeightAsync, getGlobeHeight, getGlobeHeightByCamera, cartographicToCartesian, cartesianToCartographic, transformByOffsetOnScreen, isPositionVisibleOnGlobe) are correctly defined and used.

Verification successful

The Tools type is correctly defined and integrated.

All methods (getLocationFromScreenCoordinate, getScreenCoordinateFromPosition, getTerrainHeightAsync, getGlobeHeight, getGlobeHeightByCamera, cartographicToCartesian, cartesianToCartographic, transformByOffsetOnScreen, isPositionVisibleOnGlobe) are properly referenced and used within the codebase.

  • Verified in files such as useViewer, commonReearth, and others.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `Tools` type.

# Test: Search for the usage of `Tools` in the codebase. Expect: Correct integration and usage.
rg --type ts $'Tools'

Length of output: 2604


Script:

#!/bin/bash
# Description: Verify the definitions and usages of each method in the `Tools` type.

# Methods to verify
methods=(
  "getLocationFromScreenCoordinate"
  "getScreenCoordinateFromPosition"
  "getTerrainHeightAsync"
  "getGlobeHeight"
  "getGlobeHeightByCamera"
  "cartographicToCartesian"
  "cartesianToCartographic"
  "transformByOffsetOnScreen"
  "isPositionVisibleOnGlobe"
)

# Search for each method in the codebase
for method in "${methods[@]}"; do
  echo "Searching for method: $method"
  rg --type ts "$method"
done

Length of output: 15312


57-59: Verify the correctness of Viewport type.

Ensure that all properties (query) are correctly defined and used.

Verification successful

The Viewport type is correctly defined and used.

The query property and other properties inherited from ViewportSize are appropriately utilized across the codebase.

  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/viewer.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/pluginAPIv1Types.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useViewer.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useLayers.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useCamera.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/index.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/commonReearth.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `Viewport` type.

# Test: Search for the usage of `Viewport` in the codebase. Expect: Correct integration and usage.
rg --type ts $'Viewport'

Length of output: 5447


Script:

#!/bin/bash
# Description: Extract context around the usages of `Viewport` to verify the correctness of the `query` property and other properties.

# Extract context around the definition and usage of `Viewport` in the relevant files
rg --type ts 'Viewport' -A 5 -B 5

Length of output: 49437


39-49: Verify the correctness of Viewer type.

Ensure that all properties (property, overrideProperty, viewport, interactionMode, env, tools, capture, on, off) are correctly defined and used.

Verification successful

The Viewer type is correctly defined and used.

All properties (property, overrideProperty, viewport, interactionMode, env, tools, capture, on, off) are correctly defined and used within the codebase.

  • ViewerProperty: Defined and used in multiple files.
  • Viewport: Defined and used in multiple files.
  • InteractionMode: Defined and used in multiple files.
  • Env: Defined and used in multiple files.
  • Tools: Defined and used in multiple files.
  • ViewerEvents: Defined and used in multiple files.
  • capture: Defined and used in multiple files.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `Viewer` type.

# Test: Search for the usage of `Viewer` in the codebase. Expect: Correct integration and usage.
rg --type ts $'Viewer'

Length of output: 11125


Script:

#!/bin/bash
# Description: Verify the definitions and usages of each property in the `Viewer` type.

# Search for the definition and usage of `ViewerProperty`
rg --type ts 'ViewerProperty'

# Search for the definition and usage of `Viewport`
rg --type ts 'Viewport'

# Search for the definition and usage of `InteractionMode`
rg --type ts 'InteractionMode'

# Search for the definition and usage of `Env`
rg --type ts 'Env'

# Search for the definition and usage of `Tools`
rg --type ts 'Tools'

# Search for the definition and usage of `ViewerEvents`
rg --type ts 'ViewerEvents'

# Search for the definition and usage of the `capture` method
rg --type ts 'capture'

Length of output: 24367


144-154: Verify the correctness of SelectionModeEvents type.

Ensure that all methods (on, off) are correctly defined and used.


37-37: Verify the correctness of InteractionModeType type.

Ensure that all values (default, move, selection, sketch) are correctly defined and used.

Verification successful

The InteractionModeType type is correctly defined and used.

The values "default", "move", "selection", and "sketch" are appropriately integrated and utilized within the codebase.

  • Verified usages in relevant files:
    • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/viewer.ts
    • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/commonReearth.ts
    • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useCamera.ts
    • web/src/beta/features/Visualizer/Crust/Plugins/storybook.tsx
    • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useViewer.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `InteractionModeType` type.

# Test: Search for the usage of `InteractionModeType` in the codebase. Expect: Correct integration and usage.
rg --type ts $'InteractionModeType'

Length of output: 2021


Script:

#!/bin/bash
# Description: Verify the usage of each value of `InteractionModeType` in the codebase.

# Search for the usage of "default"
rg --type ts '"default"'

# Search for the usage of "move"
rg --type ts '"move"'

# Search for the usage of "selection"
rg --type ts '"selection"'

# Search for the usage of "sketch"
rg --type ts '"sketch"'

Length of output: 46801


61-65: Verify the correctness of InteractionMode type.

Ensure that all properties (mode, override, selectionMode) are correctly defined and used.

Verification successful

The InteractionMode type is correctly defined and used.

The properties mode, override, and selectionMode are correctly integrated and utilized across the codebase.

  • mode is correctly defined as InteractionModeType.
  • override is correctly defined as a function that takes InteractionModeType as an argument.
  • selectionMode is correctly defined and used in the context of SelectionMode.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `InteractionMode` type.

# Test: Search for the usage of `InteractionMode` in the codebase. Expect: Correct integration and usage.
rg --type ts $'InteractionMode'

Length of output: 4951


Script:

#!/bin/bash
# Description: Verify the correctness of `InteractionMode` type by checking the definitions and usages of its properties.

# Search for the definition of `InteractionMode` to confirm its properties.
rg --type ts 'InteractionMode' -A 5

# Search for the usage of `mode` property within `InteractionMode`.
rg --type ts 'interactionMode\.mode'

# Search for the usage of `override` property within `InteractionMode`.
rg --type ts 'interactionMode\.override'

# Search for the usage of `selectionMode` property within `InteractionMode`.
rg --type ts 'interactionMode\.selectionMode'

Length of output: 23323


15-17: Verify the correctness of LayerSelectWithRect type.

Ensure that all properties (pressedKey) are correctly defined and used.

Verification successful

The LayerSelectWithRect type is correctly defined and used.

The pressedKey property is correctly defined as an optional property of type "shift" and is used appropriately in the context of the related event handlers.

  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/viewer.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `LayerSelectWithRect` type.

# Test: Search for the usage of `LayerSelectWithRect` in the codebase. Expect: Correct integration and usage.
rg --type ts $'LayerSelectWithRect'

Length of output: 6058


Script:

#!/bin/bash
# Extract the definition and usage of LayerSelectWithRect and its related types

# Extract the definition of LayerSelectWithRect
rg --type ts --context 5 'export declare type LayerSelectWithRect' 

# Extract the usage of LayerSelectWithRect and its related types with context
rg --type ts --context 5 'LayerSelectWithRectStart' 
rg --type ts --context 5 'LayerSelectWithRectMove' 
rg --type ts --context 5 'LayerSelectWithRectEnd' 

Length of output: 55621


51-55: Verify the correctness of ViewportSize type.

Ensure that all properties (width, height, isMobile) are correctly defined and used.

Verification successful

The ViewportSize type and its properties (width, height, isMobile) are correctly defined and used.

The properties are accessed and utilized as expected in the relevant files.

  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/pluginAPIv1Types.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useViewer.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useCommonEvents.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `ViewportSize` type.

# Test: Search for the usage of `ViewportSize` in the codebase. Expect: Correct integration and usage.
rg --type ts $'ViewportSize'

Length of output: 1243


Script:

#!/bin/bash
# Description: Verify the usage of `width`, `height`, and `isMobile` properties of `ViewportSize` type.

# Search for the usage of `width` property in the relevant files.
rg --type ts 'width' web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/pluginAPIv1Types.ts web/src/beta/features/Visualizer/Crust/Plugins/hooks/useViewer.ts web/src/beta/features/Visualizer/Crust/Plugins/hooks/useCommonEvents.ts

# Search for the usage of `height` property in the relevant files.
rg --type ts 'height' web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/pluginAPIv1Types.ts web/src/beta/features/Visualizer/Crust/Plugins/hooks/useViewer.ts web/src/beta/features/Visualizer/Crust/Plugins/hooks/useCommonEvents.ts

# Search for the usage of `isMobile` property in the relevant files.
rg --type ts 'isMobile' web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/pluginAPIv1Types.ts web/src/beta/features/Visualizer/Crust/Plugins/hooks/useViewer.ts web/src/beta/features/Visualizer/Crust/Plugins/hooks/useCommonEvents.ts

Length of output: 5791


35-35: Verify the correctness of LayerSelectWithRectStart type.

Ensure that all properties are correctly defined and used.

Verification successful

Let's start by locating the definition of LayerSelectWithRect to understand its structure and properties.


Let's start by locating the definition of MouseEventProps to understand its structure and properties.


The type LayerSelectWithRectStart is correctly defined as it inherits all necessary properties from LayerSelectWithRect, which in turn extends MouseEventProps. The properties are well-defined and cover the expected fields for mouse events.

Verified the correctness of LayerSelectWithRectStart type.

  • The type LayerSelectWithRectStart is correctly defined as an alias for LayerSelectWithRect.
  • The properties of LayerSelectWithRect are properly defined and inherited from MouseEventProps.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `LayerSelectWithRectStart` type.

# Test: Search for the usage of `LayerSelectWithRectStart` in the codebase. Expect: Correct integration and usage.
rg --type ts $'LayerSelectWithRectStart'

Length of output: 2022


Script:

#!/bin/bash
# Locate the definition of `LayerSelectWithRect` in the codebase.
rg --type ts 'type LayerSelectWithRect' -A 10

Length of output: 3187


Script:

#!/bin/bash
# Locate the definition of `MouseEventProps` in the codebase.
rg --type ts 'type MouseEventProps' -A 10

Length of output: 1069


138-154: Verify the correctness of SelectionModeEventType type.

Ensure that all event types (marqueeStart, marqueeMove, marqueeEnd) are correctly defined and used.

Verification successful

The SelectionModeEventType type is correctly defined and used.

The definitions of LayerSelectWithRectStart, LayerSelectWithRectMove, and LayerSelectWithRectEnd are accurate, and their usage in SelectionModeEventType aligns with the expected types. The integration of SelectionModeEventType across the codebase is consistent and correct.

  • LayerSelectWithRectStart, LayerSelectWithRectMove, and LayerSelectWithRectEnd are defined in web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/viewer.ts.
  • The usage of SelectionModeEventType in usePluginAPI.ts, types.ts, and useViewer.ts is consistent with its definition.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `SelectionModeEventType` type.

# Test: Search for the usage of `SelectionModeEventType` in the codebase. Expect: Correct integration and usage.
rg --type ts $'SelectionModeEventType'

Length of output: 1899


Script:

#!/bin/bash
# Description: Retrieve the definitions of LayerSelectWithRectStart, LayerSelectWithRectMove, and LayerSelectWithRectEnd

# Search for the definitions of LayerSelectWithRectStart, LayerSelectWithRectMove, and LayerSelectWithRectEnd
rg --type ts 'type LayerSelectWithRect(Start|Move|End)' -A 5

Length of output: 1825


Script:

#!/bin/bash
# Description: Extract relevant sections of the files where SelectionModeEventType is used to verify correct integration

# Extract relevant sections from usePluginAPI.ts
rg --type ts 'SelectionModeEventType' -A 10 web/src/beta/features/Visualizer/Crust/Plugins/Plugin/hooks/usePluginAPI.ts

# Extract relevant sections from types.ts
rg --type ts 'SelectionModeEventType' -A 10 web/src/beta/features/Visualizer/Crust/Plugins/types.ts

# Extract relevant sections from useViewer.ts
rg --type ts 'SelectionModeEventType' -A 10 web/src/beta/features/Visualizer/Crust/Plugins/hooks/useViewer.ts

Length of output: 3011


19-21: Verify the correctness of PickedFeature type.

Ensure that all properties (layerId) are correctly defined and used.

Verification successful

The PickedFeature type and its layerId property are correctly defined and used.

  • The PickedFeature type is defined as ComputedFeature & { layerId?: string; }.
  • It is used in LayerSelectWithRectEnd which has a features property of type PickedFeature[] | undefined.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `PickedFeature` type.

# Test: Search for the usage of `PickedFeature` in the codebase. Expect: Correct integration and usage.
rg --type ts $'PickedFeature'

Length of output: 271


Script:

#!/bin/bash
# Description: Verify the correctness of `PickedFeature` type by examining the usage of the `features` property.

# Test: Search for the usage of `features` in the codebase. Expect: Correct integration and usage.
rg --type ts 'features'

Length of output: 100584


Script:

#!/bin/bash
# Description: Verify the correctness of `PickedFeature` type by examining its definition and usage in `viewer.ts`.

# Test: Search for the `PickedFeature` type definition and usage in `viewer.ts`. Expect: Correct integration and usage.
rg --type ts 'PickedFeature' -A 10 -B 10 web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/viewer.ts

Length of output: 643


28-33: Verify the correctness of LayerSelectWithRectMove type.

Ensure that all properties (startX, startY, width, height) are correctly defined and used.

Verification successful

The LayerSelectWithRectMove type is correctly defined and used in the codebase.

The properties startX, startY, width, and height are part of the type definition and are used consistently in function signatures and event handling.

  • Files where LayerSelectWithRectMove is used:
    • web/src/beta/features/Visualizer/Crust/Plugins/types.ts
    • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useCommonEvents.ts
    • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useViewer.ts
    • web/src/beta/features/Visualizer/Crust/Plugins/hooks/index.ts
    • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/pluginAPIv1Types.ts
    • web/src/beta/features/Visualizer/Crust/index.tsx
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `LayerSelectWithRectMove` type.

# Test: Search for the usage of `LayerSelectWithRectMove` in the codebase. Expect: Correct integration and usage.
rg --type ts $'LayerSelectWithRectMove'

Length of output: 2002


Script:

#!/bin/bash
# Extract context around the usage of `LayerSelectWithRectMove` in the identified files to verify correctness of its properties.

# Searching for `LayerSelectWithRectMove` in `web/src/beta/features/Visualizer/Crust/Plugins/types.ts`
rg --type ts -A 5 -B 5 'LayerSelectWithRectMove' web/src/beta/features/Visualizer/Crust/Plugins/types.ts

# Searching for `LayerSelectWithRectMove` in `web/src/beta/features/Visualizer/Crust/Plugins/hooks/useCommonEvents.ts`
rg --type ts -A 5 -B 5 'LayerSelectWithRectMove' web/src/beta/features/Visualizer/Crust/Plugins/hooks/useCommonEvents.ts

# Searching for `LayerSelectWithRectMove` in `web/src/beta/features/Visualizer/Crust/Plugins/hooks/useViewer.ts`
rg --type ts -A 5 -B 5 'LayerSelectWithRectMove' web/src/beta/features/Visualizer/Crust/Plugins/hooks/useViewer.ts

# Searching for `LayerSelectWithRectMove` in `web/src/beta/features/Visualizer/Crust/Plugins/hooks/index.ts`
rg --type ts -A 5 -B 5 'LayerSelectWithRectMove' web/src/beta/features/Visualizer/Crust/Plugins/hooks/index.ts

# Searching for `LayerSelectWithRectMove` in `web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/pluginAPIv1Types.ts`
rg --type ts -A 5 -B 5 'LayerSelectWithRectMove' web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/pluginAPIv1Types.ts

# Searching for `LayerSelectWithRectMove` in `web/src/beta/features/Visualizer/Crust/index.tsx`
rg --type ts -A 5 -B 5 'LayerSelectWithRectMove' web/src/beta/features/Visualizer/Crust/index.tsx

Length of output: 5582


126-136: Verify the correctness of ViewerEvents type.

Ensure that all methods (on, off) are correctly defined and used.

Verification successful

ViewerEvents type verification complete

The ViewerEvents type and its methods on and off are correctly defined within the viewer.ts file. There are no further usages or implementations found elsewhere in the codebase, confirming the correctness of the type definition.

  • ViewerEvents type is correctly defined and used within viewer.ts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `ViewerEvents` type.

# Test: Search for the usage of `ViewerEvents` in the codebase. Expect: Correct integration and usage.
rg --type ts $'ViewerEvents'

Length of output: 355


Script:

#!/bin/bash
# Description: Verify the correctness of `ViewerEvents` type by checking its usage across the codebase.

# Test: Search for the usage of `ViewerEvents` type in the entire codebase.
rg 'ViewerEvents' --type ts

Length of output: 355


Script:

#!/bin/bash
# Description: Verify the implementation of `on` and `off` methods in the `viewer.ts` file.

# Test: Search for the implementation of `on` method in the `viewer.ts` file.
rg 'on' --type ts -A 5 web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/viewer.ts

# Test: Search for the implementation of `off` method in the `viewer.ts` file.
rg 'off' --type ts -A 5 web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/viewer.ts

Length of output: 4188


5-13: Verify the correctness of MouseEventProps type.

Ensure that all properties (x, y, lat, lng, height, layerId, delta) are correctly defined and used.


67-70: Verify the correctness of SelectionMode type.

Ensure that all properties (on, off) are correctly defined and used.

Verification successful

The SelectionMode type is correctly defined and used.

The properties on and off are properly set up to handle events as expected.

  • Definitions of SelectionModeEvents and SelectionModeEventType confirm the correct structure.
  • Usage instances in the codebase validate their correct implementation.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `SelectionMode` type.

# Test: Search for the usage of `SelectionMode` in the codebase. Expect: Correct integration and usage.
rg --type ts $'SelectionMode'

Length of output: 3312


Script:

#!/bin/bash
# Extract definitions of `SelectionModeEvents` and `SelectionModeEventType`

# Search for the definition of `SelectionModeEvents`
echo "Definition of SelectionModeEvents:"
rg --type ts --context 10 $'export declare type SelectionModeEvents'

# Search for the definition of `SelectionModeEventType`
echo "Definition of SelectionModeEventType:"
rg --type ts --context 10 $'export declare type SelectionModeEventType'

Length of output: 4637


Script:

#!/bin/bash
# Search for the usage of `SelectionMode` properties `on` and `off`

# Search for the usage of `SelectionMode.on`
echo "Usage of SelectionMode.on:"
rg --type ts $'SelectionMode.on'

# Search for the usage of `SelectionMode.off`
echo "Usage of SelectionMode.off:"
rg --type ts $'SelectionMode.off'

Length of output: 192


Script:

#!/bin/bash
# Refined search for the usage of `SelectionMode` and its properties `on` and `off`

# Search for the usage of `SelectionMode`
echo "Usage of SelectionMode:"
rg --type ts $'SelectionMode'

# Search for potential variations in the usage of `SelectionMode.on`
echo "Potential variations of SelectionMode.on usage:"
rg --type ts $'selectionMode.on'

# Search for potential variations in the usage of `SelectionMode.off`
echo "Potential variations of SelectionMode.off usage:"
rg --type ts $'selectionMode.off'

Length of output: 3848


108-124: Verify the correctness of ViewerEventType type.

Ensure that all event types (click, doubleClick, mouseDown, mouseUp, rightClick, rightDown, rightUp, middleClick, middleDown, middleUp, mouseMove, mouseEnter, mouseLeave, wheel, resize) are correctly defined and used.

Verification successful

The ViewerEventType type is correctly defined and used.

The search results confirm that the event names and their corresponding types (MouseEvent for mouse-related events and ViewportSize for the resize event) are correctly referenced in the codebase.

  • click: [e: MouseEvent]
  • doubleClick: [e: MouseEvent]
  • mouseDown: [e: MouseEvent]
  • mouseUp: [e: MouseEvent]
  • rightClick: [e: MouseEvent]
  • rightDown: [e: MouseEvent]
  • rightUp: [e: MouseEvent]
  • middleClick: [e: MouseEvent]
  • middleDown: [e: MouseEvent]
  • middleUp: [e: MouseEvent]
  • mouseMove: [e: MouseEvent]
  • mouseEnter: [e: MouseEvent]
  • mouseLeave: [e: MouseEvent]
  • wheel: [e: MouseEvent]
  • resize: [e: ViewportSize]

These definitions are consistent with their usage in the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `ViewerEventType` type.

# Test: Search for the usage of `ViewerEventType` in the codebase. Expect: Correct integration and usage.
rg --type ts $'ViewerEventType'

Length of output: 1814


Script:

#!/bin/bash
# Description: Verify the correctness of event names in `ViewerEventType` type.

# Test: Search for the usage of each event name defined in `ViewerEventType` in the codebase.
rg --type ts 'click|doubleClick|mouseDown|mouseUp|rightClick|rightDown|rightUp|middleClick|middleDown|middleUp|mouseMove|mouseEnter|mouseLeave|wheel|resize'

Length of output: 29389


Script:

#!/bin/bash
# Description: Verify the correctness of event types in `ViewerEventType` type.

# Test: Search for the usage of each event name with their types defined in `ViewerEventType` in the codebase.
rg --type ts 'click: \[e: MouseEvent\]|doubleClick: \[e: MouseEvent\]|mouseDown: \[e: MouseEvent\]|mouseUp: \[e: MouseEvent\]|rightClick: \[e: MouseEvent\]|rightDown: \[e: MouseEvent\]|rightUp: \[e: MouseEvent\]|middleClick: \[e: MouseEvent\]|middleDown: \[e: MouseEvent\]|middleUp: \[e: MouseEvent\]|mouseMove: \[e: MouseEvent\]|mouseEnter: \[e: MouseEvent\]|mouseLeave: \[e: MouseEvent\]|wheel: \[e: MouseEvent\]|resize: \[e: ViewportSize\]'

Length of output: 1984


1-4: Verify the correctness of imported types.

Ensure that ViewerProperty, ComputedFeature, and LatLngHeight are correctly imported from @reearth/core and ./common.

Verification successful

Verify the correctness of imported types.

Ensure that ViewerProperty, ComputedFeature, and LatLngHeight are correctly imported from @reearth/core and ./common.


Verify the correctness of imported types.

Ensure that ViewerProperty, ComputedFeature, and LatLngHeight are correctly imported from @reearth/core and ./common.


Verify the correctness of imported types.

Ensure that LatLngHeight is correctly defined and exported in ./common.


The imported types are correctly defined and exported.

The types ViewerProperty and ComputedFeature are correctly imported from @reearth/core, and LatLngHeight is correctly defined and exported in ./common.

  • ViewerProperty and ComputedFeature are confirmed to be present in @reearth/core.
  • LatLngHeight is correctly defined in web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/common.ts.

Everything looks good with the imports.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of imported types.

# Test: Search for the definition of `ViewerProperty`, `ComputedFeature`, and `LatLngHeight`. Expect: Correct definitions.
rg --type ts $'ViewerProperty'
rg --type ts $'ComputedFeature'
rg --type ts $'LatLngHeight'

Length of output: 12499


Script:

#!/bin/bash
# Description: Verify the correctness of imported types by locating their definitions.

# Locate the definition of `ViewerProperty` in the codebase.
ast-grep --lang typescript --pattern 'type ViewerProperty $_' 

# Locate the definition of `ComputedFeature` in the codebase.
ast-grep --lang typescript --pattern 'type ComputedFeature $_'

# Locate the definition of `LatLngHeight` in the codebase.
ast-grep --lang typescript --pattern 'type LatLngHeight $_'

Length of output: 1225


Script:

#!/bin/bash
# Description: Verify the correctness of imported types by locating their definitions.

# Locate the definition of `ViewerProperty` in the codebase.
rg 'type ViewerProperty' --type ts -A 5

# Locate the definition of `ComputedFeature` in the codebase.
rg 'type ComputedFeature' --type ts -A 5

# Locate the definition of `LatLngHeight` in the codebase.
rg 'type LatLngHeight' --type ts -A 5

Length of output: 2545


Script:

#!/bin/bash
# Description: Verify the correctness of imported types by locating their definitions and exports.

# Locate the definition and export of `LatLngHeight` in `./common`.
rg 'LatLngHeight' web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/common.ts -A 5

Length of output: 184

web/src/beta/features/Visualizer/Crust/Plugins/hooks/useLayers.ts (3)

38-43: Verify the correctness of showLayer callback.

Ensure


1-4: Verify the correctness of imported types and hooks.

Ensure that ComputedFeature, NaiveLayer, useGet, LayersEventType, Props, events, and useEmit are correctly imported and used.

Verification successful

All imported types and hooks are correctly defined and used.

The types and hooks ComputedFeature, NaiveLayer, useGet, LayersEventType, Props, events, and useEmit are correctly imported and used within the useLayers.ts file. The imports are necessary and correctly contribute to the functionality of the custom hook.

  • ComputedFeature and NaiveLayer are imported from @reearth/core.
  • useGet is imported from ../../utils.
  • LayersEventType, Props, events, and useEmit are imported from ../pluginAPI/types and ../utils/events.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of imported types and hooks.

# Test: Search for the definition of `ComputedFeature`, `NaiveLayer`, `useGet`, `LayersEventType`, `Props`, `events`, and `useEmit`. Expect: Correct definitions.
rg --type ts $'ComputedFeature'
rg --type ts $'NaiveLayer'
rg --type ts $'useGet'
rg --type ts $'LayersEventType'
rg --type ts $'Props'
rg --type ts $'events'
rg --type ts $'useEmit'

Length of output: 145033


31-35: Verify the correctness of hideLayer callback.

Ensure that the hideLayer callback is correctly defined and used to hide layers.

Verification successful

The hideLayer callback is correctly defined and used.

  • Definition in useLayers.ts: The hideLayer function is defined using useCallback and calls layersRef?.hide(...args).
  • Usage in index.ts and commonReearth.ts: The function is used as part of an object managing layers, consistent with its definition.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of `hideLayer` callback.

# Test: Search for the usage of `hideLayer` in the codebase. Expect: Correct definition and usage.
rg --type ts $'hideLayer'

Length of output: 756


Script:

#!/bin/bash
# Get the definition and context of `hideLayer` in `useLayers.ts`
rg --type ts -A 5 -B 5 $'const hideLayer = useCallback' web/src/beta/features/Visualizer/Crust/Plugins/hooks/useLayers.ts

# Get the usage context of `hideLayer` in `index.ts`
rg --type ts -A 5 -B 5 $'hideLayer' web/src/beta/features/Visualizer/Crust/Plugins/hooks/index.ts

# Get the usage context of `hideLayer` in `commonReearth.ts`
rg --type ts -A 5 -B 5 $'hideLayer' web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/commonReearth.ts

Length of output: 2241

web/src/beta/features/Visualizer/Crust/Plugins/PluginFrame/SafeIFrame/hooks.ts (1)

149-152: LGTM!

The added calculations for horizontalScrollbarHeight and verticalScrollbarWidth improve the accuracy of the reported dimensions by accounting for scrollbars.

web/src/beta/features/Visualizer/Crust/Plugins/Plugin/hooks/index.ts (3)

1-12: LGTM!

The imports are necessary for the functionality of the file and appear to be correct.


15-33: LGTM!

The function signature is well-defined and the parameters cover all necessary aspects for plugin management.


64-179: LGTM!

The core logic is well-structured and follows best practices for React hooks and state management. The use of callbacks, effects, and memoization is appropriate.

web/src/beta/features/Visualizer/Crust/Plugins/PluginFrame/hooks.ts (2)

84-86: LGTM! Improved reliability of onDispose callback handling.

The use of useRef to store the current value of onDispose ensures that the most recent version of the callback is invoked during cleanup, enhancing the reliability of the hook's behavior.


210-210: LGTM! Ensures the latest onDispose is called during cleanup.

Using onDisposeRef.current in the cleanup function ensures that the most recent version of the onDispose callback is invoked, which is a good practice.

web/src/beta/features/Visualizer/Crust/Plugins/hooks/useCamera.ts (5)

1-6: LGTM! Necessary imports are included.

The imports from React and other modules are standard and necessary for the functionality provided in the file.


25-35: LGTM! Memoization of cameraPosition.

Memoizing cameraPosition using useMemo helps in optimizing performance by preventing unnecessary recalculations when the camera state changes.


37-40: LGTM! Use of useGet hooks.

Using useGet for getCameraPosition, getCameraFov, and getCameraAspectRatio ensures that the latest values are retrieved when needed, which is a good practice.


44-70: LGTM! Use of useCallback for camera actions.

Wrapping camera actions like zoomIn, zoomOut, setView, flyTo, etc., in useCallback helps in optimizing performance by preventing unnecessary re-creations of the functions.

Also applies to: 72-84, 86-91, 93-96, 98-103, 105-110, 112-117, 119-124, 126-131, 133-150, 152-157, 159-164


166-177: LGTM! Well-structured event handling and return object.

The event handling using useMemo, useEmit, and useCallback is well-structured. The return object provides a comprehensive API for camera-related actions and events.

Also applies to: 179-195, 197-220

web/package.json (2)

117-117: Verify the reason for the version change of @reearth/core.

The @reearth/core package version is updated from 0.0.7-beta.0 to 0.0.7-alpha.3. This change could imply a rollback in versioning strategy or a reclassification of the package's stability. Please verify the reason for this version change.


206-206: LGTM! Addition of packageManager field.

Adding the packageManager field helps clarify the environment setup for developers and could affect how dependencies are installed or managed in the project.

web/src/beta/features/Visualizer/Crust/Plugins/storybook.tsx (10)

90-94: LGTM! The engine property is now more structured.

The nested structure for the engine property enhances clarity regarding the engine's identity and versioning.


95-129: LGTM! The viewer object is well-structured.

The new viewer object encapsulates various properties, providing a more organized approach to managing viewer-related settings.


132-152: LGTM! The camera object enhancements are well-implemented.

The expanded camera object with additional methods and properties improves the camera's configurability.


154-169: LGTM! The timeline property is more descriptive and clear.

Renaming clock to timeline and the addition of methods for controlling playback and tracking state improve clarity in managing time-related functionalities.


170-177: LGTM! The sketch property enhances functionality.

The addition of the sketch property with methods like setTool and overrideOptions enhances functionality related to sketch tools.


178-203: LGTM! The layers property is more comprehensive.

The expanded layers property with methods for selecting, finding, and manipulating layers provides a more comprehensive API for layer interactions.


204-208: LGTM! The extension property enhances functionality.

The addition of the extension property with a getter for the list enhances functionality related to extensions.


230-231: LGTM! The clientStorage property is more functional.

The addition of the dropStore method to the clientStorage property enhances functionality related to client storage.


232-232: LGTM! The overrideViewerProperty method enhances functionality.

The addition of the overrideViewerProperty method enhances functionality related to overriding viewer properties.


233-261: LGTM! The event handling properties enhance interaction management.

The addition of various event handling properties (viewerEvents, cameraEvents, etc.) allows for better management of interactions within the visualization context.

web/src/beta/features/Published/hooks.ts (5)

11-14: LGTM! New imports are correctly added.

The new imports convertData and sceneProperty2ViewerPropertyMapping are correctly added and will be used in the code.


38-39: LGTM! The initialCamera state variable improves camera state handling.

The addition of the initialCamera state variable enhances the handling of camera states.


40-54: LGTM! The useMemo hook modifications enhance viewer property management.

The modifications to the useMemo hook to extract viewerProperty, widgetThemeOptions, and cesiumIonAccessToken from the processed scene property enhance the ability to manage viewer properties in a more structured manner.


56-58: LGTM! The useEffect hook improves camera state handling.

The addition of the useEffect hook to set the currentCamera to the initialCamera improves the handling of camera states.


263-268: LGTM! The cesiumIonAccessToken logic is more reliable.

The refined logic for determining the cesiumIonAccessToken ensures that the token used is valid, improving the reliability of the viewer's access to Cesium resources.

web/src/beta/features/Visualizer/Crust/Plugins/hooks/useViewer.ts (10)

1-14: LGTM! The imports are correctly added.

The imports of various hooks and types are correctly added and will be used in the code.


16-41: LGTM! The default export function is well-defined.

The default export function is correctly defined with various properties and methods related to viewer management.


44-54: LGTM! The useGet hook is correctly used.

The useGet hook is correctly used to get viewerProperty and viewport.


55-60: LGTM! The captureScreen method is well-defined.

The captureScreen method is correctly defined using useCallback.


62-66: LGTM! The selectionModeEvents are correctly defined.

The selectionModeEvents and emitSelectionModeEvent are correctly defined using useMemo.


68-84: LGTM! The useEffect hooks are well-defined.

The useEffect hooks are correctly defined to handle layer selection events.


86-107: LGTM! The selectionModeEventsOn and selectionModeEventsOff methods are well-defined.

The selectionModeEventsOn and selectionModeEventsOff methods are correctly defined using useCallback.


109-121: LGTM! The getInteractionMode method is well-defined.

The getInteractionMode method is correctly defined using useGet and useMemo.


127-203: LGTM! The utility methods are well-defined.

The utility methods related to viewer management are correctly defined using useCallback.


205-275: LGTM! The viewer event handling methods are well-defined.

The viewerEvents and emit are correctly defined using useMemo, and various event handling methods are correctly defined using useCallback.

web/src/beta/features/Visualizer/Crust/Plugins/hooks/index.ts (6)

1-13: LGTM! Imports are relevant.

The import statements are appropriate and necessary for the functionality of the file.


15-40: LGTM! Function signature is comprehensive and well-typed.

The function signature includes all necessary props and is correctly typed.


41-74: LGTM! Correct usage of useViewer hook.

The useViewer hook is used correctly to retrieve all necessary viewer-related properties and methods.


76-102: LGTM! Correct usage of useCamera hook.

The useCamera hook is used correctly to retrieve all necessary camera-related properties and methods.


104-159: LGTM! Correct usage of remaining hooks.

The remaining hooks (useTimeline, useLayers, useSketch, useExtension, useData, useDeprecated) are used correctly to retrieve all necessary properties and methods.


161-351: LGTM! Correct usage of useMemo hook.

The useMemo hook is used correctly to create a context value.

web/src/beta/features/Editor/Visualizer/hooks.ts (6)

4-9: LGTM! Imports are relevant.

The import statements are appropriate and necessary for the functionality of the file.


62-68: LGTM! Correct usage of state and callback hooks.

The state variables and callback hooks are used correctly and efficiently.


78-90: LGTM! Correct usage of useMemo hook.

The useMemo hook is used correctly to compute viewerProperty and cesiumIonAccessToken.


92-94: LGTM! Correct usage of useEffect hook.

The useEffect hook is used correctly to synchronize the current camera with the initial camera.


281-286: LGTM! Correct usage of useMemo hook for engineMeta.

The useMemo hook is used correctly to compute engineMeta.


Line range hint 299-308:
LGTM! Correct return statement.

The return statement provides all necessary properties and methods.

web/src/beta/features/Visualizer/Crust/index.tsx (5)

Line range hint 1-20:
LGTM! Imports are relevant.

The import statements are appropriate and necessary for the functionality of the file.


60-67: LGTM! Comprehensive and well-typed Props definition.

The Props type definition includes all necessary properties and is correctly typed.


205-207: LGTM! Correct usage of useEffect hook.

The useEffect hook is used correctly to log the selectedLayer whenever it changes.


228-229: LGTM! Correct usage of useWidgetContext hook.

The useWidgetContext hook is used correctly to pass viewerProperty and initialCamera.


Line range hint 254-288:
LGTM! Correct return statement and JSX structure.

The return statement provides all necessary properties and methods related to viewer and widget management.

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

184-217: Verify viewer properties and methods.

Ensure that the viewer properties and methods are correctly defined and implemented.

Verification successful

Verified viewer properties and methods.

The viewer properties and methods are correctly defined and implemented in the commonReearth.ts file.

  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/commonReearth.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify viewer properties and methods.

# Test: Search for the definitions and implementations of the viewer properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 5 $'viewer: {'

Length of output: 113


Script:

#!/bin/bash
# Description: Verify viewer properties and methods.

# Test: Search for the definitions and implementations of the viewer properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 20 'viewer: {'

Length of output: 114


Script:

#!/bin/bash
# Description: Verify viewer properties and methods.

# Test: Search for the definitions and implementations of the viewer properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 20 'viewer: \{'

Length of output: 3841


1-9: Verify import paths and type definitions.

Ensure that the import paths are correct and the CommonReearth type definition is accurate and aligns with the rest of the codebase.


253-327: Verify layers properties and methods.

Ensure that the layers properties and methods are correctly defined and implemented.


175-349: Ensure correct construction of the returned object.

Verify that all properties and methods in the returned object are correctly defined and implemented.


328-343: Verify sketch properties and methods.

Ensure that the sketch properties and methods are correctly defined and implemented.

Verification successful

Let's correct the rg command and re-run the search to verify the definitions and implementations of the sketch properties and methods.


Let's correct the rg command by escaping both the curly braces and parentheses, and re-run the search to verify the definitions and implementations of the sketch properties and methods.


Let's search for the definitions and implementations of the methods and properties within the sketch object individually.


Let's search for the occurrences of these identifiers in the codebase to locate their definitions and implementations.


Verified sketch properties and methods.

The sketch properties and methods are correctly defined and implemented.

  • getSketchTool is defined in web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/commonReearth.ts and web/src/beta/features/Visualizer/Crust/Plugins/hooks/useSketch.ts.
  • setSketchTool is defined in web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/commonReearth.ts and web/src/beta/features/Visualizer/Crust/Plugins/hooks/useSketch.ts.
  • getSketchOptions is defined in web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/commonReearth.ts and web/src/beta/features/Visualizer/Crust/Plugins/hooks/useSketch.ts.
  • overrideSketchOptions is defined in web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/commonReearth.ts and web/src/beta/features/Visualizer/Crust/Plugins/hooks/useSketch.ts.
  • sketchEventsOn is defined in web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/commonReearth.ts and web/src/beta/features/Visualizer/Crust/Plugins/hooks/useSketch.ts.
  • sketchEventsOff is defined in web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/commonReearth.ts and web/src/beta/features/Visualizer/Crust/Plugins/hooks/useSketch.ts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify sketch properties and methods.

# Test: Search for the definitions and implementations of the sketch properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 5 $'sketch: merge(sketchDeprecated, {'

Length of output: 185


Script:

#!/bin/bash
# Description: Verify sketch properties and methods.

# Test: Search for the definitions and implementations of the sketch properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 5 $'sketch: merge(sketchDeprecated, \{'

Length of output: 155


Script:

#!/bin/bash
# Description: Verify sketch properties and methods.

# Test: Search for the definitions and implementations of the sketch properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 5 $'sketch: merge\\(sketchDeprecated, \\{'

Length of output: 651


Script:

#!/bin/bash
# Description: Verify definitions and implementations of sketch properties and methods.

# Test: Search for the definition of `getSketchTool`.
rg --type ts 'function getSketchTool'

# Test: Search for the definition of `setSketchTool`.
rg --type ts 'function setSketchTool'

# Test: Search for the definition of `getSketchOptions`.
rg --type ts 'function getSketchOptions'

# Test: Search for the definition of `overrideSketchOptions`.
rg --type ts 'function overrideSketchOptions'

# Test: Search for the definition of `sketchEventsOn`.
rg --type ts 'function sketchEventsOn'

# Test: Search for the definition of `sketchEventsOff`.
rg --type ts 'function sketchEventsOff'

Length of output: 253


Script:

#!/bin/bash
# Description: Verify occurrences of sketch properties and methods.

# Test: Search for occurrences of `getSketchTool`.
rg --type ts 'getSketchTool'

# Test: Search for occurrences of `setSketchTool`.
rg --type ts 'setSketchTool'

# Test: Search for occurrences of `getSketchOptions`.
rg --type ts 'getSketchOptions'

# Test: Search for occurrences of `overrideSketchOptions`.
rg --type ts 'overrideSketchOptions'

# Test: Search for occurrences of `sketchEventsOn`.
rg --type ts 'sketchEventsOn'

# Test: Search for occurrences of `sketchEventsOff`.
rg --type ts 'sketchEventsOff'

Length of output: 5011


218-249: Verify camera properties and methods.

Ensure that the camera properties and methods are correctly defined and implemented.

Verification successful

Verified camera properties and methods.

The camera properties and methods are correctly defined and implemented.

  • The functions such as getCameraPosition, getCameraFov, getCameraAspectRatio, getCameraViewport, zoomIn, zoomOut, setView, flyTo, flyToBoundingBox, getGlobeIntersection, enableScreenSpaceCameraController, overrideScreenSpaceCameraController, lookAt, rotateAround, rotateRight, orbit, move, moveOverTerrain, enableForceHorizontalRoll, cameraEventsOn, and cameraEventsOff are correctly defined and implemented.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify camera properties and methods.

# Test: Search for the definitions and implementations of the camera properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 5 $'camera: merge(cameraDeprecated, {'

Length of output: 185


Script:

#!/bin/bash
# Description: Verify camera properties and methods.

# Test: Search for the definitions and implementations of the camera properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 5 $'camera: merge(cameraDeprecated, \\{'

Length of output: 155


Script:

#!/bin/bash
# Description: Verify camera properties and methods.

# Test: Search for the definitions and implementations of the camera properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 5 $'camera: merge\\(cameraDeprecated, \\{'

Length of output: 656


Script:

#!/bin/bash
# Description: Verify implementations of camera properties and methods.

# Test: Search for the definitions and implementations of the methods and properties used within the camera object. Expect: Correct definitions and implementations.

# Search for getCameraPosition function
rg --type ts 'function getCameraPosition'

# Search for getCameraFov function
rg --type ts 'function getCameraFov'

# Search for getCameraAspectRatio function
rg --type ts 'function getCameraAspectRatio'

# Search for getCameraViewport function
rg --type ts 'function getCameraViewport'

# Search for zoomIn function
rg --type ts 'function zoomIn'

# Search for zoomOut function
rg --type ts 'function zoomOut'

# Search for setView function
rg --type ts 'function setView'

# Search for flyTo function
rg --type ts 'function flyTo'

# Search for flyToBoundingBox function
rg --type ts 'function flyToBoundingBox'

# Search for getGlobeIntersection function
rg --type ts 'function getGlobeIntersection'

# Search for enableScreenSpaceCameraController function
rg --type ts 'function enableScreenSpaceCameraController'

# Search for overrideScreenSpaceCameraController function
rg --type ts 'function overrideScreenSpaceCameraController'

# Search for lookAt function
rg --type ts 'function lookAt'

# Search for rotateAround function
rg --type ts 'function rotateAround'

# Search for rotateRight function
rg --type ts 'function rotateRight'

# Search for orbit function
rg --type ts 'function orbit'

# Search for move function
rg --type ts 'function move'

# Search for moveOverTerrain function
rg --type ts 'function moveOverTerrain'

# Search for enableForceHorizontalRoll function
rg --type ts 'function enableForceHorizontalRoll'

# Search for cameraEventsOn function
rg --type ts 'function cameraEventsOn'

# Search for cameraEventsOff function
rg --type ts 'function cameraEventsOff'

Length of output: 868


Script:

#!/bin/bash
# Description: Verify implementations of camera properties and methods.

# Test: Search for the definitions and implementations of the methods and properties used within the camera object. Expect: Correct definitions and implementations.

# Search for getCameraPosition
rg --type ts 'getCameraPosition'

# Search for getCameraFov
rg --type ts 'getCameraFov'

# Search for getCameraAspectRatio
rg --type ts 'getCameraAspectRatio'

# Search for getCameraViewport
rg --type ts 'getCameraViewport'

# Search for zoomIn
rg --type ts 'zoomIn'

# Search for zoomOut
rg --type ts 'zoomOut'

# Search for setView
rg --type ts 'setView'

# Search for flyTo
rg --type ts 'flyTo'

# Search for flyToBoundingBox
rg --type ts 'flyToBoundingBox'

# Search for getGlobeIntersection
rg --type ts 'getGlobeIntersection'

# Search for enableScreenSpaceCameraController
rg --type ts 'enableScreenSpaceCameraController'

# Search for overrideScreenSpaceCameraController
rg --type ts 'overrideScreenSpaceCameraController'

# Search for lookAt
rg --type ts 'lookAt'

# Search for rotateAround
rg --type ts 'rotateAround'

# Search for rotateRight
rg --type ts 'rotateRight'

# Search for orbit
rg --type ts 'orbit'

# Search for move
rg --type ts 'move'

# Search for moveOverTerrain
rg --type ts 'moveOverTerrain'

# Search for enableForceHorizontalRoll
rg --type ts 'enableForceHorizontalRoll'

# Search for cameraEventsOn
rg --type ts 'cameraEventsOn'

# Search for cameraEventsOff
rg --type ts 'cameraEventsOff'

Length of output: 199882

web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/exposedReearth.ts (4)

106-123: Verify viewer properties and methods.

Ensure that the viewer properties and methods are correctly defined and implemented.

Verification successful

Viewer properties and methods are correctly defined and implemented.

The viewer object and its properties, including overrideProperty and tools.getTerrainHeightAsync, are correctly defined and implemented in the exposedReearth.ts file.

  • viewer: merge(commonReearth.viewer, { ... })
  • overrideProperty method
  • tools.getTerrainHeightAsync method
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify viewer properties and methods.

# Test: Search for the definitions and implementations of the viewer properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 5 $'viewer: merge(commonReearth.viewer, {'

Length of output: 197


Script:

#!/bin/bash
# Description: Verify viewer properties and methods.

# Test: Search for the definitions and implementations of the viewer properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 10 $'viewer: merge\\(commonReearth.viewer, \\{'

Length of output: 1419


1-9: Verify import paths and function parameters.

Ensure that the import paths are correct and the function parameters are accurately defined.

Verification successful

Let's correct the regex parse error and re-run the script to verify the import paths and function parameters.


Let's escape the special characters in the search pattern and re-run the script to verify the import paths and function parameters.


Verification successful: Import paths and function parameters are correctly defined.

  • The import path for merge from @reearth/beta/utils/object is accurate and present in the expected file.
  • The surrounding import statements are also correctly defined.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify import paths and function parameters.

# Test: Search for the import paths and function parameters. Expect: Correct paths and definitions.
rg --type ts -A 5 $'import { merge } from "@reearth/beta/utils/object"'

Length of output: 214


Script:

#!/bin/bash
# Description: Verify import paths and function parameters.

# Test: Search for the import paths and function parameters. Expect: Correct paths and definitions.
rg --type ts -A 5 'import { merge } from "@reearth/beta/utils/object"'

Length of output: 214


Script:

#!/bin/bash
# Description: Verify import paths and function parameters.

# Test: Search for the import paths and function parameters. Expect: Correct paths and definitions.
rg --type ts -A 5 'import \{ merge \} from "@reearth/beta/utils/object"'

Length of output: 1482


124-220: Verify timeline properties and methods.

Ensure that the timeline properties and methods are correctly defined and implemented.

Verification successful

Verified timeline properties and methods.

The timeline properties and methods (play, pause, setTime, setSpeed) are correctly defined and implemented. They commit the appropriate commands to the timelineManagerRef with the necessary payload and committer information.

  • play method commits the "PLAY" command.
  • pause method commits the "PAUSE" command.
  • setTime method commits the "SET_TIME" command with the time payload.
  • setSpeed method commits the "SET_OPTIONS" command with the speed payload.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify timeline properties and methods.

# Test: Search for the definitions and implementations of the timeline properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 5 $'timeline: merge(commonReearth.timeline, {'

Length of output: 209


Script:

#!/bin/bash
# Description: Verify timeline properties and methods.

# Test: Search for the definitions and implementations of the timeline properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 50 'timeline: merge(commonReearth.timeline, {'

Length of output: 210


Script:

#!/bin/bash
# Description: Verify timeline properties and methods.

# Test: Search for the definitions and implementations of the timeline properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 50 'timeline: merge(commonReearth.timeline'

Length of output: 166


Script:

#!/bin/bash
# Description: Verify timeline properties and methods.

# Test: Search for the definitions and implementations of the timeline properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 50 'timeline: merge'

Length of output: 5570


100-364: Ensure correct construction of the returned object.

Verify that all properties and methods in the returned object are correctly defined and implemented.

web/src/beta/features/Visualizer/Crust/Plugins/hooks/useDeprecated.ts (5)

308-320: Ensure correct implementation of the warning function.

Verify that the warning function is correctly defined and implemented.

Verification successful

The warning function is correctly defined and implemented.

The function logs a warning message for deprecated properties and methods, including suggestions if available.

  • Location: web/src/beta/features/Visualizer/Crust/Plugins/hooks/useDeprecated.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the warning function.

# Test: Search for the definitions and implementations of the warning function. Expect: Correct definitions and implementations.
rg --type ts -A 5 $'function warning(name: string, additional?: string) {'

Length of output: 245


Script:

#!/bin/bash
# Description: Verify the implementation of the warning function.

# Test: Search for the definitions and implementations of the warning function. Expect: Correct definitions and implementations.
rg --type ts -A 5 $'function warning(name: string, additional?: string) \\{'

Length of output: 76


Script:

#!/bin/bash
# Description: Verify the implementation of the warning function.

# Test: Search for the definitions and implementations of the warning function. Expect: Correct definitions and implementations.
rg --type ts -A 5 'function warning'

Length of output: 690


274-304: Ensure correct implementation of utility functions.

Verify that the utility functions are correctly defined and implemented.

Verification successful

The utility functions addProperty, addWarning, and addEventWarning are correctly defined and implemented.

The definitions and implementations of the utility functions addProperty, addWarning, and addEventWarning were found in the specified file, and they match the expected structure.

  • addProperty: Found at web/src/beta/features/Visualizer/Crust/Plugins/hooks/useDeprecated.ts
  • addWarning: Found at web/src/beta/features/Visualizer/Crust/Plugins/hooks/useDeprecated.ts
  • addEventWarning: Found at web/src/beta/features/Visualizer/Crust/Plugins/hooks/useDeprecated.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the utility functions.

# Test: Search for the definitions and implementations of the utility functions. Expect: Correct definitions and implementations.
rg --type ts -A 5 $'function addProperty(obj: object, name: string, value: unknown) {'

Length of output: 281


Script:

#!/bin/bash
# Description: Verify the implementation of the utility functions.

# Test: Search for the definitions and implementations of the utility functions. Expect: Correct definitions and implementations.
rg --type ts -A 5 'function addProperty\(obj: object, name: string, value: unknown\) {'

Length of output: 287


Script:

#!/bin/bash
# Description: Verify the implementation of the utility functions.

# Test: Search for the definitions and implementations of the utility functions. Expect: Correct definitions and implementations.
rg --type ts -A 5 'function addProperty\(obj: object, name: string, value: unknown\) \{'

Length of output: 675


Script:

#!/bin/bash
# Description: Verify the implementation of the utility functions `addWarning` and `addEventWarning`.

# Test: Search for the definitions and implementations of the utility functions. Expect: Correct definitions and implementations.
rg --type ts -A 5 'function addWarning\(obj: object, name: string, value: string\) \{'
rg --type ts -A 5 'function addEventWarning\(obj: object, name: string, isOnce = false\) \{'

Length of output: 1401


1-5: Verify import paths and type definition.

Ensure that the import paths are correct and the Props type definition is accurate and aligns with the rest of the codebase.

Verification successful

Let's correct the regex pattern and re-run the search to verify the import paths and type definitions.


Let's use ast-grep to search for the import statement and verify the type definition.


Let's use ast-grep to search for the Props type definition and verify its usage.


Verification successful for import paths and type definition.

  • The import statement for useMemo from "react" is correctly used.
  • The Props type definition is accurately implemented.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify import paths and type definitions.

# Test: Search for the import paths and type definitions. Expect: Correct paths and definitions.
rg --type ts -A 5 $'import { useMemo } from "react"'

Length of output: 176


Script:

#!/bin/bash
# Description: Verify import paths and type definitions.

# Test: Search for the import paths and type definitions. Expect: Correct paths and definitions.
rg --type ts -A 5 'import { useMemo } from "react"'

Length of output: 176


Script:

#!/bin/bash
# Description: Verify import paths and type definitions using ast-grep.

# Test: Search for the import statement and type definition.
ast-grep --lang typescript --pattern $'import { useMemo } from "react"'

Length of output: 609


Script:

#!/bin/bash
# Description: Verify `Props` type definition using ast-grep.

# Test: Search for the `Props` type definition.
ast-grep --lang typescript --pattern $'type Props = {\n  built?: boolean;\n}'

Length of output: 335


7-160: Ensure correct implementation of the hook.

Verify that the hook implementation is correct and all deprecated properties and methods are accurately defined.

Verification successful

Let's correct the regex pattern by escaping the { character and try again.


Let's simplify the regex pattern to avoid issues with special characters and search for the function implementation in a more reliable way.


To ensure that all deprecated properties and methods are correctly defined and implemented, we need to verify the implementations of the addWarning and addProperty functions used in the hook.


Verified: The hook implementation is correct.

The hook correctly defines deprecated properties and methods using useMemo, and the helper functions addWarning and addProperty are implemented as expected.

  • addWarning defines properties with custom getters that return warning messages.
  • addProperty defines properties with custom getters that return specified values.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the implementation of the hook.

# Test: Search for the definitions and implementations of the deprecated properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 5 $'export default ({ built }: Props) => {'

Length of output: 190


Script:

#!/bin/bash
# Description: Verify the implementation of the hook.

# Test: Search for the definitions and implementations of the deprecated properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 5 $'export default (\\{ built \\}: Props) => {'

Length of output: 206


Script:

#!/bin/bash
# Description: Verify the implementation of the hook.

# Test: Search for the definitions and implementations of the deprecated properties and methods. Expect: Correct definitions and implementations.
rg --type ts -A 10 'export default \(\{ built \}: Props\) => \{'

Length of output: 1189


Script:

#!/bin/bash
# Description: Verify the implementations of the addWarning and addProperty functions.

# Test: Search for the definitions of the addWarning and addProperty functions. Expect: Correct definitions and implementations.
rg --type ts 'function addWarning' -A 10
rg --type ts 'function addProperty' -A 10

Length of output: 2189


163-272: Verify deprecated map.

Ensure that the deprecated map is accurate and all mappings are correctly defined.

Verification successful

Let's correct the regex pattern and rerun the search to verify the deprecated map.


Let's correct the regex pattern by escaping the { character and rerun the search to verify the deprecated map.


To ensure the deprecated map is accurate, we need to verify the usage of the deprecated properties and methods across the codebase.


Verified deprecated map.

The deprecated map in web/src/beta/features/Visualizer/Crust/Plugins/hooks/useDeprecated.ts accurately defines the mappings from deprecated properties and methods to their new counterparts.

  • Location: web/src/beta/features/Visualizer/Crust/Plugins/hooks/useDeprecated.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the deprecated map.

# Test: Search for the definitions and implementations of the deprecated map. Expect: Correct definitions and implementations.
rg --type ts -A 5 $'const deprecatedMap = {'

Length of output: 155


Script:

#!/bin/bash
# Description: Verify the deprecated map.

# Test: Search for the definitions and implementations of the deprecated map. Expect: Correct definitions and implementations.
rg --type ts -A 5 'const deprecatedMap = {'

Length of output: 155


Script:

#!/bin/bash
# Description: Verify the deprecated map.

# Test: Search for the definitions and implementations of the deprecated map. Expect: Correct definitions and implementations.
rg --type ts -A 5 'const deprecatedMap = \{'

Length of output: 776


Script:

#!/bin/bash
# Description: Verify the usage of deprecated properties and methods in the codebase.

# Test: Search for the usage of deprecated properties and methods. Expect: Correct usage and mapping.
rg --type ts 'reearth\.(engineName|visualizer\.engine|visualizer\.camera|visualizer\.property|visualizer\.overrideProperty|scene\.inEditor|scene\.built|scene\.captureScreen|scene\.getLocationFromScreen|scene\.sampleTerrainHeight|scene\.computeGlobeHeight|scene\.getGlobeHeight|scene\.toXYZ|scene\.toLngLatHeight|scene\.convertScreenToPositionOffset|scene\.isPositionVisible|scene\.toWindowPosition|scene\.pickManyFromViewport|clock\.startTime|clock\.stopTime|clock\.currentTime|clock\.playing|clock\.paused|clock\.speed|clock\.stepType|clock\.rangeType|clock\.tick|clock\.play|clock\.pause|clock\.setTime|clock\.setSpeed|clock\.setStepType|clock\.setRangeType|interactionMode\.mode|interactionMode\.override|plugins\.instances|plugins\.postMessage|plugin\.id|plugin\.extensionId|plugin\.property|camera\.getFovInfo|camera\.flyToBBox|camera\.rotateOnCenter|camera\.lookHorizontal|camera\.lookVertical|camera\.moveForward|camera\.moveBackward|camera\.moveUp|camera\.moveDown|camera\.moveLeft|camera\.moveRight|camera\.flyToGround|camera\.overrideScreenSpaceController|layers\.overrideProperty|layers\.overriddenProperties|camera\.forceHorizontalRoll|sketch\.setType|sketch\.setColor|sketch\.disableShadow|sketch\.setDefaultAppearance|sketch\.createDataOnly|sketch\.enableRelativeHeight|sketch\.allowRightClickToAbort|sketch\.allowAutoResetInteractionMode|clientStorage\.getAsync|clientStorage\.setAsync|clientStorage\.deleteAsync|clientStorage\.keysAsync|clientStorage\.dropStore|event\supdate|event\sclose|event\scameramove|event\slayeredit|event\sselect|event\smessage|event\sclick|event\sdoubleclick|event\smousedown|event\smouseup|event\srightclick|event\srightdown|event\srightup|event\smiddleclick|event\smiddledown|event\smiddleup|event\smousemove|event\smouseenter|event\smouseleave|event\swheel|event\stick|event\stimelinecommit|event\sresize|event\smodalclose|event\spopupclose|event\spluginmessage|event\ssketchfeaturecreated|event\ssketchtypechange|event\slayerVisibility|event\slayerload|event\slayerSelectWithRectStart|event\slayerSelectWithRectMove|event\slayerSelectWithRectEnd)'

Length of output: 11670

web/src/beta/features/Visualizer/Crust/Plugins/Plugin/hooks/usePluginAPI.ts (10)

87-89: Optimize useGet hook usage.

The useGet hook is used for layer, block, and widget. Ensure that this hook is necessary and not redundant.

Are these hooks necessary, or can the values be accessed directly?


117-119: Ensure proper message handling.

The pluginMessageSender callback sends messages to extensionEvents. Ensure that message handling is correctly implemented and consider adding error handling.

Are there any edge cases where message handling might fail?


121-174: Verify event initialization and merging.

The onPreInit callback initializes and merges various events. Ensure that all necessary events are correctly initialized and merged.

Are all required events being initialized and merged correctly?


176-198: Ensure proper cleanup in onDispose.

The onDispose callback handles cleanup of events and states. Ensure that all necessary cleanup actions are performed to avoid memory leaks.

Are there any resources or events that are not being properly cleaned up?


208-211: Optimize isMarshalable callback.

The isMarshalable callback checks if a target is marshalable. Ensure that this check is efficient and covers all necessary cases.

Is the marshalable check comprehensive and efficient?


213-393: Review staticExposed memoization.

The staticExposed memoization creates an exposed API for the plugin. Ensure that all necessary properties and methods are correctly exposed and consider adding error handling.

Are all required properties and methods correctly exposed?


395-397: Ensure uiEvents update handling.

The useEffect hook updates uiEvents on changes to block, layer, widget, or ctx.reearth.viewer.property. Ensure that this update is necessary and correctly implemented.

Is the uiEvents update necessary and correctly implemented?


399-405: Ensure proper modal and popup close handling.

The onModalClose and onPopupClose callbacks handle closing of modals and popups. Ensure that these callbacks are correctly implemented and consider adding error handling.

Are the modal and popup close handlers correctly implemented?


407-414: LGTM!

The return object from usePluginAPI looks good and includes all necessary properties and methods.


417-433: LGTM!

The initAndMergeEvents function correctly initializes and merges events.

web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/pluginAPIv1Types.ts (6)

114-114: Ensure layer property is always defined.

The layer property is now required. Ensure that all instances of Reearth have this property defined.

Are there any instances of Reearth where the layer property might be undefined?


118-118: Ensure viewer property is always defined.

The viewer property is now required. Ensure that all instances of Reearth have this property defined.

Are there any instances of Reearth where the viewer property might be undefined?


186-189: Ensure property and overrideProperty removal is handled.

The property and overrideProperty fields have been removed from the Scene type. Ensure that all instances where these fields were used are updated accordingly.

Are there any instances where property and overrideProperty are still being used in the codebase?


186-189: LGTM!

The new Viewer type definition looks good and includes the necessary fields.


Line range hint 1-42: LGTM!

The import statements have been correctly adjusted to reflect changes in the type definitions.


1-1: LGTM!

The deprecation note clearly indicates that the plugin API v1 is deprecated.

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: 1

Outside diff range, codebase verification and nitpick comments (2)
web/src/beta/features/Visualizer/Crust/Plugins/Plugin/hooks/usePluginAPI.ts (2)

122-175: Add comments for better readability.

The onPreInit function is well-structured but can benefit from additional comments to explain the purpose of each block of code.


214-403: Add comments for better readability.

The staticExposed function is well-structured but can benefit from additional comments to explain the purpose of each block of code.

Tools
Biome

[error] 240-240: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 241-241: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c781570 and 507a08f.

Files selected for processing (14)
  • web/src/beta/features/Editor/Visualizer/convert-infobox.ts (2 hunks)
  • web/src/beta/features/Editor/Visualizer/convert-story.ts (2 hunks)
  • web/src/beta/features/Visualizer/Crust/Infobox/Block/index.tsx (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Infobox/types.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/Plugin/hooks/usePluginAPI.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useExtension.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/exposedReearth.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/extension.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/usePluginInstances.ts (4 hunks)
  • web/src/beta/features/Visualizer/Crust/StoryPanel/Block/index.tsx (1 hunks)
  • web/src/beta/features/Visualizer/Crust/StoryPanel/types.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/hooks.tsx (2 hunks)
  • web/src/beta/features/Visualizer/Crust/index.tsx (11 hunks)
  • web/src/beta/features/Visualizer/shared/components/BlockWrapper/index.tsx (7 hunks)
Files skipped from review due to trivial changes (2)
  • web/src/beta/features/Visualizer/Crust/Infobox/Block/index.tsx
  • web/src/beta/features/Visualizer/Crust/StoryPanel/Block/index.tsx
Files skipped from review as they are similar to previous changes (5)
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useExtension.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/exposedReearth.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/extension.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/usePluginInstances.ts
  • web/src/beta/features/Visualizer/Crust/hooks.tsx
Additional context used
Biome
web/src/beta/features/Visualizer/Crust/Plugins/Plugin/hooks/usePluginAPI.ts

[error] 240-240: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)


[error] 241-241: Avoid the delete operator which can impact performance.

Unsafe fix: Use an undefined assignment instead.

(lint/performance/noDelete)

Additional comments not posted (20)
web/src/beta/features/Visualizer/Crust/StoryPanel/types.ts (2)

28-32: Enhancement: New properties for better plugin integration.

The new properties extensionType, propertyForPluginAPI, and propertyItemsForPluginBlock improve the expressiveness and integration with plugins.


35-38: Enhancement: Variant type for specific use cases.

The PluginStoryBlock type omits propertyForPluginAPI and propertyItemsForPluginBlock, creating a variant of StoryBlock for specific use cases.

web/src/beta/features/Editor/Visualizer/convert-infobox.ts (2)

25-25: Enhancement: Explicit block type categorization.

The extensionType property categorizes the block type as "infoboxBlock", improving clarity.


27-29: Enhancement: Improved property handling for plugin integration.

The propertyForPluginAPI field is introduced, and pluginBlockPropertyItems is renamed to propertyItemsForPluginBlock, improving structure and clarity.

web/src/beta/features/Visualizer/Crust/Infobox/types.ts (2)

26-30: Enhancement: New properties for better plugin integration.

The new properties extensionType, propertyForPluginAPI, and propertyItemsForPluginBlock improve the expressiveness and integration with plugins.


33-36: Enhancement: Variant type for specific use cases.

The PluginInfoboxBlock type omits propertyForPluginAPI and propertyItemsForPluginBlock, creating a variant of InfoboxBlock for specific use cases.

web/src/beta/features/Editor/Visualizer/convert-story.ts (2)

10-11: Ensure clarity in property processing imports.

The aliasing of processProperty as processNewProperty and importing the original processProperty from ./convert is clear. Ensure that this restructuring is well-documented to avoid confusion.


43-45: Ensure consistency in property processing.

The use of processNewProperty for the property field and the introduction of propertyForPluginAPI using the original processProperty is a good separation of concerns. Ensure that the usage of these fields is consistent throughout the codebase.

web/src/beta/features/Visualizer/shared/components/BlockWrapper/index.tsx (5)

6-6: Ensure correct usage of FlyTo.

The addition of the FlyTo import indicates new functionality for fly-to actions. Ensure that this new functionality is correctly integrated and tested.


33-33: Prop renaming improves clarity.

The renaming of pluginBlockPropertyItems to propertyItemsForPluginBlock enhances clarity regarding its purpose.


62-62: New onFlyTo prop added.

The addition of the onFlyTo prop allows for more flexible handling of fly-to actions. Ensure that this new prop is correctly integrated and tested.


73-73: Prop renaming applied in component.

The propertyItemsForPluginBlock prop is now used in the component, aligning with the new naming convention.


86-86: New onFlyTo prop integration.

The onFlyTo prop is now passed to the PropertyItem component, enhancing the reusability of the fly-to functionality. Ensure that this integration is correctly tested.

web/src/beta/features/Visualizer/Crust/index.tsx (3)

4-11: Ensure correct usage of new imports.

The expanded imports for Camera, ViewerProperty, and related types indicate new functionality for managing camera and viewer properties. Ensure that these new types are correctly integrated and used throughout the component.


60-67: Props type updated for viewer-centric approach.

The Props type now includes new properties for camera and viewer management, and the sceneProperty has been removed. This shift towards a more viewer-centric approach is likely to improve interaction with viewer-specific settings.


Line range hint 152-259:
Crust component updated for dynamic visual element management.

The Crust component now reflects the new props structure, focusing on viewer properties and camera management. These changes enhance the component's ability to manage visual elements dynamically, improving the user experience.

web/src/beta/features/Visualizer/Crust/Plugins/Plugin/hooks/usePluginAPI.ts (4)

33-50: Ensure consistent parameter typing.

Some parameters such as pluginProperty and layer are typed as any or undefined. Consider using more specific types for better type safety.

-  pluginProperty: any;
-  layer: Layer | undefined;
+  pluginProperty: PluginPropertyType; // Replace with actual type
+  layer?: Layer;

92-116: Combine similar event refs initialization.

The event refs initialization for viewerEventsRef, selectionModeEventsRef, cameraEventsRef, etc., follow a similar pattern. Consider creating a helper function to reduce redundancy.

-  const viewerEventsRef =
-    useRef<[Events<ViewerEventType>, EventEmitter<ViewerEventType>, (() => void) | undefined]>();
-  const selectionModeEventsRef =
-    useRef<
-      [
-        Events<SelectionModeEventType>,
-        EventEmitter<SelectionModeEventType>,
-        (() => void) | undefined,
-      ]
-    >();
-  const cameraEventsRef =
-    useRef<[Events<CameraEventType>, EventEmitter<CameraEventType>, (() => void) | undefined]>();
-  const timelineEventsRef =
-    useRef<
-      [Events<TimelineEventType>, EventEmitter<TimelineEventType>, (() => void) | undefined]
-    >();
-  const layersEventsRef =
-    useRef<[Events<LayersEventType>, EventEmitter<LayersEventType>, (() => void) | undefined]>();
-  const sketchEventsRef =
-    useRef<[Events<SketchEventType>, EventEmitter<SketchEventType>, (() => void) | undefined]>();
+  const createEventRef = <T>() =>
+    useRef<[Events<T>, EventEmitter<T>, (() => void) | undefined]>();
+  const viewerEventsRef = createEventRef<ViewerEventType>();
+  const selectionModeEventsRef = createEventRef<SelectionModeEventType>();
+  const cameraEventsRef = createEventRef<CameraEventType>();
+  const timelineEventsRef = createEventRef<TimelineEventType>();
+  const layersEventsRef = createEventRef<LayersEventType>();
+  const sketchEventsRef = createEventRef<SketchEventType>();

177-207: LGTM!

The onDispose function is well-structured and handles cleanup effectively.


209-212: LGTM!

The isMarshalable function is concise and correctly uses the useCallback hook.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 507a08f and a965aa9.

Files ignored due to path filters (1)
  • web/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (6)
  • web/package.json (2 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/Plugin/hooks/usePluginAPI.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/index.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useTimeline.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/timeline.ts (1 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/utils/events.ts (1 hunks)
Files skipped from review as they are similar to previous changes (5)
  • web/package.json
  • web/src/beta/features/Visualizer/Crust/Plugins/Plugin/hooks/usePluginAPI.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/index.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/hooks/useTimeline.ts
  • web/src/beta/features/Visualizer/Crust/Plugins/pluginAPI/types/timeline.ts
Additional context used
Biome
web/src/beta/features/Visualizer/Crust/Plugins/utils/events.ts

[error] 94-94: Avoid the use of spread (...) syntax on accumulators.

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

(lint/performance/noAccumulatingSpread)

Additional comments not posted (7)
web/src/beta/features/Visualizer/Crust/Plugins/utils/events.ts (7)

58-61: Fix potential issue in off method.

The off method should use the original callback instead of the event callback for deletion.

const off = <T extends keyof E>(type: T, callback: EventCallback<E[T]>) => {
  const ecb = getEventCallback(type, callback);
  e.removeEventListener(String(type), ecb);
-  deleteEventCallback(type, ecb);
+  deleteEventCallback(type, callback);
};

44-51: Improve deleteEventCallback function.

The deleteEventCallback function should also delete the key from the callbacks map if the map becomes empty after deletion.

const deleteEventCallback = (type: keyof E, cb: EventCallback): void => {
  const ecbs = callbacks.get(type);
  if (ecbs) {
    ecbs.delete(cb);
    if (ecbs.size === 0) {
      callbacks.delete(type);
    }
  }
};

92-99: Optimize reduce accumulator.

Avoid using spread syntax in the reduce accumulator to improve performance.

const cbs = types.reduce<{ [T in keyof E]: EventCallback<E[T]> }>(
  (a, b) => {
-    ...a,
-    [b]: (...args: E[typeof b]) => {
-      dest(b, ...args);
-    },
+    a[b] = (...args: E[typeof b]) => {
+      dest(b, ...args);
+    };
+    return a;
  },
  {} as any,
);
Tools
Biome

[error] 94-94: Avoid the use of spread (...) syntax on accumulators.

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

(lint/performance/noAccumulatingSpread)


113-124: LGTM!

The useEmit function is correctly implemented and follows best practices.


18-85: LGTM!

The events function is correctly implemented and follows best practices.


87-111: LGTM!

The mergeEvents function is correctly implemented and follows best practices.

Tools
Biome

[error] 94-94: Avoid the use of spread (...) syntax on accumulators.

Spread syntax should be avoided on accumulators (like those in .reduce) because it causes a time complexity of O(n^2).
Consider methods such as .splice or .push instead.

(lint/performance/noAccumulatingSpread)


113-124: LGTM!

The useEmit function is correctly implemented and follows best practices.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a965aa9 and 97203d0.

Files ignored due to path filters (1)
  • web/yarn.lock is excluded by !**/yarn.lock, !**/*.lock
Files selected for processing (2)
  • web/package.json (2 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/Plugin/hooks/usePluginAPI.ts (1 hunks)
Files skipped from review as they are similar to previous changes (2)
  • web/package.json
  • web/src/beta/features/Visualizer/Crust/Plugins/Plugin/hooks/usePluginAPI.ts

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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 97203d0 and eb38180.

Files ignored due to path filters (1)
  • web/yarn.lock is excluded by !**/yarn.lock, !**/*.lock, !**/*.lock
Files selected for processing (2)
  • web/package.json (1 hunks)
  • web/src/beta/features/Visualizer/shared/components/BlockWrapper/index.tsx (7 hunks)
Files skipped from review as they are similar to previous changes (2)
  • web/package.json
  • web/src/beta/features/Visualizer/shared/components/BlockWrapper/index.tsx

@airslice airslice self-assigned this Jul 29, 2024
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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between eb38180 and cbb312a.

Files selected for processing (1)
  • web/src/beta/features/Visualizer/Crust/Plugins/utils/events.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • web/src/beta/features/Visualizer/Crust/Plugins/utils/events.ts

@mkumbobeaty mkumbobeaty self-requested a review July 31, 2024 00:39
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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between cbb312a and be1a044.

Files ignored due to path filters (1)
  • web/yarn.lock is excluded by !**/yarn.lock, !**/*.lock, !**/*.lock
Files selected for processing (6)
  • web/package.json (2 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/Plugin/ModalContainer/index.tsx (2 hunks)
  • web/src/beta/features/Visualizer/Crust/Plugins/Plugin/PopupContainer/index.tsx (1 hunks)
  • web/src/beta/features/Visualizer/Crust/StoryPanel/Block/index.tsx (1 hunks)
  • web/src/beta/features/Visualizer/index.tsx (10 hunks)
  • web/src/beta/features/Visualizer/shared/components/BlockWrapper/index.tsx (7 hunks)
Files skipped from review due to trivial changes (1)
  • web/src/beta/features/Visualizer/Crust/Plugins/Plugin/PopupContainer/index.tsx
Files skipped from review as they are similar to previous changes (4)
  • web/package.json
  • web/src/beta/features/Visualizer/Crust/Plugins/Plugin/ModalContainer/index.tsx
  • web/src/beta/features/Visualizer/Crust/StoryPanel/Block/index.tsx
  • web/src/beta/features/Visualizer/shared/components/BlockWrapper/index.tsx
Additional comments not posted (5)
web/src/beta/features/Visualizer/index.tsx (5)

12-12: LGTM! New imports are appropriate.

The import statements for ViewerProperty and WidgetThemeOptions are necessary for the new properties added to VisualizerProps.

Also applies to: 22-22


49-49: LGTM! Enhanced VisualizerProps type definition.

The changes to VisualizerProps by replacing sceneProperty with viewerProperty, and adding initialCamera and widgetThemeOptions improve the component's flexibility and functionality.

Also applies to: 59-59, 72-72


141-141: LGTM! Updated Visualizer component definition.

The updates to use viewerProperty, initialCamera, and widgetThemeOptions align with the changes made to VisualizerProps and ensure effective utilization of the new properties.

Also applies to: 147-147, 165-165


183-191: LGTM! Updated useHooks function call.

The update to include viewerProperty ensures that the component now relies on this property to manage its internal state more effectively.


206-206: LGTM! Updated rendering logic.

The updates to utilize viewerProperty and initialCamera align with the changes made to VisualizerProps and ensure consistency in the component's rendering logic.

Also applies to: 227-233

@mkumbobeaty mkumbobeaty self-requested a review August 1, 2024 08:45
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

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between be1a044 and fc86588.

Files selected for processing (2)
  • web/src/beta/features/Visualizer/Crust/StoryPanel/Block/index.tsx (1 hunks)
  • web/src/beta/features/Visualizer/shared/components/BlockWrapper/index.tsx (7 hunks)
Files skipped from review as they are similar to previous changes (2)
  • web/src/beta/features/Visualizer/Crust/StoryPanel/Block/index.tsx
  • web/src/beta/features/Visualizer/shared/components/BlockWrapper/index.tsx

@airslice airslice merged commit 2a456eb into main Aug 2, 2024
13 checks passed
@airslice airslice deleted the chore/use-viewer-property branch August 2, 2024 01:06
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.

None yet

2 participants