@microsoft/fast-html 1.0.0-alpha.30 → 1.0.0-alpha.32

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 (52) hide show
  1. package/dist/dts/components/observer-map.d.ts +1 -1
  2. package/dist/dts/components/schema.d.ts +1 -1
  3. package/dist/dts/components/utilities.d.ts +20 -18
  4. package/dist/esm/components/utilities.js +116 -71
  5. package/package.json +17 -32
  6. package/dist/dts/components/request-idle-callback.d.ts +0 -41
  7. package/dist/dts/fixtures/attribute/attribute.spec.d.ts +0 -1
  8. package/dist/dts/fixtures/attribute/main.d.ts +0 -1
  9. package/dist/dts/fixtures/binding/binding.spec.d.ts +0 -1
  10. package/dist/dts/fixtures/binding/main.d.ts +0 -1
  11. package/dist/dts/fixtures/children/children.spec.d.ts +0 -1
  12. package/dist/dts/fixtures/children/main.d.ts +0 -1
  13. package/dist/dts/fixtures/dot-syntax/dot-syntax.spec.d.ts +0 -1
  14. package/dist/dts/fixtures/dot-syntax/main.d.ts +0 -1
  15. package/dist/dts/fixtures/event/event.spec.d.ts +0 -1
  16. package/dist/dts/fixtures/event/main.d.ts +0 -1
  17. package/dist/dts/fixtures/lifecycle-callbacks/lifecycle-callbacks.spec.d.ts +0 -1
  18. package/dist/dts/fixtures/lifecycle-callbacks/main.d.ts +0 -5
  19. package/dist/dts/fixtures/observer-map/main.d.ts +0 -1
  20. package/dist/dts/fixtures/observer-map/observer-map.spec.d.ts +0 -1
  21. package/dist/dts/fixtures/ref/main.d.ts +0 -1
  22. package/dist/dts/fixtures/ref/ref.spec.d.ts +0 -1
  23. package/dist/dts/fixtures/repeat/main.d.ts +0 -1
  24. package/dist/dts/fixtures/repeat/repeat.spec.d.ts +0 -1
  25. package/dist/dts/fixtures/slotted/main.d.ts +0 -1
  26. package/dist/dts/fixtures/slotted/slotted.spec.d.ts +0 -1
  27. package/dist/dts/fixtures/when/main.d.ts +0 -1
  28. package/dist/dts/fixtures/when/when.spec.d.ts +0 -1
  29. package/dist/esm/components/request-idle-callback.js +0 -72
  30. package/dist/esm/fixtures/attribute/attribute.spec.js +0 -23
  31. package/dist/esm/fixtures/attribute/main.js +0 -20
  32. package/dist/esm/fixtures/binding/binding.spec.js +0 -23
  33. package/dist/esm/fixtures/binding/main.js +0 -30
  34. package/dist/esm/fixtures/children/children.spec.js +0 -37
  35. package/dist/esm/fixtures/children/main.js +0 -25
  36. package/dist/esm/fixtures/dot-syntax/dot-syntax.spec.js +0 -116
  37. package/dist/esm/fixtures/dot-syntax/main.js +0 -42
  38. package/dist/esm/fixtures/event/event.spec.js +0 -35
  39. package/dist/esm/fixtures/event/main.js +0 -32
  40. package/dist/esm/fixtures/lifecycle-callbacks/lifecycle-callbacks.spec.js +0 -166
  41. package/dist/esm/fixtures/lifecycle-callbacks/main.js +0 -126
  42. package/dist/esm/fixtures/observer-map/main.js +0 -375
  43. package/dist/esm/fixtures/observer-map/observer-map.spec.js +0 -251
  44. package/dist/esm/fixtures/ref/main.js +0 -15
  45. package/dist/esm/fixtures/ref/ref.spec.js +0 -9
  46. package/dist/esm/fixtures/repeat/main.js +0 -44
  47. package/dist/esm/fixtures/repeat/repeat.spec.js +0 -36
  48. package/dist/esm/fixtures/slotted/main.js +0 -33
  49. package/dist/esm/fixtures/slotted/slotted.spec.js +0 -24
  50. package/dist/esm/fixtures/when/main.js +0 -156
  51. package/dist/esm/fixtures/when/when.spec.js +0 -82
  52. package/dist/esm/tsconfig.tsbuildinfo +0 -1
@@ -1,126 +0,0 @@
1
- import { __awaiter, __decorate, __metadata } from "tslib";
2
- import { RenderableFASTElement, TemplateElement } from "@microsoft/fast-html";
3
- import { attr, FASTElement, observable } from "@microsoft/fast-element";
4
- // Track lifecycle callbacks for testing
5
- export const lifecycleEvents = [];
6
- // Track hydration complete
7
- export let hydrationCompleteEmitted = false;
8
- // Configure lifecycle callbacks
9
- TemplateElement.config({
10
- elementDidRegister(name) {
11
- lifecycleEvents.push({ callback: "elementDidRegister", name });
12
- },
13
- templateWillUpdate(name) {
14
- lifecycleEvents.push({ callback: "templateWillUpdate", name });
15
- },
16
- templateDidUpdate(name) {
17
- lifecycleEvents.push({ callback: "templateDidUpdate", name });
18
- },
19
- elementDidDefine(name) {
20
- lifecycleEvents.push({ callback: "elementDidDefine", name });
21
- },
22
- elementWillHydrate(name) {
23
- lifecycleEvents.push({ callback: "elementWillHydrate", name });
24
- },
25
- elementDidHydrate(name) {
26
- lifecycleEvents.push({ callback: "elementDidHydrate", name });
27
- },
28
- hydrationComplete() {
29
- lifecycleEvents.push({ callback: "hydrationComplete" });
30
- hydrationCompleteEmitted = true;
31
- },
32
- });
33
- // Simple element with basic property
34
- class SimpleElement extends FASTElement {
35
- constructor() {
36
- super(...arguments);
37
- this.message = "Hello";
38
- }
39
- }
40
- __decorate([
41
- attr,
42
- __metadata("design:type", String)
43
- ], SimpleElement.prototype, "message", void 0);
44
- RenderableFASTElement(SimpleElement).defineAsync({
45
- name: "simple-element",
46
- templateOptions: "defer-and-hydrate",
47
- });
48
- // Complex element with multiple properties and methods
49
- class ComplexElement extends FASTElement {
50
- constructor() {
51
- super(...arguments);
52
- this.title = "Complex";
53
- this.count = 0;
54
- this.items = [];
55
- }
56
- increment() {
57
- this.count++;
58
- }
59
- addItem(item) {
60
- this.items = [...this.items, item];
61
- }
62
- }
63
- __decorate([
64
- attr,
65
- __metadata("design:type", String)
66
- ], ComplexElement.prototype, "title", void 0);
67
- __decorate([
68
- observable,
69
- __metadata("design:type", Number)
70
- ], ComplexElement.prototype, "count", void 0);
71
- __decorate([
72
- observable,
73
- __metadata("design:type", Array)
74
- ], ComplexElement.prototype, "items", void 0);
75
- RenderableFASTElement(ComplexElement).defineAsync({
76
- name: "complex-element",
77
- templateOptions: "defer-and-hydrate",
78
- });
79
- // Nested element
80
- class NestedElement extends FASTElement {
81
- constructor() {
82
- super(...arguments);
83
- this.label = "Nested";
84
- }
85
- }
86
- __decorate([
87
- attr,
88
- __metadata("design:type", String)
89
- ], NestedElement.prototype, "label", void 0);
90
- RenderableFASTElement(NestedElement).defineAsync({
91
- name: "nested-element",
92
- templateOptions: "defer-and-hydrate",
93
- });
94
- // Element with deferred hydration
95
- class DeferredElement extends FASTElement {
96
- constructor() {
97
- super(...arguments);
98
- this.status = "pending";
99
- }
100
- prepare() {
101
- return __awaiter(this, void 0, void 0, function* () {
102
- // Simulate async work
103
- yield new Promise(resolve => setTimeout(resolve, 100));
104
- this.status = "ready";
105
- });
106
- }
107
- }
108
- __decorate([
109
- attr,
110
- __metadata("design:type", String)
111
- ], DeferredElement.prototype, "status", void 0);
112
- RenderableFASTElement(DeferredElement).defineAsync({
113
- name: "deferred-element",
114
- templateOptions: "defer-and-hydrate",
115
- });
116
- // Define templates
117
- TemplateElement.options({
118
- "complex-element": {
119
- observerMap: "all",
120
- },
121
- }).define({
122
- name: "f-template",
123
- });
124
- // Make lifecycleEvents available globally for testing
125
- window.lifecycleEvents = lifecycleEvents;
126
- window.getHydrationCompleteStatus = () => hydrationCompleteEmitted;
@@ -1,375 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- import { FASTElement } from "@microsoft/fast-element";
3
- import { TemplateElement } from "../../components/index.js";
4
- class ObserverMapTestElement extends FASTElement {
5
- constructor() {
6
- super(...arguments);
7
- this.users = [
8
- {
9
- id: 1,
10
- name: "Alice Johnson",
11
- details: {
12
- personal: {
13
- age: 28,
14
- location: {
15
- city: "New York",
16
- country: "USA",
17
- coordinates: {
18
- lat: 40.7128,
19
- lng: -74.006,
20
- },
21
- },
22
- },
23
- preferences: {
24
- theme: "dark",
25
- notifications: {
26
- email: true,
27
- push: false,
28
- settings: {
29
- frequency: "daily",
30
- categories: ["tech", "news"],
31
- },
32
- },
33
- },
34
- },
35
- posts: [
36
- {
37
- id: 101,
38
- title: "First Post",
39
- content: "Hello World!",
40
- metadata: {
41
- views: 150,
42
- likes: 25,
43
- tags: ["introduction", "hello"],
44
- author: {
45
- name: "Alice Johnson",
46
- verified: true,
47
- },
48
- },
49
- },
50
- {
51
- id: 102,
52
- title: "Tech Update",
53
- content: "Latest in technology...",
54
- metadata: {
55
- views: 320,
56
- likes: 45,
57
- tags: ["tech", "update"],
58
- author: {
59
- name: "Alice Johnson",
60
- verified: true,
61
- },
62
- },
63
- },
64
- ],
65
- },
66
- {
67
- id: 2,
68
- name: "Bob Smith",
69
- details: {
70
- personal: {
71
- age: 35,
72
- location: {
73
- city: "London",
74
- country: "UK",
75
- coordinates: {
76
- lat: 51.5074,
77
- lng: -0.1278,
78
- },
79
- },
80
- },
81
- preferences: {
82
- theme: "light",
83
- notifications: {
84
- email: false,
85
- push: true,
86
- settings: {
87
- frequency: "weekly",
88
- categories: ["sports", "music"],
89
- },
90
- },
91
- },
92
- },
93
- posts: [
94
- {
95
- id: 201,
96
- title: "Music Review",
97
- content: "Amazing concert last night...",
98
- metadata: {
99
- views: 89,
100
- likes: 12,
101
- tags: ["music", "review"],
102
- author: {
103
- name: "Bob Smith",
104
- verified: false,
105
- },
106
- },
107
- },
108
- ],
109
- },
110
- ];
111
- this.selectedUserId = 1;
112
- this.stats = {
113
- totalUsers: 2,
114
- activeUsers: 1,
115
- metrics: {
116
- engagement: {
117
- daily: 45,
118
- weekly: 120,
119
- monthly: 500,
120
- },
121
- performance: {
122
- loadTime: 1.2,
123
- renderTime: 0.8,
124
- },
125
- },
126
- };
127
- // Methods to test deeply nested property changes
128
- this.updateUserAge = (userId) => {
129
- const user = this.users.find(u => u.id === userId);
130
- if (user) {
131
- user.details.personal.age += 1;
132
- }
133
- };
134
- this.toggleUserTheme = (userId) => {
135
- const user = this.users.find(u => u.id === userId);
136
- if (user) {
137
- user.details.preferences.theme =
138
- user.details.preferences.theme === "dark" ? "light" : "dark";
139
- }
140
- };
141
- this.updateUserLocation = (userId) => {
142
- const user = this.users.find(u => u.id === userId);
143
- if (user) {
144
- // Use hardcoded values since we can only pass single argument
145
- user.details.personal.location.city = "Tokyo";
146
- user.details.personal.location.country = "Japan";
147
- // Update coordinates randomly for demo
148
- user.details.personal.location.coordinates.lat = Math.random() * 180 - 90;
149
- user.details.personal.location.coordinates.lng = Math.random() * 360 - 180;
150
- }
151
- };
152
- this.addPostToUser = (userId) => {
153
- const user = this.users.find(u => u.id === userId);
154
- if (user) {
155
- const newPostId = Math.max(...user.posts.map((p) => p.id)) + 1;
156
- user.posts.push({
157
- id: newPostId,
158
- title: `New Post ${newPostId}`,
159
- content: `This is a new post with ID ${newPostId}`,
160
- metadata: {
161
- views: 0,
162
- likes: 0,
163
- tags: ["new", "auto-generated"],
164
- author: {
165
- name: user.name,
166
- verified: Math.random() > 0.5,
167
- },
168
- },
169
- });
170
- }
171
- };
172
- this.incrementPostLikes = (postId) => {
173
- // Find the post across all users since we only have postId
174
- for (const user of this.users) {
175
- const post = user.posts.find((p) => p.id === postId);
176
- if (post) {
177
- post.metadata.likes += 1;
178
- post.metadata.views += Math.floor(Math.random() * 5) + 1;
179
- break;
180
- }
181
- }
182
- };
183
- this.updateNotificationSettings = (userId) => {
184
- const user = this.users.find(u => u.id === userId);
185
- if (user) {
186
- user.details.preferences.notifications.email =
187
- !user.details.preferences.notifications.email;
188
- user.details.preferences.notifications.push =
189
- !user.details.preferences.notifications.push;
190
- // Cycle through frequency options
191
- const frequencies = ["daily", "weekly", "monthly"];
192
- const currentIndex = frequencies.indexOf(user.details.preferences.notifications.settings.frequency);
193
- const nextIndex = (currentIndex + 1) % frequencies.length;
194
- user.details.preferences.notifications.settings.frequency =
195
- frequencies[nextIndex];
196
- }
197
- };
198
- this.addNotificationCategory = (userId) => {
199
- const user = this.users.find(u => u.id === userId);
200
- if (user) {
201
- // Use hardcoded category since we can only pass single argument
202
- const category = "sports";
203
- if (!user.details.preferences.notifications.settings.categories.includes(category)) {
204
- user.details.preferences.notifications.settings.categories.push(category);
205
- }
206
- }
207
- };
208
- this.removeNotificationCategory = (userId) => {
209
- const user = this.users.find(u => u.id === userId);
210
- if (user) {
211
- // Use hardcoded category since we can only pass single argument
212
- const category = "tech";
213
- const index = user.details.preferences.notifications.settings.categories.indexOf(category);
214
- if (index > -1) {
215
- user.details.preferences.notifications.settings.categories.splice(index, 1);
216
- }
217
- }
218
- };
219
- this.addNewUser = () => {
220
- const newId = Math.max(...this.users.map(u => u.id)) + 1;
221
- this.users.push({
222
- id: newId,
223
- name: `User ${newId}`,
224
- details: {
225
- personal: {
226
- age: Math.floor(Math.random() * 50) + 18,
227
- location: {
228
- city: "Random City",
229
- country: "Random Country",
230
- coordinates: {
231
- lat: Math.random() * 180 - 90,
232
- lng: Math.random() * 360 - 180,
233
- },
234
- },
235
- },
236
- preferences: {
237
- theme: "dark",
238
- notifications: {
239
- email: Math.random() > 0.5,
240
- push: Math.random() > 0.5,
241
- settings: {
242
- frequency: ["daily", "weekly", "monthly"][Math.floor(Math.random() * 3)],
243
- categories: ["general"],
244
- },
245
- },
246
- },
247
- },
248
- posts: [],
249
- });
250
- this.stats.totalUsers = this.users.length;
251
- };
252
- this.removeUser = (userId) => {
253
- const index = this.users.findIndex(u => u.id === userId);
254
- if (index > -1) {
255
- this.users.splice(index, 1);
256
- this.stats.totalUsers = this.users.length;
257
- }
258
- };
259
- this.updateStats = () => {
260
- this.stats.metrics.engagement.daily += Math.floor(Math.random() * 10);
261
- this.stats.metrics.engagement.weekly += Math.floor(Math.random() * 20);
262
- this.stats.metrics.engagement.monthly += Math.floor(Math.random() * 50);
263
- this.stats.metrics.performance.loadTime = Math.random() * 2 + 0.5;
264
- this.stats.metrics.performance.renderTime = Math.random() * 1 + 0.3;
265
- };
266
- this.selectUser = (userId) => {
267
- this.selectedUserId = userId;
268
- };
269
- }
270
- }
271
- class ObserverMapInternalTestElement extends FASTElement {
272
- constructor() {
273
- super(...arguments);
274
- this.a = {};
275
- this.x = undefined;
276
- this.groups = [
277
- {
278
- items: [
279
- {
280
- text: "item A",
281
- actions: {
282
- trailing: [
283
- {
284
- label: "action label A",
285
- },
286
- ],
287
- },
288
- },
289
- ],
290
- },
291
- ];
292
- }
293
- removeAllItems() {
294
- this.groups[0].items.shift();
295
- }
296
- addAnItem() {
297
- this.groups[0].items.push({
298
- text: "item B",
299
- actions: {
300
- trailing: [
301
- {
302
- label: "action label A",
303
- },
304
- ],
305
- },
306
- });
307
- }
308
- updateAnItem() {
309
- this.groups[0].items[0].text = "item C";
310
- }
311
- removeGroup() {
312
- this.groups = [];
313
- }
314
- addGroup() {
315
- this.groups = [
316
- {
317
- items: [
318
- {
319
- text: "item A",
320
- actions: {
321
- trailing: [
322
- {
323
- label: "action label A",
324
- },
325
- ],
326
- },
327
- },
328
- ],
329
- },
330
- ];
331
- }
332
- updateActionLabel() {
333
- this.groups[0].items[0].actions.trailing[0].label = "action label B";
334
- }
335
- defineB() {
336
- this.a = {
337
- b: {
338
- c: "Hello world",
339
- },
340
- };
341
- }
342
- updateC() {
343
- this.a.b.c = "Hello pluto";
344
- }
345
- defineY() {
346
- this.x = {
347
- y: {
348
- z: "Z1",
349
- },
350
- };
351
- }
352
- updateZ() {
353
- this.x.y.z = "Z2";
354
- }
355
- }
356
- // Nested child components must be defined first
357
- (() => __awaiter(void 0, void 0, void 0, function* () {
358
- yield ObserverMapInternalTestElement.defineAsync({
359
- name: "observer-map-internal-test-element",
360
- });
361
- yield ObserverMapTestElement.defineAsync({
362
- name: "observer-map-test-element",
363
- });
364
- }))();
365
- // Configure TemplateElement with observerMap enabled for this test
366
- TemplateElement.options({
367
- "observer-map-test-element": {
368
- observerMap: "all", // Enable ObserverMap to track all the nested property changes
369
- },
370
- "observer-map-internal-test-element": {
371
- observerMap: "all", // Enable ObserverMap to track all the nested property changes
372
- },
373
- }).define({
374
- name: "f-template",
375
- });