@@ -15,7 +15,7 @@ export const NODE_TYPES: { [name: string]: PackageDescription } = {
15
15
export type NodeDefinition = {
16
16
package ?: string ,
17
17
name ?: string ,
18
- properties : { [ name : string | symbol ] : PropertyDefinition } ,
18
+ features : { [ name : string | symbol ] : PropertyDefinition } ,
19
19
resolved ?: boolean ;
20
20
} ;
21
21
@@ -35,29 +35,29 @@ export function getNodeDefinition(node: Node | (new (...args: any[]) => Node)):
35
35
if ( Object . prototype . hasOwnProperty . call ( target , NODE_DEFINITION_SYMBOL ) ) {
36
36
definition = target [ NODE_DEFINITION_SYMBOL ] as NodeDefinition ;
37
37
} else {
38
- const inheritedProperties = { ...( target [ NODE_DEFINITION_SYMBOL ] ?. properties || { } ) } ;
39
- for ( const p in inheritedProperties ) {
40
- inheritedProperties [ p ] = { inherited : true , ...inheritedProperties [ p ] } ;
38
+ const inheritedFeatures = { ...( target [ NODE_DEFINITION_SYMBOL ] ?. features || { } ) } ;
39
+ for ( const p in inheritedFeatures ) {
40
+ inheritedFeatures [ p ] = { inherited : true , ...inheritedFeatures [ p ] } ;
41
41
}
42
42
target [ NODE_DEFINITION_SYMBOL ] = definition = {
43
- properties : inheritedProperties ,
43
+ features : inheritedFeatures ,
44
44
resolved : false
45
45
} ;
46
46
}
47
- if ( definition && definition . properties && ! definition . resolved ) {
47
+ if ( definition && definition . features && ! definition . resolved ) {
48
48
try {
49
49
let metadataHolder ;
50
50
try {
51
51
metadataHolder = new ( node as any ) ( ) ;
52
52
} catch ( _ ) {
53
53
metadataHolder = node ;
54
54
}
55
- for ( const p in definition . properties ) {
56
- if ( ! definition . properties [ p ] . type ) {
55
+ for ( const p in definition . features ) {
56
+ if ( ! definition . features [ p ] . type ) {
57
57
const type = Reflect . getMetadata ( "design:type" , metadataHolder , p ) ;
58
- definition . properties [ p ] . type = type ;
58
+ definition . features [ p ] . type = type ;
59
59
if ( type === Array ) {
60
- definition . properties [ p ] . arrayType =
60
+ definition . features [ p ] . arrayType =
61
61
Reflect . getMetadata ( "design:arrayElementType" , metadataHolder , p ) ;
62
62
}
63
63
}
@@ -152,16 +152,16 @@ export abstract class Node extends Origin implements Destination {
152
152
}
153
153
154
154
getChildNames ( ) : string [ ] {
155
- const props = this . nodeDefinition ?. properties || { } ;
155
+ const props = this . nodeDefinition ?. features || { } ;
156
156
return Object . getOwnPropertyNames ( props ) . filter ( p => props [ p ] . child ) ;
157
157
}
158
158
159
159
get nodeDefinition ( ) : NodeDefinition {
160
160
return getNodeDefinition ( this ) ;
161
161
}
162
162
163
- get properties ( ) : PropertyDescription [ ] {
164
- const props = this . nodeDefinition ?. properties || { } ;
163
+ get features ( ) : FeatureDescription [ ] {
164
+ const props = this . nodeDefinition ?. features || { } ;
165
165
return Object . getOwnPropertyNames ( props ) . map ( p => {
166
166
const value = props [ p ] . child ?
167
167
( props [ p ] . multiple ? this . getChildren ( p ) : this . getChild ( p ) ) :
@@ -171,7 +171,7 @@ export abstract class Node extends Origin implements Destination {
171
171
}
172
172
173
173
containment ( name : string | symbol ) : PropertyDefinition | undefined {
174
- const props = this . nodeDefinition ?. properties || { } ;
174
+ const props = this . nodeDefinition ?. features || { } ;
175
175
return props [ name ] ?. child ? props [ name ] : undefined ;
176
176
}
177
177
@@ -241,7 +241,7 @@ export abstract class Node extends Origin implements Destination {
241
241
}
242
242
243
243
getAllChildren ( ) {
244
- const props = this . nodeDefinition ?. properties || { } ;
244
+ const props = this . nodeDefinition ?. features || { } ;
245
245
const result : Node [ ] = [ ] ;
246
246
for ( const p in props ) {
247
247
const prop = props [ p ] ;
@@ -273,7 +273,7 @@ export abstract class Node extends Origin implements Destination {
273
273
}
274
274
275
275
getAttributeValue ( name : string | symbol ) : any {
276
- const props = this . nodeDefinition ?. properties || { } ;
276
+ const props = this . nodeDefinition ?. features || { } ;
277
277
const prop = props [ name ] ;
278
278
if ( prop ) {
279
279
if ( prop . child ) {
@@ -291,7 +291,7 @@ export abstract class Node extends Origin implements Destination {
291
291
}
292
292
293
293
setAttributeValue ( name : string | symbol , value : any ) {
294
- const props = this . nodeDefinition ?. properties || { } ;
294
+ const props = this . nodeDefinition ?. features || { } ;
295
295
const prop = props [ name ] ;
296
296
if ( prop ) {
297
297
if ( prop . child ) {
@@ -339,7 +339,7 @@ export abstract class Node extends Origin implements Destination {
339
339
}
340
340
}
341
341
342
- export interface PropertyDescription {
342
+ export interface FeatureDescription {
343
343
name : string ;
344
344
value : any ;
345
345
}
@@ -414,11 +414,11 @@ export function registerNodeDefinition<T extends Node>(
414
414
def = {
415
415
package : pkg ,
416
416
name : name ,
417
- properties : { }
417
+ features : { }
418
418
} ;
419
419
if ( existingDef ) {
420
- for ( const prop in existingDef . properties ) {
421
- def . properties [ prop ] = { inherited : true , ...existingDef . properties [ prop ] } ;
420
+ for ( const prop in existingDef . features ) {
421
+ def . features [ prop ] = { inherited : true , ...existingDef . features [ prop ] } ;
422
422
}
423
423
}
424
424
}
@@ -450,12 +450,12 @@ export function registerNodeAttribute<T extends Node>(
450
450
methodName = Symbol ( methodName ) ;
451
451
}
452
452
const definition = ensureNodeDefinition ( type ) ;
453
- if ( ! definition . properties [ methodName ] ) {
454
- definition . properties [ methodName ] = {
453
+ if ( ! definition . features [ methodName ] ) {
454
+ definition . features [ methodName ] = {
455
455
name : methodName
456
456
} ;
457
457
}
458
- return definition . properties [ methodName ] ;
458
+ return definition . features [ methodName ] ;
459
459
}
460
460
461
461
export function registerNodeChild < T extends Node > (
0 commit comments