File: /var/www/design.system/node_modules/@rushstack/terminal/lib/TextRewriter.js.map
{"version":3,"file":"TextRewriter.js","sourceRoot":"","sources":["../src/TextRewriter.ts"],"names":[],"mappings":";AAAA,4FAA4F;AAC5F,2DAA2D;;;AA6B3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAsB,YAAY;CAejC;AAfD,oCAeC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport type { Brand } from '@rushstack/node-core-library';\n\n/**\n * Represents the internal state of a {@link TextRewriter} subclass.\n *\n * @remarks\n * For example, suppose that {@link NormalizeNewlinesTextRewriter} will be used to rewrite\n * the input `\"line 1\\r\\nline 2\\r\\n\"` to become `\"line 1\\nline 2\\n\"`. But suppose that the `\"\\r\\n\"`\n * pair is split across two chunks:\n *\n * ```ts\n * const rewriter: NormalizeNewlinesTextRewriter = new NormalizeNewlinesTextRewriter(NewlineKind.Lf);\n * const state: TextRewriterState = rewriter.initialize();\n * let output: string = rewriter.process(state, 'line 1\\r');\n * output += rewriter.process(state, '\\nline 2\\r\\n');\n * output += rewriter.close(state);\n *\n * // The final \"output\" value is: \"line 1\\nline 2\\n\"\n * ```\n *\n * The `TextRewriterState` keeps track of this context, so that split `\"\\r\"` and `\"\\n\"` are\n * interpreted as a single newline.\n *\n * @public\n */\nexport type TextRewriterState = Brand<unknown, 'TextRewriterState'>;\n\n/**\n * The abstract base class for operations that can be applied by {@link TextRewriterTransform}.\n *\n * @remarks\n * The {@link TextRewriterTransform} applies one or more character rewriting operations to its\n * chunk stream. Since these operations are applied separately to `stderr` and `stdout`, the\n * state is stored in an opaque `TextRewriterState` object.\n *\n * Conceptually, a `TextRewriter` subclass is very similar to a regular expression, with the difference\n * that `RegExp` operates on a text string, whereas `TextRewriter` operates on a stream of characters.\n *\n * The two most common subclasses are {@link NormalizeNewlinesTextRewriter} and {@link RemoveColorsTextRewriter}.\n *\n * A rewriting operation starts with `initialize()`, followed by any number of `process()` calls, and\n * then finishes with `close()`. For example:\n *\n * ```ts\n * const rewriter: NormalizeNewlinesTextRewriter = new NormalizeNewlinesTextRewriter(NewlineKind.Lf);\n * const state: TextRewriterState = rewriter.initialize();\n * let output: string = rewriter.process(state, 'line 1\\r');\n * output += rewriter.process(state, '\\nline 2\\r\\n');\n * output += rewriter.close(state);\n *\n * // The final \"output\" value is: \"line 1\\nline 2\\n\"\n * ```\n *\n * After `close()` has been called, the `TextRewriterState` state should not be reused.\n *\n * @public\n */\nexport abstract class TextRewriter {\n /**\n * Create a new `TextRewriterState` object that can be used to process a stream of characters.\n */\n public abstract initialize(): TextRewriterState;\n\n /**\n * Rewrite the next sequence of characters from the input stream, returning the modified output.\n */\n public abstract process(state: TextRewriterState, input: string): string;\n\n /**\n * Close the `TextRewriterState` object and return any buffered output.\n */\n public abstract close(state: TextRewriterState): string;\n}\n"]}