diff --git a/chrome/public/bundle/detector.js b/chrome/public/bundle/detector.js index 51a7fe5..4764e34 100644 --- a/chrome/public/bundle/detector.js +++ b/chrome/public/bundle/detector.js @@ -929,6 +929,8 @@ NODE_TYPE[NODE_TYPE["__scope__"] = 65536] = "__scope__"; NODE_TYPE[NODE_TYPE["__comment__"] = 131072] = "__comment__"; NODE_TYPE[NODE_TYPE["__profiler__"] = 262144] = "__profiler__"; + // react compiler memo + NODE_TYPE[NODE_TYPE["__compiler__"] = 524288] = "__compiler__"; })(NODE_TYPE || (NODE_TYPE = {})); var treeMap = new Map(); @@ -947,7 +949,7 @@ directory[name] = ++count + ""; } plain.k = hasKey ? directory[fiber.key] : undefined; - plain.t = fiber.type; + plain.t = getFiberType(fiber); plain.n = directory[name]; }; var assignFiber = function (plain, fiber, force) { @@ -1085,6 +1087,8 @@ }; var typeKeys = []; + // SEE https://github.com/facebook/react/blob/main/compiler/packages/react-compiler-runtime/src/index.ts + var reactCompilerSymbol = Symbol.for("react.memo_cache_sentinel"); Object.keys(NODE_TYPE).forEach(function (key) { if (!key.startsWith("__")) { typeKeys.push(+key); @@ -1136,16 +1140,6 @@ return ""; } }; - var getFiberType = function (t) { - var type = []; - typeKeys.forEach(function (key) { - if (t & key) { - var name_1 = getTypeName(key); - name_1 && type.push(name_1); - } - }); - return type; - }; var getFiberTag = function (t) { var tag = []; if (t & NODE_TYPE.__memo__) { @@ -1157,30 +1151,48 @@ if (t & NODE_TYPE.__lazy__) { tag.push("lazy"); } + if (t & NODE_TYPE.__compiler__) { + tag.push("compiler ✨"); + } return tag; }; + var getFiberType = function (fiber) { + var _a; + var t = fiber.type; + var hasCompiler = false; + // check react compiler + (_a = fiber.hookList) === null || _a === void 0 ? void 0 : _a.listToFoot(function (l) { + var _a; + if (hasCompiler) + return; + if (l.type === reactShared.HOOK_TYPE.useMemo && ((_a = l.result) === null || _a === void 0 ? void 0 : _a[reactCompilerSymbol])) { + hasCompiler = true; + } + }); + return hasCompiler ? reactShared.merge(t, NODE_TYPE.__compiler__) : t; + }; var getFiberName = function (fiber) { var typedFiber = fiber; if (fiber.type & NODE_TYPE.__provider__) { var typedElementType = fiber.elementType; - var name_2 = typedElementType.Context.displayName; - return "".concat(name_2 || "Context", ".Provider"); + var name_1 = typedElementType.Context.displayName; + return "".concat(name_1 || "Context", ".Provider"); } if (fiber.type & NODE_TYPE.__consumer__) { var typedElementType = fiber.elementType; - var name_3 = typedElementType.Context.displayName; - return "".concat(name_3 || "Context", ".Consumer"); + var name_2 = typedElementType.Context.displayName; + return "".concat(name_2 || "Context", ".Consumer"); } if (fiber.type & NODE_TYPE.__lazy__) { var typedElementType = fiber.elementType; var typedRender = typedElementType === null || typedElementType === void 0 ? void 0 : typedElementType.render; - var name_4 = (typedRender === null || typedRender === void 0 ? void 0 : typedRender.displayName) || (typedRender === null || typedRender === void 0 ? void 0 : typedRender.name) || ""; + var name_3 = (typedRender === null || typedRender === void 0 ? void 0 : typedRender.displayName) || (typedRender === null || typedRender === void 0 ? void 0 : typedRender.name) || ""; { var element = typedFiber._debugElement; var type = element === null || element === void 0 ? void 0 : element.type; - name_4 = (type === null || type === void 0 ? void 0 : type.displayName) || name_4; + name_3 = (type === null || type === void 0 ? void 0 : type.displayName) || name_3; } - return "".concat(name_4 || "anonymous"); + return "".concat(name_3 || "anonymous"); } if (fiber.type & NODE_TYPE.__portal__) return "Portal"; @@ -1208,14 +1220,14 @@ return "".concat(fiber.elementType); if (typeof fiber.elementType === "function") { var typedElementType = fiber.elementType; - var name_5 = typedElementType.displayName || typedElementType.name || "anonymous"; + var name_4 = typedElementType.displayName || typedElementType.name || "anonymous"; { var element = typedFiber._debugElement; // may be a Suspense element var type = element === null || element === void 0 ? void 0 : element.type; - name_5 = (type === null || type === void 0 ? void 0 : type.displayName) || name_5; + name_4 = (type === null || type === void 0 ? void 0 : type.displayName) || name_4; } - return "".concat(name_5); + return "".concat(name_4); } return "unknown"; }; @@ -1314,14 +1326,14 @@ for (var i = 0; i < stack.length; i++) { var isHook = i === stack.length - 1; var key = prevKey + stack[i].id + stack[i].name + (isHook ? "-".concat(index) : ""); - var name_6 = stack[i].name; + var name_5 = stack[i].name; var hasInclude = true; if (!obj[key]) { if (isHook) { - obj[key] = { n: name_6, i: index, h: true, d: 0 }; + obj[key] = { n: name_5, i: index, h: true, d: 0 }; } else { - obj[key] = { n: name_6, d: 0 }; + obj[key] = { n: name_5, d: 0 }; } hasInclude = false; } diff --git a/chrome/public/bundle/hook.js b/chrome/public/bundle/hook.js index 0da1a44..0e0b0f5 100644 --- a/chrome/public/bundle/hook.js +++ b/chrome/public/bundle/hook.js @@ -1002,6 +1002,8 @@ NODE_TYPE[NODE_TYPE["__scope__"] = 65536] = "__scope__"; NODE_TYPE[NODE_TYPE["__comment__"] = 131072] = "__comment__"; NODE_TYPE[NODE_TYPE["__profiler__"] = 262144] = "__profiler__"; + // react compiler memo + NODE_TYPE[NODE_TYPE["__compiler__"] = 524288] = "__compiler__"; })(NODE_TYPE || (NODE_TYPE = {})); var treeMap = new Map(); @@ -1020,7 +1022,7 @@ directory[name] = ++count + ""; } plain.k = hasKey ? directory[fiber.key] : undefined; - plain.t = fiber.type; + plain.t = getFiberType(fiber); plain.n = directory[name]; }; var assignFiber = function (plain, fiber, force) { @@ -1158,6 +1160,8 @@ }; var typeKeys = []; + // SEE https://github.com/facebook/react/blob/main/compiler/packages/react-compiler-runtime/src/index.ts + var reactCompilerSymbol = Symbol.for("react.memo_cache_sentinel"); Object.keys(NODE_TYPE).forEach(function (key) { if (!key.startsWith("__")) { typeKeys.push(+key); @@ -1209,16 +1213,6 @@ return ""; } }; - var getFiberType = function (t) { - var type = []; - typeKeys.forEach(function (key) { - if (t & key) { - var name_1 = getTypeName(key); - name_1 && type.push(name_1); - } - }); - return type; - }; var getFiberTag = function (t) { var tag = []; if (t & NODE_TYPE.__memo__) { @@ -1230,30 +1224,48 @@ if (t & NODE_TYPE.__lazy__) { tag.push("lazy"); } + if (t & NODE_TYPE.__compiler__) { + tag.push("compiler ✨"); + } return tag; }; + var getFiberType = function (fiber) { + var _a; + var t = fiber.type; + var hasCompiler = false; + // check react compiler + (_a = fiber.hookList) === null || _a === void 0 ? void 0 : _a.listToFoot(function (l) { + var _a; + if (hasCompiler) + return; + if (l.type === reactShared.HOOK_TYPE.useMemo && ((_a = l.result) === null || _a === void 0 ? void 0 : _a[reactCompilerSymbol])) { + hasCompiler = true; + } + }); + return hasCompiler ? reactShared.merge(t, NODE_TYPE.__compiler__) : t; + }; var getFiberName = function (fiber) { var typedFiber = fiber; if (fiber.type & NODE_TYPE.__provider__) { var typedElementType = fiber.elementType; - var name_2 = typedElementType.Context.displayName; - return "".concat(name_2 || "Context", ".Provider"); + var name_1 = typedElementType.Context.displayName; + return "".concat(name_1 || "Context", ".Provider"); } if (fiber.type & NODE_TYPE.__consumer__) { var typedElementType = fiber.elementType; - var name_3 = typedElementType.Context.displayName; - return "".concat(name_3 || "Context", ".Consumer"); + var name_2 = typedElementType.Context.displayName; + return "".concat(name_2 || "Context", ".Consumer"); } if (fiber.type & NODE_TYPE.__lazy__) { var typedElementType = fiber.elementType; var typedRender = typedElementType === null || typedElementType === void 0 ? void 0 : typedElementType.render; - var name_4 = (typedRender === null || typedRender === void 0 ? void 0 : typedRender.displayName) || (typedRender === null || typedRender === void 0 ? void 0 : typedRender.name) || ""; + var name_3 = (typedRender === null || typedRender === void 0 ? void 0 : typedRender.displayName) || (typedRender === null || typedRender === void 0 ? void 0 : typedRender.name) || ""; { var element = typedFiber._debugElement; var type = element === null || element === void 0 ? void 0 : element.type; - name_4 = (type === null || type === void 0 ? void 0 : type.displayName) || name_4; + name_3 = (type === null || type === void 0 ? void 0 : type.displayName) || name_3; } - return "".concat(name_4 || "anonymous"); + return "".concat(name_3 || "anonymous"); } if (fiber.type & NODE_TYPE.__portal__) return "Portal"; @@ -1281,14 +1293,14 @@ return "".concat(fiber.elementType); if (typeof fiber.elementType === "function") { var typedElementType = fiber.elementType; - var name_5 = typedElementType.displayName || typedElementType.name || "anonymous"; + var name_4 = typedElementType.displayName || typedElementType.name || "anonymous"; { var element = typedFiber._debugElement; // may be a Suspense element var type = element === null || element === void 0 ? void 0 : element.type; - name_5 = (type === null || type === void 0 ? void 0 : type.displayName) || name_5; + name_4 = (type === null || type === void 0 ? void 0 : type.displayName) || name_4; } - return "".concat(name_5); + return "".concat(name_4); } return "unknown"; }; @@ -1387,14 +1399,14 @@ for (var i = 0; i < stack.length; i++) { var isHook = i === stack.length - 1; var key = prevKey + stack[i].id + stack[i].name + (isHook ? "-".concat(index) : ""); - var name_6 = stack[i].name; + var name_5 = stack[i].name; var hasInclude = true; if (!obj[key]) { if (isHook) { - obj[key] = { n: name_6, i: index, h: true, d: 0 }; + obj[key] = { n: name_5, i: index, h: true, d: 0 }; } else { - obj[key] = { n: name_6, d: 0 }; + obj[key] = { n: name_5, d: 0 }; } hasInclude = false; } diff --git a/chrome/public/bundle/panel.js b/chrome/public/bundle/panel.js index 0df2689..df81712 100644 --- a/chrome/public/bundle/panel.js +++ b/chrome/public/bundle/panel.js @@ -1000,6 +1000,8 @@ NODE_TYPE[NODE_TYPE["__scope__"] = 65536] = "__scope__"; NODE_TYPE[NODE_TYPE["__comment__"] = 131072] = "__comment__"; NODE_TYPE[NODE_TYPE["__profiler__"] = 262144] = "__profiler__"; + // react compiler memo + NODE_TYPE[NODE_TYPE["__compiler__"] = 524288] = "__compiler__"; })(NODE_TYPE || (NODE_TYPE = {})); var treeMap = new Map(); @@ -1018,7 +1020,7 @@ directory[name] = ++count + ""; } plain.k = hasKey ? directory[fiber.key] : undefined; - plain.t = fiber.type; + plain.t = getFiberType(fiber); plain.n = directory[name]; }; var assignFiber = function (plain, fiber, force) { @@ -1156,6 +1158,8 @@ }; var typeKeys = []; + // SEE https://github.com/facebook/react/blob/main/compiler/packages/react-compiler-runtime/src/index.ts + var reactCompilerSymbol = Symbol.for("react.memo_cache_sentinel"); Object.keys(NODE_TYPE).forEach(function (key) { if (!key.startsWith("__")) { typeKeys.push(+key); @@ -1207,16 +1211,6 @@ return ""; } }; - var getFiberType = function (t) { - var type = []; - typeKeys.forEach(function (key) { - if (t & key) { - var name_1 = getTypeName(key); - name_1 && type.push(name_1); - } - }); - return type; - }; var getFiberTag = function (t) { var tag = []; if (t & NODE_TYPE.__memo__) { @@ -1228,30 +1222,48 @@ if (t & NODE_TYPE.__lazy__) { tag.push("lazy"); } + if (t & NODE_TYPE.__compiler__) { + tag.push("compiler ✨"); + } return tag; }; + var getFiberType = function (fiber) { + var _a; + var t = fiber.type; + var hasCompiler = false; + // check react compiler + (_a = fiber.hookList) === null || _a === void 0 ? void 0 : _a.listToFoot(function (l) { + var _a; + if (hasCompiler) + return; + if (l.type === reactShared.HOOK_TYPE.useMemo && ((_a = l.result) === null || _a === void 0 ? void 0 : _a[reactCompilerSymbol])) { + hasCompiler = true; + } + }); + return hasCompiler ? reactShared.merge(t, NODE_TYPE.__compiler__) : t; + }; var getFiberName = function (fiber) { var typedFiber = fiber; if (fiber.type & NODE_TYPE.__provider__) { var typedElementType = fiber.elementType; - var name_2 = typedElementType.Context.displayName; - return "".concat(name_2 || "Context", ".Provider"); + var name_1 = typedElementType.Context.displayName; + return "".concat(name_1 || "Context", ".Provider"); } if (fiber.type & NODE_TYPE.__consumer__) { var typedElementType = fiber.elementType; - var name_3 = typedElementType.Context.displayName; - return "".concat(name_3 || "Context", ".Consumer"); + var name_2 = typedElementType.Context.displayName; + return "".concat(name_2 || "Context", ".Consumer"); } if (fiber.type & NODE_TYPE.__lazy__) { var typedElementType = fiber.elementType; var typedRender = typedElementType === null || typedElementType === void 0 ? void 0 : typedElementType.render; - var name_4 = (typedRender === null || typedRender === void 0 ? void 0 : typedRender.displayName) || (typedRender === null || typedRender === void 0 ? void 0 : typedRender.name) || ""; + var name_3 = (typedRender === null || typedRender === void 0 ? void 0 : typedRender.displayName) || (typedRender === null || typedRender === void 0 ? void 0 : typedRender.name) || ""; { var element = typedFiber._debugElement; var type = element === null || element === void 0 ? void 0 : element.type; - name_4 = (type === null || type === void 0 ? void 0 : type.displayName) || name_4; + name_3 = (type === null || type === void 0 ? void 0 : type.displayName) || name_3; } - return "".concat(name_4 || "anonymous"); + return "".concat(name_3 || "anonymous"); } if (fiber.type & NODE_TYPE.__portal__) return "Portal"; @@ -1279,14 +1291,14 @@ return "".concat(fiber.elementType); if (typeof fiber.elementType === "function") { var typedElementType = fiber.elementType; - var name_5 = typedElementType.displayName || typedElementType.name || "anonymous"; + var name_4 = typedElementType.displayName || typedElementType.name || "anonymous"; { var element = typedFiber._debugElement; // may be a Suspense element var type = element === null || element === void 0 ? void 0 : element.type; - name_5 = (type === null || type === void 0 ? void 0 : type.displayName) || name_5; + name_4 = (type === null || type === void 0 ? void 0 : type.displayName) || name_4; } - return "".concat(name_5); + return "".concat(name_4); } return "unknown"; }; @@ -1385,14 +1397,14 @@ for (var i = 0; i < stack.length; i++) { var isHook = i === stack.length - 1; var key = prevKey + stack[i].id + stack[i].name + (isHook ? "-".concat(index) : ""); - var name_6 = stack[i].name; + var name_5 = stack[i].name; var hasInclude = true; if (!obj[key]) { if (isHook) { - obj[key] = { n: name_6, i: index, h: true, d: 0 }; + obj[key] = { n: name_5, i: index, h: true, d: 0 }; } else { - obj[key] = { n: name_6, d: 0 }; + obj[key] = { n: name_5, d: 0 }; } hasInclude = false; } diff --git a/chrome/public/bundle/proxy.js b/chrome/public/bundle/proxy.js index fa1e03d..f420c1a 100644 --- a/chrome/public/bundle/proxy.js +++ b/chrome/public/bundle/proxy.js @@ -929,6 +929,8 @@ NODE_TYPE[NODE_TYPE["__scope__"] = 65536] = "__scope__"; NODE_TYPE[NODE_TYPE["__comment__"] = 131072] = "__comment__"; NODE_TYPE[NODE_TYPE["__profiler__"] = 262144] = "__profiler__"; + // react compiler memo + NODE_TYPE[NODE_TYPE["__compiler__"] = 524288] = "__compiler__"; })(NODE_TYPE || (NODE_TYPE = {})); var treeMap = new Map(); @@ -947,7 +949,7 @@ directory[name] = ++count + ""; } plain.k = hasKey ? directory[fiber.key] : undefined; - plain.t = fiber.type; + plain.t = getFiberType(fiber); plain.n = directory[name]; }; var assignFiber = function (plain, fiber, force) { @@ -1085,6 +1087,8 @@ }; var typeKeys = []; + // SEE https://github.com/facebook/react/blob/main/compiler/packages/react-compiler-runtime/src/index.ts + var reactCompilerSymbol = Symbol.for("react.memo_cache_sentinel"); Object.keys(NODE_TYPE).forEach(function (key) { if (!key.startsWith("__")) { typeKeys.push(+key); @@ -1136,16 +1140,6 @@ return ""; } }; - var getFiberType = function (t) { - var type = []; - typeKeys.forEach(function (key) { - if (t & key) { - var name_1 = getTypeName(key); - name_1 && type.push(name_1); - } - }); - return type; - }; var getFiberTag = function (t) { var tag = []; if (t & NODE_TYPE.__memo__) { @@ -1157,30 +1151,48 @@ if (t & NODE_TYPE.__lazy__) { tag.push("lazy"); } + if (t & NODE_TYPE.__compiler__) { + tag.push("compiler ✨"); + } return tag; }; + var getFiberType = function (fiber) { + var _a; + var t = fiber.type; + var hasCompiler = false; + // check react compiler + (_a = fiber.hookList) === null || _a === void 0 ? void 0 : _a.listToFoot(function (l) { + var _a; + if (hasCompiler) + return; + if (l.type === reactShared.HOOK_TYPE.useMemo && ((_a = l.result) === null || _a === void 0 ? void 0 : _a[reactCompilerSymbol])) { + hasCompiler = true; + } + }); + return hasCompiler ? reactShared.merge(t, NODE_TYPE.__compiler__) : t; + }; var getFiberName = function (fiber) { var typedFiber = fiber; if (fiber.type & NODE_TYPE.__provider__) { var typedElementType = fiber.elementType; - var name_2 = typedElementType.Context.displayName; - return "".concat(name_2 || "Context", ".Provider"); + var name_1 = typedElementType.Context.displayName; + return "".concat(name_1 || "Context", ".Provider"); } if (fiber.type & NODE_TYPE.__consumer__) { var typedElementType = fiber.elementType; - var name_3 = typedElementType.Context.displayName; - return "".concat(name_3 || "Context", ".Consumer"); + var name_2 = typedElementType.Context.displayName; + return "".concat(name_2 || "Context", ".Consumer"); } if (fiber.type & NODE_TYPE.__lazy__) { var typedElementType = fiber.elementType; var typedRender = typedElementType === null || typedElementType === void 0 ? void 0 : typedElementType.render; - var name_4 = (typedRender === null || typedRender === void 0 ? void 0 : typedRender.displayName) || (typedRender === null || typedRender === void 0 ? void 0 : typedRender.name) || ""; + var name_3 = (typedRender === null || typedRender === void 0 ? void 0 : typedRender.displayName) || (typedRender === null || typedRender === void 0 ? void 0 : typedRender.name) || ""; { var element = typedFiber._debugElement; var type = element === null || element === void 0 ? void 0 : element.type; - name_4 = (type === null || type === void 0 ? void 0 : type.displayName) || name_4; + name_3 = (type === null || type === void 0 ? void 0 : type.displayName) || name_3; } - return "".concat(name_4 || "anonymous"); + return "".concat(name_3 || "anonymous"); } if (fiber.type & NODE_TYPE.__portal__) return "Portal"; @@ -1208,14 +1220,14 @@ return "".concat(fiber.elementType); if (typeof fiber.elementType === "function") { var typedElementType = fiber.elementType; - var name_5 = typedElementType.displayName || typedElementType.name || "anonymous"; + var name_4 = typedElementType.displayName || typedElementType.name || "anonymous"; { var element = typedFiber._debugElement; // may be a Suspense element var type = element === null || element === void 0 ? void 0 : element.type; - name_5 = (type === null || type === void 0 ? void 0 : type.displayName) || name_5; + name_4 = (type === null || type === void 0 ? void 0 : type.displayName) || name_4; } - return "".concat(name_5); + return "".concat(name_4); } return "unknown"; }; @@ -1314,14 +1326,14 @@ for (var i = 0; i < stack.length; i++) { var isHook = i === stack.length - 1; var key = prevKey + stack[i].id + stack[i].name + (isHook ? "-".concat(index) : ""); - var name_6 = stack[i].name; + var name_5 = stack[i].name; var hasInclude = true; if (!obj[key]) { if (isHook) { - obj[key] = { n: name_6, i: index, h: true, d: 0 }; + obj[key] = { n: name_5, i: index, h: true, d: 0 }; } else { - obj[key] = { n: name_6, d: 0 }; + obj[key] = { n: name_5, d: 0 }; } hasInclude = false; } diff --git a/chrome/public/bundle/service-worker.js b/chrome/public/bundle/service-worker.js index f23095d..ac02f73 100644 --- a/chrome/public/bundle/service-worker.js +++ b/chrome/public/bundle/service-worker.js @@ -929,6 +929,8 @@ NODE_TYPE[NODE_TYPE["__scope__"] = 65536] = "__scope__"; NODE_TYPE[NODE_TYPE["__comment__"] = 131072] = "__comment__"; NODE_TYPE[NODE_TYPE["__profiler__"] = 262144] = "__profiler__"; + // react compiler memo + NODE_TYPE[NODE_TYPE["__compiler__"] = 524288] = "__compiler__"; })(NODE_TYPE || (NODE_TYPE = {})); var treeMap = new Map(); @@ -947,7 +949,7 @@ directory[name] = ++count + ""; } plain.k = hasKey ? directory[fiber.key] : undefined; - plain.t = fiber.type; + plain.t = getFiberType(fiber); plain.n = directory[name]; }; var assignFiber = function (plain, fiber, force) { @@ -1085,6 +1087,8 @@ }; var typeKeys = []; + // SEE https://github.com/facebook/react/blob/main/compiler/packages/react-compiler-runtime/src/index.ts + var reactCompilerSymbol = Symbol.for("react.memo_cache_sentinel"); Object.keys(NODE_TYPE).forEach(function (key) { if (!key.startsWith("__")) { typeKeys.push(+key); @@ -1136,16 +1140,6 @@ return ""; } }; - var getFiberType = function (t) { - var type = []; - typeKeys.forEach(function (key) { - if (t & key) { - var name_1 = getTypeName(key); - name_1 && type.push(name_1); - } - }); - return type; - }; var getFiberTag = function (t) { var tag = []; if (t & NODE_TYPE.__memo__) { @@ -1157,30 +1151,48 @@ if (t & NODE_TYPE.__lazy__) { tag.push("lazy"); } + if (t & NODE_TYPE.__compiler__) { + tag.push("compiler ✨"); + } return tag; }; + var getFiberType = function (fiber) { + var _a; + var t = fiber.type; + var hasCompiler = false; + // check react compiler + (_a = fiber.hookList) === null || _a === void 0 ? void 0 : _a.listToFoot(function (l) { + var _a; + if (hasCompiler) + return; + if (l.type === reactShared.HOOK_TYPE.useMemo && ((_a = l.result) === null || _a === void 0 ? void 0 : _a[reactCompilerSymbol])) { + hasCompiler = true; + } + }); + return hasCompiler ? reactShared.merge(t, NODE_TYPE.__compiler__) : t; + }; var getFiberName = function (fiber) { var typedFiber = fiber; if (fiber.type & NODE_TYPE.__provider__) { var typedElementType = fiber.elementType; - var name_2 = typedElementType.Context.displayName; - return "".concat(name_2 || "Context", ".Provider"); + var name_1 = typedElementType.Context.displayName; + return "".concat(name_1 || "Context", ".Provider"); } if (fiber.type & NODE_TYPE.__consumer__) { var typedElementType = fiber.elementType; - var name_3 = typedElementType.Context.displayName; - return "".concat(name_3 || "Context", ".Consumer"); + var name_2 = typedElementType.Context.displayName; + return "".concat(name_2 || "Context", ".Consumer"); } if (fiber.type & NODE_TYPE.__lazy__) { var typedElementType = fiber.elementType; var typedRender = typedElementType === null || typedElementType === void 0 ? void 0 : typedElementType.render; - var name_4 = (typedRender === null || typedRender === void 0 ? void 0 : typedRender.displayName) || (typedRender === null || typedRender === void 0 ? void 0 : typedRender.name) || ""; + var name_3 = (typedRender === null || typedRender === void 0 ? void 0 : typedRender.displayName) || (typedRender === null || typedRender === void 0 ? void 0 : typedRender.name) || ""; { var element = typedFiber._debugElement; var type = element === null || element === void 0 ? void 0 : element.type; - name_4 = (type === null || type === void 0 ? void 0 : type.displayName) || name_4; + name_3 = (type === null || type === void 0 ? void 0 : type.displayName) || name_3; } - return "".concat(name_4 || "anonymous"); + return "".concat(name_3 || "anonymous"); } if (fiber.type & NODE_TYPE.__portal__) return "Portal"; @@ -1208,14 +1220,14 @@ return "".concat(fiber.elementType); if (typeof fiber.elementType === "function") { var typedElementType = fiber.elementType; - var name_5 = typedElementType.displayName || typedElementType.name || "anonymous"; + var name_4 = typedElementType.displayName || typedElementType.name || "anonymous"; { var element = typedFiber._debugElement; // may be a Suspense element var type = element === null || element === void 0 ? void 0 : element.type; - name_5 = (type === null || type === void 0 ? void 0 : type.displayName) || name_5; + name_4 = (type === null || type === void 0 ? void 0 : type.displayName) || name_4; } - return "".concat(name_5); + return "".concat(name_4); } return "unknown"; }; @@ -1314,14 +1326,14 @@ for (var i = 0; i < stack.length; i++) { var isHook = i === stack.length - 1; var key = prevKey + stack[i].id + stack[i].name + (isHook ? "-".concat(index) : ""); - var name_6 = stack[i].name; + var name_5 = stack[i].name; var hasInclude = true; if (!obj[key]) { if (isHook) { - obj[key] = { n: name_6, i: index, h: true, d: 0 }; + obj[key] = { n: name_5, i: index, h: true, d: 0 }; } else { - obj[key] = { n: name_6, d: 0 }; + obj[key] = { n: name_5, d: 0 }; } hasInclude = false; } diff --git a/chrome/src/components/TreeItem.tsx b/chrome/src/components/TreeItem.tsx index 4ea9e2b..94444c3 100644 --- a/chrome/src/components/TreeItem.tsx +++ b/chrome/src/components/TreeItem.tsx @@ -26,7 +26,13 @@ const RenderTag = memo(({ node }: { node: PlainNode }) => { return (
{tag.map((tag) => ( - + {tag} ))} @@ -122,10 +128,7 @@ export const RenderItem = ({ const currentIsClose = withCollapse && closeList?.[node.i]; - const hasSelect = useMemo( - () => withSelect && select && !currentIsSelect && selectList?.[node.i], - [withSelect, select, currentIsSelect, selectList, node.i] - ); + const hasSelect = useMemo(() => withSelect && select && !currentIsSelect && selectList?.[node.i], [withSelect, select, currentIsSelect, selectList, node.i]); const hasChild = Array.isArray(current?.c); diff --git a/packages/core/src/tree.ts b/packages/core/src/tree.ts index 7ea0923..2fea6dc 100644 --- a/packages/core/src/tree.ts +++ b/packages/core/src/tree.ts @@ -1,6 +1,6 @@ import { PlainNode } from "./plain"; import { NODE_TYPE } from "./type"; -import { getFiberName, getHook, getProps, getSource, getState, getTree } from "./utils"; +import { getFiberName, getFiberType, getHook, getProps, getSource, getState, getTree } from "./utils"; import type { MyReactFiberNodeDev, CustomRenderDispatch, MyReactFiberNode } from "@my-react/react-reconciler"; import type { ListTree } from "@my-react/react-shared"; @@ -32,7 +32,7 @@ export const shallowAssignFiber = (plain: PlainNode, fiber: MyReactFiberNode) => plain.k = hasKey ? directory[fiber.key] : undefined; - plain.t = fiber.type; + plain.t = getFiberType(fiber); plain.n = directory[name]; }; diff --git a/packages/core/src/type.ts b/packages/core/src/type.ts index 2d77fb3..6314633 100644 --- a/packages/core/src/type.ts +++ b/packages/core/src/type.ts @@ -19,4 +19,7 @@ export enum NODE_TYPE { __scope__ = 1 << 16, __comment__ = 1 << 17, __profiler__ = 1 << 18, + + // react compiler memo + __compiler__ = 1 << 19, } diff --git a/packages/core/src/utils.ts b/packages/core/src/utils.ts index dcece5b..0ec948f 100644 --- a/packages/core/src/utils.ts +++ b/packages/core/src/utils.ts @@ -1,4 +1,4 @@ -import { HOOK_TYPE } from "@my-react/react-shared"; +import { HOOK_TYPE, merge } from "@my-react/react-shared"; import { getNode, getNodeForce } from "./data"; import { getPlainNodeByFiber } from "./tree"; @@ -14,10 +14,13 @@ import type { createContext, lazy, } from "@my-react/react"; -import type { MyReactFiberContainer, MyReactFiberNode, MyReactFiberNodeDev, MyReactHookNodeDev } from "@my-react/react-reconciler"; +import type { MyReactFiberContainer, MyReactFiberNode, MyReactFiberNodeDev, MyReactHookNode, MyReactHookNodeDev } from "@my-react/react-reconciler"; export const typeKeys: number[] = []; +// SEE https://github.com/facebook/react/blob/main/compiler/packages/react-compiler-runtime/src/index.ts +const reactCompilerSymbol = Symbol.for("react.memo_cache_sentinel"); + Object.keys(NODE_TYPE).forEach((key) => { if (!key.startsWith("__")) { typeKeys.push(+key); @@ -71,19 +74,6 @@ export const getTypeName = (type: number) => { } }; -export const getFiberType = (t: number) => { - const type: string[] = []; - - typeKeys.forEach((key) => { - if (t & key) { - const name = getTypeName(key); - name && type.push(name); - } - }); - - return type; -}; - export const getFiberTag = (t: number) => { const tag: string[] = []; if (t & NODE_TYPE.__memo__) { @@ -95,9 +85,28 @@ export const getFiberTag = (t: number) => { if (t & NODE_TYPE.__lazy__) { tag.push("lazy"); } + if (t & NODE_TYPE.__compiler__) { + tag.push("compiler ✨"); + } return tag; }; +export const getFiberType = (fiber: MyReactFiberNode) => { + const t = fiber.type; + + let hasCompiler = false; + + // check react compiler + fiber.hookList?.listToFoot((l: MyReactHookNode) => { + if (hasCompiler) return; + if (l.type === HOOK_TYPE.useMemo && l.result?.[reactCompilerSymbol]) { + hasCompiler = true; + } + }); + + return hasCompiler ? merge(t, NODE_TYPE.__compiler__) : t; +}; + export const getFiberName = (fiber: MyReactFiberNodeDev) => { const typedFiber = fiber as MyReactFiberNodeDev; if (fiber.type & NODE_TYPE.__provider__) {