bunup 0.4.90 → 0.4.95

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.
@@ -0,0 +1,490 @@
1
+ import _Bun from "bun";
2
+
3
+ //#region \0dts:/Users/admin/Desktop/Projects/bunup/packages/bunup/src/helpers/entry.d.ts
4
+ type ProcessableEntry = {
5
+ fullEntryPath: string
6
+ name: string
7
+ };
8
+
9
+ //#endregion
10
+ //#region \0dts:/Users/admin/Desktop/Projects/bunup/packages/bunup/src/plugins/types.d.ts
11
+ /**
12
+ * Represents a Bun plugin that can be used with Bunup
13
+ */
14
+ type BunupBunPlugin = {
15
+ /** Identifies this as a native Bun plugin */
16
+ type: "bun"
17
+ /** Optional name for the plugin */
18
+ name?: string
19
+ /** The actual Bun plugin implementation */
20
+ plugin: BunPlugin
21
+ };
22
+ /**
23
+ * Represents the output of a build operation
24
+ */
25
+ type BuildOutput = {
26
+ /** Array of generated files with their paths and contents */
27
+ files: Array<{
28
+ /** Path to the generated file */
29
+ fullPath: string
30
+ /** Path to the generated file relative to the output directory */
31
+ relativePathToOutputDir: string
32
+ }>
33
+ };
34
+ /**
35
+ * Context provided to build hooks
36
+ */
37
+ type BuildContext = {
38
+ /** The build options that were used */
39
+ options: BuildOptions
40
+ /** The output of the build */
41
+ output: BuildOutput
42
+ };
43
+ /**
44
+ * Hooks that can be implemented by Bunup plugins
45
+ */
46
+ type BunupPluginHooks = {
47
+ /**
48
+ * Called when a build is successfully completed
49
+ * @param ctx Build context containing options and output
50
+ */
51
+ onBuildDone?: (ctx: BuildContext) => MaybePromise<void>
52
+ /**
53
+ * Called before a build starts
54
+ * @param options Build options that will be used
55
+ */
56
+ onBuildStart?: (options: BuildOptions) => MaybePromise<void>
57
+ };
58
+ /**
59
+ * Represents a Bunup-specific plugin
60
+ */
61
+ type BunupPlugin = {
62
+ /** Identifies this as a Bunup-specific plugin */
63
+ type: "bunup"
64
+ /** Optional name for the plugin */
65
+ name?: string
66
+ /** The hooks implemented by this plugin */
67
+ hooks: BunupPluginHooks
68
+ };
69
+ /**
70
+ * Union type representing all supported plugin types
71
+ */
72
+ type Plugin = BunupBunPlugin | BunupPlugin;
73
+
74
+ //#endregion
75
+ //#region \0dts:/Users/admin/Desktop/Projects/bunup/packages/bunup/src/options.d.ts
76
+ type Loader = NonNullable<BunBuildOptions["loader"]>[string];
77
+ type Define = BunBuildOptions["define"];
78
+ type Sourcemap = BunBuildOptions["sourcemap"];
79
+ type Format = Exclude<BunBuildOptions["format"], undefined>;
80
+ type Target = BunBuildOptions["target"];
81
+ type External = (string | RegExp)[];
82
+ type Env = BunBuildOptions["env"] | Record<string, string>;
83
+ type Entry = Arrayable<string> | Record<string, string>;
84
+ type ShimOptions = {
85
+ /**
86
+ * Adds __dirname and __filename shims for ESM files when used
87
+ */
88
+ dirnameFilename?: boolean
89
+ /**
90
+ * Adds import.meta.url shims for CJS files when used
91
+ */
92
+ importMetaUrl?: boolean
93
+ };
94
+ type Shims = boolean | ShimOptions;
95
+ type DtsResolve = boolean | (string | RegExp)[];
96
+ type DtsOptions = {
97
+ /**
98
+ * Entry point files for TypeScript declaration file generation
99
+ *
100
+ * This can be:
101
+ * - A string path to a file
102
+ * - An array of file paths
103
+ * - An object where keys are output names and values are input file paths
104
+ *
105
+ * The key names are used for the generated declaration files.
106
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.d.ts`
107
+ *
108
+ * If not specified, the main entry points will be used for declaration file generation.
109
+ *
110
+ * If it's a string or an array of strings, the file name (without extension)
111
+ * will be used as the name for the output declaration file.
112
+ *
113
+ * @example
114
+ * // Using a string path
115
+ * entry: 'src/index.ts' // Generates index.d.ts
116
+ *
117
+ * // Using string paths in an array
118
+ * entry: ['src/index.ts'] // Generates index.d.ts
119
+ *
120
+ * // Using named outputs as an object
121
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.d.ts and utils.d.ts
122
+ *
123
+ * // Organizing output with subdirectories
124
+ * entry: { "client/index": "src/client/index.ts", "server/index": "src/server/index.ts" } // Generates client/index.d.ts and server/index.d.ts
125
+ */
126
+ entry?: Entry
127
+ /**
128
+ * Resolve external types used in dts files from node_modules
129
+ */
130
+ resolve?: DtsResolve
131
+ };
132
+ interface BuildOptions {
133
+ /**
134
+ * Name of the build configuration
135
+ * Used for logging and identification purposes
136
+ */
137
+ name?: string;
138
+ /**
139
+ * Entry point files for the build
140
+ *
141
+ * This can be:
142
+ * - A string path to a file
143
+ * - An array of file paths
144
+ * - An object where keys are output names and values are input file paths
145
+ *
146
+ * The key names are used for the generated output files.
147
+ * For example, `{custom: 'src/index.ts'}` will generate `custom.js`
148
+ *
149
+ * If it's a string or an array of strings, the file name (without extension)
150
+ * will be used as the name for the output file.
151
+ *
152
+ * @example
153
+ * // Using a string path
154
+ * entry: 'src/index.ts' // Generates index.js
155
+ *
156
+ * // Using string paths in an array
157
+ * entry: ['src/index.ts'] // Generates index.js
158
+ *
159
+ * // Using named outputs as an object
160
+ * entry: { myModule: 'src/index.ts', utils: 'src/utility-functions.ts' } // Generates myModule.js and utils.js
161
+ */
162
+ entry: Entry;
163
+ /**
164
+ * Output directory for the bundled files
165
+ * Defaults to 'dist' if not specified
166
+ */
167
+ outDir: string;
168
+ /**
169
+ * Output formats for the bundle
170
+ * Can include 'esm', 'cjs', and/or 'iife'
171
+ * Defaults to ['cjs'] if not specified
172
+ */
173
+ format: Format[];
174
+ /**
175
+ * Whether to enable all minification options
176
+ * When true, enables minifyWhitespace, minifyIdentifiers, and minifySyntax
177
+ */
178
+ minify?: boolean;
179
+ /**
180
+ * Whether to enable code splitting
181
+ * Defaults to true for ESM format, false for CJS format
182
+ */
183
+ splitting?: boolean;
184
+ /**
185
+ * Whether to minify whitespace in the output
186
+ * Removes unnecessary whitespace to reduce file size
187
+ */
188
+ minifyWhitespace?: boolean;
189
+ /**
190
+ * Whether to minify identifiers in the output
191
+ * Renames variables and functions to shorter names
192
+ */
193
+ minifyIdentifiers?: boolean;
194
+ /**
195
+ * Whether to minify syntax in the output
196
+ * Optimizes code structure for smaller file size
197
+ */
198
+ minifySyntax?: boolean;
199
+ /**
200
+ * Whether to watch for file changes and rebuild automatically
201
+ */
202
+ watch?: boolean;
203
+ /**
204
+ * Whether to generate TypeScript declaration files (.d.ts)
205
+ * When set to true, generates declaration files for all entry points
206
+ * Can also be configured with DtsOptions for more control
207
+ */
208
+ dts?: boolean | DtsOptions;
209
+ /**
210
+ * Generate only TypeScript declaration files (.d.ts) without any JavaScript output
211
+ * When set to true, bunup will skip the JavaScript bundling process entirely
212
+ * and only generate declaration files for the specified entry points
213
+ *
214
+ * This is useful when you want to use bunup's fast declaration file generation
215
+ * but handle the JavaScript bundling separately or not at all.
216
+ *
217
+ * Note: When this option is true, the `dts` option is implicitly set to true
218
+ * and other bundling-related options are ignored.
219
+ *
220
+ * @example
221
+ * dtsOnly: true
222
+ */
223
+ dtsOnly?: boolean;
224
+ /**
225
+ * Path to a preferred tsconfig.json file to use for declaration generation
226
+ *
227
+ * If not specified, the tsconfig.json in the project root will be used.
228
+ * This option allows you to use a different TypeScript configuration
229
+ * specifically for declaration file generation.
230
+ *
231
+ * @example
232
+ * preferredTsconfigPath: './tsconfig.build.json'
233
+ */
234
+ preferredTsconfigPath?: string;
235
+ /**
236
+ * External packages that should not be bundled
237
+ * Useful for dependencies that should be kept as external imports
238
+ */
239
+ external?: External;
240
+ /**
241
+ * Packages that should be bundled even if they are in external
242
+ * Useful for dependencies that should be included in the bundle
243
+ */
244
+ noExternal?: External;
245
+ /**
246
+ * The target environment for the bundle
247
+ * Can be 'browser', 'bun', 'node', etc.
248
+ * Defaults to 'node' if not specified
249
+ */
250
+ target?: Target;
251
+ /**
252
+ * Whether to clean the output directory before building
253
+ * When true, removes all files in the outDir before starting a new build
254
+ * Defaults to true if not specified
255
+ */
256
+ clean?: boolean;
257
+ /**
258
+ * Specifies the type of sourcemap to generate
259
+ * Can be 'none', 'linked', 'external', or 'inline'
260
+ * Can also be a boolean - when true, it will use 'inline'
261
+ *
262
+ * @see https://bun.sh/docs/bundler#sourcemap
263
+ *
264
+ * @default 'none'
265
+ *
266
+ * @example
267
+ * sourcemap: 'linked'
268
+ * // or
269
+ * sourcemap: true // equivalent to 'inline'
270
+ */
271
+ sourcemap?: Sourcemap;
272
+ /**
273
+ * Define global constants for the build
274
+ * These values will be replaced at build time
275
+ *
276
+ * @see https://bun.sh/docs/bundler#define
277
+ *
278
+ * @example
279
+ * define: {
280
+ * 'process.env.NODE_ENV': '"production"',
281
+ * 'PACKAGE_VERSION': '"1.0.0"'
282
+ * }
283
+ */
284
+ define?: Define;
285
+ /**
286
+ * A callback function that runs after the build process completes
287
+ * This can be used for custom post-build operations like copying files,
288
+ * running additional tools, or logging build information
289
+ *
290
+ * If watch mode is enabled, this callback runs after each rebuild
291
+ *
292
+ * @param options The build options that were used
293
+ */
294
+ onSuccess?: (options: Partial<BuildOptions>) => MaybePromise<void>;
295
+ /**
296
+ * A banner to be added to the final bundle, this can be a directive like "use client" for react or a comment block such as a license for the code.
297
+ *
298
+ * @see https://bun.sh/docs/bundler#banner
299
+ *
300
+ * @example
301
+ * banner: '"use client";'
302
+ */
303
+ banner?: string;
304
+ /**
305
+ * A footer to be added to the final bundle, this can be something like a comment block for a license or just a fun easter egg.
306
+ *
307
+ * @see https://bun.sh/docs/bundler#footer
308
+ *
309
+ * @example
310
+ * footer: '// built with love in SF'
311
+ */
312
+ footer?: string;
313
+ /**
314
+ * Remove function calls from a bundle. For example, `drop: ["console"]` will remove all calls to `console.log`. Arguments to calls will also be removed, regardless of if those arguments may have side effects. Dropping `debugger` will remove all `debugger` statements.
315
+ *
316
+ * @see https://bun.sh/docs/bundler#drop
317
+ *
318
+ * @example
319
+ * drop: ["console", "debugger", "anyIdentifier.or.propertyAccess"]
320
+ */
321
+ drop?: string[];
322
+ /**
323
+ * A map of file extensions to [built-in loader names](https://bun.sh/docs/bundler/loaders#built-in-loaders). This can be used to quickly customize how certain files are loaded.
324
+ *
325
+ * @see https://bun.sh/docs/bundler#loader
326
+ *
327
+ * @example
328
+ * loader: {
329
+ * ".png": "dataurl",
330
+ * ".txt": "file",
331
+ * }
332
+ */
333
+ loader?: Record<string, Loader>;
334
+ /**
335
+ * Generate bytecode for the output. This can dramatically improve cold start times, but will make the final output larger and slightly increase memory usage.
336
+ *
337
+ * Bytecode is currently only supported for CommonJS (format: "cjs").
338
+ *
339
+ * Must be target: "bun"
340
+ *
341
+ * @see https://bun.sh/docs/bundler#bytecode
342
+ *
343
+ * @default false
344
+ */
345
+ bytecode?: boolean;
346
+ /**
347
+ * Disable logging during the build process. When set to true, no logs will be printed to the console.
348
+ *
349
+ * @default false
350
+ */
351
+ silent?: boolean;
352
+ /**
353
+ * You can specify a prefix to be added to specific import paths in your bundled code
354
+ *
355
+ * Used for assets, external modules, and chunk files when splitting is enabled
356
+ *
357
+ * @see https://bunup.dev/documentation/#public-path for more information
358
+ *
359
+ * @example
360
+ * publicPath: 'https://cdn.example.com/'
361
+ */
362
+ publicPath?: string;
363
+ /**
364
+ * Inject Node.js compatibility shims for ESM/CJS interoperability
365
+ *
366
+ * When set to true, automatically injects all shims when needed
367
+ * When set to an object, only injects the specified shims
368
+ *
369
+ * Available shims:
370
+ * - dirnameFilename: Adds __dirname and __filename for ESM files when used
371
+ * - importMetaUrl: Adds import.meta.url for CJS files when used
372
+ *
373
+ * @example
374
+ * // Enable all shims
375
+ * shims: true
376
+ *
377
+ * // Enable only specific shims
378
+ * shims: { dirnameFilename: true, importMetaUrl: true }
379
+ */
380
+ shims?: Shims;
381
+ /**
382
+ * Controls how environment variables are handled during bundling.
383
+ *
384
+ * Can be one of:
385
+ * - `"inline"`: Replaces all `process.env.FOO` references in your code with the actual values
386
+ * of those environment variables at the time the build runs.
387
+ * - `"disable"`: Disables environment variable injection entirely, leaving `process.env.*` as-is.
388
+ * - A string ending in `*`: Only inlines environment variables matching the given prefix.
389
+ * For example, `"MY_PUBLIC_*"` will inline variables like `MY_PUBLIC_API_URL`.
390
+ * - An object of key-value pairs: Replaces both `process.env.KEY` and `import.meta.env.KEY`
391
+ * with the provided values, regardless of the runtime environment.
392
+ *
393
+ * Note: Values are injected at build time. Secrets or private keys should be excluded
394
+ * from inlining when targeting browser environments.
395
+ *
396
+ * @see https://bun.sh/docs/bundler#env to learn more about inline, disable, prefix, and object modes
397
+ *
398
+ * @example
399
+ * // Inline all environment variables available at build time
400
+ * env: "inline"
401
+ *
402
+ * // Disable all environment variable injection
403
+ * env: "disable"
404
+ *
405
+ * // Only inline environment variables with a specific prefix
406
+ * env: "PUBLIC_*"
407
+ *
408
+ * // Provide specific environment variables manually
409
+ * env: { API_URL: "https://api.example.com", DEBUG: "false" }
410
+ */
411
+ env?: Env;
412
+ /**
413
+ * Plugins to extend the build process functionality
414
+ *
415
+ * The Plugin type uses a discriminated union pattern with the 'type' field
416
+ * to support different plugin systems. Currently, only "bun" plugins are supported,
417
+ * but in the future, this will be extended to include "bunup" plugins as well.
418
+ *
419
+ * Each plugin type has its own specific plugin implementation:
420
+ * - "bun": Uses Bun's native plugin system (BunPlugin)
421
+ * - "bunup": Will use bunup's own plugin system (coming in future versions)
422
+ *
423
+ * This architecture allows for extensibility as more plugin systems are added.
424
+ *
425
+ * @example
426
+ * plugins: [
427
+ * {
428
+ * type: "bun",
429
+ * plugin: myBunPlugin()
430
+ * },
431
+ * // In the future:
432
+ * // {
433
+ * // type: "bunup",
434
+ * // plugin: myBunupPlugin()
435
+ * // }
436
+ * ]
437
+ */
438
+ plugins?: Plugin[];
439
+ /**
440
+ * Customize the output file extension for each format.
441
+ *
442
+ * @param options Contains format, packageType, options, and entry information
443
+ * @returns Object with js and dts extensions (including the leading dot)
444
+ *
445
+ * @example
446
+ * outputExtension: ({ format, entry }) => ({
447
+ * js: entry.name === 'worker' ? '.worker.js' : `.${format}.js`,
448
+ * dts: `.${format}.d.ts`
449
+ * })
450
+ */
451
+ outputExtension?: (options: {
452
+ format: Format
453
+ packageType: string | undefined
454
+ options: BuildOptions
455
+ entry: ProcessableEntry
456
+ }) => {
457
+ js: string
458
+ dts: string
459
+ };
460
+ }
461
+
462
+ //#endregion
463
+ //#region \0dts:/Users/admin/Desktop/Projects/bunup/packages/bunup/src/types.d.ts
464
+ type MaybePromise<T> = Promise<T> | T;
465
+ type WithOptional<
466
+ T,
467
+ K extends keyof T
468
+ > = Omit<T, K> & Partial<Pick<T, K>>;
469
+ type Arrayable<T> = T | T[];
470
+ type Bun = typeof _Bun;
471
+ type BunBuildOptions = Parameters<Bun["build"]>[0];
472
+ type BunPlugin = Exclude<BunBuildOptions["plugins"], undefined>[number];
473
+ type DefineConfigItem = Omit<WithOptional<BuildOptions, "outDir" | "format">, "watch">;
474
+ type DefineWorkspaceItem = {
475
+ name: string
476
+ root: string
477
+ config: DefineConfigItem | DefineConfigItem[]
478
+ };
479
+
480
+ //#endregion
481
+ //#region \0dts:/Users/admin/Desktop/Projects/bunup/packages/bunup/src/define.d.ts
482
+ declare function defineConfig(options: Arrayable<DefineConfigItem>): Arrayable<DefineConfigItem>;
483
+ declare function defineWorkspace(options: DefineWorkspaceItem[]): DefineWorkspaceItem[];
484
+
485
+ //#endregion
486
+ //#region \0dts:/Users/admin/Desktop/Projects/bunup/packages/bunup/src/build.d.ts
487
+ declare function build(partialOptions: Partial<BuildOptions>, rootDir?: string): Promise<void>;
488
+
489
+ //#endregion
490
+ export { BuildOptions, DefineConfigItem, DefineWorkspaceItem, Plugin, build, defineConfig, defineWorkspace };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import _Bun from "bun";
2
2
 
3
- //#region \0dts:/Users/admin/Desktop/Projects/bunup/src/helpers/entry.d.ts
3
+ //#region \0dts:/Users/admin/Desktop/Projects/bunup/packages/bunup/src/helpers/entry.d.ts
4
4
  type ProcessableEntry = {
5
5
  fullEntryPath: string
6
6
  name: string
7
7
  };
8
8
 
9
9
  //#endregion
10
- //#region \0dts:/Users/admin/Desktop/Projects/bunup/src/plugins/types.d.ts
10
+ //#region \0dts:/Users/admin/Desktop/Projects/bunup/packages/bunup/src/plugins/types.d.ts
11
11
  /**
12
12
  * Represents a Bun plugin that can be used with Bunup
13
13
  */
@@ -72,7 +72,7 @@ type BunupPlugin = {
72
72
  type Plugin = BunupBunPlugin | BunupPlugin;
73
73
 
74
74
  //#endregion
75
- //#region \0dts:/Users/admin/Desktop/Projects/bunup/src/options.d.ts
75
+ //#region \0dts:/Users/admin/Desktop/Projects/bunup/packages/bunup/src/options.d.ts
76
76
  type Loader = NonNullable<BunBuildOptions["loader"]>[string];
77
77
  type Define = BunBuildOptions["define"];
78
78
  type Sourcemap = BunBuildOptions["sourcemap"];
@@ -460,7 +460,7 @@ interface BuildOptions {
460
460
  }
461
461
 
462
462
  //#endregion
463
- //#region \0dts:/Users/admin/Desktop/Projects/bunup/src/types.d.ts
463
+ //#region \0dts:/Users/admin/Desktop/Projects/bunup/packages/bunup/src/types.d.ts
464
464
  type MaybePromise<T> = Promise<T> | T;
465
465
  type WithOptional<
466
466
  T,
@@ -478,12 +478,12 @@ type DefineWorkspaceItem = {
478
478
  };
479
479
 
480
480
  //#endregion
481
- //#region \0dts:/Users/admin/Desktop/Projects/bunup/src/define.d.ts
481
+ //#region \0dts:/Users/admin/Desktop/Projects/bunup/packages/bunup/src/define.d.ts
482
482
  declare function defineConfig(options: Arrayable<DefineConfigItem>): Arrayable<DefineConfigItem>;
483
483
  declare function defineWorkspace(options: DefineWorkspaceItem[]): DefineWorkspaceItem[];
484
484
 
485
485
  //#endregion
486
- //#region \0dts:/Users/admin/Desktop/Projects/bunup/src/build.d.ts
486
+ //#region \0dts:/Users/admin/Desktop/Projects/bunup/packages/bunup/src/build.d.ts
487
487
  declare function build(partialOptions: Partial<BuildOptions>, rootDir?: string): Promise<void>;
488
488
 
489
489
  //#endregion
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  // @bun
2
- var Fr=Object.create;var{getPrototypeOf:Yr,defineProperty:V,getOwnPropertyNames:Kr}=Object;var qr=Object.prototype.hasOwnProperty;var F=(r,n,t)=>{t=r!=null?Fr(Yr(r)):{};let e=n||!r||!r.__esModule?V(t,"default",{value:r,enumerable:!0}):t;for(let o of Kr(r))if(!qr.call(e,o))V(e,o,{get:()=>r[o],enumerable:!0});return e};var Gr=(r,n)=>()=>(n||r((n={exports:{}}).exports,n),n.exports);var j=Gr((Sn,Y)=>{var $=process||{},X=$.argv||[],E=$.env||{},Qr=!(!!E.NO_COLOR||X.includes("--no-color"))&&(!!E.FORCE_COLOR||X.includes("--color")||$.platform==="win32"||($.stdout||{}).isTTY&&E.TERM!=="dumb"||!!E.CI),Zr=(r,n,t=r)=>(e)=>{let o=""+e,i=o.indexOf(n,r.length);return~i?r+zr(o,n,t,i)+n:r+o+n},zr=(r,n,t,e)=>{let o="",i=0;do o+=r.substring(i,e)+t,i=e+n.length,e=r.indexOf(n,i);while(~e);return o+r.substring(i)},J=(r=Qr)=>{let n=r?Zr:()=>String;return{isColorSupported:r,reset:n("\x1B[0m","\x1B[0m"),bold:n("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:n("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:n("\x1B[3m","\x1B[23m"),underline:n("\x1B[4m","\x1B[24m"),inverse:n("\x1B[7m","\x1B[27m"),hidden:n("\x1B[8m","\x1B[28m"),strikethrough:n("\x1B[9m","\x1B[29m"),black:n("\x1B[30m","\x1B[39m"),red:n("\x1B[31m","\x1B[39m"),green:n("\x1B[32m","\x1B[39m"),yellow:n("\x1B[33m","\x1B[39m"),blue:n("\x1B[34m","\x1B[39m"),magenta:n("\x1B[35m","\x1B[39m"),cyan:n("\x1B[36m","\x1B[39m"),white:n("\x1B[37m","\x1B[39m"),gray:n("\x1B[90m","\x1B[39m"),bgBlack:n("\x1B[40m","\x1B[49m"),bgRed:n("\x1B[41m","\x1B[49m"),bgGreen:n("\x1B[42m","\x1B[49m"),bgYellow:n("\x1B[43m","\x1B[49m"),bgBlue:n("\x1B[44m","\x1B[49m"),bgMagenta:n("\x1B[45m","\x1B[49m"),bgCyan:n("\x1B[46m","\x1B[49m"),bgWhite:n("\x1B[47m","\x1B[49m"),blackBright:n("\x1B[90m","\x1B[39m"),redBright:n("\x1B[91m","\x1B[39m"),greenBright:n("\x1B[92m","\x1B[39m"),yellowBright:n("\x1B[93m","\x1B[39m"),blueBright:n("\x1B[94m","\x1B[39m"),magentaBright:n("\x1B[95m","\x1B[39m"),cyanBright:n("\x1B[96m","\x1B[39m"),whiteBright:n("\x1B[97m","\x1B[39m"),bgBlackBright:n("\x1B[100m","\x1B[49m"),bgRedBright:n("\x1B[101m","\x1B[49m"),bgGreenBright:n("\x1B[102m","\x1B[49m"),bgYellowBright:n("\x1B[103m","\x1B[49m"),bgBlueBright:n("\x1B[104m","\x1B[49m"),bgMagentaBright:n("\x1B[105m","\x1B[49m"),bgCyanBright:n("\x1B[106m","\x1B[49m"),bgWhiteBright:n("\x1B[107m","\x1B[49m")}};Y.exports=J();Y.exports.createColors=J});function Hr(r){return r}function Dr(r){return r}import{build as Pr}from"rolldown";import{dts as rn}from"rolldown-plugin-dts";var Vr=F(j(),1);var c=F(j(),1),N=!1;function v(r){N=r??!1}class w{static instance;loggedOnceMessages=new Set;MAX_LABEL_LENGTH=3;cliColor=c.default.blue;mutedColor=c.default.dim;infoColor=c.default.cyan;warnColor=c.default.yellow;errorColor=c.default.red;defaultColor=c.default.white;progressFgColorMap={ESM:c.default.yellow,CJS:c.default.green,IIFE:c.default.magenta,DTS:c.default.blue};progressBgColorMap={ESM:c.default.bgYellow,CJS:c.default.bgGreen,IIFE:c.default.bgMagenta,DTS:c.default.bgBlue};labels={cli:"CLI",info:"INFO",warn:"WARN",error:"ERROR"};constructor(){}static getInstance(){if(!w.instance)w.instance=new w;return w.instance}dispose(){this.loggedOnceMessages.clear()}shouldLog(r){if(!r?.once)return!0;if(this.loggedOnceMessages.has(r.once))return!1;return this.loggedOnceMessages.add(r.once),!0}formatMessage({fgColor:r,bgColor:n,label:t,message:e,identifier:o,muted:i}){let s=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-t.length)),u=i?this.mutedColor(e):e,g=o?` ${n(c.default.black(` ${o} `))}`:"";return`${r(t)} ${s}${u}${g}`}output(r,n={},t=console.log){if(N||!this.shouldLog(n))return;if(n.verticalSpace)t("");if(t(r),n.verticalSpace)t("")}cli(r,n={}){let t=this.formatMessage({fgColor:this.cliColor,bgColor:c.default.bgBlue,label:this.labels.cli,message:r,identifier:n.identifier,muted:n.muted});this.output(t,n)}info(r,n={}){let t=this.formatMessage({fgColor:this.infoColor,bgColor:c.default.bgCyan,label:this.labels.info,message:r,identifier:n.identifier,muted:n.muted});this.output(t,n)}warn(r,n={}){let t=this.formatMessage({fgColor:this.warnColor,bgColor:c.default.bgYellow,label:this.labels.warn,message:r,identifier:n.identifier,muted:n.muted});this.output(t,n,console.warn)}error(r,n={}){let t=this.formatMessage({fgColor:this.errorColor,bgColor:c.default.bgRed,label:this.labels.error,message:r,identifier:n.identifier,muted:n.muted});this.output(t,n,console.error)}getProgressFgColor(r){for(let[n,t]of Object.entries(this.progressFgColorMap))if(r.includes(n))return t;return this.defaultColor}getProgressBgColor(r){for(let[n,t]of Object.entries(this.progressBgColorMap))if(r.includes(n))return t;return c.default.bgWhite}progress(r,n,t={}){let e=this.getProgressFgColor(r),o=this.getProgressBgColor(r),i=this.formatMessage({fgColor:e,bgColor:o,label:r,message:n,identifier:t.identifier,muted:t.muted});this.output(i,t)}}var f=w.getInstance();class A extends Error{constructor(r){super(r);this.name="BunupError"}}class h extends A{constructor(r){super(r);this.name="BunupBuildError"}}class p extends A{constructor(r){super(r);this.name="BunupDTSBuildError"}}class _ extends A{constructor(r){super(r);this.name="BunupIsolatedDeclError"}}var l=(r)=>{if(r instanceof Error)return r.message;return String(r)};function P(r){return r instanceof _}import cr from"path";import{ResolverFactory as vr}from"oxc-resolver";import rr from"fs/promises";import Xr from"path";function nr(r,n){switch(r){case"esm":return R(n)?".js":".mjs";case"cjs":return R(n)?".cjs":".js";case"iife":return".global.js"}}function er(r,n){switch(r){case"esm":return R(n)?".d.ts":".d.mts";case"cjs":return R(n)?".d.cts":".d.ts";case"iife":return".d.ts"}}function K(r){return r==="node"||r==="bun"}function R(r){return r==="module"}function tr(r){if(!r)return[];return Array.from(new Set([...Object.keys(r.dependencies||{}),...Object.keys(r.peerDependencies||{})]))}function I(r,n=3){return r.split("/").slice(-n).join("/")}async function or(r,n){let t=Xr.join(r,n);try{await rr.rm(t,{recursive:!0,force:!0})}catch(e){throw new h(`Failed to clean output directory: ${e}`)}await rr.mkdir(t,{recursive:!0})}function Jr(r){return tr(r).map((n)=>new RegExp(`^${n}($|\\/|\\\\)`))}function ir(r,n){return typeof n==="string"?n===r:n.test(r)}function W(r,n,t){let o=Jr(t).some((s)=>s.test(r))||n.external?.some((s)=>ir(r,s)),i=n.noExternal?.some((s)=>ir(r,s));return o&&!i}import{resolveTsImportPath as Nr}from"ts-import-resolver";var O="\x00dts:",sr=(r,n,t)=>{return{name:"bunup:virtual-dts",async resolveId(e,o){if(q(e))return e;if(!o||!q(o))return null;let i=n.tsconfig?Nr({path:e,importer:M(o),tsconfig:n.tsconfig,rootDir:t}):null;if(!i)return null;let s=C(i);if(r.has(s))return U(s);return null},load(e){if(e.startsWith(O)){let o=M(e),i=r.get(o);if(i)return i}return null}}};var G=/\.(js|mjs|cjs|ts|mts|cts|tsx|jsx)$/;function T(r){return r.endsWith(".d.ts")||r.endsWith(".d.mts")||r.endsWith(".d.cts")}function gr(r){return G.test(r)&&!T(r)}function S(r){return[".ts",".mts",".cts",".tsx"].some((n)=>r.endsWith(n))&&!T(r)}function C(r){if(T(r))return r;if(r.endsWith(".mts"))return`${r.slice(0,-4)}.d.mts`;if(r.endsWith(".cts"))return`${r.slice(0,-4)}.d.cts`;if(G.test(r))return r.replace(G,".d.ts");return`${r}.d.ts`}function q(r){return r.startsWith(O)}function M(r){return r.replace(O,"")}function U(r){return`${O}${r}`}function mr(r,n){if(n===void 0)return"";let t=r.slice(0,n).split(`
3
- `),e=t.length,o=t[t.length-1].length+1;return` (${e}:${o})`}function ur(r,n,t,e){if(typeof e==="boolean"&&e)return!1;if(Array.isArray(e)){for(let o of e)if(typeof o==="string"&&r===o)return!1;else if(o instanceof RegExp&&o.test(r))return!1}return W(r,n,t)}var H;function ar(r,n){return{name:"bunup:types-resolve",buildStart(){H||=new vr({mainFields:["types","typings","module","main"],conditionNames:["types","typings","import","require"],extensions:[".d.ts",".d.mts",".d.cts",".ts",".mts",".cts"],...r.path&&{tsconfig:{configFile:r.path}},modules:["node_modules","node_modules/@types"]})},async resolveId(t,e){if(n===!1)return;if(t==="bun")return;let o=e?M(e):void 0;if(/\0/.test(t))return;if(Array.isArray(n)){if(!n.some((g)=>typeof g==="string"?g===t:g.test(t)))return}let i=o?cr.dirname(o):process.cwd(),{path:s}=await H.async(i,t);if(!s)return;if(gr(s)){let u=C(s);try{let{path:g}=await H.async(cr.dirname(s),u);if(g)return g}catch(g){}return}return s}}}async function br(r,n,t,e,o,i){let s=C(r),u=U(s),g=typeof t.dts==="object"&&"resolve"in t.dts?t.dts.resolve:void 0;try{let{output:m}=await Pr({input:u,output:{dir:t.outDir},write:!1,...o.path&&{resolve:{tsconfigFilename:o.path}},onwarn(x,b){if(["UNRESOLVED_IMPORT","CIRCULAR_DEPENDENCY","EMPTY_BUNDLE"].includes(x.code??""))return;b(x)},plugins:[sr(n,o,i),g&&ar(o,g),rn({dtsInput:!0,emitDtsOnly:!0})],external:(x)=>ur(x,t,e,g)});if(!m[0]?.code)return f.warn(`Generated empty declaration file for entry "${r}"`,{muted:!0}),"";return m[0].code}catch(m){throw new p(`DTS bundling failed for entry "${r}": ${l(m)}`)}}import{resolveTsImportPath as nn}from"ts-import-resolver";var en=/^\s*import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]/gm,tn=/^\s*export\s+.*from\s+['"]([^'"]+)['"]/gm,on=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,sn=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,gn=/import\s+\w+\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,mn=/\/\/\/\s*<reference\s+path\s*=\s*['"]([^'"]+)['"]\s*\/>/g,un=/\/\/\/\s*<reference\s+types\s*=\s*['"]([^'"]+)['"]\s*\/>/g;function cn(r){let n=new Set,t=[en,tn,on,sn,gn,mn,un];for(let e of t){let o=r.matchAll(e);for(let i of o)if(i[1])n.add(i[1])}return n}async function xr(r,n,t){let e=new Set([r]),o=[r];while(o.length){let i=o.pop();if(!i)continue;try{let s=await Bun.file(i).text(),u=cn(s);for(let g of u){let m=n.tsconfig?nn({path:g,importer:i,tsconfig:n.tsconfig,rootDir:t}):null;if(!m||!(S(m)||T(m)))continue;if(!e.has(m))e.add(m),o.push(m)}}catch(s){f.warn(`Error processing ${i}: ${l(s)}`)}}return e}var D=F(j(),1);import{isolatedDeclaration as an}from"oxc-transform";async function fr(r,n){let t=!1,e=new Map;if(await Promise.all([...r].map(async(o)=>{try{let i=C(o);if(!await Bun.file(o).exists())return;let u=await Bun.file(o).text(),{code:g,errors:m}=an(o,u);if(g)e.set(i,g);for(let x of m){if(!t&&!n)console.log(`
4
- `);let b=x.labels[0],a=b?mr(u,b.start):"",B=`${I(o)}${a}: ${bn(x.message)}`;f[n?"warn":"error"](B),t=!0}}catch(i){f.warn(`Failed to generate declaration for ${o}: ${l(i)}`)}})),t&&!n)throw console.log(`
5
- `),new _(`TypeScript is asking for explicit type annotations on your exports. This helps ensure better, more reliable type declarations for your library. Bunup uses TypeScript's ${D.default.blue("isolatedDeclarations")} feature to generate these declarations, which requires each export from your library to be fully typed. You can learn more here: ${D.default.blue("https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#isolated-declarations")}`);return e}function bn(r){return r.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}import pr from"fs/promises";import Q from"path";async function dr(r,n){let t=Q.resolve(r),e=Q.resolve(t,n);if(!await pr.exists(t))throw new p(`Root directory does not exist: ${t}`);if(!await Bun.file(e).exists())throw new p(`Entry file does not exist: ${e}`);if(!S(e))throw new p(`Entry file must be a TypeScript file: ${e}`);if(Q.relative(t,e).startsWith(".."))throw new p(`Entry file must be within rootDir: ${e}`);return{absoluteRootDir:t,absoluteEntry:e}}async function lr(r,n,t,e,o){let{absoluteEntry:i}=await dr(r,n),s=await xr(i,e,r),u=await fr(s,t.watch);return br(i,u,t,o,e,r)}import{basename as xn,dirname as fn,extname as pn}from"path";function Cr(r){let n=xn(r),t=pn(n);return t?n.slice(0,-t.length):n}function Z(r){if(typeof r==="string")return[{fullEntryPath:r,name:Cr(r)}];if(typeof r==="object"&&!Array.isArray(r))return Object.entries(r).map(([e,o])=>({fullEntryPath:o,name:e}));let n=[],t=new Set;for(let e of r){let o=Cr(e);if(!t.has(o)){n.push({fullEntryPath:e,name:o}),t.add(o);continue}let s=fn(e).split("/").filter((g)=>g!=="."&&g!=="");if(s.length===0){let g=1,m;do m=`${o}_${g++}`;while(t.has(m));n.push({fullEntryPath:e,name:m}),t.add(m);continue}let u=!1;for(let g=1;g<=s.length&&!u;g++){let x=`${s.slice(-g).join("/")}/${o}`;if(!t.has(x))n.push({fullEntryPath:e,name:x}),t.add(x),u=!0}if(!u){let g=1,m;do m=`${s.join("/")}/${o}_${g++}`;while(t.has(m));n.push({fullEntryPath:e,name:m}),t.add(m)}}return n}function Br(r){return r.filter((n)=>S(n.fullEntryPath))}function wr(r,n){return`[dir]/${r}${n}`}import{loadConfig as hr}from"unconfig";async function Rr(r){let{config:n,sources:t}=await hr({sources:[{files:"package.json",extensions:[]}],cwd:r});return{packageJson:n,path:t?.[0]}}async function Sr(r,n){let{config:t,sources:e}=await hr({sources:n?[{files:n,extensions:[]}]:[{files:"tsconfig.json",extensions:[]}],cwd:r});return{tsconfig:t,path:e?.[0]}}var dn={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function kr(r){return{...dn,...r}}function Lr(r){let{minify:n,minifyWhitespace:t,minifyIdentifiers:e,minifySyntax:o}=r,i=n===!0;return{whitespace:t??i,identifiers:e??i,syntax:o??i}}function yr(r,n){return n==="cjs"?r:void 0}function Ir(r,n,t,e){return{...typeof t==="object"&&Object.keys(t).reduce((o,i)=>{let s=JSON.stringify(t[i]);return o[`process.env.${i}`]=s,o[`import.meta.env.${i}`]=s,o},{}),...r,...e==="cjs"&&(n===!0||typeof n==="object"&&n.importMetaUrl)&&{"import.meta.url":"importMetaUrl"}}}function Mr(r,n){return r===void 0?n==="esm":r}function Or(r){return typeof r==="string"?r:void 0}function Tr(r,n){return{name:"bunup:external-plugin",setup(t){t.onResolve({filter:/.*/},(e)=>{let o=e.path;if(W(o,r,n))return{path:o,external:!0};return null})}}}var ln=/\.(js|ts|jsx|tsx|mts|cts)$/,z={dirnameFilename:{appliesTo:(r,n)=>r==="esm"&&K(n),isNeededInFile:(r)=>/\b__dirname\b/.test(r)||/\b__filename\b/.test(r),generateCode:()=>`import { fileURLToPath } from 'url';
2
+ var Fr=Object.create;var{getPrototypeOf:Yr,defineProperty:V,getOwnPropertyNames:Kr}=Object;var qr=Object.prototype.hasOwnProperty;var F=(r,n,t)=>{t=r!=null?Fr(Yr(r)):{};let e=n||!r||!r.__esModule?V(t,"default",{value:r,enumerable:!0}):t;for(let o of Kr(r))if(!qr.call(e,o))V(e,o,{get:()=>r[o],enumerable:!0});return e};var Gr=(r,n)=>()=>(n||r((n={exports:{}}).exports,n),n.exports);var j=Gr((Sn,Y)=>{var $=process||{},X=$.argv||[],E=$.env||{},Qr=!(!!E.NO_COLOR||X.includes("--no-color"))&&(!!E.FORCE_COLOR||X.includes("--color")||$.platform==="win32"||($.stdout||{}).isTTY&&E.TERM!=="dumb"||!!E.CI),Zr=(r,n,t=r)=>(e)=>{let o=""+e,i=o.indexOf(n,r.length);return~i?r+zr(o,n,t,i)+n:r+o+n},zr=(r,n,t,e)=>{let o="",i=0;do o+=r.substring(i,e)+t,i=e+n.length,e=r.indexOf(n,i);while(~e);return o+r.substring(i)},J=(r=Qr)=>{let n=r?Zr:()=>String;return{isColorSupported:r,reset:n("\x1B[0m","\x1B[0m"),bold:n("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:n("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:n("\x1B[3m","\x1B[23m"),underline:n("\x1B[4m","\x1B[24m"),inverse:n("\x1B[7m","\x1B[27m"),hidden:n("\x1B[8m","\x1B[28m"),strikethrough:n("\x1B[9m","\x1B[29m"),black:n("\x1B[30m","\x1B[39m"),red:n("\x1B[31m","\x1B[39m"),green:n("\x1B[32m","\x1B[39m"),yellow:n("\x1B[33m","\x1B[39m"),blue:n("\x1B[34m","\x1B[39m"),magenta:n("\x1B[35m","\x1B[39m"),cyan:n("\x1B[36m","\x1B[39m"),white:n("\x1B[37m","\x1B[39m"),gray:n("\x1B[90m","\x1B[39m"),bgBlack:n("\x1B[40m","\x1B[49m"),bgRed:n("\x1B[41m","\x1B[49m"),bgGreen:n("\x1B[42m","\x1B[49m"),bgYellow:n("\x1B[43m","\x1B[49m"),bgBlue:n("\x1B[44m","\x1B[49m"),bgMagenta:n("\x1B[45m","\x1B[49m"),bgCyan:n("\x1B[46m","\x1B[49m"),bgWhite:n("\x1B[47m","\x1B[49m"),blackBright:n("\x1B[90m","\x1B[39m"),redBright:n("\x1B[91m","\x1B[39m"),greenBright:n("\x1B[92m","\x1B[39m"),yellowBright:n("\x1B[93m","\x1B[39m"),blueBright:n("\x1B[94m","\x1B[39m"),magentaBright:n("\x1B[95m","\x1B[39m"),cyanBright:n("\x1B[96m","\x1B[39m"),whiteBright:n("\x1B[97m","\x1B[39m"),bgBlackBright:n("\x1B[100m","\x1B[49m"),bgRedBright:n("\x1B[101m","\x1B[49m"),bgGreenBright:n("\x1B[102m","\x1B[49m"),bgYellowBright:n("\x1B[103m","\x1B[49m"),bgBlueBright:n("\x1B[104m","\x1B[49m"),bgMagentaBright:n("\x1B[105m","\x1B[49m"),bgCyanBright:n("\x1B[106m","\x1B[49m"),bgWhiteBright:n("\x1B[107m","\x1B[49m")}};Y.exports=J();Y.exports.createColors=J});function Hr(r){return r}function Dr(r){return r}import{build as Pr}from"rolldown";import{dts as rn}from"rolldown-plugin-dts";var Vr=F(j(),1);var c=F(j(),1),N=!1;function v(r){N=r??!1}class w{static instance;loggedOnceMessages=new Set;MAX_LABEL_LENGTH=3;cliColor=c.default.blue;mutedColor=c.default.dim;infoColor=c.default.cyan;warnColor=c.default.yellow;errorColor=c.default.red;defaultColor=c.default.white;progressFgColorMap={ESM:c.default.yellow,CJS:c.default.green,IIFE:c.default.magenta,DTS:c.default.blue};progressBgColorMap={ESM:c.default.bgYellow,CJS:c.default.bgGreen,IIFE:c.default.bgMagenta,DTS:c.default.bgBlue};labels={cli:"CLI",info:"INFO",warn:"WARN",error:"ERROR"};constructor(){}static getInstance(){if(!w.instance)w.instance=new w;return w.instance}dispose(){this.loggedOnceMessages.clear()}shouldLog(r){if(!r?.once)return!0;if(this.loggedOnceMessages.has(r.once))return!1;return this.loggedOnceMessages.add(r.once),!0}formatMessage({fgColor:r,bgColor:n,label:t,message:e,identifier:o,muted:i}){let s=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-t.length)),u=i?this.mutedColor(e):e,g=o?` ${n(c.default.black(` ${o} `))}`:"";return`${r(t)} ${s}${u}${g}`}output(r,n={},t=console.log){if(N||!this.shouldLog(n))return;if(n.verticalSpace)t("");if(t(r),n.verticalSpace)t("")}cli(r,n={}){let t=this.formatMessage({fgColor:this.cliColor,bgColor:c.default.bgBlue,label:this.labels.cli,message:r,identifier:n.identifier,muted:n.muted});this.output(t,n)}info(r,n={}){let t=this.formatMessage({fgColor:this.infoColor,bgColor:c.default.bgCyan,label:this.labels.info,message:r,identifier:n.identifier,muted:n.muted});this.output(t,n)}warn(r,n={}){let t=this.formatMessage({fgColor:this.warnColor,bgColor:c.default.bgYellow,label:this.labels.warn,message:r,identifier:n.identifier,muted:n.muted});this.output(t,n,console.warn)}error(r,n={}){let t=this.formatMessage({fgColor:this.errorColor,bgColor:c.default.bgRed,label:this.labels.error,message:r,identifier:n.identifier,muted:n.muted});this.output(t,n,console.error)}getProgressFgColor(r){for(let[n,t]of Object.entries(this.progressFgColorMap))if(r.includes(n))return t;return this.defaultColor}getProgressBgColor(r){for(let[n,t]of Object.entries(this.progressBgColorMap))if(r.includes(n))return t;return c.default.bgWhite}progress(r,n,t={}){let e=this.getProgressFgColor(r),o=this.getProgressBgColor(r),i=this.formatMessage({fgColor:e,bgColor:o,label:r,message:n,identifier:t.identifier,muted:t.muted});this.output(i,t)}}var x=w.getInstance();class A extends Error{constructor(r){super(r);this.name="BunupError"}}class h extends A{constructor(r){super(r);this.name="BunupBuildError"}}class f extends A{constructor(r){super(r);this.name="BunupDTSBuildError"}}class _ extends A{constructor(r){super(r);this.name="BunupIsolatedDeclError"}}var l=(r)=>{if(r instanceof Error)return r.message;return String(r)};function P(r){return r instanceof _}import cr from"path";import{ResolverFactory as vr}from"oxc-resolver";import rr from"fs/promises";import Xr from"path";function nr(r,n){switch(r){case"esm":return R(n)?".js":".mjs";case"cjs":return R(n)?".cjs":".js";case"iife":return".global.js"}}function er(r,n){switch(r){case"esm":return R(n)?".d.ts":".d.mts";case"cjs":return R(n)?".d.cts":".d.ts";case"iife":return".d.ts"}}function K(r){return r==="node"||r==="bun"}function R(r){return r==="module"}function tr(r){if(!r)return[];return Array.from(new Set([...Object.keys(r.dependencies||{}),...Object.keys(r.peerDependencies||{})]))}function I(r,n=3){return r.split("/").slice(-n).join("/")}async function or(r,n){let t=Xr.join(r,n);try{await rr.rm(t,{recursive:!0,force:!0})}catch(e){throw new h(`Failed to clean output directory: ${e}`)}await rr.mkdir(t,{recursive:!0})}function Jr(r){return tr(r).map((n)=>new RegExp(`^${n}($|\\/|\\\\)`))}function ir(r,n){return typeof n==="string"?n===r:n.test(r)}function W(r,n,t){let o=Jr(t).some((s)=>s.test(r))||n.external?.some((s)=>ir(r,s)),i=n.noExternal?.some((s)=>ir(r,s));return o&&!i}import{resolveTsImportPath as Nr}from"ts-import-resolver";var O="\x00dts:",sr=(r,n,t)=>{return{name:"bunup:virtual-dts",async resolveId(e,o){if(q(e))return e;if(!o||!q(o))return null;let i=n.tsconfig?Nr({path:e,importer:M(o),tsconfig:n.tsconfig,rootDir:t}):null;if(!i)return null;let s=C(i);if(r.has(s))return U(s);return null},load(e){if(e.startsWith(O)){let o=M(e),i=r.get(o);if(i)return i}return null}}};var G=/\.(js|mjs|cjs|ts|mts|cts|tsx|jsx)$/;function T(r){return r.endsWith(".d.ts")||r.endsWith(".d.mts")||r.endsWith(".d.cts")}function gr(r){return G.test(r)&&!T(r)}function S(r){return[".ts",".mts",".cts",".tsx"].some((n)=>r.endsWith(n))&&!T(r)}function C(r){if(T(r))return r;if(r.endsWith(".mts"))return`${r.slice(0,-4)}.d.mts`;if(r.endsWith(".cts"))return`${r.slice(0,-4)}.d.cts`;if(G.test(r))return r.replace(G,".d.ts");return`${r}.d.ts`}function q(r){return r.startsWith(O)}function M(r){return r.replace(O,"")}function U(r){return`${O}${r}`}function mr(r,n){if(n===void 0)return"";let t=r.slice(0,n).split(`
3
+ `),e=t.length,o=t[t.length-1].length+1;return` (${e}:${o})`}function ur(r,n,t,e){if(typeof e==="boolean"&&e)return!1;if(Array.isArray(e)){for(let o of e)if(typeof o==="string"&&r===o)return!1;else if(o instanceof RegExp&&o.test(r))return!1}return W(r,n,t)}var H;function ar(r,n){return{name:"bunup:types-resolve",buildStart(){H||=new vr({mainFields:["types","typings","module","main"],conditionNames:["types","typings","import","require"],extensions:[".d.ts",".d.mts",".d.cts",".ts",".mts",".cts"],...r.path&&{tsconfig:{configFile:r.path}},modules:["node_modules","node_modules/@types"]})},async resolveId(t,e){if(n===!1)return;if(t==="bun")return;let o=e?M(e):void 0;if(/\0/.test(t))return;if(Array.isArray(n)){if(!n.some((g)=>typeof g==="string"?g===t:g.test(t)))return}let i=o?cr.dirname(o):process.cwd(),{path:s}=await H.async(i,t);if(!s)return;if(gr(s)){let u=C(s);try{let{path:g}=await H.async(cr.dirname(s),u);if(g)return g}catch(g){}return}return s}}}async function br(r,n,t,e,o,i){let s=C(r),u=U(s),g=typeof t.dts==="object"&&"resolve"in t.dts?t.dts.resolve:void 0;try{let{output:m}=await Pr({input:u,output:{dir:t.outDir},write:!1,...o.path&&{resolve:{tsconfigFilename:o.path}},onwarn(p,b){if(["UNRESOLVED_IMPORT","CIRCULAR_DEPENDENCY","EMPTY_BUNDLE"].includes(p.code??""))return;b(p)},plugins:[sr(n,o,i),g&&ar(o,g),rn({dtsInput:!0,emitDtsOnly:!0})],external:(p)=>ur(p,t,e,g)});if(!m[0]?.code)return x.warn(`Generated empty declaration file for entry "${r}"`,{muted:!0}),"";return m[0].code}catch(m){throw new f(`DTS bundling failed for entry "${r}": ${l(m)}`)}}import{resolveTsImportPath as nn}from"ts-import-resolver";var en=/^\s*import\s+(?:[^'"]*?\s+from\s+)?['"]([^'"]+)['"]/gm,tn=/^\s*export\s+.*from\s+['"]([^'"]+)['"]/gm,on=/import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,sn=/require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,gn=/import\s+\w+\s*=\s*require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,mn=/\/\/\/\s*<reference\s+path\s*=\s*['"]([^'"]+)['"]\s*\/>/g,un=/\/\/\/\s*<reference\s+types\s*=\s*['"]([^'"]+)['"]\s*\/>/g;function cn(r){let n=new Set,t=[en,tn,on,sn,gn,mn,un];for(let e of t){let o=r.matchAll(e);for(let i of o)if(i[1])n.add(i[1])}return n}async function pr(r,n,t){let e=new Set([r]),o=[r];while(o.length){let i=o.pop();if(!i)continue;try{let s=await Bun.file(i).text(),u=cn(s);for(let g of u){let m=n.tsconfig?nn({path:g,importer:i,tsconfig:n.tsconfig,rootDir:t}):null;if(!m||!(S(m)||T(m)))continue;if(!e.has(m))e.add(m),o.push(m)}}catch(s){x.warn(`Error processing ${i}: ${l(s)}`)}}return e}var D=F(j(),1);import{isolatedDeclaration as an}from"oxc-transform";async function xr(r,n){let t=!1,e=new Map;if(await Promise.all([...r].map(async(o)=>{try{let i=C(o);if(!await Bun.file(o).exists())return;let u=await Bun.file(o).text(),{code:g,errors:m}=an(o,u);if(g)e.set(i,g);for(let p of m){if(!t&&!n)console.log(`
4
+ `);let b=p.labels[0],a=b?mr(u,b.start):"",B=`${I(o)}${a}: ${bn(p.message)}`;x[n?"warn":"error"](B),t=!0}}catch(i){x.warn(`Failed to generate declaration for ${o}: ${l(i)}`)}})),t&&!n)throw console.log(`
5
+ `),new _(`TypeScript is asking for explicit type annotations on your exports. This helps ensure better, more reliable type declarations for your library. Bunup uses TypeScript's ${D.default.blue("isolatedDeclarations")} feature to generate these declarations, which requires each export from your library to be fully typed. You can learn more here: ${D.default.blue("https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-5.html#isolated-declarations")}`);return e}function bn(r){return r.replace(" with --isolatedDeclarations","").replace(" with --isolatedDeclaration","")}import fr from"fs/promises";import Q from"path";async function dr(r,n){let t=Q.resolve(r),e=Q.resolve(t,n);if(!await fr.exists(t))throw new f(`Root directory does not exist: ${t}`);if(!await Bun.file(e).exists())throw new f(`Entry file does not exist: ${e}`);if(!S(e))throw new f(`Entry file must be a TypeScript file: ${e}`);if(Q.relative(t,e).startsWith(".."))throw new f(`Entry file must be within rootDir: ${e}`);return{absoluteRootDir:t,absoluteEntry:e}}async function lr(r,n,t,e,o){let{absoluteEntry:i}=await dr(r,n),s=await pr(i,e,r),u=await xr(s,t.watch);return br(i,u,t,o,e,r)}import{basename as pn,dirname as xn,extname as fn}from"path";function Cr(r){let n=pn(r),t=fn(n);return t?n.slice(0,-t.length):n}function Z(r){if(typeof r==="string")return[{fullEntryPath:r,name:Cr(r)}];if(typeof r==="object"&&!Array.isArray(r))return Object.entries(r).map(([e,o])=>({fullEntryPath:o,name:e}));let n=[],t=new Set;for(let e of r){let o=Cr(e);if(!t.has(o)){n.push({fullEntryPath:e,name:o}),t.add(o);continue}let s=xn(e).split("/").filter((g)=>g!=="."&&g!=="");if(s.length===0){let g=1,m;do m=`${o}_${g++}`;while(t.has(m));n.push({fullEntryPath:e,name:m}),t.add(m);continue}let u=!1;for(let g=1;g<=s.length&&!u;g++){let p=`${s.slice(-g).join("/")}/${o}`;if(!t.has(p))n.push({fullEntryPath:e,name:p}),t.add(p),u=!0}if(!u){let g=1,m;do m=`${s.join("/")}/${o}_${g++}`;while(t.has(m));n.push({fullEntryPath:e,name:m}),t.add(m)}}return n}function Br(r){return r.filter((n)=>S(n.fullEntryPath))}function wr(r,n){return`[dir]/${r}${n}`}import{loadConfig as hr}from"coffi";async function Rr(r){let{config:n,filepath:t}=await hr({name:"package",cwd:r,extensions:[".json"]});return{packageJson:n,path:t}}async function Sr(r,n){let{config:t,filepath:e}=await hr({name:"tsconfig",cwd:r,extensions:[".json"],preferredPath:n});return{tsconfig:t,path:e}}var dn={entry:[],format:["cjs"],outDir:"dist",target:"node",clean:!0};function kr(r){return{...dn,...r}}function Lr(r){let{minify:n,minifyWhitespace:t,minifyIdentifiers:e,minifySyntax:o}=r,i=n===!0;return{whitespace:t??i,identifiers:e??i,syntax:o??i}}function yr(r,n){return n==="cjs"?r:void 0}function Ir(r,n,t,e){return{...typeof t==="object"&&Object.keys(t).reduce((o,i)=>{let s=JSON.stringify(t[i]);return o[`process.env.${i}`]=s,o[`import.meta.env.${i}`]=s,o},{}),...r,...e==="cjs"&&(n===!0||typeof n==="object"&&n.importMetaUrl)&&{"import.meta.url":"importMetaUrl"}}}function Mr(r,n){return r===void 0?n==="esm":r}function Or(r){return typeof r==="string"?r:void 0}function Tr(r,n){return{name:"bunup:external-plugin",setup(t){t.onResolve({filter:/.*/},(e)=>{let o=e.path;if(W(o,r,n))return{path:o,external:!0};return null})}}}var ln=/\.(js|ts|jsx|tsx|mts|cts)$/,z={dirnameFilename:{appliesTo:(r,n)=>r==="esm"&&K(n),isNeededInFile:(r)=>/\b__dirname\b/.test(r)||/\b__filename\b/.test(r),generateCode:()=>`import { fileURLToPath } from 'url';
6
6
  import { dirname } from 'path';
7
7
 
8
8
  const __filename = fileURLToPath(import.meta.url);
@@ -12,5 +12,5 @@ var Fr=Object.create;var{getPrototypeOf:Yr,defineProperty:V,getOwnPropertyNames:
12
12
 
13
13
  const importMetaUrl = pathToFileURL(__filename).href;
14
14
 
15
- `}};function Er({format:r,target:n,shims:t}){let o=Cn(t).map((i)=>z[i]).filter((i)=>i.appliesTo(r,n));if(o.length===0)return{name:"bunup:inject-shims",setup(){}};return{name:"bunup:inject-shims",setup(i){i.onLoad({filter:ln},async({path:s})=>{let u=await Bun.file(s).text(),g=o.filter((a)=>a.isNeededInFile(u));if(g.length===0)return;let{shebangLine:m,codeContent:x}=Bn(u),b=g.map((a)=>a.generateCode()).join("");return{contents:m+b+x}})}}}function Cn(r){if(r===!0)return Object.keys(z);if(!r)return[];return Object.entries(r).filter(([n,t])=>t&&(n in z)).map(([n])=>n)}function Bn(r){if(!r.startsWith("#!"))return{shebangLine:"",codeContent:r};let n=r.indexOf(`
16
- `);return n===-1?{shebangLine:"",codeContent:r}:{shebangLine:r.slice(0,n+1),codeContent:r.slice(n+1)}}function $r(r){if(!r)return[];return r.filter((n)=>n.type==="bun")}function jr(r){if(!r)return[];return r.filter((n)=>n.type==="bunup")}async function Ar(r,n){if(!r)return;for(let t of r)if(t.hooks.onBuildStart)await t.hooks.onBuildStart(n)}async function _r(r,n,t){if(!r)return;for(let e of r)if(e.hooks.onBuildDone)await e.hooks.onBuildDone({options:n,output:t})}async function wn(r,n=process.cwd()){let t={files:[]},e=kr(r);if(!e.entry||e.entry.length===0||!e.outDir)throw new h("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(e.clean)or(n,e.outDir);v(e.silent);let{packageJson:o,path:i}=await Rr(n);if(o&&i)f.cli(`Using ${I(i,2)}`,{muted:!0,identifier:e.name,once:`${i}:${e.name}`});let s=jr(e.plugins);await Ar(s,e);let u=Z(e.entry),g=o?.type;if(!e.dtsOnly){let m=[Tr(e,o),...$r(e.plugins).map((b)=>b.plugin)],x=e.format.flatMap((b)=>u.map(async(a)=>{let k=e.outputExtension?.({format:b,packageType:g,options:e,entry:a}).js??nr(b,g),B=await Bun.build({entrypoints:[`${n}/${a.fullEntryPath}`],format:b,naming:{entry:wr(a.name,k)},splitting:Mr(e.splitting,b),bytecode:yr(e.bytecode,b),define:Ir(e.define,e.shims,e.env,b),minify:Lr(e),outdir:`${n}/${e.outDir}`,target:e.target,sourcemap:e.sourcemap,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer,publicPath:e.publicPath,env:Or(e.env),plugins:[...m,Er({format:b,target:e.target,shims:e.shims})],throw:!1});if(!B.success)for(let d of B.logs){if(d.level==="error")throw new h(d.message);if(d.level==="warning")f.warn(d.message);else if(d.level==="info")f.info(d.message)}let L=Wr(e.outDir,a.name,k),y=Ur(n,L);t.files.push({fullPath:y,relativePathToOutputDir:L}),f.progress(b.toUpperCase(),L,{identifier:e.name})}));await Promise.all(x)}if(e.dts||e.dtsOnly){let m=await Sr(n,e.preferredTsconfigPath);if(m.path)f.cli(`Using ${I(m.path,2)}`,{muted:!0,identifier:e.name,once:`${m.path}:${e.name}`});let x=e.format.filter((a)=>{if(a==="iife"&&!R(g)&&e.format.includes("cjs"))return!1;return!0}),b=typeof e.dts==="object"&&e.dts.entry?Z(e.dts.entry):Br(u);try{await Promise.all(b.map(async(a)=>{let k=await lr(n,a.fullEntryPath,e,m,o);await Promise.all(x.map(async(B)=>{let L=e.outputExtension?.({format:B,packageType:g,options:e,entry:a}).dts??er(B,g),y=Wr(e.outDir,a.name,L),d=Ur(n,y);t.files.push({fullPath:d,relativePathToOutputDir:y}),await Bun.write(d,k),f.progress("DTS",y,{identifier:e.name})}))}))}catch(a){if(P(a))throw a;throw new p(l(a))}}if(await _r(s,e,t),e.onSuccess)await e.onSuccess(e)}function Wr(r,n,t){return`${r}/${n}${t}`}function Ur(r,n){return`${r}/${n}`}export{Dr as defineWorkspace,Hr as defineConfig,wn as build};
15
+ `}};function Er({format:r,target:n,shims:t}){let o=Cn(t).map((i)=>z[i]).filter((i)=>i.appliesTo(r,n));if(o.length===0)return{name:"bunup:inject-shims",setup(){}};return{name:"bunup:inject-shims",setup(i){i.onLoad({filter:ln},async({path:s})=>{let u=await Bun.file(s).text(),g=o.filter((a)=>a.isNeededInFile(u));if(g.length===0)return;let{shebangLine:m,codeContent:p}=Bn(u),b=g.map((a)=>a.generateCode()).join("");return{contents:m+b+p}})}}}function Cn(r){if(r===!0)return Object.keys(z);if(!r)return[];return Object.entries(r).filter(([n,t])=>t&&(n in z)).map(([n])=>n)}function Bn(r){if(!r.startsWith("#!"))return{shebangLine:"",codeContent:r};let n=r.indexOf(`
16
+ `);return n===-1?{shebangLine:"",codeContent:r}:{shebangLine:r.slice(0,n+1),codeContent:r.slice(n+1)}}function $r(r){if(!r)return[];return r.filter((n)=>n.type==="bun")}function jr(r){if(!r)return[];return r.filter((n)=>n.type==="bunup")}async function Ar(r,n){if(!r)return;for(let t of r)if(t.hooks.onBuildStart)await t.hooks.onBuildStart(n)}async function _r(r,n,t){if(!r)return;for(let e of r)if(e.hooks.onBuildDone)await e.hooks.onBuildDone({options:n,output:t})}async function wn(r,n=process.cwd()){let t={files:[]},e=kr(r);if(!e.entry||e.entry.length===0||!e.outDir)throw new h("Nothing to build. Please make sure you have provided a proper bunup configuration or cli arguments.");if(e.clean)or(n,e.outDir);v(e.silent);let{packageJson:o,path:i}=await Rr(n);if(o&&i)x.cli(`Using ${I(i,2)}`,{muted:!0,identifier:e.name,once:`${i}:${e.name}`});let s=jr(e.plugins);await Ar(s,e);let u=Z(e.entry),g=o?.type;if(!e.dtsOnly){let m=[Tr(e,o),...$r(e.plugins).map((b)=>b.plugin)],p=e.format.flatMap((b)=>u.map(async(a)=>{let k=e.outputExtension?.({format:b,packageType:g,options:e,entry:a}).js??nr(b,g),B=await Bun.build({entrypoints:[`${n}/${a.fullEntryPath}`],format:b,naming:{entry:wr(a.name,k)},splitting:Mr(e.splitting,b),bytecode:yr(e.bytecode,b),define:Ir(e.define,e.shims,e.env,b),minify:Lr(e),outdir:`${n}/${e.outDir}`,target:e.target,sourcemap:e.sourcemap,loader:e.loader,drop:e.drop,banner:e.banner,footer:e.footer,publicPath:e.publicPath,env:Or(e.env),plugins:[...m,Er({format:b,target:e.target,shims:e.shims})],throw:!1});if(!B.success)for(let d of B.logs){if(d.level==="error")throw new h(d.message);if(d.level==="warning")x.warn(d.message);else if(d.level==="info")x.info(d.message)}let L=Wr(e.outDir,a.name,k),y=Ur(n,L);t.files.push({fullPath:y,relativePathToOutputDir:L}),x.progress(b.toUpperCase(),L,{identifier:e.name})}));await Promise.all(p)}if(e.dts||e.dtsOnly){let m=await Sr(n,e.preferredTsconfigPath);if(m.path)x.cli(`Using ${I(m.path,2)}`,{muted:!0,identifier:e.name,once:`${m.path}:${e.name}`});let p=e.format.filter((a)=>{if(a==="iife"&&!R(g)&&e.format.includes("cjs"))return!1;return!0}),b=typeof e.dts==="object"&&e.dts.entry?Z(e.dts.entry):Br(u);try{await Promise.all(b.map(async(a)=>{let k=await lr(n,a.fullEntryPath,e,m,o);await Promise.all(p.map(async(B)=>{let L=e.outputExtension?.({format:B,packageType:g,options:e,entry:a}).dts??er(B,g),y=Wr(e.outDir,a.name,L),d=Ur(n,y);t.files.push({fullPath:d,relativePathToOutputDir:y}),await Bun.write(d,k),x.progress("DTS",y,{identifier:e.name})}))}))}catch(a){if(P(a))throw a;throw new f(l(a))}}if(await _r(s,e,t),e.onSuccess)await e.onSuccess(e)}function Wr(r,n,t){return`${r}/${n}${t}`}function Ur(r,n){return`${r}/${n}`}export{Dr as defineWorkspace,Hr as defineConfig,wn as build};
@@ -0,0 +1,2 @@
1
+ // @bun @bun-cjs
2
+ (function(exports, require, module, __filename, __dirname) {var $=Object.create;var{getPrototypeOf:j,defineProperty:p,getOwnPropertyNames:T,getOwnPropertyDescriptor:A}=Object,k=Object.prototype.hasOwnProperty;var y=(r,e,t)=>{t=r!=null?$(j(r)):{};let n=e||!r||!r.__esModule?p(t,"default",{value:r,enumerable:!0}):t;for(let i of T(r))if(!k.call(n,i))p(n,i,{get:()=>r[i],enumerable:!0});return n},L=new WeakMap,S=(r)=>{var e=L.get(r),t;if(e)return e;if(e=p({},"__esModule",{value:!0}),r&&typeof r==="object"||typeof r==="function")T(r).map((n)=>!k.call(e,n)&&p(e,n,{get:()=>r[n],enumerable:!(t=A(r,n))||t.enumerable}));return L.set(r,e),e},N=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports);var W=(r,e)=>{for(var t in e)p(r,t,{get:e[t],enumerable:!0,configurable:!0,set:(n)=>e[t]=()=>n})};var R=N((V,M)=>{var w=process||{},I=w.argv||[],C=w.env||{},_=!(!!C.NO_COLOR||I.includes("--no-color"))&&(!!C.FORCE_COLOR||I.includes("--color")||w.platform==="win32"||(w.stdout||{}).isTTY&&C.TERM!=="dumb"||!!C.CI),Y=(r,e,t=r)=>(n)=>{let i=""+n,a=i.indexOf(e,r.length);return~a?r+K(i,e,t,a)+e:r+i+e},K=(r,e,t,n)=>{let i="",a=0;do i+=r.substring(a,n)+t,a=n+e.length,n=r.indexOf(e,a);while(~n);return i+r.substring(a)},D=(r=_)=>{let e=r?Y:()=>String;return{isColorSupported:r,reset:e("\x1B[0m","\x1B[0m"),bold:e("\x1B[1m","\x1B[22m","\x1B[22m\x1B[1m"),dim:e("\x1B[2m","\x1B[22m","\x1B[22m\x1B[2m"),italic:e("\x1B[3m","\x1B[23m"),underline:e("\x1B[4m","\x1B[24m"),inverse:e("\x1B[7m","\x1B[27m"),hidden:e("\x1B[8m","\x1B[28m"),strikethrough:e("\x1B[9m","\x1B[29m"),black:e("\x1B[30m","\x1B[39m"),red:e("\x1B[31m","\x1B[39m"),green:e("\x1B[32m","\x1B[39m"),yellow:e("\x1B[33m","\x1B[39m"),blue:e("\x1B[34m","\x1B[39m"),magenta:e("\x1B[35m","\x1B[39m"),cyan:e("\x1B[36m","\x1B[39m"),white:e("\x1B[37m","\x1B[39m"),gray:e("\x1B[90m","\x1B[39m"),bgBlack:e("\x1B[40m","\x1B[49m"),bgRed:e("\x1B[41m","\x1B[49m"),bgGreen:e("\x1B[42m","\x1B[49m"),bgYellow:e("\x1B[43m","\x1B[49m"),bgBlue:e("\x1B[44m","\x1B[49m"),bgMagenta:e("\x1B[45m","\x1B[49m"),bgCyan:e("\x1B[46m","\x1B[49m"),bgWhite:e("\x1B[47m","\x1B[49m"),blackBright:e("\x1B[90m","\x1B[39m"),redBright:e("\x1B[91m","\x1B[39m"),greenBright:e("\x1B[92m","\x1B[39m"),yellowBright:e("\x1B[93m","\x1B[39m"),blueBright:e("\x1B[94m","\x1B[39m"),magentaBright:e("\x1B[95m","\x1B[39m"),cyanBright:e("\x1B[96m","\x1B[39m"),whiteBright:e("\x1B[97m","\x1B[39m"),bgBlackBright:e("\x1B[100m","\x1B[49m"),bgRedBright:e("\x1B[101m","\x1B[49m"),bgGreenBright:e("\x1B[102m","\x1B[49m"),bgYellowBright:e("\x1B[103m","\x1B[49m"),bgBlueBright:e("\x1B[104m","\x1B[49m"),bgMagentaBright:e("\x1B[105m","\x1B[49m"),bgCyanBright:e("\x1B[106m","\x1B[49m"),bgWhiteBright:e("\x1B[107m","\x1B[49m")}};M.exports=D();M.exports.createColors=D});var q={};W(q,{report:()=>J});module.exports=S(q);var f=y(R());var o=y(R()),U=!1;class x{static instance;loggedOnceMessages=new Set;MAX_LABEL_LENGTH=3;cliColor=o.default.blue;mutedColor=o.default.dim;infoColor=o.default.cyan;warnColor=o.default.yellow;errorColor=o.default.red;defaultColor=o.default.white;progressFgColorMap={ESM:o.default.yellow,CJS:o.default.green,IIFE:o.default.magenta,DTS:o.default.blue};progressBgColorMap={ESM:o.default.bgYellow,CJS:o.default.bgGreen,IIFE:o.default.bgMagenta,DTS:o.default.bgBlue};labels={cli:"CLI",info:"INFO",warn:"WARN",error:"ERROR"};constructor(){}static getInstance(){if(!x.instance)x.instance=new x;return x.instance}dispose(){this.loggedOnceMessages.clear()}shouldLog(r){if(!r?.once)return!0;if(this.loggedOnceMessages.has(r.once))return!1;return this.loggedOnceMessages.add(r.once),!0}formatMessage({fgColor:r,bgColor:e,label:t,message:n,identifier:i,muted:a}){let b=" ".repeat(Math.max(0,this.MAX_LABEL_LENGTH-t.length)),s=a?this.mutedColor(n):n,g=i?` ${e(o.default.black(` ${i} `))}`:"";return`${r(t)} ${b}${s}${g}`}output(r,e={},t=console.log){if(U||!this.shouldLog(e))return;if(e.verticalSpace)t("");if(t(r),e.verticalSpace)t("")}cli(r,e={}){let t=this.formatMessage({fgColor:this.cliColor,bgColor:o.default.bgBlue,label:this.labels.cli,message:r,identifier:e.identifier,muted:e.muted});this.output(t,e)}info(r,e={}){let t=this.formatMessage({fgColor:this.infoColor,bgColor:o.default.bgCyan,label:this.labels.info,message:r,identifier:e.identifier,muted:e.muted});this.output(t,e)}warn(r,e={}){let t=this.formatMessage({fgColor:this.warnColor,bgColor:o.default.bgYellow,label:this.labels.warn,message:r,identifier:e.identifier,muted:e.muted});this.output(t,e,console.warn)}error(r,e={}){let t=this.formatMessage({fgColor:this.errorColor,bgColor:o.default.bgRed,label:this.labels.error,message:r,identifier:e.identifier,muted:e.muted});this.output(t,e,console.error)}getProgressFgColor(r){for(let[e,t]of Object.entries(this.progressFgColorMap))if(r.includes(e))return t;return this.defaultColor}getProgressBgColor(r){for(let[e,t]of Object.entries(this.progressBgColorMap))if(r.includes(e))return t;return o.default.bgWhite}progress(r,e,t={}){let n=this.getProgressFgColor(r),i=this.getProgressBgColor(r),a=this.formatMessage({fgColor:n,bgColor:i,label:r,message:e,identifier:t.identifier,muted:t.muted});this.output(a,t)}}function F(r,e,t){let n={};for(let s of r){let g=s.header.length,l=e.map((m)=>m[s.header]?.length||0),d=t?t[s.header]?.length||0:0;n[s.header]=Math.max(g,...l,d)}let i=(s,g,l)=>{return l==="left"?s.padEnd(g):s.padStart(g)},a=r.map((s)=>i(s.header,n[s.header],s.align)).join(o.default.gray(" | "));console.log(o.default.gray(a));let b=r.map((s)=>"-".repeat(n[s.header])).join(" | ");console.log(o.default.gray(b));for(let s of e){let g=r.map((l)=>{let d=s[l.header]||"",m=i(d,n[l.header],l.align);return l.color?l.color(m):m}).join(o.default.gray(" | "));console.log(g)}if(console.log(o.default.gray(b)),t){let s=r.map((g)=>{let l=t[g.header]||"";return i(l,n[g.header],g.align)}).join(o.default.gray(" | "));console.log(s)}}var H=x.getInstance();var X=y(R());function h(r){if(r===0)return"0 B";let e=["B","KB","MB","GB"],t=Math.floor(Math.log(r)/Math.log(1024));if(t===0)return`${r} ${e[t]}`;return`${(r/1024**t).toFixed(2)} ${e[t]}`}function J(r={}){let{maxBundleSize:e,gzip:t=!0}=r;return{type:"bunup",name:"report",hooks:{onBuildDone:async({options:n,output:i})=>{if(n.watch)return;let a=await Promise.all(i.files.map(async(c)=>{let u=c.relativePathToOutputDir,v=Bun.file(c.fullPath).size,E,O;if(t){let P=await Bun.file(c.fullPath).text();E=Bun.gzipSync(P).length,O=h(E)}return{name:u,size:v,formattedSize:h(v),gzipSize:E,formattedGzipSize:O}})),b=a.reduce((c,u)=>c+u.size,0),s=h(b),g,l;if(t)g=a.reduce((c,u)=>c+(u.gzipSize||0),0),l=h(g);let d=[{header:"File",align:"left",color:f.default.blue},{header:"Size",align:"right",color:f.default.green}];if(t)d.push({header:"Gzip",align:"right",color:f.default.magenta});let m=a.map((c)=>{let u={File:c.name,Size:c.formattedSize};if(t&&c.formattedGzipSize)u.Gzip=c.formattedGzipSize;return u}),B={File:"Total",Size:s};if(t&&l)B.Gzip=l;if(console.log(""),F(d,m,B),e&&b>e)console.log(""),console.log(f.default.red(`Your bundle size of ${s} exceeds the configured limit of ${h(e)}`));console.log("")}}}}})