Skip to content

Commit

Permalink
remove debug highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
MrWangJustToDo committed Aug 30, 2024
1 parent 440ddc3 commit 3830ae6
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 285 deletions.
2 changes: 0 additions & 2 deletions packages/myreact-dom/src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
enableDOMField,
enableEventSystem,
enableEventTrack,
enableHighlight,
injectDevField,
} from "../shared";

Expand Down Expand Up @@ -48,7 +47,6 @@ const __my_react_dom_shared__ = {
enableDOMField,
enableEventSystem,
enableEventTrack,
enableHighlight,
};

const __my_react_dom_internal__ = {
Expand Down
14 changes: 0 additions & 14 deletions packages/myreact-dom/src/client/renderDispatch/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { CustomRenderDispatch, NODE_TYPE, initHMR, listenerMap, safeCall, unmoun
import { append, clearNode, create, position, update } from "@my-react-dom-client/api";
import { clientDispatchMount } from "@my-react-dom-client/dispatchMount";
import { render } from "@my-react-dom-client/mount";
import { highlightAppendFiber, highlightRefFiber, highlightUpdateFiber } from "@my-react-dom-client/tools";
import { latestNoopRender, legacyNoopRender } from "@my-react-dom-noop/mount";
import {
asyncUpdateTimeLimit,
Expand Down Expand Up @@ -244,19 +243,6 @@ function hmrRemount(this: ClientDomDispatch, cb?: () => void) {
}

if (__DEV__) {
// dev highlight
Object.defineProperty(ClientDomDispatch.prototype, "patchToCommitUpdate", {
value: highlightUpdateFiber,
});

Object.defineProperty(ClientDomDispatch.prototype, "patchToCommitAppend", {
value: highlightAppendFiber,
});

Object.defineProperty(ClientDomDispatch.prototype, "patchToCommitSetRef", {
value: highlightRefFiber,
});

// dev log tree
Object.defineProperty(ClientDomDispatch.prototype, "_debugRender", {
get: function (this: ClientDomDispatch) {
Expand Down
223 changes: 0 additions & 223 deletions packages/myreact-dom/src/client/tools/highlight.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/myreact-dom/src/client/tools/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from "./createPortal";
export * from "./findDOMNode";
export * from "./hmr";
export * from "./highlight";
export * from "./unmountComponentAtNode";
16 changes: 2 additions & 14 deletions packages/myreact-dom/src/shared/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@ import {
import { include } from "@my-react/react-shared";

import { ClientDomDispatch } from "@my-react-dom-client/renderDispatch";
import { HighLight, debounce } from "@my-react-dom-client/tools";
import { latestNoopRender, legacyNoopRender } from "@my-react-dom-noop/mount/render";
import { PlainElement, ContainerElement, CommentStartElement } from "@my-react-dom-server/api";

import { enableControlComponent, enableDOMField, enableEventSystem, enableEventTrack, enableHighlight, enableHighlightWarn, isServer } from "./env";
import { getFiberWithNativeDom } from "./getFiberWithDom";
import { enableControlComponent, enableDOMField, enableEventSystem, enableEventTrack, isServer } from "./env";
import { debounce } from "./tools";

import type { LikeJSX } from "@my-react/react";
import type { CustomRenderDispatch, MyReactFiberNodeDev } from "@my-react/react-reconciler";
Expand All @@ -32,7 +31,6 @@ const __my_react_dom_shared__ = {
enableDOMField,
enableEventSystem,
enableEventTrack,
enableHighlight,
};

const __my_react_dom_internal__ = {
Expand All @@ -56,11 +54,6 @@ export const log = (fiber: MyReactFiberNode, level: "warn" | "error", ...rest: a
devErrorWithFiber(fiber, `[@my-react/react-dom]`, ...rest);
}

if (enableHighlightWarn.current && !isServer) {
const _fiber = getFiberWithNativeDom(fiber, (f) => f.parent);
_fiber && HighLight.getHighLightInstance().highLight(_fiber, "warn");
}

enableOptimizeTreeLog.current = last;

return;
Expand All @@ -85,11 +78,6 @@ export const logOnce = (fiber: MyReactFiberNode, level: "warn" | "error", key: s
onceErrorWithKeyAndFiber(fiber, key, `[@my-react/react-dom]`, ...rest);
}

if (enableHighlightWarn.current && !isServer) {
const _fiber = getFiberWithNativeDom(fiber, (f) => f.parent);

_fiber && HighLight.getHighLightInstance().highLight(_fiber, "warn");
}
return;
}

Expand Down
10 changes: 0 additions & 10 deletions packages/myreact-dom/src/shared/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ export const enableControlComponent = createReadonlyRef(true);
*/
export const enableEventSystem = createReadonlyRef(true);

/**
* @internal
*/
export const enableHighlight = createRef(false);

/**
* @internal
*/
Expand All @@ -48,11 +43,6 @@ export const enableEventTrack = createRef(false);
*/
export const enableHydrateWarn = createRef(true);

/**
* @internal
*/
export const enableHighlightWarn = createRef(false);

/**
* @internal
*/
Expand Down
14 changes: 14 additions & 0 deletions packages/myreact-dom/src/shared/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,17 @@ export const generateGetRawAttrKey = (map: string) => {
return false;
};
};

/**
* @internal
*/
// eslint-disable-next-line @typescript-eslint/ban-types
export const debounce = <T extends Function>(callback: T, time?: number): T => {
let id = null;
return ((...args) => {
clearTimeout(id);
id = setTimeout(() => {
callback.call(null, ...args);
}, time || 40);
}) as unknown as T;
};
Loading

0 comments on commit 3830ae6

Please sign in to comment.