🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@complex-suite/data

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@complex-suite/data - npm Package Compare versions

Comparing version
5.0.15
to
5.0.16
+21
-0
history.md

@@ -10,2 +10,23 @@ <!--

### 5.0.16
- fix(search): `SearchData.resetForm` 改为返回 `Promise<void>` 的异步函数,`parseData` 完成后再执行 `syncData` 与 `_syncData`,消除重置后 `$current` 先按空表单收集的时序错位;新增同步轻量函数 `clearFormData` 供 `reset`/`destroy` 路径调用,避免销毁场景触发异步 parse;`ComplexData.resetSearch` 改为 `Promise.resolve(search?.resetForm(...)).then(() => setSearch('reset'))` 链式调用,确保搜索在表单默认值解析完成后触发
- fix(status): operate 状态 `option: { type:'count' }` 改为顶层 `type: 'count' as const`,使 StatusItem 构造中的 `initOption.type === 'count'` 生效,count 计数模式正确初始化,并发操作状态互不干扰
- fix(search): `SearchData.destroy` 用可选链`this.$runtime?.list.clearWatcher()`替代双重条件判断,始终清理watcher;destroy后将`this.$runtime`置为undefined,使后续init能正确重建
- fix(status): `StatusData.getCurrent` 对`this.data[target]`做空判断,缺失时返回默认值`StatusValue.un`而非崩溃
- fix(dictionary): `parseValue` 中 `DefaultLoadEdit` 分支改为 `.finally()` + `new Promise` 写法替代 `.catch(() => {}).then()`,消除 `.catch` 回调无返回值导致的 TS2345 类型推断污染。
- fix(module): `DependData.$loadDependSequentially` 的 `resList` 从 `unknown[]` 改为 `PromiseSettledResult<unknown>[]`,`then` 中 push `{ status: 'fulfilled', value: res }`,`catch` 中 push `{ status: 'rejected', reason: err }`,与 `$loadDependConcurrently` 的 `Promise.allSettled` 返回格式统一,调用方可按统一结构区分成功与失败
- fix(data): `ComplexData.$triggerDataChange` 的 `.then(callback)` 改为 `.then(callback, () => {})`,显式提供 onRejected 静默处理,消除原 promise reject 时派生 Promise 的 Unhandled Promise Rejection;dataChange 仅在成功时触发,外部 `.catch()` 挂载在返回的原始 promise 上不受影响
- fix(module): `UpdateData.next` 中 `this.load.operate = false` 从方法开头延迟到 check 完成后执行(共 7 处分支含 else 兜底),`triggerLife('triggered')` 保持原位;异步 check 的 `.then` 回调增加 `load.immediate` 检查,check pending 期间用户调用 `immediate()` 时 check resolve 后优先走 `$start(0)` 而非 `_triggerStart(offset)`,消除 check 与 immediate 的竞态
- fix(search): `SearchData.validateAndSyncData` 的 `promise.then(() => { this.syncData() })` 改为 `promise.then(() => { this.syncData() }, () => {})`,显式提供 onRejected 静默处理,消除 `$validate()` reject 时的 Unhandled Promise Rejection;syncData 仅在成功时触发,外部 `.catch()` 挂载在返回的原始 promise 上不受影响
- fix(data): `BaseData.destroy` 将 `destroyLife` 条件判断移到 `triggerLife('destroyed')` 之后,保证 'destroyed' 生命周期回调在生命周期系统销毁前正常触发
- fix(data): `BaseData.$onDependLoaded` 增加 `depend.$init` 判断,若依赖已初始化完成直接执行 next(),避免动态安装模块时 dependLoaded 已触发导致监听永不执行
- fix(search): `SearchData.validateAndSyncData` 将 fire-and-forget 改为 `return promise.then(res => { this.syncData(); return res })`,将 syncData 纳入返回链,异常可被调用方 catch
- fix(module): `PaginationData._install` 的 beforeReload handler 中,当 `pageResetOption` 为用户对象时(else 分支)添加 `pageResetOption = { ...pageResetOption }` 浅拷贝断开用户对象引用,避免 `untriggerLife` 赋值污染原始 `force.module.pagination` 对象
- fix(data): `Data._install` 从空方法改为调用 `this.$setParent(target)`,所有通过 ModuleData.installData 安装的子模块自动获得 parent 引用,修复 UpdateData._trigger 中 `$getParent()` 返回 undefined 导致自动更新循环中断的问题
- chore(index,LayoutParse): 删除未使用的类型导入(index.ts: SimpleDateEdit 相关 8 个类型 + FormEditOption;LayoutParse.ts: GridParseInitOption)
- fix(data): `BaseData.onLoaded` 和 `SelectData.onLoaded` 在 loadStatus 已为 success 时立即执行 handler,补齐参数为 `(lifeValue, this, { res: undefined, args: [] })`,与 `triggerLife('loaded', this, {res, args})` 正常触发时的 3 参数签名一致
- fix(search): `SearchData.init(force)` 覆盖 `this.$runtime` 前,若旧 runtime 存在则调用 `oldRuntime.list.clearWatcher()` 清理旧 watcher,避免 `init(true)` 重复调用时旧 observeList 的 watcher 累积泄漏
- fix(core): `SelectData.loadData` 的 `!force` 分支增加 `loadStatus === StatusValue.ing` 时 `getData = false` 判断,阻止 `$reload=true` 且加载中时的并发加载竞态
- fix(module): `PaginationData.setPageAndSize` 中 `setSize` 传入第三参数 `true`、`setPage` 传入第二参数 `true`,抑制子方法各自触发的 `change` 事件,仅由 `setPageAndSize` 统一触发合并的 `currentAndSize` change 事件,消除单次分页大小切换触发3次 `paginationChange` 的问题
### 5.0.15

@@ -12,0 +33,0 @@ - fix(module): `DictionaryData.sortPageList` handler 内增加 findIndex + splice 先移除自身当前位置,再重新查找对标位置后插入,与 `sortObserveList` 的 handler 行为对齐,消除链式排序时元素重复。

+2
-2

@@ -75,5 +75,5 @@ /**

import DefaultSimpleEdit, { type DefaultSimpleEditInitOption } from './src/dictionary/DefaultSimpleEdit'
import SimpleDateEdit, { type SimpleDateEditInitOption, type dateConfigValue, type rangeLimitType, type dateConfig, type BaseSimpleDateEditOption, type PartialBaseSimpleDateEditOption, type RangeSimpleDateEditOption, type SimpleDateEditOption, type PartialSimpleDateEditOption } from './src/dictionary/SimpleDateEdit'
import SimpleDateEdit, { type SimpleDateEditInitOption } from './src/dictionary/SimpleDateEdit'
import DefaultLoadEdit, { type DefaultLoadEditInitOption } from './src/dictionary/DefaultLoadEdit'
import FormEdit, { type FormEditOption, type FormEditInitOption } from './src/dictionary/FormEdit'
import FormEdit, { type FormEditInitOption } from './src/dictionary/FormEdit'
import ListEdit, { type ListEditInitOption } from './src/dictionary/ListEdit'

@@ -80,0 +80,0 @@ import DefaultSelectEdit, { type SelectEditFilterType, type DefaultSelectEditInitOption } from './src/dictionary/DefaultSelectEdit'

{
"name": "@complex-suite/data",
"version": "5.0.15",
"version": "5.0.16",
"description": "a complex data",

@@ -15,4 +15,4 @@ "type": "module",

"dependencies": {
"@complex-suite/utils": "3.0.15",
"@complex-suite/plugin": "5.0.15"
"@complex-suite/utils": "3.0.16",
"@complex-suite/plugin": "5.0.16"
},

@@ -19,0 +19,0 @@ "devDependencies": {

@@ -118,3 +118,3 @@ import { Life } from '@complex-suite/utils'

const lifeValue = this.$life.get('loaded')!.get(id)!
lifeValueInitOption.handler(lifeValue)
lifeValueInitOption.handler(lifeValue, this, { res: undefined, args: [] })
}

@@ -138,3 +138,5 @@ }

// 非强制获取情况下,进行状态判断
if ([StatusValue.un, StatusValue.fail].includes(loadStatus)) {
if (loadStatus === StatusValue.ing) {
getData = false
} else if ([StatusValue.un, StatusValue.fail].includes(loadStatus)) {
getData = true

@@ -141,0 +143,0 @@ }

@@ -280,3 +280,3 @@ import { getComplexProp, isPromise } from '@complex-suite/utils'

$onDependLoaded(next: () => void) {
if (!this.$depend) {
if (!this.$depend || this.$depend.$init) {
next()

@@ -359,3 +359,3 @@ } else {

const lifeValue = this.$life.get('loaded')!.get(id)!
lifeValueInitOption.handler(lifeValue)
lifeValueInitOption.handler(lifeValue, this, { res: undefined, args: [] })
}

@@ -388,3 +388,2 @@ }

if (parseResetOption(destroyOption, 'promise') !== false) this.$promise.destroy()
if (parseResetOption(destroyOption, 'life') === true) this.destroyLife()
if (parseResetOption(destroyOption, 'depend') === true && this.$depend) this.$depend.destroy(true)

@@ -394,2 +393,3 @@ // 额外数据不存在destroy,因此不做销毁,在reset中可能存在清空操作

this.triggerLife('destroyed', this, destroyOption, ...args)
if (parseResetOption(destroyOption, 'life') === true) this.destroyLife()
// 清空生命周期

@@ -396,0 +396,0 @@ this.$life.destroy()

@@ -105,3 +105,3 @@ import BaseData from "./BaseData"

this.triggerLife('dataChange', this, triggerName, ...args)
})
}, () => {})
return promise

@@ -347,4 +347,5 @@ }

resetSearch(option?: resetOption) {
this.$module.search?.resetForm('reset', option)
return this.setSearch('reset')
return Promise.resolve(this.$module.search?.resetForm('reset', option)).then(() => {
return this.setSearch('reset')
})
}

@@ -351,0 +352,0 @@ $onSearchInited(next: () => void) {

@@ -70,4 +70,4 @@ import { _Data } from '@complex-suite/utils'

// eslint-disable-next-line @typescript-eslint/no-unused-vars
_install(_target: BaseData, _from?: string) {
//
_install(target: BaseData, _from?: string) {
this.$setParent(target)
}

@@ -74,0 +74,0 @@ // eslint-disable-next-line @typescript-eslint/no-unused-vars

@@ -427,3 +427,7 @@ import { isExist, exportMsg, getComplexProp, trimData, isArray } from '@complex-suite/utils'

// loadData 的结果不影响解析流程,无论加载成功/失败都继续执行 _setParseValue
return mod.loadData().catch(() => {}).then(() => this._setParseValue(mod, payload))
return new Promise((resolve, reject) => {
mod.loadData().finally(() => {
this._setParseValue(mod, payload).then(resolve, reject)
})
})
} else {

@@ -430,0 +434,0 @@ return this._setParseValue(mod, payload)

import GridParse from "./GridParse"
import InterfaceValue from "./InterfaceValue"
import type { GridParseInitOption, InterfaceValueInitOption, LayoutParseInitOption } from '../types'
import type { InterfaceValueInitOption, LayoutParseInitOption } from '../types'

@@ -5,0 +5,0 @@ class LayoutParse {

@@ -141,7 +141,7 @@ import { upperCaseFirstChar } from "@complex-suite/utils"

}
// 依序加载依赖
// 依序加载依赖,返回 PromiseSettledResult[] 与并发模式 $loadDependConcurrently 格式一致
$loadDependSequentially() {
return new Promise((resolve) => {
return new Promise<PromiseSettledResult<unknown>[]>((resolve) => {
let index = -1
const resList: unknown[] = []
const resList: PromiseSettledResult<unknown>[] = []
const next = () => {

@@ -151,6 +151,6 @@ index++

this.list[index].loadData().then(res => {
resList.push(res)
resList.push({ status: 'fulfilled', value: res })
next()
}).catch(err => {
resList.push(err)
resList.push({ status: 'rejected', reason: err })
next()

@@ -157,0 +157,0 @@ })

@@ -172,4 +172,4 @@ import { getNum } from '@complex-suite/utils'

setPageAndSize(data: { page: number, size: number }, unTriggerCurrentAndSizeLife?: boolean): { page: boolean, size: boolean, changed: boolean } {
const sizeChanged = this.setSize(data.size, true)
const pageChanged = this.setPage(data.page)
const sizeChanged = this.setSize(data.size, true, true)
const pageChanged = this.setPage(data.page, true)
const changed = sizeChanged || pageChanged

@@ -230,2 +230,5 @@ if (!unTriggerCurrentAndSizeLife && changed) {

}
} else {
// 浅拷贝断开用户对象引用,避免修改 force.module.pagination 原始对象
pageResetOption = { ...pageResetOption }
}

@@ -232,0 +235,0 @@ if (pageResetOption.untriggerLife == undefined) {

@@ -196,2 +196,5 @@ import { deepCloneData, getType } from "@complex-suite/utils"

}
if (this.$runtime) {
this.$runtime.list.clearWatcher()
}
this.$runtime = runtime

@@ -227,6 +230,6 @@ // 初始化form

const promise = this.$validate()
promise.then(() => {
return promise.then((res) => {
this.syncData()
return res
})
return promise
}

@@ -242,17 +245,27 @@ // 同步值

}
resetForm(from = '' , option?: resetOption) {
clearFormData() {
const runtime = this.$runtime
if (runtime) {
if (!option) {
option = this.$resetOption || {}
}
runtime.form.setData({})
this.parseData(runtime.dictionary, runtime.form, this.$type, undefined, from)
runtime.form.clearValidate()
if (option.sync !== false) {
this.syncData()
}
this._syncData(true, 'resetForm', from)
}
}
resetForm(from = '' , option?: resetOption): Promise<void> {
const runtime = this.$runtime
if (!runtime) {
return Promise.resolve()
}
if (!option) {
option = this.$resetOption || {}
}
this.clearFormData()
return this.parseData(runtime.dictionary, runtime.form, this.$type, undefined, from)
.then(() => {
if (this.$runtime !== runtime) return
if (option!.sync !== false) {
this.syncData()
}
this._syncData(true, 'resetForm', from)
})
}
getData(unClone?: boolean) {

@@ -276,3 +289,3 @@ return !unClone ? deepCloneData(this.$current) : this.$current

if (option !== false) {
this.resetForm('reset')
this.clearFormData()
}

@@ -283,5 +296,4 @@ }

this.reset(option)
if (this.$observe && this.$runtime) {
this.$runtime.list.clearWatcher()
}
this.$runtime?.list.clearWatcher()
this.$runtime = undefined
}

@@ -288,0 +300,0 @@ }

@@ -97,5 +97,3 @@ import Data from '../data/Data'

list: [StatusValue.un, StatusValue.ing],
option: {
type: 'count'
}
type: 'count'
} as StatusItemInitOptionObject

@@ -262,3 +260,3 @@ }

getCurrent(target = 'operate') {
return this.data[target].getCurrent()
return this.data[target]?.getCurrent() ?? StatusValue.un
}

@@ -265,0 +263,0 @@ setData(data: StatusDataValueType, target = 'operate', act?: 'reset') {

@@ -161,3 +161,2 @@ import { isPromise } from '@complex-suite/utils'

// trigger结束
this.load.operate = false
this.triggerLife('triggered', this, offset)

@@ -172,4 +171,10 @@ if (this.load.update && !this.load.immediate) {

checkRes.then(() => {
this._triggerStart(offset as number)
this.load.operate = false
if (this.load.immediate) {
this.$start(0)
} else {
this._triggerStart(offset as number)
}
}).catch(err => {
this.load.operate = false
this.$exportMsg(dataLocale.t('update.stop'), 'log')

@@ -180,11 +185,17 @@ console.error(err)

} else if (checkRes) {
this.load.operate = false
this._triggerStart(offset)
} else {
this.load.operate = false
this.clear()
}
} else {
this.load.operate = false
this.clear()
}
} else if (this.load.immediate) {
this.load.operate = false
this.$start(0)
} else {
this.load.operate = false
}

@@ -191,0 +202,0 @@ }