@microsoft/fast-element 2.10.3 → 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 (351) hide show
  1. package/ARCHITECTURE_HTML_TAGGED_TEMPLATE_LITERAL.md +1 -1
  2. package/ARCHITECTURE_OVERVIEW.md +2 -2
  3. package/CHANGELOG.json +31 -1
  4. package/CHANGELOG.md +10 -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 +143 -34
  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/context/context.api.json +1 -1
  23. package/dist/declarative/declarative.api.json +7844 -0
  24. package/dist/di/di.api.json +2 -2
  25. package/dist/dts/array-observer.d.ts +2 -0
  26. package/dist/dts/arrays.d.ts +2 -0
  27. package/dist/dts/attr.d.ts +1 -0
  28. package/dist/dts/binding/signal.d.ts +6 -6
  29. package/dist/dts/binding/two-way.d.ts +1 -0
  30. package/dist/dts/binding.d.ts +7 -0
  31. package/dist/dts/components/attributes.d.ts +2 -5
  32. package/dist/dts/components/definition-schema-transforms.d.ts +9 -0
  33. package/dist/dts/components/element-controller.d.ts +80 -114
  34. package/dist/dts/components/element-hydration.d.ts +1 -1
  35. package/dist/dts/components/enable-hydration.d.ts +34 -0
  36. package/dist/dts/components/fast-definitions.d.ts +91 -42
  37. package/dist/dts/components/fast-element.d.ts +5 -8
  38. package/dist/dts/components/hydration-tracker.d.ts +40 -0
  39. package/dist/dts/components/hydration.d.ts +18 -53
  40. package/dist/dts/components/schema.d.ts +205 -0
  41. package/dist/dts/context.d.ts +6 -6
  42. package/dist/dts/css.d.ts +3 -0
  43. package/dist/dts/debug.d.ts +5 -1
  44. package/dist/dts/declarative/attribute-map.d.ts +58 -0
  45. package/dist/dts/declarative/debug.d.ts +5 -0
  46. package/dist/dts/declarative/index.d.ts +13 -0
  47. package/dist/dts/declarative/interfaces.d.ts +9 -0
  48. package/dist/dts/declarative/observer-map-utilities.d.ts +58 -0
  49. package/dist/dts/declarative/observer-map.d.ts +89 -0
  50. package/dist/dts/declarative/runtime.d.ts +5 -0
  51. package/dist/dts/declarative/syntax.d.ts +21 -0
  52. package/dist/dts/declarative/template-bridge.d.ts +33 -0
  53. package/dist/dts/declarative/template-parser.d.ts +98 -0
  54. package/dist/dts/declarative/template.d.ts +9 -0
  55. package/dist/dts/declarative/utilities.d.ts +312 -0
  56. package/dist/dts/di/di.d.ts +1 -1
  57. package/dist/dts/directives/children.d.ts +2 -0
  58. package/dist/dts/directives/node-observation.d.ts +2 -0
  59. package/dist/dts/directives/ref.d.ts +2 -0
  60. package/dist/dts/directives/repeat.d.ts +4 -0
  61. package/dist/dts/directives/slotted.d.ts +2 -0
  62. package/dist/dts/directives/when.d.ts +3 -0
  63. package/dist/dts/dom-policy.d.ts +1 -1
  64. package/dist/dts/html.d.ts +5 -0
  65. package/dist/dts/hydration/runtime.d.ts +7 -0
  66. package/dist/dts/hydration/target-builder.d.ts +15 -12
  67. package/dist/dts/hydration.d.ts +14 -0
  68. package/dist/dts/index.d.ts +38 -42
  69. package/dist/dts/index.debug.d.ts +0 -1
  70. package/dist/dts/index.rollup.debug.d.ts +0 -1
  71. package/dist/dts/interfaces.d.ts +1 -49
  72. package/dist/dts/observable.d.ts +3 -6
  73. package/dist/dts/observation/arrays.d.ts +1 -1
  74. package/dist/dts/observation/update-queue.d.ts +1 -1
  75. package/dist/dts/platform.d.ts +25 -4
  76. package/dist/dts/render.d.ts +7 -0
  77. package/dist/dts/schema.d.ts +1 -0
  78. package/dist/dts/state/exports.d.ts +1 -1
  79. package/dist/dts/state/state.d.ts +2 -2
  80. package/dist/dts/styles/css-directive.d.ts +5 -12
  81. package/dist/dts/styles/css.d.ts +5 -7
  82. package/dist/dts/styles/element-styles.d.ts +0 -10
  83. package/dist/dts/styles.d.ts +6 -0
  84. package/dist/dts/templating/children.d.ts +1 -1
  85. package/dist/dts/templating/html-binding-directive.d.ts +10 -0
  86. package/dist/dts/templating/html-directive.d.ts +17 -0
  87. package/dist/dts/templating/hydration-view.d.ts +109 -0
  88. package/dist/dts/templating/ref.d.ts +1 -1
  89. package/dist/dts/templating/render.d.ts +8 -2
  90. package/dist/dts/templating/repeat.d.ts +2 -2
  91. package/dist/dts/templating/slotted.d.ts +1 -1
  92. package/dist/dts/templating/template.d.ts +17 -9
  93. package/dist/dts/templating/view.d.ts +25 -102
  94. package/dist/dts/templating/when.d.ts +1 -1
  95. package/dist/dts/templating.d.ts +10 -0
  96. package/dist/dts/testing/exports.d.ts +2 -2
  97. package/dist/dts/tsdoc-metadata.json +1 -1
  98. package/dist/dts/updates.d.ts +1 -0
  99. package/dist/dts/volatile.d.ts +2 -0
  100. package/dist/esm/array-observer.js +1 -0
  101. package/dist/esm/arrays.js +1 -0
  102. package/dist/esm/attr.js +1 -0
  103. package/dist/esm/binding/normalize.js +1 -1
  104. package/dist/esm/binding/signal.js +4 -4
  105. package/dist/esm/binding/two-way.js +2 -1
  106. package/dist/esm/binding.js +4 -0
  107. package/dist/esm/components/attributes.js +8 -5
  108. package/dist/esm/components/definition-schema-transforms.js +23 -0
  109. package/dist/esm/components/element-controller.js +200 -269
  110. package/dist/esm/components/element-hydration.js +1 -1
  111. package/dist/esm/components/enable-hydration.js +100 -0
  112. package/dist/esm/components/fast-definitions.js +211 -49
  113. package/dist/esm/components/fast-element.js +18 -27
  114. package/dist/esm/components/hydration-tracker.js +93 -0
  115. package/dist/esm/components/hydration.js +62 -144
  116. package/dist/esm/components/schema.js +253 -0
  117. package/dist/esm/context.js +6 -6
  118. package/dist/esm/css.js +3 -0
  119. package/dist/esm/debug.js +26 -26
  120. package/dist/esm/declarative/attribute-map.js +121 -0
  121. package/dist/esm/declarative/debug.js +5 -0
  122. package/dist/esm/declarative/index.js +3 -0
  123. package/dist/esm/declarative/interfaces.js +10 -0
  124. package/dist/esm/declarative/observer-map-utilities.js +562 -0
  125. package/dist/esm/declarative/observer-map.js +216 -0
  126. package/dist/esm/declarative/runtime.js +14 -0
  127. package/dist/esm/declarative/syntax.js +36 -0
  128. package/dist/esm/declarative/template-bridge.js +170 -0
  129. package/dist/esm/declarative/template-parser.js +306 -0
  130. package/dist/esm/declarative/template.js +142 -0
  131. package/dist/esm/declarative/utilities.js +834 -0
  132. package/dist/esm/di/di.js +6 -8
  133. package/dist/esm/directives/children.js +1 -0
  134. package/dist/esm/directives/node-observation.js +1 -0
  135. package/dist/esm/directives/ref.js +1 -0
  136. package/dist/esm/directives/repeat.js +1 -0
  137. package/dist/esm/directives/slotted.js +1 -0
  138. package/dist/esm/directives/when.js +1 -0
  139. package/dist/esm/dom-policy.js +2 -2
  140. package/dist/esm/dom.js +1 -1
  141. package/dist/esm/html.js +2 -0
  142. package/dist/esm/hydration/runtime.js +33 -0
  143. package/dist/esm/hydration/target-builder.js +97 -90
  144. package/dist/esm/hydration.js +4 -0
  145. package/dist/esm/index.debug.js +2 -1
  146. package/dist/esm/index.js +34 -29
  147. package/dist/esm/index.rollup.debug.js +3 -2
  148. package/dist/esm/index.rollup.js +1 -1
  149. package/dist/esm/interfaces.js +1 -45
  150. package/dist/esm/observable.js +1 -4
  151. package/dist/esm/observation/arrays.js +1 -1
  152. package/dist/esm/observation/observable.js +5 -5
  153. package/dist/esm/observation/update-queue.js +47 -58
  154. package/dist/esm/platform.js +31 -30
  155. package/dist/esm/render.js +1 -0
  156. package/dist/esm/schema.js +1 -0
  157. package/dist/esm/state/exports.js +1 -1
  158. package/dist/esm/styles/css-directive.js +1 -2
  159. package/dist/esm/styles/css.js +15 -56
  160. package/dist/esm/styles/element-styles.js +69 -15
  161. package/dist/esm/styles.js +2 -0
  162. package/dist/esm/templating/html-binding-directive.js +24 -10
  163. package/dist/esm/templating/hydration-view.js +235 -0
  164. package/dist/esm/templating/render.js +13 -2
  165. package/dist/esm/templating/repeat.js +36 -34
  166. package/dist/esm/templating/template.js +7 -7
  167. package/dist/esm/templating/view.js +24 -233
  168. package/dist/esm/templating.js +7 -0
  169. package/dist/esm/testing/exports.js +2 -2
  170. package/dist/esm/updates.js +1 -0
  171. package/dist/esm/volatile.js +1 -0
  172. package/dist/fast-element.api.json +9017 -6996
  173. package/dist/fast-element.d.ts +3557 -796
  174. package/dist/fast-element.debug.js +5093 -4419
  175. package/dist/fast-element.debug.min.js +2 -2
  176. package/dist/fast-element.js +5398 -4655
  177. package/dist/fast-element.min.js +2 -2
  178. package/dist/fast-element.untrimmed.d.ts +881 -481
  179. package/dist/hydration/hydration.api.json +5237 -0
  180. package/dist/styles/styles.api.json +2672 -0
  181. package/docs/api-report.api.md +344 -167
  182. package/docs/arrays/api-report.api.md +114 -0
  183. package/docs/declarative/api-report.api.md +397 -0
  184. package/docs/hydration/api-report.api.md +285 -0
  185. package/docs/styles/api-report.api.md +135 -0
  186. package/package.json +149 -40
  187. package/playwright.declarative.config.ts +26 -0
  188. package/playwright.declarative.webui.config.ts +20 -0
  189. package/scripts/declarative/build-fixtures-with-webui.js +135 -0
  190. package/scripts/declarative/build-fixtures.js +49 -0
  191. package/scripts/declarative/build-fixtures.utilities.js +101 -0
  192. package/scripts/measure-sizes.js +219 -0
  193. package/scripts/run-api-extractor.js +39 -20
  194. package/test/declarative/fixtures/README.md +72 -0
  195. package/test/declarative/fixtures/WRITING_FIXTURES.md +330 -0
  196. package/test/declarative/fixtures/bindings/README.md +12 -0
  197. package/test/declarative/fixtures/bindings/attribute/entry.html +13 -0
  198. package/test/declarative/fixtures/bindings/attribute/fast-build.config.json +6 -0
  199. package/test/declarative/fixtures/bindings/attribute/index.html +25 -0
  200. package/test/declarative/fixtures/bindings/attribute/main.ts +41 -0
  201. package/test/declarative/fixtures/bindings/attribute/state.json +8 -0
  202. package/test/declarative/fixtures/bindings/attribute/templates.html +11 -0
  203. package/test/declarative/fixtures/bindings/content/entry.html +12 -0
  204. package/test/declarative/fixtures/bindings/content/fast-build.config.json +6 -0
  205. package/test/declarative/fixtures/bindings/content/index.html +19 -0
  206. package/test/declarative/fixtures/bindings/content/main.ts +27 -0
  207. package/test/declarative/fixtures/bindings/content/state.json +4 -0
  208. package/test/declarative/fixtures/bindings/content/templates.html +6 -0
  209. package/test/declarative/fixtures/bindings/dot-syntax/entry.html +11 -0
  210. package/test/declarative/fixtures/bindings/dot-syntax/fast-build.config.json +6 -0
  211. package/test/declarative/fixtures/bindings/dot-syntax/index.html +47 -0
  212. package/test/declarative/fixtures/bindings/dot-syntax/main.ts +59 -0
  213. package/test/declarative/fixtures/bindings/dot-syntax/state.json +16 -0
  214. package/test/declarative/fixtures/bindings/dot-syntax/templates.html +17 -0
  215. package/test/declarative/fixtures/bindings/event/entry.html +11 -0
  216. package/test/declarative/fixtures/bindings/event/fast-build.config.json +6 -0
  217. package/test/declarative/fixtures/bindings/event/index.html +43 -0
  218. package/test/declarative/fixtures/bindings/event/main.ts +43 -0
  219. package/test/declarative/fixtures/bindings/event/state.json +3 -0
  220. package/test/declarative/fixtures/bindings/event/templates.html +18 -0
  221. package/test/declarative/fixtures/bindings/host/entry.html +40 -0
  222. package/test/declarative/fixtures/bindings/host/fast-build.config.json +6 -0
  223. package/test/declarative/fixtures/bindings/host/index.html +96 -0
  224. package/test/declarative/fixtures/bindings/host/main.ts +222 -0
  225. package/test/declarative/fixtures/bindings/host/state.json +9 -0
  226. package/test/declarative/fixtures/bindings/host/templates.html +55 -0
  227. package/test/declarative/fixtures/directives/README.md +12 -0
  228. package/test/declarative/fixtures/directives/children/entry.html +11 -0
  229. package/test/declarative/fixtures/directives/children/fast-build.config.json +6 -0
  230. package/test/declarative/fixtures/directives/children/index.html +15 -0
  231. package/test/declarative/fixtures/directives/children/main.ts +22 -0
  232. package/test/declarative/fixtures/directives/children/state.json +3 -0
  233. package/test/declarative/fixtures/directives/children/templates.html +3 -0
  234. package/test/declarative/fixtures/directives/ref/entry.html +11 -0
  235. package/test/declarative/fixtures/directives/ref/fast-build.config.json +6 -0
  236. package/test/declarative/fixtures/directives/ref/index.html +15 -0
  237. package/test/declarative/fixtures/directives/ref/main.ts +17 -0
  238. package/test/declarative/fixtures/directives/ref/state.json +1 -0
  239. package/test/declarative/fixtures/directives/ref/templates.html +3 -0
  240. package/test/declarative/fixtures/directives/repeat/entry.html +21 -0
  241. package/test/declarative/fixtures/directives/repeat/fast-build.config.json +6 -0
  242. package/test/declarative/fixtures/directives/repeat/index.html +133 -0
  243. package/test/declarative/fixtures/directives/repeat/main.ts +110 -0
  244. package/test/declarative/fixtures/directives/repeat/sprites.svg +8 -0
  245. package/test/declarative/fixtures/directives/repeat/state.json +10 -0
  246. package/test/declarative/fixtures/directives/repeat/templates.html +75 -0
  247. package/test/declarative/fixtures/directives/slotted/entry.html +17 -0
  248. package/test/declarative/fixtures/directives/slotted/fast-build.config.json +6 -0
  249. package/test/declarative/fixtures/directives/slotted/index.html +27 -0
  250. package/test/declarative/fixtures/directives/slotted/main.ts +29 -0
  251. package/test/declarative/fixtures/directives/slotted/state.json +1 -0
  252. package/test/declarative/fixtures/directives/slotted/templates.html +7 -0
  253. package/test/declarative/fixtures/directives/when/entry.html +51 -0
  254. package/test/declarative/fixtures/directives/when/fast-build.config.json +6 -0
  255. package/test/declarative/fixtures/directives/when/index.html +136 -0
  256. package/test/declarative/fixtures/directives/when/main.ts +172 -0
  257. package/test/declarative/fixtures/directives/when/state.json +12 -0
  258. package/test/declarative/fixtures/directives/when/templates.html +75 -0
  259. package/test/declarative/fixtures/ecosystem/README.md +11 -0
  260. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/entry.html +12 -0
  261. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/fast-build.config.json +6 -0
  262. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/index.html +20 -0
  263. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/main.ts +68 -0
  264. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/state.json +4 -0
  265. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/templates.html +7 -0
  266. package/test/declarative/fixtures/ecosystem/errors/entry.html +12 -0
  267. package/test/declarative/fixtures/ecosystem/errors/fast-build.config.json +6 -0
  268. package/test/declarative/fixtures/ecosystem/errors/index.html +20 -0
  269. package/test/declarative/fixtures/ecosystem/errors/main.ts +17 -0
  270. package/test/declarative/fixtures/ecosystem/errors/state.json +1 -0
  271. package/test/declarative/fixtures/ecosystem/errors/templates.html +7 -0
  272. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/entry.html +17 -0
  273. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/fast-build.config.json +6 -0
  274. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/index.html +56 -0
  275. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/main.ts +134 -0
  276. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/state.json +12 -0
  277. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/templates.html +34 -0
  278. package/test/declarative/fixtures/ecosystem/performance-metrics/entry.html +25 -0
  279. package/test/declarative/fixtures/ecosystem/performance-metrics/fast-build.config.json +6 -0
  280. package/test/declarative/fixtures/ecosystem/performance-metrics/fast-card.css +10 -0
  281. package/test/declarative/fixtures/ecosystem/performance-metrics/index.html +181 -0
  282. package/test/declarative/fixtures/ecosystem/performance-metrics/main.ts +58 -0
  283. package/test/declarative/fixtures/ecosystem/performance-metrics/state.json +6 -0
  284. package/test/declarative/fixtures/ecosystem/performance-metrics/templates.html +15 -0
  285. package/test/declarative/fixtures/extensions/README.md +15 -0
  286. package/test/declarative/fixtures/extensions/attribute-map/entry.html +14 -0
  287. package/test/declarative/fixtures/extensions/attribute-map/fast-build.config.json +6 -0
  288. package/test/declarative/fixtures/extensions/attribute-map/index.html +31 -0
  289. package/test/declarative/fixtures/extensions/attribute-map/main.ts +40 -0
  290. package/test/declarative/fixtures/extensions/attribute-map/state.json +4 -0
  291. package/test/declarative/fixtures/extensions/attribute-map/templates.html +14 -0
  292. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/entry.html +12 -0
  293. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/fast-build.config.json +7 -0
  294. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/index.html +25 -0
  295. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/main.ts +31 -0
  296. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/state.json +5 -0
  297. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/templates.html +11 -0
  298. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/entry.html +13 -0
  299. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/fast-build.config.json +7 -0
  300. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/index.html +23 -0
  301. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/main.ts +37 -0
  302. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/state.json +1 -0
  303. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/templates.html +9 -0
  304. package/test/declarative/fixtures/extensions/observer-map/entry.html +15 -0
  305. package/test/declarative/fixtures/extensions/observer-map/fast-build.config.json +6 -0
  306. package/test/declarative/fixtures/extensions/observer-map/index.html +442 -0
  307. package/test/declarative/fixtures/extensions/observer-map/main.ts +482 -0
  308. package/test/declarative/fixtures/extensions/observer-map/state.json +158 -0
  309. package/test/declarative/fixtures/extensions/observer-map/templates.html +172 -0
  310. package/test/declarative/fixtures/extensions/observer-map-config-object/entry.html +16 -0
  311. package/test/declarative/fixtures/extensions/observer-map-config-object/fast-build.config.json +6 -0
  312. package/test/declarative/fixtures/extensions/observer-map-config-object/index.html +27 -0
  313. package/test/declarative/fixtures/extensions/observer-map-config-object/main.ts +53 -0
  314. package/test/declarative/fixtures/extensions/observer-map-config-object/state.json +9 -0
  315. package/test/declarative/fixtures/extensions/observer-map-config-object/templates.html +12 -0
  316. package/test/declarative/fixtures/extensions/observer-map-deep-merge/README.md +98 -0
  317. package/test/declarative/fixtures/extensions/observer-map-deep-merge/entry.html +156 -0
  318. package/test/declarative/fixtures/extensions/observer-map-deep-merge/fast-build.config.json +6 -0
  319. package/test/declarative/fixtures/extensions/observer-map-deep-merge/index.html +376 -0
  320. package/test/declarative/fixtures/extensions/observer-map-deep-merge/main.ts +366 -0
  321. package/test/declarative/fixtures/extensions/observer-map-deep-merge/state.json +69 -0
  322. package/test/declarative/fixtures/extensions/observer-map-deep-merge/templates.html +91 -0
  323. package/test/declarative/fixtures/extensions/observer-map-properties/entry.html +14 -0
  324. package/test/declarative/fixtures/extensions/observer-map-properties/fast-build.config.json +6 -0
  325. package/test/declarative/fixtures/extensions/observer-map-properties/index.html +110 -0
  326. package/test/declarative/fixtures/extensions/observer-map-properties/main.ts +175 -0
  327. package/test/declarative/fixtures/extensions/observer-map-properties/state.json +29 -0
  328. package/test/declarative/fixtures/extensions/observer-map-properties/templates.html +55 -0
  329. package/test/declarative/fixtures/scenarios/README.md +7 -0
  330. package/test/declarative/fixtures/scenarios/nested-elements/entry.html +16 -0
  331. package/test/declarative/fixtures/scenarios/nested-elements/fast-build.config.json +6 -0
  332. package/test/declarative/fixtures/scenarios/nested-elements/index.html +126 -0
  333. package/test/declarative/fixtures/scenarios/nested-elements/main.ts +214 -0
  334. package/test/declarative/fixtures/scenarios/nested-elements/state.json +10 -0
  335. package/test/declarative/fixtures/scenarios/nested-elements/templates.html +54 -0
  336. package/test/declarative/index.html +12 -0
  337. package/test/declarative/vite.config.ts +55 -0
  338. package/test/declarative-main.ts +6 -0
  339. package/test/extension-subpaths-main.ts +9 -0
  340. package/test/main.ts +38 -33
  341. package/test/pure-declarative-main.ts +1 -0
  342. package/dist/dts/components/install-hydration.d.ts +0 -1
  343. package/dist/dts/pending-task.d.ts +0 -32
  344. package/dist/dts/polyfills.d.ts +0 -0
  345. package/dist/dts/styles/css-binding-directive.d.ts +0 -60
  346. package/dist/dts/templating/install-hydratable-view-templates.d.ts +0 -1
  347. package/dist/esm/components/install-hydration.js +0 -3
  348. package/dist/esm/pending-task.js +0 -28
  349. package/dist/esm/polyfills.js +0 -60
  350. package/dist/esm/styles/css-binding-directive.js +0 -76
  351. package/dist/esm/templating/install-hydratable-view-templates.js +0 -23
@@ -1,67 +1,56 @@
1
- import { KernelServiceId } from "../interfaces.js";
2
- import { FAST } from "../platform.js";
3
- /**
4
- * The default UpdateQueue.
5
- * @public
6
- */
7
- export const Updates = FAST.getById(KernelServiceId.updateQueue, () => {
8
- const tasks = [];
9
- const pendingErrors = [];
10
- const rAF = globalThis.requestAnimationFrame;
11
- let updateAsync = true;
12
- function throwFirstError() {
13
- if (pendingErrors.length) {
14
- throw pendingErrors.shift();
15
- }
1
+ const tasks = [];
2
+ const pendingErrors = [];
3
+ const rAF = globalThis.requestAnimationFrame;
4
+ let updateAsync = true;
5
+ function throwFirstError() {
6
+ if (pendingErrors.length) {
7
+ throw pendingErrors.shift();
8
+ }
9
+ }
10
+ function tryRunTask(task) {
11
+ try {
12
+ task.call();
16
13
  }
17
- function tryRunTask(task) {
18
- try {
19
- task.call();
14
+ catch (error) {
15
+ if (updateAsync) {
16
+ pendingErrors.push(error);
17
+ setTimeout(throwFirstError, 0);
20
18
  }
21
- catch (error) {
22
- if (updateAsync) {
23
- pendingErrors.push(error);
24
- setTimeout(throwFirstError, 0);
25
- }
26
- else {
27
- tasks.length = 0;
28
- throw error;
29
- }
19
+ else {
20
+ tasks.length = 0;
21
+ throw error;
30
22
  }
31
23
  }
32
- function process() {
33
- const capacity = 1024;
34
- let index = 0;
35
- while (index < tasks.length) {
36
- tryRunTask(tasks[index]);
37
- index++;
38
- // Prevent leaking memory for long chains of recursive calls to `enqueue`.
39
- // If we call `enqueue` within a task scheduled by `enqueue`, the queue will
40
- // grow, but to avoid an O(n) walk for every task we execute, we don't
41
- // shift tasks off the queue after they have been executed.
42
- // Instead, we periodically shift 1024 tasks off the queue.
43
- if (index > capacity) {
44
- // Manually shift all values starting at the index back to the
45
- // beginning of the queue.
46
- for (let scan = 0, newLength = tasks.length - index; scan < newLength; scan++) {
47
- tasks[scan] = tasks[scan + index];
48
- }
49
- tasks.length -= index;
50
- index = 0;
24
+ }
25
+ function process() {
26
+ const capacity = 1024;
27
+ let index = 0;
28
+ while (index < tasks.length) {
29
+ tryRunTask(tasks[index]);
30
+ index++;
31
+ if (index > capacity) {
32
+ for (let scan = 0, newLength = tasks.length - index; scan < newLength; scan++) {
33
+ tasks[scan] = tasks[scan + index];
51
34
  }
35
+ tasks.length -= index;
36
+ index = 0;
52
37
  }
53
- tasks.length = 0;
54
38
  }
55
- function enqueue(callable) {
56
- tasks.push(callable);
57
- if (tasks.length < 2) {
58
- updateAsync ? rAF(process) : process();
59
- }
39
+ tasks.length = 0;
40
+ }
41
+ function enqueue(callable) {
42
+ tasks.push(callable);
43
+ if (tasks.length < 2) {
44
+ updateAsync ? rAF(process) : process();
60
45
  }
61
- return Object.freeze({
62
- enqueue,
63
- next: () => new Promise(enqueue),
64
- process,
65
- setMode: (isAsync) => (updateAsync = isAsync),
66
- });
46
+ }
47
+ /**
48
+ * The default UpdateQueue.
49
+ * @public
50
+ */
51
+ export const Updates = Object.freeze({
52
+ enqueue,
53
+ next: () => new Promise(enqueue),
54
+ process,
55
+ setMode: (isAsync) => (updateAsync = isAsync),
67
56
  });
@@ -1,37 +1,38 @@
1
1
  import { noop } from "./interfaces.js";
2
- import "./polyfills.js";
3
- // ensure FAST global - duplicated debug.ts
4
- const propConfig = {
5
- configurable: false,
6
- enumerable: false,
7
- writable: false,
8
- };
9
- if (globalThis.FAST === void 0) {
10
- Reflect.defineProperty(globalThis, "FAST", Object.assign({ value: Object.create(null) }, propConfig));
11
- }
2
+ const debugMessages = Object.create(null);
12
3
  /**
13
- * The FAST global.
4
+ * The FAST messaging API for warnings and errors.
14
5
  * @public
15
6
  */
16
- export const FAST = globalThis.FAST;
17
- if (FAST.getById === void 0) {
18
- const storage = Object.create(null);
19
- Reflect.defineProperty(FAST, "getById", Object.assign({ value(id, initialize) {
20
- let found = storage[id];
21
- if (found === void 0) {
22
- found = initialize ? (storage[id] = initialize()) : null;
23
- }
24
- return found;
25
- } }, propConfig));
26
- }
27
- if (FAST.error === void 0) {
28
- Object.assign(FAST, {
29
- warn() { },
30
- error(code) {
31
- return new Error(`Error ${code}`);
32
- },
33
- addMessages() { },
34
- });
7
+ export const FAST = {
8
+ /**
9
+ * Sends a warning to the developer.
10
+ * @param code - The warning code to send.
11
+ * @param values - Values relevant for the warning message.
12
+ */
13
+ warn(_code, _values) { },
14
+ /**
15
+ * Creates an error from a code.
16
+ * @param code - The error code.
17
+ * @param values - Values relevant for the error message.
18
+ */
19
+ error(code, _values) {
20
+ return new Error(`Error ${code}`);
21
+ },
22
+ /**
23
+ * Adds debug messages for errors and warnings.
24
+ * @param messages - The message dictionary to add.
25
+ */
26
+ addMessages(messages) {
27
+ Object.assign(debugMessages, messages);
28
+ },
29
+ };
30
+ /**
31
+ * Gets the shared debug message lookup.
32
+ * @internal
33
+ */
34
+ export function getDebugMessageLookup() {
35
+ return debugMessages;
35
36
  }
36
37
  /**
37
38
  * A readonly, empty array.
@@ -0,0 +1 @@
1
+ export { RenderBehavior, RenderDirective, render } from "./templating/render.js";
@@ -0,0 +1 @@
1
+ export { Schema, schemaRegistry, } from "./components/schema.js";
@@ -1,3 +1,3 @@
1
1
  export { reactive } from "./reactive.js";
2
- export { watch } from "./watch.js";
3
2
  export * from "./state.js";
3
+ export { watch } from "./watch.js";
@@ -1,8 +1,7 @@
1
1
  import { createTypeRegistry } from "../platform.js";
2
2
  const registry = createTypeRegistry();
3
3
  /**
4
- * Instructs the css engine to provide dynamic styles or
5
- * associate behaviors with styles.
4
+ * Instructs the css engine to provide styles during CSS template composition.
6
5
  * @public
7
6
  */
8
7
  export const CSSDirective = Object.freeze({
@@ -1,30 +1,13 @@
1
- import { Binding } from "../binding/binding.js";
2
- import { oneWay } from "../binding/one-way.js";
3
- import { isFunction, isString } from "../interfaces.js";
4
- import { CSSBindingDirective } from "./css-binding-directive.js";
5
1
  import { CSSDirective } from "./css-directive.js";
6
2
  import { ElementStyles } from "./element-styles.js";
7
- const marker = `${Math.random().toString(36).substring(2, 8)}`;
8
- let varId = 0;
9
- const nextCSSVariable = () => `--v${marker}${++varId}`;
10
3
  function collectStyles(strings, values) {
11
4
  const styles = [];
12
5
  let cssString = "";
13
- const behaviors = [];
14
- const add = (behavior) => {
15
- behaviors.push(behavior);
16
- };
17
6
  for (let i = 0, ii = strings.length - 1; i < ii; ++i) {
18
7
  cssString += strings[i];
19
8
  let value = values[i];
20
- if (isFunction(value)) {
21
- value = new CSSBindingDirective(oneWay(value), nextCSSVariable()).createCSS(add);
22
- }
23
- else if (value instanceof Binding) {
24
- value = new CSSBindingDirective(value, nextCSSVariable()).createCSS(add);
25
- }
26
- else if (CSSDirective.getForInstance(value) !== void 0) {
27
- value = value.createCSS(add);
9
+ if (CSSDirective.getForInstance(value) !== void 0) {
10
+ value = value.createCSS();
28
11
  }
29
12
  if (value instanceof ElementStyles || value instanceof CSSStyleSheet) {
30
13
  if (cssString.trim() !== "") {
@@ -41,57 +24,33 @@ function collectStyles(strings, values) {
41
24
  if (cssString.trim() !== "") {
42
25
  styles.push(cssString);
43
26
  }
44
- return {
45
- styles,
46
- behaviors,
47
- };
27
+ return styles;
48
28
  }
49
29
  /**
50
30
  * Transforms a template literal string into styles.
51
31
  * @param strings - The string fragments that are interpolated with the values.
52
32
  * @param values - The values that are interpolated with the string fragments.
53
33
  * @remarks
54
- * The css helper supports interpolation of strings and ElementStyle instances.
34
+ * The css helper supports interpolation of static composable styles and CSS directives.
55
35
  * @public
56
36
  */
57
37
  export const css = ((strings, ...values) => {
58
- const { styles, behaviors } = collectStyles(strings, values);
59
- const elementStyles = new ElementStyles(styles);
60
- return behaviors.length ? elementStyles.withBehaviors(...behaviors) : elementStyles;
38
+ return new ElementStyles(collectStyles(strings, values));
61
39
  });
62
40
  class CSSPartial {
63
- constructor(styles, behaviors) {
64
- this.behaviors = behaviors;
65
- this.css = "";
66
- const stylesheets = styles.reduce((accumulated, current) => {
67
- if (isString(current)) {
68
- this.css += current;
69
- }
70
- else {
71
- accumulated.push(current);
72
- }
73
- return accumulated;
74
- }, []);
75
- if (stylesheets.length) {
76
- this.styles = new ElementStyles(stylesheets);
77
- }
78
- }
79
- createCSS(add) {
80
- this.behaviors.forEach(add);
81
- if (this.styles) {
82
- add(this);
83
- }
84
- return this.css;
85
- }
86
- addedCallback(controller) {
87
- controller.addStyles(this.styles);
41
+ constructor(styles) {
42
+ this.value =
43
+ styles.length === 0
44
+ ? ""
45
+ : styles.length === 1
46
+ ? styles[0]
47
+ : new ElementStyles(styles);
88
48
  }
89
- removedCallback(controller) {
90
- controller.removeStyles(this.styles);
49
+ createCSS() {
50
+ return this.value;
91
51
  }
92
52
  }
93
53
  CSSDirective.define(CSSPartial);
94
54
  css.partial = (strings, ...values) => {
95
- const { styles, behaviors } = collectStyles(strings, values);
96
- return new CSSPartial(styles, behaviors);
55
+ return new CSSPartial(collectStyles(strings, values));
97
56
  };
@@ -1,8 +1,14 @@
1
1
  let DefaultStyleStrategy;
2
2
  function reduceStyles(styles) {
3
- return styles
4
- .map((x) => x instanceof ElementStyles ? reduceStyles(x.styles) : [x])
5
- .reduce((prev, curr) => prev.concat(curr), []);
3
+ return styles.reduce((reduced, current) => {
4
+ if (current instanceof ElementStyles) {
5
+ reduced.push(...reduceStyles(current.styles));
6
+ }
7
+ else {
8
+ reduced.push(current);
9
+ }
10
+ return reduced;
11
+ }, []);
6
12
  }
7
13
  /**
8
14
  * Represents styles that can be applied to a custom element.
@@ -14,6 +20,11 @@ export class ElementStyles {
14
20
  */
15
21
  get strategy() {
16
22
  if (this._strategy === null) {
23
+ if (!DefaultStyleStrategy) {
24
+ ElementStyles.setDefaultStrategy(ElementStyles.supportsAdoptedStyleSheets
25
+ ? createAdoptedSheetsStrategy()
26
+ : createStyleElementStrategy());
27
+ }
17
28
  this.withStrategy(DefaultStyleStrategy);
18
29
  }
19
30
  return this._strategy;
@@ -26,9 +37,6 @@ export class ElementStyles {
26
37
  this.styles = styles;
27
38
  this.targets = new WeakSet();
28
39
  this._strategy = null;
29
- this.behaviors = styles
30
- .map((x) => x instanceof ElementStyles ? x.behaviors : null)
31
- .reduce((prev, curr) => (curr === null ? prev : prev === null ? curr : prev.concat(curr)), null);
32
40
  }
33
41
  /** @internal */
34
42
  addStylesTo(target) {
@@ -44,15 +52,6 @@ export class ElementStyles {
44
52
  isAttachedTo(target) {
45
53
  return this.targets.has(target);
46
54
  }
47
- /**
48
- * Associates behaviors with this set of styles.
49
- * @param behaviors - The behaviors to associate.
50
- */
51
- withBehaviors(...behaviors) {
52
- this.behaviors =
53
- this.behaviors === null ? behaviors : this.behaviors.concat(behaviors);
54
- return this;
55
- }
56
55
  /**
57
56
  * Sets the strategy that handles adding/removing these styles for an element.
58
57
  * @param strategy - The strategy to use.
@@ -88,3 +87,58 @@ export class ElementStyles {
88
87
  */
89
88
  ElementStyles.supportsAdoptedStyleSheets = Array.isArray(document.adoptedStyleSheets) &&
90
89
  "replace" in CSSStyleSheet.prototype;
90
+ // Fallback strategy factories used when no strategy has been explicitly set
91
+ // via ElementStyles.setDefaultStrategy (e.g. when importing only from the
92
+ // styles.js subpath without loading element-controller.ts).
93
+ function createAdoptedSheetsStrategy() {
94
+ const cache = new Map();
95
+ return class FallbackAdoptedSheetsStrategy {
96
+ constructor(styles) {
97
+ this.sheets = styles.map(x => {
98
+ if (x instanceof CSSStyleSheet) {
99
+ return x;
100
+ }
101
+ let sheet = cache.get(x);
102
+ if (sheet === void 0) {
103
+ sheet = new CSSStyleSheet();
104
+ sheet.replaceSync(x);
105
+ cache.set(x, sheet);
106
+ }
107
+ return sheet;
108
+ });
109
+ }
110
+ addStylesTo(target) {
111
+ const t = target;
112
+ t.adoptedStyleSheets = [...t.adoptedStyleSheets, ...this.sheets];
113
+ }
114
+ removeStylesFrom(target) {
115
+ const t = target;
116
+ t.adoptedStyleSheets = t.adoptedStyleSheets.filter((x) => this.sheets.indexOf(x) === -1);
117
+ }
118
+ };
119
+ }
120
+ let fallbackStyleId = 0;
121
+ function createStyleElementStrategy() {
122
+ return class FallbackStyleElementStrategy {
123
+ constructor(styles) {
124
+ this.styles = styles;
125
+ this.styleClass = `fast-${++fallbackStyleId}`;
126
+ }
127
+ addStylesTo(target) {
128
+ const t = target === document ? document.body : target;
129
+ for (let i = 0; i < this.styles.length; i++) {
130
+ const element = document.createElement("style");
131
+ element.innerHTML = this.styles[i];
132
+ element.className = this.styleClass;
133
+ t.append(element);
134
+ }
135
+ }
136
+ removeStylesFrom(target) {
137
+ const t = target === document ? document.body : target;
138
+ const styles = t.querySelectorAll(`.${this.styleClass}`);
139
+ for (let i = 0, ii = styles.length; i < ii; ++i) {
140
+ t.removeChild(styles[i]);
141
+ }
142
+ }
143
+ };
144
+ }
@@ -0,0 +1,2 @@
1
+ export { CSSDirective, cssDirective, } from "./styles/css-directive.js";
2
+ export { ElementStyles, } from "./styles/element-styles.js";
@@ -4,8 +4,8 @@ import { Message } from "../interfaces.js";
4
4
  import { ExecutionContext, } from "../observation/observable.js";
5
5
  import { FAST } from "../platform.js";
6
6
  import { HTMLDirective, } from "./html-directive.js";
7
+ import { HydrationStage } from "./hydration-view.js";
7
8
  import { Markup } from "./markup.js";
8
- import { HydrationStage } from "./view.js";
9
9
  function isContentTemplate(value) {
10
10
  return value.create !== undefined;
11
11
  }
@@ -203,9 +203,6 @@ export class HTMLBindingDirective {
203
203
  bind(controller) {
204
204
  var _a;
205
205
  const target = controller.targets[this.targetNodeId];
206
- const isHydrating = isHydratable(controller) &&
207
- controller.hydrationStage &&
208
- controller.hydrationStage !== HydrationStage.hydrated;
209
206
  switch (this.aspectType) {
210
207
  case DOMAspect.event:
211
208
  target[this.data] = controller;
@@ -214,19 +211,25 @@ export class HTMLBindingDirective {
214
211
  case DOMAspect.content:
215
212
  controller.onUnbind(this);
216
213
  // intentional fall through
217
- default:
214
+ default: {
218
215
  const observer = (_a = target[this.data]) !== null && _a !== void 0 ? _a : (target[this.data] = this.dataBinding.createObserver(this, this));
219
216
  observer.target = target;
220
217
  observer.controller = controller;
221
- if (isHydrating &&
218
+ // Evaluate to establish dependency tracking
219
+ const value = observer.bind(controller);
220
+ // Skip DOM update for attribute bindings when prerendered —
221
+ // the server has already rendered the correct attribute values.
222
+ // Content, property, and tokenList bindings must still run
223
+ // so structural directives, host properties, and class lists
224
+ // are properly initialized.
225
+ if (controller._skipAttrUpdates &&
222
226
  (this.aspectType === DOMAspect.attribute ||
223
227
  this.aspectType === DOMAspect.booleanAttribute)) {
224
- observer.bind(controller);
225
- // Skip updating target during bind for attributes
226
228
  break;
227
229
  }
228
- this.updateTarget(target, this.targetAspect, observer.bind(controller), controller);
230
+ this.updateTarget(target, this.targetAspect, value, controller);
229
231
  break;
232
+ }
230
233
  }
231
234
  }
232
235
  /** @internal */
@@ -262,11 +265,22 @@ export class HTMLBindingDirective {
262
265
  * Re-evaluates the binding expression via observer.bind() and pushes
263
266
  * the new value to the DOM through the updateTarget sink function.
264
267
  * This is the reactive update path that keeps the DOM in sync with data.
268
+ *
269
+ * Guards against stale notifications: when a view is unbound (e.g., after
270
+ * a parent `when` directive tears down a child element), coupled-lifetime
271
+ * observers may still hold active subscriptions. If a property change fires
272
+ * on the source element while the view is inactive, this guard prevents
273
+ * the binding expression from evaluating with a null source.
265
274
  * @internal
266
275
  */
267
276
  handleChange(binding, observer) {
268
- const target = observer.target;
269
277
  const controller = observer.controller;
278
+ // https://github.com/microsoft/fast/issues/7444
279
+ // This guard will be reconsidered in the next major version.
280
+ if (!controller.isBound) {
281
+ return;
282
+ }
283
+ const target = observer.target;
270
284
  this.updateTarget(target, this.targetAspect, observer.bind(controller), controller);
271
285
  }
272
286
  }