From 59219b83ee11f6c92edbf03b1505e7497993dd9e Mon Sep 17 00:00:00 2001 From: MrWangJustToDo <2711470541@qq.com> Date: Fri, 6 Dec 2024 18:35:43 +0800 Subject: [PATCH] fix missing component name --- chrome/public/bundle/detector.js | 23 +++++++++++++-------- chrome/public/bundle/hook.js | 23 +++++++++++++-------- chrome/public/bundle/panel.js | 23 +++++++++++++-------- chrome/public/bundle/proxy.js | 23 +++++++++++++-------- chrome/public/bundle/service-worker.js | 23 +++++++++++++-------- packages/core/src/instance.ts | 28 +++++++++++++++++--------- 6 files changed, 93 insertions(+), 50 deletions(-) diff --git a/chrome/public/bundle/detector.js b/chrome/public/bundle/detector.js index 63c8666..7d8c4de 100644 --- a/chrome/public/bundle/detector.js +++ b/chrome/public/bundle/detector.js @@ -2062,7 +2062,7 @@ if (!_this.hasEnable) return; _this.notifyHMR(); - _this.notifyDispatch(dispatch); + _this.notifyDispatch(dispatch, true); }; var onFiberRun = function (fiber) { var _a, _b; @@ -2250,17 +2250,24 @@ var data = getNodeFromId(Number(id)); this._notify({ type: exports.DevToolMessageEnum.chunk, data: (_a = {}, _a[id] = { loaded: data }, _a) }); }; - DevToolCore.prototype.notifyDispatch = function (dispatch) { + DevToolCore.prototype.notifyDispatch = function (dispatch, force) { if (!this.hasEnable) return; if (this._dispatch.has(dispatch)) { var now = Date.now(); - var last = map.get(dispatch); - if (last && now - last < 200) - return; - map.set(dispatch, now); - var tree = this.getTree(dispatch); - this._notify({ type: exports.DevToolMessageEnum.ready, data: tree }); + if (force) { + map.set(dispatch, now); + var tree = this.getTree(dispatch); + this._notify({ type: exports.DevToolMessageEnum.ready, data: tree }); + } + else { + var last = map.get(dispatch); + if (last && now - last < 200) + return; + map.set(dispatch, now); + var tree = this.getTree(dispatch); + this._notify({ type: exports.DevToolMessageEnum.ready, data: tree }); + } } }; DevToolCore.prototype.connect = function () { diff --git a/chrome/public/bundle/hook.js b/chrome/public/bundle/hook.js index 41401b8..213f421 100644 --- a/chrome/public/bundle/hook.js +++ b/chrome/public/bundle/hook.js @@ -2135,7 +2135,7 @@ if (!_this.hasEnable) return; _this.notifyHMR(); - _this.notifyDispatch(dispatch); + _this.notifyDispatch(dispatch, true); }; var onFiberRun = function (fiber) { var _a, _b; @@ -2323,17 +2323,24 @@ var data = getNodeFromId(Number(id)); this._notify({ type: exports.DevToolMessageEnum.chunk, data: (_a = {}, _a[id] = { loaded: data }, _a) }); }; - DevToolCore.prototype.notifyDispatch = function (dispatch) { + DevToolCore.prototype.notifyDispatch = function (dispatch, force) { if (!this.hasEnable) return; if (this._dispatch.has(dispatch)) { var now = Date.now(); - var last = map.get(dispatch); - if (last && now - last < 200) - return; - map.set(dispatch, now); - var tree = this.getTree(dispatch); - this._notify({ type: exports.DevToolMessageEnum.ready, data: tree }); + if (force) { + map.set(dispatch, now); + var tree = this.getTree(dispatch); + this._notify({ type: exports.DevToolMessageEnum.ready, data: tree }); + } + else { + var last = map.get(dispatch); + if (last && now - last < 200) + return; + map.set(dispatch, now); + var tree = this.getTree(dispatch); + this._notify({ type: exports.DevToolMessageEnum.ready, data: tree }); + } } }; DevToolCore.prototype.connect = function () { diff --git a/chrome/public/bundle/panel.js b/chrome/public/bundle/panel.js index 51ae270..245affc 100644 --- a/chrome/public/bundle/panel.js +++ b/chrome/public/bundle/panel.js @@ -2133,7 +2133,7 @@ if (!_this.hasEnable) return; _this.notifyHMR(); - _this.notifyDispatch(dispatch); + _this.notifyDispatch(dispatch, true); }; var onFiberRun = function (fiber) { var _a, _b; @@ -2321,17 +2321,24 @@ var data = getNodeFromId(Number(id)); this._notify({ type: exports.DevToolMessageEnum.chunk, data: (_a = {}, _a[id] = { loaded: data }, _a) }); }; - DevToolCore.prototype.notifyDispatch = function (dispatch) { + DevToolCore.prototype.notifyDispatch = function (dispatch, force) { if (!this.hasEnable) return; if (this._dispatch.has(dispatch)) { var now = Date.now(); - var last = map.get(dispatch); - if (last && now - last < 200) - return; - map.set(dispatch, now); - var tree = this.getTree(dispatch); - this._notify({ type: exports.DevToolMessageEnum.ready, data: tree }); + if (force) { + map.set(dispatch, now); + var tree = this.getTree(dispatch); + this._notify({ type: exports.DevToolMessageEnum.ready, data: tree }); + } + else { + var last = map.get(dispatch); + if (last && now - last < 200) + return; + map.set(dispatch, now); + var tree = this.getTree(dispatch); + this._notify({ type: exports.DevToolMessageEnum.ready, data: tree }); + } } }; DevToolCore.prototype.connect = function () { diff --git a/chrome/public/bundle/proxy.js b/chrome/public/bundle/proxy.js index c8c0b50..71c7ad4 100644 --- a/chrome/public/bundle/proxy.js +++ b/chrome/public/bundle/proxy.js @@ -2062,7 +2062,7 @@ if (!_this.hasEnable) return; _this.notifyHMR(); - _this.notifyDispatch(dispatch); + _this.notifyDispatch(dispatch, true); }; var onFiberRun = function (fiber) { var _a, _b; @@ -2250,17 +2250,24 @@ var data = getNodeFromId(Number(id)); this._notify({ type: exports.DevToolMessageEnum.chunk, data: (_a = {}, _a[id] = { loaded: data }, _a) }); }; - DevToolCore.prototype.notifyDispatch = function (dispatch) { + DevToolCore.prototype.notifyDispatch = function (dispatch, force) { if (!this.hasEnable) return; if (this._dispatch.has(dispatch)) { var now = Date.now(); - var last = map.get(dispatch); - if (last && now - last < 200) - return; - map.set(dispatch, now); - var tree = this.getTree(dispatch); - this._notify({ type: exports.DevToolMessageEnum.ready, data: tree }); + if (force) { + map.set(dispatch, now); + var tree = this.getTree(dispatch); + this._notify({ type: exports.DevToolMessageEnum.ready, data: tree }); + } + else { + var last = map.get(dispatch); + if (last && now - last < 200) + return; + map.set(dispatch, now); + var tree = this.getTree(dispatch); + this._notify({ type: exports.DevToolMessageEnum.ready, data: tree }); + } } }; DevToolCore.prototype.connect = function () { diff --git a/chrome/public/bundle/service-worker.js b/chrome/public/bundle/service-worker.js index 27c6da0..746a606 100644 --- a/chrome/public/bundle/service-worker.js +++ b/chrome/public/bundle/service-worker.js @@ -2062,7 +2062,7 @@ if (!_this.hasEnable) return; _this.notifyHMR(); - _this.notifyDispatch(dispatch); + _this.notifyDispatch(dispatch, true); }; var onFiberRun = function (fiber) { var _a, _b; @@ -2250,17 +2250,24 @@ var data = getNodeFromId(Number(id)); this._notify({ type: exports.DevToolMessageEnum.chunk, data: (_a = {}, _a[id] = { loaded: data }, _a) }); }; - DevToolCore.prototype.notifyDispatch = function (dispatch) { + DevToolCore.prototype.notifyDispatch = function (dispatch, force) { if (!this.hasEnable) return; if (this._dispatch.has(dispatch)) { var now = Date.now(); - var last = map.get(dispatch); - if (last && now - last < 200) - return; - map.set(dispatch, now); - var tree = this.getTree(dispatch); - this._notify({ type: exports.DevToolMessageEnum.ready, data: tree }); + if (force) { + map.set(dispatch, now); + var tree = this.getTree(dispatch); + this._notify({ type: exports.DevToolMessageEnum.ready, data: tree }); + } + else { + var last = map.get(dispatch); + if (last && now - last < 200) + return; + map.set(dispatch, now); + var tree = this.getTree(dispatch); + this._notify({ type: exports.DevToolMessageEnum.ready, data: tree }); + } } }; DevToolCore.prototype.connect = function () { diff --git a/packages/core/src/instance.ts b/packages/core/src/instance.ts index c81e185..16e8b6e 100644 --- a/packages/core/src/instance.ts +++ b/packages/core/src/instance.ts @@ -217,7 +217,7 @@ export class DevToolCore { this.notifyHMR(); - this.notifyDispatch(dispatch); + this.notifyDispatch(dispatch, true); }; const onFiberRun = (fiber: MyReactFiberNodeDev) => { @@ -478,21 +478,29 @@ export class DevToolCore { this._notify({ type: DevToolMessageEnum.chunk, data: { [id]: { loaded: data } } }); } - notifyDispatch(dispatch: DevToolRenderDispatch) { + notifyDispatch(dispatch: DevToolRenderDispatch, force?: boolean) { if (!this.hasEnable) return; if (this._dispatch.has(dispatch)) { const now = Date.now(); - const last = map.get(dispatch); - - if (last && now - last < 200) return; - - map.set(dispatch, now); + if (force) { + map.set(dispatch, now); - const tree = this.getTree(dispatch); - - this._notify({ type: DevToolMessageEnum.ready, data: tree }); + const tree = this.getTree(dispatch); + + this._notify({ type: DevToolMessageEnum.ready, data: tree }); + } else { + const last = map.get(dispatch); + + if (last && now - last < 200) return; + + map.set(dispatch, now); + + const tree = this.getTree(dispatch); + + this._notify({ type: DevToolMessageEnum.ready, data: tree }); + } } }