Skip to content

Commit 166a8b8

Browse files
janechuCopilot
andcommitted
fix: address PR review feedback
- enableHydration() now calls ensureDeclarativeRuntime() so html templates become hydratable (#1) - TemplateElement.config() enables hydration when per-element callbacks (elementWillHydrate/elementDidHydrate) are configured (#2) - ElementStyles lazily initializes DefaultStyleStrategy so styles.js subpath works standalone without element-controller (#3) - Disable dtsRollup in all subpath api-extractor configs (#4) - Re-export moved types (ElementStyles, HostBehavior, etc.) as type exports from root barrel (#5) - Add api-extractor configs for styles.js and arrays.js subpaths (#6) - Update 3.x docs to import css from styles.js subpath (#7) - Fix migration guide New Exports table with current APIs (#8) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent d6a0c3d commit 166a8b8

64 files changed

Lines changed: 3041 additions & 28 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/fast-element/SIZES.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Bundle sizes for `@microsoft/fast-element` exports.
44

55
| Export | Minified | Gzip | Brotli |
66
|--------|----------|------|--------|
7-
| CDN Rollup Bundle | 63.66 KB | 19.00 KB | 17.01 KB |
8-
| FASTElement | 22.83 KB | 7.19 KB | 6.49 KB |
7+
| CDN Rollup Bundle | 65.17 KB | 19.44 KB | 17.34 KB |
8+
| FASTElement | 23.71 KB | 7.37 KB | 6.63 KB |
99
| Updates | 473 B | 337 B | 287 B |
1010
| Observable | 6.70 KB | 2.49 KB | 2.22 KB |
1111
| observable | 6.74 KB | 2.50 KB | 2.24 KB |
@@ -17,7 +17,7 @@ Bundle sizes for `@microsoft/fast-element` exports.
1717
| when | 1.82 KB | 712 B | 568 B |
1818
| html | 25.92 KB | 8.50 KB | 7.61 KB |
1919
| repeat | 29.57 KB | 9.42 KB | 8.47 KB |
20-
| css | 1.55 KB | 731 B | 654 B |
21-
| ElementStyles | 788 B | 397 B | 332 B |
22-
| enableHydration | 24.27 KB | 7.59 KB | 6.86 KB |
20+
| css | 2.43 KB | 1.00 KB | 911 B |
21+
| ElementStyles | 1.65 KB | 729 B | 623 B |
22+
| enableHydration | 43.33 KB | 13.30 KB | 11.93 KB |
2323
| ArrayObserver | 12.51 KB | 4.45 KB | 4.01 KB |
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3+
"extends": "../../api-extractor.json",
4+
"mainEntryPointFilePath": "./dist/dts/arrays.d.ts",
5+
"dtsRollup": { "enabled": false },
6+
"apiReport": {
7+
"enabled": true,
8+
"reportFolder": "<projectFolder>/docs/arrays",
9+
"reportFileName": "api-report"
10+
},
11+
"docModel": {
12+
"enabled": true,
13+
"apiJsonFilePath": "<projectFolder>/dist/arrays/arrays.api.json"
14+
}
15+
}

packages/fast-element/api-extractor.context.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
33
"extends": "../../api-extractor.json",
44
"mainEntryPointFilePath": "./dist/dts/context.d.ts",
5+
"dtsRollup": { "enabled": false },
56
"apiReport": {
67
"enabled": true,
78
"reportFolder": "<projectFolder>/docs/context",

packages/fast-element/api-extractor.declarative.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
33
"extends": "../../api-extractor.json",
44
"mainEntryPointFilePath": "./dist/dts/declarative.d.ts",
5+
"dtsRollup": { "enabled": false },
56
"apiReport": {
67
"enabled": true,
78
"reportFolder": "<projectFolder>/docs/declarative",

packages/fast-element/api-extractor.di.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
33
"extends": "../../api-extractor.json",
44
"mainEntryPointFilePath": "./dist/dts/di/di.d.ts",
5+
"dtsRollup": { "enabled": false },
56
"apiReport": {
67
"enabled": true,
78
"reportFolder": "<projectFolder>/docs/di",

packages/fast-element/api-extractor.hydration.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
33
"extends": "../../api-extractor.json",
44
"mainEntryPointFilePath": "./dist/dts/hydration.d.ts",
5+
"dtsRollup": { "enabled": false },
56
"apiReport": {
67
"enabled": true,
78
"reportFolder": "<projectFolder>/docs/hydration",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3+
"extends": "../../api-extractor.json",
4+
"mainEntryPointFilePath": "./dist/dts/styles.d.ts",
5+
"dtsRollup": { "enabled": false },
6+
"apiReport": {
7+
"enabled": true,
8+
"reportFolder": "<projectFolder>/docs/styles",
9+
"reportFileName": "api-report"
10+
},
11+
"docModel": {
12+
"enabled": true,
13+
"apiJsonFilePath": "<projectFolder>/dist/styles/styles.api.json"
14+
}
15+
}

packages/fast-element/docs/api-report.api.md

Lines changed: 74 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ export const Compiler: {
134134
aggregate(parts: (string | ViewBehaviorFactory)[], policy?: DOMPolicy): ViewBehaviorFactory;
135135
};
136136

137+
// @public
138+
export type ComposableStyles = string | ElementStyles | CSSStyleSheet;
139+
137140
// @public
138141
export type Constructable<T = {}> = {
139142
new (...args: any[]): T;
@@ -196,15 +199,12 @@ export interface DOMPolicy {
196199
// @public
197200
export type DOMSink = (target: Node, aspectName: string, value: any, ...args: any[]) => void;
198201

199-
// Warning: (ae-forgotten-export) The symbol "HostController" needs to be exported by the entry point index.d.ts
200-
//
201202
// @public
202203
export class ElementController<TElement extends HTMLElement = HTMLElement> implements Notifier, HostController<TElement> {
203204
// @internal
204205
constructor(element: TElement, definition: FASTElementDefinition);
205206
addBehavior(behavior: HostBehavior<TElement>): void;
206207
addStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
207-
// Warning: (ae-forgotten-export) The symbol "HostBehavior" needs to be exported by the entry point index.d.ts
208208
protected behaviors: Map<HostBehavior<TElement>, number> | null;
209209
protected bindObservables(): void;
210210
protected captureBoundObservables(): void;
@@ -223,7 +223,6 @@ export class ElementController<TElement extends HTMLElement = HTMLElement> imple
223223
get isConnected(): boolean;
224224
readonly isHydrated: Promise<boolean>;
225225
readonly isPrerendered: Promise<boolean>;
226-
// Warning: (ae-forgotten-export) The symbol "ElementStyles" needs to be exported by the entry point index.d.ts
227226
get mainStyles(): ElementStyles | null;
228227
set mainStyles(value: ElementStyles | null);
229228
protected needsInitialization: boolean;
@@ -263,6 +262,25 @@ export const elements: (selector?: string) => ElementsFilter;
263262
// @public
264263
export type ElementsFilter = (value: Node, index?: number, array?: Node[]) => boolean;
265264

265+
// @public
266+
export class ElementStyles {
267+
constructor(styles: ReadonlyArray<ComposableStyles>);
268+
// @internal (undocumented)
269+
addStylesTo(target: StyleTarget): void;
270+
// @internal (undocumented)
271+
isAttachedTo(target: StyleTarget): boolean;
272+
static normalize(styles: ComposableStyles | ComposableStyles[] | undefined): ElementStyles | undefined;
273+
// @internal (undocumented)
274+
removeStylesFrom(target: StyleTarget): void;
275+
static setDefaultStrategy(Strategy: ConstructibleStyleStrategy): void;
276+
get strategy(): StyleStrategy;
277+
// (undocumented)
278+
readonly styles: ReadonlyArray<ComposableStyles>;
279+
static readonly supportsAdoptedStyleSheets: boolean;
280+
// Warning: (ae-forgotten-export) The symbol "ConstructibleStyleStrategy" needs to be exported by the entry point index.d.ts
281+
withStrategy(Strategy: ConstructibleStyleStrategy): this;
282+
}
283+
266284
// @public
267285
export interface ElementView<TSource = any, TParent = any> extends View<TSource, TParent> {
268286
appendTo(node: Node): void;
@@ -393,6 +411,24 @@ export const fastElementRegistry: TypeRegistry<FASTElementDefinition>;
393411
// @public
394412
export type FASTElementTemplateResolver<TType extends Constructable<HTMLElement> = Constructable<HTMLElement>> = (definition: FASTElementDefinition<TType>) => ElementViewTemplate<InstanceType<TType>> | Promise<ElementViewTemplate<InstanceType<TType>>>;
395413

414+
// @public
415+
export interface HostBehavior<TSource = any> {
416+
addedCallback?(controller: HostController<TSource>): void;
417+
connectedCallback?(controller: HostController<TSource>): void;
418+
disconnectedCallback?(controller: HostController<TSource>): void;
419+
removedCallback?(controller: HostController<TSource>): void;
420+
}
421+
422+
// @public
423+
export interface HostController<TSource = any> extends ExpressionController<TSource> {
424+
addBehavior(behavior: HostBehavior<TSource>): void;
425+
addStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
426+
readonly isConnected: boolean;
427+
mainStyles: ElementStyles | null;
428+
removeBehavior(behavior: HostBehavior<TSource>, force?: boolean): void;
429+
removeStyles(styles: ElementStyles | HTMLStyleElement | null | undefined): void;
430+
}
431+
396432
// @public
397433
export const html: HTMLTemplateTag;
398434

@@ -638,7 +674,6 @@ export interface PartialFASTElementDefinition<TType extends Constructable<HTMLEl
638674
readonly name: string;
639675
readonly registry?: CustomElementRegistry;
640676
readonly shadowOptions?: Partial<ShadowRootOptions> | null;
641-
// Warning: (ae-forgotten-export) The symbol "ComposableStyles" needs to be exported by the entry point index.d.ts
642677
readonly styles?: ComposableStyles | ComposableStyles[];
643678
readonly template?: ElementViewTemplate<InstanceType<TType>> | FASTElementTemplateResolver<TType>;
644679
}
@@ -699,8 +734,6 @@ export function repeat<TSource = any, TArray extends ReadonlyArray<any> = Readon
699734
export class RepeatBehavior<TSource = any> implements ViewBehavior, Subscriber {
700735
constructor(directive: RepeatDirective);
701736
bind(controller: ViewController): void;
702-
// Warning: (ae-forgotten-export) The symbol "Splice" needs to be exported by the entry point index.d.ts
703-
// Warning: (ae-forgotten-export) The symbol "Sort" needs to be exported by the entry point index.d.ts
704737
handleChange(source: any, args: Splice[] | Sort[] | ExpressionObserver): void;
705738
unbind(): void;
706739
// @internal (undocumented)
@@ -749,6 +782,13 @@ export class SlottedDirective extends NodeObservationDirective<SlottedDirectiveO
749782
export interface SlottedDirectiveOptions<T = any> extends NodeBehaviorOptions<T>, AssignedNodesOptions {
750783
}
751784

785+
// @public
786+
export class Sort {
787+
constructor(sorted?: number[] | undefined);
788+
// (undocumented)
789+
sorted?: number[] | undefined;
790+
}
791+
752792
// @public
753793
export const SourceLifetime: Readonly<{
754794
readonly unknown: undefined;
@@ -758,6 +798,19 @@ export const SourceLifetime: Readonly<{
758798
// @public
759799
export type SourceLifetime = (typeof SourceLifetime)[keyof typeof SourceLifetime];
760800

801+
// @public
802+
export class Splice {
803+
constructor(index: number, removed: any[], addedCount: number);
804+
// (undocumented)
805+
addedCount: number;
806+
adjustTo(array: any[]): this;
807+
// (undocumented)
808+
index: number;
809+
// (undocumented)
810+
removed: any[];
811+
reset?: boolean;
812+
}
813+
761814
// @public
762815
export const enum Stages {
763816
connected = 1,
@@ -776,6 +829,20 @@ export abstract class StatelessAttachedAttributeDirective<TOptions> implements H
776829
protected options: TOptions;
777830
}
778831

832+
// @public
833+
export interface StyleStrategy {
834+
addStylesTo(target: StyleTarget): void;
835+
removeStylesFrom(target: StyleTarget): void;
836+
}
837+
838+
// @public
839+
export interface StyleTarget extends Pick<Node, "getRootNode"> {
840+
adoptedStyleSheets?: CSSStyleSheet[];
841+
append(styles: HTMLStyleElement): void;
842+
querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
843+
removeChild(styles: HTMLStyleElement): void;
844+
}
845+
779846
// @public
780847
export interface Subscriber {
781848
handleChange(subject: any, args: any): void;
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
## API Report File for "@microsoft/fast-element"
2+
3+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
4+
5+
```ts
6+
7+
// Warning: (ae-forgotten-export) The symbol "SubscriberSet" needs to be exported by the entry point arrays.d.ts
8+
//
9+
// @public
10+
export interface ArrayObserver extends SubscriberSet {
11+
addSort(sort: Sort): void;
12+
addSplice(splice: Splice): void;
13+
flush(): void;
14+
readonly lengthObserver: LengthObserver;
15+
reset(oldCollection: any[] | undefined): void;
16+
readonly sortObserver: SortObserver;
17+
strategy: SpliceStrategy | null;
18+
}
19+
20+
// @public
21+
export const ArrayObserver: Readonly<{
22+
readonly sorted: 0;
23+
readonly enable: () => void;
24+
}>;
25+
26+
// Warning: (ae-forgotten-export) The symbol "Subscriber" needs to be exported by the entry point arrays.d.ts
27+
//
28+
// @public
29+
export interface LengthObserver extends Subscriber {
30+
length: number;
31+
}
32+
33+
// @public
34+
export function lengthOf<T>(array: readonly T[]): number;
35+
36+
// @public
37+
export class Sort {
38+
constructor(sorted?: number[] | undefined);
39+
// (undocumented)
40+
sorted?: number[] | undefined;
41+
}
42+
43+
// @public
44+
export function sortedCount<T>(array: readonly T[]): number;
45+
46+
// @public
47+
export interface SortObserver extends Subscriber {
48+
sorted: number;
49+
}
50+
51+
// @public
52+
export class Splice {
53+
constructor(index: number, removed: any[], addedCount: number);
54+
// (undocumented)
55+
addedCount: number;
56+
adjustTo(array: any[]): this;
57+
// (undocumented)
58+
index: number;
59+
// (undocumented)
60+
removed: any[];
61+
reset?: boolean;
62+
}
63+
64+
// @public
65+
export interface SpliceStrategy {
66+
normalize(previous: unknown[] | undefined, current: unknown[], changes: Splice[] | undefined): readonly Splice[];
67+
pop(array: any[], observer: ArrayObserver, pop: typeof Array.prototype.pop, args: any[]): any;
68+
push(array: any[], observer: ArrayObserver, push: typeof Array.prototype.push, args: any[]): any;
69+
reverse(array: any[], observer: ArrayObserver, reverse: typeof Array.prototype.reverse, args: any[]): any;
70+
shift(array: any[], observer: ArrayObserver, shift: typeof Array.prototype.shift, args: any[]): any;
71+
sort(array: any[], observer: ArrayObserver, sort: typeof Array.prototype.sort, args: any[]): any[];
72+
splice(array: any[], observer: ArrayObserver, splice: typeof Array.prototype.splice, args: any[]): any;
73+
readonly support: SpliceStrategySupport;
74+
unshift(array: any[], observer: ArrayObserver, unshift: typeof Array.prototype.unshift, args: any[]): any[];
75+
}
76+
77+
// @public
78+
export const SpliceStrategy: Readonly<{
79+
readonly reset: Splice[];
80+
readonly setDefaultStrategy: (strategy: SpliceStrategy) => void;
81+
}>;
82+
83+
// @public
84+
export const SpliceStrategySupport: Readonly<{
85+
readonly reset: 1;
86+
readonly splice: 2;
87+
readonly optimized: 3;
88+
}>;
89+
90+
// @public
91+
export type SpliceStrategySupport = (typeof SpliceStrategySupport)[keyof typeof SpliceStrategySupport];
92+
93+
// (No @packageDocumentation comment for this package)
94+
95+
```

0 commit comments

Comments
 (0)