import { SCRIPTS_REGEX } from './scripts.js' ; import transformers from '../transformers/index.js' ; import type { Pipe } from '../types.js' ; const TransformerPipe = async function ( args ) { let { config , doc } = args ; const scripts = doc . scripts . arr ; let scriptsIndex = 0 ; let content = doc . content . replace ( SCRIPTS_REGEX , ( content , _attrs , _scripts_inner_content ) => { const script = scripts [ scriptsIndex ++ ] ; if ( doc . scripts . dom && script === doc . scripts . dom ) { content = '' ; } else if ( script === doc . scripts . ssr ) { return transformers . ssr ( { config , doc } ) ; } else if ( script === doc . scripts . instance ) { return transformers . instance ( { config , doc } ) ; } return content ; } ) ; doc . content = content ; if ( ! doc . scripts . instance ?. content ) { doc . content = `
     ${ doc . content }
     ${ transformers . instance ( { config , doc } ) }
    ` ; } return { config , doc , continue : true } ; } ; export default TransformerPipe ;