@@ -102,7 +102,7 @@ export type XmlC14NIsVisibleCallback = (node: XmlNodePtr, parent: XmlNodePtr) =>
102102/**
103103 * Options for XML canonicalization
104104 */
105- export interface C14NOptionsBase {
105+ export interface C14NOptions {
106106 /** The canonicalization mode to use
107107 * @default XmlC14NMode.XML_C14N_1_0
108108 */
@@ -117,25 +117,22 @@ export interface C14NOptionsBase {
117117 * Only applies when mode is XML_C14N_EXCLUSIVE_1_0
118118 */
119119 inclusiveNamespacePrefixes ?: string [ ] ;
120- }
121120
122- export interface C14NOptionsWithCallback extends C14NOptionsBase {
123121 /** Custom callback to determine node visibility
124- * Cannot be used together with nodeSet
122+ * Must not be used together with { @link nodeSet}
125123 */
126- isVisible : XmlC14NIsVisibleCallback ;
127- nodeSet ?: never ;
128- }
124+ isVisible ?: XmlC14NIsVisibleCallback ;
129125
130- export interface C14NOptionsWithNodeSet extends C14NOptionsBase {
131126 /** Set of nodes to include in canonicalization
132- * Cannot be used together with isVisible
127+ * Must not be used together with { @link isVisible}
133128 */
134- nodeSet : Set < XmlNode > ;
135- isVisible ?: never ;
129+ nodeSet ?: Set < XmlNode > ;
136130}
137131
138- export type C14NOptions = C14NOptionsWithCallback | C14NOptionsWithNodeSet | C14NOptionsBase ;
132+ /**
133+ * C14N options without filtering callbacks (for subtree canonicalization)
134+ */
135+ export type SubtreeC14NOptions = Omit < C14NOptions , 'isVisible' | 'nodeSet' > ;
139136
140137/**
141138 * Check if a node is within a subtree rooted at a specific node by walking
@@ -172,7 +169,9 @@ function canonicalizeInternal(
172169 cascade : boolean = true ,
173170) : void {
174171 const hasIsVisible = ( opts : C14NOptions ) :
175- opts is C14NOptions & { isVisible : XmlC14NIsVisibleCallback } => typeof ( opts as any ) . isVisible === 'function' ;
172+ opts is C14NOptions & {
173+ isVisible : XmlC14NIsVisibleCallback
174+ } => typeof ( opts as any ) . isVisible === 'function' ;
176175
177176 const hasNodeSet = ( opts : C14NOptions ) :
178177 opts is C14NOptions & { nodeSet : Set < XmlNode > } => ( opts as any ) . nodeSet instanceof Set ;
@@ -195,7 +194,8 @@ function canonicalizeInternal(
195194 const context : C14NCallbackContext = {
196195 jsCallback : hasIsVisible ( options ) ? options . isVisible : null ,
197196 rootPtrs : hasNodeSet ( options )
198- ? new Set ( Array . from ( options . nodeSet ) . map ( ( n ) => n . _nodePtr ) )
197+ ? new Set ( Array . from ( options . nodeSet )
198+ . map ( ( n ) => n . _nodePtr ) )
199199 : null ,
200200 cascade,
201201 invisible : cascade ? new Set < number > ( ) : null ,
@@ -286,7 +286,7 @@ export function canonicalizeSubtree(
286286 handler : XmlOutputBufferHandler ,
287287 doc : XmlDocument ,
288288 subtreeRoot : XmlNode ,
289- options : C14NOptionsBase = { } ,
289+ options : SubtreeC14NOptions = { } ,
290290) : void {
291291 const subtreeRootPtr = subtreeRoot . _nodePtr ;
292292 const isVisible = ( nodePtr : number , parentPtr : number ) => (
0 commit comments