@storm-software/workspace-tools 1.62.18 → 1.62.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/declarations.d.ts +129 -0
- package/executors.json +35 -0
- package/generators.json +53 -0
- package/index.js +4 -2410
- package/meta.json +1 -1
- package/package.json +16 -2
- package/src/executors/npm-publish/schema.d.ts +8 -0
- package/src/executors/npm-publish/schema.json +26 -0
- package/src/executors/tsup/executor.js +4 -2410
- package/src/executors/tsup/schema.d.ts +48 -0
- package/src/executors/tsup/schema.json +223 -0
- package/src/executors/tsup-browser/executor.js +4 -2410
- package/src/executors/tsup-browser/schema.d.ts +9 -0
- package/src/executors/tsup-browser/schema.json +11 -0
- package/src/executors/tsup-neutral/executor.js +4 -2410
- package/src/executors/tsup-neutral/schema.d.ts +5 -0
- package/src/executors/tsup-neutral/schema.json +11 -0
- package/src/executors/tsup-node/executor.js +4 -2410
- package/src/executors/tsup-node/schema.d.ts +7 -0
- package/src/executors/tsup-node/schema.json +20 -0
- package/src/executors/typia/schema.d.ts +6 -0
- package/src/executors/typia/schema.json +38 -0
- package/src/generators/browser-library/files/README.md +58 -0
- package/src/generators/browser-library/files/jest.config.ts +3 -0
- package/src/generators/browser-library/files/src/index.ts.template +10 -0
- package/src/generators/browser-library/files/tsconfig.spec.json +13 -0
- package/src/generators/browser-library/schema.d.ts +22 -0
- package/src/generators/browser-library/schema.json +82 -0
- package/src/generators/config-schema/schema.d.ts +3 -0
- package/src/generators/config-schema/schema.json +20 -0
- package/src/generators/init/schema.d.ts +3 -0
- package/src/generators/init/schema.json +16 -0
- package/src/generators/neutral-library/files/README.md +58 -0
- package/src/generators/neutral-library/files/jest.config.ts +3 -0
- package/src/generators/neutral-library/files/src/index.ts.template +10 -0
- package/src/generators/neutral-library/files/tsconfig.spec.json +13 -0
- package/src/generators/neutral-library/schema.d.ts +6 -0
- package/src/generators/neutral-library/schema.json +82 -0
- package/src/generators/node-library/files/README.md +58 -0
- package/src/generators/node-library/files/jest.config.ts +3 -0
- package/src/generators/node-library/files/src/index.ts.template +10 -0
- package/src/generators/node-library/files/tsconfig.spec.json +13 -0
- package/src/generators/node-library/schema.d.ts +22 -0
- package/src/generators/node-library/schema.json +82 -0
- package/src/generators/preset/files/.all-contributorsrc.template +48 -0
- package/src/generators/preset/files/.editorconfig +454 -0
- package/src/generators/preset/files/.env.template +43 -0
- package/src/generators/preset/files/.gitattributes +52 -0
- package/src/generators/preset/files/.github/.nvmrc +1 -0
- package/src/generators/preset/files/.github/.whitesource +14 -0
- package/src/generators/preset/files/.github/CODEOWNERS +1 -0
- package/src/generators/preset/files/.github/CODE_OF_CONDUCT.md +125 -0
- package/src/generators/preset/files/.github/CONTRIBUTING.md.template +15 -0
- package/src/generators/preset/files/.github/FUNDING.yml +3 -0
- package/src/generators/preset/files/.github/ISSUE_TEMPLATE/bug-report.yml.template +102 -0
- package/src/generators/preset/files/.github/ISSUE_TEMPLATE/documentation.yml.template +56 -0
- package/src/generators/preset/files/.github/ISSUE_TEMPLATE/feature-request.yml.template +60 -0
- package/src/generators/preset/files/.github/PULL_REQUEST_TEMPLATE.md.template +39 -0
- package/src/generators/preset/files/.github/SECURITY.md +9 -0
- package/src/generators/preset/files/.github/actions/setup-workspace/action.yaml +41 -0
- package/src/generators/preset/files/.github/codecov.yml +29 -0
- package/src/generators/preset/files/.github/labels.yml +78 -0
- package/src/generators/preset/files/.github/renovate.json.template +51 -0
- package/src/generators/preset/files/.github/stale.yml +50 -0
- package/src/generators/preset/files/.github/workflows/build-release.yml.template +94 -0
- package/src/generators/preset/files/.github/workflows/code-review.yml +18 -0
- package/src/generators/preset/files/.github/workflows/codeql.yml +84 -0
- package/src/generators/preset/files/.github/workflows/git-guardian.yml +23 -0
- package/src/generators/preset/files/.github/workflows/greetings.yml +24 -0
- package/src/generators/preset/files/.github/workflows/labels.yml +31 -0
- package/src/generators/preset/files/.github/workflows/lock.yml +26 -0
- package/src/generators/preset/files/.log4brains.yml.template +5 -0
- package/src/generators/preset/files/.markdownlint.json +28 -0
- package/src/generators/preset/files/.verdaccio/config.yml.template +40 -0
- package/src/generators/preset/files/.vscode/README.md +32 -0
- package/src/generators/preset/files/.vscode/cspell.json +3 -0
- package/src/generators/preset/files/.vscode/extensions.json +14 -0
- package/src/generators/preset/files/.vscode/launch.json +37 -0
- package/src/generators/preset/files/.vscode/settings.json +316 -0
- package/src/generators/preset/files/.vscode/tasks.json +19 -0
- package/src/generators/preset/files/LICENSE +201 -0
- package/src/generators/preset/files/README.md.template +273 -0
- package/src/generators/preset/files/assets/diagrams/.gitkeep +0 -0
- package/src/generators/preset/files/assets/icons/dark/.gitkeep +0 -0
- package/src/generators/preset/files/assets/icons/light/.gitkeep +0 -0
- package/src/generators/preset/files/assets/logos/.gitkeep +0 -0
- package/src/generators/preset/files/biome.json +4 -0
- package/src/generators/preset/files/docs/api-reference/.gitkeep +0 -0
- package/src/generators/preset/files/docs/readme-templates/README.footer.md.template +94 -0
- package/src/generators/preset/files/docs/readme-templates/README.header.md.template +17 -0
- package/src/generators/preset/files/lefthook.json +6 -0
- package/src/generators/preset/files/nx.json +3 -0
- package/src/generators/preset/files/pnpm-workspace.yaml +6 -0
- package/src/generators/preset/files/socket.yaml +20 -0
- package/src/generators/preset/files/tsconfig.base.json.template +11 -0
- package/src/generators/preset/schema.d.ts +14 -0
- package/src/generators/preset/schema.json +103 -0
- package/src/generators/release-version/schema.d.ts +3 -0
- package/src/generators/release-version/schema.json +66 -0
- package/src/utils/index.js +4 -2410
|
@@ -379956,2412 +379956,6 @@ var require_lib4 = __commonJS({
|
|
|
379956
379956
|
}
|
|
379957
379957
|
});
|
|
379958
379958
|
|
|
379959
|
-
// node_modules/.pnpm/esbuild@0.19.12/node_modules/esbuild/lib/main.js
|
|
379960
|
-
var require_main2 = __commonJS({
|
|
379961
|
-
"node_modules/.pnpm/esbuild@0.19.12/node_modules/esbuild/lib/main.js"(exports2, module2) {
|
|
379962
|
-
"use strict";
|
|
379963
|
-
var __defProp4 = Object.defineProperty;
|
|
379964
|
-
var __getOwnPropDesc3 = Object.getOwnPropertyDescriptor;
|
|
379965
|
-
var __getOwnPropNames3 = Object.getOwnPropertyNames;
|
|
379966
|
-
var __hasOwnProp3 = Object.prototype.hasOwnProperty;
|
|
379967
|
-
var __export4 = (target, all) => {
|
|
379968
|
-
for (var name in all)
|
|
379969
|
-
__defProp4(target, name, { get: all[name], enumerable: true });
|
|
379970
|
-
};
|
|
379971
|
-
var __copyProps3 = (to3, from, except, desc) => {
|
|
379972
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
379973
|
-
for (let key2 of __getOwnPropNames3(from))
|
|
379974
|
-
if (!__hasOwnProp3.call(to3, key2) && key2 !== except)
|
|
379975
|
-
__defProp4(to3, key2, { get: () => from[key2], enumerable: !(desc = __getOwnPropDesc3(from, key2)) || desc.enumerable });
|
|
379976
|
-
}
|
|
379977
|
-
return to3;
|
|
379978
|
-
};
|
|
379979
|
-
var __toCommonJS2 = (mod) => __copyProps3(__defProp4({}, "__esModule", { value: true }), mod);
|
|
379980
|
-
var node_exports = {};
|
|
379981
|
-
__export4(node_exports, {
|
|
379982
|
-
analyzeMetafile: () => analyzeMetafile,
|
|
379983
|
-
analyzeMetafileSync: () => analyzeMetafileSync,
|
|
379984
|
-
build: () => build2,
|
|
379985
|
-
buildSync: () => buildSync,
|
|
379986
|
-
context: () => context,
|
|
379987
|
-
default: () => node_default,
|
|
379988
|
-
formatMessages: () => formatMessages,
|
|
379989
|
-
formatMessagesSync: () => formatMessagesSync,
|
|
379990
|
-
initialize: () => initialize,
|
|
379991
|
-
stop: () => stop,
|
|
379992
|
-
transform: () => transform2,
|
|
379993
|
-
transformSync: () => transformSync,
|
|
379994
|
-
version: () => version
|
|
379995
|
-
});
|
|
379996
|
-
module2.exports = __toCommonJS2(node_exports);
|
|
379997
|
-
function encodePacket(packet) {
|
|
379998
|
-
let visit = (value) => {
|
|
379999
|
-
if (value === null) {
|
|
380000
|
-
bb.write8(0);
|
|
380001
|
-
} else if (typeof value === "boolean") {
|
|
380002
|
-
bb.write8(1);
|
|
380003
|
-
bb.write8(+value);
|
|
380004
|
-
} else if (typeof value === "number") {
|
|
380005
|
-
bb.write8(2);
|
|
380006
|
-
bb.write32(value | 0);
|
|
380007
|
-
} else if (typeof value === "string") {
|
|
380008
|
-
bb.write8(3);
|
|
380009
|
-
bb.write(encodeUTF8(value));
|
|
380010
|
-
} else if (value instanceof Uint8Array) {
|
|
380011
|
-
bb.write8(4);
|
|
380012
|
-
bb.write(value);
|
|
380013
|
-
} else if (value instanceof Array) {
|
|
380014
|
-
bb.write8(5);
|
|
380015
|
-
bb.write32(value.length);
|
|
380016
|
-
for (let item of value) {
|
|
380017
|
-
visit(item);
|
|
380018
|
-
}
|
|
380019
|
-
} else {
|
|
380020
|
-
let keys = Object.keys(value);
|
|
380021
|
-
bb.write8(6);
|
|
380022
|
-
bb.write32(keys.length);
|
|
380023
|
-
for (let key2 of keys) {
|
|
380024
|
-
bb.write(encodeUTF8(key2));
|
|
380025
|
-
visit(value[key2]);
|
|
380026
|
-
}
|
|
380027
|
-
}
|
|
380028
|
-
};
|
|
380029
|
-
let bb = new ByteBuffer();
|
|
380030
|
-
bb.write32(0);
|
|
380031
|
-
bb.write32(packet.id << 1 | +!packet.isRequest);
|
|
380032
|
-
visit(packet.value);
|
|
380033
|
-
writeUInt32LE(bb.buf, bb.len - 4, 0);
|
|
380034
|
-
return bb.buf.subarray(0, bb.len);
|
|
380035
|
-
}
|
|
380036
|
-
function decodePacket(bytes) {
|
|
380037
|
-
let visit = () => {
|
|
380038
|
-
switch (bb.read8()) {
|
|
380039
|
-
case 0:
|
|
380040
|
-
return null;
|
|
380041
|
-
case 1:
|
|
380042
|
-
return !!bb.read8();
|
|
380043
|
-
case 2:
|
|
380044
|
-
return bb.read32();
|
|
380045
|
-
case 3:
|
|
380046
|
-
return decodeUTF8(bb.read());
|
|
380047
|
-
case 4:
|
|
380048
|
-
return bb.read();
|
|
380049
|
-
case 5: {
|
|
380050
|
-
let count = bb.read32();
|
|
380051
|
-
let value2 = [];
|
|
380052
|
-
for (let i3 = 0; i3 < count; i3++) {
|
|
380053
|
-
value2.push(visit());
|
|
380054
|
-
}
|
|
380055
|
-
return value2;
|
|
380056
|
-
}
|
|
380057
|
-
case 6: {
|
|
380058
|
-
let count = bb.read32();
|
|
380059
|
-
let value2 = {};
|
|
380060
|
-
for (let i3 = 0; i3 < count; i3++) {
|
|
380061
|
-
value2[decodeUTF8(bb.read())] = visit();
|
|
380062
|
-
}
|
|
380063
|
-
return value2;
|
|
380064
|
-
}
|
|
380065
|
-
default:
|
|
380066
|
-
throw new Error("Invalid packet");
|
|
380067
|
-
}
|
|
380068
|
-
};
|
|
380069
|
-
let bb = new ByteBuffer(bytes);
|
|
380070
|
-
let id = bb.read32();
|
|
380071
|
-
let isRequest = (id & 1) === 0;
|
|
380072
|
-
id >>>= 1;
|
|
380073
|
-
let value = visit();
|
|
380074
|
-
if (bb.ptr !== bytes.length) {
|
|
380075
|
-
throw new Error("Invalid packet");
|
|
380076
|
-
}
|
|
380077
|
-
return { id, isRequest, value };
|
|
380078
|
-
}
|
|
380079
|
-
var ByteBuffer = class {
|
|
380080
|
-
constructor(buf = new Uint8Array(1024)) {
|
|
380081
|
-
this.buf = buf;
|
|
380082
|
-
this.len = 0;
|
|
380083
|
-
this.ptr = 0;
|
|
380084
|
-
}
|
|
380085
|
-
_write(delta) {
|
|
380086
|
-
if (this.len + delta > this.buf.length) {
|
|
380087
|
-
let clone = new Uint8Array((this.len + delta) * 2);
|
|
380088
|
-
clone.set(this.buf);
|
|
380089
|
-
this.buf = clone;
|
|
380090
|
-
}
|
|
380091
|
-
this.len += delta;
|
|
380092
|
-
return this.len - delta;
|
|
380093
|
-
}
|
|
380094
|
-
write8(value) {
|
|
380095
|
-
let offset = this._write(1);
|
|
380096
|
-
this.buf[offset] = value;
|
|
380097
|
-
}
|
|
380098
|
-
write32(value) {
|
|
380099
|
-
let offset = this._write(4);
|
|
380100
|
-
writeUInt32LE(this.buf, value, offset);
|
|
380101
|
-
}
|
|
380102
|
-
write(bytes) {
|
|
380103
|
-
let offset = this._write(4 + bytes.length);
|
|
380104
|
-
writeUInt32LE(this.buf, bytes.length, offset);
|
|
380105
|
-
this.buf.set(bytes, offset + 4);
|
|
380106
|
-
}
|
|
380107
|
-
_read(delta) {
|
|
380108
|
-
if (this.ptr + delta > this.buf.length) {
|
|
380109
|
-
throw new Error("Invalid packet");
|
|
380110
|
-
}
|
|
380111
|
-
this.ptr += delta;
|
|
380112
|
-
return this.ptr - delta;
|
|
380113
|
-
}
|
|
380114
|
-
read8() {
|
|
380115
|
-
return this.buf[this._read(1)];
|
|
380116
|
-
}
|
|
380117
|
-
read32() {
|
|
380118
|
-
return readUInt32LE(this.buf, this._read(4));
|
|
380119
|
-
}
|
|
380120
|
-
read() {
|
|
380121
|
-
let length = this.read32();
|
|
380122
|
-
let bytes = new Uint8Array(length);
|
|
380123
|
-
let ptr = this._read(bytes.length);
|
|
380124
|
-
bytes.set(this.buf.subarray(ptr, ptr + length));
|
|
380125
|
-
return bytes;
|
|
380126
|
-
}
|
|
380127
|
-
};
|
|
380128
|
-
var encodeUTF8;
|
|
380129
|
-
var decodeUTF8;
|
|
380130
|
-
var encodeInvariant;
|
|
380131
|
-
if (typeof TextEncoder !== "undefined" && typeof TextDecoder !== "undefined") {
|
|
380132
|
-
let encoder = new TextEncoder();
|
|
380133
|
-
let decoder = new TextDecoder();
|
|
380134
|
-
encodeUTF8 = (text) => encoder.encode(text);
|
|
380135
|
-
decodeUTF8 = (bytes) => decoder.decode(bytes);
|
|
380136
|
-
encodeInvariant = 'new TextEncoder().encode("")';
|
|
380137
|
-
} else if (typeof Buffer !== "undefined") {
|
|
380138
|
-
encodeUTF8 = (text) => Buffer.from(text);
|
|
380139
|
-
decodeUTF8 = (bytes) => {
|
|
380140
|
-
let { buffer: buffer2, byteOffset, byteLength } = bytes;
|
|
380141
|
-
return Buffer.from(buffer2, byteOffset, byteLength).toString();
|
|
380142
|
-
};
|
|
380143
|
-
encodeInvariant = 'Buffer.from("")';
|
|
380144
|
-
} else {
|
|
380145
|
-
throw new Error("No UTF-8 codec found");
|
|
380146
|
-
}
|
|
380147
|
-
if (!(encodeUTF8("") instanceof Uint8Array))
|
|
380148
|
-
throw new Error(`Invariant violation: "${encodeInvariant} instanceof Uint8Array" is incorrectly false
|
|
380149
|
-
|
|
380150
|
-
This indicates that your JavaScript environment is broken. You cannot use
|
|
380151
|
-
esbuild in this environment because esbuild relies on this invariant. This
|
|
380152
|
-
is not a problem with esbuild. You need to fix your environment instead.
|
|
380153
|
-
`);
|
|
380154
|
-
function readUInt32LE(buffer2, offset) {
|
|
380155
|
-
return buffer2[offset++] | buffer2[offset++] << 8 | buffer2[offset++] << 16 | buffer2[offset++] << 24;
|
|
380156
|
-
}
|
|
380157
|
-
function writeUInt32LE(buffer2, value, offset) {
|
|
380158
|
-
buffer2[offset++] = value;
|
|
380159
|
-
buffer2[offset++] = value >> 8;
|
|
380160
|
-
buffer2[offset++] = value >> 16;
|
|
380161
|
-
buffer2[offset++] = value >> 24;
|
|
380162
|
-
}
|
|
380163
|
-
var quote2 = JSON.stringify;
|
|
380164
|
-
var buildLogLevelDefault = "warning";
|
|
380165
|
-
var transformLogLevelDefault = "silent";
|
|
380166
|
-
function validateTarget(target) {
|
|
380167
|
-
validateStringValue(target, "target");
|
|
380168
|
-
if (target.indexOf(",") >= 0)
|
|
380169
|
-
throw new Error(`Invalid target: ${target}`);
|
|
380170
|
-
return target;
|
|
380171
|
-
}
|
|
380172
|
-
var canBeAnything = () => null;
|
|
380173
|
-
var mustBeBoolean = (value) => typeof value === "boolean" ? null : "a boolean";
|
|
380174
|
-
var mustBeString = (value) => typeof value === "string" ? null : "a string";
|
|
380175
|
-
var mustBeRegExp = (value) => value instanceof RegExp ? null : "a RegExp object";
|
|
380176
|
-
var mustBeInteger = (value) => typeof value === "number" && value === (value | 0) ? null : "an integer";
|
|
380177
|
-
var mustBeFunction = (value) => typeof value === "function" ? null : "a function";
|
|
380178
|
-
var mustBeArray = (value) => Array.isArray(value) ? null : "an array";
|
|
380179
|
-
var mustBeObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) ? null : "an object";
|
|
380180
|
-
var mustBeEntryPoints = (value) => typeof value === "object" && value !== null ? null : "an array or an object";
|
|
380181
|
-
var mustBeWebAssemblyModule = (value) => value instanceof WebAssembly.Module ? null : "a WebAssembly.Module";
|
|
380182
|
-
var mustBeObjectOrNull = (value) => typeof value === "object" && !Array.isArray(value) ? null : "an object or null";
|
|
380183
|
-
var mustBeStringOrBoolean = (value) => typeof value === "string" || typeof value === "boolean" ? null : "a string or a boolean";
|
|
380184
|
-
var mustBeStringOrObject = (value) => typeof value === "string" || typeof value === "object" && value !== null && !Array.isArray(value) ? null : "a string or an object";
|
|
380185
|
-
var mustBeStringOrArray = (value) => typeof value === "string" || Array.isArray(value) ? null : "a string or an array";
|
|
380186
|
-
var mustBeStringOrUint8Array = (value) => typeof value === "string" || value instanceof Uint8Array ? null : "a string or a Uint8Array";
|
|
380187
|
-
var mustBeStringOrURL = (value) => typeof value === "string" || value instanceof URL ? null : "a string or a URL";
|
|
380188
|
-
function getFlag(object, keys, key2, mustBeFn) {
|
|
380189
|
-
let value = object[key2];
|
|
380190
|
-
keys[key2 + ""] = true;
|
|
380191
|
-
if (value === void 0)
|
|
380192
|
-
return void 0;
|
|
380193
|
-
let mustBe = mustBeFn(value);
|
|
380194
|
-
if (mustBe !== null)
|
|
380195
|
-
throw new Error(`${quote2(key2)} must be ${mustBe}`);
|
|
380196
|
-
return value;
|
|
380197
|
-
}
|
|
380198
|
-
function checkForInvalidFlags(object, keys, where) {
|
|
380199
|
-
for (let key2 in object) {
|
|
380200
|
-
if (!(key2 in keys)) {
|
|
380201
|
-
throw new Error(`Invalid option ${where}: ${quote2(key2)}`);
|
|
380202
|
-
}
|
|
380203
|
-
}
|
|
380204
|
-
}
|
|
380205
|
-
function validateInitializeOptions(options8) {
|
|
380206
|
-
let keys = /* @__PURE__ */ Object.create(null);
|
|
380207
|
-
let wasmURL = getFlag(options8, keys, "wasmURL", mustBeStringOrURL);
|
|
380208
|
-
let wasmModule = getFlag(options8, keys, "wasmModule", mustBeWebAssemblyModule);
|
|
380209
|
-
let worker = getFlag(options8, keys, "worker", mustBeBoolean);
|
|
380210
|
-
checkForInvalidFlags(options8, keys, "in initialize() call");
|
|
380211
|
-
return {
|
|
380212
|
-
wasmURL,
|
|
380213
|
-
wasmModule,
|
|
380214
|
-
worker
|
|
380215
|
-
};
|
|
380216
|
-
}
|
|
380217
|
-
function validateMangleCache(mangleCache) {
|
|
380218
|
-
let validated;
|
|
380219
|
-
if (mangleCache !== void 0) {
|
|
380220
|
-
validated = /* @__PURE__ */ Object.create(null);
|
|
380221
|
-
for (let key2 in mangleCache) {
|
|
380222
|
-
let value = mangleCache[key2];
|
|
380223
|
-
if (typeof value === "string" || value === false) {
|
|
380224
|
-
validated[key2] = value;
|
|
380225
|
-
} else {
|
|
380226
|
-
throw new Error(`Expected ${quote2(key2)} in mangle cache to map to either a string or false`);
|
|
380227
|
-
}
|
|
380228
|
-
}
|
|
380229
|
-
}
|
|
380230
|
-
return validated;
|
|
380231
|
-
}
|
|
380232
|
-
function pushLogFlags(flags, options8, keys, isTTY2, logLevelDefault) {
|
|
380233
|
-
let color = getFlag(options8, keys, "color", mustBeBoolean);
|
|
380234
|
-
let logLevel = getFlag(options8, keys, "logLevel", mustBeString);
|
|
380235
|
-
let logLimit = getFlag(options8, keys, "logLimit", mustBeInteger);
|
|
380236
|
-
if (color !== void 0)
|
|
380237
|
-
flags.push(`--color=${color}`);
|
|
380238
|
-
else if (isTTY2)
|
|
380239
|
-
flags.push(`--color=true`);
|
|
380240
|
-
flags.push(`--log-level=${logLevel || logLevelDefault}`);
|
|
380241
|
-
flags.push(`--log-limit=${logLimit || 0}`);
|
|
380242
|
-
}
|
|
380243
|
-
function validateStringValue(value, what, key2) {
|
|
380244
|
-
if (typeof value !== "string") {
|
|
380245
|
-
throw new Error(`Expected value for ${what}${key2 !== void 0 ? " " + quote2(key2) : ""} to be a string, got ${typeof value} instead`);
|
|
380246
|
-
}
|
|
380247
|
-
return value;
|
|
380248
|
-
}
|
|
380249
|
-
function pushCommonFlags(flags, options8, keys) {
|
|
380250
|
-
let legalComments = getFlag(options8, keys, "legalComments", mustBeString);
|
|
380251
|
-
let sourceRoot = getFlag(options8, keys, "sourceRoot", mustBeString);
|
|
380252
|
-
let sourcesContent = getFlag(options8, keys, "sourcesContent", mustBeBoolean);
|
|
380253
|
-
let target = getFlag(options8, keys, "target", mustBeStringOrArray);
|
|
380254
|
-
let format3 = getFlag(options8, keys, "format", mustBeString);
|
|
380255
|
-
let globalName = getFlag(options8, keys, "globalName", mustBeString);
|
|
380256
|
-
let mangleProps = getFlag(options8, keys, "mangleProps", mustBeRegExp);
|
|
380257
|
-
let reserveProps = getFlag(options8, keys, "reserveProps", mustBeRegExp);
|
|
380258
|
-
let mangleQuoted = getFlag(options8, keys, "mangleQuoted", mustBeBoolean);
|
|
380259
|
-
let minify = getFlag(options8, keys, "minify", mustBeBoolean);
|
|
380260
|
-
let minifySyntax = getFlag(options8, keys, "minifySyntax", mustBeBoolean);
|
|
380261
|
-
let minifyWhitespace = getFlag(options8, keys, "minifyWhitespace", mustBeBoolean);
|
|
380262
|
-
let minifyIdentifiers = getFlag(options8, keys, "minifyIdentifiers", mustBeBoolean);
|
|
380263
|
-
let lineLimit = getFlag(options8, keys, "lineLimit", mustBeInteger);
|
|
380264
|
-
let drop = getFlag(options8, keys, "drop", mustBeArray);
|
|
380265
|
-
let dropLabels = getFlag(options8, keys, "dropLabels", mustBeArray);
|
|
380266
|
-
let charset = getFlag(options8, keys, "charset", mustBeString);
|
|
380267
|
-
let treeShaking = getFlag(options8, keys, "treeShaking", mustBeBoolean);
|
|
380268
|
-
let ignoreAnnotations = getFlag(options8, keys, "ignoreAnnotations", mustBeBoolean);
|
|
380269
|
-
let jsx = getFlag(options8, keys, "jsx", mustBeString);
|
|
380270
|
-
let jsxFactory = getFlag(options8, keys, "jsxFactory", mustBeString);
|
|
380271
|
-
let jsxFragment = getFlag(options8, keys, "jsxFragment", mustBeString);
|
|
380272
|
-
let jsxImportSource = getFlag(options8, keys, "jsxImportSource", mustBeString);
|
|
380273
|
-
let jsxDev = getFlag(options8, keys, "jsxDev", mustBeBoolean);
|
|
380274
|
-
let jsxSideEffects = getFlag(options8, keys, "jsxSideEffects", mustBeBoolean);
|
|
380275
|
-
let define2 = getFlag(options8, keys, "define", mustBeObject);
|
|
380276
|
-
let logOverride = getFlag(options8, keys, "logOverride", mustBeObject);
|
|
380277
|
-
let supported = getFlag(options8, keys, "supported", mustBeObject);
|
|
380278
|
-
let pure = getFlag(options8, keys, "pure", mustBeArray);
|
|
380279
|
-
let keepNames = getFlag(options8, keys, "keepNames", mustBeBoolean);
|
|
380280
|
-
let platform = getFlag(options8, keys, "platform", mustBeString);
|
|
380281
|
-
let tsconfigRaw = getFlag(options8, keys, "tsconfigRaw", mustBeStringOrObject);
|
|
380282
|
-
if (legalComments)
|
|
380283
|
-
flags.push(`--legal-comments=${legalComments}`);
|
|
380284
|
-
if (sourceRoot !== void 0)
|
|
380285
|
-
flags.push(`--source-root=${sourceRoot}`);
|
|
380286
|
-
if (sourcesContent !== void 0)
|
|
380287
|
-
flags.push(`--sources-content=${sourcesContent}`);
|
|
380288
|
-
if (target) {
|
|
380289
|
-
if (Array.isArray(target))
|
|
380290
|
-
flags.push(`--target=${Array.from(target).map(validateTarget).join(",")}`);
|
|
380291
|
-
else
|
|
380292
|
-
flags.push(`--target=${validateTarget(target)}`);
|
|
380293
|
-
}
|
|
380294
|
-
if (format3)
|
|
380295
|
-
flags.push(`--format=${format3}`);
|
|
380296
|
-
if (globalName)
|
|
380297
|
-
flags.push(`--global-name=${globalName}`);
|
|
380298
|
-
if (platform)
|
|
380299
|
-
flags.push(`--platform=${platform}`);
|
|
380300
|
-
if (tsconfigRaw)
|
|
380301
|
-
flags.push(`--tsconfig-raw=${typeof tsconfigRaw === "string" ? tsconfigRaw : JSON.stringify(tsconfigRaw)}`);
|
|
380302
|
-
if (minify)
|
|
380303
|
-
flags.push("--minify");
|
|
380304
|
-
if (minifySyntax)
|
|
380305
|
-
flags.push("--minify-syntax");
|
|
380306
|
-
if (minifyWhitespace)
|
|
380307
|
-
flags.push("--minify-whitespace");
|
|
380308
|
-
if (minifyIdentifiers)
|
|
380309
|
-
flags.push("--minify-identifiers");
|
|
380310
|
-
if (lineLimit)
|
|
380311
|
-
flags.push(`--line-limit=${lineLimit}`);
|
|
380312
|
-
if (charset)
|
|
380313
|
-
flags.push(`--charset=${charset}`);
|
|
380314
|
-
if (treeShaking !== void 0)
|
|
380315
|
-
flags.push(`--tree-shaking=${treeShaking}`);
|
|
380316
|
-
if (ignoreAnnotations)
|
|
380317
|
-
flags.push(`--ignore-annotations`);
|
|
380318
|
-
if (drop)
|
|
380319
|
-
for (let what of drop)
|
|
380320
|
-
flags.push(`--drop:${validateStringValue(what, "drop")}`);
|
|
380321
|
-
if (dropLabels)
|
|
380322
|
-
flags.push(`--drop-labels=${Array.from(dropLabels).map((what) => validateStringValue(what, "dropLabels")).join(",")}`);
|
|
380323
|
-
if (mangleProps)
|
|
380324
|
-
flags.push(`--mangle-props=${mangleProps.source}`);
|
|
380325
|
-
if (reserveProps)
|
|
380326
|
-
flags.push(`--reserve-props=${reserveProps.source}`);
|
|
380327
|
-
if (mangleQuoted !== void 0)
|
|
380328
|
-
flags.push(`--mangle-quoted=${mangleQuoted}`);
|
|
380329
|
-
if (jsx)
|
|
380330
|
-
flags.push(`--jsx=${jsx}`);
|
|
380331
|
-
if (jsxFactory)
|
|
380332
|
-
flags.push(`--jsx-factory=${jsxFactory}`);
|
|
380333
|
-
if (jsxFragment)
|
|
380334
|
-
flags.push(`--jsx-fragment=${jsxFragment}`);
|
|
380335
|
-
if (jsxImportSource)
|
|
380336
|
-
flags.push(`--jsx-import-source=${jsxImportSource}`);
|
|
380337
|
-
if (jsxDev)
|
|
380338
|
-
flags.push(`--jsx-dev`);
|
|
380339
|
-
if (jsxSideEffects)
|
|
380340
|
-
flags.push(`--jsx-side-effects`);
|
|
380341
|
-
if (define2) {
|
|
380342
|
-
for (let key2 in define2) {
|
|
380343
|
-
if (key2.indexOf("=") >= 0)
|
|
380344
|
-
throw new Error(`Invalid define: ${key2}`);
|
|
380345
|
-
flags.push(`--define:${key2}=${validateStringValue(define2[key2], "define", key2)}`);
|
|
380346
|
-
}
|
|
380347
|
-
}
|
|
380348
|
-
if (logOverride) {
|
|
380349
|
-
for (let key2 in logOverride) {
|
|
380350
|
-
if (key2.indexOf("=") >= 0)
|
|
380351
|
-
throw new Error(`Invalid log override: ${key2}`);
|
|
380352
|
-
flags.push(`--log-override:${key2}=${validateStringValue(logOverride[key2], "log override", key2)}`);
|
|
380353
|
-
}
|
|
380354
|
-
}
|
|
380355
|
-
if (supported) {
|
|
380356
|
-
for (let key2 in supported) {
|
|
380357
|
-
if (key2.indexOf("=") >= 0)
|
|
380358
|
-
throw new Error(`Invalid supported: ${key2}`);
|
|
380359
|
-
const value = supported[key2];
|
|
380360
|
-
if (typeof value !== "boolean")
|
|
380361
|
-
throw new Error(`Expected value for supported ${quote2(key2)} to be a boolean, got ${typeof value} instead`);
|
|
380362
|
-
flags.push(`--supported:${key2}=${value}`);
|
|
380363
|
-
}
|
|
380364
|
-
}
|
|
380365
|
-
if (pure)
|
|
380366
|
-
for (let fn6 of pure)
|
|
380367
|
-
flags.push(`--pure:${validateStringValue(fn6, "pure")}`);
|
|
380368
|
-
if (keepNames)
|
|
380369
|
-
flags.push(`--keep-names`);
|
|
380370
|
-
}
|
|
380371
|
-
function flagsForBuildOptions(callName, options8, isTTY2, logLevelDefault, writeDefault) {
|
|
380372
|
-
var _a22;
|
|
380373
|
-
let flags = [];
|
|
380374
|
-
let entries = [];
|
|
380375
|
-
let keys = /* @__PURE__ */ Object.create(null);
|
|
380376
|
-
let stdinContents = null;
|
|
380377
|
-
let stdinResolveDir = null;
|
|
380378
|
-
pushLogFlags(flags, options8, keys, isTTY2, logLevelDefault);
|
|
380379
|
-
pushCommonFlags(flags, options8, keys);
|
|
380380
|
-
let sourcemap = getFlag(options8, keys, "sourcemap", mustBeStringOrBoolean);
|
|
380381
|
-
let bundle = getFlag(options8, keys, "bundle", mustBeBoolean);
|
|
380382
|
-
let splitting = getFlag(options8, keys, "splitting", mustBeBoolean);
|
|
380383
|
-
let preserveSymlinks = getFlag(options8, keys, "preserveSymlinks", mustBeBoolean);
|
|
380384
|
-
let metafile = getFlag(options8, keys, "metafile", mustBeBoolean);
|
|
380385
|
-
let outfile = getFlag(options8, keys, "outfile", mustBeString);
|
|
380386
|
-
let outdir = getFlag(options8, keys, "outdir", mustBeString);
|
|
380387
|
-
let outbase = getFlag(options8, keys, "outbase", mustBeString);
|
|
380388
|
-
let tsconfig = getFlag(options8, keys, "tsconfig", mustBeString);
|
|
380389
|
-
let resolveExtensions = getFlag(options8, keys, "resolveExtensions", mustBeArray);
|
|
380390
|
-
let nodePathsInput = getFlag(options8, keys, "nodePaths", mustBeArray);
|
|
380391
|
-
let mainFields = getFlag(options8, keys, "mainFields", mustBeArray);
|
|
380392
|
-
let conditions = getFlag(options8, keys, "conditions", mustBeArray);
|
|
380393
|
-
let external = getFlag(options8, keys, "external", mustBeArray);
|
|
380394
|
-
let packages = getFlag(options8, keys, "packages", mustBeString);
|
|
380395
|
-
let alias = getFlag(options8, keys, "alias", mustBeObject);
|
|
380396
|
-
let loader2 = getFlag(options8, keys, "loader", mustBeObject);
|
|
380397
|
-
let outExtension2 = getFlag(options8, keys, "outExtension", mustBeObject);
|
|
380398
|
-
let publicPath = getFlag(options8, keys, "publicPath", mustBeString);
|
|
380399
|
-
let entryNames = getFlag(options8, keys, "entryNames", mustBeString);
|
|
380400
|
-
let chunkNames = getFlag(options8, keys, "chunkNames", mustBeString);
|
|
380401
|
-
let assetNames = getFlag(options8, keys, "assetNames", mustBeString);
|
|
380402
|
-
let inject = getFlag(options8, keys, "inject", mustBeArray);
|
|
380403
|
-
let banner = getFlag(options8, keys, "banner", mustBeObject);
|
|
380404
|
-
let footer = getFlag(options8, keys, "footer", mustBeObject);
|
|
380405
|
-
let entryPoints = getFlag(options8, keys, "entryPoints", mustBeEntryPoints);
|
|
380406
|
-
let absWorkingDir = getFlag(options8, keys, "absWorkingDir", mustBeString);
|
|
380407
|
-
let stdin2 = getFlag(options8, keys, "stdin", mustBeObject);
|
|
380408
|
-
let write = (_a22 = getFlag(options8, keys, "write", mustBeBoolean)) != null ? _a22 : writeDefault;
|
|
380409
|
-
let allowOverwrite = getFlag(options8, keys, "allowOverwrite", mustBeBoolean);
|
|
380410
|
-
let mangleCache = getFlag(options8, keys, "mangleCache", mustBeObject);
|
|
380411
|
-
keys.plugins = true;
|
|
380412
|
-
checkForInvalidFlags(options8, keys, `in ${callName}() call`);
|
|
380413
|
-
if (sourcemap)
|
|
380414
|
-
flags.push(`--sourcemap${sourcemap === true ? "" : `=${sourcemap}`}`);
|
|
380415
|
-
if (bundle)
|
|
380416
|
-
flags.push("--bundle");
|
|
380417
|
-
if (allowOverwrite)
|
|
380418
|
-
flags.push("--allow-overwrite");
|
|
380419
|
-
if (splitting)
|
|
380420
|
-
flags.push("--splitting");
|
|
380421
|
-
if (preserveSymlinks)
|
|
380422
|
-
flags.push("--preserve-symlinks");
|
|
380423
|
-
if (metafile)
|
|
380424
|
-
flags.push(`--metafile`);
|
|
380425
|
-
if (outfile)
|
|
380426
|
-
flags.push(`--outfile=${outfile}`);
|
|
380427
|
-
if (outdir)
|
|
380428
|
-
flags.push(`--outdir=${outdir}`);
|
|
380429
|
-
if (outbase)
|
|
380430
|
-
flags.push(`--outbase=${outbase}`);
|
|
380431
|
-
if (tsconfig)
|
|
380432
|
-
flags.push(`--tsconfig=${tsconfig}`);
|
|
380433
|
-
if (packages)
|
|
380434
|
-
flags.push(`--packages=${packages}`);
|
|
380435
|
-
if (resolveExtensions) {
|
|
380436
|
-
let values = [];
|
|
380437
|
-
for (let value of resolveExtensions) {
|
|
380438
|
-
validateStringValue(value, "resolve extension");
|
|
380439
|
-
if (value.indexOf(",") >= 0)
|
|
380440
|
-
throw new Error(`Invalid resolve extension: ${value}`);
|
|
380441
|
-
values.push(value);
|
|
380442
|
-
}
|
|
380443
|
-
flags.push(`--resolve-extensions=${values.join(",")}`);
|
|
380444
|
-
}
|
|
380445
|
-
if (publicPath)
|
|
380446
|
-
flags.push(`--public-path=${publicPath}`);
|
|
380447
|
-
if (entryNames)
|
|
380448
|
-
flags.push(`--entry-names=${entryNames}`);
|
|
380449
|
-
if (chunkNames)
|
|
380450
|
-
flags.push(`--chunk-names=${chunkNames}`);
|
|
380451
|
-
if (assetNames)
|
|
380452
|
-
flags.push(`--asset-names=${assetNames}`);
|
|
380453
|
-
if (mainFields) {
|
|
380454
|
-
let values = [];
|
|
380455
|
-
for (let value of mainFields) {
|
|
380456
|
-
validateStringValue(value, "main field");
|
|
380457
|
-
if (value.indexOf(",") >= 0)
|
|
380458
|
-
throw new Error(`Invalid main field: ${value}`);
|
|
380459
|
-
values.push(value);
|
|
380460
|
-
}
|
|
380461
|
-
flags.push(`--main-fields=${values.join(",")}`);
|
|
380462
|
-
}
|
|
380463
|
-
if (conditions) {
|
|
380464
|
-
let values = [];
|
|
380465
|
-
for (let value of conditions) {
|
|
380466
|
-
validateStringValue(value, "condition");
|
|
380467
|
-
if (value.indexOf(",") >= 0)
|
|
380468
|
-
throw new Error(`Invalid condition: ${value}`);
|
|
380469
|
-
values.push(value);
|
|
380470
|
-
}
|
|
380471
|
-
flags.push(`--conditions=${values.join(",")}`);
|
|
380472
|
-
}
|
|
380473
|
-
if (external)
|
|
380474
|
-
for (let name of external)
|
|
380475
|
-
flags.push(`--external:${validateStringValue(name, "external")}`);
|
|
380476
|
-
if (alias) {
|
|
380477
|
-
for (let old in alias) {
|
|
380478
|
-
if (old.indexOf("=") >= 0)
|
|
380479
|
-
throw new Error(`Invalid package name in alias: ${old}`);
|
|
380480
|
-
flags.push(`--alias:${old}=${validateStringValue(alias[old], "alias", old)}`);
|
|
380481
|
-
}
|
|
380482
|
-
}
|
|
380483
|
-
if (banner) {
|
|
380484
|
-
for (let type2 in banner) {
|
|
380485
|
-
if (type2.indexOf("=") >= 0)
|
|
380486
|
-
throw new Error(`Invalid banner file type: ${type2}`);
|
|
380487
|
-
flags.push(`--banner:${type2}=${validateStringValue(banner[type2], "banner", type2)}`);
|
|
380488
|
-
}
|
|
380489
|
-
}
|
|
380490
|
-
if (footer) {
|
|
380491
|
-
for (let type2 in footer) {
|
|
380492
|
-
if (type2.indexOf("=") >= 0)
|
|
380493
|
-
throw new Error(`Invalid footer file type: ${type2}`);
|
|
380494
|
-
flags.push(`--footer:${type2}=${validateStringValue(footer[type2], "footer", type2)}`);
|
|
380495
|
-
}
|
|
380496
|
-
}
|
|
380497
|
-
if (inject)
|
|
380498
|
-
for (let path32 of inject)
|
|
380499
|
-
flags.push(`--inject:${validateStringValue(path32, "inject")}`);
|
|
380500
|
-
if (loader2) {
|
|
380501
|
-
for (let ext2 in loader2) {
|
|
380502
|
-
if (ext2.indexOf("=") >= 0)
|
|
380503
|
-
throw new Error(`Invalid loader extension: ${ext2}`);
|
|
380504
|
-
flags.push(`--loader:${ext2}=${validateStringValue(loader2[ext2], "loader", ext2)}`);
|
|
380505
|
-
}
|
|
380506
|
-
}
|
|
380507
|
-
if (outExtension2) {
|
|
380508
|
-
for (let ext2 in outExtension2) {
|
|
380509
|
-
if (ext2.indexOf("=") >= 0)
|
|
380510
|
-
throw new Error(`Invalid out extension: ${ext2}`);
|
|
380511
|
-
flags.push(`--out-extension:${ext2}=${validateStringValue(outExtension2[ext2], "out extension", ext2)}`);
|
|
380512
|
-
}
|
|
380513
|
-
}
|
|
380514
|
-
if (entryPoints) {
|
|
380515
|
-
if (Array.isArray(entryPoints)) {
|
|
380516
|
-
for (let i3 = 0, n = entryPoints.length; i3 < n; i3++) {
|
|
380517
|
-
let entryPoint = entryPoints[i3];
|
|
380518
|
-
if (typeof entryPoint === "object" && entryPoint !== null) {
|
|
380519
|
-
let entryPointKeys = /* @__PURE__ */ Object.create(null);
|
|
380520
|
-
let input = getFlag(entryPoint, entryPointKeys, "in", mustBeString);
|
|
380521
|
-
let output = getFlag(entryPoint, entryPointKeys, "out", mustBeString);
|
|
380522
|
-
checkForInvalidFlags(entryPoint, entryPointKeys, "in entry point at index " + i3);
|
|
380523
|
-
if (input === void 0)
|
|
380524
|
-
throw new Error('Missing property "in" for entry point at index ' + i3);
|
|
380525
|
-
if (output === void 0)
|
|
380526
|
-
throw new Error('Missing property "out" for entry point at index ' + i3);
|
|
380527
|
-
entries.push([output, input]);
|
|
380528
|
-
} else {
|
|
380529
|
-
entries.push(["", validateStringValue(entryPoint, "entry point at index " + i3)]);
|
|
380530
|
-
}
|
|
380531
|
-
}
|
|
380532
|
-
} else {
|
|
380533
|
-
for (let key2 in entryPoints) {
|
|
380534
|
-
entries.push([key2, validateStringValue(entryPoints[key2], "entry point", key2)]);
|
|
380535
|
-
}
|
|
380536
|
-
}
|
|
380537
|
-
}
|
|
380538
|
-
if (stdin2) {
|
|
380539
|
-
let stdinKeys = /* @__PURE__ */ Object.create(null);
|
|
380540
|
-
let contents = getFlag(stdin2, stdinKeys, "contents", mustBeStringOrUint8Array);
|
|
380541
|
-
let resolveDir = getFlag(stdin2, stdinKeys, "resolveDir", mustBeString);
|
|
380542
|
-
let sourcefile = getFlag(stdin2, stdinKeys, "sourcefile", mustBeString);
|
|
380543
|
-
let loader22 = getFlag(stdin2, stdinKeys, "loader", mustBeString);
|
|
380544
|
-
checkForInvalidFlags(stdin2, stdinKeys, 'in "stdin" object');
|
|
380545
|
-
if (sourcefile)
|
|
380546
|
-
flags.push(`--sourcefile=${sourcefile}`);
|
|
380547
|
-
if (loader22)
|
|
380548
|
-
flags.push(`--loader=${loader22}`);
|
|
380549
|
-
if (resolveDir)
|
|
380550
|
-
stdinResolveDir = resolveDir;
|
|
380551
|
-
if (typeof contents === "string")
|
|
380552
|
-
stdinContents = encodeUTF8(contents);
|
|
380553
|
-
else if (contents instanceof Uint8Array)
|
|
380554
|
-
stdinContents = contents;
|
|
380555
|
-
}
|
|
380556
|
-
let nodePaths = [];
|
|
380557
|
-
if (nodePathsInput) {
|
|
380558
|
-
for (let value of nodePathsInput) {
|
|
380559
|
-
value += "";
|
|
380560
|
-
nodePaths.push(value);
|
|
380561
|
-
}
|
|
380562
|
-
}
|
|
380563
|
-
return {
|
|
380564
|
-
entries,
|
|
380565
|
-
flags,
|
|
380566
|
-
write,
|
|
380567
|
-
stdinContents,
|
|
380568
|
-
stdinResolveDir,
|
|
380569
|
-
absWorkingDir,
|
|
380570
|
-
nodePaths,
|
|
380571
|
-
mangleCache: validateMangleCache(mangleCache)
|
|
380572
|
-
};
|
|
380573
|
-
}
|
|
380574
|
-
function flagsForTransformOptions(callName, options8, isTTY2, logLevelDefault) {
|
|
380575
|
-
let flags = [];
|
|
380576
|
-
let keys = /* @__PURE__ */ Object.create(null);
|
|
380577
|
-
pushLogFlags(flags, options8, keys, isTTY2, logLevelDefault);
|
|
380578
|
-
pushCommonFlags(flags, options8, keys);
|
|
380579
|
-
let sourcemap = getFlag(options8, keys, "sourcemap", mustBeStringOrBoolean);
|
|
380580
|
-
let sourcefile = getFlag(options8, keys, "sourcefile", mustBeString);
|
|
380581
|
-
let loader2 = getFlag(options8, keys, "loader", mustBeString);
|
|
380582
|
-
let banner = getFlag(options8, keys, "banner", mustBeString);
|
|
380583
|
-
let footer = getFlag(options8, keys, "footer", mustBeString);
|
|
380584
|
-
let mangleCache = getFlag(options8, keys, "mangleCache", mustBeObject);
|
|
380585
|
-
checkForInvalidFlags(options8, keys, `in ${callName}() call`);
|
|
380586
|
-
if (sourcemap)
|
|
380587
|
-
flags.push(`--sourcemap=${sourcemap === true ? "external" : sourcemap}`);
|
|
380588
|
-
if (sourcefile)
|
|
380589
|
-
flags.push(`--sourcefile=${sourcefile}`);
|
|
380590
|
-
if (loader2)
|
|
380591
|
-
flags.push(`--loader=${loader2}`);
|
|
380592
|
-
if (banner)
|
|
380593
|
-
flags.push(`--banner=${banner}`);
|
|
380594
|
-
if (footer)
|
|
380595
|
-
flags.push(`--footer=${footer}`);
|
|
380596
|
-
return {
|
|
380597
|
-
flags,
|
|
380598
|
-
mangleCache: validateMangleCache(mangleCache)
|
|
380599
|
-
};
|
|
380600
|
-
}
|
|
380601
|
-
function createChannel(streamIn) {
|
|
380602
|
-
const requestCallbacksByKey = {};
|
|
380603
|
-
const closeData = { didClose: false, reason: "" };
|
|
380604
|
-
let responseCallbacks = {};
|
|
380605
|
-
let nextRequestID = 0;
|
|
380606
|
-
let nextBuildKey = 0;
|
|
380607
|
-
let stdout = new Uint8Array(16 * 1024);
|
|
380608
|
-
let stdoutUsed = 0;
|
|
380609
|
-
let readFromStdout = (chunk) => {
|
|
380610
|
-
let limit = stdoutUsed + chunk.length;
|
|
380611
|
-
if (limit > stdout.length) {
|
|
380612
|
-
let swap = new Uint8Array(limit * 2);
|
|
380613
|
-
swap.set(stdout);
|
|
380614
|
-
stdout = swap;
|
|
380615
|
-
}
|
|
380616
|
-
stdout.set(chunk, stdoutUsed);
|
|
380617
|
-
stdoutUsed += chunk.length;
|
|
380618
|
-
let offset = 0;
|
|
380619
|
-
while (offset + 4 <= stdoutUsed) {
|
|
380620
|
-
let length = readUInt32LE(stdout, offset);
|
|
380621
|
-
if (offset + 4 + length > stdoutUsed) {
|
|
380622
|
-
break;
|
|
380623
|
-
}
|
|
380624
|
-
offset += 4;
|
|
380625
|
-
handleIncomingPacket(stdout.subarray(offset, offset + length));
|
|
380626
|
-
offset += length;
|
|
380627
|
-
}
|
|
380628
|
-
if (offset > 0) {
|
|
380629
|
-
stdout.copyWithin(0, offset, stdoutUsed);
|
|
380630
|
-
stdoutUsed -= offset;
|
|
380631
|
-
}
|
|
380632
|
-
};
|
|
380633
|
-
let afterClose = (error) => {
|
|
380634
|
-
closeData.didClose = true;
|
|
380635
|
-
if (error)
|
|
380636
|
-
closeData.reason = ": " + (error.message || error);
|
|
380637
|
-
const text = "The service was stopped" + closeData.reason;
|
|
380638
|
-
for (let id in responseCallbacks) {
|
|
380639
|
-
responseCallbacks[id](text, null);
|
|
380640
|
-
}
|
|
380641
|
-
responseCallbacks = {};
|
|
380642
|
-
};
|
|
380643
|
-
let sendRequest = (refs, value, callback) => {
|
|
380644
|
-
if (closeData.didClose)
|
|
380645
|
-
return callback("The service is no longer running" + closeData.reason, null);
|
|
380646
|
-
let id = nextRequestID++;
|
|
380647
|
-
responseCallbacks[id] = (error, response) => {
|
|
380648
|
-
try {
|
|
380649
|
-
callback(error, response);
|
|
380650
|
-
} finally {
|
|
380651
|
-
if (refs)
|
|
380652
|
-
refs.unref();
|
|
380653
|
-
}
|
|
380654
|
-
};
|
|
380655
|
-
if (refs)
|
|
380656
|
-
refs.ref();
|
|
380657
|
-
streamIn.writeToStdin(encodePacket({ id, isRequest: true, value }));
|
|
380658
|
-
};
|
|
380659
|
-
let sendResponse = (id, value) => {
|
|
380660
|
-
if (closeData.didClose)
|
|
380661
|
-
throw new Error("The service is no longer running" + closeData.reason);
|
|
380662
|
-
streamIn.writeToStdin(encodePacket({ id, isRequest: false, value }));
|
|
380663
|
-
};
|
|
380664
|
-
let handleRequest = async (id, request) => {
|
|
380665
|
-
try {
|
|
380666
|
-
if (request.command === "ping") {
|
|
380667
|
-
sendResponse(id, {});
|
|
380668
|
-
return;
|
|
380669
|
-
}
|
|
380670
|
-
if (typeof request.key === "number") {
|
|
380671
|
-
const requestCallbacks = requestCallbacksByKey[request.key];
|
|
380672
|
-
if (!requestCallbacks) {
|
|
380673
|
-
return;
|
|
380674
|
-
}
|
|
380675
|
-
const callback = requestCallbacks[request.command];
|
|
380676
|
-
if (callback) {
|
|
380677
|
-
await callback(id, request);
|
|
380678
|
-
return;
|
|
380679
|
-
}
|
|
380680
|
-
}
|
|
380681
|
-
throw new Error(`Invalid command: ` + request.command);
|
|
380682
|
-
} catch (e3) {
|
|
380683
|
-
const errors = [extractErrorMessageV8(e3, streamIn, null, void 0, "")];
|
|
380684
|
-
try {
|
|
380685
|
-
sendResponse(id, { errors });
|
|
380686
|
-
} catch {
|
|
380687
|
-
}
|
|
380688
|
-
}
|
|
380689
|
-
};
|
|
380690
|
-
let isFirstPacket = true;
|
|
380691
|
-
let handleIncomingPacket = (bytes) => {
|
|
380692
|
-
if (isFirstPacket) {
|
|
380693
|
-
isFirstPacket = false;
|
|
380694
|
-
let binaryVersion = String.fromCharCode(...bytes);
|
|
380695
|
-
if (binaryVersion !== "0.19.12") {
|
|
380696
|
-
throw new Error(`Cannot start service: Host version "${"0.19.12"}" does not match binary version ${quote2(binaryVersion)}`);
|
|
380697
|
-
}
|
|
380698
|
-
return;
|
|
380699
|
-
}
|
|
380700
|
-
let packet = decodePacket(bytes);
|
|
380701
|
-
if (packet.isRequest) {
|
|
380702
|
-
handleRequest(packet.id, packet.value);
|
|
380703
|
-
} else {
|
|
380704
|
-
let callback = responseCallbacks[packet.id];
|
|
380705
|
-
delete responseCallbacks[packet.id];
|
|
380706
|
-
if (packet.value.error)
|
|
380707
|
-
callback(packet.value.error, {});
|
|
380708
|
-
else
|
|
380709
|
-
callback(null, packet.value);
|
|
380710
|
-
}
|
|
380711
|
-
};
|
|
380712
|
-
let buildOrContext = ({ callName, refs, options: options8, isTTY: isTTY2, defaultWD: defaultWD2, callback }) => {
|
|
380713
|
-
let refCount = 0;
|
|
380714
|
-
const buildKey = nextBuildKey++;
|
|
380715
|
-
const requestCallbacks = {};
|
|
380716
|
-
const buildRefs = {
|
|
380717
|
-
ref() {
|
|
380718
|
-
if (++refCount === 1) {
|
|
380719
|
-
if (refs)
|
|
380720
|
-
refs.ref();
|
|
380721
|
-
}
|
|
380722
|
-
},
|
|
380723
|
-
unref() {
|
|
380724
|
-
if (--refCount === 0) {
|
|
380725
|
-
delete requestCallbacksByKey[buildKey];
|
|
380726
|
-
if (refs)
|
|
380727
|
-
refs.unref();
|
|
380728
|
-
}
|
|
380729
|
-
}
|
|
380730
|
-
};
|
|
380731
|
-
requestCallbacksByKey[buildKey] = requestCallbacks;
|
|
380732
|
-
buildRefs.ref();
|
|
380733
|
-
buildOrContextImpl(
|
|
380734
|
-
callName,
|
|
380735
|
-
buildKey,
|
|
380736
|
-
sendRequest,
|
|
380737
|
-
sendResponse,
|
|
380738
|
-
buildRefs,
|
|
380739
|
-
streamIn,
|
|
380740
|
-
requestCallbacks,
|
|
380741
|
-
options8,
|
|
380742
|
-
isTTY2,
|
|
380743
|
-
defaultWD2,
|
|
380744
|
-
(err, res) => {
|
|
380745
|
-
try {
|
|
380746
|
-
callback(err, res);
|
|
380747
|
-
} finally {
|
|
380748
|
-
buildRefs.unref();
|
|
380749
|
-
}
|
|
380750
|
-
}
|
|
380751
|
-
);
|
|
380752
|
-
};
|
|
380753
|
-
let transform22 = ({ callName, refs, input, options: options8, isTTY: isTTY2, fs: fs33, callback }) => {
|
|
380754
|
-
const details = createObjectStash();
|
|
380755
|
-
let start = (inputPath) => {
|
|
380756
|
-
try {
|
|
380757
|
-
if (typeof input !== "string" && !(input instanceof Uint8Array))
|
|
380758
|
-
throw new Error('The input to "transform" must be a string or a Uint8Array');
|
|
380759
|
-
let {
|
|
380760
|
-
flags,
|
|
380761
|
-
mangleCache
|
|
380762
|
-
} = flagsForTransformOptions(callName, options8, isTTY2, transformLogLevelDefault);
|
|
380763
|
-
let request = {
|
|
380764
|
-
command: "transform",
|
|
380765
|
-
flags,
|
|
380766
|
-
inputFS: inputPath !== null,
|
|
380767
|
-
input: inputPath !== null ? encodeUTF8(inputPath) : typeof input === "string" ? encodeUTF8(input) : input
|
|
380768
|
-
};
|
|
380769
|
-
if (mangleCache)
|
|
380770
|
-
request.mangleCache = mangleCache;
|
|
380771
|
-
sendRequest(refs, request, (error, response) => {
|
|
380772
|
-
if (error)
|
|
380773
|
-
return callback(new Error(error), null);
|
|
380774
|
-
let errors = replaceDetailsInMessages(response.errors, details);
|
|
380775
|
-
let warnings = replaceDetailsInMessages(response.warnings, details);
|
|
380776
|
-
let outstanding = 1;
|
|
380777
|
-
let next = () => {
|
|
380778
|
-
if (--outstanding === 0) {
|
|
380779
|
-
let result = {
|
|
380780
|
-
warnings,
|
|
380781
|
-
code: response.code,
|
|
380782
|
-
map: response.map,
|
|
380783
|
-
mangleCache: void 0,
|
|
380784
|
-
legalComments: void 0
|
|
380785
|
-
};
|
|
380786
|
-
if ("legalComments" in response)
|
|
380787
|
-
result.legalComments = response == null ? void 0 : response.legalComments;
|
|
380788
|
-
if (response.mangleCache)
|
|
380789
|
-
result.mangleCache = response == null ? void 0 : response.mangleCache;
|
|
380790
|
-
callback(null, result);
|
|
380791
|
-
}
|
|
380792
|
-
};
|
|
380793
|
-
if (errors.length > 0)
|
|
380794
|
-
return callback(failureErrorWithLog("Transform failed", errors, warnings), null);
|
|
380795
|
-
if (response.codeFS) {
|
|
380796
|
-
outstanding++;
|
|
380797
|
-
fs33.readFile(response.code, (err, contents) => {
|
|
380798
|
-
if (err !== null) {
|
|
380799
|
-
callback(err, null);
|
|
380800
|
-
} else {
|
|
380801
|
-
response.code = contents;
|
|
380802
|
-
next();
|
|
380803
|
-
}
|
|
380804
|
-
});
|
|
380805
|
-
}
|
|
380806
|
-
if (response.mapFS) {
|
|
380807
|
-
outstanding++;
|
|
380808
|
-
fs33.readFile(response.map, (err, contents) => {
|
|
380809
|
-
if (err !== null) {
|
|
380810
|
-
callback(err, null);
|
|
380811
|
-
} else {
|
|
380812
|
-
response.map = contents;
|
|
380813
|
-
next();
|
|
380814
|
-
}
|
|
380815
|
-
});
|
|
380816
|
-
}
|
|
380817
|
-
next();
|
|
380818
|
-
});
|
|
380819
|
-
} catch (e3) {
|
|
380820
|
-
let flags = [];
|
|
380821
|
-
try {
|
|
380822
|
-
pushLogFlags(flags, options8, {}, isTTY2, transformLogLevelDefault);
|
|
380823
|
-
} catch {
|
|
380824
|
-
}
|
|
380825
|
-
const error = extractErrorMessageV8(e3, streamIn, details, void 0, "");
|
|
380826
|
-
sendRequest(refs, { command: "error", flags, error }, () => {
|
|
380827
|
-
error.detail = details.load(error.detail);
|
|
380828
|
-
callback(failureErrorWithLog("Transform failed", [error], []), null);
|
|
380829
|
-
});
|
|
380830
|
-
}
|
|
380831
|
-
};
|
|
380832
|
-
if ((typeof input === "string" || input instanceof Uint8Array) && input.length > 1024 * 1024) {
|
|
380833
|
-
let next = start;
|
|
380834
|
-
start = () => fs33.writeFile(input, next);
|
|
380835
|
-
}
|
|
380836
|
-
start(null);
|
|
380837
|
-
};
|
|
380838
|
-
let formatMessages2 = ({ callName, refs, messages: messages2, options: options8, callback }) => {
|
|
380839
|
-
if (!options8)
|
|
380840
|
-
throw new Error(`Missing second argument in ${callName}() call`);
|
|
380841
|
-
let keys = {};
|
|
380842
|
-
let kind = getFlag(options8, keys, "kind", mustBeString);
|
|
380843
|
-
let color = getFlag(options8, keys, "color", mustBeBoolean);
|
|
380844
|
-
let terminalWidth = getFlag(options8, keys, "terminalWidth", mustBeInteger);
|
|
380845
|
-
checkForInvalidFlags(options8, keys, `in ${callName}() call`);
|
|
380846
|
-
if (kind === void 0)
|
|
380847
|
-
throw new Error(`Missing "kind" in ${callName}() call`);
|
|
380848
|
-
if (kind !== "error" && kind !== "warning")
|
|
380849
|
-
throw new Error(`Expected "kind" to be "error" or "warning" in ${callName}() call`);
|
|
380850
|
-
let request = {
|
|
380851
|
-
command: "format-msgs",
|
|
380852
|
-
messages: sanitizeMessages(messages2, "messages", null, "", terminalWidth),
|
|
380853
|
-
isWarning: kind === "warning"
|
|
380854
|
-
};
|
|
380855
|
-
if (color !== void 0)
|
|
380856
|
-
request.color = color;
|
|
380857
|
-
if (terminalWidth !== void 0)
|
|
380858
|
-
request.terminalWidth = terminalWidth;
|
|
380859
|
-
sendRequest(refs, request, (error, response) => {
|
|
380860
|
-
if (error)
|
|
380861
|
-
return callback(new Error(error), null);
|
|
380862
|
-
callback(null, response.messages);
|
|
380863
|
-
});
|
|
380864
|
-
};
|
|
380865
|
-
let analyzeMetafile2 = ({ callName, refs, metafile, options: options8, callback }) => {
|
|
380866
|
-
if (options8 === void 0)
|
|
380867
|
-
options8 = {};
|
|
380868
|
-
let keys = {};
|
|
380869
|
-
let color = getFlag(options8, keys, "color", mustBeBoolean);
|
|
380870
|
-
let verbose = getFlag(options8, keys, "verbose", mustBeBoolean);
|
|
380871
|
-
checkForInvalidFlags(options8, keys, `in ${callName}() call`);
|
|
380872
|
-
let request = {
|
|
380873
|
-
command: "analyze-metafile",
|
|
380874
|
-
metafile
|
|
380875
|
-
};
|
|
380876
|
-
if (color !== void 0)
|
|
380877
|
-
request.color = color;
|
|
380878
|
-
if (verbose !== void 0)
|
|
380879
|
-
request.verbose = verbose;
|
|
380880
|
-
sendRequest(refs, request, (error, response) => {
|
|
380881
|
-
if (error)
|
|
380882
|
-
return callback(new Error(error), null);
|
|
380883
|
-
callback(null, response.result);
|
|
380884
|
-
});
|
|
380885
|
-
};
|
|
380886
|
-
return {
|
|
380887
|
-
readFromStdout,
|
|
380888
|
-
afterClose,
|
|
380889
|
-
service: {
|
|
380890
|
-
buildOrContext,
|
|
380891
|
-
transform: transform22,
|
|
380892
|
-
formatMessages: formatMessages2,
|
|
380893
|
-
analyzeMetafile: analyzeMetafile2
|
|
380894
|
-
}
|
|
380895
|
-
};
|
|
380896
|
-
}
|
|
380897
|
-
function buildOrContextImpl(callName, buildKey, sendRequest, sendResponse, refs, streamIn, requestCallbacks, options8, isTTY2, defaultWD2, callback) {
|
|
380898
|
-
const details = createObjectStash();
|
|
380899
|
-
const isContext = callName === "context";
|
|
380900
|
-
const handleError = (e3, pluginName) => {
|
|
380901
|
-
const flags = [];
|
|
380902
|
-
try {
|
|
380903
|
-
pushLogFlags(flags, options8, {}, isTTY2, buildLogLevelDefault);
|
|
380904
|
-
} catch {
|
|
380905
|
-
}
|
|
380906
|
-
const message = extractErrorMessageV8(e3, streamIn, details, void 0, pluginName);
|
|
380907
|
-
sendRequest(refs, { command: "error", flags, error: message }, () => {
|
|
380908
|
-
message.detail = details.load(message.detail);
|
|
380909
|
-
callback(failureErrorWithLog(isContext ? "Context failed" : "Build failed", [message], []), null);
|
|
380910
|
-
});
|
|
380911
|
-
};
|
|
380912
|
-
let plugins;
|
|
380913
|
-
if (typeof options8 === "object") {
|
|
380914
|
-
const value = options8.plugins;
|
|
380915
|
-
if (value !== void 0) {
|
|
380916
|
-
if (!Array.isArray(value))
|
|
380917
|
-
return handleError(new Error(`"plugins" must be an array`), "");
|
|
380918
|
-
plugins = value;
|
|
380919
|
-
}
|
|
380920
|
-
}
|
|
380921
|
-
if (plugins && plugins.length > 0) {
|
|
380922
|
-
if (streamIn.isSync)
|
|
380923
|
-
return handleError(new Error("Cannot use plugins in synchronous API calls"), "");
|
|
380924
|
-
handlePlugins(
|
|
380925
|
-
buildKey,
|
|
380926
|
-
sendRequest,
|
|
380927
|
-
sendResponse,
|
|
380928
|
-
refs,
|
|
380929
|
-
streamIn,
|
|
380930
|
-
requestCallbacks,
|
|
380931
|
-
options8,
|
|
380932
|
-
plugins,
|
|
380933
|
-
details
|
|
380934
|
-
).then(
|
|
380935
|
-
(result) => {
|
|
380936
|
-
if (!result.ok)
|
|
380937
|
-
return handleError(result.error, result.pluginName);
|
|
380938
|
-
try {
|
|
380939
|
-
buildOrContextContinue(result.requestPlugins, result.runOnEndCallbacks, result.scheduleOnDisposeCallbacks);
|
|
380940
|
-
} catch (e3) {
|
|
380941
|
-
handleError(e3, "");
|
|
380942
|
-
}
|
|
380943
|
-
},
|
|
380944
|
-
(e3) => handleError(e3, "")
|
|
380945
|
-
);
|
|
380946
|
-
return;
|
|
380947
|
-
}
|
|
380948
|
-
try {
|
|
380949
|
-
buildOrContextContinue(null, (result, done) => done([], []), () => {
|
|
380950
|
-
});
|
|
380951
|
-
} catch (e3) {
|
|
380952
|
-
handleError(e3, "");
|
|
380953
|
-
}
|
|
380954
|
-
function buildOrContextContinue(requestPlugins, runOnEndCallbacks, scheduleOnDisposeCallbacks) {
|
|
380955
|
-
const writeDefault = streamIn.hasFS;
|
|
380956
|
-
const {
|
|
380957
|
-
entries,
|
|
380958
|
-
flags,
|
|
380959
|
-
write,
|
|
380960
|
-
stdinContents,
|
|
380961
|
-
stdinResolveDir,
|
|
380962
|
-
absWorkingDir,
|
|
380963
|
-
nodePaths,
|
|
380964
|
-
mangleCache
|
|
380965
|
-
} = flagsForBuildOptions(callName, options8, isTTY2, buildLogLevelDefault, writeDefault);
|
|
380966
|
-
if (write && !streamIn.hasFS)
|
|
380967
|
-
throw new Error(`The "write" option is unavailable in this environment`);
|
|
380968
|
-
const request = {
|
|
380969
|
-
command: "build",
|
|
380970
|
-
key: buildKey,
|
|
380971
|
-
entries,
|
|
380972
|
-
flags,
|
|
380973
|
-
write,
|
|
380974
|
-
stdinContents,
|
|
380975
|
-
stdinResolveDir,
|
|
380976
|
-
absWorkingDir: absWorkingDir || defaultWD2,
|
|
380977
|
-
nodePaths,
|
|
380978
|
-
context: isContext
|
|
380979
|
-
};
|
|
380980
|
-
if (requestPlugins)
|
|
380981
|
-
request.plugins = requestPlugins;
|
|
380982
|
-
if (mangleCache)
|
|
380983
|
-
request.mangleCache = mangleCache;
|
|
380984
|
-
const buildResponseToResult = (response, callback2) => {
|
|
380985
|
-
const result = {
|
|
380986
|
-
errors: replaceDetailsInMessages(response.errors, details),
|
|
380987
|
-
warnings: replaceDetailsInMessages(response.warnings, details),
|
|
380988
|
-
outputFiles: void 0,
|
|
380989
|
-
metafile: void 0,
|
|
380990
|
-
mangleCache: void 0
|
|
380991
|
-
};
|
|
380992
|
-
const originalErrors = result.errors.slice();
|
|
380993
|
-
const originalWarnings = result.warnings.slice();
|
|
380994
|
-
if (response.outputFiles)
|
|
380995
|
-
result.outputFiles = response.outputFiles.map(convertOutputFiles);
|
|
380996
|
-
if (response.metafile)
|
|
380997
|
-
result.metafile = JSON.parse(response.metafile);
|
|
380998
|
-
if (response.mangleCache)
|
|
380999
|
-
result.mangleCache = response.mangleCache;
|
|
381000
|
-
if (response.writeToStdout !== void 0)
|
|
381001
|
-
console.log(decodeUTF8(response.writeToStdout).replace(/\n$/, ""));
|
|
381002
|
-
runOnEndCallbacks(result, (onEndErrors, onEndWarnings) => {
|
|
381003
|
-
if (originalErrors.length > 0 || onEndErrors.length > 0) {
|
|
381004
|
-
const error = failureErrorWithLog("Build failed", originalErrors.concat(onEndErrors), originalWarnings.concat(onEndWarnings));
|
|
381005
|
-
return callback2(error, null, onEndErrors, onEndWarnings);
|
|
381006
|
-
}
|
|
381007
|
-
callback2(null, result, onEndErrors, onEndWarnings);
|
|
381008
|
-
});
|
|
381009
|
-
};
|
|
381010
|
-
let latestResultPromise;
|
|
381011
|
-
let provideLatestResult;
|
|
381012
|
-
if (isContext)
|
|
381013
|
-
requestCallbacks["on-end"] = (id, request2) => new Promise((resolve3) => {
|
|
381014
|
-
buildResponseToResult(request2, (err, result, onEndErrors, onEndWarnings) => {
|
|
381015
|
-
const response = {
|
|
381016
|
-
errors: onEndErrors,
|
|
381017
|
-
warnings: onEndWarnings
|
|
381018
|
-
};
|
|
381019
|
-
if (provideLatestResult)
|
|
381020
|
-
provideLatestResult(err, result);
|
|
381021
|
-
latestResultPromise = void 0;
|
|
381022
|
-
provideLatestResult = void 0;
|
|
381023
|
-
sendResponse(id, response);
|
|
381024
|
-
resolve3();
|
|
381025
|
-
});
|
|
381026
|
-
});
|
|
381027
|
-
sendRequest(refs, request, (error, response) => {
|
|
381028
|
-
if (error)
|
|
381029
|
-
return callback(new Error(error), null);
|
|
381030
|
-
if (!isContext) {
|
|
381031
|
-
return buildResponseToResult(response, (err, res) => {
|
|
381032
|
-
scheduleOnDisposeCallbacks();
|
|
381033
|
-
return callback(err, res);
|
|
381034
|
-
});
|
|
381035
|
-
}
|
|
381036
|
-
if (response.errors.length > 0) {
|
|
381037
|
-
return callback(failureErrorWithLog("Context failed", response.errors, response.warnings), null);
|
|
381038
|
-
}
|
|
381039
|
-
let didDispose = false;
|
|
381040
|
-
const result = {
|
|
381041
|
-
rebuild: () => {
|
|
381042
|
-
if (!latestResultPromise)
|
|
381043
|
-
latestResultPromise = new Promise((resolve3, reject) => {
|
|
381044
|
-
let settlePromise;
|
|
381045
|
-
provideLatestResult = (err, result2) => {
|
|
381046
|
-
if (!settlePromise)
|
|
381047
|
-
settlePromise = () => err ? reject(err) : resolve3(result2);
|
|
381048
|
-
};
|
|
381049
|
-
const triggerAnotherBuild = () => {
|
|
381050
|
-
const request2 = {
|
|
381051
|
-
command: "rebuild",
|
|
381052
|
-
key: buildKey
|
|
381053
|
-
};
|
|
381054
|
-
sendRequest(refs, request2, (error2, response2) => {
|
|
381055
|
-
if (error2) {
|
|
381056
|
-
reject(new Error(error2));
|
|
381057
|
-
} else if (settlePromise) {
|
|
381058
|
-
settlePromise();
|
|
381059
|
-
} else {
|
|
381060
|
-
triggerAnotherBuild();
|
|
381061
|
-
}
|
|
381062
|
-
});
|
|
381063
|
-
};
|
|
381064
|
-
triggerAnotherBuild();
|
|
381065
|
-
});
|
|
381066
|
-
return latestResultPromise;
|
|
381067
|
-
},
|
|
381068
|
-
watch: (options22 = {}) => new Promise((resolve3, reject) => {
|
|
381069
|
-
if (!streamIn.hasFS)
|
|
381070
|
-
throw new Error(`Cannot use the "watch" API in this environment`);
|
|
381071
|
-
const keys = {};
|
|
381072
|
-
checkForInvalidFlags(options22, keys, `in watch() call`);
|
|
381073
|
-
const request2 = {
|
|
381074
|
-
command: "watch",
|
|
381075
|
-
key: buildKey
|
|
381076
|
-
};
|
|
381077
|
-
sendRequest(refs, request2, (error2) => {
|
|
381078
|
-
if (error2)
|
|
381079
|
-
reject(new Error(error2));
|
|
381080
|
-
else
|
|
381081
|
-
resolve3(void 0);
|
|
381082
|
-
});
|
|
381083
|
-
}),
|
|
381084
|
-
serve: (options22 = {}) => new Promise((resolve3, reject) => {
|
|
381085
|
-
if (!streamIn.hasFS)
|
|
381086
|
-
throw new Error(`Cannot use the "serve" API in this environment`);
|
|
381087
|
-
const keys = {};
|
|
381088
|
-
const port = getFlag(options22, keys, "port", mustBeInteger);
|
|
381089
|
-
const host = getFlag(options22, keys, "host", mustBeString);
|
|
381090
|
-
const servedir = getFlag(options22, keys, "servedir", mustBeString);
|
|
381091
|
-
const keyfile = getFlag(options22, keys, "keyfile", mustBeString);
|
|
381092
|
-
const certfile = getFlag(options22, keys, "certfile", mustBeString);
|
|
381093
|
-
const fallback = getFlag(options22, keys, "fallback", mustBeString);
|
|
381094
|
-
const onRequest = getFlag(options22, keys, "onRequest", mustBeFunction);
|
|
381095
|
-
checkForInvalidFlags(options22, keys, `in serve() call`);
|
|
381096
|
-
const request2 = {
|
|
381097
|
-
command: "serve",
|
|
381098
|
-
key: buildKey,
|
|
381099
|
-
onRequest: !!onRequest
|
|
381100
|
-
};
|
|
381101
|
-
if (port !== void 0)
|
|
381102
|
-
request2.port = port;
|
|
381103
|
-
if (host !== void 0)
|
|
381104
|
-
request2.host = host;
|
|
381105
|
-
if (servedir !== void 0)
|
|
381106
|
-
request2.servedir = servedir;
|
|
381107
|
-
if (keyfile !== void 0)
|
|
381108
|
-
request2.keyfile = keyfile;
|
|
381109
|
-
if (certfile !== void 0)
|
|
381110
|
-
request2.certfile = certfile;
|
|
381111
|
-
if (fallback !== void 0)
|
|
381112
|
-
request2.fallback = fallback;
|
|
381113
|
-
sendRequest(refs, request2, (error2, response2) => {
|
|
381114
|
-
if (error2)
|
|
381115
|
-
return reject(new Error(error2));
|
|
381116
|
-
if (onRequest) {
|
|
381117
|
-
requestCallbacks["serve-request"] = (id, request3) => {
|
|
381118
|
-
onRequest(request3.args);
|
|
381119
|
-
sendResponse(id, {});
|
|
381120
|
-
};
|
|
381121
|
-
}
|
|
381122
|
-
resolve3(response2);
|
|
381123
|
-
});
|
|
381124
|
-
}),
|
|
381125
|
-
cancel: () => new Promise((resolve3) => {
|
|
381126
|
-
if (didDispose)
|
|
381127
|
-
return resolve3();
|
|
381128
|
-
const request2 = {
|
|
381129
|
-
command: "cancel",
|
|
381130
|
-
key: buildKey
|
|
381131
|
-
};
|
|
381132
|
-
sendRequest(refs, request2, () => {
|
|
381133
|
-
resolve3();
|
|
381134
|
-
});
|
|
381135
|
-
}),
|
|
381136
|
-
dispose: () => new Promise((resolve3) => {
|
|
381137
|
-
if (didDispose)
|
|
381138
|
-
return resolve3();
|
|
381139
|
-
didDispose = true;
|
|
381140
|
-
const request2 = {
|
|
381141
|
-
command: "dispose",
|
|
381142
|
-
key: buildKey
|
|
381143
|
-
};
|
|
381144
|
-
sendRequest(refs, request2, () => {
|
|
381145
|
-
resolve3();
|
|
381146
|
-
scheduleOnDisposeCallbacks();
|
|
381147
|
-
refs.unref();
|
|
381148
|
-
});
|
|
381149
|
-
})
|
|
381150
|
-
};
|
|
381151
|
-
refs.ref();
|
|
381152
|
-
callback(null, result);
|
|
381153
|
-
});
|
|
381154
|
-
}
|
|
381155
|
-
}
|
|
381156
|
-
var handlePlugins = async (buildKey, sendRequest, sendResponse, refs, streamIn, requestCallbacks, initialOptions, plugins, details) => {
|
|
381157
|
-
let onStartCallbacks = [];
|
|
381158
|
-
let onEndCallbacks = [];
|
|
381159
|
-
let onResolveCallbacks = {};
|
|
381160
|
-
let onLoadCallbacks = {};
|
|
381161
|
-
let onDisposeCallbacks = [];
|
|
381162
|
-
let nextCallbackID = 0;
|
|
381163
|
-
let i3 = 0;
|
|
381164
|
-
let requestPlugins = [];
|
|
381165
|
-
let isSetupDone = false;
|
|
381166
|
-
plugins = [...plugins];
|
|
381167
|
-
for (let item of plugins) {
|
|
381168
|
-
let keys = {};
|
|
381169
|
-
if (typeof item !== "object")
|
|
381170
|
-
throw new Error(`Plugin at index ${i3} must be an object`);
|
|
381171
|
-
const name = getFlag(item, keys, "name", mustBeString);
|
|
381172
|
-
if (typeof name !== "string" || name === "")
|
|
381173
|
-
throw new Error(`Plugin at index ${i3} is missing a name`);
|
|
381174
|
-
try {
|
|
381175
|
-
let setup = getFlag(item, keys, "setup", mustBeFunction);
|
|
381176
|
-
if (typeof setup !== "function")
|
|
381177
|
-
throw new Error(`Plugin is missing a setup function`);
|
|
381178
|
-
checkForInvalidFlags(item, keys, `on plugin ${quote2(name)}`);
|
|
381179
|
-
let plugin = {
|
|
381180
|
-
name,
|
|
381181
|
-
onStart: false,
|
|
381182
|
-
onEnd: false,
|
|
381183
|
-
onResolve: [],
|
|
381184
|
-
onLoad: []
|
|
381185
|
-
};
|
|
381186
|
-
i3++;
|
|
381187
|
-
let resolve3 = (path32, options8 = {}) => {
|
|
381188
|
-
if (!isSetupDone)
|
|
381189
|
-
throw new Error('Cannot call "resolve" before plugin setup has completed');
|
|
381190
|
-
if (typeof path32 !== "string")
|
|
381191
|
-
throw new Error(`The path to resolve must be a string`);
|
|
381192
|
-
let keys2 = /* @__PURE__ */ Object.create(null);
|
|
381193
|
-
let pluginName = getFlag(options8, keys2, "pluginName", mustBeString);
|
|
381194
|
-
let importer = getFlag(options8, keys2, "importer", mustBeString);
|
|
381195
|
-
let namespace = getFlag(options8, keys2, "namespace", mustBeString);
|
|
381196
|
-
let resolveDir = getFlag(options8, keys2, "resolveDir", mustBeString);
|
|
381197
|
-
let kind = getFlag(options8, keys2, "kind", mustBeString);
|
|
381198
|
-
let pluginData = getFlag(options8, keys2, "pluginData", canBeAnything);
|
|
381199
|
-
checkForInvalidFlags(options8, keys2, "in resolve() call");
|
|
381200
|
-
return new Promise((resolve22, reject) => {
|
|
381201
|
-
const request = {
|
|
381202
|
-
command: "resolve",
|
|
381203
|
-
path: path32,
|
|
381204
|
-
key: buildKey,
|
|
381205
|
-
pluginName: name
|
|
381206
|
-
};
|
|
381207
|
-
if (pluginName != null)
|
|
381208
|
-
request.pluginName = pluginName;
|
|
381209
|
-
if (importer != null)
|
|
381210
|
-
request.importer = importer;
|
|
381211
|
-
if (namespace != null)
|
|
381212
|
-
request.namespace = namespace;
|
|
381213
|
-
if (resolveDir != null)
|
|
381214
|
-
request.resolveDir = resolveDir;
|
|
381215
|
-
if (kind != null)
|
|
381216
|
-
request.kind = kind;
|
|
381217
|
-
else
|
|
381218
|
-
throw new Error(`Must specify "kind" when calling "resolve"`);
|
|
381219
|
-
if (pluginData != null)
|
|
381220
|
-
request.pluginData = details.store(pluginData);
|
|
381221
|
-
sendRequest(refs, request, (error, response) => {
|
|
381222
|
-
if (error !== null)
|
|
381223
|
-
reject(new Error(error));
|
|
381224
|
-
else
|
|
381225
|
-
resolve22({
|
|
381226
|
-
errors: replaceDetailsInMessages(response.errors, details),
|
|
381227
|
-
warnings: replaceDetailsInMessages(response.warnings, details),
|
|
381228
|
-
path: response.path,
|
|
381229
|
-
external: response.external,
|
|
381230
|
-
sideEffects: response.sideEffects,
|
|
381231
|
-
namespace: response.namespace,
|
|
381232
|
-
suffix: response.suffix,
|
|
381233
|
-
pluginData: details.load(response.pluginData)
|
|
381234
|
-
});
|
|
381235
|
-
});
|
|
381236
|
-
});
|
|
381237
|
-
};
|
|
381238
|
-
let promise = setup({
|
|
381239
|
-
initialOptions,
|
|
381240
|
-
resolve: resolve3,
|
|
381241
|
-
onStart(callback) {
|
|
381242
|
-
let registeredText = `This error came from the "onStart" callback registered here:`;
|
|
381243
|
-
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onStart");
|
|
381244
|
-
onStartCallbacks.push({ name, callback, note: registeredNote });
|
|
381245
|
-
plugin.onStart = true;
|
|
381246
|
-
},
|
|
381247
|
-
onEnd(callback) {
|
|
381248
|
-
let registeredText = `This error came from the "onEnd" callback registered here:`;
|
|
381249
|
-
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onEnd");
|
|
381250
|
-
onEndCallbacks.push({ name, callback, note: registeredNote });
|
|
381251
|
-
plugin.onEnd = true;
|
|
381252
|
-
},
|
|
381253
|
-
onResolve(options8, callback) {
|
|
381254
|
-
let registeredText = `This error came from the "onResolve" callback registered here:`;
|
|
381255
|
-
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onResolve");
|
|
381256
|
-
let keys2 = {};
|
|
381257
|
-
let filter3 = getFlag(options8, keys2, "filter", mustBeRegExp);
|
|
381258
|
-
let namespace = getFlag(options8, keys2, "namespace", mustBeString);
|
|
381259
|
-
checkForInvalidFlags(options8, keys2, `in onResolve() call for plugin ${quote2(name)}`);
|
|
381260
|
-
if (filter3 == null)
|
|
381261
|
-
throw new Error(`onResolve() call is missing a filter`);
|
|
381262
|
-
let id = nextCallbackID++;
|
|
381263
|
-
onResolveCallbacks[id] = { name, callback, note: registeredNote };
|
|
381264
|
-
plugin.onResolve.push({ id, filter: filter3.source, namespace: namespace || "" });
|
|
381265
|
-
},
|
|
381266
|
-
onLoad(options8, callback) {
|
|
381267
|
-
let registeredText = `This error came from the "onLoad" callback registered here:`;
|
|
381268
|
-
let registeredNote = extractCallerV8(new Error(registeredText), streamIn, "onLoad");
|
|
381269
|
-
let keys2 = {};
|
|
381270
|
-
let filter3 = getFlag(options8, keys2, "filter", mustBeRegExp);
|
|
381271
|
-
let namespace = getFlag(options8, keys2, "namespace", mustBeString);
|
|
381272
|
-
checkForInvalidFlags(options8, keys2, `in onLoad() call for plugin ${quote2(name)}`);
|
|
381273
|
-
if (filter3 == null)
|
|
381274
|
-
throw new Error(`onLoad() call is missing a filter`);
|
|
381275
|
-
let id = nextCallbackID++;
|
|
381276
|
-
onLoadCallbacks[id] = { name, callback, note: registeredNote };
|
|
381277
|
-
plugin.onLoad.push({ id, filter: filter3.source, namespace: namespace || "" });
|
|
381278
|
-
},
|
|
381279
|
-
onDispose(callback) {
|
|
381280
|
-
onDisposeCallbacks.push(callback);
|
|
381281
|
-
},
|
|
381282
|
-
esbuild: streamIn.esbuild
|
|
381283
|
-
});
|
|
381284
|
-
if (promise)
|
|
381285
|
-
await promise;
|
|
381286
|
-
requestPlugins.push(plugin);
|
|
381287
|
-
} catch (e3) {
|
|
381288
|
-
return { ok: false, error: e3, pluginName: name };
|
|
381289
|
-
}
|
|
381290
|
-
}
|
|
381291
|
-
requestCallbacks["on-start"] = async (id, request) => {
|
|
381292
|
-
let response = { errors: [], warnings: [] };
|
|
381293
|
-
await Promise.all(onStartCallbacks.map(async ({ name, callback, note }) => {
|
|
381294
|
-
try {
|
|
381295
|
-
let result = await callback();
|
|
381296
|
-
if (result != null) {
|
|
381297
|
-
if (typeof result !== "object")
|
|
381298
|
-
throw new Error(`Expected onStart() callback in plugin ${quote2(name)} to return an object`);
|
|
381299
|
-
let keys = {};
|
|
381300
|
-
let errors = getFlag(result, keys, "errors", mustBeArray);
|
|
381301
|
-
let warnings = getFlag(result, keys, "warnings", mustBeArray);
|
|
381302
|
-
checkForInvalidFlags(result, keys, `from onStart() callback in plugin ${quote2(name)}`);
|
|
381303
|
-
if (errors != null)
|
|
381304
|
-
response.errors.push(...sanitizeMessages(errors, "errors", details, name, void 0));
|
|
381305
|
-
if (warnings != null)
|
|
381306
|
-
response.warnings.push(...sanitizeMessages(warnings, "warnings", details, name, void 0));
|
|
381307
|
-
}
|
|
381308
|
-
} catch (e3) {
|
|
381309
|
-
response.errors.push(extractErrorMessageV8(e3, streamIn, details, note && note(), name));
|
|
381310
|
-
}
|
|
381311
|
-
}));
|
|
381312
|
-
sendResponse(id, response);
|
|
381313
|
-
};
|
|
381314
|
-
requestCallbacks["on-resolve"] = async (id, request) => {
|
|
381315
|
-
let response = {}, name = "", callback, note;
|
|
381316
|
-
for (let id2 of request.ids) {
|
|
381317
|
-
try {
|
|
381318
|
-
({ name, callback, note } = onResolveCallbacks[id2]);
|
|
381319
|
-
let result = await callback({
|
|
381320
|
-
path: request.path,
|
|
381321
|
-
importer: request.importer,
|
|
381322
|
-
namespace: request.namespace,
|
|
381323
|
-
resolveDir: request.resolveDir,
|
|
381324
|
-
kind: request.kind,
|
|
381325
|
-
pluginData: details.load(request.pluginData)
|
|
381326
|
-
});
|
|
381327
|
-
if (result != null) {
|
|
381328
|
-
if (typeof result !== "object")
|
|
381329
|
-
throw new Error(`Expected onResolve() callback in plugin ${quote2(name)} to return an object`);
|
|
381330
|
-
let keys = {};
|
|
381331
|
-
let pluginName = getFlag(result, keys, "pluginName", mustBeString);
|
|
381332
|
-
let path32 = getFlag(result, keys, "path", mustBeString);
|
|
381333
|
-
let namespace = getFlag(result, keys, "namespace", mustBeString);
|
|
381334
|
-
let suffix = getFlag(result, keys, "suffix", mustBeString);
|
|
381335
|
-
let external = getFlag(result, keys, "external", mustBeBoolean);
|
|
381336
|
-
let sideEffects = getFlag(result, keys, "sideEffects", mustBeBoolean);
|
|
381337
|
-
let pluginData = getFlag(result, keys, "pluginData", canBeAnything);
|
|
381338
|
-
let errors = getFlag(result, keys, "errors", mustBeArray);
|
|
381339
|
-
let warnings = getFlag(result, keys, "warnings", mustBeArray);
|
|
381340
|
-
let watchFiles = getFlag(result, keys, "watchFiles", mustBeArray);
|
|
381341
|
-
let watchDirs = getFlag(result, keys, "watchDirs", mustBeArray);
|
|
381342
|
-
checkForInvalidFlags(result, keys, `from onResolve() callback in plugin ${quote2(name)}`);
|
|
381343
|
-
response.id = id2;
|
|
381344
|
-
if (pluginName != null)
|
|
381345
|
-
response.pluginName = pluginName;
|
|
381346
|
-
if (path32 != null)
|
|
381347
|
-
response.path = path32;
|
|
381348
|
-
if (namespace != null)
|
|
381349
|
-
response.namespace = namespace;
|
|
381350
|
-
if (suffix != null)
|
|
381351
|
-
response.suffix = suffix;
|
|
381352
|
-
if (external != null)
|
|
381353
|
-
response.external = external;
|
|
381354
|
-
if (sideEffects != null)
|
|
381355
|
-
response.sideEffects = sideEffects;
|
|
381356
|
-
if (pluginData != null)
|
|
381357
|
-
response.pluginData = details.store(pluginData);
|
|
381358
|
-
if (errors != null)
|
|
381359
|
-
response.errors = sanitizeMessages(errors, "errors", details, name, void 0);
|
|
381360
|
-
if (warnings != null)
|
|
381361
|
-
response.warnings = sanitizeMessages(warnings, "warnings", details, name, void 0);
|
|
381362
|
-
if (watchFiles != null)
|
|
381363
|
-
response.watchFiles = sanitizeStringArray(watchFiles, "watchFiles");
|
|
381364
|
-
if (watchDirs != null)
|
|
381365
|
-
response.watchDirs = sanitizeStringArray(watchDirs, "watchDirs");
|
|
381366
|
-
break;
|
|
381367
|
-
}
|
|
381368
|
-
} catch (e3) {
|
|
381369
|
-
response = { id: id2, errors: [extractErrorMessageV8(e3, streamIn, details, note && note(), name)] };
|
|
381370
|
-
break;
|
|
381371
|
-
}
|
|
381372
|
-
}
|
|
381373
|
-
sendResponse(id, response);
|
|
381374
|
-
};
|
|
381375
|
-
requestCallbacks["on-load"] = async (id, request) => {
|
|
381376
|
-
let response = {}, name = "", callback, note;
|
|
381377
|
-
for (let id2 of request.ids) {
|
|
381378
|
-
try {
|
|
381379
|
-
({ name, callback, note } = onLoadCallbacks[id2]);
|
|
381380
|
-
let result = await callback({
|
|
381381
|
-
path: request.path,
|
|
381382
|
-
namespace: request.namespace,
|
|
381383
|
-
suffix: request.suffix,
|
|
381384
|
-
pluginData: details.load(request.pluginData),
|
|
381385
|
-
with: request.with
|
|
381386
|
-
});
|
|
381387
|
-
if (result != null) {
|
|
381388
|
-
if (typeof result !== "object")
|
|
381389
|
-
throw new Error(`Expected onLoad() callback in plugin ${quote2(name)} to return an object`);
|
|
381390
|
-
let keys = {};
|
|
381391
|
-
let pluginName = getFlag(result, keys, "pluginName", mustBeString);
|
|
381392
|
-
let contents = getFlag(result, keys, "contents", mustBeStringOrUint8Array);
|
|
381393
|
-
let resolveDir = getFlag(result, keys, "resolveDir", mustBeString);
|
|
381394
|
-
let pluginData = getFlag(result, keys, "pluginData", canBeAnything);
|
|
381395
|
-
let loader2 = getFlag(result, keys, "loader", mustBeString);
|
|
381396
|
-
let errors = getFlag(result, keys, "errors", mustBeArray);
|
|
381397
|
-
let warnings = getFlag(result, keys, "warnings", mustBeArray);
|
|
381398
|
-
let watchFiles = getFlag(result, keys, "watchFiles", mustBeArray);
|
|
381399
|
-
let watchDirs = getFlag(result, keys, "watchDirs", mustBeArray);
|
|
381400
|
-
checkForInvalidFlags(result, keys, `from onLoad() callback in plugin ${quote2(name)}`);
|
|
381401
|
-
response.id = id2;
|
|
381402
|
-
if (pluginName != null)
|
|
381403
|
-
response.pluginName = pluginName;
|
|
381404
|
-
if (contents instanceof Uint8Array)
|
|
381405
|
-
response.contents = contents;
|
|
381406
|
-
else if (contents != null)
|
|
381407
|
-
response.contents = encodeUTF8(contents);
|
|
381408
|
-
if (resolveDir != null)
|
|
381409
|
-
response.resolveDir = resolveDir;
|
|
381410
|
-
if (pluginData != null)
|
|
381411
|
-
response.pluginData = details.store(pluginData);
|
|
381412
|
-
if (loader2 != null)
|
|
381413
|
-
response.loader = loader2;
|
|
381414
|
-
if (errors != null)
|
|
381415
|
-
response.errors = sanitizeMessages(errors, "errors", details, name, void 0);
|
|
381416
|
-
if (warnings != null)
|
|
381417
|
-
response.warnings = sanitizeMessages(warnings, "warnings", details, name, void 0);
|
|
381418
|
-
if (watchFiles != null)
|
|
381419
|
-
response.watchFiles = sanitizeStringArray(watchFiles, "watchFiles");
|
|
381420
|
-
if (watchDirs != null)
|
|
381421
|
-
response.watchDirs = sanitizeStringArray(watchDirs, "watchDirs");
|
|
381422
|
-
break;
|
|
381423
|
-
}
|
|
381424
|
-
} catch (e3) {
|
|
381425
|
-
response = { id: id2, errors: [extractErrorMessageV8(e3, streamIn, details, note && note(), name)] };
|
|
381426
|
-
break;
|
|
381427
|
-
}
|
|
381428
|
-
}
|
|
381429
|
-
sendResponse(id, response);
|
|
381430
|
-
};
|
|
381431
|
-
let runOnEndCallbacks = (result, done) => done([], []);
|
|
381432
|
-
if (onEndCallbacks.length > 0) {
|
|
381433
|
-
runOnEndCallbacks = (result, done) => {
|
|
381434
|
-
(async () => {
|
|
381435
|
-
const onEndErrors = [];
|
|
381436
|
-
const onEndWarnings = [];
|
|
381437
|
-
for (const { name, callback, note } of onEndCallbacks) {
|
|
381438
|
-
let newErrors;
|
|
381439
|
-
let newWarnings;
|
|
381440
|
-
try {
|
|
381441
|
-
const value = await callback(result);
|
|
381442
|
-
if (value != null) {
|
|
381443
|
-
if (typeof value !== "object")
|
|
381444
|
-
throw new Error(`Expected onEnd() callback in plugin ${quote2(name)} to return an object`);
|
|
381445
|
-
let keys = {};
|
|
381446
|
-
let errors = getFlag(value, keys, "errors", mustBeArray);
|
|
381447
|
-
let warnings = getFlag(value, keys, "warnings", mustBeArray);
|
|
381448
|
-
checkForInvalidFlags(value, keys, `from onEnd() callback in plugin ${quote2(name)}`);
|
|
381449
|
-
if (errors != null)
|
|
381450
|
-
newErrors = sanitizeMessages(errors, "errors", details, name, void 0);
|
|
381451
|
-
if (warnings != null)
|
|
381452
|
-
newWarnings = sanitizeMessages(warnings, "warnings", details, name, void 0);
|
|
381453
|
-
}
|
|
381454
|
-
} catch (e3) {
|
|
381455
|
-
newErrors = [extractErrorMessageV8(e3, streamIn, details, note && note(), name)];
|
|
381456
|
-
}
|
|
381457
|
-
if (newErrors) {
|
|
381458
|
-
onEndErrors.push(...newErrors);
|
|
381459
|
-
try {
|
|
381460
|
-
result.errors.push(...newErrors);
|
|
381461
|
-
} catch {
|
|
381462
|
-
}
|
|
381463
|
-
}
|
|
381464
|
-
if (newWarnings) {
|
|
381465
|
-
onEndWarnings.push(...newWarnings);
|
|
381466
|
-
try {
|
|
381467
|
-
result.warnings.push(...newWarnings);
|
|
381468
|
-
} catch {
|
|
381469
|
-
}
|
|
381470
|
-
}
|
|
381471
|
-
}
|
|
381472
|
-
done(onEndErrors, onEndWarnings);
|
|
381473
|
-
})();
|
|
381474
|
-
};
|
|
381475
|
-
}
|
|
381476
|
-
let scheduleOnDisposeCallbacks = () => {
|
|
381477
|
-
for (const cb of onDisposeCallbacks) {
|
|
381478
|
-
setTimeout(() => cb(), 0);
|
|
381479
|
-
}
|
|
381480
|
-
};
|
|
381481
|
-
isSetupDone = true;
|
|
381482
|
-
return {
|
|
381483
|
-
ok: true,
|
|
381484
|
-
requestPlugins,
|
|
381485
|
-
runOnEndCallbacks,
|
|
381486
|
-
scheduleOnDisposeCallbacks
|
|
381487
|
-
};
|
|
381488
|
-
};
|
|
381489
|
-
function createObjectStash() {
|
|
381490
|
-
const map2 = /* @__PURE__ */ new Map();
|
|
381491
|
-
let nextID = 0;
|
|
381492
|
-
return {
|
|
381493
|
-
load(id) {
|
|
381494
|
-
return map2.get(id);
|
|
381495
|
-
},
|
|
381496
|
-
store(value) {
|
|
381497
|
-
if (value === void 0)
|
|
381498
|
-
return -1;
|
|
381499
|
-
const id = nextID++;
|
|
381500
|
-
map2.set(id, value);
|
|
381501
|
-
return id;
|
|
381502
|
-
}
|
|
381503
|
-
};
|
|
381504
|
-
}
|
|
381505
|
-
function extractCallerV8(e3, streamIn, ident) {
|
|
381506
|
-
let note;
|
|
381507
|
-
let tried = false;
|
|
381508
|
-
return () => {
|
|
381509
|
-
if (tried)
|
|
381510
|
-
return note;
|
|
381511
|
-
tried = true;
|
|
381512
|
-
try {
|
|
381513
|
-
let lines = (e3.stack + "").split("\n");
|
|
381514
|
-
lines.splice(1, 1);
|
|
381515
|
-
let location = parseStackLinesV8(streamIn, lines, ident);
|
|
381516
|
-
if (location) {
|
|
381517
|
-
note = { text: e3.message, location };
|
|
381518
|
-
return note;
|
|
381519
|
-
}
|
|
381520
|
-
} catch {
|
|
381521
|
-
}
|
|
381522
|
-
};
|
|
381523
|
-
}
|
|
381524
|
-
function extractErrorMessageV8(e3, streamIn, stash, note, pluginName) {
|
|
381525
|
-
let text = "Internal error";
|
|
381526
|
-
let location = null;
|
|
381527
|
-
try {
|
|
381528
|
-
text = (e3 && e3.message || e3) + "";
|
|
381529
|
-
} catch {
|
|
381530
|
-
}
|
|
381531
|
-
try {
|
|
381532
|
-
location = parseStackLinesV8(streamIn, (e3.stack + "").split("\n"), "");
|
|
381533
|
-
} catch {
|
|
381534
|
-
}
|
|
381535
|
-
return { id: "", pluginName, text, location, notes: note ? [note] : [], detail: stash ? stash.store(e3) : -1 };
|
|
381536
|
-
}
|
|
381537
|
-
function parseStackLinesV8(streamIn, lines, ident) {
|
|
381538
|
-
let at8 = " at ";
|
|
381539
|
-
if (streamIn.readFileSync && !lines[0].startsWith(at8) && lines[1].startsWith(at8)) {
|
|
381540
|
-
for (let i3 = 1; i3 < lines.length; i3++) {
|
|
381541
|
-
let line3 = lines[i3];
|
|
381542
|
-
if (!line3.startsWith(at8))
|
|
381543
|
-
continue;
|
|
381544
|
-
line3 = line3.slice(at8.length);
|
|
381545
|
-
while (true) {
|
|
381546
|
-
let match2 = /^(?:new |async )?\S+ \((.*)\)$/.exec(line3);
|
|
381547
|
-
if (match2) {
|
|
381548
|
-
line3 = match2[1];
|
|
381549
|
-
continue;
|
|
381550
|
-
}
|
|
381551
|
-
match2 = /^eval at \S+ \((.*)\)(?:, \S+:\d+:\d+)?$/.exec(line3);
|
|
381552
|
-
if (match2) {
|
|
381553
|
-
line3 = match2[1];
|
|
381554
|
-
continue;
|
|
381555
|
-
}
|
|
381556
|
-
match2 = /^(\S+):(\d+):(\d+)$/.exec(line3);
|
|
381557
|
-
if (match2) {
|
|
381558
|
-
let contents;
|
|
381559
|
-
try {
|
|
381560
|
-
contents = streamIn.readFileSync(match2[1], "utf8");
|
|
381561
|
-
} catch {
|
|
381562
|
-
break;
|
|
381563
|
-
}
|
|
381564
|
-
let lineText = contents.split(/\r\n|\r|\n|\u2028|\u2029/)[+match2[2] - 1] || "";
|
|
381565
|
-
let column2 = +match2[3] - 1;
|
|
381566
|
-
let length = lineText.slice(column2, column2 + ident.length) === ident ? ident.length : 0;
|
|
381567
|
-
return {
|
|
381568
|
-
file: match2[1],
|
|
381569
|
-
namespace: "file",
|
|
381570
|
-
line: +match2[2],
|
|
381571
|
-
column: encodeUTF8(lineText.slice(0, column2)).length,
|
|
381572
|
-
length: encodeUTF8(lineText.slice(column2, column2 + length)).length,
|
|
381573
|
-
lineText: lineText + "\n" + lines.slice(1).join("\n"),
|
|
381574
|
-
suggestion: ""
|
|
381575
|
-
};
|
|
381576
|
-
}
|
|
381577
|
-
break;
|
|
381578
|
-
}
|
|
381579
|
-
}
|
|
381580
|
-
}
|
|
381581
|
-
return null;
|
|
381582
|
-
}
|
|
381583
|
-
function failureErrorWithLog(text, errors, warnings) {
|
|
381584
|
-
let limit = 5;
|
|
381585
|
-
text += errors.length < 1 ? "" : ` with ${errors.length} error${errors.length < 2 ? "" : "s"}:` + errors.slice(0, limit + 1).map((e3, i3) => {
|
|
381586
|
-
if (i3 === limit)
|
|
381587
|
-
return "\n...";
|
|
381588
|
-
if (!e3.location)
|
|
381589
|
-
return `
|
|
381590
|
-
error: ${e3.text}`;
|
|
381591
|
-
let { file, line: line3, column: column2 } = e3.location;
|
|
381592
|
-
let pluginText = e3.pluginName ? `[plugin: ${e3.pluginName}] ` : "";
|
|
381593
|
-
return `
|
|
381594
|
-
${file}:${line3}:${column2}: ERROR: ${pluginText}${e3.text}`;
|
|
381595
|
-
}).join("");
|
|
381596
|
-
let error = new Error(text);
|
|
381597
|
-
for (const [key2, value] of [["errors", errors], ["warnings", warnings]]) {
|
|
381598
|
-
Object.defineProperty(error, key2, {
|
|
381599
|
-
configurable: true,
|
|
381600
|
-
enumerable: true,
|
|
381601
|
-
get: () => value,
|
|
381602
|
-
set: (value2) => Object.defineProperty(error, key2, {
|
|
381603
|
-
configurable: true,
|
|
381604
|
-
enumerable: true,
|
|
381605
|
-
value: value2
|
|
381606
|
-
})
|
|
381607
|
-
});
|
|
381608
|
-
}
|
|
381609
|
-
return error;
|
|
381610
|
-
}
|
|
381611
|
-
function replaceDetailsInMessages(messages2, stash) {
|
|
381612
|
-
for (const message of messages2) {
|
|
381613
|
-
message.detail = stash.load(message.detail);
|
|
381614
|
-
}
|
|
381615
|
-
return messages2;
|
|
381616
|
-
}
|
|
381617
|
-
function sanitizeLocation(location, where, terminalWidth) {
|
|
381618
|
-
if (location == null)
|
|
381619
|
-
return null;
|
|
381620
|
-
let keys = {};
|
|
381621
|
-
let file = getFlag(location, keys, "file", mustBeString);
|
|
381622
|
-
let namespace = getFlag(location, keys, "namespace", mustBeString);
|
|
381623
|
-
let line3 = getFlag(location, keys, "line", mustBeInteger);
|
|
381624
|
-
let column2 = getFlag(location, keys, "column", mustBeInteger);
|
|
381625
|
-
let length = getFlag(location, keys, "length", mustBeInteger);
|
|
381626
|
-
let lineText = getFlag(location, keys, "lineText", mustBeString);
|
|
381627
|
-
let suggestion = getFlag(location, keys, "suggestion", mustBeString);
|
|
381628
|
-
checkForInvalidFlags(location, keys, where);
|
|
381629
|
-
if (lineText) {
|
|
381630
|
-
const relevantASCII = lineText.slice(
|
|
381631
|
-
0,
|
|
381632
|
-
(column2 && column2 > 0 ? column2 : 0) + (length && length > 0 ? length : 0) + (terminalWidth && terminalWidth > 0 ? terminalWidth : 80)
|
|
381633
|
-
);
|
|
381634
|
-
if (!/[\x7F-\uFFFF]/.test(relevantASCII) && !/\n/.test(lineText)) {
|
|
381635
|
-
lineText = relevantASCII;
|
|
381636
|
-
}
|
|
381637
|
-
}
|
|
381638
|
-
return {
|
|
381639
|
-
file: file || "",
|
|
381640
|
-
namespace: namespace || "",
|
|
381641
|
-
line: line3 || 0,
|
|
381642
|
-
column: column2 || 0,
|
|
381643
|
-
length: length || 0,
|
|
381644
|
-
lineText: lineText || "",
|
|
381645
|
-
suggestion: suggestion || ""
|
|
381646
|
-
};
|
|
381647
|
-
}
|
|
381648
|
-
function sanitizeMessages(messages2, property, stash, fallbackPluginName, terminalWidth) {
|
|
381649
|
-
let messagesClone = [];
|
|
381650
|
-
let index = 0;
|
|
381651
|
-
for (const message of messages2) {
|
|
381652
|
-
let keys = {};
|
|
381653
|
-
let id = getFlag(message, keys, "id", mustBeString);
|
|
381654
|
-
let pluginName = getFlag(message, keys, "pluginName", mustBeString);
|
|
381655
|
-
let text = getFlag(message, keys, "text", mustBeString);
|
|
381656
|
-
let location = getFlag(message, keys, "location", mustBeObjectOrNull);
|
|
381657
|
-
let notes = getFlag(message, keys, "notes", mustBeArray);
|
|
381658
|
-
let detail = getFlag(message, keys, "detail", canBeAnything);
|
|
381659
|
-
let where = `in element ${index} of "${property}"`;
|
|
381660
|
-
checkForInvalidFlags(message, keys, where);
|
|
381661
|
-
let notesClone = [];
|
|
381662
|
-
if (notes) {
|
|
381663
|
-
for (const note of notes) {
|
|
381664
|
-
let noteKeys = {};
|
|
381665
|
-
let noteText = getFlag(note, noteKeys, "text", mustBeString);
|
|
381666
|
-
let noteLocation = getFlag(note, noteKeys, "location", mustBeObjectOrNull);
|
|
381667
|
-
checkForInvalidFlags(note, noteKeys, where);
|
|
381668
|
-
notesClone.push({
|
|
381669
|
-
text: noteText || "",
|
|
381670
|
-
location: sanitizeLocation(noteLocation, where, terminalWidth)
|
|
381671
|
-
});
|
|
381672
|
-
}
|
|
381673
|
-
}
|
|
381674
|
-
messagesClone.push({
|
|
381675
|
-
id: id || "",
|
|
381676
|
-
pluginName: pluginName || fallbackPluginName,
|
|
381677
|
-
text: text || "",
|
|
381678
|
-
location: sanitizeLocation(location, where, terminalWidth),
|
|
381679
|
-
notes: notesClone,
|
|
381680
|
-
detail: stash ? stash.store(detail) : -1
|
|
381681
|
-
});
|
|
381682
|
-
index++;
|
|
381683
|
-
}
|
|
381684
|
-
return messagesClone;
|
|
381685
|
-
}
|
|
381686
|
-
function sanitizeStringArray(values, property) {
|
|
381687
|
-
const result = [];
|
|
381688
|
-
for (const value of values) {
|
|
381689
|
-
if (typeof value !== "string")
|
|
381690
|
-
throw new Error(`${quote2(property)} must be an array of strings`);
|
|
381691
|
-
result.push(value);
|
|
381692
|
-
}
|
|
381693
|
-
return result;
|
|
381694
|
-
}
|
|
381695
|
-
function convertOutputFiles({ path: path32, contents, hash }) {
|
|
381696
|
-
let text = null;
|
|
381697
|
-
return {
|
|
381698
|
-
path: path32,
|
|
381699
|
-
contents,
|
|
381700
|
-
hash,
|
|
381701
|
-
get text() {
|
|
381702
|
-
const binary2 = this.contents;
|
|
381703
|
-
if (text === null || binary2 !== contents) {
|
|
381704
|
-
contents = binary2;
|
|
381705
|
-
text = decodeUTF8(binary2);
|
|
381706
|
-
}
|
|
381707
|
-
return text;
|
|
381708
|
-
}
|
|
381709
|
-
};
|
|
381710
|
-
}
|
|
381711
|
-
var fs7 = require("fs");
|
|
381712
|
-
var os6 = require("os");
|
|
381713
|
-
var path14 = require("path");
|
|
381714
|
-
var ESBUILD_BINARY_PATH = process.env.ESBUILD_BINARY_PATH || ESBUILD_BINARY_PATH;
|
|
381715
|
-
var isValidBinaryPath = (x5) => !!x5 && x5 !== "/usr/bin/esbuild";
|
|
381716
|
-
var packageDarwin_arm64 = "@esbuild/darwin-arm64";
|
|
381717
|
-
var packageDarwin_x64 = "@esbuild/darwin-x64";
|
|
381718
|
-
var knownWindowsPackages = {
|
|
381719
|
-
"win32 arm64 LE": "@esbuild/win32-arm64",
|
|
381720
|
-
"win32 ia32 LE": "@esbuild/win32-ia32",
|
|
381721
|
-
"win32 x64 LE": "@esbuild/win32-x64"
|
|
381722
|
-
};
|
|
381723
|
-
var knownUnixlikePackages = {
|
|
381724
|
-
"aix ppc64 BE": "@esbuild/aix-ppc64",
|
|
381725
|
-
"android arm64 LE": "@esbuild/android-arm64",
|
|
381726
|
-
"darwin arm64 LE": "@esbuild/darwin-arm64",
|
|
381727
|
-
"darwin x64 LE": "@esbuild/darwin-x64",
|
|
381728
|
-
"freebsd arm64 LE": "@esbuild/freebsd-arm64",
|
|
381729
|
-
"freebsd x64 LE": "@esbuild/freebsd-x64",
|
|
381730
|
-
"linux arm LE": "@esbuild/linux-arm",
|
|
381731
|
-
"linux arm64 LE": "@esbuild/linux-arm64",
|
|
381732
|
-
"linux ia32 LE": "@esbuild/linux-ia32",
|
|
381733
|
-
"linux mips64el LE": "@esbuild/linux-mips64el",
|
|
381734
|
-
"linux ppc64 LE": "@esbuild/linux-ppc64",
|
|
381735
|
-
"linux riscv64 LE": "@esbuild/linux-riscv64",
|
|
381736
|
-
"linux s390x BE": "@esbuild/linux-s390x",
|
|
381737
|
-
"linux x64 LE": "@esbuild/linux-x64",
|
|
381738
|
-
"linux loong64 LE": "@esbuild/linux-loong64",
|
|
381739
|
-
"netbsd x64 LE": "@esbuild/netbsd-x64",
|
|
381740
|
-
"openbsd x64 LE": "@esbuild/openbsd-x64",
|
|
381741
|
-
"sunos x64 LE": "@esbuild/sunos-x64"
|
|
381742
|
-
};
|
|
381743
|
-
var knownWebAssemblyFallbackPackages = {
|
|
381744
|
-
"android arm LE": "@esbuild/android-arm",
|
|
381745
|
-
"android x64 LE": "@esbuild/android-x64"
|
|
381746
|
-
};
|
|
381747
|
-
function pkgAndSubpathForCurrentPlatform() {
|
|
381748
|
-
let pkg;
|
|
381749
|
-
let subpath;
|
|
381750
|
-
let isWASM = false;
|
|
381751
|
-
let platformKey = `${process.platform} ${os6.arch()} ${os6.endianness()}`;
|
|
381752
|
-
if (platformKey in knownWindowsPackages) {
|
|
381753
|
-
pkg = knownWindowsPackages[platformKey];
|
|
381754
|
-
subpath = "esbuild.exe";
|
|
381755
|
-
} else if (platformKey in knownUnixlikePackages) {
|
|
381756
|
-
pkg = knownUnixlikePackages[platformKey];
|
|
381757
|
-
subpath = "bin/esbuild";
|
|
381758
|
-
} else if (platformKey in knownWebAssemblyFallbackPackages) {
|
|
381759
|
-
pkg = knownWebAssemblyFallbackPackages[platformKey];
|
|
381760
|
-
subpath = "bin/esbuild";
|
|
381761
|
-
isWASM = true;
|
|
381762
|
-
} else {
|
|
381763
|
-
throw new Error(`Unsupported platform: ${platformKey}`);
|
|
381764
|
-
}
|
|
381765
|
-
return { pkg, subpath, isWASM };
|
|
381766
|
-
}
|
|
381767
|
-
function pkgForSomeOtherPlatform() {
|
|
381768
|
-
const libMainJS = require.resolve("esbuild");
|
|
381769
|
-
const nodeModulesDirectory = path14.dirname(path14.dirname(path14.dirname(libMainJS)));
|
|
381770
|
-
if (path14.basename(nodeModulesDirectory) === "node_modules") {
|
|
381771
|
-
for (const unixKey in knownUnixlikePackages) {
|
|
381772
|
-
try {
|
|
381773
|
-
const pkg = knownUnixlikePackages[unixKey];
|
|
381774
|
-
if (fs7.existsSync(path14.join(nodeModulesDirectory, pkg)))
|
|
381775
|
-
return pkg;
|
|
381776
|
-
} catch {
|
|
381777
|
-
}
|
|
381778
|
-
}
|
|
381779
|
-
for (const windowsKey in knownWindowsPackages) {
|
|
381780
|
-
try {
|
|
381781
|
-
const pkg = knownWindowsPackages[windowsKey];
|
|
381782
|
-
if (fs7.existsSync(path14.join(nodeModulesDirectory, pkg)))
|
|
381783
|
-
return pkg;
|
|
381784
|
-
} catch {
|
|
381785
|
-
}
|
|
381786
|
-
}
|
|
381787
|
-
}
|
|
381788
|
-
return null;
|
|
381789
|
-
}
|
|
381790
|
-
function downloadedBinPath(pkg, subpath) {
|
|
381791
|
-
const esbuildLibDir = path14.dirname(require.resolve("esbuild"));
|
|
381792
|
-
return path14.join(esbuildLibDir, `downloaded-${pkg.replace("/", "-")}-${path14.basename(subpath)}`);
|
|
381793
|
-
}
|
|
381794
|
-
function generateBinPath() {
|
|
381795
|
-
if (isValidBinaryPath(ESBUILD_BINARY_PATH)) {
|
|
381796
|
-
if (!fs7.existsSync(ESBUILD_BINARY_PATH)) {
|
|
381797
|
-
console.warn(`[esbuild] Ignoring bad configuration: ESBUILD_BINARY_PATH=${ESBUILD_BINARY_PATH}`);
|
|
381798
|
-
} else {
|
|
381799
|
-
return { binPath: ESBUILD_BINARY_PATH, isWASM: false };
|
|
381800
|
-
}
|
|
381801
|
-
}
|
|
381802
|
-
const { pkg, subpath, isWASM } = pkgAndSubpathForCurrentPlatform();
|
|
381803
|
-
let binPath;
|
|
381804
|
-
try {
|
|
381805
|
-
binPath = require.resolve(`${pkg}/${subpath}`);
|
|
381806
|
-
} catch (e3) {
|
|
381807
|
-
binPath = downloadedBinPath(pkg, subpath);
|
|
381808
|
-
if (!fs7.existsSync(binPath)) {
|
|
381809
|
-
try {
|
|
381810
|
-
require.resolve(pkg);
|
|
381811
|
-
} catch {
|
|
381812
|
-
const otherPkg = pkgForSomeOtherPlatform();
|
|
381813
|
-
if (otherPkg) {
|
|
381814
|
-
let suggestions = `
|
|
381815
|
-
Specifically the "${otherPkg}" package is present but this platform
|
|
381816
|
-
needs the "${pkg}" package instead. People often get into this
|
|
381817
|
-
situation by installing esbuild on Windows or macOS and copying "node_modules"
|
|
381818
|
-
into a Docker image that runs Linux, or by copying "node_modules" between
|
|
381819
|
-
Windows and WSL environments.
|
|
381820
|
-
|
|
381821
|
-
If you are installing with npm, you can try not copying the "node_modules"
|
|
381822
|
-
directory when you copy the files over, and running "npm ci" or "npm install"
|
|
381823
|
-
on the destination platform after the copy. Or you could consider using yarn
|
|
381824
|
-
instead of npm which has built-in support for installing a package on multiple
|
|
381825
|
-
platforms simultaneously.
|
|
381826
|
-
|
|
381827
|
-
If you are installing with yarn, you can try listing both this platform and the
|
|
381828
|
-
other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
|
|
381829
|
-
feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
|
|
381830
|
-
Keep in mind that this means multiple copies of esbuild will be present.
|
|
381831
|
-
`;
|
|
381832
|
-
if (pkg === packageDarwin_x64 && otherPkg === packageDarwin_arm64 || pkg === packageDarwin_arm64 && otherPkg === packageDarwin_x64) {
|
|
381833
|
-
suggestions = `
|
|
381834
|
-
Specifically the "${otherPkg}" package is present but this platform
|
|
381835
|
-
needs the "${pkg}" package instead. People often get into this
|
|
381836
|
-
situation by installing esbuild with npm running inside of Rosetta 2 and then
|
|
381837
|
-
trying to use it with node running outside of Rosetta 2, or vice versa (Rosetta
|
|
381838
|
-
2 is Apple's on-the-fly x86_64-to-arm64 translation service).
|
|
381839
|
-
|
|
381840
|
-
If you are installing with npm, you can try ensuring that both npm and node are
|
|
381841
|
-
not running under Rosetta 2 and then reinstalling esbuild. This likely involves
|
|
381842
|
-
changing how you installed npm and/or node. For example, installing node with
|
|
381843
|
-
the universal installer here should work: https://nodejs.org/en/download/. Or
|
|
381844
|
-
you could consider using yarn instead of npm which has built-in support for
|
|
381845
|
-
installing a package on multiple platforms simultaneously.
|
|
381846
|
-
|
|
381847
|
-
If you are installing with yarn, you can try listing both "arm64" and "x64"
|
|
381848
|
-
in your ".yarnrc.yml" file using the "supportedArchitectures" feature:
|
|
381849
|
-
https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
|
|
381850
|
-
Keep in mind that this means multiple copies of esbuild will be present.
|
|
381851
|
-
`;
|
|
381852
|
-
}
|
|
381853
|
-
throw new Error(`
|
|
381854
|
-
You installed esbuild for another platform than the one you're currently using.
|
|
381855
|
-
This won't work because esbuild is written with native code and needs to
|
|
381856
|
-
install a platform-specific binary executable.
|
|
381857
|
-
${suggestions}
|
|
381858
|
-
Another alternative is to use the "esbuild-wasm" package instead, which works
|
|
381859
|
-
the same way on all platforms. But it comes with a heavy performance cost and
|
|
381860
|
-
can sometimes be 10x slower than the "esbuild" package, so you may also not
|
|
381861
|
-
want to do that.
|
|
381862
|
-
`);
|
|
381863
|
-
}
|
|
381864
|
-
throw new Error(`The package "${pkg}" could not be found, and is needed by esbuild.
|
|
381865
|
-
|
|
381866
|
-
If you are installing esbuild with npm, make sure that you don't specify the
|
|
381867
|
-
"--no-optional" or "--omit=optional" flags. The "optionalDependencies" feature
|
|
381868
|
-
of "package.json" is used by esbuild to install the correct binary executable
|
|
381869
|
-
for your current platform.`);
|
|
381870
|
-
}
|
|
381871
|
-
throw e3;
|
|
381872
|
-
}
|
|
381873
|
-
}
|
|
381874
|
-
if (/\.zip\//.test(binPath)) {
|
|
381875
|
-
let pnpapi;
|
|
381876
|
-
try {
|
|
381877
|
-
pnpapi = require("pnpapi");
|
|
381878
|
-
} catch (e3) {
|
|
381879
|
-
}
|
|
381880
|
-
if (pnpapi) {
|
|
381881
|
-
const root2 = pnpapi.getPackageInformation(pnpapi.topLevel).packageLocation;
|
|
381882
|
-
const binTargetPath = path14.join(
|
|
381883
|
-
root2,
|
|
381884
|
-
"node_modules",
|
|
381885
|
-
".cache",
|
|
381886
|
-
"esbuild",
|
|
381887
|
-
`pnpapi-${pkg.replace("/", "-")}-${"0.19.12"}-${path14.basename(subpath)}`
|
|
381888
|
-
);
|
|
381889
|
-
if (!fs7.existsSync(binTargetPath)) {
|
|
381890
|
-
fs7.mkdirSync(path14.dirname(binTargetPath), { recursive: true });
|
|
381891
|
-
fs7.copyFileSync(binPath, binTargetPath);
|
|
381892
|
-
fs7.chmodSync(binTargetPath, 493);
|
|
381893
|
-
}
|
|
381894
|
-
return { binPath: binTargetPath, isWASM };
|
|
381895
|
-
}
|
|
381896
|
-
}
|
|
381897
|
-
return { binPath, isWASM };
|
|
381898
|
-
}
|
|
381899
|
-
var child_process = require("child_process");
|
|
381900
|
-
var crypto = require("crypto");
|
|
381901
|
-
var path22 = require("path");
|
|
381902
|
-
var fs23 = require("fs");
|
|
381903
|
-
var os22 = require("os");
|
|
381904
|
-
var tty2 = require("tty");
|
|
381905
|
-
var worker_threads;
|
|
381906
|
-
if (process.env.ESBUILD_WORKER_THREADS !== "0") {
|
|
381907
|
-
try {
|
|
381908
|
-
worker_threads = require("worker_threads");
|
|
381909
|
-
} catch {
|
|
381910
|
-
}
|
|
381911
|
-
let [major, minor] = process.versions.node.split(".");
|
|
381912
|
-
if (
|
|
381913
|
-
// <v12.17.0 does not work
|
|
381914
|
-
+major < 12 || +major === 12 && +minor < 17 || +major === 13 && +minor < 13
|
|
381915
|
-
) {
|
|
381916
|
-
worker_threads = void 0;
|
|
381917
|
-
}
|
|
381918
|
-
}
|
|
381919
|
-
var _a3;
|
|
381920
|
-
var isInternalWorkerThread = ((_a3 = worker_threads == null ? void 0 : worker_threads.workerData) == null ? void 0 : _a3.esbuildVersion) === "0.19.12";
|
|
381921
|
-
var esbuildCommandAndArgs = () => {
|
|
381922
|
-
if ((!ESBUILD_BINARY_PATH || false) && (path22.basename(__filename) !== "main.js" || path22.basename(__dirname) !== "lib")) {
|
|
381923
|
-
throw new Error(
|
|
381924
|
-
`The esbuild JavaScript API cannot be bundled. Please mark the "esbuild" package as external so it's not included in the bundle.
|
|
381925
|
-
|
|
381926
|
-
More information: The file containing the code for esbuild's JavaScript API (${__filename}) does not appear to be inside the esbuild package on the file system, which usually means that the esbuild package was bundled into another file. This is problematic because the API needs to run a binary executable inside the esbuild package which is located using a relative path from the API code to the executable. If the esbuild package is bundled, the relative path will be incorrect and the executable won't be found.`
|
|
381927
|
-
);
|
|
381928
|
-
}
|
|
381929
|
-
if (false) {
|
|
381930
|
-
return ["node", [path22.join(__dirname, "..", "bin", "esbuild")]];
|
|
381931
|
-
} else {
|
|
381932
|
-
const { binPath, isWASM } = generateBinPath();
|
|
381933
|
-
if (isWASM) {
|
|
381934
|
-
return ["node", [binPath]];
|
|
381935
|
-
} else {
|
|
381936
|
-
return [binPath, []];
|
|
381937
|
-
}
|
|
381938
|
-
}
|
|
381939
|
-
};
|
|
381940
|
-
var isTTY = () => tty2.isatty(2);
|
|
381941
|
-
var fsSync = {
|
|
381942
|
-
readFile(tempFile, callback) {
|
|
381943
|
-
try {
|
|
381944
|
-
let contents = fs23.readFileSync(tempFile, "utf8");
|
|
381945
|
-
try {
|
|
381946
|
-
fs23.unlinkSync(tempFile);
|
|
381947
|
-
} catch {
|
|
381948
|
-
}
|
|
381949
|
-
callback(null, contents);
|
|
381950
|
-
} catch (err) {
|
|
381951
|
-
callback(err, null);
|
|
381952
|
-
}
|
|
381953
|
-
},
|
|
381954
|
-
writeFile(contents, callback) {
|
|
381955
|
-
try {
|
|
381956
|
-
let tempFile = randomFileName();
|
|
381957
|
-
fs23.writeFileSync(tempFile, contents);
|
|
381958
|
-
callback(tempFile);
|
|
381959
|
-
} catch {
|
|
381960
|
-
callback(null);
|
|
381961
|
-
}
|
|
381962
|
-
}
|
|
381963
|
-
};
|
|
381964
|
-
var fsAsync = {
|
|
381965
|
-
readFile(tempFile, callback) {
|
|
381966
|
-
try {
|
|
381967
|
-
fs23.readFile(tempFile, "utf8", (err, contents) => {
|
|
381968
|
-
try {
|
|
381969
|
-
fs23.unlink(tempFile, () => callback(err, contents));
|
|
381970
|
-
} catch {
|
|
381971
|
-
callback(err, contents);
|
|
381972
|
-
}
|
|
381973
|
-
});
|
|
381974
|
-
} catch (err) {
|
|
381975
|
-
callback(err, null);
|
|
381976
|
-
}
|
|
381977
|
-
},
|
|
381978
|
-
writeFile(contents, callback) {
|
|
381979
|
-
try {
|
|
381980
|
-
let tempFile = randomFileName();
|
|
381981
|
-
fs23.writeFile(tempFile, contents, (err) => err !== null ? callback(null) : callback(tempFile));
|
|
381982
|
-
} catch {
|
|
381983
|
-
callback(null);
|
|
381984
|
-
}
|
|
381985
|
-
}
|
|
381986
|
-
};
|
|
381987
|
-
var version = "0.19.12";
|
|
381988
|
-
var build2 = (options8) => ensureServiceIsRunning().build(options8);
|
|
381989
|
-
var context = (buildOptions) => ensureServiceIsRunning().context(buildOptions);
|
|
381990
|
-
var transform2 = (input, options8) => ensureServiceIsRunning().transform(input, options8);
|
|
381991
|
-
var formatMessages = (messages2, options8) => ensureServiceIsRunning().formatMessages(messages2, options8);
|
|
381992
|
-
var analyzeMetafile = (messages2, options8) => ensureServiceIsRunning().analyzeMetafile(messages2, options8);
|
|
381993
|
-
var buildSync = (options8) => {
|
|
381994
|
-
if (worker_threads && !isInternalWorkerThread) {
|
|
381995
|
-
if (!workerThreadService)
|
|
381996
|
-
workerThreadService = startWorkerThreadService(worker_threads);
|
|
381997
|
-
return workerThreadService.buildSync(options8);
|
|
381998
|
-
}
|
|
381999
|
-
let result;
|
|
382000
|
-
runServiceSync((service) => service.buildOrContext({
|
|
382001
|
-
callName: "buildSync",
|
|
382002
|
-
refs: null,
|
|
382003
|
-
options: options8,
|
|
382004
|
-
isTTY: isTTY(),
|
|
382005
|
-
defaultWD,
|
|
382006
|
-
callback: (err, res) => {
|
|
382007
|
-
if (err)
|
|
382008
|
-
throw err;
|
|
382009
|
-
result = res;
|
|
382010
|
-
}
|
|
382011
|
-
}));
|
|
382012
|
-
return result;
|
|
382013
|
-
};
|
|
382014
|
-
var transformSync = (input, options8) => {
|
|
382015
|
-
if (worker_threads && !isInternalWorkerThread) {
|
|
382016
|
-
if (!workerThreadService)
|
|
382017
|
-
workerThreadService = startWorkerThreadService(worker_threads);
|
|
382018
|
-
return workerThreadService.transformSync(input, options8);
|
|
382019
|
-
}
|
|
382020
|
-
let result;
|
|
382021
|
-
runServiceSync((service) => service.transform({
|
|
382022
|
-
callName: "transformSync",
|
|
382023
|
-
refs: null,
|
|
382024
|
-
input,
|
|
382025
|
-
options: options8 || {},
|
|
382026
|
-
isTTY: isTTY(),
|
|
382027
|
-
fs: fsSync,
|
|
382028
|
-
callback: (err, res) => {
|
|
382029
|
-
if (err)
|
|
382030
|
-
throw err;
|
|
382031
|
-
result = res;
|
|
382032
|
-
}
|
|
382033
|
-
}));
|
|
382034
|
-
return result;
|
|
382035
|
-
};
|
|
382036
|
-
var formatMessagesSync = (messages2, options8) => {
|
|
382037
|
-
if (worker_threads && !isInternalWorkerThread) {
|
|
382038
|
-
if (!workerThreadService)
|
|
382039
|
-
workerThreadService = startWorkerThreadService(worker_threads);
|
|
382040
|
-
return workerThreadService.formatMessagesSync(messages2, options8);
|
|
382041
|
-
}
|
|
382042
|
-
let result;
|
|
382043
|
-
runServiceSync((service) => service.formatMessages({
|
|
382044
|
-
callName: "formatMessagesSync",
|
|
382045
|
-
refs: null,
|
|
382046
|
-
messages: messages2,
|
|
382047
|
-
options: options8,
|
|
382048
|
-
callback: (err, res) => {
|
|
382049
|
-
if (err)
|
|
382050
|
-
throw err;
|
|
382051
|
-
result = res;
|
|
382052
|
-
}
|
|
382053
|
-
}));
|
|
382054
|
-
return result;
|
|
382055
|
-
};
|
|
382056
|
-
var analyzeMetafileSync = (metafile, options8) => {
|
|
382057
|
-
if (worker_threads && !isInternalWorkerThread) {
|
|
382058
|
-
if (!workerThreadService)
|
|
382059
|
-
workerThreadService = startWorkerThreadService(worker_threads);
|
|
382060
|
-
return workerThreadService.analyzeMetafileSync(metafile, options8);
|
|
382061
|
-
}
|
|
382062
|
-
let result;
|
|
382063
|
-
runServiceSync((service) => service.analyzeMetafile({
|
|
382064
|
-
callName: "analyzeMetafileSync",
|
|
382065
|
-
refs: null,
|
|
382066
|
-
metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
|
|
382067
|
-
options: options8,
|
|
382068
|
-
callback: (err, res) => {
|
|
382069
|
-
if (err)
|
|
382070
|
-
throw err;
|
|
382071
|
-
result = res;
|
|
382072
|
-
}
|
|
382073
|
-
}));
|
|
382074
|
-
return result;
|
|
382075
|
-
};
|
|
382076
|
-
var stop = () => {
|
|
382077
|
-
if (stopService)
|
|
382078
|
-
stopService();
|
|
382079
|
-
if (workerThreadService)
|
|
382080
|
-
workerThreadService.stop();
|
|
382081
|
-
};
|
|
382082
|
-
var initializeWasCalled = false;
|
|
382083
|
-
var initialize = (options8) => {
|
|
382084
|
-
options8 = validateInitializeOptions(options8 || {});
|
|
382085
|
-
if (options8.wasmURL)
|
|
382086
|
-
throw new Error(`The "wasmURL" option only works in the browser`);
|
|
382087
|
-
if (options8.wasmModule)
|
|
382088
|
-
throw new Error(`The "wasmModule" option only works in the browser`);
|
|
382089
|
-
if (options8.worker)
|
|
382090
|
-
throw new Error(`The "worker" option only works in the browser`);
|
|
382091
|
-
if (initializeWasCalled)
|
|
382092
|
-
throw new Error('Cannot call "initialize" more than once');
|
|
382093
|
-
ensureServiceIsRunning();
|
|
382094
|
-
initializeWasCalled = true;
|
|
382095
|
-
return Promise.resolve();
|
|
382096
|
-
};
|
|
382097
|
-
var defaultWD = process.cwd();
|
|
382098
|
-
var longLivedService;
|
|
382099
|
-
var stopService;
|
|
382100
|
-
var ensureServiceIsRunning = () => {
|
|
382101
|
-
if (longLivedService)
|
|
382102
|
-
return longLivedService;
|
|
382103
|
-
let [command, args] = esbuildCommandAndArgs();
|
|
382104
|
-
let child = child_process.spawn(command, args.concat(`--service=${"0.19.12"}`, "--ping"), {
|
|
382105
|
-
windowsHide: true,
|
|
382106
|
-
stdio: ["pipe", "pipe", "inherit"],
|
|
382107
|
-
cwd: defaultWD
|
|
382108
|
-
});
|
|
382109
|
-
let { readFromStdout, afterClose, service } = createChannel({
|
|
382110
|
-
writeToStdin(bytes) {
|
|
382111
|
-
child.stdin.write(bytes, (err) => {
|
|
382112
|
-
if (err)
|
|
382113
|
-
afterClose(err);
|
|
382114
|
-
});
|
|
382115
|
-
},
|
|
382116
|
-
readFileSync: fs23.readFileSync,
|
|
382117
|
-
isSync: false,
|
|
382118
|
-
hasFS: true,
|
|
382119
|
-
esbuild: node_exports
|
|
382120
|
-
});
|
|
382121
|
-
child.stdin.on("error", afterClose);
|
|
382122
|
-
child.on("error", afterClose);
|
|
382123
|
-
const stdin2 = child.stdin;
|
|
382124
|
-
const stdout = child.stdout;
|
|
382125
|
-
stdout.on("data", readFromStdout);
|
|
382126
|
-
stdout.on("end", afterClose);
|
|
382127
|
-
stopService = () => {
|
|
382128
|
-
stdin2.destroy();
|
|
382129
|
-
stdout.destroy();
|
|
382130
|
-
child.kill();
|
|
382131
|
-
initializeWasCalled = false;
|
|
382132
|
-
longLivedService = void 0;
|
|
382133
|
-
stopService = void 0;
|
|
382134
|
-
};
|
|
382135
|
-
let refCount = 0;
|
|
382136
|
-
child.unref();
|
|
382137
|
-
if (stdin2.unref) {
|
|
382138
|
-
stdin2.unref();
|
|
382139
|
-
}
|
|
382140
|
-
if (stdout.unref) {
|
|
382141
|
-
stdout.unref();
|
|
382142
|
-
}
|
|
382143
|
-
const refs = {
|
|
382144
|
-
ref() {
|
|
382145
|
-
if (++refCount === 1)
|
|
382146
|
-
child.ref();
|
|
382147
|
-
},
|
|
382148
|
-
unref() {
|
|
382149
|
-
if (--refCount === 0)
|
|
382150
|
-
child.unref();
|
|
382151
|
-
}
|
|
382152
|
-
};
|
|
382153
|
-
longLivedService = {
|
|
382154
|
-
build: (options8) => new Promise((resolve3, reject) => {
|
|
382155
|
-
service.buildOrContext({
|
|
382156
|
-
callName: "build",
|
|
382157
|
-
refs,
|
|
382158
|
-
options: options8,
|
|
382159
|
-
isTTY: isTTY(),
|
|
382160
|
-
defaultWD,
|
|
382161
|
-
callback: (err, res) => err ? reject(err) : resolve3(res)
|
|
382162
|
-
});
|
|
382163
|
-
}),
|
|
382164
|
-
context: (options8) => new Promise((resolve3, reject) => service.buildOrContext({
|
|
382165
|
-
callName: "context",
|
|
382166
|
-
refs,
|
|
382167
|
-
options: options8,
|
|
382168
|
-
isTTY: isTTY(),
|
|
382169
|
-
defaultWD,
|
|
382170
|
-
callback: (err, res) => err ? reject(err) : resolve3(res)
|
|
382171
|
-
})),
|
|
382172
|
-
transform: (input, options8) => new Promise((resolve3, reject) => service.transform({
|
|
382173
|
-
callName: "transform",
|
|
382174
|
-
refs,
|
|
382175
|
-
input,
|
|
382176
|
-
options: options8 || {},
|
|
382177
|
-
isTTY: isTTY(),
|
|
382178
|
-
fs: fsAsync,
|
|
382179
|
-
callback: (err, res) => err ? reject(err) : resolve3(res)
|
|
382180
|
-
})),
|
|
382181
|
-
formatMessages: (messages2, options8) => new Promise((resolve3, reject) => service.formatMessages({
|
|
382182
|
-
callName: "formatMessages",
|
|
382183
|
-
refs,
|
|
382184
|
-
messages: messages2,
|
|
382185
|
-
options: options8,
|
|
382186
|
-
callback: (err, res) => err ? reject(err) : resolve3(res)
|
|
382187
|
-
})),
|
|
382188
|
-
analyzeMetafile: (metafile, options8) => new Promise((resolve3, reject) => service.analyzeMetafile({
|
|
382189
|
-
callName: "analyzeMetafile",
|
|
382190
|
-
refs,
|
|
382191
|
-
metafile: typeof metafile === "string" ? metafile : JSON.stringify(metafile),
|
|
382192
|
-
options: options8,
|
|
382193
|
-
callback: (err, res) => err ? reject(err) : resolve3(res)
|
|
382194
|
-
}))
|
|
382195
|
-
};
|
|
382196
|
-
return longLivedService;
|
|
382197
|
-
};
|
|
382198
|
-
var runServiceSync = (callback) => {
|
|
382199
|
-
let [command, args] = esbuildCommandAndArgs();
|
|
382200
|
-
let stdin2 = new Uint8Array();
|
|
382201
|
-
let { readFromStdout, afterClose, service } = createChannel({
|
|
382202
|
-
writeToStdin(bytes) {
|
|
382203
|
-
if (stdin2.length !== 0)
|
|
382204
|
-
throw new Error("Must run at most one command");
|
|
382205
|
-
stdin2 = bytes;
|
|
382206
|
-
},
|
|
382207
|
-
isSync: true,
|
|
382208
|
-
hasFS: true,
|
|
382209
|
-
esbuild: node_exports
|
|
382210
|
-
});
|
|
382211
|
-
callback(service);
|
|
382212
|
-
let stdout = child_process.execFileSync(command, args.concat(`--service=${"0.19.12"}`), {
|
|
382213
|
-
cwd: defaultWD,
|
|
382214
|
-
windowsHide: true,
|
|
382215
|
-
input: stdin2,
|
|
382216
|
-
// We don't know how large the output could be. If it's too large, the
|
|
382217
|
-
// command will fail with ENOBUFS. Reserve 16mb for now since that feels
|
|
382218
|
-
// like it should be enough. Also allow overriding this with an environment
|
|
382219
|
-
// variable.
|
|
382220
|
-
maxBuffer: +process.env.ESBUILD_MAX_BUFFER || 16 * 1024 * 1024
|
|
382221
|
-
});
|
|
382222
|
-
readFromStdout(stdout);
|
|
382223
|
-
afterClose(null);
|
|
382224
|
-
};
|
|
382225
|
-
var randomFileName = () => {
|
|
382226
|
-
return path22.join(os22.tmpdir(), `esbuild-${crypto.randomBytes(32).toString("hex")}`);
|
|
382227
|
-
};
|
|
382228
|
-
var workerThreadService = null;
|
|
382229
|
-
var startWorkerThreadService = (worker_threads2) => {
|
|
382230
|
-
let { port1: mainPort, port2: workerPort } = new worker_threads2.MessageChannel();
|
|
382231
|
-
let worker = new worker_threads2.Worker(__filename, {
|
|
382232
|
-
workerData: { workerPort, defaultWD, esbuildVersion: "0.19.12" },
|
|
382233
|
-
transferList: [workerPort],
|
|
382234
|
-
// From node's documentation: https://nodejs.org/api/worker_threads.html
|
|
382235
|
-
//
|
|
382236
|
-
// Take care when launching worker threads from preload scripts (scripts loaded
|
|
382237
|
-
// and run using the `-r` command line flag). Unless the `execArgv` option is
|
|
382238
|
-
// explicitly set, new Worker threads automatically inherit the command line flags
|
|
382239
|
-
// from the running process and will preload the same preload scripts as the main
|
|
382240
|
-
// thread. If the preload script unconditionally launches a worker thread, every
|
|
382241
|
-
// thread spawned will spawn another until the application crashes.
|
|
382242
|
-
//
|
|
382243
|
-
execArgv: []
|
|
382244
|
-
});
|
|
382245
|
-
let nextID = 0;
|
|
382246
|
-
let fakeBuildError = (text) => {
|
|
382247
|
-
let error = new Error(`Build failed with 1 error:
|
|
382248
|
-
error: ${text}`);
|
|
382249
|
-
let errors = [{ id: "", pluginName: "", text, location: null, notes: [], detail: void 0 }];
|
|
382250
|
-
error.errors = errors;
|
|
382251
|
-
error.warnings = [];
|
|
382252
|
-
return error;
|
|
382253
|
-
};
|
|
382254
|
-
let validateBuildSyncOptions = (options8) => {
|
|
382255
|
-
if (!options8)
|
|
382256
|
-
return;
|
|
382257
|
-
let plugins = options8.plugins;
|
|
382258
|
-
if (plugins && plugins.length > 0)
|
|
382259
|
-
throw fakeBuildError(`Cannot use plugins in synchronous API calls`);
|
|
382260
|
-
};
|
|
382261
|
-
let applyProperties = (object, properties) => {
|
|
382262
|
-
for (let key2 in properties) {
|
|
382263
|
-
object[key2] = properties[key2];
|
|
382264
|
-
}
|
|
382265
|
-
};
|
|
382266
|
-
let runCallSync = (command, args) => {
|
|
382267
|
-
let id = nextID++;
|
|
382268
|
-
let sharedBuffer = new SharedArrayBuffer(8);
|
|
382269
|
-
let sharedBufferView = new Int32Array(sharedBuffer);
|
|
382270
|
-
let msg = { sharedBuffer, id, command, args };
|
|
382271
|
-
worker.postMessage(msg);
|
|
382272
|
-
let status = Atomics.wait(sharedBufferView, 0, 0);
|
|
382273
|
-
if (status !== "ok" && status !== "not-equal")
|
|
382274
|
-
throw new Error("Internal error: Atomics.wait() failed: " + status);
|
|
382275
|
-
let { message: { id: id2, resolve: resolve3, reject, properties } } = worker_threads2.receiveMessageOnPort(mainPort);
|
|
382276
|
-
if (id !== id2)
|
|
382277
|
-
throw new Error(`Internal error: Expected id ${id} but got id ${id2}`);
|
|
382278
|
-
if (reject) {
|
|
382279
|
-
applyProperties(reject, properties);
|
|
382280
|
-
throw reject;
|
|
382281
|
-
}
|
|
382282
|
-
return resolve3;
|
|
382283
|
-
};
|
|
382284
|
-
worker.unref();
|
|
382285
|
-
return {
|
|
382286
|
-
buildSync(options8) {
|
|
382287
|
-
validateBuildSyncOptions(options8);
|
|
382288
|
-
return runCallSync("build", [options8]);
|
|
382289
|
-
},
|
|
382290
|
-
transformSync(input, options8) {
|
|
382291
|
-
return runCallSync("transform", [input, options8]);
|
|
382292
|
-
},
|
|
382293
|
-
formatMessagesSync(messages2, options8) {
|
|
382294
|
-
return runCallSync("formatMessages", [messages2, options8]);
|
|
382295
|
-
},
|
|
382296
|
-
analyzeMetafileSync(metafile, options8) {
|
|
382297
|
-
return runCallSync("analyzeMetafile", [metafile, options8]);
|
|
382298
|
-
},
|
|
382299
|
-
stop() {
|
|
382300
|
-
worker.terminate();
|
|
382301
|
-
workerThreadService = null;
|
|
382302
|
-
}
|
|
382303
|
-
};
|
|
382304
|
-
};
|
|
382305
|
-
var startSyncServiceWorker = () => {
|
|
382306
|
-
let workerPort = worker_threads.workerData.workerPort;
|
|
382307
|
-
let parentPort = worker_threads.parentPort;
|
|
382308
|
-
let extractProperties = (object) => {
|
|
382309
|
-
let properties = {};
|
|
382310
|
-
if (object && typeof object === "object") {
|
|
382311
|
-
for (let key2 in object) {
|
|
382312
|
-
properties[key2] = object[key2];
|
|
382313
|
-
}
|
|
382314
|
-
}
|
|
382315
|
-
return properties;
|
|
382316
|
-
};
|
|
382317
|
-
try {
|
|
382318
|
-
let service = ensureServiceIsRunning();
|
|
382319
|
-
defaultWD = worker_threads.workerData.defaultWD;
|
|
382320
|
-
parentPort.on("message", (msg) => {
|
|
382321
|
-
(async () => {
|
|
382322
|
-
let { sharedBuffer, id, command, args } = msg;
|
|
382323
|
-
let sharedBufferView = new Int32Array(sharedBuffer);
|
|
382324
|
-
try {
|
|
382325
|
-
switch (command) {
|
|
382326
|
-
case "build":
|
|
382327
|
-
workerPort.postMessage({ id, resolve: await service.build(args[0]) });
|
|
382328
|
-
break;
|
|
382329
|
-
case "transform":
|
|
382330
|
-
workerPort.postMessage({ id, resolve: await service.transform(args[0], args[1]) });
|
|
382331
|
-
break;
|
|
382332
|
-
case "formatMessages":
|
|
382333
|
-
workerPort.postMessage({ id, resolve: await service.formatMessages(args[0], args[1]) });
|
|
382334
|
-
break;
|
|
382335
|
-
case "analyzeMetafile":
|
|
382336
|
-
workerPort.postMessage({ id, resolve: await service.analyzeMetafile(args[0], args[1]) });
|
|
382337
|
-
break;
|
|
382338
|
-
default:
|
|
382339
|
-
throw new Error(`Invalid command: ${command}`);
|
|
382340
|
-
}
|
|
382341
|
-
} catch (reject) {
|
|
382342
|
-
workerPort.postMessage({ id, reject, properties: extractProperties(reject) });
|
|
382343
|
-
}
|
|
382344
|
-
Atomics.add(sharedBufferView, 0, 1);
|
|
382345
|
-
Atomics.notify(sharedBufferView, 0, Infinity);
|
|
382346
|
-
})();
|
|
382347
|
-
});
|
|
382348
|
-
} catch (reject) {
|
|
382349
|
-
parentPort.on("message", (msg) => {
|
|
382350
|
-
let { sharedBuffer, id } = msg;
|
|
382351
|
-
let sharedBufferView = new Int32Array(sharedBuffer);
|
|
382352
|
-
workerPort.postMessage({ id, reject, properties: extractProperties(reject) });
|
|
382353
|
-
Atomics.add(sharedBufferView, 0, 1);
|
|
382354
|
-
Atomics.notify(sharedBufferView, 0, Infinity);
|
|
382355
|
-
});
|
|
382356
|
-
}
|
|
382357
|
-
};
|
|
382358
|
-
if (isInternalWorkerThread) {
|
|
382359
|
-
startSyncServiceWorker();
|
|
382360
|
-
}
|
|
382361
|
-
var node_default = node_exports;
|
|
382362
|
-
}
|
|
382363
|
-
});
|
|
382364
|
-
|
|
382365
379959
|
// node_modules/.pnpm/load-tsconfig@0.2.5/node_modules/load-tsconfig/dist/index.cjs
|
|
382366
379960
|
var require_dist2 = __commonJS({
|
|
382367
379961
|
"node_modules/.pnpm/load-tsconfig@0.2.5/node_modules/load-tsconfig/dist/index.cjs"(exports2, module2) {
|
|
@@ -382611,7 +380205,7 @@ var require_dist3 = __commonJS({
|
|
|
382611
380205
|
var import_fs22 = __toESM3(require("fs"), 1);
|
|
382612
380206
|
var import_path22 = __toESM3(require("path"), 1);
|
|
382613
380207
|
var import_url13 = require("url");
|
|
382614
|
-
var import_esbuild =
|
|
380208
|
+
var import_esbuild = require("esbuild");
|
|
382615
380209
|
var import_load_tsconfig = require_dist2();
|
|
382616
380210
|
var import_fs5 = __toESM3(require("fs"), 1);
|
|
382617
380211
|
var import_path13 = __toESM3(require("path"), 1);
|
|
@@ -383965,7 +381559,7 @@ var require_signals2 = __commonJS({
|
|
|
383965
381559
|
});
|
|
383966
381560
|
|
|
383967
381561
|
// node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/main.js
|
|
383968
|
-
var
|
|
381562
|
+
var require_main2 = __commonJS({
|
|
383969
381563
|
"node_modules/.pnpm/human-signals@2.1.0/node_modules/human-signals/build/src/main.js"(exports2) {
|
|
383970
381564
|
"use strict";
|
|
383971
381565
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
@@ -384025,7 +381619,7 @@ var require_main3 = __commonJS({
|
|
|
384025
381619
|
var require_error4 = __commonJS({
|
|
384026
381620
|
"node_modules/.pnpm/execa@5.1.1/node_modules/execa/lib/error.js"(exports2, module2) {
|
|
384027
381621
|
"use strict";
|
|
384028
|
-
var { signalsByName } =
|
|
381622
|
+
var { signalsByName } = require_main2();
|
|
384029
381623
|
var getErrorPrefix = ({ timedOut, timeout, errorCode, signal, signalDescription, exitCode, isCanceled }) => {
|
|
384030
381624
|
if (timedOut) {
|
|
384031
381625
|
return `timed out after ${timeout} milliseconds`;
|
|
@@ -435165,7 +432759,7 @@ var require_dist6 = __commonJS({
|
|
|
435165
432759
|
var _execa2 = _interopRequireDefault(_execa);
|
|
435166
432760
|
var _treekill = require_tree_kill();
|
|
435167
432761
|
var _treekill2 = _interopRequireDefault(_treekill);
|
|
435168
|
-
var _esbuild =
|
|
432762
|
+
var _esbuild = require("esbuild");
|
|
435169
432763
|
var nodeProtocolPlugin = () => {
|
|
435170
432764
|
const nodeProtocol = "node:";
|
|
435171
432765
|
return {
|