Skip to content

Commit 3f4cca9

Browse files
janechuCopilot
andcommitted
refactor: move observerMap/attributeMap to fast-element as FASTElementExtension factories
- Create packages/fast-element/src/extensions/observer-map.ts and attribute-map.ts as FASTElementExtension factory functions with ObserverMap/AttributeMap classes - Create packages/fast-element/src/extensions/schema.ts with Schema class and types - Create packages/fast-element/src/extensions/utilities.ts with observable proxy utilities (assignObservables, deepMerge, assignProxy, deepEqual, etc.) - Add sub-path exports for extensions in fast-element package.json - Add extensions parameter to FASTElementDefinition.compose() for synchronous execution after definition construction (critical for timing with TemplateElement) - Update FASTElement.define() to accept and forward extensions array - Remove ObserverMap, AttributeMap classes and proxy utilities from fast-html - Replace fast-html schema.ts with re-exports from fast-element - Update all fixture files to import deepMerge from fast-element - Update DESIGN.md, README.md, SCHEMA_OBSERVER_MAP.md, WRITING_FIXTURES.md - Regenerate API reports and website API docs - Add beachball change files for both packages Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 6a7c20b commit 3f4cca9

24 files changed

Lines changed: 2066 additions & 1652 deletions

change/@microsoft-fast-element-convert-observer-map-attribute-map.json renamed to change/@microsoft-fast-element-b9d26cf5-d4e3-43ad-ae88-056745023268.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"type": "minor",
3-
"comment": "Add observerMap() and attributeMap() FASTElementExtension factories; add extensions parameter to FASTElementDefinition.compose()",
3+
"comment": "refactor: move observerMap/attributeMap to fast-element as FASTElementExtension factories",
44
"packageName": "@microsoft/fast-element",
55
"email": "7559015+janechu@users.noreply.github.com",
66
"dependentChangeType": "none"
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: move observerMap/attributeMap to fast-element as FASTElementExtension factories",
4+
"packageName": "@microsoft/fast-html",
5+
"email": "7559015+janechu@users.noreply.github.com",
6+
"dependentChangeType": "none"
7+
}

change/@microsoft-fast-html-convert-observer-map-attribute-map.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

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

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,16 @@
44
55
```ts
66

7+
// Warning: (ae-forgotten-export) The symbol "CachedPathCommon" needs to be exported by the entry point index.d.ts
8+
//
9+
// @public (undocumented)
10+
export interface AccessCachedPath extends CachedPathCommon {
11+
// Warning: (ae-forgotten-export) The symbol "AccessCachedPathType" needs to be exported by the entry point index.d.ts
12+
//
13+
// (undocumented)
14+
type: AccessCachedPathType;
15+
}
16+
717
// @public
818
export interface Accessor {
919
getValue(source: any): any;
@@ -42,6 +52,12 @@ export interface Aspected {
4252
targetAspect: string;
4353
}
4454

55+
// @public
56+
export function assignObservables(schema: JSONSchema | JSONSchemaDefinition, rootSchema: JSONSchema, data: any, target: any, rootProperty: string): typeof Proxy;
57+
58+
// @public
59+
export function assignProxy(schema: JSONSchema | JSONSchemaDefinition, rootSchema: JSONSchema, target: any, rootProperty: string, object: any): typeof Proxy;
60+
4561
// @public
4662
export function attr(config?: DecoratorAttributeConfiguration): (target: {}, property: string) => void;
4763

@@ -77,6 +93,13 @@ export class AttributeDefinition implements Accessor {
7793
setValue(source: HTMLElement, newValue: any): void;
7894
}
7995

96+
// @public
97+
export class AttributeMap {
98+
constructor(classPrototype: any, schema: Schema, definition?: FASTElementDefinition, config?: AttributeMapConfig);
99+
// (undocumented)
100+
defineProperties(): void;
101+
}
102+
80103
// @public
81104
export function attributeMap(config?: AttributeMapConfig): FASTElementExtension;
82105

@@ -114,6 +137,12 @@ export interface BindingDirective {
114137
// @public
115138
export const booleanConverter: ValueConverter;
116139

140+
// @public (undocumented)
141+
export type CachedPath = DefaultCachedPath | RepeatCachedPath | AccessCachedPath | EventCachedPath;
142+
143+
// @public (undocumented)
144+
export type CachedPathMap = Map<string, Map<string, JSONSchema>>;
145+
117146
// @public
118147
export type Callable = typeof Function.prototype.call | {
119148
call(): void;
@@ -141,6 +170,14 @@ export class ChildrenDirective extends NodeObservationDirective<ChildrenDirectiv
141170
// @public
142171
export type ChildrenDirectiveOptions<T = any> = ChildListDirectiveOptions<T> | SubtreeDirectiveOptions<T>;
143172

173+
// @public (undocumented)
174+
export interface ChildrenMap {
175+
// (undocumented)
176+
attributeName: string;
177+
// (undocumented)
178+
customElementName: string;
179+
}
180+
144181
// @public
145182
export type Class<T, C = {}> = C & Constructable<T> & {
146183
readonly prototype: T;
@@ -248,9 +285,26 @@ export function customElement(nameOrDef: string | PartialFASTElementDefinition):
248285
// @public
249286
export type DecoratorAttributeConfiguration = Omit<AttributeConfiguration, "property">;
250287

288+
// @public
289+
export function deepEqual(obj1: any, obj2: any): boolean;
290+
291+
// @public
292+
export function deepMerge(target: any, source: any): boolean;
293+
294+
// @public (undocumented)
295+
export interface DefaultCachedPath extends CachedPathCommon {
296+
// Warning: (ae-forgotten-export) The symbol "DefaultCachedPathType" needs to be exported by the entry point index.d.ts
297+
//
298+
// (undocumented)
299+
type: DefaultCachedPathType;
300+
}
301+
251302
// @beta
252303
export const deferHydrationAttribute = "defer-hydration";
253304

305+
// @public (undocumented)
306+
export const defsPropertyName = "$defs";
307+
254308
// @public
255309
export interface Disposable {
256310
dispose(): void;
@@ -387,6 +441,14 @@ export interface ElementViewTemplate<TSource = any, TParent = any> {
387441
// @public
388442
export const emptyArray: readonly never[];
389443

444+
// @public (undocumented)
445+
export interface EventCachedPath extends CachedPathCommon {
446+
// Warning: (ae-forgotten-export) The symbol "EventCachedPathType" needs to be exported by the entry point index.d.ts
447+
//
448+
// (undocumented)
449+
type: EventCachedPathType;
450+
}
451+
390452
// @public
391453
export interface ExecutionContext<TParent = any> {
392454
readonly event: Event;
@@ -439,6 +501,16 @@ export interface ExpressionObserver<TSource = any, TReturn = any, TParent = any>
439501
// @public
440502
export const FAST: FASTGlobal;
441503

504+
// Warning: (ae-forgotten-export) The symbol "FastContextMetaData" needs to be exported by the entry point index.d.ts
505+
//
506+
// @public (undocumented)
507+
export const fastContextMetaData: FastContextMetaData;
508+
509+
// Warning: (ae-forgotten-export) The symbol "FastContextsMetaData" needs to be exported by the entry point index.d.ts
510+
//
511+
// @public (undocumented)
512+
export const fastContextsMetaData: FastContextsMetaData;
513+
442514
// @public
443515
export interface FASTElement extends HTMLElement {
444516
$emit(type: string, detail?: any, options?: Omit<CustomEventInit, "detail">): boolean | void;
@@ -502,6 +574,9 @@ export interface FASTGlobal {
502574
warn(code: number, values?: Record<string, any>): void;
503575
}
504576

577+
// @public
578+
export function findDef(schema: JSONSchema | JSONSchemaDefinition): string | null;
579+
505580
// @public
506581
export interface HostBehavior<TSource = any> {
507582
addedCallback?(controller: HostController<TSource>): void;
@@ -670,6 +745,29 @@ export function isHydratable<TSource = any, TParent = any>(template: ElementView
670745
// @beta (undocumented)
671746
export function isHydratable(template: ContentTemplate): template is HydratableContentTemplate;
672747

748+
// @public
749+
export function isPlainObject(value: any): value is Record<string, any>;
750+
751+
// Warning: (ae-forgotten-export) The symbol "JSONSchemaCommon" needs to be exported by the entry point index.d.ts
752+
//
753+
// @public (undocumented)
754+
export interface JSONSchema extends JSONSchemaCommon {
755+
// (undocumented)
756+
$defs?: Record<string, JSONSchemaDefinition>;
757+
// (undocumented)
758+
$id: string;
759+
// (undocumented)
760+
$schema: string;
761+
}
762+
763+
// @public (undocumented)
764+
export interface JSONSchemaDefinition extends JSONSchemaCommon {
765+
// (undocumented)
766+
$fast_context: string;
767+
// (undocumented)
768+
$fast_parent_contexts: Array<string>;
769+
}
770+
673771
// @public
674772
export interface LengthObserver extends Subscriber {
675773
length: number;
@@ -748,6 +846,13 @@ export interface ObservationRecord {
748846
propertySource: any;
749847
}
750848

849+
// @public
850+
export class ObserverMap {
851+
constructor(classPrototype: any, schema: Schema, config?: ObserverMapConfig);
852+
// (undocumented)
853+
defineProperties(): void;
854+
}
855+
751856
// @public
752857
export function observerMap(config?: ObserverMapConfig): FASTElementExtension;
753858

@@ -827,6 +932,9 @@ export class RefDirective extends StatelessAttachedAttributeDirective<string> {
827932
targetNodeId: string;
828933
}
829934

935+
// @public (undocumented)
936+
export const refPropertyName = "$ref";
937+
830938
// @public
831939
export function render<TSource = any, TItem = any, TParent = any>(value?: Expression<TSource, TItem> | Binding<TSource, TItem> | {}, template?: ContentTemplate | string | Expression<TSource, ContentTemplate | string | Node, TParent> | Binding<TSource, ContentTemplate | string | Node, TParent>): CaptureType<TSource, TParent>;
832940

@@ -866,6 +974,14 @@ export class RepeatBehavior<TSource = any> implements ViewBehavior, Subscriber {
866974
views: SyntheticView[];
867975
}
868976

977+
// @public (undocumented)
978+
export interface RepeatCachedPath extends CachedPathCommon {
979+
// Warning: (ae-forgotten-export) The symbol "RepeatCachedPathType" needs to be exported by the entry point index.d.ts
980+
//
981+
// (undocumented)
982+
type: RepeatCachedPathType;
983+
}
984+
869985
// @public
870986
export class RepeatDirective<TSource = any> implements HTMLDirective, ViewBehaviorFactory, BindingDirective {
871987
constructor(dataBinding: Binding<TSource>, templateBinding: Binding<TSource, SyntheticViewTemplate>, options: RepeatOptions);
@@ -886,6 +1002,16 @@ export interface RepeatOptions {
8861002
recycle?: boolean;
8871003
}
8881004

1005+
// @public
1006+
export class Schema {
1007+
constructor(name: string);
1008+
// Warning: (ae-forgotten-export) The symbol "RegisterPathConfig" needs to be exported by the entry point index.d.ts
1009+
addPath(config: RegisterPathConfig): void;
1010+
getRootProperties(): IterableIterator<string>;
1011+
getSchema(rootPropertyName: string): JSONSchema | null;
1012+
static jsonSchemaMap: CachedPathMap;
1013+
}
1014+
8891015
// @public
8901016
export interface ShadowRootOptions extends ShadowRootInit {
8911017
// @beta

packages/fast-element/package.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,22 @@
9090
"types": "./dist/dts/observation/observable.d.ts",
9191
"default": "./dist/esm/observation/observable.js"
9292
},
93+
"./extensions/observer-map.js": {
94+
"types": "./dist/dts/extensions/observer-map.d.ts",
95+
"default": "./dist/esm/extensions/observer-map.js"
96+
},
97+
"./extensions/attribute-map.js": {
98+
"types": "./dist/dts/extensions/attribute-map.d.ts",
99+
"default": "./dist/esm/extensions/attribute-map.js"
100+
},
101+
"./extensions/schema.js": {
102+
"types": "./dist/dts/extensions/schema.d.ts",
103+
"default": "./dist/esm/extensions/schema.js"
104+
},
105+
"./extensions/utilities.js": {
106+
"types": "./dist/dts/extensions/utilities.d.ts",
107+
"default": "./dist/esm/extensions/utilities.js"
108+
},
93109
"./package.json": "./package.json"
94110
},
95111
"unpkg": "dist/fast-element.min.js",

0 commit comments

Comments
 (0)