dtsroll 1.0.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/LICENSE +21 -0
- package/README.md +103 -0
- package/dist/cli.mjs +37 -0
- package/package.json +39 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Hiroki Osame <hiroki.osame@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# dtsroll
|
|
2
|
+
|
|
3
|
+
_dtsroll_ is a CLI tool for bundling TypeScript declaration (`.d.ts`) files.
|
|
4
|
+
|
|
5
|
+
### Why bundle `.d.ts` files?
|
|
6
|
+
|
|
7
|
+
- **Smaller distribution**
|
|
8
|
+
|
|
9
|
+
Tree-shaking removes unused code, keeping only what's needed and reducing the output size.
|
|
10
|
+
|
|
11
|
+
- **Bundle in private dependencies**
|
|
12
|
+
|
|
13
|
+
Inline types from private dependencies (e.g., monorepo packages) that aren't accessible to consumers.
|
|
14
|
+
|
|
15
|
+
- **Improve TS performance**
|
|
16
|
+
|
|
17
|
+
Flattens multiple files into one, reducing TypeScript's file resolution for type checking.
|
|
18
|
+
|
|
19
|
+
## Install
|
|
20
|
+
```
|
|
21
|
+
npm install --save-dev dtsroll
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick start
|
|
25
|
+
|
|
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)
|
|
29
|
+
|
|
30
|
+
2. Pass in the entry declaration file to _dtsroll_
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
dtsroll --dry-run dist/index.d.ts
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
> [!CAUTION]
|
|
37
|
+
> _dtsroll_ is designed to run on compiled output so it modifies files in-place.
|
|
38
|
+
> - It will modify files you pass in, and files they import.
|
|
39
|
+
> - Only pass in backed up or generated files
|
|
40
|
+
> - Start with `--dry-run`
|
|
41
|
+
|
|
42
|
+
3. If the changes look good, remove the `--dry-run` flag:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
dtsroll dist/index.d.ts
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Recommended setup
|
|
49
|
+
|
|
50
|
+
Running `dtsroll` without specifying input files will auto-detect them from `package.json`.
|
|
51
|
+
|
|
52
|
+
Update your `package.json` to reference `.d.ts` files and include `dtsroll` in the build step:
|
|
53
|
+
```diff
|
|
54
|
+
{
|
|
55
|
+
"name": "my-package",
|
|
56
|
+
"exports": {
|
|
57
|
+
+ "types": "./dist/index.d.ts",
|
|
58
|
+
"default": "./dist/index.js"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
+ "build": "tsc && dtsroll"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Externalization
|
|
67
|
+
|
|
68
|
+
By default, _dtsroll_ decides which dependencies to bundle or keep external by analyzing the `package.json` file. Packages in `devDependencies` are bundled, and packages in other dependency types are externalized.
|
|
69
|
+
|
|
70
|
+
When there is no `package.json` file, you can specify packages to externalize with the `--external` flag.
|
|
71
|
+
|
|
72
|
+
#### Handling `@types` packages
|
|
73
|
+
|
|
74
|
+
Some packages need separate `@types/*` packages for type definitions. In this setup, typically:
|
|
75
|
+
|
|
76
|
+
- The main package is in `dependencies`.
|
|
77
|
+
- The corresponding `@types/*` package is in `devDependencies`.
|
|
78
|
+
|
|
79
|
+
Because the main package is in `dependencies`, _dtsroll_ externalizes it. However, consumers of your package won’t get the type definitions for it because the `@types/*` package is only in `devDependencies`.
|
|
80
|
+
|
|
81
|
+
To fix this, _dtsroll_ will display a warning suggesting you move the `@types/*` package out of `devDependencies`.
|
|
82
|
+
|
|
83
|
+
## CLI Options
|
|
84
|
+
|
|
85
|
+
### --help, -h
|
|
86
|
+
Display usage instructions.
|
|
87
|
+
|
|
88
|
+
### --dry-run, -d
|
|
89
|
+
Simulate the bundling process without modifying the disk and logs what would happen.
|
|
90
|
+
|
|
91
|
+
### --external, -e
|
|
92
|
+
If there is no `package.json` file, you can specify package names to exclude from the bundle.
|
|
93
|
+
|
|
94
|
+
> [!NOTE]
|
|
95
|
+
> This flag can only be used when there is no `package.json`. It's better to define dependencies appropriately in `package.json` instead of using this flag.
|
|
96
|
+
|
|
97
|
+
### --conditions, -C
|
|
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
|
+
|
|
100
|
+
## Related
|
|
101
|
+
|
|
102
|
+
### pkgroll
|
|
103
|
+
For package bundling (along with dts bundling), check out [pkgroll](https://github.com/privatenumber/pkgroll).
|
package/dist/cli.mjs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
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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D(?:\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|\uD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D7A\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\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\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(`
|
|
28
|
+
|
|
29
|
+
`)),C.length>0&&(console.log(j(`
|
|
30
|
+
Chunks`)),console.log(C.map(c=>E({file:c,indent:" ",bullet:"\u25A0",color:Q})).join(`
|
|
31
|
+
|
|
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});
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "dtsroll",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Bundle dts files",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"bundle",
|
|
7
|
+
"typescript",
|
|
8
|
+
"dts",
|
|
9
|
+
"declaration"
|
|
10
|
+
],
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"repository": "privatenumber/dtsroll",
|
|
13
|
+
"funding": "https://github.com/privatenumber/dtsroll?sponsor=1",
|
|
14
|
+
"author": {
|
|
15
|
+
"name": "Hiroki Osame",
|
|
16
|
+
"email": "hiroki.osame@gmail.com"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"bin": "./dist/cli.mjs",
|
|
22
|
+
"exports": null,
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": ">=18"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
28
|
+
"rollup": "^4.29.1",
|
|
29
|
+
"rollup-plugin-dts": "6.1.1"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"typescript": "^4.1 || ^5.0"
|
|
33
|
+
},
|
|
34
|
+
"peerDependenciesMeta": {
|
|
35
|
+
"typescript": {
|
|
36
|
+
"optional": true
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|