Github actions require checking in the entire node_modules or using a vercel service what the fuck github
This commit is contained in:
21
node_modules/mime/LICENSE
generated
vendored
Normal file
21
node_modules/mime/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2023 Robert Kieffer
|
||||
|
||||
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.
|
||||
143
node_modules/mime/README.md
generated
vendored
Normal file
143
node_modules/mime/README.md
generated
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
<!--
|
||||
-- This file is auto-generated from src/README_js.md. Changes should be made there.
|
||||
-->
|
||||
# Mime
|
||||
|
||||
[](https://www.npmjs.com/package/mime)
|
||||
[](https://github.com/broofa/mime/actions/workflows/ci.yml?query=branch%3Amain)
|
||||
|
||||
An API for MIME type information.
|
||||
|
||||
- All `mime-db` types
|
||||
- Compact and dependency-free [](https://bundlejs.com/?q=mime)
|
||||
- Full TS support
|
||||
|
||||
|
||||
> [!Note]
|
||||
> `mime@4` is now `latest`. If you're upgrading from `mime@3`, note the following:
|
||||
> * `mime@4` is API-compatible with `mime@3`, with ~~one~~ two exceptions:
|
||||
> * Direct imports of `mime` properties [no longer supported](https://github.com/broofa/mime/issues/295)
|
||||
> * `mime.define()` cannot be called on the default `mime` object
|
||||
> * ESM module support is required. [ESM Module FAQ](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).
|
||||
> * Requires an [ES2020](https://caniuse.com/?search=es2020) or newer runtime
|
||||
> * Built-in Typescript types (`@types/mime` no longer needed)
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm install mime
|
||||
```
|
||||
|
||||
## Quick Start
|
||||
|
||||
For the full version (800+ MIME types, 1,000+ extensions):
|
||||
|
||||
```javascript
|
||||
import mime from 'mime';
|
||||
|
||||
mime.getType('txt'); // ⇨ 'text/plain'
|
||||
mime.getExtension('text/plain'); // ⇨ 'txt'
|
||||
```
|
||||
|
||||
### Lite Version [](https://bundlejs.com/?q=mime/lite)
|
||||
|
||||
`mime/lite` is a drop-in `mime` replacement, stripped of unofficial ("`prs.*`", "`x-*`", "`vnd.*`") types:
|
||||
|
||||
```javascript
|
||||
import mime from 'mime/lite';
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### `mime.getType(pathOrExtension)`
|
||||
|
||||
Get mime type for the given file path or extension. E.g.
|
||||
|
||||
```javascript
|
||||
mime.getType('js'); // ⇨ 'application/javascript'
|
||||
mime.getType('json'); // ⇨ 'application/json'
|
||||
|
||||
mime.getType('txt'); // ⇨ 'text/plain'
|
||||
mime.getType('dir/text.txt'); // ⇨ 'text/plain'
|
||||
mime.getType('dir\\text.txt'); // ⇨ 'text/plain'
|
||||
mime.getType('.text.txt'); // ⇨ 'text/plain'
|
||||
mime.getType('.txt'); // ⇨ 'text/plain'
|
||||
```
|
||||
|
||||
`null` is returned in cases where an extension is not detected or recognized
|
||||
|
||||
```javascript
|
||||
mime.getType('foo/txt'); // ⇨ null
|
||||
mime.getType('bogus_type'); // ⇨ null
|
||||
```
|
||||
|
||||
### `mime.getExtension(type)`
|
||||
|
||||
Get file extension for the given mime type. Charset options (often included in Content-Type headers) are ignored.
|
||||
|
||||
```javascript
|
||||
mime.getExtension('text/plain'); // ⇨ 'txt'
|
||||
mime.getExtension('application/json'); // ⇨ 'json'
|
||||
mime.getExtension('text/html; charset=utf8'); // ⇨ 'html'
|
||||
```
|
||||
|
||||
### `mime.getAllExtensions(type)`
|
||||
|
||||
> [!Note]
|
||||
> New in `mime@4`
|
||||
|
||||
Get all file extensions for the given mime type.
|
||||
|
||||
```javascript --run default
|
||||
mime.getAllExtensions('image/jpeg'); // ⇨ Set(3) { 'jpeg', 'jpg', 'jpe' }
|
||||
```
|
||||
|
||||
## Custom `Mime` instances
|
||||
|
||||
The default `mime` objects are immutable. Custom, mutable versions can be created as follows...
|
||||
### new Mime(type map [, type map, ...])
|
||||
|
||||
Create a new, custom mime instance. For example, to create a mutable version of the default `mime` instance:
|
||||
|
||||
```javascript
|
||||
import { Mime } from 'mime/lite';
|
||||
|
||||
import standardTypes from 'mime/types/standard.js';
|
||||
import otherTypes from 'mime/types/other.js';
|
||||
|
||||
const mime = new Mime(standardTypes, otherTypes);
|
||||
```
|
||||
|
||||
Each argument is passed to the `define()` method, below. For example `new Mime(standardTypes, otherTypes)` is synonomous with `new Mime().define(standardTypes).define(otherTypes)`
|
||||
|
||||
### `mime.define(type map [, force = false])`
|
||||
|
||||
> [!Note]
|
||||
> Only available on custom `Mime` instances
|
||||
|
||||
Define MIME type -> extensions.
|
||||
|
||||
Attempting to map a type to an already-defined extension will `throw` unless the `force` argument is set to `true`.
|
||||
|
||||
```javascript
|
||||
mime.define({'text/x-abc': ['abc', 'abcd']});
|
||||
|
||||
mime.getType('abcd'); // ⇨ 'text/x-abc'
|
||||
mime.getExtension('text/x-abc') // ⇨ 'abc'
|
||||
```
|
||||
|
||||
## Command Line
|
||||
|
||||
### Extension -> type
|
||||
|
||||
```bash
|
||||
$ mime scripts/jquery.js
|
||||
application/javascript
|
||||
```
|
||||
|
||||
### Type -> extension
|
||||
|
||||
```bash
|
||||
$ mime -r image/jpeg
|
||||
jpeg
|
||||
```
|
||||
6
node_modules/mime/bin/cli.js
generated
vendored
Executable file
6
node_modules/mime/bin/cli.js
generated
vendored
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
// Thin wrapper around mime
|
||||
import mime_cli from '../dist/src/mime_cli.js';
|
||||
|
||||
await mime_cli();
|
||||
17
node_modules/mime/dist/src/Mime.d.ts
generated
vendored
Normal file
17
node_modules/mime/dist/src/Mime.d.ts
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
type TypeMap = {
|
||||
[key: string]: string[];
|
||||
};
|
||||
export default class Mime {
|
||||
#private;
|
||||
constructor(...args: TypeMap[]);
|
||||
define(typeMap: TypeMap, force?: boolean): this;
|
||||
getType(path: string): string | null;
|
||||
getExtension(type: string): string | null;
|
||||
getAllExtensions(type: string): Set<string> | null;
|
||||
_freeze(): this;
|
||||
_getTestState(): {
|
||||
types: Map<string, string>;
|
||||
extensions: Map<string, string>;
|
||||
};
|
||||
}
|
||||
export {};
|
||||
85
node_modules/mime/dist/src/Mime.js
generated
vendored
Normal file
85
node_modules/mime/dist/src/Mime.js
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
||||
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
||||
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
||||
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
||||
};
|
||||
var _Mime_extensionToType, _Mime_typeToExtension, _Mime_typeToExtensions;
|
||||
class Mime {
|
||||
constructor(...args) {
|
||||
_Mime_extensionToType.set(this, new Map());
|
||||
_Mime_typeToExtension.set(this, new Map());
|
||||
_Mime_typeToExtensions.set(this, new Map());
|
||||
for (const arg of args) {
|
||||
this.define(arg);
|
||||
}
|
||||
}
|
||||
define(typeMap, force = false) {
|
||||
for (let [type, extensions] of Object.entries(typeMap)) {
|
||||
type = type.toLowerCase();
|
||||
extensions = extensions.map((ext) => ext.toLowerCase());
|
||||
if (!__classPrivateFieldGet(this, _Mime_typeToExtensions, "f").has(type)) {
|
||||
__classPrivateFieldGet(this, _Mime_typeToExtensions, "f").set(type, new Set());
|
||||
}
|
||||
const allExtensions = __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type);
|
||||
let first = true;
|
||||
for (let extension of extensions) {
|
||||
const starred = extension.startsWith('*');
|
||||
extension = starred ? extension.slice(1) : extension;
|
||||
allExtensions?.add(extension);
|
||||
if (first) {
|
||||
__classPrivateFieldGet(this, _Mime_typeToExtension, "f").set(type, extension);
|
||||
}
|
||||
first = false;
|
||||
if (starred)
|
||||
continue;
|
||||
const currentType = __classPrivateFieldGet(this, _Mime_extensionToType, "f").get(extension);
|
||||
if (currentType && currentType != type && !force) {
|
||||
throw new Error(`"${type} -> ${extension}" conflicts with "${currentType} -> ${extension}". Pass \`force=true\` to override this definition.`);
|
||||
}
|
||||
__classPrivateFieldGet(this, _Mime_extensionToType, "f").set(extension, type);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
getType(path) {
|
||||
if (typeof path !== 'string')
|
||||
return null;
|
||||
const last = path.replace(/^.*[/\\]/, '').toLowerCase();
|
||||
const ext = last.replace(/^.*\./, '').toLowerCase();
|
||||
const hasPath = last.length < path.length;
|
||||
const hasDot = ext.length < last.length - 1;
|
||||
if (!hasDot && hasPath)
|
||||
return null;
|
||||
return __classPrivateFieldGet(this, _Mime_extensionToType, "f").get(ext) ?? null;
|
||||
}
|
||||
getExtension(type) {
|
||||
if (typeof type !== 'string')
|
||||
return null;
|
||||
type = type?.split?.(';')[0];
|
||||
return ((type && __classPrivateFieldGet(this, _Mime_typeToExtension, "f").get(type.trim().toLowerCase())) ?? null);
|
||||
}
|
||||
getAllExtensions(type) {
|
||||
if (typeof type !== 'string')
|
||||
return null;
|
||||
return __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type.toLowerCase()) ?? null;
|
||||
}
|
||||
_freeze() {
|
||||
this.define = () => {
|
||||
throw new Error('define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances');
|
||||
};
|
||||
Object.freeze(this);
|
||||
for (const extensions of __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").values()) {
|
||||
Object.freeze(extensions);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
_getTestState() {
|
||||
return {
|
||||
types: __classPrivateFieldGet(this, _Mime_extensionToType, "f"),
|
||||
extensions: __classPrivateFieldGet(this, _Mime_typeToExtension, "f"),
|
||||
};
|
||||
}
|
||||
}
|
||||
_Mime_extensionToType = new WeakMap(), _Mime_typeToExtension = new WeakMap(), _Mime_typeToExtensions = new WeakMap();
|
||||
export default Mime;
|
||||
//# sourceMappingURL=Mime.js.map
|
||||
1
node_modules/mime/dist/src/Mime.js.map
generated
vendored
Normal file
1
node_modules/mime/dist/src/Mime.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Mime.js","sourceRoot":"","sources":["../../src/Mime.ts"],"names":[],"mappings":";;;;;;AAEA,MAAqB,IAAI;IAKvB,YAAY,GAAG,IAAe;QAJ9B,gCAAmB,IAAI,GAAG,EAAkB,EAAC;QAC7C,gCAAmB,IAAI,GAAG,EAAkB,EAAC;QAC7C,iCAAoB,IAAI,GAAG,EAAuB,EAAC;QAGjD,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACtB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;SAClB;IACH,CAAC;IAcD,MAAM,CAAC,OAAgB,EAAE,KAAK,GAAG,KAAK;QACpC,KAAK,IAAI,CAAC,IAAI,EAAE,UAAU,C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D,OAAO;QACL,IAAI,CAAC,MAAM,GAAG,GAAG,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,8HAA8H,CAAC,CAAC;QAClJ,CAAC,CAAC;QAEF,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAEpB,KAAK,MAAM,UAAU,IAAI,uBAAA,IAAI,8BAAkB,CAAC,MAAM,EAAE,EAAE;YACxD,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;SAC3B;QAED,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa;QACX,OAAO;YACL,KAAK,EAAE,uBAAA,IAAI,6BAAiB;YAC5B,UAAU,EAAE,uBAAA,IAAI,6BAAiB;SAClC,CAAC;IACJ,CAAC;CACF;;eAtIoB,IAAI"}
|
||||
4
node_modules/mime/dist/src/index.d.ts
generated
vendored
Normal file
4
node_modules/mime/dist/src/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import Mime from './Mime.js';
|
||||
export { default as Mime } from './Mime.js';
|
||||
declare const _default: Mime;
|
||||
export default _default;
|
||||
6
node_modules/mime/dist/src/index.js
generated
vendored
Normal file
6
node_modules/mime/dist/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import otherTypes from '../types/other.js';
|
||||
import standardTypes from '../types/standard.js';
|
||||
import Mime from './Mime.js';
|
||||
export { default as Mime } from './Mime.js';
|
||||
export default new Mime(standardTypes, otherTypes)._freeze();
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/mime/dist/src/index.js.map
generated
vendored
Normal file
1
node_modules/mime/dist/src/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,mBAAmB,CAAC;AAC3C,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAE5C,eAAe,IAAI,IAAI,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC"}
|
||||
4
node_modules/mime/dist/src/index_lite.d.ts
generated
vendored
Normal file
4
node_modules/mime/dist/src/index_lite.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import Mime from './Mime.js';
|
||||
export { default as Mime } from './Mime.js';
|
||||
declare const _default: Mime;
|
||||
export default _default;
|
||||
5
node_modules/mime/dist/src/index_lite.js
generated
vendored
Normal file
5
node_modules/mime/dist/src/index_lite.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import standardTypes from '../types/standard.js';
|
||||
import Mime from './Mime.js';
|
||||
export { default as Mime } from './Mime.js';
|
||||
export default new Mime(standardTypes)._freeze();
|
||||
//# sourceMappingURL=index_lite.js.map
|
||||
1
node_modules/mime/dist/src/index_lite.js.map
generated
vendored
Normal file
1
node_modules/mime/dist/src/index_lite.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index_lite.js","sourceRoot":"","sources":["../../src/index_lite.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAE5C,eAAe,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,CAAC"}
|
||||
2
node_modules/mime/dist/src/mime_cli.d.ts
generated
vendored
Normal file
2
node_modules/mime/dist/src/mime_cli.d.ts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env node
|
||||
export default function (): Promise<void>;
|
||||
67
node_modules/mime/dist/src/mime_cli.js
generated
vendored
Normal file
67
node_modules/mime/dist/src/mime_cli.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env node
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import mime from './index.js';
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
export default async function () {
|
||||
process.title = 'mime';
|
||||
const json = await fs.readFile(path.join(__dirname, '../../package.json'), 'utf-8');
|
||||
const pkg = JSON.parse(json);
|
||||
const args = process.argv.splice(2);
|
||||
if (args.includes('--version') ||
|
||||
args.includes('-v') ||
|
||||
args.includes('--v')) {
|
||||
console.log(pkg.version);
|
||||
process.exit(0);
|
||||
}
|
||||
else if (args.includes('--name') ||
|
||||
args.includes('-n') ||
|
||||
args.includes('--n')) {
|
||||
console.log(pkg.name);
|
||||
process.exit(0);
|
||||
}
|
||||
else if (args.includes('--help') ||
|
||||
args.includes('-h') ||
|
||||
args.includes('--h')) {
|
||||
console.log(pkg.name + ' - ' + pkg.description + '\n');
|
||||
console.log(`Usage:
|
||||
|
||||
mime [flags] [path_or_extension]
|
||||
|
||||
Flags:
|
||||
--help, -h Show this message
|
||||
--version, -v Display the version
|
||||
--name, -n Print the name of the program
|
||||
--reverse, -r Print the extension of the mime type
|
||||
|
||||
Note: the command will exit after it executes if a command is specified
|
||||
The path_or_extension is the path to the file or the extension of the file.
|
||||
|
||||
Examples:
|
||||
mime --help
|
||||
mime --version
|
||||
mime --name
|
||||
mime -v
|
||||
mime --reverse application/text
|
||||
mime src/log.js
|
||||
mime new.py
|
||||
mime foo.sh
|
||||
`);
|
||||
process.exit(0);
|
||||
}
|
||||
else if (args.includes('--reverse') || args.includes('-r')) {
|
||||
const mimeType = args[args.length - 1];
|
||||
const extension = mime.getExtension(mimeType);
|
||||
if (!extension)
|
||||
process.exit(1);
|
||||
process.stdout.write(extension + '\n');
|
||||
process.exit(0);
|
||||
}
|
||||
const file = args[0];
|
||||
const type = mime.getType(file);
|
||||
if (!type)
|
||||
process.exit(1);
|
||||
process.stdout.write(type + '\n');
|
||||
}
|
||||
//# sourceMappingURL=mime_cli.js.map
|
||||
1
node_modules/mime/dist/src/mime_cli.js.map
generated
vendored
Normal file
1
node_modules/mime/dist/src/mime_cli.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"mime_cli.js","sourceRoot":"","sources":["../../src/mime_cli.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,IAAI,MAAM,YAAY,CAAC;AAE9B,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAE/D,MAAM,CAAC,OAAO,CAAC,KAAK;IAClB,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC;IAMvB,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC,QAAQ,CAC5B,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,EAC1C,OAAO,CACR,CAAC;IACF,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE7B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAEpC,IACE,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC;QAC1B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QACnB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EACpB;QACA,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;KACjB;SAAM,IACL,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACvB,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;QACnB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EACpB;QACA,OAAO,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.d.ts
generated
vendored
Normal file
4
node_modules/mime/dist/types/other.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
declare const types: {
|
||||
[key: string]: string[];
|
||||
};
|
||||
export default types;
|
||||
4
node_modules/mime/dist/types/other.js
generated
vendored
Normal file
4
node_modules/mime/dist/types/other.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/mime/dist/types/other.js.map
generated
vendored
Normal file
1
node_modules/mime/dist/types/other.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
4
node_modules/mime/dist/types/standard.d.ts
generated
vendored
Normal file
4
node_modules/mime/dist/types/standard.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
declare const types: {
|
||||
[key: string]: string[];
|
||||
};
|
||||
export default types;
|
||||
4
node_modules/mime/dist/types/standard.js
generated
vendored
Normal file
4
node_modules/mime/dist/types/standard.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
1
node_modules/mime/dist/types/standard.js.map
generated
vendored
Normal file
1
node_modules/mime/dist/types/standard.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
75
node_modules/mime/package.json
generated
vendored
Normal file
75
node_modules/mime/package.json
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"author": {
|
||||
"name": "Robert Kieffer",
|
||||
"url": "http://github.com/broofa",
|
||||
"email": "robert@broofa.com"
|
||||
},
|
||||
"type": "module",
|
||||
"engines": {
|
||||
"node": ">=16"
|
||||
},
|
||||
"main": "./dist/src/index.js",
|
||||
"exports": {
|
||||
".": "./dist/src/index.js",
|
||||
"./lite": "./dist/src/index_lite.js",
|
||||
"./types/standard.js": "./dist/types/standard.js",
|
||||
"./types/other.js": "./dist/types/other.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
"bin",
|
||||
"dist/src",
|
||||
"dist/types",
|
||||
"src",
|
||||
"types"
|
||||
],
|
||||
"bin": {
|
||||
"mime": "bin/cli.js"
|
||||
},
|
||||
"contributors": [],
|
||||
"description": "A comprehensive library for mime-type mapping",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/mime-db": "1.*",
|
||||
"@types/mime-types": "2.1.1",
|
||||
"@types/node": "20.5.9",
|
||||
"@typescript-eslint/eslint-plugin": "6.6.0",
|
||||
"@typescript-eslint/parser": "6.6.0",
|
||||
"chalk": "5.3.0",
|
||||
"mime-score": "2.0.4",
|
||||
"mime-types": "2.1.35",
|
||||
"prettier": "3.0.3",
|
||||
"runmd": "1.3.9",
|
||||
"standard-version": "9.5.0",
|
||||
"typescript": "5.2.2"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "npm run build:clean && tsc",
|
||||
"build:clean": "rm -fr dist",
|
||||
"build:types": "node dist/scripts/build.js",
|
||||
"build:watch": "npm run build:clean && tsc --watch",
|
||||
"lint": "prettier -c .",
|
||||
"lint:fix": "prettier -w .",
|
||||
"prepublishOnly": "npm run build && npm run build:types && npm test",
|
||||
"release": "# `standard-version --dry-run --prerelease` is the command you're after",
|
||||
"test": "node --test && ./test/exports_test.sh",
|
||||
"test:watch": "clear && node --enable-source-maps --test --watch test"
|
||||
},
|
||||
"keywords": [
|
||||
"extension",
|
||||
"file",
|
||||
"mime",
|
||||
"mime-db",
|
||||
"mimetypes",
|
||||
"util"
|
||||
],
|
||||
"name": "mime",
|
||||
"repository": {
|
||||
"url": "https://github.com/broofa/mime",
|
||||
"type": "git"
|
||||
},
|
||||
"version": "4.0.3",
|
||||
"funding": [
|
||||
"https://github.com/sponsors/broofa"
|
||||
]
|
||||
}
|
||||
137
node_modules/mime/src/Mime.ts
generated
vendored
Normal file
137
node_modules/mime/src/Mime.ts
generated
vendored
Normal file
@@ -0,0 +1,137 @@
|
||||
type TypeMap = { [key: string]: string[] };
|
||||
|
||||
export default class Mime {
|
||||
#extensionToType = new Map<string, string>();
|
||||
#typeToExtension = new Map<string, string>();
|
||||
#typeToExtensions = new Map<string, Set<string>>();
|
||||
|
||||
constructor(...args: TypeMap[]) {
|
||||
for (const arg of args) {
|
||||
this.define(arg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Define mimetype -> extension mappings. Each key is a mime-type that maps
|
||||
* to an array of extensions associated with the type. The first extension is
|
||||
* used as the default extension for the type.
|
||||
*
|
||||
* e.g. mime.define({'audio/ogg', ['oga', 'ogg', 'spx']});
|
||||
*
|
||||
* If a mapping for an extension has already been defined an error will be
|
||||
* thrown unless the `force` argument is set to `true`.
|
||||
*
|
||||
* e.g. mime.define({'audio/wav', ['wav']}, {'audio/x-wav', ['*wav']});
|
||||
*/
|
||||
define(typeMap: TypeMap, force = false) {
|
||||
for (let [type, extensions] of Object.entries(typeMap)) {
|
||||
// Lowercase thingz
|
||||
type = type.toLowerCase();
|
||||
extensions = extensions.map((ext) => ext.toLowerCase());
|
||||
|
||||
if (!this.#typeToExtensions.has(type)) {
|
||||
this.#typeToExtensions.set(type, new Set<string>());
|
||||
}
|
||||
const allExtensions = this.#typeToExtensions.get(type);
|
||||
|
||||
let first = true;
|
||||
for (let extension of extensions) {
|
||||
const starred = extension.startsWith('*');
|
||||
|
||||
extension = starred ? extension.slice(1) : extension;
|
||||
|
||||
// Add to list of extensions for the type
|
||||
allExtensions?.add(extension);
|
||||
|
||||
if (first) {
|
||||
// Map type to default extension (first in list)
|
||||
this.#typeToExtension.set(type, extension);
|
||||
}
|
||||
first = false;
|
||||
|
||||
// Starred types are not eligible to be the default extension
|
||||
if (starred) continue;
|
||||
|
||||
// Map extension to type
|
||||
const currentType = this.#extensionToType.get(extension);
|
||||
if (currentType && currentType != type && !force) {
|
||||
throw new Error(
|
||||
`"${type} -> ${extension}" conflicts with "${currentType} -> ${extension}". Pass \`force=true\` to override this definition.`,
|
||||
);
|
||||
}
|
||||
this.#extensionToType.set(extension, type);
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get mime type associated with an extension
|
||||
*/
|
||||
getType(path: string) {
|
||||
if (typeof path !== 'string') return null;
|
||||
|
||||
// Remove chars preceeding `/` or `\`
|
||||
const last = path.replace(/^.*[/\\]/, '').toLowerCase();
|
||||
|
||||
// Remove chars preceeding '.'
|
||||
const ext = last.replace(/^.*\./, '').toLowerCase();
|
||||
|
||||
const hasPath = last.length < path.length;
|
||||
const hasDot = ext.length < last.length - 1;
|
||||
|
||||
// Extension-less file?
|
||||
if (!hasDot && hasPath) return null;
|
||||
|
||||
return this.#extensionToType.get(ext) ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default file extension associated with a mime type
|
||||
*/
|
||||
getExtension(type: string) {
|
||||
if (typeof type !== 'string') return null;
|
||||
|
||||
// Remove http header parameter(s) (specifically, charset)
|
||||
type = type?.split?.(';')[0];
|
||||
|
||||
return (
|
||||
(type && this.#typeToExtension.get(type.trim().toLowerCase())) ?? null
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all file extensions associated with a mime type
|
||||
*/
|
||||
getAllExtensions(type: string) {
|
||||
if (typeof type !== 'string') return null;
|
||||
|
||||
return this.#typeToExtensions.get(type.toLowerCase()) ?? null;
|
||||
}
|
||||
|
||||
//
|
||||
// Private API, for internal use only. These APIs may change at any time
|
||||
//
|
||||
|
||||
_freeze() {
|
||||
this.define = () => {
|
||||
throw new Error('define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances');
|
||||
};
|
||||
|
||||
Object.freeze(this);
|
||||
|
||||
for (const extensions of this.#typeToExtensions.values()) {
|
||||
Object.freeze(extensions);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
_getTestState() {
|
||||
return {
|
||||
types: this.#extensionToType,
|
||||
extensions: this.#typeToExtension,
|
||||
};
|
||||
}
|
||||
}
|
||||
7
node_modules/mime/src/index.ts
generated
vendored
Normal file
7
node_modules/mime/src/index.ts
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
import otherTypes from '../types/other.js';
|
||||
import standardTypes from '../types/standard.js';
|
||||
import Mime from './Mime.js';
|
||||
|
||||
export { default as Mime } from './Mime.js';
|
||||
|
||||
export default new Mime(standardTypes, otherTypes)._freeze();
|
||||
6
node_modules/mime/src/index_lite.ts
generated
vendored
Normal file
6
node_modules/mime/src/index_lite.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import standardTypes from '../types/standard.js';
|
||||
import Mime from './Mime.js';
|
||||
|
||||
export { default as Mime } from './Mime.js';
|
||||
|
||||
export default new Mime(standardTypes)._freeze();
|
||||
85
node_modules/mime/src/mime_cli.ts
generated
vendored
Executable file
85
node_modules/mime/src/mime_cli.ts
generated
vendored
Executable file
@@ -0,0 +1,85 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import mime from './index.js';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
|
||||
export default async function () {
|
||||
process.title = 'mime';
|
||||
|
||||
// TODO: Use json imports to access package.json once "import attributes" are
|
||||
// a real, stable thing.
|
||||
//
|
||||
// See https://github.com/tc39/proposal-import-attributes
|
||||
const json = await fs.readFile(
|
||||
path.join(__dirname, '../../package.json'),
|
||||
'utf-8',
|
||||
);
|
||||
const pkg = JSON.parse(json);
|
||||
|
||||
const args = process.argv.splice(2);
|
||||
|
||||
if (
|
||||
args.includes('--version') ||
|
||||
args.includes('-v') ||
|
||||
args.includes('--v')
|
||||
) {
|
||||
console.log(pkg.version);
|
||||
process.exit(0);
|
||||
} else if (
|
||||
args.includes('--name') ||
|
||||
args.includes('-n') ||
|
||||
args.includes('--n')
|
||||
) {
|
||||
console.log(pkg.name);
|
||||
process.exit(0);
|
||||
} else if (
|
||||
args.includes('--help') ||
|
||||
args.includes('-h') ||
|
||||
args.includes('--h')
|
||||
) {
|
||||
console.log(pkg.name + ' - ' + pkg.description + '\n');
|
||||
console.log(`Usage:
|
||||
|
||||
mime [flags] [path_or_extension]
|
||||
|
||||
Flags:
|
||||
--help, -h Show this message
|
||||
--version, -v Display the version
|
||||
--name, -n Print the name of the program
|
||||
--reverse, -r Print the extension of the mime type
|
||||
|
||||
Note: the command will exit after it executes if a command is specified
|
||||
The path_or_extension is the path to the file or the extension of the file.
|
||||
|
||||
Examples:
|
||||
mime --help
|
||||
mime --version
|
||||
mime --name
|
||||
mime -v
|
||||
mime --reverse application/text
|
||||
mime src/log.js
|
||||
mime new.py
|
||||
mime foo.sh
|
||||
`);
|
||||
process.exit(0);
|
||||
} else if (args.includes('--reverse') || args.includes('-r')) {
|
||||
const mimeType = args[args.length - 1];
|
||||
const extension = mime.getExtension(mimeType);
|
||||
|
||||
if (!extension) process.exit(1);
|
||||
|
||||
process.stdout.write(extension + '\n');
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const file = args[0];
|
||||
const type = mime.getType(file);
|
||||
|
||||
if (!type) process.exit(1);
|
||||
|
||||
process.stdout.write(type + '\n');
|
||||
}
|
||||
3
node_modules/mime/types/other.ts
generated
vendored
Normal file
3
node_modules/mime/types/other.ts
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3
node_modules/mime/types/standard.ts
generated
vendored
Normal file
3
node_modules/mime/types/standard.ts
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user