diff --git a/glass-easel-miniprogram-adapter/src/behavior.ts b/glass-easel-miniprogram-adapter/src/behavior.ts index 93c34eb..47e6fac 100644 --- a/glass-easel-miniprogram-adapter/src/behavior.ts +++ b/glass-easel-miniprogram-adapter/src/behavior.ts @@ -32,6 +32,8 @@ export class Behavior< /** @internal */ _$: glassEasel.GeneralBehavior /** @internal */ + _$chainingFilter?: typeUtils.ChainingFilterFunc + /** @internal */ _$bindedDefinitionFilter?: (target: GeneralComponentDefinition) => void /** @internal */ _$export?: (source: GeneralComponent | null) => TComponentExport @@ -41,9 +43,11 @@ export class Behavior< inner: glassEasel.Behavior, parents: GeneralBehavior[], definitionFilter: DefinitionFilter | undefined, + chainingFilter: typeUtils.ChainingFilterFunc | undefined, componentExport: ((source: GeneralComponent | null) => TComponentExport) | undefined, ) { this._$ = inner as glassEasel.GeneralBehavior + this._$chainingFilter = chainingFilter this._$export = componentExport // processing definition filter diff --git a/glass-easel-miniprogram-adapter/src/builder/behavior_builder.ts b/glass-easel-miniprogram-adapter/src/builder/behavior_builder.ts index e9e32b2..c01d0d4 100644 --- a/glass-easel-miniprogram-adapter/src/builder/behavior_builder.ts +++ b/glass-easel-miniprogram-adapter/src/builder/behavior_builder.ts @@ -43,6 +43,7 @@ export class BehaviorBuilder< TExtraThisFields > { private _$definitionFilter: DefinitionFilter | undefined + private _$chainingFilter?: ChainingFilterFunc /** @internal */ static create(codeSpace: CodeSpace): BehaviorBuilder { @@ -74,7 +75,7 @@ export class BehaviorBuilder< >, TChainingFilter > { - this._$.chainingFilter(func as any) + this._$chainingFilter = func return this as any } @@ -103,6 +104,9 @@ export class BehaviorBuilder< this._$parents.push(behavior as GeneralBehavior) // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment this._$ = this._$.behavior(behavior._$) + if (behavior._$chainingFilter) { + return behavior._$chainingFilter(this as any) + } return this as any } @@ -284,6 +288,7 @@ export class BehaviorBuilder< this._$.registerBehavior(), this._$parents, this._$definitionFilter, + this._$chainingFilter, this._$export, ) } diff --git a/glass-easel-miniprogram-adapter/src/builder/component_builder.ts b/glass-easel-miniprogram-adapter/src/builder/component_builder.ts index d07586c..ae65f46 100644 --- a/glass-easel-miniprogram-adapter/src/builder/component_builder.ts +++ b/glass-easel-miniprogram-adapter/src/builder/component_builder.ts @@ -125,6 +125,9 @@ export class ComponentBuilder< // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment this._$export = behavior._$export as any } + if (behavior._$chainingFilter) { + return behavior._$chainingFilter(this as any) + } return this as any } diff --git a/glass-easel-miniprogram-adapter/tests/space.test.ts b/glass-easel-miniprogram-adapter/tests/space.test.ts index 2328b79..bfb74cd 100644 --- a/glass-easel-miniprogram-adapter/tests/space.test.ts +++ b/glass-easel-miniprogram-adapter/tests/space.test.ts @@ -753,7 +753,7 @@ describe('define', () => { .chainingFilter((chain) => { const oldData = chain.data.bind(chain) const newData = function () { - oldData(() => ({ + return oldData(() => ({ a: 123, })) }