@microsoft/fast-element 2.10.4 → 3.0.0-rc.1

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.
Files changed (349) hide show
  1. package/ARCHITECTURE_HTML_TAGGED_TEMPLATE_LITERAL.md +1 -1
  2. package/ARCHITECTURE_OVERVIEW.md +2 -2
  3. package/CHANGELOG.json +1 -1
  4. package/CHANGELOG.md +2 -2
  5. package/DECLARATIVE_DESIGN.md +806 -0
  6. package/DECLARATIVE_HTML.md +470 -0
  7. package/DECLARATIVE_MIGRATION.md +215 -0
  8. package/DECLARATIVE_RENDERING.md +530 -0
  9. package/DECLARATIVE_RENDERING_LIFECYCLE.md +288 -0
  10. package/DECLARATIVE_SCHEMA_OBSERVER_MAP.md +489 -0
  11. package/DESIGN.md +138 -33
  12. package/MIGRATION.md +387 -0
  13. package/README.md +208 -1
  14. package/SIZES.md +25 -0
  15. package/api-extractor.arrays.json +15 -0
  16. package/api-extractor.context.json +1 -0
  17. package/api-extractor.declarative.json +15 -0
  18. package/api-extractor.di.json +1 -0
  19. package/api-extractor.hydration.json +15 -0
  20. package/api-extractor.styles.json +15 -0
  21. package/dist/arrays/arrays.api.json +2621 -0
  22. package/dist/declarative/declarative.api.json +7844 -0
  23. package/dist/di/di.api.json +1 -1
  24. package/dist/dts/array-observer.d.ts +2 -0
  25. package/dist/dts/arrays.d.ts +2 -0
  26. package/dist/dts/attr.d.ts +1 -0
  27. package/dist/dts/binding/signal.d.ts +6 -6
  28. package/dist/dts/binding/two-way.d.ts +1 -0
  29. package/dist/dts/binding.d.ts +7 -0
  30. package/dist/dts/components/attributes.d.ts +2 -5
  31. package/dist/dts/components/definition-schema-transforms.d.ts +9 -0
  32. package/dist/dts/components/element-controller.d.ts +80 -114
  33. package/dist/dts/components/element-hydration.d.ts +1 -1
  34. package/dist/dts/components/enable-hydration.d.ts +34 -0
  35. package/dist/dts/components/fast-definitions.d.ts +91 -42
  36. package/dist/dts/components/fast-element.d.ts +5 -8
  37. package/dist/dts/components/hydration-tracker.d.ts +40 -0
  38. package/dist/dts/components/hydration.d.ts +18 -53
  39. package/dist/dts/components/schema.d.ts +205 -0
  40. package/dist/dts/context.d.ts +6 -6
  41. package/dist/dts/css.d.ts +3 -0
  42. package/dist/dts/debug.d.ts +5 -1
  43. package/dist/dts/declarative/attribute-map.d.ts +58 -0
  44. package/dist/dts/declarative/debug.d.ts +5 -0
  45. package/dist/dts/declarative/index.d.ts +13 -0
  46. package/dist/dts/declarative/interfaces.d.ts +9 -0
  47. package/dist/dts/declarative/observer-map-utilities.d.ts +58 -0
  48. package/dist/dts/declarative/observer-map.d.ts +89 -0
  49. package/dist/dts/declarative/runtime.d.ts +5 -0
  50. package/dist/dts/declarative/syntax.d.ts +21 -0
  51. package/dist/dts/declarative/template-bridge.d.ts +33 -0
  52. package/dist/dts/declarative/template-parser.d.ts +98 -0
  53. package/dist/dts/declarative/template.d.ts +9 -0
  54. package/dist/dts/declarative/utilities.d.ts +312 -0
  55. package/dist/dts/di/di.d.ts +1 -1
  56. package/dist/dts/directives/children.d.ts +2 -0
  57. package/dist/dts/directives/node-observation.d.ts +2 -0
  58. package/dist/dts/directives/ref.d.ts +2 -0
  59. package/dist/dts/directives/repeat.d.ts +4 -0
  60. package/dist/dts/directives/slotted.d.ts +2 -0
  61. package/dist/dts/directives/when.d.ts +3 -0
  62. package/dist/dts/dom-policy.d.ts +1 -1
  63. package/dist/dts/html.d.ts +5 -0
  64. package/dist/dts/hydration/runtime.d.ts +7 -0
  65. package/dist/dts/hydration/target-builder.d.ts +15 -12
  66. package/dist/dts/hydration.d.ts +14 -0
  67. package/dist/dts/index.d.ts +38 -42
  68. package/dist/dts/index.debug.d.ts +0 -1
  69. package/dist/dts/index.rollup.debug.d.ts +0 -1
  70. package/dist/dts/interfaces.d.ts +1 -49
  71. package/dist/dts/observable.d.ts +3 -6
  72. package/dist/dts/observation/arrays.d.ts +1 -1
  73. package/dist/dts/observation/update-queue.d.ts +1 -1
  74. package/dist/dts/platform.d.ts +25 -4
  75. package/dist/dts/render.d.ts +7 -0
  76. package/dist/dts/schema.d.ts +1 -0
  77. package/dist/dts/state/exports.d.ts +1 -1
  78. package/dist/dts/state/state.d.ts +2 -2
  79. package/dist/dts/styles/css-directive.d.ts +5 -12
  80. package/dist/dts/styles/css.d.ts +5 -7
  81. package/dist/dts/styles/element-styles.d.ts +0 -10
  82. package/dist/dts/styles.d.ts +6 -0
  83. package/dist/dts/templating/children.d.ts +1 -1
  84. package/dist/dts/templating/html-binding-directive.d.ts +4 -0
  85. package/dist/dts/templating/html-directive.d.ts +17 -0
  86. package/dist/dts/templating/hydration-view.d.ts +109 -0
  87. package/dist/dts/templating/ref.d.ts +1 -1
  88. package/dist/dts/templating/render.d.ts +1 -1
  89. package/dist/dts/templating/repeat.d.ts +2 -2
  90. package/dist/dts/templating/slotted.d.ts +1 -1
  91. package/dist/dts/templating/template.d.ts +17 -9
  92. package/dist/dts/templating/view.d.ts +25 -102
  93. package/dist/dts/templating/when.d.ts +1 -1
  94. package/dist/dts/templating.d.ts +10 -0
  95. package/dist/dts/testing/exports.d.ts +2 -2
  96. package/dist/dts/updates.d.ts +1 -0
  97. package/dist/dts/volatile.d.ts +2 -0
  98. package/dist/esm/array-observer.js +1 -0
  99. package/dist/esm/arrays.js +1 -0
  100. package/dist/esm/attr.js +1 -0
  101. package/dist/esm/binding/normalize.js +1 -1
  102. package/dist/esm/binding/signal.js +4 -4
  103. package/dist/esm/binding/two-way.js +2 -1
  104. package/dist/esm/binding.js +4 -0
  105. package/dist/esm/components/attributes.js +8 -5
  106. package/dist/esm/components/definition-schema-transforms.js +23 -0
  107. package/dist/esm/components/element-controller.js +200 -269
  108. package/dist/esm/components/element-hydration.js +1 -1
  109. package/dist/esm/components/enable-hydration.js +100 -0
  110. package/dist/esm/components/fast-definitions.js +211 -49
  111. package/dist/esm/components/fast-element.js +18 -27
  112. package/dist/esm/components/hydration-tracker.js +93 -0
  113. package/dist/esm/components/hydration.js +62 -144
  114. package/dist/esm/components/schema.js +253 -0
  115. package/dist/esm/context.js +6 -6
  116. package/dist/esm/css.js +3 -0
  117. package/dist/esm/debug.js +26 -26
  118. package/dist/esm/declarative/attribute-map.js +121 -0
  119. package/dist/esm/declarative/debug.js +5 -0
  120. package/dist/esm/declarative/index.js +3 -0
  121. package/dist/esm/declarative/interfaces.js +10 -0
  122. package/dist/esm/declarative/observer-map-utilities.js +562 -0
  123. package/dist/esm/declarative/observer-map.js +216 -0
  124. package/dist/esm/declarative/runtime.js +14 -0
  125. package/dist/esm/declarative/syntax.js +36 -0
  126. package/dist/esm/declarative/template-bridge.js +170 -0
  127. package/dist/esm/declarative/template-parser.js +306 -0
  128. package/dist/esm/declarative/template.js +142 -0
  129. package/dist/esm/declarative/utilities.js +834 -0
  130. package/dist/esm/di/di.js +6 -8
  131. package/dist/esm/directives/children.js +1 -0
  132. package/dist/esm/directives/node-observation.js +1 -0
  133. package/dist/esm/directives/ref.js +1 -0
  134. package/dist/esm/directives/repeat.js +1 -0
  135. package/dist/esm/directives/slotted.js +1 -0
  136. package/dist/esm/directives/when.js +1 -0
  137. package/dist/esm/dom-policy.js +2 -2
  138. package/dist/esm/dom.js +1 -1
  139. package/dist/esm/html.js +2 -0
  140. package/dist/esm/hydration/runtime.js +33 -0
  141. package/dist/esm/hydration/target-builder.js +97 -90
  142. package/dist/esm/hydration.js +4 -0
  143. package/dist/esm/index.debug.js +2 -1
  144. package/dist/esm/index.js +34 -29
  145. package/dist/esm/index.rollup.debug.js +3 -2
  146. package/dist/esm/index.rollup.js +1 -1
  147. package/dist/esm/interfaces.js +1 -45
  148. package/dist/esm/observable.js +1 -4
  149. package/dist/esm/observation/arrays.js +1 -1
  150. package/dist/esm/observation/observable.js +5 -5
  151. package/dist/esm/observation/update-queue.js +47 -58
  152. package/dist/esm/platform.js +31 -30
  153. package/dist/esm/render.js +1 -0
  154. package/dist/esm/schema.js +1 -0
  155. package/dist/esm/state/exports.js +1 -1
  156. package/dist/esm/styles/css-directive.js +1 -2
  157. package/dist/esm/styles/css.js +15 -56
  158. package/dist/esm/styles/element-styles.js +69 -15
  159. package/dist/esm/styles.js +2 -0
  160. package/dist/esm/templating/html-binding-directive.js +10 -8
  161. package/dist/esm/templating/hydration-view.js +235 -0
  162. package/dist/esm/templating/render.js +1 -1
  163. package/dist/esm/templating/repeat.js +36 -34
  164. package/dist/esm/templating/template.js +7 -7
  165. package/dist/esm/templating/view.js +24 -233
  166. package/dist/esm/templating.js +7 -0
  167. package/dist/esm/testing/exports.js +2 -2
  168. package/dist/esm/updates.js +1 -0
  169. package/dist/esm/volatile.js +1 -0
  170. package/dist/fast-element.api.json +9016 -6995
  171. package/dist/fast-element.d.ts +3557 -796
  172. package/dist/fast-element.debug.js +5088 -4437
  173. package/dist/fast-element.debug.min.js +2 -2
  174. package/dist/fast-element.js +5369 -4649
  175. package/dist/fast-element.min.js +2 -2
  176. package/dist/fast-element.untrimmed.d.ts +863 -475
  177. package/dist/hydration/hydration.api.json +5237 -0
  178. package/dist/styles/styles.api.json +2672 -0
  179. package/docs/api-report.api.md +343 -166
  180. package/docs/arrays/api-report.api.md +114 -0
  181. package/docs/declarative/api-report.api.md +397 -0
  182. package/docs/hydration/api-report.api.md +285 -0
  183. package/docs/styles/api-report.api.md +135 -0
  184. package/package.json +149 -41
  185. package/playwright.declarative.config.ts +26 -0
  186. package/playwright.declarative.webui.config.ts +20 -0
  187. package/scripts/declarative/build-fixtures-with-webui.js +135 -0
  188. package/scripts/declarative/build-fixtures.js +49 -0
  189. package/scripts/declarative/build-fixtures.utilities.js +101 -0
  190. package/scripts/measure-sizes.js +219 -0
  191. package/scripts/run-api-extractor.js +39 -20
  192. package/test/declarative/fixtures/README.md +72 -0
  193. package/test/declarative/fixtures/WRITING_FIXTURES.md +330 -0
  194. package/test/declarative/fixtures/bindings/README.md +12 -0
  195. package/test/declarative/fixtures/bindings/attribute/entry.html +13 -0
  196. package/test/declarative/fixtures/bindings/attribute/fast-build.config.json +6 -0
  197. package/test/declarative/fixtures/bindings/attribute/index.html +25 -0
  198. package/test/declarative/fixtures/bindings/attribute/main.ts +41 -0
  199. package/test/declarative/fixtures/bindings/attribute/state.json +8 -0
  200. package/test/declarative/fixtures/bindings/attribute/templates.html +11 -0
  201. package/test/declarative/fixtures/bindings/content/entry.html +12 -0
  202. package/test/declarative/fixtures/bindings/content/fast-build.config.json +6 -0
  203. package/test/declarative/fixtures/bindings/content/index.html +19 -0
  204. package/test/declarative/fixtures/bindings/content/main.ts +27 -0
  205. package/test/declarative/fixtures/bindings/content/state.json +4 -0
  206. package/test/declarative/fixtures/bindings/content/templates.html +6 -0
  207. package/test/declarative/fixtures/bindings/dot-syntax/entry.html +11 -0
  208. package/test/declarative/fixtures/bindings/dot-syntax/fast-build.config.json +6 -0
  209. package/test/declarative/fixtures/bindings/dot-syntax/index.html +47 -0
  210. package/test/declarative/fixtures/bindings/dot-syntax/main.ts +59 -0
  211. package/test/declarative/fixtures/bindings/dot-syntax/state.json +16 -0
  212. package/test/declarative/fixtures/bindings/dot-syntax/templates.html +17 -0
  213. package/test/declarative/fixtures/bindings/event/entry.html +11 -0
  214. package/test/declarative/fixtures/bindings/event/fast-build.config.json +6 -0
  215. package/test/declarative/fixtures/bindings/event/index.html +43 -0
  216. package/test/declarative/fixtures/bindings/event/main.ts +43 -0
  217. package/test/declarative/fixtures/bindings/event/state.json +3 -0
  218. package/test/declarative/fixtures/bindings/event/templates.html +18 -0
  219. package/test/declarative/fixtures/bindings/host/entry.html +40 -0
  220. package/test/declarative/fixtures/bindings/host/fast-build.config.json +6 -0
  221. package/test/declarative/fixtures/bindings/host/index.html +96 -0
  222. package/test/declarative/fixtures/bindings/host/main.ts +222 -0
  223. package/test/declarative/fixtures/bindings/host/state.json +9 -0
  224. package/test/declarative/fixtures/bindings/host/templates.html +55 -0
  225. package/test/declarative/fixtures/directives/README.md +12 -0
  226. package/test/declarative/fixtures/directives/children/entry.html +11 -0
  227. package/test/declarative/fixtures/directives/children/fast-build.config.json +6 -0
  228. package/test/declarative/fixtures/directives/children/index.html +15 -0
  229. package/test/declarative/fixtures/directives/children/main.ts +22 -0
  230. package/test/declarative/fixtures/directives/children/state.json +3 -0
  231. package/test/declarative/fixtures/directives/children/templates.html +3 -0
  232. package/test/declarative/fixtures/directives/ref/entry.html +11 -0
  233. package/test/declarative/fixtures/directives/ref/fast-build.config.json +6 -0
  234. package/test/declarative/fixtures/directives/ref/index.html +15 -0
  235. package/test/declarative/fixtures/directives/ref/main.ts +17 -0
  236. package/test/declarative/fixtures/directives/ref/state.json +1 -0
  237. package/test/declarative/fixtures/directives/ref/templates.html +3 -0
  238. package/test/declarative/fixtures/directives/repeat/entry.html +21 -0
  239. package/test/declarative/fixtures/directives/repeat/fast-build.config.json +6 -0
  240. package/test/declarative/fixtures/directives/repeat/index.html +133 -0
  241. package/test/declarative/fixtures/directives/repeat/main.ts +110 -0
  242. package/test/declarative/fixtures/directives/repeat/sprites.svg +8 -0
  243. package/test/declarative/fixtures/directives/repeat/state.json +10 -0
  244. package/test/declarative/fixtures/directives/repeat/templates.html +75 -0
  245. package/test/declarative/fixtures/directives/slotted/entry.html +17 -0
  246. package/test/declarative/fixtures/directives/slotted/fast-build.config.json +6 -0
  247. package/test/declarative/fixtures/directives/slotted/index.html +27 -0
  248. package/test/declarative/fixtures/directives/slotted/main.ts +29 -0
  249. package/test/declarative/fixtures/directives/slotted/state.json +1 -0
  250. package/test/declarative/fixtures/directives/slotted/templates.html +7 -0
  251. package/test/declarative/fixtures/directives/when/entry.html +51 -0
  252. package/test/declarative/fixtures/directives/when/fast-build.config.json +6 -0
  253. package/test/declarative/fixtures/directives/when/index.html +136 -0
  254. package/test/declarative/fixtures/directives/when/main.ts +172 -0
  255. package/test/declarative/fixtures/directives/when/state.json +12 -0
  256. package/test/declarative/fixtures/directives/when/templates.html +75 -0
  257. package/test/declarative/fixtures/ecosystem/README.md +11 -0
  258. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/entry.html +12 -0
  259. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/fast-build.config.json +6 -0
  260. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/index.html +20 -0
  261. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/main.ts +68 -0
  262. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/state.json +4 -0
  263. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/templates.html +7 -0
  264. package/test/declarative/fixtures/ecosystem/errors/entry.html +12 -0
  265. package/test/declarative/fixtures/ecosystem/errors/fast-build.config.json +6 -0
  266. package/test/declarative/fixtures/ecosystem/errors/index.html +20 -0
  267. package/test/declarative/fixtures/ecosystem/errors/main.ts +17 -0
  268. package/test/declarative/fixtures/ecosystem/errors/state.json +1 -0
  269. package/test/declarative/fixtures/ecosystem/errors/templates.html +7 -0
  270. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/entry.html +17 -0
  271. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/fast-build.config.json +6 -0
  272. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/index.html +56 -0
  273. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/main.ts +134 -0
  274. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/state.json +12 -0
  275. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/templates.html +34 -0
  276. package/test/declarative/fixtures/ecosystem/performance-metrics/entry.html +25 -0
  277. package/test/declarative/fixtures/ecosystem/performance-metrics/fast-build.config.json +6 -0
  278. package/test/declarative/fixtures/ecosystem/performance-metrics/fast-card.css +10 -0
  279. package/test/declarative/fixtures/ecosystem/performance-metrics/index.html +181 -0
  280. package/test/declarative/fixtures/ecosystem/performance-metrics/main.ts +58 -0
  281. package/test/declarative/fixtures/ecosystem/performance-metrics/state.json +6 -0
  282. package/test/declarative/fixtures/ecosystem/performance-metrics/templates.html +15 -0
  283. package/test/declarative/fixtures/extensions/README.md +15 -0
  284. package/test/declarative/fixtures/extensions/attribute-map/entry.html +14 -0
  285. package/test/declarative/fixtures/extensions/attribute-map/fast-build.config.json +6 -0
  286. package/test/declarative/fixtures/extensions/attribute-map/index.html +31 -0
  287. package/test/declarative/fixtures/extensions/attribute-map/main.ts +40 -0
  288. package/test/declarative/fixtures/extensions/attribute-map/state.json +4 -0
  289. package/test/declarative/fixtures/extensions/attribute-map/templates.html +14 -0
  290. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/entry.html +12 -0
  291. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/fast-build.config.json +7 -0
  292. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/index.html +25 -0
  293. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/main.ts +31 -0
  294. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/state.json +5 -0
  295. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/templates.html +11 -0
  296. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/entry.html +13 -0
  297. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/fast-build.config.json +7 -0
  298. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/index.html +23 -0
  299. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/main.ts +37 -0
  300. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/state.json +1 -0
  301. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/templates.html +9 -0
  302. package/test/declarative/fixtures/extensions/observer-map/entry.html +15 -0
  303. package/test/declarative/fixtures/extensions/observer-map/fast-build.config.json +6 -0
  304. package/test/declarative/fixtures/extensions/observer-map/index.html +442 -0
  305. package/test/declarative/fixtures/extensions/observer-map/main.ts +482 -0
  306. package/test/declarative/fixtures/extensions/observer-map/state.json +158 -0
  307. package/test/declarative/fixtures/extensions/observer-map/templates.html +172 -0
  308. package/test/declarative/fixtures/extensions/observer-map-config-object/entry.html +16 -0
  309. package/test/declarative/fixtures/extensions/observer-map-config-object/fast-build.config.json +6 -0
  310. package/test/declarative/fixtures/extensions/observer-map-config-object/index.html +27 -0
  311. package/test/declarative/fixtures/extensions/observer-map-config-object/main.ts +53 -0
  312. package/test/declarative/fixtures/extensions/observer-map-config-object/state.json +9 -0
  313. package/test/declarative/fixtures/extensions/observer-map-config-object/templates.html +12 -0
  314. package/test/declarative/fixtures/extensions/observer-map-deep-merge/README.md +98 -0
  315. package/test/declarative/fixtures/extensions/observer-map-deep-merge/entry.html +156 -0
  316. package/test/declarative/fixtures/extensions/observer-map-deep-merge/fast-build.config.json +6 -0
  317. package/test/declarative/fixtures/extensions/observer-map-deep-merge/index.html +376 -0
  318. package/test/declarative/fixtures/extensions/observer-map-deep-merge/main.ts +366 -0
  319. package/test/declarative/fixtures/extensions/observer-map-deep-merge/state.json +69 -0
  320. package/test/declarative/fixtures/extensions/observer-map-deep-merge/templates.html +91 -0
  321. package/test/declarative/fixtures/extensions/observer-map-properties/entry.html +14 -0
  322. package/test/declarative/fixtures/extensions/observer-map-properties/fast-build.config.json +6 -0
  323. package/test/declarative/fixtures/extensions/observer-map-properties/index.html +110 -0
  324. package/test/declarative/fixtures/extensions/observer-map-properties/main.ts +175 -0
  325. package/test/declarative/fixtures/extensions/observer-map-properties/state.json +29 -0
  326. package/test/declarative/fixtures/extensions/observer-map-properties/templates.html +55 -0
  327. package/test/declarative/fixtures/scenarios/README.md +7 -0
  328. package/test/declarative/fixtures/scenarios/nested-elements/entry.html +16 -0
  329. package/test/declarative/fixtures/scenarios/nested-elements/fast-build.config.json +6 -0
  330. package/test/declarative/fixtures/scenarios/nested-elements/index.html +126 -0
  331. package/test/declarative/fixtures/scenarios/nested-elements/main.ts +214 -0
  332. package/test/declarative/fixtures/scenarios/nested-elements/state.json +10 -0
  333. package/test/declarative/fixtures/scenarios/nested-elements/templates.html +54 -0
  334. package/test/declarative/index.html +12 -0
  335. package/test/declarative/vite.config.ts +55 -0
  336. package/test/declarative-main.ts +6 -0
  337. package/test/extension-subpaths-main.ts +9 -0
  338. package/test/main.ts +38 -33
  339. package/test/pure-declarative-main.ts +1 -0
  340. package/dist/dts/components/install-hydration.d.ts +0 -1
  341. package/dist/dts/pending-task.d.ts +0 -32
  342. package/dist/dts/polyfills.d.ts +0 -0
  343. package/dist/dts/styles/css-binding-directive.d.ts +0 -60
  344. package/dist/dts/templating/install-hydratable-view-templates.d.ts +0 -1
  345. package/dist/esm/components/install-hydration.js +0 -3
  346. package/dist/esm/pending-task.js +0 -28
  347. package/dist/esm/polyfills.js +0 -60
  348. package/dist/esm/styles/css-binding-directive.js +0 -76
  349. package/dist/esm/templating/install-hydratable-view-templates.js +0 -23
package/MIGRATION.md ADDED
@@ -0,0 +1,387 @@
1
+ # Migrating from previous versions
2
+
3
+ ## FASTGlobal version tracking (v2 → v3)
4
+
5
+ ### Removed API
6
+
7
+ | Removed | Replacement |
8
+ |---|---|
9
+ | `FAST.versions` | No replacement. Multiple FAST versions on the same page are unsupported in v3. |
10
+
11
+ ### Removed configuration
12
+
13
+ | Removed | Replacement |
14
+ |---|---|
15
+ | `fast-kernel="share"` / `fast-kernel="share-v2"` / `fast-kernel="isolate"` | No replacement. FAST now uses a single shared kernel contract, and multiple FAST versions on the same page are unsupported. |
16
+
17
+ ### Migration steps
18
+
19
+ 1. Remove any runtime checks that read `FAST.versions`.
20
+ 2. Fix duplicate FAST installs in your bundler or dependency graph instead of relying on version tracking at runtime.
21
+ 3. Remove any `fast-kernel` script attributes. They no longer affect FAST initialization.
22
+
23
+ ## Native `globalThis` requirement (v2 → v3)
24
+
25
+ ### Changed behavior
26
+
27
+ - **Native `globalThis` required**: `@microsoft/fast-element` no longer installs
28
+ a `globalThis` polyfill as a side effect. The package only keeps the
29
+ `requestIdleCallback` / `cancelIdleCallback` fallback for environments that
30
+ still lack those APIs.
31
+
32
+ ### Migration steps
33
+
34
+ 1. Verify that the browsers and JS runtimes you support provide native
35
+ `globalThis`.
36
+ 2. If you still target an older runtime without `globalThis`, load that
37
+ polyfill before importing `@microsoft/fast-element`.
38
+
39
+ ## Declarative HTML moved into fast-element (v3)
40
+
41
+ Declarative HTML APIs now ship from `@microsoft/fast-element` instead of the
42
+ removed `@microsoft/fast-html` package.
43
+
44
+ ### Import changes
45
+
46
+ | Before | After |
47
+ |---|---|
48
+ | `@microsoft/fast-html` | `@microsoft/fast-element` |
49
+ | `@microsoft/fast-html/utilities.js` | `@microsoft/fast-element` |
50
+
51
+ Core FAST Element helpers are available from the root package export:
52
+
53
+ | API | Import path |
54
+ |---|---|
55
+ | `Updates` | `@microsoft/fast-element` |
56
+ | `Observable`, `observable` | `@microsoft/fast-element` |
57
+ | `attr`, `AttributeDefinition`, converters, `ValueConverter` | `@microsoft/fast-element` |
58
+ | `Binding`, `oneWay`, `oneTime`, `listener` | `@microsoft/fast-element` |
59
+ | `DOM`, `DOMAspect`, `DOMPolicy` | `@microsoft/fast-element` |
60
+ | `Schema`, `schemaRegistry`, schema types | `@microsoft/fast-element` |
61
+ | `css` | `@microsoft/fast-element` |
62
+ | `html`, `ViewTemplate`, `HTMLView` | `@microsoft/fast-element` |
63
+ | `Compiler`, `HTMLDirective`, `htmlDirective`, templating/view types | `@microsoft/fast-element` |
64
+ | `render`, `RenderBehavior`, `RenderDirective` | `@microsoft/fast-element` |
65
+ | `enableHydration`, `HydrationTracker`, hydration types | `@microsoft/fast-element/hydration.js` |
66
+ | `ArrayObserver` | `@microsoft/fast-element` |
67
+ | `volatile` | `@microsoft/fast-element` |
68
+ | `children` | `@microsoft/fast-element` |
69
+ | `elements`, `NodeObservationDirective` | `@microsoft/fast-element` |
70
+ | `ref` | `@microsoft/fast-element` |
71
+ | `slotted` | `@microsoft/fast-element` |
72
+ | `when` | `@microsoft/fast-element` |
73
+ | `repeat` | `@microsoft/fast-element` |
74
+
75
+ ### Migration steps
76
+
77
+ 1. Update declarative runtime imports to
78
+ `@microsoft/fast-element/declarative.js`.
79
+ 2. Update declarative utility imports such as `deepMerge` to
80
+ `@microsoft/fast-element/declarative-utilities.js`.
81
+ 3. Keep importing FAST Element APIs such as `FASTElement`, `FAST`,
82
+ `ElementController`, definition/controller types, `attr`, `Schema`, and
83
+ `observable` from `@microsoft/fast-element`.
84
+ 4. Call `enableHydration()` from `@microsoft/fast-element/hydration.js` when
85
+ prerendered content should be hydrated.
86
+
87
+ ## `TemplateOptions` removal (v3)
88
+
89
+ ### Removed APIs
90
+
91
+ | Removed | Replacement |
92
+ |---|---|
93
+ | `TemplateOptions` | No replacement |
94
+ | `PartialFASTElementDefinition.templateOptions` | No replacement |
95
+ | `FASTElementDefinition.templateOptions` | No replacement |
96
+
97
+ ### Changed behavior
98
+
99
+ - `FASTElement.define()` no longer uses `templateOptions` to delay platform
100
+ definition or connection.
101
+ - Elements can still be defined before a template is attached; a later
102
+ `FASTElementDefinition.template` update notifies connected elements so they
103
+ can render or hydrate with the new template.
104
+
105
+ ### Migration steps
106
+
107
+ 1. Remove `templateOptions` from element definitions.
108
+ 2. Continue calling `define({ name })` when a definition needs to exist before
109
+ its template is attached.
110
+ 3. If a template is supplied later, assign `FASTElementDefinition.template` (or
111
+ use the declarative runtime that does so for you).
112
+
113
+
114
+ ## Declarative TemplateElement API removal (v3)
115
+
116
+ ### Removed APIs
117
+
118
+ | Removed | Replacement |
119
+ |---|---|
120
+ | `TemplateElement` public export | `declarativeTemplate()` on each FAST element definition |
121
+ | `TemplateElement.define({ name: "f-template" })` | No manual definition; `declarativeTemplate()` defines FAST's internal `<f-template>` publisher in the target registry |
122
+ | `TemplateElement.config(callbacks)` / `HydrationLifecycleCallbacks` | Per-element callbacks via `declarativeTemplate(callbacks)` and global callbacks via `enableHydration(options)` |
123
+ | `TemplateElement.options(...)`, `ElementOptions`, `ElementOptionsDictionary` | Define extensions: `attributeMap(...)` and `observerMap(...)` passed as the second argument to `define()` |
124
+ | `AttributeMap` / `ObserverMap` exports from the old declarative public surface | `attributeMap()` / `observerMap()` extension helpers and their config types |
125
+
126
+ ### Migration steps
127
+
128
+ 1. Replace manual `<f-template>` registration with `template: declarativeTemplate()`:
129
+
130
+ ```typescript
131
+ // Before
132
+ import { TemplateElement } from "@microsoft/fast-element";
133
+ TemplateElement.define({ name: "f-template" });
134
+
135
+ MyElement.define({ name: "my-element" });
136
+
137
+ // After
138
+ import { declarativeTemplate } from "@microsoft/fast-element/declarative.js";
139
+
140
+ MyElement.define({
141
+ name: "my-element",
142
+ template: declarativeTemplate(),
143
+ });
144
+ ```
145
+
146
+ 2. Replace `TemplateElement.options()` with definition extensions:
147
+
148
+ ```typescript
149
+ import { attributeMap } from "@microsoft/fast-element/attribute-map.js";
150
+ import { declarativeTemplate } from "@microsoft/fast-element/declarative.js";
151
+ import { observerMap } from "@microsoft/fast-element/observer-map.js";
152
+
153
+ MyElement.define(
154
+ {
155
+ name: "my-element",
156
+ template: declarativeTemplate(),
157
+ },
158
+ [attributeMap(), observerMap()],
159
+ );
160
+ ```
161
+
162
+ `attributeMap()` is imported from
163
+ `@microsoft/fast-element/attribute-map.js` and `observerMap()` from
164
+ `@microsoft/fast-element/observer-map.js` for declarative templates,
165
+ manually supplied schemas, or both. `FASTElementDefinition.schema` is optional;
166
+ `declarativeTemplate()` assigns it automatically, and `observerMap()` can
167
+ take a manual schema with `observerMap({ schema })`.
168
+
169
+ 3. Replace `TemplateElement.config()` with `declarativeTemplate(callbacks)` for
170
+ per-element callbacks and `enableHydration(options)` for global hydration
171
+ callbacks. Hydration is not installed by `declarative.js`; call
172
+ `enableHydration()` before elements connect when SSR content should hydrate.
173
+
174
+ ## Debug entrypoint explicit enablement (v3)
175
+
176
+ ### Import changes
177
+
178
+ | Before | After |
179
+ |---|---|
180
+ | `import "@microsoft/fast-element";` | `import { enableDebug } from "@microsoft/fast-element/debug.js"; enableDebug();` |
181
+
182
+ ### Migration steps
183
+
184
+ 1. Replace setup-only `debug.js` imports with an explicit `enableDebug()` call.
185
+ 2. Keep using the root package `development` export or debug rollup bundle when
186
+ you want debug behavior enabled automatically.
187
+
188
+ ## Declarative event handler `e` removal (v3)
189
+
190
+ ### Removed behavior
191
+
192
+ | Removed | Replacement |
193
+ |---|---|
194
+ | Bare `e` event arguments in declarative event handlers | `$e` |
195
+ | `TemplateParser.hasDeprecatedEventSyntax` | No replacement |
196
+
197
+ Only `$e` and `$c` are reserved event handler arguments in declarative
198
+ templates. Bare `e` now resolves like any other binding path on the current
199
+ data source.
200
+
201
+ ### Migration steps
202
+
203
+ 1. Replace declarative event bindings such as
204
+ `@click="{handleClick(e)}"` with `@click="{handleClick($e)}"`.
205
+ 2. Remove any `TemplateParser.hasDeprecatedEventSyntax` checks or warnings from
206
+ custom tooling.
207
+
208
+ ## Prerendered Content Optimization (v2 → v3)
209
+
210
+ ### Removed exports
211
+
212
+ | Export | Replacement |
213
+ |---|---|
214
+ | `HydratableElementController` | `ElementController` (prerendered path built in) |
215
+ | `HydrationControllerCallbacks` | `ElementHydrationCallbacks` via `ElementController.configHydration()` |
216
+ | `needsHydrationAttribute` | `ElementController.isPrerendered` |
217
+ | `deferHydrationAttribute` | Template-pending guard in `ElementController.connect()` |
218
+
219
+ ### Removed side-effect imports
220
+
221
+ | Import | Replacement |
222
+ |---|---|
223
+ | `@microsoft/fast-element/install-hydration.js` | No replacement needed — prerendered path is built into `ElementController` |
224
+
225
+ Use `enableHydration()` from `@microsoft/fast-element/hydration.js` when SSR
226
+ content should hydrate. The declarative entrypoint no longer installs hydration
227
+ automatically.
228
+
229
+ ### Changed behavior
230
+
231
+ - **`attributeChangedCallback` during upgrade**: When `isPrerendered` is true and the element has not yet connected, attribute change callbacks are suppressed. After connection, all attribute changes are processed normally.
232
+ - **Declarative template resolution**: `declarativeTemplate()` waits for the
233
+ matching `<f-template>` before `define()` completes, so connected elements
234
+ hydrate with a concrete template. No `defer-hydration` attribute is needed.
235
+ - **Binding evaluation with existing shadow root**: When an existing shadow root is detected, `attribute` and `booleanAttribute` bindings skip their initial DOM update. All other binding types (event, content, property, tokenList) run normally.
236
+
237
+ ### New APIs
238
+
239
+ - **`ElementController.isPrerendered`** (`Promise<boolean>`): Resolves to `true` after prerendered content has been hydrated, or `false` when the component is client-side rendered. Component authors can await this to know when the element is fully interactive.
240
+ - **`ViewController.isPrerendered`** (`Promise<boolean> | undefined`): Available to custom directives. Resolves to `true` when the view's content was prerendered, `false` otherwise.
241
+
242
+ ### Migration steps
243
+
244
+ 1. Remove `HydratableElementController.install()` calls.
245
+ 2. Remove `import "@microsoft/fast-element/install-hydration.js"` side-effect imports.
246
+ 3. Replace `element.$fastController instanceof HydratableElementController` checks with `await element.$fastController.isPrerendered`.
247
+ 4. Remove `defer-hydration` and `needs-hydration` attributes from server-rendered markup.
248
+
249
+ ## Hydration Marker Format (v3)
250
+
251
+ ### Changed format
252
+
253
+ The hydration markers embedded in SSR output have been simplified from verbose, index-embedded comment markers to compact, data-free sequential markers.
254
+
255
+ #### Comment markers
256
+
257
+ | Marker type | Old format | New format |
258
+ |---|---|---|
259
+ | Content binding start | `<!-- fe-b$$start$$<index>$$<scopeId>$$fe-b -->` | `<!--fe:b-->` |
260
+ | Content binding end | `<!-- fe-b$$end$$<index>$$<scopeId>$$fe-b -->` | `<!--fe:/b-->` |
261
+ | Repeat item start | `<!-- fe-repeat$$start$$<itemIndex>$$fe-repeat -->` | `<!--fe:r-->` |
262
+ | Repeat item end | `<!-- fe-repeat$$end$$<itemIndex>$$fe-repeat -->` | `<!--fe:/r-->` |
263
+ | Element boundary start | `<!-- fe-eb$$start$$<elementId>$$fe-eb -->` | `<!--fe:e-->` |
264
+ | Element boundary end | `<!-- fe-eb$$end$$<elementId>$$fe-eb -->` | `<!--fe:/e-->` |
265
+
266
+ #### Attribute binding markers
267
+
268
+ | Old format | New format |
269
+ |---|---|
270
+ | `data-fe-b="0 1 2"` (space-separated indices) | `data-fe="N"` (binding count) |
271
+ | `data-fe-b-0` (enumerated, one per factory) | `data-fe="N"` |
272
+ | `data-fe-c-0-3` (compact, start index + count) | `data-fe="N"` |
273
+
274
+ ### Removed APIs
275
+
276
+ | Export | Replacement |
277
+ |---|---|
278
+ | `HydrationMarkup.contentBindingStartMarker(index, scopeId)` | `HydrationMarkup.contentBindingStartMarker()` |
279
+ | `HydrationMarkup.contentBindingEndMarker(index, scopeId)` | `HydrationMarkup.contentBindingEndMarker()` |
280
+ | `HydrationMarkup.isContentBindingStartMarker(data)` | `HydrationMarkup.isContentBindingStartMarker(data)` (unchanged signature, new implementation) |
281
+ | `HydrationMarkup.isContentBindingEndMarker(data)` | `HydrationMarkup.isContentBindingEndMarker(data)` (unchanged signature, new implementation) |
282
+ | `HydrationMarkup.parseAttributeBinding(element)` | `HydrationMarkup.parseAttributeBindingCount(element)` |
283
+ | `HydrationMarkup.parseRepeatStartMarker(data)` | `HydrationMarkup.isRepeatViewStartMarker(data)` |
284
+ | `HydrationMarkup.parseRepeatEndMarker(data)` | `HydrationMarkup.isRepeatViewEndMarker(data)` |
285
+ | `HydrationMarkup.parseElementBoundaryStartMarker(content)` | `HydrationMarkup.isElementBoundaryStartMarker(node)` |
286
+ | `HydrationMarkup.parseElementBoundaryEndMarker(content)` | `HydrationMarkup.isElementBoundaryEndMarker(node)` |
287
+
288
+ ### Impact
289
+
290
+ This is a **breaking change** for SSR output format. Any system that produces or parses hydration markers must be updated to use the new format. The `@microsoft/fast-build` Rust crate and WASM binary have been updated accordingly.
291
+
292
+ - Marker parsing uses string equality checks (`data === "fe:b"`) instead of regex
293
+ - Start/end pairing uses balanced depth counting instead of embedded IDs
294
+ - The hydration walker uses a sequential factory pointer instead of index-based lookup
295
+ - SSR and client versions must match — mixing old SSR output with new client code (or vice versa) will fail
296
+
297
+ ## Async define/compose/register API (v3)
298
+
299
+ ### Removed APIs
300
+
301
+ | Removed | Replacement |
302
+ |---|---|
303
+ | `FASTElement.defineAsync()` | `FASTElement.define()` (now returns `Promise<TType>`) |
304
+ | `FASTElementDefinition.composeAsync()` | `FASTElementDefinition.compose()` (now returns `Promise<FASTElementDefinition>`) |
305
+ | `FASTElementDefinition.registerAsync()` | `FASTElementDefinition.register()` (same `Promise<Function>` return type) |
306
+
307
+ ### Changed behavior
308
+
309
+ - **`FASTElement.define()`** now returns `Promise<TType>`. When a concrete
310
+ template is provided at definition time, the Promise resolves immediately.
311
+ When `template: declarativeTemplate()` is used, the Promise resolves after
312
+ the matching `<f-template>` supplies the concrete template.
313
+ - **`FASTElement.compose()`** now returns `Promise<FASTElementDefinition>`. The Promise always resolves immediately.
314
+ - **`FASTElementDefinition.compose()`** now returns `Promise<FASTElementDefinition>`. The Promise always resolves immediately.
315
+ - **`@customElement` decorator** calls `define()` internally but does not return the Promise (fire-and-forget). For complete definitions with a template, the element is registered via a microtask.
316
+
317
+ ### Migration steps
318
+
319
+ 1. Replace `defineAsync()` calls with `define()`:
320
+
321
+ ```typescript
322
+ // Before
323
+ MyElement.defineAsync({
324
+ name: "my-element",
325
+ templateOptions: "defer-and-hydrate",
326
+ });
327
+
328
+ // After
329
+ await MyElement.define({
330
+ name: "my-element",
331
+ template: declarativeTemplate(),
332
+ });
333
+ ```
334
+
335
+ 2. Replace `composeAsync()` calls with `compose()` and add `await`:
336
+
337
+ ```typescript
338
+ // Before
339
+ const def = await FASTElementDefinition.composeAsync(MyElement, name);
340
+
341
+ // After
342
+ const def = await FASTElementDefinition.compose(MyElement, name);
343
+ ```
344
+
345
+ 3. Replace `registerAsync()` calls with `register()`:
346
+
347
+ ```typescript
348
+ // Before
349
+ const el = await FASTElementDefinition.registerAsync(name);
350
+
351
+ // After
352
+ const el = await FASTElementDefinition.register(name);
353
+ ```
354
+
355
+ 4. Add `await` to `compose()` calls that chain `.define()`:
356
+
357
+ ```typescript
358
+ // Before
359
+ FASTElementDefinition.compose(MyElement, options).define();
360
+
361
+ // After
362
+ (await FASTElementDefinition.compose(MyElement, options)).define();
363
+ ```
364
+
365
+ ## Dynamic stylesheet behaviors (v3)
366
+
367
+ ### Removed API
368
+
369
+ | Removed | Replacement |
370
+ |---|---|
371
+ | `ElementStyles.withBehaviors()` | Move the runtime condition into the element and call `this.$fastController.addStyles()` / `this.$fastController.removeStyles()` directly. |
372
+ | `ElementStyles.behaviors` | Move any runtime behavior out of the stylesheet and into the element or controller lifecycle. |
373
+ | CSS bindings in `css` (for example ``css`color: ${x => x.color}```) | Move the dynamic value into the element and update classes, attributes, or inline styles from element code. |
374
+ | `CSSDirective.createCSS(add)` | Update directives to implement `createCSS()` and return only static CSS content. |
375
+
376
+ ### Changed behavior
377
+
378
+ - `css` and `css.partial()` no longer compose `HostBehavior`s.
379
+ - `css` no longer accepts function or `Binding` interpolations.
380
+ - `ElementStyles` is now a fully static style container.
381
+
382
+ ### Migration steps
383
+
384
+ 1. Keep the conditional `ElementStyles` in a separate `css` value.
385
+ 2. Move the external listener or condition (for example `matchMedia()` or an app event subscription) into the element lifecycle.
386
+ 3. Call `this.$fastController.addStyles(styles)` when the condition is active and `this.$fastController.removeStyles(styles)` when it is inactive or during cleanup.
387
+ 4. If you previously interpolated bindings or behavior-producing directives into `css`, replace them with element state and standard DOM or controller updates.
package/README.md CHANGED
@@ -51,4 +51,211 @@ For simplicity, examples throughout the documentation will assume the library ha
51
51
 
52
52
  :::tip
53
53
  Looking for a quick guide on building components? Check out [our Cheat Sheet](../resources/cheat-sheet.md#building-components).
54
- :::
54
+ :::
55
+
56
+ ## Browser Requirements
57
+
58
+ FAST Element v3 assumes a modern runtime with native `globalThis`. The `FAST`
59
+ object is now a module-scoped export (not on `globalThis`). If you need to
60
+ support an environment without `globalThis`, load that polyfill before
61
+ importing `@microsoft/fast-element`.
62
+
63
+ ## Debug entrypoint
64
+
65
+ `@microsoft/fast-element/debug.js` exports `enableDebug()` instead of configuring
66
+ FAST at import time. The development root export and debug rollup bundle still
67
+ enable debug behavior automatically.
68
+
69
+ ```ts
70
+ import { enableDebug } from "@microsoft/fast-element/debug.js";
71
+
72
+ enableDebug();
73
+ ```
74
+
75
+ ## Export Sizes
76
+
77
+ Bundle sizes for each tree-shakeable export are tracked in [`SIZES.md`](./SIZES.md) and regenerated on every build. See the [Export Sizes](https://www.fast.design/docs/3.x/resources/export-sizes/) documentation page for the latest numbers.
78
+
79
+ ## Root Imports and Path Exports
80
+
81
+ The root `@microsoft/fast-element` entrypoint exports the FAST Element
82
+ implementation APIs, including the element base class, kernel, controller,
83
+ definition APIs, template APIs, binding helpers, directives, styles, and schema
84
+ helpers. Declarative, hydration, context, and dependency injection APIs are
85
+ available from their focused path exports.
86
+
87
+ Focused package path exports remain available for consumers that want to import
88
+ a narrower entrypoint directly. The website's
89
+ [Path Exports](https://www.fast.design/docs/3.x/advanced/path-exports/) page is
90
+ generated from `package.json` and lists each supported path.
91
+
92
+ ## Dynamic Style Application
93
+
94
+ Import `css`, `CSSTemplateTag`, `CSSValue`, and style APIs such as
95
+ `ElementStyles`, `CSSDirective`, `cssDirective`, `ComposableStyles`,
96
+ `HostBehavior`, `HostController`, `StyleStrategy`, and `StyleTarget` from
97
+ `@microsoft/fast-element`:
98
+
99
+ ```ts
100
+ import { ElementStyles, css } from "@microsoft/fast-element";
101
+ ```
102
+
103
+ When runtime state or external signals need to add or remove styles, create the
104
+ `ElementStyles` with `css` and toggle it through
105
+ `this.$fastController.addStyles()` / `this.$fastController.removeStyles()` from
106
+ the element lifecycle or change handlers.
107
+
108
+ `css` templates remain static style definitions. Runtime CSS bindings and
109
+ behavior-producing CSS directives are no longer supported; keep the condition on
110
+ the element and toggle a separate `ElementStyles` instance through the
111
+ controller when styles need to change.
112
+
113
+ ## Declarative HTML
114
+
115
+ FAST Element publishes its declarative HTML runtime from
116
+ `@microsoft/fast-element/declarative.js`. This entrypoint exports the
117
+ functional APIs for declarative templates: `declarativeTemplate()`,
118
+ `TemplateParser`, and related configuration types. `attributeMap()` and
119
+ `observerMap()` are available from their own focused path exports. The
120
+ declarative runtime is pure at import time; declarative APIs lazily install only
121
+ declarative debug messages. Hydration is separate and remains opt-in through
122
+ `enableHydration()` from `@microsoft/fast-element/hydration.js`.
123
+
124
+ ```ts
125
+ import { FASTElement } from "@microsoft/fast-element";
126
+ import { declarativeTemplate } from "@microsoft/fast-element/declarative.js";
127
+
128
+ class MyElement extends FASTElement {}
129
+
130
+ MyElement.define({
131
+ name: "my-element",
132
+ template: declarativeTemplate(),
133
+ });
134
+ ```
135
+
136
+ `declarativeTemplate()` automatically defines FAST's internal native
137
+ `<f-template>` publisher in the relevant registry, resolves the matching
138
+ `<f-template name="my-element">`, and keeps the definition template concrete
139
+ before `define()` resolves. Consumers should not import or define the
140
+ `<f-template>` implementation directly.
141
+
142
+ Declarative schema behavior is enabled with define extensions:
143
+
144
+ ```ts
145
+ import { attributeMap } from "@microsoft/fast-element/attribute-map.js";
146
+ import { declarativeTemplate } from "@microsoft/fast-element/declarative.js";
147
+ import { observerMap } from "@microsoft/fast-element/observer-map.js";
148
+
149
+ MyElement.define(
150
+ {
151
+ name: "my-element",
152
+ template: declarativeTemplate(),
153
+ },
154
+ [attributeMap(), observerMap()],
155
+ );
156
+ ```
157
+
158
+ `attributeMap()` creates `@attr`-style accessors for leaf bindings, and
159
+ `observerMap()` creates deep observable accessors for discovered root
160
+ properties. Declarative templates assign `definition.schema` during template
161
+ resolution so these extensions always have schema data when used with
162
+ `declarativeTemplate()`. For non-declarative/manual schema use, import `Schema`
163
+ from `@microsoft/fast-element` and pass it on the element definition;
164
+ `observerMap()` can also receive
165
+ `observerMap({ schema })` directly. When both extensions are present, attribute
166
+ mapping runs before observer mapping.
167
+
168
+ Declarative utilities such as `deepMerge` are available from
169
+ `@microsoft/fast-element/declarative-utilities.js`. See
170
+ [`DECLARATIVE_HTML.md`](./DECLARATIVE_HTML.md) for declarative implementation
171
+ details and the
172
+ [Declarative HTML docs](https://fast.design/docs/3.x/declarative-templates/overview/)
173
+ for guides on writing f-templates, defining declarative elements, and
174
+ server-side rendering. Declarative event bindings use `$e` for the DOM event
175
+ object and `$c` for the execution context.
176
+
177
+ ## Prerendered Content Optimization
178
+
179
+ Hydration of prerendered content is **opt-in**. Call `enableHydration()` from `@microsoft/fast-element/hydration.js` before any FAST elements connect to activate the hydration path:
180
+
181
+ ```typescript
182
+ import { enableHydration } from "@microsoft/fast-element/hydration.js";
183
+
184
+ enableHydration({
185
+ hydrationComplete() {
186
+ console.log("hydration complete");
187
+ },
188
+ });
189
+ ```
190
+
191
+ When hydration is enabled and a FAST element connects with an existing shadow root (from server-side rendering or declarative shadow DOM), `ElementController` detects this and hydrates instead of re-rendering. Two properties on the controller let you inspect the result:
192
+
193
+ - **`isPrerendered: Promise<boolean>`** — resolves `true` when the element had a declarative shadow root (DSD) at connect time, regardless of whether hydration ran.
194
+ - **`isHydrated: Promise<boolean>`** — resolves `true` only when hydration actually ran successfully.
195
+
196
+ This enables several optimizations:
197
+
198
+ - **Hydration instead of re-render**: The template uses `hydrate()` to map existing DOM nodes to binding targets rather than cloning new DOM.
199
+ - **Declarative template resolution**: `declarativeTemplate()` waits for the
200
+ matching `<f-template>` before `define()` completes, so connected elements
201
+ hydrate with a concrete template.
202
+ - **Attribute skip**: `onAttributeChangedCallback()` skips processing during initial upgrade when the element is prerendered, since server-rendered attribute values are already correct.
203
+ - **Binding skip**: `HTMLBindingDirective.bind()` skips `updateTarget` for `attribute` and `booleanAttribute` aspect types when the view is prerendered.
204
+
205
+ Per-element lifecycle callbacks can be passed directly to `declarativeTemplate()`:
206
+
207
+ ```typescript
208
+ import { declarativeTemplate } from "@microsoft/fast-element/declarative.js";
209
+
210
+ MyComponent.define({
211
+ name: "my-component",
212
+ template: declarativeTemplate({
213
+ elementWillHydrate(source) {
214
+ console.log(`${source.localName} will hydrate`);
215
+ },
216
+ elementDidHydrate(source) {
217
+ console.log(`${source.localName} hydrated`);
218
+ },
219
+ }),
220
+ });
221
+ ```
222
+
223
+ Component authors can await both promises to distinguish prerendered content from successful hydration:
224
+
225
+ ```typescript
226
+ const controller = this.$fastController;
227
+ const prerendered = await controller.isPrerendered;
228
+ const hydrated = await controller.isHydrated;
229
+
230
+ if (prerendered && !hydrated) {
231
+ // Had DSD but hydration wasn't enabled — client-side rendered
232
+ }
233
+ ```
234
+
235
+ Custom directives can also await `controller.isPrerendered` and `controller.isHydrated` (both `Promise<boolean>` on the `ViewController` interface) to determine how the view's content was rendered.
236
+
237
+ ## Define Extensions
238
+
239
+ `FASTElement.define()` accepts an optional second argument — an array of extension callbacks that are invoked with the resolved element definition before the element is registered with the platform. This enables a plugin pattern where reusable behaviors can hook into element registration.
240
+
241
+ ```typescript
242
+ import { FASTElement, type FASTElementExtension } from "@microsoft/fast-element";
243
+
244
+ function logger(): FASTElementExtension {
245
+ return definition => {
246
+ console.log(`Defining element: ${definition.name}`);
247
+ };
248
+ }
249
+
250
+ class MyComponent extends FASTElement {
251
+ // component code
252
+ }
253
+
254
+ // Method style
255
+ MyComponent.define({ name: "my-component", template, styles }, [logger()]);
256
+
257
+ // Static style
258
+ FASTElement.define(MyComponent, { name: "my-component" }, [logger()]);
259
+ ```
260
+
261
+ Each extension receives the full `FASTElementDefinition`, which includes the resolved element name, type, template, styles, and attribute metadata. Extensions run before `customElements.define()`, so any setup they perform is available when existing DOM elements are upgraded.
package/SIZES.md ADDED
@@ -0,0 +1,25 @@
1
+ # Export Sizes
2
+
3
+ Bundle sizes for `@microsoft/fast-element` exports.
4
+
5
+ | Export | Minified | Gzip | Brotli |
6
+ |--------|----------|------|--------|
7
+ | CDN Rollup Bundle | 76.36 KB | 22.91 KB | 20.32 KB |
8
+ | FASTElement (@microsoft/fast-element/fast-element.js) | 23.73 KB | 7.38 KB | 6.63 KB |
9
+ | Updates (@microsoft/fast-element/updates.js) | 473 B | 335 B | 288 B |
10
+ | Observable (@microsoft/fast-element/observable.js) | 6.70 KB | 2.50 KB | 2.22 KB |
11
+ | observable (@microsoft/fast-element/observable.js) | 6.74 KB | 2.51 KB | 2.23 KB |
12
+ | attr (@microsoft/fast-element/attr.js) | 477 B | 288 B | 244 B |
13
+ | children (@microsoft/fast-element/children.js) | 4.81 KB | 1.86 KB | 1.64 KB |
14
+ | ref (@microsoft/fast-element/ref.js) | 3.78 KB | 1.52 KB | 1.34 KB |
15
+ | slotted (@microsoft/fast-element/slotted.js) | 4.60 KB | 1.79 KB | 1.58 KB |
16
+ | volatile (@microsoft/fast-element/volatile.js) | 6.79 KB | 2.53 KB | 2.25 KB |
17
+ | when (@microsoft/fast-element/when.js) | 1.82 KB | 712 B | 565 B |
18
+ | html (@microsoft/fast-element/html.js) | 25.92 KB | 8.50 KB | 7.61 KB |
19
+ | repeat (@microsoft/fast-element/repeat.js) | 29.57 KB | 9.41 KB | 8.47 KB |
20
+ | css (@microsoft/fast-element/css.js) | 2.43 KB | 1.00 KB | 911 B |
21
+ | enableHydration (@microsoft/fast-element/hydration.js) | 43.27 KB | 13.22 KB | 11.89 KB |
22
+ | declarativeTemplate (@microsoft/fast-element/declarative.js) | 58.77 KB | 18.46 KB | 16.46 KB |
23
+ | ArrayObserver (@microsoft/fast-element/array-observer.js) | 12.51 KB | 4.45 KB | 4.01 KB |
24
+ | observerMap (@microsoft/fast-element/observer-map.js) | 20.41 KB | 7.26 KB | 6.52 KB |
25
+ | attributeMap (@microsoft/fast-element/attribute-map.js) | 15.78 KB | 5.59 KB | 5.04 KB |
@@ -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
+ }
@@ -2,6 +2,7 @@
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
3
  "extends": "../../api-extractor.json",
4
4
  "mainEntryPointFilePath": "./dist/dts/context.d.ts",
5
+ "dtsRollup": { "enabled": false },
5
6
  "apiReport": {
6
7
  "enabled": true,
7
8
  "reportFolder": "<projectFolder>/docs/context",
@@ -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/declarative/index.d.ts",
5
+ "dtsRollup": { "enabled": false },
6
+ "apiReport": {
7
+ "enabled": true,
8
+ "reportFolder": "<projectFolder>/docs/declarative",
9
+ "reportFileName": "api-report"
10
+ },
11
+ "docModel": {
12
+ "enabled": true,
13
+ "apiJsonFilePath": "<projectFolder>/dist/declarative/declarative.api.json"
14
+ }
15
+ }
@@ -2,6 +2,7 @@
2
2
  "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3
3
  "extends": "../../api-extractor.json",
4
4
  "mainEntryPointFilePath": "./dist/dts/di/di.d.ts",
5
+ "dtsRollup": { "enabled": false },
5
6
  "apiReport": {
6
7
  "enabled": true,
7
8
  "reportFolder": "<projectFolder>/docs/di",