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

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 (286) hide show
  1. package/CHANGELOG.md +51 -1
  2. package/README.md +50 -14
  3. package/dist/context/context.api.json +13 -13
  4. package/dist/declarative/declarative.api.json +654 -15
  5. package/dist/di/di.api.json +15 -15
  6. package/dist/dts/__test__/helpers.d.ts +6 -0
  7. package/dist/dts/__test__/setup-node.d.ts +0 -0
  8. package/dist/dts/binding/binding.d.ts +15 -5
  9. package/dist/dts/binding/one-time.d.ts +1 -1
  10. package/dist/dts/binding/one-way.d.ts +1 -1
  11. package/dist/dts/binding/signal.d.ts +1 -1
  12. package/dist/dts/binding/two-way.d.ts +1 -1
  13. package/dist/dts/components/attributes.d.ts +1 -1
  14. package/dist/dts/components/enable-hydration.d.ts +22 -2
  15. package/dist/dts/components/fast-definitions.d.ts +7 -4
  16. package/dist/dts/components/fast-element.d.ts +42 -12
  17. package/dist/dts/components/hydration-tracker.d.ts +47 -4
  18. package/dist/dts/components/hydration.d.ts +5 -0
  19. package/dist/dts/context.d.ts +7 -7
  20. package/dist/dts/declarative/debug.d.ts +2 -3
  21. package/dist/dts/declarative/index.d.ts +3 -2
  22. package/dist/dts/declarative/interfaces.d.ts +1 -2
  23. package/dist/dts/declarative/template.d.ts +2 -1
  24. package/dist/dts/declarative/utilities.d.ts +50 -4
  25. package/dist/dts/di/di.d.ts +6 -6
  26. package/dist/dts/dom-policy.d.ts +22 -4
  27. package/dist/dts/dom.d.ts +4 -16
  28. package/dist/dts/hydration/diagnostics.d.ts +93 -0
  29. package/dist/dts/hydration/hydration-debugger.d.ts +35 -0
  30. package/dist/dts/hydration/messages.d.ts +62 -0
  31. package/dist/dts/hydration/target-builder.d.ts +26 -1
  32. package/dist/dts/hydration.d.ts +7 -3
  33. package/dist/dts/index.d.ts +7 -3
  34. package/dist/dts/interfaces.d.ts +1 -0
  35. package/dist/dts/observation/observable.d.ts +3 -3
  36. package/dist/dts/platform.d.ts +20 -4
  37. package/dist/dts/registry.d.ts +1 -0
  38. package/dist/dts/templating/children.d.ts +1 -1
  39. package/dist/dts/templating/compiler.d.ts +1 -1
  40. package/dist/dts/templating/html-binding-directive.d.ts +6 -2
  41. package/dist/dts/templating/html-directive.d.ts +2 -1
  42. package/dist/dts/templating/hydration-view.d.ts +24 -3
  43. package/dist/dts/templating/ref.d.ts +1 -1
  44. package/dist/dts/templating/render.d.ts +2 -2
  45. package/dist/dts/templating/repeat.d.ts +1 -1
  46. package/dist/dts/templating/slotted.d.ts +1 -1
  47. package/dist/dts/templating/template.d.ts +5 -5
  48. package/dist/dts/templating/when.d.ts +1 -1
  49. package/dist/dts/testing/fakes.d.ts +4 -4
  50. package/dist/esm/__test__/helpers.js +22 -0
  51. package/dist/esm/__test__/setup-node.js +18 -0
  52. package/dist/esm/binding/two-way.js +1 -2
  53. package/dist/esm/components/attributes.js +12 -8
  54. package/dist/esm/components/element-controller.js +11 -6
  55. package/dist/esm/components/enable-hydration.js +27 -3
  56. package/dist/esm/components/fast-definitions.js +19 -18
  57. package/dist/esm/components/hydration-tracker.js +34 -5
  58. package/dist/esm/components/hydration.js +85 -6
  59. package/dist/esm/debug.js +1 -0
  60. package/dist/esm/declarative/attribute-map.js +2 -1
  61. package/dist/esm/declarative/debug.js +0 -1
  62. package/dist/esm/declarative/index.js +1 -0
  63. package/dist/esm/declarative/interfaces.js +0 -1
  64. package/dist/esm/declarative/observer-map-utilities.js +58 -55
  65. package/dist/esm/declarative/template-bridge.js +4 -14
  66. package/dist/esm/declarative/template.js +4 -3
  67. package/dist/esm/declarative/utilities.js +236 -1
  68. package/dist/esm/di/di.js +2 -1
  69. package/dist/esm/dom-policy.js +33 -4
  70. package/dist/esm/hydration/diagnostics.js +50 -0
  71. package/dist/esm/hydration/hydration-debugger.js +112 -0
  72. package/dist/esm/hydration/messages.js +84 -0
  73. package/dist/esm/hydration/target-builder.js +65 -19
  74. package/dist/esm/hydration.js +3 -1
  75. package/dist/esm/index.js +6 -2
  76. package/dist/esm/interfaces.js +1 -0
  77. package/dist/esm/metadata.js +2 -8
  78. package/dist/esm/observation/notifier.js +2 -4
  79. package/dist/esm/registry.js +1 -0
  80. package/dist/esm/templating/html-binding-directive.js +1 -1
  81. package/dist/esm/templating/hydration-view.js +20 -27
  82. package/dist/esm/templating/render.js +39 -18
  83. package/dist/esm/templating/repeat.js +51 -17
  84. package/dist/esm/templating/view.js +1 -1
  85. package/dist/esm/testing/fixture.js +2 -2
  86. package/dist/esm/testing/timeout.js +2 -2
  87. package/dist/fast-element.api.json +1329 -99
  88. package/dist/fast-element.d.ts +147 -66
  89. package/dist/fast-element.debug.js +392 -99
  90. package/dist/fast-element.debug.min.js +2 -2
  91. package/dist/fast-element.js +392 -99
  92. package/dist/fast-element.min.js +2 -2
  93. package/dist/fast-element.untrimmed.d.ts +133 -70
  94. package/dist/hydration/hydration.api.json +1280 -57
  95. package/dist/styles/styles.api.json +1 -1
  96. package/package.json +21 -9
  97. package/ARCHITECTURE_FASTELEMENT.md +0 -63
  98. package/ARCHITECTURE_HTML_TAGGED_TEMPLATE_LITERAL.md +0 -36
  99. package/ARCHITECTURE_INTRO.md +0 -10
  100. package/ARCHITECTURE_OVERVIEW.md +0 -52
  101. package/ARCHITECTURE_UPDATES.md +0 -11
  102. package/CHANGELOG.json +0 -2275
  103. package/DECLARATIVE_DESIGN.md +0 -806
  104. package/DECLARATIVE_HTML.md +0 -470
  105. package/DECLARATIVE_MIGRATION.md +0 -215
  106. package/DECLARATIVE_RENDERING.md +0 -530
  107. package/DECLARATIVE_RENDERING_LIFECYCLE.md +0 -288
  108. package/DECLARATIVE_SCHEMA_OBSERVER_MAP.md +0 -489
  109. package/DESIGN.md +0 -615
  110. package/MIGRATION.md +0 -387
  111. package/SIZES.md +0 -25
  112. package/api-extractor.arrays.json +0 -15
  113. package/api-extractor.context.json +0 -15
  114. package/api-extractor.declarative.json +0 -15
  115. package/api-extractor.di.json +0 -15
  116. package/api-extractor.hydration.json +0 -15
  117. package/api-extractor.styles.json +0 -15
  118. package/biome.json +0 -4
  119. package/docs/ACKNOWLEDGEMENTS.md +0 -12
  120. package/docs/api-report.api.md +0 -1299
  121. package/docs/arrays/api-report.api.md +0 -114
  122. package/docs/context/api-report.api.md +0 -69
  123. package/docs/declarative/api-report.api.md +0 -397
  124. package/docs/di/api-report.api.md +0 -315
  125. package/docs/fast-element-2-changes.md +0 -15
  126. package/docs/hydration/api-report.api.md +0 -285
  127. package/docs/styles/api-report.api.md +0 -135
  128. package/playwright.config.ts +0 -26
  129. package/playwright.declarative.config.ts +0 -26
  130. package/playwright.declarative.webui.config.ts +0 -20
  131. package/scripts/declarative/build-fixtures-with-webui.js +0 -135
  132. package/scripts/declarative/build-fixtures.js +0 -49
  133. package/scripts/declarative/build-fixtures.utilities.js +0 -101
  134. package/scripts/measure-sizes.js +0 -219
  135. package/scripts/run-api-extractor.js +0 -70
  136. package/test/declarative/fixtures/README.md +0 -72
  137. package/test/declarative/fixtures/WRITING_FIXTURES.md +0 -330
  138. package/test/declarative/fixtures/bindings/README.md +0 -12
  139. package/test/declarative/fixtures/bindings/attribute/entry.html +0 -13
  140. package/test/declarative/fixtures/bindings/attribute/fast-build.config.json +0 -6
  141. package/test/declarative/fixtures/bindings/attribute/index.html +0 -25
  142. package/test/declarative/fixtures/bindings/attribute/main.ts +0 -41
  143. package/test/declarative/fixtures/bindings/attribute/state.json +0 -8
  144. package/test/declarative/fixtures/bindings/attribute/templates.html +0 -11
  145. package/test/declarative/fixtures/bindings/content/entry.html +0 -12
  146. package/test/declarative/fixtures/bindings/content/fast-build.config.json +0 -6
  147. package/test/declarative/fixtures/bindings/content/index.html +0 -19
  148. package/test/declarative/fixtures/bindings/content/main.ts +0 -27
  149. package/test/declarative/fixtures/bindings/content/state.json +0 -4
  150. package/test/declarative/fixtures/bindings/content/templates.html +0 -6
  151. package/test/declarative/fixtures/bindings/dot-syntax/entry.html +0 -11
  152. package/test/declarative/fixtures/bindings/dot-syntax/fast-build.config.json +0 -6
  153. package/test/declarative/fixtures/bindings/dot-syntax/index.html +0 -47
  154. package/test/declarative/fixtures/bindings/dot-syntax/main.ts +0 -59
  155. package/test/declarative/fixtures/bindings/dot-syntax/state.json +0 -16
  156. package/test/declarative/fixtures/bindings/dot-syntax/templates.html +0 -17
  157. package/test/declarative/fixtures/bindings/event/entry.html +0 -11
  158. package/test/declarative/fixtures/bindings/event/fast-build.config.json +0 -6
  159. package/test/declarative/fixtures/bindings/event/index.html +0 -43
  160. package/test/declarative/fixtures/bindings/event/main.ts +0 -43
  161. package/test/declarative/fixtures/bindings/event/state.json +0 -3
  162. package/test/declarative/fixtures/bindings/event/templates.html +0 -18
  163. package/test/declarative/fixtures/bindings/host/entry.html +0 -40
  164. package/test/declarative/fixtures/bindings/host/fast-build.config.json +0 -6
  165. package/test/declarative/fixtures/bindings/host/index.html +0 -96
  166. package/test/declarative/fixtures/bindings/host/main.ts +0 -222
  167. package/test/declarative/fixtures/bindings/host/state.json +0 -9
  168. package/test/declarative/fixtures/bindings/host/templates.html +0 -55
  169. package/test/declarative/fixtures/directives/README.md +0 -12
  170. package/test/declarative/fixtures/directives/children/entry.html +0 -11
  171. package/test/declarative/fixtures/directives/children/fast-build.config.json +0 -6
  172. package/test/declarative/fixtures/directives/children/index.html +0 -15
  173. package/test/declarative/fixtures/directives/children/main.ts +0 -22
  174. package/test/declarative/fixtures/directives/children/state.json +0 -3
  175. package/test/declarative/fixtures/directives/children/templates.html +0 -3
  176. package/test/declarative/fixtures/directives/ref/entry.html +0 -11
  177. package/test/declarative/fixtures/directives/ref/fast-build.config.json +0 -6
  178. package/test/declarative/fixtures/directives/ref/index.html +0 -15
  179. package/test/declarative/fixtures/directives/ref/main.ts +0 -17
  180. package/test/declarative/fixtures/directives/ref/state.json +0 -1
  181. package/test/declarative/fixtures/directives/ref/templates.html +0 -3
  182. package/test/declarative/fixtures/directives/repeat/entry.html +0 -21
  183. package/test/declarative/fixtures/directives/repeat/fast-build.config.json +0 -6
  184. package/test/declarative/fixtures/directives/repeat/index.html +0 -133
  185. package/test/declarative/fixtures/directives/repeat/main.ts +0 -110
  186. package/test/declarative/fixtures/directives/repeat/sprites.svg +0 -8
  187. package/test/declarative/fixtures/directives/repeat/state.json +0 -10
  188. package/test/declarative/fixtures/directives/repeat/templates.html +0 -75
  189. package/test/declarative/fixtures/directives/slotted/entry.html +0 -17
  190. package/test/declarative/fixtures/directives/slotted/fast-build.config.json +0 -6
  191. package/test/declarative/fixtures/directives/slotted/index.html +0 -27
  192. package/test/declarative/fixtures/directives/slotted/main.ts +0 -29
  193. package/test/declarative/fixtures/directives/slotted/state.json +0 -1
  194. package/test/declarative/fixtures/directives/slotted/templates.html +0 -7
  195. package/test/declarative/fixtures/directives/when/entry.html +0 -51
  196. package/test/declarative/fixtures/directives/when/fast-build.config.json +0 -6
  197. package/test/declarative/fixtures/directives/when/index.html +0 -136
  198. package/test/declarative/fixtures/directives/when/main.ts +0 -172
  199. package/test/declarative/fixtures/directives/when/state.json +0 -12
  200. package/test/declarative/fixtures/directives/when/templates.html +0 -75
  201. package/test/declarative/fixtures/ecosystem/README.md +0 -11
  202. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/entry.html +0 -12
  203. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/fast-build.config.json +0 -6
  204. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/index.html +0 -20
  205. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/main.ts +0 -68
  206. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/state.json +0 -4
  207. package/test/declarative/fixtures/ecosystem/declarative-no-hydration/templates.html +0 -7
  208. package/test/declarative/fixtures/ecosystem/errors/entry.html +0 -12
  209. package/test/declarative/fixtures/ecosystem/errors/fast-build.config.json +0 -6
  210. package/test/declarative/fixtures/ecosystem/errors/index.html +0 -20
  211. package/test/declarative/fixtures/ecosystem/errors/main.ts +0 -17
  212. package/test/declarative/fixtures/ecosystem/errors/state.json +0 -1
  213. package/test/declarative/fixtures/ecosystem/errors/templates.html +0 -7
  214. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/entry.html +0 -17
  215. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/fast-build.config.json +0 -6
  216. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/index.html +0 -56
  217. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/main.ts +0 -134
  218. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/state.json +0 -12
  219. package/test/declarative/fixtures/ecosystem/lifecycle-callbacks/templates.html +0 -34
  220. package/test/declarative/fixtures/ecosystem/performance-metrics/entry.html +0 -25
  221. package/test/declarative/fixtures/ecosystem/performance-metrics/fast-build.config.json +0 -6
  222. package/test/declarative/fixtures/ecosystem/performance-metrics/fast-card.css +0 -10
  223. package/test/declarative/fixtures/ecosystem/performance-metrics/index.html +0 -181
  224. package/test/declarative/fixtures/ecosystem/performance-metrics/main.ts +0 -58
  225. package/test/declarative/fixtures/ecosystem/performance-metrics/state.json +0 -6
  226. package/test/declarative/fixtures/ecosystem/performance-metrics/templates.html +0 -15
  227. package/test/declarative/fixtures/extensions/README.md +0 -15
  228. package/test/declarative/fixtures/extensions/attribute-map/entry.html +0 -14
  229. package/test/declarative/fixtures/extensions/attribute-map/fast-build.config.json +0 -6
  230. package/test/declarative/fixtures/extensions/attribute-map/index.html +0 -31
  231. package/test/declarative/fixtures/extensions/attribute-map/main.ts +0 -40
  232. package/test/declarative/fixtures/extensions/attribute-map/state.json +0 -4
  233. package/test/declarative/fixtures/extensions/attribute-map/templates.html +0 -14
  234. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/entry.html +0 -12
  235. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/fast-build.config.json +0 -7
  236. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/index.html +0 -25
  237. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/main.ts +0 -31
  238. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/state.json +0 -5
  239. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy/templates.html +0 -11
  240. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/entry.html +0 -13
  241. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/fast-build.config.json +0 -7
  242. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/index.html +0 -23
  243. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/main.ts +0 -37
  244. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/state.json +0 -1
  245. package/test/declarative/fixtures/extensions/attribute-map-naming-strategy-camel-case/templates.html +0 -9
  246. package/test/declarative/fixtures/extensions/observer-map/entry.html +0 -15
  247. package/test/declarative/fixtures/extensions/observer-map/fast-build.config.json +0 -6
  248. package/test/declarative/fixtures/extensions/observer-map/index.html +0 -442
  249. package/test/declarative/fixtures/extensions/observer-map/main.ts +0 -482
  250. package/test/declarative/fixtures/extensions/observer-map/state.json +0 -158
  251. package/test/declarative/fixtures/extensions/observer-map/templates.html +0 -172
  252. package/test/declarative/fixtures/extensions/observer-map-config-object/entry.html +0 -16
  253. package/test/declarative/fixtures/extensions/observer-map-config-object/fast-build.config.json +0 -6
  254. package/test/declarative/fixtures/extensions/observer-map-config-object/index.html +0 -27
  255. package/test/declarative/fixtures/extensions/observer-map-config-object/main.ts +0 -53
  256. package/test/declarative/fixtures/extensions/observer-map-config-object/state.json +0 -9
  257. package/test/declarative/fixtures/extensions/observer-map-config-object/templates.html +0 -12
  258. package/test/declarative/fixtures/extensions/observer-map-deep-merge/README.md +0 -98
  259. package/test/declarative/fixtures/extensions/observer-map-deep-merge/entry.html +0 -156
  260. package/test/declarative/fixtures/extensions/observer-map-deep-merge/fast-build.config.json +0 -6
  261. package/test/declarative/fixtures/extensions/observer-map-deep-merge/index.html +0 -376
  262. package/test/declarative/fixtures/extensions/observer-map-deep-merge/main.ts +0 -366
  263. package/test/declarative/fixtures/extensions/observer-map-deep-merge/state.json +0 -69
  264. package/test/declarative/fixtures/extensions/observer-map-deep-merge/templates.html +0 -91
  265. package/test/declarative/fixtures/extensions/observer-map-properties/entry.html +0 -14
  266. package/test/declarative/fixtures/extensions/observer-map-properties/fast-build.config.json +0 -6
  267. package/test/declarative/fixtures/extensions/observer-map-properties/index.html +0 -110
  268. package/test/declarative/fixtures/extensions/observer-map-properties/main.ts +0 -175
  269. package/test/declarative/fixtures/extensions/observer-map-properties/state.json +0 -29
  270. package/test/declarative/fixtures/extensions/observer-map-properties/templates.html +0 -55
  271. package/test/declarative/fixtures/scenarios/README.md +0 -7
  272. package/test/declarative/fixtures/scenarios/nested-elements/entry.html +0 -16
  273. package/test/declarative/fixtures/scenarios/nested-elements/fast-build.config.json +0 -6
  274. package/test/declarative/fixtures/scenarios/nested-elements/index.html +0 -126
  275. package/test/declarative/fixtures/scenarios/nested-elements/main.ts +0 -214
  276. package/test/declarative/fixtures/scenarios/nested-elements/state.json +0 -10
  277. package/test/declarative/fixtures/scenarios/nested-elements/templates.html +0 -54
  278. package/test/declarative/index.html +0 -12
  279. package/test/declarative/vite.config.ts +0 -55
  280. package/test/declarative-main.ts +0 -6
  281. package/test/extension-subpaths-main.ts +0 -9
  282. package/test/index.html +0 -11
  283. package/test/main.ts +0 -109
  284. package/test/pure-declarative-main.ts +0 -1
  285. package/test/vite.config.ts +0 -19
  286. package/tsconfig.api-extractor.json +0 -6
@@ -1,482 +0,0 @@
1
- import { attr } from "@microsoft/fast-element/attr.js";
2
- import { declarativeTemplate } from "@microsoft/fast-element/declarative.js";
3
- import { FASTElement } from "@microsoft/fast-element/fast-element.js";
4
- import { enableHydration } from "@microsoft/fast-element/hydration.js";
5
- import { Observable, observable } from "@microsoft/fast-element/observable.js";
6
- import { observerMap } from "@microsoft/fast-element/observer-map.js";
7
-
8
- class ObserverMapTestElement extends FASTElement {
9
- public users: any[] = [
10
- {
11
- id: 1,
12
- name: "Alice Johnson",
13
- details: {
14
- personal: {
15
- age: 28,
16
- location: {
17
- city: "New York",
18
- country: "USA",
19
- coordinates: {
20
- lat: 40.7128,
21
- lng: -74.006,
22
- },
23
- },
24
- },
25
- preferences: {
26
- theme: "dark",
27
- notifications: {
28
- email: true,
29
- push: false,
30
- settings: {
31
- frequency: "daily",
32
- categories: ["tech", "news"],
33
- },
34
- },
35
- },
36
- },
37
- posts: [
38
- {
39
- id: 101,
40
- title: "First Post",
41
- content: "Hello World!",
42
- metadata: {
43
- views: 150,
44
- likes: 25,
45
- tags: ["introduction", "hello"],
46
- author: {
47
- name: "Alice Johnson",
48
- verified: true,
49
- },
50
- },
51
- },
52
- {
53
- id: 102,
54
- title: "Tech Update",
55
- content: "Latest in technology...",
56
- metadata: {
57
- views: 320,
58
- likes: 45,
59
- tags: ["tech", "update"],
60
- author: {
61
- name: "Alice Johnson",
62
- verified: true,
63
- },
64
- },
65
- },
66
- ],
67
- },
68
- {
69
- id: 2,
70
- name: "Bob Smith",
71
- details: {
72
- personal: {
73
- age: 35,
74
- location: {
75
- city: "London",
76
- country: "UK",
77
- coordinates: {
78
- lat: 51.5074,
79
- lng: -0.1278,
80
- },
81
- },
82
- },
83
- preferences: {
84
- theme: "light",
85
- notifications: {
86
- email: false,
87
- push: true,
88
- settings: {
89
- frequency: "weekly",
90
- categories: ["sports", "music"],
91
- },
92
- },
93
- },
94
- },
95
- posts: [
96
- {
97
- id: 201,
98
- title: "Music Review",
99
- content: "Amazing concert last night...",
100
- metadata: {
101
- views: 89,
102
- likes: 12,
103
- tags: ["music", "review"],
104
- author: {
105
- name: "Bob Smith",
106
- verified: false,
107
- },
108
- },
109
- },
110
- ],
111
- },
112
- ];
113
-
114
- public selecteduserid: number = 1;
115
-
116
- public stats = {
117
- totalusers: 2,
118
- activeusers: 1,
119
- metrics: {
120
- engagement: {
121
- daily: 100,
122
- weekly: 500,
123
- monthly: 2000,
124
- },
125
- performance: {
126
- loadtime: 1.2,
127
- rendertime: 0.8,
128
- },
129
- },
130
- };
131
-
132
- // Methods to test deeply nested property changes
133
- public updateUserAge = (userId: number) => {
134
- const user = this.users.find(u => u.id === userId);
135
- if (user) {
136
- user.details.personal.age += 1;
137
- }
138
- };
139
-
140
- public toggleUserTheme = (userId: number) => {
141
- const user = this.users.find(u => u.id === userId);
142
- if (user) {
143
- user.details.preferences.theme =
144
- user.details.preferences.theme === "dark" ? "light" : "dark";
145
- }
146
- };
147
-
148
- public updateUserLocation = (userId: number) => {
149
- const user = this.users.find(u => u.id === userId);
150
- if (user) {
151
- // Use hardcoded values since we can only pass single argument
152
- user.details.personal.location.city = "Tokyo";
153
- user.details.personal.location.country = "Japan";
154
- // Update coordinates randomly for demo
155
- user.details.personal.location.coordinates.lat = Math.random() * 180 - 90;
156
- user.details.personal.location.coordinates.lng = Math.random() * 360 - 180;
157
- }
158
- };
159
-
160
- public addPostToUser = (userId: number) => {
161
- const user = this.users.find(u => u.id === userId);
162
- if (user) {
163
- const newPostId = Math.max(...user.posts.map((p: any) => p.id)) + 1;
164
- user.posts.push({
165
- id: newPostId,
166
- title: `New Post ${newPostId}`,
167
- content: `This is a new post with ID ${newPostId}`,
168
- metadata: {
169
- views: 0,
170
- likes: 0,
171
- tags: ["new", "auto-generated"],
172
- author: {
173
- name: user.name,
174
- verified: Math.random() > 0.5,
175
- },
176
- },
177
- });
178
- }
179
- };
180
-
181
- public incrementPostLikes = (postId: number) => {
182
- // Find the post across all users since we only have postId
183
- for (const user of this.users) {
184
- const post = user.posts.find((p: any) => p.id === postId);
185
- if (post) {
186
- post.metadata.likes += 1;
187
- post.metadata.views += Math.floor(Math.random() * 5) + 1;
188
- break;
189
- }
190
- }
191
- };
192
-
193
- public updateNotificationSettings = (userId: number) => {
194
- const user = this.users.find(u => u.id === userId);
195
- if (user) {
196
- user.details.preferences.notifications.email =
197
- !user.details.preferences.notifications.email;
198
- user.details.preferences.notifications.push =
199
- !user.details.preferences.notifications.push;
200
-
201
- // Cycle through frequency options
202
- const frequencies = ["daily", "weekly", "monthly"];
203
- const currentIndex = frequencies.indexOf(
204
- user.details.preferences.notifications.settings.frequency,
205
- );
206
- const nextIndex = (currentIndex + 1) % frequencies.length;
207
- user.details.preferences.notifications.settings.frequency =
208
- frequencies[nextIndex];
209
- }
210
- };
211
-
212
- public addNotificationCategory = (userId: number) => {
213
- const user = this.users.find(u => u.id === userId);
214
- if (user) {
215
- // Use hardcoded category since we can only pass single argument
216
- const category = "sports";
217
- if (
218
- !user.details.preferences.notifications.settings.categories.includes(
219
- category,
220
- )
221
- ) {
222
- user.details.preferences.notifications.settings.categories.push(category);
223
- }
224
- }
225
- };
226
-
227
- public removeNotificationCategory = (userId: number) => {
228
- const user = this.users.find(u => u.id === userId);
229
- if (user) {
230
- // Use hardcoded category since we can only pass single argument
231
- const category = "tech";
232
- const index =
233
- user.details.preferences.notifications.settings.categories.indexOf(
234
- category,
235
- );
236
- if (index > -1) {
237
- user.details.preferences.notifications.settings.categories.splice(
238
- index,
239
- 1,
240
- );
241
- }
242
- }
243
- };
244
-
245
- public addNewUser = () => {
246
- const newId = Math.max(...this.users.map(u => u.id)) + 1;
247
- this.users.push({
248
- id: newId,
249
- name: `User ${newId}`,
250
- details: {
251
- personal: {
252
- age: Math.floor(Math.random() * 50) + 18,
253
- location: {
254
- city: "Random City",
255
- country: "Random Country",
256
- coordinates: {
257
- lat: Math.random() * 180 - 90,
258
- lng: Math.random() * 360 - 180,
259
- },
260
- },
261
- },
262
- preferences: {
263
- theme: "dark",
264
- notifications: {
265
- email: Math.random() > 0.5,
266
- push: Math.random() > 0.5,
267
- settings: {
268
- frequency: ["daily", "weekly", "monthly"][
269
- Math.floor(Math.random() * 3)
270
- ],
271
- categories: ["general"],
272
- },
273
- },
274
- },
275
- },
276
- posts: [],
277
- });
278
- this.stats.totalusers = this.users.length;
279
- };
280
-
281
- public removeUser = (userId: number) => {
282
- const index = this.users.findIndex(u => u.id === userId);
283
- if (index > -1) {
284
- this.users.splice(index, 1);
285
- this.stats.totalusers = this.users.length;
286
- }
287
- };
288
-
289
- public updateStats = () => {
290
- this.stats.metrics.engagement.daily += Math.floor(Math.random() * 10);
291
- this.stats.metrics.engagement.weekly += Math.floor(Math.random() * 20);
292
- this.stats.metrics.engagement.monthly += Math.floor(Math.random() * 50);
293
- this.stats.metrics.performance.loadtime = Math.random() * 2 + 0.5;
294
- this.stats.metrics.performance.rendertime = Math.random() * 1 + 0.3;
295
- };
296
-
297
- public selectUser = (userId: number) => {
298
- this.selecteduserid = userId;
299
- };
300
- }
301
-
302
- class ObserverMapInternalTestElement extends FASTElement {
303
- public selecteduserid?: number;
304
- public totalusers?: number;
305
-
306
- public a: any = {};
307
-
308
- public x: any = undefined;
309
-
310
- public groups = [
311
- {
312
- items: [
313
- {
314
- text: "item A",
315
- actions: {
316
- trailing: [
317
- {
318
- label: "action label A",
319
- },
320
- ],
321
- },
322
- },
323
- ],
324
- },
325
- ];
326
-
327
- public removeAllItems() {
328
- this.groups[0].items.shift();
329
- }
330
-
331
- public addAnItem() {
332
- this.groups[0].items.push({
333
- text: "item B",
334
- actions: {
335
- trailing: [
336
- {
337
- label: "action label A",
338
- },
339
- ],
340
- },
341
- });
342
- }
343
-
344
- public updateAnItem() {
345
- this.groups[0].items[0].text = "item C";
346
- }
347
-
348
- public removeGroup() {
349
- this.groups = [];
350
- }
351
-
352
- public addGroup() {
353
- this.groups = [
354
- {
355
- items: [
356
- {
357
- text: "item A",
358
- actions: {
359
- trailing: [
360
- {
361
- label: "action label A",
362
- },
363
- ],
364
- },
365
- },
366
- ],
367
- },
368
- ];
369
- }
370
-
371
- public updateActionLabel() {
372
- this.groups[0].items[0].actions.trailing[0].label = "action label B";
373
- }
374
-
375
- public defineB() {
376
- this.a = {
377
- b: {
378
- c: "Hello world",
379
- },
380
- };
381
- }
382
-
383
- public updateC() {
384
- this.a.b.c = "Hello pluto";
385
- }
386
-
387
- public defineY() {
388
- this.x = {
389
- y: {
390
- z: "Z1",
391
- },
392
- };
393
- }
394
-
395
- public updateZ() {
396
- this.x.y.z = "Z2";
397
- }
398
- }
399
-
400
- (window as any).messages = [];
401
-
402
- class ObserverMapWithObservablesTestElement extends FASTElement {
403
- @observable
404
- public value1: number = 42;
405
-
406
- value1Changed(previous: any, current: any) {
407
- (window as any).messages.push(`value1 changed from ${previous} to ${current}`);
408
- }
409
-
410
- public updateValue1() {
411
- this.value1 += 1;
412
- }
413
-
414
- public value2: number = 42;
415
-
416
- value2Changed(previous: any, current: any) {
417
- (window as any).messages.push(`value2 changed from ${previous} to ${current}`);
418
- }
419
-
420
- @attr({ attribute: "some-attribute" })
421
- attribute: string = "initial";
422
-
423
- attributeChanged(previous: string, current: string) {
424
- (window as any).messages.push(`attribute changed from ${previous} to ${current}`);
425
- }
426
-
427
- public updateValue2() {
428
- this.value2 += 1;
429
- }
430
- }
431
-
432
- ObserverMapInternalTestElement.define(
433
- {
434
- name: "observer-map-internal-test-element",
435
- template: declarativeTemplate(),
436
- },
437
- [observerMap()],
438
- );
439
-
440
- ObserverMapTestElement.define(
441
- {
442
- name: "observer-map-test-element",
443
- template: declarativeTemplate(),
444
- },
445
- [observerMap()],
446
- );
447
-
448
- ObserverMapWithObservablesTestElement.define(
449
- {
450
- name: "observer-map-with-observables-test-element",
451
- template: declarativeTemplate(),
452
- },
453
- [observerMap()],
454
- );
455
-
456
- class ObserverMapSimpleArrayTestElement extends FASTElement {
457
- public items: string[] = ["foo", "baz"];
458
-
459
- public updateFirstItem() {
460
- this.items[0] = "bar";
461
- }
462
-
463
- public updateSecondItem() {
464
- this.items[1] = "qux";
465
- }
466
- }
467
-
468
- ObserverMapSimpleArrayTestElement.define(
469
- {
470
- name: "observer-map-simple-array-test-element",
471
- template: declarativeTemplate(),
472
- },
473
- [observerMap()],
474
- );
475
-
476
- enableHydration({
477
- hydrationComplete() {
478
- (window as any).hydrationCompleted = true;
479
- },
480
- });
481
-
482
- (window as any).Observable = Observable;
@@ -1,158 +0,0 @@
1
- {
2
- "items": ["foo", "baz"],
3
- "value1": 42,
4
- "value2": 42,
5
- "selecteduserid": 1,
6
- "totalusers": 2,
7
- "metrics": {
8
- "engagement": {
9
- "daily": 100,
10
- "weekly": 500,
11
- "monthly": 2000
12
- },
13
- "performance": {
14
- "loadtime": 1.2,
15
- "rendertime": 0.8
16
- }
17
- },
18
- "groups": [
19
- {
20
- "items": [
21
- {
22
- "text": "item A",
23
- "actions": {
24
- "trailing": [
25
- {
26
- "label": "action label A"
27
- }
28
- ]
29
- }
30
- }
31
- ]
32
- }
33
- ],
34
- "a": {
35
- "b": {
36
- "c": ""
37
- }
38
- },
39
- "stats": {
40
- "totalusers": 2,
41
- "activeusers": 1,
42
- "metrics": {
43
- "performance": {
44
- "loadtime": 1.2,
45
- "rendertime": 0.8
46
- },
47
- "engagement": {
48
- "daily": 100,
49
- "weekly": 500,
50
- "monthly": 2000
51
- }
52
- }
53
- },
54
- "users": [
55
- {
56
- "id": 1,
57
- "name": "Alice Johnson",
58
- "details": {
59
- "personal": {
60
- "age": 28,
61
- "location": {
62
- "city": "New York",
63
- "country": "USA",
64
- "coordinates": {
65
- "lat": 40.7128,
66
- "lng": -74.006
67
- }
68
- }
69
- },
70
- "preferences": {
71
- "theme": "dark",
72
- "notifications": {
73
- "email": true,
74
- "push": false,
75
- "settings": {
76
- "frequency": "daily",
77
- "categories": ["tech", "news"]
78
- }
79
- }
80
- }
81
- },
82
- "posts": [
83
- {
84
- "id": 101,
85
- "title": "First Post",
86
- "content": "Hello World!",
87
- "metadata": {
88
- "views": 150,
89
- "likes": 25,
90
- "tags": ["introduction", "hello"],
91
- "author": {
92
- "name": "Alice Johnson",
93
- "verified": true
94
- }
95
- }
96
- },
97
- {
98
- "id": 102,
99
- "title": "Tech Update",
100
- "content": "Latest in technology...",
101
- "metadata": {
102
- "views": 320,
103
- "likes": 45,
104
- "tags": ["tech", "update"],
105
- "author": {
106
- "name": "Alice Johnson",
107
- "verified": true
108
- }
109
- }
110
- }
111
- ]
112
- },
113
- {
114
- "id": 2,
115
- "name": "Bob Smith",
116
- "details": {
117
- "personal": {
118
- "age": 35,
119
- "location": {
120
- "city": "London",
121
- "country": "UK",
122
- "coordinates": {
123
- "lat": 51.5074,
124
- "lng": -0.1278
125
- }
126
- }
127
- },
128
- "preferences": {
129
- "theme": "light",
130
- "notifications": {
131
- "email": false,
132
- "push": true,
133
- "settings": {
134
- "frequency": "weekly",
135
- "categories": ["sports", "music"]
136
- }
137
- }
138
- }
139
- },
140
- "posts": [
141
- {
142
- "id": 201,
143
- "title": "Music Review",
144
- "content": "Amazing concert last night...",
145
- "metadata": {
146
- "views": 89,
147
- "likes": 12,
148
- "tags": ["music", "review"],
149
- "author": {
150
- "name": "Bob Smith",
151
- "verified": false
152
- }
153
- }
154
- }
155
- ]
156
- }
157
- ]
158
- }