Match-id-d0e5ae18684fb3ef46de9d8df3806ec5e84da25b
This commit is contained in:
parent
dfa9ad8f02
commit
c6f1debb03
|
@ -32,6 +32,8 @@ module.exports = {
|
||||||
es6: true,
|
es6: true,
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
|
'@typescript-eslint/no-explicit-any': 'off',
|
||||||
|
'@typescript-eslint/no-non-null-assertion': 'off',
|
||||||
'accessor-pairs': 'off',
|
'accessor-pairs': 'off',
|
||||||
'brace-style': ['error', '1tbs'],
|
'brace-style': ['error', '1tbs'],
|
||||||
'func-style': ['warn', 'declaration', { allowArrowFunctions: true }],
|
'func-style': ['warn', 'declaration', { allowArrowFunctions: true }],
|
||||||
|
|
|
@ -165,7 +165,7 @@ function getChildByIndex(vNode: VNode, idx: number) {
|
||||||
|
|
||||||
// 从多个更新节点中,计算出开始节点。即:找到最近的共同的父辈节点
|
// 从多个更新节点中,计算出开始节点。即:找到最近的共同的父辈节点
|
||||||
export function calcStartUpdateVNode(treeRoot: VNode) {
|
export function calcStartUpdateVNode(treeRoot: VNode) {
|
||||||
const toUpdateNodes = Array.from(treeRoot.toUpdateNodes);
|
const toUpdateNodes = [...treeRoot.toUpdateNodes];
|
||||||
|
|
||||||
if (toUpdateNodes.length === 0) {
|
if (toUpdateNodes.length === 0) {
|
||||||
return treeRoot;
|
return treeRoot;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type { VNode } from '../Types';
|
import type { VNode } from '../Types';
|
||||||
import type { Hook } from './HookType';
|
import type { Hook } from './HookType';
|
||||||
|
|
||||||
let processingVNode: VNode = null;
|
let processingVNode: VNode | null = null;
|
||||||
|
|
||||||
// lastTimeHook是上一次执行func时产生的hooks中,与currentHook对应的hook
|
// lastTimeHook是上一次执行func时产生的hooks中,与currentHook对应的hook
|
||||||
let lastTimeHook: Hook<any, any> | null = null;
|
let lastTimeHook: Hook<any, any> | null = null;
|
||||||
|
@ -13,7 +13,7 @@ export function getProcessingVNode() {
|
||||||
return processingVNode;
|
return processingVNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setProcessingVNode(vNode: VNode) {
|
export function setProcessingVNode(vNode: VNode | null) {
|
||||||
processingVNode = vNode;
|
processingVNode = vNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,11 +21,11 @@ export function getLastTimeHook() {
|
||||||
return lastTimeHook;
|
return lastTimeHook;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setLastTimeHook(hook: Hook<any, any>) {
|
export function setLastTimeHook(hook: Hook<any, any> | null) {
|
||||||
lastTimeHook = hook;
|
lastTimeHook = hook;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setCurrentHook(hook: Hook<any, any>) {
|
export function setCurrentHook(hook: Hook<any, any> | null) {
|
||||||
currentHook = hook;
|
currentHook = hook;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,17 +15,17 @@ import {
|
||||||
setProcessingVNode,
|
setProcessingVNode,
|
||||||
setCurrentHook, getNextHook
|
setCurrentHook, getNextHook
|
||||||
} from './BaseHook';
|
} from './BaseHook';
|
||||||
import {useStateImpl,} from './UseStateHook';
|
import {useStateImpl} from './UseStateHook';
|
||||||
import {useReducerImpl,} from './UseReducerHook';
|
import {useReducerImpl} from './UseReducerHook';
|
||||||
import {HookStage, setHookStage} from './HookStage';
|
import {HookStage, setHookStage} from './HookStage';
|
||||||
|
|
||||||
// hook对外入口
|
// hook对外入口
|
||||||
export function exeFunctionHook(
|
export function exeFunctionHook<Props extends Record<string, any>, Arg>(
|
||||||
funcComp: (props: Object, arg: Object) => any,
|
funcComp: (props: Props, arg: Arg) => any,
|
||||||
props: Object,
|
props: Props,
|
||||||
arg: Object,
|
arg: Arg,
|
||||||
processing: VNode,
|
processing: VNode,
|
||||||
): any {
|
) {
|
||||||
// 重置全局变量
|
// 重置全局变量
|
||||||
resetGlobalVariable();
|
resetGlobalVariable();
|
||||||
|
|
||||||
|
@ -39,13 +39,13 @@ export function exeFunctionHook(
|
||||||
processing.effectList = [];
|
processing.effectList = [];
|
||||||
|
|
||||||
// 设置hook阶段
|
// 设置hook阶段
|
||||||
if (processing.isCreated || !processing.oldHooks.length) {
|
if (processing.isCreated || !processing.oldHooks!.length) {
|
||||||
setHookStage(HookStage.Init);
|
setHookStage(HookStage.Init);
|
||||||
} else {
|
} else {
|
||||||
setHookStage(HookStage.Update);
|
setHookStage(HookStage.Update);
|
||||||
}
|
}
|
||||||
|
|
||||||
let comp = funcComp(props, arg);
|
const comp = funcComp(props, arg);
|
||||||
|
|
||||||
// 设置hook阶段为null,用于判断hook是否在函数组件中调用
|
// 设置hook阶段为null,用于判断hook是否在函数组件中调用
|
||||||
setHookStage(null);
|
setHookStage(null);
|
||||||
|
|
|
@ -10,6 +10,6 @@ export function getHookStage() {
|
||||||
return hookStage;
|
return hookStage;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setHookStage(phase: HookStage) {
|
export function setHookStage(phase: HookStage| null) {
|
||||||
hookStage = phase;
|
hookStage = phase;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
"libs/*"
|
"libs/*"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"lint": "eslint . --ext .ts",
|
||||||
"build": " webpack --config ./scripts/webpack/webpack.config.js",
|
"build": " webpack --config ./scripts/webpack/webpack.config.js",
|
||||||
"build-3rdLib": "node ./scripts/gen3rdLib.js",
|
"build-3rdLib": "node ./scripts/gen3rdLib.js",
|
||||||
"build-3rdLib-dev": "npm run build & node ./scripts/gen3rdLib.js --dev",
|
"build-3rdLib-dev": "npm run build & node ./scripts/gen3rdLib.js --dev",
|
||||||
|
|
Loading…
Reference in New Issue