????

Your IP : 3.15.149.154


Current Path : C:/inetpub/vhost/invest.gdtsolutions.vn/api/node_modules/ts-node/dist/
Upload File :
Current File : C:/inetpub/vhost/invest.gdtsolutions.vn/api/node_modules/ts-node/dist/repl.js.map

{"version":3,"file":"repl.js","sourceRoot":"","sources":["../src/repl.ts"],"names":[],"mappings":";;;AACA,2BAA6B;AAC7B,+BAA4B;AAC5B,+BAKc;AACd,2BAAoD;AACpD,mCAA+D;AAC/D,2BAA4C;AAC5C,qCAAkC;AAClC,iCAAiC;AAGjC,mCAAwC;AAExC,eAAe;AACf,IAAI,qBAAqD,CAAC;AAC1D,SAAS,uBAAuB;IAC9B,IAAI,qBAAqB,KAAK,SAAS,EAAE;QACvC,CAAC;YACC,oBAAoB,EAAE,qBAAqB;SAC5C,GAAG,OAAO,CAAC,sCAAsC,CAAC,CAAC,CAAC;KACtD;IACD,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AACD,IAAI,IAAkB,CAAC;AACvB,SAAS,YAAY;IACnB,IAAI,IAAI,KAAK,SAAS,EAAE;QACtB,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;KACxB;IACD,OAAO,IAAI,CAAC,SAAS,CAAC;AACxB,CAAC;AAED,gBAAgB;AACH,QAAA,aAAa,GAAG,WAAW,CAAC;AACzC,gBAAgB;AACH,QAAA,SAAS,GAAG,QAAQ,CAAC;AAClC,gBAAgB;AACH,QAAA,cAAc,GAAG,YAAY,CAAC;AAC3C,gBAAgB;AACH,QAAA,UAAU,GAAG,SAAS,CAAC;AACpC,gBAAgB;AACH,QAAA,aAAa,GAAG,WAAW,CAAC;AACzC,gBAAgB;AACH,QAAA,SAAS,GAAG,QAAQ,CAAC;AAsFlC;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,UAAU,CAAC,UAA6B,EAAE;;IACxD,MAAM,EAAE,iDAAiD,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAC7E,IAAI,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC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B,OAAO,CAAC,SAAS,GAAG,GAAG,CAAC;QACxB,OAAO,CAAC,UAAU,GAAG,IAAI,kBAAkB,GAAG,CAAC;KAChD;IACD,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC;IACxB,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;IACjC,OAAO,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC;AAZD,oCAYC","sourcesContent":["import type * as _diff from 'diff';\nimport { homedir } from 'os';\nimport { join } from 'path';\nimport {\n  Recoverable,\n  ReplOptions,\n  REPLServer,\n  start as nodeReplStart,\n} from 'repl';\nimport { Context, createContext, Script } from 'vm';\nimport { Service, CreateOptions, TSError, env } from './index';\nimport { readFileSync, statSync } from 'fs';\nimport { Console } from 'console';\nimport * as assert from 'assert';\nimport type * as tty from 'tty';\nimport type * as Module from 'module';\nimport { builtinModules } from 'module';\n\n// Lazy-loaded.\nlet _processTopLevelAwait: (src: string) => string | null;\nfunction getProcessTopLevelAwait() {\n  if (_processTopLevelAwait === undefined) {\n    ({\n      processTopLevelAwait: _processTopLevelAwait,\n    } = require('../dist-raw/node-internal-repl-await'));\n  }\n  return _processTopLevelAwait;\n}\nlet diff: typeof _diff;\nfunction getDiffLines() {\n  if (diff === undefined) {\n    diff = require('diff');\n  }\n  return diff.diffLines;\n}\n\n/** @internal */\nexport const EVAL_FILENAME = `[eval].ts`;\n/** @internal */\nexport const EVAL_NAME = `[eval]`;\n/** @internal */\nexport const STDIN_FILENAME = `[stdin].ts`;\n/** @internal */\nexport const STDIN_NAME = `[stdin]`;\n/** @internal */\nexport const REPL_FILENAME = '<repl>.ts';\n/** @internal */\nexport const REPL_NAME = '<repl>';\n\nexport interface ReplService {\n  readonly state: EvalState;\n  /**\n   * Bind this REPL to a ts-node compiler service.  A compiler service must be bound before `eval`-ing code or starting the REPL\n   */\n  setService(service: Service): void;\n  /**\n   * Append code to the virtual <repl> source file, compile it to JavaScript, throw semantic errors if the typechecker is enabled,\n   * and execute it.\n   *\n   * Note: typically, you will want to call `start()` instead of using this method.\n   *\n   * @param code string of TypeScript.\n   */\n  evalCode(code: string): any;\n  /** @internal */\n  evalCodeInternal(opts: {\n    code: string;\n    enableTopLevelAwait?: boolean;\n    context?: Context;\n  }):\n    | {\n        containsTopLevelAwait: true;\n        valuePromise: Promise<any>;\n      }\n    | {\n        containsTopLevelAwait: false;\n        value: any;\n      };\n  /**\n   * `eval` implementation compatible with node's REPL API\n   *\n   * Can be used in advanced scenarios if you want to manually create your own\n   * node REPL instance and delegate eval to this `ReplService`.\n   *\n   * Example:\n   *\n   *     import {start} from 'repl';\n   *     const replService: tsNode.ReplService = ...; // assuming you have already created a ts-node ReplService\n   *     const nodeRepl = start({eval: replService.eval});\n   */\n  nodeEval(\n    code: string,\n    // TODO change to `Context` in a future release?  Technically a breaking change\n    context: any,\n    _filename: string,\n    callback: (err: Error | null, result?: any) => any\n  ): void;\n  evalAwarePartialHost: EvalAwarePartialHost;\n  /** Start a node REPL */\n  start(): void;\n  /**\n   * Start a node REPL, evaling a string of TypeScript before it starts.\n   * @deprecated\n   */\n  start(code: string): void;\n  /** @internal */\n  startInternal(opts?: ReplOptions): REPLServer;\n  /** @internal */\n  readonly stdin: NodeJS.ReadableStream;\n  /** @internal */\n  readonly stdout: NodeJS.WritableStream;\n  /** @internal */\n  readonly stderr: NodeJS.WritableStream;\n  /** @internal */\n  readonly console: Console;\n}\n\n/** @category REPL */\nexport interface CreateReplOptions {\n  service?: Service;\n  state?: EvalState;\n  stdin?: NodeJS.ReadableStream;\n  stdout?: NodeJS.WritableStream;\n  stderr?: NodeJS.WritableStream;\n  /** @internal */\n  composeWithEvalAwarePartialHost?: EvalAwarePartialHost;\n  /**\n   * @internal\n   * Ignore diagnostics that are annoying when interactively entering input line-by-line.\n   */\n  ignoreDiagnosticsThatAreAnnoyingInInteractiveRepl?: boolean;\n}\n\n/**\n * Create a ts-node REPL instance.\n *\n * Pay close attention to the example below.  Today, the API requires a few lines\n * of boilerplate to correctly bind the `ReplService` to the ts-node `Service` and\n * vice-versa.\n *\n * Usage example:\n *\n *     const repl = tsNode.createRepl();\n *     const service = tsNode.create({...repl.evalAwarePartialHost});\n *     repl.setService(service);\n *     repl.start();\n *\n * @category REPL\n */\nexport function createRepl(options: CreateReplOptions = {}) {\n  const { ignoreDiagnosticsThatAreAnnoyingInInteractiveRepl = true } = options;\n  let service = options.service;\n  let nodeReplServer: REPLServer;\n  // If `useGlobal` is not true, then REPL creates a context when started.\n  // This stores a reference to it or to `global`, whichever is used, after REPL has started.\n  let context: Context | undefined;\n  const state =\n    options.state ?? new EvalState(join(process.cwd(), REPL_FILENAME));\n  const evalAwarePartialHost = createEvalAwarePartialHost(\n    state,\n    options.composeWithEvalAwarePartialHost\n  );\n  const stdin = options.stdin ?? process.stdin;\n  const stdout = options.stdout ?? process.stdout;\n  const stderr = options.stderr ?? process.stderr;\n  const _console =\n    stdout === process.stdout && stderr === process.stderr\n      ? console\n      : new Console(stdout, stderr);\n\n  const replService: ReplService = {\n    state: options.state ?? new EvalState(join(process.cwd(), EVAL_FILENAME)),\n    setService,\n    evalCode,\n    evalCodeInternal,\n    nodeEval,\n    evalAwarePartialHost,\n    start,\n    startInternal,\n    stdin,\n    stdout,\n    stderr,\n    console: _console,\n  };\n\n  return replService;\n\n  function setService(_service: Service) {\n    service = _service;\n    if (ignoreDiagnosticsThatAreAnnoyingInInteractiveRepl) {\n      service.addDiagnosticFilter({\n        appliesToAllFiles: false,\n        filenamesAbsolute: [state.path],\n        diagnosticsIgnored: [\n          2393, // Duplicate function implementation: https://github.com/TypeStrong/ts-node/issues/729\n          6133, // <identifier> is declared but its value is never read. https://github.com/TypeStrong/ts-node/issues/850\n          7027, // Unreachable code detected. https://github.com/TypeStrong/ts-node/issues/469\n          ...(service.shouldReplAwait ? topLevelAwaitDiagnosticCodes : []),\n        ],\n      });\n    }\n  }\n\n  function evalCode(code: string) {\n    const result = appendCompileAndEvalInput({\n      service: service!,\n      state,\n      input: code,\n      context,\n      overrideIsCompletion: false,\n    });\n    assert(result.containsTopLevelAwait === false);\n    return result.value;\n  }\n\n  function evalCodeInternal(options: {\n    code: string;\n    enableTopLevelAwait?: boolean;\n    context: Context;\n  }) {\n    const { code, enableTopLevelAwait, context } = options;\n    return appendCompileAndEvalInput({\n      service: service!,\n      state,\n      input: code,\n      enableTopLevelAwait,\n      context,\n    });\n  }\n\n  function nodeEval(\n    code: string,\n    context: any,\n    _filename: string,\n    callback: (err: Error | null, result?: any) => any\n  ) {\n    // TODO: Figure out how to handle completion here.\n    if (code === '.scope') {\n      callback(null);\n      return;\n    }\n\n    try {\n      const evalResult = evalCodeInternal({\n        code,\n        enableTopLevelAwait: true,\n        context,\n      });\n\n      if (evalResult.containsTopLevelAwait) {\n        (async () => {\n          try {\n            callback(null, await evalResult.valuePromise);\n          } catch (promiseError) {\n            handleError(promiseError);\n          }\n        })();\n      } else {\n        callback(null, evalResult.value);\n      }\n    } catch (error) {\n      handleError(error);\n    }\n\n    // Log TSErrors, check if they're recoverable, log helpful hints for certain\n    // well-known errors, and invoke `callback()`\n    // TODO should evalCode API get the same error-handling benefits?\n    function handleError(error: unknown) {\n      // Don't show TLA hint if the user explicitly disabled repl top level await\n      const canLogTopLevelAwaitHint =\n        service!.options.experimentalReplAwait !== false &&\n        !service!.shouldReplAwait;\n      if (error instanceof TSError) {\n        // Support recoverable compilations using >= node 6.\n        if (Recoverable && isRecoverable(error)) {\n          callback(new Recoverable(error));\n          return;\n        } else {\n          _console.error(error);\n\n          if (\n            canLogTopLevelAwaitHint &&\n            error.diagnosticCodes.some((dC) =>\n              topLevelAwaitDiagnosticCodes.includes(dC)\n            )\n          ) {\n            _console.error(getTopLevelAwaitHint());\n          }\n          callback(null);\n        }\n      } else {\n        let _error = error as Error | undefined;\n        if (\n          canLogTopLevelAwaitHint &&\n          _error instanceof SyntaxError &&\n          _error.message?.includes('await is only valid')\n        ) {\n          try {\n            // Only way I know to make our hint appear after the error\n            _error.message += `\\n\\n${getTopLevelAwaitHint()}`;\n            _error.stack = _error.stack?.replace(\n              /(SyntaxError:.*)/,\n              (_, $1) => `${$1}\\n\\n${getTopLevelAwaitHint()}`\n            );\n          } catch {}\n        }\n        callback(_error as Error);\n      }\n    }\n    function getTopLevelAwaitHint() {\n      return `Hint: REPL top-level await requires TypeScript version 3.8 or higher and target ES2018 or higher. You are using TypeScript ${\n        service!.ts.version\n      } and target ${\n        service!.ts.ScriptTarget[service!.config.options.target!]\n      }.`;\n    }\n  }\n\n  // Note: `code` argument is deprecated\n  function start(code?: string) {\n    startInternal({ code });\n  }\n\n  // Note: `code` argument is deprecated\n  function startInternal(\n    options?: ReplOptions & { code?: string; forceToBeModule?: boolean }\n  ) {\n    const { code, forceToBeModule = true, ...optionsOverride } = options ?? {};\n    // TODO assert that `service` is set; remove all `service!` non-null assertions\n\n    // Eval incoming code before the REPL starts.\n    // Note: deprecated\n    if (code) {\n      try {\n        evalCode(`${code}\\n`);\n      } catch (err) {\n        _console.error(err);\n        // Note: should not be killing the process here, but this codepath is deprecated anyway\n        process.exit(1);\n      }\n    }\n\n    // In case the typescript compiler hasn't compiled anything yet,\n    // make it run though compilation at least one time before\n    // the REPL starts for a snappier user experience on startup.\n    service?.compile('', state.path);\n\n    const repl = nodeReplStart({\n      prompt: '> ',\n      input: replService.stdin,\n      output: replService.stdout,\n      // Mimicking node's REPL implementation: https://github.com/nodejs/node/blob/168b22ba073ee1cbf8d0bcb4ded7ff3099335d04/lib/internal/repl.js#L28-L30\n      terminal:\n        (stdout as tty.WriteStream).isTTY &&\n        !parseInt(env.NODE_NO_READLINE!, 10),\n      eval: nodeEval,\n      useGlobal: true,\n      ...optionsOverride,\n    });\n\n    nodeReplServer = repl;\n    context = repl.context;\n\n    // Bookmark the point where we should reset the REPL state.\n    const resetEval = appendToEvalState(state, '');\n\n    function reset() {\n      resetEval();\n\n      // Hard fix for TypeScript forcing `Object.defineProperty(exports, ...)`.\n      runInContext('exports = module.exports', state.path, context);\n      if (forceToBeModule) {\n        state.input += 'export {};void 0;\\n';\n      }\n\n      // Declare node builtins.\n      // Skip the same builtins as `addBuiltinLibsToObject`:\n      //   those starting with _\n      //   those containing /\n      //   those that already exist as globals\n      // Intentionally suppress type errors in case @types/node does not declare any of them, and because\n      // `declare import` is technically invalid syntax.\n      // Avoid this when in transpileOnly, because third-party transpilers may not handle `declare import`.\n      if (!service?.transpileOnly) {\n        state.input += `// @ts-ignore\\n${builtinModules\n          .filter(\n            (name) =>\n              !name.startsWith('_') &&\n              !name.includes('/') &&\n              !['console', 'module', 'process'].includes(name)\n          )\n          .map((name) => `declare import ${name} = require('${name}')`)\n          .join(';')}\\n`;\n      }\n    }\n\n    reset();\n    repl.on('reset', reset);\n\n    repl.defineCommand('type', {\n      help: 'Check the type of a TypeScript identifier',\n      action: function (identifier: string) {\n        if (!identifier) {\n          repl.displayPrompt();\n          return;\n        }\n\n        const undo = appendToEvalState(state, identifier);\n        const { name, comment } = service!.getTypeInfo(\n          state.input,\n          state.path,\n          state.input.length\n        );\n\n        undo();\n\n        if (name) repl.outputStream.write(`${name}\\n`);\n        if (comment) repl.outputStream.write(`${comment}\\n`);\n        repl.displayPrompt();\n      },\n    });\n\n    // Set up REPL history when available natively via node.js >= 11.\n    if (repl.setupHistory) {\n      const historyPath =\n        env.TS_NODE_HISTORY || join(homedir(), '.ts_node_repl_history');\n\n      repl.setupHistory(historyPath, (err) => {\n        if (!err) return;\n\n        _console.error(err);\n        process.exit(1);\n      });\n    }\n\n    return repl;\n  }\n}\n\n/**\n * Eval state management. Stores virtual `[eval].ts` file\n */\nexport class EvalState {\n  /** @internal */\n  input = '';\n  /** @internal */\n  output = '';\n  /** @internal */\n  version = 0;\n  /** @internal */\n  lines = 0;\n\n  __tsNodeEvalStateBrand: unknown;\n\n  constructor(public path: string) {}\n}\n\n/**\n * Filesystem host functions which are aware of the \"virtual\" `[eval].ts`, `<repl>`, or `[stdin].ts` file used to compile REPL inputs.\n * Must be passed to `create()` to create a ts-node compiler service which can compile REPL inputs.\n */\nexport type EvalAwarePartialHost = Pick<\n  CreateOptions,\n  'readFile' | 'fileExists'\n>;\n\nexport function createEvalAwarePartialHost(\n  state: EvalState,\n  composeWith?: EvalAwarePartialHost\n): EvalAwarePartialHost {\n  function readFile(path: string) {\n    if (path === state.path) return state.input;\n\n    if (composeWith?.readFile) return composeWith.readFile(path);\n\n    try {\n      return readFileSync(path, 'utf8');\n    } catch (err) {\n      /* Ignore. */\n    }\n  }\n  function fileExists(path: string) {\n    if (path === state.path) return true;\n\n    if (composeWith?.fileExists) return composeWith.fileExists(path);\n\n    try {\n      const stats = statSync(path);\n      return stats.isFile() || stats.isFIFO();\n    } catch (err) {\n      return false;\n    }\n  }\n  return { readFile, fileExists };\n}\n\nconst sourcemapCommentRe = /\\/\\/# ?sourceMappingURL=\\S+[\\s\\r\\n]*$/;\n\ntype AppendCompileAndEvalInputResult =\n  | { containsTopLevelAwait: true; valuePromise: Promise<any> }\n  | { containsTopLevelAwait: false; value: any };\n/**\n * Evaluate the code snippet.\n *\n * Append it to virtual .ts file, compile, handle compiler errors, compute a diff of the JS, and eval any code that\n * appears as \"added\" in the diff.\n */\nfunction appendCompileAndEvalInput(options: {\n  service: Service;\n  state: EvalState;\n  input: string;\n  wrappedErr?: unknown;\n  /** Enable top-level await but only if the TSNode service allows it. */\n  enableTopLevelAwait?: boolean;\n  context: Context | undefined;\n  /**\n   * Added so that `evalCode` can be guaranteed *not* to trigger the `isCompletion`\n   * codepath.  However, the `isCompletion` logic is ancient and maybe should be removed entirely.\n   * Nobody's looked at it in a long time.\n   */\n  overrideIsCompletion?: boolean;\n}): AppendCompileAndEvalInputResult {\n  const {\n    service,\n    state,\n    wrappedErr,\n    enableTopLevelAwait = false,\n    context,\n    overrideIsCompletion,\n  } = options;\n  let { input } = options;\n\n  // It's confusing for `{ a: 1 }` to be interpreted as a block statement\n  // rather than an object literal. So, we first try to wrap it in\n  // parentheses, so that it will be interpreted as an expression.\n  // Based on https://github.com/nodejs/node/blob/c2e6822153bad023ab7ebd30a6117dcc049e475c/lib/repl.js#L413-L422\n  let wrappedCmd = false;\n  if (!wrappedErr && /^\\s*{/.test(input) && !/;\\s*$/.test(input)) {\n    input = `(${input.trim()})\\n`;\n    wrappedCmd = true;\n  }\n\n  const lines = state.lines;\n  const isCompletion = overrideIsCompletion ?? !/\\n$/.test(input);\n  const undo = appendToEvalState(state, input);\n  let output: string;\n\n  // Based on https://github.com/nodejs/node/blob/92573721c7cff104ccb82b6ed3e8aa69c4b27510/lib/repl.js#L457-L461\n  function adjustUseStrict(code: string) {\n    // \"void 0\" keeps the repl from returning \"use strict\" as the result\n    // value for statements and declarations that don't return a value.\n    return code.replace(/^\"use strict\";/, '\"use strict\"; void 0;');\n  }\n\n  try {\n    output = service.compile(state.input, state.path, -lines);\n  } catch (err) {\n    undo();\n\n    if (wrappedCmd) {\n      if (err instanceof TSError && err.diagnosticCodes[0] === 2339) {\n        // Ensure consistent and more sane behavior between { a: 1 }['b'] and ({ a: 1 }['b'])\n        throw err;\n      }\n      // Unwrap and try again\n      return appendCompileAndEvalInput({\n        ...options,\n        wrappedErr: err,\n      });\n    }\n\n    if (wrappedErr) throw wrappedErr;\n    throw err;\n  }\n\n  output = adjustUseStrict(output);\n\n  // Note: REPL does not respect sourcemaps!\n  // To properly do that, we'd need to prefix the code we eval -- which comes\n  // from `diffLines` -- with newlines so that it's at the proper line numbers.\n  // Then we'd need to ensure each bit of eval-ed code, if there are multiples,\n  // has the sourcemap appended to it.\n  // We might also need to integrate with our sourcemap hooks' cache; I'm not sure.\n  const outputWithoutSourcemapComment = output.replace(sourcemapCommentRe, '');\n  const oldOutputWithoutSourcemapComment = state.output.replace(\n    sourcemapCommentRe,\n    ''\n  );\n\n  // Use `diff` to check for new JavaScript to execute.\n  const changes = getDiffLines()(\n    oldOutputWithoutSourcemapComment,\n    outputWithoutSourcemapComment\n  );\n\n  if (isCompletion) {\n    undo();\n  } else {\n    state.output = output;\n\n    // Insert a semicolon to make sure that the code doesn't interact with the next line,\n    // for example to prevent `2\\n+ 2` from producing 4.\n    // This is safe since the output will not change since we can only get here with successful inputs,\n    // and adding a semicolon to the end of a successful input won't ever change the output.\n    state.input = state.input.replace(\n      /([^\\n\\s])([\\n\\s]*)$/,\n      (all, lastChar, whitespace) => {\n        if (lastChar !== ';') return `${lastChar};${whitespace}`;\n        return all;\n      }\n    );\n  }\n\n  let commands: Array<{ mustAwait?: true; execCommand: () => any }> = [];\n  let containsTopLevelAwait = false;\n\n  // Build a list of \"commands\": bits of JS code in the diff that must be executed.\n  for (const change of changes) {\n    if (change.added) {\n      if (\n        enableTopLevelAwait &&\n        service.shouldReplAwait &&\n        change.value.indexOf('await') > -1\n      ) {\n        const processTopLevelAwait = getProcessTopLevelAwait();\n\n        // Newline prevents comments to mess with wrapper\n        const wrappedResult = processTopLevelAwait(change.value + '\\n');\n        if (wrappedResult !== null) {\n          containsTopLevelAwait = true;\n          commands.push({\n            mustAwait: true,\n            execCommand: () => runInContext(wrappedResult, state.path, context),\n          });\n          continue;\n        }\n      }\n      commands.push({\n        execCommand: () => runInContext(change.value, state.path, context),\n      });\n    }\n  }\n\n  // Execute all commands asynchronously if necessary, returning the result or a\n  // promise of the result.\n  if (containsTopLevelAwait) {\n    return {\n      containsTopLevelAwait,\n      valuePromise: (async () => {\n        let value;\n        for (const command of commands) {\n          const r = command.execCommand();\n          value = command.mustAwait ? await r : r;\n        }\n        return value;\n      })(),\n    };\n  } else {\n    return {\n      containsTopLevelAwait: false,\n      value: commands.reduce<any>((_, c) => c.execCommand(), undefined),\n    };\n  }\n}\n\n/**\n * Low-level execution of JS code in context\n */\nfunction runInContext(code: string, filename: string, context?: Context) {\n  const script = new Script(code, { filename });\n\n  if (context === undefined || context === global) {\n    return script.runInThisContext();\n  } else {\n    return script.runInContext(context);\n  }\n}\n\n/**\n * Append to the eval instance and return an undo function.\n */\nfunction appendToEvalState(state: EvalState, input: string) {\n  const undoInput = state.input;\n  const undoVersion = state.version;\n  const undoOutput = state.output;\n  const undoLines = state.lines;\n\n  state.input += input;\n  state.lines += lineCount(input);\n  state.version++;\n\n  return function () {\n    state.input = undoInput;\n    state.output = undoOutput;\n    state.version = undoVersion;\n    state.lines = undoLines;\n  };\n}\n\n/**\n * Count the number of lines.\n */\nfunction lineCount(value: string) {\n  let count = 0;\n\n  for (const char of value) {\n    if (char === '\\n') {\n      count++;\n    }\n  }\n\n  return count;\n}\n\n/**\n * TS diagnostic codes which are recoverable, meaning that the user likely entered an incomplete line of code\n * and should be prompted for the next.  For example, starting a multi-line for() loop and not finishing it.\n * null value means code is always recoverable.  `Set` means code is only recoverable when occurring alongside at least one\n * of the other codes.\n */\nconst RECOVERY_CODES: Map<number, Set<number> | null> = new Map([\n  [1003, null], // \"Identifier expected.\"\n  [1005, null], // \"')' expected.\", \"'}' expected.\"\n  [1109, null], // \"Expression expected.\"\n  [1126, null], // \"Unexpected end of text.\"\n  [\n    1136, // \"Property assignment expected.\"\n    new Set([1005]), // happens when typing out an object literal or block scope across multiple lines: '{ foo: 123,'\n  ],\n  [1160, null], // \"Unterminated template literal.\"\n  [1161, null], // \"Unterminated regular expression literal.\"\n  [2355, null], // \"A function whose declared type is neither 'void' nor 'any' must return a value.\"\n  [2391, null], // \"Function implementation is missing or not immediately following the declaration.\"\n  [\n    7010, // \"Function, which lacks return-type annotation, implicitly has an 'any' return type.\"\n    new Set([1005]), // happens when fn signature spread across multiple lines: 'function a(\\nb: any\\n) {'\n  ],\n]);\n\n/**\n * Diagnostic codes raised when using top-level await.\n * These are suppressed when top-level await is enabled.\n * When it is *not* enabled, these trigger a helpful hint about enabling top-level await.\n */\nconst topLevelAwaitDiagnosticCodes = [\n  1375, // 'await' expressions are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module.\n  1378, // Top-level 'await' expressions are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.\n  1431, // 'for await' loops are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module.\n  1432, // Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher.\n];\n\n/**\n * Check if a function can recover gracefully.\n */\nfunction isRecoverable(error: TSError) {\n  return error.diagnosticCodes.every((code) => {\n    const deps = RECOVERY_CODES.get(code);\n    return (\n      deps === null ||\n      (deps && error.diagnosticCodes.some((code) => deps.has(code)))\n    );\n  });\n}\n\n/**\n * @internal\n * Set properties on `context` before eval-ing [stdin] or [eval] input.\n */\nexport function setupContext(\n  context: any,\n  module: Module,\n  filenameAndDirname: 'eval' | 'stdin' | null\n) {\n  if (filenameAndDirname) {\n    context.__dirname = '.';\n    context.__filename = `[${filenameAndDirname}]`;\n  }\n  context.module = module;\n  context.exports = module.exports;\n  context.require = module.require.bind(module);\n}\n"]}