Match-id-80dac32ce407402ccfcdaf71a197c4f53d3cac98
This commit is contained in:
commit
7f2f2a8746
|
@ -7,7 +7,7 @@
|
|||
"build": "webpack --config ./webpack.config.js",
|
||||
"watch": "webpack --config ./webpack.config.js --watch",
|
||||
"build-dev": "webpack --config ./webpack.dev.js",
|
||||
"start": "webpack serve --config ./webpack.dev.js ",
|
||||
"start": "npm run build && webpack serve --config ./webpack.dev.js ",
|
||||
"test": "jest"
|
||||
},
|
||||
"keywords": [],
|
||||
|
|
|
@ -51,6 +51,7 @@ chrome.runtime.onMessage.addListener(function (message, sender, sendResponse) {
|
|||
changeSource(message, DevToolBackground);
|
||||
connections[tabId].postMessage(message);
|
||||
} else {
|
||||
// TODO: 如果查询失败,发送 chrome message,请求 panel 主动建立连接
|
||||
console.log('Tab not found in connection list.');
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -134,6 +134,7 @@ let helper;
|
|||
|
||||
function init(horizonHelper) {
|
||||
helper = horizonHelper;
|
||||
window.__HORIZON_DEV_HOOK__.isInit = true;
|
||||
}
|
||||
|
||||
function injectHook() {
|
||||
|
@ -144,6 +145,7 @@ function injectHook() {
|
|||
enumerable: false,
|
||||
value: {
|
||||
init,
|
||||
isInit: false,
|
||||
addIfNotInclude,
|
||||
send,
|
||||
deleteVNode,
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<html style="display: flex">
|
||||
|
||||
<head>
|
||||
<meta charset="utf8">
|
||||
<title>Horizon</title>
|
||||
<script src='horizon.production.js'></script>
|
||||
<style>
|
||||
html {
|
||||
width: 100%;
|
||||
|
@ -24,11 +22,12 @@
|
|||
}
|
||||
|
||||
</style>
|
||||
<script src='horizon.development.js'></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="root"></div>
|
||||
<div id="root"></div>
|
||||
<script src="panel.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -1,5 +1,21 @@
|
|||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
const fs = require('fs');
|
||||
|
||||
function handleBuildDir() {
|
||||
const staticDir = path.join(__dirname, 'build');
|
||||
console.log('staticDir: ', staticDir);
|
||||
const isBuildExist = fs.existsSync(staticDir);
|
||||
console.log('isBuildExist: ', isBuildExist);
|
||||
if (!isBuildExist) {
|
||||
fs.mkdirSync(staticDir);
|
||||
}
|
||||
fs.copyFileSync(path.join(__dirname, 'src', 'panel', 'panel.html'),path.join(staticDir, 'panel.html'));
|
||||
fs.copyFileSync(path.join(__dirname, 'src', 'main', 'main.html'),path.join(staticDir, 'main.html'));
|
||||
fs.copyFileSync(path.join(__dirname, 'src', 'manifest.json'),path.join(staticDir, 'manifest.json'));
|
||||
}
|
||||
handleBuildDir();
|
||||
|
||||
|
||||
const config = {
|
||||
entry: {
|
||||
|
|
|
@ -47,7 +47,7 @@ module.exports = {
|
|||
},
|
||||
devServer: {
|
||||
static: {
|
||||
directory: path.join(__dirname, 'dist'),
|
||||
directory: path.join(__dirname, 'build'),
|
||||
},
|
||||
open: 'panel.html',
|
||||
port: 9000,
|
||||
|
|
|
@ -74,7 +74,7 @@ export const helper = {
|
|||
},
|
||||
};
|
||||
|
||||
function injectUpdater() {
|
||||
export function injectUpdater() {
|
||||
const hook = window.__HORIZON_DEV_HOOK__;
|
||||
if (hook) {
|
||||
hook.init(helper);
|
||||
|
|
|
@ -36,6 +36,7 @@ import {
|
|||
updateShouldUpdateOfTree
|
||||
} from './vnode/VNodeShouldUpdate';
|
||||
import { getPathArr } from './utils/vNodePath';
|
||||
import { injectUpdater } from '../external/devtools';
|
||||
|
||||
// 不可恢复错误
|
||||
let unrecoverableErrorDuringBuild: any = null;
|
||||
|
@ -281,6 +282,11 @@ function renderFromRoot(treeRoot) {
|
|||
|
||||
if (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.send(treeRoot);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue