Skip to content

Commit

Permalink
chore: bump 3.5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasticsoul committed Dec 16, 2023
1 parent a116b13 commit 2e34783
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "helux",
"version": "3.5.6",
"version": "3.5.7",
"description": "A state library core that integrates atom, signal, collection dep, derive and watch, it supports all react like frameworks( including react 18 ).",
"keywords": [],
"author": {
Expand Down
2 changes: 1 addition & 1 deletion packages/helux-core/src/consts/user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { VER as limuVer } from 'limu';

export const VER = '3.5.6';
export const VER = '3.5.7';

export const LIMU_VER = limuVer;

Expand Down
5 changes: 4 additions & 1 deletion packages/helux-core/src/factory/creator/mutateFn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ export function watchAndCallMutateDict(options: IWatchAndCallMutateDictOptions)
const { desc, fn, task, deps, immediate } = item;
const fnCtx = getRunningFn().fnCtx;
if (isFirstCall && fnCtx) {
fnCtx.subFnInfo = item; // 将子函数信息挂上去
// 将子函数信息挂上去
fnCtx.subFnInfo = item;
// 优先读子函数配置,在读模块配置
fnCtx.checkDeadCycle = item.checkDeadCycle ?? internal.checkDeadCycle;
}

FN_DEP_KEYS.del();
Expand Down
2 changes: 2 additions & 0 deletions packages/helux-core/src/factory/creator/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export function parseOptions(innerOptions: IInnerOptions, options: ICreateOption
const moduleName = options.moduleName || '';
const alertDeadCycleErr = options.alertDeadCycleErr ?? isDebug();
const deep = options.deep ?? true;
const checkDeadCycle = options.checkDeadCycle ?? true;
const recordLoading = options.recordLoading || RECORD_LOADING.PRIVATE;
const rules = options.rules || [];
const before = options.before || noop;
Expand All @@ -161,6 +162,7 @@ export function parseOptions(innerOptions: IInnerOptions, options: ICreateOption
/** TODO 未来支持 atom 对象销毁 */
isDestroyed: false,
alertDeadCycleErr,
checkDeadCycle,
rawState,
sharedKey,
sharedKeyStr,
Expand Down
1 change: 1 addition & 0 deletions packages/helux-core/src/helpers/fnCtx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function buildFnCtx(specificProps?: Partial<IFnCtx>): IFnCtx {
fnKey: '', // 在 feDep.mapFn 阶段会生成
fn: noop,
subFnInfo: fakeMutateFnItem,
checkDeadCycle: true,
isFirstLevel: true,
isExpired: false,
task: noop,
Expand Down
3 changes: 2 additions & 1 deletion packages/helux-core/src/helpers/fnRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ function runWatch(fnCtx: IFnCtx, options: IRnFnOpt) {
return;
}
// simpleWatch 的依赖时转移进去的,不需要判死循环,否则会照成误判
if (fnCtx.isSimpleWatch) {
// 设定了 checkDeadCycle 为 false,不检查死循环
if (fnCtx.isSimpleWatch || !fnCtx.checkDeadCycle) {
return fnCtx.fn({ isFirstCall, triggerReasons, sn });
}
// 优先开始检查 mutate 多个同步函数间的死循环
Expand Down
4 changes: 2 additions & 2 deletions packages/helux-core/src/types/api.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
|------------------------------------------------------------------------------------------------
| [email protected].6
| [email protected].7
| A state library core that integrates atom, signal, collection dep, derive and watch,
| it supports all react like frameworks ( including react 18 ).
|------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -59,7 +59,7 @@ import type {
WatchOptionsType,
} from './base';

export declare const VER: '3.5.6';
export declare const VER: '3.5.7';

export declare const LIMU_VER: string;

Expand Down
23 changes: 17 additions & 6 deletions packages/helux-core/src/types/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ export type MutateFnItem<T = SharedState, P = ReadOnlyArr> = {
task?: MutateTask<T, P>;
/** default: false, task 是否立即执行 */
immediate?: boolean;
/**
* default: undefined,是否检测死循环,设置为 false 表示不检查
* 未设定时,使用 atom、share 接口设定的checkDeadCycle值
*/
checkDeadCycle?: boolean;
};

/** std item 确保了 desc 一定存在 */
Expand Down Expand Up @@ -464,8 +469,8 @@ export type SyncFnBuilder<T = SharedState, V = any> = (

export type Syncer<T = SharedState> = T extends Atom | ReadOnlyAtom
? T['val'] extends Primitive
? SyncerFn
: { [key in keyof T['val']]: SyncerFn }
? SyncerFn
: { [key in keyof T['val']]: SyncerFn }
: { [key in keyof T]: SyncerFn };

export type SafeLoading<T = SharedState, O extends ICreateOptions<T> = ICreateOptions<T>> = O['mutate'] extends MutateFnDict<T>
Expand All @@ -474,16 +479,16 @@ export type SafeLoading<T = SharedState, O extends ICreateOptions<T> = ICreateOp

type FnResultType<T extends PlainObject | DeriveFn> = T extends PlainObject
? T['fn'] extends Fn
? DerivedAtom<ReturnType<T['fn']>>
: DerivedAtom<any>
? DerivedAtom<ReturnType<T['fn']>>
: DerivedAtom<any>
: T extends DeriveFn
? DerivedAtom<ReturnType<T>>
: DerivedAtom<any>;

type FnResultValType<T extends PlainObject | DeriveFn> = T extends PlainObject
? T['fn'] extends Fn
? ReturnType<T['fn']>
: any
? ReturnType<T['fn']>
: any
: T extends DeriveFn
? ReturnType<T>
: any;
Expand Down Expand Up @@ -803,6 +808,10 @@ export interface ICreateOptionsFull<T = SharedState> {
* 不配置此项时,开发环境弹死循环提示,生产环境不弹
*/
alertDeadCycleErr: boolean;
/**
* default: true,是否检测死循环,设置为 false 表示不检查
*/
checkDeadCycle?: boolean;
}

export interface IInnerCreateOptions<T = SharedState> extends ICreateOptionsFull<SharedState> {
Expand Down Expand Up @@ -1103,6 +1112,8 @@ export interface IFnCtx {
extra;
/** 对应的可能存在的子函数描述 */
subFnInfo: MutateFnStdItem;
/** 由 createSharedOptions.checkDeadCycle 和 mutateFnItem.checkDeadCycle 共同生成 */
checkDeadCycle: boolean;
setLoading: (loading: boolean, err?: any) => void;
}

Expand Down

0 comments on commit 2e34783

Please sign in to comment.