@@ -31,12 +31,13 @@ export type SlotMapTypes = {
3131 setup : Map < string , SetupConfig >
3232 customDecorator : Map < string , CustomDecoratorRecord [ ] >
3333}
34+ type SlotMapNames = keyof SlotMapTypes
3435class Slot {
3536 master : any
3637 constructor ( master : any ) {
3738 this . master = master
3839 }
39- names : Map < string , SlotMapTypes [ keyof SlotMapTypes ] > = new Map ( )
40+ names : Map < keyof SlotMapTypes , SlotMapTypes [ keyof SlotMapTypes ] > = new Map ( )
4041 obtainMap < T extends keyof SlotMapTypes > ( name : T ) : SlotMapTypes [ T ] {
4142 let map = this . getMap ( name )
4243 if ( ! map ) {
@@ -112,26 +113,25 @@ export function getSuperSlot(obj: any) {
112113}
113114
114115/**
115- * Exclude decorated names by a filter
116+ * Filter decorated names
116117 */
117- export function excludeNames ( names : string [ ] , slot : Slot , filter ?: ( mapName : string ) => boolean ) {
118+ export function filterNames ( names : string [ ] , slot : Slot , mapNames ?: SlotMapNames [ ] ) {
118119 return names . filter ( name => {
119120 let currSlot : Slot | null = slot
120121 while ( currSlot != null ) {
121122 for ( const mapName of currSlot . names . keys ( ) ) {
122- if ( filter && ! filter ( mapName ) ) {
123- continue
124- }
125123 if ( mapName === 'customDecorator' ) {
126124 const map = currSlot . obtainMap ( 'customDecorator' )
127125 if ( map . has ( name ) ) {
128126 if ( map . get ( name ) ! . every ( ite => ! ite . preserve ) ) {
129127 return false
130- } else {
131- continue
132128 }
133129 }
134130 }
131+ if ( mapNames && mapNames . includes ( mapName ) ) {
132+ continue
133+ }
134+
135135 const map = currSlot . names . get ( mapName ) !
136136 if ( map . has ( name ) ) {
137137 return false
@@ -145,13 +145,22 @@ export function excludeNames(names: string[], slot: Slot, filter?: (mapName: str
145145}
146146
147147/**
148- * Get own properties by a filter
148+ * Get own propertie name by a filter
149149 */
150- export function getValidNames ( obj : any , filter : ( des : PropertyDescriptor , name : string ) => boolean ) {
150+ export function getValidOwnPropertyNames ( obj : any , filter : ( des : PropertyDescriptor , name : string ) => boolean ) {
151151 const descriptors = Object . getOwnPropertyDescriptors ( obj )
152152 return Object . keys ( descriptors ) . filter ( name => filter ( descriptors [ name ] , name ) )
153153}
154154
155+
156+ /**
157+ * Transform provide into function.
158+ */
159+ export function getProviderFunction ( provide : any ) : ( ) => { } {
160+ if ( typeof provide === 'function' ) return provide
161+ return function ( ) { return provide || { } }
162+ }
163+
155164export function optionNullableMemberDecorator < T > ( handler : { ( proto : any , name : string , option ?: T ) : any } ) {
156165 function decorator ( ) : any
157166 function decorator ( option : T ) : any //option
@@ -197,7 +206,3 @@ export function optionNullableClassDecorator<T>(handler: { (cons: VueCons, optio
197206 return decorator
198207}
199208
200- export function getProviderFunction ( provide : any ) : ( ) => { } {
201- if ( typeof provide === 'function' ) return provide
202- return function ( ) { return provide || { } }
203- }
0 commit comments