11import { decodeHTML } from 'entities'
22import type { XMLBuilder } from 'fast-xml-parser'
3- import { Expression } from 'path-expression-matcher'
43import type {
54 AnyOf ,
65 DateLike ,
@@ -912,22 +911,32 @@ export const parseJsonObject = (value: unknown): unknown => {
912911 } catch { }
913912}
914913
914+ // TODO: Remove expandStopNodes and namespaceContainers after fast-xml-parser
915+ // resolves stop node performance regression. Revert feed configs from
916+ // ...expandStopNodes(namespaceStopNodes, [...]) back to ...namespaceStopNodes.
917+ // https://github.com/NaturalIntelligence/fast-xml-parser/issues/816
918+
919+ // Namespace elements that act as containers for other namespace elements.
920+ const namespaceContainers = [
921+ 'media:group' ,
922+ 'media:content' ,
923+ 'media:group.media:content' ,
924+ 'media:embed' ,
925+ 'podcast:liveitem' ,
926+ 'itunes:owner' ,
927+ ]
928+
915929// Expands wildcard stop nodes (*.prefix:element) into explicit paths for
916930// each feed container, including paths through namespace containers (e.g.
917931// media:group, podcast:liveitem). Only crosses containers with leaves from
918- // the same namespace prefix. Pre-constructs Expression objects once at
919- // module load to avoid re-parsing on every XMLParser.parse() call.
920- // When fxp resolves its performance regression, this can be replaced with
921- // raw wildcard strings passed directly to XMLParser.
922- export const createStopNodeExpressions = (
923- wildcardStopNodes : Array < string > ,
924- explicitStopNodes : Array < string > ,
932+ // the same namespace prefix.
933+ export const expandStopNodes = (
934+ stopNodes : Array < string > ,
925935 feedContainerPaths : Array < string > ,
926- namespaceContainers : Array < string > ,
927- ) : Array < Expression > => {
936+ ) : Array < string > => {
928937 const set = new Set < string > ( )
929938
930- for ( const node of wildcardStopNodes ) {
939+ for ( const node of stopNodes ) {
931940 const suffix = node . slice ( 2 )
932941 const prefix = suffix . split ( ':' ) [ 0 ]
933942
@@ -942,9 +951,5 @@ export const createStopNodeExpressions = (
942951 }
943952 }
944953
945- for ( const node of explicitStopNodes ) {
946- set . add ( node )
947- }
948-
949- return [ ...set ] . map ( ( node ) => new Expression ( node ) )
954+ return [ ...set ]
950955}
0 commit comments