This commit is contained in:
2026-03-03 15:23:00 +00:00
parent 5e3726de39
commit 8e223bfbec
3689 changed files with 955330 additions and 1011 deletions

11
node_modules/@hapi/ammo/LICENSE.md generated vendored Executable file
View File

@@ -0,0 +1,11 @@
Copyright (c) 2014-2022, Project contributors
Copyright (c) 2014-2020, Sideway Inc
Copyright (c) 2014, Walmart.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* The names of any contributors may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS OFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

18
node_modules/@hapi/ammo/README.md generated vendored Normal file
View File

@@ -0,0 +1,18 @@
<a href="https://hapi.dev"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a>
# @hapi/ammo
#### HTTP Range processing utilities.
**ammo** is part of the **hapi** ecosystem and was designed to work seamlessly with the [hapi web framework](https://hapi.dev) and its other components (but works great on its own or with other frameworks). If you are using a different web framework and find this module useful, check out [hapi](https://hapi.dev) they work even better together.
### Visit the [hapi.dev](https://hapi.dev) Developer Portal for tutorials, documentation, and support
## Useful resources
- [Documentation and API](https://hapi.dev/family/ammo/)
- [Versions status](https://hapi.dev/resources/status/#ammo) (builds, dependencies, node versions, licenses, eol)
- [Changelog](https://hapi.dev/family/ammo/changelog/)
- [Project policies](https://hapi.dev/policies/)
- [Free and commercial support options](https://hapi.dev/support/)

41
node_modules/@hapi/ammo/lib/index.d.ts generated vendored Executable file
View File

@@ -0,0 +1,41 @@
/// <reference types="node" />
import * as Stream from 'stream';
/**
* Parses an HTTP Range header.
*
* @param header - the HTTP Range header.
* @param length - the payload length.
*
* @returns an array of range objects.
*/
export function header(header: string, length: number): null | Range[];
/**
* A transform stream taking full payload and returning the requested range.
*/
export class Clip extends Stream.Transform {
/**
* Constructs a new transform steam.
*
* @param range - the requested range.
*/
constructor(range: Range);
}
export interface Range {
/**
* The range start position (inclusive).
*/
readonly from: number;
/**
* The range end position (inclusive).
*/
readonly to: number;
}

185
node_modules/@hapi/ammo/lib/index.js generated vendored Executable file
View File

@@ -0,0 +1,185 @@
'use strict';
const Stream = require('stream');
const Hoek = require('@hapi/hoek');
const internals = {};
// RFC 7233 (https://tools.ietf.org/html/rfc7233#appendix-D)
//
// Range = "bytes" "=" byte-range-set
// byte-range-set = *( "," OWS ) byte-range-spec *( OWS "," [ OWS byte-range-spec ] )
// byte-range-spec = ( 1*DIGIT "-" [ 1*DIGIT ] ) / ( "-" 1*DIGIT )
// 12 3 3 4 425 6 7 7 8 865 1
internals.headerRx = /^bytes=[\s,]*((?:(?:\d+\-\d*)|(?:\-\d+))(?:\s*,\s*(?:(?:\d+\-\d*)|(?:\-\d+)))*)$/i;
exports.header = function (header, length) {
// Parse header
const parts = internals.headerRx.exec(header);
if (!parts) {
return null;
}
const lastPos = length - 1;
const result = [];
const ranges = parts[1].match(/\d*\-\d*/g);
// Handle headers with multiple ranges
for (let range of ranges) {
let from;
let to;
range = range.split('-');
if (range[0]) {
from = parseInt(range[0], 10);
}
if (range[1]) {
to = parseInt(range[1], 10);
if (from !== undefined) { // Can be 0
// From-To
if (to > lastPos) {
to = lastPos;
}
}
else {
// -To
from = length - to;
to = lastPos;
}
}
else {
// From-
to = lastPos;
}
if (from > to) {
return null;
}
result.push(new internals.Range(from, to));
}
if (result.length === 1) {
return result;
}
// Sort and consolidate ranges
result.sort((a, b) => a.from - b.from);
const consolidated = [];
for (let i = result.length - 1; i > 0; --i) {
const current = result[i];
const before = result[i - 1];
if (current.from <= before.to + 1) {
before.to = current.to;
}
else {
consolidated.unshift(current);
}
}
consolidated.unshift(result[0]);
return consolidated;
};
internals.Range = class {
constructor(from, to) {
this.from = from;
this.to = to;
}
};
exports.Clip = class extends Stream.Transform {
constructor(range) {
if (!(range instanceof internals.Range)) {
Hoek.assert(typeof range === 'object', 'Expected "range" object');
const from = range.from ?? 0;
Hoek.assert(typeof from === 'number', '"range.from" must be a number');
Hoek.assert(from === parseInt(from, 10) && from >= 0, '"range.from" must be a positive integer');
const to = range.to ?? 0;
Hoek.assert(typeof to === 'number', '"range.to" must be a number');
Hoek.assert(to === parseInt(to, 10) && to >= 0, '"range.to" must be a positive integer');
Hoek.assert(to >= from, '"range.to" must be greater than or equal to "range.from"');
range = new internals.Range(from, to);
}
super();
this._range = range;
this._next = 0;
this._pipes = new Set();
this.on('pipe', (pipe) => this._pipes.add(pipe));
this.on('unpipe', (pipe) => this._pipes.delete(pipe));
}
_transform(chunk, encoding, done) {
try {
internals.processChunk(this, chunk);
}
catch (err) {
return done(err);
}
return done();
}
_flush(done) {
this._pipes.clear();
done();
}
};
internals.processChunk = function (stream, chunk) {
// Read desired range from a stream
const pos = stream._next;
stream._next = stream._next + chunk.length;
if (stream._next <= stream._range.from) { // Before range
return;
}
if (pos > stream._range.to) { // After range
for (const pipe of stream._pipes) {
pipe.unpipe(stream);
}
stream._pipes.clear();
stream.end();
return;
}
// Calculate bounds of chunk to read
const from = Math.max(0, stream._range.from - pos);
const to = Math.min(chunk.length, stream._range.to - pos + 1);
stream.push(chunk.slice(from, to));
};

37
node_modules/@hapi/ammo/package.json generated vendored Executable file
View File

@@ -0,0 +1,37 @@
{
"name": "@hapi/ammo",
"description": "HTTP Range processing utilities",
"version": "6.0.1",
"repository": "git://github.com/hapijs/ammo",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"keywords": [
"http",
"range",
"utilities"
],
"files": [
"lib"
],
"eslintConfig": {
"extends": [
"plugin:@hapi/module"
]
},
"dependencies": {
"@hapi/hoek": "^11.0.2"
},
"devDependencies": {
"@hapi/code": "^9.0.3",
"@hapi/eslint-plugin": "*",
"@hapi/lab": "^25.1.2",
"@hapi/wreck": "^18.0.1",
"@types/node": "^17.0.31",
"typescript": "~4.6.4"
},
"scripts": {
"test": "lab -a @hapi/code -t 100 -L -Y",
"test-cov-html": "lab -a @hapi/code -r html -o coverage.html"
},
"license": "BSD-3-Clause"
}