{"version":3,"sources":["../src/index.ts","../src/error.ts","../src/parser.ts"],"sourcesContent":["import { ViewParser } from \"./parser\"\nimport { type ViewUnit, type ViewParserConfig } from \"./types\"\nimport { type types as t } from \"@babel/core\"\n\n/**\n * @brief Generate view units from a babel ast\n * @param statement\n * @param config\n * @param options\n * @returns ViewUnit[]\n */\nexport function parseView(\n  statement: t.BlockStatement,\n  config: ViewParserConfig\n): ViewUnit[] {\n  return new ViewParser(config).parse(statement)\n}\n\nexport type * from \"./types\"\n","import { createErrorHandler } from \"@dlightjs/error-handler\"\n\nexport const DLError = createErrorHandler(\n  \"ViewParser\",\n  {\n    1: \"Invalid syntax in DLight's View, only accepts dot chain call expression\",\n    2: \"First argument of $0() must be an expression\",\n    3: \"Invalid syntax in DLight's View, only accepts expression as props\",\n    4: \"Invalid Snippet calling, only accepts static snippet calling like `this.Snippet()`\",\n  },\n  {\n    1: \"DLight only accepts ForOfStatement as for loop, skipping this statement\",\n    2: \"EnvUnit must have at least one child, skipping this statement\",\n    3: \"Only Env/Comp/HTMLUnit can have a statement block as its children, skipping this statement\",\n    4: \"If you want to use a key in a for loop, make the first statement as a label statement like `key: item`, skipping this key for now\",\n    5: \"ForUnit must have at least one child, skipping this statement\",\n  },\n  {\n    1: \"EnvUnit must have at least one prop, skipping this statement and flattening its children\",\n  }\n)\n","import { type types as t, type traverse as tr } from \"@babel/core\"\nimport {\n  type ViewProp,\n  type IfBranch,\n  type ViewUnit,\n  type ViewParserConfig,\n  SwitchBranch,\n} from \"./types\"\nimport { DLError } from \"./error\"\n\nexport class ViewParser {\n  private readonly compWrapper: string = \"comp\"\n  private readonly htmlTagWrapper: string = \"tag\"\n  private readonly environmentTagName: string = \"env\"\n  private readonly expressionTagName: string = \"_\"\n\n  private readonly config: ViewParserConfig\n\n  private readonly t: typeof t\n  private readonly traverse: typeof tr\n  private readonly snippetNames: string[]\n  private readonly htmlTags: string[]\n\n  readonly viewUnits: ViewUnit[] = []\n\n  /**\n   * @brief Constructor\n   * @param statement\n   * @param config\n   * @param options\n   */\n  constructor(config: ViewParserConfig) {\n    this.config = config\n    this.t = config.babelApi.types\n    this.traverse = config.babelApi.traverse\n    this.snippetNames = config.snippetNames\n    this.htmlTags = config.htmlTags\n  }\n\n  parse(statement: t.BlockStatement) {\n    const statements = [...statement.directives, ...statement.body]\n    statements.forEach(this.parseStatement.bind(this))\n    // ---- If the view is an empty env, throw an error\n    if (\n      this.viewUnits.length === 1 &&\n      this.viewUnits[0].type === \"env\" &&\n      this.viewUnits[0].children.length === 0\n    ) {\n      DLError.error2()\n      return []\n    }\n\n    return this.viewUnits\n  }\n\n  /**\n   * @brief Parse the statements\n   * @returns\n   */\n  private parseStatement(statement: t.Statement | t.Directive): void {\n    if (this.isInvalidExpression(statement)) return\n    if (this.t.isExpressionStatement(statement)) {\n      this.parseExpression(statement.expression)\n      return\n    }\n    if (this.t.isTryStatement(statement)) {\n      this.parseTry(statement)\n      return\n    }\n    if (this.t.isForOfStatement(statement)) {\n      this.parseFor(statement)\n      return\n    }\n    if (this.t.isIfStatement(statement)) {\n      this.parseIf(statement)\n      return\n    }\n    if (this.t.isSwitchStatement(statement)) {\n      this.parseSwitch(statement)\n      return\n    }\n    if (this.t.isDirective(statement)) {\n      this.parseText(statement.value)\n      return\n    }\n    if (this.t.isBlockStatement(statement)) {\n      // ---- If the statement is a block statement, treat it as last unit's children\n      const lastViewUnit = this.viewUnits[this.viewUnits.length - 1]\n      const type = lastViewUnit?.type\n      const childViewUnits = this.parseView(statement)\n      if (type === \"html\") {\n        delete lastViewUnit.props.textContent\n        lastViewUnit.children.push(...childViewUnits)\n      } else if (type === \"comp\" || type === \"snippet\") {\n        lastViewUnit.children.push(...childViewUnits)\n      } else if (type === \"env\") {\n        if (childViewUnits.length > 0) {\n          lastViewUnit.children.push(...childViewUnits)\n        } else {\n          this.viewUnits.pop()\n          DLError.error2()\n        }\n      } else {\n        DLError.error3()\n      }\n    }\n  }\n\n  /**\n   * @brief Parse the expression node\n   *  CallExpression -> Tag\n   *  StringLiteral/TemplateLiteral -> Text\n   *  TaggedTemplateExpression -> Tag + Text / Exp\n   * @param expression\n   */\n  private parseExpression(expression: t.Expression): void {\n    if (this.t.isCallExpression(expression)) {\n      this.parseTag(expression)\n      return\n    }\n    if (\n      this.t.isStringLiteral(expression) ||\n      this.t.isTemplateLiteral(expression)\n    ) {\n      this.parseText(expression)\n      return\n    }\n    if (this.t.isTaggedTemplateExpression(expression)) {\n      this.parseTaggedTemplate(expression)\n      return\n    }\n\n    // ---- Default ExpressionTag\n    //      e.g. this.count -> _(this.count)\n    this.viewUnits.push({\n      type: \"exp\",\n      content: this.parseProp(expression),\n      props: {},\n    })\n  }\n\n  /**\n   * @brief Parse if statement conditions\n   * @param node\n   * @returns IfBranch[]\n   */\n  private parseIfBranches(node: t.IfStatement): IfBranch[] {\n    const conditions: IfBranch[] = []\n    const condition = node.test\n    const ifBody = this.t.isBlockStatement(node.consequent)\n      ? node.consequent\n      : this.t.blockStatement([node.consequent])\n    conditions.push({\n      condition,\n      children: this.parseView(ifBody),\n    })\n\n    // ---- If the alternate is an if statement, parse it recursively\n    if (this.t.isIfStatement(node.alternate)) {\n      conditions.push(...this.parseIfBranches(node.alternate))\n    } else if (node.alternate) {\n      const altBody = this.t.isBlockStatement(node.alternate)\n        ? node.alternate\n        : this.t.blockStatement([node.alternate])\n      conditions.push({\n        condition: this.t.booleanLiteral(true),\n        children: this.parseView(altBody),\n      })\n    }\n\n    return conditions\n  }\n\n  /**\n   * @brief Parse if statement with else if and else\n   * @param node\n   */\n  private parseIf(node: t.IfStatement): void {\n    this.viewUnits.push({\n      type: \"if\",\n      branches: this.parseIfBranches(node),\n    })\n  }\n\n  /**\n   * @brief Parse switch statement\n   * @param node\n   */\n  private parseSwitch(node: t.SwitchStatement) {\n    const branches: SwitchBranch[] = []\n    const switchBody = node.cases\n    switchBody.forEach(s => {\n      const caseBodyPre = s.consequent\n      const caseBody =\n        caseBodyPre.length === 1 && this.t.isBlockStatement(caseBodyPre[0])\n          ? caseBodyPre[0]\n          : this.t.blockStatement(caseBodyPre)\n      const isBreak = this.t.isBreakStatement(\n        caseBody.body[caseBody.body.length - 1]\n      )\n      if (isBreak) {\n        caseBody.body.pop()\n      }\n\n      const children = this.parseView(caseBody)\n      const branch: SwitchBranch = {\n        case: s.test ?? this.t.booleanLiteral(true),\n        children,\n        break: isBreak,\n      }\n      branches.push(branch)\n    })\n    this.viewUnits.push({\n      type: \"switch\",\n      discriminant: node.discriminant,\n      branches,\n    })\n  }\n\n  /**\n   * @brief Parse try statement\n   * @param node\n   */\n  private parseTry(node: t.TryStatement) {\n    const tryBody = this.t.blockStatement(node.block.body)\n    const catchBodyNode = node.handler?.body ?? this.t.blockStatement([])\n\n    this.viewUnits.push({\n      type: \"try\",\n      children: this.parseView(tryBody),\n      exception: node.handler?.param ?? null,\n      catchChildren: this.parseView(catchBodyNode),\n    })\n  }\n\n  /**\n   * @brief Parse for of loop\n   * Only accept for of loop with variable declaration\n   *  e.g. for (const item of array) {}\n   * Key:\n   *  1. If the first statement is an array expression and is not a null or undefined,\n   *     treat the first element as the key.\n   *     e.g. for (const { idx, item } of array) { [idx]; div(item) }\n   *          key will be \"idx\"\n   *  2. If the first statement is an array expression and is null or undefined, treat it as a non-keyed loop.\n   *      e.g. for (const { item } of array) { [null]; div(item) }\n   *          no specific key\n   *  3. If the first statement is not an array expression, treat the item itself as the key.\n   *      e.g. for (const item of array) { div(item) }\n   *          key will be \"item\"\n   * @param node\n   */\n  private parseFor(node: t.ForOfStatement): void {\n    const left = node.left\n    if (!this.t.isVariableDeclaration(left)) {\n      DLError.throw1()\n    }\n    const item = (left as t.VariableDeclaration).declarations[0].id\n    const array = node.right\n    let key: t.Expression = this.t.nullLiteral()\n    const forBody = node.body\n    let forBodyStatements: Array<t.Statement | t.Directive>\n    if (this.t.isExpressionStatement(forBody)) {\n      // ---- If the for body is an expression statement, treat it as the only statement\n      forBodyStatements = [forBody]\n    } else if (this.t.isBlockStatement(forBody)) {\n      const childNodes = forBody.body\n      if (childNodes.length === 0) return DLError.error5()\n      const firstStatement = childNodes[0]\n      if (\n        this.t.isLabeledStatement(firstStatement) &&\n        this.t.isIdentifier(firstStatement.label)\n      ) {\n        if (\n          firstStatement.label.name !== \"key\" ||\n          !this.t.isExpressionStatement(firstStatement.body)\n        ) {\n          DLError.error4()\n        } else {\n          // ---- Treat the first array element labeled by key as the key\n          const keyNode = firstStatement.body.expression\n          // ---- If the key is undefined or null, treat it as no key\n          if (\n            this.t.isExpression(keyNode) &&\n            !(\n              this.t.isNullLiteral(keyNode) ||\n              (this.t.isIdentifier(keyNode) && keyNode.name === \"undefined\")\n            )\n          ) {\n            key = keyNode\n          }\n        }\n        forBodyStatements = childNodes.slice(1)\n      } else {\n        forBodyStatements = childNodes\n      }\n    } else return\n\n    const directives = forBodyStatements.filter(s =>\n      this.t.isDirective(s)\n    ) as t.Directive[]\n    const statements = forBodyStatements.filter(\n      s => !this.t.isDirective(s)\n    ) as t.Statement[]\n    const forBodyBlockStatement = this.t.blockStatement(statements, directives)\n    // ---- Parse the for body statements\n    this.viewUnits.push({\n      type: \"for\",\n      item,\n      array,\n      key,\n      children: this.parseView(forBodyBlockStatement),\n    })\n  }\n\n  /**\n   * @brief Parse text node\n   *  1. `text text`\n   *  2. \"text2 text2\"\n   * @param node\n   */\n  private parseText(\n    node: t.StringLiteral | t.TemplateLiteral | t.DirectiveLiteral\n  ): void {\n    if (this.t.isDirectiveLiteral(node)) node = this.t.stringLiteral(node.value)\n\n    this.viewUnits.push({\n      type: \"text\",\n      content: node,\n    })\n  }\n\n  /**\n   * @brief Parse tagged template expression\n   * Two tagged template expression cases\n   *  1. type without call expressions\n   *      e.g. i18n`any text`\n   *        => exp: _(i18n`any text`)\n   *  2. type with string literal / template literal\n   *      e.g. \"any text\" `any other text`/ `any text` `any other text`\n   *       => text: \"any text\" + text: `any other text`\n   * @param node\n   * @param path\n   */\n  private parseTaggedTemplate(node: t.TaggedTemplateExpression): void {\n    if (\n      this.t.isStringLiteral(node.tag) ||\n      this.t.isTemplateLiteral(node.tag)\n    ) {\n      // ---- Case 2\n      this.viewUnits.push({\n        type: \"text\",\n        content: node.tag,\n      })\n      this.viewUnits.push({\n        type: \"text\",\n        content: node.quasi,\n      })\n      return\n    }\n    // ---- Case 1\n    this.viewUnits.push({\n      type: \"exp\",\n      content: this.parseProp(node),\n      props: {},\n    })\n  }\n\n  /**\n   * @brief Return a block statement if the node is a prop view\n   * @param node\n   * @returns\n   */\n  private isPropView(node: t.Node): null | t.BlockStatement {\n    if (\n      !(\n        this.t.isArrowFunctionExpression(node) &&\n        (this.t.isIdentifier(node.params[0], { name: \"View\" }) ||\n          this.t.isIdentifier(node.params[0], { name: \"_View\" }))\n      )\n    )\n      return null\n\n    const body = node.body\n    if (this.t.isBlockStatement(body)) return body\n    return this.t.blockStatement([this.t.expressionStatement(body)])\n  }\n\n  /**\n   * @brief Parse props in the type node\n   * @param propNode\n   * @returns ViewProp\n   */\n  private parseProp(propNode: t.Node | undefined): ViewProp {\n    if (propNode && !this.t.isExpression(propNode)) DLError.throw3()\n    propNode = propNode as t.Expression\n    // ---- If there is no propNode, set the default prop as true\n    if (!propNode) {\n      return {\n        value: this.t.booleanLiteral(true),\n        viewPropMap: {},\n      }\n    }\n\n    // ---- Collect View => {} nodes as DLProp\n    const dlViewPropResult: Record<string, ViewUnit[]> = {}\n    this.traverse(this.valueWrapper(propNode), {\n      ArrowFunctionExpression: innerPath => {\n        const node = this.isPropView(innerPath.node)\n        if (!node) return\n        const id = this.uid()\n        // ---- Parse the body of View => {} as a new View\n        dlViewPropResult[id] = this.parseView(node)\n        // ---- Replace the View => {} with a id string literal\n        const newNode = this.t.stringLiteral(id)\n        if (innerPath.node === propNode) {\n          propNode = newNode\n        }\n        innerPath.replaceWith(newNode)\n        innerPath.skip()\n      },\n    })\n\n    return {\n      value: propNode,\n      viewPropMap: dlViewPropResult,\n    }\n  }\n\n  /**\n   * @brief Parse the type node\n   * @param node\n   */\n  private parseTag(node: t.CallExpression): void {\n    const props: Record<string, ViewProp> = {}\n\n    // ---- Keep iterating until the node has no call expression\n    let n = node\n    while (\n      this.t.isMemberExpression(n?.callee) &&\n      n?.callee?.object &&\n      !this.isPureMemberExpression(n.callee)\n    ) {\n      const property = n.callee.property\n      if (\n        !this.t.isIdentifier(property) ||\n        !this.t.isCallExpression(n.callee.object)\n      ) {\n        DLError.throw1()\n        continue\n      }\n\n      const key = property.name\n      const prop = this.parseProp(n.arguments[0])\n      props[key] = prop\n      n = n.callee.object\n    }\n\n    let contentProp: ViewProp | undefined\n    if (n.arguments.length > 0) {\n      // ---- The last argument is the content prop of the type,\n      //      so only parse prop when it exists instead of\n      //      treating empty prop as \"true\" like other props\n      contentProp = this.parseProp(n.arguments[0])\n    }\n\n    if (this.t.isIdentifier(n.callee)) {\n      // ---- Special cases for expression type\n      const tagName = n.callee.name\n      if (tagName === this.expressionTagName && contentProp) {\n        // ---- Must have content prop or else just ignore it\n        this.viewUnits.push({\n          type: \"exp\",\n          content: contentProp,\n          props,\n        })\n        return\n      }\n      if (tagName === this.environmentTagName) {\n        if (Object.keys(props).length === 0) {\n          DLError.warn1()\n          return\n        }\n        this.viewUnits.push({\n          type: \"env\",\n          props,\n          children: [],\n        })\n        return\n      }\n      if (this.htmlTags.includes(tagName)) {\n        let children: ViewUnit[] = []\n        if (contentProp) {\n          let isViewProp = false\n          if (\n            contentProp.viewPropMap &&\n            Object.keys(contentProp.viewPropMap).length === 1\n          ) {\n            const key = Object.keys(contentProp.viewPropMap)[0]\n            if (this.t.isStringLiteral(contentProp.value, { value: key })) {\n              isViewProp = true\n              const viewUnit = contentProp.viewPropMap[key]\n              children = viewUnit\n            }\n          }\n          if (!isViewProp) props.textContent = contentProp\n        }\n        this.viewUnits.push({\n          type: \"html\",\n          tag: this.t.stringLiteral(tagName),\n          props,\n          children,\n        })\n        return\n      }\n      // ---- Custom tag\n      if (contentProp) props._$content = contentProp\n      this.viewUnits.push({\n        type: \"comp\",\n        tag: n.callee,\n        props,\n        children: [],\n      })\n      return\n    }\n    if (\n      this.t.isMemberExpression(n.callee) &&\n      this.t.isThisExpression(n.callee.object) &&\n      this.t.isIdentifier(n.callee.property) &&\n      this.snippetNames.includes(n.callee.property.name)\n    ) {\n      // ---- Snippet\n      if (contentProp) props.content = contentProp\n      if (\n        !(\n          this.t.isMemberExpression(n.callee) &&\n          this.t.isThisExpression(n.callee.object) &&\n          this.t.isIdentifier(n.callee.property)\n        )\n      )\n        return DLError.throw4()\n      this.viewUnits.push({\n        type: \"snippet\",\n        tag: n.callee.property.name,\n        props,\n        children: [],\n      })\n      return\n    }\n    if (this.t.isExpression(n.callee)) {\n      // ---- 1. Custom tag\n      //      2. htmlTag(xxx)\n      //      3. tag(xxx)\n      const [tagType, tag] = this.alterTagType(n.callee)\n      if (contentProp) {\n        props[tagType === \"html\" ? \"textContent\" : \"_$content\"] = contentProp\n      }\n      this.viewUnits.push({\n        type: tagType,\n        tag,\n        props,\n        children: [],\n      })\n    }\n  }\n\n  /* ---- Helper Functions ---- */\n  /**\n   * @brief Test if the node is a pure member expression without call expression\n   * @param node\n   */\n  private isPureMemberExpression(node: t.Expression): boolean {\n    let isPure = true\n    this.traverse(this.valueWrapper(node), {\n      CallExpression: () => {\n        isPure = false\n      },\n    })\n    return isPure\n  }\n\n  /**\n   * @brief Alter the tag type by checking the tag name\n   * @param viewUnit\n   * @returns [\"html\" | \"comp\", t.Expression]\n   */\n  private alterTagType(tag: t.Expression): [\"html\" | \"comp\", t.Expression] {\n    if (this.t.isCallExpression(tag) && this.t.isIdentifier(tag.callee)) {\n      const tagName = tag.callee.name\n      const tagType =\n        tagName === this.htmlTagWrapper\n          ? \"html\"\n          : tagName === this.compWrapper\n            ? \"comp\"\n            : undefined\n      if (tagType) {\n        const tagTarget = tag.arguments[0]\n        if (!this.t.isExpression(tagTarget)) DLError.throw2(tagName)\n        return [tagType, tagTarget as t.Expression]\n      }\n    }\n    return [\"comp\", tag]\n  }\n\n  /**\n   * @brief Test if the expression is invalid\n   *  1. For: only accept ForOfStatement\n   * @param node\n   * @returns is this expression invalid\n   */\n  private isInvalidExpression(node: t.Statement | t.Directive): boolean {\n    const isInvalidForStatement =\n      this.t.isForStatement(node) && !this.t.isForOfStatement(node)\n    if (isInvalidForStatement) {\n      DLError.error1()\n      return true\n    }\n    return false\n  }\n\n  /**\n   * @brief Wrap the value in a file\n   * @param node\n   * @returns wrapped value\n   */\n  private valueWrapper(node: t.Expression): t.File {\n    return this.t.file(this.t.program([this.t.expressionStatement(node)]))\n  }\n\n  /**\n   * @brief Parse the view by duplicating current parser's classRootPath, statements and htmlTags\n   * @param statements\n   * @returns ViewUnit[]\n   */\n  private parseView(statement: t.BlockStatement): ViewUnit[] {\n    return new ViewParser(this.config).parse(statement)\n  }\n\n  /**\n   * @brief Generate a unique id\n   * @returns a unique id\n   */\n  private uid(): string {\n    return Math.random().toString(36).slice(2)\n  }\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,eAAAE,IAAA,eAAAC,EAAAH,GCAA,IAAAI,EAAmC,mCAEtBC,KAAU,sBACrB,aACA,CACE,EAAG,0EACH,EAAG,+CACH,EAAG,oEACH,EAAG,oFACL,EACA,CACE,EAAG,0EACH,EAAG,gEACH,EAAG,6FACH,EAAG,oIACH,EAAG,+DACL,EACA,CACE,EAAG,0FACL,CACF,ECVO,IAAMC,EAAN,KAAiB,CACL,YAAsB,OACtB,eAAyB,MACzB,mBAA6B,MAC7B,kBAA4B,IAE5B,OAEA,EACA,SACA,aACA,SAER,UAAwB,CAAC,EAQlC,YAAYC,EAA0B,CACpC,KAAK,OAASA,EACd,KAAK,EAAIA,EAAO,SAAS,MACzB,KAAK,SAAWA,EAAO,SAAS,SAChC,KAAK,aAAeA,EAAO,aAC3B,KAAK,SAAWA,EAAO,QACzB,CAEA,MAAMC,EAA6B,CAIjC,MAHmB,CAAC,GAAGA,EAAU,WAAY,GAAGA,EAAU,IAAI,EACnD,QAAQ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GAAG/C,EAAQ,OAAO0C,CAAO,EACpD,CAACE,EAASG,CAAyB,GAG9C,MAAO,CAAC,OAAQF,CAAG,CACrB,CAQQ,oBAAoBxC,EAA0C,CAGpE,OADE,KAAK,EAAE,eAAeA,CAAI,GAAK,CAAC,KAAK,EAAE,iBAAiBA,CAAI,GAE5DL,EAAQ,OAAO,EACR,IAEF,EACT,CAOQ,aAAaK,EAA4B,CAC/C,OAAO,KAAK,EAAE,KAAK,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,oBAAoBA,CAAI,CAAC,CAAC,CAAC,CACvE,CAOQ,UAAUN,EAAyC,CACzD,OAAO,IAAIF,EAAW,KAAK,MAAM,EAAE,MAAME,CAAS,CACpD,CAMQ,KAAc,CACpB,OAAO,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,CAAC,CAC3C,CACF,EF1nBO,SAASiD,EACdC,EACAC,EACY,CACZ,OAAO,IAAIC,EAAWD,CAAM,EAAE,MAAMD,CAAS,CAC/C","names":["src_exports","__export","parseView","__toCommonJS","import_error_handler","DLError","ViewParser","config","statement","DLError","lastViewUnit","type","childViewUnits","expression","node","conditions","condition","ifBody","altBody","branches","caseBodyPre","caseBody","isBreak","children","branch","tryBody","catchBodyNode","left","item","array","key","forBody","forBodyStatements","childNodes","firstStatement","keyNode","directives","s","statements","forBodyBlockStatement","body","propNode","dlViewPropResult","innerPath","id","newNode","props","n","property","prop","contentProp","tagName","isViewProp","tagType","tag","isPure","tagTarget","parseView","statement","config","ViewParser"]}