dtsroll 1.0.0 → 1.2.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/README.md CHANGED
@@ -6,15 +6,15 @@ _dtsroll_ is a CLI tool for bundling TypeScript declaration (`.d.ts`) files.
6
6
 
7
7
  - **Smaller distribution**
8
8
 
9
- Tree-shaking removes unused code, keeping only what's needed and reducing the output size.
9
+ Tree-shaking removes unused code, keeping only what's needed and reducing the output size.
10
10
 
11
11
  - **Bundle in private dependencies**
12
12
 
13
- Inline types from private dependencies (e.g., monorepo packages) that aren't accessible to consumers.
13
+ Inline types from private dependencies (e.g., monorepo packages) that aren't accessible to consumers.
14
14
 
15
15
  - **Improve TS performance**
16
16
 
17
- Flattens multiple files into one, reducing TypeScript's file resolution for type checking.
17
+ Flattens multiple files into one, reducing TypeScript's file resolution for type checking.
18
18
 
19
19
  ## Install
20
20
  ```
@@ -24,14 +24,14 @@ npm install --save-dev dtsroll
24
24
  ## Quick start
25
25
 
26
26
  1. Compile your TypeScript code with declaration (`.d.ts`) files
27
- - If using the TypeScript compiler (`tsc`), enable [`declaration`](https://www.typescriptlang.org/tsconfig/#declaration)
28
- - If using Vite, use a plugin like [vite-plugin-dts](https://www.npmjs.com/package/vite-plugin-dts)
27
+ - If using the TypeScript compiler (`tsc`), enable [`declaration`](https://www.typescriptlang.org/tsconfig/#declaration)
28
+ - If using Vite, use a plugin like [vite-plugin-dts](https://www.npmjs.com/package/vite-plugin-dts)
29
29
 
30
30
  2. Pass in the entry declaration file to _dtsroll_
31
31
 
32
- ```sh
33
- dtsroll --dry-run dist/index.d.ts
34
- ```
32
+ ```sh
33
+ dtsroll --dry-run dist/index.d.ts
34
+ ```
35
35
 
36
36
  > [!CAUTION]
37
37
  > _dtsroll_ is designed to run on compiled output so it modifies files in-place.
@@ -41,9 +41,9 @@ npm install --save-dev dtsroll
41
41
 
42
42
  3. If the changes look good, remove the `--dry-run` flag:
43
43
 
44
- ```sh
45
- dtsroll dist/index.d.ts
46
- ```
44
+ ```sh
45
+ dtsroll dist/index.d.ts
46
+ ```
47
47
 
48
48
  ### Recommended setup
49
49
 
@@ -80,7 +80,7 @@ Because the main package is in `dependencies`, _dtsroll_ externalizes it. Howev
80
80
 
81
81
  To fix this, _dtsroll_ will display a warning suggesting you move the `@types/*` package out of `devDependencies`.
82
82
 
83
- ## CLI Options
83
+ ## CLI
84
84
 
85
85
  ### --help, -h
86
86
  Display usage instructions.
@@ -97,6 +97,54 @@ If there is no `package.json` file, you can specify package names to exclude fro
97
97
  ### --conditions, -C
98
98
  Provide resolution conditions to target specific entry points in dependencies, similar to Node’s [`--conditions`](https://nodejs.org/api/cli.html#-c-condition---conditionscondition).
99
99
 
100
+ ## Node.js API
101
+ ```ts
102
+ import { dtsroll } from 'dtsroll'
103
+
104
+ await dtsroll(options as {
105
+
106
+ /**
107
+ * CWD to find the package.json in
108
+ * @default process.cwd()
109
+ */
110
+ cwd?: string
111
+
112
+ /**
113
+ * Defaults to auto-detecting d.ts files from package.json
114
+ */
115
+ inputs?: string[]
116
+
117
+ /**
118
+ * Only used if there's no package.json
119
+ * Defaults to auto-detecting dependencies from package.json
120
+ */
121
+ external?: string[]
122
+
123
+ conditions?: string[]
124
+
125
+ dryRun?: boolean
126
+ })
127
+ ```
128
+
129
+ ## Vite plugin
130
+
131
+ Use it in conjunction with a plugin that generates the initial declaration files like `vite-plugin-dts`.
132
+
133
+ ```ts
134
+ import { defineConfig } from 'vitest/config'
135
+ import dts from 'vite-plugin-dts'
136
+ import { dtsroll } from 'dtsroll/vite'
137
+
138
+ export default defineConfig({
139
+ // ...
140
+ plugins: [
141
+ // ...
142
+ dts(),
143
+ dtsroll()
144
+ ]
145
+ })
146
+ ```
147
+
100
148
  ## Related
101
149
 
102
150
  ### pkgroll
package/dist/cli.mjs CHANGED
@@ -1,37 +1,66 @@
1
1
  #!/usr/bin/env node
2
- var Lu=Object.defineProperty;var s=(u,D)=>Lu(u,"name",{value:D,configurable:!0});import g from"node:path";import _u from"tty";import I from"node:fs/promises";import{rollup as Wu}from"rollup";import{dts as Gu}from"rollup-plugin-dts";import Yu from"@rollup/plugin-node-resolve";const Zu="known-flag",Ju="unknown-flag",Uu="argument",{stringify:x}=JSON,qu=/\B([A-Z])/g,Ku=s(u=>u.replace(qu,"-$1").toLowerCase(),"v$1"),{hasOwnProperty:Hu}=Object.prototype,O=s((u,D)=>Hu.call(u,D),"w$2"),Vu=s(u=>Array.isArray(u),"L$2"),ru=s(u=>typeof u=="function"?[u,!1]:Vu(u)?[u[0],!0]:ru(u.type),"b$2"),Qu=s((u,D)=>u===Boolean?D!=="false":D,"d$2"),Xu=s((u,D)=>typeof D=="boolean"?D:u===Number&&D===""?Number.NaN:u(D),"m$1"),uD=/[\s.:=]/,DD=s(u=>{const D=`Flag name ${x(u)}`;if(u.length===0)throw new Error(`${D} cannot be empty`);if(u.length===1)throw new Error(`${D} must be longer than a character`);const e=u.match(uD);if(e)throw new Error(`${D} cannot contain ${x(e?.[0])}`)},"B"),eD=s(u=>{const D={},e=s((t,n)=>{if(O(D,t))throw new Error(`Duplicate flags named ${x(t)}`);D[t]=n},"r");for(const t in u){if(!O(u,t))continue;DD(t);const n=u[t],o=[[],...ru(n),n];e(t,o);const r=Ku(t);if(t!==r&&e(r,o),"alias"in n&&typeof n.alias=="string"){const{alias:i}=n,a=`Flag alias ${x(i)} for flag ${x(t)}`;if(i.length===0)throw new Error(`${a} cannot be empty`);if(i.length>1)throw new Error(`${a} must be a single character`);e(i,o)}}return D},"K$1"),tD=s((u,D)=>{const e={};for(const t in u){if(!O(u,t))continue;const[n,,o,r]=D[t];if(n.length===0&&"default"in r){let{default:i}=r;typeof i=="function"&&(i=i()),e[t]=i}else e[t]=o?n:n.pop()}return e},"_$2"),N="--",nD=/[.:=]/,oD=/^-{1,2}\w/,rD=s(u=>{if(!oD.test(u))return;const D=!u.startsWith(N);let e=u.slice(D?1:2),t;const n=e.match(nD);if(n){const{index:o}=n;t=e.slice(o+1),e=e.slice(0,o)}return[e,t,D]},"N"),iD=s((u,{onFlag:D,onArgument:e})=>{let t;const n=s((o,r)=>{if(typeof t!="function")return!0;t(o,r),t=void 0},"o");for(let o=0;o<u.length;o+=1){const r=u[o];if(r===N){n();const a=u.slice(o+1);e?.(a,[o],!0);break}const i=rD(r);if(i){if(n(),!D)continue;const[a,F,l]=i;if(l)for(let C=0;C<a.length;C+=1){n();const E=C===a.length-1;t=D(a[C],E?F:void 0,[o,C+1,E])}else t=D(a,F,[o])}else n(r,[o])&&e?.([r],[o])}n()},"$$1"),sD=s((u,D)=>{for(const[e,t,n]of D.reverse()){if(t){const o=u[e];let r=o.slice(0,t);if(n||(r+=o.slice(t+1)),r!=="-"){u[e]=r;continue}}u.splice(e,1)}},"E"),aD=s((u,D=process.argv.slice(2),{ignore:e}={})=>{const t=[],n=eD(u),o={},r=[];return r[N]=[],iD(D,{onFlag(i,a,F){const l=O(n,i);if(!e?.(l?Zu:Ju,i,a)){if(l){const[C,E]=n[i],p=Qu(E,a),f=s((c,d)=>{t.push(F),d&&t.push(d),C.push(Xu(E,c||""))},"p");return p===void 0?f:f(p)}O(o,i)||(o[i]=[]),o[i].push(a===void 0?!0:a),t.push(F)}},onArgument(i,a,F){e?.(Uu,D[a[0]])||(r.push(...i),F?(r[N]=i,D.splice(a[0])):t.push(a))}}),sD(D,t),{flags:tD(u,n),unknownFlags:o,_:r}},"U$2");var FD=Object.create,T=Object.defineProperty,lD=Object.defineProperties,CD=Object.getOwnPropertyDescriptor,ED=Object.getOwnPropertyDescriptors,cD=Object.getOwnPropertyNames,iu=Object.getOwnPropertySymbols,pD=Object.getPrototypeOf,su=Object.prototype.hasOwnProperty,fD=Object.prototype.propertyIsEnumerable,au=s((u,D,e)=>D in u?T(u,D,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[D]=e,"W$1"),z=s((u,D)=>{for(var e in D||(D={}))su.call(D,e)&&au(u,e,D[e]);if(iu)for(var e of iu(D))fD.call(D,e)&&au(u,e,D[e]);return u},"p"),Z=s((u,D)=>lD(u,ED(D)),"c"),dD=s(u=>T(u,"__esModule",{value:!0}),"nD"),gD=s((u,D)=>()=>(u&&(D=u(u=0)),D),"rD"),BD=s((u,D)=>()=>(D||u((D={exports:{}}).exports,D),D.exports),"iD"),hD=s((u,D,e,t)=>{if(D&&typeof D=="object"||typeof D=="function")for(let n of cD(D))!su.call(u,n)&&n!=="default"&&T(u,n,{get:s(()=>D[n],"get"),enumerable:!(t=CD(D,n))||t.enumerable});return u},"oD"),mD=s((u,D)=>hD(dD(T(u!=null?FD(pD(u)):{},"default",{value:u,enumerable:!0})),u),"BD"),B=gD(()=>{}),AD=BD((u,D)=>{B(),D.exports=function(){return/\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67)\uDB40\uDC7F|(?:\uD83E\uDDD1\uD83C\uDFFF\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFC-\uDFFF])|\uD83D\uDC68(?:\uD83C\uDFFB(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|[\u2695\u2696\u2708]\uFE0F|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))?|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFF]))|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])\uFE0F|\u200D(?:(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D[\uDC66\uDC67])|\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC)?|(?:\uD83D\uDC69(?:\uD83C\uDFFB\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|(?:\uD83C[\uDFFC-\uDFFF])\u200D\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69]))|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC69(?:\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83E\uDDD1(?:\u200D(?:\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|\uD83D\uDE36\u200D\uD83C\uDF2B|\uD83C\uDFF3\uFE0F\u200D\u26A7|\uD83D\uDC3B\u200D\u2744|(?:(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\uD83C\uDFF4\u200D\u2620|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])\u200D[\u2640\u2642]|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u2600-\u2604\u260E\u2611\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26B0\u26B1\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0\u26F1\u26F4\u26F7\u26F8\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u3030\u303D\u3297\u3299]|\uD83C[\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]|\uD83D[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3])\uFE0F|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDE35\u200D\uD83D\uDCAB|\uD83D\uDE2E\u200D\uD83D\uDCA8|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83E\uDDD1(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83D\uDC69(?:\uD83C\uDFFF|\uD83C\uDFFE|\uD83C\uDFFD|\uD83C\uDFFC|\uD83C\uDFFB)?|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF6\uD83C\uDDE6|\uD83C\uDDF4\uD83C\uDDF2|\uD83D\uDC08\u200D\u2B1B|\u2764\uFE0F\u200D(?:\uD83D\uDD25|\uD83E\uDE79)|\uD83D\uDC41\uFE0F|\uD83C\uDFF3\uFE0F|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|[#\*0-9]\uFE0F\u20E3|\u2764\uFE0F|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|\uD83C\uDFF4|(?:[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270C\u270D]|\uD83D[\uDD74\uDD90])(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])|[\u270A\u270B]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC08\uDC15\uDC3B\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE2E\uDE35\uDE36\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5]|\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD]|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF]|[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0D\uDD0E\uDD10-\uDD17\uDD1D\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78\uDD7A-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCB\uDDD0\uDDE0-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6]|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5-\uDED7\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26A7\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5-\uDED7\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDD78\uDD7A-\uDDCB\uDDCD-\uDDFF\uDE70-\uDE74\uDE78-\uDE7A\uDE80-\uDE86\uDE90-\uDEA8\uDEB0-\uDEB6\uDEC0-\uDEC2\uDED0-\uDED6])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0C\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDD77\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g}});B(),B(),B();var bD=s(u=>{var D,e,t;let n=(D=process.stdout.columns)!=null?D:Number.POSITIVE_INFINITY;return typeof u=="function"&&(u=u(n)),u||(u={}),Array.isArray(u)?{columns:u,stdoutColumns:n}:{columns:(e=u.columns)!=null?e:[],stdoutColumns:(t=u.stdoutColumns)!=null?t:n}},"v");B(),B(),B(),B(),B();function yD({onlyFirst:u=!1}={}){let D=["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)","(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))"].join("|");return new RegExp(D,u?void 0:"g")}s(yD,"w$1");function Fu(u){if(typeof u!="string")throw new TypeError(`Expected a \`string\`, got \`${typeof u}\``);return u.replace(yD(),"")}s(Fu,"d$1"),B();function wD(u){return Number.isInteger(u)?u>=4352&&(u<=4447||u===9001||u===9002||11904<=u&&u<=12871&&u!==12351||12880<=u&&u<=19903||19968<=u&&u<=42182||43360<=u&&u<=43388||44032<=u&&u<=55203||63744<=u&&u<=64255||65040<=u&&u<=65049||65072<=u&&u<=65131||65281<=u&&u<=65376||65504<=u&&u<=65510||110592<=u&&u<=110593||127488<=u&&u<=127569||131072<=u&&u<=262141):!1}s(wD,"y$1");var $D=mD(AD());function y(u){if(typeof u!="string"||u.length===0||(u=Fu(u),u.length===0))return 0;u=u.replace((0,$D.default)()," ");let D=0;for(let e=0;e<u.length;e++){let t=u.codePointAt(e);t<=31||t>=127&&t<=159||t>=768&&t<=879||(t>65535&&e++,D+=wD(t)?2:1)}return D}s(y,"g");var lu=s(u=>Math.max(...u.split(`
3
- `).map(y)),"b$1"),vD=s(u=>{let D=[];for(let e of u){let{length:t}=e,n=t-D.length;for(let o=0;o<n;o+=1)D.push(0);for(let o=0;o<t;o+=1){let r=lu(e[o]);r>D[o]&&(D[o]=r)}}return D},"k$1");B();var Cu=/^\d+%$/,Eu={width:"auto",align:"left",contentWidth:0,paddingLeft:0,paddingRight:0,paddingTop:0,paddingBottom:0,horizontalPadding:0,paddingLeftString:"",paddingRightString:""},xD=s((u,D)=>{var e;let t=[];for(let n=0;n<u.length;n+=1){let o=(e=D[n])!=null?e:"auto";if(typeof o=="number"||o==="auto"||o==="content-width"||typeof o=="string"&&Cu.test(o)){t.push(Z(z({},Eu),{width:o,contentWidth:u[n]}));continue}if(o&&typeof o=="object"){let r=Z(z(z({},Eu),o),{contentWidth:u[n]});r.horizontalPadding=r.paddingLeft+r.paddingRight,t.push(r);continue}throw new Error(`Invalid column width: ${JSON.stringify(o)}`)}return t},"sD");function OD(u,D){for(let e of u){let{width:t}=e;if(t==="content-width"&&(e.width=e.contentWidth),t==="auto"){let a=Math.min(20,e.contentWidth);e.width=a,e.autoOverflow=e.contentWidth-a}if(typeof t=="string"&&Cu.test(t)){let a=Number.parseFloat(t.slice(0,-1))/100;e.width=Math.floor(D*a)-(e.paddingLeft+e.paddingRight)}let{horizontalPadding:n}=e,o=1,r=o+n;if(r>=D){let a=r-D,F=Math.ceil(e.paddingLeft/n*a),l=a-F;e.paddingLeft-=F,e.paddingRight-=l,e.horizontalPadding=e.paddingLeft+e.paddingRight}e.paddingLeftString=e.paddingLeft?" ".repeat(e.paddingLeft):"",e.paddingRightString=e.paddingRight?" ".repeat(e.paddingRight):"";let i=D-e.horizontalPadding;e.width=Math.max(Math.min(e.width,i),o)}}s(OD,"aD");var cu=s(()=>Object.assign([],{columns:0}),"G");function MD(u,D){let e=[cu()],[t]=e;for(let n of u){let o=n.width+n.horizontalPadding;t.columns+o>D&&(t=cu(),e.push(t)),t.push(n),t.columns+=o}for(let n of e){let o=n.reduce((E,p)=>E+p.width+p.horizontalPadding,0),r=D-o;if(r===0)continue;let i=n.filter(E=>"autoOverflow"in E),a=i.filter(E=>E.autoOverflow>0),F=a.reduce((E,p)=>E+p.autoOverflow,0),l=Math.min(F,r);for(let E of a){let p=Math.floor(E.autoOverflow/F*l);E.width+=p,r-=p}let C=Math.floor(r/i.length);for(let E=0;E<i.length;E+=1){let p=i[E];E===i.length-1?p.width+=r:p.width+=C,r-=C}}return e}s(MD,"lD");function jD(u,D,e){let t=xD(e,D);return OD(t,u),MD(t,u)}s(jD,"Z$1"),B(),B(),B();var J=10,pu=s((u=0)=>D=>`\x1B[${D+u}m`,"U$1"),fu=s((u=0)=>D=>`\x1B[${38+u};5;${D}m`,"V$1"),du=s((u=0)=>(D,e,t)=>`\x1B[${38+u};2;${D};${e};${t}m`,"Y");function PD(){let u=new Map,D={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};D.color.gray=D.color.blackBright,D.bgColor.bgGray=D.bgColor.bgBlackBright,D.color.grey=D.color.blackBright,D.bgColor.bgGrey=D.bgColor.bgBlackBright;for(let[e,t]of Object.entries(D)){for(let[n,o]of Object.entries(t))D[n]={open:`\x1B[${o[0]}m`,close:`\x1B[${o[1]}m`},t[n]=D[n],u.set(o[0],o[1]);Object.defineProperty(D,e,{value:t,enumerable:!1})}return Object.defineProperty(D,"codes",{value:u,enumerable:!1}),D.color.close="\x1B[39m",D.bgColor.close="\x1B[49m",D.color.ansi=pu(),D.color.ansi256=fu(),D.color.ansi16m=du(),D.bgColor.ansi=pu(J),D.bgColor.ansi256=fu(J),D.bgColor.ansi16m=du(J),Object.defineProperties(D,{rgbToAnsi256:{value:s((e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),"value"),enumerable:!1},hexToRgb:{value:s(e=>{let t=/(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(e.toString(16));if(!t)return[0,0,0];let{colorString:n}=t.groups;n.length===3&&(n=n.split("").map(r=>r+r).join(""));let o=Number.parseInt(n,16);return[o>>16&255,o>>8&255,o&255]},"value"),enumerable:!1},hexToAnsi256:{value:s(e=>D.rgbToAnsi256(...D.hexToRgb(e)),"value"),enumerable:!1},ansi256ToAnsi:{value:s(e=>{if(e<8)return 30+e;if(e<16)return 90+(e-8);let t,n,o;if(e>=232)t=((e-232)*10+8)/255,n=t,o=t;else{e-=16;let a=e%36;t=Math.floor(e/36)/5,n=Math.floor(a/6)/5,o=a%6/5}let r=Math.max(t,n,o)*2;if(r===0)return 30;let i=30+(Math.round(o)<<2|Math.round(n)<<1|Math.round(t));return r===2&&(i+=60),i},"value"),enumerable:!1},rgbToAnsi:{value:s((e,t,n)=>D.ansi256ToAnsi(D.rgbToAnsi256(e,t,n)),"value"),enumerable:!1},hexToAnsi:{value:s(e=>D.ansi256ToAnsi(D.hexToAnsi256(e)),"value"),enumerable:!1}}),D}s(PD,"AD");var kD=PD(),SD=kD,R=new Set(["\x1B","\x9B"]),ID=39,U="\x07",gu="[",ND="]",Bu="m",q=`${ND}8;;`,hu=s(u=>`${R.values().next().value}${gu}${u}${Bu}`,"J$1"),mu=s(u=>`${R.values().next().value}${q}${u}${U}`,"Q"),TD=s(u=>u.split(" ").map(D=>y(D)),"hD"),K=s((u,D,e)=>{let t=[...D],n=!1,o=!1,r=y(Fu(u[u.length-1]));for(let[i,a]of t.entries()){let F=y(a);if(r+F<=e?u[u.length-1]+=a:(u.push(a),r=0),R.has(a)&&(n=!0,o=t.slice(i+1).join("").startsWith(q)),n){o?a===U&&(n=!1,o=!1):a===Bu&&(n=!1);continue}r+=F,r===e&&i<t.length-1&&(u.push(""),r=0)}!r&&u[u.length-1].length>0&&u.length>1&&(u[u.length-2]+=u.pop())},"S$1"),zD=s(u=>{let D=u.split(" "),e=D.length;for(;e>0&&!(y(D[e-1])>0);)e--;return e===D.length?u:D.slice(0,e).join(" ")+D.slice(e).join("")},"cD"),RD=s((u,D,e={})=>{if(e.trim!==!1&&u.trim()==="")return"";let t="",n,o,r=TD(u),i=[""];for(let[F,l]of u.split(" ").entries()){e.trim!==!1&&(i[i.length-1]=i[i.length-1].trimStart());let C=y(i[i.length-1]);if(F!==0&&(C>=D&&(e.wordWrap===!1||e.trim===!1)&&(i.push(""),C=0),(C>0||e.trim===!1)&&(i[i.length-1]+=" ",C++)),e.hard&&r[F]>D){let E=D-C,p=1+Math.floor((r[F]-E-1)/D);Math.floor((r[F]-1)/D)<p&&i.push(""),K(i,l,D);continue}if(C+r[F]>D&&C>0&&r[F]>0){if(e.wordWrap===!1&&C<D){K(i,l,D);continue}i.push("")}if(C+r[F]>D&&e.wordWrap===!1){K(i,l,D);continue}i[i.length-1]+=l}e.trim!==!1&&(i=i.map(F=>zD(F)));let a=[...i.join(`
4
- `)];for(let[F,l]of a.entries()){if(t+=l,R.has(l)){let{groups:E}=new RegExp(`(?:\\${gu}(?<code>\\d+)m|\\${q}(?<uri>.*)${U})`).exec(a.slice(F).join(""))||{groups:{}};if(E.code!==void 0){let p=Number.parseFloat(E.code);n=p===ID?void 0:p}else E.uri!==void 0&&(o=E.uri.length===0?void 0:E.uri)}let C=SD.codes.get(Number(n));a[F+1]===`
5
- `?(o&&(t+=mu("")),n&&C&&(t+=hu(C))):l===`
6
- `&&(n&&C&&(t+=hu(n)),o&&(t+=mu(o)))}return t},"dD");function LD(u,D,e){return String(u).normalize().replace(/\r\n/g,`
7
- `).split(`
8
- `).map(t=>RD(t,D,e)).join(`
9
- `)}s(LD,"T$1");var Au=s(u=>Array.from({length:u}).fill(""),"X");function _D(u,D){let e=[],t=0;for(let n of u){let o=0,r=n.map(a=>{var F;let l=(F=D[t])!=null?F:"";t+=1,a.preprocess&&(l=a.preprocess(l)),lu(l)>a.width&&(l=LD(l,a.width,{hard:!0}));let C=l.split(`
10
- `);if(a.postprocess){let{postprocess:E}=a;C=C.map((p,f)=>E.call(a,p,f))}return a.paddingTop&&C.unshift(...Au(a.paddingTop)),a.paddingBottom&&C.push(...Au(a.paddingBottom)),C.length>o&&(o=C.length),Z(z({},a),{lines:C})}),i=[];for(let a=0;a<o;a+=1){let F=r.map(l=>{var C;let E=(C=l.lines[a])!=null?C:"",p=Number.isFinite(l.width)?" ".repeat(l.width-y(E)):"",f=l.paddingLeftString;return l.align==="right"&&(f+=p),f+=E,l.align==="left"&&(f+=p),f+l.paddingRightString}).join("");i.push(F)}e.push(i.join(`
11
- `))}return e.join(`
12
- `)}s(_D,"P");function WD(u,D){if(!u||u.length===0)return"";let e=vD(u),t=e.length;if(t===0)return"";let{stdoutColumns:n,columns:o}=bD(D);if(o.length>t)throw new Error(`${o.length} columns defined, but only ${t} columns found`);let r=jD(n,o,e);return u.map(i=>_D(r,i)).join(`
13
- `)}s(WD,"mD"),B();var GD=["<",">","=",">=","<="];function YD(u){if(!GD.includes(u))throw new TypeError(`Invalid breakpoint operator: ${u}`)}s(YD,"xD");function ZD(u){let D=Object.keys(u).map(e=>{let[t,n]=e.split(" ");YD(t);let o=Number.parseInt(n,10);if(Number.isNaN(o))throw new TypeError(`Invalid breakpoint value: ${n}`);let r=u[e];return{operator:t,breakpoint:o,value:r}}).sort((e,t)=>t.breakpoint-e.breakpoint);return e=>{var t;return(t=D.find(({operator:n,breakpoint:o})=>n==="="&&e===o||n===">"&&e>o||n==="<"&&e<o||n===">="&&e>=o||n==="<="&&e<=o))==null?void 0:t.value}}s(ZD,"wD");const JD=s(u=>u.replace(/[\W_]([a-z\d])?/gi,(D,e)=>e?e.toUpperCase():""),"S"),UD=s(u=>u.replace(/\B([A-Z])/g,"-$1").toLowerCase(),"q"),qD={"> 80":[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"auto"}],"> 40":[{width:"auto",paddingLeft:2,paddingRight:8,preprocess:s(u=>u.trim(),"preprocess")},{width:"100%",paddingLeft:2,paddingBottom:1}],"> 0":{stdoutColumns:1e3,columns:[{width:"content-width",paddingLeft:2,paddingRight:8},{width:"content-width"}]}};function KD(u){let D=!1;return{type:"table",data:{tableData:Object.keys(u).sort((e,t)=>e.localeCompare(t)).map(e=>{const t=u[e],n="alias"in t;return n&&(D=!0),{name:e,flag:t,flagFormatted:`--${UD(e)}`,aliasesEnabled:D,aliasFormatted:n?`-${t.alias}`:void 0}}).map(e=>(e.aliasesEnabled=D,[{type:"flagName",data:e},{type:"flagDescription",data:e}])),tableBreakpoints:qD}}}s(KD,"D");const bu=s(u=>!u||(u.version??(u.help?u.help.version:void 0)),"A"),yu=s(u=>{const D="parent"in u&&u.parent?.name;return(D?`${D} `:"")+u.name},"C");function HD(u){const D=[];u.name&&D.push(yu(u));const e=bu(u)??("parent"in u&&bu(u.parent));if(e&&D.push(`v${e}`),D.length!==0)return{id:"name",type:"text",data:`${D.join(" ")}
14
- `}}s(HD,"R");function VD(u){const{help:D}=u;if(!(!D||!D.description))return{id:"description",type:"text",data:`${D.description}
15
- `}}s(VD,"L");function QD(u){const D=u.help||{};if("usage"in D)return D.usage?{id:"usage",type:"section",data:{title:"Usage:",body:Array.isArray(D.usage)?D.usage.join(`
16
- `):D.usage}}:void 0;if(u.name){const e=[],t=[yu(u)];if(u.flags&&Object.keys(u.flags).length>0&&t.push("[flags...]"),u.parameters&&u.parameters.length>0){const{parameters:n}=u,o=n.indexOf("--"),r=o>-1&&n.slice(o+1).some(i=>i.startsWith("<"));t.push(n.map(i=>i!=="--"?i:r?"--":"[--]").join(" "))}if(t.length>1&&e.push(t.join(" ")),"commands"in u&&u.commands?.length&&e.push(`${u.name} <command>`),e.length>0)return{id:"usage",type:"section",data:{title:"Usage:",body:e.join(`
17
- `)}}}}s(QD,"T");function XD(u){return!("commands"in u)||!u.commands?.length?void 0:{id:"commands",type:"section",data:{title:"Commands:",body:{type:"table",data:{tableData:u.commands.map(D=>[D.options.name,D.options.help?D.options.help.description:""]),tableOptions:[{width:"content-width",paddingLeft:2,paddingRight:8}]}},indentBody:0}}}s(XD,"_");function ue(u){if(!(!u.flags||Object.keys(u.flags).length===0))return{id:"flags",type:"section",data:{title:"Flags:",body:KD(u.flags),indentBody:0}}}s(ue,"k");function De(u){const{help:D}=u;if(!D||!D.examples||D.examples.length===0)return;let{examples:e}=D;if(Array.isArray(e)&&(e=e.join(`
18
- `)),e)return{id:"examples",type:"section",data:{title:"Examples:",body:e}}}s(De,"F");function ee(u){if(!("alias"in u)||!u.alias)return;const{alias:D}=u;return{id:"aliases",type:"section",data:{title:"Aliases:",body:Array.isArray(D)?D.join(", "):D}}}s(ee,"H");const te=s(u=>[HD,VD,QD,XD,ue,De,ee].map(D=>D(u)).filter(Boolean),"U"),ne=_u.WriteStream.prototype.hasColors();class oe{static{s(this,"M")}text(D){return D}bold(D){return ne?`\x1B[1m${D}\x1B[22m`:D.toLocaleUpperCase()}indentText({text:D,spaces:e}){return D.replace(/^/gm," ".repeat(e))}heading(D){return this.bold(D)}section({title:D,body:e,indentBody:t=2}){return`${(D?`${this.heading(D)}
19
- `:"")+(e?this.indentText({text:this.render(e),spaces:t}):"")}
20
- `}table({tableData:D,tableOptions:e,tableBreakpoints:t}){return WD(D.map(n=>n.map(o=>this.render(o))),t?ZD(t):e)}flagParameter(D){return D===Boolean?"":D===String?"<string>":D===Number?"<number>":Array.isArray(D)?this.flagParameter(D[0]):"<value>"}flagOperator(D){return" "}flagName(D){const{flag:e,flagFormatted:t,aliasesEnabled:n,aliasFormatted:o}=D;let r="";if(o?r+=`${o}, `:n&&(r+=" "),r+=t,"placeholder"in e&&typeof e.placeholder=="string")r+=`${this.flagOperator(D)}${e.placeholder}`;else{const i=this.flagParameter("type"in e?e.type:e);i&&(r+=`${this.flagOperator(D)}${i}`)}return r}flagDefault(D){return JSON.stringify(D)}flagDescription({flag:D}){let e="description"in D?D.description??"":"";if("default"in D){let{default:t}=D;typeof t=="function"&&(t=t()),t&&(e+=` (default: ${this.flagDefault(t)})`)}return e}render(D){if(typeof D=="string")return D;if(Array.isArray(D))return D.map(e=>this.render(e)).join(`
21
- `);if("type"in D&&this[D.type]){const e=this[D.type];if(typeof e=="function")return e.call(this,D.data)}throw new Error(`Invalid node type: ${JSON.stringify(D)}`)}}const wu=/^[\w.-]+$/,{stringify:m}=JSON,re=/[|\\{}()[\]^$+*?.]/;function H(u){const D=[];let e,t;for(const n of u){if(t)throw new Error(`Invalid parameter: Spread parameter ${m(t)} must be last`);const o=n[0],r=n[n.length-1];let i;if(o==="<"&&r===">"&&(i=!0,e))throw new Error(`Invalid parameter: Required parameter ${m(n)} cannot come after optional parameter ${m(e)}`);if(o==="["&&r==="]"&&(i=!1,e=n),i===void 0)throw new Error(`Invalid parameter: ${m(n)}. Must be wrapped in <> (required parameter) or [] (optional parameter)`);let a=n.slice(1,-1);const F=a.slice(-3)==="...";F&&(t=n,a=a.slice(0,-3));const l=a.match(re);if(l)throw new Error(`Invalid parameter: ${m(n)}. Invalid character found ${m(l[0])}`);D.push({name:a,required:i,spread:F})}return D}s(H,"w");function V(u,D,e,t){for(let n=0;n<D.length;n+=1){const{name:o,required:r,spread:i}=D[n],a=JD(o);if(a in u)throw new Error(`Invalid parameter: ${m(o)} is used more than once.`);const F=i?e.slice(n):e[n];if(i&&(n=D.length),r&&(!F||i&&F.length===0))return console.error(`Error: Missing required parameter ${m(o)}
22
- `),t(),process.exit(1);u[a]=F}}s(V,"b");function ie(u){return u===void 0||u!==!1}s(ie,"W");function $u(u,D,e,t){const n={...D.flags},o=D.version;o&&(n.version={type:Boolean,description:"Show version"});const{help:r}=D,i=ie(r);i&&!("help"in n)&&(n.help={type:Boolean,alias:"h",description:"Show help"});const a=aD(n,t,{ignore:D.ignoreArgv}),F=s(()=>{console.log(D.version)},"f");if(o&&a.flags.version===!0)return F(),process.exit(0);const l=new oe,C=i&&r?.render?r.render:f=>l.render(f),E=s(f=>{const c=te({...D,...f?{help:f}:{},flags:n});console.log(C(c,l))},"u");if(i&&a.flags.help===!0)return E(),process.exit(0);if(D.parameters){let{parameters:f}=D,c=a._;const d=f.indexOf("--"),$=f.slice(d+1),h=Object.create(null);if(d>-1&&$.length>0){f=f.slice(0,d);const k=a._["--"];c=c.slice(0,-k.length||void 0),V(h,H(f),c,E),V(h,H($),k,E)}else V(h,H(f),c,E);Object.assign(a._,h)}const p={...a,showVersion:F,showHelp:E};return typeof e=="function"&&e(p),{command:u,...p}}s($u,"x");function se(u,D){const e=new Map;for(const t of D){const n=[t.options.name],{alias:o}=t.options;o&&(Array.isArray(o)?n.push(...o):n.push(o));for(const r of n){if(e.has(r))throw new Error(`Duplicate command name found: ${m(r)}`);e.set(r,t)}}return e.get(u)}s(se,"z");function ae(u,D,e=process.argv.slice(2)){if(!u)throw new Error("Options is required");if("name"in u&&(!u.name||!wu.test(u.name)))throw new Error(`Invalid script name: ${m(u.name)}`);const t=e[0];if(u.commands&&wu.test(t)){const n=se(t,u.commands);if(n)return $u(n.options.name,{...n.options,parent:u},n.callback,e.slice(1))}return $u(void 0,u,D,e)}s(ae,"Z");let w=!0;const v=typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{};let M=0;if(v.process&&v.process.env&&v.process.stdout){const{FORCE_COLOR:u,NODE_DISABLE_COLORS:D,NO_COLOR:e,TERM:t,COLORTERM:n}=v.process.env;D||e||u==="0"?w=!1:u==="1"||u==="2"||u==="3"?w=!0:t==="dumb"?w=!1:"CI"in v.process.env&&["TRAVIS","CIRCLECI","APPVEYOR","GITLAB_CI","GITHUB_ACTIONS","BUILDKITE","DRONE"].some(o=>o in v.process.env)?w=!0:w=process.stdout.isTTY,w&&(process.platform==="win32"||n&&(n==="truecolor"||n==="24bit")?M=3:t&&(t.endsWith("-256color")||t.endsWith("256"))?M=2:M=1)}let vu={enabled:w,supportLevel:M};function b(u,D,e=1){const t=`\x1B[${u}m`,n=`\x1B[${D}m`,o=new RegExp(`\\x1b\\[${D}m`,"g");return r=>vu.enabled&&vu.supportLevel>=e?t+(""+r).replace(o,t)+n:""+r}s(b,"kolorist");const j=b(1,22),A=b(2,22),Fe=b(30,39),xu=b(32,39),Q=b(33,39),L=b(35,39),X=b(93,39),le=b(43,49);var Ce="dtsroll",Ee="1.0.0",ce="Bundle dts files";const _=".d.ts",uu="\u26A0",pe=/^[$_\p{ID_Start}][$\u200C\u200D\p{ID_Continue}]*$/u,fe=new Set(["do","if","in","for","int","new","try","var","byte","case","char","else","enum","goto","long","null","this","true","void","with","break","catch","class","const","false","final","float","short","super","throw","while","delete","double","export","import","native","public","return","static","switch","throws","typeof","boolean","default","extends","finally","package","private","abstract","continue","debugger","function","volatile","interface","protected","transient","implements","instanceof","synchronized"]),de=s(u=>!pe.test(u)||fe.has(u),"propertyNeedsQuotes"),Ou=s(async u=>I.access(u).then(()=>!0,()=>!1),"pathExists"),Mu="@types/",ge=s(u=>{let D=u.slice(Mu.length);return D.includes("__")&&(D=`@${D.replace("__","/")}`),D},"getOriginalPackageName"),ju=s(u=>{let D=u.indexOf("/");if(D===-1)return u;if(u[0]==="@"){const e=u.indexOf("/",D+1);if(e===-1)return u;D=e}return u.slice(0,D)},"getPackageName"),Be=s(async u=>{const D=await I.readFile(u,"utf8");return JSON.parse(D)},"readPackageJson"),he=s((u,D)=>{const e={},t=s((n,o)=>{if(!n.endsWith(_))return;const r=g.join(D,n);e[r]||(e[r]=o)},"addEntry");return u.types&&t(u.types,"types"),u.typings&&t(u.typings,"typings"),u.exports&&s(function n(o,r){if(typeof o=="string"?t(o,r):Array.isArray(o)&&o.forEach((i,a)=>n(i,`${r}[${a}]`)),typeof o=="object"&&o)for(const[i,a]of Object.entries(o)){const F=de(i)?`["${i}"]`:`.${i}`;n(a,r+F)}},"gather")(u.exports,"exports"),e},"getDtsEntryPoints"),me=["dependencies","peerDependencies","optionalDependencies"],Ae=s(u=>{const D=new Map;for(const e of me){const t=u[e];if(t){const n=Object.keys(t);for(const o of n)D.set(o,`by package.json ${e}`)}}return D},"getExternals"),be=s(async u=>{const D=g.resolve("package.json");if(!await Ou(D))return;let t;try{t=await Be(D)}catch(o){throw new Error(`Failed to parse package.json at ${D}: ${o.message}`)}return Ae(t).forEach((o,r)=>u.set(r,o)),{getDtsEntryPoints:s(()=>he(t,g.dirname(D)),"getDtsEntryPoints"),getDevTypePackages:s(()=>!t.private&&t.devDependencies?Object.fromEntries(Object.keys(t.devDependencies).filter(o=>o.startsWith(Mu)).map(o=>[ge(o),o])):{},"getDevTypePackages")}},"processPackageJson"),ye=s(u=>{const D=u.map(n=>n.split(g.sep).slice(0,-1)),e=[],[t]=D;for(let n=0;n<t.length;n+=1){const o=t[n];if(!D.every(i=>i[n]===o))break;e.push(o)}return e.join(g.sep)},"getCommonDirectory"),P=process.cwd(),we=s(async u=>{if(!u)throw new Error("No input files");const D=Array.isArray(u);console.log(j(`
23
- \u{1F4E5} Entry points${D?"":" in package.json"}`));const e=D?u.map(o=>[o]):Object.entries(u),t=[],n=await Promise.all(e.map(async([o,r])=>{const i=g.relative(P,o);return o.startsWith(P)?o.endsWith(_)?await Ou(o)?(t.push(o),` \u2192 ${xu(i)}${r?` ${A(`from ${r}`)}`:""}`):` ${X(`${uu} ${i} ${A("File not found")}`)}`:` ${X(`${uu} ${i} ${A("Ignoring non-d.ts input")}`)}`:` ${X(`${uu} ${i} ${A("Ignoring file outside of cwd")}`)}`}));if(console.log(n.join(`
24
- `)),t.length===0)throw new Error("No input files");return t},"validateInput"),$e=s(([u])=>u==="."||u===g.sep,"isPath"),ve=s(u=>{const D=new Map,e=new Map,t=new Map;return{externalizePlugin:{name:"externalize",async resolveId(r,i,a){const F=!$e(r)&&ju(r);if(F){const C=u.get(F);if(C)return t.set(F,C),{id:r,external:!0}}const l=await this.resolve(r,i,a);return l?(F&&D.set(l.id,r),i&&l.id!==i&&e.set(l.id,i),l):(F&&t.set(F,"because unresolvable"),{id:r,external:!0})}},externalized:t,getPackageEntryPoint:s(r=>{let i=r;do{if(D.has(i))return D.get(i);i=e.get(i)}while(i)},"getPackageEntryPoint")}},"createExternalizePlugin"),xe=`${g.sep}node_modules${g.sep}`,Oe=s(u=>{let D=[];return{name:"remove-bundled-modules",async generateBundle(e,t){const n=Object.values(t),o=Array.from(new Set(n.flatMap(({moduleIds:F})=>F).filter(F=>F.startsWith(P)&&!F.includes(xe)))),i=(await Promise.all(o.map(F=>I.stat(F)))).reduce((F,{size:l})=>F+l,0);u.value=i;const a=new Set(n.map(({fileName:F})=>g.join(e.dir,F)));D=o.filter(F=>!a.has(F))},writeBundle:s(async()=>{await Promise.all(D.map(e=>I.rm(e)))},"writeBundle")}},"removeBundledModulesPlugin"),Me=s((u,D)=>Object.fromEntries(u.map(e=>[e.slice(D.length+1).slice(0,-_.length),e])),"createInputMap"),je=s(async(u,D,e,t,n)=>{const{externalizePlugin:o,externalized:r,getPackageEntryPoint:i}=ve(e),a={},F={input:Me(u,D),output:{dir:D,chunkFileNames:"_dtsroll-chunks/[name].ts"},plugins:[o,Yu({extensions:[".ts",_],exportConditions:t}),Gu({respectExternal:!0}),Oe(a)]};return{built:await(await Wu(F))[n](F.output),externalized:r,getPackageEntryPoint:i,sourceSize:a.value}},"build");let Pu={};const ku=new WeakMap,Su={metric:[{from:0,to:1e3,unit:"B",long:"bytes"},{from:1e3,to:1e6,unit:"kB",long:"kilobytes"},{from:1e6,to:1e9,unit:"MB",long:"megabytes"},{from:1e9,to:1e12,unit:"GB",long:"gigabytes"},{from:1e12,to:1e15,unit:"TB",long:"terabytes"},{from:1e15,to:1e18,unit:"PB",long:"petabytes"},{from:1e18,to:1e21,unit:"EB",long:"exabytes"},{from:1e21,to:1e24,unit:"ZB",long:"zettabytes"},{from:1e24,to:1e27,unit:"YB",long:"yottabytes"}],metric_octet:[{from:0,to:1e3,unit:"o",long:"octets"},{from:1e3,to:1e6,unit:"ko",long:"kilooctets"},{from:1e6,to:1e9,unit:"Mo",long:"megaoctets"},{from:1e9,to:1e12,unit:"Go",long:"gigaoctets"},{from:1e12,to:1e15,unit:"To",long:"teraoctets"},{from:1e15,to:1e18,unit:"Po",long:"petaoctets"},{from:1e18,to:1e21,unit:"Eo",long:"exaoctets"},{from:1e21,to:1e24,unit:"Zo",long:"zettaoctets"},{from:1e24,to:1e27,unit:"Yo",long:"yottaoctets"}],iec:[{from:0,to:Math.pow(1024,1),unit:"B",long:"bytes"},{from:Math.pow(1024,1),to:Math.pow(1024,2),unit:"KiB",long:"kibibytes"},{from:Math.pow(1024,2),to:Math.pow(1024,3),unit:"MiB",long:"mebibytes"},{from:Math.pow(1024,3),to:Math.pow(1024,4),unit:"GiB",long:"gibibytes"},{from:Math.pow(1024,4),to:Math.pow(1024,5),unit:"TiB",long:"tebibytes"},{from:Math.pow(1024,5),to:Math.pow(1024,6),unit:"PiB",long:"pebibytes"},{from:Math.pow(1024,6),to:Math.pow(1024,7),unit:"EiB",long:"exbibytes"},{from:Math.pow(1024,7),to:Math.pow(1024,8),unit:"ZiB",long:"zebibytes"},{from:Math.pow(1024,8),to:Math.pow(1024,9),unit:"YiB",long:"yobibytes"}],iec_octet:[{from:0,to:Math.pow(1024,1),unit:"o",long:"octets"},{from:Math.pow(1024,1),to:Math.pow(1024,2),unit:"Kio",long:"kibioctets"},{from:Math.pow(1024,2),to:Math.pow(1024,3),unit:"Mio",long:"mebioctets"},{from:Math.pow(1024,3),to:Math.pow(1024,4),unit:"Gio",long:"gibioctets"},{from:Math.pow(1024,4),to:Math.pow(1024,5),unit:"Tio",long:"tebioctets"},{from:Math.pow(1024,5),to:Math.pow(1024,6),unit:"Pio",long:"pebioctets"},{from:Math.pow(1024,6),to:Math.pow(1024,7),unit:"Eio",long:"exbioctets"},{from:Math.pow(1024,7),to:Math.pow(1024,8),unit:"Zio",long:"zebioctets"},{from:Math.pow(1024,8),to:Math.pow(1024,9),unit:"Yio",long:"yobioctets"}]};class Pe{static{s(this,"ByteSize")}constructor(D,e){e=Object.assign({units:"metric",precision:1,locale:void 0},Pu,e),ku.set(this,e),Object.assign(Su,e.customUnits);const t=D<0?"-":"";D=Math.abs(D);const n=Su[e.units];if(n){const o=n.find(r=>D>=r.from&&D<r.to);if(o){const r=new Intl.NumberFormat(e.locale,{style:"decimal",maximumFractionDigits:e.precision}),i=o.from===0?t+r.format(D):t+r.format(D/o.from);this.value=i,this.unit=o.unit,this.long=o.long}else this.value=t+D,this.unit="",this.long=""}else throw new Error(`Invalid units specified: ${e.units}`)}toString(){const D=ku.get(this);return D.toStringFn?D.toStringFn.bind(this)():`${this.value} ${this.unit}`}}function W(u,D){return new Pe(u,D)}s(W,"byteSize"),W.defaultOptions=function(u){Pu=u};const ke=s(({outputDirectory:u,built:D,externalized:e,getPackageEntryPoint:t,getDevTypePackages:n,sourceSize:o})=>{const r=g.relative(P,u)+g.sep,i=new Set,a={};let F=0;const l=[],C=[];for(const c of D.output){const d=Buffer.byteLength(c.code,"utf8");a[c.fileName]=d,F+=d,"isEntry"in c&&c.isEntry?l.push(c):C.push(c)}const E=s(({file:c,indent:d,bullet:$,color:h})=>{const k=W(a[c.fileName]).toString();let eu=`${d}${$} ${A(h(r))}${h(c.fileName)} ${k}`;const{moduleIds:tu}=c;eu+=`
25
- ${tu.sort().map((S,Nu)=>{const Tu=Nu===tu.length-1,nu=`${d} ${Tu?"\u2514\u2500 ":"\u251C\u2500 "}`,Y=g.relative(P,S),ou=t(S);if(ou)return`${nu}${A(L(ou))} ${A(`(${Y})`)}`;const zu=g.basename(Y),Ru=g.dirname(Y)+g.sep;return`${nu}${A(Ru)}${A(zu)}`}).join(`
26
- `)}`;for(const S of c.imports)i.add(ju(S));return eu},"logChunk");console.log(j(`
27
- \u{1F4A0} Bundled output`)),console.log(l.map(c=>E({file:c,indent:" ",bullet:"\u25CF",color:xu})).join(`
2
+ import { cli } from 'cleye';
3
+ import { b as bgYellow, a as black, d as dtsroll } from './index--BBQtOEp.mjs';
4
+ import { l as logOutput } from './log-output-CwMUFOmQ.mjs';
5
+ import 'node:path';
6
+ import 'node:fs/promises';
7
+ import 'rollup';
8
+ import 'rollup-plugin-dts';
9
+ import '@rollup/plugin-node-resolve';
10
+ import 'byte-size';
28
11
 
29
- `)),C.length>0&&(console.log(j(`
30
- Chunks`)),console.log(C.map(c=>E({file:c,indent:" ",bullet:"\u25A0",color:Q})).join(`
12
+ var name = "dtsroll";
13
+ var version = "1.2.0";
14
+ var description = "Bundle dts files";
31
15
 
32
- `))),console.log(j(`
33
- \u2696\uFE0F Size savings`));const p=((o-F)/o*100).toFixed(0);console.log(` Input source size: ${W(o).toString()}`),console.log(` Bundled output size: ${W(F).toString()} (${p}% decrease)`);const f=Array.from(i).filter(c=>e.has(c));if(f.length>0){const c=n?.()??{};console.log(j(`
34
- \u{1F4E6} Externalized packages`)),console.log(f.map(d=>{const $=e.get(d);let h=` \u2500 ${L(d)} ${A(`externalized ${$}`)}`;return c[d]&&(h+=`
35
- ${Q("Warning:")} ${L(c[d])} should not be in devDependencies if ${L(d)} is externalized`),h}).sort().join(`
36
- `))}},"logOutput"),Du=ae({name:Ce,version:Ee,help:{description:ce},parameters:["[input files...]"],flags:{conditions:{type:[String],alias:"C",description:"Export conditions"},dryRun:{type:Boolean,alias:"d",description:"Dry run; no files will be written"},external:{type:[String],alias:"e",description:"Dependency to externalize"}}}),{flags:G}=Du,Iu=G.dryRun;Iu&&console.log(le(Fe(" Dry run - No files will be written "))),(async()=>{const u=new Map,D=await be(u);if(G.external.length>0)if(D)console.warn(`${Q("Warning:")} The --external flag is only supported when there is no package.json`);else for(const a of G.external)u.set(a,"by --external flag");const e=await we(Du._.inputFiles.length>0?Du._.inputFiles.map(a=>g.resolve(a)):D?.getDtsEntryPoints()),t=ye(e),{built:n,externalized:o,getPackageEntryPoint:r,sourceSize:i}=await je(e,t,u,G.conditions,Iu?"generate":"write");ke({outputDirectory:t,built:n,externalized:o,sourceSize:i,getPackageEntryPoint:r,getDevTypePackages:D?.getDevTypePackages})})().catch(u=>{console.error(`
37
- Failed to build:`,u.message),process.exitCode=1});
16
+ const argv = cli({
17
+ name,
18
+ version,
19
+ help: {
20
+ description
21
+ },
22
+ parameters: ["[input files...]"],
23
+ flags: {
24
+ conditions: {
25
+ type: [String],
26
+ alias: "C",
27
+ description: "Export conditions"
28
+ },
29
+ dryRun: {
30
+ type: Boolean,
31
+ alias: "d",
32
+ description: "Dry run; no files will be written"
33
+ },
34
+ external: {
35
+ type: [String],
36
+ alias: "e",
37
+ description: "Dependency to externalize"
38
+ }
39
+ // sourcemap: {
40
+ // type: Boolean,
41
+ // description: 'Generate sourcemaps',
42
+ // },
43
+ }
44
+ });
45
+ const { flags } = argv;
46
+ const dryMode = flags.dryRun;
47
+ if (dryMode) {
48
+ console.log(bgYellow(black(" Dry run - No files will be written ")));
49
+ }
50
+ dtsroll({
51
+ inputs: argv._.inputFiles,
52
+ external: flags.external,
53
+ conditions: flags.conditions,
54
+ dryRun: flags.dryRun
55
+ }).then(
56
+ (output) => {
57
+ if ("error" in output) {
58
+ process.exitCode = 1;
59
+ }
60
+ logOutput(output);
61
+ },
62
+ (error) => {
63
+ console.error("\nFailed to build:", error.message);
64
+ process.exitCode = 1;
65
+ }
66
+ );
@@ -0,0 +1,535 @@
1
+ import path from 'node:path';
2
+ import fs from 'node:fs/promises';
3
+ import { rollup } from 'rollup';
4
+ import { dts } from 'rollup-plugin-dts';
5
+ import nodeResolve from '@rollup/plugin-node-resolve';
6
+
7
+ let enabled = true;
8
+ // Support both browser and node environments
9
+ const globalVar = typeof self !== 'undefined'
10
+ ? self
11
+ : typeof window !== 'undefined'
12
+ ? window
13
+ : typeof global !== 'undefined'
14
+ ? global
15
+ : {};
16
+ /**
17
+ * Detect how much colors the current terminal supports
18
+ */
19
+ let supportLevel = 0 /* none */;
20
+ if (globalVar.process && globalVar.process.env && globalVar.process.stdout) {
21
+ const { FORCE_COLOR, NODE_DISABLE_COLORS, NO_COLOR, TERM, COLORTERM } = globalVar.process.env;
22
+ if (NODE_DISABLE_COLORS || NO_COLOR || FORCE_COLOR === '0') {
23
+ enabled = false;
24
+ }
25
+ else if (FORCE_COLOR === '1' ||
26
+ FORCE_COLOR === '2' ||
27
+ FORCE_COLOR === '3') {
28
+ enabled = true;
29
+ }
30
+ else if (TERM === 'dumb') {
31
+ enabled = false;
32
+ }
33
+ else if ('CI' in globalVar.process.env &&
34
+ [
35
+ 'TRAVIS',
36
+ 'CIRCLECI',
37
+ 'APPVEYOR',
38
+ 'GITLAB_CI',
39
+ 'GITHUB_ACTIONS',
40
+ 'BUILDKITE',
41
+ 'DRONE',
42
+ ].some(vendor => vendor in globalVar.process.env)) {
43
+ enabled = true;
44
+ }
45
+ else {
46
+ enabled = process.stdout.isTTY;
47
+ }
48
+ if (enabled) {
49
+ // Windows supports 24bit True Colors since Windows 10 revision #14931,
50
+ // see https://devblogs.microsoft.com/commandline/24-bit-color-in-the-windows-console/
51
+ if (process.platform === 'win32') {
52
+ supportLevel = 3 /* trueColor */;
53
+ }
54
+ else {
55
+ if (COLORTERM && (COLORTERM === 'truecolor' || COLORTERM === '24bit')) {
56
+ supportLevel = 3 /* trueColor */;
57
+ }
58
+ else if (TERM && (TERM.endsWith('-256color') || TERM.endsWith('256'))) {
59
+ supportLevel = 2 /* ansi256 */;
60
+ }
61
+ else {
62
+ supportLevel = 1 /* ansi */;
63
+ }
64
+ }
65
+ }
66
+ }
67
+ let options = {
68
+ enabled,
69
+ supportLevel,
70
+ };
71
+ function kolorist(start, end, level = 1 /* ansi */) {
72
+ const open = `\x1b[${start}m`;
73
+ const close = `\x1b[${end}m`;
74
+ const regex = new RegExp(`\\x1b\\[${end}m`, 'g');
75
+ return (str) => {
76
+ return options.enabled && options.supportLevel >= level
77
+ ? open + ('' + str).replace(regex, open) + close
78
+ : '' + str;
79
+ };
80
+ }
81
+ const bold = kolorist(1, 22);
82
+ const dim = kolorist(2, 22);
83
+ const underline = kolorist(4, 24);
84
+ // colors
85
+ const black = kolorist(30, 39);
86
+ const red = kolorist(31, 39);
87
+ const green = kolorist(32, 39);
88
+ const yellow = kolorist(33, 39);
89
+ const magenta = kolorist(35, 39);
90
+ const lightYellow = kolorist(93, 39);
91
+ const bgYellow = kolorist(43, 49);
92
+
93
+ const dtsExtension = ".d.ts";
94
+ const warningSignUnicode = "\u26A0";
95
+
96
+ const isValidIdentifier = /^[$_\p{ID_Start}][$\u200C\u200D\p{ID_Continue}]*$/u;
97
+ const reservedWords = /* @__PURE__ */ new Set([
98
+ "do",
99
+ "if",
100
+ "in",
101
+ "for",
102
+ "int",
103
+ "new",
104
+ "try",
105
+ "var",
106
+ "byte",
107
+ "case",
108
+ "char",
109
+ "else",
110
+ "enum",
111
+ "goto",
112
+ "long",
113
+ "null",
114
+ "this",
115
+ "true",
116
+ "void",
117
+ "with",
118
+ "break",
119
+ "catch",
120
+ "class",
121
+ "const",
122
+ "false",
123
+ "final",
124
+ "float",
125
+ "short",
126
+ "super",
127
+ "throw",
128
+ "while",
129
+ "delete",
130
+ "double",
131
+ "export",
132
+ "import",
133
+ "native",
134
+ "public",
135
+ "return",
136
+ "static",
137
+ "switch",
138
+ "throws",
139
+ "typeof",
140
+ "boolean",
141
+ "default",
142
+ "extends",
143
+ "finally",
144
+ "package",
145
+ "private",
146
+ "abstract",
147
+ "continue",
148
+ "debugger",
149
+ "function",
150
+ "volatile",
151
+ "interface",
152
+ "protected",
153
+ "transient",
154
+ "implements",
155
+ "instanceof",
156
+ "synchronized"
157
+ ]);
158
+ const propertyNeedsQuotes = (property) => !isValidIdentifier.test(property) || reservedWords.has(property);
159
+
160
+ const pathExists = async (filePath) => fs.access(filePath).then(() => true, () => false);
161
+
162
+ const typesPrefix = "@types/";
163
+ const getOriginalPackageName = (typePackageName) => {
164
+ let originalPackageName = typePackageName.slice(typesPrefix.length);
165
+ if (originalPackageName.includes("__")) {
166
+ originalPackageName = `@${originalPackageName.replace("__", "/")}`;
167
+ }
168
+ return originalPackageName;
169
+ };
170
+ const getPackageName = (id) => {
171
+ let indexOfSlash = id.indexOf("/");
172
+ if (indexOfSlash === -1) {
173
+ return id;
174
+ }
175
+ if (id[0] === "@") {
176
+ const secondSlash = id.indexOf("/", indexOfSlash + 1);
177
+ if (secondSlash === -1) {
178
+ return id;
179
+ }
180
+ indexOfSlash = secondSlash;
181
+ }
182
+ return id.slice(0, indexOfSlash);
183
+ };
184
+
185
+ const readPackageJson = async (filePath) => {
186
+ const packageJsonString = await fs.readFile(filePath, "utf8");
187
+ return JSON.parse(packageJsonString);
188
+ };
189
+ const getDtsEntryPoints = (packageJson, packageJsonDirectory) => {
190
+ const entryPoints = {};
191
+ const addEntry = (subpath, from) => {
192
+ if (!subpath.endsWith(dtsExtension)) {
193
+ return;
194
+ }
195
+ const entryPath = path.join(packageJsonDirectory, subpath);
196
+ if (!entryPoints[entryPath]) {
197
+ entryPoints[entryPath] = from;
198
+ }
199
+ };
200
+ if (packageJson.types) {
201
+ addEntry(packageJson.types, "types");
202
+ }
203
+ if (packageJson.typings) {
204
+ addEntry(packageJson.typings, "typings");
205
+ }
206
+ if (packageJson.exports) {
207
+ (function gather(exportValue, propertyPath) {
208
+ if (typeof exportValue === "string") {
209
+ addEntry(exportValue, propertyPath);
210
+ } else if (Array.isArray(exportValue)) {
211
+ exportValue.forEach((value, index) => gather(value, `${propertyPath}[${index}]`));
212
+ }
213
+ if (typeof exportValue === "object" && exportValue) {
214
+ for (const [property, value] of Object.entries(exportValue)) {
215
+ const newProperty = propertyNeedsQuotes(property) ? `["${property}"]` : `.${property}`;
216
+ gather(value, propertyPath + newProperty);
217
+ }
218
+ }
219
+ })(packageJson.exports, "exports");
220
+ }
221
+ return entryPoints;
222
+ };
223
+ const externalizedDependencies = [
224
+ "dependencies",
225
+ "peerDependencies",
226
+ "optionalDependencies"
227
+ ];
228
+ const getExternals = (packageJson) => {
229
+ const external = /* @__PURE__ */ new Map();
230
+ for (const dependencyType of externalizedDependencies) {
231
+ const dependencyObject = packageJson[dependencyType];
232
+ if (dependencyObject) {
233
+ const dependencyNames = Object.keys(dependencyObject);
234
+ for (const dependencyName of dependencyNames) {
235
+ external.set(dependencyName, `by package.json ${dependencyType}`);
236
+ }
237
+ }
238
+ }
239
+ return external;
240
+ };
241
+ const getPackageJson = async (cwd) => {
242
+ const packageJsonPath = path.resolve(cwd, "package.json");
243
+ const exists = await pathExists(packageJsonPath);
244
+ if (!exists) {
245
+ return;
246
+ }
247
+ let packageJson;
248
+ try {
249
+ packageJson = await readPackageJson(packageJsonPath);
250
+ } catch (error) {
251
+ throw new Error(`Failed to parse package.json at ${packageJsonPath}: ${error.message}`);
252
+ }
253
+ return {
254
+ getExternals: () => getExternals(packageJson),
255
+ getDtsEntryPoints: () => getDtsEntryPoints(packageJson, path.dirname(packageJsonPath)),
256
+ devTypePackages: !packageJson.private && packageJson.devDependencies ? Object.fromEntries(
257
+ Object.keys(packageJson.devDependencies).filter((dep) => dep.startsWith(typesPrefix)).map((dep) => [getOriginalPackageName(dep), dep])
258
+ ) : {}
259
+ };
260
+ };
261
+
262
+ const getCommonDirectory = (filePaths) => {
263
+ const splitPaths = filePaths.map((filePath) => filePath.split(path.sep).slice(0, -1));
264
+ const commonPath = [];
265
+ const [firstPath] = splitPaths;
266
+ for (let i = 0; i < firstPath.length; i += 1) {
267
+ const segment = firstPath[i];
268
+ const segmentIsCommon = splitPaths.every((pathParts) => pathParts[i] === segment);
269
+ if (!segmentIsCommon) {
270
+ break;
271
+ }
272
+ commonPath.push(segment);
273
+ }
274
+ return commonPath.join(path.sep);
275
+ };
276
+
277
+ const validateInput = async (inputFiles) => {
278
+ if (!inputFiles) {
279
+ throw new Error("No input files");
280
+ }
281
+ const isCliInput = Array.isArray(inputFiles);
282
+ const inputNormalized = isCliInput ? inputFiles.map((i) => [i]) : Object.entries(inputFiles);
283
+ return await Promise.all(inputNormalized.map(
284
+ async ([inputFile, inputSource]) => {
285
+ const notDts = !inputFile.endsWith(dtsExtension);
286
+ if (notDts) {
287
+ return [inputFile, inputSource, "Ignoring non-d.ts input"];
288
+ }
289
+ const exists = await pathExists(inputFile);
290
+ if (!exists) {
291
+ return [inputFile, inputSource, "File not found"];
292
+ }
293
+ return [inputFile, inputSource];
294
+ }
295
+ ));
296
+ };
297
+
298
+ const isPath = ([firstCharacter]) => firstCharacter === "." || firstCharacter === path.sep;
299
+
300
+ const createExternalizePlugin = (configuredExternals) => {
301
+ const resolvedBareSpecifiers = /* @__PURE__ */ new Map();
302
+ const importPath = /* @__PURE__ */ new Map();
303
+ const externalized = /* @__PURE__ */ new Map();
304
+ const externalizePlugin = {
305
+ name: "externalize",
306
+ async resolveId(id, importer, options) {
307
+ const packageName = !isPath(id) && getPackageName(id);
308
+ if (packageName) {
309
+ const externalReason = configuredExternals.get(packageName);
310
+ if (externalReason) {
311
+ externalized.set(packageName, externalReason);
312
+ return {
313
+ id,
314
+ external: true
315
+ };
316
+ }
317
+ }
318
+ const resolved = await this.resolve(id, importer, options);
319
+ if (resolved) {
320
+ if (packageName) {
321
+ resolvedBareSpecifiers.set(resolved.id, id);
322
+ }
323
+ if (
324
+ // Self imports happen
325
+ importer && resolved.id !== importer && importPath.get(importer) !== resolved.id
326
+ ) {
327
+ importPath.set(resolved.id, importer);
328
+ }
329
+ return resolved;
330
+ }
331
+ if (packageName) {
332
+ externalized.set(packageName, "because unresolvable");
333
+ }
334
+ return {
335
+ id,
336
+ external: true
337
+ };
338
+ }
339
+ };
340
+ const getPackageEntryPoint = (subpackagePath) => {
341
+ let i = 0;
342
+ let lastEntry = subpackagePath;
343
+ do {
344
+ if (resolvedBareSpecifiers.has(lastEntry)) {
345
+ return resolvedBareSpecifiers.get(lastEntry);
346
+ }
347
+ lastEntry = importPath.get(lastEntry);
348
+ i += 1;
349
+ } while (lastEntry && i < 100);
350
+ };
351
+ return {
352
+ externalizePlugin,
353
+ externalized,
354
+ getPackageEntryPoint
355
+ };
356
+ };
357
+
358
+ const nodeModules = `${path.sep}node_modules${path.sep}`;
359
+ const removeBundledModulesPlugin = (outputDirectory, sizeRef) => {
360
+ let deleteFiles = [];
361
+ return {
362
+ name: "remove-bundled-modules",
363
+ transform: {
364
+ // Get size of raw code before other transformations
365
+ order: "pre",
366
+ handler: (code) => ({
367
+ meta: {
368
+ size: Buffer.byteLength(code)
369
+ }
370
+ })
371
+ },
372
+ async generateBundle(options, bundle) {
373
+ const modules = Object.values(bundle);
374
+ const bundledSourceFiles = Array.from(new Set(
375
+ modules.flatMap(({ moduleIds }) => moduleIds).filter((moduleId) => (
376
+ // To avoid deleting files from symlinked dependencies
377
+ moduleId.startsWith(outputDirectory) && !moduleId.includes(nodeModules)
378
+ ))
379
+ ));
380
+ const fileSizes = bundledSourceFiles.map((moduleId) => this.getModuleInfo(moduleId).meta);
381
+ const totalSize = fileSizes.reduce((total, { size }) => total + size, 0);
382
+ sizeRef.value = totalSize;
383
+ const outputFiles = new Set(modules.map(({ fileName }) => path.join(options.dir, fileName)));
384
+ deleteFiles = bundledSourceFiles.filter((moduleId) => !outputFiles.has(moduleId));
385
+ },
386
+ writeBundle: async () => {
387
+ await Promise.all(
388
+ deleteFiles.map((moduleId) => fs.rm(moduleId))
389
+ );
390
+ }
391
+ };
392
+ };
393
+
394
+ const createInputMap = (input, outputDirectory) => Object.fromEntries(
395
+ input.map((inputFile) => [
396
+ inputFile.slice(outputDirectory.length + 1).slice(0, -dtsExtension.length),
397
+ inputFile
398
+ ])
399
+ );
400
+ const build = async (input, outputDirectory, externals, mode, conditions) => {
401
+ const {
402
+ externalizePlugin,
403
+ externalized,
404
+ getPackageEntryPoint
405
+ } = createExternalizePlugin(externals);
406
+ const sizeRef = {};
407
+ const rollupConfig = {
408
+ input: createInputMap(input, outputDirectory),
409
+ output: {
410
+ // sourcemap: true,
411
+ dir: outputDirectory,
412
+ chunkFileNames: "_dtsroll-chunks/[name].ts"
413
+ },
414
+ plugins: [
415
+ externalizePlugin,
416
+ removeBundledModulesPlugin(outputDirectory, sizeRef),
417
+ nodeResolve({
418
+ extensions: [".ts", dtsExtension],
419
+ exportConditions: conditions
420
+ }),
421
+ dts({
422
+ respectExternal: true
423
+ /**
424
+ * Setting a tsconfig or compilerOptions shouldn't be necessary since
425
+ * we're dealing with pre-compiled d.ts files
426
+ *
427
+ * But may be something we need to support if we want to support
428
+ * aliases in the future
429
+ */
430
+ })
431
+ ]
432
+ };
433
+ const rollupBuild = await rollup(rollupConfig);
434
+ const built = await rollupBuild[mode](rollupConfig.output);
435
+ await rollupBuild.close();
436
+ return {
437
+ built,
438
+ externalized,
439
+ getPackageEntryPoint,
440
+ sourceSize: sizeRef.value
441
+ };
442
+ };
443
+
444
+ const dtsroll = async ({
445
+ cwd = process.cwd(),
446
+ inputs,
447
+ external,
448
+ conditions,
449
+ dryRun
450
+ } = {}) => {
451
+ const pkgJson = await getPackageJson(cwd);
452
+ const externals = pkgJson ? pkgJson.getExternals() : /* @__PURE__ */ new Map();
453
+ if (external && external.length > 0) {
454
+ if (pkgJson) {
455
+ console.warn(`${yellow("Warning:")} The --external flag is only supported when there is no package.json`);
456
+ } else {
457
+ for (const externalDependency of external) {
458
+ externals.set(externalDependency, "by --external flag");
459
+ }
460
+ }
461
+ }
462
+ const manualInput = inputs && inputs.length > 0;
463
+ const validatedInputs = await validateInput(
464
+ manualInput ? inputs.map((file) => path.resolve(file)) : pkgJson?.getDtsEntryPoints()
465
+ );
466
+ const inputFiles = validatedInputs.filter((input) => !input[2]).map(([file]) => file);
467
+ if (inputFiles.length === 0) {
468
+ return {
469
+ inputs: validatedInputs,
470
+ error: "No input files"
471
+ };
472
+ }
473
+ const outputDirectory = getCommonDirectory(inputFiles);
474
+ const {
475
+ built,
476
+ externalized,
477
+ getPackageEntryPoint,
478
+ sourceSize
479
+ } = await build(
480
+ inputFiles,
481
+ outputDirectory,
482
+ externals,
483
+ dryRun ? "generate" : "write",
484
+ conditions
485
+ );
486
+ let outputSize = 0;
487
+ const outputEntries = [];
488
+ const outputChunks = [];
489
+ const moduleImports = /* @__PURE__ */ new Set();
490
+ for (const file of built.output) {
491
+ const size = Buffer.byteLength(file.code);
492
+ outputSize += size;
493
+ const moduleToPackage = Object.fromEntries(
494
+ file.moduleIds.map((moduleId) => [moduleId, getPackageEntryPoint(moduleId)])
495
+ );
496
+ const chunkWithSize = Object.assign(file, {
497
+ size,
498
+ moduleToPackage
499
+ });
500
+ if (chunkWithSize.isEntry) {
501
+ outputEntries.push(chunkWithSize);
502
+ } else {
503
+ outputChunks.push(chunkWithSize);
504
+ }
505
+ for (const id of file.imports) {
506
+ moduleImports.add(getPackageName(id));
507
+ }
508
+ }
509
+ const externalPackages = [];
510
+ moduleImports.forEach((importedSpecifier) => {
511
+ const reason = externalized.get(importedSpecifier);
512
+ if (reason) {
513
+ externalPackages.push([
514
+ importedSpecifier,
515
+ reason,
516
+ pkgJson?.devTypePackages?.[importedSpecifier]
517
+ ]);
518
+ }
519
+ });
520
+ return {
521
+ inputs: validatedInputs,
522
+ outputDirectory,
523
+ output: {
524
+ entries: outputEntries,
525
+ chunks: outputChunks
526
+ },
527
+ size: {
528
+ input: sourceSize,
529
+ output: outputSize
530
+ },
531
+ externals: externalPackages
532
+ };
533
+ };
534
+
535
+ export { black as a, bgYellow as b, bold as c, dtsroll as d, dim as e, green as g, lightYellow as l, magenta as m, red as r, underline as u, warningSignUnicode as w, yellow as y };
@@ -0,0 +1,43 @@
1
+ import { OutputChunk } from 'rollup';
2
+
3
+ type Output = OutputChunk & {
4
+ size: number;
5
+ moduleToPackage: Record<string, string | undefined>;
6
+ };
7
+ type Externals = [
8
+ packageName: string,
9
+ reason?: string,
10
+ warning?: string
11
+ ][];
12
+ type ValidatedInput = [
13
+ inputPath: string,
14
+ inputSource: string | undefined,
15
+ error?: string
16
+ ];
17
+ type DtsrollOutput = {
18
+ inputs: ValidatedInput[];
19
+ error: string;
20
+ } | {
21
+ inputs: ValidatedInput[];
22
+ outputDirectory: string;
23
+ output: {
24
+ entries: Output[];
25
+ chunks: Output[];
26
+ };
27
+ size: {
28
+ input: number;
29
+ output: number;
30
+ };
31
+ externals: Externals;
32
+ };
33
+
34
+ type Options = {
35
+ cwd?: string;
36
+ inputs?: string[];
37
+ external?: string[];
38
+ conditions?: string[];
39
+ dryRun?: boolean;
40
+ };
41
+ declare const dtsroll: ({ cwd, inputs, external, conditions, dryRun, }?: Options) => Promise<DtsrollOutput>;
42
+
43
+ export { type DtsrollOutput, type Options, dtsroll };
package/dist/index.mjs ADDED
@@ -0,0 +1,6 @@
1
+ import 'node:path';
2
+ export { d as dtsroll } from './index--BBQtOEp.mjs';
3
+ import 'node:fs/promises';
4
+ import 'rollup';
5
+ import 'rollup-plugin-dts';
6
+ import '@rollup/plugin-node-resolve';
@@ -0,0 +1,100 @@
1
+ import path from 'node:path';
2
+ import byteSize from 'byte-size';
3
+ import { u as underline, c as bold, l as lightYellow, w as warningSignUnicode, e as dim, g as green, r as red, m as magenta, y as yellow } from './index--BBQtOEp.mjs';
4
+
5
+ const cwd = process.cwd();
6
+
7
+ const logOutput = (dtsOutput) => {
8
+ console.log(underline("dtsroll"));
9
+ const { inputs } = dtsOutput;
10
+ const isCliInput = inputs[0]?.[1] === void 0;
11
+ console.log(bold(`
12
+ \u{1F4E5} Entry points${isCliInput ? "" : " in package.json"}`));
13
+ console.log(
14
+ inputs.map(([inputFile, inputSource, error]) => {
15
+ const relativeInputFile = path.relative(cwd, inputFile);
16
+ const logPath2 = relativeInputFile.length < inputFile.length ? relativeInputFile : inputFile;
17
+ if (error) {
18
+ return ` ${lightYellow(`${warningSignUnicode} ${logPath2} ${dim(error)}`)}`;
19
+ }
20
+ return ` \u2192 ${green(logPath2)}${inputSource ? ` ${dim(`from ${inputSource}`)}` : ""}`;
21
+ }).join("\n")
22
+ );
23
+ if ("error" in dtsOutput) {
24
+ console.error(`${red("Error:")} ${dtsOutput.error}`);
25
+ return;
26
+ }
27
+ const {
28
+ outputDirectory,
29
+ output: {
30
+ entries: outputEntries,
31
+ chunks: outputChunks
32
+ },
33
+ size,
34
+ externals
35
+ } = dtsOutput;
36
+ const outputDirectoryRelative = path.relative(cwd, outputDirectory);
37
+ const logPath = (outputDirectoryRelative.length < outputDirectory.length ? outputDirectoryRelative : outputDirectory) + path.sep;
38
+ const logChunk = ({
39
+ file,
40
+ indent,
41
+ bullet,
42
+ color
43
+ }) => {
44
+ const sizeFormatted = byteSize(file.size).toString();
45
+ let log = `${indent}${bullet} ${dim(color(logPath))}${color(file.fileName)} ${sizeFormatted}`;
46
+ const { moduleIds, moduleToPackage } = file;
47
+ log += `
48
+ ${moduleIds.sort().map((moduleId, index) => {
49
+ const isLast = index === moduleIds.length - 1;
50
+ const prefix = `${indent} ${isLast ? "\u2514\u2500 " : "\u251C\u2500 "}`;
51
+ const relativeModuleId = path.relative(cwd, moduleId);
52
+ const logModuleId = relativeModuleId.length < moduleId.length ? relativeModuleId : moduleId;
53
+ const bareSpecifier = moduleToPackage[moduleId];
54
+ if (bareSpecifier) {
55
+ return `${prefix}${dim(`${magenta(bareSpecifier)} (${logModuleId})`)}`;
56
+ }
57
+ return `${prefix}${dim(logModuleId)}`;
58
+ }).join("\n")}`;
59
+ return log;
60
+ };
61
+ console.log(bold("\n\u{1F4A0} Bundled output"));
62
+ console.log(
63
+ outputEntries.map((file) => logChunk({
64
+ file,
65
+ indent: " ",
66
+ bullet: "\u25CF",
67
+ color: green
68
+ })).join("\n\n")
69
+ );
70
+ if (outputChunks.length > 0) {
71
+ console.log(bold("\n Chunks"));
72
+ console.log(
73
+ outputChunks.map((file) => logChunk({
74
+ file,
75
+ indent: " ",
76
+ bullet: "\u25A0",
77
+ color: yellow
78
+ })).join("\n\n")
79
+ );
80
+ }
81
+ console.log(bold("\n\u2696\uFE0F Size savings"));
82
+ const percentage = ((size.input - size.output) / size.input * 100).toFixed(0);
83
+ console.log(` Input source size: ${byteSize(size.input).toString()}`);
84
+ console.log(` Bundled output size: ${byteSize(size.output).toString()} (${percentage}% decrease)`);
85
+ if (externals.length > 0) {
86
+ console.log(bold("\n\u{1F4E6} External packages"));
87
+ console.log(
88
+ externals.map(([packageName, reason, devTypePackage]) => {
89
+ let stdout = ` \u2500 ${magenta(packageName)} ${dim(`externalized ${reason}`)}`;
90
+ if (devTypePackage) {
91
+ stdout += `
92
+ ${yellow("Warning:")} ${magenta(devTypePackage)} should not be in devDependencies if ${magenta(packageName)} is externalized`;
93
+ }
94
+ return stdout;
95
+ }).sort().join("\n")
96
+ );
97
+ }
98
+ };
99
+
100
+ export { logOutput as l };
package/dist/vite.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { Plugin } from 'vite';
2
+ import { Options } from './index.js';
3
+ import 'rollup';
4
+
5
+ declare const dtsrollPlugin: (options?: Options) => Plugin;
6
+
7
+ export { dtsrollPlugin as dtsroll };
package/dist/vite.mjs ADDED
@@ -0,0 +1,38 @@
1
+ import { l as logOutput } from './log-output-CwMUFOmQ.mjs';
2
+ import { d as dtsroll } from './index--BBQtOEp.mjs';
3
+ import 'node:path';
4
+ import 'byte-size';
5
+ import 'node:fs/promises';
6
+ import 'rollup';
7
+ import 'rollup-plugin-dts';
8
+ import '@rollup/plugin-node-resolve';
9
+
10
+ const dtsrollPlugin = (options) => {
11
+ let built = false;
12
+ let cwd;
13
+ return {
14
+ name: "dtsroll",
15
+ apply: "build",
16
+ enforce: "post",
17
+ config: ({ root }) => {
18
+ cwd = root;
19
+ },
20
+ writeBundle: {
21
+ sequential: true,
22
+ order: "post",
23
+ handler: async () => {
24
+ if (built) {
25
+ return;
26
+ }
27
+ logOutput(await dtsroll({
28
+ cwd,
29
+ ...options
30
+ }));
31
+ console.log();
32
+ built = true;
33
+ }
34
+ }
35
+ };
36
+ };
37
+
38
+ export { dtsrollPlugin as dtsroll };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtsroll",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "Bundle dts files",
5
5
  "keywords": [
6
6
  "bundle",
@@ -19,20 +19,36 @@
19
19
  "dist"
20
20
  ],
21
21
  "bin": "./dist/cli.mjs",
22
- "exports": null,
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.mjs"
26
+ },
27
+ "./vite": {
28
+ "types": "./dist/vite.d.ts",
29
+ "default": "./dist/vite.mjs"
30
+ }
31
+ },
32
+ "imports": {
33
+ "#dtsroll": "./src/index.ts",
34
+ "#dtsroll/vite": "./src/vite.ts"
35
+ },
23
36
  "engines": {
24
37
  "node": ">=18"
25
38
  },
26
39
  "dependencies": {
27
40
  "@rollup/plugin-node-resolve": "^16.0.0",
41
+ "byte-size": "^9.0.1",
42
+ "cleye": "^1.3.2",
28
43
  "rollup": "^4.29.1",
29
44
  "rollup-plugin-dts": "6.1.1"
30
45
  },
31
46
  "peerDependencies": {
32
- "typescript": "^4.1 || ^5.0"
47
+ "typescript": "^4.5 || ^5.0",
48
+ "vite": "5 || 6"
33
49
  },
34
50
  "peerDependenciesMeta": {
35
- "typescript": {
51
+ "vite": {
36
52
  "optional": true
37
53
  }
38
54
  }