@design.estate/dees-wcctools 1.0.96 → 1.0.97

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@design.estate/dees-wcctools",
3
- "version": "1.0.96",
3
+ "version": "1.0.97",
4
4
  "private": false,
5
5
  "description": "A set of web component tools for creating element catalogues, enabling the structured development and documentation of custom elements and pages.",
6
6
  "exports": {
package/readme.hints.md CHANGED
@@ -12,10 +12,16 @@ The properties panel had timing issues detecting rendered elements because:
12
12
  1. Added a 100ms initial delay to allow render completion
13
13
  2. Implemented recursive element search that:
14
14
  - Searches through nested children up to 5 levels deep
15
- - Checks shadow roots of elements
16
- - Handles complex DOM structures
15
+ - Checks both light DOM and shadow DOM for all elements
16
+ - Handles complex DOM structures generically
17
+ - Works with any wrapper elements, not specific to dees-demowrapper
17
18
  3. Added retry mechanism with up to 5 attempts (200ms between retries)
18
19
  4. Improved error messages to show retry count
20
+ 5. Comprehensive error handling:
21
+ - Errors in element search don't break the update cycle
22
+ - Individual property errors don't prevent other properties from rendering
23
+ - scheduleUpdate always completes even if createProperties fails
24
+ - Clears warnings and property content appropriately on errors
19
25
 
20
26
  ### Code Flow
21
27
  1. Dashboard renders element demo into viewport using `render(anonItem.demo(), viewport)`
package/readme.plan.md CHANGED
@@ -61,4 +61,28 @@ The properties panel has timing issues detecting rendered elements because:
61
61
  - Access children via wrapper.children property
62
62
  - Updated documentation with correct import path (lowercase 'demotools')
63
63
  - Examples show how to use querySelector for powerful element selection
64
- - Added clarifying comment about querySelector working on slotted content
64
+ - Added clarifying comment about querySelector working on slotted content
65
+
66
+ ## Fixed Properties Panel Compatibility:
67
+ - Made element search generic - works with any container elements
68
+ - Searches both light DOM and shadow DOM recursively
69
+ - Improved error handling to prevent breaking the update cycle
70
+ - Errors in one property don't prevent others from rendering
71
+ - Detection continues working even after errors occur
72
+ - Maintains compatibility with all element structures
73
+
74
+ # Test Elements Created (COMPLETED)
75
+
76
+ ## Created comprehensive test elements:
77
+ 1. **test-noprops** - Element with no @property decorators
78
+ 2. **test-complextypes** - Element with arrays, objects, dates, and complex nested data
79
+ 3. **test-withwrapper** - Element that uses dees-demowrapper in its demo
80
+ 4. **test-edgecases** - Element with edge cases (null, undefined, NaN, Infinity, circular refs)
81
+ 5. **test-nested** - Element with deeply nested structure to test recursive search
82
+
83
+ These test various scenarios:
84
+ - Properties panel handling of elements without properties
85
+ - Complex data type display and editing
86
+ - Element detection inside dees-demowrapper
87
+ - Error handling for problematic values
88
+ - Deep nesting and shadow DOM traversal
@@ -229,23 +229,28 @@ export class WccProperties extends DeesElement {
229
229
  private async findElementRecursively(container: Element, elementClass: any, maxDepth: number = 5): Promise<HTMLElement | null> {
230
230
  if (maxDepth <= 0) return null;
231
231
 
232
- // Check direct children
233
- for (const child of Array.from(container.children)) {
234
- if (child instanceof elementClass) {
235
- return child as HTMLElement;
232
+ try {
233
+ // Check direct children
234
+ for (const child of Array.from(container.children)) {
235
+ if (child instanceof elementClass) {
236
+ return child as HTMLElement;
237
+ }
236
238
  }
237
- }
238
-
239
- // Check shadow roots of children
240
- for (const child of Array.from(container.children)) {
241
- if (child.shadowRoot) {
242
- const found = await this.findElementRecursively(child.shadowRoot as any, elementClass, maxDepth - 1);
239
+
240
+ // Search in all children recursively
241
+ for (const child of Array.from(container.children)) {
242
+ // First, always check the light DOM children
243
+ const found = await this.findElementRecursively(child, elementClass, maxDepth - 1);
243
244
  if (found) return found;
245
+
246
+ // Also check shadow root if it exists
247
+ if (child.shadowRoot) {
248
+ const shadowFound = await this.findElementRecursively(child.shadowRoot as any, elementClass, maxDepth - 1);
249
+ if (shadowFound) return shadowFound;
250
+ }
244
251
  }
245
-
246
- // Also check nested children
247
- const found = await this.findElementRecursively(child, elementClass, maxDepth - 1);
248
- if (found) return found;
252
+ } catch (error) {
253
+ console.error('Error in findElementRecursively:', error);
249
254
  }
250
255
 
251
256
  return null;
@@ -254,6 +259,9 @@ export class WccProperties extends DeesElement {
254
259
  public async createProperties() {
255
260
  console.log('creating properties for:');
256
261
  console.log(this.selectedItem);
262
+
263
+ // Clear any previous warnings
264
+ this.warning = null;
257
265
  const isEnumeration = (propertyArg): boolean => {
258
266
  const keys = Object.keys(propertyArg.type);
259
267
  const values = [];
@@ -315,15 +323,20 @@ export class WccProperties extends DeesElement {
315
323
  let retries = 0;
316
324
  while (!firstFoundInstantiatedElement && retries < 5) {
317
325
  await new Promise(resolve => setTimeout(resolve, 200));
318
- firstFoundInstantiatedElement = await this.findElementRecursively(
319
- viewport,
320
- this.selectedItem as any
321
- );
326
+ try {
327
+ firstFoundInstantiatedElement = await this.findElementRecursively(
328
+ viewport,
329
+ this.selectedItem as any
330
+ );
331
+ } catch (error) {
332
+ console.error('Error during element search retry:', error);
333
+ }
322
334
  retries++;
323
335
  }
324
336
 
325
337
  if (!firstFoundInstantiatedElement) {
326
338
  this.warning = `no first instantiated element found for >>${anonItem.name}<< after ${retries} retries`;
339
+ this.propertyContent = [];
327
340
  return;
328
341
  }
329
342
  const classProperties: Map<string, any> = anonItem.elementProperties;
@@ -337,9 +350,10 @@ export class WccProperties extends DeesElement {
337
350
  if (key === 'goBright' || key === 'domtools') {
338
351
  continue;
339
352
  }
340
- const property = classProperties.get(key);
341
- const propertyTypeString = await determinePropertyType(property);
342
- propertyArray.push(
353
+ try {
354
+ const property = classProperties.get(key);
355
+ const propertyTypeString = await determinePropertyType(property);
356
+ propertyArray.push(
343
357
  html`
344
358
  <div class="property">
345
359
  ${key} / ${propertyTypeString}<br />
@@ -392,6 +406,10 @@ export class WccProperties extends DeesElement {
392
406
  </div>
393
407
  `
394
408
  );
409
+ } catch (error) {
410
+ console.error(`Error processing property ${key}:`, error);
411
+ // Continue with next property even if this one fails
412
+ }
395
413
  }
396
414
  this.propertyContent = propertyArray;
397
415
  } else {
@@ -413,7 +431,14 @@ export class WccProperties extends DeesElement {
413
431
  }
414
432
 
415
433
  public async scheduleUpdate() {
416
- await this.createProperties();
434
+ try {
435
+ await this.createProperties();
436
+ } catch (error) {
437
+ console.error('Error creating properties:', error);
438
+ // Clear property content on error to show clean state
439
+ this.propertyContent = [];
440
+ }
441
+ // Always call super.scheduleUpdate to ensure component updates
417
442
  super.scheduleUpdate();
418
443
  }
419
444