import { walk } from 'svelte/compiler' ; import type { Ast , TemplateNode } from 'svelte/types/compiler/interfaces.d' ; import type { PluginOptions } from '../types' ; import Processor from './processor' ; param processor const parser = ( processor ) : void => { const ast = ( processor . ast as unknown ) as TemplateNode ; walk ( ast , { enter ( baseNode ) { const node = baseNode as TemplateNode ; if ( node . type === 'Script' || node . type === 'Fragment' ) { this . skip ( ) ; } if ( node . type === 'ClassSelector' ) { const generatedClassName = processor . createModuleClassname ( node . name ) ; processor . addModule ( node . name , generatedClassName ) ; processor . magicContent . overwrite ( node . start , node . end , `.${ generatedClassName }` ) ; } } } ) ; } ; const scopedProcessor = async ( ast , content , filename , options ) : Promise < string > => { const processor = new Processor ( ast , content , filename , options , parser ) ; const processedContent = processor . parse ( ) ; return processedContent ; } ; export default scopedProcessor ;