Skip to content

Commit

Permalink
chore: bump 3.5.9
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasticsoul committed Dec 16, 2023
1 parent e376e89 commit 753bfdb
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 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.7",
"version": "3.5.9",
"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.8';
export const VER = '3.5.9';

export const LIMU_VER = limuVer;

Expand Down
10 changes: 5 additions & 5 deletions packages/helux-core/src/factory/creator/mutateFn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import { createWatchLogic } from '../createWatch';
import { buildReactive, innerFlush } from './reactive';

interface ICallMutateBase {
/** 透传给用户 */
isFirstCall?: boolean;
/** watchAndCallMutateDict 需要自己捕获错误 */
throwErr?: boolean;
desc?: string;
sn?: number;
deps?: Fn;
from: From;
/** watchAndRunMutate 需要自己捕获错误 */
throwErr?: boolean;
/** 控制死循环探测逻辑执行时机 */
isFirstCall?: boolean;
}

interface ICallMutateFnOpt<T = SharedState> extends ICallMutateBase {
Expand Down Expand Up @@ -118,7 +118,7 @@ export function callAsyncMutateFnLogic<T = SharedState>(

/** 呼叫同步函数的逻辑封装 */
export function callMutateFnLogic<T = SharedState>(targetState: T, options: ICallMutateFnOpt<T>): [any, Error | null] {
const { desc = '', sn, fn, getArgs = noop, deps, from, throwErr, isFirstCall } = options;
const { desc = '', sn, fn, getArgs = noop, deps, from, throwErr, isFirstCall = false } = options;
const internal = getInternal(targetState);
const { forAtom, setStateFactory, sharedState } = internal;
const innerSetOptions: IInnerSetStateOptions = { desc, sn, from, isFirstCall };
Expand Down
2 changes: 1 addition & 1 deletion packages/helux-core/src/factory/creator/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function parseMutateFn(fnItem: Dict, inputDesc?: string, checkDupDict?: D
deps: depsVar,
task: taskVar,
immediate,
depKeys: []
depKeys: [],
};
}
}
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].8
| [email protected].9
| 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.8';
export declare const VER: '3.5.9';

export declare const LIMU_VER: string;

Expand Down
26 changes: 14 additions & 12 deletions packages/helux-core/src/types/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,20 +272,22 @@ export type MutateWitness<T = any> = {
// for mutate task
export type MutateTask<T = SharedState, P = ReadOnlyArr> = (param: IMutateTaskParam<T, P>) => Promise<void>;

export type MutateFnParams<T = SharedState, P = ReadOnlyArr> = {
/** 是否第一次调用 */
isFirstCall: boolean;
/** mutate deps 函数的返回值 */
input: P;
/** 只读状态 */
state: StateType<T>;
/** 草稿根状态,对与 atom 对象,根状态是未拆箱的值 */
draftRoot: DraftRootType<T>;
};

/** 如定义了 task 函数,则 fn 在异步函数执行之前回执行一次,且只在首次执行一次,后续不会执行 */
export type MutateFn<T = SharedState, P = ReadOnlyArr> = (
/** 草稿状态,对与 atom 对象 draft 是已拆箱的值,如需操作未拆箱值可读取下面的 params.draftRoot */
draft: DraftType<T>,
params: {
/** 是否第一次调用 */
isFirstCall: boolean;
/** mutate deps 函数的返回值 */
input: P;
/** 只读状态 */
state: StateType<T>;
/** 草稿根状态,对与 atom 对象,根状态是未拆箱的值 */
draftRoot: DraftRootType<T>;
},
params: MutateFnParams<T, P>,
) => void;

export type MutateFnItem<T = SharedState, P = ReadOnlyArr> = {
Expand Down Expand Up @@ -730,7 +732,7 @@ export interface IAtomCtx<T = any> extends ISharedStateCtxBase<Atom<T>> {
setAtomVal: (val: T) => void;
}

export interface IMutateFnParams<T = SharedState> {
export interface BeforeFnParams<T = SharedState> {
from: From;
desc?: FnDesc;
sn?: number;
Expand Down Expand Up @@ -802,7 +804,7 @@ export interface ICreateOptionsFull<T = SharedState> {
* action、mutate、setState、sync提交状态之前的函数,建议优先对 draft 操作,
* 如需要返回则返回的部分对象是全新值才是安全的草稿,该函数执行时机是在中间件之前
*/
before: (params: IMutateFnParams<T>) => void | Partial<T>;
before: (params: BeforeFnParams<T>) => void | Partial<T>;
/**
* deafult: undefined
* 不配置此项时,开发环境弹死循环提示,生产环境不弹
Expand Down

0 comments on commit 753bfdb

Please sign in to comment.