first commit

This commit is contained in:
2026-03-10 16:18:05 +00:00
commit 11f9c069b5
31635 changed files with 3187747 additions and 0 deletions

78
node_modules/multitars/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,78 @@
# multitars
## 0.2.4
### Patch Changes
- Update rollup config for reduced output and exclude sources from sourcemaps
Submitted by [@kitten](https://github.com/kitten) (See [#17](https://github.com/kitten/multitars/pull/17))
## 0.2.3
### Patch Changes
- Revert trailer boundary check update
Submitted by [@kitten](https://github.com/kitten) (See [#15](https://github.com/kitten/multitars/pull/15))
## 0.2.2
### Patch Changes
- Drop block scoping transform which interferred with generator
Submitted by [@kitten](https://github.com/kitten) (See [#13](https://github.com/kitten/multitars/pull/13))
- Reduce `ReadableStreamBlockReader` memory complexity
Submitted by [@kitten](https://github.com/kitten) (See [#11](https://github.com/kitten/multitars/pull/11))
- Skip `File` constructor to improve performance
Submitted by [@kitten](https://github.com/kitten) (See [#12](https://github.com/kitten/multitars/pull/12))
## 0.2.1
### Patch Changes
- Replace `parseInt(val, 8)` for octal parsing with manual parsing (hotpath)
Submitted by [@kitten](https://github.com/kitten) (See [#9](https://github.com/kitten/multitars/pull/9))
## 0.2.0
### Minor Changes
- Allow `parseMultipart` and `streamMultipart` to handle custom headers via a `MultipartPart` abstraction extending `StreamFile`
Submitted by [@kitten](https://github.com/kitten) (See [#7](https://github.com/kitten/multitars/pull/7))
## 0.1.0
### Minor Changes
- Add basic README
Submitted by [@kitten](https://github.com/kitten) (See [`87831f1`](https://github.com/kitten/multitars/commit/87831f1c7e0e163d54f1992f220440db99c5e20f))
- Accept `ReadableStream` inputs on `tar` and `streamMultipart`
Submitted by [@kitten](https://github.com/kitten) (See [#5](https://github.com/kitten/multitars/pull/5))
- Accept `Iterable<Uint8Array>` and `AsyncIterable<Uint8Array>` on `untar` and `parseMultipart`
Submitted by [@kitten](https://github.com/kitten) (See [#5](https://github.com/kitten/multitars/pull/5))
- Add `iterableToStream` and `streamToAsyncIterable` conversion helpers
Submitted by [@kitten](https://github.com/kitten) (See [#4](https://github.com/kitten/multitars/pull/4))
### Patch Changes
- Improve multipart's boundary search performance
Submitted by [@kitten](https://github.com/kitten) (See [#6](https://github.com/kitten/multitars/pull/6))
## 0.0.3
### Patch Changes
- Normalize type flag of `CONTIGUOUS_FILE` and `OLD_FILE` to `FILE`
Submitted by [@kitten](https://github.com/kitten) (See [`d8f1785`](https://github.com/kitten/multitars/commit/d8f1785da78b9ed2359e1cb7c19387cabccd055d))
- Add missing `FormEntry` export
Submitted by [@kitten](https://github.com/kitten) (See [`8fae4f3`](https://github.com/kitten/multitars/commit/8fae4f3740f3c9d278d6f7faee757b2d684af0cc))
## 0.0.2
### Patch Changes
- Generate random boundary ID for multipart output and expose `multipartContentType`
Submitted by [@kitten](https://github.com/kitten) (See [`54b65ac`](https://github.com/kitten/multitars/commit/54b65ac7b50b2981c5ee182eeabaaedafb9dd489))
## 0.0.1
Initial Release.

22
node_modules/multitars/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,22 @@
MIT License
Copyright (c) Phil Pluckthun,
Copyright (c) 650 Industries, Inc. (aka Expo),
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

142
node_modules/multitars/README.md generated vendored Normal file
View File

@@ -0,0 +1,142 @@
# multitars
`multitars` is a memory-efficient parser and producer of [Tar archives](https://www.gnu.org/software/tar/manual/html_node/Standard.html)
and [`multipart/form-data` bodies](https://datatracker.ietf.org/doc/html/rfc2388).
## Implementation
The goal of `multitars` is to allow any JavaScript runtime that supports the
[Web Streams API standard](https://developer.mozilla.org/en-US/docs/Web/API/Streams_API)
to efficiently consume and/or produce Tar and form-data `ReadableStream` data without buffering
them in full.
This has been built with the explicit purpose in mind to:
- Accept `Request` bodies in the `tar` or `multipart/form-data` format
- Send `Request` bodies in the `tar` or `multipart/form-data` format
- Transform arbitrarily-sized `tar` or `multipart/form-data` streams
As such, the underlying implementation uses fixed block size reading to parse
Tar chunks and Form-data boundaries, switching to pull-based reading when possible
to keep overhead to a minimum.
- The tar implementation should match [`node-tar`](https://github.com/isaacs/node-tar)'s support of the Tar format (including PAX)
- The multipart implementation optionally accepts a `Content-Length` header in boundaries
- Both parsers operate on `StreamFile` which extends the standard `File` API
## API Reference
### `ReadableStreamLike<T>`
```ts
export type ReadableStreamLike<T> =
| ReadableStream<T>
| AsyncIterable<T>
| Iterable<T>;
```
All input arguments to stream helper functions support receiving data as either `ReadableStream`,
`AsyncIterable`, or `Iterable`.
### `parseMultipart(stream: ReadableStreamLike<Uint8Array>, params: ParseMultipartParams) => AsyncGenerator<StreamFile>`
- Accepts a stream of `Uint8Array` binary data
- **Parameters**
- `contentType`: The raw `Content-Type` header to search a `boundary=*` in
Returns an async iterable (as `AsyncGenerator`) of `StreamFile` with individual form-data values.
When a `StreamFile` isn't consumed, it's skipped before the next one is emitted.
### `streamMultipart(entries: ReadableStreamLike<FormEntry>): AsyncGenerator<Uint8Array>`
- Accepts a stream of `FormEntry`s
- `[string, string | Uint8Array | Blob | File]` tuples
Returns an async iterable of `Uint8Array` chunks encoding the output body stream.
### `multipartContentType: string`
The string value that `Content-Type` should be set to when sending `streamMultipart()`'s output as request bodies.
This contains a seeded multipart boundary identifier.
### `untar(stream: ReadableStreamLike<Uint8Array>) => AsyncGenerator<TarFile | TarChunk>`
- Accepts a stream of `Uint8Array` binary data
Returns an async iterable (as `AsyncGenerator`) of `TarFile`, for files in the Tar archive, and `TarChunk` for non-files.
When a `TarFile`/`TarChunk` isn't consumed, it's skipped before the next one is emitted.
### `tar(entries: ReadableStreamLike<TarChunk | TarFile> | Iterable<TarChunk | TarFile>) => AsyncGenerator<Uint8Array>`
- Accepts a stream of `TarChunk`s and `TarFile`s
Returns an async iterable of `Uint8Array` chunks encoding the output Tar archive stream.
The Tar archive will use PAX headers in its output.
### `interface TarChunkHeader`
A `TarFile` or `TarChunk` represent entries in a Tar archive. They have a set of common properties based on the Tar headers.
**Properties:**
- `mode`: Permission fields
- `uid`: User ID (if applicable/set, otherwise `0`)
- `gid`: Group ID (if applicable/set, otherwise `0`)
- `mtime`: Modified Time (if applicable/set, otherwise `0`)
- `linkname`: Only set for symlinks (the linked to name)
- `uname`: User Name (if applicable/set)
- `gname`: Group Name (if applicable/set)
- `typeflag: TarTypeFlag`: The type of the Tar entry
### `enum TarTypeFlag`
```ts
export enum TarTypeFlag {
FILE = 48 /* '0': regular file */,
LINK = 49 /* '1': link */,
SYMLINK = 50 /* '2': symbolic link */,
DIRECTORY = 53 /* '5': directory */,
}
```
### `class TarFile implements TarChunkHeader`
A `TarFile` represents a file in a Tar archive. It can be consumed or streamed like a regular `File`.
Its `typeflag` property is always set to `TarTypeFlag.FILE`.
### `class TarChunk implements TarChunkHeader`
A `TarChunk` represents a non-file in a Tar archive, which are hardlinks, symlinks, or directories.
They typically don't carry content bodies, but their content is preserved if they do contain any data.
Note that `TarChunk`s for directories (`typeflag: TarTypeFlag.DIRECTORY`) are optional and `multitars` does
not validate the directory structure of Tar archives since it streams any Tar contents. Tar archives may
contain nested files in directories without any `TarChunk` for directories being emitted.
### `streamToIterable(stream: ReadableStream) => AsyncIterable`
- Accepts a `ReadableStream`
Returns an `AsyncIterable` emitting the `ReadableStream`'s values.
This is an identity function if the runtime supports `Symbol.asyncIterator` on `ReadableStream`.
### `iterableToStream(iterable: AsyncIterable<T> | Iterable<T>, sourceOptions?: SafeIteratorSourceOptions) => BodyReadableStream<T>`
- Accepts an `AsyncIterable` or `Iterable`
- **Parameters**
- `signal?: AbortSignal`: A parent `AbortSignal` to abort the returned `ReadableStream` on
- `expectedLength?: number | bigint`: The expected length of the stream (Specific to Cloudflare workerd)
Returns a `BodyReadableStream` that emits the values of the passed iterable. `BodyReadableStream`
extends a regular `ReadableStream` with an added `signal: AbortSignal` property. This signal will
abort when the input iterable emits an error.
A common problem with Fetch Standard implementations is that a `ReadbleStream` passed to
a request does not propagate its error once the request has started. This prevents the
request from being cancelled and the error from propagating to the response when the input
Readable Stream errors.
The `BodyReadableStream` provides a `signal: AbortSignal` property so the underlying iterable error
can forcefully be propagated into a `fetch` call.

191
node_modules/multitars/dist/multitars.d.ts generated vendored Normal file
View File

@@ -0,0 +1,191 @@
type ReadableStreamLike<T> = ReadableStream<T> | AsyncIterable<T> | Iterable<T>;
declare function streamToAsyncIterable<T>(stream: ReadableStream<T>): AsyncIterable<T>;
interface SafeIteratorSourceOptions {
signal?: AbortSignal;
expectedLength?: number | bigint;
}
interface BodyReadableStream<T> extends ReadableStream<T> {
signal: AbortSignal;
}
/** Converts an `AsyncIterable` or `Iterable` into a safe `ReadableStream` with a safety `AbortSignal`
* @remarks
* This helper converts an iterable to a `ReadableStream` with a paired `AbortSignal`. The `AbortSignal`
* will abort when the underlying iterable errors.
*
* A common problem with Fetch Standard implementations is that a `ReaadbleStream` passed to
* a request does not propagate its error once the request has started. This prevents the
* request from being cancelled and the error from propagating to the response when the input
* Readable Stream errors.
* This helper provides an AbortSignal to forcefully abort the request when the underlying iterable
* errors.
*
* @param iterable - The AsyncIterable to wrap and catch errors from
* @param sourceOptions - An optional `expectedLength` and parent `signal` that may propagate to the output `ReadableStream`
* @returns `BodyReadableStream` that is a converted `ReadableStream` of the iterable with a `signal: AbortSignal` property that aborts when the iterable errors.
*/
declare function iterableToStream<T>(
iterable: AsyncIterable<T> | Iterable<T>,
sourceOptions?: SafeIteratorSourceOptions
): BodyReadableStream<T>;
interface StreamFileOptions {
type?: string;
lastModified?: number;
size?: number;
}
declare const StreamFile_base: {
new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag): File;
prototype: File;
};
declare class StreamFile extends StreamFile_base implements File {
#private;
constructor(
stream: ReadableStream<Uint8Array<ArrayBuffer>> | BlobPart[],
name: string,
options: StreamFileOptions
);
get lastModified(): number;
get size(): number;
get name(): string;
set name(name: string);
get type(): string;
set type(type: string);
stream(): ReadableStream<Uint8Array<ArrayBuffer>>;
bytes(): Promise<Uint8Array<ArrayBuffer>>;
arrayBuffer(): Promise<ArrayBuffer>;
text(): Promise<string>;
json(): Promise<any>;
slice(): never;
}
interface MultipartPartOptions extends StreamFileOptions {
headers?: MultipartHeaders;
}
interface MultipartHeaders {
'content-disposition'?: string;
'content-length'?: string;
'content-type'?: string;
[headerName: string]: string | undefined;
}
declare class MultipartPart extends StreamFile {
headers: MultipartHeaders;
constructor(
stream: ReadableStream<Uint8Array<ArrayBuffer>> | BlobPart[],
name: string,
options?: MultipartPartOptions
);
}
interface ParseMultipartParams {
/** The `Content-Type` header value */
contentType: string;
}
/** Provide tar entry iterator */
declare function parseMultipart(
stream: ReadableStreamLike<Uint8Array>,
params: ParseMultipartParams
): AsyncGenerator<MultipartPart>;
type FormValue = string | Uint8Array<ArrayBuffer> | MultipartPart | Blob | File;
type FormEntry = readonly [name: string, value: FormValue];
declare const multipartContentType: string;
declare function streamMultipart(
entries: ReadableStreamLike<FormEntry>
): AsyncGenerator<Uint8Array<ArrayBuffer>>;
declare const enum InternalTypeFlag {
OLD_FILE = 0,
CONTIGUOUS_FILE = 55,
CHAR_DEV = 51,
BLOCK_DEV = 52,
FIFO = 54,
LONG_LINK_NAME = 75,
LONG_NAME = 76,
OLD_LONG_NAME = 78,
TAPE_VOL = 86,
GAX = 103,
PAX = 120,
}
declare enum TarTypeFlag {
FILE = 48,
LINK = 49,
SYMLINK = 50,
DIRECTORY = 53,
}
interface TarChunkHeader {
name: string;
mode: number;
uid: number;
gid: number;
size: number;
mtime: number;
typeflag: TarTypeFlag | InternalTypeFlag;
linkname: string | null;
uname: string | null;
gname: string | null;
devmajor: number;
devminor: number;
}
interface TarHeader extends TarChunkHeader {
_prefix?: string;
_longName?: string;
_longLinkName?: string;
_paxName?: string;
_paxLinkName?: string;
_paxSize?: number;
}
type TarChunkTypeFlag = Exclude<TarTypeFlag, TarTypeFlag.FILE>;
declare class TarChunk extends StreamFile implements TarChunkHeader {
mode: number;
uid: number;
gid: number;
mtime: number;
typeflag: TarChunkTypeFlag;
linkname: string | null;
uname: string | null;
gname: string | null;
devmajor: number;
devminor: number;
constructor(stream: ReadableStream<Uint8Array<ArrayBuffer>> | BlobPart[], header: TarHeader);
}
declare class TarFile extends StreamFile implements TarChunkHeader {
mode: number;
uid: number;
gid: number;
mtime: number;
typeflag: TarTypeFlag.FILE;
linkname: null;
uname: string | null;
gname: string | null;
devmajor: number;
devminor: number;
static from(
stream: ReadableStream<Uint8Array<ArrayBuffer>> | BlobPart[],
name: string,
options: StreamFileOptions
): TarFile;
constructor(stream: ReadableStream<Uint8Array<ArrayBuffer>> | BlobPart[], header: TarHeader);
}
/** Provide tar entry iterator */
declare function untar(stream: ReadableStreamLike<Uint8Array>): AsyncGenerator<TarFile | TarChunk>;
declare function tar(
entries: ReadableStreamLike<TarChunk | TarFile>
): AsyncGenerator<Uint8Array<ArrayBuffer>>;
export {
MultipartPart,
StreamFile,
TarChunk,
TarFile,
TarTypeFlag,
iterableToStream,
multipartContentType,
parseMultipart,
streamMultipart,
streamToAsyncIterable,
tar,
untar,
};
export type { FormEntry, FormValue, MultipartHeaders, MultipartPartOptions, StreamFileOptions };

1313
node_modules/multitars/dist/multitars.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
node_modules/multitars/dist/multitars.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

1297
node_modules/multitars/dist/multitars.mjs generated vendored Normal file

File diff suppressed because it is too large Load Diff

1
node_modules/multitars/dist/multitars.mjs.map generated vendored Normal file

File diff suppressed because one or more lines are too long

80
node_modules/multitars/package.json generated vendored Normal file
View File

@@ -0,0 +1,80 @@
{
"name": "multitars",
"version": "0.2.4",
"description": "Multipart and Tar utilities for the Web Streams API",
"author": "Phil Pluckthun <phil@kitten.sh>",
"source": "./src/index.ts",
"main": "./dist/multitars",
"module": "./dist/multitars.mjs",
"types": "./dist/multitars.d.ts",
"files": [
"LICENSE.md",
"README.md",
"CHANGELOG.md",
"dist/"
],
"exports": {
".": {
"types": "./dist/multitars.d.ts",
"import": "./dist/multitars.mjs",
"require": "./dist/multitars.js",
"source": "./src/index.ts"
},
"./package.json": "./package.json"
},
"prettier": {
"singleQuote": true,
"arrowParens": "avoid",
"trailingComma": "es5"
},
"lint-staged": {
"*.{js,ts,json,md}": "prettier --write"
},
"keywords": [],
"license": "MIT",
"repository": "https://github.com/kitten/multitars",
"bugs": {
"url": "https://github.com/kitten/multitars/issues"
},
"devDependencies": {
"@babel/plugin-transform-typescript": "^7.28.5",
"@changesets/cli": "^2.29.7",
"@changesets/get-github-info": "^0.6.0",
"@fastify/busboy": "^3.2.0",
"@remix-run/tar-parser": "^0.7.0",
"@rollup/plugin-babel": "^6.1.0",
"@rollup/plugin-commonjs": "^29.0.0",
"@rollup/plugin-node-resolve": "^16.0.3",
"@rollup/plugin-terser": "^0.4.4",
"@types/tar-stream": "^3.1.4",
"dotenv": "^17.2.3",
"lint-staged": "^16.2.6",
"modern-tar": "^0.7.2",
"npm-run-all": "^4.1.5",
"prettier": "^3.6.2",
"rimraf": "^6.1.0",
"rollup": "^4.53.3",
"rollup-plugin-cjs-check": "^1.0.3",
"rollup-plugin-dts": "^6.2.3",
"tar": "^7.5.2",
"tar-stream": "^3.1.7",
"typescript": "^5.9.3",
"vitest": "^4.0.10"
},
"publishConfig": {
"access": "public",
"provenance": true
},
"scripts": {
"test": "vitest test",
"test:run": "vitest test --run",
"prebench": "pnpm run build",
"bench": "vitest bench",
"build": "rollup -c ./scripts/rollup.config.mjs",
"postbuild": "tsc --lib esnext,dom,dom.iterable --target esnext --module nodenext --moduleResolution nodenext --noEmit ./dist/multitars.d.ts",
"check": "tsc --noEmit",
"clean": "rimraf dist node_modules/.cache",
"changeset:version": "changeset version && pnpm install --lockfile-only",
"changeset:publish": "changeset publish"
}
}