Skip to content

Commit

Permalink
improve inspector
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeart committed Jan 11, 2025
1 parent bd51bfd commit bb2d7db
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
35 changes: 32 additions & 3 deletions src/utils/inspector/ember-inspector.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import * as backburner from 'backburner.js';
import { getRoot } from '../dom';
import { $_debug_args, $context, $nodes, CHILD, COMPONENT_ID_PROPERTY, getBounds, isArray, TREE } from '../shared';
import { $_debug_args, $context, $nodes, CHILD, COMPONENT_ID_PROPERTY, getBounds, isArray, RENDERED_NODES_PROPERTY, TREE } from '../shared';
import { Component } from '..';
import { Cell, MergedCell, getCells, getMergedCells } from '../reactive';
import { $args } from '../shared';
import { inspect } from '@/utils/inspector';
import { IfCondition } from '../control-flow/if';
import { AsyncListComponent, SyncListComponent } from '../control-flow/list';
import { attributes } from 'happy-dom/lib/PropertySymbol.js';
import { template } from '@babel/core';
import { NS_HTML } from '../namespaces';

const genericProxy = new Proxy(
{},
Expand Down Expand Up @@ -492,11 +495,37 @@ const EmberProxy: any = new Proxy(
};
}

const children = childs?.map((child) => componentToRenderTree(child)) ?? [];

const children = (childs?.map((child) => componentToRenderTree(child)) ?? []).filter(el => el !== null);
// @ts-expect-error
component[RENDERED_NODES_PROPERTY].forEach((node, index) => {
// @ts-expect-error
if ('attributes' in node && node.namespaceURI === NS_HTML) {
// children.push({
// id: `${component[COMPONENT_ID_PROPERTY]}-${index}`,
// type: 'html-element',
// instance: node,
// // @ts-expect-error
// name: node.tagName.toLowerCase(),
// children: [],
// template: null,
// args: {
// named: {},
// positional: [],
// },
// bounds: {
// firstNode: node,
// lastNode: node,
// parentElement: node.parentElement,
// }
// })
}
});
if (componentName.startsWith('UnstableChildWrapper') && children.length === 1) {
return children[0];
}
if (componentName.startsWith('SVGProvider')) {
return null;
}
let allArgs = function () {
if ($_debug_args in component) {
return component[$_debug_args] ?? {};
Expand Down
3 changes: 3 additions & 0 deletions src/utils/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ if (!import.meta.env.SSR) {
}

export function getBounds(ctx: Component<any>) {
if (ctx[RENDERED_NODES_PROPERTY].length) {
return ctx[RENDERED_NODES_PROPERTY].slice(0);
}
return BOUNDS.get(ctx) ?? [];
}
export function setBounds(component: ComponentReturnType) {
Expand Down

0 comments on commit bb2d7db

Please sign in to comment.