From d1a945fdd188770e1d539c488a1a520fa83b3ed7 Mon Sep 17 00:00:00 2001 From: LastLeaf Date: Wed, 3 Jul 2024 20:13:38 +0800 Subject: [PATCH] feat: preserve some devtools interfaces --- glass-easel/src/dev_tools.ts | 8 ++++++-- glass-easel/src/index.ts | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/glass-easel/src/dev_tools.ts b/glass-easel/src/dev_tools.ts index ce3003b..292db79 100644 --- a/glass-easel/src/dev_tools.ts +++ b/glass-easel/src/dev_tools.ts @@ -7,8 +7,10 @@ export interface DevTools { performance?: PerformanceDevTools } +export interface MountPointEnv {} + export interface InspectorDevTools { - addMountPoint(root: Element): void + addMountPoint(root: Element, env: MountPointEnv): void removeMountPoint(root: Element): void } @@ -103,11 +105,13 @@ export const addTimelineEvent = (type: string, data?: Record) = } export const attachInspector = (elem: Element) => { + if (!ENV.DEV) return const inspector = getDevTools()?.inspector - inspector?.addMountPoint(elem) + inspector?.addMountPoint(elem, {}) } export const detachInspector = (elem: Element) => { + if (!ENV.DEV) return const inspector = getDevTools()?.inspector inspector?.removeMountPoint(elem) } diff --git a/glass-easel/src/index.ts b/glass-easel/src/index.ts index 95db527..b97c4b1 100644 --- a/glass-easel/src/index.ts +++ b/glass-easel/src/index.ts @@ -78,7 +78,7 @@ export { removeGlobalErrorListener, removeGlobalWarningListener, } from './warning' -export { DevTools, InspectorDevTools, PerformanceDevTools } from './dev_tools' +export { DevTools, InspectorDevTools, PerformanceDevTools, MountPointEnv } from './dev_tools' import { type Behavior } from './behavior' import {