@microsoft/fast-element 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9167,6 +9167,37 @@
9167
9167
  "isProtected": false,
9168
9168
  "isAbstract": false
9169
9169
  },
9170
+ {
9171
+ "kind": "Property",
9172
+ "canonicalReference": "@microsoft/fast-element!FASTElementDefinition#lifecycleCallbacks:member",
9173
+ "docComment": "/**\n * Lifecycle callbacks for template events.\n */\n",
9174
+ "excerptTokens": [
9175
+ {
9176
+ "kind": "Content",
9177
+ "text": "readonly lifecycleCallbacks?: "
9178
+ },
9179
+ {
9180
+ "kind": "Reference",
9181
+ "text": "TemplateLifecycleCallbacks",
9182
+ "canonicalReference": "@microsoft/fast-element!TemplateLifecycleCallbacks:interface"
9183
+ },
9184
+ {
9185
+ "kind": "Content",
9186
+ "text": ";"
9187
+ }
9188
+ ],
9189
+ "isReadonly": true,
9190
+ "isOptional": true,
9191
+ "releaseTag": "Public",
9192
+ "name": "lifecycleCallbacks",
9193
+ "propertyTypeTokenRange": {
9194
+ "startIndex": 1,
9195
+ "endIndex": 2
9196
+ },
9197
+ "isStatic": false,
9198
+ "isProtected": false,
9199
+ "isAbstract": false
9200
+ },
9170
9201
  {
9171
9202
  "kind": "Property",
9172
9203
  "canonicalReference": "@microsoft/fast-element!FASTElementDefinition#name:member",
@@ -12336,6 +12367,60 @@
12336
12367
  "name": "HydratableElementController",
12337
12368
  "preserveMemberOrder": false,
12338
12369
  "members": [
12370
+ {
12371
+ "kind": "Method",
12372
+ "canonicalReference": "@microsoft/fast-element!HydratableElementController.config:member(1)",
12373
+ "docComment": "/**\n * Configure lifecycle callbacks for hydration events\n */\n",
12374
+ "excerptTokens": [
12375
+ {
12376
+ "kind": "Content",
12377
+ "text": "static config(callbacks: "
12378
+ },
12379
+ {
12380
+ "kind": "Reference",
12381
+ "text": "HydrationControllerCallbacks",
12382
+ "canonicalReference": "@microsoft/fast-element!HydrationControllerCallbacks:interface"
12383
+ },
12384
+ {
12385
+ "kind": "Content",
12386
+ "text": "): "
12387
+ },
12388
+ {
12389
+ "kind": "Content",
12390
+ "text": "typeof "
12391
+ },
12392
+ {
12393
+ "kind": "Reference",
12394
+ "text": "HydratableElementController",
12395
+ "canonicalReference": "@microsoft/fast-element!HydratableElementController:class"
12396
+ },
12397
+ {
12398
+ "kind": "Content",
12399
+ "text": ";"
12400
+ }
12401
+ ],
12402
+ "isStatic": true,
12403
+ "returnTypeTokenRange": {
12404
+ "startIndex": 3,
12405
+ "endIndex": 5
12406
+ },
12407
+ "releaseTag": "Beta",
12408
+ "isProtected": false,
12409
+ "overloadIndex": 1,
12410
+ "parameters": [
12411
+ {
12412
+ "parameterName": "callbacks",
12413
+ "parameterTypeTokenRange": {
12414
+ "startIndex": 1,
12415
+ "endIndex": 2
12416
+ },
12417
+ "isOptional": false
12418
+ }
12419
+ ],
12420
+ "isOptional": false,
12421
+ "isAbstract": false,
12422
+ "name": "config"
12423
+ },
12339
12424
  {
12340
12425
  "kind": "Method",
12341
12426
  "canonicalReference": "@microsoft/fast-element!HydratableElementController#connect:member(1)",
@@ -12962,6 +13047,142 @@
12962
13047
  },
12963
13048
  "implementsTokenRanges": []
12964
13049
  },
13050
+ {
13051
+ "kind": "Interface",
13052
+ "canonicalReference": "@microsoft/fast-element!HydrationControllerCallbacks:interface",
13053
+ "docComment": "/**\n * Lifecycle callbacks for element hydration events\n *\n * @public\n */\n",
13054
+ "excerptTokens": [
13055
+ {
13056
+ "kind": "Content",
13057
+ "text": "export interface HydrationControllerCallbacks "
13058
+ }
13059
+ ],
13060
+ "fileUrlPath": "dist/dts/components/element-controller.d.ts",
13061
+ "releaseTag": "Public",
13062
+ "name": "HydrationControllerCallbacks",
13063
+ "preserveMemberOrder": false,
13064
+ "members": [
13065
+ {
13066
+ "kind": "MethodSignature",
13067
+ "canonicalReference": "@microsoft/fast-element!HydrationControllerCallbacks#elementDidHydrate:member(1)",
13068
+ "docComment": "/**\n * Called after hydration has finished\n */\n",
13069
+ "excerptTokens": [
13070
+ {
13071
+ "kind": "Content",
13072
+ "text": "elementDidHydrate?(name: "
13073
+ },
13074
+ {
13075
+ "kind": "Content",
13076
+ "text": "string"
13077
+ },
13078
+ {
13079
+ "kind": "Content",
13080
+ "text": "): "
13081
+ },
13082
+ {
13083
+ "kind": "Content",
13084
+ "text": "void"
13085
+ },
13086
+ {
13087
+ "kind": "Content",
13088
+ "text": ";"
13089
+ }
13090
+ ],
13091
+ "isOptional": true,
13092
+ "returnTypeTokenRange": {
13093
+ "startIndex": 3,
13094
+ "endIndex": 4
13095
+ },
13096
+ "releaseTag": "Public",
13097
+ "overloadIndex": 1,
13098
+ "parameters": [
13099
+ {
13100
+ "parameterName": "name",
13101
+ "parameterTypeTokenRange": {
13102
+ "startIndex": 1,
13103
+ "endIndex": 2
13104
+ },
13105
+ "isOptional": false
13106
+ }
13107
+ ],
13108
+ "name": "elementDidHydrate"
13109
+ },
13110
+ {
13111
+ "kind": "MethodSignature",
13112
+ "canonicalReference": "@microsoft/fast-element!HydrationControllerCallbacks#elementWillHydrate:member(1)",
13113
+ "docComment": "/**\n * Called before hydration has started\n */\n",
13114
+ "excerptTokens": [
13115
+ {
13116
+ "kind": "Content",
13117
+ "text": "elementWillHydrate?(name: "
13118
+ },
13119
+ {
13120
+ "kind": "Content",
13121
+ "text": "string"
13122
+ },
13123
+ {
13124
+ "kind": "Content",
13125
+ "text": "): "
13126
+ },
13127
+ {
13128
+ "kind": "Content",
13129
+ "text": "void"
13130
+ },
13131
+ {
13132
+ "kind": "Content",
13133
+ "text": ";"
13134
+ }
13135
+ ],
13136
+ "isOptional": true,
13137
+ "returnTypeTokenRange": {
13138
+ "startIndex": 3,
13139
+ "endIndex": 4
13140
+ },
13141
+ "releaseTag": "Public",
13142
+ "overloadIndex": 1,
13143
+ "parameters": [
13144
+ {
13145
+ "parameterName": "name",
13146
+ "parameterTypeTokenRange": {
13147
+ "startIndex": 1,
13148
+ "endIndex": 2
13149
+ },
13150
+ "isOptional": false
13151
+ }
13152
+ ],
13153
+ "name": "elementWillHydrate"
13154
+ },
13155
+ {
13156
+ "kind": "MethodSignature",
13157
+ "canonicalReference": "@microsoft/fast-element!HydrationControllerCallbacks#hydrationComplete:member(1)",
13158
+ "docComment": "/**\n * Called after all elements have completed hydration\n */\n",
13159
+ "excerptTokens": [
13160
+ {
13161
+ "kind": "Content",
13162
+ "text": "hydrationComplete?(): "
13163
+ },
13164
+ {
13165
+ "kind": "Content",
13166
+ "text": "void"
13167
+ },
13168
+ {
13169
+ "kind": "Content",
13170
+ "text": ";"
13171
+ }
13172
+ ],
13173
+ "isOptional": true,
13174
+ "returnTypeTokenRange": {
13175
+ "startIndex": 1,
13176
+ "endIndex": 2
13177
+ },
13178
+ "releaseTag": "Public",
13179
+ "overloadIndex": 1,
13180
+ "parameters": [],
13181
+ "name": "hydrationComplete"
13182
+ }
13183
+ ],
13184
+ "extendsTokenRanges": []
13185
+ },
12965
13186
  {
12966
13187
  "kind": "Class",
12967
13188
  "canonicalReference": "@microsoft/fast-element!InlineTemplateDirective:class",
@@ -14973,6 +15194,34 @@
14973
15194
  "endIndex": 2
14974
15195
  }
14975
15196
  },
15197
+ {
15198
+ "kind": "PropertySignature",
15199
+ "canonicalReference": "@microsoft/fast-element!PartialFASTElementDefinition#lifecycleCallbacks:member",
15200
+ "docComment": "/**\n * Lifecycle callbacks for template events.\n */\n",
15201
+ "excerptTokens": [
15202
+ {
15203
+ "kind": "Content",
15204
+ "text": "readonly lifecycleCallbacks?: "
15205
+ },
15206
+ {
15207
+ "kind": "Reference",
15208
+ "text": "TemplateLifecycleCallbacks",
15209
+ "canonicalReference": "@microsoft/fast-element!TemplateLifecycleCallbacks:interface"
15210
+ },
15211
+ {
15212
+ "kind": "Content",
15213
+ "text": ";"
15214
+ }
15215
+ ],
15216
+ "isReadonly": true,
15217
+ "isOptional": true,
15218
+ "releaseTag": "Public",
15219
+ "name": "lifecycleCallbacks",
15220
+ "propertyTypeTokenRange": {
15221
+ "startIndex": 1,
15222
+ "endIndex": 2
15223
+ }
15224
+ },
14976
15225
  {
14977
15226
  "kind": "PropertySignature",
14978
15227
  "canonicalReference": "@microsoft/fast-element!PartialFASTElementDefinition#name:member",
@@ -20790,10 +21039,118 @@
20790
21039
  ],
20791
21040
  "extendsTokenRanges": []
20792
21041
  },
21042
+ {
21043
+ "kind": "Interface",
21044
+ "canonicalReference": "@microsoft/fast-element!TemplateLifecycleCallbacks:interface",
21045
+ "docComment": "/**\n * Lifecycle callbacks for template events.\n *\n * @public\n */\n",
21046
+ "excerptTokens": [
21047
+ {
21048
+ "kind": "Content",
21049
+ "text": "export interface TemplateLifecycleCallbacks "
21050
+ }
21051
+ ],
21052
+ "fileUrlPath": "dist/dts/components/fast-definitions.d.ts",
21053
+ "releaseTag": "Public",
21054
+ "name": "TemplateLifecycleCallbacks",
21055
+ "preserveMemberOrder": false,
21056
+ "members": [
21057
+ {
21058
+ "kind": "MethodSignature",
21059
+ "canonicalReference": "@microsoft/fast-element!TemplateLifecycleCallbacks#elementDidDefine:member(1)",
21060
+ "docComment": "/**\n * Called after the custom element has been defined\n */\n",
21061
+ "excerptTokens": [
21062
+ {
21063
+ "kind": "Content",
21064
+ "text": "elementDidDefine?(name: "
21065
+ },
21066
+ {
21067
+ "kind": "Content",
21068
+ "text": "string"
21069
+ },
21070
+ {
21071
+ "kind": "Content",
21072
+ "text": "): "
21073
+ },
21074
+ {
21075
+ "kind": "Content",
21076
+ "text": "void"
21077
+ },
21078
+ {
21079
+ "kind": "Content",
21080
+ "text": ";"
21081
+ }
21082
+ ],
21083
+ "isOptional": true,
21084
+ "returnTypeTokenRange": {
21085
+ "startIndex": 3,
21086
+ "endIndex": 4
21087
+ },
21088
+ "releaseTag": "Public",
21089
+ "overloadIndex": 1,
21090
+ "parameters": [
21091
+ {
21092
+ "parameterName": "name",
21093
+ "parameterTypeTokenRange": {
21094
+ "startIndex": 1,
21095
+ "endIndex": 2
21096
+ },
21097
+ "isOptional": false
21098
+ }
21099
+ ],
21100
+ "name": "elementDidDefine"
21101
+ },
21102
+ {
21103
+ "kind": "MethodSignature",
21104
+ "canonicalReference": "@microsoft/fast-element!TemplateLifecycleCallbacks#templateDidUpdate:member(1)",
21105
+ "docComment": "/**\n * Called after the template has been assigned to the definition\n */\n",
21106
+ "excerptTokens": [
21107
+ {
21108
+ "kind": "Content",
21109
+ "text": "templateDidUpdate?(name: "
21110
+ },
21111
+ {
21112
+ "kind": "Content",
21113
+ "text": "string"
21114
+ },
21115
+ {
21116
+ "kind": "Content",
21117
+ "text": "): "
21118
+ },
21119
+ {
21120
+ "kind": "Content",
21121
+ "text": "void"
21122
+ },
21123
+ {
21124
+ "kind": "Content",
21125
+ "text": ";"
21126
+ }
21127
+ ],
21128
+ "isOptional": true,
21129
+ "returnTypeTokenRange": {
21130
+ "startIndex": 3,
21131
+ "endIndex": 4
21132
+ },
21133
+ "releaseTag": "Public",
21134
+ "overloadIndex": 1,
21135
+ "parameters": [
21136
+ {
21137
+ "parameterName": "name",
21138
+ "parameterTypeTokenRange": {
21139
+ "startIndex": 1,
21140
+ "endIndex": 2
21141
+ },
21142
+ "isOptional": false
21143
+ }
21144
+ ],
21145
+ "name": "templateDidUpdate"
21146
+ }
21147
+ ],
21148
+ "extendsTokenRanges": []
21149
+ },
20793
21150
  {
20794
21151
  "kind": "TypeAlias",
20795
21152
  "canonicalReference": "@microsoft/fast-element!TemplateOptions:type",
20796
- "docComment": "/**\n * Template options.\n *\n * @alpha\n */\n",
21153
+ "docComment": "/**\n * Type for the `TemplateOptions` const enum.\n *\n * @alpha\n */\n",
20797
21154
  "excerptTokens": [
20798
21155
  {
20799
21156
  "kind": "Content",
@@ -20801,7 +21158,25 @@
20801
21158
  },
20802
21159
  {
20803
21160
  "kind": "Content",
20804
- "text": "\"defer-and-hydrate\""
21161
+ "text": "(typeof "
21162
+ },
21163
+ {
21164
+ "kind": "Reference",
21165
+ "text": "TemplateOptions",
21166
+ "canonicalReference": "@microsoft/fast-element!TemplateOptions:var"
21167
+ },
21168
+ {
21169
+ "kind": "Content",
21170
+ "text": ")[keyof typeof "
21171
+ },
21172
+ {
21173
+ "kind": "Reference",
21174
+ "text": "TemplateOptions",
21175
+ "canonicalReference": "@microsoft/fast-element!TemplateOptions:var"
21176
+ },
21177
+ {
21178
+ "kind": "Content",
21179
+ "text": "]"
20805
21180
  },
20806
21181
  {
20807
21182
  "kind": "Content",
@@ -20812,6 +21187,29 @@
20812
21187
  "releaseTag": "Alpha",
20813
21188
  "name": "TemplateOptions",
20814
21189
  "typeTokenRange": {
21190
+ "startIndex": 1,
21191
+ "endIndex": 6
21192
+ }
21193
+ },
21194
+ {
21195
+ "kind": "Variable",
21196
+ "canonicalReference": "@microsoft/fast-element!TemplateOptions:var",
21197
+ "docComment": "/**\n * Values for the `templateOptions` property.\n *\n * @alpha\n */\n",
21198
+ "excerptTokens": [
21199
+ {
21200
+ "kind": "Content",
21201
+ "text": "TemplateOptions: "
21202
+ },
21203
+ {
21204
+ "kind": "Content",
21205
+ "text": "{\n readonly deferAndHydrate: \"defer-and-hydrate\";\n}"
21206
+ }
21207
+ ],
21208
+ "fileUrlPath": "dist/dts/components/fast-definitions.d.ts",
21209
+ "isReadonly": true,
21210
+ "releaseTag": "Alpha",
21211
+ "name": "TemplateOptions",
21212
+ "variableTypeTokenRange": {
20815
21213
  "startIndex": 1,
20816
21214
  "endIndex": 2
20817
21215
  }
@@ -3128,7 +3128,7 @@ class HydrationView extends DefaultExecutionContext {
3128
3128
  fragment.appendChild(end);
3129
3129
  }
3130
3130
  bind(source, context = this) {
3131
- var _b, _c;
3131
+ var _b;
3132
3132
  if (this.hydrationStage !== HydrationStage.hydrated) {
3133
3133
  this._hydrationStage = HydrationStage.hydrating;
3134
3134
  }
@@ -3172,7 +3172,28 @@ class HydrationView extends DefaultExecutionContext {
3172
3172
  if (typeof templateString !== "string") {
3173
3173
  templateString = templateString.innerHTML;
3174
3174
  }
3175
- throw new HydrationBindingError(`HydrationView was unable to successfully target bindings inside "${(_c = ((_b = this.firstChild) === null || _b === void 0 ? void 0 : _b.getRootNode()).host) === null || _c === void 0 ? void 0 : _c.nodeName}".`, factory, createRangeForNodes(this.firstChild, this.lastChild).cloneContents(), templateString);
3175
+ const hostElement = ((_b = this.firstChild) === null || _b === void 0 ? void 0 : _b.getRootNode())
3176
+ .host;
3177
+ const hostName = (hostElement === null || hostElement === void 0 ? void 0 : hostElement.nodeName) || "unknown";
3178
+ const factoryInfo = factory;
3179
+ // Build detailed error message
3180
+ const details = [
3181
+ `HydrationView was unable to successfully target bindings inside "<${hostName.toLowerCase()}>".`,
3182
+ `\nMismatch Details:`,
3183
+ ` - Expected target node ID: "${factory.targetNodeId}"`,
3184
+ ` - Available target IDs: [${Object.keys(this.targets).join(", ") || "none"}]`,
3185
+ ];
3186
+ if (factory.targetTagName) {
3187
+ details.push(` - Expected tag name: "${factory.targetTagName}"`);
3188
+ }
3189
+ if (factoryInfo.sourceAspect) {
3190
+ details.push(` - Source aspect: "${factoryInfo.sourceAspect}"`);
3191
+ }
3192
+ if (factoryInfo.aspectType !== undefined) {
3193
+ details.push(` - Aspect type: ${factoryInfo.aspectType}`);
3194
+ }
3195
+ details.push(`\nThis usually means:`, ` 1. The server-rendered HTML doesn't match the client template`, ` 2. The hydration markers are missing or corrupted`, ` 3. The DOM structure was modified before hydration`, `\nTemplate: ${templateString.slice(0, 200)}${templateString.length > 200 ? "..." : ""}`);
3196
+ throw new HydrationBindingError(details.join("\n"), factory, createRangeForNodes(this.firstChild, this.lastChild).cloneContents(), templateString);
3176
3197
  }
3177
3198
  }
3178
3199
  }
@@ -4756,6 +4777,13 @@ const fastElementBaseTypes = new Set();
4756
4777
  * @internal
4757
4778
  */
4758
4779
  const fastElementRegistry = FAST.getById(KernelServiceId.elementRegistry, () => createTypeRegistry());
4780
+ /**
4781
+ * Values for the `templateOptions` property.
4782
+ * @alpha
4783
+ */
4784
+ const TemplateOptions = {
4785
+ deferAndHydrate: "defer-and-hydrate",
4786
+ };
4759
4787
  /**
4760
4788
  * Defines metadata for a FASTElement.
4761
4789
  * @public
@@ -4819,10 +4847,12 @@ class FASTElementDefinition {
4819
4847
  * This operation is idempotent per registry.
4820
4848
  */
4821
4849
  define(registry = this.registry) {
4850
+ var _b, _c;
4822
4851
  const type = this.type;
4823
4852
  if (!registry.get(this.name)) {
4824
4853
  this.platformDefined = true;
4825
4854
  registry.define(this.name, type, this.elementOptions);
4855
+ (_c = (_b = this.lifecycleCallbacks) === null || _b === void 0 ? void 0 : _b.elementDidDefine) === null || _c === void 0 ? void 0 : _c.call(_b, this.name);
4826
4856
  }
4827
4857
  return this;
4828
4858
  }
@@ -4863,15 +4893,13 @@ class FASTElementDefinition {
4863
4893
  }, nameOrDef));
4864
4894
  }
4865
4895
  const definition = new FASTElementDefinition(type, nameOrDef);
4866
- Promise.all([
4867
- new Promise(resolve => {
4868
- Observable.getNotifier(definition).subscribe({
4869
- handleChange: () => resolve(),
4870
- }, "template");
4871
- }),
4872
- ]).then(() => {
4873
- resolve(definition);
4874
- });
4896
+ Observable.getNotifier(definition).subscribe({
4897
+ handleChange: () => {
4898
+ var _b, _c;
4899
+ (_c = (_b = definition.lifecycleCallbacks) === null || _b === void 0 ? void 0 : _b.templateDidUpdate) === null || _c === void 0 ? void 0 : _c.call(_b, definition.name);
4900
+ resolve(definition);
4901
+ },
4902
+ }, "template");
4875
4903
  });
4876
4904
  }
4877
4905
  }
@@ -4899,9 +4927,7 @@ FASTElementDefinition.registerAsync = (name) => __awaiter(void 0, void 0, void 0
4899
4927
  if (FASTElementDefinition.isRegistered[name]) {
4900
4928
  resolve(FASTElementDefinition.isRegistered[name]);
4901
4929
  }
4902
- Observable.getNotifier(FASTElementDefinition.isRegistered).subscribe({
4903
- handleChange: () => resolve(FASTElementDefinition.isRegistered[name]),
4904
- }, name);
4930
+ Observable.getNotifier(FASTElementDefinition.isRegistered).subscribe({ handleChange: () => resolve(FASTElementDefinition.isRegistered[name]) }, name);
4905
4931
  });
4906
4932
  });
4907
4933
  Observable.defineProperty(FASTElementDefinition.prototype, "template");
@@ -5997,24 +6023,39 @@ const needsHydrationAttribute = "needs-hydration";
5997
6023
  * @beta
5998
6024
  */
5999
6025
  class HydratableElementController extends ElementController {
6026
+ /**
6027
+ * Configure lifecycle callbacks for hydration events
6028
+ */
6029
+ static config(callbacks) {
6030
+ HydratableElementController.lifecycleCallbacks = callbacks;
6031
+ return this;
6032
+ }
6000
6033
  static hydrationObserverHandler(records) {
6001
6034
  for (const record of records) {
6002
6035
  HydratableElementController.hydrationObserver.unobserve(record.target);
6003
6036
  record.target.$fastController.connect();
6004
6037
  }
6005
6038
  }
6039
+ /**
6040
+ * Checks if all elements have completed hydration and dispatches event if complete
6041
+ */
6042
+ static checkHydrationComplete() {
6043
+ var _a, _b;
6044
+ if (!document.querySelector(`[${needsHydrationAttribute}]`)) {
6045
+ (_b = (_a = HydratableElementController.lifecycleCallbacks) === null || _a === void 0 ? void 0 : _a.hydrationComplete) === null || _b === void 0 ? void 0 : _b.call(_a);
6046
+ }
6047
+ }
6006
6048
  static forCustomElement(element, override) {
6007
6049
  const definition = FASTElementDefinition.getForInstance(element);
6008
- if (definition !== undefined &&
6009
- definition.templateOptions === "defer-and-hydrate" &&
6050
+ if ((definition === null || definition === void 0 ? void 0 : definition.templateOptions) === TemplateOptions.deferAndHydrate &&
6010
6051
  !definition.template) {
6011
- element.setAttribute(deferHydrationAttribute, "");
6012
- element.setAttribute(needsHydrationAttribute, "");
6052
+ element.toggleAttribute(deferHydrationAttribute, true);
6053
+ element.toggleAttribute(needsHydrationAttribute, true);
6013
6054
  }
6014
6055
  return super.forCustomElement(element, override);
6015
6056
  }
6016
6057
  connect() {
6017
- var _a, _b;
6058
+ var _a, _b, _c, _d, _e, _f;
6018
6059
  // Initialize needsHydration on first connect
6019
6060
  if (this.needsHydration === undefined) {
6020
6061
  this.needsHydration =
@@ -6039,11 +6080,13 @@ class HydratableElementController extends ElementController {
6039
6080
  if (this.stage !== 3 /* Stages.disconnected */) {
6040
6081
  return;
6041
6082
  }
6083
+ // Callback: Before hydration has started
6084
+ (_b = (_a = HydratableElementController.lifecycleCallbacks) === null || _a === void 0 ? void 0 : _a.elementWillHydrate) === null || _b === void 0 ? void 0 : _b.call(_a, this.definition.name);
6042
6085
  this.stage = 0 /* Stages.connecting */;
6043
6086
  this.bindObservables();
6044
6087
  this.connectBehaviors();
6045
6088
  const element = this.source;
6046
- const host = (_a = getShadowRoot(element)) !== null && _a !== void 0 ? _a : element;
6089
+ const host = (_c = getShadowRoot(element)) !== null && _c !== void 0 ? _c : element;
6047
6090
  if (this.template) {
6048
6091
  if (isHydratable(this.template)) {
6049
6092
  let firstChild = host.firstChild;
@@ -6060,7 +6103,7 @@ class HydratableElementController extends ElementController {
6060
6103
  }
6061
6104
  }
6062
6105
  this.view = this.template.hydrate(firstChild, lastChild, element);
6063
- (_b = this.view) === null || _b === void 0 ? void 0 : _b.bind(this.source);
6106
+ (_d = this.view) === null || _d === void 0 ? void 0 : _d.bind(this.source);
6064
6107
  }
6065
6108
  else {
6066
6109
  this.renderTemplate(this.template);
@@ -6071,6 +6114,10 @@ class HydratableElementController extends ElementController {
6071
6114
  this.source.removeAttribute(needsHydrationAttribute);
6072
6115
  this.needsInitialization = this.needsHydration = false;
6073
6116
  Observable.notify(this, isConnectedPropertyName);
6117
+ // Callback: After hydration has finished
6118
+ (_f = (_e = HydratableElementController.lifecycleCallbacks) === null || _e === void 0 ? void 0 : _e.elementDidHydrate) === null || _f === void 0 ? void 0 : _f.call(_e, this.definition.name);
6119
+ // Check if hydration is complete after this element is hydrated
6120
+ HydratableElementController.checkHydrationComplete();
6074
6121
  }
6075
6122
  disconnect() {
6076
6123
  super.disconnect();
@@ -6113,21 +6160,11 @@ function compose(type, nameOrDef) {
6113
6160
  return FASTElementDefinition.compose(this, type);
6114
6161
  }
6115
6162
  function defineAsync(type, nameOrDef) {
6116
- if (isFunction(type)) {
6117
- return new Promise(resolve => {
6118
- FASTElementDefinition.composeAsync(type, nameOrDef).then(value => {
6119
- resolve(value);
6120
- });
6121
- }).then(value => {
6122
- return value.define().type;
6123
- });
6124
- }
6125
- return new Promise(resolve => {
6126
- FASTElementDefinition.composeAsync(this, type).then(value => {
6127
- resolve(value);
6128
- });
6129
- }).then(value => {
6130
- return value.define().type;
6163
+ return __awaiter(this, void 0, void 0, function* () {
6164
+ if (isFunction(type)) {
6165
+ return (yield FASTElementDefinition.composeAsync(type, nameOrDef)).define().type;
6166
+ }
6167
+ return (yield FASTElementDefinition.composeAsync(this, type)).define().type;
6131
6168
  });
6132
6169
  }
6133
6170
  function define(type, nameOrDef) {
@@ -6184,4 +6221,4 @@ function customElement(nameOrDef) {
6184
6221
 
6185
6222
  DOM.setPolicy(DOMPolicy.create());
6186
6223
 
6187
- export { ArrayObserver, AttributeConfiguration, AttributeDefinition, Binding, CSSBindingDirective, CSSDirective, ChildrenDirective, Compiler, DOM, DOMAspect, ElementController, ElementStyles, ExecutionContext, FAST, FASTElement, FASTElementDefinition, HTMLBindingDirective, HTMLDirective, HTMLView, HydratableElementController, HydrationBindingError, InlineTemplateDirective, Markup, NodeObservationDirective, Observable, Parser, PropertyChangeNotifier, RefDirective, RenderBehavior, RenderDirective, RepeatBehavior, RepeatDirective, SlottedDirective, Sort, SourceLifetime, Splice, SpliceStrategy, SpliceStrategySupport, StatelessAttachedAttributeDirective, SubscriberSet, Updates, ViewTemplate, attr, booleanConverter, children, css, cssDirective, customElement, elements, emptyArray, fastElementRegistry, html, htmlDirective, lengthOf, listener, normalizeBinding$1 as normalizeBinding, nullableBooleanConverter, nullableNumberConverter, observable, oneTime, oneWay, ref, render, repeat, slotted, sortedCount, volatile, when };
6224
+ export { ArrayObserver, AttributeConfiguration, AttributeDefinition, Binding, CSSBindingDirective, CSSDirective, ChildrenDirective, Compiler, DOM, DOMAspect, ElementController, ElementStyles, ExecutionContext, FAST, FASTElement, FASTElementDefinition, HTMLBindingDirective, HTMLDirective, HTMLView, HydratableElementController, HydrationBindingError, InlineTemplateDirective, Markup, NodeObservationDirective, Observable, Parser, PropertyChangeNotifier, RefDirective, RenderBehavior, RenderDirective, RepeatBehavior, RepeatDirective, SlottedDirective, Sort, SourceLifetime, Splice, SpliceStrategy, SpliceStrategySupport, StatelessAttachedAttributeDirective, SubscriberSet, TemplateOptions, Updates, ViewTemplate, attr, booleanConverter, children, css, cssDirective, customElement, elements, emptyArray, fastElementRegistry, html, htmlDirective, lengthOf, listener, normalizeBinding$1 as normalizeBinding, nullableBooleanConverter, nullableNumberConverter, observable, oneTime, oneWay, ref, render, repeat, slotted, sortedCount, volatile, when };