docs:更新文档

This commit is contained in:
张益铭
2021-03-01 15:06:11 +08:00
parent 1542135ab0
commit 9064b372e8
5835 changed files with 904126 additions and 161722 deletions

3
node_modules/esbuild/README.md generated vendored Normal file
View File

@@ -0,0 +1,3 @@
# esbuild
This is a JavaScript bundler and minifier. See https://github.com/evanw/esbuild and the [JavaScript API documentation](https://github.com/evanw/esbuild/blob/master/docs/js-api.md) for details.

5
node_modules/esbuild/bin/esbuild generated vendored Normal file
View File

@@ -0,0 +1,5 @@
#!/usr/bin/env node
const path = require('path');
const esbuild_exe = path.join(__dirname, '..', 'esbuild.exe');
const child_process = require('child_process');
child_process.spawnSync(esbuild_exe, process.argv.slice(2), { stdio: 'inherit' });

BIN
node_modules/esbuild/esbuild.exe generated vendored Normal file

Binary file not shown.

225
node_modules/esbuild/install.js generated vendored Normal file
View File

@@ -0,0 +1,225 @@
var __assign = Object.assign;
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (result) => {
return result.done ? resolve(result.value) : Promise.resolve(result.value).then(fulfilled, rejected);
};
step((generator = generator.apply(__this, __arguments)).next());
});
};
const fs = require("fs");
const os = require("os");
const path = require("path");
const zlib = require("zlib");
const https = require("https");
const child_process = require("child_process");
const version = "0.7.22";
const binPath = path.join(__dirname, "bin", "esbuild");
function installBinaryFromPackage(name, fromPath, toPath) {
return __async(this, null, function* () {
const cachePath = getCachePath(name);
try {
fs.copyFileSync(cachePath, toPath);
fs.chmodSync(toPath, 493);
validateBinaryVersion(toPath);
const now = new Date();
fs.utimesSync(cachePath, now, now);
return;
} catch (e) {
}
let buffer;
let didFail = false;
try {
buffer = installUsingNPM(name, fromPath);
} catch (err) {
didFail = true;
console.error(`Trying to install "${name}" using npm`);
console.error(`Failed to install "${name}" using npm: ${err && err.message || err}`);
}
if (!buffer) {
const url = `https://registry.npmjs.org/${name}/-/${name}-${version}.tgz`;
console.error(`Trying to download ${JSON.stringify(url)}`);
try {
buffer = extractFileFromTarGzip(yield fetch(url), fromPath);
} catch (err) {
console.error(`Failed to download ${JSON.stringify(url)}: ${err && err.message || err}`);
}
}
if (!buffer) {
console.error(`Install unsuccessful`);
process.exit(1);
}
fs.writeFileSync(toPath, buffer, {mode: 493});
try {
validateBinaryVersion(toPath);
} catch (err) {
console.error(`The version of the downloaded binary is incorrect: ${err && err.message || err}`);
console.error(`Install unsuccessful`);
process.exit(1);
}
try {
fs.mkdirSync(path.dirname(cachePath), {recursive: true});
fs.copyFileSync(toPath, cachePath);
cleanCacheLRU(cachePath);
} catch (e) {
}
if (didFail)
console.error(`Install successful`);
});
}
function validateBinaryVersion(binaryPath) {
const stdout = child_process.execFileSync(binaryPath, ["--version"]).toString().trim();
if (stdout !== version) {
throw new Error(`Expected ${JSON.stringify(version)} but got ${JSON.stringify(stdout)}`);
}
}
function getCachePath(name) {
const home = os.homedir();
const common = ["esbuild", "bin", `${name}@${version}`];
if (process.platform === "darwin")
return path.join(home, "Library", "Caches", ...common);
if (process.platform === "win32")
return path.join(home, "AppData", "Local", "Cache", ...common);
return path.join(home, ".cache", ...common);
}
function cleanCacheLRU(fileToKeep) {
const dir = path.dirname(fileToKeep);
const entries = [];
for (const entry of fs.readdirSync(dir)) {
const entryPath = path.join(dir, entry);
try {
const stats = fs.statSync(entryPath);
entries.push({path: entryPath, mtime: stats.mtime});
} catch (e) {
}
}
entries.sort((a, b) => +b.mtime - +a.mtime);
for (const entry of entries.slice(5)) {
try {
fs.unlinkSync(entry.path);
} catch (e) {
}
}
}
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, file) {
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;
file = `package/${file}`;
while (offset < buffer.length) {
let name = str(offset, 100);
let size = parseInt(str(offset + 124, 12), 8);
offset += 512;
if (!isNaN(size)) {
if (name === file)
return buffer.subarray(offset, offset + size);
offset += size + 511 & ~511;
}
}
throw new Error(`Could not find ${JSON.stringify(file)} in archive`);
}
function installUsingNPM(name, file) {
const installDir = path.join(__dirname, ".install");
fs.mkdirSync(installDir, {recursive: true});
fs.writeFileSync(path.join(installDir, "package.json"), "{}");
const env = __assign(__assign({}, process.env), {npm_config_global: void 0});
child_process.execSync(`npm install --loglevel=error --prefer-offline --no-audit --progress=false ${name}@${version}`, {cwd: installDir, stdio: "pipe", env});
const buffer = fs.readFileSync(path.join(installDir, "node_modules", name, file));
removeRecursive(installDir);
return buffer;
}
function removeRecursive(dir) {
for (const entry of fs.readdirSync(dir)) {
const entryPath = path.join(dir, entry);
let stats;
try {
stats = fs.lstatSync(entryPath);
} catch (e) {
continue;
}
if (stats.isDirectory())
removeRecursive(entryPath);
else
fs.unlinkSync(entryPath);
}
fs.rmdirSync(dir);
}
function installOnUnix(name) {
if (process.env.ESBUILD_BIN_PATH_FOR_TESTS) {
fs.unlinkSync(binPath);
fs.symlinkSync(process.env.ESBUILD_BIN_PATH_FOR_TESTS, binPath);
} else {
installBinaryFromPackage(name, "bin/esbuild", binPath).catch((e) => setImmediate(() => {
throw e;
}));
}
}
function installOnWindows(name) {
fs.writeFileSync(binPath, `#!/usr/bin/env node
const path = require('path');
const esbuild_exe = path.join(__dirname, '..', 'esbuild.exe');
const child_process = require('child_process');
child_process.spawnSync(esbuild_exe, process.argv.slice(2), { stdio: 'inherit' });
`);
const exePath = path.join(__dirname, "esbuild.exe");
if (process.env.ESBUILD_BIN_PATH_FOR_TESTS) {
fs.copyFileSync(process.env.ESBUILD_BIN_PATH_FOR_TESTS, exePath);
} else {
installBinaryFromPackage(name, "esbuild.exe", exePath).catch((e) => setImmediate(() => {
throw e;
}));
}
}
const key = `${process.platform} ${os.arch()} ${os.endianness()}`;
const knownWindowsPackages = {
"win32 ia32 LE": "esbuild-windows-32",
"win32 x64 LE": "esbuild-windows-64"
};
const knownUnixlikePackages = {
"darwin x64 LE": "esbuild-darwin-64",
"freebsd arm64 LE": "esbuild-freebsd-arm64",
"freebsd x64 LE": "esbuild-freebsd-64",
"linux arm64 LE": "esbuild-linux-arm64",
"linux ia32 LE": "esbuild-linux-32",
"linux ppc64 LE": "esbuild-linux-ppc64le",
"linux x64 LE": "esbuild-linux-64"
};
if (key in knownWindowsPackages) {
installOnWindows(knownWindowsPackages[key]);
} else if (key in knownUnixlikePackages) {
installOnUnix(knownUnixlikePackages[key]);
} else {
console.error(`Unsupported platform: ${key}`);
process.exit(1);
}

196
node_modules/esbuild/lib/main.d.ts generated vendored Normal file
View File

@@ -0,0 +1,196 @@
export type Platform = 'browser' | 'node';
export type Format = 'iife' | 'cjs' | 'esm';
export type Loader = 'js' | 'jsx' | 'ts' | 'tsx' | 'css' | 'json' | 'text' | 'base64' | 'file' | 'dataurl' | 'binary';
export type LogLevel = 'info' | 'warning' | 'error' | 'silent';
export type Strict = 'nullish-coalescing' | 'optional-chaining' | 'class-fields';
export type Charset = 'ascii' | 'utf8';
interface CommonOptions {
sourcemap?: boolean | 'inline' | 'external';
format?: Format;
globalName?: string;
target?: string | string[];
strict?: boolean | Strict[];
minify?: boolean;
minifyWhitespace?: boolean;
minifyIdentifiers?: boolean;
minifySyntax?: boolean;
charset?: Charset;
jsxFactory?: string;
jsxFragment?: string;
define?: { [key: string]: string };
pure?: string[];
avoidTDZ?: boolean;
color?: boolean;
logLevel?: LogLevel;
errorLimit?: number;
}
export interface BuildOptions extends CommonOptions {
bundle?: boolean;
splitting?: boolean;
outfile?: string;
metafile?: string;
outdir?: string;
platform?: Platform;
color?: boolean;
external?: string[];
loader?: { [ext: string]: Loader };
resolveExtensions?: string[];
mainFields?: string[];
write?: boolean;
tsconfig?: string;
outExtension?: { [ext: string]: string };
publicPath?: string;
inject?: string[];
entryPoints?: string[];
stdin?: StdinOptions;
}
export interface StdinOptions {
contents: string;
resolveDir?: string;
sourcefile?: string;
loader?: Loader;
}
export interface Message {
text: string;
location: Location | null;
}
export interface Location {
file: string;
line: number; // 1-based
column: number; // 0-based, in bytes
length: number; // in bytes
lineText: string;
}
export interface OutputFile {
path: string;
contents: Uint8Array;
}
export interface BuildResult {
warnings: Message[];
outputFiles?: OutputFile[]; // Only when "write: false"
}
export interface BuildFailure extends Error {
errors: Message[];
warnings: Message[];
}
export interface TransformOptions extends CommonOptions {
tsconfigRaw?: string | {
compilerOptions?: {
jsxFactory?: string,
jsxFragmentFactory?: string,
useDefineForClassFields?: boolean,
importsNotUsedAsValues?: 'remove' | 'preserve' | 'error',
},
};
sourcefile?: string;
loader?: Loader;
}
export interface TransformResult {
js: string;
jsSourceMap: string;
warnings: Message[];
}
export interface TransformFailure extends Error {
errors: Message[];
warnings: Message[];
}
// This is the type information for the "metafile" JSON format
export interface Metadata {
inputs: {
[path: string]: {
bytes: number
imports: {
path: string
}[]
}
}
outputs: {
[path: string]: {
bytes: number
inputs: {
[path: string]: {
bytesInOutput: number
}
}
imports: {
path: string
}[]
}
}
}
export interface Service {
build(options: BuildOptions): Promise<BuildResult>;
transform(input: string, options?: TransformOptions): Promise<TransformResult>;
// This stops the service, which kills the long-lived child process. Any
// pending requests will be aborted.
stop(): void;
}
// 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: no
export declare function build(options: BuildOptions): Promise<BuildResult>;
// 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: no
export declare function transform(input: string, options?: TransformOptions): Promise<TransformResult>;
// A synchronous version of "build".
//
// Works in node: yes
// Works in browser: no
export declare function buildSync(options: BuildOptions): BuildResult;
// A synchronous version of "transform".
//
// Works in node: yes
// Works in browser: no
export declare function transformSync(input: string, options?: TransformOptions): TransformResult;
// This starts "esbuild" as a long-lived child process that is then reused, so
// you can call methods on the service many times without the overhead of
// starting up a new child process each time.
//
// Works in node: yes
// Works in browser: yes ("options" is required)
export declare function startService(options?: ServiceOptions): Promise<Service>;
export interface ServiceOptions {
// The URL of the "esbuild.wasm" file. This must be provided when running
// esbuild in the browser.
wasmURL?: string
// 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;

813
node_modules/esbuild/lib/main.js generated vendored Normal file
View File

@@ -0,0 +1,813 @@
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
var __export = (target, all) => {
__markAsModule(target);
for (var name in all)
__defProp(target, name, {get: all[name], enumerable: true});
};
var __exportStar = (target, module2, desc) => {
__markAsModule(target);
if (typeof module2 === "object" || typeof module2 === "function") {
for (let key of __getOwnPropNames(module2))
if (!__hasOwnProp.call(target, key) && key !== "default")
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
}
return target;
};
var __toModule = (module2) => {
if (module2 && module2.__esModule)
return module2;
return __exportStar(__defProp(__create(__getProtoOf(module2)), "default", {value: module2, enumerable: true}), module2);
};
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (result) => {
return result.done ? resolve(result.value) : Promise.resolve(result.value).then(fulfilled, rejected);
};
step((generator = generator.apply(__this, __arguments)).next());
});
};
// lib/node.ts
__export(exports, {
build: () => build,
buildSync: () => buildSync,
startService: () => startService,
transform: () => transform,
transformSync: () => transformSync,
version: () => version
});
// lib/stdio_protocol.ts
function encodePacket(packet) {
let visit = (value) => {
if (value === null) {
bb.write8(0);
} else if (typeof value === "boolean") {
bb.write8(1);
bb.write8(+value);
} else if (typeof value === "number") {
bb.write8(2);
bb.write32(value | 0);
} else if (typeof value === "string") {
bb.write8(3);
bb.write(encodeUTF8(value));
} else if (value instanceof Uint8Array) {
bb.write8(4);
bb.write(value);
} else if (value instanceof Array) {
bb.write8(5);
bb.write32(value.length);
for (let item of value) {
visit(item);
}
} else {
let keys = Object.keys(value);
bb.write8(6);
bb.write32(keys.length);
for (let key of keys) {
bb.write(encodeUTF8(key));
visit(value[key]);
}
}
};
let bb = new ByteBuffer();
bb.write32(0);
bb.write32(packet.id << 1 | +!packet.isRequest);
visit(packet.value);
writeUInt32LE(bb.buf, bb.len - 4, 0);
return bb.buf.subarray(0, bb.len);
}
function decodePacket(bytes) {
let visit = () => {
switch (bb.read8()) {
case 0:
return null;
case 1:
return !!bb.read8();
case 2:
return bb.read32();
case 3:
return decodeUTF8(bb.read());
case 4:
return bb.read();
case 5: {
let count = bb.read32();
let value2 = [];
for (let i = 0; i < count; i++) {
value2.push(visit());
}
return value2;
}
case 6: {
let count = bb.read32();
let value2 = {};
for (let i = 0; i < count; i++) {
value2[decodeUTF8(bb.read())] = visit();
}
return value2;
}
default:
throw new Error("Invalid packet");
}
};
let bb = new ByteBuffer(bytes);
let id = bb.read32();
let isRequest = (id & 1) === 0;
id >>>= 1;
let value = visit();
if (bb.ptr !== bytes.length) {
throw new Error("Invalid packet");
}
return {id, isRequest, value};
}
class ByteBuffer {
constructor(buf = new Uint8Array(1024)) {
this.buf = buf;
this.len = 0;
this.ptr = 0;
}
_write(delta) {
if (this.len + delta > this.buf.length) {
let clone = new Uint8Array((this.len + delta) * 2);
clone.set(this.buf);
this.buf = clone;
}
this.len += delta;
return this.len - delta;
}
write8(value) {
let offset = this._write(1);
this.buf[offset] = value;
}
write32(value) {
let offset = this._write(4);
writeUInt32LE(this.buf, value, offset);
}
write(bytes) {
let offset = this._write(4 + bytes.length);
writeUInt32LE(this.buf, bytes.length, offset);
this.buf.set(bytes, offset + 4);
}
_read(delta) {
if (this.ptr + delta > this.buf.length) {
throw new Error("Invalid packet");
}
this.ptr += delta;
return this.ptr - delta;
}
read8() {
return this.buf[this._read(1)];
}
read32() {
return readUInt32LE(this.buf, this._read(4));
}
read() {
let length = this.read32();
let bytes = new Uint8Array(length);
let ptr = this._read(bytes.length);
bytes.set(this.buf.subarray(ptr, ptr + length));
return bytes;
}
}
let encodeUTF8;
let decodeUTF8;
if (typeof TextEncoder !== "undefined" && typeof TextDecoder !== "undefined") {
let encoder = new TextEncoder();
let decoder = new TextDecoder();
encodeUTF8 = (text) => encoder.encode(text);
decodeUTF8 = (bytes) => decoder.decode(bytes);
} else if (typeof Buffer !== "undefined") {
encodeUTF8 = (text) => Buffer.from(text);
decodeUTF8 = (bytes) => Buffer.from(bytes).toString();
} else {
throw new Error("No UTF-8 codec found");
}
function readUInt32LE(buffer, offset) {
return buffer[offset++] | buffer[offset++] << 8 | buffer[offset++] << 16 | buffer[offset++] << 24;
}
function writeUInt32LE(buffer, value, offset) {
buffer[offset++] = value;
buffer[offset++] = value >> 8;
buffer[offset++] = value >> 16;
buffer[offset++] = value >> 24;
}
// lib/common.ts
function validateTarget(target) {
target += "";
if (target.indexOf(",") >= 0)
throw new Error(`Invalid target: ${target}`);
return target;
}
let mustBeBoolean = (value) => typeof value === "boolean" ? null : "a boolean";
let mustBeString = (value) => typeof value === "string" ? null : "a string";
let mustBeInteger = (value) => typeof value === "number" && value === (value | 0) ? null : "an integer";
let mustBeArray = (value) => Array.isArray(value) ? null : "an array";
let mustBeObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? null : "an object";
let mustBeStringOrBoolean = (value) => typeof value === "string" || typeof value === "boolean" ? null : "a string or a boolean";
let mustBeStringOrObject = (value) => typeof value === "string" || typeof value === "object" && value !== null && !Array.isArray(value) ? null : "a string or an object";
let mustBeStringOrArray = (value) => typeof value === "string" || Array.isArray(value) ? null : "a string or an array";
let mustBeBooleanOrArray = (value) => typeof value === "boolean" || Array.isArray(value) ? null : "a boolean or an array";
function getFlag(object, keys, key, mustBeFn) {
let value = object[key];
keys[key + ""] = true;
if (value === void 0)
return void 0;
let mustBe = mustBeFn(value);
if (mustBe !== null)
throw new Error(`"${key}" must be ${mustBe}`);
return value;
}
function checkForInvalidFlags(object, keys) {
for (let key in object) {
if (!(key in keys)) {
throw new Error(`Invalid option: "${key}"`);
}
}
}
function pushLogFlags(flags, options, keys, isTTY2, logLevelDefault) {
let color = getFlag(options, keys, "color", mustBeBoolean);
let logLevel = getFlag(options, keys, "logLevel", mustBeString);
let errorLimit = getFlag(options, keys, "errorLimit", mustBeInteger);
if (color)
flags.push(`--color=${color}`);
else if (isTTY2)
flags.push(`--color=true`);
flags.push(`--log-level=${logLevel || logLevelDefault}`);
flags.push(`--error-limit=${errorLimit || 0}`);
}
function pushCommonFlags(flags, options, keys) {
let target = getFlag(options, keys, "target", mustBeStringOrArray);
let format = getFlag(options, keys, "format", mustBeString);
let globalName = getFlag(options, keys, "globalName", mustBeString);
let strict = getFlag(options, keys, "strict", mustBeBooleanOrArray);
let minify = getFlag(options, keys, "minify", mustBeBoolean);
let minifySyntax = getFlag(options, keys, "minifySyntax", mustBeBoolean);
let minifyWhitespace = getFlag(options, keys, "minifyWhitespace", mustBeBoolean);
let minifyIdentifiers = getFlag(options, keys, "minifyIdentifiers", mustBeBoolean);
let charset = getFlag(options, keys, "charset", mustBeString);
let jsxFactory = getFlag(options, keys, "jsxFactory", mustBeString);
let jsxFragment = getFlag(options, keys, "jsxFragment", mustBeString);
let define = getFlag(options, keys, "define", mustBeObject);
let pure = getFlag(options, keys, "pure", mustBeArray);
let avoidTDZ = getFlag(options, keys, "avoidTDZ", mustBeBoolean);
if (target) {
if (Array.isArray(target))
flags.push(`--target=${Array.from(target).map(validateTarget).join(",")}`);
else
flags.push(`--target=${validateTarget(target)}`);
}
if (format)
flags.push(`--format=${format}`);
if (globalName)
flags.push(`--global-name=${globalName}`);
if (strict === true)
flags.push(`--strict`);
else if (strict)
for (let key of strict)
flags.push(`--strict:${key}`);
if (minify)
flags.push("--minify");
if (minifySyntax)
flags.push("--minify-syntax");
if (minifyWhitespace)
flags.push("--minify-whitespace");
if (minifyIdentifiers)
flags.push("--minify-identifiers");
if (charset)
flags.push(`--charset=${charset}`);
if (jsxFactory)
flags.push(`--jsx-factory=${jsxFactory}`);
if (jsxFragment)
flags.push(`--jsx-fragment=${jsxFragment}`);
if (define) {
for (let key in define) {
if (key.indexOf("=") >= 0)
throw new Error(`Invalid define: ${key}`);
flags.push(`--define:${key}=${define[key]}`);
}
}
if (pure)
for (let fn of pure)
flags.push(`--pure:${fn}`);
if (avoidTDZ)
flags.push(`--avoid-tdz`);
}
function flagsForBuildOptions(options, isTTY2, logLevelDefault) {
let flags = [];
let keys = Object.create(null);
let stdinContents = null;
let stdinResolveDir = null;
pushLogFlags(flags, options, keys, isTTY2, logLevelDefault);
pushCommonFlags(flags, options, keys);
let sourcemap = getFlag(options, keys, "sourcemap", mustBeStringOrBoolean);
let bundle = getFlag(options, keys, "bundle", mustBeBoolean);
let splitting = getFlag(options, keys, "splitting", mustBeBoolean);
let metafile = getFlag(options, keys, "metafile", mustBeString);
let outfile = getFlag(options, keys, "outfile", mustBeString);
let outdir = getFlag(options, keys, "outdir", mustBeString);
let platform = getFlag(options, keys, "platform", mustBeString);
let tsconfig = getFlag(options, keys, "tsconfig", mustBeString);
let resolveExtensions = getFlag(options, keys, "resolveExtensions", mustBeArray);
let mainFields = getFlag(options, keys, "mainFields", mustBeArray);
let external = getFlag(options, keys, "external", mustBeArray);
let loader = getFlag(options, keys, "loader", mustBeObject);
let outExtension = getFlag(options, keys, "outExtension", mustBeObject);
let publicPath = getFlag(options, keys, "publicPath", mustBeString);
let inject = getFlag(options, keys, "inject", mustBeArray);
let entryPoints = getFlag(options, keys, "entryPoints", mustBeArray);
let stdin = getFlag(options, keys, "stdin", mustBeObject);
let write = getFlag(options, keys, "write", mustBeBoolean) !== false;
checkForInvalidFlags(options, keys);
if (sourcemap)
flags.push(`--sourcemap${sourcemap === true ? "" : `=${sourcemap}`}`);
if (bundle)
flags.push("--bundle");
if (splitting)
flags.push("--splitting");
if (metafile)
flags.push(`--metafile=${metafile}`);
if (outfile)
flags.push(`--outfile=${outfile}`);
if (outdir)
flags.push(`--outdir=${outdir}`);
if (platform)
flags.push(`--platform=${platform}`);
if (tsconfig)
flags.push(`--tsconfig=${tsconfig}`);
if (resolveExtensions)
flags.push(`--resolve-extensions=${resolveExtensions.join(",")}`);
if (publicPath)
flags.push(`--public-path=${publicPath}`);
if (mainFields)
flags.push(`--main-fields=${mainFields.join(",")}`);
if (external)
for (let name of external)
flags.push(`--external:${name}`);
if (inject)
for (let path2 of inject)
flags.push(`--inject:${path2}`);
if (loader) {
for (let ext in loader) {
if (ext.indexOf("=") >= 0)
throw new Error(`Invalid extension: ${ext}`);
flags.push(`--loader:${ext}=${loader[ext]}`);
}
}
if (outExtension) {
for (let ext in outExtension) {
if (ext.indexOf("=") >= 0)
throw new Error(`Invalid extension: ${ext}`);
flags.push(`--out-extension:${ext}=${outExtension[ext]}`);
}
}
if (entryPoints) {
for (let entryPoint of entryPoints) {
entryPoint += "";
if (entryPoint.startsWith("-"))
throw new Error(`Invalid entry point: ${entryPoint}`);
flags.push(entryPoint);
}
}
if (stdin) {
let stdinKeys = Object.create(null);
let contents = getFlag(stdin, stdinKeys, "contents", mustBeString);
let resolveDir = getFlag(stdin, stdinKeys, "resolveDir", mustBeString);
let sourcefile = getFlag(stdin, stdinKeys, "sourcefile", mustBeString);
let loader2 = getFlag(stdin, stdinKeys, "loader", mustBeString);
checkForInvalidFlags(stdin, stdinKeys);
if (sourcefile)
flags.push(`--sourcefile=${sourcefile}`);
if (loader2)
flags.push(`--loader=${loader2}`);
if (resolveDir)
stdinResolveDir = resolveDir + "";
stdinContents = contents ? contents + "" : "";
}
return [flags, write, stdinContents, stdinResolveDir];
}
function flagsForTransformOptions(options, isTTY2, logLevelDefault) {
let flags = [];
let keys = Object.create(null);
pushLogFlags(flags, options, keys, isTTY2, logLevelDefault);
pushCommonFlags(flags, options, keys);
let sourcemap = getFlag(options, keys, "sourcemap", mustBeStringOrBoolean);
let tsconfigRaw = getFlag(options, keys, "tsconfigRaw", mustBeStringOrObject);
let sourcefile = getFlag(options, keys, "sourcefile", mustBeString);
let loader = getFlag(options, keys, "loader", mustBeString);
checkForInvalidFlags(options, keys);
if (sourcemap)
flags.push(`--sourcemap=${sourcemap === true ? "external" : sourcemap}`);
if (tsconfigRaw)
flags.push(`--tsconfig-raw=${typeof tsconfigRaw === "string" ? tsconfigRaw : JSON.stringify(tsconfigRaw)}`);
if (sourcefile)
flags.push(`--sourcefile=${sourcefile}`);
if (loader)
flags.push(`--loader=${loader}`);
return flags;
}
function createChannel(streamIn) {
let responseCallbacks = new Map();
let isClosed = false;
let nextRequestID = 0;
let stdout = new Uint8Array(16 * 1024);
let stdoutUsed = 0;
let readFromStdout = (chunk) => {
let limit = stdoutUsed + chunk.length;
if (limit > stdout.length) {
let swap = new Uint8Array(limit * 2);
swap.set(stdout);
stdout = swap;
}
stdout.set(chunk, stdoutUsed);
stdoutUsed += chunk.length;
let offset = 0;
while (offset + 4 <= stdoutUsed) {
let length = readUInt32LE(stdout, offset);
if (offset + 4 + length > stdoutUsed) {
break;
}
offset += 4;
handleIncomingPacket(stdout.slice(offset, offset + length));
offset += length;
}
if (offset > 0) {
stdout.set(stdout.slice(offset));
stdoutUsed -= offset;
}
};
let afterClose = () => {
isClosed = true;
for (let callback of responseCallbacks.values()) {
callback("The service was stopped", null);
}
responseCallbacks.clear();
};
let sendRequest = (value, callback) => {
if (isClosed)
return callback("The service is no longer running", null);
let id = nextRequestID++;
responseCallbacks.set(id, callback);
streamIn.writeToStdin(encodePacket({id, isRequest: true, value}));
};
let sendResponse = (id, value) => {
if (isClosed)
throw new Error("The service is no longer running");
streamIn.writeToStdin(encodePacket({id, isRequest: false, value}));
};
let handleRequest = (id, request) => __async(this, null, function* () {
try {
let command = request.command;
switch (command) {
default:
throw new Error(`Invalid command: ` + command);
}
} catch (e) {
sendResponse(id, {errors: [yield extractErrorMessageV8(e, streamIn)]});
}
});
let isFirstPacket = true;
let handleIncomingPacket = (bytes) => {
if (isFirstPacket) {
isFirstPacket = false;
let binaryVersion = String.fromCharCode(...bytes);
if (binaryVersion !== "0.7.22") {
throw new Error(`Cannot start service: Host version "${"0.7.22"}" does not match binary version ${JSON.stringify(binaryVersion)}`);
}
return;
}
let packet = decodePacket(bytes);
if (packet.isRequest) {
handleRequest(packet.id, packet.value);
} else {
let callback = responseCallbacks.get(packet.id);
responseCallbacks.delete(packet.id);
if (packet.value.error)
callback(packet.value.error, {});
else
callback(null, packet.value);
}
};
return {
readFromStdout,
afterClose,
service: {
build(options, isTTY2, callback) {
const logLevelDefault = "info";
try {
let [flags, write, stdin, resolveDir] = flagsForBuildOptions(options, isTTY2, logLevelDefault);
let request = {command: "build", flags, write, stdin, resolveDir};
sendRequest(request, (error, response) => {
if (error)
return callback(new Error(error), null);
let errors = response.errors;
let warnings = response.warnings;
if (errors.length > 0)
return callback(failureErrorWithLog("Build failed", errors, warnings), null);
let result = {warnings};
if (!write)
result.outputFiles = response.outputFiles;
callback(null, result);
});
} catch (e) {
let flags = [];
try {
pushLogFlags(flags, options, {}, isTTY2, logLevelDefault);
} catch (e2) {
}
sendRequest({command: "error", flags, error: extractErrorMessageV8(e, streamIn)}, () => {
callback(e, null);
});
}
},
transform(input, options, isTTY2, fs2, callback) {
const logLevelDefault = "silent";
let start = (inputPath) => {
try {
let flags = flagsForTransformOptions(options, isTTY2, logLevelDefault);
let request = {
command: "transform",
flags,
inputFS: inputPath !== null,
input: inputPath !== null ? inputPath : input + ""
};
sendRequest(request, (error, response) => {
if (error)
return callback(new Error(error), null);
let errors = response.errors;
let warnings = response.warnings;
let outstanding = 1;
let next = () => --outstanding === 0 && callback(null, {warnings, js: response.js, jsSourceMap: response.jsSourceMap});
if (errors.length > 0)
return callback(failureErrorWithLog("Transform failed", errors, warnings), null);
if (response.jsFS) {
outstanding++;
fs2.readFile(response.js, (err, contents) => {
if (err !== null) {
callback(err, null);
} else {
response.js = contents;
next();
}
});
}
if (response.jsSourceMapFS) {
outstanding++;
fs2.readFile(response.jsSourceMap, (err, contents) => {
if (err !== null) {
callback(err, null);
} else {
response.jsSourceMap = contents;
next();
}
});
}
next();
});
} catch (e) {
let flags = [];
try {
pushLogFlags(flags, options, {}, isTTY2, logLevelDefault);
} catch (e2) {
}
sendRequest({command: "error", flags, error: extractErrorMessageV8(e, streamIn)}, () => {
callback(e, null);
});
}
};
if (typeof input === "string" && input.length > 1024 * 1024) {
let next = start;
start = () => fs2.writeFile(input, next);
}
start(null);
}
}
};
}
function extractErrorMessageV8(e, streamIn) {
let text = "Internal error";
let location = null;
try {
text = (e && e.message || e) + "";
} catch (e2) {
}
try {
let stack = e.stack + "";
let lines = stack.split("\n", 3);
let at = " at ";
if (streamIn.readFileSync && !lines[0].startsWith(at) && lines[1].startsWith(at)) {
let line = lines[1].slice(at.length);
while (true) {
let match = /^\S+ \((.*)\)$/.exec(line);
if (match) {
line = match[1];
continue;
}
match = /^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(line);
if (match) {
line = match[1];
continue;
}
match = /^(\S+):(\d+):(\d+)$/.exec(line);
if (match) {
let contents = streamIn.readFileSync(match[1], "utf8");
let lineText = contents.split(/\r\n|\r|\n|\u2028|\u2029/)[+match[2] - 1] || "";
location = {
file: match[1],
line: +match[2],
column: +match[3] - 1,
length: 0,
lineText: lineText + "\n" + lines.slice(1).join("\n")
};
}
break;
}
}
} catch (e2) {
}
return {text, location};
}
function failureErrorWithLog(text, errors, warnings) {
let limit = 5;
let summary = errors.length < 1 ? "" : ` with ${errors.length} error${errors.length < 2 ? "" : "s"}:` + errors.slice(0, limit + 1).map((e, i) => {
if (i === limit)
return "\n...";
if (!e.location)
return `
error: ${e.text}`;
let {file, line, column} = e.location;
return `
${file}:${line}:${column}: error: ${e.text}`;
}).join("");
let error = new Error(`${text}${summary}`);
error.errors = errors;
error.warnings = warnings;
return error;
}
// lib/node.ts
const child_process = __toModule(require("child_process"));
const crypto = __toModule(require("crypto"));
const path = __toModule(require("path"));
const fs = __toModule(require("fs"));
const os = __toModule(require("os"));
const tty = __toModule(require("tty"));
let esbuildCommandAndArgs = () => {
if (false) {
return ["node", [path.join(__dirname, "..", "bin", "esbuild")]];
}
if (process.platform === "win32") {
return [path.join(__dirname, "..", "esbuild.exe"), []];
}
return [path.join(__dirname, "..", "bin", "esbuild"), []];
};
let isTTY = () => tty.isatty(2);
let version = "0.7.22";
let build = (options) => {
return startService().then((service) => {
let promise = service.build(options);
promise.then(service.stop, service.stop);
return promise;
});
};
let transform = (input, options) => {
return startService().then((service) => {
let promise = service.transform(input, options);
promise.then(service.stop, service.stop);
return promise;
});
};
let buildSync = (options) => {
let result;
runServiceSync((service) => service.build(options, isTTY(), (err, res) => {
if (err)
throw err;
result = res;
}));
return result;
};
let transformSync = (input, options) => {
let result;
runServiceSync((service) => service.transform(input, options || {}, isTTY(), {
readFile(tempFile, callback) {
try {
let contents = fs.readFileSync(tempFile, "utf8");
try {
fs.unlinkSync(tempFile);
} catch (e) {
}
callback(null, contents);
} catch (err) {
callback(err, null);
}
},
writeFile(contents, callback) {
try {
let tempFile = randomFileName();
fs.writeFileSync(tempFile, contents);
callback(tempFile);
} catch (e) {
callback(null);
}
}
}, (err, res) => {
if (err)
throw err;
result = res;
}));
return result;
};
let startService = (options) => {
if (options) {
if (options.wasmURL)
throw new Error(`The "wasmURL" option only works in the browser`);
if (options.worker)
throw new Error(`The "worker" option only works in the browser`);
}
let [command, args] = esbuildCommandAndArgs();
let child = child_process.spawn(command, args.concat(`--service=${"0.7.22"}`), {
cwd: process.cwd(),
windowsHide: true,
stdio: ["pipe", "pipe", "inherit"]
});
let {readFromStdout, afterClose, service} = createChannel({
writeToStdin(bytes) {
child.stdin.write(bytes);
},
readFileSync: fs.readFileSync
});
child.stdout.on("data", readFromStdout);
child.stdout.on("end", afterClose);
return Promise.resolve({
build: (options2) => new Promise((resolve, reject) => service.build(options2, isTTY(), (err, res) => err ? reject(err) : resolve(res))),
transform: (input, options2) => new Promise((resolve, reject) => service.transform(input, options2 || {}, isTTY(), {
readFile(tempFile, callback) {
try {
fs.readFile(tempFile, "utf8", (err, contents) => {
try {
fs.unlink(tempFile, () => callback(err, contents));
} catch (e) {
callback(err, contents);
}
});
} catch (err) {
callback(err, null);
}
},
writeFile(contents, callback) {
try {
let tempFile = randomFileName();
fs.writeFile(tempFile, contents, (err) => err !== null ? callback(null) : callback(tempFile));
} catch (e) {
callback(null);
}
}
}, (err, res) => err ? reject(err) : resolve(res))),
stop() {
child.kill();
}
});
};
let runServiceSync = (callback) => {
let [command, args] = esbuildCommandAndArgs();
let stdin = new Uint8Array();
let {readFromStdout, afterClose, service} = createChannel({
writeToStdin(bytes) {
if (stdin.length !== 0)
throw new Error("Must run at most one command");
stdin = bytes;
}
});
callback(service);
let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.7.22"}`), {
cwd: process.cwd(),
windowsHide: true,
input: stdin,
maxBuffer: +process.env.ESBUILD_MAX_BUFFER || 16 * 1024 * 1024
});
readFromStdout(stdout);
afterClose();
};
let randomFileName = () => {
return path.join(os.tmpdir(), `esbuild-${crypto.randomBytes(32).toString("hex")}`);
};

51
node_modules/esbuild/package.json generated vendored Normal file
View File

@@ -0,0 +1,51 @@
{
"_args": [
[
"esbuild@0.7.22",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "esbuild@0.7.22",
"_id": "esbuild@0.7.22",
"_inBundle": false,
"_integrity": "sha1-kUm5A/gSi3xFp1QEbCQZnXa74I4=",
"_location": "/esbuild",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "esbuild@0.7.22",
"name": "esbuild",
"escapedName": "esbuild",
"rawSpec": "0.7.22",
"saveSpec": null,
"fetchSpec": "0.7.22"
},
"_requiredBy": [
"/vite"
],
"_resolved": "http://192.168.250.101:4873/esbuild/-/esbuild-0.7.22.tgz",
"_spec": "0.7.22",
"_where": "J:\\Github\\CURD-TS",
"bin": {
"esbuild": "bin/esbuild"
},
"bugs": {
"url": "https://github.com/evanw/esbuild/issues"
},
"description": "An extremely fast JavaScript bundler and minifier.",
"homepage": "https://github.com/evanw/esbuild#readme",
"license": "MIT",
"main": "lib/main.js",
"name": "esbuild",
"repository": {
"type": "git",
"url": "git+https://github.com/evanw/esbuild.git"
},
"scripts": {
"postinstall": "node install.js"
},
"types": "lib/main.d.ts",
"version": "0.7.22"
}