gameStatusUpdate/node_modules/@babel/generator/lib/generators/classes.js.map

1 line
14 KiB
Plaintext
Raw Normal View History

2024-11-04 11:06:36 -08:00
{"version":3,"names":["_t","require","isExportDefaultDeclaration","isExportNamedDeclaration","ClassDeclaration","node","parent","inExport","_shouldPrintDecoratorsBeforeExport","printJoin","decorators","declare","word","space","abstract","id","print","typeParameters","superClass","superTypeParameters","implements","printList","body","ClassBody","token","length","newline","separator","classBodyEmptySemicolonsPrinter","exit","enterDelimited","statement","indent","printTrailingSeparator","endsWith","rightBrace","printer","tokenMap","start","end","indexes","getIndexes","k","occurrenceCount","nextLocIndex","advanceNextLocIndex","i","tok","matchesOriginal","_tokens","undefined","ClassProperty","static","format","preserveFormat","_node$key$loc","endLine","key","loc","line","catchUp","tsPrintClassMemberModifiers","computed","_variance","optional","definite","typeAnnotation","value","semicolon","ClassAccessorProperty","_node$key$loc2","ClassPrivateProperty","ClassMethod","_classMethodHead","ClassPrivateMethod","_node$key$loc3","_methodHead","StaticBlock","printSequence"],"sources":["../../src/generators/classes.ts"],"sourcesContent":["import type Printer from \"../printer.ts\";\nimport {\n isExportDefaultDeclaration,\n isExportNamedDeclaration,\n} from \"@babel/types\";\nimport type * as t from \"@babel/types\";\n\n// We inline this package\n// eslint-disable-next-line import/no-extraneous-dependencies\nimport * as charCodes from \"charcodes\";\n\nexport function ClassDeclaration(\n this: Printer,\n node: t.ClassDeclaration,\n parent: t.Node,\n) {\n const inExport =\n isExportDefaultDeclaration(parent) || isExportNamedDeclaration(parent);\n\n if (\n !inExport ||\n !this._shouldPrintDecoratorsBeforeExport(\n parent as t.ExportDeclaration & { declaration: t.ClassDeclaration },\n )\n ) {\n this.printJoin(node.decorators);\n }\n\n if (node.declare) {\n // TS\n this.word(\"declare\");\n this.space();\n }\n\n if (node.abstract) {\n // TS\n this.word(\"abstract\");\n this.space();\n }\n\n this.word(\"class\");\n\n if (node.id) {\n this.space();\n this.print(node.id);\n }\n\n this.print(node.typeParameters);\n\n if (node.superClass) {\n this.space();\n this.word(\"extends\");\n this.space();\n this.print(node.superClass);\n this.print(node.superTypeParameters);\n }\n\n if (node.implements) {\n this.space();\n this.word(\"implements\");\n this.space();\n this.printList(node.implements);\n }\n\n this.space();\n this.print(node.body);\n}\n\nexport { ClassDeclaration as ClassExpression };\n\nexport function ClassBody(this: Printer, node: t.ClassBody) {\n this.token(\"{\");\n if (node.body.length === 0) {\n this.token(\"}\");\n } else {\n this.newline();\n\n const separator = classBodyEmptySemicolonsPrinter(this, node);\n separator?.(-1); // print leading semicolons in preserveFormat mode\n\n const exit = this.enterDelimited();\n this.printJoin(node.body, {\n statement: true,\n indent: true,\n separator,\n printTrailingSeparator: true,\n });\n exit();\n\n if (!this.endsWith(charCodes.lineFeed)) this.newline();\n\n this.rightBrace(node);\n }\n}\n\nfunction classBodyEmptySemicolonsPrinter(printer: Printer, node: t.ClassBody) {\n if (!printer.tokenMap || node.start == null || node.end == null) {\n return null;\n }\n\n // \"empty statements\" in class bodies are not represented in the AST.\n // Print them by checking if there are any ; tokens between the current AST\n // member and the next one.\n\n const indexes = printer.tokenMap.getIndexes(node);\n if (!indexes) return null;\n\n let k = 1; // start from 1 to skip '{'\n\n let occurrenceCount = 0;\n\n let nextLocIndex = 0;\n const advanceNextLocIndex = () => {\n while (\n nextLocIndex < node.body.length &&\n node.body[nextLocIndex].start == null\n ) {\n nextLocIndex++;\n }\n };\n advanceNextLocIndex();\n\n return (i: number) => {\n if (nextLocIndex <= i) {\n nextLocIndex = i + 1;\n advanceNextLocI