-
Notifications
You must be signed in to change notification settings - Fork 26.9k
feat(devtools): add transfer state tab #62465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Help needed:
|
devtools/projects/ng-devtools-backend/src/lib/client-event-subscribers.ts
Outdated
Show resolved
Hide resolved
devtools/projects/ng-devtools-backend/src/lib/ng-debug-api/ng-debug-api.ts
Outdated
Show resolved
Hide resolved
devtools/projects/ng-devtools/src/lib/devtools-tabs/transfer-state/transfer-state.component.ts
Outdated
Show resolved
Hide resolved
devtools/projects/ng-devtools-backend/src/lib/client-event-subscribers.ts
Outdated
Show resolved
Hide resolved
...ools/projects/ng-devtools/src/lib/devtools-tabs/transfer-state/transfer-state.component.scss
Show resolved
Hide resolved
...ools/projects/ng-devtools/src/lib/devtools-tabs/transfer-state/transfer-state.component.scss
Outdated
Show resolved
Hide resolved
...ools/projects/ng-devtools/src/lib/devtools-tabs/transfer-state/transfer-state.component.scss
Outdated
Show resolved
Hide resolved
...ools/projects/ng-devtools/src/lib/devtools-tabs/transfer-state/transfer-state.component.html
Outdated
Show resolved
Hide resolved
...ools/projects/ng-devtools/src/lib/devtools-tabs/transfer-state/transfer-state.component.html
Outdated
Show resolved
Hide resolved
eb9c225 to
a331ee5
Compare
a331ee5 to
5ca05aa
Compare
| const doc = getDocument(); | ||
|
|
||
| const appId = injector.get(APP_ID); | ||
| const scriptId = appId + '-state'; | ||
| const script = doc.getElementById(scriptId) as HTMLScriptElement; | ||
|
|
||
| if (!script) { | ||
| return {}; | ||
| } | ||
|
|
||
| if (!script.textContent || script.textContent.trim() === '') { | ||
| return {}; | ||
| } | ||
| return JSON.parse(script.textContent) as Record<string, unknown>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can basically be replaced by retrieveTransferredState() located in transfer_state.ts (we'll need to export it first).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect this function to strip internal framework keys from packages/core/src/hydration/utils.ts : __nghData__ & __nghDeferData__ which are used for (incremental) hydration and don't have real meaning for developers.
devtools/projects/ng-devtools/src/lib/devtools-tabs/transfer-state/transfer-state.component.ts
Show resolved
Hide resolved
devtools/projects/ng-devtools/src/lib/devtools-tabs/transfer-state/transfer-state.component.ts
Outdated
Show resolved
Hide resolved
devtools/projects/ng-devtools/src/lib/devtools-tabs/transfer-state/transfer-state.component.ts
Outdated
Show resolved
Hide resolved
devtools/projects/ng-devtools/src/lib/devtools-tabs/devtools-tabs.component.html
Outdated
Show resolved
Hide resolved
...ools/projects/ng-devtools/src/lib/devtools-tabs/transfer-state/transfer-state.component.html
Outdated
Show resolved
Hide resolved
devtools/projects/ng-devtools-backend/src/lib/ng-debug-api/ng-debug-api.ts
Show resolved
Hide resolved
devtools/projects/ng-devtools/src/lib/devtools-tabs/transfer-state/transfer-state.component.ts
Outdated
Show resolved
Hide resolved
devtools/projects/ng-devtools/src/lib/devtools-tabs/transfer-state/transfer-state.component.ts
Outdated
Show resolved
Hide resolved
devtools/projects/ng-devtools/src/lib/devtools-tabs/transfer-state/transfer-state.component.ts
Outdated
Show resolved
Hide resolved
devtools/projects/ng-devtools/src/lib/devtools-tabs/transfer-state/transfer-state.component.ts
Outdated
Show resolved
Hide resolved
93d523a to
9c20601
Compare
AndrewKushnir
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, just left one comment.
AndrewKushnir
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JeanMeche thanks for the update, I've left a comment with a couple of suggestions.
| /** | ||
| * Set of transfer state keys that are used internally by the framework | ||
| */ | ||
| export const internalHydrationTransferStateKeys = [ | ||
| TRANSFER_STATE_TOKEN_ID, | ||
| TRANSFER_STATE_DEFER_BLOCKS_INFO, | ||
| ]; | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to propose a couple of changes:
- Create a function (instead of an array) as mentioned below
- Use the function to filter out such keys from the transfer state (in the logic inside of
getTransferState) - For tests, we can use regular hydration specs as a base, just add a few more keys to the transfer state and after that assess whether
getTransferStatereturns only public/application keys
| /** | |
| * Set of transfer state keys that are used internally by the framework | |
| */ | |
| export const internalHydrationTransferStateKeys = [ | |
| TRANSFER_STATE_TOKEN_ID, | |
| TRANSFER_STATE_DEFER_BLOCKS_INFO, | |
| ]; | |
| /** | |
| * Checks whether a given key is used by the framework for transferring hydration data. | |
| */ | |
| export function isInternalHydrationTransferStateKey(key: string): boolean { | |
| return key === TRANSFER_STATE_TOKEN_ID || key === TRANSFER_STATE_DEFER_BLOCKS_INFO; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've extracted the core part of this PR into a separate PR #62722
|
Blocked on #62722 |
7be7172 to
9c20601
Compare
|
@JeanMeche what you think about adding checkbox "Hide internal keys" on top of the page to hide hydration and other internal keys conditionally? As sometimes maybe that keys can be useful, as @eneajaho mentioned in this PR |
|
That could an idea, but let's keep that for as a follow-up and let's try to land this PR first 🙂 |
9c20601 to
35a701d
Compare
35a701d to
7ec3fc2
Compare
|
PR is now unblocked, we need a final approval and we can send it to the merge queue ! |
7ec3fc2 to
037febd
Compare
dgp1130
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks good to me, happy to merge this as is and we can iterate more as we move forward with it.
Thanks @Avcharov for contributing this! It's a very cool addition to Angular DevTools.
Add transfer state tab, which is taking transfer state script by using APP_ID. Created internal api ɵgetTransferState to retrieve transfer state value from app into devtools app.
037febd to
03f1d92
Compare
thePunderWoman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
reviewed-for: fw-general
|
This PR was merged into the repository by commit a2f366f. The changes were merged into the following branches: main |
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
PR Type
What kind of change does this PR introduce?
What is the current behavior?
transfer state is visible only on elements tab in ng-state script.
Issue Number: #62237
What is the new behavior?
Did workaround with adding of new transfer state tab. Still consider solution with transfer state list in components tab intead of proposed. Let me know which one is prefered.
Demo:

Does this PR introduce a breaking change?