Skip to content

Commit cb3684e

Browse files
authored
chore(web-components): Upgrade Fluent Web Components to FAST Element v3 (microsoft#36351)
# Pull Request ## 📖 Description Upgrade the Fluent Web Components (`@fluentui/web-components`) and Chart Web Components (`@fluentui/chart-web-components`) from FAST Element v2 to v3. The bulk of this change migrates the async (SSR) component definitions away from the `@microsoft/fast-html` `RenderableFASTElement(...).defineAsync(...)` pattern to FAST Element v3's declarative API. Each `*.definition-async.ts` now exports a `declarativeDefinition` built from `declarativeTemplate()` and the `FluentDesignSystem` registry, and each `define-async.ts` registers it with the standard `Element.define(...)` call. This drops the `@microsoft/fast-html` runtime dependency entirely. Supporting changes: - Bump `@microsoft/fast-element` from `^2.0.0` to `^3.0.0` in both `web-components` and `chart-web-components`. - Fix timing bugs and race conditions surfaced by the v3 declarative hydration flow. This is a prerelease-level change for `@fluentui/web-components` and a patch for `@fluentui/chart-web-components`.
1 parent 7088c40 commit cb3684e

96 files changed

Lines changed: 405 additions & 334 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.

apps/vr-tests-web-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"html-react-parser": "4.0.0",
1919
"@fluentui/tokens": ">=1.0.0-alpha",
2020
"@fluentui/web-components": ">=3.0.0-alpha",
21-
"@microsoft/fast-element": "^2.0.0",
21+
"@microsoft/fast-element": "^3.0.0",
2222
"tslib": "^2.1.0"
2323
}
2424
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "chore: upgrade to FAST Element v3",
4+
"packageName": "@fluentui/chart-web-components",
5+
"email": "863023+radium-v@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "refactor: migrate async definitions to fast-element v3 declarative API",
4+
"packageName": "@fluentui/web-components",
5+
"email": "863023+radium-v@users.noreply.github.com",
6+
"dependentChangeType": "patch"
7+
}

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,9 @@
7272
"@microsoft/api-extractor": "7.51.0",
7373
"@microsoft/api-extractor-model": "7.31.2",
7474
"@microsoft/eslint-plugin-sdl": "1.0.1",
75-
"@microsoft/fast-build": "0.7.0",
76-
"@microsoft/fast-element": "2.10.4",
77-
"@microsoft/fast-html": "1.0.0-alpha.54",
78-
"@microsoft/fast-test-harness": "0.3.1",
75+
"@microsoft/fast-build": "0.9.0",
76+
"@microsoft/fast-element": "3.0.0",
77+
"@microsoft/fast-test-harness": "0.4.0",
7978
"@microsoft/focusgroup-polyfill": "1.5.0",
8079
"@microsoft/load-themed-styles": "1.10.26",
8180
"@microsoft/loader-load-themed-styles": "2.0.17",

packages/charts/chart-web-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
"tslib": "^2.1.0"
7979
},
8080
"peerDependencies": {
81-
"@microsoft/fast-element": "^2.0.0"
81+
"@microsoft/fast-element": "^3.0.0"
8282
},
8383
"beachball": {
8484
"disallowedChangeTypes": [

packages/charts/chart-web-components/src/utils/chart-helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export const jsonConverter: ValueConverter = {
77
return JSON.stringify(value);
88
},
99
fromView(value: string): any {
10-
return JSON.parse(value);
10+
return typeof value === 'string' ? JSON.parse(value) : value;
1111
},
1212
};
1313

packages/web-components/docs/web-components.api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,8 @@ export class BaseField extends FASTElement {
731731
// (undocumented)
732732
setValidationStates(): void;
733733
// @internal
734+
protected get slottedInputObserver(): MutationObserver;
735+
// @internal
734736
slottedInputs: SlottableInput[];
735737
// @internal
736738
slottedInputsChanged(prev: SlottableInput[] | undefined, next: SlottableInput[] | undefined): void;

packages/web-components/package.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"./*/define.js": "./dist/esm/*/define.js",
4949
"./*/define-async.js": "./dist/esm/*/define-async.js",
5050
"./*/definition.js": "./dist/esm/*/*.definition.js",
51+
"./*/definition-async.js": "./dist/esm/*/*.definition-async.js",
5152
"./*/options.js": "./dist/esm/*/*.options.js",
5253
"./*/styles.js": "./dist/esm/*/*.styles.js",
5354
"./*/styles.css": "./dist/esm/*/*.styles.css",
@@ -109,18 +110,12 @@
109110
"rollup-plugin-fast-tagged-templates": "^1.0.2"
110111
},
111112
"dependencies": {
112-
"@fluentui/tokens": "1.0.0-alpha.23",
113+
"@fluentui/tokens": "^1.0.0-alpha.23",
113114
"tslib": "^2.1.0"
114115
},
115116
"peerDependencies": {
116-
"@microsoft/fast-element": "^2.0.0",
117-
"@microsoft/fast-html": "^1.0.0-alpha.53",
118-
"@microsoft/focusgroup-polyfill": "^1.4.1"
119-
},
120-
"peerDependenciesMeta": {
121-
"@microsoft/fast-html": {
122-
"optional": true
123-
}
117+
"@microsoft/fast-element": "^3.0.0",
118+
"@microsoft/focusgroup-polyfill": "^1.5.0"
124119
},
125120
"beachball": {
126121
"disallowedChangeTypes": [
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
import type { PartialFASTElementDefinition } from '@microsoft/fast-element';
1+
import { declarativeTemplate, type PartialFASTElementDefinition } from '@microsoft/fast-element/declarative.js';
2+
import { FluentDesignSystem } from '../fluent-design-system.js';
23
import { tagName } from './accordion-item.options.js';
34

45
/**
5-
* The async definition configuration for the fluent-accordion-item element.
6+
* The async definition configuration for the `<fluent-accordion-item>` element.
67
*
78
* @public
89
* @remarks
910
* This is used in server-side rendering (SSR) scenarios where the template
1011
* is provided as a deferred option to be hydrated later.
1112
*/
12-
export const definition: PartialFASTElementDefinition = {
13+
export const declarativeDefinition: PartialFASTElementDefinition = {
1314
name: tagName,
14-
templateOptions: 'defer-and-hydrate',
15+
registry: FluentDesignSystem.registry,
16+
template: declarativeTemplate(),
1517
};
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { RenderableFASTElement } from '@microsoft/fast-html';
2-
import { definition } from './accordion-item.definition-async.js';
1+
import { declarativeDefinition } from './accordion-item.definition-async.js';
32
import { AccordionItem } from './accordion-item.js';
43

5-
RenderableFASTElement(AccordionItem).defineAsync(definition);
4+
AccordionItem.define(declarativeDefinition);

0 commit comments

Comments
 (0)