{"version":3,"names":["SourcePos","identifierName","undefined","line","column","filename","Buffer","constructor","map","_map","_buf","_str","_appendCount","_last","_queue","_queueCursor","_position","_sourcePosition","_disallowedPop","objectReusable","_allocQueue","queue","i","push","char","repeat","_pushQueue","cursor","length","item","_popQueue","Error","get","_flush","result","code","trimRight","decodedMap","getDecoded","resultMap","value","Object","defineProperty","writable","rawMappings","mappings","getRawMappings","append","str","maybeNewline","_append","appendChar","_appendChar","sourcePosition","queueIndentation","queueCursor","sourcePos","String","fromCharCode","_mark","len","charCodeAt","indexOf","last","mark","removeTrailingNewline","removeLastSemicolon","getLastChar","endsWithCharAndNewline","lastCp","hasContent","exactSource","loc","cb","source","_disallowPop","prop","_normalizePosition","withSource","originalLine","originalColumn","originalFilename","originalIdentifierName","disallowedPop","targetObj","pos","getCurrentColumn","lastIndex","getCurrentLine","count"],"sources":["../src/buffer.ts"],"sourcesContent":["import type SourceMap from \"./source-map\";\nimport * as charcodes from \"charcodes\";\n\nexport type Pos = {\n line: number;\n column: number;\n};\nexport type Loc = {\n start?: Pos;\n end?: Pos;\n identifierName?: string;\n filename?: string;\n};\ntype SourcePos = {\n identifierName: string | undefined;\n line: number | undefined;\n column: number | undefined;\n filename: string | undefined;\n};\n\ntype QueueItem = {\n char: number;\n repeat: number;\n line: number | undefined;\n column: number | undefined;\n identifierName: string | undefined;\n filename: string | undefined;\n};\n\nfunction SourcePos(): SourcePos {\n return {\n identifierName: undefined,\n line: undefined,\n column: undefined,\n filename: undefined,\n };\n}\n\nexport default class Buffer {\n constructor(map?: SourceMap | null) {\n this._map = map;\n\n this._allocQueue();\n }\n\n _map: SourceMap = null;\n _buf = \"\";\n _str = \"\";\n _appendCount = 0;\n _last = 0;\n _queue: QueueItem[] = [];\n _queueCursor = 0;\n\n _position = {\n line: 1,\n column: 0,\n };\n _sourcePosition = SourcePos();\n _disallowedPop: SourcePos & { objectReusable: boolean } = {\n identifierName: undefined,\n line: undefined,\n column: undefined,\n filename: undefined,\n objectReusable: true, // To avoid deleting and re-creating objects, we reuse existing objects when they are not needed anymore.\n };\n\n _allocQueue() {\n const queue = this._queue;\n\n for (let i = 0; i < 16; i++) {\n queue.push({\n char: 0,\n repeat: 1,\n line: undefined,\n column: undefined,\n identifierName: undefined,\n filename: \"\",\n });\n }\n }\n\n _pushQueue(\n char: number,\n repeat: number,\n line: number | undefined,\n column: number | undefined,\n identifierName: string | undefined,\n filename: string | undefined,\n ) {\n const cursor = this._queueCursor;\n if (cursor === this._queue.length) {\n this._allocQueue();\n }\n const item = this._queue[cursor];\n item.char = char;\n item.repeat = repeat;\n item.line = line;\n item.column = column;\n item.identifierName = identifierName;\n item.filename = filename;\n\n this._queueCursor++;\n }\n\n _popQueue(): QueueItem {\n if (this._queueCursor === 0) {\n throw new Error(\"Cannot pop from empty queue\");\n }\n return this._queue[--this._queueCursor];\n }\n\n /**\n * Get the final string output from the buffer, along with the sourcemap if one exists.\n */\n\n get() {\n this._flush();\n\n const map = this._map;\n const result = {\n // Whatever trim is used here should not execute a regex against the\n // source string since it may be arbitrarily large after all transformations\n code: (this._buf + this._str).trimRight(),\n // Decoded sourcemap is free to generate.\n decodedMap: map?.getDecoded(),\n\n // Encoding the sourcemap is moderately CPU expensive.\n get map() {\n const resultMap = map ? map.get() : null;\n result.map = resultMap;\n return resultMap;\n },\n set map(value) {\n Object.defineProperty(result, \"map\", { value, writable: true });\n },\n // Retrieving the raw mappings is very memory intensive.\n get rawMappings() {\n const mappings = map?.getRawMappings();\n result.rawMappings = mappings;\n return mappings;\n },\n set rawMappings(value) {\n Object.defineProperty(result, \"rawMappings\", { value, writable: true });\n },\n };\n\n return result;\n }\n\n /**\n * Add a string to the buffer that cannot be reverted.\n */\n\n append(str: string, maybeNewline: boolean): void {\n this._flush();\n\n this._append(str, this._sourcePosition, maybeNewline);\n }\n\n appendChar(char: number): void {\n this._flush();\n this._appendChar(char, 1, this._sourcePosition);\n }\n\n /**\n * Add a string to the buffer than can be reverted.\n */\n queue(char: number): void {\n // Drop trailing spaces when a newline is inserted.\n if (char === charcodes.lineFeed) {\n while (this._queueCursor !== 0) {\n const char = this._queue[this._queueCursor - 1].char;\n if (char !== charcodes.space && char !== charcodes.tab) {\n break;\n }\n\n this._queueCursor--;\n }\n }\n\n const sourcePosition = this._sourcePosition;\n this._pushQueue(\n char,\n 1,\n sourcePosition.line,\n sourcePosition.column,\n sourcePosition.identifierName,\n sourcePosition.filename,\n );\n }\n\n /**\n * Same as queue, but this indentation will never have a sourcmap marker.\n */\n queueIndentation(char: number, repeat: number): void {\n this._pushQueue(char, repeat, undefined, undefined, undefined, undefined);\n }\n\n _flush(): void {\n const queueCursor = this._queueCursor;\n const queue = this._queue;\n for (let i = 0; i < queueCursor; i++) {\n const item: QueueItem = queue[i];\n this._appendChar(item.char, item.repeat, item);\n }\n this._queueCursor = 0;\n }\n\n _appendChar(char: number, repeat: number, sourcePos: SourcePos): void {\n this._last = char;\n\n this._str +=\n repeat > 1\n ? String.fromCharCode(char).repeat(repeat)\n : String.fromCharCode(char);\n\n if (char !== charcodes.lineFeed) {\n this._mark(\n sourcePos.line,\n sourcePos.column,\n sourcePos.identifierName,\n sourcePos.filename,\n );\n this._position.column += repeat;\n } else {\n this._position.line++;\n this._position.column = 0;\n }\n }\n\n _append(str: string, sourcePos: SourcePos, maybeNewline: boolean): void {\n const len = str.length;\n\n this._last = str.charCodeAt(len - 1);\n\n if (++this._appendCount > 4096) {\n +this._str; // Unexplainable huge performance boost. Ref: https://github.com/davidmarkclements/flatstr License: MIT\n this._buf += this._str;\n this._str = str;\n this._appendCount = 0;\n } else {\n this._str += str;\n }\n\n if (!maybeNewline && !this._map) {\n this._position.column += len;\n return;\n }\n\n const { column, identifierName, filename } = sourcePos;\n let line = sourcePos.line;\n\n // Search for newline chars. We search only for `\\n`, since both `\\r` and\n // `\\r\\n` are normalized to `\\n` during parse. We exclude `\\u2028` and\n // `\\u2029` for performance reasons, they're so uncommon that it's probably\n // ok. It's also unclear how other sourcemap utilities handle them...\n let i = str.indexOf(\"\\n\");\n let last = 0;\n\n // If the string starts with a newline char, then adding a mark is redundant.\n // This catches both \"no newlines\" and \"newline after several chars\".\n if (i !== 0) {\n this._mark(line, column, identifierName, filename);\n }\n\n // Now, find each reamining newline char in the string.\n while (i !== -1) {\n this._position.line++;\n this._position.column = 0;\n last = i + 1;\n\n // We mark the start of each line, which happens directly after this newline char\n // unless this is the last char.\n if (last < str.length) {\n this._mark(++line, 0, identifierName, filename);\n }\n i = str.indexOf(\"\\n\", last);\n }\n this._position.column += str.length - last;\n }\n\n _mark(\n line: number | undefined,\n column: number | undefined,\n identifierName: string | undefined,\n filename: string | undefined,\n ): void {\n this._map?.mark(this._position, line, column, identifierName, filename);\n }\n\n removeTrailingNewline(): void {\n const queueCursor = this._queueCursor;\n if (\n queueCursor !== 0 &&\n this._queue[queueCursor - 1].char === charcodes.lineFeed\n ) {\n this._queueCursor--;\n }\n }\n\n removeLastSemicolon(): void {\n const queueCursor = this._queueCursor;\n if (\n queueCursor !== 0 &&\n this._queue[queueCursor - 1].char === charcodes.semicolon\n ) {\n this._queueCursor--;\n }\n }\n\n getLastChar(): number {\n const queueCursor = this._queueCursor;\n return queueCursor !== 0 ? this._queue[queueCursor - 1].char : this._last;\n }\n\n /**\n * check if current _last + queue ends with newline, return the character before newline\n *\n * @param {*} ch\n * @memberof Buffer\n */\n endsWithCharAndNewline(): number {\n const queue = this._queue;\n const queueCursor = this._queueCursor;\n if (queueCursor !== 0) {\n // every element in queue is one-length whitespace string\n const lastCp = queue[queueCursor - 1].char;\n if (lastCp !== charcodes.lineFeed) return;\n if (queueCursor > 1) {\n return queue[queueCursor - 2].char;\n } else {\n return this._last;\n }\n }\n // We assume that everything being matched is at most a single token plus some whitespace,\n // which everything currently is, but otherwise we'd have to expand _last or check _buf.\n }\n\n hasContent(): boolean {\n return this._queueCursor !== 0 || !!this._last;\n }\n\n /**\n * Certain sourcemap usecases expect mappings to be more accurate than\n * Babel's generic sourcemap handling allows. For now, we special-case\n * identifiers to allow for the primary cases to work.\n * The goal of this line is to ensure that the map output from Babel will\n * have an exact range on identifiers in the output code. Without this\n * line, Babel would potentially include some number of trailing tokens\n * that are printed after the identifier, but before another location has\n * been assigned.\n * This allows tooling like Rollup and Webpack to more accurately perform\n * their own transformations. Most importantly, this allows the import/export\n * transformations performed by those tools to loose less information when\n * applying their own transformations on top of the code and map results\n * generated by Babel itself.\n *\n * The primary example of this is the snippet:\n *\n * import mod from \"mod\";\n * mod();\n *\n * With this line, there will be one mapping range over \"mod\" and another\n * over \"();\", where previously it would have been a single mapping.\n */\n exactSource(loc: Loc | undefined, cb: () => void) {\n if (!this._map) return cb();\n\n this.source(\"start\", loc);\n\n cb();\n\n // In cases where tokens are printed after this item, we want to\n // ensure that they get the location of the _end_ of the identifier.\n // To accomplish this, we assign the location and explicitly disable\n // the standard Buffer withSource previous-position \"reactivation\"\n // logic. This means that if another item calls '.source()' to set\n // the location after the identifier, it is fine, but the position won't\n // be automatically replaced with the previous value.\n this.source(\"end\", loc);\n this._disallowPop(\"start\", loc);\n }\n\n /**\n * Sets a given position as the current source location so generated code after this call\n * will be given this position in the sourcemap.\n */\n\n source(prop: \"start\" | \"end\", loc: Loc | undefined): void {\n if (!loc) return;\n\n // Since this is called extremely often, we re-use the same _sourcePosition\n // object for the whole lifetime of the buffer.\n this._normalizePosition(prop, loc, this._sourcePosition);\n }\n\n /**\n * Call a callback with a specific source location and restore on completion.\n */\n\n withSource(prop: \"start\" | \"end\", loc: Loc, cb: () => void): void {\n if (!this._map) return cb();\n\n // Use the call stack to manage a stack of \"source location\" data because\n // the _sourcePosition object is mutated over the course of code generation,\n // and constantly copying it would be slower.\n const originalLine = this._sourcePosition.line;\n const originalColumn = this._sourcePosition.column;\n const originalFilename = this._sourcePosition.filename;\n const originalIdentifierName = this._sourcePosition.identifierName;\n\n this.source(prop, loc);\n\n cb();\n\n if (\n // Verify if reactivating this specific position has been disallowed.\n this._disallowedPop.objectReusable ||\n this._disallowedPop.line !== originalLine ||\n this._disallowedPop.column !== originalColumn ||\n this._disallowedPop.filename !== originalFilename\n ) {\n this._sourcePosition.line = originalLine;\n this._sourcePosition.column = originalColumn;\n this._sourcePosition.filename = originalFilename;\n this._sourcePosition.identifierName = originalIdentifierName;\n this._disallowedPop.objectReusable = true;\n }\n }\n\n /**\n * Allow printers to disable the default location-reset behavior of the\n * sourcemap output, so that certain printers can be sure that the\n * \"end\" location that they set is actually treated as the end position.\n */\n _disallowPop(prop: \"start\" | \"end\", loc: Loc) {\n if (!loc) return;\n\n const disallowedPop = this._disallowedPop;\n\n this._normalizePosition(prop, loc, disallowedPop);\n\n disallowedPop.objectReusable = false;\n }\n\n _normalizePosition(prop: \"start\" | \"end\", loc: Loc, targetObj: SourcePos) {\n const pos = loc[prop];\n\n targetObj.identifierName =\n (prop === \"start\" && loc.identifierName) || undefined;\n if (pos) {\n targetObj.line = pos.line;\n targetObj.column = pos.column;\n targetObj.filename = loc.filename;\n } else {\n targetObj.line = null;\n targetObj.column = null;\n targetObj.filename = null;\n }\n }\n\n getCurrentColumn(): number {\n const queue = this._queue;\n\n let lastIndex = -1;\n let len = 0;\n for (let i = 0; i < this._queueCursor; i++) {\n const item = queue[i];\n if (item.char === charcodes.lineFeed) {\n lastIndex = i;\n len += item.repeat;\n }\n }\n\n return lastIndex === -1 ? this._position.column + len : len - 1 - lastIndex;\n }\n\n getCurrentLine(): number {\n let count = 0;\n\n const queue = this._queue;\n for (let i = 0; i < this._queueCursor; i++) {\n if (queue[i].char === charcodes.lineFeed) {\n count++;\n }\n }\n\n return this._position.line + count;\n }\n}\n"],"mappings":";;;;;;;AA6BA,SAASA,SAAT,GAAgC;EAC9B,OAAO;IACLC,cAAc,EAAEC,SADX;IAELC,IAAI,EAAED,SAFD;IAGLE,MAAM,EAAEF,SAHH;IAILG,QAAQ,EAAEH;EAJL,CAAP;AAMD;;AAEc,MAAMI,MAAN,CAAa;EAC1BC,WAAW,CAACC,GAAD,EAAyB;IAAA,KAMpCC,IANoC,GAMl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