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

Navigate to the annotation in the sidecar file #5999

Merged
merged 9 commits into from
Jun 19, 2024

Conversation

gbalint
Copy link
Contributor

@gbalint gbalint commented Jun 19, 2024

Problem:
Followup to #5989
Clicking on the Components inspector section's ◇ logo opens the annotation file for the given component AND jumps to the annotation of the component in the file.

(Second task of #5971 )

Fix:
I used the Babel parser to find the component annotation in the sidecar file.

  • It can find the annotation if it in the exported object literal, or even if it is in a variable referred from this file. It does not support imports though, everything has to be in this file.
  • This is a best effort to find the annotation, if it can not do it like this (e.g. the annotation is dynamically generated, or anything which the parser is not prepared for), then it just doesn't save the bounds. Clicking on the button will still open the sidecar file.

The bounds are stored in the component descriptor source object (which until now only stored the file path itself).

Manual Tests:
I hereby swear that:

  • I opened a hydrogen project and it loaded
  • I could navigate to various routes in Preview mode

@gbalint gbalint changed the title Feature/navigate to annotation Navigate to the annotation in the sidecar file Jun 19, 2024
Copy link
Contributor

github-actions bot commented Jun 19, 2024

Try me

Copy link

relativeci bot commented Jun 19, 2024

#13142 Bundle Size — 62.25MiB (+0.02%).

3ef38d2(current) vs 6339ece master#13140(baseline)

Warning

Bundle contains 51 duplicate packages – View duplicate packages

Bundle metrics  Change 4 changes Regression 2 regressions
                 Current
#13142
     Baseline
#13140
Regression  Initial JS 45.32MiB(+0.02%) 45.31MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 40.71% 22.66%
No change  Chunks 30 30
No change  Assets 33 33
Change  Modules 4305(+0.07%) 4302
Regression  Duplicate Modules 525(+0.38%) 523
No change  Duplicate Code 31.84% 31.84%
No change  Packages 448 448
No change  Duplicate Packages 51 51
Bundle size by type  Change 2 changes Regression 1 regression Improvement 1 improvement
                 Current
#13142
     Baseline
#13140
Regression  JS 62.24MiB (+0.02%) 62.23MiB
Improvement  HTML 11.16KiB (-0.33%) 11.2KiB

Bundle analysis reportBranch feature/navigate-to-annotationProject dashboard

@gbalint gbalint marked this pull request as ready for review June 19, 2024 13:46
@gbalint gbalint merged commit 54692aa into master Jun 19, 2024
16 checks passed
@gbalint gbalint deleted the feature/navigate-to-annotation branch June 19, 2024 14:06
gbalint added a commit that referenced this pull request Jun 20, 2024
**Problem:**
Followup to #5999
3rd and 4th task of
#5971

Added a new context menu item to the property control: you can directly
navigate to the annotation of that specific property using the "Open
<propertyname> annotation" menu item.

**Commit Details:** (< vv pls delete this section if's not relevant)

- Extended the component descriptor parser to process the individual
properties too.
- Extended the source representation of a descriptor to include bounds
for the full annotation, and bounds for the individual properties too.
- Extracting getting the component data in component-section into a
hook, so I can use it from the individual controls to create to
necessary context menu item.
- I removed property name from the `unset` context menu item 

**Manual Tests:**
I hereby swear that:

- [x] I opened a hydrogen project and it loaded
- [x] I could navigate to various routes in Preview mode

Fixes #5971
liady pushed a commit that referenced this pull request Dec 13, 2024
**Problem:**
Followup to #5989
Clicking on the Components inspector section's ◇ logo opens the
annotation file for the given component AND jumps to the annotation of
the component in the file.

(Second task of #5971 )


**Fix:**
I used the Babel parser to find the component annotation in the sidecar
file.
- It can find the annotation if it in the exported object literal, or
even if it is in a variable referred from this file. It does not support
imports though, everything has to be in this file.
- This is a best effort to find the annotation, if it can not do it like
this (e.g. the annotation is dynamically generated, or anything which
the parser is not prepared for), then it just doesn't save the bounds.
Clicking on the button will still open the sidecar file.

The bounds are stored in the component descriptor source object (which
until now only stored the file path itself).

**Manual Tests:**
I hereby swear that:

- [x] I opened a hydrogen project and it loaded
- [x] I could navigate to various routes in Preview mode
liady pushed a commit that referenced this pull request Dec 13, 2024
**Problem:**
Followup to #5999
3rd and 4th task of
#5971

Added a new context menu item to the property control: you can directly
navigate to the annotation of that specific property using the "Open
<propertyname> annotation" menu item.

**Commit Details:** (< vv pls delete this section if's not relevant)

- Extended the component descriptor parser to process the individual
properties too.
- Extended the source representation of a descriptor to include bounds
for the full annotation, and bounds for the individual properties too.
- Extracting getting the component data in component-section into a
hook, so I can use it from the individual controls to create to
necessary context menu item.
- I removed property name from the `unset` context menu item 

**Manual Tests:**
I hereby swear that:

- [x] I opened a hydrogen project and it loaded
- [x] I could navigate to various routes in Preview mode

Fixes #5971
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants