Skip to content

Commit 4f3a444

Browse files
authored
fix(signals): green the Angular compat matrix, and the Forms writes-off note (#497)
* test(overlay): run the debug API canary from Angular 14.0 The debug API test added in #489 calls `bootstrapApplication`, which Angular publishes from 14.0, so it failed with "bootstrapApplication is not a function" in the Angular 12.2 compat job. Gate it at 14.0, like the other real-app tests that need a standalone bootstrap. * fix(overlay): declare the toggleWatchSignal debug function Angular 22.3 prereleases publish `ng.toggleWatchSignal` through their internal global utils, so the debug API canary failed on Angular next with an undeclared function. Add it to `NgDebugApi` as optional, with no `@since` because no release has it yet, and to `NG_DEBUG_FUNCTIONS`. The overlay does not call it. Regenerate the Angular debug API page. * fix(signals): fold the params computed of Angular 22.3 resources Angular 22.3 prereleases run a resource's params function in a new `Resource#name.params` computed, which `extRequest` reads. Resource folding never joined an edge from `extRequest`, because that node used to run the user's params function and may read another resource. The new `params` node was left on its own and showed as an extra unnamed resource card ("resource 2" in the compat test). Join `extRequest` to its own `params`, and treat `params` as the part that reads user code, so a resource whose params read another resource still stays apart from it. Released versions build no `params` node and fold as before. * fix(forms): show the writes-off note text in the Forms action bar The template interpolated the writesOff input signal without calling it, so the note read [Input Signal: ...] instead of the message. * build(extension): rebuild the panel bundle
1 parent fb092d3 commit 4f3a444

12 files changed

Lines changed: 66 additions & 9 deletions

File tree

‎app/src/__tests__/forms-panels.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,15 @@ describe('FormsFields inline editing', () => {
11471147
const edit = button(fixture, 'Edit email');
11481148
expect(edit.disabled).toBe(true);
11491149
expect(edit.getAttribute('aria-describedby')).toBe('forms-writes-off');
1150+
const notes = [
1151+
...(fixture.nativeElement as HTMLElement).querySelectorAll('[id="forms-writes-off"]'),
1152+
];
1153+
expect(notes.length).toBeGreaterThan(0);
1154+
for (const note of notes) {
1155+
expect(note.textContent!.trim()).not.toBe('');
1156+
expect(note.textContent).not.toContain('function');
1157+
expect(note.textContent).not.toContain('[Input Signal');
1158+
}
11501159
});
11511160
});
11521161

‎app/src/pages/forms-action-bar.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ import { FORMS_STYLES } from './forms-types';
7575
</button>
7676
</div>
7777
@if (!canWrite()) {
78-
<p id="forms-writes-off" class="muted">{{ writesOff }}</p>
78+
<p id="forms-writes-off" class="muted">{{ writesOff() }}</p>
7979
}
8080
<p class="status" role="status">{{ message() }}</p>
8181
</div>

‎apps/docs/src/content/api/angular-debug-api.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ A required function is one every supported Angular version publishes, so the ove
3333
| `ɵgetInjectorMetadata` | 17.0 | No | Type (`element`, `environment` or `null`) and source of an injector. |
3434
| `ɵsetProfiler` | See note | No | Adds a profiler. From 20.0 it hands back its remover; before that it has one slot (`ng-capabilities.ts` checks the version). |
3535
| `ɵgetSignalGraph` | 19.1 | No | The reactive graph of an injector. Node ids from 20.1. |
36+
| `toggleWatchSignal` | See note | No | Watches or unwatches a signal-graph node by id. Present in 22.3 prereleases; not called by the overlay. |
3637
| `ɵgetDeferBlocks` | 19.1 | No | `@defer` blocks under a node. Replaced by `ɵgetControlFlowBlocks` in 22.0. |
3738
| `ɵgetControlFlowBlocks` | 22.0 | No | `@defer` and `@for` blocks under a node. |
3839
| `ɵgetTransferState` | See note | No | The TransferState entries without Angular's own hydration keys. Present in 22.1; not checked on older versions. |

‎apps/docs/src/content/inspectors/signals.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ Click an entry under **Dependencies (producers)** or **Consumers** to open that
8484

8585
### Resources
8686

87-
Angular builds each `resource()`, `httpResource()` and `rxResource()` from several internal signals, labeled `Resource#name.value`, `Resource#name.state` and so on. The tab folds them into one card under **Resources**, and leaves them out of the **Signals** list. Angular labels these signals from 21.0.1. On earlier versions they have no names, so the tab shows no **Resources** cards and lists them as unnamed nodes. Each card shows:
87+
Angular builds each `resource()`, `httpResource()` and `rxResource()` from several internal signals, labeled `Resource#name.value`, `Resource#name.state` and so on. The tab folds them into one card under **Resources**, and leaves them out of the **Signals** list. Angular labels these signals from 21.0.1, and the 22.3 prereleases add a `Resource#name.params` computed that the tab folds in the same way. On earlier versions they have no names, so the tab shows no **Resources** cards and lists them as unnamed nodes. Each card shows:
8888

8989
| Field | Meaning |
9090
| --------------- | ----------------------------------------------------------------------------------------- |

extension/ui/assets/browser-agent-rpc-KH4HHvHf-aJiGMZYV.js renamed to extension/ui/assets/browser-agent-rpc-KH4HHvHf-DF8dhgzY.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎extension/ui/index.html‎

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/devtools/CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ What remains: `/config` exports `DEFAULT_POPUP_HOTKEY`, `PANGULAR_ACTIONS`, `PAN
331331
- Turning **Counts launcher** on or off in a popped-out panel changes the launcher on the app page that opened it. The popup takes the change only from the window it popped the panel out into.
332332
- The **Pipes** list is one Tab stop with arrow keys, Home and End, like the other lists in the panel, and in every list the Tab stop follows a row selected with a click that does not focus it, as in Safari (#370).
333333
- The popup's **No devtools server found** state and the panel's **Can't reach the devtools server** message link to the troubleshooting docs (#373).
334+
- On Angular 22.3 prereleases the Signals tab folds the new `Resource#name.params` computed into its resource, instead of showing it as an extra **resource 2** card.
335+
- The Forms tab's note under the action buttons, shown when form writes are off, says why instead of printing `[Input Signal: …]`.
334336

335337
### Docs
336338

‎packages/devtools/src/__tests__/debug-api-real.test.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import { STANDALONE, angularAtLeast, zonelessProviders } from './angular-version
99
class DebugRoot {}
1010
Component({ ...STANDALONE, selector: 'app-root', template: '<p>ok</p>' })(DebugRoot);
1111

12-
describe('NgDebugApi against a real app', () => {
12+
// `bootstrapApplication` and standalone components arrive in 14.0.
13+
describe.runIf(angularAtLeast('14.0'))('NgDebugApi against a real app', () => {
1314
let app: ApplicationRef | null = null;
1415
afterEach(() => {
1516
app?.destroy();

‎packages/devtools/src/__tests__/signal-resources.test.ts‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,37 @@ describe('groupResources', () => {
7070
]);
7171
});
7272

73+
it('folds the params computed of Angular 22.3 prereleases into its resource, and keeps another resource it reads apart', () => {
74+
// From 22.3 `extRequest` reads a `params` computed, which runs the user's params function.
75+
const nodes = [
76+
node('1', 'computed', 'Resource.value', 'Ada'),
77+
node('2', 'linkedSignal', 'Resource.state'),
78+
node('3', 'linkedSignal', 'Resource.extRequest'),
79+
node('4', 'computed', 'Resource.params', 1),
80+
node('5', 'computed', 'Resource.value', ['Ada post']),
81+
node('6', 'linkedSignal', 'Resource.state'),
82+
node('7', 'linkedSignal', 'Resource.extRequest'),
83+
node('8', 'computed', 'Resource.params', 'Ada'),
84+
node('9', 'signal', 'userId', 1),
85+
];
86+
const edges: SignalGraphEdge[] = [
87+
{ consumer: 0, producer: 1 },
88+
{ consumer: 1, producer: 2 },
89+
{ consumer: 2, producer: 3 },
90+
{ consumer: 3, producer: 8 },
91+
{ consumer: 4, producer: 5 },
92+
{ consumer: 5, producer: 6 },
93+
{ consumer: 6, producer: 7 },
94+
// The second resource's params read the first resource's value.
95+
{ consumer: 7, producer: 0 },
96+
];
97+
const resources = groupResources(nodes, edges, [], serialize);
98+
expect(resources.map((r) => [r.name, r.value, r.nodeIds])).toEqual([
99+
['resource 1', 'Ada', ['1', '2', '3', '4']],
100+
['resource 2', ['Ada post'], ['5', '6', '7', '8']],
101+
]);
102+
});
103+
73104
it('derives status from the graph when no instance holds the resource', () => {
74105
const nodes = [
75106
node('1', 'computed', 'Resource#trips.value', '(threw an error)'),

0 commit comments

Comments
 (0)