Match-id-0aa7af9b42fd69fca90b5f8d9b55d3a19e3234fe
This commit is contained in:
parent
0ae3910553
commit
5fa9f49496
|
@ -51,6 +51,7 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
|
||||||
changeSource(message, DevToolBackground);
|
changeSource(message, DevToolBackground);
|
||||||
connections[tabId].postMessage(message);
|
connections[tabId].postMessage(message);
|
||||||
} else {
|
} else {
|
||||||
|
// TODO: 如果查询失败,发送 chrome message,请求 panel 主动建立连接
|
||||||
console.log('Tab not found in connection list.');
|
console.log('Tab not found in connection list.');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -134,6 +134,7 @@ let helper;
|
||||||
|
|
||||||
function init(horizonHelper) {
|
function init(horizonHelper) {
|
||||||
helper = horizonHelper;
|
helper = horizonHelper;
|
||||||
|
window.__HORIZON_DEV_HOOK__.isInit = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function injectHook() {
|
function injectHook() {
|
||||||
|
@ -144,6 +145,7 @@ function injectHook() {
|
||||||
enumerable: false,
|
enumerable: false,
|
||||||
value: {
|
value: {
|
||||||
init,
|
init,
|
||||||
|
isInit: false,
|
||||||
addIfNotInclude,
|
addIfNotInclude,
|
||||||
send,
|
send,
|
||||||
deleteVNode,
|
deleteVNode,
|
||||||
|
|
|
@ -74,7 +74,7 @@ export const helper = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
function injectUpdater() {
|
export function injectUpdater() {
|
||||||
const hook = window.__HORIZON_DEV_HOOK__;
|
const hook = window.__HORIZON_DEV_HOOK__;
|
||||||
if (hook) {
|
if (hook) {
|
||||||
hook.init(helper);
|
hook.init(helper);
|
||||||
|
|
|
@ -36,6 +36,7 @@ import {
|
||||||
updateShouldUpdateOfTree
|
updateShouldUpdateOfTree
|
||||||
} from './vnode/VNodeShouldUpdate';
|
} from './vnode/VNodeShouldUpdate';
|
||||||
import { getPathArr } from './utils/vNodePath';
|
import { getPathArr } from './utils/vNodePath';
|
||||||
|
import { injectUpdater } from '../external/devtools';
|
||||||
|
|
||||||
// 不可恢复错误
|
// 不可恢复错误
|
||||||
let unrecoverableErrorDuringBuild: any = null;
|
let unrecoverableErrorDuringBuild: any = null;
|
||||||
|
@ -281,6 +282,11 @@ function renderFromRoot(treeRoot) {
|
||||||
|
|
||||||
if (window.__HORIZON_DEV_HOOK__) {
|
if (window.__HORIZON_DEV_HOOK__) {
|
||||||
const hook = window.__HORIZON_DEV_HOOK__;
|
const hook = window.__HORIZON_DEV_HOOK__;
|
||||||
|
// injector.js 可能在 Horizon 代码之后加载,此时无 __HORIZON_DEV_HOOK__ 全局变量
|
||||||
|
// Horizon 代码初次加载时不会初始化 helper
|
||||||
|
if (!hook.isInit) {
|
||||||
|
injectUpdater();
|
||||||
|
}
|
||||||
hook.addIfNotInclude(treeRoot);
|
hook.addIfNotInclude(treeRoot);
|
||||||
hook.send(treeRoot);
|
hook.send(treeRoot);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue