整理成开源版本
This commit is contained in:
parent
e40e28d9e4
commit
da8892bf08
@ -1,3 +0,0 @@
|
|||||||
<script src="./node_modules/@ffmpeg/ffmpeg/dist/umd/ffmpeg.js"></script>
|
|
||||||
<script>
|
|
||||||
</script>
|
|
1
node_modules/.bin/esbuild
generated
vendored
1
node_modules/.bin/esbuild
generated
vendored
@ -1 +0,0 @@
|
|||||||
../esbuild/bin/esbuild
|
|
1
node_modules/.bin/nanoid
generated
vendored
1
node_modules/.bin/nanoid
generated
vendored
@ -1 +0,0 @@
|
|||||||
../nanoid/bin/nanoid.cjs
|
|
1
node_modules/.bin/rollup
generated
vendored
1
node_modules/.bin/rollup
generated
vendored
@ -1 +0,0 @@
|
|||||||
../rollup/dist/bin/rollup
|
|
1
node_modules/.bin/vite
generated
vendored
1
node_modules/.bin/vite
generated
vendored
@ -1 +0,0 @@
|
|||||||
../vite/bin/vite.js
|
|
69
node_modules/.yarn-integrity
generated
vendored
69
node_modules/.yarn-integrity
generated
vendored
@ -1,69 +0,0 @@
|
|||||||
{
|
|
||||||
"systemParams": "darwin-arm64-108",
|
|
||||||
"modulesFolders": [
|
|
||||||
"node_modules"
|
|
||||||
],
|
|
||||||
"flags": [],
|
|
||||||
"linkedModules": [],
|
|
||||||
"topLevelPatterns": [
|
|
||||||
"@ffmpeg/ffmpeg@^0.12.10",
|
|
||||||
"@ffmpeg/util@^0.12.1",
|
|
||||||
"vite@^5.4.8"
|
|
||||||
],
|
|
||||||
"lockfileEntries": {
|
|
||||||
"@esbuild/aix-ppc64@0.21.5": "https://registry.yarnpkg.com/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz#c7184a326533fcdf1b8ee0733e21c713b975575f",
|
|
||||||
"@esbuild/android-arm64@0.21.5": "https://registry.yarnpkg.com/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz#09d9b4357780da9ea3a7dfb833a1f1ff439b4052",
|
|
||||||
"@esbuild/android-arm@0.21.5": "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.21.5.tgz#9b04384fb771926dfa6d7ad04324ecb2ab9b2e28",
|
|
||||||
"@esbuild/android-x64@0.21.5": "https://registry.yarnpkg.com/@esbuild/android-x64/-/android-x64-0.21.5.tgz#29918ec2db754cedcb6c1b04de8cd6547af6461e",
|
|
||||||
"@esbuild/darwin-arm64@0.21.5": "https://registry.yarnpkg.com/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz#e495b539660e51690f3928af50a76fb0a6ccff2a",
|
|
||||||
"@esbuild/darwin-x64@0.21.5": "https://registry.yarnpkg.com/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz#c13838fa57372839abdddc91d71542ceea2e1e22",
|
|
||||||
"@esbuild/freebsd-arm64@0.21.5": "https://registry.yarnpkg.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz#646b989aa20bf89fd071dd5dbfad69a3542e550e",
|
|
||||||
"@esbuild/freebsd-x64@0.21.5": "https://registry.yarnpkg.com/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz#aa615cfc80af954d3458906e38ca22c18cf5c261",
|
|
||||||
"@esbuild/linux-arm64@0.21.5": "https://registry.yarnpkg.com/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz#70ac6fa14f5cb7e1f7f887bcffb680ad09922b5b",
|
|
||||||
"@esbuild/linux-arm@0.21.5": "https://registry.yarnpkg.com/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz#fc6fd11a8aca56c1f6f3894f2bea0479f8f626b9",
|
|
||||||
"@esbuild/linux-ia32@0.21.5": "https://registry.yarnpkg.com/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz#3271f53b3f93e3d093d518d1649d6d68d346ede2",
|
|
||||||
"@esbuild/linux-loong64@0.21.5": "https://registry.yarnpkg.com/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz#ed62e04238c57026aea831c5a130b73c0f9f26df",
|
|
||||||
"@esbuild/linux-mips64el@0.21.5": "https://registry.yarnpkg.com/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz#e79b8eb48bf3b106fadec1ac8240fb97b4e64cbe",
|
|
||||||
"@esbuild/linux-ppc64@0.21.5": "https://registry.yarnpkg.com/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz#5f2203860a143b9919d383ef7573521fb154c3e4",
|
|
||||||
"@esbuild/linux-riscv64@0.21.5": "https://registry.yarnpkg.com/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz#07bcafd99322d5af62f618cb9e6a9b7f4bb825dc",
|
|
||||||
"@esbuild/linux-s390x@0.21.5": "https://registry.yarnpkg.com/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz#b7ccf686751d6a3e44b8627ababc8be3ef62d8de",
|
|
||||||
"@esbuild/linux-x64@0.21.5": "https://registry.yarnpkg.com/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz#6d8f0c768e070e64309af8004bb94e68ab2bb3b0",
|
|
||||||
"@esbuild/netbsd-x64@0.21.5": "https://registry.yarnpkg.com/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz#bbe430f60d378ecb88decb219c602667387a6047",
|
|
||||||
"@esbuild/openbsd-x64@0.21.5": "https://registry.yarnpkg.com/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz#99d1cf2937279560d2104821f5ccce220cb2af70",
|
|
||||||
"@esbuild/sunos-x64@0.21.5": "https://registry.yarnpkg.com/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz#08741512c10d529566baba837b4fe052c8f3487b",
|
|
||||||
"@esbuild/win32-arm64@0.21.5": "https://registry.yarnpkg.com/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz#675b7385398411240735016144ab2e99a60fc75d",
|
|
||||||
"@esbuild/win32-ia32@0.21.5": "https://registry.yarnpkg.com/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz#1bfc3ce98aa6ca9a0969e4d2af72144c59c1193b",
|
|
||||||
"@esbuild/win32-x64@0.21.5": "https://registry.yarnpkg.com/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz#acad351d582d157bb145535db2a6ff53dd514b5c",
|
|
||||||
"@ffmpeg/ffmpeg@^0.12.10": "https://registry.yarnpkg.com/@ffmpeg/ffmpeg/-/ffmpeg-0.12.10.tgz#e3cce21f21f11f33dfc1ec1d5ad5694f4a3073c9",
|
|
||||||
"@ffmpeg/types@^0.12.2": "https://registry.yarnpkg.com/@ffmpeg/types/-/types-0.12.2.tgz#bc7eef321ae50225c247091f1f23fd3087c6aa1d",
|
|
||||||
"@ffmpeg/util@^0.12.1": "https://registry.yarnpkg.com/@ffmpeg/util/-/util-0.12.1.tgz#98afa20d7b4c0821eebdb205ddcfa5d07b0a4f53",
|
|
||||||
"@rollup/rollup-android-arm-eabi@4.24.0": "https://registry.yarnpkg.com/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.24.0.tgz#1661ff5ea9beb362795304cb916049aba7ac9c54",
|
|
||||||
"@rollup/rollup-android-arm64@4.24.0": "https://registry.yarnpkg.com/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.24.0.tgz#2ffaa91f1b55a0082b8a722525741aadcbd3971e",
|
|
||||||
"@rollup/rollup-darwin-arm64@4.24.0": "https://registry.yarnpkg.com/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.24.0.tgz#627007221b24b8cc3063703eee0b9177edf49c1f",
|
|
||||||
"@rollup/rollup-darwin-x64@4.24.0": "https://registry.yarnpkg.com/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.24.0.tgz#0605506142b9e796c370d59c5984ae95b9758724",
|
|
||||||
"@rollup/rollup-linux-arm-gnueabihf@4.24.0": "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.24.0.tgz#62dfd196d4b10c0c2db833897164d2d319ee0cbb",
|
|
||||||
"@rollup/rollup-linux-arm-musleabihf@4.24.0": "https://registry.yarnpkg.com/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.24.0.tgz#53ce72aeb982f1f34b58b380baafaf6a240fddb3",
|
|
||||||
"@rollup/rollup-linux-arm64-gnu@4.24.0": "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.24.0.tgz#1632990f62a75c74f43e4b14ab3597d7ed416496",
|
|
||||||
"@rollup/rollup-linux-arm64-musl@4.24.0": "https://registry.yarnpkg.com/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.24.0.tgz#8c03a996efb41e257b414b2e0560b7a21f2d9065",
|
|
||||||
"@rollup/rollup-linux-powerpc64le-gnu@4.24.0": "https://registry.yarnpkg.com/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.24.0.tgz#5b98729628d5bcc8f7f37b58b04d6845f85c7b5d",
|
|
||||||
"@rollup/rollup-linux-riscv64-gnu@4.24.0": "https://registry.yarnpkg.com/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.24.0.tgz#48e42e41f4cabf3573cfefcb448599c512e22983",
|
|
||||||
"@rollup/rollup-linux-s390x-gnu@4.24.0": "https://registry.yarnpkg.com/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.24.0.tgz#e0b4f9a966872cb7d3e21b9e412a4b7efd7f0b58",
|
|
||||||
"@rollup/rollup-linux-x64-gnu@4.24.0": "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.24.0.tgz#78144741993100f47bd3da72fce215e077ae036b",
|
|
||||||
"@rollup/rollup-linux-x64-musl@4.24.0": "https://registry.yarnpkg.com/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.24.0.tgz#d9fe32971883cd1bd858336bd33a1c3ca6146127",
|
|
||||||
"@rollup/rollup-win32-arm64-msvc@4.24.0": "https://registry.yarnpkg.com/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.24.0.tgz#71fa3ea369316db703a909c790743972e98afae5",
|
|
||||||
"@rollup/rollup-win32-ia32-msvc@4.24.0": "https://registry.yarnpkg.com/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.24.0.tgz#653f5989a60658e17d7576a3996deb3902e342e2",
|
|
||||||
"@rollup/rollup-win32-x64-msvc@4.24.0": "https://registry.yarnpkg.com/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.24.0.tgz#0574d7e87b44ee8511d08cc7f914bcb802b70818",
|
|
||||||
"@types/estree@1.0.6": "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.6.tgz#628effeeae2064a1b4e79f78e81d87b7e5fc7b50",
|
|
||||||
"esbuild@^0.21.3": "https://registry.yarnpkg.com/esbuild/-/esbuild-0.21.5.tgz#9ca301b120922959b766360d8ac830da0d02997d",
|
|
||||||
"fsevents@~2.3.2": "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6",
|
|
||||||
"fsevents@~2.3.3": "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6",
|
|
||||||
"nanoid@^3.3.7": "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.7.tgz#d0c301a691bc8d54efa0a2226ccf3fe2fd656bd8",
|
|
||||||
"picocolors@^1.1.0": "https://registry.yarnpkg.com/picocolors/-/picocolors-1.1.0.tgz#5358b76a78cde483ba5cef6a9dc9671440b27d59",
|
|
||||||
"postcss@^8.4.43": "https://registry.yarnpkg.com/postcss/-/postcss-8.4.47.tgz#5bf6c9a010f3e724c503bf03ef7947dcb0fea365",
|
|
||||||
"rollup@^4.20.0": "https://registry.yarnpkg.com/rollup/-/rollup-4.24.0.tgz#c14a3576f20622ea6a5c9cad7caca5e6e9555d05",
|
|
||||||
"source-map-js@^1.2.1": "https://registry.yarnpkg.com/source-map-js/-/source-map-js-1.2.1.tgz#1ce5650fddd87abc099eda37dcff024c2667ae46",
|
|
||||||
"vite@^5.4.8": "https://registry.yarnpkg.com/vite/-/vite-5.4.8.tgz#af548ce1c211b2785478d3ba3e8da51e39a287e8"
|
|
||||||
},
|
|
||||||
"files": [],
|
|
||||||
"artifacts": {}
|
|
||||||
}
|
|
3
node_modules/@esbuild/darwin-arm64/README.md
generated
vendored
3
node_modules/@esbuild/darwin-arm64/README.md
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
# esbuild
|
|
||||||
|
|
||||||
This is the macOS ARM 64-bit binary for esbuild, a JavaScript bundler and minifier. See https://github.com/evanw/esbuild for details.
|
|
BIN
node_modules/@esbuild/darwin-arm64/bin/esbuild
generated
vendored
BIN
node_modules/@esbuild/darwin-arm64/bin/esbuild
generated
vendored
Binary file not shown.
20
node_modules/@esbuild/darwin-arm64/package.json
generated
vendored
20
node_modules/@esbuild/darwin-arm64/package.json
generated
vendored
@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@esbuild/darwin-arm64",
|
|
||||||
"version": "0.21.5",
|
|
||||||
"description": "The macOS ARM 64-bit binary for esbuild, a JavaScript bundler.",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/evanw/esbuild.git"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
|
||||||
"preferUnplugged": true,
|
|
||||||
"engines": {
|
|
||||||
"node": ">=12"
|
|
||||||
},
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
]
|
|
||||||
}
|
|
145
node_modules/@ffmpeg/ffmpeg/dist/esm/classes.d.ts
generated
vendored
145
node_modules/@ffmpeg/ffmpeg/dist/esm/classes.d.ts
generated
vendored
@ -1,145 +0,0 @@
|
|||||||
import { FSNode, FFMessageLoadConfig, OK, IsFirst, LogEventCallback, ProgressEventCallback, FileData, FFFSType, FFFSMountOptions, FFFSPath } from "./types.js";
|
|
||||||
type FFMessageOptions = {
|
|
||||||
signal?: AbortSignal;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Provides APIs to interact with ffmpeg web worker.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const ffmpeg = new FFmpeg();
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export declare class FFmpeg {
|
|
||||||
#private;
|
|
||||||
loaded: boolean;
|
|
||||||
/**
|
|
||||||
* Listen to log or prgress events from `ffmpeg.exec()`.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* ffmpeg.on("log", ({ type, message }) => {
|
|
||||||
* // ...
|
|
||||||
* })
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* ffmpeg.on("progress", ({ progress, time }) => {
|
|
||||||
* // ...
|
|
||||||
* })
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @remarks
|
|
||||||
* - log includes output to stdout and stderr.
|
|
||||||
* - The progress events are accurate only when the length of
|
|
||||||
* input and output video/audio file are the same.
|
|
||||||
*
|
|
||||||
* @category FFmpeg
|
|
||||||
*/
|
|
||||||
on(event: "log", callback: LogEventCallback): void;
|
|
||||||
on(event: "progress", callback: ProgressEventCallback): void;
|
|
||||||
/**
|
|
||||||
* Unlisten to log or prgress events from `ffmpeg.exec()`.
|
|
||||||
*
|
|
||||||
* @category FFmpeg
|
|
||||||
*/
|
|
||||||
off(event: "log", callback: LogEventCallback): void;
|
|
||||||
off(event: "progress", callback: ProgressEventCallback): void;
|
|
||||||
/**
|
|
||||||
* Loads ffmpeg-core inside web worker. It is required to call this method first
|
|
||||||
* as it initializes WebAssembly and other essential variables.
|
|
||||||
*
|
|
||||||
* @category FFmpeg
|
|
||||||
* @returns `true` if ffmpeg core is loaded for the first time.
|
|
||||||
*/
|
|
||||||
load: ({ classWorkerURL, ...config }?: FFMessageLoadConfig, { signal }?: FFMessageOptions) => Promise<IsFirst>;
|
|
||||||
/**
|
|
||||||
* Execute ffmpeg command.
|
|
||||||
*
|
|
||||||
* @remarks
|
|
||||||
* To avoid common I/O issues, ["-nostdin", "-y"] are prepended to the args
|
|
||||||
* by default.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const ffmpeg = new FFmpeg();
|
|
||||||
* await ffmpeg.load();
|
|
||||||
* await ffmpeg.writeFile("video.avi", ...);
|
|
||||||
* // ffmpeg -i video.avi video.mp4
|
|
||||||
* await ffmpeg.exec(["-i", "video.avi", "video.mp4"]);
|
|
||||||
* const data = ffmpeg.readFile("video.mp4");
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @returns `0` if no error, `!= 0` if timeout (1) or error.
|
|
||||||
* @category FFmpeg
|
|
||||||
*/
|
|
||||||
exec: (args: string[], timeout?: number, { signal }?: FFMessageOptions) => Promise<number>;
|
|
||||||
/**
|
|
||||||
* Terminate all ongoing API calls and terminate web worker.
|
|
||||||
* `FFmpeg.load()` must be called again before calling any other APIs.
|
|
||||||
*
|
|
||||||
* @category FFmpeg
|
|
||||||
*/
|
|
||||||
terminate: () => void;
|
|
||||||
/**
|
|
||||||
* Write data to ffmpeg.wasm.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const ffmpeg = new FFmpeg();
|
|
||||||
* await ffmpeg.load();
|
|
||||||
* await ffmpeg.writeFile("video.avi", await fetchFile("../video.avi"));
|
|
||||||
* await ffmpeg.writeFile("text.txt", "hello world");
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
writeFile: (path: string, data: FileData, { signal }?: FFMessageOptions) => Promise<OK>;
|
|
||||||
mount: (fsType: FFFSType, options: FFFSMountOptions, mountPoint: FFFSPath) => Promise<OK>;
|
|
||||||
unmount: (mountPoint: FFFSPath) => Promise<OK>;
|
|
||||||
/**
|
|
||||||
* Read data from ffmpeg.wasm.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const ffmpeg = new FFmpeg();
|
|
||||||
* await ffmpeg.load();
|
|
||||||
* const data = await ffmpeg.readFile("video.mp4");
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
readFile: (path: string, encoding?: string, { signal }?: FFMessageOptions) => Promise<FileData>;
|
|
||||||
/**
|
|
||||||
* Delete a file.
|
|
||||||
*
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
deleteFile: (path: string, { signal }?: FFMessageOptions) => Promise<OK>;
|
|
||||||
/**
|
|
||||||
* Rename a file or directory.
|
|
||||||
*
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
rename: (oldPath: string, newPath: string, { signal }?: FFMessageOptions) => Promise<OK>;
|
|
||||||
/**
|
|
||||||
* Create a directory.
|
|
||||||
*
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
createDir: (path: string, { signal }?: FFMessageOptions) => Promise<OK>;
|
|
||||||
/**
|
|
||||||
* List directory contents.
|
|
||||||
*
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
listDir: (path: string, { signal }?: FFMessageOptions) => Promise<FSNode[]>;
|
|
||||||
/**
|
|
||||||
* Delete an empty directory.
|
|
||||||
*
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
deleteDir: (path: string, { signal }?: FFMessageOptions) => Promise<OK>;
|
|
||||||
}
|
|
||||||
export {};
|
|
277
node_modules/@ffmpeg/ffmpeg/dist/esm/classes.js
generated
vendored
277
node_modules/@ffmpeg/ffmpeg/dist/esm/classes.js
generated
vendored
@ -1,277 +0,0 @@
|
|||||||
import { FFMessageType } from "./const.js";
|
|
||||||
import { getMessageID } from "./utils.js";
|
|
||||||
import { ERROR_TERMINATED, ERROR_NOT_LOADED } from "./errors.js";
|
|
||||||
/**
|
|
||||||
* Provides APIs to interact with ffmpeg web worker.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const ffmpeg = new FFmpeg();
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export class FFmpeg {
|
|
||||||
#worker = null;
|
|
||||||
/**
|
|
||||||
* #resolves and #rejects tracks Promise resolves and rejects to
|
|
||||||
* be called when we receive message from web worker.
|
|
||||||
*/
|
|
||||||
#resolves = {};
|
|
||||||
#rejects = {};
|
|
||||||
#logEventCallbacks = [];
|
|
||||||
#progressEventCallbacks = [];
|
|
||||||
loaded = false;
|
|
||||||
/**
|
|
||||||
* register worker message event handlers.
|
|
||||||
*/
|
|
||||||
#registerHandlers = () => {
|
|
||||||
if (this.#worker) {
|
|
||||||
this.#worker.onmessage = ({ data: { id, type, data }, }) => {
|
|
||||||
switch (type) {
|
|
||||||
case FFMessageType.LOAD:
|
|
||||||
this.loaded = true;
|
|
||||||
this.#resolves[id](data);
|
|
||||||
break;
|
|
||||||
case FFMessageType.MOUNT:
|
|
||||||
case FFMessageType.UNMOUNT:
|
|
||||||
case FFMessageType.EXEC:
|
|
||||||
case FFMessageType.WRITE_FILE:
|
|
||||||
case FFMessageType.READ_FILE:
|
|
||||||
case FFMessageType.DELETE_FILE:
|
|
||||||
case FFMessageType.RENAME:
|
|
||||||
case FFMessageType.CREATE_DIR:
|
|
||||||
case FFMessageType.LIST_DIR:
|
|
||||||
case FFMessageType.DELETE_DIR:
|
|
||||||
this.#resolves[id](data);
|
|
||||||
break;
|
|
||||||
case FFMessageType.LOG:
|
|
||||||
this.#logEventCallbacks.forEach((f) => f(data));
|
|
||||||
break;
|
|
||||||
case FFMessageType.PROGRESS:
|
|
||||||
this.#progressEventCallbacks.forEach((f) => f(data));
|
|
||||||
break;
|
|
||||||
case FFMessageType.ERROR:
|
|
||||||
this.#rejects[id](data);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
delete this.#resolves[id];
|
|
||||||
delete this.#rejects[id];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Generic function to send messages to web worker.
|
|
||||||
*/
|
|
||||||
#send = ({ type, data }, trans = [], signal) => {
|
|
||||||
if (!this.#worker) {
|
|
||||||
return Promise.reject(ERROR_NOT_LOADED);
|
|
||||||
}
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const id = getMessageID();
|
|
||||||
this.#worker && this.#worker.postMessage({ id, type, data }, trans);
|
|
||||||
this.#resolves[id] = resolve;
|
|
||||||
this.#rejects[id] = reject;
|
|
||||||
signal?.addEventListener("abort", () => {
|
|
||||||
reject(new DOMException(`Message # ${id} was aborted`, "AbortError"));
|
|
||||||
}, { once: true });
|
|
||||||
});
|
|
||||||
};
|
|
||||||
on(event, callback) {
|
|
||||||
if (event === "log") {
|
|
||||||
this.#logEventCallbacks.push(callback);
|
|
||||||
}
|
|
||||||
else if (event === "progress") {
|
|
||||||
this.#progressEventCallbacks.push(callback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
off(event, callback) {
|
|
||||||
if (event === "log") {
|
|
||||||
this.#logEventCallbacks = this.#logEventCallbacks.filter((f) => f !== callback);
|
|
||||||
}
|
|
||||||
else if (event === "progress") {
|
|
||||||
this.#progressEventCallbacks = this.#progressEventCallbacks.filter((f) => f !== callback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Loads ffmpeg-core inside web worker. It is required to call this method first
|
|
||||||
* as it initializes WebAssembly and other essential variables.
|
|
||||||
*
|
|
||||||
* @category FFmpeg
|
|
||||||
* @returns `true` if ffmpeg core is loaded for the first time.
|
|
||||||
*/
|
|
||||||
load = ({ classWorkerURL, ...config } = {}, { signal } = {}) => {
|
|
||||||
if (!this.#worker) {
|
|
||||||
this.#worker = classWorkerURL ?
|
|
||||||
new Worker(new URL(classWorkerURL, import.meta.url), {
|
|
||||||
type: "module",
|
|
||||||
}) :
|
|
||||||
// We need to duplicated the code here to enable webpack
|
|
||||||
// to bundle worekr.js here.
|
|
||||||
new Worker(new URL("./worker.js", import.meta.url), {
|
|
||||||
type: "module",
|
|
||||||
});
|
|
||||||
this.#registerHandlers();
|
|
||||||
}
|
|
||||||
return this.#send({
|
|
||||||
type: FFMessageType.LOAD,
|
|
||||||
data: config,
|
|
||||||
}, undefined, signal);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Execute ffmpeg command.
|
|
||||||
*
|
|
||||||
* @remarks
|
|
||||||
* To avoid common I/O issues, ["-nostdin", "-y"] are prepended to the args
|
|
||||||
* by default.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const ffmpeg = new FFmpeg();
|
|
||||||
* await ffmpeg.load();
|
|
||||||
* await ffmpeg.writeFile("video.avi", ...);
|
|
||||||
* // ffmpeg -i video.avi video.mp4
|
|
||||||
* await ffmpeg.exec(["-i", "video.avi", "video.mp4"]);
|
|
||||||
* const data = ffmpeg.readFile("video.mp4");
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @returns `0` if no error, `!= 0` if timeout (1) or error.
|
|
||||||
* @category FFmpeg
|
|
||||||
*/
|
|
||||||
exec = (
|
|
||||||
/** ffmpeg command line args */
|
|
||||||
args,
|
|
||||||
/**
|
|
||||||
* milliseconds to wait before stopping the command execution.
|
|
||||||
*
|
|
||||||
* @defaultValue -1
|
|
||||||
*/
|
|
||||||
timeout = -1, { signal } = {}) => this.#send({
|
|
||||||
type: FFMessageType.EXEC,
|
|
||||||
data: { args, timeout },
|
|
||||||
}, undefined, signal);
|
|
||||||
/**
|
|
||||||
* Terminate all ongoing API calls and terminate web worker.
|
|
||||||
* `FFmpeg.load()` must be called again before calling any other APIs.
|
|
||||||
*
|
|
||||||
* @category FFmpeg
|
|
||||||
*/
|
|
||||||
terminate = () => {
|
|
||||||
const ids = Object.keys(this.#rejects);
|
|
||||||
// rejects all incomplete Promises.
|
|
||||||
for (const id of ids) {
|
|
||||||
this.#rejects[id](ERROR_TERMINATED);
|
|
||||||
delete this.#rejects[id];
|
|
||||||
delete this.#resolves[id];
|
|
||||||
}
|
|
||||||
if (this.#worker) {
|
|
||||||
this.#worker.terminate();
|
|
||||||
this.#worker = null;
|
|
||||||
this.loaded = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Write data to ffmpeg.wasm.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const ffmpeg = new FFmpeg();
|
|
||||||
* await ffmpeg.load();
|
|
||||||
* await ffmpeg.writeFile("video.avi", await fetchFile("../video.avi"));
|
|
||||||
* await ffmpeg.writeFile("text.txt", "hello world");
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
writeFile = (path, data, { signal } = {}) => {
|
|
||||||
const trans = [];
|
|
||||||
if (data instanceof Uint8Array) {
|
|
||||||
trans.push(data.buffer);
|
|
||||||
}
|
|
||||||
return this.#send({
|
|
||||||
type: FFMessageType.WRITE_FILE,
|
|
||||||
data: { path, data },
|
|
||||||
}, trans, signal);
|
|
||||||
};
|
|
||||||
mount = (fsType, options, mountPoint) => {
|
|
||||||
const trans = [];
|
|
||||||
return this.#send({
|
|
||||||
type: FFMessageType.MOUNT,
|
|
||||||
data: { fsType, options, mountPoint },
|
|
||||||
}, trans);
|
|
||||||
};
|
|
||||||
unmount = (mountPoint) => {
|
|
||||||
const trans = [];
|
|
||||||
return this.#send({
|
|
||||||
type: FFMessageType.UNMOUNT,
|
|
||||||
data: { mountPoint },
|
|
||||||
}, trans);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Read data from ffmpeg.wasm.
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const ffmpeg = new FFmpeg();
|
|
||||||
* await ffmpeg.load();
|
|
||||||
* const data = await ffmpeg.readFile("video.mp4");
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
readFile = (path,
|
|
||||||
/**
|
|
||||||
* File content encoding, supports two encodings:
|
|
||||||
* - utf8: read file as text file, return data in string type.
|
|
||||||
* - binary: read file as binary file, return data in Uint8Array type.
|
|
||||||
*
|
|
||||||
* @defaultValue binary
|
|
||||||
*/
|
|
||||||
encoding = "binary", { signal } = {}) => this.#send({
|
|
||||||
type: FFMessageType.READ_FILE,
|
|
||||||
data: { path, encoding },
|
|
||||||
}, undefined, signal);
|
|
||||||
/**
|
|
||||||
* Delete a file.
|
|
||||||
*
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
deleteFile = (path, { signal } = {}) => this.#send({
|
|
||||||
type: FFMessageType.DELETE_FILE,
|
|
||||||
data: { path },
|
|
||||||
}, undefined, signal);
|
|
||||||
/**
|
|
||||||
* Rename a file or directory.
|
|
||||||
*
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
rename = (oldPath, newPath, { signal } = {}) => this.#send({
|
|
||||||
type: FFMessageType.RENAME,
|
|
||||||
data: { oldPath, newPath },
|
|
||||||
}, undefined, signal);
|
|
||||||
/**
|
|
||||||
* Create a directory.
|
|
||||||
*
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
createDir = (path, { signal } = {}) => this.#send({
|
|
||||||
type: FFMessageType.CREATE_DIR,
|
|
||||||
data: { path },
|
|
||||||
}, undefined, signal);
|
|
||||||
/**
|
|
||||||
* List directory contents.
|
|
||||||
*
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
listDir = (path, { signal } = {}) => this.#send({
|
|
||||||
type: FFMessageType.LIST_DIR,
|
|
||||||
data: { path },
|
|
||||||
}, undefined, signal);
|
|
||||||
/**
|
|
||||||
* Delete an empty directory.
|
|
||||||
*
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
deleteDir = (path, { signal } = {}) => this.#send({
|
|
||||||
type: FFMessageType.DELETE_DIR,
|
|
||||||
data: { path },
|
|
||||||
}, undefined, signal);
|
|
||||||
}
|
|
21
node_modules/@ffmpeg/ffmpeg/dist/esm/const.d.ts
generated
vendored
21
node_modules/@ffmpeg/ffmpeg/dist/esm/const.d.ts
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
export declare const MIME_TYPE_JAVASCRIPT = "text/javascript";
|
|
||||||
export declare const MIME_TYPE_WASM = "application/wasm";
|
|
||||||
export declare const CORE_VERSION = "0.12.6";
|
|
||||||
export declare const CORE_URL: string;
|
|
||||||
export declare enum FFMessageType {
|
|
||||||
LOAD = "LOAD",
|
|
||||||
EXEC = "EXEC",
|
|
||||||
WRITE_FILE = "WRITE_FILE",
|
|
||||||
READ_FILE = "READ_FILE",
|
|
||||||
DELETE_FILE = "DELETE_FILE",
|
|
||||||
RENAME = "RENAME",
|
|
||||||
CREATE_DIR = "CREATE_DIR",
|
|
||||||
LIST_DIR = "LIST_DIR",
|
|
||||||
DELETE_DIR = "DELETE_DIR",
|
|
||||||
ERROR = "ERROR",
|
|
||||||
DOWNLOAD = "DOWNLOAD",
|
|
||||||
PROGRESS = "PROGRESS",
|
|
||||||
LOG = "LOG",
|
|
||||||
MOUNT = "MOUNT",
|
|
||||||
UNMOUNT = "UNMOUNT"
|
|
||||||
}
|
|
22
node_modules/@ffmpeg/ffmpeg/dist/esm/const.js
generated
vendored
22
node_modules/@ffmpeg/ffmpeg/dist/esm/const.js
generated
vendored
@ -1,22 +0,0 @@
|
|||||||
export const MIME_TYPE_JAVASCRIPT = "text/javascript";
|
|
||||||
export const MIME_TYPE_WASM = "application/wasm";
|
|
||||||
export const CORE_VERSION = "0.12.6";
|
|
||||||
export const CORE_URL = `https://unpkg.com/@ffmpeg/core@${CORE_VERSION}/dist/umd/ffmpeg-core.js`;
|
|
||||||
export var FFMessageType;
|
|
||||||
(function (FFMessageType) {
|
|
||||||
FFMessageType["LOAD"] = "LOAD";
|
|
||||||
FFMessageType["EXEC"] = "EXEC";
|
|
||||||
FFMessageType["WRITE_FILE"] = "WRITE_FILE";
|
|
||||||
FFMessageType["READ_FILE"] = "READ_FILE";
|
|
||||||
FFMessageType["DELETE_FILE"] = "DELETE_FILE";
|
|
||||||
FFMessageType["RENAME"] = "RENAME";
|
|
||||||
FFMessageType["CREATE_DIR"] = "CREATE_DIR";
|
|
||||||
FFMessageType["LIST_DIR"] = "LIST_DIR";
|
|
||||||
FFMessageType["DELETE_DIR"] = "DELETE_DIR";
|
|
||||||
FFMessageType["ERROR"] = "ERROR";
|
|
||||||
FFMessageType["DOWNLOAD"] = "DOWNLOAD";
|
|
||||||
FFMessageType["PROGRESS"] = "PROGRESS";
|
|
||||||
FFMessageType["LOG"] = "LOG";
|
|
||||||
FFMessageType["MOUNT"] = "MOUNT";
|
|
||||||
FFMessageType["UNMOUNT"] = "UNMOUNT";
|
|
||||||
})(FFMessageType || (FFMessageType = {}));
|
|
3
node_modules/@ffmpeg/ffmpeg/dist/esm/empty.d.mts
generated
vendored
3
node_modules/@ffmpeg/ffmpeg/dist/esm/empty.d.mts
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
export declare class FFmpeg {
|
|
||||||
constructor();
|
|
||||||
}
|
|
6
node_modules/@ffmpeg/ffmpeg/dist/esm/empty.mjs
generated
vendored
6
node_modules/@ffmpeg/ffmpeg/dist/esm/empty.mjs
generated
vendored
@ -1,6 +0,0 @@
|
|||||||
// File to be imported in node enviroments
|
|
||||||
export class FFmpeg {
|
|
||||||
constructor() {
|
|
||||||
throw new Error("ffmpeg.wasm does not support nodejs");
|
|
||||||
}
|
|
||||||
}
|
|
4
node_modules/@ffmpeg/ffmpeg/dist/esm/errors.d.ts
generated
vendored
4
node_modules/@ffmpeg/ffmpeg/dist/esm/errors.d.ts
generated
vendored
@ -1,4 +0,0 @@
|
|||||||
export declare const ERROR_UNKNOWN_MESSAGE_TYPE: Error;
|
|
||||||
export declare const ERROR_NOT_LOADED: Error;
|
|
||||||
export declare const ERROR_TERMINATED: Error;
|
|
||||||
export declare const ERROR_IMPORT_FAILURE: Error;
|
|
4
node_modules/@ffmpeg/ffmpeg/dist/esm/errors.js
generated
vendored
4
node_modules/@ffmpeg/ffmpeg/dist/esm/errors.js
generated
vendored
@ -1,4 +0,0 @@
|
|||||||
export const ERROR_UNKNOWN_MESSAGE_TYPE = new Error("unknown message type");
|
|
||||||
export const ERROR_NOT_LOADED = new Error("ffmpeg is not loaded, call `await ffmpeg.load()` first");
|
|
||||||
export const ERROR_TERMINATED = new Error("called FFmpeg.terminate()");
|
|
||||||
export const ERROR_IMPORT_FAILURE = new Error("failed to import ffmpeg-core.js");
|
|
1
node_modules/@ffmpeg/ffmpeg/dist/esm/index.d.ts
generated
vendored
1
node_modules/@ffmpeg/ffmpeg/dist/esm/index.d.ts
generated
vendored
@ -1 +0,0 @@
|
|||||||
export * from "./classes.js";
|
|
1
node_modules/@ffmpeg/ffmpeg/dist/esm/index.js
generated
vendored
1
node_modules/@ffmpeg/ffmpeg/dist/esm/index.js
generated
vendored
@ -1 +0,0 @@
|
|||||||
export * from "./classes.js";
|
|
131
node_modules/@ffmpeg/ffmpeg/dist/esm/types.d.ts
generated
vendored
131
node_modules/@ffmpeg/ffmpeg/dist/esm/types.d.ts
generated
vendored
@ -1,131 +0,0 @@
|
|||||||
export type FFFSPath = string;
|
|
||||||
/**
|
|
||||||
* ffmpeg-core loading configuration.
|
|
||||||
*/
|
|
||||||
export interface FFMessageLoadConfig {
|
|
||||||
/**
|
|
||||||
* `ffmpeg-core.js` URL.
|
|
||||||
*
|
|
||||||
* @defaultValue `https://unpkg.com/@ffmpeg/core@${CORE_VERSION}/dist/umd/ffmpeg-core.js`;
|
|
||||||
*/
|
|
||||||
coreURL?: string;
|
|
||||||
/**
|
|
||||||
* `ffmpeg-core.wasm` URL.
|
|
||||||
*
|
|
||||||
* @defaultValue `https://unpkg.com/@ffmpeg/core@${CORE_VERSION}/dist/umd/ffmpeg-core.wasm`;
|
|
||||||
*/
|
|
||||||
wasmURL?: string;
|
|
||||||
/**
|
|
||||||
* `ffmpeg-core.worker.js` URL. This worker is spawned when using multithread version of ffmpeg-core.
|
|
||||||
*
|
|
||||||
* @ref: https://ffmpegwasm.netlify.app/docs/overview#architecture
|
|
||||||
* @defaultValue `https://unpkg.com/@ffmpeg/core-mt@${CORE_VERSION}/dist/umd/ffmpeg-core.worker.js`;
|
|
||||||
*/
|
|
||||||
workerURL?: string;
|
|
||||||
/**
|
|
||||||
* `ffmpeg.worker.js` URL. This worker is spawned when FFmpeg.load() is called, it is an essential worker and usually you don't need to update this config.
|
|
||||||
*
|
|
||||||
* @ref: https://ffmpegwasm.netlify.app/docs/overview#architecture
|
|
||||||
* @defaultValue `./worker.js`
|
|
||||||
*/
|
|
||||||
classWorkerURL?: string;
|
|
||||||
}
|
|
||||||
export interface FFMessageExecData {
|
|
||||||
args: string[];
|
|
||||||
timeout?: number;
|
|
||||||
}
|
|
||||||
export interface FFMessageWriteFileData {
|
|
||||||
path: FFFSPath;
|
|
||||||
data: FileData;
|
|
||||||
}
|
|
||||||
export interface FFMessageReadFileData {
|
|
||||||
path: FFFSPath;
|
|
||||||
encoding: string;
|
|
||||||
}
|
|
||||||
export interface FFMessageDeleteFileData {
|
|
||||||
path: FFFSPath;
|
|
||||||
}
|
|
||||||
export interface FFMessageRenameData {
|
|
||||||
oldPath: FFFSPath;
|
|
||||||
newPath: FFFSPath;
|
|
||||||
}
|
|
||||||
export interface FFMessageCreateDirData {
|
|
||||||
path: FFFSPath;
|
|
||||||
}
|
|
||||||
export interface FFMessageListDirData {
|
|
||||||
path: FFFSPath;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @remarks
|
|
||||||
* Only deletes empty directory.
|
|
||||||
*/
|
|
||||||
export interface FFMessageDeleteDirData {
|
|
||||||
path: FFFSPath;
|
|
||||||
}
|
|
||||||
export declare enum FFFSType {
|
|
||||||
MEMFS = "MEMFS",
|
|
||||||
NODEFS = "NODEFS",
|
|
||||||
NODERAWFS = "NODERAWFS",
|
|
||||||
IDBFS = "IDBFS",
|
|
||||||
WORKERFS = "WORKERFS",
|
|
||||||
PROXYFS = "PROXYFS"
|
|
||||||
}
|
|
||||||
export type WorkerFSFileEntry = File;
|
|
||||||
export interface WorkerFSBlobEntry {
|
|
||||||
name: string;
|
|
||||||
data: Blob;
|
|
||||||
}
|
|
||||||
export interface WorkerFSMountData {
|
|
||||||
blobs?: WorkerFSBlobEntry[];
|
|
||||||
files?: WorkerFSFileEntry[];
|
|
||||||
}
|
|
||||||
export type FFFSMountOptions = WorkerFSMountData;
|
|
||||||
export interface FFMessageMountData {
|
|
||||||
fsType: FFFSType;
|
|
||||||
options: FFFSMountOptions;
|
|
||||||
mountPoint: FFFSPath;
|
|
||||||
}
|
|
||||||
export interface FFMessageUnmountData {
|
|
||||||
mountPoint: FFFSPath;
|
|
||||||
}
|
|
||||||
export type FFMessageData = FFMessageLoadConfig | FFMessageExecData | FFMessageWriteFileData | FFMessageReadFileData | FFMessageDeleteFileData | FFMessageRenameData | FFMessageCreateDirData | FFMessageListDirData | FFMessageDeleteDirData | FFMessageMountData | FFMessageUnmountData;
|
|
||||||
export interface Message {
|
|
||||||
type: string;
|
|
||||||
data?: FFMessageData;
|
|
||||||
}
|
|
||||||
export interface FFMessage extends Message {
|
|
||||||
id: number;
|
|
||||||
}
|
|
||||||
export interface FFMessageEvent extends MessageEvent {
|
|
||||||
data: FFMessage;
|
|
||||||
}
|
|
||||||
export interface LogEvent {
|
|
||||||
type: string;
|
|
||||||
message: string;
|
|
||||||
}
|
|
||||||
export interface ProgressEvent {
|
|
||||||
progress: number;
|
|
||||||
time: number;
|
|
||||||
}
|
|
||||||
export type ExitCode = number;
|
|
||||||
export type ErrorMessage = string;
|
|
||||||
export type FileData = Uint8Array | string;
|
|
||||||
export type IsFirst = boolean;
|
|
||||||
export type OK = boolean;
|
|
||||||
export interface FSNode {
|
|
||||||
name: string;
|
|
||||||
isDir: boolean;
|
|
||||||
}
|
|
||||||
export type CallbackData = FileData | ExitCode | ErrorMessage | LogEvent | ProgressEvent | IsFirst | OK | Error | FSNode[] | undefined;
|
|
||||||
export interface Callbacks {
|
|
||||||
[id: number | string]: (data: CallbackData) => void;
|
|
||||||
}
|
|
||||||
export type LogEventCallback = (event: LogEvent) => void;
|
|
||||||
export type ProgressEventCallback = (event: ProgressEvent) => void;
|
|
||||||
export interface FFMessageEventCallback {
|
|
||||||
data: {
|
|
||||||
id: number;
|
|
||||||
type: string;
|
|
||||||
data: CallbackData;
|
|
||||||
};
|
|
||||||
}
|
|
9
node_modules/@ffmpeg/ffmpeg/dist/esm/types.js
generated
vendored
9
node_modules/@ffmpeg/ffmpeg/dist/esm/types.js
generated
vendored
@ -1,9 +0,0 @@
|
|||||||
export var FFFSType;
|
|
||||||
(function (FFFSType) {
|
|
||||||
FFFSType["MEMFS"] = "MEMFS";
|
|
||||||
FFFSType["NODEFS"] = "NODEFS";
|
|
||||||
FFFSType["NODERAWFS"] = "NODERAWFS";
|
|
||||||
FFFSType["IDBFS"] = "IDBFS";
|
|
||||||
FFFSType["WORKERFS"] = "WORKERFS";
|
|
||||||
FFFSType["PROXYFS"] = "PROXYFS";
|
|
||||||
})(FFFSType || (FFFSType = {}));
|
|
4
node_modules/@ffmpeg/ffmpeg/dist/esm/utils.d.ts
generated
vendored
4
node_modules/@ffmpeg/ffmpeg/dist/esm/utils.d.ts
generated
vendored
@ -1,4 +0,0 @@
|
|||||||
/**
|
|
||||||
* Generate an unique message ID.
|
|
||||||
*/
|
|
||||||
export declare const getMessageID: () => number;
|
|
7
node_modules/@ffmpeg/ffmpeg/dist/esm/utils.js
generated
vendored
7
node_modules/@ffmpeg/ffmpeg/dist/esm/utils.js
generated
vendored
@ -1,7 +0,0 @@
|
|||||||
/**
|
|
||||||
* Generate an unique message ID.
|
|
||||||
*/
|
|
||||||
export const getMessageID = (() => {
|
|
||||||
let messageID = 0;
|
|
||||||
return () => messageID++;
|
|
||||||
})();
|
|
9
node_modules/@ffmpeg/ffmpeg/dist/esm/worker.d.ts
generated
vendored
9
node_modules/@ffmpeg/ffmpeg/dist/esm/worker.d.ts
generated
vendored
@ -1,9 +0,0 @@
|
|||||||
/// <reference no-default-lib="true"/>
|
|
||||||
/// <reference lib="esnext" />
|
|
||||||
/// <reference lib="webworker" />
|
|
||||||
import type { FFmpegCoreModuleFactory } from "@ffmpeg/types";
|
|
||||||
declare global {
|
|
||||||
interface WorkerGlobalScope {
|
|
||||||
createFFmpegCore: FFmpegCoreModuleFactory;
|
|
||||||
}
|
|
||||||
}
|
|
151
node_modules/@ffmpeg/ffmpeg/dist/esm/worker.js
generated
vendored
151
node_modules/@ffmpeg/ffmpeg/dist/esm/worker.js
generated
vendored
@ -1,151 +0,0 @@
|
|||||||
/// <reference no-default-lib="true" />
|
|
||||||
/// <reference lib="esnext" />
|
|
||||||
/// <reference lib="webworker" />
|
|
||||||
import { CORE_URL, FFMessageType } from "./const.js";
|
|
||||||
import { ERROR_UNKNOWN_MESSAGE_TYPE, ERROR_NOT_LOADED, ERROR_IMPORT_FAILURE, } from "./errors.js";
|
|
||||||
let ffmpeg;
|
|
||||||
const load = async ({ coreURL: _coreURL, wasmURL: _wasmURL, workerURL: _workerURL, }) => {
|
|
||||||
const first = !ffmpeg;
|
|
||||||
try {
|
|
||||||
if (!_coreURL)
|
|
||||||
_coreURL = CORE_URL;
|
|
||||||
// when web worker type is `classic`.
|
|
||||||
importScripts(_coreURL);
|
|
||||||
}
|
|
||||||
catch {
|
|
||||||
if (!_coreURL)
|
|
||||||
_coreURL = CORE_URL.replace('/umd/', '/esm/');
|
|
||||||
// when web worker type is `module`.
|
|
||||||
self.createFFmpegCore = (await import(
|
|
||||||
/* webpackIgnore: true */ /* @vite-ignore */ _coreURL)).default;
|
|
||||||
if (!self.createFFmpegCore) {
|
|
||||||
throw ERROR_IMPORT_FAILURE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const coreURL = _coreURL;
|
|
||||||
const wasmURL = _wasmURL ? _wasmURL : _coreURL.replace(/.js$/g, ".wasm");
|
|
||||||
const workerURL = _workerURL
|
|
||||||
? _workerURL
|
|
||||||
: _coreURL.replace(/.js$/g, ".worker.js");
|
|
||||||
ffmpeg = await self.createFFmpegCore({
|
|
||||||
// Fix `Overload resolution failed.` when using multi-threaded ffmpeg-core.
|
|
||||||
// Encoded wasmURL and workerURL in the URL as a hack to fix locateFile issue.
|
|
||||||
mainScriptUrlOrBlob: `${coreURL}#${btoa(JSON.stringify({ wasmURL, workerURL }))}`,
|
|
||||||
});
|
|
||||||
ffmpeg.setLogger((data) => self.postMessage({ type: FFMessageType.LOG, data }));
|
|
||||||
ffmpeg.setProgress((data) => self.postMessage({
|
|
||||||
type: FFMessageType.PROGRESS,
|
|
||||||
data,
|
|
||||||
}));
|
|
||||||
return first;
|
|
||||||
};
|
|
||||||
const exec = ({ args, timeout = -1 }) => {
|
|
||||||
ffmpeg.setTimeout(timeout);
|
|
||||||
ffmpeg.exec(...args);
|
|
||||||
const ret = ffmpeg.ret;
|
|
||||||
ffmpeg.reset();
|
|
||||||
return ret;
|
|
||||||
};
|
|
||||||
const writeFile = ({ path, data }) => {
|
|
||||||
ffmpeg.FS.writeFile(path, data);
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
const readFile = ({ path, encoding }) => ffmpeg.FS.readFile(path, { encoding });
|
|
||||||
// TODO: check if deletion works.
|
|
||||||
const deleteFile = ({ path }) => {
|
|
||||||
ffmpeg.FS.unlink(path);
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
const rename = ({ oldPath, newPath }) => {
|
|
||||||
ffmpeg.FS.rename(oldPath, newPath);
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
// TODO: check if creation works.
|
|
||||||
const createDir = ({ path }) => {
|
|
||||||
ffmpeg.FS.mkdir(path);
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
const listDir = ({ path }) => {
|
|
||||||
const names = ffmpeg.FS.readdir(path);
|
|
||||||
const nodes = [];
|
|
||||||
for (const name of names) {
|
|
||||||
const stat = ffmpeg.FS.stat(`${path}/${name}`);
|
|
||||||
const isDir = ffmpeg.FS.isDir(stat.mode);
|
|
||||||
nodes.push({ name, isDir });
|
|
||||||
}
|
|
||||||
return nodes;
|
|
||||||
};
|
|
||||||
// TODO: check if deletion works.
|
|
||||||
const deleteDir = ({ path }) => {
|
|
||||||
ffmpeg.FS.rmdir(path);
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
const mount = ({ fsType, options, mountPoint }) => {
|
|
||||||
const str = fsType;
|
|
||||||
const fs = ffmpeg.FS.filesystems[str];
|
|
||||||
if (!fs)
|
|
||||||
return false;
|
|
||||||
ffmpeg.FS.mount(fs, options, mountPoint);
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
const unmount = ({ mountPoint }) => {
|
|
||||||
ffmpeg.FS.unmount(mountPoint);
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
self.onmessage = async ({ data: { id, type, data: _data }, }) => {
|
|
||||||
const trans = [];
|
|
||||||
let data;
|
|
||||||
try {
|
|
||||||
if (type !== FFMessageType.LOAD && !ffmpeg)
|
|
||||||
throw ERROR_NOT_LOADED; // eslint-disable-line
|
|
||||||
switch (type) {
|
|
||||||
case FFMessageType.LOAD:
|
|
||||||
data = await load(_data);
|
|
||||||
break;
|
|
||||||
case FFMessageType.EXEC:
|
|
||||||
data = exec(_data);
|
|
||||||
break;
|
|
||||||
case FFMessageType.WRITE_FILE:
|
|
||||||
data = writeFile(_data);
|
|
||||||
break;
|
|
||||||
case FFMessageType.READ_FILE:
|
|
||||||
data = readFile(_data);
|
|
||||||
break;
|
|
||||||
case FFMessageType.DELETE_FILE:
|
|
||||||
data = deleteFile(_data);
|
|
||||||
break;
|
|
||||||
case FFMessageType.RENAME:
|
|
||||||
data = rename(_data);
|
|
||||||
break;
|
|
||||||
case FFMessageType.CREATE_DIR:
|
|
||||||
data = createDir(_data);
|
|
||||||
break;
|
|
||||||
case FFMessageType.LIST_DIR:
|
|
||||||
data = listDir(_data);
|
|
||||||
break;
|
|
||||||
case FFMessageType.DELETE_DIR:
|
|
||||||
data = deleteDir(_data);
|
|
||||||
break;
|
|
||||||
case FFMessageType.MOUNT:
|
|
||||||
data = mount(_data);
|
|
||||||
break;
|
|
||||||
case FFMessageType.UNMOUNT:
|
|
||||||
data = unmount(_data);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw ERROR_UNKNOWN_MESSAGE_TYPE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
self.postMessage({
|
|
||||||
id,
|
|
||||||
type: FFMessageType.ERROR,
|
|
||||||
data: e.toString(),
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (data instanceof Uint8Array) {
|
|
||||||
trans.push(data.buffer);
|
|
||||||
}
|
|
||||||
self.postMessage({ id, type, data }, trans);
|
|
||||||
};
|
|
2
node_modules/@ffmpeg/ffmpeg/dist/umd/814.ffmpeg.js
generated
vendored
2
node_modules/@ffmpeg/ffmpeg/dist/umd/814.ffmpeg.js
generated
vendored
@ -1,2 +0,0 @@
|
|||||||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FFmpegWASM=t():e.FFmpegWASM=t()}(self,(()=>(()=>{"use strict";const e="https://unpkg.com/@ffmpeg/core@0.12.6/dist/umd/ffmpeg-core.js";var t;!function(e){e.LOAD="LOAD",e.EXEC="EXEC",e.WRITE_FILE="WRITE_FILE",e.READ_FILE="READ_FILE",e.DELETE_FILE="DELETE_FILE",e.RENAME="RENAME",e.CREATE_DIR="CREATE_DIR",e.LIST_DIR="LIST_DIR",e.DELETE_DIR="DELETE_DIR",e.ERROR="ERROR",e.DOWNLOAD="DOWNLOAD",e.PROGRESS="PROGRESS",e.LOG="LOG",e.MOUNT="MOUNT",e.UNMOUNT="UNMOUNT"}(t||(t={}));const r=new Error("unknown message type"),a=new Error("ffmpeg is not loaded, call `await ffmpeg.load()` first"),s=(new Error("called FFmpeg.terminate()"),new Error("failed to import ffmpeg-core.js"));let o;return self.onmessage=async({data:{id:n,type:E,data:c}})=>{const i=[];let p;try{if(E!==t.LOAD&&!o)throw a;switch(E){case t.LOAD:p=await(async({coreURL:r,wasmURL:a,workerURL:n})=>{const E=!o;try{r||(r=e),importScripts(r)}catch{if(r||(r=e.replace("/umd/","/esm/")),self.createFFmpegCore=(await import(r)).default,!self.createFFmpegCore)throw s}const c=r,i=a||r.replace(/.js$/g,".wasm"),p=n||r.replace(/.js$/g,".worker.js");return o=await self.createFFmpegCore({mainScriptUrlOrBlob:`${c}#${btoa(JSON.stringify({wasmURL:i,workerURL:p}))}`}),o.setLogger((e=>self.postMessage({type:t.LOG,data:e}))),o.setProgress((e=>self.postMessage({type:t.PROGRESS,data:e}))),E})(c);break;case t.EXEC:p=(({args:e,timeout:t=-1})=>{o.setTimeout(t),o.exec(...e);const r=o.ret;return o.reset(),r})(c);break;case t.WRITE_FILE:p=(({path:e,data:t})=>(o.FS.writeFile(e,t),!0))(c);break;case t.READ_FILE:p=(({path:e,encoding:t})=>o.FS.readFile(e,{encoding:t}))(c);break;case t.DELETE_FILE:p=(({path:e})=>(o.FS.unlink(e),!0))(c);break;case t.RENAME:p=(({oldPath:e,newPath:t})=>(o.FS.rename(e,t),!0))(c);break;case t.CREATE_DIR:p=(({path:e})=>(o.FS.mkdir(e),!0))(c);break;case t.LIST_DIR:p=(({path:e})=>{const t=o.FS.readdir(e),r=[];for(const a of t){const t=o.FS.stat(`${e}/${a}`),s=o.FS.isDir(t.mode);r.push({name:a,isDir:s})}return r})(c);break;case t.DELETE_DIR:p=(({path:e})=>(o.FS.rmdir(e),!0))(c);break;case t.MOUNT:p=(({fsType:e,options:t,mountPoint:r})=>{const a=e,s=o.FS.filesystems[a];return!!s&&(o.FS.mount(s,t,r),!0)})(c);break;case t.UNMOUNT:p=(({mountPoint:e})=>(o.FS.unmount(e),!0))(c);break;default:throw r}}catch(e){return void self.postMessage({id:n,type:t.ERROR,data:e.toString()})}p instanceof Uint8Array&&i.push(p.buffer),self.postMessage({id:n,type:E,data:p},i)},{}})()));
|
|
||||||
//# sourceMappingURL=814.ffmpeg.js.map
|
|
1
node_modules/@ffmpeg/ffmpeg/dist/umd/814.ffmpeg.js.map
generated
vendored
1
node_modules/@ffmpeg/ffmpeg/dist/umd/814.ffmpeg.js.map
generated
vendored
File diff suppressed because one or more lines are too long
2
node_modules/@ffmpeg/ffmpeg/dist/umd/ffmpeg.js
generated
vendored
2
node_modules/@ffmpeg/ffmpeg/dist/umd/ffmpeg.js
generated
vendored
@ -1,2 +0,0 @@
|
|||||||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FFmpegWASM=t():e.FFmpegWASM=t()}(self,(()=>(()=>{"use strict";var e={m:{},d:(t,s)=>{for(var r in s)e.o(s,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:s[r]})},u:e=>e+".ffmpeg.js"};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},(()=>{var t;e.g.importScripts&&(t=e.g.location+"");var s=e.g.document;if(!t&&s&&(s.currentScript&&(t=s.currentScript.src),!t)){var r=s.getElementsByTagName("script");if(r.length)for(var a=r.length-1;a>-1&&!t;)t=r[a--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),e.p=t})(),e.b=document.baseURI||self.location.href;var t,s={};e.r(s),e.d(s,{FFmpeg:()=>i}),function(e){e.LOAD="LOAD",e.EXEC="EXEC",e.WRITE_FILE="WRITE_FILE",e.READ_FILE="READ_FILE",e.DELETE_FILE="DELETE_FILE",e.RENAME="RENAME",e.CREATE_DIR="CREATE_DIR",e.LIST_DIR="LIST_DIR",e.DELETE_DIR="DELETE_DIR",e.ERROR="ERROR",e.DOWNLOAD="DOWNLOAD",e.PROGRESS="PROGRESS",e.LOG="LOG",e.MOUNT="MOUNT",e.UNMOUNT="UNMOUNT"}(t||(t={}));const r=(()=>{let e=0;return()=>e++})(),a=(new Error("unknown message type"),new Error("ffmpeg is not loaded, call `await ffmpeg.load()` first")),o=new Error("called FFmpeg.terminate()");new Error("failed to import ffmpeg-core.js");class i{#e=null;#t={};#s={};#r=[];#a=[];loaded=!1;#o=()=>{this.#e&&(this.#e.onmessage=({data:{id:e,type:s,data:r}})=>{switch(s){case t.LOAD:this.loaded=!0,this.#t[e](r);break;case t.MOUNT:case t.UNMOUNT:case t.EXEC:case t.WRITE_FILE:case t.READ_FILE:case t.DELETE_FILE:case t.RENAME:case t.CREATE_DIR:case t.LIST_DIR:case t.DELETE_DIR:this.#t[e](r);break;case t.LOG:this.#r.forEach((e=>e(r)));break;case t.PROGRESS:this.#a.forEach((e=>e(r)));break;case t.ERROR:this.#s[e](r)}delete this.#t[e],delete this.#s[e]})};#i=({type:e,data:t},s=[],o)=>this.#e?new Promise(((a,i)=>{const n=r();this.#e&&this.#e.postMessage({id:n,type:e,data:t},s),this.#t[n]=a,this.#s[n]=i,o?.addEventListener("abort",(()=>{i(new DOMException(`Message # ${n} was aborted`,"AbortError"))}),{once:!0})})):Promise.reject(a);on(e,t){"log"===e?this.#r.push(t):"progress"===e&&this.#a.push(t)}off(e,t){"log"===e?this.#r=this.#r.filter((e=>e!==t)):"progress"===e&&(this.#a=this.#a.filter((e=>e!==t)))}load=({classWorkerURL:s,...r}={},{signal:a}={})=>(this.#e||(this.#e=s?new Worker(new URL(s,"file:///home/jeromewu/ffmpeg.wasm/packages/ffmpeg/dist/esm/classes.js"),{type:"module"}):new Worker(new URL(e.p+e.u(814),e.b),{type:void 0}),this.#o()),this.#i({type:t.LOAD,data:r},void 0,a));exec=(e,s=-1,{signal:r}={})=>this.#i({type:t.EXEC,data:{args:e,timeout:s}},void 0,r);terminate=()=>{const e=Object.keys(this.#s);for(const t of e)this.#s[t](o),delete this.#s[t],delete this.#t[t];this.#e&&(this.#e.terminate(),this.#e=null,this.loaded=!1)};writeFile=(e,s,{signal:r}={})=>{const a=[];return s instanceof Uint8Array&&a.push(s.buffer),this.#i({type:t.WRITE_FILE,data:{path:e,data:s}},a,r)};mount=(e,s,r)=>this.#i({type:t.MOUNT,data:{fsType:e,options:s,mountPoint:r}},[]);unmount=e=>this.#i({type:t.UNMOUNT,data:{mountPoint:e}},[]);readFile=(e,s="binary",{signal:r}={})=>this.#i({type:t.READ_FILE,data:{path:e,encoding:s}},void 0,r);deleteFile=(e,{signal:s}={})=>this.#i({type:t.DELETE_FILE,data:{path:e}},void 0,s);rename=(e,s,{signal:r}={})=>this.#i({type:t.RENAME,data:{oldPath:e,newPath:s}},void 0,r);createDir=(e,{signal:s}={})=>this.#i({type:t.CREATE_DIR,data:{path:e}},void 0,s);listDir=(e,{signal:s}={})=>this.#i({type:t.LIST_DIR,data:{path:e}},void 0,s);deleteDir=(e,{signal:s}={})=>this.#i({type:t.DELETE_DIR,data:{path:e}},void 0,s)}return s})()));
|
|
||||||
//# sourceMappingURL=ffmpeg.js.map
|
|
1
node_modules/@ffmpeg/ffmpeg/dist/umd/ffmpeg.js.map
generated
vendored
1
node_modules/@ffmpeg/ffmpeg/dist/umd/ffmpeg.js.map
generated
vendored
File diff suppressed because one or more lines are too long
64
node_modules/@ffmpeg/ffmpeg/package.json
generated
vendored
64
node_modules/@ffmpeg/ffmpeg/package.json
generated
vendored
@ -1,64 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@ffmpeg/ffmpeg",
|
|
||||||
"version": "0.12.10",
|
|
||||||
"description": "FFmpeg WebAssembly version for browser",
|
|
||||||
"main": "./dist/umd/ffmpeg.js",
|
|
||||||
"types": "./dist/esm/index.d.ts",
|
|
||||||
"exports": {
|
|
||||||
".": {
|
|
||||||
"types": "./dist/esm/index.d.ts",
|
|
||||||
"node": "./dist/esm/empty.mjs",
|
|
||||||
"default": {
|
|
||||||
"import": "./dist/esm/index.js",
|
|
||||||
"require": "./dist/umd/ffmpeg.js"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"dev": "webpack -w --mode development",
|
|
||||||
"lint": "eslint src",
|
|
||||||
"clean": "rimraf dist",
|
|
||||||
"build:esm": "tsc -p tsconfig.esm.json",
|
|
||||||
"build:umd": "webpack",
|
|
||||||
"build": "npm run clean && npm run build:esm && npm run build:umd",
|
|
||||||
"prepublishOnly": "npm run build"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"dist",
|
|
||||||
"types/ffmpeg.d.ts"
|
|
||||||
],
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/ffmpegwasm/ffmpeg.wasm.git"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"ffmpeg",
|
|
||||||
"WebAssembly",
|
|
||||||
"video",
|
|
||||||
"audio",
|
|
||||||
"transcode"
|
|
||||||
],
|
|
||||||
"author": "Jerome Wu <jeromewus@gmail.com>",
|
|
||||||
"license": "MIT",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/ffmpegwasm/ffmpeg.wasm/issues"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=18.x"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/ffmpegwasm/ffmpeg.wasm#readme",
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@typescript-eslint/eslint-plugin": "^6.1.0",
|
|
||||||
"@typescript-eslint/parser": "^6.1.0",
|
|
||||||
"eslint": "^8.45.0",
|
|
||||||
"rimraf": "^5.0.1",
|
|
||||||
"typescript": "^5.1.6",
|
|
||||||
"webpack-cli": "^5.1.4"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"@ffmpeg/types": "^0.12.2"
|
|
||||||
}
|
|
||||||
}
|
|
32
node_modules/@ffmpeg/types/package.json
generated
vendored
32
node_modules/@ffmpeg/types/package.json
generated
vendored
@ -1,32 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@ffmpeg/types",
|
|
||||||
"version": "0.12.2",
|
|
||||||
"description": "ffmpeg.wasm types",
|
|
||||||
"types": "types",
|
|
||||||
"files": [
|
|
||||||
"types"
|
|
||||||
],
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/ffmpegwasm/ffmpeg.wasm.git"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"ffmpeg",
|
|
||||||
"WebAssembly",
|
|
||||||
"video",
|
|
||||||
"audio",
|
|
||||||
"transcode"
|
|
||||||
],
|
|
||||||
"author": "Jerome Wu <jeromewus@gmail.com>",
|
|
||||||
"license": "MIT",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/ffmpegwasm/ffmpeg.wasm/issues"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=16.x"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/ffmpegwasm/ffmpeg.wasm#readme",
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
}
|
|
||||||
}
|
|
131
node_modules/@ffmpeg/types/types/index.d.ts
generated
vendored
131
node_modules/@ffmpeg/types/types/index.d.ts
generated
vendored
@ -1,131 +0,0 @@
|
|||||||
// TODO: Add lint and test.
|
|
||||||
|
|
||||||
export type Pointer = number;
|
|
||||||
|
|
||||||
export type StringPointer = Pointer;
|
|
||||||
export type StringArrayPointer = Pointer;
|
|
||||||
export type DateString = string;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Options for readFile.
|
|
||||||
*
|
|
||||||
* @see [Emscripten File System API](https://emscripten.org/docs/api_reference/Filesystem-API.html#FS.readFile)
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
export interface ReadFileOptions {
|
|
||||||
/** encoding of the file, must be `binary` or `utf8` */
|
|
||||||
encdoing: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Describes attributes of a node. (a.k.a file, directory)
|
|
||||||
*
|
|
||||||
* @see [Emscripten File System API](https://emscripten.org/docs/api_reference/Filesystem-API.html#FS.stat)
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
export interface Stat {
|
|
||||||
dev: number;
|
|
||||||
ino: number;
|
|
||||||
mode: number;
|
|
||||||
nlink: number;
|
|
||||||
uid: number;
|
|
||||||
gid: number;
|
|
||||||
rdev: number;
|
|
||||||
size: number;
|
|
||||||
atime: DateString;
|
|
||||||
mtime: DateString;
|
|
||||||
ctime: DateString;
|
|
||||||
blksize: number;
|
|
||||||
blocks: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FSFilesystemWORKERFS {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FSFilesystemMEMFS {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FSFilesystems {
|
|
||||||
WORKERFS: FSFilesystemWORKERFS;
|
|
||||||
MEMFS: FSFilesystemMEMFS;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type FSFilesystem =
|
|
||||||
| FSFilesystemWORKERFS
|
|
||||||
| FSFilesystemMEMFS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Functions to interact with Emscripten FS library.
|
|
||||||
*
|
|
||||||
* @see [Emscripten File System API](https://emscripten.org/docs/api_reference/Filesystem-API.html)
|
|
||||||
* @category File System
|
|
||||||
*/
|
|
||||||
export interface FS {
|
|
||||||
mkdir: (path: string) => void;
|
|
||||||
rmdir: (path: string) => void;
|
|
||||||
rename: (oldPath: string, newPath: string) => void;
|
|
||||||
writeFile: (path: string, data: Uint8Array | string) => void;
|
|
||||||
readFile: (path: string, opts: OptionReadFile) => Uint8Array | string;
|
|
||||||
readdir: (path: string) => string[];
|
|
||||||
unlink: (path: string) => void;
|
|
||||||
stat: (path: string) => Stat;
|
|
||||||
/** mode is a numeric notation of permission, @see [Numeric Notation](https://en.wikipedia.org/wiki/File-system_permissions#Numeric_notation) */
|
|
||||||
isFile: (mode: number) => boolean;
|
|
||||||
/** mode is a numeric notation of permission, @see [Numeric Notation](https://en.wikipedia.org/wiki/File-system_permissions#Numeric_notation) */
|
|
||||||
isDir: (mode: number) => boolean;
|
|
||||||
mount: (fileSystemType: FSFilesystem, data: WorkerFSMountConfig, path: string) => void;
|
|
||||||
unmount: (path: string) => void;
|
|
||||||
filesystems: FSFilesystems;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Arguments passed to setLogger callback function.
|
|
||||||
*/
|
|
||||||
export interface Log {
|
|
||||||
/** file descriptor of the log, must be `stdout` or `stderr` */
|
|
||||||
type: string;
|
|
||||||
message: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Arguments passed to setProgress callback function.
|
|
||||||
*/
|
|
||||||
export interface Progress {
|
|
||||||
/** progress of the operation, interval = [0, 1] */
|
|
||||||
progress: number;
|
|
||||||
/** time of transcoded media in microseconds, ex: if a video is 10 seconds long, when time is 1000000 means 1 second of the video is transcoded already. */
|
|
||||||
time: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* FFmpeg core module, an object to interact with ffmpeg.
|
|
||||||
*/
|
|
||||||
export interface FFmpegCoreModule {
|
|
||||||
/** default arguments prepend when running exec() */
|
|
||||||
DEFAULT_ARGS: string[];
|
|
||||||
FS: FS;
|
|
||||||
NULL: Pointer;
|
|
||||||
SIZE_I32: number;
|
|
||||||
|
|
||||||
/** return code of the ffmpeg exec, error when ret != 0 */
|
|
||||||
ret: number;
|
|
||||||
timeout: number;
|
|
||||||
mainScriptUrlOrBlob: string;
|
|
||||||
|
|
||||||
exec: (...args: string[]) => number;
|
|
||||||
reset: () => void;
|
|
||||||
setLogger: (logger: (log: Log) => void) => void;
|
|
||||||
setTimeout: (timeout: number) => void;
|
|
||||||
setProgress: (handler: (progress: Progress) => void) => void;
|
|
||||||
|
|
||||||
locateFile: (path: string, prefix: string) => string;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Factory of FFmpegCoreModule.
|
|
||||||
*/
|
|
||||||
export type FFmpegCoreModuleFactory = (
|
|
||||||
moduleOverrides?: Partial<FFmpegCoreModule>
|
|
||||||
) => Promise<FFmpegCoreModule>;
|
|
1
node_modules/@ffmpeg/util/dist/cjs/const.d.ts
generated
vendored
1
node_modules/@ffmpeg/util/dist/cjs/const.d.ts
generated
vendored
@ -1 +0,0 @@
|
|||||||
export declare const HeaderContentLength = "Content-Length";
|
|
4
node_modules/@ffmpeg/util/dist/cjs/const.js
generated
vendored
4
node_modules/@ffmpeg/util/dist/cjs/const.js
generated
vendored
@ -1,4 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.HeaderContentLength = void 0;
|
|
||||||
exports.HeaderContentLength = "Content-Length";
|
|
2
node_modules/@ffmpeg/util/dist/cjs/errors.d.ts
generated
vendored
2
node_modules/@ffmpeg/util/dist/cjs/errors.d.ts
generated
vendored
@ -1,2 +0,0 @@
|
|||||||
export declare const ERROR_RESPONSE_BODY_READER: Error;
|
|
||||||
export declare const ERROR_INCOMPLETED_DOWNLOAD: Error;
|
|
5
node_modules/@ffmpeg/util/dist/cjs/errors.js
generated
vendored
5
node_modules/@ffmpeg/util/dist/cjs/errors.js
generated
vendored
@ -1,5 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.ERROR_INCOMPLETED_DOWNLOAD = exports.ERROR_RESPONSE_BODY_READER = void 0;
|
|
||||||
exports.ERROR_RESPONSE_BODY_READER = new Error("failed to get response body reader");
|
|
||||||
exports.ERROR_INCOMPLETED_DOWNLOAD = new Error("failed to complete download");
|
|
50
node_modules/@ffmpeg/util/dist/cjs/index.d.ts
generated
vendored
50
node_modules/@ffmpeg/util/dist/cjs/index.d.ts
generated
vendored
@ -1,50 +0,0 @@
|
|||||||
import { ProgressCallback } from "./types.js";
|
|
||||||
/**
|
|
||||||
* An util function to fetch data from url string, base64, URL, File or Blob format.
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ```ts
|
|
||||||
* // URL
|
|
||||||
* await fetchFile("http://localhost:3000/video.mp4");
|
|
||||||
* // base64
|
|
||||||
* await fetchFile("data:<type>;base64,wL2dvYWwgbW9yZ...");
|
|
||||||
* // URL
|
|
||||||
* await fetchFile(new URL("video.mp4", import.meta.url));
|
|
||||||
* // File
|
|
||||||
* fileInput.addEventListener('change', (e) => {
|
|
||||||
* await fetchFile(e.target.files[0]);
|
|
||||||
* });
|
|
||||||
* // Blob
|
|
||||||
* const blob = new Blob(...);
|
|
||||||
* await fetchFile(blob);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export declare const fetchFile: (file?: string | File | Blob) => Promise<Uint8Array>;
|
|
||||||
/**
|
|
||||||
* importScript dynamically import a script, useful when you
|
|
||||||
* want to use different versions of ffmpeg.wasm based on environment.
|
|
||||||
*
|
|
||||||
* Example:
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* await importScript("http://localhost:3000/ffmpeg.js");
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export declare const importScript: (url: string) => Promise<void>;
|
|
||||||
/**
|
|
||||||
* Download content of a URL with progress.
|
|
||||||
*
|
|
||||||
* Progress only works when Content-Length is provided by the server.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
export declare const downloadWithProgress: (url: string | URL, cb?: ProgressCallback) => Promise<ArrayBuffer>;
|
|
||||||
/**
|
|
||||||
* toBlobURL fetches data from an URL and return a blob URL.
|
|
||||||
*
|
|
||||||
* Example:
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* await toBlobURL("http://localhost:3000/ffmpeg.js", "text/javascript");
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export declare const toBlobURL: (url: string, mimeType: string, progress?: boolean, cb?: ProgressCallback) => Promise<string>;
|
|
173
node_modules/@ffmpeg/util/dist/cjs/index.js
generated
vendored
173
node_modules/@ffmpeg/util/dist/cjs/index.js
generated
vendored
@ -1,173 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
||||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
||||||
return new (P || (P = Promise))(function (resolve, reject) {
|
|
||||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
||||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
||||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
||||||
});
|
|
||||||
};
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.toBlobURL = exports.downloadWithProgress = exports.importScript = exports.fetchFile = void 0;
|
|
||||||
const errors_js_1 = require("./errors.js");
|
|
||||||
const const_js_1 = require("./const.js");
|
|
||||||
const readFromBlobOrFile = (blob) => new Promise((resolve, reject) => {
|
|
||||||
const fileReader = new FileReader();
|
|
||||||
fileReader.onload = () => {
|
|
||||||
const { result } = fileReader;
|
|
||||||
if (result instanceof ArrayBuffer) {
|
|
||||||
resolve(new Uint8Array(result));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resolve(new Uint8Array());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
fileReader.onerror = (event) => {
|
|
||||||
var _a, _b;
|
|
||||||
reject(Error(`File could not be read! Code=${((_b = (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.error) === null || _b === void 0 ? void 0 : _b.code) || -1}`));
|
|
||||||
};
|
|
||||||
fileReader.readAsArrayBuffer(blob);
|
|
||||||
});
|
|
||||||
/**
|
|
||||||
* An util function to fetch data from url string, base64, URL, File or Blob format.
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ```ts
|
|
||||||
* // URL
|
|
||||||
* await fetchFile("http://localhost:3000/video.mp4");
|
|
||||||
* // base64
|
|
||||||
* await fetchFile("data:<type>;base64,wL2dvYWwgbW9yZ...");
|
|
||||||
* // URL
|
|
||||||
* await fetchFile(new URL("video.mp4", import.meta.url));
|
|
||||||
* // File
|
|
||||||
* fileInput.addEventListener('change', (e) => {
|
|
||||||
* await fetchFile(e.target.files[0]);
|
|
||||||
* });
|
|
||||||
* // Blob
|
|
||||||
* const blob = new Blob(...);
|
|
||||||
* await fetchFile(blob);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
const fetchFile = (file) => __awaiter(void 0, void 0, void 0, function* () {
|
|
||||||
let data;
|
|
||||||
if (typeof file === "string") {
|
|
||||||
/* From base64 format */
|
|
||||||
if (/data:_data\/([a-zA-Z]*);base64,([^"]*)/.test(file)) {
|
|
||||||
data = atob(file.split(",")[1])
|
|
||||||
.split("")
|
|
||||||
.map((c) => c.charCodeAt(0));
|
|
||||||
/* From remote server/URL */
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
data = yield (yield fetch(file)).arrayBuffer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (file instanceof URL) {
|
|
||||||
data = yield (yield fetch(file)).arrayBuffer();
|
|
||||||
}
|
|
||||||
else if (file instanceof File || file instanceof Blob) {
|
|
||||||
data = yield readFromBlobOrFile(file);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new Uint8Array();
|
|
||||||
}
|
|
||||||
return new Uint8Array(data);
|
|
||||||
});
|
|
||||||
exports.fetchFile = fetchFile;
|
|
||||||
/**
|
|
||||||
* importScript dynamically import a script, useful when you
|
|
||||||
* want to use different versions of ffmpeg.wasm based on environment.
|
|
||||||
*
|
|
||||||
* Example:
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* await importScript("http://localhost:3000/ffmpeg.js");
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
const importScript = (url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
const script = document.createElement("script");
|
|
||||||
const eventHandler = () => {
|
|
||||||
script.removeEventListener("load", eventHandler);
|
|
||||||
resolve();
|
|
||||||
};
|
|
||||||
script.src = url;
|
|
||||||
script.type = "text/javascript";
|
|
||||||
script.addEventListener("load", eventHandler);
|
|
||||||
document.getElementsByTagName("head")[0].appendChild(script);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
exports.importScript = importScript;
|
|
||||||
/**
|
|
||||||
* Download content of a URL with progress.
|
|
||||||
*
|
|
||||||
* Progress only works when Content-Length is provided by the server.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
const downloadWithProgress = (url, cb) => __awaiter(void 0, void 0, void 0, function* () {
|
|
||||||
var _a;
|
|
||||||
const resp = yield fetch(url);
|
|
||||||
let buf;
|
|
||||||
try {
|
|
||||||
// Set total to -1 to indicate that there is not Content-Type Header.
|
|
||||||
const total = parseInt(resp.headers.get(const_js_1.HeaderContentLength) || "-1");
|
|
||||||
const reader = (_a = resp.body) === null || _a === void 0 ? void 0 : _a.getReader();
|
|
||||||
if (!reader)
|
|
||||||
throw errors_js_1.ERROR_RESPONSE_BODY_READER;
|
|
||||||
const chunks = [];
|
|
||||||
let received = 0;
|
|
||||||
for (;;) {
|
|
||||||
const { done, value } = yield reader.read();
|
|
||||||
const delta = value ? value.length : 0;
|
|
||||||
if (done) {
|
|
||||||
if (total != -1 && total !== received)
|
|
||||||
throw errors_js_1.ERROR_INCOMPLETED_DOWNLOAD;
|
|
||||||
cb && cb({ url, total, received, delta, done });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
chunks.push(value);
|
|
||||||
received += delta;
|
|
||||||
cb && cb({ url, total, received, delta, done });
|
|
||||||
}
|
|
||||||
const data = new Uint8Array(received);
|
|
||||||
let position = 0;
|
|
||||||
for (const chunk of chunks) {
|
|
||||||
data.set(chunk, position);
|
|
||||||
position += chunk.length;
|
|
||||||
}
|
|
||||||
buf = data.buffer;
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
console.log(`failed to send download progress event: `, e);
|
|
||||||
// Fetch arrayBuffer directly when it is not possible to get progress.
|
|
||||||
buf = yield resp.arrayBuffer();
|
|
||||||
cb &&
|
|
||||||
cb({
|
|
||||||
url,
|
|
||||||
total: buf.byteLength,
|
|
||||||
received: buf.byteLength,
|
|
||||||
delta: 0,
|
|
||||||
done: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return buf;
|
|
||||||
});
|
|
||||||
exports.downloadWithProgress = downloadWithProgress;
|
|
||||||
/**
|
|
||||||
* toBlobURL fetches data from an URL and return a blob URL.
|
|
||||||
*
|
|
||||||
* Example:
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* await toBlobURL("http://localhost:3000/ffmpeg.js", "text/javascript");
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
const toBlobURL = (url, mimeType, progress = false, cb) => __awaiter(void 0, void 0, void 0, function* () {
|
|
||||||
const buf = progress
|
|
||||||
? yield (0, exports.downloadWithProgress)(url, cb)
|
|
||||||
: yield (yield fetch(url)).arrayBuffer();
|
|
||||||
const blob = new Blob([buf], { type: mimeType });
|
|
||||||
return URL.createObjectURL(blob);
|
|
||||||
});
|
|
||||||
exports.toBlobURL = toBlobURL;
|
|
8
node_modules/@ffmpeg/util/dist/cjs/types.d.ts
generated
vendored
8
node_modules/@ffmpeg/util/dist/cjs/types.d.ts
generated
vendored
@ -1,8 +0,0 @@
|
|||||||
export interface DownloadProgressEvent {
|
|
||||||
url: string | URL;
|
|
||||||
total: number;
|
|
||||||
received: number;
|
|
||||||
delta: number;
|
|
||||||
done: boolean;
|
|
||||||
}
|
|
||||||
export type ProgressCallback = (event: DownloadProgressEvent) => void;
|
|
2
node_modules/@ffmpeg/util/dist/cjs/types.js
generated
vendored
2
node_modules/@ffmpeg/util/dist/cjs/types.js
generated
vendored
@ -1,2 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
node_modules/@ffmpeg/util/dist/esm/const.d.ts
generated
vendored
1
node_modules/@ffmpeg/util/dist/esm/const.d.ts
generated
vendored
@ -1 +0,0 @@
|
|||||||
export declare const HeaderContentLength = "Content-Length";
|
|
1
node_modules/@ffmpeg/util/dist/esm/const.js
generated
vendored
1
node_modules/@ffmpeg/util/dist/esm/const.js
generated
vendored
@ -1 +0,0 @@
|
|||||||
export const HeaderContentLength = "Content-Length";
|
|
2
node_modules/@ffmpeg/util/dist/esm/errors.d.ts
generated
vendored
2
node_modules/@ffmpeg/util/dist/esm/errors.d.ts
generated
vendored
@ -1,2 +0,0 @@
|
|||||||
export declare const ERROR_RESPONSE_BODY_READER: Error;
|
|
||||||
export declare const ERROR_INCOMPLETED_DOWNLOAD: Error;
|
|
2
node_modules/@ffmpeg/util/dist/esm/errors.js
generated
vendored
2
node_modules/@ffmpeg/util/dist/esm/errors.js
generated
vendored
@ -1,2 +0,0 @@
|
|||||||
export const ERROR_RESPONSE_BODY_READER = new Error("failed to get response body reader");
|
|
||||||
export const ERROR_INCOMPLETED_DOWNLOAD = new Error("failed to complete download");
|
|
50
node_modules/@ffmpeg/util/dist/esm/index.d.ts
generated
vendored
50
node_modules/@ffmpeg/util/dist/esm/index.d.ts
generated
vendored
@ -1,50 +0,0 @@
|
|||||||
import { ProgressCallback } from "./types.js";
|
|
||||||
/**
|
|
||||||
* An util function to fetch data from url string, base64, URL, File or Blob format.
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ```ts
|
|
||||||
* // URL
|
|
||||||
* await fetchFile("http://localhost:3000/video.mp4");
|
|
||||||
* // base64
|
|
||||||
* await fetchFile("data:<type>;base64,wL2dvYWwgbW9yZ...");
|
|
||||||
* // URL
|
|
||||||
* await fetchFile(new URL("video.mp4", import.meta.url));
|
|
||||||
* // File
|
|
||||||
* fileInput.addEventListener('change', (e) => {
|
|
||||||
* await fetchFile(e.target.files[0]);
|
|
||||||
* });
|
|
||||||
* // Blob
|
|
||||||
* const blob = new Blob(...);
|
|
||||||
* await fetchFile(blob);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export declare const fetchFile: (file?: string | File | Blob) => Promise<Uint8Array>;
|
|
||||||
/**
|
|
||||||
* importScript dynamically import a script, useful when you
|
|
||||||
* want to use different versions of ffmpeg.wasm based on environment.
|
|
||||||
*
|
|
||||||
* Example:
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* await importScript("http://localhost:3000/ffmpeg.js");
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export declare const importScript: (url: string) => Promise<void>;
|
|
||||||
/**
|
|
||||||
* Download content of a URL with progress.
|
|
||||||
*
|
|
||||||
* Progress only works when Content-Length is provided by the server.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
export declare const downloadWithProgress: (url: string | URL, cb?: ProgressCallback) => Promise<ArrayBuffer>;
|
|
||||||
/**
|
|
||||||
* toBlobURL fetches data from an URL and return a blob URL.
|
|
||||||
*
|
|
||||||
* Example:
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* await toBlobURL("http://localhost:3000/ffmpeg.js", "text/javascript");
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export declare const toBlobURL: (url: string, mimeType: string, progress?: boolean, cb?: ProgressCallback) => Promise<string>;
|
|
153
node_modules/@ffmpeg/util/dist/esm/index.js
generated
vendored
153
node_modules/@ffmpeg/util/dist/esm/index.js
generated
vendored
@ -1,153 +0,0 @@
|
|||||||
import { ERROR_RESPONSE_BODY_READER, ERROR_INCOMPLETED_DOWNLOAD, } from "./errors.js";
|
|
||||||
import { HeaderContentLength } from "./const.js";
|
|
||||||
const readFromBlobOrFile = (blob) => new Promise((resolve, reject) => {
|
|
||||||
const fileReader = new FileReader();
|
|
||||||
fileReader.onload = () => {
|
|
||||||
const { result } = fileReader;
|
|
||||||
if (result instanceof ArrayBuffer) {
|
|
||||||
resolve(new Uint8Array(result));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
resolve(new Uint8Array());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
fileReader.onerror = (event) => {
|
|
||||||
reject(Error(`File could not be read! Code=${event?.target?.error?.code || -1}`));
|
|
||||||
};
|
|
||||||
fileReader.readAsArrayBuffer(blob);
|
|
||||||
});
|
|
||||||
/**
|
|
||||||
* An util function to fetch data from url string, base64, URL, File or Blob format.
|
|
||||||
*
|
|
||||||
* Examples:
|
|
||||||
* ```ts
|
|
||||||
* // URL
|
|
||||||
* await fetchFile("http://localhost:3000/video.mp4");
|
|
||||||
* // base64
|
|
||||||
* await fetchFile("data:<type>;base64,wL2dvYWwgbW9yZ...");
|
|
||||||
* // URL
|
|
||||||
* await fetchFile(new URL("video.mp4", import.meta.url));
|
|
||||||
* // File
|
|
||||||
* fileInput.addEventListener('change', (e) => {
|
|
||||||
* await fetchFile(e.target.files[0]);
|
|
||||||
* });
|
|
||||||
* // Blob
|
|
||||||
* const blob = new Blob(...);
|
|
||||||
* await fetchFile(blob);
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export const fetchFile = async (file) => {
|
|
||||||
let data;
|
|
||||||
if (typeof file === "string") {
|
|
||||||
/* From base64 format */
|
|
||||||
if (/data:_data\/([a-zA-Z]*);base64,([^"]*)/.test(file)) {
|
|
||||||
data = atob(file.split(",")[1])
|
|
||||||
.split("")
|
|
||||||
.map((c) => c.charCodeAt(0));
|
|
||||||
/* From remote server/URL */
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
data = await (await fetch(file)).arrayBuffer();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (file instanceof URL) {
|
|
||||||
data = await (await fetch(file)).arrayBuffer();
|
|
||||||
}
|
|
||||||
else if (file instanceof File || file instanceof Blob) {
|
|
||||||
data = await readFromBlobOrFile(file);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return new Uint8Array();
|
|
||||||
}
|
|
||||||
return new Uint8Array(data);
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* importScript dynamically import a script, useful when you
|
|
||||||
* want to use different versions of ffmpeg.wasm based on environment.
|
|
||||||
*
|
|
||||||
* Example:
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* await importScript("http://localhost:3000/ffmpeg.js");
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export const importScript = async (url) => new Promise((resolve) => {
|
|
||||||
const script = document.createElement("script");
|
|
||||||
const eventHandler = () => {
|
|
||||||
script.removeEventListener("load", eventHandler);
|
|
||||||
resolve();
|
|
||||||
};
|
|
||||||
script.src = url;
|
|
||||||
script.type = "text/javascript";
|
|
||||||
script.addEventListener("load", eventHandler);
|
|
||||||
document.getElementsByTagName("head")[0].appendChild(script);
|
|
||||||
});
|
|
||||||
/**
|
|
||||||
* Download content of a URL with progress.
|
|
||||||
*
|
|
||||||
* Progress only works when Content-Length is provided by the server.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
export const downloadWithProgress = async (url, cb) => {
|
|
||||||
const resp = await fetch(url);
|
|
||||||
let buf;
|
|
||||||
try {
|
|
||||||
// Set total to -1 to indicate that there is not Content-Type Header.
|
|
||||||
const total = parseInt(resp.headers.get(HeaderContentLength) || "-1");
|
|
||||||
const reader = resp.body?.getReader();
|
|
||||||
if (!reader)
|
|
||||||
throw ERROR_RESPONSE_BODY_READER;
|
|
||||||
const chunks = [];
|
|
||||||
let received = 0;
|
|
||||||
for (;;) {
|
|
||||||
const { done, value } = await reader.read();
|
|
||||||
const delta = value ? value.length : 0;
|
|
||||||
if (done) {
|
|
||||||
if (total != -1 && total !== received)
|
|
||||||
throw ERROR_INCOMPLETED_DOWNLOAD;
|
|
||||||
cb && cb({ url, total, received, delta, done });
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
chunks.push(value);
|
|
||||||
received += delta;
|
|
||||||
cb && cb({ url, total, received, delta, done });
|
|
||||||
}
|
|
||||||
const data = new Uint8Array(received);
|
|
||||||
let position = 0;
|
|
||||||
for (const chunk of chunks) {
|
|
||||||
data.set(chunk, position);
|
|
||||||
position += chunk.length;
|
|
||||||
}
|
|
||||||
buf = data.buffer;
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
console.log(`failed to send download progress event: `, e);
|
|
||||||
// Fetch arrayBuffer directly when it is not possible to get progress.
|
|
||||||
buf = await resp.arrayBuffer();
|
|
||||||
cb &&
|
|
||||||
cb({
|
|
||||||
url,
|
|
||||||
total: buf.byteLength,
|
|
||||||
received: buf.byteLength,
|
|
||||||
delta: 0,
|
|
||||||
done: true,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return buf;
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* toBlobURL fetches data from an URL and return a blob URL.
|
|
||||||
*
|
|
||||||
* Example:
|
|
||||||
*
|
|
||||||
* ```ts
|
|
||||||
* await toBlobURL("http://localhost:3000/ffmpeg.js", "text/javascript");
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export const toBlobURL = async (url, mimeType, progress = false, cb) => {
|
|
||||||
const buf = progress
|
|
||||||
? await downloadWithProgress(url, cb)
|
|
||||||
: await (await fetch(url)).arrayBuffer();
|
|
||||||
const blob = new Blob([buf], { type: mimeType });
|
|
||||||
return URL.createObjectURL(blob);
|
|
||||||
};
|
|
8
node_modules/@ffmpeg/util/dist/esm/types.d.ts
generated
vendored
8
node_modules/@ffmpeg/util/dist/esm/types.d.ts
generated
vendored
@ -1,8 +0,0 @@
|
|||||||
export interface DownloadProgressEvent {
|
|
||||||
url: string | URL;
|
|
||||||
total: number;
|
|
||||||
received: number;
|
|
||||||
delta: number;
|
|
||||||
done: boolean;
|
|
||||||
}
|
|
||||||
export type ProgressCallback = (event: DownloadProgressEvent) => void;
|
|
1
node_modules/@ffmpeg/util/dist/esm/types.js
generated
vendored
1
node_modules/@ffmpeg/util/dist/esm/types.js
generated
vendored
@ -1 +0,0 @@
|
|||||||
export {};
|
|
1
node_modules/@ffmpeg/util/dist/umd/index.js
generated
vendored
1
node_modules/@ffmpeg/util/dist/umd/index.js
generated
vendored
@ -1 +0,0 @@
|
|||||||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FFmpegUtil=t():e.FFmpegUtil=t()}(self,(()=>(()=>{"use strict";var e={591:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.HeaderContentLength=void 0,t.HeaderContentLength="Content-Length"},431:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ERROR_INCOMPLETED_DOWNLOAD=t.ERROR_RESPONSE_BODY_READER=void 0,t.ERROR_RESPONSE_BODY_READER=new Error("failed to get response body reader"),t.ERROR_INCOMPLETED_DOWNLOAD=new Error("failed to complete download")},915:function(e,t,o){var r=this&&this.__awaiter||function(e,t,o,r){return new(o||(o=Promise))((function(n,i){function d(e){try{l(r.next(e))}catch(e){i(e)}}function a(e){try{l(r.throw(e))}catch(e){i(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(d,a)}l((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:!0}),t.toBlobURL=t.downloadWithProgress=t.importScript=t.fetchFile=void 0;const n=o(431),i=o(591);t.fetchFile=e=>r(void 0,void 0,void 0,(function*(){let t;if("string"==typeof e)t=/data:_data\/([a-zA-Z]*);base64,([^"]*)/.test(e)?atob(e.split(",")[1]).split("").map((e=>e.charCodeAt(0))):yield(yield fetch(e)).arrayBuffer();else if(e instanceof URL)t=yield(yield fetch(e)).arrayBuffer();else{if(!(e instanceof File||e instanceof Blob))return new Uint8Array;t=yield(o=e,new Promise(((e,t)=>{const r=new FileReader;r.onload=()=>{const{result:t}=r;t instanceof ArrayBuffer?e(new Uint8Array(t)):e(new Uint8Array)},r.onerror=e=>{var o,r;t(Error(`File could not be read! Code=${(null===(r=null===(o=null==e?void 0:e.target)||void 0===o?void 0:o.error)||void 0===r?void 0:r.code)||-1}`))},r.readAsArrayBuffer(o)})))}var o;return new Uint8Array(t)})),t.importScript=e=>r(void 0,void 0,void 0,(function*(){return new Promise((t=>{const o=document.createElement("script"),r=()=>{o.removeEventListener("load",r),t()};o.src=e,o.type="text/javascript",o.addEventListener("load",r),document.getElementsByTagName("head")[0].appendChild(o)}))})),t.downloadWithProgress=(e,t)=>r(void 0,void 0,void 0,(function*(){var o;const r=yield fetch(e);let d;try{const a=parseInt(r.headers.get(i.HeaderContentLength)||"-1"),l=null===(o=r.body)||void 0===o?void 0:o.getReader();if(!l)throw n.ERROR_RESPONSE_BODY_READER;const c=[];let s=0;for(;;){const{done:o,value:r}=yield l.read(),i=r?r.length:0;if(o){if(-1!=a&&a!==s)throw n.ERROR_INCOMPLETED_DOWNLOAD;t&&t({url:e,total:a,received:s,delta:i,done:o});break}c.push(r),s+=i,t&&t({url:e,total:a,received:s,delta:i,done:o})}const f=new Uint8Array(s);let u=0;for(const e of c)f.set(e,u),u+=e.length;d=f.buffer}catch(o){console.log("failed to send download progress event: ",o),d=yield r.arrayBuffer(),t&&t({url:e,total:d.byteLength,received:d.byteLength,delta:0,done:!0})}return d})),t.toBlobURL=(e,o,n=!1,i)=>r(void 0,void 0,void 0,(function*(){const r=n?yield(0,t.downloadWithProgress)(e,i):yield(yield fetch(e)).arrayBuffer(),d=new Blob([r],{type:o});return URL.createObjectURL(d)}))}},t={};return function o(r){var n=t[r];if(void 0!==n)return n.exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,o),i.exports}(915)})()));
|
|
56
node_modules/@ffmpeg/util/package.json
generated
vendored
56
node_modules/@ffmpeg/util/package.json
generated
vendored
@ -1,56 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@ffmpeg/util",
|
|
||||||
"version": "0.12.1",
|
|
||||||
"description": "browser utils for @ffmpeg/*",
|
|
||||||
"main": "./dist/cjs/index.js",
|
|
||||||
"types": "./dist/cjs/index.d.ts",
|
|
||||||
"exports": {
|
|
||||||
".": {
|
|
||||||
"types": "./dist/cjs/index.d.ts",
|
|
||||||
"import": "./dist/esm/index.js",
|
|
||||||
"require": "./dist/cjs/index.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"dev": "tsc -p tsconfig-esm.json --watch",
|
|
||||||
"lint": "eslint src",
|
|
||||||
"clean": "rimraf dist",
|
|
||||||
"build:esm": "tsc -p tsconfig.esm.json",
|
|
||||||
"build:umd": "tsc -p tsconfig.cjs.json && webpack",
|
|
||||||
"build": "npm run clean && npm run build:esm && npm run build:umd",
|
|
||||||
"prepublishOnly": "npm run build"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"dist"
|
|
||||||
],
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/ffmpegwasm/ffmpeg.wasm.git"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"ffmpeg",
|
|
||||||
"video",
|
|
||||||
"audio",
|
|
||||||
"transcode"
|
|
||||||
],
|
|
||||||
"author": "Jerome Wu <jeromewus@gmail.com>",
|
|
||||||
"license": "MIT",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/ffmpegwasm/ffmpeg.wasm/issues"
|
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=18.x"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/ffmpegwasm/ffmpeg.wasm#readme",
|
|
||||||
"publishConfig": {
|
|
||||||
"access": "public"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@typescript-eslint/eslint-plugin": "^6.1.0",
|
|
||||||
"@typescript-eslint/parser": "^6.1.0",
|
|
||||||
"eslint": "^8.45.0",
|
|
||||||
"rimraf": "^5.0.1",
|
|
||||||
"typescript": "^5.1.6",
|
|
||||||
"webpack-cli": "^5.1.4"
|
|
||||||
}
|
|
||||||
}
|
|
3
node_modules/@rollup/rollup-darwin-arm64/README.md
generated
vendored
3
node_modules/@rollup/rollup-darwin-arm64/README.md
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
# `@rollup/rollup-darwin-arm64`
|
|
||||||
|
|
||||||
This is the **aarch64-apple-darwin** binary for `rollup`
|
|
19
node_modules/@rollup/rollup-darwin-arm64/package.json
generated
vendored
19
node_modules/@rollup/rollup-darwin-arm64/package.json
generated
vendored
@ -1,19 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@rollup/rollup-darwin-arm64",
|
|
||||||
"version": "4.24.0",
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"files": [
|
|
||||||
"rollup.darwin-arm64.node"
|
|
||||||
],
|
|
||||||
"description": "Native bindings for Rollup",
|
|
||||||
"author": "Lukas Taegert-Atkinson",
|
|
||||||
"homepage": "https://rollupjs.org/",
|
|
||||||
"license": "MIT",
|
|
||||||
"repository": "rollup/rollup",
|
|
||||||
"main": "./rollup.darwin-arm64.node"
|
|
||||||
}
|
|
BIN
node_modules/@rollup/rollup-darwin-arm64/rollup.darwin-arm64.node
generated
vendored
BIN
node_modules/@rollup/rollup-darwin-arm64/rollup.darwin-arm64.node
generated
vendored
Binary file not shown.
21
node_modules/@types/estree/LICENSE
generated
vendored
21
node_modules/@types/estree/LICENSE
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) Microsoft Corporation.
|
|
||||||
|
|
||||||
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
|
|
15
node_modules/@types/estree/README.md
generated
vendored
15
node_modules/@types/estree/README.md
generated
vendored
@ -1,15 +0,0 @@
|
|||||||
# Installation
|
|
||||||
> `npm install --save @types/estree`
|
|
||||||
|
|
||||||
# Summary
|
|
||||||
This package contains type definitions for estree (https://github.com/estree/estree).
|
|
||||||
|
|
||||||
# Details
|
|
||||||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/estree.
|
|
||||||
|
|
||||||
### Additional Details
|
|
||||||
* Last updated: Wed, 18 Sep 2024 09:37:00 GMT
|
|
||||||
* Dependencies: none
|
|
||||||
|
|
||||||
# Credits
|
|
||||||
These definitions were written by [RReverser](https://github.com/RReverser).
|
|
167
node_modules/@types/estree/flow.d.ts
generated
vendored
167
node_modules/@types/estree/flow.d.ts
generated
vendored
@ -1,167 +0,0 @@
|
|||||||
declare namespace ESTree {
|
|
||||||
interface FlowTypeAnnotation extends Node {}
|
|
||||||
|
|
||||||
interface FlowBaseTypeAnnotation extends FlowTypeAnnotation {}
|
|
||||||
|
|
||||||
interface FlowLiteralTypeAnnotation extends FlowTypeAnnotation, Literal {}
|
|
||||||
|
|
||||||
interface FlowDeclaration extends Declaration {}
|
|
||||||
|
|
||||||
interface AnyTypeAnnotation extends FlowBaseTypeAnnotation {}
|
|
||||||
|
|
||||||
interface ArrayTypeAnnotation extends FlowTypeAnnotation {
|
|
||||||
elementType: FlowTypeAnnotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface BooleanLiteralTypeAnnotation extends FlowLiteralTypeAnnotation {}
|
|
||||||
|
|
||||||
interface BooleanTypeAnnotation extends FlowBaseTypeAnnotation {}
|
|
||||||
|
|
||||||
interface ClassImplements extends Node {
|
|
||||||
id: Identifier;
|
|
||||||
typeParameters?: TypeParameterInstantiation | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ClassProperty {
|
|
||||||
key: Expression;
|
|
||||||
value?: Expression | null;
|
|
||||||
typeAnnotation?: TypeAnnotation | null;
|
|
||||||
computed: boolean;
|
|
||||||
static: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface DeclareClass extends FlowDeclaration {
|
|
||||||
id: Identifier;
|
|
||||||
typeParameters?: TypeParameterDeclaration | null;
|
|
||||||
body: ObjectTypeAnnotation;
|
|
||||||
extends: InterfaceExtends[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface DeclareFunction extends FlowDeclaration {
|
|
||||||
id: Identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface DeclareModule extends FlowDeclaration {
|
|
||||||
id: Literal | Identifier;
|
|
||||||
body: BlockStatement;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface DeclareVariable extends FlowDeclaration {
|
|
||||||
id: Identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface FunctionTypeAnnotation extends FlowTypeAnnotation {
|
|
||||||
params: FunctionTypeParam[];
|
|
||||||
returnType: FlowTypeAnnotation;
|
|
||||||
rest?: FunctionTypeParam | null;
|
|
||||||
typeParameters?: TypeParameterDeclaration | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface FunctionTypeParam {
|
|
||||||
name: Identifier;
|
|
||||||
typeAnnotation: FlowTypeAnnotation;
|
|
||||||
optional: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface GenericTypeAnnotation extends FlowTypeAnnotation {
|
|
||||||
id: Identifier | QualifiedTypeIdentifier;
|
|
||||||
typeParameters?: TypeParameterInstantiation | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface InterfaceExtends extends Node {
|
|
||||||
id: Identifier | QualifiedTypeIdentifier;
|
|
||||||
typeParameters?: TypeParameterInstantiation | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface InterfaceDeclaration extends FlowDeclaration {
|
|
||||||
id: Identifier;
|
|
||||||
typeParameters?: TypeParameterDeclaration | null;
|
|
||||||
extends: InterfaceExtends[];
|
|
||||||
body: ObjectTypeAnnotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface IntersectionTypeAnnotation extends FlowTypeAnnotation {
|
|
||||||
types: FlowTypeAnnotation[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface MixedTypeAnnotation extends FlowBaseTypeAnnotation {}
|
|
||||||
|
|
||||||
interface NullableTypeAnnotation extends FlowTypeAnnotation {
|
|
||||||
typeAnnotation: TypeAnnotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface NumberLiteralTypeAnnotation extends FlowLiteralTypeAnnotation {}
|
|
||||||
|
|
||||||
interface NumberTypeAnnotation extends FlowBaseTypeAnnotation {}
|
|
||||||
|
|
||||||
interface StringLiteralTypeAnnotation extends FlowLiteralTypeAnnotation {}
|
|
||||||
|
|
||||||
interface StringTypeAnnotation extends FlowBaseTypeAnnotation {}
|
|
||||||
|
|
||||||
interface TupleTypeAnnotation extends FlowTypeAnnotation {
|
|
||||||
types: FlowTypeAnnotation[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TypeofTypeAnnotation extends FlowTypeAnnotation {
|
|
||||||
argument: FlowTypeAnnotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TypeAlias extends FlowDeclaration {
|
|
||||||
id: Identifier;
|
|
||||||
typeParameters?: TypeParameterDeclaration | null;
|
|
||||||
right: FlowTypeAnnotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TypeAnnotation extends Node {
|
|
||||||
typeAnnotation: FlowTypeAnnotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TypeCastExpression extends Expression {
|
|
||||||
expression: Expression;
|
|
||||||
typeAnnotation: TypeAnnotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TypeParameterDeclaration extends Node {
|
|
||||||
params: Identifier[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface TypeParameterInstantiation extends Node {
|
|
||||||
params: FlowTypeAnnotation[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ObjectTypeAnnotation extends FlowTypeAnnotation {
|
|
||||||
properties: ObjectTypeProperty[];
|
|
||||||
indexers: ObjectTypeIndexer[];
|
|
||||||
callProperties: ObjectTypeCallProperty[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ObjectTypeCallProperty extends Node {
|
|
||||||
value: FunctionTypeAnnotation;
|
|
||||||
static: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ObjectTypeIndexer extends Node {
|
|
||||||
id: Identifier;
|
|
||||||
key: FlowTypeAnnotation;
|
|
||||||
value: FlowTypeAnnotation;
|
|
||||||
static: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface ObjectTypeProperty extends Node {
|
|
||||||
key: Expression;
|
|
||||||
value: FlowTypeAnnotation;
|
|
||||||
optional: boolean;
|
|
||||||
static: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface QualifiedTypeIdentifier extends Node {
|
|
||||||
qualification: Identifier | QualifiedTypeIdentifier;
|
|
||||||
id: Identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface UnionTypeAnnotation extends FlowTypeAnnotation {
|
|
||||||
types: FlowTypeAnnotation[];
|
|
||||||
}
|
|
||||||
|
|
||||||
interface VoidTypeAnnotation extends FlowBaseTypeAnnotation {}
|
|
||||||
}
|
|
684
node_modules/@types/estree/index.d.ts
generated
vendored
684
node_modules/@types/estree/index.d.ts
generated
vendored
@ -1,684 +0,0 @@
|
|||||||
// This definition file follows a somewhat unusual format. ESTree allows
|
|
||||||
// runtime type checks based on the `type` parameter. In order to explain this
|
|
||||||
// to typescript we want to use discriminated union types:
|
|
||||||
// https://github.com/Microsoft/TypeScript/pull/9163
|
|
||||||
//
|
|
||||||
// For ESTree this is a bit tricky because the high level interfaces like
|
|
||||||
// Node or Function are pulling double duty. We want to pass common fields down
|
|
||||||
// to the interfaces that extend them (like Identifier or
|
|
||||||
// ArrowFunctionExpression), but you can't extend a type union or enforce
|
|
||||||
// common fields on them. So we've split the high level interfaces into two
|
|
||||||
// types, a base type which passes down inherited fields, and a type union of
|
|
||||||
// all types which extend the base type. Only the type union is exported, and
|
|
||||||
// the union is how other types refer to the collection of inheriting types.
|
|
||||||
//
|
|
||||||
// This makes the definitions file here somewhat more difficult to maintain,
|
|
||||||
// but it has the notable advantage of making ESTree much easier to use as
|
|
||||||
// an end user.
|
|
||||||
|
|
||||||
export interface BaseNodeWithoutComments {
|
|
||||||
// Every leaf interface that extends BaseNode must specify a type property.
|
|
||||||
// The type property should be a string literal. For example, Identifier
|
|
||||||
// has: `type: "Identifier"`
|
|
||||||
type: string;
|
|
||||||
loc?: SourceLocation | null | undefined;
|
|
||||||
range?: [number, number] | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BaseNode extends BaseNodeWithoutComments {
|
|
||||||
leadingComments?: Comment[] | undefined;
|
|
||||||
trailingComments?: Comment[] | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NodeMap {
|
|
||||||
AssignmentProperty: AssignmentProperty;
|
|
||||||
CatchClause: CatchClause;
|
|
||||||
Class: Class;
|
|
||||||
ClassBody: ClassBody;
|
|
||||||
Expression: Expression;
|
|
||||||
Function: Function;
|
|
||||||
Identifier: Identifier;
|
|
||||||
Literal: Literal;
|
|
||||||
MethodDefinition: MethodDefinition;
|
|
||||||
ModuleDeclaration: ModuleDeclaration;
|
|
||||||
ModuleSpecifier: ModuleSpecifier;
|
|
||||||
Pattern: Pattern;
|
|
||||||
PrivateIdentifier: PrivateIdentifier;
|
|
||||||
Program: Program;
|
|
||||||
Property: Property;
|
|
||||||
PropertyDefinition: PropertyDefinition;
|
|
||||||
SpreadElement: SpreadElement;
|
|
||||||
Statement: Statement;
|
|
||||||
Super: Super;
|
|
||||||
SwitchCase: SwitchCase;
|
|
||||||
TemplateElement: TemplateElement;
|
|
||||||
VariableDeclarator: VariableDeclarator;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Node = NodeMap[keyof NodeMap];
|
|
||||||
|
|
||||||
export interface Comment extends BaseNodeWithoutComments {
|
|
||||||
type: "Line" | "Block";
|
|
||||||
value: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SourceLocation {
|
|
||||||
source?: string | null | undefined;
|
|
||||||
start: Position;
|
|
||||||
end: Position;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Position {
|
|
||||||
/** >= 1 */
|
|
||||||
line: number;
|
|
||||||
/** >= 0 */
|
|
||||||
column: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Program extends BaseNode {
|
|
||||||
type: "Program";
|
|
||||||
sourceType: "script" | "module";
|
|
||||||
body: Array<Directive | Statement | ModuleDeclaration>;
|
|
||||||
comments?: Comment[] | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Directive extends BaseNode {
|
|
||||||
type: "ExpressionStatement";
|
|
||||||
expression: Literal;
|
|
||||||
directive: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BaseFunction extends BaseNode {
|
|
||||||
params: Pattern[];
|
|
||||||
generator?: boolean | undefined;
|
|
||||||
async?: boolean | undefined;
|
|
||||||
// The body is either BlockStatement or Expression because arrow functions
|
|
||||||
// can have a body that's either. FunctionDeclarations and
|
|
||||||
// FunctionExpressions have only BlockStatement bodies.
|
|
||||||
body: BlockStatement | Expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Function = FunctionDeclaration | FunctionExpression | ArrowFunctionExpression;
|
|
||||||
|
|
||||||
export type Statement =
|
|
||||||
| ExpressionStatement
|
|
||||||
| BlockStatement
|
|
||||||
| StaticBlock
|
|
||||||
| EmptyStatement
|
|
||||||
| DebuggerStatement
|
|
||||||
| WithStatement
|
|
||||||
| ReturnStatement
|
|
||||||
| LabeledStatement
|
|
||||||
| BreakStatement
|
|
||||||
| ContinueStatement
|
|
||||||
| IfStatement
|
|
||||||
| SwitchStatement
|
|
||||||
| ThrowStatement
|
|
||||||
| TryStatement
|
|
||||||
| WhileStatement
|
|
||||||
| DoWhileStatement
|
|
||||||
| ForStatement
|
|
||||||
| ForInStatement
|
|
||||||
| ForOfStatement
|
|
||||||
| Declaration;
|
|
||||||
|
|
||||||
export interface BaseStatement extends BaseNode {}
|
|
||||||
|
|
||||||
export interface EmptyStatement extends BaseStatement {
|
|
||||||
type: "EmptyStatement";
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BlockStatement extends BaseStatement {
|
|
||||||
type: "BlockStatement";
|
|
||||||
body: Statement[];
|
|
||||||
innerComments?: Comment[] | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface StaticBlock extends Omit<BlockStatement, "type"> {
|
|
||||||
type: "StaticBlock";
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ExpressionStatement extends BaseStatement {
|
|
||||||
type: "ExpressionStatement";
|
|
||||||
expression: Expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface IfStatement extends BaseStatement {
|
|
||||||
type: "IfStatement";
|
|
||||||
test: Expression;
|
|
||||||
consequent: Statement;
|
|
||||||
alternate?: Statement | null | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LabeledStatement extends BaseStatement {
|
|
||||||
type: "LabeledStatement";
|
|
||||||
label: Identifier;
|
|
||||||
body: Statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BreakStatement extends BaseStatement {
|
|
||||||
type: "BreakStatement";
|
|
||||||
label?: Identifier | null | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ContinueStatement extends BaseStatement {
|
|
||||||
type: "ContinueStatement";
|
|
||||||
label?: Identifier | null | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface WithStatement extends BaseStatement {
|
|
||||||
type: "WithStatement";
|
|
||||||
object: Expression;
|
|
||||||
body: Statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SwitchStatement extends BaseStatement {
|
|
||||||
type: "SwitchStatement";
|
|
||||||
discriminant: Expression;
|
|
||||||
cases: SwitchCase[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ReturnStatement extends BaseStatement {
|
|
||||||
type: "ReturnStatement";
|
|
||||||
argument?: Expression | null | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ThrowStatement extends BaseStatement {
|
|
||||||
type: "ThrowStatement";
|
|
||||||
argument: Expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TryStatement extends BaseStatement {
|
|
||||||
type: "TryStatement";
|
|
||||||
block: BlockStatement;
|
|
||||||
handler?: CatchClause | null | undefined;
|
|
||||||
finalizer?: BlockStatement | null | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface WhileStatement extends BaseStatement {
|
|
||||||
type: "WhileStatement";
|
|
||||||
test: Expression;
|
|
||||||
body: Statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DoWhileStatement extends BaseStatement {
|
|
||||||
type: "DoWhileStatement";
|
|
||||||
body: Statement;
|
|
||||||
test: Expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ForStatement extends BaseStatement {
|
|
||||||
type: "ForStatement";
|
|
||||||
init?: VariableDeclaration | Expression | null | undefined;
|
|
||||||
test?: Expression | null | undefined;
|
|
||||||
update?: Expression | null | undefined;
|
|
||||||
body: Statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BaseForXStatement extends BaseStatement {
|
|
||||||
left: VariableDeclaration | Pattern;
|
|
||||||
right: Expression;
|
|
||||||
body: Statement;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ForInStatement extends BaseForXStatement {
|
|
||||||
type: "ForInStatement";
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface DebuggerStatement extends BaseStatement {
|
|
||||||
type: "DebuggerStatement";
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Declaration = FunctionDeclaration | VariableDeclaration | ClassDeclaration;
|
|
||||||
|
|
||||||
export interface BaseDeclaration extends BaseStatement {}
|
|
||||||
|
|
||||||
export interface MaybeNamedFunctionDeclaration extends BaseFunction, BaseDeclaration {
|
|
||||||
type: "FunctionDeclaration";
|
|
||||||
/** It is null when a function declaration is a part of the `export default function` statement */
|
|
||||||
id: Identifier | null;
|
|
||||||
body: BlockStatement;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FunctionDeclaration extends MaybeNamedFunctionDeclaration {
|
|
||||||
id: Identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface VariableDeclaration extends BaseDeclaration {
|
|
||||||
type: "VariableDeclaration";
|
|
||||||
declarations: VariableDeclarator[];
|
|
||||||
kind: "var" | "let" | "const";
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface VariableDeclarator extends BaseNode {
|
|
||||||
type: "VariableDeclarator";
|
|
||||||
id: Pattern;
|
|
||||||
init?: Expression | null | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ExpressionMap {
|
|
||||||
ArrayExpression: ArrayExpression;
|
|
||||||
ArrowFunctionExpression: ArrowFunctionExpression;
|
|
||||||
AssignmentExpression: AssignmentExpression;
|
|
||||||
AwaitExpression: AwaitExpression;
|
|
||||||
BinaryExpression: BinaryExpression;
|
|
||||||
CallExpression: CallExpression;
|
|
||||||
ChainExpression: ChainExpression;
|
|
||||||
ClassExpression: ClassExpression;
|
|
||||||
ConditionalExpression: ConditionalExpression;
|
|
||||||
FunctionExpression: FunctionExpression;
|
|
||||||
Identifier: Identifier;
|
|
||||||
ImportExpression: ImportExpression;
|
|
||||||
Literal: Literal;
|
|
||||||
LogicalExpression: LogicalExpression;
|
|
||||||
MemberExpression: MemberExpression;
|
|
||||||
MetaProperty: MetaProperty;
|
|
||||||
NewExpression: NewExpression;
|
|
||||||
ObjectExpression: ObjectExpression;
|
|
||||||
SequenceExpression: SequenceExpression;
|
|
||||||
TaggedTemplateExpression: TaggedTemplateExpression;
|
|
||||||
TemplateLiteral: TemplateLiteral;
|
|
||||||
ThisExpression: ThisExpression;
|
|
||||||
UnaryExpression: UnaryExpression;
|
|
||||||
UpdateExpression: UpdateExpression;
|
|
||||||
YieldExpression: YieldExpression;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Expression = ExpressionMap[keyof ExpressionMap];
|
|
||||||
|
|
||||||
export interface BaseExpression extends BaseNode {}
|
|
||||||
|
|
||||||
export type ChainElement = SimpleCallExpression | MemberExpression;
|
|
||||||
|
|
||||||
export interface ChainExpression extends BaseExpression {
|
|
||||||
type: "ChainExpression";
|
|
||||||
expression: ChainElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ThisExpression extends BaseExpression {
|
|
||||||
type: "ThisExpression";
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ArrayExpression extends BaseExpression {
|
|
||||||
type: "ArrayExpression";
|
|
||||||
elements: Array<Expression | SpreadElement | null>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ObjectExpression extends BaseExpression {
|
|
||||||
type: "ObjectExpression";
|
|
||||||
properties: Array<Property | SpreadElement>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PrivateIdentifier extends BaseNode {
|
|
||||||
type: "PrivateIdentifier";
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Property extends BaseNode {
|
|
||||||
type: "Property";
|
|
||||||
key: Expression | PrivateIdentifier;
|
|
||||||
value: Expression | Pattern; // Could be an AssignmentProperty
|
|
||||||
kind: "init" | "get" | "set";
|
|
||||||
method: boolean;
|
|
||||||
shorthand: boolean;
|
|
||||||
computed: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PropertyDefinition extends BaseNode {
|
|
||||||
type: "PropertyDefinition";
|
|
||||||
key: Expression | PrivateIdentifier;
|
|
||||||
value?: Expression | null | undefined;
|
|
||||||
computed: boolean;
|
|
||||||
static: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FunctionExpression extends BaseFunction, BaseExpression {
|
|
||||||
id?: Identifier | null | undefined;
|
|
||||||
type: "FunctionExpression";
|
|
||||||
body: BlockStatement;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SequenceExpression extends BaseExpression {
|
|
||||||
type: "SequenceExpression";
|
|
||||||
expressions: Expression[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UnaryExpression extends BaseExpression {
|
|
||||||
type: "UnaryExpression";
|
|
||||||
operator: UnaryOperator;
|
|
||||||
prefix: true;
|
|
||||||
argument: Expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BinaryExpression extends BaseExpression {
|
|
||||||
type: "BinaryExpression";
|
|
||||||
operator: BinaryOperator;
|
|
||||||
left: Expression | PrivateIdentifier;
|
|
||||||
right: Expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AssignmentExpression extends BaseExpression {
|
|
||||||
type: "AssignmentExpression";
|
|
||||||
operator: AssignmentOperator;
|
|
||||||
left: Pattern | MemberExpression;
|
|
||||||
right: Expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface UpdateExpression extends BaseExpression {
|
|
||||||
type: "UpdateExpression";
|
|
||||||
operator: UpdateOperator;
|
|
||||||
argument: Expression;
|
|
||||||
prefix: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface LogicalExpression extends BaseExpression {
|
|
||||||
type: "LogicalExpression";
|
|
||||||
operator: LogicalOperator;
|
|
||||||
left: Expression;
|
|
||||||
right: Expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ConditionalExpression extends BaseExpression {
|
|
||||||
type: "ConditionalExpression";
|
|
||||||
test: Expression;
|
|
||||||
alternate: Expression;
|
|
||||||
consequent: Expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BaseCallExpression extends BaseExpression {
|
|
||||||
callee: Expression | Super;
|
|
||||||
arguments: Array<Expression | SpreadElement>;
|
|
||||||
}
|
|
||||||
export type CallExpression = SimpleCallExpression | NewExpression;
|
|
||||||
|
|
||||||
export interface SimpleCallExpression extends BaseCallExpression {
|
|
||||||
type: "CallExpression";
|
|
||||||
optional: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface NewExpression extends BaseCallExpression {
|
|
||||||
type: "NewExpression";
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MemberExpression extends BaseExpression, BasePattern {
|
|
||||||
type: "MemberExpression";
|
|
||||||
object: Expression | Super;
|
|
||||||
property: Expression | PrivateIdentifier;
|
|
||||||
computed: boolean;
|
|
||||||
optional: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Pattern = Identifier | ObjectPattern | ArrayPattern | RestElement | AssignmentPattern | MemberExpression;
|
|
||||||
|
|
||||||
export interface BasePattern extends BaseNode {}
|
|
||||||
|
|
||||||
export interface SwitchCase extends BaseNode {
|
|
||||||
type: "SwitchCase";
|
|
||||||
test?: Expression | null | undefined;
|
|
||||||
consequent: Statement[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CatchClause extends BaseNode {
|
|
||||||
type: "CatchClause";
|
|
||||||
param: Pattern | null;
|
|
||||||
body: BlockStatement;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Identifier extends BaseNode, BaseExpression, BasePattern {
|
|
||||||
type: "Identifier";
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Literal = SimpleLiteral | RegExpLiteral | BigIntLiteral;
|
|
||||||
|
|
||||||
export interface SimpleLiteral extends BaseNode, BaseExpression {
|
|
||||||
type: "Literal";
|
|
||||||
value: string | boolean | number | null;
|
|
||||||
raw?: string | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RegExpLiteral extends BaseNode, BaseExpression {
|
|
||||||
type: "Literal";
|
|
||||||
value?: RegExp | null | undefined;
|
|
||||||
regex: {
|
|
||||||
pattern: string;
|
|
||||||
flags: string;
|
|
||||||
};
|
|
||||||
raw?: string | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BigIntLiteral extends BaseNode, BaseExpression {
|
|
||||||
type: "Literal";
|
|
||||||
value?: bigint | null | undefined;
|
|
||||||
bigint: string;
|
|
||||||
raw?: string | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type UnaryOperator = "-" | "+" | "!" | "~" | "typeof" | "void" | "delete";
|
|
||||||
|
|
||||||
export type BinaryOperator =
|
|
||||||
| "=="
|
|
||||||
| "!="
|
|
||||||
| "==="
|
|
||||||
| "!=="
|
|
||||||
| "<"
|
|
||||||
| "<="
|
|
||||||
| ">"
|
|
||||||
| ">="
|
|
||||||
| "<<"
|
|
||||||
| ">>"
|
|
||||||
| ">>>"
|
|
||||||
| "+"
|
|
||||||
| "-"
|
|
||||||
| "*"
|
|
||||||
| "/"
|
|
||||||
| "%"
|
|
||||||
| "**"
|
|
||||||
| "|"
|
|
||||||
| "^"
|
|
||||||
| "&"
|
|
||||||
| "in"
|
|
||||||
| "instanceof";
|
|
||||||
|
|
||||||
export type LogicalOperator = "||" | "&&" | "??";
|
|
||||||
|
|
||||||
export type AssignmentOperator =
|
|
||||||
| "="
|
|
||||||
| "+="
|
|
||||||
| "-="
|
|
||||||
| "*="
|
|
||||||
| "/="
|
|
||||||
| "%="
|
|
||||||
| "**="
|
|
||||||
| "<<="
|
|
||||||
| ">>="
|
|
||||||
| ">>>="
|
|
||||||
| "|="
|
|
||||||
| "^="
|
|
||||||
| "&="
|
|
||||||
| "||="
|
|
||||||
| "&&="
|
|
||||||
| "??=";
|
|
||||||
|
|
||||||
export type UpdateOperator = "++" | "--";
|
|
||||||
|
|
||||||
export interface ForOfStatement extends BaseForXStatement {
|
|
||||||
type: "ForOfStatement";
|
|
||||||
await: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Super extends BaseNode {
|
|
||||||
type: "Super";
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SpreadElement extends BaseNode {
|
|
||||||
type: "SpreadElement";
|
|
||||||
argument: Expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ArrowFunctionExpression extends BaseExpression, BaseFunction {
|
|
||||||
type: "ArrowFunctionExpression";
|
|
||||||
expression: boolean;
|
|
||||||
body: BlockStatement | Expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface YieldExpression extends BaseExpression {
|
|
||||||
type: "YieldExpression";
|
|
||||||
argument?: Expression | null | undefined;
|
|
||||||
delegate: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TemplateLiteral extends BaseExpression {
|
|
||||||
type: "TemplateLiteral";
|
|
||||||
quasis: TemplateElement[];
|
|
||||||
expressions: Expression[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TaggedTemplateExpression extends BaseExpression {
|
|
||||||
type: "TaggedTemplateExpression";
|
|
||||||
tag: Expression;
|
|
||||||
quasi: TemplateLiteral;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TemplateElement extends BaseNode {
|
|
||||||
type: "TemplateElement";
|
|
||||||
tail: boolean;
|
|
||||||
value: {
|
|
||||||
/** It is null when the template literal is tagged and the text has an invalid escape (e.g. - tag`\unicode and \u{55}`) */
|
|
||||||
cooked?: string | null | undefined;
|
|
||||||
raw: string;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AssignmentProperty extends Property {
|
|
||||||
value: Pattern;
|
|
||||||
kind: "init";
|
|
||||||
method: boolean; // false
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ObjectPattern extends BasePattern {
|
|
||||||
type: "ObjectPattern";
|
|
||||||
properties: Array<AssignmentProperty | RestElement>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ArrayPattern extends BasePattern {
|
|
||||||
type: "ArrayPattern";
|
|
||||||
elements: Array<Pattern | null>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface RestElement extends BasePattern {
|
|
||||||
type: "RestElement";
|
|
||||||
argument: Pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AssignmentPattern extends BasePattern {
|
|
||||||
type: "AssignmentPattern";
|
|
||||||
left: Pattern;
|
|
||||||
right: Expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type Class = ClassDeclaration | ClassExpression;
|
|
||||||
export interface BaseClass extends BaseNode {
|
|
||||||
superClass?: Expression | null | undefined;
|
|
||||||
body: ClassBody;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ClassBody extends BaseNode {
|
|
||||||
type: "ClassBody";
|
|
||||||
body: Array<MethodDefinition | PropertyDefinition | StaticBlock>;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MethodDefinition extends BaseNode {
|
|
||||||
type: "MethodDefinition";
|
|
||||||
key: Expression | PrivateIdentifier;
|
|
||||||
value: FunctionExpression;
|
|
||||||
kind: "constructor" | "method" | "get" | "set";
|
|
||||||
computed: boolean;
|
|
||||||
static: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MaybeNamedClassDeclaration extends BaseClass, BaseDeclaration {
|
|
||||||
type: "ClassDeclaration";
|
|
||||||
/** It is null when a class declaration is a part of the `export default class` statement */
|
|
||||||
id: Identifier | null;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ClassDeclaration extends MaybeNamedClassDeclaration {
|
|
||||||
id: Identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ClassExpression extends BaseClass, BaseExpression {
|
|
||||||
type: "ClassExpression";
|
|
||||||
id?: Identifier | null | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface MetaProperty extends BaseExpression {
|
|
||||||
type: "MetaProperty";
|
|
||||||
meta: Identifier;
|
|
||||||
property: Identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ModuleDeclaration =
|
|
||||||
| ImportDeclaration
|
|
||||||
| ExportNamedDeclaration
|
|
||||||
| ExportDefaultDeclaration
|
|
||||||
| ExportAllDeclaration;
|
|
||||||
export interface BaseModuleDeclaration extends BaseNode {}
|
|
||||||
|
|
||||||
export type ModuleSpecifier = ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier | ExportSpecifier;
|
|
||||||
export interface BaseModuleSpecifier extends BaseNode {
|
|
||||||
local: Identifier;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ImportDeclaration extends BaseModuleDeclaration {
|
|
||||||
type: "ImportDeclaration";
|
|
||||||
specifiers: Array<ImportSpecifier | ImportDefaultSpecifier | ImportNamespaceSpecifier>;
|
|
||||||
source: Literal;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ImportSpecifier extends BaseModuleSpecifier {
|
|
||||||
type: "ImportSpecifier";
|
|
||||||
imported: Identifier | Literal;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ImportExpression extends BaseExpression {
|
|
||||||
type: "ImportExpression";
|
|
||||||
source: Expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ImportDefaultSpecifier extends BaseModuleSpecifier {
|
|
||||||
type: "ImportDefaultSpecifier";
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ImportNamespaceSpecifier extends BaseModuleSpecifier {
|
|
||||||
type: "ImportNamespaceSpecifier";
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ExportNamedDeclaration extends BaseModuleDeclaration {
|
|
||||||
type: "ExportNamedDeclaration";
|
|
||||||
declaration?: Declaration | null | undefined;
|
|
||||||
specifiers: ExportSpecifier[];
|
|
||||||
source?: Literal | null | undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ExportSpecifier extends Omit<BaseModuleSpecifier, "local"> {
|
|
||||||
type: "ExportSpecifier";
|
|
||||||
local: Identifier | Literal;
|
|
||||||
exported: Identifier | Literal;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ExportDefaultDeclaration extends BaseModuleDeclaration {
|
|
||||||
type: "ExportDefaultDeclaration";
|
|
||||||
declaration: MaybeNamedFunctionDeclaration | MaybeNamedClassDeclaration | Expression;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ExportAllDeclaration extends BaseModuleDeclaration {
|
|
||||||
type: "ExportAllDeclaration";
|
|
||||||
exported: Identifier | Literal | null;
|
|
||||||
source: Literal;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AwaitExpression extends BaseExpression {
|
|
||||||
type: "AwaitExpression";
|
|
||||||
argument: Expression;
|
|
||||||
}
|
|
26
node_modules/@types/estree/package.json
generated
vendored
26
node_modules/@types/estree/package.json
generated
vendored
@ -1,26 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "@types/estree",
|
|
||||||
"version": "1.0.6",
|
|
||||||
"description": "TypeScript definitions for estree",
|
|
||||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/estree",
|
|
||||||
"license": "MIT",
|
|
||||||
"contributors": [
|
|
||||||
{
|
|
||||||
"name": "RReverser",
|
|
||||||
"githubUsername": "RReverser",
|
|
||||||
"url": "https://github.com/RReverser"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"main": "",
|
|
||||||
"types": "index.d.ts",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
|
|
||||||
"directory": "types/estree"
|
|
||||||
},
|
|
||||||
"scripts": {},
|
|
||||||
"dependencies": {},
|
|
||||||
"typesPublisherContentHash": "0310b41994a6f8d7530af6c53d47d8b227f32925e43718507fdb1178e05006b1",
|
|
||||||
"typeScriptVersion": "4.8",
|
|
||||||
"nonNpm": true
|
|
||||||
}
|
|
21
node_modules/esbuild/LICENSE.md
generated
vendored
21
node_modules/esbuild/LICENSE.md
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
MIT License
|
|
||||||
|
|
||||||
Copyright (c) 2020 Evan Wallace
|
|
||||||
|
|
||||||
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.
|
|
3
node_modules/esbuild/README.md
generated
vendored
3
node_modules/esbuild/README.md
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
# esbuild
|
|
||||||
|
|
||||||
This is a JavaScript bundler and minifier. See https://github.com/evanw/esbuild and the [JavaScript API documentation](https://esbuild.github.io/api/) for details.
|
|
220
node_modules/esbuild/bin/esbuild
generated
vendored
220
node_modules/esbuild/bin/esbuild
generated
vendored
@ -1,220 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
"use strict";
|
|
||||||
var __create = Object.create;
|
|
||||||
var __defProp = Object.defineProperty;
|
|
||||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
||||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
||||||
var __getProtoOf = Object.getPrototypeOf;
|
|
||||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
||||||
var __copyProps = (to, from, except, desc) => {
|
|
||||||
if (from && typeof from === "object" || typeof from === "function") {
|
|
||||||
for (let key of __getOwnPropNames(from))
|
|
||||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
||||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
||||||
}
|
|
||||||
return to;
|
|
||||||
};
|
|
||||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
||||||
// If the importer is in node compatibility mode or this is not an ESM
|
|
||||||
// file that has been converted to a CommonJS file using a Babel-
|
|
||||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
||||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
||||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
||||||
mod
|
|
||||||
));
|
|
||||||
|
|
||||||
// lib/npm/node-platform.ts
|
|
||||||
var fs = require("fs");
|
|
||||||
var os = require("os");
|
|
||||||
var path = require("path");
|
|
||||||
var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
|
|
||||||
var isValidBinaryPath = (x) => !!x && x !== "/usr/bin/esbuild";
|
|
||||||
var packageDarwin_arm64 = "@esbuild/darwin-arm64";
|
|
||||||
var packageDarwin_x64 = "@esbuild/darwin-x64";
|
|
||||||
var knownWindowsPackages = {
|
|
||||||
"win32 arm64 LE": "@esbuild/win32-arm64",
|
|
||||||
"win32 ia32 LE": "@esbuild/win32-ia32",
|
|
||||||
"win32 x64 LE": "@esbuild/win32-x64"
|
|
||||||
};
|
|
||||||
var knownUnixlikePackages = {
|
|
||||||
"aix ppc64 BE": "@esbuild/aix-ppc64",
|
|
||||||
"android arm64 LE": "@esbuild/android-arm64",
|
|
||||||
"darwin arm64 LE": "@esbuild/darwin-arm64",
|
|
||||||
"darwin x64 LE": "@esbuild/darwin-x64",
|
|
||||||
"freebsd arm64 LE": "@esbuild/freebsd-arm64",
|
|
||||||
"freebsd x64 LE": "@esbuild/freebsd-x64",
|
|
||||||
"linux arm LE": "@esbuild/linux-arm",
|
|
||||||
"linux arm64 LE": "@esbuild/linux-arm64",
|
|
||||||
"linux ia32 LE": "@esbuild/linux-ia32",
|
|
||||||
"linux mips64el LE": "@esbuild/linux-mips64el",
|
|
||||||
"linux ppc64 LE": "@esbuild/linux-ppc64",
|
|
||||||
"linux riscv64 LE": "@esbuild/linux-riscv64",
|
|
||||||
"linux s390x BE": "@esbuild/linux-s390x",
|
|
||||||
"linux x64 LE": "@esbuild/linux-x64",
|
|
||||||
"linux loong64 LE": "@esbuild/linux-loong64",
|
|
||||||
"netbsd x64 LE": "@esbuild/netbsd-x64",
|
|
||||||
"openbsd x64 LE": "@esbuild/openbsd-x64",
|
|
||||||
"sunos x64 LE": "@esbuild/sunos-x64"
|
|
||||||
};
|
|
||||||
var knownWebAssemblyFallbackPackages = {
|
|
||||||
"android arm LE": "@esbuild/android-arm",
|
|
||||||
"android x64 LE": "@esbuild/android-x64"
|
|
||||||
};
|
|
||||||
function pkgAndSubpathForCurrentPlatform() {
|
|
||||||
let pkg;
|
|
||||||
let subpath;
|
|
||||||
let isWASM2 = false;
|
|
||||||
let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
|
|
||||||
if (platformKey in knownWindowsPackages) {
|
|
||||||
pkg = knownWindowsPackages[platformKey];
|
|
||||||
subpath = "esbuild.exe";
|
|
||||||
} else if (platformKey in knownUnixlikePackages) {
|
|
||||||
pkg = knownUnixlikePackages[platformKey];
|
|
||||||
subpath = "bin/esbuild";
|
|
||||||
} else if (platformKey in knownWebAssemblyFallbackPackages) {
|
|
||||||
pkg = knownWebAssemblyFallbackPackages[platformKey];
|
|
||||||
subpath = "bin/esbuild";
|
|
||||||
isWASM2 = true;
|
|
||||||
} else {
|
|
||||||
throw new Error(`Unsupported platform: ${platformKey}`);
|
|
||||||
}
|
|
||||||
return { pkg, subpath, isWASM: isWASM2 };
|
|
||||||
}
|
|
||||||
function pkgForSomeOtherPlatform() {
|
|
||||||
const libMainJS = require.resolve("esbuild");
|
|
||||||
const nodeModulesDirectory = path.dirname(path.dirname(path.dirname(libMainJS)));
|
|
||||||
if (path.basename(nodeModulesDirectory) === "node_modules") {
|
|
||||||
for (const unixKey in knownUnixlikePackages) {
|
|
||||||
try {
|
|
||||||
const pkg = knownUnixlikePackages[unixKey];
|
|
||||||
if (fs.existsSync(path.join(nodeModulesDirectory, pkg))) return pkg;
|
|
||||||
} catch {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (const windowsKey in knownWindowsPackages) {
|
|
||||||
try {
|
|
||||||
const pkg = knownWindowsPackages[windowsKey];
|
|
||||||
if (fs.existsSync(path.join(nodeModulesDirectory, pkg))) return pkg;
|
|
||||||
} catch {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
function downloadedBinPath(pkg, subpath) {
|
|
||||||
const esbuildLibDir = path.dirname(require.resolve("esbuild"));
|
|
||||||
return path.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path.basename(subpath)}`);
|
|
||||||
}
|
|
||||||
function generateBinPath() {
|
|
||||||
if (isValidBinaryPath(ESBUILD_BINARY_PATH)) {
|
|
||||||
if (!fs.existsSync(ESBUILD_BINARY_PATH)) {
|
|
||||||
console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`);
|
|
||||||
} else {
|
|
||||||
return { binPath: ESBUILD_BINARY_PATH, isWASM: false };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const { pkg, subpath, isWASM: isWASM2 } = pkgAndSubpathForCurrentPlatform();
|
|
||||||
let binPath2;
|
|
||||||
try {
|
|
||||||
binPath2 = require.resolve(`${pkg}/${subpath}`);
|
|
||||||
} catch (e) {
|
|
||||||
binPath2 = downloadedBinPath(pkg, subpath);
|
|
||||||
if (!fs.existsSync(binPath2)) {
|
|
||||||
try {
|
|
||||||
require.resolve(pkg);
|
|
||||||
} catch {
|
|
||||||
const otherPkg = pkgForSomeOtherPlatform();
|
|
||||||
if (otherPkg) {
|
|
||||||
let suggestions = `
|
|
||||||
Specifically the "${otherPkg}" package is present but this platform
|
|
||||||
needs the "${pkg}" package instead. People often get into this
|
|
||||||
situation by installing esbuild on Windows or macOS and copying "node_modules"
|
|
||||||
into a Docker image that runs Linux, or by copying "node_modules" between
|
|
||||||
Windows and WSL environments.
|
|
||||||
|
|
||||||
If you are installing with npm, you can try not copying the "node_modules"
|
|
||||||
directory when you copy the files over, and running "npm ci" or "npm install"
|
|
||||||
on the destination platform after the copy. Or you could consider using yarn
|
|
||||||
instead of npm which has built-in support for installing a package on multiple
|
|
||||||
platforms simultaneously.
|
|
||||||
|
|
||||||
If you are installing with yarn, you can try listing both this platform and the
|
|
||||||
other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
|
|
||||||
feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
|
|
||||||
Keep in mind that this means multiple copies of esbuild will be present.
|
|
||||||
`;
|
|
||||||
if (pkg === packageDarwin_x64 && otherPkg === packageDarwin_arm64 || pkg === packageDarwin_arm64 && otherPkg === packageDarwin_x64) {
|
|
||||||
suggestions = `
|
|
||||||
Specifically the "${otherPkg}" package is present but this platform
|
|
||||||
needs the "${pkg}" package instead. People often get into this
|
|
||||||
situation by installing esbuild with npm running inside of Rosetta 2 and then
|
|
||||||
trying to use it with node running outside of Rosetta 2, or vice versa (Rosetta
|
|
||||||
2 is Apple's on-the-fly x86_64-to-arm64 translation service).
|
|
||||||
|
|
||||||
If you are installing with npm, you can try ensuring that both npm and node are
|
|
||||||
not running under Rosetta 2 and then reinstalling esbuild. This likely involves
|
|
||||||
changing how you installed npm and/or node. For example, installing node with
|
|
||||||
the universal installer here should work: https://nodejs.org/en/download/. Or
|
|
||||||
you could consider using yarn instead of npm which has built-in support for
|
|
||||||
installing a package on multiple platforms simultaneously.
|
|
||||||
|
|
||||||
If you are installing with yarn, you can try listing both "arm64" and "x64"
|
|
||||||
in your ".yarnrc.yml" file using the "supportedArchitectures" feature:
|
|
||||||
https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
|
|
||||||
Keep in mind that this means multiple copies of esbuild will be present.
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
throw new Error(`
|
|
||||||
You installed esbuild for another platform than the one you're currently using.
|
|
||||||
This won't work because esbuild is written with native code and needs to
|
|
||||||
install a platform-specific binary executable.
|
|
||||||
${suggestions}
|
|
||||||
Another alternative is to use the "esbuild-wasm" package instead, which works
|
|
||||||
the same way on all platforms. But it comes with a heavy performance cost and
|
|
||||||
can sometimes be 10x slower than the "esbuild" package, so you may also not
|
|
||||||
want to do that.
|
|
||||||
`);
|
|
||||||
}
|
|
||||||
throw new Error(`The package "${pkg}" could not be found, and is needed by esbuild.
|
|
||||||
|
|
||||||
If you are installing esbuild with npm, make sure that you don't specify the
|
|
||||||
"--no-optional" or "--omit=optional" flags. The "optionalDependencies" feature
|
|
||||||
of "package.json" is used by esbuild to install the correct binary executable
|
|
||||||
for your current platform.`);
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (/\.zip\//.test(binPath2)) {
|
|
||||||
let pnpapi;
|
|
||||||
try {
|
|
||||||
pnpapi = require("pnpapi");
|
|
||||||
} catch (e) {
|
|
||||||
}
|
|
||||||
if (pnpapi) {
|
|
||||||
const root = pnpapi.getPackageInformation(pnpapi.topLevel).packageLocation;
|
|
||||||
const binTargetPath = path.join(
|
|
||||||
root,
|
|
||||||
"node_modules",
|
|
||||||
".cache",
|
|
||||||
"esbuild",
|
|
||||||
`pnpapi-${pkg.replace("/", "-")}-${"0.21.5"}-${path.basename(subpath)}`
|
|
||||||
);
|
|
||||||
if (!fs.existsSync(binTargetPath)) {
|
|
||||||
fs.mkdirSync(path.dirname(binTargetPath), { recursive: true });
|
|
||||||
fs.copyFileSync(binPath2, binTargetPath);
|
|
||||||
fs.chmodSync(binTargetPath, 493);
|
|
||||||
}
|
|
||||||
return { binPath: binTargetPath, isWASM: isWASM2 };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return { binPath: binPath2, isWASM: isWASM2 };
|
|
||||||
}
|
|
||||||
|
|
||||||
// lib/npm/node-shim.ts
|
|
||||||
var { binPath, isWASM } = generateBinPath();
|
|
||||||
if (isWASM) {
|
|
||||||
require("child_process").execFileSync("node", [binPath].concat(process.argv.slice(2)), { stdio: "inherit" });
|
|
||||||
} else {
|
|
||||||
require("child_process").execFileSync(binPath, process.argv.slice(2), { stdio: "inherit" });
|
|
||||||
}
|
|
285
node_modules/esbuild/install.js
generated
vendored
285
node_modules/esbuild/install.js
generated
vendored
@ -1,285 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
var __create = Object.create;
|
|
||||||
var __defProp = Object.defineProperty;
|
|
||||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
||||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
||||||
var __getProtoOf = Object.getPrototypeOf;
|
|
||||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
||||||
var __copyProps = (to, from, except, desc) => {
|
|
||||||
if (from && typeof from === "object" || typeof from === "function") {
|
|
||||||
for (let key of __getOwnPropNames(from))
|
|
||||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
||||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
||||||
}
|
|
||||||
return to;
|
|
||||||
};
|
|
||||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
||||||
// If the importer is in node compatibility mode or this is not an ESM
|
|
||||||
// file that has been converted to a CommonJS file using a Babel-
|
|
||||||
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
||||||
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
||||||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
||||||
mod
|
|
||||||
));
|
|
||||||
|
|
||||||
// lib/npm/node-platform.ts
|
|
||||||
var fs = require("fs");
|
|
||||||
var os = require("os");
|
|
||||||
var path = require("path");
|
|
||||||
var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
|
|
||||||
var isValidBinaryPath = (x) => !!x && x !== "/usr/bin/esbuild";
|
|
||||||
var knownWindowsPackages = {
|
|
||||||
"win32 arm64 LE": "@esbuild/win32-arm64",
|
|
||||||
"win32 ia32 LE": "@esbuild/win32-ia32",
|
|
||||||
"win32 x64 LE": "@esbuild/win32-x64"
|
|
||||||
};
|
|
||||||
var knownUnixlikePackages = {
|
|
||||||
"aix ppc64 BE": "@esbuild/aix-ppc64",
|
|
||||||
"android arm64 LE": "@esbuild/android-arm64",
|
|
||||||
"darwin arm64 LE": "@esbuild/darwin-arm64",
|
|
||||||
"darwin x64 LE": "@esbuild/darwin-x64",
|
|
||||||
"freebsd arm64 LE": "@esbuild/freebsd-arm64",
|
|
||||||
"freebsd x64 LE": "@esbuild/freebsd-x64",
|
|
||||||
"linux arm LE": "@esbuild/linux-arm",
|
|
||||||
"linux arm64 LE": "@esbuild/linux-arm64",
|
|
||||||
"linux ia32 LE": "@esbuild/linux-ia32",
|
|
||||||
"linux mips64el LE": "@esbuild/linux-mips64el",
|
|
||||||
"linux ppc64 LE": "@esbuild/linux-ppc64",
|
|
||||||
"linux riscv64 LE": "@esbuild/linux-riscv64",
|
|
||||||
"linux s390x BE": "@esbuild/linux-s390x",
|
|
||||||
"linux x64 LE": "@esbuild/linux-x64",
|
|
||||||
"linux loong64 LE": "@esbuild/linux-loong64",
|
|
||||||
"netbsd x64 LE": "@esbuild/netbsd-x64",
|
|
||||||
"openbsd x64 LE": "@esbuild/openbsd-x64",
|
|
||||||
"sunos x64 LE": "@esbuild/sunos-x64"
|
|
||||||
};
|
|
||||||
var knownWebAssemblyFallbackPackages = {
|
|
||||||
"android arm LE": "@esbuild/android-arm",
|
|
||||||
"android x64 LE": "@esbuild/android-x64"
|
|
||||||
};
|
|
||||||
function pkgAndSubpathForCurrentPlatform() {
|
|
||||||
let pkg;
|
|
||||||
let subpath;
|
|
||||||
let isWASM = false;
|
|
||||||
let platformKey = `${process.platform} ${os.arch()} ${os.endianness()}`;
|
|
||||||
if (platformKey in knownWindowsPackages) {
|
|
||||||
pkg = knownWindowsPackages[platformKey];
|
|
||||||
subpath = "esbuild.exe";
|
|
||||||
} else if (platformKey in knownUnixlikePackages) {
|
|
||||||
pkg = knownUnixlikePackages[platformKey];
|
|
||||||
subpath = "bin/esbuild";
|
|
||||||
} else if (platformKey in knownWebAssemblyFallbackPackages) {
|
|
||||||
pkg = knownWebAssemblyFallbackPackages[platformKey];
|
|
||||||
subpath = "bin/esbuild";
|
|
||||||
isWASM = true;
|
|
||||||
} else {
|
|
||||||
throw new Error(`Unsupported platform: ${platformKey}`);
|
|
||||||
}
|
|
||||||
return { pkg, subpath, isWASM };
|
|
||||||
}
|
|
||||||
function downloadedBinPath(pkg, subpath) {
|
|
||||||
const esbuildLibDir = path.dirname(require.resolve("esbuild"));
|
|
||||||
return path.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path.basename(subpath)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// lib/npm/node-install.ts
|
|
||||||
var fs2 = require("fs");
|
|
||||||
var os2 = require("os");
|
|
||||||
var path2 = require("path");
|
|
||||||
var zlib = require("zlib");
|
|
||||||
var https = require("https");
|
|
||||||
var child_process = require("child_process");
|
|
||||||
var versionFromPackageJSON = require(path2.join(__dirname, "package.json")).version;
|
|
||||||
var toPath = path2.join(__dirname, "bin", "esbuild");
|
|
||||||
var isToPathJS = true;
|
|
||||||
function validateBinaryVersion(...command) {
|
|
||||||
command.push("--version");
|
|
||||||
let stdout;
|
|
||||||
try {
|
|
||||||
stdout = child_process.execFileSync(command.shift(), command, {
|
|
||||||
// Without this, this install script strangely crashes with the error
|
|
||||||
// "EACCES: permission denied, write" but only on Ubuntu Linux when node is
|
|
||||||
// installed from the Snap Store. This is not a problem when you download
|
|
||||||
// the official version of node. The problem appears to be that stderr
|
|
||||||
// (i.e. file descriptor 2) isn't writable?
|
|
||||||
//
|
|
||||||
// More info:
|
|
||||||
// - https://snapcraft.io/ (what the Snap Store is)
|
|
||||||
// - https://nodejs.org/dist/ (download the official version of node)
|
|
||||||
// - https://github.com/evanw/esbuild/issues/1711#issuecomment-1027554035
|
|
||||||
//
|
|
||||||
stdio: "pipe"
|
|
||||||
}).toString().trim();
|
|
||||||
} catch (err) {
|
|
||||||
if (os2.platform() === "darwin" && /_SecTrustEvaluateWithError/.test(err + "")) {
|
|
||||||
let os3 = "this version of macOS";
|
|
||||||
try {
|
|
||||||
os3 = "macOS " + child_process.execFileSync("sw_vers", ["-productVersion"]).toString().trim();
|
|
||||||
} catch {
|
|
||||||
}
|
|
||||||
throw new Error(`The "esbuild" package cannot be installed because ${os3} is too outdated.
|
|
||||||
|
|
||||||
The Go compiler (which esbuild relies on) no longer supports ${os3},
|
|
||||||
which means the "esbuild" binary executable can't be run. You can either:
|
|
||||||
|
|
||||||
* Update your version of macOS to one that the Go compiler supports
|
|
||||||
* Use the "esbuild-wasm" package instead of the "esbuild" package
|
|
||||||
* Build esbuild yourself using an older version of the Go compiler
|
|
||||||
`);
|
|
||||||
}
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
if (stdout !== versionFromPackageJSON) {
|
|
||||||
throw new Error(`Expected ${JSON.stringify(versionFromPackageJSON)} but got ${JSON.stringify(stdout)}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function isYarn() {
|
|
||||||
const { npm_config_user_agent } = process.env;
|
|
||||||
if (npm_config_user_agent) {
|
|
||||||
return /\byarn\//.test(npm_config_user_agent);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
function fetch(url) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
https.get(url, (res) => {
|
|
||||||
if ((res.statusCode === 301 || res.statusCode === 302) && res.headers.location)
|
|
||||||
return fetch(res.headers.location).then(resolve, reject);
|
|
||||||
if (res.statusCode !== 200)
|
|
||||||
return reject(new Error(`Server responded with ${res.statusCode}`));
|
|
||||||
let chunks = [];
|
|
||||||
res.on("data", (chunk) => chunks.push(chunk));
|
|
||||||
res.on("end", () => resolve(Buffer.concat(chunks)));
|
|
||||||
}).on("error", reject);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function extractFileFromTarGzip(buffer, subpath) {
|
|
||||||
try {
|
|
||||||
buffer = zlib.unzipSync(buffer);
|
|
||||||
} catch (err) {
|
|
||||||
throw new Error(`Invalid gzip data in archive: ${err && err.message || err}`);
|
|
||||||
}
|
|
||||||
let str = (i, n) => String.fromCharCode(...buffer.subarray(i, i + n)).replace(/\0.*$/, "");
|
|
||||||
let offset = 0;
|
|
||||||
subpath = `package/${subpath}`;
|
|
||||||
while (offset < buffer.length) {
|
|
||||||
let name = str(offset, 100);
|
|
||||||
let size = parseInt(str(offset + 124, 12), 8);
|
|
||||||
offset += 512;
|
|
||||||
if (!isNaN(size)) {
|
|
||||||
if (name === subpath) return buffer.subarray(offset, offset + size);
|
|
||||||
offset += size + 511 & ~511;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new Error(`Could not find ${JSON.stringify(subpath)} in archive`);
|
|
||||||
}
|
|
||||||
function installUsingNPM(pkg, subpath, binPath) {
|
|
||||||
const env = { ...process.env, npm_config_global: void 0 };
|
|
||||||
const esbuildLibDir = path2.dirname(require.resolve("esbuild"));
|
|
||||||
const installDir = path2.join(esbuildLibDir, "npm-install");
|
|
||||||
fs2.mkdirSync(installDir);
|
|
||||||
try {
|
|
||||||
fs2.writeFileSync(path2.join(installDir, "package.json"), "{}");
|
|
||||||
child_process.execSync(
|
|
||||||
`npm install --loglevel=error --prefer-offline --no-audit --progress=false ${pkg}@${versionFromPackageJSON}`,
|
|
||||||
{ cwd: installDir, stdio: "pipe", env }
|
|
||||||
);
|
|
||||||
const installedBinPath = path2.join(installDir, "node_modules", pkg, subpath);
|
|
||||||
fs2.renameSync(installedBinPath, binPath);
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
removeRecursive(installDir);
|
|
||||||
} catch {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function removeRecursive(dir) {
|
|
||||||
for (const entry of fs2.readdirSync(dir)) {
|
|
||||||
const entryPath = path2.join(dir, entry);
|
|
||||||
let stats;
|
|
||||||
try {
|
|
||||||
stats = fs2.lstatSync(entryPath);
|
|
||||||
} catch {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (stats.isDirectory()) removeRecursive(entryPath);
|
|
||||||
else fs2.unlinkSync(entryPath);
|
|
||||||
}
|
|
||||||
fs2.rmdirSync(dir);
|
|
||||||
}
|
|
||||||
function applyManualBinaryPathOverride(overridePath) {
|
|
||||||
const pathString = JSON.stringify(overridePath);
|
|
||||||
fs2.writeFileSync(toPath, `#!/usr/bin/env node
|
|
||||||
require('child_process').execFileSync(${pathString}, process.argv.slice(2), { stdio: 'inherit' });
|
|
||||||
`);
|
|
||||||
const libMain = path2.join(__dirname, "lib", "main.js");
|
|
||||||
const code = fs2.readFileSync(libMain, "utf8");
|
|
||||||
fs2.writeFileSync(libMain, `var ESBUILD_BINARY_PATH = ${pathString};
|
|
||||||
${code}`);
|
|
||||||
}
|
|
||||||
function maybeOptimizePackage(binPath) {
|
|
||||||
if (os2.platform() !== "win32" && !isYarn()) {
|
|
||||||
const tempPath = path2.join(__dirname, "bin-esbuild");
|
|
||||||
try {
|
|
||||||
fs2.linkSync(binPath, tempPath);
|
|
||||||
fs2.renameSync(tempPath, toPath);
|
|
||||||
isToPathJS = false;
|
|
||||||
fs2.unlinkSync(tempPath);
|
|
||||||
} catch {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async function downloadDirectlyFromNPM(pkg, subpath, binPath) {
|
|
||||||
const url = `https://registry.npmjs.org/${pkg}/-/${pkg.replace("@esbuild/", "")}-${versionFromPackageJSON}.tgz`;
|
|
||||||
console.error(`[esbuild] Trying to download ${JSON.stringify(url)}`);
|
|
||||||
try {
|
|
||||||
fs2.writeFileSync(binPath, extractFileFromTarGzip(await fetch(url), subpath));
|
|
||||||
fs2.chmodSync(binPath, 493);
|
|
||||||
} catch (e) {
|
|
||||||
console.error(`[esbuild] Failed to download ${JSON.stringify(url)}: ${e && e.message || e}`);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
async function checkAndPreparePackage() {
|
|
||||||
if (isValidBinaryPath(ESBUILD_BINARY_PATH)) {
|
|
||||||
if (!fs2.existsSync(ESBUILD_BINARY_PATH)) {
|
|
||||||
console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`);
|
|
||||||
} else {
|
|
||||||
applyManualBinaryPathOverride(ESBUILD_BINARY_PATH);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const { pkg, subpath } = pkgAndSubpathForCurrentPlatform();
|
|
||||||
let binPath;
|
|
||||||
try {
|
|
||||||
binPath = require.resolve(`${pkg}/${subpath}`);
|
|
||||||
} catch (e) {
|
|
||||||
console.error(`[esbuild] Failed to find package "${pkg}" on the file system
|
|
||||||
|
|
||||||
This can happen if you use the "--no-optional" flag. The "optionalDependencies"
|
|
||||||
package.json feature is used by esbuild to install the correct binary executable
|
|
||||||
for your current platform. This install script will now attempt to work around
|
|
||||||
this. If that fails, you need to remove the "--no-optional" flag to use esbuild.
|
|
||||||
`);
|
|
||||||
binPath = downloadedBinPath(pkg, subpath);
|
|
||||||
try {
|
|
||||||
console.error(`[esbuild] Trying to install package "${pkg}" using npm`);
|
|
||||||
installUsingNPM(pkg, subpath, binPath);
|
|
||||||
} catch (e2) {
|
|
||||||
console.error(`[esbuild] Failed to install package "${pkg}" using npm: ${e2 && e2.message || e2}`);
|
|
||||||
try {
|
|
||||||
await downloadDirectlyFromNPM(pkg, subpath, binPath);
|
|
||||||
} catch (e3) {
|
|
||||||
throw new Error(`Failed to install package "${pkg}"`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
maybeOptimizePackage(binPath);
|
|
||||||
}
|
|
||||||
checkAndPreparePackage().then(() => {
|
|
||||||
if (isToPathJS) {
|
|
||||||
validateBinaryVersion(process.execPath, toPath);
|
|
||||||
} else {
|
|
||||||
validateBinaryVersion(toPath);
|
|
||||||
}
|
|
||||||
});
|
|
705
node_modules/esbuild/lib/main.d.ts
generated
vendored
705
node_modules/esbuild/lib/main.d.ts
generated
vendored
@ -1,705 +0,0 @@
|
|||||||
export type Platform = 'browser' | 'node' | 'neutral'
|
|
||||||
export type Format = 'iife' | 'cjs' | 'esm'
|
|
||||||
export type Loader = 'base64' | 'binary' | 'copy' | 'css' | 'dataurl' | 'default' | 'empty' | 'file' | 'js' | 'json' | 'jsx' | 'local-css' | 'text' | 'ts' | 'tsx'
|
|
||||||
export type LogLevel = 'verbose' | 'debug' | 'info' | 'warning' | 'error' | 'silent'
|
|
||||||
export type Charset = 'ascii' | 'utf8'
|
|
||||||
export type Drop = 'console' | 'debugger'
|
|
||||||
|
|
||||||
interface CommonOptions {
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#sourcemap */
|
|
||||||
sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both'
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#legal-comments */
|
|
||||||
legalComments?: 'none' | 'inline' | 'eof' | 'linked' | 'external'
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#source-root */
|
|
||||||
sourceRoot?: string
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#sources-content */
|
|
||||||
sourcesContent?: boolean
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#format */
|
|
||||||
format?: Format
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#global-name */
|
|
||||||
globalName?: string
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#target */
|
|
||||||
target?: string | string[]
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#supported */
|
|
||||||
supported?: Record<string, boolean>
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#platform */
|
|
||||||
platform?: Platform
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#mangle-props */
|
|
||||||
mangleProps?: RegExp
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#mangle-props */
|
|
||||||
reserveProps?: RegExp
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#mangle-props */
|
|
||||||
mangleQuoted?: boolean
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#mangle-props */
|
|
||||||
mangleCache?: Record<string, string | false>
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#drop */
|
|
||||||
drop?: Drop[]
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#drop-labels */
|
|
||||||
dropLabels?: string[]
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#minify */
|
|
||||||
minify?: boolean
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#minify */
|
|
||||||
minifyWhitespace?: boolean
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#minify */
|
|
||||||
minifyIdentifiers?: boolean
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#minify */
|
|
||||||
minifySyntax?: boolean
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#line-limit */
|
|
||||||
lineLimit?: number
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#charset */
|
|
||||||
charset?: Charset
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#tree-shaking */
|
|
||||||
treeShaking?: boolean
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#ignore-annotations */
|
|
||||||
ignoreAnnotations?: boolean
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#jsx */
|
|
||||||
jsx?: 'transform' | 'preserve' | 'automatic'
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#jsx-factory */
|
|
||||||
jsxFactory?: string
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#jsx-fragment */
|
|
||||||
jsxFragment?: string
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#jsx-import-source */
|
|
||||||
jsxImportSource?: string
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#jsx-development */
|
|
||||||
jsxDev?: boolean
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#jsx-side-effects */
|
|
||||||
jsxSideEffects?: boolean
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#define */
|
|
||||||
define?: { [key: string]: string }
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#pure */
|
|
||||||
pure?: string[]
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#keep-names */
|
|
||||||
keepNames?: boolean
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#color */
|
|
||||||
color?: boolean
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#log-level */
|
|
||||||
logLevel?: LogLevel
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#log-limit */
|
|
||||||
logLimit?: number
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#log-override */
|
|
||||||
logOverride?: Record<string, LogLevel>
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#tsconfig-raw */
|
|
||||||
tsconfigRaw?: string | TsconfigRaw
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TsconfigRaw {
|
|
||||||
compilerOptions?: {
|
|
||||||
alwaysStrict?: boolean
|
|
||||||
baseUrl?: string
|
|
||||||
experimentalDecorators?: boolean
|
|
||||||
importsNotUsedAsValues?: 'remove' | 'preserve' | 'error'
|
|
||||||
jsx?: 'preserve' | 'react-native' | 'react' | 'react-jsx' | 'react-jsxdev'
|
|
||||||
jsxFactory?: string
|
|
||||||
jsxFragmentFactory?: string
|
|
||||||
jsxImportSource?: string
|
|
||||||
paths?: Record<string, string[]>
|
|
||||||
preserveValueImports?: boolean
|
|
||||||
strict?: boolean
|
|
||||||
target?: string
|
|
||||||
useDefineForClassFields?: boolean
|
|
||||||
verbatimModuleSyntax?: boolean
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BuildOptions extends CommonOptions {
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#bundle */
|
|
||||||
bundle?: boolean
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#splitting */
|
|
||||||
splitting?: boolean
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#preserve-symlinks */
|
|
||||||
preserveSymlinks?: boolean
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#outfile */
|
|
||||||
outfile?: string
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#metafile */
|
|
||||||
metafile?: boolean
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#outdir */
|
|
||||||
outdir?: string
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#outbase */
|
|
||||||
outbase?: string
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#external */
|
|
||||||
external?: string[]
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#packages */
|
|
||||||
packages?: 'external'
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#alias */
|
|
||||||
alias?: Record<string, string>
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#loader */
|
|
||||||
loader?: { [ext: string]: Loader }
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#resolve-extensions */
|
|
||||||
resolveExtensions?: string[]
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#main-fields */
|
|
||||||
mainFields?: string[]
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#conditions */
|
|
||||||
conditions?: string[]
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#write */
|
|
||||||
write?: boolean
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#allow-overwrite */
|
|
||||||
allowOverwrite?: boolean
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#tsconfig */
|
|
||||||
tsconfig?: string
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#out-extension */
|
|
||||||
outExtension?: { [ext: string]: string }
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#public-path */
|
|
||||||
publicPath?: string
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#entry-names */
|
|
||||||
entryNames?: string
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#chunk-names */
|
|
||||||
chunkNames?: string
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#asset-names */
|
|
||||||
assetNames?: string
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#inject */
|
|
||||||
inject?: string[]
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#banner */
|
|
||||||
banner?: { [type: string]: string }
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#footer */
|
|
||||||
footer?: { [type: string]: string }
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#entry-points */
|
|
||||||
entryPoints?: string[] | Record<string, string> | { in: string, out: string }[]
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#stdin */
|
|
||||||
stdin?: StdinOptions
|
|
||||||
/** Documentation: https://esbuild.github.io/plugins/ */
|
|
||||||
plugins?: Plugin[]
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#working-directory */
|
|
||||||
absWorkingDir?: string
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#node-paths */
|
|
||||||
nodePaths?: string[]; // The "NODE_PATH" variable from Node.js
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface StdinOptions {
|
|
||||||
contents: string | Uint8Array
|
|
||||||
resolveDir?: string
|
|
||||||
sourcefile?: string
|
|
||||||
loader?: Loader
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Message {
|
|
||||||
id: string
|
|
||||||
pluginName: string
|
|
||||||
text: string
|
|
||||||
location: Location | null
|
|
||||||
notes: Note[]
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Optional user-specified data that is passed through unmodified. You can
|
|
||||||
* use this to stash the original error, for example.
|
|
||||||
*/
|
|
||||||
detail: any
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Note {
|
|
||||||
text: string
|
|
||||||
location: Location | null
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Location {
|
|
||||||
file: string
|
|
||||||
namespace: string
|
|
||||||
/** 1-based */
|
|
||||||
line: number
|
|
||||||
/** 0-based, in bytes */
|
|
||||||
column: number
|
|
||||||
/** in bytes */
|
|
||||||
length: number
|
|
||||||
lineText: string
|
|
||||||
suggestion: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface OutputFile {
|
|
||||||
path: string
|
|
||||||
contents: Uint8Array
|
|
||||||
hash: string
|
|
||||||
/** "contents" as text (changes automatically with "contents") */
|
|
||||||
readonly text: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BuildResult<ProvidedOptions extends BuildOptions = BuildOptions> {
|
|
||||||
errors: Message[]
|
|
||||||
warnings: Message[]
|
|
||||||
/** Only when "write: false" */
|
|
||||||
outputFiles: OutputFile[] | (ProvidedOptions['write'] extends false ? never : undefined)
|
|
||||||
/** Only when "metafile: true" */
|
|
||||||
metafile: Metafile | (ProvidedOptions['metafile'] extends true ? never : undefined)
|
|
||||||
/** Only when "mangleCache" is present */
|
|
||||||
mangleCache: Record<string, string | false> | (ProvidedOptions['mangleCache'] extends Object ? never : undefined)
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BuildFailure extends Error {
|
|
||||||
errors: Message[]
|
|
||||||
warnings: Message[]
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#serve-arguments */
|
|
||||||
export interface ServeOptions {
|
|
||||||
port?: number
|
|
||||||
host?: string
|
|
||||||
servedir?: string
|
|
||||||
keyfile?: string
|
|
||||||
certfile?: string
|
|
||||||
fallback?: string
|
|
||||||
onRequest?: (args: ServeOnRequestArgs) => void
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ServeOnRequestArgs {
|
|
||||||
remoteAddress: string
|
|
||||||
method: string
|
|
||||||
path: string
|
|
||||||
status: number
|
|
||||||
/** The time to generate the response, not to send it */
|
|
||||||
timeInMS: number
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#serve-return-values */
|
|
||||||
export interface ServeResult {
|
|
||||||
port: number
|
|
||||||
host: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TransformOptions extends CommonOptions {
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#sourcefile */
|
|
||||||
sourcefile?: string
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#loader */
|
|
||||||
loader?: Loader
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#banner */
|
|
||||||
banner?: string
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#footer */
|
|
||||||
footer?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TransformResult<ProvidedOptions extends TransformOptions = TransformOptions> {
|
|
||||||
code: string
|
|
||||||
map: string
|
|
||||||
warnings: Message[]
|
|
||||||
/** Only when "mangleCache" is present */
|
|
||||||
mangleCache: Record<string, string | false> | (ProvidedOptions['mangleCache'] extends Object ? never : undefined)
|
|
||||||
/** Only when "legalComments" is "external" */
|
|
||||||
legalComments: string | (ProvidedOptions['legalComments'] extends 'external' ? never : undefined)
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface TransformFailure extends Error {
|
|
||||||
errors: Message[]
|
|
||||||
warnings: Message[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Plugin {
|
|
||||||
name: string
|
|
||||||
setup: (build: PluginBuild) => (void | Promise<void>)
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PluginBuild {
|
|
||||||
/** Documentation: https://esbuild.github.io/plugins/#build-options */
|
|
||||||
initialOptions: BuildOptions
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/plugins/#resolve */
|
|
||||||
resolve(path: string, options?: ResolveOptions): Promise<ResolveResult>
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/plugins/#on-start */
|
|
||||||
onStart(callback: () =>
|
|
||||||
(OnStartResult | null | void | Promise<OnStartResult | null | void>)): void
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/plugins/#on-end */
|
|
||||||
onEnd(callback: (result: BuildResult) =>
|
|
||||||
(OnEndResult | null | void | Promise<OnEndResult | null | void>)): void
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/plugins/#on-resolve */
|
|
||||||
onResolve(options: OnResolveOptions, callback: (args: OnResolveArgs) =>
|
|
||||||
(OnResolveResult | null | undefined | Promise<OnResolveResult | null | undefined>)): void
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/plugins/#on-load */
|
|
||||||
onLoad(options: OnLoadOptions, callback: (args: OnLoadArgs) =>
|
|
||||||
(OnLoadResult | null | undefined | Promise<OnLoadResult | null | undefined>)): void
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/plugins/#on-dispose */
|
|
||||||
onDispose(callback: () => void): void
|
|
||||||
|
|
||||||
// This is a full copy of the esbuild library in case you need it
|
|
||||||
esbuild: {
|
|
||||||
context: typeof context,
|
|
||||||
build: typeof build,
|
|
||||||
buildSync: typeof buildSync,
|
|
||||||
transform: typeof transform,
|
|
||||||
transformSync: typeof transformSync,
|
|
||||||
formatMessages: typeof formatMessages,
|
|
||||||
formatMessagesSync: typeof formatMessagesSync,
|
|
||||||
analyzeMetafile: typeof analyzeMetafile,
|
|
||||||
analyzeMetafileSync: typeof analyzeMetafileSync,
|
|
||||||
initialize: typeof initialize,
|
|
||||||
version: typeof version,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/plugins/#resolve-options */
|
|
||||||
export interface ResolveOptions {
|
|
||||||
pluginName?: string
|
|
||||||
importer?: string
|
|
||||||
namespace?: string
|
|
||||||
resolveDir?: string
|
|
||||||
kind?: ImportKind
|
|
||||||
pluginData?: any
|
|
||||||
with?: Record<string, string>
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/plugins/#resolve-results */
|
|
||||||
export interface ResolveResult {
|
|
||||||
errors: Message[]
|
|
||||||
warnings: Message[]
|
|
||||||
|
|
||||||
path: string
|
|
||||||
external: boolean
|
|
||||||
sideEffects: boolean
|
|
||||||
namespace: string
|
|
||||||
suffix: string
|
|
||||||
pluginData: any
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface OnStartResult {
|
|
||||||
errors?: PartialMessage[]
|
|
||||||
warnings?: PartialMessage[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface OnEndResult {
|
|
||||||
errors?: PartialMessage[]
|
|
||||||
warnings?: PartialMessage[]
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/plugins/#on-resolve-options */
|
|
||||||
export interface OnResolveOptions {
|
|
||||||
filter: RegExp
|
|
||||||
namespace?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/plugins/#on-resolve-arguments */
|
|
||||||
export interface OnResolveArgs {
|
|
||||||
path: string
|
|
||||||
importer: string
|
|
||||||
namespace: string
|
|
||||||
resolveDir: string
|
|
||||||
kind: ImportKind
|
|
||||||
pluginData: any
|
|
||||||
with: Record<string, string>
|
|
||||||
}
|
|
||||||
|
|
||||||
export type ImportKind =
|
|
||||||
| 'entry-point'
|
|
||||||
|
|
||||||
// JS
|
|
||||||
| 'import-statement'
|
|
||||||
| 'require-call'
|
|
||||||
| 'dynamic-import'
|
|
||||||
| 'require-resolve'
|
|
||||||
|
|
||||||
// CSS
|
|
||||||
| 'import-rule'
|
|
||||||
| 'composes-from'
|
|
||||||
| 'url-token'
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/plugins/#on-resolve-results */
|
|
||||||
export interface OnResolveResult {
|
|
||||||
pluginName?: string
|
|
||||||
|
|
||||||
errors?: PartialMessage[]
|
|
||||||
warnings?: PartialMessage[]
|
|
||||||
|
|
||||||
path?: string
|
|
||||||
external?: boolean
|
|
||||||
sideEffects?: boolean
|
|
||||||
namespace?: string
|
|
||||||
suffix?: string
|
|
||||||
pluginData?: any
|
|
||||||
|
|
||||||
watchFiles?: string[]
|
|
||||||
watchDirs?: string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/plugins/#on-load-options */
|
|
||||||
export interface OnLoadOptions {
|
|
||||||
filter: RegExp
|
|
||||||
namespace?: string
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/plugins/#on-load-arguments */
|
|
||||||
export interface OnLoadArgs {
|
|
||||||
path: string
|
|
||||||
namespace: string
|
|
||||||
suffix: string
|
|
||||||
pluginData: any
|
|
||||||
with: Record<string, string>
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/plugins/#on-load-results */
|
|
||||||
export interface OnLoadResult {
|
|
||||||
pluginName?: string
|
|
||||||
|
|
||||||
errors?: PartialMessage[]
|
|
||||||
warnings?: PartialMessage[]
|
|
||||||
|
|
||||||
contents?: string | Uint8Array
|
|
||||||
resolveDir?: string
|
|
||||||
loader?: Loader
|
|
||||||
pluginData?: any
|
|
||||||
|
|
||||||
watchFiles?: string[]
|
|
||||||
watchDirs?: string[]
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PartialMessage {
|
|
||||||
id?: string
|
|
||||||
pluginName?: string
|
|
||||||
text?: string
|
|
||||||
location?: Partial<Location> | null
|
|
||||||
notes?: PartialNote[]
|
|
||||||
detail?: any
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface PartialNote {
|
|
||||||
text?: string
|
|
||||||
location?: Partial<Location> | null
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#metafile */
|
|
||||||
export interface Metafile {
|
|
||||||
inputs: {
|
|
||||||
[path: string]: {
|
|
||||||
bytes: number
|
|
||||||
imports: {
|
|
||||||
path: string
|
|
||||||
kind: ImportKind
|
|
||||||
external?: boolean
|
|
||||||
original?: string
|
|
||||||
with?: Record<string, string>
|
|
||||||
}[]
|
|
||||||
format?: 'cjs' | 'esm'
|
|
||||||
with?: Record<string, string>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
outputs: {
|
|
||||||
[path: string]: {
|
|
||||||
bytes: number
|
|
||||||
inputs: {
|
|
||||||
[path: string]: {
|
|
||||||
bytesInOutput: number
|
|
||||||
}
|
|
||||||
}
|
|
||||||
imports: {
|
|
||||||
path: string
|
|
||||||
kind: ImportKind | 'file-loader'
|
|
||||||
external?: boolean
|
|
||||||
}[]
|
|
||||||
exports: string[]
|
|
||||||
entryPoint?: string
|
|
||||||
cssBundle?: string
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface FormatMessagesOptions {
|
|
||||||
kind: 'error' | 'warning'
|
|
||||||
color?: boolean
|
|
||||||
terminalWidth?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface AnalyzeMetafileOptions {
|
|
||||||
color?: boolean
|
|
||||||
verbose?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface WatchOptions {
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface BuildContext<ProvidedOptions extends BuildOptions = BuildOptions> {
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#rebuild */
|
|
||||||
rebuild(): Promise<BuildResult<ProvidedOptions>>
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#watch */
|
|
||||||
watch(options?: WatchOptions): Promise<void>
|
|
||||||
|
|
||||||
/** Documentation: https://esbuild.github.io/api/#serve */
|
|
||||||
serve(options?: ServeOptions): Promise<ServeResult>
|
|
||||||
|
|
||||||
cancel(): Promise<void>
|
|
||||||
dispose(): Promise<void>
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is a TypeScript type-level function which replaces any keys in "In"
|
|
||||||
// that aren't in "Out" with "never". We use this to reject properties with
|
|
||||||
// typos in object literals. See: https://stackoverflow.com/questions/49580725
|
|
||||||
type SameShape<Out, In extends Out> = In & { [Key in Exclude<keyof In, keyof Out>]: never }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function invokes the "esbuild" command-line tool for you. It returns a
|
|
||||||
* promise that either resolves with a "BuildResult" object or rejects with a
|
|
||||||
* "BuildFailure" object.
|
|
||||||
*
|
|
||||||
* - Works in node: yes
|
|
||||||
* - Works in browser: yes
|
|
||||||
*
|
|
||||||
* Documentation: https://esbuild.github.io/api/#build
|
|
||||||
*/
|
|
||||||
export declare function build<T extends BuildOptions>(options: SameShape<BuildOptions, T>): Promise<BuildResult<T>>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is the advanced long-running form of "build" that supports additional
|
|
||||||
* features such as watch mode and a local development server.
|
|
||||||
*
|
|
||||||
* - Works in node: yes
|
|
||||||
* - Works in browser: no
|
|
||||||
*
|
|
||||||
* Documentation: https://esbuild.github.io/api/#build
|
|
||||||
*/
|
|
||||||
export declare function context<T extends BuildOptions>(options: SameShape<BuildOptions, T>): Promise<BuildContext<T>>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function transforms a single JavaScript file. It can be used to minify
|
|
||||||
* JavaScript, convert TypeScript/JSX to JavaScript, or convert newer JavaScript
|
|
||||||
* to older JavaScript. It returns a promise that is either resolved with a
|
|
||||||
* "TransformResult" object or rejected with a "TransformFailure" object.
|
|
||||||
*
|
|
||||||
* - Works in node: yes
|
|
||||||
* - Works in browser: yes
|
|
||||||
*
|
|
||||||
* Documentation: https://esbuild.github.io/api/#transform
|
|
||||||
*/
|
|
||||||
export declare function transform<T extends TransformOptions>(input: string | Uint8Array, options?: SameShape<TransformOptions, T>): Promise<TransformResult<T>>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts log messages to formatted message strings suitable for printing in
|
|
||||||
* the terminal. This allows you to reuse the built-in behavior of esbuild's
|
|
||||||
* log message formatter. This is a batch-oriented API for efficiency.
|
|
||||||
*
|
|
||||||
* - Works in node: yes
|
|
||||||
* - Works in browser: yes
|
|
||||||
*/
|
|
||||||
export declare function formatMessages(messages: PartialMessage[], options: FormatMessagesOptions): Promise<string[]>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pretty-prints an analysis of the metafile JSON to a string. This is just for
|
|
||||||
* convenience to be able to match esbuild's pretty-printing exactly. If you want
|
|
||||||
* to customize it, you can just inspect the data in the metafile yourself.
|
|
||||||
*
|
|
||||||
* - Works in node: yes
|
|
||||||
* - Works in browser: yes
|
|
||||||
*
|
|
||||||
* Documentation: https://esbuild.github.io/api/#analyze
|
|
||||||
*/
|
|
||||||
export declare function analyzeMetafile(metafile: Metafile | string, options?: AnalyzeMetafileOptions): Promise<string>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A synchronous version of "build".
|
|
||||||
*
|
|
||||||
* - Works in node: yes
|
|
||||||
* - Works in browser: no
|
|
||||||
*
|
|
||||||
* Documentation: https://esbuild.github.io/api/#build
|
|
||||||
*/
|
|
||||||
export declare function buildSync<T extends BuildOptions>(options: SameShape<BuildOptions, T>): BuildResult<T>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A synchronous version of "transform".
|
|
||||||
*
|
|
||||||
* - Works in node: yes
|
|
||||||
* - Works in browser: no
|
|
||||||
*
|
|
||||||
* Documentation: https://esbuild.github.io/api/#transform
|
|
||||||
*/
|
|
||||||
export declare function transformSync<T extends TransformOptions>(input: string | Uint8Array, options?: SameShape<TransformOptions, T>): TransformResult<T>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A synchronous version of "formatMessages".
|
|
||||||
*
|
|
||||||
* - Works in node: yes
|
|
||||||
* - Works in browser: no
|
|
||||||
*/
|
|
||||||
export declare function formatMessagesSync(messages: PartialMessage[], options: FormatMessagesOptions): string[]
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A synchronous version of "analyzeMetafile".
|
|
||||||
*
|
|
||||||
* - Works in node: yes
|
|
||||||
* - Works in browser: no
|
|
||||||
*
|
|
||||||
* Documentation: https://esbuild.github.io/api/#analyze
|
|
||||||
*/
|
|
||||||
export declare function analyzeMetafileSync(metafile: Metafile | string, options?: AnalyzeMetafileOptions): string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This configures the browser-based version of esbuild. It is necessary to
|
|
||||||
* call this first and wait for the returned promise to be resolved before
|
|
||||||
* making other API calls when using esbuild in the browser.
|
|
||||||
*
|
|
||||||
* - Works in node: yes
|
|
||||||
* - Works in browser: yes ("options" is required)
|
|
||||||
*
|
|
||||||
* Documentation: https://esbuild.github.io/api/#browser
|
|
||||||
*/
|
|
||||||
export declare function initialize(options: InitializeOptions): Promise<void>
|
|
||||||
|
|
||||||
export interface InitializeOptions {
|
|
||||||
/**
|
|
||||||
* The URL of the "esbuild.wasm" file. This must be provided when running
|
|
||||||
* esbuild in the browser.
|
|
||||||
*/
|
|
||||||
wasmURL?: string | URL
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The result of calling "new WebAssembly.Module(buffer)" where "buffer"
|
|
||||||
* is a typed array or ArrayBuffer containing the binary code of the
|
|
||||||
* "esbuild.wasm" file.
|
|
||||||
*
|
|
||||||
* You can use this as an alternative to "wasmURL" for environments where it's
|
|
||||||
* not possible to download the WebAssembly module.
|
|
||||||
*/
|
|
||||||
wasmModule?: WebAssembly.Module
|
|
||||||
|
|
||||||
/**
|
|
||||||
* By default esbuild runs the WebAssembly-based browser API in a web worker
|
|
||||||
* to avoid blocking the UI thread. This can be disabled by setting "worker"
|
|
||||||
* to false.
|
|
||||||
*/
|
|
||||||
worker?: boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
export let version: string
|
|
||||||
|
|
||||||
// Call this function to terminate esbuild's child process. The child process
|
|
||||||
// is not terminated and re-created after each API call because it's more
|
|
||||||
// efficient to keep it around when there are multiple API calls.
|
|
||||||
//
|
|
||||||
// In node this happens automatically before the parent node process exits. So
|
|
||||||
// you only need to call this if you know you will not make any more esbuild
|
|
||||||
// API calls and you want to clean up resources.
|
|
||||||
//
|
|
||||||
// Unlike node, Deno lacks the necessary APIs to clean up child processes
|
|
||||||
// automatically. You must manually call stop() in Deno when you're done
|
|
||||||
// using esbuild or Deno will continue running forever.
|
|
||||||
//
|
|
||||||
// Another reason you might want to call this is if you are using esbuild from
|
|
||||||
// within a Deno test. Deno fails tests that create a child process without
|
|
||||||
// killing it before the test ends, so you have to call this function (and
|
|
||||||
// await the returned promise) in every Deno test that uses esbuild.
|
|
||||||
export declare function stop(): Promise<void>
|
|
||||||
|
|
||||||
// Note: These declarations exist to avoid type errors when you omit "dom" from
|
|
||||||
// "lib" in your "tsconfig.json" file. TypeScript confusingly declares the
|
|
||||||
// global "WebAssembly" type in "lib.dom.d.ts" even though it has nothing to do
|
|
||||||
// with the browser DOM and is present in many non-browser JavaScript runtimes
|
|
||||||
// (e.g. node and deno). Declaring it here allows esbuild's API to be used in
|
|
||||||
// these scenarios.
|
|
||||||
//
|
|
||||||
// There's an open issue about getting this problem corrected (although these
|
|
||||||
// declarations will need to remain even if this is fixed for backward
|
|
||||||
// compatibility with older TypeScript versions):
|
|
||||||
//
|
|
||||||
// https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/826
|
|
||||||
//
|
|
||||||
declare global {
|
|
||||||
namespace WebAssembly {
|
|
||||||
interface Module {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
interface URL {
|
|
||||||
}
|
|
||||||
}
|
|
2239
node_modules/esbuild/lib/main.js
generated
vendored
2239
node_modules/esbuild/lib/main.js
generated
vendored
File diff suppressed because it is too large
Load Diff
46
node_modules/esbuild/package.json
generated
vendored
46
node_modules/esbuild/package.json
generated
vendored
@ -1,46 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "esbuild",
|
|
||||||
"version": "0.21.5",
|
|
||||||
"description": "An extremely fast JavaScript and CSS bundler and minifier.",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "git+https://github.com/evanw/esbuild.git"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"postinstall": "node install.js"
|
|
||||||
},
|
|
||||||
"main": "lib/main.js",
|
|
||||||
"types": "lib/main.d.ts",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=12"
|
|
||||||
},
|
|
||||||
"bin": {
|
|
||||||
"esbuild": "bin/esbuild"
|
|
||||||
},
|
|
||||||
"optionalDependencies": {
|
|
||||||
"@esbuild/aix-ppc64": "0.21.5",
|
|
||||||
"@esbuild/android-arm": "0.21.5",
|
|
||||||
"@esbuild/android-arm64": "0.21.5",
|
|
||||||
"@esbuild/android-x64": "0.21.5",
|
|
||||||
"@esbuild/darwin-arm64": "0.21.5",
|
|
||||||
"@esbuild/darwin-x64": "0.21.5",
|
|
||||||
"@esbuild/freebsd-arm64": "0.21.5",
|
|
||||||
"@esbuild/freebsd-x64": "0.21.5",
|
|
||||||
"@esbuild/linux-arm": "0.21.5",
|
|
||||||
"@esbuild/linux-arm64": "0.21.5",
|
|
||||||
"@esbuild/linux-ia32": "0.21.5",
|
|
||||||
"@esbuild/linux-loong64": "0.21.5",
|
|
||||||
"@esbuild/linux-mips64el": "0.21.5",
|
|
||||||
"@esbuild/linux-ppc64": "0.21.5",
|
|
||||||
"@esbuild/linux-riscv64": "0.21.5",
|
|
||||||
"@esbuild/linux-s390x": "0.21.5",
|
|
||||||
"@esbuild/linux-x64": "0.21.5",
|
|
||||||
"@esbuild/netbsd-x64": "0.21.5",
|
|
||||||
"@esbuild/openbsd-x64": "0.21.5",
|
|
||||||
"@esbuild/sunos-x64": "0.21.5",
|
|
||||||
"@esbuild/win32-arm64": "0.21.5",
|
|
||||||
"@esbuild/win32-ia32": "0.21.5",
|
|
||||||
"@esbuild/win32-x64": "0.21.5"
|
|
||||||
},
|
|
||||||
"license": "MIT"
|
|
||||||
}
|
|
22
node_modules/fsevents/LICENSE
generated
vendored
22
node_modules/fsevents/LICENSE
generated
vendored
@ -1,22 +0,0 @@
|
|||||||
MIT License
|
|
||||||
-----------
|
|
||||||
|
|
||||||
Copyright (C) 2010-2020 by Philipp Dunkel, Ben Noordhuis, Elan Shankar, Paul Miller
|
|
||||||
|
|
||||||
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.
|
|
89
node_modules/fsevents/README.md
generated
vendored
89
node_modules/fsevents/README.md
generated
vendored
@ -1,89 +0,0 @@
|
|||||||
# fsevents
|
|
||||||
|
|
||||||
Native access to MacOS FSEvents in [Node.js](https://nodejs.org/)
|
|
||||||
|
|
||||||
The FSEvents API in MacOS allows applications to register for notifications of
|
|
||||||
changes to a given directory tree. It is a very fast and lightweight alternative
|
|
||||||
to kqueue.
|
|
||||||
|
|
||||||
This is a low-level library. For a cross-platform file watching module that
|
|
||||||
uses fsevents, check out [Chokidar](https://github.com/paulmillr/chokidar).
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
```sh
|
|
||||||
npm install fsevents
|
|
||||||
```
|
|
||||||
|
|
||||||
Supports only **Node.js v8.16 and higher**.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const fsevents = require('fsevents');
|
|
||||||
|
|
||||||
// To start observation
|
|
||||||
const stop = fsevents.watch(__dirname, (path, flags, id) => {
|
|
||||||
const info = fsevents.getInfo(path, flags);
|
|
||||||
});
|
|
||||||
|
|
||||||
// To end observation
|
|
||||||
stop();
|
|
||||||
```
|
|
||||||
|
|
||||||
> **Important note:** The API behaviour is slightly different from typical JS APIs. The `stop` function **must** be
|
|
||||||
> retrieved and stored somewhere, even if you don't plan to stop the watcher. If you forget it, the garbage collector
|
|
||||||
> will eventually kick in, the watcher will be unregistered, and your callbacks won't be called anymore.
|
|
||||||
|
|
||||||
The callback passed as the second parameter to `.watch` get's called whenever the operating system detects a
|
|
||||||
a change in the file system. It takes three arguments:
|
|
||||||
|
|
||||||
###### `fsevents.watch(dirname: string, (path: string, flags: number, id: string) => void): () => Promise<undefined>`
|
|
||||||
|
|
||||||
* `path: string` - the item in the filesystem that have been changed
|
|
||||||
* `flags: number` - a numeric value describing what the change was
|
|
||||||
* `id: string` - an unique-id identifying this specific event
|
|
||||||
|
|
||||||
Returns closer callback which when called returns a Promise resolving when the watcher process has been shut down.
|
|
||||||
|
|
||||||
###### `fsevents.getInfo(path: string, flags: number, id: string): FsEventInfo`
|
|
||||||
|
|
||||||
The `getInfo` function takes the `path`, `flags` and `id` arguments and converts those parameters into a structure
|
|
||||||
that is easier to digest to determine what the change was.
|
|
||||||
|
|
||||||
The `FsEventsInfo` has the following shape:
|
|
||||||
|
|
||||||
```js
|
|
||||||
/**
|
|
||||||
* @typedef {'created'|'modified'|'deleted'|'moved'|'root-changed'|'cloned'|'unknown'} FsEventsEvent
|
|
||||||
* @typedef {'file'|'directory'|'symlink'} FsEventsType
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
"event": "created", // {FsEventsEvent}
|
|
||||||
"path": "file.txt",
|
|
||||||
"type": "file", // {FsEventsType}
|
|
||||||
"changes": {
|
|
||||||
"inode": true, // Had iNode Meta-Information changed
|
|
||||||
"finder": false, // Had Finder Meta-Data changed
|
|
||||||
"access": false, // Had access permissions changed
|
|
||||||
"xattrs": false // Had xAttributes changed
|
|
||||||
},
|
|
||||||
"flags": 0x100000000
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Changelog
|
|
||||||
|
|
||||||
- v2.3 supports Apple Silicon ARM CPUs
|
|
||||||
- v2 supports node 8.16+ and reduces package size massively
|
|
||||||
- v1.2.8 supports node 6+
|
|
||||||
- v1.2.7 supports node 4+
|
|
||||||
|
|
||||||
## Troubleshooting
|
|
||||||
|
|
||||||
- I'm getting `EBADPLATFORM` `Unsupported platform for fsevents` error.
|
|
||||||
- It's fine, nothing is broken. fsevents is macos-only. Other platforms are skipped. If you want to hide this warning, report a bug to NPM bugtracker asking them to hide ebadplatform warnings by default.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
The MIT License Copyright (C) 2010-2020 by Philipp Dunkel, Ben Noordhuis, Elan Shankar, Paul Miller — see LICENSE file.
|
|
||||||
|
|
||||||
Visit our [GitHub page](https://github.com/fsevents/fsevents) and [NPM Page](https://npmjs.org/package/fsevents)
|
|
46
node_modules/fsevents/fsevents.d.ts
generated
vendored
46
node_modules/fsevents/fsevents.d.ts
generated
vendored
@ -1,46 +0,0 @@
|
|||||||
declare type Event = "created" | "cloned" | "modified" | "deleted" | "moved" | "root-changed" | "unknown";
|
|
||||||
declare type Type = "file" | "directory" | "symlink";
|
|
||||||
declare type FileChanges = {
|
|
||||||
inode: boolean;
|
|
||||||
finder: boolean;
|
|
||||||
access: boolean;
|
|
||||||
xattrs: boolean;
|
|
||||||
};
|
|
||||||
declare type Info = {
|
|
||||||
event: Event;
|
|
||||||
path: string;
|
|
||||||
type: Type;
|
|
||||||
changes: FileChanges;
|
|
||||||
flags: number;
|
|
||||||
};
|
|
||||||
declare type WatchHandler = (path: string, flags: number, id: string) => void;
|
|
||||||
export declare function watch(path: string, handler: WatchHandler): () => Promise<void>;
|
|
||||||
export declare function watch(path: string, since: number, handler: WatchHandler): () => Promise<void>;
|
|
||||||
export declare function getInfo(path: string, flags: number): Info;
|
|
||||||
export declare const constants: {
|
|
||||||
None: 0x00000000;
|
|
||||||
MustScanSubDirs: 0x00000001;
|
|
||||||
UserDropped: 0x00000002;
|
|
||||||
KernelDropped: 0x00000004;
|
|
||||||
EventIdsWrapped: 0x00000008;
|
|
||||||
HistoryDone: 0x00000010;
|
|
||||||
RootChanged: 0x00000020;
|
|
||||||
Mount: 0x00000040;
|
|
||||||
Unmount: 0x00000080;
|
|
||||||
ItemCreated: 0x00000100;
|
|
||||||
ItemRemoved: 0x00000200;
|
|
||||||
ItemInodeMetaMod: 0x00000400;
|
|
||||||
ItemRenamed: 0x00000800;
|
|
||||||
ItemModified: 0x00001000;
|
|
||||||
ItemFinderInfoMod: 0x00002000;
|
|
||||||
ItemChangeOwner: 0x00004000;
|
|
||||||
ItemXattrMod: 0x00008000;
|
|
||||||
ItemIsFile: 0x00010000;
|
|
||||||
ItemIsDir: 0x00020000;
|
|
||||||
ItemIsSymlink: 0x00040000;
|
|
||||||
ItemIsHardlink: 0x00100000;
|
|
||||||
ItemIsLastHardlink: 0x00200000;
|
|
||||||
OwnEvent: 0x00080000;
|
|
||||||
ItemCloned: 0x00400000;
|
|
||||||
};
|
|
||||||
export {};
|
|
83
node_modules/fsevents/fsevents.js
generated
vendored
83
node_modules/fsevents/fsevents.js
generated
vendored
@ -1,83 +0,0 @@
|
|||||||
/*
|
|
||||||
** © 2020 by Philipp Dunkel, Ben Noordhuis, Elan Shankar, Paul Miller
|
|
||||||
** Licensed under MIT License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* jshint node:true */
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
if (process.platform !== "darwin") {
|
|
||||||
throw new Error(`Module 'fsevents' is not compatible with platform '${process.platform}'`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const Native = require("./fsevents.node");
|
|
||||||
const events = Native.constants;
|
|
||||||
|
|
||||||
function watch(path, since, handler) {
|
|
||||||
if (typeof path !== "string") {
|
|
||||||
throw new TypeError(`fsevents argument 1 must be a string and not a ${typeof path}`);
|
|
||||||
}
|
|
||||||
if ("function" === typeof since && "undefined" === typeof handler) {
|
|
||||||
handler = since;
|
|
||||||
since = Native.flags.SinceNow;
|
|
||||||
}
|
|
||||||
if (typeof since !== "number") {
|
|
||||||
throw new TypeError(`fsevents argument 2 must be a number and not a ${typeof since}`);
|
|
||||||
}
|
|
||||||
if (typeof handler !== "function") {
|
|
||||||
throw new TypeError(`fsevents argument 3 must be a function and not a ${typeof handler}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
let instance = Native.start(Native.global, path, since, handler);
|
|
||||||
if (!instance) throw new Error(`could not watch: ${path}`);
|
|
||||||
return () => {
|
|
||||||
const result = instance ? Promise.resolve(instance).then(Native.stop) : Promise.resolve(undefined);
|
|
||||||
instance = undefined;
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function getInfo(path, flags) {
|
|
||||||
return {
|
|
||||||
path,
|
|
||||||
flags,
|
|
||||||
event: getEventType(flags),
|
|
||||||
type: getFileType(flags),
|
|
||||||
changes: getFileChanges(flags),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function getFileType(flags) {
|
|
||||||
if (events.ItemIsFile & flags) return "file";
|
|
||||||
if (events.ItemIsDir & flags) return "directory";
|
|
||||||
if (events.MustScanSubDirs & flags) return "directory";
|
|
||||||
if (events.ItemIsSymlink & flags) return "symlink";
|
|
||||||
}
|
|
||||||
function anyIsTrue(obj) {
|
|
||||||
for (let key in obj) {
|
|
||||||
if (obj[key]) return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
function getEventType(flags) {
|
|
||||||
if (events.ItemRemoved & flags) return "deleted";
|
|
||||||
if (events.ItemRenamed & flags) return "moved";
|
|
||||||
if (events.ItemCreated & flags) return "created";
|
|
||||||
if (events.ItemModified & flags) return "modified";
|
|
||||||
if (events.RootChanged & flags) return "root-changed";
|
|
||||||
if (events.ItemCloned & flags) return "cloned";
|
|
||||||
if (anyIsTrue(flags)) return "modified";
|
|
||||||
return "unknown";
|
|
||||||
}
|
|
||||||
function getFileChanges(flags) {
|
|
||||||
return {
|
|
||||||
inode: !!(events.ItemInodeMetaMod & flags),
|
|
||||||
finder: !!(events.ItemFinderInfoMod & flags),
|
|
||||||
access: !!(events.ItemChangeOwner & flags),
|
|
||||||
xattrs: !!(events.ItemXattrMod & flags),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.watch = watch;
|
|
||||||
exports.getInfo = getInfo;
|
|
||||||
exports.constants = events;
|
|
BIN
node_modules/fsevents/fsevents.node
generated
vendored
BIN
node_modules/fsevents/fsevents.node
generated
vendored
Binary file not shown.
62
node_modules/fsevents/package.json
generated
vendored
62
node_modules/fsevents/package.json
generated
vendored
@ -1,62 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "fsevents",
|
|
||||||
"version": "2.3.3",
|
|
||||||
"description": "Native Access to MacOS FSEvents",
|
|
||||||
"main": "fsevents.js",
|
|
||||||
"types": "fsevents.d.ts",
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"files": [
|
|
||||||
"fsevents.d.ts",
|
|
||||||
"fsevents.js",
|
|
||||||
"fsevents.node"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
|
|
||||||
},
|
|
||||||
"scripts": {
|
|
||||||
"clean": "node-gyp clean && rm -f fsevents.node",
|
|
||||||
"build": "node-gyp clean && rm -f fsevents.node && node-gyp rebuild && node-gyp clean",
|
|
||||||
"test": "/bin/bash ./test.sh 2>/dev/null",
|
|
||||||
"prepublishOnly": "npm run build"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/fsevents/fsevents.git"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"fsevents",
|
|
||||||
"mac"
|
|
||||||
],
|
|
||||||
"contributors": [
|
|
||||||
{
|
|
||||||
"name": "Philipp Dunkel",
|
|
||||||
"email": "pip@pipobscure.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Ben Noordhuis",
|
|
||||||
"email": "info@bnoordhuis.nl"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Elan Shankar",
|
|
||||||
"email": "elan.shanker@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Miroslav Bajtoš",
|
|
||||||
"email": "mbajtoss@gmail.com"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Paul Miller",
|
|
||||||
"url": "https://paulmillr.com"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/fsevents/fsevents/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/fsevents/fsevents",
|
|
||||||
"devDependencies": {
|
|
||||||
"node-gyp": "^9.4.0"
|
|
||||||
}
|
|
||||||
}
|
|
20
node_modules/nanoid/LICENSE
generated
vendored
20
node_modules/nanoid/LICENSE
generated
vendored
@ -1,20 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright 2017 Andrey Sitnik <andrey@sitnik.ru>
|
|
||||||
|
|
||||||
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.
|
|
39
node_modules/nanoid/README.md
generated
vendored
39
node_modules/nanoid/README.md
generated
vendored
@ -1,39 +0,0 @@
|
|||||||
# Nano ID
|
|
||||||
|
|
||||||
<img src="https://ai.github.io/nanoid/logo.svg" align="right"
|
|
||||||
alt="Nano ID logo by Anton Lovchikov" width="180" height="94">
|
|
||||||
|
|
||||||
**English** | [Русский](./README.ru.md) | [简体中文](./README.zh-CN.md) | [Bahasa Indonesia](./README.id-ID.md)
|
|
||||||
|
|
||||||
A tiny, secure, URL-friendly, unique string ID generator for JavaScript.
|
|
||||||
|
|
||||||
> “An amazing level of senseless perfectionism,
|
|
||||||
> which is simply impossible not to respect.”
|
|
||||||
|
|
||||||
* **Small.** 130 bytes (minified and gzipped). No dependencies.
|
|
||||||
[Size Limit] controls the size.
|
|
||||||
* **Fast.** It is 2 times faster than UUID.
|
|
||||||
* **Safe.** It uses hardware random generator. Can be used in clusters.
|
|
||||||
* **Short IDs.** It uses a larger alphabet than UUID (`A-Za-z0-9_-`).
|
|
||||||
So ID size was reduced from 36 to 21 symbols.
|
|
||||||
* **Portable.** Nano ID was ported
|
|
||||||
to [20 programming languages](#other-programming-languages).
|
|
||||||
|
|
||||||
```js
|
|
||||||
import { nanoid } from 'nanoid'
|
|
||||||
model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
|
|
||||||
```
|
|
||||||
|
|
||||||
Supports modern browsers, IE [with Babel], Node.js and React Native.
|
|
||||||
|
|
||||||
[online tool]: https://gitpod.io/#https://github.com/ai/nanoid/
|
|
||||||
[with Babel]: https://developer.epages.com/blog/coding/how-to-transpile-node-modules-with-babel-and-webpack-in-a-monorepo/
|
|
||||||
[Size Limit]: https://github.com/ai/size-limit
|
|
||||||
|
|
||||||
<a href="https://evilmartians.com/?utm_source=nanoid">
|
|
||||||
<img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
|
|
||||||
alt="Sponsored by Evil Martians" width="236" height="54">
|
|
||||||
</a>
|
|
||||||
|
|
||||||
## Docs
|
|
||||||
Read full docs **[here](https://github.com/ai/nanoid#readme)**.
|
|
34
node_modules/nanoid/async/index.browser.cjs
generated
vendored
34
node_modules/nanoid/async/index.browser.cjs
generated
vendored
@ -1,34 +0,0 @@
|
|||||||
let random = async bytes => crypto.getRandomValues(new Uint8Array(bytes))
|
|
||||||
let customAlphabet = (alphabet, defaultSize = 21) => {
|
|
||||||
let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
|
|
||||||
let step = -~((1.6 * mask * defaultSize) / alphabet.length)
|
|
||||||
return async (size = defaultSize) => {
|
|
||||||
let id = ''
|
|
||||||
while (true) {
|
|
||||||
let bytes = crypto.getRandomValues(new Uint8Array(step))
|
|
||||||
let i = step
|
|
||||||
while (i--) {
|
|
||||||
id += alphabet[bytes[i] & mask] || ''
|
|
||||||
if (id.length === size) return id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let nanoid = async (size = 21) => {
|
|
||||||
let id = ''
|
|
||||||
let bytes = crypto.getRandomValues(new Uint8Array(size))
|
|
||||||
while (size--) {
|
|
||||||
let byte = bytes[size] & 63
|
|
||||||
if (byte < 36) {
|
|
||||||
id += byte.toString(36)
|
|
||||||
} else if (byte < 62) {
|
|
||||||
id += (byte - 26).toString(36).toUpperCase()
|
|
||||||
} else if (byte < 63) {
|
|
||||||
id += '_'
|
|
||||||
} else {
|
|
||||||
id += '-'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
}
|
|
||||||
module.exports = { nanoid, customAlphabet, random }
|
|
34
node_modules/nanoid/async/index.browser.js
generated
vendored
34
node_modules/nanoid/async/index.browser.js
generated
vendored
@ -1,34 +0,0 @@
|
|||||||
let random = async bytes => crypto.getRandomValues(new Uint8Array(bytes))
|
|
||||||
let customAlphabet = (alphabet, defaultSize = 21) => {
|
|
||||||
let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
|
|
||||||
let step = -~((1.6 * mask * defaultSize) / alphabet.length)
|
|
||||||
return async (size = defaultSize) => {
|
|
||||||
let id = ''
|
|
||||||
while (true) {
|
|
||||||
let bytes = crypto.getRandomValues(new Uint8Array(step))
|
|
||||||
let i = step
|
|
||||||
while (i--) {
|
|
||||||
id += alphabet[bytes[i] & mask] || ''
|
|
||||||
if (id.length === size) return id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let nanoid = async (size = 21) => {
|
|
||||||
let id = ''
|
|
||||||
let bytes = crypto.getRandomValues(new Uint8Array(size))
|
|
||||||
while (size--) {
|
|
||||||
let byte = bytes[size] & 63
|
|
||||||
if (byte < 36) {
|
|
||||||
id += byte.toString(36)
|
|
||||||
} else if (byte < 62) {
|
|
||||||
id += (byte - 26).toString(36).toUpperCase()
|
|
||||||
} else if (byte < 63) {
|
|
||||||
id += '_'
|
|
||||||
} else {
|
|
||||||
id += '-'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
}
|
|
||||||
export { nanoid, customAlphabet, random }
|
|
35
node_modules/nanoid/async/index.cjs
generated
vendored
35
node_modules/nanoid/async/index.cjs
generated
vendored
@ -1,35 +0,0 @@
|
|||||||
let crypto = require('crypto')
|
|
||||||
let { urlAlphabet } = require('../url-alphabet/index.cjs')
|
|
||||||
let random = bytes =>
|
|
||||||
new Promise((resolve, reject) => {
|
|
||||||
crypto.randomFill(Buffer.allocUnsafe(bytes), (err, buf) => {
|
|
||||||
if (err) {
|
|
||||||
reject(err)
|
|
||||||
} else {
|
|
||||||
resolve(buf)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
let customAlphabet = (alphabet, defaultSize = 21) => {
|
|
||||||
let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
|
|
||||||
let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
|
|
||||||
let tick = (id, size = defaultSize) =>
|
|
||||||
random(step).then(bytes => {
|
|
||||||
let i = step
|
|
||||||
while (i--) {
|
|
||||||
id += alphabet[bytes[i] & mask] || ''
|
|
||||||
if (id.length === size) return id
|
|
||||||
}
|
|
||||||
return tick(id, size)
|
|
||||||
})
|
|
||||||
return size => tick('', size)
|
|
||||||
}
|
|
||||||
let nanoid = (size = 21) =>
|
|
||||||
random(size).then(bytes => {
|
|
||||||
let id = ''
|
|
||||||
while (size--) {
|
|
||||||
id += urlAlphabet[bytes[size] & 63]
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
})
|
|
||||||
module.exports = { nanoid, customAlphabet, random }
|
|
56
node_modules/nanoid/async/index.d.ts
generated
vendored
56
node_modules/nanoid/async/index.d.ts
generated
vendored
@ -1,56 +0,0 @@
|
|||||||
/**
|
|
||||||
* Generate secure URL-friendly unique ID. The non-blocking version.
|
|
||||||
*
|
|
||||||
* By default, the ID will have 21 symbols to have a collision probability
|
|
||||||
* similar to UUID v4.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { nanoid } from 'nanoid/async'
|
|
||||||
* nanoid().then(id => {
|
|
||||||
* model.id = id
|
|
||||||
* })
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @param size Size of the ID. The default size is 21.
|
|
||||||
* @returns A promise with a random string.
|
|
||||||
*/
|
|
||||||
export function nanoid(size?: number): Promise<string>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A low-level function.
|
|
||||||
* Generate secure unique ID with custom alphabet. The non-blocking version.
|
|
||||||
*
|
|
||||||
* Alphabet must contain 256 symbols or less. Otherwise, the generator
|
|
||||||
* will not be secure.
|
|
||||||
*
|
|
||||||
* @param alphabet Alphabet used to generate the ID.
|
|
||||||
* @param defaultSize Size of the ID. The default size is 21.
|
|
||||||
* @returns A function that returns a promise with a random string.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { customAlphabet } from 'nanoid/async'
|
|
||||||
* const nanoid = customAlphabet('0123456789абвгдеё', 5)
|
|
||||||
* nanoid().then(id => {
|
|
||||||
* model.id = id //=> "8ё56а"
|
|
||||||
* })
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export function customAlphabet(
|
|
||||||
alphabet: string,
|
|
||||||
defaultSize?: number
|
|
||||||
): (size?: number) => Promise<string>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate an array of random bytes collected from hardware noise.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { random } from 'nanoid/async'
|
|
||||||
* random(5).then(bytes => {
|
|
||||||
* bytes //=> [10, 67, 212, 67, 89]
|
|
||||||
* })
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @param bytes Size of the array.
|
|
||||||
* @returns A promise with a random bytes array.
|
|
||||||
*/
|
|
||||||
export function random(bytes: number): Promise<Uint8Array>
|
|
35
node_modules/nanoid/async/index.js
generated
vendored
35
node_modules/nanoid/async/index.js
generated
vendored
@ -1,35 +0,0 @@
|
|||||||
import crypto from 'crypto'
|
|
||||||
import { urlAlphabet } from '../url-alphabet/index.js'
|
|
||||||
let random = bytes =>
|
|
||||||
new Promise((resolve, reject) => {
|
|
||||||
crypto.randomFill(Buffer.allocUnsafe(bytes), (err, buf) => {
|
|
||||||
if (err) {
|
|
||||||
reject(err)
|
|
||||||
} else {
|
|
||||||
resolve(buf)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
let customAlphabet = (alphabet, defaultSize = 21) => {
|
|
||||||
let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
|
|
||||||
let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
|
|
||||||
let tick = (id, size = defaultSize) =>
|
|
||||||
random(step).then(bytes => {
|
|
||||||
let i = step
|
|
||||||
while (i--) {
|
|
||||||
id += alphabet[bytes[i] & mask] || ''
|
|
||||||
if (id.length === size) return id
|
|
||||||
}
|
|
||||||
return tick(id, size)
|
|
||||||
})
|
|
||||||
return size => tick('', size)
|
|
||||||
}
|
|
||||||
let nanoid = (size = 21) =>
|
|
||||||
random(size).then(bytes => {
|
|
||||||
let id = ''
|
|
||||||
while (size--) {
|
|
||||||
id += urlAlphabet[bytes[size] & 63]
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
})
|
|
||||||
export { nanoid, customAlphabet, random }
|
|
26
node_modules/nanoid/async/index.native.js
generated
vendored
26
node_modules/nanoid/async/index.native.js
generated
vendored
@ -1,26 +0,0 @@
|
|||||||
import { getRandomBytesAsync } from 'expo-random'
|
|
||||||
import { urlAlphabet } from '../url-alphabet/index.js'
|
|
||||||
let random = getRandomBytesAsync
|
|
||||||
let customAlphabet = (alphabet, defaultSize = 21) => {
|
|
||||||
let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
|
|
||||||
let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
|
|
||||||
let tick = (id, size = defaultSize) =>
|
|
||||||
random(step).then(bytes => {
|
|
||||||
let i = step
|
|
||||||
while (i--) {
|
|
||||||
id += alphabet[bytes[i] & mask] || ''
|
|
||||||
if (id.length === size) return id
|
|
||||||
}
|
|
||||||
return tick(id, size)
|
|
||||||
})
|
|
||||||
return size => tick('', size)
|
|
||||||
}
|
|
||||||
let nanoid = (size = 21) =>
|
|
||||||
random(size).then(bytes => {
|
|
||||||
let id = ''
|
|
||||||
while (size--) {
|
|
||||||
id += urlAlphabet[bytes[size] & 63]
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
})
|
|
||||||
export { nanoid, customAlphabet, random }
|
|
12
node_modules/nanoid/async/package.json
generated
vendored
12
node_modules/nanoid/async/package.json
generated
vendored
@ -1,12 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "module",
|
|
||||||
"main": "index.cjs",
|
|
||||||
"module": "index.js",
|
|
||||||
"react-native": {
|
|
||||||
"./index.js": "./index.native.js"
|
|
||||||
},
|
|
||||||
"browser": {
|
|
||||||
"./index.js": "./index.browser.js",
|
|
||||||
"./index.cjs": "./index.browser.cjs"
|
|
||||||
}
|
|
||||||
}
|
|
55
node_modules/nanoid/bin/nanoid.cjs
generated
vendored
55
node_modules/nanoid/bin/nanoid.cjs
generated
vendored
@ -1,55 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
let { nanoid, customAlphabet } = require('..')
|
|
||||||
|
|
||||||
function print(msg) {
|
|
||||||
process.stdout.write(msg + '\n')
|
|
||||||
}
|
|
||||||
|
|
||||||
function error(msg) {
|
|
||||||
process.stderr.write(msg + '\n')
|
|
||||||
process.exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (process.argv.includes('--help') || process.argv.includes('-h')) {
|
|
||||||
print(`
|
|
||||||
Usage
|
|
||||||
$ nanoid [options]
|
|
||||||
|
|
||||||
Options
|
|
||||||
-s, --size Generated ID size
|
|
||||||
-a, --alphabet Alphabet to use
|
|
||||||
-h, --help Show this help
|
|
||||||
|
|
||||||
Examples
|
|
||||||
$ nanoid --s 15
|
|
||||||
S9sBF77U6sDB8Yg
|
|
||||||
|
|
||||||
$ nanoid --size 10 --alphabet abc
|
|
||||||
bcabababca`)
|
|
||||||
process.exit()
|
|
||||||
}
|
|
||||||
|
|
||||||
let alphabet, size
|
|
||||||
for (let i = 2; i < process.argv.length; i++) {
|
|
||||||
let arg = process.argv[i]
|
|
||||||
if (arg === '--size' || arg === '-s') {
|
|
||||||
size = Number(process.argv[i + 1])
|
|
||||||
i += 1
|
|
||||||
if (Number.isNaN(size) || size <= 0) {
|
|
||||||
error('Size must be positive integer')
|
|
||||||
}
|
|
||||||
} else if (arg === '--alphabet' || arg === '-a') {
|
|
||||||
alphabet = process.argv[i + 1]
|
|
||||||
i += 1
|
|
||||||
} else {
|
|
||||||
error('Unknown argument ' + arg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (alphabet) {
|
|
||||||
let customNanoid = customAlphabet(alphabet, size)
|
|
||||||
print(customNanoid())
|
|
||||||
} else {
|
|
||||||
print(nanoid(size))
|
|
||||||
}
|
|
34
node_modules/nanoid/index.browser.cjs
generated
vendored
34
node_modules/nanoid/index.browser.cjs
generated
vendored
@ -1,34 +0,0 @@
|
|||||||
let { urlAlphabet } = require('./url-alphabet/index.cjs')
|
|
||||||
let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))
|
|
||||||
let customRandom = (alphabet, defaultSize, getRandom) => {
|
|
||||||
let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
|
|
||||||
let step = -~((1.6 * mask * defaultSize) / alphabet.length)
|
|
||||||
return (size = defaultSize) => {
|
|
||||||
let id = ''
|
|
||||||
while (true) {
|
|
||||||
let bytes = getRandom(step)
|
|
||||||
let j = step
|
|
||||||
while (j--) {
|
|
||||||
id += alphabet[bytes[j] & mask] || ''
|
|
||||||
if (id.length === size) return id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let customAlphabet = (alphabet, size = 21) =>
|
|
||||||
customRandom(alphabet, size, random)
|
|
||||||
let nanoid = (size = 21) =>
|
|
||||||
crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
|
|
||||||
byte &= 63
|
|
||||||
if (byte < 36) {
|
|
||||||
id += byte.toString(36)
|
|
||||||
} else if (byte < 62) {
|
|
||||||
id += (byte - 26).toString(36).toUpperCase()
|
|
||||||
} else if (byte > 62) {
|
|
||||||
id += '-'
|
|
||||||
} else {
|
|
||||||
id += '_'
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
}, '')
|
|
||||||
module.exports = { nanoid, customAlphabet, customRandom, urlAlphabet, random }
|
|
34
node_modules/nanoid/index.browser.js
generated
vendored
34
node_modules/nanoid/index.browser.js
generated
vendored
@ -1,34 +0,0 @@
|
|||||||
import { urlAlphabet } from './url-alphabet/index.js'
|
|
||||||
let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))
|
|
||||||
let customRandom = (alphabet, defaultSize, getRandom) => {
|
|
||||||
let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
|
|
||||||
let step = -~((1.6 * mask * defaultSize) / alphabet.length)
|
|
||||||
return (size = defaultSize) => {
|
|
||||||
let id = ''
|
|
||||||
while (true) {
|
|
||||||
let bytes = getRandom(step)
|
|
||||||
let j = step
|
|
||||||
while (j--) {
|
|
||||||
id += alphabet[bytes[j] & mask] || ''
|
|
||||||
if (id.length === size) return id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let customAlphabet = (alphabet, size = 21) =>
|
|
||||||
customRandom(alphabet, size, random)
|
|
||||||
let nanoid = (size = 21) =>
|
|
||||||
crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
|
|
||||||
byte &= 63
|
|
||||||
if (byte < 36) {
|
|
||||||
id += byte.toString(36)
|
|
||||||
} else if (byte < 62) {
|
|
||||||
id += (byte - 26).toString(36).toUpperCase()
|
|
||||||
} else if (byte > 62) {
|
|
||||||
id += '-'
|
|
||||||
} else {
|
|
||||||
id += '_'
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
}, '')
|
|
||||||
export { nanoid, customAlphabet, customRandom, urlAlphabet, random }
|
|
45
node_modules/nanoid/index.cjs
generated
vendored
45
node_modules/nanoid/index.cjs
generated
vendored
@ -1,45 +0,0 @@
|
|||||||
let crypto = require('crypto')
|
|
||||||
let { urlAlphabet } = require('./url-alphabet/index.cjs')
|
|
||||||
const POOL_SIZE_MULTIPLIER = 128
|
|
||||||
let pool, poolOffset
|
|
||||||
let fillPool = bytes => {
|
|
||||||
if (!pool || pool.length < bytes) {
|
|
||||||
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER)
|
|
||||||
crypto.randomFillSync(pool)
|
|
||||||
poolOffset = 0
|
|
||||||
} else if (poolOffset + bytes > pool.length) {
|
|
||||||
crypto.randomFillSync(pool)
|
|
||||||
poolOffset = 0
|
|
||||||
}
|
|
||||||
poolOffset += bytes
|
|
||||||
}
|
|
||||||
let random = bytes => {
|
|
||||||
fillPool((bytes -= 0))
|
|
||||||
return pool.subarray(poolOffset - bytes, poolOffset)
|
|
||||||
}
|
|
||||||
let customRandom = (alphabet, defaultSize, getRandom) => {
|
|
||||||
let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
|
|
||||||
let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
|
|
||||||
return (size = defaultSize) => {
|
|
||||||
let id = ''
|
|
||||||
while (true) {
|
|
||||||
let bytes = getRandom(step)
|
|
||||||
let i = step
|
|
||||||
while (i--) {
|
|
||||||
id += alphabet[bytes[i] & mask] || ''
|
|
||||||
if (id.length === size) return id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let customAlphabet = (alphabet, size = 21) =>
|
|
||||||
customRandom(alphabet, size, random)
|
|
||||||
let nanoid = (size = 21) => {
|
|
||||||
fillPool((size -= 0))
|
|
||||||
let id = ''
|
|
||||||
for (let i = poolOffset - size; i < poolOffset; i++) {
|
|
||||||
id += urlAlphabet[pool[i] & 63]
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
}
|
|
||||||
module.exports = { nanoid, customAlphabet, customRandom, urlAlphabet, random }
|
|
91
node_modules/nanoid/index.d.cts
generated
vendored
91
node_modules/nanoid/index.d.cts
generated
vendored
@ -1,91 +0,0 @@
|
|||||||
/**
|
|
||||||
* Generate secure URL-friendly unique ID.
|
|
||||||
*
|
|
||||||
* By default, the ID will have 21 symbols to have a collision probability
|
|
||||||
* similar to UUID v4.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { nanoid } from 'nanoid'
|
|
||||||
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @param size Size of the ID. The default size is 21.
|
|
||||||
* @returns A random string.
|
|
||||||
*/
|
|
||||||
export function nanoid(size?: number): string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate secure unique ID with custom alphabet.
|
|
||||||
*
|
|
||||||
* Alphabet must contain 256 symbols or less. Otherwise, the generator
|
|
||||||
* will not be secure.
|
|
||||||
*
|
|
||||||
* @param alphabet Alphabet used to generate the ID.
|
|
||||||
* @param defaultSize Size of the ID. The default size is 21.
|
|
||||||
* @returns A random string generator.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const { customAlphabet } = require('nanoid')
|
|
||||||
* const nanoid = customAlphabet('0123456789абвгдеё', 5)
|
|
||||||
* nanoid() //=> "8ё56а"
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export function customAlphabet(
|
|
||||||
alphabet: string,
|
|
||||||
defaultSize?: number
|
|
||||||
): (size?: number) => string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate unique ID with custom random generator and alphabet.
|
|
||||||
*
|
|
||||||
* Alphabet must contain 256 symbols or less. Otherwise, the generator
|
|
||||||
* will not be secure.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { customRandom } from 'nanoid/format'
|
|
||||||
*
|
|
||||||
* const nanoid = customRandom('abcdef', 5, size => {
|
|
||||||
* const random = []
|
|
||||||
* for (let i = 0; i < size; i++) {
|
|
||||||
* random.push(randomByte())
|
|
||||||
* }
|
|
||||||
* return random
|
|
||||||
* })
|
|
||||||
*
|
|
||||||
* nanoid() //=> "fbaef"
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @param alphabet Alphabet used to generate a random string.
|
|
||||||
* @param size Size of the random string.
|
|
||||||
* @param random A random bytes generator.
|
|
||||||
* @returns A random string generator.
|
|
||||||
*/
|
|
||||||
export function customRandom(
|
|
||||||
alphabet: string,
|
|
||||||
size: number,
|
|
||||||
random: (bytes: number) => Uint8Array
|
|
||||||
): () => string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* URL safe symbols.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { urlAlphabet } from 'nanoid'
|
|
||||||
* const nanoid = customAlphabet(urlAlphabet, 10)
|
|
||||||
* nanoid() //=> "Uakgb_J5m9"
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export const urlAlphabet: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate an array of random bytes collected from hardware noise.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { customRandom, random } from 'nanoid'
|
|
||||||
* const nanoid = customRandom("abcdef", 5, random)
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @param bytes Size of the array.
|
|
||||||
* @returns An array of random bytes.
|
|
||||||
*/
|
|
||||||
export function random(bytes: number): Uint8Array
|
|
91
node_modules/nanoid/index.d.ts
generated
vendored
91
node_modules/nanoid/index.d.ts
generated
vendored
@ -1,91 +0,0 @@
|
|||||||
/**
|
|
||||||
* Generate secure URL-friendly unique ID.
|
|
||||||
*
|
|
||||||
* By default, the ID will have 21 symbols to have a collision probability
|
|
||||||
* similar to UUID v4.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { nanoid } from 'nanoid'
|
|
||||||
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @param size Size of the ID. The default size is 21.
|
|
||||||
* @returns A random string.
|
|
||||||
*/
|
|
||||||
export function nanoid(size?: number): string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate secure unique ID with custom alphabet.
|
|
||||||
*
|
|
||||||
* Alphabet must contain 256 symbols or less. Otherwise, the generator
|
|
||||||
* will not be secure.
|
|
||||||
*
|
|
||||||
* @param alphabet Alphabet used to generate the ID.
|
|
||||||
* @param defaultSize Size of the ID. The default size is 21.
|
|
||||||
* @returns A random string generator.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* const { customAlphabet } = require('nanoid')
|
|
||||||
* const nanoid = customAlphabet('0123456789абвгдеё', 5)
|
|
||||||
* nanoid() //=> "8ё56а"
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export function customAlphabet(
|
|
||||||
alphabet: string,
|
|
||||||
defaultSize?: number
|
|
||||||
): (size?: number) => string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate unique ID with custom random generator and alphabet.
|
|
||||||
*
|
|
||||||
* Alphabet must contain 256 symbols or less. Otherwise, the generator
|
|
||||||
* will not be secure.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { customRandom } from 'nanoid/format'
|
|
||||||
*
|
|
||||||
* const nanoid = customRandom('abcdef', 5, size => {
|
|
||||||
* const random = []
|
|
||||||
* for (let i = 0; i < size; i++) {
|
|
||||||
* random.push(randomByte())
|
|
||||||
* }
|
|
||||||
* return random
|
|
||||||
* })
|
|
||||||
*
|
|
||||||
* nanoid() //=> "fbaef"
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @param alphabet Alphabet used to generate a random string.
|
|
||||||
* @param size Size of the random string.
|
|
||||||
* @param random A random bytes generator.
|
|
||||||
* @returns A random string generator.
|
|
||||||
*/
|
|
||||||
export function customRandom(
|
|
||||||
alphabet: string,
|
|
||||||
size: number,
|
|
||||||
random: (bytes: number) => Uint8Array
|
|
||||||
): () => string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* URL safe symbols.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { urlAlphabet } from 'nanoid'
|
|
||||||
* const nanoid = customAlphabet(urlAlphabet, 10)
|
|
||||||
* nanoid() //=> "Uakgb_J5m9"
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export const urlAlphabet: string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate an array of random bytes collected from hardware noise.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { customRandom, random } from 'nanoid'
|
|
||||||
* const nanoid = customRandom("abcdef", 5, random)
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @param bytes Size of the array.
|
|
||||||
* @returns An array of random bytes.
|
|
||||||
*/
|
|
||||||
export function random(bytes: number): Uint8Array
|
|
45
node_modules/nanoid/index.js
generated
vendored
45
node_modules/nanoid/index.js
generated
vendored
@ -1,45 +0,0 @@
|
|||||||
import crypto from 'crypto'
|
|
||||||
import { urlAlphabet } from './url-alphabet/index.js'
|
|
||||||
const POOL_SIZE_MULTIPLIER = 128
|
|
||||||
let pool, poolOffset
|
|
||||||
let fillPool = bytes => {
|
|
||||||
if (!pool || pool.length < bytes) {
|
|
||||||
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER)
|
|
||||||
crypto.randomFillSync(pool)
|
|
||||||
poolOffset = 0
|
|
||||||
} else if (poolOffset + bytes > pool.length) {
|
|
||||||
crypto.randomFillSync(pool)
|
|
||||||
poolOffset = 0
|
|
||||||
}
|
|
||||||
poolOffset += bytes
|
|
||||||
}
|
|
||||||
let random = bytes => {
|
|
||||||
fillPool((bytes -= 0))
|
|
||||||
return pool.subarray(poolOffset - bytes, poolOffset)
|
|
||||||
}
|
|
||||||
let customRandom = (alphabet, defaultSize, getRandom) => {
|
|
||||||
let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
|
|
||||||
let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
|
|
||||||
return (size = defaultSize) => {
|
|
||||||
let id = ''
|
|
||||||
while (true) {
|
|
||||||
let bytes = getRandom(step)
|
|
||||||
let i = step
|
|
||||||
while (i--) {
|
|
||||||
id += alphabet[bytes[i] & mask] || ''
|
|
||||||
if (id.length === size) return id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let customAlphabet = (alphabet, size = 21) =>
|
|
||||||
customRandom(alphabet, size, random)
|
|
||||||
let nanoid = (size = 21) => {
|
|
||||||
fillPool((size -= 0))
|
|
||||||
let id = ''
|
|
||||||
for (let i = poolOffset - size; i < poolOffset; i++) {
|
|
||||||
id += urlAlphabet[pool[i] & 63]
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
}
|
|
||||||
export { nanoid, customAlphabet, customRandom, urlAlphabet, random }
|
|
1
node_modules/nanoid/nanoid.js
generated
vendored
1
node_modules/nanoid/nanoid.js
generated
vendored
@ -1 +0,0 @@
|
|||||||
export let nanoid=(t=21)=>crypto.getRandomValues(new Uint8Array(t)).reduce(((t,e)=>t+=(e&=63)<36?e.toString(36):e<62?(e-26).toString(36).toUpperCase():e<63?"_":"-"),"");
|
|
21
node_modules/nanoid/non-secure/index.cjs
generated
vendored
21
node_modules/nanoid/non-secure/index.cjs
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
let urlAlphabet =
|
|
||||||
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
|
||||||
let customAlphabet = (alphabet, defaultSize = 21) => {
|
|
||||||
return (size = defaultSize) => {
|
|
||||||
let id = ''
|
|
||||||
let i = size
|
|
||||||
while (i--) {
|
|
||||||
id += alphabet[(Math.random() * alphabet.length) | 0]
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let nanoid = (size = 21) => {
|
|
||||||
let id = ''
|
|
||||||
let i = size
|
|
||||||
while (i--) {
|
|
||||||
id += urlAlphabet[(Math.random() * 64) | 0]
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
}
|
|
||||||
module.exports = { nanoid, customAlphabet }
|
|
33
node_modules/nanoid/non-secure/index.d.ts
generated
vendored
33
node_modules/nanoid/non-secure/index.d.ts
generated
vendored
@ -1,33 +0,0 @@
|
|||||||
/**
|
|
||||||
* Generate URL-friendly unique ID. This method uses the non-secure
|
|
||||||
* predictable random generator with bigger collision probability.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { nanoid } from 'nanoid/non-secure'
|
|
||||||
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
|
|
||||||
* ```
|
|
||||||
*
|
|
||||||
* @param size Size of the ID. The default size is 21.
|
|
||||||
* @returns A random string.
|
|
||||||
*/
|
|
||||||
export function nanoid(size?: number): string
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a unique ID based on a custom alphabet.
|
|
||||||
* This method uses the non-secure predictable random generator
|
|
||||||
* with bigger collision probability.
|
|
||||||
*
|
|
||||||
* @param alphabet Alphabet used to generate the ID.
|
|
||||||
* @param defaultSize Size of the ID. The default size is 21.
|
|
||||||
* @returns A random string generator.
|
|
||||||
*
|
|
||||||
* ```js
|
|
||||||
* import { customAlphabet } from 'nanoid/non-secure'
|
|
||||||
* const nanoid = customAlphabet('0123456789абвгдеё', 5)
|
|
||||||
* model.id = //=> "8ё56а"
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export function customAlphabet(
|
|
||||||
alphabet: string,
|
|
||||||
defaultSize?: number
|
|
||||||
): (size?: number) => string
|
|
21
node_modules/nanoid/non-secure/index.js
generated
vendored
21
node_modules/nanoid/non-secure/index.js
generated
vendored
@ -1,21 +0,0 @@
|
|||||||
let urlAlphabet =
|
|
||||||
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
|
||||||
let customAlphabet = (alphabet, defaultSize = 21) => {
|
|
||||||
return (size = defaultSize) => {
|
|
||||||
let id = ''
|
|
||||||
let i = size
|
|
||||||
while (i--) {
|
|
||||||
id += alphabet[(Math.random() * alphabet.length) | 0]
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let nanoid = (size = 21) => {
|
|
||||||
let id = ''
|
|
||||||
let i = size
|
|
||||||
while (i--) {
|
|
||||||
id += urlAlphabet[(Math.random() * 64) | 0]
|
|
||||||
}
|
|
||||||
return id
|
|
||||||
}
|
|
||||||
export { nanoid, customAlphabet }
|
|
6
node_modules/nanoid/non-secure/package.json
generated
vendored
6
node_modules/nanoid/non-secure/package.json
generated
vendored
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "module",
|
|
||||||
"main": "index.cjs",
|
|
||||||
"module": "index.js",
|
|
||||||
"react-native": "index.js"
|
|
||||||
}
|
|
88
node_modules/nanoid/package.json
generated
vendored
88
node_modules/nanoid/package.json
generated
vendored
@ -1,88 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "nanoid",
|
|
||||||
"version": "3.3.7",
|
|
||||||
"description": "A tiny (116 bytes), secure URL-friendly unique string ID generator",
|
|
||||||
"keywords": [
|
|
||||||
"uuid",
|
|
||||||
"random",
|
|
||||||
"id",
|
|
||||||
"url"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
|
|
||||||
},
|
|
||||||
"funding": [
|
|
||||||
{
|
|
||||||
"type": "github",
|
|
||||||
"url": "https://github.com/sponsors/ai"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"author": "Andrey Sitnik <andrey@sitnik.ru>",
|
|
||||||
"license": "MIT",
|
|
||||||
"repository": "ai/nanoid",
|
|
||||||
"browser": {
|
|
||||||
"./index.js": "./index.browser.js",
|
|
||||||
"./async/index.js": "./async/index.browser.js",
|
|
||||||
"./async/index.cjs": "./async/index.browser.cjs",
|
|
||||||
"./index.cjs": "./index.browser.cjs"
|
|
||||||
},
|
|
||||||
"react-native": "index.js",
|
|
||||||
"bin": "./bin/nanoid.cjs",
|
|
||||||
"sideEffects": false,
|
|
||||||
"types": "./index.d.ts",
|
|
||||||
"type": "module",
|
|
||||||
"main": "index.cjs",
|
|
||||||
"module": "index.js",
|
|
||||||
"exports": {
|
|
||||||
".": {
|
|
||||||
"browser": "./index.browser.js",
|
|
||||||
"require": {
|
|
||||||
"types": "./index.d.cts",
|
|
||||||
"default": "./index.cjs"
|
|
||||||
},
|
|
||||||
"import": {
|
|
||||||
"types": "./index.d.ts",
|
|
||||||
"default": "./index.js"
|
|
||||||
},
|
|
||||||
"default": "./index.js"
|
|
||||||
},
|
|
||||||
"./package.json": "./package.json",
|
|
||||||
"./async/package.json": "./async/package.json",
|
|
||||||
"./async": {
|
|
||||||
"browser": "./async/index.browser.js",
|
|
||||||
"require": {
|
|
||||||
"types": "./index.d.cts",
|
|
||||||
"default": "./async/index.cjs"
|
|
||||||
},
|
|
||||||
"import": {
|
|
||||||
"types": "./index.d.ts",
|
|
||||||
"default": "./async/index.js"
|
|
||||||
},
|
|
||||||
"default": "./async/index.js"
|
|
||||||
},
|
|
||||||
"./non-secure/package.json": "./non-secure/package.json",
|
|
||||||
"./non-secure": {
|
|
||||||
"require": {
|
|
||||||
"types": "./index.d.cts",
|
|
||||||
"default": "./non-secure/index.cjs"
|
|
||||||
},
|
|
||||||
"import": {
|
|
||||||
"types": "./index.d.ts",
|
|
||||||
"default": "./non-secure/index.js"
|
|
||||||
},
|
|
||||||
"default": "./non-secure/index.js"
|
|
||||||
},
|
|
||||||
"./url-alphabet/package.json": "./url-alphabet/package.json",
|
|
||||||
"./url-alphabet": {
|
|
||||||
"require": {
|
|
||||||
"types": "./index.d.cts",
|
|
||||||
"default": "./url-alphabet/index.cjs"
|
|
||||||
},
|
|
||||||
"import": {
|
|
||||||
"types": "./index.d.ts",
|
|
||||||
"default": "./url-alphabet/index.js"
|
|
||||||
},
|
|
||||||
"default": "./url-alphabet/index.js"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
3
node_modules/nanoid/url-alphabet/index.cjs
generated
vendored
3
node_modules/nanoid/url-alphabet/index.cjs
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
let urlAlphabet =
|
|
||||||
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
|
||||||
module.exports = { urlAlphabet }
|
|
3
node_modules/nanoid/url-alphabet/index.js
generated
vendored
3
node_modules/nanoid/url-alphabet/index.js
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
let urlAlphabet =
|
|
||||||
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
|
|
||||||
export { urlAlphabet }
|
|
6
node_modules/nanoid/url-alphabet/package.json
generated
vendored
6
node_modules/nanoid/url-alphabet/package.json
generated
vendored
@ -1,6 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "module",
|
|
||||||
"main": "index.cjs",
|
|
||||||
"module": "index.js",
|
|
||||||
"react-native": "index.js"
|
|
||||||
}
|
|
15
node_modules/picocolors/LICENSE
generated
vendored
15
node_modules/picocolors/LICENSE
generated
vendored
@ -1,15 +0,0 @@
|
|||||||
ISC License
|
|
||||||
|
|
||||||
Copyright (c) 2021-2024 Oleksii Raspopov, Kostiantyn Denysov, Anton Verinov
|
|
||||||
|
|
||||||
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.
|
|
177
node_modules/picocolors/README.md
generated
vendored
177
node_modules/picocolors/README.md
generated
vendored
@ -1,177 +0,0 @@
|
|||||||
# picocolors
|
|
||||||
|
|
||||||
The tiniest and the fastest library for terminal output formatting with ANSI colors.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
import pc from "picocolors"
|
|
||||||
|
|
||||||
console.log(
|
|
||||||
pc.green(`How are ${pc.italic(`you`)} doing?`)
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
- **No dependencies.**
|
|
||||||
- **14 times** smaller and **2 times** faster than chalk.
|
|
||||||
- Used by popular tools like PostCSS, SVGO, Stylelint, and Browserslist.
|
|
||||||
- Node.js v6+ & browsers support. Support for both CJS and ESM projects.
|
|
||||||
- TypeScript type declarations included.
|
|
||||||
- [`NO_COLOR`](https://no-color.org/) friendly.
|
|
||||||
|
|
||||||
## Motivation
|
|
||||||
|
|
||||||
With `picocolors` we are trying to draw attention to the `node_modules` size
|
|
||||||
problem and promote performance-first culture.
|
|
||||||
|
|
||||||
## Prior Art
|
|
||||||
|
|
||||||
Credits go to the following projects:
|
|
||||||
|
|
||||||
- [Nanocolors](https://github.com/ai/nanocolors) by [@ai](https://github.com/ai)
|
|
||||||
- [Colorette](https://github.com/jorgebucaran/colorette) by [@jorgebucaran](https://github.com/jorgebucaran)
|
|
||||||
- [Kleur](https://github.com/lukeed/kleur) by [@lukeed](https://github.com/lukeed)
|
|
||||||
- [Colors.js](https://github.com/Marak/colors.js) by [@Marak](https://github.com/Marak)
|
|
||||||
- [Chalk](https://github.com/chalk/chalk) by [@sindresorhus](https://github.com/sindresorhus)
|
|
||||||
|
|
||||||
## Benchmarks
|
|
||||||
|
|
||||||
The space in node_modules including sub-dependencies:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
$ node ./benchmarks/size.js
|
|
||||||
Data from packagephobia.com
|
|
||||||
chalk 101 kB
|
|
||||||
cli-color 1249 kB
|
|
||||||
ansi-colors 25 kB
|
|
||||||
kleur 21 kB
|
|
||||||
colorette 17 kB
|
|
||||||
nanocolors 16 kB
|
|
||||||
+ picocolors 7 kB
|
|
||||||
```
|
|
||||||
|
|
||||||
Library loading time:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
$ node ./benchmarks/loading.js
|
|
||||||
chalk 6.167 ms
|
|
||||||
cli-color 31.431 ms
|
|
||||||
ansi-colors 1.585 ms
|
|
||||||
kleur 2.008 ms
|
|
||||||
kleur/colors 0.773 ms
|
|
||||||
colorette 2.476 ms
|
|
||||||
nanocolors 0.833 ms
|
|
||||||
+ picocolors 0.466 ms
|
|
||||||
```
|
|
||||||
|
|
||||||
Benchmark for simple use case:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
$ node ./benchmarks/simple.js
|
|
||||||
chalk 24,066,342 ops/sec
|
|
||||||
cli-color 938,700 ops/sec
|
|
||||||
ansi-colors 4,532,542 ops/sec
|
|
||||||
kleur 20,343,122 ops/sec
|
|
||||||
kleur/colors 35,415,770 ops/sec
|
|
||||||
colorette 34,244,834 ops/sec
|
|
||||||
nanocolors 33,443,265 ops/sec
|
|
||||||
+ picocolors 33,271,645 ops/sec
|
|
||||||
```
|
|
||||||
|
|
||||||
Benchmark for complex use cases:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
$ node ./benchmarks/complex.js
|
|
||||||
chalk 969,915 ops/sec
|
|
||||||
cli-color 131,639 ops/sec
|
|
||||||
ansi-colors 342,250 ops/sec
|
|
||||||
kleur 611,880 ops/sec
|
|
||||||
kleur/colors 1,129,526 ops/sec
|
|
||||||
colorette 1,747,277 ops/sec
|
|
||||||
nanocolors 1,251,312 ops/sec
|
|
||||||
+ picocolors 2,024,086 ops/sec
|
|
||||||
```
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
Picocolors provides an object which includes a variety of text coloring and formatting functions
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
import pc from "picocolors"
|
|
||||||
```
|
|
||||||
|
|
||||||
The object includes following coloring functions: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `gray`.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
console.log(`I see a ${pc.red("red door")} and I want it painted ${pc.black("black")}`)
|
|
||||||
```
|
|
||||||
|
|
||||||
The object also includes following background color modifier functions: `bgBlack`, `bgRed`, `bgGreen`, `bgYellow`, `bgBlue`, `bgMagenta`, `bgCyan`, `bgWhite` and bright variants `bgBlackBright`, `bgRedBright`, `bgGreenBright`, `bgYellowBright`, `bgBlueBright`, `bgMagentaBright`, `bgCyanBright`, `bgWhiteBright`.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
console.log(
|
|
||||||
pc.bgBlack(
|
|
||||||
pc.white(`Tom appeared on the sidewalk with a bucket of whitewash and a long-handled brush.`)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
```
|
|
||||||
|
|
||||||
Besides colors, the object includes following formatting functions: `dim`, `bold`, `hidden`, `italic`, `underline`, `strikethrough`, `reset`, `inverse` and bright variants `blackBright`, `redBright`, `greenBright`, `yellowBright`, `blueBright`, `magentaBright`, `cyanBright`, `whiteBright`.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
for (let task of tasks) {
|
|
||||||
console.log(`${pc.bold(task.name)} ${pc.dim(task.durationMs + "ms")}`)
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
The library provides additional utilities to ensure the best results for the task:
|
|
||||||
|
|
||||||
- `isColorSupported` — boolean, explicitly tells whether or not the colors or formatting appear on the screen
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
import pc from "picocolors"
|
|
||||||
|
|
||||||
if (pc.isColorSupported) {
|
|
||||||
console.log("Yay! This script can use colors and formatters")
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
- `createColors(enabled)` — a function that returns a new API object with manually defined color support configuration
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
import pc from "picocolors"
|
|
||||||
|
|
||||||
let { red, bgWhite } = pc.createColors(options.enableColors)
|
|
||||||
```
|
|
||||||
|
|
||||||
## Replacing `chalk`
|
|
||||||
|
|
||||||
1. Replace package name in import:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
- import chalk from 'chalk'
|
|
||||||
+ import pico from 'picocolors'
|
|
||||||
```
|
|
||||||
|
|
||||||
2. Replace variable:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
- chalk.red(text)
|
|
||||||
+ pico.red(text)
|
|
||||||
```
|
|
||||||
|
|
||||||
3. Replace chains to nested calls:
|
|
||||||
|
|
||||||
```diff
|
|
||||||
- chalk.red.bold(text)
|
|
||||||
+ pico.red(pico.bold(text))
|
|
||||||
```
|
|
||||||
|
|
||||||
4. You can use [`colorize-template`](https://github.com/usmanyunusov/colorize-template)
|
|
||||||
to replace chalk’s tagged template literal.
|
|
||||||
|
|
||||||
```diff
|
|
||||||
+ import { createColorize } from 'colorize-template'
|
|
||||||
|
|
||||||
+ let colorize = createColorize(pico)
|
|
||||||
- chalk.red.bold`full {yellow ${"text"}}`
|
|
||||||
+ colorize`{red.bold full {yellow ${"text"}}}`
|
|
||||||
```
|
|
49
node_modules/picocolors/package.json
generated
vendored
49
node_modules/picocolors/package.json
generated
vendored
@ -1,49 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "picocolors",
|
|
||||||
"version": "1.1.0",
|
|
||||||
"main": "./picocolors.js",
|
|
||||||
"types": "./picocolors.d.ts",
|
|
||||||
"browser": {
|
|
||||||
"./picocolors.js": "./picocolors.browser.js"
|
|
||||||
},
|
|
||||||
"sideEffects": false,
|
|
||||||
"description": "The tiniest and the fastest library for terminal output formatting with ANSI colors",
|
|
||||||
"scripts": {
|
|
||||||
"test": "node tests/test.js"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"picocolors.*",
|
|
||||||
"types.ts"
|
|
||||||
],
|
|
||||||
"keywords": [
|
|
||||||
"terminal",
|
|
||||||
"colors",
|
|
||||||
"formatting",
|
|
||||||
"cli",
|
|
||||||
"console"
|
|
||||||
],
|
|
||||||
"author": "Alexey Raspopov",
|
|
||||||
"repository": "alexeyraspopov/picocolors",
|
|
||||||
"license": "ISC",
|
|
||||||
"devDependencies": {
|
|
||||||
"ansi-colors": "^4.1.1",
|
|
||||||
"benchmark": "^2.1.4",
|
|
||||||
"chalk": "^4.1.2",
|
|
||||||
"clean-publish": "^3.0.3",
|
|
||||||
"cli-color": "^2.0.0",
|
|
||||||
"colorette": "^2.0.12",
|
|
||||||
"kleur": "^4.1.4",
|
|
||||||
"nanocolors": "^0.2.12",
|
|
||||||
"prettier": "^2.4.1"
|
|
||||||
},
|
|
||||||
"prettier": {
|
|
||||||
"printWidth": 100,
|
|
||||||
"useTabs": true,
|
|
||||||
"tabWidth": 2,
|
|
||||||
"semi": false,
|
|
||||||
"arrowParens": "avoid"
|
|
||||||
},
|
|
||||||
"clean-publish": {
|
|
||||||
"cleanDocs": true
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user