node_modules/svelte2tsx/index.js
/**
 * Walks the HTMLx part of the Svelte component
 * and converts it to JSX
 */
Walks the HTMLx part of the Svelte component
and converts it to JSX
Walks the HTMLx part of the Svelte component and converts it to JSX
function convertHtmlxToJsx(str, ast, onWalk = null, onLeave = null, options = {}) {
    const htmlx = str.original;
    stripDoctype(str);
    str.prepend('<>');
    str.append('</>');
    const templateScopeManager = new TemplateScopeManager();
    let ifScope = new IfScope(templateScopeManager);
    compiler.walk(ast, {
        enter: (node, parent, prop, index) => {
            try {
                switch (node.type) {
                    case 'IfBlock':
                        handleIf(htmlx, str, node, ifScope);
                        if (!node.elseif) {
                            ifScope = ifScope.getChild();
                        }
                        break;
                    case 'EachBlock':
                        templateScopeManager.eachEnter(node);
                        handleEach(htmlx, str, node, ifScope);
                        break;
                    case 'ElseBlock':
                        templateScopeManager.elseEnter(parent);
                        handleElse(htmlx, str, node, parent, ifScope);
                        break;
                    case 'AwaitBlock':
                        handleAwait(htmlx, str, node, ifScope, templateScopeManager);
                        break;
                    case 'PendingBlock':
                        templateScopeManager.awaitPendingEnter(node, parent);
                        handleAwaitPending(parent, htmlx, str, ifScope);
                        break;
                    case 'ThenBlock':
                        templateScopeManager.awaitThenEnter(node, parent);
                        handleAwaitThen(parent, htmlx, str, ifScope);
                        break;
                    case 'CatchBlock':
                        templateScopeManager.awaitCatchEnter(node, parent);
                        handleAwaitCatch(parent, htmlx, str, ifScope);
                        break;
                    case 'KeyBlock':
                        handleKey(htmlx, str, node);
                        break;
                    case 'RawMustacheTag':
                        handleRawHtml(htmlx, str, node);
                        break;
                    case 'DebugTag':
                        handleDebug(htmlx, str, node);
                        break;
                    case 'InlineComponent':
                        templateScopeManager.componentOrSlotTemplateOrElementEnter(node);
                        handleComponent(htmlx, str, node, parent, ifScope, templateScopeManager.value);
                        break;
                    case 'Element':
                        templateScopeManager.componentOrSlotTemplateOrElementEnter(node);
                        handleElement(htmlx, str, node, parent, ifScope, templateScopeManager.value);
                        break;
                    case 'Comment':
                        handleComment(str, node);
                        break;
                    case 'Binding':
                        handleBinding(htmlx, str, node, parent);
                        break;
                    case 'Class':
                        handleClassDirective(str, node);
                        break;
                    case 'Action':
                        handleActionDirective(htmlx, str, node, parent);
                        break;
                    case 'Transition':
                        handleTransitionDirective(htmlx, str, node, parent);
                        break;
                    case 'Animation':
                        handleAnimateDirective(htmlx, str, node, parent);
                        break;
                    case 'Attribute':
                        handleAttribute(htmlx, str, node, parent, options.preserveAttributeCase);
                        break;
                    case 'EventHandler':
                        handleEventHandler(htmlx, str, node, parent);
                        break;
                    case 'Options':
                        handleSvelteTag(htmlx, str, node);
                        break;
                    case 'Window':
                        handleSvelteTag(htmlx, str, node);
                        break;
                    case 'Head':
                        handleSvelteTag(htmlx, str, node);
                        break;
                    case 'Body':
                        handleSvelteTag(htmlx, str, node);
                        break;
                    case 'SlotTemplate':
                        handleSvelteTag(htmlx, str, node);
                        templateScopeManager.componentOrSlotTemplateOrElementEnter(node);
                        if (usesLet(node)) {
                            handleSlot(htmlx, str, node, parent, getSlotName(node) || 'default', ifScope, templateScopeManager.value);
                        }
                        break;
                    case 'Text':
                        handleText(str, node);
                        break;
                }
                if (onWalk) {
                    onWalk(node, parent, prop, index);
                }
            }
            catch (e) {
                console.error('Error walking node ', node);
                throw e;
            }
        },
        leave: (node, parent, prop, index) => {
            try {
                switch (node.type) {
                    case 'IfBlock':
                        if (!node.elseif) {
                            ifScope = ifScope.getParent();
                        }
                        break;
                    case 'EachBlock':
                        templateScopeManager.eachLeave(node);
                        break;
                    case 'AwaitBlock':
                        templateScopeManager.awaitLeave();
                        break;
                    case 'InlineComponent':
                    case 'Element':
                    case 'SlotTemplate':
                        templateScopeManager.componentOrSlotTemplateOrElementLeave(node);
                        break;
                }
                if (onLeave) {
                    onLeave(node, parent, prop, index);
                }
            }
            catch (e) {
                console.error('Error leaving node ', node);
                throw e;
            }
        }
    });
}
function convertHtmlxToJsx ( str , ast , onWalk = null , onLeave = null , options = { } ) { const htmlx = str . original ; stripDoctype ( str ) ; str . prepend ( '<>' ) ; str . append ( '</>' ) ; const templateScopeManager = new TemplateScopeManager ( ) ; let ifScope = new IfScope ( templateScopeManager ) ; compiler . walk ( ast , { enter : ( node , parent , prop , index ) => { try { switch ( node . type ) { case 'IfBlock' : handleIf ( htmlx , str , node , ifScope ) ; if ( ! node . elseif ) { ifScope = ifScope . getChild ( ) ; } break ; case 'EachBlock' : templateScopeManager . eachEnter ( node ) ; handleEach ( htmlx , str , node , ifScope ) ; break ; case 'ElseBlock' : templateScopeManager . elseEnter ( parent ) ; handleElse ( htmlx , str , node , parent , ifScope ) ; break ; case 'AwaitBlock' : handleAwait ( htmlx , str , node , ifScope , templateScopeManager ) ; break ; case 'PendingBlock' : templateScopeManager . awaitPendingEnter ( node , parent ) ; handleAwaitPending ( parent , htmlx , str , ifScope ) ; break ; case 'ThenBlock' : templateScopeManager . awaitThenEnter ( node , parent ) ; handleAwaitThen ( parent , htmlx , str , ifScope ) ; break ; case 'CatchBlock' : templateScopeManager . awaitCatchEnter ( node , parent ) ; handleAwaitCatch ( parent , htmlx , str , ifScope ) ; break ; case 'KeyBlock' : handleKey ( htmlx , str , node ) ; break ; case 'RawMustacheTag' : handleRawHtml ( htmlx , str , node ) ; break ; case 'DebugTag' : handleDebug ( htmlx , str , node ) ; break ; case 'InlineComponent' : templateScopeManager . componentOrSlotTemplateOrElementEnter ( node ) ; handleComponent ( htmlx , str , node , parent , ifScope , templateScopeManager . value ) ; break ; case 'Element' : templateScopeManager . componentOrSlotTemplateOrElementEnter ( node ) ; handleElement ( htmlx , str , node , parent , ifScope , templateScopeManager . value ) ; break ; case 'Comment' : handleComment ( str , node ) ; break ; case 'Binding' : handleBinding ( htmlx , str , node , parent ) ; break ; case 'Class' : handleClassDirective ( str , node ) ; break ; case 'Action' : handleActionDirective ( htmlx , str , node , parent ) ; break ; case 'Transition' : handleTransitionDirective ( htmlx , str , node , parent ) ; break ; case 'Animation' : handleAnimateDirective ( htmlx , str , node , parent ) ; break ; case 'Attribute' : handleAttribute ( htmlx , str , node , parent , options . preserveAttributeCase ) ; break ; case 'EventHandler' : handleEventHandler ( htmlx , str , node , parent ) ; break ; case 'Options' : handleSvelteTag ( htmlx , str , node ) ; break ; case 'Window' : handleSvelteTag ( htmlx , str , node ) ; break ; case 'Head' : handleSvelteTag ( htmlx , str , node ) ; break ; case 'Body' : handleSvelteTag ( htmlx , str , node ) ; break ; case 'SlotTemplate' : handleSvelteTag ( htmlx , str , node ) ; templateScopeManager . componentOrSlotTemplateOrElementEnter ( node ) ; if ( usesLet ( node ) ) { handleSlot ( htmlx , str , node , parent , getSlotName ( node ) || 'default' , ifScope , templateScopeManager . value ) ; } break ; case 'Text' : handleText ( str , node ) ; break ; } if ( onWalk ) { onWalk ( node , parent , prop , index ) ; } } catch ( e ) { console . error ( 'Error walking node ' , node ) ; throw e ; } } , leave : ( node , parent , prop , index ) => { try { switch ( node . type ) { case 'IfBlock' : if ( ! node . elseif ) { ifScope = ifScope . getParent ( ) ; } break ; case 'EachBlock' : templateScopeManager . eachLeave ( node ) ; break ; case 'AwaitBlock' : templateScopeManager . awaitLeave ( ) ; break ; case 'InlineComponent' : case 'Element' : case 'SlotTemplate' : templateScopeManager . componentOrSlotTemplateOrElementLeave ( node ) ; break ; } if ( onLeave ) { onLeave ( node , parent , prop , index ) ; } } catch ( e ) { console . error ( 'Error leaving node ' , node ) ; throw e ; } } } ) ; }
Walks the HTMLx part of the Svelte component
 and converts it to JSX
Walks the HTMLx part of the Svelte component and converts it to JSX