import { parseComponents as remoteParseComponents, generateBuilderVars as remoteGenerateBuilderVars } from "./remoteParser.js"; export class ModuleParser { /** * Parse components (c-if, c-for, c-else, c-hidden) and module tags * Converts Acai syntax to Twig syntax * Uses the remote appParser to ensure consistency with frontend * @param {string} html - The HTML content to parse * @param {string[]} moduleIds - Optional list of module IDs to recognize as tags * @param {string} prefixVar - Optional prefix for variables (used internally) * @param {boolean} skipBuilderData - Optional flag to skip extractBuilderData (to avoid recursion) * @returns {Promise} - The parsed HTML with Twig syntax */ static async parseComponents(html, moduleIds = [], listTables = [], prefixVar = "", skipBuilderData = false) { if (!html) return html; // Use the remote appParser (same as frontend) return await remoteParseComponents(html, moduleIds, listTables, prefixVar, skipBuilderData); } /** * Generate builder variables from code * Uses the remote appParser to ensure consistency with frontend * @param {string} code - The HTML code to analyze * @param {object} previousSchema - Optional previous schema for field name mapping * @returns {Promise<{codeParsed: string, codeVars: object}>} - Parsed code and variables */ static async generateBuilderVars(code, previousSchema = null) { // Use the remote appParser (same as frontend) return await remoteGenerateBuilderVars(code, previousSchema); } }