@storm-software/tsup 0.1.0

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/dist/index.cjs ADDED
@@ -0,0 +1,2996 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
11
+ var __commonJS = (cb, mod) => function __require() {
12
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13
+ };
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27
+ // If the importer is in node compatibility mode or this is not an ESM
28
+ // file that has been converted to a CommonJS file using a Babel-
29
+ // compatible transform (i.e. "__esModule" has not been set), then set
30
+ // "default" to the CommonJS "module.exports" for node compatibility.
31
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32
+ mod
33
+ ));
34
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
+
36
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__27cd8c2707e42da8a6ff3e707ec47ae0/node_modules/tsup/assets/cjs_shims.js
37
+ var init_cjs_shims = __esm({
38
+ "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__27cd8c2707e42da8a6ff3e707ec47ae0/node_modules/tsup/assets/cjs_shims.js"() {
39
+ "use strict";
40
+ }
41
+ });
42
+
43
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__27cd8c2707e42da8a6ff3e707ec47ae0/node_modules/tsup/dist/chunk-BYH4XDRH.js
44
+ var require_chunk_BYH4XDRH = __commonJS({
45
+ "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__27cd8c2707e42da8a6ff3e707ec47ae0/node_modules/tsup/dist/chunk-BYH4XDRH.js"(exports2) {
46
+ "use strict";
47
+ init_cjs_shims();
48
+ Object.defineProperty(exports2, "__esModule", { value: true });
49
+ var version = "8.4.0";
50
+ exports2.version = version;
51
+ }
52
+ });
53
+
54
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__27cd8c2707e42da8a6ff3e707ec47ae0/node_modules/tsup/dist/chunk-TWFEYLU4.js
55
+ var require_chunk_TWFEYLU4 = __commonJS({
56
+ "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__27cd8c2707e42da8a6ff3e707ec47ae0/node_modules/tsup/dist/chunk-TWFEYLU4.js"(exports2) {
57
+ "use strict";
58
+ init_cjs_shims();
59
+ Object.defineProperty(exports2, "__esModule", { value: true });
60
+ function _interopRequireDefault(obj) {
61
+ return obj && obj.__esModule ? obj : { default: obj };
62
+ }
63
+ function _optionalChain(ops) {
64
+ let lastAccessLHS = void 0;
65
+ let value = ops[0];
66
+ let i = 1;
67
+ while (i < ops.length) {
68
+ const op = ops[i];
69
+ const fn = ops[i + 1];
70
+ i += 2;
71
+ if ((op === "optionalAccess" || op === "optionalCall") && value == null) {
72
+ return void 0;
73
+ }
74
+ if (op === "access" || op === "optionalAccess") {
75
+ lastAccessLHS = value;
76
+ value = fn(value);
77
+ } else if (op === "call" || op === "optionalCall") {
78
+ value = fn((...args) => value.call(lastAccessLHS, ...args));
79
+ lastAccessLHS = void 0;
80
+ }
81
+ }
82
+ return value;
83
+ }
84
+ var __create2 = Object.create;
85
+ var __defProp2 = Object.defineProperty;
86
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
87
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
88
+ var __getProtoOf2 = Object.getPrototypeOf;
89
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
90
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
91
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
92
+ }) : x)(function(x) {
93
+ if (typeof require !== "undefined") return require.apply(this, arguments);
94
+ throw Error('Dynamic require of "' + x + '" is not supported');
95
+ });
96
+ var __commonJS2 = (cb, mod) => function __require2() {
97
+ return mod || (0, cb[__getOwnPropNames2(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
98
+ };
99
+ var __copyProps2 = (to, from, except, desc) => {
100
+ if (from && typeof from === "object" || typeof from === "function") {
101
+ for (let key of __getOwnPropNames2(from))
102
+ if (!__hasOwnProp2.call(to, key) && key !== except)
103
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
104
+ }
105
+ return to;
106
+ };
107
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
108
+ // If the importer is in node compatibility mode or this is not an ESM
109
+ // file that has been converted to a CommonJS file using a Babel-
110
+ // compatible transform (i.e. "__esModule" has not been set), then set
111
+ // "default" to the CommonJS "module.exports" for node compatibility.
112
+ isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
113
+ mod
114
+ ));
115
+ var _fs = require("fs");
116
+ var _fs2 = _interopRequireDefault(_fs);
117
+ var _path = require("path");
118
+ var _path2 = _interopRequireDefault(_path);
119
+ var _resolvefrom = require("resolve-from");
120
+ var _resolvefrom2 = _interopRequireDefault(_resolvefrom);
121
+ var singleComment = Symbol("singleComment");
122
+ var multiComment = Symbol("multiComment");
123
+ var stripWithoutWhitespace = () => "";
124
+ var stripWithWhitespace = (string, start, end) => string.slice(start, end).replace(/\S/g, " ");
125
+ var isEscaped = (jsonString, quotePosition) => {
126
+ let index = quotePosition - 1;
127
+ let backslashCount = 0;
128
+ while (jsonString[index] === "\\") {
129
+ index -= 1;
130
+ backslashCount += 1;
131
+ }
132
+ return Boolean(backslashCount % 2);
133
+ };
134
+ function stripJsonComments(jsonString, { whitespace = true, trailingCommas = false } = {}) {
135
+ if (typeof jsonString !== "string") {
136
+ throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof jsonString}\``);
137
+ }
138
+ const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;
139
+ let isInsideString = false;
140
+ let isInsideComment = false;
141
+ let offset = 0;
142
+ let buffer = "";
143
+ let result = "";
144
+ let commaIndex = -1;
145
+ for (let index = 0; index < jsonString.length; index++) {
146
+ const currentCharacter = jsonString[index];
147
+ const nextCharacter = jsonString[index + 1];
148
+ if (!isInsideComment && currentCharacter === '"') {
149
+ const escaped = isEscaped(jsonString, index);
150
+ if (!escaped) {
151
+ isInsideString = !isInsideString;
152
+ }
153
+ }
154
+ if (isInsideString) {
155
+ continue;
156
+ }
157
+ if (!isInsideComment && currentCharacter + nextCharacter === "//") {
158
+ buffer += jsonString.slice(offset, index);
159
+ offset = index;
160
+ isInsideComment = singleComment;
161
+ index++;
162
+ } else if (isInsideComment === singleComment && currentCharacter + nextCharacter === "\r\n") {
163
+ index++;
164
+ isInsideComment = false;
165
+ buffer += strip(jsonString, offset, index);
166
+ offset = index;
167
+ continue;
168
+ } else if (isInsideComment === singleComment && currentCharacter === "\n") {
169
+ isInsideComment = false;
170
+ buffer += strip(jsonString, offset, index);
171
+ offset = index;
172
+ } else if (!isInsideComment && currentCharacter + nextCharacter === "/*") {
173
+ buffer += jsonString.slice(offset, index);
174
+ offset = index;
175
+ isInsideComment = multiComment;
176
+ index++;
177
+ continue;
178
+ } else if (isInsideComment === multiComment && currentCharacter + nextCharacter === "*/") {
179
+ index++;
180
+ isInsideComment = false;
181
+ buffer += strip(jsonString, offset, index + 1);
182
+ offset = index + 1;
183
+ continue;
184
+ } else if (trailingCommas && !isInsideComment) {
185
+ if (commaIndex !== -1) {
186
+ if (currentCharacter === "}" || currentCharacter === "]") {
187
+ buffer += jsonString.slice(offset, index);
188
+ result += strip(buffer, 0, 1) + buffer.slice(1);
189
+ buffer = "";
190
+ offset = index;
191
+ commaIndex = -1;
192
+ } else if (currentCharacter !== " " && currentCharacter !== " " && currentCharacter !== "\r" && currentCharacter !== "\n") {
193
+ buffer += jsonString.slice(offset, index);
194
+ offset = index;
195
+ commaIndex = -1;
196
+ }
197
+ } else if (currentCharacter === ",") {
198
+ result += buffer + jsonString.slice(offset, index);
199
+ buffer = "";
200
+ offset = index;
201
+ commaIndex = index;
202
+ }
203
+ }
204
+ }
205
+ return result + buffer + (isInsideComment ? strip(jsonString.slice(offset)) : jsonString.slice(offset));
206
+ }
207
+ var _tinyglobby = require("tinyglobby");
208
+ function getPostcss() {
209
+ return localRequire("postcss");
210
+ }
211
+ function getApiExtractor() {
212
+ return localRequire("@microsoft/api-extractor");
213
+ }
214
+ function localRequire(moduleName) {
215
+ const p = _resolvefrom2.default.silent(process.cwd(), moduleName);
216
+ return p && __require(p);
217
+ }
218
+ async function removeFiles(patterns, dir) {
219
+ const files = await _tinyglobby.glob.call(void 0, patterns, {
220
+ cwd: dir,
221
+ absolute: true
222
+ });
223
+ files.forEach((file) => _fs2.default.existsSync(file) && _fs2.default.unlinkSync(file));
224
+ }
225
+ function debouncePromise(fn, delay, onError) {
226
+ let timeout;
227
+ let promiseInFly;
228
+ let callbackPending;
229
+ return function debounced(...args) {
230
+ if (promiseInFly) {
231
+ callbackPending = () => {
232
+ debounced(...args);
233
+ callbackPending = void 0;
234
+ };
235
+ } else {
236
+ if (timeout != null) clearTimeout(timeout);
237
+ timeout = setTimeout(() => {
238
+ timeout = void 0;
239
+ promiseInFly = fn(...args).catch(onError).finally(() => {
240
+ promiseInFly = void 0;
241
+ if (callbackPending) callbackPending();
242
+ });
243
+ }, delay);
244
+ }
245
+ };
246
+ }
247
+ function slash(path2) {
248
+ const isExtendedLengthPath = path2.startsWith("\\\\?\\");
249
+ if (isExtendedLengthPath) {
250
+ return path2;
251
+ }
252
+ return path2.replace(/\\/g, "/");
253
+ }
254
+ function truthy(value) {
255
+ return Boolean(value);
256
+ }
257
+ function jsoncParse(data) {
258
+ try {
259
+ return new Function(`return ${stripJsonComments(data).trim()}`)();
260
+ } catch (e2) {
261
+ return {};
262
+ }
263
+ }
264
+ function defaultOutExtension({
265
+ format,
266
+ pkgType
267
+ }) {
268
+ let jsExtension = ".js";
269
+ let dtsExtension = ".d.ts";
270
+ const isModule = pkgType === "module";
271
+ if (isModule && format === "cjs") {
272
+ jsExtension = ".cjs";
273
+ dtsExtension = ".d.cts";
274
+ }
275
+ if (!isModule && format === "esm") {
276
+ jsExtension = ".mjs";
277
+ dtsExtension = ".d.mts";
278
+ }
279
+ if (format === "iife") {
280
+ jsExtension = ".global.js";
281
+ }
282
+ return {
283
+ js: jsExtension,
284
+ dts: dtsExtension
285
+ };
286
+ }
287
+ function ensureTempDeclarationDir(options2) {
288
+ const cwd = options2.workspaceConfig?.workspaceRoot || process.cwd();
289
+ const dirPath = _path2.default.join(cwd, ".tsup", "declaration");
290
+ if (_fs2.default.existsSync(dirPath)) {
291
+ return dirPath;
292
+ }
293
+ _fs2.default.mkdirSync(dirPath, { recursive: true });
294
+ const gitIgnorePath = _path2.default.join(cwd, ".tsup", ".gitignore");
295
+ writeFileSync(gitIgnorePath, "**/*\n");
296
+ return dirPath;
297
+ }
298
+ var toObjectEntry = (entry) => {
299
+ if (typeof entry === "string") {
300
+ entry = [entry];
301
+ }
302
+ if (!Array.isArray(entry)) {
303
+ return entry;
304
+ }
305
+ entry = entry.map((e) => e.replace(/\\/g, "/"));
306
+ const ancestor = findLowestCommonAncestor(entry);
307
+ return entry.reduce(
308
+ (result, item) => {
309
+ const key = item.replace(ancestor, "").replace(/^\//, "").replace(/\.[a-z]+$/, "");
310
+ return {
311
+ ...result,
312
+ [key]: item
313
+ };
314
+ },
315
+ {}
316
+ );
317
+ };
318
+ var findLowestCommonAncestor = (filepaths) => {
319
+ if (filepaths.length <= 1) return "";
320
+ const [first, ...rest] = filepaths;
321
+ let ancestor = first.split("/");
322
+ for (const filepath of rest) {
323
+ const directories = filepath.split("/", ancestor.length);
324
+ let index = 0;
325
+ for (const directory of directories) {
326
+ if (directory === ancestor[index]) {
327
+ index += 1;
328
+ } else {
329
+ ancestor = ancestor.slice(0, index);
330
+ break;
331
+ }
332
+ }
333
+ ancestor = ancestor.slice(0, index);
334
+ }
335
+ return ancestor.length <= 1 && ancestor[0] === "" ? `/${ancestor[0]}` : ancestor.join("/");
336
+ };
337
+ function toAbsolutePath(p, cwd) {
338
+ if (_path2.default.isAbsolute(p)) {
339
+ return p;
340
+ }
341
+ return slash(_path2.default.normalize(_path2.default.join(cwd || process.cwd(), p)));
342
+ }
343
+ function writeFileSync(filePath, content) {
344
+ _fs2.default.mkdirSync(_path2.default.dirname(filePath), { recursive: true });
345
+ _fs2.default.writeFileSync(filePath, content);
346
+ }
347
+ function replaceDtsWithJsExtensions(dtsFilePath) {
348
+ return dtsFilePath.replace(
349
+ /\.d\.(ts|mts|cts)$/,
350
+ (_, fileExtension) => {
351
+ switch (fileExtension) {
352
+ case "ts":
353
+ return ".js";
354
+ case "mts":
355
+ return ".mjs";
356
+ case "cts":
357
+ return ".cjs";
358
+ default:
359
+ return "";
360
+ }
361
+ }
362
+ );
363
+ }
364
+ var convertArrayEntriesToObjectEntries = (arrayOfEntries) => {
365
+ const objectEntries = Object.fromEntries(
366
+ arrayOfEntries.map(
367
+ (entry) => [
368
+ _path2.default.posix.join(
369
+ ...entry.split(_path2.default.posix.sep).slice(1, -1).concat(_path2.default.parse(entry).name)
370
+ ),
371
+ entry
372
+ ]
373
+ )
374
+ );
375
+ return objectEntries;
376
+ };
377
+ var resolveEntryPaths = async (entryPaths) => {
378
+ const resolvedEntryPaths = typeof entryPaths === "string" || Array.isArray(entryPaths) ? convertArrayEntriesToObjectEntries(await _tinyglobby.glob.call(void 0, entryPaths)) : entryPaths;
379
+ return resolvedEntryPaths;
380
+ };
381
+ var resolveExperimentalDtsConfig = async (options2, tsconfig) => {
382
+ const resolvedEntryPaths = await resolveEntryPaths(
383
+ _optionalChain([options2, "access", (_2) => _2.experimentalDts, "optionalAccess", (_3) => _3.entry]) || options2.entry
384
+ );
385
+ const experimentalDtsObjectEntry = Object.keys(resolvedEntryPaths).length === 0 ? Array.isArray(options2.entry) ? convertArrayEntriesToObjectEntries(options2.entry) : options2.entry : resolvedEntryPaths;
386
+ const normalizedExperimentalDtsConfig = {
387
+ compilerOptions: {
388
+ ...tsconfig.data.compilerOptions || {},
389
+ ..._optionalChain([options2, "access", (_4) => _4.experimentalDts, "optionalAccess", (_5) => _5.compilerOptions]) || {}
390
+ },
391
+ entry: experimentalDtsObjectEntry
392
+ };
393
+ return normalizedExperimentalDtsConfig;
394
+ };
395
+ var resolveInitialExperimentalDtsConfig = async (experimentalDts) => {
396
+ if (experimentalDts == null) {
397
+ return;
398
+ }
399
+ if (typeof experimentalDts === "boolean")
400
+ return experimentalDts ? { entry: {} } : void 0;
401
+ if (typeof experimentalDts === "string") {
402
+ return {
403
+ entry: convertArrayEntriesToObjectEntries(await _tinyglobby.glob.call(void 0, experimentalDts))
404
+ };
405
+ }
406
+ return {
407
+ ...experimentalDts,
408
+ entry: _optionalChain([experimentalDts, "optionalAccess", (_6) => _6.entry]) == null ? {} : await resolveEntryPaths(experimentalDts.entry)
409
+ };
410
+ };
411
+ exports2.__require = __require;
412
+ exports2.__commonJS = __commonJS2;
413
+ exports2.__toESM = __toESM2;
414
+ exports2.getPostcss = getPostcss;
415
+ exports2.getApiExtractor = getApiExtractor;
416
+ exports2.localRequire = localRequire;
417
+ exports2.removeFiles = removeFiles;
418
+ exports2.debouncePromise = debouncePromise;
419
+ exports2.slash = slash;
420
+ exports2.truthy = truthy;
421
+ exports2.jsoncParse = jsoncParse;
422
+ exports2.defaultOutExtension = defaultOutExtension;
423
+ exports2.ensureTempDeclarationDir = ensureTempDeclarationDir;
424
+ exports2.toObjectEntry = toObjectEntry;
425
+ exports2.toAbsolutePath = toAbsolutePath;
426
+ exports2.writeFileSync = writeFileSync;
427
+ exports2.replaceDtsWithJsExtensions = replaceDtsWithJsExtensions;
428
+ exports2.resolveExperimentalDtsConfig = resolveExperimentalDtsConfig;
429
+ exports2.resolveInitialExperimentalDtsConfig = resolveInitialExperimentalDtsConfig;
430
+ }
431
+ });
432
+
433
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__27cd8c2707e42da8a6ff3e707ec47ae0/node_modules/tsup/dist/chunk-VGC3FXLU.js
434
+ var require_chunk_VGC3FXLU = __commonJS({
435
+ "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__27cd8c2707e42da8a6ff3e707ec47ae0/node_modules/tsup/dist/chunk-VGC3FXLU.js"(exports2) {
436
+ "use strict";
437
+ init_cjs_shims();
438
+ Object.defineProperty(exports2, "__esModule", { value: true });
439
+ function _interopRequireDefault(obj) {
440
+ return obj && obj.__esModule ? obj : { default: obj };
441
+ }
442
+ function _optionalChain(ops) {
443
+ let lastAccessLHS = void 0;
444
+ let value = ops[0];
445
+ let i = 1;
446
+ while (i < ops.length) {
447
+ const op = ops[i];
448
+ const fn = ops[i + 1];
449
+ i += 2;
450
+ if ((op === "optionalAccess" || op === "optionalCall") && value == null) {
451
+ return void 0;
452
+ }
453
+ if (op === "access" || op === "optionalAccess") {
454
+ lastAccessLHS = value;
455
+ value = fn(value);
456
+ } else if (op === "call" || op === "optionalCall") {
457
+ value = fn((...args) => value.call(lastAccessLHS, ...args));
458
+ lastAccessLHS = void 0;
459
+ }
460
+ }
461
+ return value;
462
+ }
463
+ var _chunkTWFEYLU4js = require_chunk_TWFEYLU4();
464
+ var _fs = require("fs");
465
+ var _fs2 = _interopRequireDefault(_fs);
466
+ var _path = require("path");
467
+ var _path2 = _interopRequireDefault(_path);
468
+ var _joycon = require("joycon");
469
+ var _joycon2 = _interopRequireDefault(_joycon);
470
+ var _bundlerequire = require("bundle-require");
471
+ var joycon = new (0, _joycon2.default)();
472
+ var loadJson = async (filepath, options2) => {
473
+ try {
474
+ return _chunkTWFEYLU4js.jsoncParse.call(void 0, await _fs2.default.promises.readFile(filepath, "utf8"));
475
+ } catch (error) {
476
+ if (error instanceof Error) {
477
+ throw new Error(
478
+ `Failed to parse ${_path2.default.relative(options2.workspaceConfig?.workspaceRoot || process.cwd(), filepath)}: ${error.message}`
479
+ );
480
+ } else {
481
+ throw error;
482
+ }
483
+ }
484
+ };
485
+ var jsonLoader = {
486
+ test: /\.json$/,
487
+ load(filepath) {
488
+ return loadJson(filepath);
489
+ }
490
+ };
491
+ joycon.addLoader(jsonLoader);
492
+ async function loadTsupConfig(cwd, configFile) {
493
+ const configJoycon = new (0, _joycon2.default)();
494
+ const configPath = await configJoycon.resolve({
495
+ files: configFile ? [configFile] : [
496
+ "tsup.config.ts",
497
+ "tsup.config.cts",
498
+ "tsup.config.mts",
499
+ "tsup.config.js",
500
+ "tsup.config.cjs",
501
+ "tsup.config.mjs",
502
+ "tsup.config.json",
503
+ "package.json"
504
+ ],
505
+ cwd,
506
+ stopDir: _path2.default.parse(cwd).root,
507
+ packageKey: "tsup"
508
+ });
509
+ if (configPath) {
510
+ if (configPath.endsWith(".json")) {
511
+ let data = await loadJson(configPath);
512
+ if (configPath.endsWith("package.json")) {
513
+ data = data.tsup;
514
+ }
515
+ if (data) {
516
+ return { path: configPath, data };
517
+ }
518
+ return {};
519
+ }
520
+ const config = await _bundlerequire.bundleRequire.call(void 0, {
521
+ filepath: configPath
522
+ });
523
+ return {
524
+ path: configPath,
525
+ data: config.mod.tsup || config.mod.default || config.mod
526
+ };
527
+ }
528
+ return {};
529
+ }
530
+ async function loadPkg(cwd, clearCache = false) {
531
+ if (clearCache) {
532
+ joycon.clearCache();
533
+ }
534
+ const { data } = await joycon.load(["package.json"], cwd, _path2.default.dirname(cwd));
535
+ return data || {};
536
+ }
537
+ async function getProductionDeps(cwd, clearCache = false) {
538
+ const data = await loadPkg(cwd, clearCache);
539
+ const deps = Array.from(
540
+ /* @__PURE__ */ new Set([
541
+ ...Object.keys(data.dependencies || {}),
542
+ ...Object.keys(data.peerDependencies || {})
543
+ ])
544
+ );
545
+ return deps;
546
+ }
547
+ async function getAllDepsHash(cwd) {
548
+ const data = await loadPkg(cwd, true);
549
+ return JSON.stringify({
550
+ ...data.dependencies,
551
+ ...data.peerDependencies,
552
+ ...data.devDependencies
553
+ });
554
+ }
555
+ var _util = require("util");
556
+ var _util2 = _interopRequireDefault(_util);
557
+ var _worker_threads = require("worker_threads");
558
+ var _picocolors = require("picocolors");
559
+ var _picocolors2 = _interopRequireDefault(_picocolors);
560
+ var colorize = (type, data, onlyImportant = false) => {
561
+ if (onlyImportant && (type === "info" || type === "success")) return data;
562
+ const color = type === "info" ? "blue" : type === "error" ? "red" : type === "warn" ? "yellow" : "green";
563
+ return _picocolors2.default[color](data);
564
+ };
565
+ var makeLabel = (name, input, type) => {
566
+ return [
567
+ name && `${_picocolors2.default.dim("[")}${name.toUpperCase()}${_picocolors2.default.dim("]")}`,
568
+ colorize(type, input.toUpperCase())
569
+ ].filter(Boolean).join(" ");
570
+ };
571
+ var silent = false;
572
+ function setSilent(isSilent) {
573
+ silent = !!isSilent;
574
+ }
575
+ function getSilent() {
576
+ return silent;
577
+ }
578
+ var createLogger = (name) => {
579
+ return {
580
+ setName(_name) {
581
+ name = _name;
582
+ },
583
+ success(label, ...args) {
584
+ return this.log(label, "success", ...args);
585
+ },
586
+ info(label, ...args) {
587
+ return this.log(label, "info", ...args);
588
+ },
589
+ error(label, ...args) {
590
+ return this.log(label, "error", ...args);
591
+ },
592
+ warn(label, ...args) {
593
+ return this.log(label, "warn", ...args);
594
+ },
595
+ log(label, type, ...data) {
596
+ const args = [
597
+ makeLabel(name, label, type),
598
+ ...data.map((item) => colorize(type, item, true))
599
+ ];
600
+ switch (type) {
601
+ case "error": {
602
+ if (!_worker_threads.isMainThread) {
603
+ _optionalChain([_worker_threads.parentPort, "optionalAccess", (_) => _.postMessage, "call", (_2) => _2({
604
+ type: "error",
605
+ text: _util2.default.format(...args)
606
+ })]);
607
+ return;
608
+ }
609
+ return console.error(...args);
610
+ }
611
+ default:
612
+ if (silent) return;
613
+ if (!_worker_threads.isMainThread) {
614
+ _optionalChain([_worker_threads.parentPort, "optionalAccess", (_3) => _3.postMessage, "call", (_4) => _4({
615
+ type: "log",
616
+ text: _util2.default.format(...args)
617
+ })]);
618
+ return;
619
+ }
620
+ console.log(...args);
621
+ }
622
+ }
623
+ };
624
+ };
625
+ var prettyBytes = (bytes) => {
626
+ if (bytes === 0) return "0 B";
627
+ const unit = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
628
+ const exp = Math.floor(Math.log(bytes) / Math.log(1024));
629
+ return `${(bytes / 1024 ** exp).toFixed(2)} ${unit[exp]}`;
630
+ };
631
+ var getLengthOfLongestString = (strings) => {
632
+ return strings.reduce((max, str) => {
633
+ return Math.max(max, str.length);
634
+ }, 0);
635
+ };
636
+ var padRight = (str, maxLength) => {
637
+ return str + " ".repeat(maxLength - str.length);
638
+ };
639
+ var reportSize = (logger, format, files) => {
640
+ const filenames = Object.keys(files);
641
+ const maxLength = getLengthOfLongestString(filenames) + 1;
642
+ for (const name of filenames) {
643
+ logger.success(
644
+ format,
645
+ `${_picocolors2.default.bold(padRight(name, maxLength))}${_picocolors2.default.green(
646
+ prettyBytes(files[name])
647
+ )}`
648
+ );
649
+ }
650
+ };
651
+ exports2.loadTsupConfig = loadTsupConfig;
652
+ exports2.loadPkg = loadPkg;
653
+ exports2.getProductionDeps = getProductionDeps;
654
+ exports2.getAllDepsHash = getAllDepsHash;
655
+ exports2.setSilent = setSilent;
656
+ exports2.getSilent = getSilent;
657
+ exports2.createLogger = createLogger;
658
+ exports2.reportSize = reportSize;
659
+ }
660
+ });
661
+
662
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__27cd8c2707e42da8a6ff3e707ec47ae0/node_modules/tsup/dist/chunk-JZ25TPTY.js
663
+ var require_chunk_JZ25TPTY = __commonJS({
664
+ "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__27cd8c2707e42da8a6ff3e707ec47ae0/node_modules/tsup/dist/chunk-JZ25TPTY.js"(exports2) {
665
+ "use strict";
666
+ init_cjs_shims();
667
+ Object.defineProperty(exports2, "__esModule", { value: true });
668
+ function _interopRequireDefault(obj) {
669
+ return obj && obj.__esModule ? obj : { default: obj };
670
+ }
671
+ var _worker_threads = require("worker_threads");
672
+ var _picocolors = require("picocolors");
673
+ var _picocolors2 = _interopRequireDefault(_picocolors);
674
+ var PrettyError = class extends Error {
675
+ constructor(message) {
676
+ super(message);
677
+ this.name = this.constructor.name;
678
+ if (typeof Error.captureStackTrace === "function") {
679
+ Error.captureStackTrace(this, this.constructor);
680
+ } else {
681
+ this.stack = new Error(message).stack;
682
+ }
683
+ }
684
+ };
685
+ function handleError(error) {
686
+ if (error.loc) {
687
+ console.error(
688
+ _picocolors2.default.bold(
689
+ _picocolors2.default.red(
690
+ `Error parsing: ${error.loc.file}:${error.loc.line}:${error.loc.column}`
691
+ )
692
+ )
693
+ );
694
+ }
695
+ if (error.frame) {
696
+ console.error(_picocolors2.default.red(error.message));
697
+ console.error(_picocolors2.default.dim(error.frame));
698
+ } else if (error instanceof PrettyError) {
699
+ console.error(_picocolors2.default.red(error.message));
700
+ } else {
701
+ console.error(_picocolors2.default.red(error.stack));
702
+ }
703
+ process.exitCode = 1;
704
+ if (!_worker_threads.isMainThread && _worker_threads.parentPort) {
705
+ _worker_threads.parentPort.postMessage("error");
706
+ }
707
+ }
708
+ exports2.PrettyError = PrettyError;
709
+ exports2.handleError = handleError;
710
+ }
711
+ });
712
+
713
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__27cd8c2707e42da8a6ff3e707ec47ae0/node_modules/tsup/dist/commonjs-plugin.js
714
+ var require_commonjs_plugin = __commonJS({
715
+ "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__27cd8c2707e42da8a6ff3e707ec47ae0/node_modules/tsup/dist/commonjs-plugin.js"(exports2, module2) {
716
+ "use strict";
717
+ init_cjs_shims();
718
+ var __defProp2 = Object.defineProperty;
719
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
720
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
721
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
722
+ var __export2 = (target, all) => {
723
+ for (var name in all)
724
+ __defProp2(target, name, { get: all[name], enumerable: true });
725
+ };
726
+ var __copyProps2 = (to, from, except, desc) => {
727
+ if (from && typeof from === "object" || typeof from === "function") {
728
+ for (let key of __getOwnPropNames2(from))
729
+ if (!__hasOwnProp2.call(to, key) && key !== except)
730
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
731
+ }
732
+ return to;
733
+ };
734
+ var __toCommonJS2 = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
735
+ var index_exports2 = {};
736
+ __export2(index_exports2, {
737
+ commonjs: () => commonjs,
738
+ default: () => index_default
739
+ });
740
+ module2.exports = __toCommonJS2(index_exports2);
741
+ var import_fs = require("fs");
742
+ function isNewLine(code) {
743
+ return code === 10 || code === 13 || code === 8232 || code === 8233;
744
+ }
745
+ function codePointToString(ch) {
746
+ if (ch <= 65535) return String.fromCharCode(ch);
747
+ ch -= 65536;
748
+ return String.fromCharCode((ch >> 10) + 55296, (ch & 1023) + 56320);
749
+ }
750
+ var Lexer = class {
751
+ input = "";
752
+ pos = 0;
753
+ readString(input, pos) {
754
+ if (pos >= input.length) return null;
755
+ this.input = input;
756
+ this.pos = pos;
757
+ const quote = this.input.charCodeAt(pos);
758
+ if (!(quote === 34 || quote === 39)) return null;
759
+ let out = "";
760
+ let chunkStart = ++this.pos;
761
+ while (true) {
762
+ if (this.pos >= this.input.length) return null;
763
+ let ch = this.input.charCodeAt(this.pos);
764
+ if (ch === quote) break;
765
+ if (ch === 92) {
766
+ out += this.input.slice(chunkStart, this.pos);
767
+ const escaped = this.readEscapedChar();
768
+ if (escaped === null) return null;
769
+ out += escaped;
770
+ chunkStart = this.pos;
771
+ } else {
772
+ if (isNewLine(ch)) return null;
773
+ ++this.pos;
774
+ }
775
+ }
776
+ out += this.input.slice(chunkStart, this.pos++);
777
+ return out;
778
+ }
779
+ readEscapedChar() {
780
+ let ch = this.input.charCodeAt(++this.pos);
781
+ let code;
782
+ ++this.pos;
783
+ switch (ch) {
784
+ case 110:
785
+ return "\n";
786
+ case 114:
787
+ return "\r";
788
+ case 120:
789
+ code = this.readHexChar(2);
790
+ if (code === null) return null;
791
+ return String.fromCharCode(code);
792
+ case 117:
793
+ code = this.readCodePoint();
794
+ if (code === null) return null;
795
+ return codePointToString(code);
796
+ case 116:
797
+ return " ";
798
+ case 98:
799
+ return "\b";
800
+ case 118:
801
+ return "\v";
802
+ case 102:
803
+ return "\f";
804
+ case 13:
805
+ if (this.input.charCodeAt(this.pos) === 10) {
806
+ ++this.pos;
807
+ }
808
+ case 10:
809
+ return "";
810
+ case 56:
811
+ case 57:
812
+ return null;
813
+ default:
814
+ if (ch >= 48 && ch <= 55) {
815
+ let match = this.input.slice(this.pos - 1, this.pos + 2).match(/^[0-7]+/);
816
+ if (match === null) return null;
817
+ let octalStr = match[0];
818
+ let octal = parseInt(octalStr, 8);
819
+ if (octal > 255) {
820
+ octalStr = octalStr.slice(0, -1);
821
+ octal = parseInt(octalStr, 8);
822
+ }
823
+ this.pos += octalStr.length - 1;
824
+ ch = this.input.charCodeAt(this.pos);
825
+ if (octalStr !== "0" || ch === 56 || ch === 57) return null;
826
+ return String.fromCharCode(octal);
827
+ }
828
+ if (isNewLine(ch)) return "";
829
+ return String.fromCharCode(ch);
830
+ }
831
+ }
832
+ readInt(radix, len) {
833
+ let start = this.pos;
834
+ let total = 0;
835
+ for (let i = 0; i < len; ++i, ++this.pos) {
836
+ let code = this.input.charCodeAt(this.pos);
837
+ let val;
838
+ if (code >= 97) {
839
+ val = code - 97 + 10;
840
+ } else if (code >= 65) {
841
+ val = code - 65 + 10;
842
+ } else if (code >= 48 && code <= 57) {
843
+ val = code - 48;
844
+ } else {
845
+ val = Infinity;
846
+ }
847
+ if (val >= radix) break;
848
+ total = total * radix + val;
849
+ }
850
+ if (this.pos === start || len != null && this.pos - start !== len) return null;
851
+ return total;
852
+ }
853
+ readHexChar(len) {
854
+ return this.readInt(16, len);
855
+ }
856
+ readCodePoint() {
857
+ let ch = this.input.charCodeAt(this.pos);
858
+ let code;
859
+ if (ch === 123) {
860
+ ++this.pos;
861
+ code = this.readHexChar(this.input.indexOf("}", this.pos) - this.pos);
862
+ ++this.pos;
863
+ if (code && code > 1114111) return null;
864
+ } else {
865
+ code = this.readHexChar(4);
866
+ }
867
+ return code;
868
+ }
869
+ };
870
+ function orderedUniq(array) {
871
+ let ret = [], visited = /* @__PURE__ */ new Set();
872
+ for (let val of array) if (!visited.has(val)) visited.add(val), ret.push(val);
873
+ return ret;
874
+ }
875
+ function cachedReduce(array, reducer, s) {
876
+ let cache = [s], cacheLen = 1, last = s;
877
+ return (len) => {
878
+ while (cacheLen <= len) cacheLen = cache.push(last = reducer(last, array[cacheLen - 1]));
879
+ return cache[len];
880
+ };
881
+ }
882
+ var reservedWords = "break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public";
883
+ var builtin = "arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl";
884
+ var forbiddenIdentifiers = new Set(`${reservedWords} ${builtin}`.split(" "));
885
+ forbiddenIdentifiers.add("");
886
+ var makeLegalIdentifier = function makeLegalIdentifier2(str) {
887
+ let identifier = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(/[^$_a-zA-Z0-9]/g, "_");
888
+ if (/\d/.test(identifier[0]) || forbiddenIdentifiers.has(identifier)) {
889
+ identifier = `_${identifier}`;
890
+ }
891
+ return identifier || "_";
892
+ };
893
+ function prepend(code, prefix) {
894
+ if (code.startsWith("#!")) {
895
+ const i = code.indexOf("\n") + 1;
896
+ return code.slice(0, i) + prefix + code.slice(i);
897
+ }
898
+ return prefix + code;
899
+ }
900
+ function commonjs({
901
+ filter = /\.c?js$/,
902
+ transform = false,
903
+ transformConfig,
904
+ requireReturnsDefault = false,
905
+ ignore
906
+ } = {}) {
907
+ const init_cjs_module_lexer = transform ? import("cjs-module-lexer") : void 0;
908
+ const use_default_export = typeof requireReturnsDefault === "function" ? requireReturnsDefault : (_path) => requireReturnsDefault;
909
+ const is_ignored = typeof ignore === "function" ? ignore : Array.isArray(ignore) ? (path) => ignore.includes(path) : () => false;
910
+ return {
911
+ name: "commonjs",
912
+ setup({ onLoad, esbuild }) {
913
+ let esbuild_shim;
914
+ const require_esbuild = () => esbuild || (esbuild_shim || (esbuild_shim = require("esbuild")));
915
+ const read = import_fs.promises.readFile;
916
+ const lexer = new Lexer();
917
+ onLoad({ filter }, async (args) => {
918
+ let parseCJS;
919
+ if (init_cjs_module_lexer) {
920
+ const { init, parse } = await init_cjs_module_lexer;
921
+ await init();
922
+ parseCJS = parse;
923
+ }
924
+ let contents;
925
+ try {
926
+ contents = await read(args.path, "utf8");
927
+ } catch {
928
+ return null;
929
+ }
930
+ const willTransform = transform === true || typeof transform === "function" && transform(args.path);
931
+ let cjsExports;
932
+ if (parseCJS && willTransform) {
933
+ let sourcemapIndex = contents.lastIndexOf("//# sourceMappingURL=");
934
+ let sourcemap;
935
+ if (sourcemapIndex !== -1) {
936
+ sourcemap = contents.slice(sourcemapIndex);
937
+ let sourcemapEnd = sourcemap.indexOf("\n");
938
+ if (sourcemapEnd !== -1 && sourcemap.slice(sourcemapEnd + 1).trimStart().length > 0) {
939
+ sourcemap = void 0;
940
+ } else {
941
+ contents = contents.slice(0, sourcemapIndex);
942
+ }
943
+ }
944
+ cjsExports = parseCJS(contents);
945
+ let { behavior, exports: exports22, sideEffects } = typeof willTransform === "object" ? willTransform : {};
946
+ behavior ?? (behavior = (transformConfig == null ? void 0 : transformConfig.behavior) ?? "node");
947
+ exports22 = orderedUniq(cjsExports.exports.concat(exports22 ?? []));
948
+ sideEffects ?? (sideEffects = (transformConfig == null ? void 0 : transformConfig.sideEffects) ?? true);
949
+ let exportDefault = behavior === "node" ? "export default exports;" : "export default exports.__esModule ? exports.default : exports;";
950
+ let exportsMap = exports22.map((e) => [e, makeLegalIdentifier(e)]);
951
+ if (exportsMap.some(([e]) => e === "default")) {
952
+ if (behavior === "node") {
953
+ exportsMap = exportsMap.filter(([e]) => e !== "default");
954
+ } else {
955
+ exportDefault = "";
956
+ }
957
+ }
958
+ let reexports = cjsExports.reexports.map((e) => `export * from ${JSON.stringify(e)};`).join("");
959
+ let transformed;
960
+ if (sideEffects === false) {
961
+ transformed = [
962
+ // make sure we don't manipulate the first line so that sourcemap is fine
963
+ reexports + "var mod, exports = /* @__PURE__ */ ((exports, module) => {" + contents,
964
+ "return module.exports})((mod = { exports: {} }).exports, mod); " + exportDefault
965
+ ];
966
+ if (exportsMap.length > 0) {
967
+ for (const [e, name] of exportsMap) {
968
+ transformed.push(`var ${name} = /* @__PURE__ */ (() => exports[${JSON.stringify(e)}])();`);
969
+ }
970
+ transformed.push(
971
+ `export { ${exportsMap.map(([e, name]) => e === name ? e : `${name} as ${JSON.stringify(e)}`).join(", ")} };`
972
+ );
973
+ }
974
+ } else {
975
+ transformed = [
976
+ reexports + "var exports = {}, module = { exports }; {" + contents,
977
+ "}; exports = module.exports; " + exportDefault
978
+ ];
979
+ if (exportsMap.length > 0) {
980
+ transformed.push(
981
+ `var { ${exportsMap.map(([e, name]) => e === name ? e : `${JSON.stringify(e)}: ${name}`).join(", ")} } = exports;`,
982
+ `export { ${exportsMap.map(([e, name]) => e === name ? e : `${name} as ${JSON.stringify(e)}`).join(", ")} };`
983
+ );
984
+ }
985
+ }
986
+ contents = transformed.join("\n") + (sourcemap ? "\n" + sourcemap : "");
987
+ }
988
+ function makeName(path) {
989
+ let name = `__import_${makeLegalIdentifier(path)}`;
990
+ if (contents.includes(name)) {
991
+ let suffix = 2;
992
+ while (contents.includes(`${name}${suffix}`)) suffix++;
993
+ name = `${name}${suffix}`;
994
+ }
995
+ return name;
996
+ }
997
+ let warnings;
998
+ try {
999
+ ({ warnings } = await require_esbuild().transform(contents, { format: "esm", logLevel: "silent" }));
1000
+ } catch (err) {
1001
+ ({ warnings } = err);
1002
+ }
1003
+ let lines = contents.split("\n");
1004
+ let getOffset = cachedReduce(lines, (a, b) => a + 1 + b.length, 0);
1005
+ if (warnings && (warnings = warnings.filter((e) => e.text.includes('"require" to "esm"'))).length) {
1006
+ let edits = [];
1007
+ let imports = [];
1008
+ for (const { location } of warnings) {
1009
+ if (location === null) continue;
1010
+ const { line, lineText, column, length } = location;
1011
+ const leftBrace = column + length + 1;
1012
+ const path = lexer.readString(lineText, leftBrace);
1013
+ if (path === null || is_ignored(path)) continue;
1014
+ const rightBrace = lineText.indexOf(")", leftBrace + 2 + path.length) + 1;
1015
+ let name = makeName(path);
1016
+ let import_statement;
1017
+ if (use_default_export(path)) {
1018
+ import_statement = `import ${name} from ${JSON.stringify(path)};`;
1019
+ } else {
1020
+ import_statement = `import * as ${name} from ${JSON.stringify(path)};`;
1021
+ }
1022
+ let offset2 = getOffset(line - 1);
1023
+ edits.push([offset2 + column, offset2 + rightBrace, name]);
1024
+ imports.push(import_statement);
1025
+ }
1026
+ if (imports.length === 0) return null;
1027
+ imports = orderedUniq(imports);
1028
+ let offset = 0;
1029
+ for (const [start, end, name] of edits) {
1030
+ contents = contents.slice(0, start + offset) + name + contents.slice(end + offset);
1031
+ offset += name.length - (end - start);
1032
+ }
1033
+ contents = prepend(contents, [...imports, cjsExports ? "exports;" : ""].join(""));
1034
+ return { contents };
1035
+ }
1036
+ });
1037
+ }
1038
+ };
1039
+ }
1040
+ var index_default = commonjs;
1041
+ }
1042
+ });
1043
+
1044
+ // ../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__27cd8c2707e42da8a6ff3e707ec47ae0/node_modules/tsup/dist/index.js
1045
+ var require_dist = __commonJS({
1046
+ "../../node_modules/.pnpm/tsup@8.4.0_patch_hash=751a554d775c3572381af4e7e5fa22eeda6dd6856012fb1cf521d6806eb2dc74__27cd8c2707e42da8a6ff3e707ec47ae0/node_modules/tsup/dist/index.js"(exports2) {
1047
+ "use strict";
1048
+ init_cjs_shims();
1049
+ Object.defineProperty(exports2, "__esModule", { value: true });
1050
+ function _interopRequireWildcard(obj) {
1051
+ if (obj && obj.__esModule) {
1052
+ return obj;
1053
+ } else {
1054
+ var newObj = {};
1055
+ if (obj != null) {
1056
+ for (var key in obj) {
1057
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
1058
+ newObj[key] = obj[key];
1059
+ }
1060
+ }
1061
+ }
1062
+ newObj.default = obj;
1063
+ return newObj;
1064
+ }
1065
+ }
1066
+ function _interopRequireDefault(obj) {
1067
+ return obj && obj.__esModule ? obj : { default: obj };
1068
+ }
1069
+ function _nullishCoalesce(lhs, rhsFn) {
1070
+ if (lhs != null) {
1071
+ return lhs;
1072
+ } else {
1073
+ return rhsFn();
1074
+ }
1075
+ }
1076
+ function _optionalChain(ops) {
1077
+ let lastAccessLHS = void 0;
1078
+ let value = ops[0];
1079
+ let i = 1;
1080
+ while (i < ops.length) {
1081
+ const op = ops[i];
1082
+ const fn = ops[i + 1];
1083
+ i += 2;
1084
+ if ((op === "optionalAccess" || op === "optionalCall") && value == null) {
1085
+ return void 0;
1086
+ }
1087
+ if (op === "access" || op === "optionalAccess") {
1088
+ lastAccessLHS = value;
1089
+ value = fn(value);
1090
+ } else if (op === "call" || op === "optionalCall") {
1091
+ value = fn((...args) => value.call(lastAccessLHS, ...args));
1092
+ lastAccessLHS = void 0;
1093
+ }
1094
+ }
1095
+ return value;
1096
+ }
1097
+ var _class;
1098
+ var _chunkBYH4XDRHjs = require_chunk_BYH4XDRH();
1099
+ var _chunkVGC3FXLUjs = require_chunk_VGC3FXLU();
1100
+ var _chunkJZ25TPTYjs = require_chunk_JZ25TPTY();
1101
+ var _chunkTWFEYLU4js = require_chunk_TWFEYLU4();
1102
+ var _commonjsPluginjs = require_commonjs_plugin();
1103
+ var _path = require("path");
1104
+ var _path2 = _interopRequireDefault(_path);
1105
+ var _fs = require("fs");
1106
+ var _fs2 = _interopRequireDefault(_fs);
1107
+ var _worker_threads = require("worker_threads");
1108
+ var _bundlerequire = require("bundle-require");
1109
+ var _tinyexec = require("tinyexec");
1110
+ var _tinyglobby = require("tinyglobby");
1111
+ var _treekill = require("tree-kill");
1112
+ var _treekill2 = _interopRequireDefault(_treekill);
1113
+ var _esbuild = require("esbuild");
1114
+ var _consola = require("consola");
1115
+ var _consola2 = _interopRequireDefault(_consola);
1116
+ var nodeProtocolPlugin = () => {
1117
+ const nodeProtocol = "node:";
1118
+ return {
1119
+ name: "node-protocol-plugin",
1120
+ setup({ onResolve }) {
1121
+ onResolve(
1122
+ {
1123
+ filter: /^node:/
1124
+ },
1125
+ ({ path: path12 }) => ({
1126
+ path: path12.slice(nodeProtocol.length),
1127
+ external: true
1128
+ })
1129
+ );
1130
+ }
1131
+ };
1132
+ };
1133
+ var NON_NODE_MODULE_RE = /^[A-Z]:[/\\]|^\.{0,2}\/|^\.{1,2}$/;
1134
+ var externalPlugin = ({
1135
+ external,
1136
+ noExternal,
1137
+ skipNodeModulesBundle,
1138
+ tsconfigResolvePaths
1139
+ }) => {
1140
+ return {
1141
+ name: `external`,
1142
+ setup(build22) {
1143
+ if (skipNodeModulesBundle) {
1144
+ const resolvePatterns = _bundlerequire.tsconfigPathsToRegExp.call(
1145
+ void 0,
1146
+ tsconfigResolvePaths || {}
1147
+ );
1148
+ build22.onResolve({ filter: /.*/ }, (args) => {
1149
+ if (_bundlerequire.match.call(void 0, args.path, resolvePatterns)) {
1150
+ return;
1151
+ }
1152
+ if (_bundlerequire.match.call(void 0, args.path, noExternal)) {
1153
+ return;
1154
+ }
1155
+ if (_bundlerequire.match.call(void 0, args.path, external)) {
1156
+ return { external: true };
1157
+ }
1158
+ if (!NON_NODE_MODULE_RE.test(args.path)) {
1159
+ return {
1160
+ path: args.path,
1161
+ external: true
1162
+ };
1163
+ }
1164
+ });
1165
+ } else {
1166
+ build22.onResolve({ filter: /.*/ }, (args) => {
1167
+ if (_bundlerequire.match.call(void 0, args.path, noExternal)) {
1168
+ return;
1169
+ }
1170
+ if (_bundlerequire.match.call(void 0, args.path, external)) {
1171
+ return { external: true };
1172
+ }
1173
+ });
1174
+ }
1175
+ }
1176
+ };
1177
+ };
1178
+ var postcssPlugin = ({
1179
+ options: options2,
1180
+ css,
1181
+ inject,
1182
+ cssLoader
1183
+ }) => {
1184
+ return {
1185
+ name: "postcss",
1186
+ setup(build22) {
1187
+ let configCache;
1188
+ const getPostcssConfig = async () => {
1189
+ const loadConfig = _chunkTWFEYLU4js.__require.call(void 0, "postcss-load-config");
1190
+ if (configCache) {
1191
+ return configCache;
1192
+ }
1193
+ try {
1194
+ const result = await loadConfig({}, options2.workspaceConfig?.workspaceRoot || process.cwd());
1195
+ configCache = result;
1196
+ return result;
1197
+ } catch (error) {
1198
+ if (error.message.includes("No PostCSS Config found in")) {
1199
+ const result = { plugins: [], options: {} };
1200
+ return result;
1201
+ }
1202
+ throw error;
1203
+ }
1204
+ };
1205
+ build22.onResolve({ filter: /^#style-inject$/ }, () => {
1206
+ return { path: "#style-inject", namespace: "#style-inject" };
1207
+ });
1208
+ build22.onLoad(
1209
+ { filter: /^#style-inject$/, namespace: "#style-inject" },
1210
+ () => {
1211
+ return {
1212
+ // Taken from https://github.com/egoist/style-inject/blob/master/src/index.js (MIT)
1213
+ contents: `
1214
+ export default function styleInject(css, { insertAt } = {}) {
1215
+ if (!css || typeof document === 'undefined') return
1216
+
1217
+ const head = document.head || document.getElementsByTagName('head')[0]
1218
+ const style = document.createElement('style')
1219
+ style.type = 'text/css'
1220
+
1221
+ if (insertAt === 'top') {
1222
+ if (head.firstChild) {
1223
+ head.insertBefore(style, head.firstChild)
1224
+ } else {
1225
+ head.appendChild(style)
1226
+ }
1227
+ } else {
1228
+ head.appendChild(style)
1229
+ }
1230
+
1231
+ if (style.styleSheet) {
1232
+ style.styleSheet.cssText = css
1233
+ } else {
1234
+ style.appendChild(document.createTextNode(css))
1235
+ }
1236
+ }
1237
+ `,
1238
+ loader: "js"
1239
+ };
1240
+ }
1241
+ );
1242
+ build22.onLoad({ filter: /\.css$/ }, async (args) => {
1243
+ let contents;
1244
+ if (css && args.path.endsWith(".svelte.css")) {
1245
+ contents = css.get(args.path);
1246
+ } else {
1247
+ contents = await _fs2.default.promises.readFile(args.path, "utf8");
1248
+ }
1249
+ const { plugins, options: options3 } = await getPostcssConfig();
1250
+ if (plugins && plugins.length > 0) {
1251
+ const postcss = _chunkTWFEYLU4js.getPostcss.call(void 0);
1252
+ if (!postcss) {
1253
+ return {
1254
+ errors: [
1255
+ {
1256
+ text: `postcss is not installed`
1257
+ }
1258
+ ]
1259
+ };
1260
+ }
1261
+ const result = await _optionalChain([postcss, "optionalAccess", (_2) => _2.default, "call", (_3) => _3(plugins), "access", (_4) => _4.process, "call", (_5) => _5(contents, { ...options3, from: args.path })]);
1262
+ contents = result.css;
1263
+ }
1264
+ if (inject) {
1265
+ contents = (await _esbuild.transform.call(void 0, contents, {
1266
+ minify: build22.initialOptions.minify,
1267
+ minifyIdentifiers: build22.initialOptions.minifyIdentifiers,
1268
+ minifySyntax: build22.initialOptions.minifySyntax,
1269
+ minifyWhitespace: build22.initialOptions.minifyWhitespace,
1270
+ logLevel: build22.initialOptions.logLevel,
1271
+ loader: "css"
1272
+ })).code;
1273
+ contents = typeof inject === "function" ? await inject(JSON.stringify(contents), args.path) : `import styleInject from '#style-inject';styleInject(${JSON.stringify(
1274
+ contents
1275
+ )})`;
1276
+ return {
1277
+ contents,
1278
+ loader: "js"
1279
+ };
1280
+ }
1281
+ return {
1282
+ contents,
1283
+ loader: _nullishCoalesce(cssLoader, () => "css")
1284
+ };
1285
+ });
1286
+ }
1287
+ };
1288
+ };
1289
+ var useSvelteCssExtension = (p) => p.replace(/\.svelte$/, ".svelte.css");
1290
+ var sveltePlugin = ({
1291
+ css,
1292
+ options: options2
1293
+ }) => {
1294
+ return {
1295
+ name: "svelte",
1296
+ setup(build22) {
1297
+ let svelte;
1298
+ let sveltePreprocessor;
1299
+ build22.onResolve({ filter: /\.svelte\.css$/ }, (args) => {
1300
+ return {
1301
+ path: _path2.default.relative(
1302
+ options2.workspaceConfig?.workspaceRoot || process.cwd(),
1303
+ _path2.default.join(args.resolveDir, args.path)
1304
+ ),
1305
+ namespace: "svelte-css"
1306
+ };
1307
+ });
1308
+ build22.onLoad({ filter: /\.svelte$/ }, async (args) => {
1309
+ svelte = svelte || _chunkTWFEYLU4js.localRequire.call(void 0, "svelte/compiler");
1310
+ sveltePreprocessor = sveltePreprocessor || _chunkTWFEYLU4js.localRequire.call(void 0, "svelte-preprocess");
1311
+ if (!svelte) {
1312
+ return {
1313
+ errors: [{ text: `You need to install "svelte" in your project` }]
1314
+ };
1315
+ }
1316
+ const convertMessage = ({ message, start, end }) => {
1317
+ let location;
1318
+ if (start && end) {
1319
+ const lineText = source.split(/\r\n|\r|\n/g)[start.line - 1];
1320
+ const lineEnd = start.line === end.line ? end.column : lineText.length;
1321
+ location = {
1322
+ file: filename,
1323
+ line: start.line,
1324
+ column: start.column,
1325
+ length: lineEnd - start.column,
1326
+ lineText
1327
+ };
1328
+ }
1329
+ return { text: message, location };
1330
+ };
1331
+ const source = await _fs2.default.promises.readFile(args.path, "utf8");
1332
+ const filename = _path2.default.relative(options2.workspaceConfig?.workspaceRoot || process.cwd(), args.path);
1333
+ try {
1334
+ const preprocess = await svelte.preprocess(
1335
+ source,
1336
+ sveltePreprocessor ? sveltePreprocessor({
1337
+ sourceMap: true,
1338
+ typescript: {
1339
+ compilerOptions: {
1340
+ verbatimModuleSyntax: true
1341
+ }
1342
+ }
1343
+ }) : {
1344
+ async script({ content, attributes }) {
1345
+ if (attributes.lang !== "ts") return { code: content };
1346
+ const { code, map } = await _esbuild.transform.call(void 0, content, {
1347
+ sourcefile: args.path,
1348
+ loader: "ts",
1349
+ sourcemap: true,
1350
+ tsconfigRaw: {
1351
+ compilerOptions: {
1352
+ verbatimModuleSyntax: true
1353
+ }
1354
+ },
1355
+ logLevel: build22.initialOptions.logLevel
1356
+ });
1357
+ return {
1358
+ code,
1359
+ map
1360
+ };
1361
+ }
1362
+ },
1363
+ {
1364
+ filename: args.path
1365
+ }
1366
+ );
1367
+ const result = svelte.compile(preprocess.code, {
1368
+ filename,
1369
+ css: "external"
1370
+ });
1371
+ let contents = result.js.code;
1372
+ if (css && result.css && result.css.code) {
1373
+ const cssPath = useSvelteCssExtension(filename);
1374
+ css.set(cssPath, result.css.code);
1375
+ contents = `import '${useSvelteCssExtension(_path2.default.basename(args.path))}';${contents}`;
1376
+ }
1377
+ return { contents, warnings: result.warnings.map(convertMessage) };
1378
+ } catch (error) {
1379
+ return { errors: [convertMessage(error)] };
1380
+ }
1381
+ });
1382
+ }
1383
+ };
1384
+ };
1385
+ var nativeNodeModulesPlugin = () => {
1386
+ return {
1387
+ name: "native-node-modules",
1388
+ setup(build22) {
1389
+ build22.onResolve({ filter: /\.node$/, namespace: "file" }, (args) => {
1390
+ const resolvedId = _chunkTWFEYLU4js.__require.resolve(args.path, {
1391
+ paths: [args.resolveDir]
1392
+ });
1393
+ if (resolvedId.endsWith(".node")) {
1394
+ return {
1395
+ path: resolvedId,
1396
+ namespace: "node-file"
1397
+ };
1398
+ }
1399
+ return {
1400
+ path: resolvedId
1401
+ };
1402
+ });
1403
+ build22.onLoad({ filter: /.*/, namespace: "node-file" }, (args) => {
1404
+ return {
1405
+ contents: `
1406
+ import path from ${JSON.stringify(args.path)}
1407
+ try { module.exports = require(path) }
1408
+ catch {}
1409
+ `,
1410
+ resolveDir: _path2.default.dirname(args.path)
1411
+ };
1412
+ });
1413
+ build22.onResolve(
1414
+ { filter: /\.node$/, namespace: "node-file" },
1415
+ (args) => ({
1416
+ path: args.path,
1417
+ namespace: "file"
1418
+ })
1419
+ );
1420
+ const opts = build22.initialOptions;
1421
+ opts.loader = opts.loader || {};
1422
+ opts.loader[".node"] = "file";
1423
+ }
1424
+ };
1425
+ };
1426
+ var getOutputExtensionMap = (options2, format, pkgType) => {
1427
+ const outExtension = options2.outExtension || _chunkTWFEYLU4js.defaultOutExtension;
1428
+ const defaultExtension = _chunkTWFEYLU4js.defaultOutExtension.call(void 0, { format, pkgType });
1429
+ const extension = outExtension({ options: options2, format, pkgType });
1430
+ return {
1431
+ ".js": extension.js || defaultExtension.js
1432
+ };
1433
+ };
1434
+ var generateExternal = async (external) => {
1435
+ const result = [];
1436
+ for (const item of external) {
1437
+ if (typeof item !== "string" || !item.endsWith("package.json")) {
1438
+ result.push(item);
1439
+ continue;
1440
+ }
1441
+ const pkgPath = _path2.default.isAbsolute(item) ? _path2.default.dirname(item) : _path2.default.dirname(_path2.default.resolve(options.workspaceConfig?.workspaceRoot || process.cwd(), item));
1442
+ const deps = await _chunkVGC3FXLUjs.getProductionDeps.call(void 0, pkgPath);
1443
+ result.push(...deps);
1444
+ }
1445
+ return result;
1446
+ };
1447
+ async function runEsbuild(options2, {
1448
+ format,
1449
+ css,
1450
+ logger: logger3,
1451
+ buildDependencies,
1452
+ pluginContainer
1453
+ }) {
1454
+ const pkg = await _chunkVGC3FXLUjs.loadPkg.call(void 0, options2.workspaceConfig?.workspaceRoot || process.cwd());
1455
+ const deps = await _chunkVGC3FXLUjs.getProductionDeps.call(void 0, options2.workspaceConfig?.workspaceRoot || process.cwd());
1456
+ const external = [
1457
+ // Exclude dependencies, e.g. `lodash`, `lodash/get`
1458
+ ...deps.map((dep) => new RegExp(`^${dep}($|\\/|\\\\)`)),
1459
+ ...await generateExternal(options2.external || [])
1460
+ ];
1461
+ const outDir = options2.outDir;
1462
+ const outExtension = getOutputExtensionMap(options2, format, pkg.type);
1463
+ const env = {
1464
+ ...options2.env
1465
+ };
1466
+ if (options2.replaceNodeEnv) {
1467
+ env.NODE_ENV = options2.minify || options2.minifyWhitespace ? "production" : "development";
1468
+ }
1469
+ logger3.info(format, "Build start");
1470
+ const startTime = Date.now();
1471
+ let result;
1472
+ const splitting = format === "iife" ? false : typeof options2.splitting === "boolean" ? options2.splitting : format === "esm";
1473
+ const platform = options2.platform || "node";
1474
+ const loader = options2.loader || {};
1475
+ const injectShims = options2.shims;
1476
+ const bundle = typeof options2.bundle === "undefined" ? true : options2.bundle;
1477
+ pluginContainer.setContext({
1478
+ format,
1479
+ splitting,
1480
+ options: options2,
1481
+ logger: logger3
1482
+ });
1483
+ await pluginContainer.buildStarted();
1484
+ const esbuildPlugins = [
1485
+ format === "cjs" && options2.removeNodeProtocol && nodeProtocolPlugin(),
1486
+ format === "esm" && bundle && _commonjsPluginjs.commonjs.call(void 0),
1487
+ {
1488
+ name: "modify-options",
1489
+ setup(build22) {
1490
+ pluginContainer.modifyEsbuildOptions(build22.initialOptions);
1491
+ if (options2.esbuildOptions) {
1492
+ options2.esbuildOptions(build22.initialOptions, { format });
1493
+ }
1494
+ }
1495
+ },
1496
+ // esbuild's `external` option doesn't support RegExp
1497
+ // So here we use a custom plugin to implement it
1498
+ format !== "iife" && externalPlugin({
1499
+ external,
1500
+ noExternal: options2.noExternal,
1501
+ skipNodeModulesBundle: options2.skipNodeModulesBundle,
1502
+ tsconfigResolvePaths: options2.tsconfigResolvePaths
1503
+ }),
1504
+ // options.tsconfigDecoratorMetadata && swcPlugin({ logger: logger3 }),
1505
+ nativeNodeModulesPlugin(),
1506
+ postcssPlugin({
1507
+ options: options2,
1508
+ css,
1509
+ inject: options2.injectStyle,
1510
+ cssLoader: loader[".css"]
1511
+ }),
1512
+ sveltePlugin({ css, options: options2 }),
1513
+ ...options2.esbuildPlugins || []
1514
+ ];
1515
+ const banner = typeof options2.banner === "function" ? options2.banner({ format }) : options2.banner;
1516
+ const footer = typeof options2.footer === "function" ? options2.footer({ format }) : options2.footer;
1517
+ try {
1518
+ result = await _esbuild.build.call(void 0, {
1519
+ entryPoints: options2.entry,
1520
+ format: format === "cjs" && splitting || options2.treeshake ? "esm" : format,
1521
+ bundle,
1522
+ platform,
1523
+ globalName: options2.globalName,
1524
+ jsxFactory: options2.jsxFactory,
1525
+ jsxFragment: options2.jsxFragment,
1526
+ sourcemap: options2.sourcemap ? "external" : false,
1527
+ target: options2.target,
1528
+ banner,
1529
+ footer,
1530
+ tsconfig: options2.tsconfig,
1531
+ loader: {
1532
+ ".aac": "file",
1533
+ ".css": "file",
1534
+ ".eot": "file",
1535
+ ".flac": "file",
1536
+ ".gif": "file",
1537
+ ".jpeg": "file",
1538
+ ".jpg": "file",
1539
+ ".mp3": "file",
1540
+ ".mp4": "file",
1541
+ ".ogg": "file",
1542
+ ".otf": "file",
1543
+ ".png": "file",
1544
+ ".svg": "file",
1545
+ ".ttf": "file",
1546
+ ".wav": "file",
1547
+ ".webm": "file",
1548
+ ".webp": "file",
1549
+ ".woff": "file",
1550
+ ".woff2": "file",
1551
+ ...loader
1552
+ },
1553
+ mainFields: platform === "node" ? ["module", "main"] : ["browser", "module", "main"],
1554
+ plugins: esbuildPlugins.filter(_chunkTWFEYLU4js.truthy),
1555
+ define: {
1556
+ TSUP_FORMAT: JSON.stringify(format),
1557
+ ...format === "cjs" && injectShims ? {
1558
+ "import.meta.url": "importMetaUrl"
1559
+ } : {},
1560
+ ...options2.define,
1561
+ ...Object.keys(env).reduce((res, key) => {
1562
+ const value = JSON.stringify(env[key]);
1563
+ return {
1564
+ ...res,
1565
+ [`process.env.${key}`]: value,
1566
+ [`import.meta.env.${key}`]: value
1567
+ };
1568
+ }, {})
1569
+ },
1570
+ inject: [
1571
+ format === "cjs" && injectShims ? _path2.default.join(__dirname, "../assets/cjs_shims.js") : "",
1572
+ format === "esm" && injectShims && platform === "node" ? _path2.default.join(__dirname, "../assets/esm_shims.js") : "",
1573
+ ...options2.inject || []
1574
+ ].filter(Boolean),
1575
+ outdir: options2.legacyOutput && format !== "cjs" ? _path2.default.join(outDir, format) : outDir,
1576
+ outExtension: options2.legacyOutput ? void 0 : outExtension,
1577
+ write: false,
1578
+ splitting,
1579
+ logLevel: "error",
1580
+ minify: options2.minify === "terser" ? false : options2.minify,
1581
+ minifyWhitespace: options2.minifyWhitespace,
1582
+ minifyIdentifiers: options2.minifyIdentifiers,
1583
+ minifySyntax: options2.minifySyntax,
1584
+ keepNames: options2.keepNames,
1585
+ pure: typeof options2.pure === "string" ? [options2.pure] : options2.pure,
1586
+ metafile: true
1587
+ });
1588
+ } catch (error) {
1589
+ logger3.error(format, "Build failed");
1590
+ throw error;
1591
+ }
1592
+ if (result && result.warnings && !_chunkVGC3FXLUjs.getSilent.call(void 0)) {
1593
+ const messages = result.warnings.filter((warning) => {
1594
+ if (warning.text.includes(
1595
+ `This call to "require" will not be bundled because`
1596
+ ) || warning.text.includes(`Indirect calls to "require" will not be bundled`))
1597
+ return false;
1598
+ return true;
1599
+ });
1600
+ const formatted = await _esbuild.formatMessages.call(void 0, messages, {
1601
+ kind: "warning",
1602
+ color: true
1603
+ });
1604
+ formatted.forEach((message) => {
1605
+ _consola2.default.warn(message);
1606
+ });
1607
+ }
1608
+ if (result && result.outputFiles) {
1609
+ await pluginContainer.buildFinished({
1610
+ options: options2,
1611
+ outputFiles: result.outputFiles,
1612
+ metafile: result.metafile
1613
+ });
1614
+ const timeInMs = Date.now() - startTime;
1615
+ logger3.success(format, `\u26A1\uFE0F Build success in ${Math.floor(timeInMs)}ms`);
1616
+ }
1617
+ if (result.metafile) {
1618
+ for (const file of Object.keys(result.metafile.inputs)) {
1619
+ buildDependencies.add(file);
1620
+ }
1621
+ if (options2.metafile) {
1622
+ const outPath = _path2.default.resolve(outDir, `metafile-${format}.json`);
1623
+ await _fs2.default.promises.mkdir(_path2.default.dirname(outPath), { recursive: true });
1624
+ await _fs2.default.promises.writeFile(
1625
+ outPath,
1626
+ JSON.stringify(result.metafile),
1627
+ "utf8"
1628
+ );
1629
+ }
1630
+ }
1631
+ }
1632
+ var shebang = () => {
1633
+ return {
1634
+ name: "shebang",
1635
+ renderChunk(_, info) {
1636
+ if (info.type === "chunk" && /\.(cjs|js|mjs)$/.test(info.path) && info.code.startsWith("#!")) {
1637
+ info.mode = 493;
1638
+ }
1639
+ }
1640
+ };
1641
+ };
1642
+ var cjsSplitting = () => {
1643
+ return {
1644
+ name: "cjs-splitting",
1645
+ async renderChunk(code, info) {
1646
+ if (!this.splitting || this.options.treeshake || // <-- handled by rollup
1647
+ this.format !== "cjs" || info.type !== "chunk" || !/\.(js|cjs)$/.test(info.path)) {
1648
+ return;
1649
+ }
1650
+ const { transform: transform3 } = await Promise.resolve().then(() => _interopRequireWildcard(require("sucrase")));
1651
+ const result = transform3(code, {
1652
+ filePath: info.path,
1653
+ transforms: ["imports"],
1654
+ sourceMapOptions: this.options.sourcemap ? {
1655
+ compiledFilename: info.path
1656
+ } : void 0
1657
+ });
1658
+ return {
1659
+ code: result.code,
1660
+ map: result.sourceMap
1661
+ };
1662
+ }
1663
+ };
1664
+ };
1665
+ var _sourcemap = require("source-map");
1666
+ var outputFile = async (filepath, data, options2) => {
1667
+ await _fs2.default.promises.mkdir(_path2.default.dirname(filepath), { recursive: true });
1668
+ await _fs2.default.promises.writeFile(filepath, data, options2);
1669
+ };
1670
+ function copyDirSync(srcDir, destDir) {
1671
+ if (!_fs2.default.existsSync(srcDir)) return;
1672
+ _fs2.default.mkdirSync(destDir, { recursive: true });
1673
+ for (const file of _fs2.default.readdirSync(srcDir)) {
1674
+ const srcFile = _path2.default.resolve(srcDir, file);
1675
+ if (srcFile === destDir) {
1676
+ continue;
1677
+ }
1678
+ const destFile = _path2.default.resolve(destDir, file);
1679
+ const stat = _fs2.default.statSync(srcFile);
1680
+ if (stat.isDirectory()) {
1681
+ copyDirSync(srcFile, destFile);
1682
+ } else {
1683
+ _fs2.default.copyFileSync(srcFile, destFile);
1684
+ }
1685
+ }
1686
+ }
1687
+ var parseSourceMap = (map) => {
1688
+ return typeof map === "string" ? JSON.parse(map) : map;
1689
+ };
1690
+ var isJS = (path12) => /\.(js|mjs|cjs)$/.test(path12);
1691
+ var isCSS = (path12) => /\.css$/.test(path12);
1692
+ var PluginContainer = class {
1693
+ constructor(plugins) {
1694
+ this.plugins = plugins;
1695
+ }
1696
+ setContext(context) {
1697
+ this.context = context;
1698
+ }
1699
+ getContext() {
1700
+ if (!this.context) throw new Error(`Plugin context is not set`);
1701
+ return this.context;
1702
+ }
1703
+ modifyEsbuildOptions(options2) {
1704
+ for (const plugin of this.plugins) {
1705
+ if (plugin.esbuildOptions) {
1706
+ plugin.esbuildOptions.call(this.getContext(), options2);
1707
+ }
1708
+ }
1709
+ }
1710
+ async buildStarted() {
1711
+ for (const plugin of this.plugins) {
1712
+ if (plugin.buildStart) {
1713
+ await plugin.buildStart.call(this.getContext());
1714
+ }
1715
+ }
1716
+ }
1717
+ async buildFinished({
1718
+ options: options2,
1719
+ outputFiles,
1720
+ metafile
1721
+ }) {
1722
+ const files = outputFiles.filter((file) => !file.path.endsWith(".map")).map((file) => {
1723
+ if (isJS(file.path) || isCSS(file.path)) {
1724
+ const relativePath = _chunkTWFEYLU4js.slash.call(void 0, _path2.default.relative(options2.workspaceConfig?.workspaceRoot || process.cwd(), file.path));
1725
+ const meta = _optionalChain([metafile, "optionalAccess", (_6) => _6.outputs, "access", (_7) => _7[relativePath]]);
1726
+ return {
1727
+ type: "chunk",
1728
+ path: file.path,
1729
+ code: file.text,
1730
+ map: _optionalChain([outputFiles, "access", (_8) => _8.find, "call", (_9) => _9((f) => f.path === `${file.path}.map`), "optionalAccess", (_10) => _10.text]),
1731
+ entryPoint: _optionalChain([meta, "optionalAccess", (_11) => _11.entryPoint]),
1732
+ exports: _optionalChain([meta, "optionalAccess", (_12) => _12.exports]),
1733
+ imports: _optionalChain([meta, "optionalAccess", (_13) => _13.imports])
1734
+ };
1735
+ } else {
1736
+ return { type: "asset", path: file.path, contents: file.contents };
1737
+ }
1738
+ });
1739
+ const writtenFiles = [];
1740
+ await Promise.all(
1741
+ files.map(async (info) => {
1742
+ for (const plugin of this.plugins) {
1743
+ if (info.type === "chunk" && plugin.renderChunk) {
1744
+ const result = await plugin.renderChunk.call(
1745
+ this.getContext(),
1746
+ info.code,
1747
+ info
1748
+ );
1749
+ if (result) {
1750
+ info.code = result.code;
1751
+ if (result.map) {
1752
+ try {
1753
+ const originalConsumer = await new (0, _sourcemap.SourceMapConsumer)(
1754
+ parseSourceMap(info.map)
1755
+ );
1756
+ const newConsumer = await new (0, _sourcemap.SourceMapConsumer)(
1757
+ parseSourceMap(result.map)
1758
+ );
1759
+ const generator = _sourcemap.SourceMapGenerator.fromSourceMap(newConsumer);
1760
+ generator.applySourceMap(originalConsumer, info.path);
1761
+ info.map = generator.toJSON();
1762
+ originalConsumer.destroy();
1763
+ newConsumer.destroy();
1764
+ } catch (error) {
1765
+ console.warn(
1766
+ `Failed to parse sourcemap for ${info.path}: ${error.message}`
1767
+ );
1768
+ }
1769
+ }
1770
+ }
1771
+ }
1772
+ }
1773
+ const inlineSourceMap = this.context.options.sourcemap === "inline";
1774
+ const contents = info.type === "chunk" ? info.code + getSourcemapComment(
1775
+ inlineSourceMap,
1776
+ info.map,
1777
+ info.path,
1778
+ isCSS(info.path)
1779
+ ) : info.contents;
1780
+ await outputFile(info.path, contents, {
1781
+ mode: info.type === "chunk" ? info.mode : void 0
1782
+ });
1783
+ writtenFiles.push({
1784
+ get name() {
1785
+ return _path2.default.relative(options2.workspaceConfig?.workspaceRoot || process.cwd(), info.path);
1786
+ },
1787
+ get size() {
1788
+ return contents.length;
1789
+ }
1790
+ });
1791
+ if (info.type === "chunk" && info.map && !inlineSourceMap) {
1792
+ const map = typeof info.map === "string" ? JSON.parse(info.map) : info.map;
1793
+ const outPath = `${info.path}.map`;
1794
+ const contents2 = JSON.stringify(map);
1795
+ await outputFile(outPath, contents2);
1796
+ writtenFiles.push({
1797
+ get name() {
1798
+ return _path2.default.relative(options2.workspaceConfig?.workspaceRoot || process.cwd(), outPath);
1799
+ },
1800
+ get size() {
1801
+ return contents2.length;
1802
+ }
1803
+ });
1804
+ }
1805
+ })
1806
+ );
1807
+ for (const plugin of this.plugins) {
1808
+ if (plugin.buildEnd) {
1809
+ await plugin.buildEnd.call(this.getContext(), { writtenFiles });
1810
+ }
1811
+ }
1812
+ }
1813
+ };
1814
+ var getSourcemapComment = (inline, map, filepath, isCssFile) => {
1815
+ if (!map) return "";
1816
+ const prefix = isCssFile ? "/*" : "//";
1817
+ const suffix = isCssFile ? " */" : "";
1818
+ const url = inline ? `data:application/json;base64,${Buffer.from(
1819
+ typeof map === "string" ? map : JSON.stringify(map)
1820
+ ).toString("base64")}` : `${_path2.default.basename(filepath)}.map`;
1821
+ return `${prefix}# sourceMappingURL=${url}${suffix}`;
1822
+ };
1823
+ var TARGETS = ["es5", "es3"];
1824
+ var swcTarget = () => {
1825
+ let enabled = false;
1826
+ let target;
1827
+ return {
1828
+ name: "swc-target",
1829
+ esbuildOptions(options2) {
1830
+ if (typeof options2.target === "string" && TARGETS.includes(options2.target)) {
1831
+ target = options2.target;
1832
+ options2.target = "es2020";
1833
+ enabled = true;
1834
+ }
1835
+ },
1836
+ async renderChunk(code, info) {
1837
+ if (!enabled || !/\.(cjs|mjs|js)$/.test(info.path)) {
1838
+ return;
1839
+ }
1840
+ const swc = _chunkTWFEYLU4js.localRequire.call(void 0, "@swc/core");
1841
+ if (!swc) {
1842
+ throw new (0, _chunkJZ25TPTYjs.PrettyError)(
1843
+ `@swc/core is required for ${target} target. Please install it with \`npm install @swc/core -D\``
1844
+ );
1845
+ }
1846
+ const result = await swc.transform(code, {
1847
+ filename: info.path,
1848
+ sourceMaps: this.options.sourcemap,
1849
+ minify: Boolean(this.options.minify),
1850
+ jsc: {
1851
+ target,
1852
+ parser: {
1853
+ syntax: "ecmascript"
1854
+ },
1855
+ minify: this.options.minify === true ? {
1856
+ compress: false,
1857
+ mangle: {
1858
+ reserved: this.options.globalName ? [this.options.globalName] : []
1859
+ }
1860
+ } : void 0
1861
+ },
1862
+ module: {
1863
+ type: this.format === "cjs" ? "commonjs" : "es6"
1864
+ }
1865
+ });
1866
+ return {
1867
+ code: result.code,
1868
+ map: result.map
1869
+ };
1870
+ }
1871
+ };
1872
+ };
1873
+ var sizeReporter = () => {
1874
+ return {
1875
+ name: "size-reporter",
1876
+ buildEnd({ writtenFiles }) {
1877
+ _chunkVGC3FXLUjs.reportSize.call(
1878
+ void 0,
1879
+ this.logger,
1880
+ this.format,
1881
+ writtenFiles.reduce((res, file) => {
1882
+ return {
1883
+ ...res,
1884
+ [file.name]: file.size
1885
+ };
1886
+ }, {})
1887
+ );
1888
+ }
1889
+ };
1890
+ };
1891
+ var _rollup = require("rollup");
1892
+ var treeShakingPlugin = ({
1893
+ treeshake,
1894
+ name,
1895
+ silent
1896
+ }) => {
1897
+ return {
1898
+ name: "tree-shaking",
1899
+ async renderChunk(code, info) {
1900
+ if (!treeshake || !/\.(cjs|js|mjs)$/.test(info.path)) return;
1901
+ const bundle = await _rollup.rollup.call(void 0, {
1902
+ input: [info.path],
1903
+ plugins: [
1904
+ {
1905
+ name: "tsup",
1906
+ resolveId(source) {
1907
+ if (source === info.path) return source;
1908
+ return false;
1909
+ },
1910
+ load(id) {
1911
+ if (id === info.path) return { code, map: info.map };
1912
+ }
1913
+ }
1914
+ ],
1915
+ treeshake,
1916
+ makeAbsoluteExternalsRelative: false,
1917
+ preserveEntrySignatures: "exports-only",
1918
+ onwarn: silent ? () => {
1919
+ } : void 0
1920
+ });
1921
+ const result = await bundle.generate({
1922
+ interop: "auto",
1923
+ format: this.format,
1924
+ file: info.path,
1925
+ sourcemap: !!this.options.sourcemap,
1926
+ compact: !!this.options.minify,
1927
+ name
1928
+ });
1929
+ for (const file of result.output) {
1930
+ if (file.type === "chunk" && file.fileName === _path2.default.basename(info.path)) {
1931
+ return {
1932
+ code: file.code,
1933
+ map: file.map
1934
+ };
1935
+ }
1936
+ }
1937
+ }
1938
+ };
1939
+ };
1940
+ var copyPublicDir = (publicDir, outDir) => {
1941
+ if (!publicDir) return;
1942
+ copyDirSync(_path2.default.resolve(publicDir === true ? "public" : publicDir), outDir);
1943
+ };
1944
+ var isInPublicDir = (publicDir, filePath) => {
1945
+ if (!publicDir) return false;
1946
+ const publicPath = _chunkTWFEYLU4js.slash.call(
1947
+ void 0,
1948
+ _path2.default.resolve(publicDir === true ? "public" : publicDir)
1949
+ );
1950
+ return _chunkTWFEYLU4js.slash.call(void 0, _path2.default.resolve(filePath)).startsWith(`${publicPath}/`);
1951
+ };
1952
+ var terserPlugin = ({
1953
+ minifyOptions,
1954
+ format,
1955
+ terserOptions = {},
1956
+ globalName,
1957
+ logger: logger3
1958
+ }) => {
1959
+ return {
1960
+ name: "terser",
1961
+ async renderChunk(code, info) {
1962
+ if (minifyOptions !== "terser" || !/\.(cjs|js|mjs)$/.test(info.path))
1963
+ return;
1964
+ const terser = _chunkTWFEYLU4js.localRequire.call(void 0, "terser");
1965
+ if (!terser) {
1966
+ throw new (0, _chunkJZ25TPTYjs.PrettyError)(
1967
+ "terser is required for terser minification. Please install it with `npm install terser -D`"
1968
+ );
1969
+ }
1970
+ const { minify } = terser;
1971
+ const defaultOptions = {};
1972
+ if (format === "esm") {
1973
+ defaultOptions.module = true;
1974
+ } else if (!(format === "iife" && globalName !== void 0)) {
1975
+ defaultOptions.toplevel = true;
1976
+ }
1977
+ try {
1978
+ const minifiedOutput = await minify(
1979
+ { [info.path]: code },
1980
+ { ...defaultOptions, ...terserOptions }
1981
+ );
1982
+ logger3.info("TERSER", "Minifying with Terser");
1983
+ if (!minifiedOutput.code) {
1984
+ logger3.error("TERSER", "Failed to minify with terser");
1985
+ }
1986
+ logger3.success("TERSER", "Terser Minification success");
1987
+ return { code: minifiedOutput.code, map: minifiedOutput.map };
1988
+ } catch (error) {
1989
+ logger3.error("TERSER", "Failed to minify with terser");
1990
+ logger3.error("TERSER", error);
1991
+ }
1992
+ return { code, map: info.map };
1993
+ }
1994
+ };
1995
+ };
1996
+ var _typescript = require("typescript");
1997
+ var _typescript2 = _interopRequireDefault(_typescript);
1998
+ var logger = _chunkVGC3FXLUjs.createLogger.call(void 0);
1999
+ var AliasPool = (_class = class {
2000
+ constructor() {
2001
+ _class.prototype.__init.call(this);
2002
+ }
2003
+ __init() {
2004
+ this.seen = /* @__PURE__ */ new Set();
2005
+ }
2006
+ assign(name) {
2007
+ let suffix = 0;
2008
+ let alias = name === "default" ? "default_alias" : name;
2009
+ while (this.seen.has(alias)) {
2010
+ alias = `${name}_alias_${++suffix}`;
2011
+ if (suffix >= 1e3) {
2012
+ throw new Error(
2013
+ "Alias generation exceeded limit. Possible infinite loop detected."
2014
+ );
2015
+ }
2016
+ }
2017
+ this.seen.add(alias);
2018
+ return alias;
2019
+ }
2020
+ }, _class);
2021
+ function getExports(program, fileMapping) {
2022
+ const checker = program.getTypeChecker();
2023
+ const aliasPool = new AliasPool();
2024
+ const assignAlias = aliasPool.assign.bind(aliasPool);
2025
+ function extractExports(sourceFileName) {
2026
+ const cwd = program.getCurrentDirectory();
2027
+ sourceFileName = _chunkTWFEYLU4js.toAbsolutePath.call(void 0, sourceFileName, cwd);
2028
+ const sourceFile = program.getSourceFile(sourceFileName);
2029
+ if (!sourceFile) {
2030
+ return [];
2031
+ }
2032
+ const destFileName = fileMapping.get(sourceFileName);
2033
+ if (!destFileName) {
2034
+ return [];
2035
+ }
2036
+ const moduleSymbol = checker.getSymbolAtLocation(sourceFile);
2037
+ if (!moduleSymbol) {
2038
+ return [];
2039
+ }
2040
+ const exports3 = [];
2041
+ const exportSymbols = checker.getExportsOfModule(moduleSymbol);
2042
+ exportSymbols.forEach((symbol) => {
2043
+ const name = symbol.getName();
2044
+ exports3.push({
2045
+ kind: "named",
2046
+ sourceFileName,
2047
+ destFileName,
2048
+ name,
2049
+ alias: assignAlias(name),
2050
+ isTypeOnly: false
2051
+ });
2052
+ });
2053
+ return exports3;
2054
+ }
2055
+ return program.getRootFileNames().flatMap(extractExports);
2056
+ }
2057
+ function emitDtsFiles(program, host) {
2058
+ const fileMapping = /* @__PURE__ */ new Map();
2059
+ const writeFile = (fileName, text, writeByteOrderMark, onError, sourceFiles, data) => {
2060
+ const sourceFile = _optionalChain([sourceFiles, "optionalAccess", (_14) => _14[0]]);
2061
+ const sourceFileName = _optionalChain([sourceFile, "optionalAccess", (_15) => _15.fileName]);
2062
+ if (sourceFileName && !fileName.endsWith(".map")) {
2063
+ const cwd = program.getCurrentDirectory();
2064
+ fileMapping.set(
2065
+ _chunkTWFEYLU4js.toAbsolutePath.call(void 0, sourceFileName, cwd),
2066
+ _chunkTWFEYLU4js.toAbsolutePath.call(void 0, fileName, cwd)
2067
+ );
2068
+ }
2069
+ return host.writeFile(
2070
+ fileName,
2071
+ text,
2072
+ writeByteOrderMark,
2073
+ onError,
2074
+ sourceFiles,
2075
+ data
2076
+ );
2077
+ };
2078
+ const emitResult = program.emit(void 0, writeFile, void 0, true);
2079
+ const diagnostics = _typescript2.default.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
2080
+ const diagnosticMessages = [];
2081
+ diagnostics.forEach((diagnostic) => {
2082
+ if (diagnostic.file) {
2083
+ const { line, character } = _typescript2.default.getLineAndCharacterOfPosition(
2084
+ diagnostic.file,
2085
+ diagnostic.start
2086
+ );
2087
+ const message = _typescript2.default.flattenDiagnosticMessageText(
2088
+ diagnostic.messageText,
2089
+ "\n"
2090
+ );
2091
+ diagnosticMessages.push(
2092
+ `${diagnostic.file.fileName} (${line + 1},${character + 1}): ${message}`
2093
+ );
2094
+ } else {
2095
+ const message = _typescript2.default.flattenDiagnosticMessageText(
2096
+ diagnostic.messageText,
2097
+ "\n"
2098
+ );
2099
+ diagnosticMessages.push(message);
2100
+ }
2101
+ });
2102
+ const diagnosticMessage = diagnosticMessages.join("\n");
2103
+ if (diagnosticMessage) {
2104
+ logger.error(
2105
+ "TSC",
2106
+ `Failed to emit declaration files.
2107
+
2108
+ ${diagnosticMessage}`
2109
+ );
2110
+ throw new Error("TypeScript compilation failed");
2111
+ }
2112
+ return fileMapping;
2113
+ }
2114
+ function emit(compilerOptions, tsconfig, _options) {
2115
+ const cwd = _options.workspaceConfig?.workspaceRoot || process.cwd();
2116
+ let rawTsconfig = _bundlerequire.loadTsConfig.call(void 0, cwd, tsconfig.replace(cwd, ""));
2117
+ if (!rawTsconfig) {
2118
+ rawTsconfig = _bundlerequire.loadTsConfig.call(void 0, process.cwd(), tsconfig.replace(cwd, ""));
2119
+ if (!rawTsconfig) {
2120
+ throw new Error(`Unable to find ${tsconfig || "tsconfig.json"} in ${cwd}`);
2121
+ }
2122
+ }
2123
+ const declarationDir = _chunkTWFEYLU4js.ensureTempDeclarationDir.call(void 0, _options);
2124
+ const parsedTsconfig = _typescript2.default.parseJsonConfigFileContent(
2125
+ {
2126
+ ...rawTsconfig.data,
2127
+ compilerOptions: {
2128
+ ..._optionalChain([rawTsconfig, "access", (_16) => _16.data, "optionalAccess", (_17) => _17.compilerOptions]),
2129
+ ...compilerOptions,
2130
+ // Enable declaration emit and disable javascript emit
2131
+ noEmit: false,
2132
+ declaration: true,
2133
+ declarationMap: true,
2134
+ declarationDir,
2135
+ emitDeclarationOnly: true
2136
+ }
2137
+ },
2138
+ _typescript2.default.sys,
2139
+ tsconfig ? _path.dirname.call(void 0, tsconfig) : "./"
2140
+ );
2141
+ const options2 = parsedTsconfig.options;
2142
+ const host = _typescript2.default.createCompilerHost(options2);
2143
+ const program = _typescript2.default.createProgram(
2144
+ parsedTsconfig.fileNames,
2145
+ options2,
2146
+ host
2147
+ );
2148
+ const fileMapping = emitDtsFiles(program, host);
2149
+ return getExports(program, fileMapping);
2150
+ }
2151
+ function runTypeScriptCompiler(options2) {
2152
+ try {
2153
+ const start = Date.now();
2154
+ const getDuration = () => {
2155
+ return `${Math.floor(Date.now() - start)}ms`;
2156
+ };
2157
+ logger.info("tsc", "Build start");
2158
+ const dtsOptions = options2.experimentalDts;
2159
+ const exports3 = emit(dtsOptions.compilerOptions, options2.tsconfig, options2);
2160
+ logger.success("tsc", `\u26A1\uFE0F Build success in ${getDuration()}`);
2161
+ return exports3;
2162
+ } catch (error) {
2163
+ _chunkJZ25TPTYjs.handleError.call(void 0, error);
2164
+ logger.error("tsc", "Build error");
2165
+ }
2166
+ }
2167
+ function formatAggregationExports(exports3, declarationDirPath) {
2168
+ const lines = exports3.map(
2169
+ (declaration) => formatAggregationExport(declaration, declarationDirPath)
2170
+ ).filter(_chunkTWFEYLU4js.truthy);
2171
+ if (lines.length === 0) {
2172
+ lines.push("export {};");
2173
+ }
2174
+ return `${lines.join("\n")}
2175
+ `;
2176
+ }
2177
+ function formatAggregationExport(declaration, declarationDirPath) {
2178
+ const dest = _chunkTWFEYLU4js.replaceDtsWithJsExtensions.call(
2179
+ void 0,
2180
+ `./${_path2.default.posix.normalize(
2181
+ _chunkTWFEYLU4js.slash.call(void 0, _path2.default.relative(declarationDirPath, declaration.destFileName))
2182
+ )}`
2183
+ );
2184
+ if (declaration.kind === "module") {
2185
+ return "";
2186
+ } else if (declaration.kind === "named") {
2187
+ return [
2188
+ "export",
2189
+ declaration.isTypeOnly ? "type" : "",
2190
+ "{",
2191
+ declaration.name,
2192
+ declaration.name === declaration.alias ? "" : `as ${declaration.alias}`,
2193
+ "} from",
2194
+ `'${dest}';`
2195
+ ].filter(_chunkTWFEYLU4js.truthy).join(" ");
2196
+ } else {
2197
+ throw new Error("Unknown declaration");
2198
+ }
2199
+ }
2200
+ function formatDistributionExports(exports3, fromFilePath, toFilePath) {
2201
+ let importPath = _chunkTWFEYLU4js.replaceDtsWithJsExtensions.call(
2202
+ void 0,
2203
+ _path2.default.posix.relative(
2204
+ _path2.default.posix.dirname(_path2.default.posix.normalize(_chunkTWFEYLU4js.slash.call(void 0, fromFilePath))),
2205
+ _path2.default.posix.normalize(_chunkTWFEYLU4js.slash.call(void 0, toFilePath))
2206
+ )
2207
+ );
2208
+ if (!/^\.+\//.test(importPath)) {
2209
+ importPath = `./${importPath}`;
2210
+ }
2211
+ const seen = {
2212
+ named: /* @__PURE__ */ new Set(),
2213
+ module: /* @__PURE__ */ new Set()
2214
+ };
2215
+ const lines = exports3.filter((declaration) => {
2216
+ if (declaration.kind === "module") {
2217
+ if (seen.module.has(declaration.moduleName)) {
2218
+ return false;
2219
+ }
2220
+ seen.module.add(declaration.moduleName);
2221
+ return true;
2222
+ } else if (declaration.kind === "named") {
2223
+ if (seen.named.has(declaration.name)) {
2224
+ return false;
2225
+ }
2226
+ seen.named.add(declaration.name);
2227
+ return true;
2228
+ } else {
2229
+ return false;
2230
+ }
2231
+ }).map((declaration) => formatDistributionExport(declaration, importPath)).filter(_chunkTWFEYLU4js.truthy);
2232
+ if (lines.length === 0) {
2233
+ lines.push("export {};");
2234
+ }
2235
+ return `${lines.join("\n")}
2236
+ `;
2237
+ }
2238
+ function formatDistributionExport(declaration, dest) {
2239
+ if (declaration.kind === "named") {
2240
+ return [
2241
+ "export",
2242
+ declaration.isTypeOnly ? "type" : "",
2243
+ "{",
2244
+ declaration.alias,
2245
+ declaration.name === declaration.alias ? "" : `as ${declaration.name}`,
2246
+ "} from",
2247
+ `'${dest}';`
2248
+ ].filter(_chunkTWFEYLU4js.truthy).join(" ");
2249
+ } else if (declaration.kind === "module") {
2250
+ return `export * from '${declaration.moduleName}';`;
2251
+ }
2252
+ return "";
2253
+ }
2254
+ var logger2 = _chunkVGC3FXLUjs.createLogger.call(void 0);
2255
+ function rollupDtsFile(inputFilePath, outputFilePath, tsconfigFilePath, options2) {
2256
+ const cwd = options2.workspaceConfig?.workspaceRoot || process.cwd();
2257
+ const packageJsonFullPath = _path2.default.join(cwd, "package.json");
2258
+ const configObject = {
2259
+ mainEntryPointFilePath: inputFilePath,
2260
+ apiReport: {
2261
+ enabled: false,
2262
+ // `reportFileName` is not been used. It's just to fit the requirement of API Extractor.
2263
+ reportFileName: "tsup-report.api.md"
2264
+ },
2265
+ docModel: { enabled: false },
2266
+ dtsRollup: {
2267
+ enabled: true,
2268
+ untrimmedFilePath: outputFilePath
2269
+ },
2270
+ tsdocMetadata: { enabled: false },
2271
+ compiler: {
2272
+ tsconfigFilePath
2273
+ },
2274
+ projectFolder: cwd,
2275
+ newlineKind: "lf"
2276
+ };
2277
+ const prepareOptions = {
2278
+ configObject,
2279
+ configObjectFullPath: void 0,
2280
+ packageJsonFullPath
2281
+ };
2282
+ const imported = _chunkTWFEYLU4js.getApiExtractor.call(void 0);
2283
+ if (!imported) {
2284
+ throw new Error(
2285
+ `@microsoft/api-extractor is not installed. Please install it first.`
2286
+ );
2287
+ }
2288
+ const { ExtractorConfig, Extractor } = imported;
2289
+ const extractorConfig = ExtractorConfig.prepare(prepareOptions);
2290
+ const extractorResult = Extractor.invoke(extractorConfig, {
2291
+ // Equivalent to the "--local" command-line parameter
2292
+ localBuild: true,
2293
+ // Equivalent to the "--verbose" command-line parameter
2294
+ showVerboseMessages: true
2295
+ });
2296
+ if (!extractorResult.succeeded) {
2297
+ throw new Error(
2298
+ `API Extractor completed with ${extractorResult.errorCount} errors and ${extractorResult.warningCount} warnings when processing ${inputFilePath}`
2299
+ );
2300
+ }
2301
+ }
2302
+ async function rollupDtsFiles(options2, exports3, format) {
2303
+ if (!options2.experimentalDts || !_optionalChain([options2, "access", (_18) => _18.experimentalDts, "optionalAccess", (_19) => _19.entry])) {
2304
+ return;
2305
+ }
2306
+ const declarationDir = _chunkTWFEYLU4js.ensureTempDeclarationDir.call(void 0, options2);
2307
+ const outDir = options2.outDir || "dist";
2308
+ const pkg = await _chunkVGC3FXLUjs.loadPkg.call(void 0, options2.workspaceConfig?.workspaceRoot || process.cwd());
2309
+ const dtsExtension = _chunkTWFEYLU4js.defaultOutExtension.call(void 0, { format, pkgType: pkg.type }).dts;
2310
+ const tsconfig = options2.tsconfig || "tsconfig.json";
2311
+ let dtsInputFilePath = _path2.default.join(
2312
+ declarationDir,
2313
+ `_tsup-dts-aggregation${dtsExtension}`
2314
+ );
2315
+ dtsInputFilePath = dtsInputFilePath.replace(/\.d\.mts$/, ".dmts.d.ts").replace(/\.d\.cts$/, ".dcts.d.ts");
2316
+ const dtsOutputFilePath = _path2.default.join(outDir, `_tsup-dts-rollup${dtsExtension}`);
2317
+ _chunkTWFEYLU4js.writeFileSync.call(
2318
+ void 0,
2319
+ dtsInputFilePath,
2320
+ formatAggregationExports(exports3, declarationDir, options2)
2321
+ );
2322
+ rollupDtsFile(dtsInputFilePath, dtsOutputFilePath, tsconfig, options2);
2323
+ for (let [out, sourceFileName] of Object.entries(
2324
+ options2.experimentalDts.entry
2325
+ )) {
2326
+ sourceFileName = _chunkTWFEYLU4js.toAbsolutePath.call(void 0, sourceFileName);
2327
+ const outFileName = _path2.default.join(outDir, out + dtsExtension);
2328
+ const currentExports = exports3.filter(
2329
+ (declaration) => declaration.sourceFileName === sourceFileName
2330
+ );
2331
+ _chunkTWFEYLU4js.writeFileSync.call(
2332
+ void 0,
2333
+ outFileName,
2334
+ formatDistributionExports(currentExports, outFileName, dtsOutputFilePath)
2335
+ );
2336
+ }
2337
+ }
2338
+ async function cleanDtsFiles(options2) {
2339
+ if (options2.clean) {
2340
+ await _chunkTWFEYLU4js.removeFiles.call(void 0, ["**/*.d.{ts,mts,cts}"], options2.outDir);
2341
+ }
2342
+ }
2343
+ async function runDtsRollup(options2, exports3) {
2344
+ try {
2345
+ const start = Date.now();
2346
+ const getDuration = () => {
2347
+ return `${Math.floor(Date.now() - start)}ms`;
2348
+ };
2349
+ logger2.info("dts", "Build start");
2350
+ if (!exports3) {
2351
+ throw new Error("Unexpected internal error: dts exports is not define");
2352
+ }
2353
+ await cleanDtsFiles(options2);
2354
+ for (const format of options2.format) {
2355
+ await rollupDtsFiles(options2, exports3, format);
2356
+ }
2357
+ logger2.success("dts", `\u26A1\uFE0F Build success in ${getDuration()}`);
2358
+ } catch (error) {
2359
+ _chunkJZ25TPTYjs.handleError.call(void 0, error);
2360
+ logger2.error("dts", "Build error");
2361
+ }
2362
+ }
2363
+ var cjsInterop = () => {
2364
+ return {
2365
+ name: "cjs-interop",
2366
+ renderChunk(code, info) {
2367
+ if (!this.options.cjsInterop || this.format !== "cjs" || info.type !== "chunk" || !/\.(js|cjs)$/.test(info.path) || !info.entryPoint || _optionalChain([info, "access", (_20) => _20.exports, "optionalAccess", (_21) => _21.length]) !== 1 || info.exports[0] !== "default") {
2368
+ return;
2369
+ }
2370
+ return {
2371
+ code: `${code}
2372
+ module.exports = exports.default;
2373
+ `,
2374
+ map: info.map
2375
+ };
2376
+ }
2377
+ };
2378
+ };
2379
+ var defineConfig = (options2) => options2;
2380
+ var isTaskkillCmdProcessNotFoundError = (err) => {
2381
+ return process.platform === "win32" && "cmd" in err && "code" in err && typeof err.cmd === "string" && err.cmd.startsWith("taskkill") && err.code === 128;
2382
+ };
2383
+ var killProcess = ({ pid, signal }) => new Promise((resolve, reject) => {
2384
+ _treekill2.default.call(void 0, pid, signal, (err) => {
2385
+ if (err && !isTaskkillCmdProcessNotFoundError(err)) return reject(err);
2386
+ resolve();
2387
+ });
2388
+ });
2389
+ var normalizeOptions = async (logger3, optionsFromConfigFile, optionsOverride) => {
2390
+ const _options = {
2391
+ ...optionsFromConfigFile,
2392
+ ...optionsOverride
2393
+ };
2394
+ const options2 = {
2395
+ outDir: "dist",
2396
+ removeNodeProtocol: true,
2397
+ ..._options,
2398
+ format: typeof _options.format === "string" ? [_options.format] : _options.format || ["cjs"],
2399
+ dts: typeof _options.dts === "boolean" ? _options.dts ? {} : void 0 : typeof _options.dts === "string" ? { entry: _options.dts } : _options.dts,
2400
+ experimentalDts: await _chunkTWFEYLU4js.resolveInitialExperimentalDtsConfig.call(
2401
+ void 0,
2402
+ _options.experimentalDts
2403
+ )
2404
+ };
2405
+ if (!options2.workspaceConfig)
2406
+ options2.workspaceConfig = {};
2407
+ if (!options2.workspaceConfig.workspaceRoot)
2408
+ options2.workspaceConfig.workspaceRoot = process.cwd();
2409
+ _chunkVGC3FXLUjs.setSilent.call(void 0, options2.silent);
2410
+ const entry = options2.entry || options2.entryPoints;
2411
+ if (!entry || Object.keys(entry).length === 0) {
2412
+ throw new (0, _chunkJZ25TPTYjs.PrettyError)(`No input files, try "tsup <your-file>" instead`);
2413
+ }
2414
+ if (Array.isArray(entry)) {
2415
+ options2.entry = await _tinyglobby.glob.call(void 0, entry);
2416
+ if (!options2.entry || options2.entry.length === 0) {
2417
+ throw new (0, _chunkJZ25TPTYjs.PrettyError)(`Cannot find ${entry}`);
2418
+ } else {
2419
+ logger3.info("CLI", `Building entry: ${options2.entry.join(", ")}`);
2420
+ }
2421
+ } else {
2422
+ Object.keys(entry).forEach((alias) => {
2423
+ const filename = entry[alias];
2424
+ if (!_fs2.default.existsSync(filename)) {
2425
+ throw new (0, _chunkJZ25TPTYjs.PrettyError)(`Cannot find ${alias}: ${filename}`);
2426
+ }
2427
+ });
2428
+ options2.entry = entry;
2429
+ logger3.info("CLI", `Building entry: ${JSON.stringify(entry)}`);
2430
+ }
2431
+ const tsconfig = _bundlerequire.loadTsConfig.call(void 0, options2.workspaceConfig?.workspaceRoot || process.cwd(), options2.tsconfig);
2432
+ if (tsconfig) {
2433
+ logger3.info(
2434
+ "CLI",
2435
+ `Using tsconfig: ${_path2.default.relative(options2.workspaceConfig?.workspaceRoot || process.cwd(), tsconfig.path)}`
2436
+ );
2437
+ options2.tsconfig = tsconfig.path;
2438
+ options2.tsconfigResolvePaths = _optionalChain([tsconfig, "access", (_22) => _22.data, "optionalAccess", (_23) => _23.compilerOptions, "optionalAccess", (_24) => _24.paths]) || {};
2439
+ options2.tsconfigDecoratorMetadata = _optionalChain([tsconfig, "access", (_25) => _25.data, "optionalAccess", (_26) => _26.compilerOptions, "optionalAccess", (_27) => _27.emitDecoratorMetadata]);
2440
+ if (options2.dts) {
2441
+ options2.dts.compilerOptions = {
2442
+ ...tsconfig.data.compilerOptions || {},
2443
+ ...options2.dts.compilerOptions || {}
2444
+ };
2445
+ }
2446
+ if (options2.experimentalDts) {
2447
+ options2.experimentalDts = await _chunkTWFEYLU4js.resolveExperimentalDtsConfig.call(
2448
+ void 0,
2449
+ options2,
2450
+ tsconfig
2451
+ );
2452
+ }
2453
+ if (!options2.target) {
2454
+ options2.target = _optionalChain([tsconfig, "access", (_28) => _28.data, "optionalAccess", (_29) => _29.compilerOptions, "optionalAccess", (_30) => _30.target, "optionalAccess", (_31) => _31.toLowerCase, "call", (_32) => _32()]);
2455
+ }
2456
+ } else if (options2.tsconfig) {
2457
+ throw new (0, _chunkJZ25TPTYjs.PrettyError)(`Cannot find tsconfig: ${options2.tsconfig}`);
2458
+ }
2459
+ if (!options2.target) {
2460
+ options2.target = "node16";
2461
+ }
2462
+ return options2;
2463
+ };
2464
+ async function build2(_options) {
2465
+ const config = _options.config === false ? {} : await _chunkVGC3FXLUjs.loadTsupConfig.call(
2466
+ void 0,
2467
+ _options.workspaceConfig?.workspaceRoot || process.cwd(),
2468
+ _options.config === true ? void 0 : _options.config
2469
+ );
2470
+ const configData = typeof config.data === "function" ? await config.data(_options) : config.data;
2471
+ await Promise.all(
2472
+ [...Array.isArray(configData) ? configData : [configData]].map(
2473
+ async (item) => {
2474
+ const logger3 = _chunkVGC3FXLUjs.createLogger.call(void 0, _optionalChain([item, "optionalAccess", (_33) => _33.name]));
2475
+ const options2 = await normalizeOptions(logger3, item, _options);
2476
+ logger3.info("CLI", `tsup v${_chunkBYH4XDRHjs.version}`);
2477
+ if (config.path) {
2478
+ logger3.info("CLI", `Using tsup config: ${config.path}`);
2479
+ }
2480
+ if (options2.watch) {
2481
+ logger3.info("CLI", "Running in watch mode");
2482
+ }
2483
+ const experimentalDtsTask = async () => {
2484
+ if (!options2.dts && options2.experimentalDts) {
2485
+ const exports3 = runTypeScriptCompiler(options2);
2486
+ await runDtsRollup(options2, exports3);
2487
+ }
2488
+ };
2489
+ const dtsTask = async () => {
2490
+ if (options2.dts && options2.experimentalDts) {
2491
+ throw new Error(
2492
+ "You can't use both `dts` and `experimentalDts` at the same time"
2493
+ );
2494
+ }
2495
+ await experimentalDtsTask();
2496
+ if (options2.dts) {
2497
+ await new Promise((resolve, reject) => {
2498
+ let workerPath = _path2.default.join(__dirname, "./rollup.cjs");
2499
+ if (!_fs2.default.existsSync(workerPath)) {
2500
+ workerPath = _path2.default.join(__dirname, "./rollup.js");
2501
+ }
2502
+ const worker = new (0, _worker_threads.Worker)(workerPath);
2503
+ const terminateWorker = () => {
2504
+ if (options2.watch) return;
2505
+ worker.terminate();
2506
+ };
2507
+ worker.postMessage({
2508
+ configName: _optionalChain([item, "optionalAccess", (_34) => _34.name]),
2509
+ options: {
2510
+ ...options2,
2511
+ // functions cannot be cloned
2512
+ injectStyle: typeof options2.injectStyle === "function" ? void 0 : options2.injectStyle,
2513
+ banner: void 0,
2514
+ footer: void 0,
2515
+ esbuildPlugins: void 0,
2516
+ esbuildOptions: void 0,
2517
+ plugins: void 0,
2518
+ treeshake: void 0,
2519
+ onSuccess: void 0,
2520
+ outExtension: void 0
2521
+ }
2522
+ });
2523
+ worker.on("message", (data) => {
2524
+ if (data === "error") {
2525
+ terminateWorker();
2526
+ reject(new Error("error occurred in dts build"));
2527
+ } else if (data === "success") {
2528
+ terminateWorker();
2529
+ resolve();
2530
+ } else {
2531
+ const { type, text } = data;
2532
+ if (type === "log") {
2533
+ console.log(text);
2534
+ } else if (type === "error") {
2535
+ console.error(text);
2536
+ }
2537
+ }
2538
+ });
2539
+ });
2540
+ }
2541
+ };
2542
+ const mainTasks = async () => {
2543
+ if (!_optionalChain([options2, "access", (_35) => _35.dts, "optionalAccess", (_36) => _36.only])) {
2544
+ let onSuccessProcess;
2545
+ let onSuccessCleanup;
2546
+ const buildDependencies = /* @__PURE__ */ new Set();
2547
+ let depsHash = await _chunkVGC3FXLUjs.getAllDepsHash.call(void 0, options2.workspaceConfig?.workspaceRoot || process.cwd());
2548
+ const doOnSuccessCleanup = async () => {
2549
+ if (onSuccessProcess) {
2550
+ await killProcess({
2551
+ pid: onSuccessProcess.pid,
2552
+ signal: options2.killSignal || "SIGTERM"
2553
+ });
2554
+ } else if (onSuccessCleanup) {
2555
+ await onSuccessCleanup();
2556
+ }
2557
+ onSuccessProcess = void 0;
2558
+ onSuccessCleanup = void 0;
2559
+ };
2560
+ const debouncedBuildAll = _chunkTWFEYLU4js.debouncePromise.call(
2561
+ void 0,
2562
+ () => {
2563
+ return buildAll();
2564
+ },
2565
+ 100,
2566
+ _chunkJZ25TPTYjs.handleError
2567
+ );
2568
+ const buildAll = async () => {
2569
+ await doOnSuccessCleanup();
2570
+ const previousBuildDependencies = new Set(buildDependencies);
2571
+ buildDependencies.clear();
2572
+ if (options2.clean) {
2573
+ const extraPatterns = Array.isArray(options2.clean) ? options2.clean : [];
2574
+ if (options2.dts || options2.experimentalDts) {
2575
+ extraPatterns.unshift("!**/*.d.{ts,cts,mts}");
2576
+ }
2577
+ await _chunkTWFEYLU4js.removeFiles.call(void 0, ["**/*", ...extraPatterns], options2.outDir);
2578
+ logger3.info("CLI", "Cleaning output folder");
2579
+ }
2580
+ const css = /* @__PURE__ */ new Map();
2581
+ await Promise.all([
2582
+ ...options2.format.map(async (format, index) => {
2583
+ const pluginContainer = new PluginContainer([
2584
+ shebang(),
2585
+ ...options2.plugins || [],
2586
+ treeShakingPlugin({
2587
+ treeshake: options2.treeshake,
2588
+ name: options2.globalName,
2589
+ silent: options2.silent
2590
+ }),
2591
+ cjsSplitting(),
2592
+ cjsInterop(),
2593
+ swcTarget(),
2594
+ sizeReporter(),
2595
+ terserPlugin({
2596
+ minifyOptions: options2.minify,
2597
+ format,
2598
+ terserOptions: options2.terserOptions,
2599
+ globalName: options2.globalName,
2600
+ logger: logger3
2601
+ })
2602
+ ]);
2603
+ await runEsbuild(options2, {
2604
+ pluginContainer,
2605
+ format,
2606
+ css: index === 0 || options2.injectStyle ? css : void 0,
2607
+ logger: logger3,
2608
+ buildDependencies
2609
+ }).catch((error) => {
2610
+ previousBuildDependencies.forEach(
2611
+ (v) => buildDependencies.add(v)
2612
+ );
2613
+ throw error;
2614
+ });
2615
+ })
2616
+ ]);
2617
+ if (options2.onSuccess) {
2618
+ if (typeof options2.onSuccess === "function") {
2619
+ onSuccessCleanup = await options2.onSuccess();
2620
+ } else {
2621
+ onSuccessProcess = _tinyexec.exec.call(void 0, options2.onSuccess, [], {
2622
+ nodeOptions: { shell: true, stdio: "inherit" }
2623
+ });
2624
+ _optionalChain([onSuccessProcess, "access", (_37) => _37.process, "optionalAccess", (_38) => _38.on, "call", (_39) => _39("exit", (code) => {
2625
+ if (code && code !== 0) {
2626
+ process.exitCode = code;
2627
+ }
2628
+ })]);
2629
+ }
2630
+ }
2631
+ };
2632
+ const startWatcher = async () => {
2633
+ if (!options2.watch) return;
2634
+ const { watch } = await Promise.resolve().then(() => _interopRequireWildcard(require("chokidar")));
2635
+ const customIgnores = options2.ignoreWatch ? Array.isArray(options2.ignoreWatch) ? options2.ignoreWatch : [options2.ignoreWatch] : [];
2636
+ const ignored = [
2637
+ "**/{.git,node_modules}/**",
2638
+ options2.outDir,
2639
+ ...customIgnores
2640
+ ];
2641
+ const watchPaths = typeof options2.watch === "boolean" ? "." : Array.isArray(options2.watch) ? options2.watch.filter((path12) => typeof path12 === "string") : options2.watch;
2642
+ logger3.info(
2643
+ "CLI",
2644
+ `Watching for changes in ${Array.isArray(watchPaths) ? watchPaths.map((v) => `"${v}"`).join(" | ") : `"${watchPaths}"`}`
2645
+ );
2646
+ logger3.info(
2647
+ "CLI",
2648
+ `Ignoring changes in ${ignored.map((v) => `"${v}"`).join(" | ")}`
2649
+ );
2650
+ const watcher = watch(await _tinyglobby.glob.call(void 0, watchPaths), {
2651
+ ignoreInitial: true,
2652
+ ignorePermissionErrors: true,
2653
+ ignored: (p) => _tinyglobby.globSync.call(void 0, p, { ignore: ignored }).length === 0
2654
+ });
2655
+ watcher.on("all", async (type, file) => {
2656
+ file = _chunkTWFEYLU4js.slash.call(void 0, file);
2657
+ if (options2.publicDir && isInPublicDir(options2.publicDir, file)) {
2658
+ logger3.info("CLI", `Change in public dir: ${file}`);
2659
+ copyPublicDir(options2.publicDir, options2.outDir);
2660
+ return;
2661
+ }
2662
+ let shouldSkipChange = false;
2663
+ if (options2.watch === true) {
2664
+ if (file === "package.json" && !buildDependencies.has(file)) {
2665
+ const currentHash = await _chunkVGC3FXLUjs.getAllDepsHash.call(void 0, options2.workspaceConfig?.workspaceRoot || process.cwd());
2666
+ shouldSkipChange = currentHash === depsHash;
2667
+ depsHash = currentHash;
2668
+ } else if (!buildDependencies.has(file)) {
2669
+ shouldSkipChange = true;
2670
+ }
2671
+ }
2672
+ if (shouldSkipChange) {
2673
+ return;
2674
+ }
2675
+ logger3.info("CLI", `Change detected: ${type} ${file}`);
2676
+ debouncedBuildAll();
2677
+ });
2678
+ };
2679
+ logger3.info("CLI", `Target: ${options2.target}`);
2680
+ await buildAll();
2681
+ copyPublicDir(options2.publicDir, options2.outDir);
2682
+ startWatcher();
2683
+ }
2684
+ };
2685
+ await Promise.all([dtsTask(), mainTasks()]);
2686
+ }
2687
+ )
2688
+ );
2689
+ }
2690
+ exports2.build = build2;
2691
+ exports2.defineConfig = defineConfig;
2692
+ }
2693
+ });
2694
+
2695
+ // src/index.ts
2696
+ var index_exports = {};
2697
+ __export(index_exports, {
2698
+ build: () => build
2699
+ });
2700
+ module.exports = __toCommonJS(index_exports);
2701
+ init_cjs_shims();
2702
+
2703
+ // ../config-tools/dist/logger/console.js
2704
+ init_cjs_shims();
2705
+
2706
+ // ../config-tools/dist/chunk-7L77OWOV.js
2707
+ init_cjs_shims();
2708
+
2709
+ // ../config-tools/dist/chunk-LA3S35UI.js
2710
+ init_cjs_shims();
2711
+ var DEFAULT_COLOR_CONFIG = {
2712
+ light: {
2713
+ background: "#fafafa",
2714
+ foreground: "#1d1e22",
2715
+ brand: "#1fb2a6",
2716
+ alternate: "#db2777",
2717
+ help: "#5C4EE5",
2718
+ success: "#087f5b",
2719
+ info: "#0550ae",
2720
+ warning: "#e3b341",
2721
+ danger: "#D8314A",
2722
+ fatal: "#51070f",
2723
+ link: "#3fa6ff",
2724
+ positive: "#22c55e",
2725
+ negative: "#dc2626",
2726
+ gradient: ["#1fb2a6", "#db2777", "#5C4EE5"]
2727
+ },
2728
+ dark: {
2729
+ background: "#1d1e22",
2730
+ foreground: "#cbd5e1",
2731
+ brand: "#2dd4bf",
2732
+ alternate: "#db2777",
2733
+ help: "#818cf8",
2734
+ success: "#10b981",
2735
+ info: "#58a6ff",
2736
+ warning: "#f3d371",
2737
+ danger: "#D8314A",
2738
+ fatal: "#a40e26",
2739
+ link: "#3fa6ff",
2740
+ positive: "#22c55e",
2741
+ negative: "#dc2626",
2742
+ gradient: ["#1fb2a6", "#db2777", "#818cf8"]
2743
+ }
2744
+ };
2745
+
2746
+ // ../config-tools/dist/chunk-HVVJHTFS.js
2747
+ init_cjs_shims();
2748
+ var import_chalk = __toESM(require("chalk"), 1);
2749
+ var chalkDefault = {
2750
+ hex: (_) => (message) => message,
2751
+ bgHex: (_) => ({
2752
+ whiteBright: (message) => message,
2753
+ white: (message) => message
2754
+ }),
2755
+ white: (message) => message,
2756
+ whiteBright: (message) => message,
2757
+ gray: (message) => message,
2758
+ bold: {
2759
+ hex: (_) => (message) => message,
2760
+ bgHex: (_) => ({
2761
+ whiteBright: (message) => message,
2762
+ white: (message) => message
2763
+ }),
2764
+ whiteBright: (message) => message,
2765
+ white: (message) => message
2766
+ },
2767
+ dim: {
2768
+ hex: (_) => (message) => message,
2769
+ gray: (message) => message
2770
+ }
2771
+ };
2772
+ var getChalk = () => {
2773
+ let _chalk = import_chalk.default;
2774
+ if (!_chalk?.hex || !_chalk?.bold?.hex || !_chalk?.bgHex || !_chalk?.whiteBright || !_chalk?.white) {
2775
+ _chalk = chalkDefault;
2776
+ }
2777
+ return _chalk;
2778
+ };
2779
+
2780
+ // ../config-tools/dist/chunk-LM2UMGYA.js
2781
+ init_cjs_shims();
2782
+
2783
+ // ../config-tools/dist/chunk-G2MK47WL.js
2784
+ init_cjs_shims();
2785
+ function isUnicodeSupported() {
2786
+ if (process.platform !== "win32") {
2787
+ return process.env.TERM !== "linux";
2788
+ }
2789
+ return Boolean(process.env.WT_SESSION) || // Windows Terminal
2790
+ Boolean(process.env.TERMINUS_SUBLIME) || // Terminus (<0.2.27)
2791
+ process.env.ConEmuTask === "{cmd::Cmder}" || // ConEmu and cmder
2792
+ process.env.TERM_PROGRAM === "Terminus-Sublime" || process.env.TERM_PROGRAM === "vscode" || process.env.TERM === "xterm-256color" || process.env.TERM === "alacritty" || process.env.TERM === "rxvt-unicode" || process.env.TERM === "rxvt-unicode-256color" || process.env.TERMINAL_EMULATOR === "JetBrains-JediTerm";
2793
+ }
2794
+
2795
+ // ../config-tools/dist/chunk-POXTJ6GF.js
2796
+ init_cjs_shims();
2797
+ var LogLevel = {
2798
+ SILENT: 0,
2799
+ FATAL: 10,
2800
+ ERROR: 20,
2801
+ WARN: 30,
2802
+ SUCCESS: 35,
2803
+ INFO: 40,
2804
+ DEBUG: 60,
2805
+ TRACE: 70,
2806
+ ALL: 100
2807
+ };
2808
+ var LogLevelLabel = {
2809
+ SILENT: "silent",
2810
+ FATAL: "fatal",
2811
+ ERROR: "error",
2812
+ WARN: "warn",
2813
+ SUCCESS: "success",
2814
+ INFO: "info",
2815
+ DEBUG: "debug",
2816
+ TRACE: "trace",
2817
+ ALL: "all"
2818
+ };
2819
+
2820
+ // ../config-tools/dist/chunk-LM2UMGYA.js
2821
+ var useIcon = (c, fallback) => isUnicodeSupported() ? c : fallback;
2822
+ var CONSOLE_ICONS = {
2823
+ [LogLevelLabel.ERROR]: useIcon("\u2718", "\xD7"),
2824
+ [LogLevelLabel.FATAL]: useIcon("\u{1F480}", "\xD7"),
2825
+ [LogLevelLabel.WARN]: useIcon("\u26A0", "\u203C"),
2826
+ [LogLevelLabel.INFO]: useIcon("\u2139", "i"),
2827
+ [LogLevelLabel.SUCCESS]: useIcon("\u2714", "\u221A"),
2828
+ [LogLevelLabel.DEBUG]: useIcon("\u{1F6E0}", "D"),
2829
+ [LogLevelLabel.TRACE]: useIcon("\u{1F6E0}", "T"),
2830
+ [LogLevelLabel.ALL]: useIcon("\u2709", "\u2192")
2831
+ };
2832
+
2833
+ // ../config-tools/dist/chunk-CZ4IE2QN.js
2834
+ init_cjs_shims();
2835
+ var formatTimestamp = (date = /* @__PURE__ */ new Date()) => {
2836
+ return `${date.toLocaleDateString()} ${date.toLocaleTimeString()}`;
2837
+ };
2838
+
2839
+ // ../config-tools/dist/chunk-K4CDYUQR.js
2840
+ init_cjs_shims();
2841
+ var getLogLevel = (label) => {
2842
+ switch (label) {
2843
+ case "all":
2844
+ return LogLevel.ALL;
2845
+ case "trace":
2846
+ return LogLevel.TRACE;
2847
+ case "debug":
2848
+ return LogLevel.DEBUG;
2849
+ case "info":
2850
+ return LogLevel.INFO;
2851
+ case "warn":
2852
+ return LogLevel.WARN;
2853
+ case "error":
2854
+ return LogLevel.ERROR;
2855
+ case "fatal":
2856
+ return LogLevel.FATAL;
2857
+ case "silent":
2858
+ return LogLevel.SILENT;
2859
+ default:
2860
+ return LogLevel.INFO;
2861
+ }
2862
+ };
2863
+
2864
+ // ../config-tools/dist/chunk-7L77OWOV.js
2865
+ var getLogFn = (logLevel = LogLevel.INFO, config = {}, _chalk = getChalk()) => {
2866
+ const colors = !config.colors?.dark && !config.colors?.["base"] && !config.colors?.["base"]?.dark ? DEFAULT_COLOR_CONFIG : config.colors?.dark && typeof config.colors.dark === "string" ? config.colors : config.colors?.["base"]?.dark && typeof config.colors["base"].dark === "string" ? config.colors["base"].dark : config.colors?.["base"] ? config.colors?.["base"] : DEFAULT_COLOR_CONFIG;
2867
+ const configLogLevel = config.logLevel || process.env.STORM_LOG_LEVEL || LogLevelLabel.INFO;
2868
+ if (logLevel > getLogLevel(configLogLevel) || logLevel <= LogLevel.SILENT || getLogLevel(configLogLevel) <= LogLevel.SILENT) {
2869
+ return (_) => {
2870
+ };
2871
+ }
2872
+ if (typeof logLevel === "number" && LogLevel.FATAL >= logLevel) {
2873
+ return (message) => {
2874
+ console.error(
2875
+ `
2876
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.fatal ?? DEFAULT_COLOR_CONFIG.dark.fatal)(`[${CONSOLE_ICONS[LogLevelLabel.FATAL]} Fatal] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
2877
+ `
2878
+ );
2879
+ };
2880
+ }
2881
+ if (typeof logLevel === "number" && LogLevel.ERROR >= logLevel) {
2882
+ return (message) => {
2883
+ console.error(
2884
+ `
2885
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.danger ?? DEFAULT_COLOR_CONFIG.dark.danger)(`[${CONSOLE_ICONS[LogLevelLabel.ERROR]} Error] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
2886
+ `
2887
+ );
2888
+ };
2889
+ }
2890
+ if (typeof logLevel === "number" && LogLevel.WARN >= logLevel) {
2891
+ return (message) => {
2892
+ console.warn(
2893
+ `
2894
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.warning ?? DEFAULT_COLOR_CONFIG.dark.warning)(`[${CONSOLE_ICONS[LogLevelLabel.WARN]} Warn] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
2895
+ `
2896
+ );
2897
+ };
2898
+ }
2899
+ if (typeof logLevel === "number" && LogLevel.SUCCESS >= logLevel) {
2900
+ return (message) => {
2901
+ console.info(
2902
+ `
2903
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.success ?? DEFAULT_COLOR_CONFIG.dark.success)(`[${CONSOLE_ICONS[LogLevelLabel.SUCCESS]} Success] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
2904
+ `
2905
+ );
2906
+ };
2907
+ }
2908
+ if (typeof logLevel === "number" && LogLevel.INFO >= logLevel) {
2909
+ return (message) => {
2910
+ console.info(
2911
+ `
2912
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.info ?? DEFAULT_COLOR_CONFIG.dark.info)(`[${CONSOLE_ICONS[LogLevelLabel.INFO]} Info] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
2913
+ `
2914
+ );
2915
+ };
2916
+ }
2917
+ if (typeof logLevel === "number" && LogLevel.DEBUG >= logLevel) {
2918
+ return (message) => {
2919
+ console.debug(
2920
+ `
2921
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.info ?? DEFAULT_COLOR_CONFIG.dark.info)(`[${CONSOLE_ICONS[LogLevelLabel.DEBUG]} Debug] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
2922
+ `
2923
+ );
2924
+ };
2925
+ }
2926
+ if (typeof logLevel === "number" && LogLevel.TRACE >= logLevel) {
2927
+ return (message) => {
2928
+ console.debug(
2929
+ `
2930
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.info ?? DEFAULT_COLOR_CONFIG.dark.info)(`[${CONSOLE_ICONS[LogLevelLabel.TRACE]} Trace] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
2931
+ `
2932
+ );
2933
+ };
2934
+ }
2935
+ return (message) => {
2936
+ console.log(
2937
+ `
2938
+ ${_chalk.gray(formatTimestamp())} ${_chalk.hex(colors.brand ?? DEFAULT_COLOR_CONFIG.dark.brand)(`[${CONSOLE_ICONS[LogLevelLabel.ALL]} System] `)}${_chalk.bold.whiteBright(formatLogMessage(message))}
2939
+ `
2940
+ );
2941
+ };
2942
+ };
2943
+ var writeDebug = (message, config) => getLogFn(LogLevel.DEBUG, config)(message);
2944
+ var getStopwatch = (name) => {
2945
+ const start = process.hrtime();
2946
+ return () => {
2947
+ const end = process.hrtime(start);
2948
+ console.info(
2949
+ `
2950
+ > \u23F1\uFE0F The${name ? ` ${name}` : ""} process took ${Math.round(
2951
+ end[0] * 1e3 + end[1] / 1e6
2952
+ )}ms to complete
2953
+ `
2954
+ );
2955
+ };
2956
+ };
2957
+ var MAX_DEPTH = 4;
2958
+ var formatLogMessage = (message, options2 = {}, depth = 0) => {
2959
+ if (depth > MAX_DEPTH) {
2960
+ return "<max depth>";
2961
+ }
2962
+ const prefix = options2.prefix ?? "-";
2963
+ const skip = options2.skip ?? [];
2964
+ return typeof message === "undefined" || message === null || !message && typeof message !== "boolean" ? "<none>" : typeof message === "string" ? message : Array.isArray(message) ? `
2965
+ ${message.map((item, index) => ` ${prefix}> #${index} = ${formatLogMessage(item, { prefix: `${prefix}-`, skip }, depth + 1)}`).join("\n")}` : typeof message === "object" ? `
2966
+ ${Object.keys(message).filter((key) => !skip.includes(key)).map(
2967
+ (key) => ` ${prefix}> ${key} = ${_isFunction(message[key]) ? "<function>" : typeof message[key] === "object" ? formatLogMessage(
2968
+ message[key],
2969
+ { prefix: `${prefix}-`, skip },
2970
+ depth + 1
2971
+ ) : message[key]}`
2972
+ ).join("\n")}` : message;
2973
+ };
2974
+ var _isFunction = (value) => {
2975
+ try {
2976
+ return value instanceof Function || typeof value === "function" || !!(value?.constructor && value?.call && value?.apply);
2977
+ } catch {
2978
+ return false;
2979
+ }
2980
+ };
2981
+
2982
+ // src/index.ts
2983
+ var import_tsup = __toESM(require_dist(), 1);
2984
+ async function build(options2) {
2985
+ writeDebug(
2986
+ ` \u{1F680} Running ${options2.name || "tsup"} build`,
2987
+ options2.workspaceConfig
2988
+ );
2989
+ const stopwatch = getStopwatch(`${options2.name || "tsup"} build`);
2990
+ await (0, import_tsup.build)(options2);
2991
+ stopwatch();
2992
+ }
2993
+ // Annotate the CommonJS export names for ESM import in node:
2994
+ 0 && (module.exports = {
2995
+ build
2996
+ });