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/  Your IP : 104.23.197.30   [ Reverse IP ]
Web Server : nginx/1.18.0
System : Linux ip-172-31-29-104 5.15.0-1075-aws #82~20.04.1-Ubuntu SMP Thu Dec 19 05:24:09 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.3-4ubuntu2.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/node_modules/ts-node/dist/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/node_modules/ts-node/dist/esm.js.map
{"version":3,"file":"esm.js","sourceRoot":"","sources":["../src/esm.ts"],"names":[],"mappings":";;;AAAA,mCAMiB;AACjB,6BAMa;AACb,+BAA+B;AAC/B,iCAAiC;AACjC,iCAA0C;AAC1C,mCAAuC;AACvC,MAAM,EACJ,aAAa,GACd,GAAG,OAAO,CAAC,6CAA6C,CAAC,CAAC;AAC3D,MAAM,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,yCAAyC,CAAC,CAAC;AAiFhF,2FAA2F;AAC3F,6FAA6F;AAC7F,MAAM,WAAW,GACf,IAAA,oBAAY,EAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IAC7C,IAAA,oBAAY,EAAC,OAAO,CAAC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,\n  format as formatUrl,\n  UrlWithStringQuery,\n  fileURLToPath,\n  pathToFileURL,\n} from 'url';\nimport { extname } from 'path';\nimport * as assert from 'assert';\nimport { normalizeSlashes } from './util';\nimport { createRequire } from 'module';\nconst {\n  createResolve,\n} = require('../dist-raw/node-esm-resolve-implementation');\nconst { defaultGetFormat } = require('../dist-raw/node-esm-default-get-format');\n\n// Note: On Windows, URLs look like this: file:///D:/dev/@TypeStrong/ts-node-examples/foo.ts\n\n// NOTE ABOUT MULTIPLE EXPERIMENTAL LOADER APIS\n//\n// At the time of writing, this file implements 2x different loader APIs.\n// Node made a breaking change to the loader API in https://github.com/nodejs/node/pull/37468\n//\n// We check the node version number and export either the *old* or the *new* API.\n//\n// Today, we are implementing the *new* API on top of our implementation of the *old* API,\n// which relies on copy-pasted code from the *old* hooks implementation in node.\n//\n// In the future, we will likely invert this: we will copy-paste the *new* API implementation\n// from node, build our implementation of the *new* API on top of it, and implement the *old*\n// hooks API as a shim to the *new* API.\n\nexport interface NodeLoaderHooksAPI1 {\n  resolve: NodeLoaderHooksAPI1.ResolveHook;\n  getFormat: NodeLoaderHooksAPI1.GetFormatHook;\n  transformSource: NodeLoaderHooksAPI1.TransformSourceHook;\n}\nexport namespace NodeLoaderHooksAPI1 {\n  export type ResolveHook = NodeLoaderHooksAPI2.ResolveHook;\n  export type GetFormatHook = (\n    url: string,\n    context: {},\n    defaultGetFormat: GetFormatHook\n  ) => Promise<{ format: NodeLoaderHooksFormat }>;\n  export type TransformSourceHook = (\n    source: string | Buffer,\n    context: { url: string; format: NodeLoaderHooksFormat },\n    defaultTransformSource: NodeLoaderHooksAPI1.TransformSourceHook\n  ) => Promise<{ source: string | Buffer }>;\n}\n\nexport interface NodeLoaderHooksAPI2 {\n  resolve: NodeLoaderHooksAPI2.ResolveHook;\n  load: NodeLoaderHooksAPI2.LoadHook;\n}\nexport namespace NodeLoaderHooksAPI2 {\n  export type ResolveHook = (\n    specifier: string,\n    context: {\n      conditions?: NodeImportConditions;\n      importAssertions?: NodeImportAssertions;\n      parentURL: string;\n    },\n    defaultResolve: ResolveHook\n  ) => Promise<{ url: string; format?: NodeLoaderHooksFormat }>;\n  export type LoadHook = (\n    url: string,\n    context: {\n      format: NodeLoaderHooksFormat | null | undefined;\n      importAssertions?: NodeImportAssertions;\n    },\n    defaultLoad: NodeLoaderHooksAPI2['load']\n  ) => Promise<{\n    format: NodeLoaderHooksFormat;\n    source: string | Buffer | undefined;\n  }>;\n  export type NodeImportConditions = unknown;\n  export interface NodeImportAssertions {\n    type?: 'json';\n  }\n}\n\nexport type NodeLoaderHooksFormat =\n  | 'builtin'\n  | 'commonjs'\n  | 'dynamic'\n  | 'json'\n  | 'module'\n  | 'wasm';\n\nexport type NodeImportConditions = unknown;\nexport interface NodeImportAssertions {\n  type?: 'json';\n}\n\n// The hooks API changed in node version X so we need to check for backwards compatibility.\n// TODO: When the new API is backported to v12, v14, update these version checks accordingly.\nconst newHooksAPI =\n  versionGteLt(process.versions.node, '17.0.0') ||\n  versionGteLt(process.versions.node, '16.12.0', '17.0.0') ||\n  versionGteLt(process.versions.node, '14.999.999', '15.0.0') ||\n  versionGteLt(process.versions.node, '12.999.999', '13.0.0');\n\n/** @internal */\nexport function filterHooksByAPIVersion(\n  hooks: NodeLoaderHooksAPI1 & NodeLoaderHooksAPI2\n): NodeLoaderHooksAPI1 | NodeLoaderHooksAPI2 {\n  const { getFormat, load, resolve, transformSource } = hooks;\n  // Explicit return type to avoid TS's non-ideal inferred type\n  const hooksAPI: NodeLoaderHooksAPI1 | NodeLoaderHooksAPI2 = newHooksAPI\n    ? { resolve, load, getFormat: undefined, transformSource: undefined }\n    : { resolve, getFormat, transformSource, load: undefined };\n  return hooksAPI;\n}\n\n/** @internal */\nexport function registerAndCreateEsmHooks(opts?: RegisterOptions) {\n  // Automatically performs registration just like `-r ts-node/register`\n  const tsNodeInstance = register(opts);\n\n  return createEsmHooks(tsNodeInstance);\n}\n\nexport function createEsmHooks(tsNodeService: Service) {\n  tsNodeService.enableExperimentalEsmLoaderInterop();\n\n  // Custom implementation that considers additional file extensions and automatically adds file extensions\n  const nodeResolveImplementation = createResolve({\n    ...getExtensions(tsNodeService.config),\n    preferTsExts: tsNodeService.options.preferTsExts,\n  });\n\n  const hooksAPI = filterHooksByAPIVersion({\n    resolve,\n    load,\n    getFormat,\n    transformSource,\n  });\n\n  function isFileUrlOrNodeStyleSpecifier(parsed: UrlWithStringQuery) {\n    // We only understand file:// URLs, but in node, the specifier can be a node-style `./foo` or `foo`\n    const { protocol } = parsed;\n    return protocol === null || protocol === 'file:';\n  }\n\n  /**\n   * Named \"probably\" as a reminder that this is a guess.\n   * node does not explicitly tell us if we're resolving the entrypoint or not.\n   */\n  function isProbablyEntrypoint(specifier: string, parentURL: string) {\n    return parentURL === undefined && specifier.startsWith('file://');\n  }\n  // Side-channel between `resolve()` and `load()` hooks\n  const rememberIsProbablyEntrypoint = new Set();\n  const rememberResolvedViaCommonjsFallback = new Set();\n\n  async function resolve(\n    specifier: string,\n    context: { parentURL: string },\n    defaultResolve: typeof resolve\n  ): Promise<{ url: string; format?: NodeLoaderHooksFormat }> {\n    const defer = async () => {\n      const r = await defaultResolve(specifier, context, defaultResolve);\n      return r;\n    };\n    // See: https://github.com/nodejs/node/discussions/41711\n    // nodejs will likely implement a similar fallback.  Till then, we can do our users a favor and fallback today.\n    async function entrypointFallback(\n      cb: () => ReturnType<typeof resolve>\n    ): ReturnType<typeof resolve> {\n      try {\n        const resolution = await cb();\n        if (\n          resolution?.url &&\n          isProbablyEntrypoint(specifier, context.parentURL)\n        )\n          rememberIsProbablyEntrypoint.add(resolution.url);\n        return resolution;\n      } catch (esmResolverError) {\n        if (!isProbablyEntrypoint(specifier, context.parentURL))\n          throw esmResolverError;\n        try {\n          let cjsSpecifier = specifier;\n          // Attempt to convert from ESM file:// to CommonJS path\n          try {\n            if (specifier.startsWith('file://'))\n              cjsSpecifier = fileURLToPath(specifier);\n          } catch {}\n          const resolution = pathToFileURL(\n            createRequire(process.cwd()).resolve(cjsSpecifier)\n          ).toString();\n          rememberIsProbablyEntrypoint.add(resolution);\n          rememberResolvedViaCommonjsFallback.add(resolution);\n          return { url: resolution, format: 'commonjs' };\n        } catch (commonjsResolverError) {\n          throw esmResolverError;\n        }\n      }\n    }\n\n    const parsed = parseUrl(specifier);\n    const { pathname, protocol, hostname } = parsed;\n\n    if (!isFileUrlOrNodeStyleSpecifier(parsed)) {\n      return entrypointFallback(defer);\n    }\n\n    if (protocol !== null && protocol !== 'file:') {\n      return entrypointFallback(defer);\n    }\n\n    // Malformed file:// URL?  We should always see `null` or `''`\n    if (hostname) {\n      // TODO file://./foo sets `hostname` to `'.'`.  Perhaps we should special-case this.\n      return entrypointFallback(defer);\n    }\n\n    // pathname is the path to be resolved\n\n    return entrypointFallback(() =>\n      nodeResolveImplementation.defaultResolve(\n        specifier,\n        context,\n        defaultResolve\n      )\n    );\n  }\n\n  // `load` from new loader hook API (See description at the top of this file)\n  async function load(\n    url: string,\n    context: {\n      format: NodeLoaderHooksFormat | null | undefined;\n      importAssertions?: NodeLoaderHooksAPI2.NodeImportAssertions;\n    },\n    defaultLoad: typeof load\n  ): Promise<{\n    format: NodeLoaderHooksFormat;\n    source: string | Buffer | undefined;\n  }> {\n    // If we get a format hint from resolve() on the context then use it\n    // otherwise call the old getFormat() hook using node's old built-in defaultGetFormat() that ships with ts-node\n    const format =\n      context.format ??\n      (await getFormat(url, context, defaultGetFormat)).format;\n\n    let source = undefined;\n    if (format !== 'builtin' && format !== 'commonjs') {\n      // Call the new defaultLoad() to get the source\n      const { source: rawSource } = await defaultLoad(\n        url,\n        {\n          ...context,\n          format,\n        },\n        defaultLoad\n      );\n\n      if (rawSource === undefined || rawSource === null) {\n        throw new Error(\n          `Failed to load raw source: Format was '${format}' and url was '${url}''.`\n        );\n      }\n\n      // Emulate node's built-in old defaultTransformSource() so we can re-use the old transformSource() hook\n      const defaultTransformSource: typeof transformSource = async (\n        source,\n        _context,\n        _defaultTransformSource\n      ) => ({ source });\n\n      // Call the old hook\n      const { source: transformedSource } = await transformSource(\n        rawSource,\n        { url, format },\n        defaultTransformSource\n      );\n      source = transformedSource;\n    }\n\n    return { format, source };\n  }\n\n  async function getFormat(\n    url: string,\n    context: {},\n    defaultGetFormat: typeof getFormat\n  ): Promise<{ format: NodeLoaderHooksFormat }> {\n    const defer = (overrideUrl: string = url) =>\n      defaultGetFormat(overrideUrl, context, defaultGetFormat);\n\n    // See: https://github.com/nodejs/node/discussions/41711\n    // nodejs will likely implement a similar fallback.  Till then, we can do our users a favor and fallback today.\n    async function entrypointFallback(\n      cb: () => ReturnType<typeof getFormat>\n    ): ReturnType<typeof getFormat> {\n      try {\n        return await cb();\n      } catch (getFormatError) {\n        if (!rememberIsProbablyEntrypoint.has(url)) throw getFormatError;\n        return { format: 'commonjs' };\n      }\n    }\n\n    const parsed = parseUrl(url);\n\n    if (!isFileUrlOrNodeStyleSpecifier(parsed)) {\n      return entrypointFallback(defer);\n    }\n\n    const { pathname } = parsed;\n    assert(\n      pathname !== null,\n      'ESM getFormat() hook: URL should never have null pathname'\n    );\n\n    const nativePath = fileURLToPath(url);\n\n    // If file has .ts, .tsx, or .jsx extension, then ask node how it would treat this file if it were .js\n    const ext = extname(nativePath);\n    let nodeSays: { format: NodeLoaderHooksFormat };\n    if (ext !== '.js' && !tsNodeService.ignored(nativePath)) {\n      nodeSays = await entrypointFallback(() =>\n        defer(formatUrl(pathToFileURL(nativePath + '.js')))\n      );\n    } else {\n      nodeSays = await entrypointFallback(defer);\n    }\n    // For files compiled by ts-node that node believes are either CJS or ESM, check if we should override that classification\n    if (\n      !tsNodeService.ignored(nativePath) &&\n      (nodeSays.format === 'commonjs' || nodeSays.format === 'module')\n    ) {\n      const { moduleType } = tsNodeService.moduleTypeClassifier.classifyModule(\n        normalizeSlashes(nativePath)\n      );\n      if (moduleType === 'cjs') {\n        return { format: 'commonjs' };\n      } else if (moduleType === 'esm') {\n        return { format: 'module' };\n      }\n    }\n    return nodeSays;\n  }\n\n  async function transformSource(\n    source: string | Buffer,\n    context: { url: string; format: NodeLoaderHooksFormat },\n    defaultTransformSource: typeof transformSource\n  ): Promise<{ source: string | Buffer }> {\n    if (source === null || source === undefined) {\n      throw new Error('No source');\n    }\n\n    const defer = () =>\n      defaultTransformSource(source, context, defaultTransformSource);\n\n    const sourceAsString =\n      typeof source === 'string' ? source : source.toString('utf8');\n\n    const { url } = context;\n    const parsed = parseUrl(url);\n\n    if (!isFileUrlOrNodeStyleSpecifier(parsed)) {\n      return defer();\n    }\n    const nativePath = fileURLToPath(url);\n\n    if (tsNodeService.ignored(nativePath)) {\n      return defer();\n    }\n\n    const emittedJs = tsNodeService.compile(sourceAsString, nativePath);\n\n    return { source: emittedJs };\n  }\n\n  return hooksAPI;\n}\n"]}

Anon7 - 2022
AnonSec Team