Skip to content

Commit 62ab9ad

Browse files
committed
4fa5d18 feat(bazel): support bundling .d.ts with code splitting (#60321)
1 parent b43d3b4 commit 62ab9ad

File tree

5 files changed

+90
-98
lines changed

5 files changed

+90
-98
lines changed

BUILD_INFO

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
Tue Mar 11 18:38:52 UTC 2025
2-
8be6e3888b0d918f945fe4937353ce3cc1ec7f77
1+
Tue Mar 11 20:12:40 UTC 2025
2+
4fa5d18e5a57be03979b73be03a3d280c6dc0cb5

fesm2022/elements.mjs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/**
2-
* @license Angular v20.0.0-next.1+sha-8be6e38
2+
* @license Angular v20.0.0-next.1+sha-4fa5d18
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/
66

7-
import { ComponentFactoryResolver, NgZone, ApplicationRef, ɵChangeDetectionScheduler, ɵisViewDirty, ɵmarkForRefresh, Injector, Version } from '@angular/core';
7+
import { ComponentFactoryResolver, NgZone, ApplicationRef, ɵChangeDetectionScheduler as _ChangeDetectionScheduler, ɵisViewDirty as _isViewDirty, ɵmarkForRefresh as _markForRefresh, Injector, Version } from '@angular/core';
88
import { ReplaySubject, merge, Observable } from 'rxjs';
99
import { switchMap } from 'rxjs/operators';
1010

@@ -72,6 +72,8 @@ function getComponentInputs(component, injector) {
7272
}
7373

7474
// NOTE: This is a (slightly improved) version of what is used in ngUpgrade's
75+
// `DowngradeComponentAdapter`.
76+
// TODO(gkalpak): Investigate if it makes sense to share the code.
7577
function extractProjectableNodes(host, ngContentSelectors) {
7678
const nodes = host.childNodes;
7779
const projectableNodes = ngContentSelectors.map(() => []);
@@ -163,7 +165,7 @@ class ComponentNgElementStrategy {
163165
this.inputMap = inputMap;
164166
this.ngZone = this.injector.get(NgZone);
165167
this.appRef = this.injector.get(ApplicationRef);
166-
this.cdScheduler = injector.get(ɵChangeDetectionScheduler);
168+
this.cdScheduler = injector.get(_ChangeDetectionScheduler);
167169
this.elementZone = typeof Zone === 'undefined' ? null : this.ngZone.run(() => Zone.current);
168170
}
169171
/**
@@ -228,12 +230,12 @@ class ComponentNgElementStrategy {
228230
this.runInZone(() => {
229231
this.componentRef.setInput(this.inputMap.get(property) ?? property, value);
230232
// `setInput` won't mark the view dirty if the input didn't change from its previous value.
231-
if (ɵisViewDirty(this.componentRef.hostView)) {
233+
if (_isViewDirty(this.componentRef.hostView)) {
232234
// `setInput` will have marked the view dirty already, but also mark it for refresh. This
233235
// guarantees the view will be checked even if the input is being set from within change
234236
// detection. This provides backwards compatibility, since we used to unconditionally
235237
// schedule change detection in addition to the current zone run.
236-
ɵmarkForRefresh(this.componentRef.changeDetectorRef);
238+
_markForRefresh(this.componentRef.changeDetectorRef);
237239
// Notifying the scheduler with `NotificationSource.CustomElement` causes a `tick()` to be
238240
// scheduled unconditionally, even if the scheduler is otherwise disabled.
239241
this.cdScheduler.notify(6 /* NotificationSource.CustomElement */);
@@ -408,7 +410,7 @@ function createCustomElement(component, config) {
408410
/**
409411
* @publicApi
410412
*/
411-
const VERSION = new Version('20.0.0-next.1+sha-8be6e38');
413+
const VERSION = new Version('20.0.0-next.1+sha-4fa5d18');
412414

413415
export { NgElement, VERSION, createCustomElement };
414416
//# sourceMappingURL=elements.mjs.map

fesm2022/elements.mjs.map

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

index.d.ts

Lines changed: 77 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,71 @@
11
/**
2-
* @license Angular v20.0.0-next.1+sha-8be6e38
2+
* @license Angular v20.0.0-next.1+sha-4fa5d18
33
* (c) 2010-2025 Google LLC. https://angular.io/
44
* License: MIT
55
*/
66

7-
8-
import { Injector } from '@angular/core';
9-
import { Observable } from 'rxjs';
10-
import { Subscription } from 'rxjs';
11-
import { Type } from '@angular/core';
12-
import { Version } from '@angular/core';
7+
import { Injector, Type, Version } from '@angular/core';
8+
import { Observable, Subscription } from 'rxjs';
139

1410
/**
15-
* @description Creates a custom element class based on an Angular component.
11+
* Interface for the events emitted through the NgElementStrategy.
1612
*
17-
* Builds a class that encapsulates the functionality of the provided component and
18-
* uses the configuration information to provide more context to the class.
19-
* Takes the component factory's inputs and outputs to convert them to the proper
20-
* custom element API and add hooks to input changes.
13+
* @publicApi
14+
*/
15+
interface NgElementStrategyEvent {
16+
name: string;
17+
value: any;
18+
}
19+
/**
20+
* Underlying strategy used by the NgElement to create/destroy the component and react to input
21+
* changes.
2122
*
22-
* The configuration's injector is the initial injector set on the class,
23-
* and used by default for each created instance.This behavior can be overridden with the
24-
* static property to affect all newly created instances, or as a constructor argument for
25-
* one-off creations.
23+
* @publicApi
24+
*/
25+
interface NgElementStrategy {
26+
events: Observable<NgElementStrategyEvent>;
27+
connect(element: HTMLElement): void;
28+
disconnect(): void;
29+
getInputValue(propName: string): any;
30+
setInputValue(propName: string, value: string, transform?: (value: any) => any): void;
31+
}
32+
/**
33+
* Factory used to create new strategies for each NgElement instance.
2634
*
27-
* @see [Angular Elements Overview](guide/elements "Turning Angular components into custom elements")
35+
* @publicApi
36+
*/
37+
interface NgElementStrategyFactory {
38+
/** Creates a new instance to be used for an NgElement. */
39+
create(injector: Injector): NgElementStrategy;
40+
}
41+
42+
/**
43+
* Prototype for a class constructor based on an Angular component
44+
* that can be used for custom element registration. Implemented and returned
45+
* by the {@link createCustomElement createCustomElement() function}.
2846
*
29-
* @param component The component to transform.
30-
* @param config A configuration that provides initialization information to the created class.
31-
* @returns The custom-element construction class, which can be registered with
32-
* a browser's `CustomElementRegistry`.
47+
* @see [Angular Elements Overview](guide/elements "Turning Angular components into custom elements")
3348
*
3449
* @publicApi
3550
*/
36-
export declare function createCustomElement<P>(component: Type<any>, config: NgElementConfig): NgElementConstructor<P>;
37-
51+
interface NgElementConstructor<P> {
52+
/**
53+
* An array of observed attribute names for the custom element,
54+
* derived by transforming input property names from the source component.
55+
*/
56+
readonly observedAttributes: string[];
57+
/**
58+
* Initializes a constructor instance.
59+
* @param injector If provided, overrides the configured injector.
60+
*/
61+
new (injector?: Injector): NgElement & WithProperties<P>;
62+
}
3863
/**
3964
* Implements the functionality needed for a custom element.
4065
*
4166
* @publicApi
4267
*/
43-
export declare abstract class NgElement extends HTMLElement {
68+
declare abstract class NgElement extends HTMLElement {
4469
/**
4570
* The strategy that controls how a component is transformed in a custom element.
4671
*/
@@ -69,15 +94,24 @@ export declare abstract class NgElement extends HTMLElement {
6994
*/
7095
abstract disconnectedCallback(): void;
7196
}
72-
97+
/**
98+
* Additional type information that can be added to the NgElement class,
99+
* for properties that are added based
100+
* on the inputs and methods of the underlying component.
101+
*
102+
* @publicApi
103+
*/
104+
type WithProperties<P> = {
105+
[property in keyof P]: P[property];
106+
};
73107
/**
74108
* A configuration that initializes an NgElementConstructor with the
75109
* dependencies and strategy it needs to transform a component into
76110
* a custom element class.
77111
*
78112
* @publicApi
79113
*/
80-
export declare interface NgElementConfig {
114+
interface NgElementConfig {
81115
/**
82116
* The injector to use for retrieving the component's factory.
83117
*/
@@ -88,77 +122,33 @@ export declare interface NgElementConfig {
88122
*/
89123
strategyFactory?: NgElementStrategyFactory;
90124
}
91-
92125
/**
93-
* Prototype for a class constructor based on an Angular component
94-
* that can be used for custom element registration. Implemented and returned
95-
* by the {@link createCustomElement createCustomElement() function}.
126+
* @description Creates a custom element class based on an Angular component.
96127
*
97-
* @see [Angular Elements Overview](guide/elements "Turning Angular components into custom elements")
128+
* Builds a class that encapsulates the functionality of the provided component and
129+
* uses the configuration information to provide more context to the class.
130+
* Takes the component factory's inputs and outputs to convert them to the proper
131+
* custom element API and add hooks to input changes.
98132
*
99-
* @publicApi
100-
*/
101-
export declare interface NgElementConstructor<P> {
102-
/**
103-
* An array of observed attribute names for the custom element,
104-
* derived by transforming input property names from the source component.
105-
*/
106-
readonly observedAttributes: string[];
107-
/**
108-
* Initializes a constructor instance.
109-
* @param injector If provided, overrides the configured injector.
110-
*/
111-
new (injector?: Injector): NgElement & WithProperties<P>;
112-
}
113-
114-
/**
115-
* Underlying strategy used by the NgElement to create/destroy the component and react to input
116-
* changes.
133+
* The configuration's injector is the initial injector set on the class,
134+
* and used by default for each created instance.This behavior can be overridden with the
135+
* static property to affect all newly created instances, or as a constructor argument for
136+
* one-off creations.
117137
*
118-
* @publicApi
119-
*/
120-
export declare interface NgElementStrategy {
121-
events: Observable<NgElementStrategyEvent>;
122-
connect(element: HTMLElement): void;
123-
disconnect(): void;
124-
getInputValue(propName: string): any;
125-
setInputValue(propName: string, value: string, transform?: (value: any) => any): void;
126-
}
127-
128-
/**
129-
* Interface for the events emitted through the NgElementStrategy.
138+
* @see [Angular Elements Overview](guide/elements "Turning Angular components into custom elements")
130139
*
131-
* @publicApi
132-
*/
133-
export declare interface NgElementStrategyEvent {
134-
name: string;
135-
value: any;
136-
}
137-
138-
/**
139-
* Factory used to create new strategies for each NgElement instance.
140+
* @param component The component to transform.
141+
* @param config A configuration that provides initialization information to the created class.
142+
* @returns The custom-element construction class, which can be registered with
143+
* a browser's `CustomElementRegistry`.
140144
*
141145
* @publicApi
142146
*/
143-
export declare interface NgElementStrategyFactory {
144-
/** Creates a new instance to be used for an NgElement. */
145-
create(injector: Injector): NgElementStrategy;
146-
}
147-
148-
/**
149-
* @publicApi
150-
*/
151-
export declare const VERSION: Version;
147+
declare function createCustomElement<P>(component: Type<any>, config: NgElementConfig): NgElementConstructor<P>;
152148

153149
/**
154-
* Additional type information that can be added to the NgElement class,
155-
* for properties that are added based
156-
* on the inputs and methods of the underlying component.
157-
*
158150
* @publicApi
159151
*/
160-
export declare type WithProperties<P> = {
161-
[property in keyof P]: P[property];
162-
};
152+
declare const VERSION: Version;
163153

164-
export { }
154+
export { NgElement, type NgElementConfig, type NgElementConstructor, type NgElementStrategy, type NgElementStrategyEvent, type NgElementStrategyFactory, VERSION, type WithProperties, createCustomElement };

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@angular/elements",
3-
"version": "20.0.0-next.1+sha-8be6e38",
3+
"version": "20.0.0-next.1+sha-4fa5d18",
44
"description": "Angular - library for using Angular Components as Custom Elements",
55
"author": "angular",
66
"license": "MIT",
@@ -11,7 +11,7 @@
1111
"tslib": "^2.3.0"
1212
},
1313
"peerDependencies": {
14-
"@angular/core": "20.0.0-next.1+sha-8be6e38",
14+
"@angular/core": "20.0.0-next.1+sha-4fa5d18",
1515
"rxjs": "^6.5.3 || ^7.4.0"
1616
},
1717
"repository": {

0 commit comments

Comments
 (0)