@@ -21,11 +21,14 @@ export enum NodeStatus {
2121 LOCKED = 'locked' ,
2222}
2323
24+ type NodeConstructorData = [ NodeData , RegExp ?]
25+
2426export abstract class Node {
2527
26- private _data : NodeData
2728 private _attributes : Attribute
28- private _knownDavService = / ( r e m o t e | p u b l i c ) \. p h p \/ ( w e b ) ? d a v / i
29+
30+ protected _data : NodeData
31+ protected _knownDavService = / ( r e m o t e | p u b l i c ) \. p h p \/ ( w e b ) ? d a v / i
2932
3033 private readonlyAttributes = Object . entries ( Object . getOwnPropertyDescriptors ( Node . prototype ) )
3134 . filter ( e => typeof e [ 1 ] . get === 'function' && e [ 0 ] !== '__proto__' )
@@ -58,7 +61,7 @@ export abstract class Node {
5861 } ,
5962 } as ProxyHandler < Attribute >
6063
61- constructor ( data : NodeData , davService ?: RegExp ) {
64+ protected constructor ( ... [ data , davService ] : NodeConstructorData ) {
6265 if ( ! data . mime ) {
6366 data . mime = 'application/octet-stream'
6467 }
@@ -346,13 +349,6 @@ export abstract class Node {
346349 this . _data . status = status
347350 }
348351
349- /**
350- * Get the node data
351- */
352- get data ( ) : NodeData {
353- return structuredClone ( this . _data )
354- }
355-
356352 /**
357353 * Move the node to a new destination
358354 *
@@ -424,7 +420,10 @@ export abstract class Node {
424420 /**
425421 * Returns a clone of the node
426422 */
427- abstract clone ( ) : Node
423+ clone ( ) : this {
424+ // @ts -expect-error -- this class is abstract and cannot be instantiated directly but all its children can
425+ return new this . constructor ( this . data , this . _knownDavService )
426+ }
428427
429428}
430429
0 commit comments