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