{"version":3,"sources":["../src/index.ts","../src/error.ts","../src/parser.ts"],"sourcesContent":["import { type ViewUnit } from \"@dlightjs/view-parser\"\nimport { ReactivityParser } from \"./parser\"\nimport { type ViewParticle, type ReactivityParserConfig } from \"./types\"\n\n/**\n * @brief Parse view units to get used properties and view particles with reactivity\n * @param viewUnits\n * @param config\n * @param options\n * @returns [viewParticles, usedProperties]\n */\nexport function parseReactivity(\n  viewUnits: ViewUnit[],\n  config: ReactivityParserConfig\n): [ViewParticle[], Set<string>] {\n  // ---- ReactivityParser only accepts one view unit at a time,\n  //      so we loop through the view units and get all the used properties\n  const usedProperties = new Set<string>()\n  const dlParticles = viewUnits.map(viewUnit => {\n    const parser = new ReactivityParser(config)\n    const dlParticle = parser.parse(viewUnit)\n    parser.usedProperties.forEach(usedProperties.add.bind(usedProperties))\n    return dlParticle\n  })\n  return [dlParticles, usedProperties]\n}\n\nexport type * from \"./types\"\n","import { createErrorHandler } from \"@dlightjs/error-handler\"\n\nexport const DLError = createErrorHandler(\"ReactivityParser\", {\n  1: \"Invalid ViewUnit type\",\n})\n","import {\n  type TemplateProp,\n  type ReactivityParserConfig,\n  type MutableParticle,\n  type ViewParticle,\n  type TemplateParticle,\n  type TextParticle,\n  type HTMLParticle,\n  type DependencyProp,\n  type ExpParticle,\n  type CompParticle,\n  type ForParticle,\n  type IfParticle,\n  type EnvParticle,\n  type SnippetParticle,\n  SwitchParticle,\n  TryParticle,\n} from \"./types\"\nimport { type NodePath, type types as t, type traverse } from \"@babel/core\"\nimport {\n  type TextUnit,\n  type HTMLUnit,\n  type ViewUnit,\n  type CompUnit,\n  type ViewProp,\n  type ForUnit,\n  type IfUnit,\n  type EnvUnit,\n  type ExpUnit,\n  type SnippetUnit,\n  SwitchUnit,\n  TryUnit,\n} from \"@dlightjs/view-parser\"\nimport { DLError } from \"./error\"\n\nexport class ReactivityParser {\n  private readonly config: ReactivityParserConfig\n\n  private readonly t: typeof t\n  private readonly traverse: typeof traverse\n  private readonly availableProperties: string[]\n  private readonly availableIdentifiers?: string[]\n  private readonly dependencyMap: Record<string, string[]>\n  private readonly identifierDepMap: Record<string, string[]>\n  private readonly dependencyParseType\n  private readonly reactivityFuncNames\n\n  private readonly escapeNamings = [\"escape\", \"$\"]\n  private static readonly customHTMLProps = [\n    \"didUpdate\",\n    \"willMount\",\n    \"didMount\",\n    \"willUnmount\",\n    \"didUnmount\",\n    \"element\",\n    \"innerHTML\",\n    \"props\",\n    \"attrs\",\n    \"dataset\",\n    \"forwardProps\",\n  ]\n\n  readonly usedProperties = new Set<string>()\n\n  /**\n   * @brief Constructor\n   * @param viewUnit\n   * @param config\n   * @param options\n   */\n  constructor(config: ReactivityParserConfig) {\n    this.config = config\n    this.t = config.babelApi.types\n    this.traverse = config.babelApi.traverse\n    this.availableProperties = config.availableProperties\n    this.availableIdentifiers = config.availableIdentifiers\n    this.dependencyMap = config.dependencyMap\n    this.identifierDepMap = config.identifierDepMap ?? {}\n    this.dependencyParseType = config.dependencyParseType ?? \"property\"\n    this.reactivityFuncNames = config.reactivityFuncNames ?? []\n  }\n\n  /**\n   * @brief Parse the ViewUnit into a ViewParticle\n   * @returns\n   */\n  parse(viewUnit: ViewUnit): ViewParticle {\n    return this.parseViewUnit(viewUnit)\n  }\n\n  /**\n   * @brief Parse a ViewUnit into a ViewParticle\n   * @param viewUnit\n   * @returns ViewParticle\n   */\n  private parseViewUnit(viewUnit: ViewUnit): ViewParticle {\n    if (this.isHTMLTemplate(viewUnit))\n      return this.parseTemplate(viewUnit as HTMLUnit)\n    if (viewUnit.type === \"text\") return this.parseText(viewUnit)\n    if (viewUnit.type === \"html\") return this.parseHTML(viewUnit)\n    if (viewUnit.type === \"comp\") return this.parseComp(viewUnit)\n    if (viewUnit.type === \"for\") return this.parseFor(viewUnit)\n    if (viewUnit.type === \"try\") return this.parseTry(viewUnit)\n    if (viewUnit.type === \"if\") return this.parseIf(viewUnit)\n    if (viewUnit.type === \"env\") return this.parseEnv(viewUnit)\n    if (viewUnit.type === \"exp\") return this.parseExp(viewUnit)\n    if (viewUnit.type === \"switch\") return this.parseSwitch(viewUnit)\n    if (viewUnit.type === \"snippet\") return this.parseSnippet(viewUnit)\n    return DLError.throw1()\n  }\n\n  // ---- Parsers ----\n  // ---- @Template ----\n  /**\n   * @brief Collect static HTMLUnit into a template particle and generate a template string\n   *  MutableParticle means whatever unit that is not a static HTMLUnit or a TextUnit\n   *  Props means all the non-static props of the nested HTMLUnit or TextUnit, e.g. div().className(this.name)\n   * @param htmlUnit\n   * @returns TemplateParticle\n   */\n  private parseTemplate(htmlUnit: HTMLUnit): TemplateParticle {\n    return {\n      type: \"template\",\n      template: this.generateTemplate(htmlUnit),\n      props: this.parseTemplateProps(htmlUnit),\n      mutableParticles: this.generateMutableParticles(htmlUnit),\n    }\n  }\n\n  /**\n   * @brief Generate a template\n   *  There'll be a situation where the tag is dynamic, e.g. tag(this.htmlTag),\n   *  which we can't generate a template string for it, so we'll wrap it in an ExpParticle in parseHTML() section\n   * @param htmlUnit\n   * @returns template string\n   */\n  private generateTemplate(unit: HTMLUnit): HTMLParticle {\n    const staticProps = this.filterTemplateProps(\n      // ---- Get all the static props\n      Object.entries(unit.props).filter(\n        ([, prop]) =>\n          this.isStaticProp(prop) &&\n          // ---- Filter out props with false values\n          !(this.t.isBooleanLiteral(prop.value) && !prop.value.value)\n      )\n    ).map(([key, prop]) => [\n      key,\n      {\n        ...prop,\n        dependencyIndexArr: [],\n        dependenciesNode: this.t.arrayExpression([]),\n        dynamic: false,\n      },\n    ])\n\n    let children: ViewParticle[] = []\n    if (!unit.props.textContent) {\n      children = unit.children\n        .map(unit => {\n          if (unit.type === \"html\" && this.t.isStringLiteral(unit.tag)) {\n            return this.generateTemplate(unit)\n          }\n          if (unit.type === \"text\" && this.t.isStringLiteral(unit.content)) {\n            return this.parseText(unit)\n          }\n        })\n        .filter(Boolean) as HTMLParticle[]\n    }\n    return {\n      type: \"html\",\n      tag: unit.tag,\n      props: Object.fromEntries(staticProps),\n      children,\n    }\n  }\n\n  /**\n   * @brief Collect all the mutable nodes in a static HTMLUnit\n   *  We use this function to collect mutable nodes' path and props,\n   *  so that in the generator, we know which position to insert the mutable nodes\n   * @param htmlUnit\n   * @returns mutable particles\n   */\n  private generateMutableParticles(htmlUnit: HTMLUnit): MutableParticle[] {\n    const mutableParticles: MutableParticle[] = []\n    const generateMutableUnit = (unit: HTMLUnit, path: number[] = []) => {\n      // ---- Generate mutable particles for current HTMLUnit\n      unit.children?.forEach((child, idx) => {\n        if (\n          !(child.type === \"html\" && this.t.isStringLiteral(child.tag)) &&\n          !(child.type === \"text\" && this.t.isStringLiteral(child.content))\n        ) {\n          mutableParticles.push({\n            path: [...path, idx],\n            ...this.parseViewParticle(child),\n          })\n        }\n      })\n      // ---- Recursively generate mutable particles for static HTMLUnit children\n      unit.children\n        ?.filter(\n          child => child.type === \"html\" && this.t.isStringLiteral(child.tag)\n        )\n        .forEach((child, idx) => {\n          generateMutableUnit(child as HTMLUnit, [...path, idx])\n        })\n    }\n    generateMutableUnit(htmlUnit)\n\n    return mutableParticles\n  }\n\n  /**\n   * @brief Collect all the props in a static HTMLUnit or its nested HTMLUnit or TextUnit children\n   *  Just like the mutable nodes, props are also equipped with path,\n   *  so that we know which HTML ChildNode to insert the props\n   * @param htmlUnit\n   * @returns props\n   */\n  private parseTemplateProps(htmlUnit: HTMLUnit): TemplateProp[] {\n    const templateProps: TemplateProp[] = []\n    const generateVariableProp = (unit: HTMLUnit, path: number[]) => {\n      // ---- Generate all non-static(string/number/boolean) props for current HTMLUnit\n      //      to be inserted further in the generator\n      Object.entries(unit.props)\n        .filter(([, prop]) => !this.isStaticProp(prop))\n        .forEach(([key, prop]) => {\n          templateProps.push({\n            tag: (unit.tag as t.StringLiteral).value,\n            key,\n            path,\n            value: prop.value,\n            ...this.getDependencies(prop.value),\n          })\n        })\n      // ---- Recursively generate props for static HTMLUnit children\n      unit.children\n        .filter(\n          child =>\n            (child.type === \"html\" && this.t.isStringLiteral(child.tag)) ||\n            (child.type === \"text\" && this.t.isStringLiteral(child.content))\n        )\n        .forEach((child, idx) => {\n          if (child.type === \"html\") {\n            generateVariableProp(child, [...path, idx])\n          } else if (child.type === \"text\") {\n            // ---- if the child is a TextUnit, we just insert the text content\n            templateProps.push({\n              tag: \"text\",\n              key: \"value\",\n              path: [...path, idx],\n              value: child.content,\n              dependencyIndexArr: [],\n              dependenciesNode: this.t.arrayExpression([]),\n              dynamic: false,\n            })\n          }\n        })\n    }\n    generateVariableProp(htmlUnit, [])\n\n    return templateProps\n  }\n\n  // ---- @Text ----\n  /**\n   * @brief Parse a TextUnit into a TextParticle.\n   *  This is only for a top level TextUnit, because if nested in HTMLUnit, it'll be parsed in the template string\n   * @param textUnit\n   * @returns TextParticle\n   */\n  private parseText(textUnit: TextUnit): TextParticle {\n    return {\n      type: \"text\",\n      content: {\n        value: textUnit.content,\n        ...this.getDependencies(textUnit.content),\n      },\n    }\n  }\n\n  // ---- @HTML ----\n  /**\n   * @brief Parse an HTMLUnit with a dynamic tag into an ExpParticle or an HTMLParticle\n   *  We detect dependencies in the tag, if there's no dependency,\n   *  we parse it as an HTMLParticle and dynamically append it to the parent node;\n   *  if there's dependency, we parse it as an ExpParticle and wrap it in an ExpParticle\n   *  so that we can make the tag reactive\n   * @param htmlUnit\n   * @returns ExpParticle | HTMLParticle\n   */\n  private parseHTML(htmlUnit: HTMLUnit): ExpParticle | HTMLParticle {\n    const { dependencyIndexArr, dependenciesNode, dynamic } =\n      this.getDependencies(htmlUnit.tag)\n\n    const innerHTMLParticle: HTMLParticle = {\n      type: \"html\",\n      tag: htmlUnit.tag,\n      props: {},\n      children: [],\n    }\n\n    innerHTMLParticle.props = Object.fromEntries(\n      Object.entries(htmlUnit.props).map(([key, prop]) => [\n        key,\n        this.generateDependencyProp(prop),\n      ])\n    )\n\n    innerHTMLParticle.children = htmlUnit.children.map(\n      this.parseViewParticle.bind(this)\n    )\n\n    // ---- Not a dynamic tag\n    if (!dynamic) return innerHTMLParticle\n\n    // ---- Dynamic tag, wrap it in an ExpParticle to make the tag reactive\n    const id = this.uid()\n    return {\n      type: \"exp\",\n      content: {\n        value: this.t.stringLiteral(id),\n        viewPropMap: {\n          [id]: [innerHTMLParticle],\n        },\n        dependencyIndexArr,\n        dependenciesNode,\n        dynamic,\n      },\n      props: {},\n    }\n  }\n\n  // ---- @Comp ----\n  /**\n   * @brief Parse a CompUnit into a CompParticle or an ExpParticle\n   *  Similar to parseHTML(), we detect dependencies in the tag, if there's no dependency,\n   *  we parse it as a regular CompParticle, otherwise we wrap it with an ExpParticle.\n   * @param compUnit\n   * @returns CompParticle | ExpParticle\n   */\n  private parseComp(compUnit: CompUnit): CompParticle | ExpParticle {\n    const { dependencyIndexArr, dependenciesNode, dynamic } =\n      this.getDependencies(compUnit.tag)\n\n    const compParticle: CompParticle = {\n      type: \"comp\",\n      tag: compUnit.tag,\n      props: {},\n      children: [],\n    }\n\n    compParticle.props = Object.fromEntries(\n      Object.entries(compUnit.props).map(([key, prop]) => [\n        key,\n        this.generateDependencyProp(prop),\n      ])\n    )\n    compParticle.children = compUnit.children.map(\n      this.parseViewParticle.bind(this)\n    )\n\n    if (!dynamic) return compParticle\n\n    const id = this.uid()\n    return {\n      type: \"exp\",\n      content: {\n        value: this.t.stringLiteral(id),\n        viewPropMap: {\n          [id]: [compParticle],\n        },\n        dependencyIndexArr,\n        dependenciesNode,\n        dynamic,\n      },\n      props: {},\n    }\n  }\n\n  // ---- @For ----\n  /**\n   * @brief Parse a ForUnit into a ForParticle with dependencies\n   *  Key and item doesn't need to be reactive, so here we don't collect dependencies for it\n   * @param forUnit\n   * @returns ForParticle\n   */\n  private parseFor(forUnit: ForUnit): ForParticle {\n    const { dependencyIndexArr, dependenciesNode, dynamic } =\n      this.getDependencies(forUnit.array)\n    const prevIdentifierDepMap = this.config.identifierDepMap\n    // ---- Find all the identifiers in the key and remove them from the identifierDepMap\n    //      because once the key is changed, that identifier related dependencies will be changed too,\n    //      so no need to update them\n    const keyDep = this.t.isIdentifier(forUnit.key) && forUnit.key.name\n    // ---- Generate an identifierDepMap to track identifiers in item and make them reactive\n    //      based on the dependencies from the array\n    this.config.identifierDepMap = Object.fromEntries(\n      this.getIdentifiers(\n        this.t.assignmentExpression(\n          \"=\",\n          forUnit.item,\n          this.t.objectExpression([])\n        )\n      )\n        .filter(id => !keyDep || id !== keyDep)\n        .map(id => [\n          id,\n          dependencyIndexArr.map(n => this.availableProperties[n]),\n        ])\n    )\n\n    const forParticle: ForParticle = {\n      type: \"for\",\n      item: forUnit.item,\n      array: {\n        value: forUnit.array,\n        dynamic,\n        dependencyIndexArr,\n        dependenciesNode,\n      },\n      children: forUnit.children.map(this.parseViewParticle.bind(this)),\n      key: forUnit.key,\n    }\n    this.config.identifierDepMap = prevIdentifierDepMap\n    return forParticle\n  }\n\n  // ---- @If ----\n  /**\n   * @brief Parse an IfUnit into an IfParticle with dependencies\n   * @param ifUnit\n   * @returns IfParticle\n   */\n  private parseIf(ifUnit: IfUnit): IfParticle {\n    return {\n      type: \"if\",\n      branches: ifUnit.branches.map(branch => ({\n        condition: {\n          value: branch.condition,\n          ...this.getDependencies(branch.condition),\n        },\n        children: branch.children.map(this.parseViewParticle.bind(this)),\n      })),\n    }\n  }\n\n  // ---- @Switch ----\n  /**\n   * @brief Parse a SwitchUnit into an SwitchParticle with dependencies\n   * @param switchUnit\n   * @returns SwitchParticle\n   */\n  private parseSwitch(switchUnit: SwitchUnit): SwitchParticle {\n    return {\n      type: \"switch\",\n      discriminant: {\n        value: switchUnit.discriminant,\n        ...this.getDependencies(switchUnit.discriminant),\n      },\n      branches: switchUnit.branches.map(branch => ({\n        case: {\n          value: branch.case,\n          ...this.getDependencies(branch.case),\n        },\n        children: branch.children.map(this.parseViewParticle.bind(this)),\n        break: branch.break,\n      })),\n    }\n  }\n\n  // ---- @Try ----\n  /**\n   * @brief Parse a TryUnit into an TryParticle with dependencies\n   * @param tryUnit\n   * @returns TryParticle\n   */\n  private parseTry(tryUnit: TryUnit): TryParticle {\n    return {\n      type: \"try\",\n      children: tryUnit.children.map(this.parseViewParticle.bind(this)),\n      exception: tryUnit.exception,\n      catchChildren: tryUnit.catchChildren.map(\n        this.parseViewParticle.bind(this)\n      ),\n    }\n  }\n\n  // ---- @Env ----\n  /**\n   * @brief Parse an EnvUnit into an EnvParticle with dependencies\n   * @param envUnit\n   * @returns EnvParticle\n   */\n  private parseEnv(envUnit: EnvUnit): EnvParticle {\n    return {\n      type: \"env\",\n      props: Object.fromEntries(\n        Object.entries(envUnit.props).map(([key, prop]) => [\n          key,\n          this.generateDependencyProp(prop),\n        ])\n      ),\n      children: envUnit.children.map(this.parseViewParticle.bind(this)),\n    }\n  }\n\n  // ---- @Exp ----\n  /**\n   * @brief Parse an ExpUnit into an ExpParticle with dependencies\n   * @param expUnit\n   * @returns ExpParticle\n   */\n  private parseExp(expUnit: ExpUnit): ExpParticle {\n    const expParticle: ExpParticle = {\n      type: \"exp\",\n      content: this.generateDependencyProp(expUnit.content),\n      props: Object.fromEntries(\n        Object.entries(expUnit.props).map(([key, prop]) => [\n          key,\n          this.generateDependencyProp(prop),\n        ])\n      ),\n    }\n    return expParticle\n  }\n\n  // ---- @Snippet ----\n  /**\n   * @brief Parse a SnippetUnit into a SnippetParticle with dependencies\n   * @param snippetUnit\n   * @returns SnippetParticle\n   */\n  private parseSnippet(snippetUnit: SnippetUnit): SnippetParticle {\n    const snippetParticle: SnippetParticle = {\n      type: \"snippet\",\n      tag: snippetUnit.tag,\n      props: {},\n      children: [],\n    }\n    if (snippetUnit.props) {\n      snippetParticle.props = Object.fromEntries(\n        Object.entries(snippetUnit.props).map(([key, prop]) => [\n          key,\n          this.generateDependencyProp(prop),\n        ])\n      )\n    }\n    if (snippetUnit.children) {\n      snippetParticle.children = snippetUnit.children.map(\n        this.parseViewParticle.bind(this)\n      )\n    }\n\n    return snippetParticle\n  }\n\n  // ---- Dependencies ----\n  /**\n   * @brief Generate a dependency prop with dependencies\n   * @param prop\n   * @returns DependencyProp\n   */\n  private generateDependencyProp(prop: ViewProp): DependencyProp {\n    const dependencyProp: DependencyProp = {\n      value: prop.value,\n      ...this.getDependencies(prop.value),\n      viewPropMap: Object.fromEntries(\n        Object.entries(prop.viewPropMap).map(([key, units]) => [\n          key,\n          units.map(this.parseViewParticle.bind(this)),\n        ])\n      ),\n    }\n    return dependencyProp\n  }\n\n  /**\n   * @brief Get all the dependencies of a node\n   *  this.dependencyParseType controls how we parse the dependencies\n   * 1. property: parse the dependencies of a node as a property, e.g. this.name\n   * 2. identifier: parse the dependencies of a node as an identifier, e.g. name\n   * The availableProperties is the list of all the properties that can be used in the template,\n   * no matter it's a property or an identifier\n   * @param node\n   * @returns dependency index array\n   */\n  private getDependencies(node: t.Expression | t.Statement): {\n    dynamic: boolean\n    dependencyIndexArr: number[]\n    dependenciesNode: t.ArrayExpression\n  } {\n    if (\n      this.t.isFunctionExpression(node) ||\n      this.t.isArrowFunctionExpression(node)\n    ) {\n      return {\n        dynamic: false,\n        dependencyIndexArr: [],\n        dependenciesNode: this.t.arrayExpression([]),\n      }\n    }\n    // ---- Both id and prop deps need to be calculated because\n    //      id is for snippet update, prop is normal update\n    //      in a snippet, the depsNode should be both id and prop\n    const [directIdentifierDeps, identifierDepNodes] =\n      this.getIdentifierDependencies(node)\n    const [directPropertyDeps, propertyDepNodes] =\n      this.getPropertyDependencies(node)\n    const directDependencies =\n      this.dependencyParseType === \"identifier\"\n        ? directIdentifierDeps\n        : directPropertyDeps\n    const identifierMapDependencies = this.getIdentifierMapDependencies(node)\n    const deps = [\n      ...new Set([...directDependencies, ...identifierMapDependencies]),\n    ]\n\n    const depNodes = [\n      ...identifierDepNodes,\n      ...propertyDepNodes,\n    ] as t.Expression[]\n\n    return {\n      dynamic: depNodes.length > 0 || deps.length > 0,\n      dependencyIndexArr: deps,\n      dependenciesNode: this.t.arrayExpression(depNodes),\n    }\n  }\n\n  /**\n   * @brief Get all the dependencies of a node if a property is a valid dependency as\n   *  1. the identifier is in the availableProperties\n   *  2. the identifier is a stand alone identifier\n   *  3. the identifier is not in an escape function\n   *  4. the identifier is not in a manual function\n   *  5. the identifier is not the left side of an assignment expression, which is an assignment expression\n   *  6. the identifier is not the right side of an assignment expression, which is an update expression\n   * @param node\n   * @returns dependency index array\n   */\n  private getIdentifierDependencies(\n    node: t.Expression | t.Statement\n  ): [number[], t.Node[]] {\n    const availableIdentifiers =\n      this.availableIdentifiers ?? this.availableProperties\n\n    const deps = new Set<string>()\n    const assignDeps = new Set<string>()\n    const depNodes: Record<string, t.Node[]> = {}\n\n    const wrappedNode = this.valueWrapper(node)\n    this.traverse(wrappedNode, {\n      Identifier: innerPath => {\n        const identifier = innerPath.node\n        const idName = identifier.name\n        if (!availableIdentifiers.includes(idName)) return\n        if (\n          this.isAssignmentExpressionLeft(innerPath) ||\n          this.isAssignmentFunction(innerPath)\n        ) {\n          assignDeps.add(idName)\n        } else if (\n          this.isStandAloneIdentifier(innerPath) &&\n          !this.isMemberInEscapeFunction(innerPath) &&\n          !this.isMemberInManualFunction(innerPath)\n        ) {\n          deps.add(idName)\n          this.dependencyMap[idName]?.forEach(deps.add.bind(deps))\n          if (!depNodes[idName]) depNodes[idName] = []\n          depNodes[idName].push(this.geneDependencyNode(innerPath))\n        }\n      },\n    })\n\n    assignDeps.forEach(dep => {\n      deps.delete(dep)\n      delete depNodes[dep]\n    })\n    let dependencyNodes = Object.values(depNodes).flat()\n    // ---- deduplicate the dependency nodes\n    dependencyNodes = dependencyNodes.filter((n, i) => {\n      const idx = dependencyNodes.findIndex(m => this.t.isNodesEquivalent(m, n))\n      return idx === i\n    })\n\n    deps.forEach(this.usedProperties.add.bind(this.usedProperties))\n    return [\n      [...deps].map(dep => this.availableProperties.indexOf(dep)),\n      dependencyNodes,\n    ]\n  }\n\n  /**\n   * @brief Get all the dependencies of a node if a member expression is a valid dependency as\n   *  1. the property is in the availableProperties\n   *  2. the object is this\n   *  3. the member expression is not in an escape function\n   *  4. the member expression is not in a manual function\n   *  5. the member expression is not the left side of an assignment expression, which is an assignment expression\n   *  6. the member is not a pure function declaration\n   * @param node\n   * @returns dependency index array\n   */\n  private getPropertyDependencies(\n    node: t.Expression | t.Statement\n  ): [number[], t.Node[]] {\n    const deps = new Set<string>()\n    const assignDeps = new Set<string>()\n    const depNodes: Record<string, t.Node[]> = {}\n\n    const wrappedNode = this.valueWrapper(node)\n    this.traverse(wrappedNode, {\n      MemberExpression: innerPath => {\n        if (\n          !this.t.isIdentifier(innerPath.node.property) ||\n          !this.t.isThisExpression(innerPath.node.object)\n        )\n          return\n        const propertyKey = innerPath.node.property.name\n        if (\n          this.isAssignmentExpressionLeft(innerPath) ||\n          this.isAssignmentFunction(innerPath)\n        ) {\n          assignDeps.add(propertyKey)\n        } else if (\n          this.availableProperties.includes(propertyKey) &&\n          !this.isMemberInEscapeFunction(innerPath) &&\n          !this.isMemberInManualFunction(innerPath)\n        ) {\n          deps.add(propertyKey)\n          this.dependencyMap[propertyKey]?.forEach(deps.add.bind(deps))\n          if (!depNodes[propertyKey]) depNodes[propertyKey] = []\n          depNodes[propertyKey].push(this.geneDependencyNode(innerPath))\n        }\n      },\n    })\n\n    assignDeps.forEach(dep => {\n      deps.delete(dep)\n      delete depNodes[dep]\n    })\n    let dependencyNodes = Object.values(depNodes).flat()\n    // ---- deduplicate the dependency nodes\n    dependencyNodes = dependencyNodes.filter((n, i) => {\n      const idx = dependencyNodes.findIndex(m => this.t.isNodesEquivalent(m, n))\n      return idx === i\n    })\n\n    deps.forEach(this.usedProperties.add.bind(this.usedProperties))\n    return [\n      [...deps].map(dep => this.availableProperties.indexOf(dep)),\n      dependencyNodes,\n    ]\n  }\n\n  /**\n   * @brief Generate a dependency node from a dependency identifier,\n   *  loop until the parent node is not a binary expression or a member expression\n   * @param path\n   * @returns\n   */\n  private geneDependencyNode(path: NodePath): t.Node {\n    let parentPath = path\n    while (parentPath?.parentPath) {\n      const pParentPath = parentPath.parentPath\n      if (\n        !(\n          this.t.isMemberExpression(pParentPath.node, { computed: false }) ||\n          this.t.isOptionalMemberExpression(pParentPath.node)\n        )\n      ) {\n        break\n      }\n      parentPath = pParentPath\n    }\n    const depNode = this.t.cloneNode(parentPath.node)\n    // ---- Turn memberExpression to optionalMemberExpression\n    this.traverse(this.valueWrapper(depNode as t.Expression), {\n      MemberExpression: innerPath => {\n        if (this.t.isThisExpression(innerPath.node.object)) return\n        innerPath.node.optional = true\n        innerPath.node.type = \"OptionalMemberExpression\" as any\n      },\n    })\n    return depNode\n  }\n\n  /**\n   * @brief Get dependencies from the identifierDepMap\n   *  e.g.\n   *  map: { \"a\": [\"dep1\", \"dep2\"] }\n   *  expression: const b = a\n   *  deps for b: [\"dep1\", \"dep2\"]\n   * @param node\n   * @returns dependency index array\n   */\n  private getIdentifierMapDependencies(\n    node: t.Expression | t.Statement\n  ): number[] {\n    const deps = new Set<string>()\n\n    const wrappedNode = this.valueWrapper(node)\n    this.traverse(wrappedNode, {\n      Identifier: innerPath => {\n        const identifier = innerPath.node\n        const idName = identifier.name\n        if (this.isAttrFromFunction(innerPath, idName)) return\n        const depsArray = this.identifierDepMap[idName]\n\n        if (!depsArray || !Array.isArray(depsArray)) return\n        if (\n          this.isMemberInEscapeFunction(innerPath) ||\n          this.isMemberInManualFunction(innerPath)\n        )\n          return\n        depsArray.forEach(deps.add.bind(deps))\n      },\n    })\n\n    deps.forEach(this.usedProperties.add.bind(this.usedProperties))\n    return [...deps].map(dep => this.availableProperties.indexOf(dep))\n  }\n\n  // ---- Utils ----\n  /**\n   * @brief Parse a ViewUnit into a ViewParticle by new-ing a ReactivityParser\n   * @param viewUnit\n   * @returns ViewParticle\n   */\n  private parseViewParticle(viewUnit: ViewUnit): ViewParticle {\n    const parser = new ReactivityParser(this.config)\n    const parsedUnit = parser.parse(viewUnit)\n    // ---- Collect used properties\n    parser.usedProperties.forEach(\n      this.usedProperties.add.bind(this.usedProperties)\n    )\n    return parsedUnit\n  }\n\n  /**\n   * @brief Check if a ViewUnit is a static HTMLUnit that can be parsed into a template\n   *  Must satisfy:\n   *  1. type is html\n   *  2. tag is a string literal, i.e., non-dynamic tag\n   *  3. has at least one child that is a static HTMLUnit,\n   *     or else just call a createElement function, no need for template clone\n   * @param viewUnit\n   * @returns is a static HTMLUnit\n   */\n  private isHTMLTemplate(viewUnit: ViewUnit): boolean {\n    return (\n      viewUnit.type === \"html\" &&\n      this.t.isStringLiteral(viewUnit.tag) &&\n      !!viewUnit.children?.some(\n        child => child.type === \"html\" && this.t.isStringLiteral(child.tag)\n      )\n    )\n  }\n\n  /**\n   * @brief Check if a prop is a static prop\n   *  i.e.\n   *  1. no viewPropMap\n   *  2. value is a string/number/boolean literal\n   * @param prop\n   * @returns is a static prop\n   */\n  private isStaticProp(prop: ViewProp): boolean {\n    const { value, viewPropMap } = prop\n    return (\n      (!viewPropMap || Object.keys(viewPropMap).length === 0) &&\n      (this.t.isStringLiteral(value) ||\n        this.t.isNumericLiteral(value) ||\n        this.t.isBooleanLiteral(value))\n    )\n  }\n\n  /**\n   * @brief Filter out some props that are not needed in the template,\n   *  these are all special props to be parsed differently in the generator\n   * @param props\n   * @returns filtered props\n   */\n  private filterTemplateProps<T>(\n    props: Array<[string, T]>\n  ): Array<[string, T]> {\n    return (\n      props\n        // ---- Filter out event listeners\n        .filter(([key]) => !key.startsWith(\"on\"))\n        // ---- Filter out specific props\n        .filter(([key]) => !ReactivityParser.customHTMLProps.includes(key))\n    )\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.Statement): t.File {\n    return this.t.file(\n      this.t.program([\n        this.t.isStatement(node) ? node : this.t.expressionStatement(node),\n      ])\n    )\n  }\n\n  /**\n   * @brief Check if an identifier is a simple stand alone identifier,\n   *  i.e., not a member expression, nor a function param\n   * @param path\n   *  1. not a member expression\n   *  2. not a function param\n   *  3. not in a declaration\n   *  4. not as object property's not computed key\n   * @returns is a stand alone identifier\n   */\n  private isStandAloneIdentifier(path: NodePath<t.Identifier>): boolean {\n    const node = path.node\n    const parentNode = path.parentPath?.node\n    const isMemberExpression =\n      this.t.isMemberExpression(parentNode) && parentNode.property === node\n    if (isMemberExpression) return false\n    const isFunctionParam = this.isAttrFromFunction(path, node.name)\n    if (isFunctionParam) return false\n    while (path.parentPath) {\n      if (this.t.isVariableDeclarator(path.parentPath.node)) return false\n      if (\n        this.t.isObjectProperty(path.parentPath.node) &&\n        path.parentPath.node.key === path.node &&\n        !path.parentPath.node.computed\n      )\n        return false\n      path = path.parentPath as NodePath<t.Identifier>\n    }\n    return true\n  }\n\n  /**\n   * @brief Get all identifiers as strings in a node\n   * @param node\n   * @returns identifiers\n   */\n  private getIdentifiers(node: t.Node): string[] {\n    if (this.t.isIdentifier(node)) return [node.name]\n    const identifierKeys = new Set<string>()\n    this.traverse(this.valueWrapper(node as t.Expression), {\n      Identifier: innerPath => {\n        if (!this.isStandAloneIdentifier(innerPath)) return\n        identifierKeys.add(innerPath.node.name)\n      },\n    })\n    return [...identifierKeys]\n  }\n\n  /**\n   * @brief check if the identifier is from a function param till the stopNode\n   *  e.g:\n   *  function myFunc1(ok) { // stopNode = functionBody\n   *     const myFunc2 = ok => ok // from function param\n   *     console.log(ok) // not from function param\n   *  }\n   */\n  private isAttrFromFunction(path: NodePath, idName: string) {\n    let reversePath = path.parentPath\n\n    const checkParam: (param: t.Node) => boolean = (param: t.Node) => {\n      // ---- 3 general types:\n      //      * represent allow nesting\n      // ---0 Identifier: (a)\n      // ---1 RestElement: (...a)   *\n      // ---1 Pattern: 3 sub Pattern\n      // -----0   AssignmentPattern: (a=1)   *\n      // -----1   ArrayPattern: ([a, b])   *\n      // -----2   ObjectPattern: ({a, b})\n      if (this.t.isIdentifier(param)) return param.name === idName\n      if (this.t.isAssignmentPattern(param)) return checkParam(param.left)\n      if (this.t.isArrayPattern(param)) {\n        return param.elements\n          .filter(Boolean)\n          .map(el => checkParam(el!))\n          .includes(true)\n      }\n      if (this.t.isObjectPattern(param)) {\n        return (\n          param.properties.filter(\n            prop =>\n              this.t.isObjectProperty(prop) && this.t.isIdentifier(prop.key)\n          ) as t.ObjectProperty[]\n        )\n          .map(prop => (prop.key as t.Identifier).name)\n          .includes(idName)\n      }\n      if (this.t.isRestElement(param)) return checkParam(param.argument)\n\n      return false\n    }\n\n    while (reversePath) {\n      const node = reversePath.node\n      if (\n        this.t.isArrowFunctionExpression(node) ||\n        this.t.isFunctionDeclaration(node)\n      ) {\n        for (const param of node.params) {\n          if (checkParam(param)) return true\n        }\n      }\n      reversePath = reversePath.parentPath\n    }\n\n    return false\n  }\n\n  /**\n   * @brief Check if it's the left side of an assignment expression, e.g. this.count = 1\n   * @param innerPath\n   * @returns is left side of an assignment expression\n   */\n  private isAssignmentExpressionLeft(innerPath: NodePath): boolean {\n    let parentPath = innerPath.parentPath\n    while (parentPath && !this.t.isStatement(parentPath.node)) {\n      if (this.t.isAssignmentExpression(parentPath.node)) {\n        if (parentPath.node.left === innerPath.node) return true\n        const leftPath = parentPath.get(\"left\") as NodePath\n        if (innerPath.isDescendant(leftPath)) return true\n      } else if (this.t.isUpdateExpression(parentPath.node)) {\n        return true\n      }\n      parentPath = parentPath.parentPath\n    }\n\n    return false\n  }\n\n  /**\n   * @brief Check if it's a reactivity function, e.g. arr.push\n   * @param innerPath\n   * @returns\n   */\n  private isAssignmentFunction(innerPath: NodePath): boolean {\n    let parentPath = innerPath.parentPath\n\n    while (parentPath && this.t.isMemberExpression(parentPath.node)) {\n      parentPath = parentPath.parentPath\n    }\n    if (!parentPath) return false\n    return (\n      this.t.isCallExpression(parentPath.node) &&\n      this.t.isMemberExpression(parentPath.node.callee) &&\n      this.t.isIdentifier(parentPath.node.callee.property) &&\n      this.reactivityFuncNames.includes(parentPath.node.callee.property.name)\n    )\n  }\n\n  /**\n   * @brief Check if it's in an \"escape\" function,\n   *        e.g. escape(() => { console.log(this.count) })\n   *              deps will be empty instead of [\"count\"]\n   * @param innerPath\n   * @param classDeclarationNode\n   * @returns is in escape function\n   */\n  private isMemberInEscapeFunction(innerPath: NodePath): boolean {\n    let isInFunction = false\n    let reversePath = innerPath.parentPath\n    while (reversePath) {\n      const node = reversePath.node\n      if (\n        this.t.isCallExpression(node) &&\n        this.t.isIdentifier(node.callee) &&\n        this.escapeNamings.includes(node.callee.name)\n      ) {\n        isInFunction = true\n        break\n      }\n      reversePath = reversePath.parentPath\n    }\n    return isInFunction\n  }\n\n  /**\n   * @brief Check if it's in a \"manual\" function,\n   *        e.g. manual(() => { console.log(this.count) }, [\"flag\"])\n   *             deps will be [\"flag\"] instead of [\"count\"]\n   * @param innerPath\n   * @param classDeclarationNode\n   * @returns is in manual function\n   */\n  private isMemberInManualFunction(innerPath: NodePath): boolean {\n    let isInFunction = false\n    let reversePath = innerPath.parentPath\n\n    while (reversePath) {\n      const node = reversePath.node\n      const parentNode = reversePath.parentPath?.node\n      const isManual =\n        this.t.isCallExpression(parentNode) &&\n        this.t.isIdentifier(parentNode.callee) &&\n        parentNode.callee.name === \"manual\"\n      const isFirstParam =\n        this.t.isCallExpression(parentNode) && parentNode.arguments[0] === node\n      if (isManual && isFirstParam) {\n        isInFunction = true\n        break\n      }\n      reversePath = reversePath.parentPath\n    }\n\n    return isInFunction\n  }\n\n  /**\n   * @brief Generate a random string\n   * @returns\n   */\n  private uid(): string {\n    return Math.random().toString(36).slice(2)\n  }\n}\n"],"mappings":"qjBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GCAA,IAAAI,EAAmC,mCAEtBC,KAAU,sBAAmB,mBAAoB,CAC5D,EAAG,uBACL,CAAC,EC+BM,IAAMC,EAAN,KAAuB,CACX,OAEA,EACA,SACA,oBACA,qBACA,cACA,iBACA,oBACA,oBAEA,cAAgB,CAAC,SAAU,GAAG,EAetC,eAAiB,IAAI,IAQ9B,YAAYC,EAAgC,CAC1C,KAAK,OAASA,EACd,KAAK,EAAIA,EAAO,SAAS,MACzB,KAAK,SAAWA,EAAO,SAAS,SAChC,KAAK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","_ReactivityParser","config","viewUnit","DLError","htmlUnit","unit","staticProps","prop","key","children","mutableParticles","generateMutableUnit","path","child","idx","templateProps","generateVariableProp","textUnit","dependencyIndexArr","dependenciesNode","dynamic","innerHTMLParticle","id","compUnit","compParticle","forUnit","prevIdentifierDepMap","keyDep","n","forParticle","ifUnit","branch","switchUnit","tryUnit","envUnit","expUnit","snippetUnit","snippetParticle","units","node","directIdentifierDeps","identifierDepNodes","directPropertyDeps","propertyDepNodes","directDependencies","identifierMapDependencies","deps","depNodes","availableIdentifiers","assignDeps","wrappedNode","innerPath","idName","dep","dependencyNodes","i","m","propertyKey","parentPath","pParentPath","depNode","depsArray","parser","parsedUnit","value","viewPropMap","props","parentNode","identifierKeys","reversePath","checkParam","param","el","leftPath","isInFunction","isManual","isFirstParam","ReactivityParser","__publicField","parseReactivity","viewUnits","config","usedProperties","viewUnit","parser","ReactivityParser","dlParticle"]}