dtsroll 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -12
- package/dist/cli.mjs +63 -34
- package/dist/index-D3bowY1b.mjs +534 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.mjs +6 -0
- package/dist/log-output-D6QoPA8O.mjs +100 -0
- package/dist/vite.d.ts +7 -0
- package/dist/vite.mjs +31 -0
- package/package.json +20 -4
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
28
|
-
|
|
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
|
-
|
|
33
|
-
|
|
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
|
-
|
|
45
|
-
|
|
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
|
|
83
|
+
## CLI
|
|
84
84
|
|
|
85
85
|
### --help, -h
|
|
86
86
|
Display usage instructions.
|
|
@@ -97,6 +97,37 @@ 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({
|
|
105
|
+
// inputs?: string[];
|
|
106
|
+
// external?: string[];
|
|
107
|
+
// conditions?: string[];
|
|
108
|
+
// dryRun?: boolean;
|
|
109
|
+
})
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Vite plugin
|
|
113
|
+
|
|
114
|
+
Use it in conjunction with a plugin that generates the initial declaration files like `vite-plugin-dts`.
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
import { defineConfig } from 'vitest/config'
|
|
118
|
+
import dts from 'vite-plugin-dts'
|
|
119
|
+
import { dtsroll } from 'dtsroll/vite'
|
|
120
|
+
|
|
121
|
+
export default defineConfig({
|
|
122
|
+
// ...
|
|
123
|
+
plugins: [
|
|
124
|
+
// ...
|
|
125
|
+
dts(),
|
|
126
|
+
dtsroll()
|
|
127
|
+
]
|
|
128
|
+
})
|
|
129
|
+
```
|
|
130
|
+
|
|
100
131
|
## Related
|
|
101
132
|
|
|
102
133
|
### 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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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-D3bowY1b.mjs';
|
|
4
|
+
import { l as logOutput } from './log-output-D6QoPA8O.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
|
-
|
|
30
|
-
|
|
12
|
+
var name = "dtsroll";
|
|
13
|
+
var version = "1.1.0";
|
|
14
|
+
var description = "Bundle dts files";
|
|
31
15
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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,534 @@
|
|
|
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 () => {
|
|
242
|
+
const packageJsonPath = path.resolve("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
|
+
inputs,
|
|
446
|
+
external,
|
|
447
|
+
conditions,
|
|
448
|
+
dryRun
|
|
449
|
+
} = {}) => {
|
|
450
|
+
const pkgJson = await getPackageJson();
|
|
451
|
+
const externals = pkgJson ? pkgJson.getExternals() : /* @__PURE__ */ new Map();
|
|
452
|
+
if (external && external.length > 0) {
|
|
453
|
+
if (pkgJson) {
|
|
454
|
+
console.warn(`${yellow("Warning:")} The --external flag is only supported when there is no package.json`);
|
|
455
|
+
} else {
|
|
456
|
+
for (const externalDependency of external) {
|
|
457
|
+
externals.set(externalDependency, "by --external flag");
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
const manualInput = inputs && inputs.length > 0;
|
|
462
|
+
const validatedInputs = await validateInput(
|
|
463
|
+
manualInput ? inputs.map((file) => path.resolve(file)) : pkgJson?.getDtsEntryPoints()
|
|
464
|
+
);
|
|
465
|
+
const inputFiles = validatedInputs.filter((input) => !input[2]).map(([file]) => file);
|
|
466
|
+
if (inputFiles.length === 0) {
|
|
467
|
+
return {
|
|
468
|
+
inputs: validatedInputs,
|
|
469
|
+
error: "No input files"
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
const outputDirectory = getCommonDirectory(inputFiles);
|
|
473
|
+
const {
|
|
474
|
+
built,
|
|
475
|
+
externalized,
|
|
476
|
+
getPackageEntryPoint,
|
|
477
|
+
sourceSize
|
|
478
|
+
} = await build(
|
|
479
|
+
inputFiles,
|
|
480
|
+
outputDirectory,
|
|
481
|
+
externals,
|
|
482
|
+
dryRun ? "generate" : "write",
|
|
483
|
+
conditions
|
|
484
|
+
);
|
|
485
|
+
let outputSize = 0;
|
|
486
|
+
const outputEntries = [];
|
|
487
|
+
const outputChunks = [];
|
|
488
|
+
const moduleImports = /* @__PURE__ */ new Set();
|
|
489
|
+
for (const file of built.output) {
|
|
490
|
+
const size = Buffer.byteLength(file.code);
|
|
491
|
+
outputSize += size;
|
|
492
|
+
const moduleToPackage = Object.fromEntries(
|
|
493
|
+
file.moduleIds.map((moduleId) => [moduleId, getPackageEntryPoint(moduleId)])
|
|
494
|
+
);
|
|
495
|
+
const chunkWithSize = Object.assign(file, {
|
|
496
|
+
size,
|
|
497
|
+
moduleToPackage
|
|
498
|
+
});
|
|
499
|
+
if (chunkWithSize.isEntry) {
|
|
500
|
+
outputEntries.push(chunkWithSize);
|
|
501
|
+
} else {
|
|
502
|
+
outputChunks.push(chunkWithSize);
|
|
503
|
+
}
|
|
504
|
+
for (const id of file.imports) {
|
|
505
|
+
moduleImports.add(getPackageName(id));
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
const externalPackages = [];
|
|
509
|
+
moduleImports.forEach((importedSpecifier) => {
|
|
510
|
+
const reason = externalized.get(importedSpecifier);
|
|
511
|
+
if (reason) {
|
|
512
|
+
externalPackages.push([
|
|
513
|
+
importedSpecifier,
|
|
514
|
+
reason,
|
|
515
|
+
pkgJson?.devTypePackages?.[importedSpecifier]
|
|
516
|
+
]);
|
|
517
|
+
}
|
|
518
|
+
});
|
|
519
|
+
return {
|
|
520
|
+
inputs: validatedInputs,
|
|
521
|
+
outputDirectory,
|
|
522
|
+
output: {
|
|
523
|
+
entries: outputEntries,
|
|
524
|
+
chunks: outputChunks
|
|
525
|
+
},
|
|
526
|
+
size: {
|
|
527
|
+
input: sourceSize,
|
|
528
|
+
output: outputSize
|
|
529
|
+
},
|
|
530
|
+
externals: externalPackages
|
|
531
|
+
};
|
|
532
|
+
};
|
|
533
|
+
|
|
534
|
+
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 };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
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,
|
|
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
|
+
inputs?: string[];
|
|
36
|
+
external?: string[];
|
|
37
|
+
conditions?: string[];
|
|
38
|
+
dryRun?: boolean;
|
|
39
|
+
};
|
|
40
|
+
declare const dtsroll: ({ inputs, external, conditions, dryRun, }?: Options) => Promise<DtsrollOutput>;
|
|
41
|
+
|
|
42
|
+
export { type DtsrollOutput, type Options, dtsroll };
|
package/dist/index.mjs
ADDED
|
@@ -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-D3bowY1b.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
package/dist/vite.mjs
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { l as logOutput } from './log-output-D6QoPA8O.mjs';
|
|
2
|
+
import { d as dtsroll } from './index-D3bowY1b.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
|
+
return {
|
|
13
|
+
name: "dtsroll",
|
|
14
|
+
apply: "build",
|
|
15
|
+
enforce: "post",
|
|
16
|
+
writeBundle: {
|
|
17
|
+
sequential: true,
|
|
18
|
+
order: "post",
|
|
19
|
+
handler: async () => {
|
|
20
|
+
if (built) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
logOutput(await dtsroll(options));
|
|
24
|
+
console.log();
|
|
25
|
+
built = true;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { dtsrollPlugin as dtsroll };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dtsroll",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.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":
|
|
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.
|
|
47
|
+
"typescript": "^4.5 || ^5.0",
|
|
48
|
+
"vite": "5 || 6"
|
|
33
49
|
},
|
|
34
50
|
"peerDependenciesMeta": {
|
|
35
|
-
"
|
|
51
|
+
"vite": {
|
|
36
52
|
"optional": true
|
|
37
53
|
}
|
|
38
54
|
}
|