This commit is contained in:
2025-08-18 23:06:34 +08:00
parent 0bc04fb659
commit ed18af0cad
1926 changed files with 275098 additions and 0 deletions

15
package/node_modules/proggy/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,15 @@
The ISC License
Copyright (c) GitHub, Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

114
package/node_modules/proggy/lib/client.js generated vendored Normal file
View File

@@ -0,0 +1,114 @@
const EE = require('events')
const onProgress = Symbol('onProgress')
const bars = Symbol('bars')
const listener = Symbol('listener')
const normData = Symbol('normData')
class Client extends EE {
constructor ({ normalize = false, stopOnDone = false } = {}) {
super()
this.normalize = !!normalize
this.stopOnDone = !!stopOnDone
this[bars] = new Map()
this[listener] = null
}
get size () {
return this[bars].size
}
get listening () {
return !!this[listener]
}
addListener (...args) {
return this.on(...args)
}
on (ev, ...args) {
if (ev === 'progress' && !this[listener]) {
this.start()
}
return super.on(ev, ...args)
}
off (ev, ...args) {
return this.removeListener(ev, ...args)
}
removeListener (ev, ...args) {
const ret = super.removeListener(ev, ...args)
if (ev === 'progress' && this.listeners(ev).length === 0) {
this.stop()
}
return ret
}
stop () {
if (this[listener]) {
process.removeListener('progress', this[listener])
this[listener] = null
}
}
start () {
if (!this[listener]) {
this[listener] = (...args) => this[onProgress](...args)
process.on('progress', this[listener])
}
}
[onProgress] (key, data) {
data = this[normData](key, data)
if (!this[bars].has(key)) {
this.emit('bar', key, data)
}
this[bars].set(key, data)
this.emit('progress', key, data)
if (data.done) {
this[bars].delete(key)
this.emit('barDone', key, data)
if (this.size === 0) {
if (this.stopOnDone) {
this.stop()
}
this.emit('done')
}
}
}
[normData] (key, data) {
const actualValue = data.value
const actualTotal = data.total
let value = actualValue
let total = actualTotal
const done = data.done || value >= total
if (this.normalize) {
const bar = this[bars].get(key)
total = 100
if (done) {
value = 100
} else {
// show value as a portion of 100
const pct = 100 * actualValue / actualTotal
if (bar) {
// don't ever go backwards, and don't stand still
// move at least 1% of the remaining value if it wouldn't move.
value = (pct > bar.value) ? pct
: (100 - bar.value) / 100 + bar.value
}
}
}
// include the key
return {
...data,
key,
name: data.name || key,
value,
total,
actualValue,
actualTotal,
done,
}
}
}
module.exports = Client

15
package/node_modules/proggy/lib/index.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
exports.Client = require('./client.js')
exports.Tracker = require('./tracker.js')
const trackers = new Map()
exports.createTracker = (name, key, total) => {
const tracker = new exports.Tracker(name, key, total)
if (trackers.has(tracker.key)) {
const msg = `proggy: duplicate progress id ${JSON.stringify(tracker.key)}`
throw new Error(msg)
}
trackers.set(tracker.key, tracker)
tracker.on('done', () => trackers.delete(tracker.key))
return tracker
}
exports.createClient = (options = {}) => new exports.Client(options)

68
package/node_modules/proggy/lib/tracker.js generated vendored Normal file
View File

@@ -0,0 +1,68 @@
// The tracker class is intentionally as naive as possible. it is just
// an ergonomic wrapper around process.emit('progress', ...)
const EE = require('events')
class Tracker extends EE {
constructor (name, key, total) {
super()
if (!name) {
throw new Error('proggy: Tracker needs a name')
}
if (typeof key === 'number' && !total) {
total = key
key = null
}
if (!total) {
total = 100
}
if (!key) {
key = name
}
this.done = false
this.name = name
this.key = key
this.value = 0
this.total = total
}
finish (metadata = {}) {
this.update(this.total, this.total, metadata)
}
update (value, total, metadata) {
if (!metadata) {
if (total && typeof total === 'object') {
metadata = total
} else {
metadata = {}
}
}
if (typeof total !== 'number') {
total = this.total
}
if (this.done) {
const msg = `proggy: updating completed tracker: ${JSON.stringify(this.key)}`
throw new Error(msg)
}
this.value = value
this.total = total
const done = this.value >= this.total
process.emit('progress', this.key, {
...metadata,
name: this.name,
key: this.key,
value,
total,
done,
})
if (done) {
this.done = true
this.emit('done')
}
}
}
module.exports = Tracker

48
package/node_modules/proggy/package.json generated vendored Normal file
View File

@@ -0,0 +1,48 @@
{
"name": "proggy",
"version": "2.0.0",
"files": [
"bin/",
"lib/"
],
"main": "lib/index.js",
"description": "Progress bar updates at a distance",
"repository": {
"type": "git",
"url": "https://github.com/npm/proggy.git"
},
"author": "GitHub Inc.",
"license": "ISC",
"scripts": {
"test": "tap",
"posttest": "npm run lint",
"snap": "tap",
"postsnap": "eslint lib test --fix",
"lint": "eslint \"**/*.js\"",
"postlint": "template-oss-check",
"lintfix": "npm run lint -- --fix",
"template-oss-apply": "template-oss-apply --force"
},
"devDependencies": {
"@npmcli/eslint-config": "^3.0.1",
"@npmcli/template-oss": "4.5.1",
"chalk": "^4.1.2",
"cli-progress": "^3.10.0",
"npmlog": "^6.0.1",
"tap": "^16.0.1"
},
"tap": {
"coverage-map": "map.js",
"nyc-arg": [
"--exclude",
"tap-snapshots/**"
]
},
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.5.1"
}
}