You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
6.8 KiB
1 line
6.8 KiB
{"version":3,"names":["JSXAttribute","node","print","name","value","token","JSXIdentifier","word","JSXNamespacedName","namespace","JSXMemberExpression","object","property","JSXSpreadAttribute","argument","rightBrace","JSXExpressionContainer","expression","JSXSpreadChild","JSXText","raw","getPossibleRaw","undefined","JSXElement","open","openingElement","selfClosing","indent","child","children","dedent","closingElement","spaceSeparator","space","JSXOpeningElement","typeParameters","attributes","length","printJoin","separator","JSXClosingElement","JSXEmptyExpression","printInnerComments","JSXFragment","openingFragment","closingFragment","JSXOpeningFragment","JSXClosingFragment"],"sources":["../../src/generators/jsx.ts"],"sourcesContent":["import type Printer from \"../printer.ts\";\nimport type * as t from \"@babel/types\";\n\nexport function JSXAttribute(this: Printer, node: t.JSXAttribute) {\n this.print(node.name);\n if (node.value) {\n this.token(\"=\");\n this.print(node.value);\n }\n}\n\nexport function JSXIdentifier(this: Printer, node: t.JSXIdentifier) {\n this.word(node.name);\n}\n\nexport function JSXNamespacedName(this: Printer, node: t.JSXNamespacedName) {\n this.print(node.namespace);\n this.token(\":\");\n this.print(node.name);\n}\n\nexport function JSXMemberExpression(\n this: Printer,\n node: t.JSXMemberExpression,\n) {\n this.print(node.object);\n this.token(\".\");\n this.print(node.property);\n}\n\nexport function JSXSpreadAttribute(this: Printer, node: t.JSXSpreadAttribute) {\n this.token(\"{\");\n this.token(\"...\");\n this.print(node.argument);\n this.rightBrace(node);\n}\n\nexport function JSXExpressionContainer(\n this: Printer,\n node: t.JSXExpressionContainer,\n) {\n this.token(\"{\");\n this.print(node.expression);\n this.rightBrace(node);\n}\n\nexport function JSXSpreadChild(this: Printer, node: t.JSXSpreadChild) {\n this.token(\"{\");\n this.token(\"...\");\n this.print(node.expression);\n this.rightBrace(node);\n}\n\nexport function JSXText(this: Printer, node: t.JSXText) {\n const raw = this.getPossibleRaw(node);\n\n if (raw !== undefined) {\n this.token(raw, true);\n } else {\n this.token(node.value, true);\n }\n}\n\nexport function JSXElement(this: Printer, node: t.JSXElement) {\n const open = node.openingElement;\n this.print(open);\n if (open.selfClosing) return;\n\n this.indent();\n for (const child of node.children) {\n this.print(child);\n }\n this.dedent();\n\n this.print(node.closingElement);\n}\n\nfunction spaceSeparator(this: Printer) {\n this.space();\n}\n\nexport function JSXOpeningElement(this: Printer, node: t.JSXOpeningElement) {\n this.token(\"<\");\n this.print(node.name);\n this.print(node.typeParameters); // TS\n if (node.attributes.length > 0) {\n this.space();\n this.printJoin(node.attributes, { separator: spaceSeparator });\n }\n if (node.selfClosing) {\n this.space();\n this.token(\"/>\");\n } else {\n this.token(\">\");\n }\n}\n\nexport function JSXClosingElement(this: Printer, node: t.JSXClosingElement) {\n this.token(\"</\");\n this.print(node.name);\n this.token(\">\");\n}\n\nexport function JSXEmptyExpression(this: Printer) {\n // This node is empty, so forcefully print its inner comments.\n this.printInnerComments();\n}\n\nexport function JSXFragment(this: Printer, node: t.JSXFragment) {\n this.print(node.openingFragment);\n\n this.indent();\n for (const child of node.children) {\n this.print(child);\n }\n this.dedent();\n\n this.print(node.closingFragment);\n}\n\nexport function JSXOpeningFragment(this: Printer) {\n this.token(\"<\");\n this.token(\">\");\n}\n\nexport function JSXClosingFragment(this: Printer) {\n this.token(\"</\");\n this.token(\">\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAGO,SAASA,YAAYA,CAAgBC,IAAoB,EAAE;EAChE,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,IAAI,CAAC;EACrB,IAAIF,IAAI,CAACG,KAAK,EAAE;IACd,IAAI,CAACC,SAAK,GAAI,CAAC;IACf,IAAI,CAACH,KAAK,CAACD,IAAI,CAACG,KAAK,CAAC;EACxB;AACF;AAEO,SAASE,aAAaA,CAAgBL,IAAqB,EAAE;EAClE,IAAI,CAACM,IAAI,CAACN,IAAI,CAACE,IAAI,CAAC;AACtB;AAEO,SAASK,iBAAiBA,CAAgBP,IAAyB,EA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