$21 GRAYBYTE WORDPRESS FILE MANAGER $81

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/cpanel/ea-nodejs22/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/

HOME
Current File : /opt/cpanel/ea-nodejs22/lib/node_modules/npm/node_modules/@npmcli/arborist/lib//edge.js
// An edge in the dependency graph
// Represents a dependency relationship of some kind

const util = require('node:util')
const npa = require('npm-package-arg')
const depValid = require('./dep-valid.js')

class ArboristEdge {
  constructor (edge) {
    this.name = edge.name
    this.spec = edge.spec
    this.type = edge.type

    const edgeFrom = edge.from?.location
    const edgeTo = edge.to?.location
    const override = edge.overrides?.value

    if (edgeFrom != null) {
      this.from = edgeFrom
    }
    if (edgeTo) {
      this.to = edgeTo
    }
    if (edge.error) {
      this.error = edge.error
    }
    if (edge.peerConflicted) {
      this.peerConflicted = true
    }
    if (override) {
      this.overridden = override
    }
  }
}

class Edge {
  #accept
  #error
  #explanation
  #from
  #name
  #spec
  #to
  #type

  static types = Object.freeze([
    'prod',
    'dev',
    'optional',
    'peer',
    'peerOptional',
    'workspace',
  ])

  // XXX where is this used?
  static errors = Object.freeze([
    'DETACHED',
    'MISSING',
    'PEER LOCAL',
    'INVALID',
  ])

  constructor (options) {
    const { type, name, spec, accept, from, overrides } = options

    // XXX are all of these error states even possible?
    if (typeof spec !== 'string') {
      throw new TypeError('must provide string spec')
    }
    if (!Edge.types.includes(type)) {
      throw new TypeError(`invalid type: ${type}\n(valid types are: ${Edge.types.join(', ')})`)
    }
    if (type === 'workspace' && npa(spec).type !== 'directory') {
      throw new TypeError('workspace edges must be a symlink')
    }
    if (typeof name !== 'string') {
      throw new TypeError('must provide dependency name')
    }
    if (!from) {
      throw new TypeError('must provide "from" node')
    }
    if (accept !== undefined) {
      if (typeof accept !== 'string') {
        throw new TypeError('accept field must be a string if provided')
      }
      this.#accept = accept || '*'
    }
    if (overrides !== undefined) {
      this.overrides = overrides
    }

    this.#name = name
    this.#type = type
    this.#spec = spec
    this.#explanation = null
    this.#from = from

    from.edgesOut.get(this.#name)?.detach()
    from.addEdgeOut(this)

    this.reload(true)
    this.peerConflicted = false
  }

  satisfiedBy (node) {
    if (node.name !== this.#name) {
      return false
    }

    // NOTE: this condition means we explicitly do not support overriding
    // bundled or shrinkwrapped dependencies
    if (node.hasShrinkwrap || node.inShrinkwrap || node.inBundle) {
      return depValid(node, this.rawSpec, this.#accept, this.#from)
    }
    return depValid(node, this.spec, this.#accept, this.#from)
  }

  // return the edge data, and an explanation of how that edge came to be here
  explain (seen = []) {
    if (!this.#explanation) {
      const explanation = {
        type: this.#type,
        name: this.#name,
        spec: this.spec,
      }
      if (this.rawSpec !== this.spec) {
        explanation.rawSpec = this.rawSpec
        explanation.overridden = true
      }
      if (this.bundled) {
        explanation.bundled = this.bundled
      }
      if (this.error) {
        explanation.error = this.error
      }
      if (this.#from) {
        explanation.from = this.#from.explain(null, seen)
      }
      this.#explanation = explanation
    }
    return this.#explanation
  }

  get bundled () {
    return !!this.#from?.package?.bundleDependencies?.includes(this.#name)
  }

  get workspace () {
    return this.#type === 'workspace'
  }

  get prod () {
    return this.#type === 'prod'
  }

  get dev () {
    return this.#type === 'dev'
  }

  get optional () {
    return this.#type === 'optional' || this.#type === 'peerOptional'
  }

  get peer () {
    return this.#type === 'peer' || this.#type === 'peerOptional'
  }

  get type () {
    return this.#type
  }

  get name () {
    return this.#name
  }

  get rawSpec () {
    return this.#spec
  }

  get spec () {
    if (this.overrides?.value && this.overrides.value !== '*' && this.overrides.name === this.#name) {
      if (this.overrides.value.startsWith('$')) {
        const ref = this.overrides.value.slice(1)
        // we may be a virtual root, if we are we want to resolve reference overrides
        // from the real root, not the virtual one
        const pkg = this.#from.sourceReference
          ? this.#from.sourceReference.root.package
          : this.#from.root.package
        if (pkg.devDependencies?.[ref]) {
          return pkg.devDependencies[ref]
        }
        if (pkg.optionalDependencies?.[ref]) {
          return pkg.optionalDependencies[ref]
        }
        if (pkg.dependencies?.[ref]) {
          return pkg.dependencies[ref]
        }
        if (pkg.peerDependencies?.[ref]) {
          return pkg.peerDependencies[ref]
        }

        throw new Error(`Unable to resolve reference ${this.overrides.value}`)
      }
      return this.overrides.value
    }
    return this.#spec
  }

  get accept () {
    return this.#accept
  }

  get valid () {
    return !this.error
  }

  get missing () {
    return this.error === 'MISSING'
  }

  get invalid () {
    return this.error === 'INVALID'
  }

  get peerLocal () {
    return this.error === 'PEER LOCAL'
  }

  get error () {
    if (!this.#error) {
      if (!this.#to) {
        if (this.optional) {
          this.#error = null
        } else {
          this.#error = 'MISSING'
        }
      } else if (this.peer && this.#from === this.#to.parent && !this.#from.isTop) {
        this.#error = 'PEER LOCAL'
      } else if (!this.satisfiedBy(this.#to)) {
        this.#error = 'INVALID'
      } else {
        this.#error = 'OK'
      }
    }
    if (this.#error === 'OK') {
      return null
    }
    return this.#error
  }

  reload (hard = false) {
    this.#explanation = null
    if (this.#from.overrides) {
      this.overrides = this.#from.overrides.getEdgeRule(this)
    } else {
      delete this.overrides
    }
    const newTo = this.#from.resolve(this.#name)
    if (newTo !== this.#to) {
      if (this.#to) {
        this.#to.edgesIn.delete(this)
      }
      this.#to = newTo
      this.#error = null
      if (this.#to) {
        this.#to.addEdgeIn(this)
      }
    } else if (hard) {
      this.#error = null
    }
  }

  detach () {
    this.#explanation = null
    if (this.#to) {
      this.#to.edgesIn.delete(this)
    }
    this.#from.edgesOut.delete(this.#name)
    this.#to = null
    this.#error = 'DETACHED'
    this.#from = null
  }

  get from () {
    return this.#from
  }

  get to () {
    return this.#to
  }

  toJSON () {
    return new ArboristEdge(this)
  }

  [util.inspect.custom] () {
    return this.toJSON()
  }
}

module.exports = Edge

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
1 Jan 1970 8.00 AM
root / root
0
arborist
--
16 Mar 2026 5.04 PM
root / root
0755
add-rm-pkg-deps.js
4.891 KB
17 Jan 2026 1.16 AM
root / root
0644
audit-report.js
11.945 KB
17 Jan 2026 1.16 AM
root / root
0644
calc-dep-flags.js
3.424 KB
17 Jan 2026 1.16 AM
root / root
0644
can-place-dep.js
13.938 KB
17 Jan 2026 1.16 AM
root / root
0644
case-insensitive-map.js
1.21 KB
17 Jan 2026 1.16 AM
root / root
0644
consistent-resolve.js
1.266 KB
17 Jan 2026 1.16 AM
root / root
0644
debug.js
1.252 KB
17 Jan 2026 1.16 AM
root / root
0644
deepest-nesting-target.js
0.675 KB
17 Jan 2026 1.16 AM
root / root
0644
dep-valid.js
5.005 KB
17 Jan 2026 1.16 AM
root / root
0644
diff.js
9.573 KB
17 Jan 2026 1.16 AM
root / root
0644
edge.js
6.625 KB
17 Jan 2026 1.16 AM
root / root
0644
from-path.js
1.069 KB
17 Jan 2026 1.16 AM
root / root
0644
gather-dep-set.js
1.256 KB
17 Jan 2026 1.16 AM
root / root
0644
index.js
0.267 KB
17 Jan 2026 1.16 AM
root / root
0644
inventory.js
3.246 KB
17 Jan 2026 1.16 AM
root / root
0644
link.js
3.041 KB
17 Jan 2026 1.16 AM
root / root
0644
node.js
42.95 KB
17 Jan 2026 1.16 AM
root / root
0644
optional-set.js
1.321 KB
17 Jan 2026 1.16 AM
root / root
0644
override-resolves.js
0.22 KB
17 Jan 2026 1.16 AM
root / root
0644
override-set.js
3.115 KB
17 Jan 2026 1.16 AM
root / root
0644
packument-cache.js
2.496 KB
17 Jan 2026 1.16 AM
root / root
0644
peer-entry-sets.js
2.57 KB
17 Jan 2026 1.16 AM
root / root
0644
place-dep.js
19.752 KB
17 Jan 2026 1.16 AM
root / root
0644
printable.js
5.1 KB
17 Jan 2026 1.16 AM
root / root
0644
query-selector-all.js
28.841 KB
17 Jan 2026 1.16 AM
root / root
0644
realpath.js
2.593 KB
17 Jan 2026 1.16 AM
root / root
0644
relpath.js
0.133 KB
17 Jan 2026 1.16 AM
root / root
0644
reset-dep-flags.js
0.623 KB
17 Jan 2026 1.16 AM
root / root
0644
retire-path.js
0.489 KB
17 Jan 2026 1.16 AM
root / root
0644
shrinkwrap.js
36.827 KB
17 Jan 2026 1.16 AM
root / root
0644
signal-handling.js
2.192 KB
17 Jan 2026 1.16 AM
root / root
0644
signals.js
1.349 KB
17 Jan 2026 1.16 AM
root / root
0644
spec-from-lock.js
0.854 KB
17 Jan 2026 1.16 AM
root / root
0644
tracker.js
2.921 KB
17 Jan 2026 1.16 AM
root / root
0644
tree-check.js
4.045 KB
17 Jan 2026 1.16 AM
root / root
0644
version-from-tgz.js
1.453 KB
17 Jan 2026 1.16 AM
root / root
0644
vuln.js
5.818 KB
17 Jan 2026 1.16 AM
root / root
0644
yarn-lock.js
10.56 KB
17 Jan 2026 1.16 AM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF