Skip to content

Commit

Permalink
ember-inspector-support
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeart committed Jan 10, 2024
1 parent 0715704 commit 2150033
Show file tree
Hide file tree
Showing 10 changed files with 910 additions and 4 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"@babel/core": "^7.23.6",
"@babel/preset-typescript": "^7.23.3",
"@glimmer/syntax": "^0.87.1",
"backburner.js": "^2.8.0",
"content-tag": "^1.2.2"
}
}
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import '@glint/environment-glimmerx';
import '@glint/environment-ember-template-imports';
import '@/utils/ember-inspector';

import './style.css';

Expand Down
27 changes: 26 additions & 1 deletion src/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ const $_className = 'className';

let ROOT: Component<any> | null = null;

export function getRoot() {
return ROOT;
}

type ModifierFn = (
element: HTMLElement,
...args: unknown[]
Expand Down Expand Up @@ -583,7 +587,28 @@ const ArgProxyHandler = {
};
export function $_args(args: Record<string, unknown>) {
if (IS_GLIMMER_COMPAT_MODE) {
return new Proxy(args, ArgProxyHandler);
if (import.meta.env.DEV) {
const newArgs: Record<string, () => unknown> = {};
Object.keys(args).forEach((key) => {
try {
Object.defineProperty(newArgs, key, {
get() {
if (!isFn(args[key])) {
return args[key];
}
// @ts-expect-error function signature
return args[key]();
},
enumerable: true,
});
} catch(e) {
console.error(e);
}
});
return newArgs;
} else {
return new Proxy(args, ArgProxyHandler);
}
} else {
return args;
}
Expand Down
Loading

0 comments on commit 2150033

Please sign in to comment.