nf3 0.2.0 → 0.3.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.
Files changed (49) hide show
  1. package/README.md +23 -25
  2. package/dist/_chunks/libs/confbox.mjs +7 -0
  3. package/dist/_chunks/libs/exsolve.mjs +1 -0
  4. package/dist/_chunks/libs/pathe.mjs +1 -0
  5. package/dist/_chunks/libs/pkg-types.mjs +1 -0
  6. package/dist/_chunks/trace.mjs +253 -0
  7. package/dist/_chunks/trace2.mjs +3 -0
  8. package/dist/_chunks/types.d.mts +101 -0
  9. package/dist/index.d.mts +2 -96
  10. package/dist/index.mjs +2 -316
  11. package/dist/node_modules/@isaacs/balanced-match/dist/commonjs/index.js +1 -0
  12. package/dist/node_modules/@isaacs/balanced-match/dist/commonjs/package.json +3 -0
  13. package/dist/node_modules/@isaacs/balanced-match/package.json +19 -0
  14. package/dist/node_modules/@isaacs/brace-expansion/dist/commonjs/index.js +1 -0
  15. package/dist/node_modules/@isaacs/brace-expansion/dist/commonjs/package.json +3 -0
  16. package/dist/node_modules/@isaacs/brace-expansion/package.json +19 -0
  17. package/dist/node_modules/@mapbox/node-pre-gyp/lib/install.js +1 -1
  18. package/dist/node_modules/@mapbox/node-pre-gyp/lib/mock/http.js +2 -0
  19. package/dist/node_modules/@mapbox/node-pre-gyp/lib/mock/s3.js +1 -0
  20. package/dist/node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js +1 -1
  21. package/dist/node_modules/@mapbox/node-pre-gyp/lib/publish.js +1 -1
  22. package/dist/node_modules/@mapbox/node-pre-gyp/lib/util/abi_crosswalk.json +53 -1
  23. package/dist/node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js +1 -2
  24. package/dist/node_modules/@mapbox/node-pre-gyp/lib/util/versioning.js +1 -1
  25. package/dist/node_modules/@mapbox/node-pre-gyp/package.json +1 -1
  26. package/dist/node_modules/@vercel/nft/out/resolve-dependency.js +1 -1
  27. package/dist/node_modules/@vercel/nft/package.json +1 -1
  28. package/dist/node_modules/glob/package.json +1 -1
  29. package/dist/node_modules/lru-cache/dist/commonjs/index.js +1 -1
  30. package/dist/node_modules/lru-cache/package.json +1 -1
  31. package/dist/node_modules/minimatch/dist/commonjs/ast.js +1 -1
  32. package/dist/node_modules/minimatch/dist/commonjs/escape.js +1 -1
  33. package/dist/node_modules/minimatch/dist/commonjs/index.js +3 -3
  34. package/dist/node_modules/minimatch/dist/commonjs/unescape.js +1 -1
  35. package/dist/node_modules/minimatch/package.json +1 -1
  36. package/dist/node_modules/path-scurry/dist/commonjs/index.js +1 -1
  37. package/dist/node_modules/path-scurry/package.json +1 -1
  38. package/dist/plugin.d.mts +7 -0
  39. package/dist/plugin.mjs +92 -0
  40. package/package.json +13 -13
  41. package/dist/_libs/confbox.mjs +0 -13
  42. package/dist/_libs/exsolve.mjs +0 -1
  43. package/dist/_libs/mlly.mjs +0 -1
  44. package/dist/_libs/pkg-types.mjs +0 -1
  45. package/dist/node_modules/acorn/dist/acorn.mjs +0 -9
  46. package/dist/node_modules/balanced-match/index.js +0 -1
  47. package/dist/node_modules/balanced-match/package.json +0 -5
  48. package/dist/node_modules/brace-expansion/index.js +0 -1
  49. package/dist/node_modules/brace-expansion/package.json +0 -5
package/README.md CHANGED
@@ -20,42 +20,40 @@ Originally extracted from [Nitro](https://nitro.build) and used for optimizing `
20
20
 
21
21
  ## Usage
22
22
 
23
- ### Rollup/Rolldown plugin
23
+ ### API
24
+
25
+ ```js
26
+ import { traceNodeModules } from "nf3";
27
+
28
+ await traceNodeModules(["./index.mjs"], {
29
+ // outDir: "dist",
30
+ // chmod: 0o755,
31
+ // writePackageJson: true,
32
+ // traceAlias: {},
33
+ // hooks: {},
34
+ // nft: {}, // https://github.com/vercel/nft#options
35
+ });
36
+ ```
37
+
38
+ ### Rollup/Rolldown/Vite Plugin
24
39
 
25
40
  ```js
26
- import { rollupNodeFileTrace } from "nf3";
41
+ import { externals } from "nf3/plugin";
27
42
 
28
43
  export default {
29
44
  plugins: [
30
- rollupNodeFileTrace({
31
- // rootDir: process.cwd(),
32
- // outDir: "dist",
33
- // exportConditions: ["node", "import", "default"],
34
- // traceAlias: {},
35
- // chmod: true, // or 0o755
36
- // noTrace: false,
37
- // inline: [/^@my-scope\//],
38
- // external: ["fsevents"],
39
- // moduleDirectories: ["node_modules"],
45
+ externals({
46
+ // rootDir: ".",
47
+ // conditions: ["node", "import", "default"],
48
+ // include: [/^@my-scope\//],
49
+ // exclude: ["fsevents"],
40
50
  // traceInclude: ["some-lib"],
41
- // writePackageJson: true,
42
- // hooks: {},
43
- // traceOptions: { /* see https://github.com/vercel/nft#options */ }
51
+ // trace: {}
44
52
  }),
45
53
  ],
46
54
  };
47
55
  ```
48
56
 
49
- ### API
50
-
51
- ```js
52
- import { traceNodeModules } from "nf3";
53
-
54
- await traceNodeModules(["./index.mjs"], {
55
- /* options */
56
- });
57
- ```
58
-
59
57
  ### Hooks
60
58
 
61
59
  After the Rollup plugin traces the required files, `traceNodeModules` processes them into an optimized `node_modules` output.
@@ -0,0 +1,7 @@
1
+ const b=/^(?:( )+|\t+)/,d=`space`;function g(n,a){let o=new Map,s=0,c,l;for(let u of n.split(/\n/g)){if(!u)continue;let n,f,p,y,D,O=u.match(b);if(O===null)s=0,c=``;else{if(n=O[0].length,f=O[1]?d:`tab`,a&&f===d&&n===1)continue;f!==c&&(s=0),c=f,p=1,y=0;let e=n-s;if(s=n,e===0)p=0,y=1;else{let t=e>0?e:-e;l=T(f,t)}D=o.get(l),D=D===void 0?[1,0]:[D[0]+p,D[1]+y],o.set(l,D)}}return o}function T(e,n){return(e===d?`s`:`t`)+String(n)}function w(e){return{type:e[0]===`s`?d:`tab`,amount:Number(e.slice(1))}}function E(e){let t,n=0,i=0;for(let[a,[o,s]]of e)(o>n||o===n&&s>i)&&(n=o,i=s,t=a);return t}function S$1(e,n){return(e===d?` `:` `).repeat(n)}function _(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);let t=g(e,!0);t.size===0&&(t=g(e,!1));let i=E(t),c,l=0,u=``;return i!==void 0&&({type:c,amount:l}=w(i),u=S$1(c,l)),{amount:l,type:c,indent:u}}const m=Symbol.for(`__confbox_fmt__`),k=/^(\s+)/,v=/(\s+)$/;function x$1(e,t={}){return{sample:t.indent===void 0&&t.preserveIndentation!==!1&&e.slice(0,t?.sampleSize||1024),whiteSpace:t.preserveWhitespace===!1?void 0:{start:k.exec(e)?.[0]||``,end:v.exec(e)?.[0]||``}}}function N(e,t,n){!t||typeof t!=`object`||Object.defineProperty(t,m,{enumerable:!1,configurable:!0,writable:!0,value:x$1(e,n)})}function C(e,t){if(!e||typeof e!=`object`||!(m in e))return{indent:t?.indent??2,whitespace:{start:``,end:``}};let n=e[m];return{indent:t?.indent||_(n.sample||``).indent,whitespace:n.whiteSpace||{start:``,end:``}}}function $(e,t=!1){let n=e.length,i=0,a=``,o=0,s=16,c=0,l=0,u=0,f=0,p=0;function y(t,n){let a=0,o=0;for(;a<t;){let t=e.charCodeAt(i);if(t>=48&&t<=57)o=o*16+t-48;else if(t>=65&&t<=70)o=o*16+t-65+10;else if(t>=97&&t<=102)o=o*16+t-97+10;else break;i++,a++}return a<t&&(o=-1),o}function D(e){i=e,a=``,o=0,s=16,p=0}function O(){let t=i;if(e.charCodeAt(i)===48)i++;else for(i++;i<e.length&&L(e.charCodeAt(i));)i++;if(i<e.length&&e.charCodeAt(i)===46)if(i++,i<e.length&&L(e.charCodeAt(i)))for(i++;i<e.length&&L(e.charCodeAt(i));)i++;else return p=3,e.substring(t,i);let n=i;if(i<e.length&&(e.charCodeAt(i)===69||e.charCodeAt(i)===101))if(i++,(i<e.length&&e.charCodeAt(i)===43||e.charCodeAt(i)===45)&&i++,i<e.length&&L(e.charCodeAt(i))){for(i++;i<e.length&&L(e.charCodeAt(i));)i++;n=i}else p=3;return e.substring(t,n)}function M(){let t=``,a=i;for(;;){if(i>=n){t+=e.substring(a,i),p=2;break}let o=e.charCodeAt(i);if(o===34){t+=e.substring(a,i),i++;break}if(o===92){if(t+=e.substring(a,i),i++,i>=n){p=2;break}switch(e.charCodeAt(i++)){case 34:t+=`"`;break;case 92:t+=`\\`;break;case 47:t+=`/`;break;case 98:t+=`\b`;break;case 102:t+=`\f`;break;case 110:t+=`
2
+ `;break;case 114:t+=`\r`;break;case 116:t+=` `;break;case 117:let e=y(4);e>=0?t+=String.fromCharCode(e):p=4;break;default:p=5}a=i;continue}if(o>=0&&o<=31)if(r(o)){t+=e.substring(a,i),p=2;break}else p=6;i++}return t}function F(){if(a=``,p=0,o=i,l=c,f=u,i>=n)return o=n,s=17;let t=e.charCodeAt(i);if(J(t)){do i++,a+=String.fromCharCode(t),t=e.charCodeAt(i);while(J(t));return s=15}if(r(t))return i++,a+=String.fromCharCode(t),t===13&&e.charCodeAt(i)===10&&(i++,a+=`
3
+ `),c++,u=i,s=14;switch(t){case 123:return i++,s=1;case 125:return i++,s=2;case 91:return i++,s=3;case 93:return i++,s=4;case 58:return i++,s=6;case 44:return i++,s=5;case 34:return i++,a=M(),s=10;case 47:let l=i-1;if(e.charCodeAt(i+1)===47){for(i+=2;i<n&&!r(e.charCodeAt(i));)i++;return a=e.substring(l,i),s=12}if(e.charCodeAt(i+1)===42){i+=2;let t=n-1,o=!1;for(;i<t;){let t=e.charCodeAt(i);if(t===42&&e.charCodeAt(i+1)===47){i+=2,o=!0;break}i++,r(t)&&(t===13&&e.charCodeAt(i)===10&&i++,c++,u=i)}return o||(i++,p=1),a=e.substring(l,i),s=13}return a+=String.fromCharCode(t),i++,s=16;case 45:if(a+=String.fromCharCode(t),i++,i===n||!L(e.charCodeAt(i)))return s=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return a+=O(),s=11;default:for(;i<n&&I(t);)i++,t=e.charCodeAt(i);if(o!==i){switch(a=e.substring(o,i),a){case`true`:return s=8;case`false`:return s=9;case`null`:return s=7}return s=16}return a+=String.fromCharCode(t),i++,s=16}}function I(e){if(J(e)||r(e))return!1;switch(e){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return!1}return!0}function R(){let e;do e=F();while(e>=12&&e<=15);return e}return{setPosition:D,getPosition:()=>i,scan:t?R:F,getToken:()=>s,getTokenValue:()=>a,getTokenOffset:()=>o,getTokenLength:()=>i-o,getTokenStartLine:()=>l,getTokenStartCharacter:()=>o-f,getTokenError:()=>p}}function J(e){return e===32||e===9}function r(e){return e===10||e===13}function L(e){return e>=48&&e<=57}var Q;(function(e){e[e.lineFeed=10]=`lineFeed`,e[e.carriageReturn=13]=`carriageReturn`,e[e.space=32]=`space`,e[e._0=48]=`_0`,e[e._1=49]=`_1`,e[e._2=50]=`_2`,e[e._3=51]=`_3`,e[e._4=52]=`_4`,e[e._5=53]=`_5`,e[e._6=54]=`_6`,e[e._7=55]=`_7`,e[e._8=56]=`_8`,e[e._9=57]=`_9`,e[e.a=97]=`a`,e[e.b=98]=`b`,e[e.c=99]=`c`,e[e.d=100]=`d`,e[e.e=101]=`e`,e[e.f=102]=`f`,e[e.g=103]=`g`,e[e.h=104]=`h`,e[e.i=105]=`i`,e[e.j=106]=`j`,e[e.k=107]=`k`,e[e.l=108]=`l`,e[e.m=109]=`m`,e[e.n=110]=`n`,e[e.o=111]=`o`,e[e.p=112]=`p`,e[e.q=113]=`q`,e[e.r=114]=`r`,e[e.s=115]=`s`,e[e.t=116]=`t`,e[e.u=117]=`u`,e[e.v=118]=`v`,e[e.w=119]=`w`,e[e.x=120]=`x`,e[e.y=121]=`y`,e[e.z=122]=`z`,e[e.A=65]=`A`,e[e.B=66]=`B`,e[e.C=67]=`C`,e[e.D=68]=`D`,e[e.E=69]=`E`,e[e.F=70]=`F`,e[e.G=71]=`G`,e[e.H=72]=`H`,e[e.I=73]=`I`,e[e.J=74]=`J`,e[e.K=75]=`K`,e[e.L=76]=`L`,e[e.M=77]=`M`,e[e.N=78]=`N`,e[e.O=79]=`O`,e[e.P=80]=`P`,e[e.Q=81]=`Q`,e[e.R=82]=`R`,e[e.S=83]=`S`,e[e.T=84]=`T`,e[e.U=85]=`U`,e[e.V=86]=`V`,e[e.W=87]=`W`,e[e.X=88]=`X`,e[e.Y=89]=`Y`,e[e.Z=90]=`Z`,e[e.asterisk=42]=`asterisk`,e[e.backslash=92]=`backslash`,e[e.closeBrace=125]=`closeBrace`,e[e.closeBracket=93]=`closeBracket`,e[e.colon=58]=`colon`,e[e.comma=44]=`comma`,e[e.dot=46]=`dot`,e[e.doubleQuote=34]=`doubleQuote`,e[e.minus=45]=`minus`,e[e.openBrace=123]=`openBrace`,e[e.openBracket=91]=`openBracket`,e[e.plus=43]=`plus`,e[e.slash=47]=`slash`,e[e.formFeed=12]=`formFeed`,e[e.tab=9]=`tab`})(Q||={}),Array(20).fill(0).map((e,t)=>` `.repeat(t)),Array(200).fill(0).map((e,t)=>`
4
+ `+` `.repeat(t)),Array(200).fill(0).map((e,t)=>`\r`+` `.repeat(t)),Array(200).fill(0).map((e,t)=>`\r
5
+ `+` `.repeat(t)),Array(200).fill(0).map((e,t)=>`
6
+ `+` `.repeat(t)),Array(200).fill(0).map((e,t)=>`\r`+` `.repeat(t)),Array(200).fill(0).map((e,t)=>`\r
7
+ `+` `.repeat(t));var U;(function(e){e.DEFAULT={allowTrailingComma:!1}})(U||={});function S(e,t=[],n=U.DEFAULT){let i=null,a=[],o=[];function s(e){Array.isArray(a)?a.push(e):i!==null&&(a[i]=e)}return P(e,{onObjectBegin:()=>{let e={};s(e),o.push(a),a=e,i=null},onObjectProperty:e=>{i=e},onObjectEnd:()=>{a=o.pop()},onArrayBegin:()=>{let e=[];s(e),o.push(a),a=e,i=null},onArrayEnd:()=>{a=o.pop()},onLiteralValue:s,onError:(e,n,i)=>{t.push({error:e,offset:n,length:i})}},n),a[0]}function P(e,t,n=U.DEFAULT){let i=$(e,!1),a=[],o=0;function s(e){return e?()=>o===0&&e(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter()):()=>!0}function c(e){return e?t=>o===0&&e(t,i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter()):()=>!0}function l(e){return e?t=>o===0&&e(t,i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter(),()=>a.slice()):()=>!0}function u(e){return e?()=>{o>0?o++:e(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter(),()=>a.slice())===!1&&(o=1)}:()=>!0}function f(e){return e?()=>{o>0&&o--,o===0&&e(i.getTokenOffset(),i.getTokenLength(),i.getTokenStartLine(),i.getTokenStartCharacter())}:()=>!0}let p=u(t.onObjectBegin),y=l(t.onObjectProperty),D=f(t.onObjectEnd),A=u(t.onArrayBegin),ee=f(t.onArrayEnd),j=l(t.onLiteralValue),M=c(t.onSeparator),I=s(t.onComment),R=c(t.onError),B=n&&n.disallowComments,V=n&&n.allowTrailingComma;function G(){for(;;){let e=i.scan();switch(i.getTokenError()){case 4:Y(14);break;case 5:Y(15);break;case 3:Y(13);break;case 1:B||Y(11);break;case 2:Y(12);break;case 6:Y(16);break}switch(e){case 12:case 13:B?Y(10):I();break;case 16:Y(1);break;case 15:case 14:break;default:return e}}}function Y(e,t=[],n=[]){if(R(e),t.length+n.length>0){let e=i.getToken();for(;e!==17;){if(t.indexOf(e)!==-1){G();break}else if(n.indexOf(e)!==-1)break;e=G()}}}function X(e){let t=i.getTokenValue();return e?j(t):(y(t),a.push(t)),G(),!0}function te(){switch(i.getToken()){case 11:let e=i.getTokenValue(),t=Number(e);isNaN(t)&&(Y(2),t=0),j(t);break;case 7:j(null);break;case 8:j(!0);break;case 9:j(!1);break;default:return!1}return G(),!0}function ne(){return i.getToken()===10?(X(!1),i.getToken()===6?(M(`:`),G(),Z()||Y(4,[],[2,5])):Y(5,[],[2,5]),a.pop(),!0):(Y(3,[],[2,5]),!1)}function re(){p(),G();let e=!1;for(;i.getToken()!==2&&i.getToken()!==17;){if(i.getToken()===5){if(e||Y(4,[],[]),M(`,`),G(),i.getToken()===2&&V)break}else e&&Y(6,[],[]);ne()||Y(4,[],[2,5]),e=!0}return D(),i.getToken()===2?G():Y(7,[2],[]),!0}function ie(){A(),G();let e=!0,t=!1;for(;i.getToken()!==4&&i.getToken()!==17;){if(i.getToken()===5){if(t||Y(4,[],[]),M(`,`),G(),i.getToken()===4&&V)break}else t&&Y(6,[],[]);e?(a.push(0),e=!1):a[a.length-1]++,Z()||Y(4,[],[4,5]),t=!0}return ee(),e||a.pop(),i.getToken()===4?G():Y(8,[4],[]),!0}function Z(){switch(i.getToken()){case 3:return ie();case 1:return re();case 10:return X(!0);default:return te()}}return G(),i.getToken()===17?n.allowEmptyContent?!0:(Y(4,[],[]),!1):Z()?(i.getToken()!==17&&Y(9,[],[]),!0):(Y(4,[],[]),!1)}var W;(function(e){e[e.None=0]=`None`,e[e.UnexpectedEndOfComment=1]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=2]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=3]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=4]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=5]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=6]=`InvalidCharacter`})(W||={});var H;(function(e){e[e.OpenBraceToken=1]=`OpenBraceToken`,e[e.CloseBraceToken=2]=`CloseBraceToken`,e[e.OpenBracketToken=3]=`OpenBracketToken`,e[e.CloseBracketToken=4]=`CloseBracketToken`,e[e.CommaToken=5]=`CommaToken`,e[e.ColonToken=6]=`ColonToken`,e[e.NullKeyword=7]=`NullKeyword`,e[e.TrueKeyword=8]=`TrueKeyword`,e[e.FalseKeyword=9]=`FalseKeyword`,e[e.StringLiteral=10]=`StringLiteral`,e[e.NumericLiteral=11]=`NumericLiteral`,e[e.LineCommentTrivia=12]=`LineCommentTrivia`,e[e.BlockCommentTrivia=13]=`BlockCommentTrivia`,e[e.LineBreakTrivia=14]=`LineBreakTrivia`,e[e.Trivia=15]=`Trivia`,e[e.Unknown=16]=`Unknown`,e[e.EOF=17]=`EOF`})(H||={});const K=S;var q;(function(e){e[e.InvalidSymbol=1]=`InvalidSymbol`,e[e.InvalidNumberFormat=2]=`InvalidNumberFormat`,e[e.PropertyNameExpected=3]=`PropertyNameExpected`,e[e.ValueExpected=4]=`ValueExpected`,e[e.ColonExpected=5]=`ColonExpected`,e[e.CommaExpected=6]=`CommaExpected`,e[e.CloseBraceExpected=7]=`CloseBraceExpected`,e[e.CloseBracketExpected=8]=`CloseBracketExpected`,e[e.EndOfFileExpected=9]=`EndOfFileExpected`,e[e.InvalidCommentToken=10]=`InvalidCommentToken`,e[e.UnexpectedEndOfComment=11]=`UnexpectedEndOfComment`,e[e.UnexpectedEndOfString=12]=`UnexpectedEndOfString`,e[e.UnexpectedEndOfNumber=13]=`UnexpectedEndOfNumber`,e[e.InvalidUnicode=14]=`InvalidUnicode`,e[e.InvalidEscapeCharacter=15]=`InvalidEscapeCharacter`,e[e.InvalidCharacter=16]=`InvalidCharacter`})(q||={});function x(e,t){let n=JSON.parse(e,t?.reviver);return N(e,n,t),n}function z(e,t){let n=C(e,t),i=JSON.stringify(e,t?.replacer,n.indent);return n.whitespace.start+i+n.whitespace.end}function h(e,t){let n=K(e,t?.errors,t);return N(e,n,t),n}export{x as n,z as r,h as t};
@@ -0,0 +1 @@
1
+ import fs,{lstatSync,realpathSync,statSync}from"node:fs";import{URL as URL$1,fileURLToPath,pathToFileURL}from"node:url";import path,{isAbsolute}from"node:path";import assert from"node:assert";import process$1 from"node:process";import v8 from"node:v8";import{format,inspect}from"node:util";const nodeBuiltins=`_http_agent._http_client._http_common._http_incoming._http_outgoing._http_server._stream_duplex._stream_passthrough._stream_readable._stream_transform._stream_wrap._stream_writable._tls_common._tls_wrap.assert.assert/strict.async_hooks.buffer.child_process.cluster.console.constants.crypto.dgram.diagnostics_channel.dns.dns/promises.domain.events.fs.fs/promises.http.http2.https.inspector.inspector/promises.module.net.os.path.path/posix.path/win32.perf_hooks.process.punycode.querystring.readline.readline/promises.repl.stream.stream/consumers.stream/promises.stream/web.string_decoder.sys.timers.timers/promises.tls.trace_events.tty.url.util.util/types.v8.vm.wasi.worker_threads.zlib`.split(`.`),own$1={}.hasOwnProperty,classRegExp=/^([A-Z][a-z\d]*)+$/,kTypes=new Set([`string`,`function`,`number`,`object`,`Function`,`Object`,`boolean`,`bigint`,`symbol`]),messages=new Map;let userStackTraceLimit;function formatList(l,R=`and`){return l.length<3?l.join(` ${R} `):`${l.slice(0,-1).join(`, `)}, ${R} ${l.at(-1)}`}function createError(l,R,z){return messages.set(l,R),makeNodeErrorWithCode(z,l)}function makeNodeErrorWithCode(l,R){return function(...z){let B=Error.stackTraceLimit;isErrorStackTraceLimitWritable()&&(Error.stackTraceLimit=0);let V=new l;isErrorStackTraceLimitWritable()&&(Error.stackTraceLimit=B);let H=getMessage(R,z,V);return Object.defineProperties(V,{message:{value:H,enumerable:!1,writable:!0,configurable:!0},toString:{value(){return`${this.name} [${R}]: ${this.message}`},enumerable:!1,writable:!0,configurable:!0}}),captureLargerStackTrace(V),V.code=R,V}}function isErrorStackTraceLimitWritable(){try{if(v8.startupSnapshot.isBuildingSnapshot())return!1}catch{}let l=Object.getOwnPropertyDescriptor(Error,`stackTraceLimit`);return l===void 0?Object.isExtensible(Error):own$1.call(l,`writable`)&&l.writable!==void 0?l.writable:l.set!==void 0}function hideStackFrames(l){let R=`__node_internal_`+l.name;return Object.defineProperty(l,`name`,{value:R}),l}const captureLargerStackTrace=hideStackFrames(function(l){let R=isErrorStackTraceLimitWritable();return R&&(userStackTraceLimit=Error.stackTraceLimit,Error.stackTraceLimit=1/0),Error.captureStackTrace(l),R&&(Error.stackTraceLimit=userStackTraceLimit),l});function getMessage(l,R,z){let B=messages.get(l);if(assert.ok(B!==void 0,"expected `message` to be found"),typeof B==`function`)return assert.ok(B.length<=R.length,`Code: ${l}; The provided arguments length (${R.length}) does not match the required ones (${B.length}).`),Reflect.apply(B,z,R);let V=/%[dfijoOs]/g,H=0;for(;V.exec(B)!==null;)H++;return assert.ok(H===R.length,`Code: ${l}; The provided arguments length (${R.length}) does not match the required ones (${H}).`),R.length===0?B:(R.unshift(B),Reflect.apply(format,null,R))}function determineSpecificType(l){if(l==null)return String(l);if(typeof l==`function`&&l.name)return`function ${l.name}`;if(typeof l==`object`)return l.constructor&&l.constructor.name?`an instance of ${l.constructor.name}`:`${inspect(l,{depth:-1})}`;let R=inspect(l,{colors:!1});return R.length>28&&(R=`${R.slice(0,25)}...`),`type ${typeof l} (${R})`}createError(`ERR_INVALID_ARG_TYPE`,(l,R,z)=>{assert.ok(typeof l==`string`,`'name' must be a string`),Array.isArray(R)||(R=[R]);let B=`The `;if(l.endsWith(` argument`))B+=`${l} `;else{let R=l.includes(`.`)?`property`:`argument`;B+=`"${l}" ${R} `}B+=`must be `;let V=[],H=[],U=[];for(let l of R)assert.ok(typeof l==`string`,`All expected entries have to be of type string`),kTypes.has(l)?V.push(l.toLowerCase()):classRegExp.exec(l)===null?(assert.ok(l!==`object`,`The value "object" should be written as "Object"`),U.push(l)):H.push(l);if(H.length>0){let l=V.indexOf(`object`);l!==-1&&(V.slice(l,1),H.push(`Object`))}return V.length>0&&(B+=`${V.length>1?`one of type`:`of type`} ${formatList(V,`or`)}`,(H.length>0||U.length>0)&&(B+=` or `)),H.length>0&&(B+=`an instance of ${formatList(H,`or`)}`,U.length>0&&(B+=` or `)),U.length>0&&(U.length>1?B+=`one of ${formatList(U,`or`)}`:(U[0]?.toLowerCase()!==U[0]&&(B+=`an `),B+=`${U[0]}`)),B+=`. Received ${determineSpecificType(z)}`,B},TypeError);const ERR_INVALID_MODULE_SPECIFIER=createError(`ERR_INVALID_MODULE_SPECIFIER`,(l,R,z)=>`Invalid module "${l}" ${R}${z?` imported from ${z}`:``}`,TypeError),ERR_INVALID_PACKAGE_CONFIG=createError(`ERR_INVALID_PACKAGE_CONFIG`,(l,R,z)=>`Invalid package config ${l}${R?` while importing ${R}`:``}${z?`. ${z}`:``}`,Error),ERR_INVALID_PACKAGE_TARGET=createError(`ERR_INVALID_PACKAGE_TARGET`,(l,R,z,B=!1,V)=>{let H=typeof z==`string`&&!B&&z.length>0&&!z.startsWith(`./`);return R===`.`?(assert.ok(B===!1),`Invalid "exports" main target ${JSON.stringify(z)} defined in the package config ${l}package.json${V?` imported from ${V}`:``}${H?`; targets must start with "./"`:``}`):`Invalid "${B?`imports`:`exports`}" target ${JSON.stringify(z)} defined for '${R}' in the package config ${l}package.json${V?` imported from ${V}`:``}${H?`; targets must start with "./"`:``}`},Error),ERR_MODULE_NOT_FOUND=createError(`ERR_MODULE_NOT_FOUND`,(l,R,z=!1)=>`Cannot find ${z?`module`:`package`} '${l}' imported from ${R}`,Error);createError(`ERR_NETWORK_IMPORT_DISALLOWED`,`import of '%s' by %s is not supported: %s`,Error);const ERR_PACKAGE_IMPORT_NOT_DEFINED=createError(`ERR_PACKAGE_IMPORT_NOT_DEFINED`,(l,R,z)=>`Package import specifier "${l}" is not defined${R?` in package ${R||``}package.json`:``} imported from ${z}`,TypeError),ERR_PACKAGE_PATH_NOT_EXPORTED=createError(`ERR_PACKAGE_PATH_NOT_EXPORTED`,(l,R,z)=>R===`.`?`No "exports" main defined in ${l}package.json${z?` imported from ${z}`:``}`:`Package subpath '${R}' is not defined by "exports" in ${l}package.json${z?` imported from ${z}`:``}`,Error),ERR_UNSUPPORTED_DIR_IMPORT=createError(`ERR_UNSUPPORTED_DIR_IMPORT`,`Directory import '%s' is not supported resolving ES modules imported from %s`,Error),ERR_UNSUPPORTED_RESOLVE_REQUEST=createError(`ERR_UNSUPPORTED_RESOLVE_REQUEST`,`Failed to resolve module specifier "%s" from "%s": Invalid relative URL or base scheme is not hierarchical.`,TypeError),ERR_UNKNOWN_FILE_EXTENSION=createError(`ERR_UNKNOWN_FILE_EXTENSION`,(l,R)=>`Unknown file extension "${l}" for ${R}`,TypeError);createError(`ERR_INVALID_ARG_VALUE`,(l,R,z=`is invalid`)=>{let B=inspect(R);return B.length>128&&(B=`${B.slice(0,128)}...`),`The ${l.includes(`.`)?`property`:`argument`} '${l}' ${z}. Received ${B}`},TypeError);const hasOwnProperty$1={}.hasOwnProperty,cache=new Map;function read(R,{base:z,specifier:B}){let V=cache.get(R);if(V)return V;let U;try{U=fs.readFileSync(path.toNamespacedPath(R),`utf8`)}catch(l){let R=l;if(R.code!==`ENOENT`)throw R}let G={exists:!1,pjsonPath:R,main:void 0,name:void 0,type:`none`,exports:void 0,imports:void 0};if(U!==void 0){let l;try{l=JSON.parse(U)}catch(l){let V=new ERR_INVALID_PACKAGE_CONFIG(R,(z?`"${B}" from `:``)+fileURLToPath(z||B),l.message);throw V.cause=l,V}G.exists=!0,hasOwnProperty$1.call(l,`name`)&&typeof l.name==`string`&&(G.name=l.name),hasOwnProperty$1.call(l,`main`)&&typeof l.main==`string`&&(G.main=l.main),hasOwnProperty$1.call(l,`exports`)&&(G.exports=l.exports),hasOwnProperty$1.call(l,`imports`)&&(G.imports=l.imports),hasOwnProperty$1.call(l,`type`)&&(l.type===`commonjs`||l.type===`module`)&&(G.type=l.type)}return cache.set(R,G),G}function getPackageScopeConfig(l){let R=new URL(`package.json`,l);for(;!R.pathname.endsWith(`node_modules/package.json`);){let z=read(fileURLToPath(R),{specifier:l});if(z.exists)return z;let B=R;if(R=new URL(`../package.json`,R),R.pathname===B.pathname)break}return{pjsonPath:fileURLToPath(R),exists:!1,type:`none`}}const hasOwnProperty={}.hasOwnProperty,extensionFormatMap={__proto__:null,".json":`json`,".cjs":`commonjs`,".cts":`commonjs`,".js":`module`,".ts":`module`,".mts":`module`,".mjs":`module`},protocolHandlers={__proto__:null,"data:":getDataProtocolModuleFormat,"file:":getFileProtocolModuleFormat,"node:":()=>`builtin`};function mimeToFormat(l){return l&&/\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(l)?`module`:l===`application/json`?`json`:null}function getDataProtocolModuleFormat(l){let{1:R}=/^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(l.pathname)||[null,null,null];return mimeToFormat(R)}function extname(l){let R=l.pathname,z=R.length;for(;z--;){let l=R.codePointAt(z);if(l===47)return``;if(l===46)return R.codePointAt(z-1)===47?``:R.slice(z)}return``}function getFileProtocolModuleFormat(l,R,z){let B=extname(l);if(B===`.js`){let{type:R}=getPackageScopeConfig(l);return R===`none`?`commonjs`:R}if(B===``){let{type:R}=getPackageScopeConfig(l);return R===`none`||R===`commonjs`?`commonjs`:`module`}let V=extensionFormatMap[B];if(V)return V;if(!z)throw new ERR_UNKNOWN_FILE_EXTENSION(B,fileURLToPath(l))}function defaultGetFormatWithoutErrors(l,R){let z=l.protocol;return hasOwnProperty.call(protocolHandlers,z)&&protocolHandlers[z](l,R,!0)||null}const RegExpPrototypeSymbolReplace=RegExp.prototype[Symbol.replace],own={}.hasOwnProperty,invalidSegmentRegEx=/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i,deprecatedInvalidSegmentRegEx=/(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i,invalidPackageNameRegEx=/^\.|%|\\/,patternRegEx=/\*/g,encodedSeparatorRegEx=/%2f|%5c/i,emittedPackageWarnings=new Set,doubleSlashRegEx=/[/\\]{2}/;function emitInvalidSegmentDeprecation(l,R,z,B,V,U,W){if(process$1.noDeprecation)return;let G=fileURLToPath(B),K=doubleSlashRegEx.exec(W?l:R)!==null;process$1.emitWarning(`Use of deprecated ${K?`double slash`:`leading or trailing slash matching`} resolving "${l}" for module request "${R}" ${R===z?``:`matched to "${z}" `}in the "${V?`imports`:`exports`}" field module resolution of the package at ${G}${U?` imported from ${fileURLToPath(U)}`:``}.`,`DeprecationWarning`,`DEP0166`)}function emitLegacyIndexDeprecation(l,R,z,B){if(process$1.noDeprecation||defaultGetFormatWithoutErrors(l,{parentURL:z.href})!==`module`)return;let U=fileURLToPath(l.href),G=fileURLToPath(new URL$1(`.`,R)),K=fileURLToPath(z);B?path.resolve(G,B)!==U&&process$1.emitWarning(`Package ${G} has a "main" field set to "${B}", excluding the full filename and extension to the resolved file at "${U.slice(G.length)}", imported from ${K}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`,`DeprecationWarning`,`DEP0151`):process$1.emitWarning(`No "main" or "exports" field defined in the package.json for ${G} resolving the main entry point "${U.slice(G.length)}", imported from ${K}.\nDefault "index" lookups for the main are deprecated for ES modules.`,`DeprecationWarning`,`DEP0151`)}function tryStatSync(l){try{return statSync(l)}catch{}}function fileExists(l){let R=statSync(l,{throwIfNoEntry:!1});return(R?R.isFile():void 0)??!1}function legacyMainResolve(l,R,z){let B;if(R.main!==void 0){if(B=new URL$1(R.main,l),fileExists(B))return B;let H=[`./${R.main}.js`,`./${R.main}.json`,`./${R.main}.node`,`./${R.main}/index.js`,`./${R.main}/index.json`,`./${R.main}/index.node`],U=-1;for(;++U<H.length&&(B=new URL$1(H[U],l),!fileExists(B));)B=void 0;if(B)return emitLegacyIndexDeprecation(B,l,z,R.main),B}let U=[`./index.js`,`./index.json`,`./index.node`],W=-1;for(;++W<U.length&&(B=new URL$1(U[W],l),!fileExists(B));)B=void 0;if(B)return emitLegacyIndexDeprecation(B,l,z,R.main),B;throw new ERR_MODULE_NOT_FOUND(fileURLToPath(new URL$1(`.`,l)),fileURLToPath(z))}function finalizeResolution(l,R,B){if(encodedSeparatorRegEx.exec(l.pathname)!==null)throw new ERR_INVALID_MODULE_SPECIFIER(l.pathname,String.raw`must not include encoded "/" or "\" characters`,fileURLToPath(R));let V;try{V=fileURLToPath(l)}catch(z){throw Object.defineProperty(z,`input`,{value:String(l)}),Object.defineProperty(z,`module`,{value:String(R)}),z}let G=tryStatSync(V.endsWith(`/`)?V.slice(-1):V);if(G&&G.isDirectory()){let z=new ERR_UNSUPPORTED_DIR_IMPORT(V,fileURLToPath(R));throw z.url=String(l),z}if(!G||!G.isFile()){let z=new ERR_MODULE_NOT_FOUND(V||l.pathname,R&&fileURLToPath(R),!0);throw z.url=String(l),z}if(!B){let R=realpathSync(V),{search:B,hash:H}=l;l=pathToFileURL(R+(V.endsWith(path.sep)?`/`:``)),l.search=B,l.hash=H}return l}function importNotDefined(l,R,z){return new ERR_PACKAGE_IMPORT_NOT_DEFINED(l,R&&fileURLToPath(new URL$1(`.`,R)),fileURLToPath(z))}function exportsNotFound(l,R,z){return new ERR_PACKAGE_PATH_NOT_EXPORTED(fileURLToPath(new URL$1(`.`,R)),l,z&&fileURLToPath(z))}function throwInvalidSubpath(l,R,z,B,V){throw new ERR_INVALID_MODULE_SPECIFIER(l,`request is not a valid match in pattern "${R}" for the "${B?`imports`:`exports`}" resolution of ${fileURLToPath(z)}`,V&&fileURLToPath(V))}function invalidPackageTarget(l,R,z,B,U){return R=typeof R==`object`&&R?JSON.stringify(R,null,``):`${R}`,new ERR_INVALID_PACKAGE_TARGET(fileURLToPath(new URL$1(`.`,z)),l,R,B,U&&fileURLToPath(U))}function resolvePackageTargetString(l,R,z,B,H,U,W,G,K){if(R!==``&&!U&&l.at(-1)!==`/`)throw invalidPackageTarget(z,l,B,W,H);if(!l.startsWith(`./`)){if(W&&!l.startsWith(`../`)&&!l.startsWith(`/`)){let z=!1;try{new URL$1(l),z=!0}catch{}if(!z)return packageResolve(U?RegExpPrototypeSymbolReplace.call(patternRegEx,l,()=>R):l+R,B,K)}throw invalidPackageTarget(z,l,B,W,H)}if(invalidSegmentRegEx.exec(l.slice(2))!==null)if(deprecatedInvalidSegmentRegEx.exec(l.slice(2))===null){if(!G){let V=U?z.replace(`*`,()=>R):z+R;emitInvalidSegmentDeprecation(U?RegExpPrototypeSymbolReplace.call(patternRegEx,l,()=>R):l,V,z,B,W,H,!0)}}else throw invalidPackageTarget(z,l,B,W,H);let q=new URL$1(l,B),J=q.pathname,Y=new URL$1(`.`,B).pathname;if(!J.startsWith(Y))throw invalidPackageTarget(z,l,B,W,H);if(R===``)return q;if(invalidSegmentRegEx.exec(R)!==null){let V=U?z.replace(`*`,()=>R):z+R;deprecatedInvalidSegmentRegEx.exec(R)===null?G||emitInvalidSegmentDeprecation(U?RegExpPrototypeSymbolReplace.call(patternRegEx,l,()=>R):l,V,z,B,W,H,!1):throwInvalidSubpath(V,z,B,W,H)}return U?new URL$1(RegExpPrototypeSymbolReplace.call(patternRegEx,q.href,()=>R)):new URL$1(R,q)}function isArrayIndex(l){let R=Number(l);return`${R}`===l?R>=0&&R<4294967295:!1}function resolvePackageTarget(l,R,z,B,V,U,W,G,K){if(typeof R==`string`)return resolvePackageTargetString(R,z,B,l,V,U,W,G,K);if(Array.isArray(R)){let H=R;if(H.length===0)return null;let q,J=-1;for(;++J<H.length;){let R=H[J],Y;try{Y=resolvePackageTarget(l,R,z,B,V,U,W,G,K)}catch(l){let R=l;if(q=R,R.code===`ERR_INVALID_PACKAGE_TARGET`)continue;throw l}if(Y!==void 0){if(Y===null){q=null;continue}return Y}}if(q==null)return null;throw q}if(typeof R==`object`&&R){let q=Object.getOwnPropertyNames(R),J=-1;for(;++J<q.length;){let R=q[J];if(isArrayIndex(R))throw new ERR_INVALID_PACKAGE_CONFIG(fileURLToPath(l),fileURLToPath(V),`"exports" cannot contain numeric property keys.`)}for(J=-1;++J<q.length;){let H=q[J];if(H===`default`||K&&K.has(H)){let q=R[H],J=resolvePackageTarget(l,q,z,B,V,U,W,G,K);if(J===void 0)continue;return J}}return null}if(R===null)return null;throw invalidPackageTarget(B,R,l,W,V)}function isConditionalExportsMainSugar(l,R,z){if(typeof l==`string`||Array.isArray(l))return!0;if(typeof l!=`object`||!l)return!1;let B=Object.getOwnPropertyNames(l),V=!1,U=0,W=-1;for(;++W<B.length;){let l=B[W],G=l===``||l[0]!==`.`;if(U++===0)V=G;else if(V!==G)throw new ERR_INVALID_PACKAGE_CONFIG(fileURLToPath(R),fileURLToPath(z),`"exports" cannot contain some keys starting with '.' and some not. The exports object must either be an object of package subpath keys or an object of main entry condition name keys only.`)}return V}function emitTrailingSlashPatternDeprecation(l,R,z){if(process$1.noDeprecation)return;let B=fileURLToPath(R);emittedPackageWarnings.has(B+`|`+l)||(emittedPackageWarnings.add(B+`|`+l),process$1.emitWarning(`Use of deprecated trailing slash pattern mapping "${l}" in the "exports" field module resolution of the package at ${B}${z?` imported from ${fileURLToPath(z)}`:``}. Mapping specifiers ending in "/" is no longer supported.`,`DeprecationWarning`,`DEP0155`))}function packageExportsResolve(l,R,z,B,V){let H=z.exports;if(isConditionalExportsMainSugar(H,l,B)&&(H={".":H}),own.call(H,R)&&!R.includes(`*`)&&!R.endsWith(`/`)){let z=H[R],U=resolvePackageTarget(l,z,``,R,B,!1,!1,!1,V);if(U==null)throw exportsNotFound(R,l,B);return U}let U=``,W=``,G=Object.getOwnPropertyNames(H),K=-1;for(;++K<G.length;){let z=G[K],V=z.indexOf(`*`);if(V!==-1&&R.startsWith(z.slice(0,V))){R.endsWith(`/`)&&emitTrailingSlashPatternDeprecation(R,l,B);let H=z.slice(V+1);R.length>=z.length&&R.endsWith(H)&&patternKeyCompare(U,z)===1&&z.lastIndexOf(`*`)===V&&(U=z,W=R.slice(V,R.length-H.length))}}if(U){let z=H[U],G=resolvePackageTarget(l,z,W,U,B,!0,!1,R.endsWith(`/`),V);if(G==null)throw exportsNotFound(R,l,B);return G}throw exportsNotFound(R,l,B)}function patternKeyCompare(l,R){let z=l.indexOf(`*`),B=R.indexOf(`*`),V=z===-1?l.length:z+1,H=B===-1?R.length:B+1;return V>H?-1:H>V||z===-1?1:B===-1||l.length>R.length?-1:R.length>l.length?1:0}function packageImportsResolve(l,R,z){if(l===`#`||l.startsWith(`#/`)||l.endsWith(`/`))throw new ERR_INVALID_MODULE_SPECIFIER(l,`is not a valid internal imports specifier name`,fileURLToPath(R));let B,V=getPackageScopeConfig(R);if(V.exists){B=pathToFileURL(V.pjsonPath);let H=V.imports;if(H)if(own.call(H,l)&&!l.includes(`*`)){let V=resolvePackageTarget(B,H[l],``,l,R,!1,!0,!1,z);if(V!=null)return V}else{let V=``,U=``,W=Object.getOwnPropertyNames(H),G=-1;for(;++G<W.length;){let R=W[G],z=R.indexOf(`*`);if(z!==-1&&l.startsWith(R.slice(0,-1))){let B=R.slice(z+1);l.length>=R.length&&l.endsWith(B)&&patternKeyCompare(V,R)===1&&R.lastIndexOf(`*`)===z&&(V=R,U=l.slice(z,l.length-B.length))}}if(V){let l=H[V],W=resolvePackageTarget(B,l,U,V,R,!0,!0,!1,z);if(W!=null)return W}}}throw importNotDefined(l,B,R)}function parsePackageName(l,R){let z=l.indexOf(`/`),B=!0,V=!1;l[0]===`@`&&(V=!0,z===-1||l.length===0?B=!1:z=l.indexOf(`/`,z+1));let U=z===-1?l:l.slice(0,z);if(invalidPackageNameRegEx.exec(U)!==null&&(B=!1),!B)throw new ERR_INVALID_MODULE_SPECIFIER(l,`is not a valid package name`,fileURLToPath(R));return{packageName:U,packageSubpath:`.`+(z===-1?``:l.slice(z)),isScoped:V}}function packageResolve(l,R,z){if(nodeBuiltins.includes(l))return new URL$1(`node:`+l);let{packageName:B,packageSubpath:W,isScoped:G}=parsePackageName(l,R),K=getPackageScopeConfig(R);if(K.exists&&K.name===B&&K.exports!==void 0&&K.exports!==null)return packageExportsResolve(pathToFileURL(K.pjsonPath),W,K,R,z);let q=new URL$1(`./node_modules/`+B+`/package.json`,R),J=fileURLToPath(q),Y;do{let U=tryStatSync(J.slice(0,-13));if(!U||!U.isDirectory()){Y=J,q=new URL$1((G?`../../../../node_modules/`:`../../../node_modules/`)+B+`/package.json`,q),J=fileURLToPath(q);continue}let K=read(J,{base:R,specifier:l});return K.exports!==void 0&&K.exports!==null?packageExportsResolve(q,W,K,R,z):W===`.`?legacyMainResolve(q,K,R):new URL$1(W,q)}while(J.length!==Y.length);throw new ERR_MODULE_NOT_FOUND(B,fileURLToPath(R),!1)}function isRelativeSpecifier(l){return l[0]===`.`&&(l.length===1||l[1]===`/`||l[1]===`.`&&(l.length===2||l[2]===`/`))}function shouldBeTreatedAsRelativeOrAbsolutePath(l){return l===``?!1:l[0]===`/`?!0:isRelativeSpecifier(l)}function moduleResolve(l,R,z,B){let H=R.protocol,U=H===`data:`,W;if(shouldBeTreatedAsRelativeOrAbsolutePath(l))try{W=new URL$1(l,R)}catch(z){let B=new ERR_UNSUPPORTED_RESOLVE_REQUEST(l,R);throw B.cause=z,B}else if(H===`file:`&&l[0]===`#`)W=packageImportsResolve(l,R,z);else try{W=new URL$1(l)}catch(B){if(U&&!nodeBuiltins.includes(l)){let z=new ERR_UNSUPPORTED_RESOLVE_REQUEST(l,R);throw z.cause=B,z}W=packageResolve(l,R,z)}return assert.ok(W!==void 0,`expected to be defined`),W.protocol===`file:`?finalizeResolution(W,R,B):W}const DEFAULT_CONDITIONS_SET=new Set([`node`,`import`]),isWindows=(()=>process.platform===`win32`)(),globalCache=(()=>globalThis.__EXSOLVE_CACHE__||=new Map)();function resolveModuleURL(l,B){let V=_parseInput(l);if(`external`in V)return V.external;let H=V.specifier,W=V.url,G=V.absolutePath,K,q;if(B?.cache!==!1&&(K=_cacheKey(G||H,B),q=B?.cache&&typeof B?.cache==`object`?B.cache:globalCache),q){let l=q.get(K);if(typeof l==`string`)return l;if(l instanceof Error){if(B?.try)return;throw l}}if(G)try{let l=lstatSync(G);if(l.isSymbolicLink()&&(G=realpathSync(G),W=pathToFileURL(G)),l.isFile())return q&&q.set(K,W.href),W.href}catch(l){if(l?.code!==`ENOENT`)throw q&&q.set(K,l),l}let J=B?.conditions?new Set(B.conditions):DEFAULT_CONDITIONS_SET,Y=H||W.href,X=_normalizeBases(B?.from),Z=B?.suffixes||[``],Q=B?.extensions?[``,...B.extensions]:[``],$;for(let l of X){for(let R of Z){let z=_join(Y,R);z===`.`&&(z+=`/.`);for(let R of Q)if($=_tryModuleResolve(z+R,l,J),$)break;if($)break}if($)break}if(!$){let R=Error(`Cannot resolve module "${l}" (from: ${X.map(l=>_fmtPath(l)).join(`, `)})`);if(R.code=`ERR_MODULE_NOT_FOUND`,q&&q.set(K,R),B?.try)return;throw R}return q&&q.set(K,$.href),$.href}function resolveModulePath(l,R){let z=resolveModuleURL(l,R);if(!z||!z.startsWith(`file://`)&&R?.try)return;let B=fileURLToPath(z);return isWindows?_normalizeWinPath(B):B}function _tryModuleResolve(l,R,z){try{return moduleResolve(l,R,z)}catch{}}function _normalizeBases(l){let R=(Array.isArray(l)?l:[l]).flatMap(l=>_normalizeBase(l));return R.length===0?[pathToFileURL(`./`)]:R}function _normalizeBase(l){if(!l)return[];if(_isURL(l))return[l];if(typeof l!=`string`)return[];if(/^(?:node|data|http|https|file):/.test(l))return new URL(l);try{return l.endsWith(`/`)||statSync(l).isDirectory()?pathToFileURL(l+`/`):pathToFileURL(l)}catch{return[pathToFileURL(l+`/`),pathToFileURL(l)]}}function _fmtPath(l){try{return fileURLToPath(l)}catch{return l}}function _cacheKey(l,R){return JSON.stringify([l,(R?.conditions||[`node`,`import`]).sort(),R?.extensions,R?.from,R?.suffixes])}function _join(l,R){return!l||!R||R===`/`?l:(l.endsWith(`/`)?l:l+`/`)+(R.startsWith(`/`)?R.slice(1):R)}function _normalizeWinPath(l){return l.replace(/\\/g,`/`).replace(/^[a-z]:\//,l=>l.toUpperCase())}function _isURL(l){return l instanceof URL||l?.constructor?.name===`URL`}function _parseInput(l){if(typeof l==`string`){if(l.startsWith(`file:`)){let R=new URL(l);return{url:R,absolutePath:fileURLToPath(R)}}return isAbsolute(l)?{url:pathToFileURL(l),absolutePath:l}:/^(?:node|data|http|https):/.test(l)?{external:l}:nodeBuiltins.includes(l)&&!l.includes(`:`)?{external:`node:${l}`}:{specifier:l}}if(_isURL(l))return l.protocol===`file:`?{url:l,absolutePath:fileURLToPath(l)}:{external:l.href};throw TypeError("id must be a `string` or `URL`")}export{resolveModulePath as t};
@@ -0,0 +1 @@
1
+ const _DRIVE_LETTER_START_RE=/^[A-Za-z]:\//;function normalizeWindowsPath(s=``){return s&&s.replace(/\\/g,`/`).replace(_DRIVE_LETTER_START_RE,e=>e.toUpperCase())}const _UNC_REGEX=/^[/\\]{2}/,_IS_ABSOLUTE_RE=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/,_DRIVE_LETTER_RE=/^[A-Za-z]:$/,_ROOT_FOLDER_RE=/^\/([A-Za-z]:)?$/,normalize=function(e){if(e.length===0)return`.`;e=normalizeWindowsPath(e);let l=e.match(_UNC_REGEX),d=isAbsolute(e),f=e[e.length-1]===`/`;return e=normalizeString(e,!d),e.length===0?d?`/`:f?`./`:`.`:(f&&(e+=`/`),_DRIVE_LETTER_RE.test(e)&&(e+=`/`),l?d?`//${e}`:`//./${e}`:d&&!isAbsolute(e)?`/${e}`:e)},join=function(...e){let s=``;for(let c of e)if(c)if(s.length>0){let e=s[s.length-1]===`/`,l=c[0]===`/`;e&&l?s+=c.slice(1):s+=e||l?c:`/${c}`}else s+=c;return normalize(s)};function cwd(){return typeof process<`u`&&typeof process.cwd==`function`?process.cwd().replace(/\\/g,`/`):`/`}const resolve=function(...e){e=e.map(e=>normalizeWindowsPath(e));let c=``,l=!1;for(let s=e.length-1;s>=-1&&!l;s--){let u=s>=0?e[s]:cwd();!u||u.length===0||(c=`${u}/${c}`,l=isAbsolute(u))}return c=normalizeString(c,!l),l&&!isAbsolute(c)?`/${c}`:c.length>0?c:`.`};function normalizeString(e,s){let c=``,l=0,u=-1,d=0,f=null;for(let p=0;p<=e.length;++p){if(p<e.length)f=e[p];else if(f===`/`)break;else f=`/`;if(f===`/`){if(!(u===p-1||d===1))if(d===2){if(c.length<2||l!==2||c[c.length-1]!==`.`||c[c.length-2]!==`.`){if(c.length>2){let e=c.lastIndexOf(`/`);e===-1?(c=``,l=0):(c=c.slice(0,e),l=c.length-1-c.lastIndexOf(`/`)),u=p,d=0;continue}else if(c.length>0){c=``,l=0,u=p,d=0;continue}}s&&(c+=c.length>0?`/..`:`..`,l=2)}else c.length>0?c+=`/${e.slice(u+1,p)}`:c=e.slice(u+1,p),l=p-u-1;u=p,d=0}else f===`.`&&d!==-1?++d:d=-1}return c}const isAbsolute=function(e){return _IS_ABSOLUTE_RE.test(e)},relative=function(e,s){let c=resolve(e).replace(_ROOT_FOLDER_RE,`$1`).split(`/`),l=resolve(s).replace(_ROOT_FOLDER_RE,`$1`).split(`/`);if(l[0][1]===`:`&&c[0][1]===`:`&&c[0]!==l[0])return l.join(`/`);let u=[...c];for(let e of u){if(l[0]!==e)break;c.shift(),l.shift()}return[...c.map(()=>`..`),...l].join(`/`)},dirname=function(e){let c=normalizeWindowsPath(e).replace(/\/$/,``).split(`/`).slice(0,-1);return c.length===1&&_DRIVE_LETTER_RE.test(c[0])&&(c[0]+=`/`),c.join(`/`)||(isAbsolute(e)?`/`:`.`)};export{relative as a,normalize as i,isAbsolute as n,resolve as o,join as r,dirname as t};
@@ -0,0 +1 @@
1
+ import{i as normalize,n as isAbsolute,o as resolve,r as join}from"./pathe.mjs";import{n as x,r as z,t as h}from"./confbox.mjs";import{t as resolveModulePath}from"./exsolve.mjs";import{promises,statSync}from"node:fs";import{fileURLToPath}from"node:url";import"node:fs/promises";const defaultFindOptions={startingFrom:`.`,rootPattern:/^node_modules$/,reverse:!1,test:e=>{try{if(statSync(e).isFile())return!0}catch{}}};async function findFile(e,u={}){let p=Array.isArray(e)?e:[e],m={...defaultFindOptions,...u},g=resolve(m.startingFrom),_=g[0]===`/`,v=g.split(`/`).filter(Boolean);if(p.includes(v.at(-1))&&await m.test(g))return g;_&&(v[0]=`/`+v[0]);let y=v.findIndex(e=>e.match(m.rootPattern));if(y===-1&&(y=0),m.reverse)for(let e=y+1;e<=v.length;e++)for(let u of p){let d=join(...v.slice(0,e),u);if(await m.test(d))return d}else for(let e=v.length;e>y;e--)for(let u of p){let d=join(...v.slice(0,e),u);if(await m.test(d))return d}throw Error(`Cannot find matching ${e} in ${m.startingFrom} or parent directories`)}function findNearestFile(e,u={}){return findFile(e,u)}function _resolvePath(d,f={}){return d instanceof URL||d.startsWith(`file://`)?normalize(fileURLToPath(d)):isAbsolute(d)?normalize(d):resolveModulePath(d,{...f,from:f.from||f.parent||f.url})}const FileCache=new Map;async function readPackageJSON(e,u={}){let d=await resolvePackageJSON(e,u),f=u.cache&&typeof u.cache!=`boolean`?u.cache:FileCache;if(u.cache&&f.has(d))return f.get(d);let m=await promises.readFile(d,`utf8`),_;try{_=x(m)}catch{_=h(m)}return f.set(d,_),_}async function writePackageJSON(e,u){await promises.writeFile(e,z(u))}async function resolvePackageJSON(e=process.cwd(),u={}){return findNearestFile(`package.json`,{...u,startingFrom:_resolvePath(e,u)})}export{writePackageJSON as n,readPackageJSON as t};
@@ -0,0 +1,253 @@
1
+ import { a as relative, o as resolve, r as join$1, t as dirname } from "./libs/pathe.mjs";
2
+ import { n as writePackageJSON, t as readPackageJSON } from "./libs/pkg-types.mjs";
3
+ import { createRequire } from "node:module";
4
+ import { promises } from "node:fs";
5
+ import { nodeFileTrace } from "@vercel/nft";
6
+ import { isAbsolute } from "node:path";
7
+ import semver from "semver";
8
+ import { join } from "node:path/posix";
9
+
10
+ //#region src/_utils.ts
11
+ const isWindows = process.platform === "win32";
12
+ const NODE_MODULES_RE = /^(?<dir>.+\/node_modules\/)(?<name>[^/@]+|@[^/]+\/[^/]+)(?:\/(?<subpath>.+))?$/;
13
+ function parseNodeModulePath(path$1) {
14
+ return NODE_MODULES_RE.exec(path$1)?.groups || {};
15
+ }
16
+ const IMPORT_RE = /^(?!\.)(?<name>[^/@]+|@[^/]+\/[^/]+)(?:\/(?<subpath>.+))?$/;
17
+ function toImport(id) {
18
+ if (isAbsolute(id)) {
19
+ const { name, subpath } = parseNodeModulePath(id) || {};
20
+ if (name && subpath) return join(name, subpath);
21
+ } else if (IMPORT_RE.test(id)) return id;
22
+ }
23
+ function guessSubpath(path$1, conditions) {
24
+ const { dir, name, subpath } = NODE_MODULES_RE.exec(path$1)?.groups || {};
25
+ if (!dir || !name || !subpath) return;
26
+ const exports = getPkgJSON(join(dir, name) + "/")?.exports;
27
+ if (!exports || typeof exports !== "object") return;
28
+ for (const e of flattenExports(exports)) {
29
+ if (!conditions.includes(e.condition || "default")) continue;
30
+ if (e.fsPath === subpath) return join(name, e.subpath);
31
+ if (e.fsPath.includes("*")) {
32
+ const fsPathRe = /* @__PURE__ */ new RegExp("^" + escapeRegExp(e.fsPath).replace(String.raw`\*`, "(.+?)") + "$");
33
+ if (fsPathRe.test(subpath)) {
34
+ const matched = fsPathRe.exec(subpath)?.[1];
35
+ if (matched) return join(name, e.subpath.replace("*", matched));
36
+ }
37
+ }
38
+ }
39
+ }
40
+ function getPkgJSON(dir) {
41
+ const cache = getPkgJSON._cache ||= /* @__PURE__ */ new Map();
42
+ if (cache.has(dir)) return cache.get(dir);
43
+ try {
44
+ const pkg = createRequire(dir)("./package.json");
45
+ cache.set(dir, pkg);
46
+ return pkg;
47
+ } catch {}
48
+ }
49
+ function flattenExports(exports = {}, parentSubpath = "./") {
50
+ return Object.entries(exports).flatMap(([key, value]) => {
51
+ const [subpath, condition] = key.startsWith(".") ? [key.slice(1)] : [void 0, key];
52
+ const _subPath = join(parentSubpath, subpath || "");
53
+ if (typeof value === "string") return [{
54
+ subpath: _subPath,
55
+ fsPath: value.replace(/^\.\//, ""),
56
+ condition
57
+ }];
58
+ return typeof value === "object" ? flattenExports(value, _subPath) : [];
59
+ });
60
+ }
61
+ function escapeRegExp(string) {
62
+ return string.replace(/[-\\^$*+?.()|[\]{}]/g, String.raw`\$&`);
63
+ }
64
+ function pathRegExp(string) {
65
+ if (isWindows) string = string.replace(/\\/g, "/");
66
+ let escaped = escapeRegExp(string);
67
+ if (isWindows) escaped = escaped.replace(/\//g, String.raw`[/\\]`);
68
+ return escaped;
69
+ }
70
+ function toPathRegExp(input) {
71
+ if (input instanceof RegExp) return input;
72
+ if (typeof input === "string") return new RegExp(pathRegExp(input));
73
+ throw new TypeError("Expected a string or RegExp", { cause: input });
74
+ }
75
+
76
+ //#endregion
77
+ //#region src/trace.ts
78
+ const DEFAULT_CONDITIONS = [
79
+ "node",
80
+ "import",
81
+ "default"
82
+ ];
83
+ async function traceNodeModules(input, opts) {
84
+ const rootDir = resolve(opts.rootDir || ".");
85
+ await opts?.hooks?.traceStart?.(input);
86
+ const traceResult = await nodeFileTrace([...input], {
87
+ base: "/",
88
+ exportsOnly: true,
89
+ processCwd: rootDir,
90
+ conditions: (opts.conditions || DEFAULT_CONDITIONS).filter((c) => ![
91
+ "require",
92
+ "import",
93
+ "default"
94
+ ].includes(c)),
95
+ ...opts.nft
96
+ });
97
+ await opts?.hooks?.traceResult?.(traceResult);
98
+ const _resolveTracedPath = (p) => promises.realpath(resolve(opts.nft?.base || "/", p));
99
+ const tracedFiles = Object.fromEntries(await Promise.all([...traceResult.reasons.entries()].map(async ([_path, reasons]) => {
100
+ if (reasons.ignored) return;
101
+ const path$1 = await _resolveTracedPath(_path);
102
+ if (!path$1.includes("node_modules")) return;
103
+ if (!await isFile(path$1)) return;
104
+ const { dir: baseDir, name: pkgName, subpath } = parseNodeModulePath(path$1);
105
+ if (!baseDir || !pkgName) return;
106
+ const pkgPath = join$1(baseDir, pkgName);
107
+ return [path$1, {
108
+ path: path$1,
109
+ parents: await Promise.all([...reasons.parents].map((p) => _resolveTracedPath(p))),
110
+ subpath,
111
+ pkgName,
112
+ pkgPath
113
+ }];
114
+ })).then((r) => r.filter(Boolean)));
115
+ await opts?.hooks?.tracedFiles?.(tracedFiles);
116
+ const tracedPackages = {};
117
+ for (const tracedFile of Object.values(tracedFiles)) {
118
+ const pkgName = tracedFile.pkgName;
119
+ let tracedPackage = tracedPackages[pkgName];
120
+ let pkgJSON = await readPackageJSON(tracedFile.pkgPath, { cache: true }).catch(() => {});
121
+ if (!pkgJSON) pkgJSON = {
122
+ name: pkgName,
123
+ version: "0.0.0"
124
+ };
125
+ if (!tracedPackage) {
126
+ tracedPackage = {
127
+ name: pkgName,
128
+ versions: {}
129
+ };
130
+ tracedPackages[pkgName] = tracedPackage;
131
+ }
132
+ let tracedPackageVersion = tracedPackage.versions[pkgJSON.version || "0.0.0"];
133
+ if (!tracedPackageVersion) {
134
+ tracedPackageVersion = {
135
+ path: tracedFile.pkgPath,
136
+ files: [],
137
+ pkgJSON
138
+ };
139
+ tracedPackage.versions[pkgJSON.version || "0.0.0"] = tracedPackageVersion;
140
+ }
141
+ tracedPackageVersion.files.push(tracedFile.path);
142
+ tracedFile.pkgName = pkgName;
143
+ if (pkgJSON.version) tracedFile.pkgVersion = pkgJSON.version;
144
+ }
145
+ await opts?.hooks?.tracedPackages?.(tracedPackages);
146
+ const usedAliases = {};
147
+ const outDir = resolve(rootDir, opts.outDir || "dist", "node_modules");
148
+ const writePackage = async (name, version, _pkgPath) => {
149
+ const pkg = tracedPackages[name];
150
+ const pkgPath = _pkgPath || pkg.name;
151
+ for (const src of pkg.versions[version].files) {
152
+ const { subpath } = parseNodeModulePath(src);
153
+ if (!subpath) continue;
154
+ const dst = resolve(outDir, pkgPath, subpath);
155
+ await promises.mkdir(dirname(dst), { recursive: true });
156
+ const transformers = (opts.transform || []).filter((t) => t?.filter?.(src) && t.handler);
157
+ if (transformers.length > 0) {
158
+ let content = await promises.readFile(src, "utf8");
159
+ for (const transformer of transformers) content = await transformer.handler(content, src) ?? content;
160
+ await promises.writeFile(dst, content, "utf8");
161
+ } else await promises.copyFile(src, dst);
162
+ if (opts.chmod) await promises.chmod(dst, opts.chmod === true ? 420 : opts.chmod);
163
+ }
164
+ const pkgJSON = pkg.versions[version].pkgJSON;
165
+ applyProductionCondition(pkgJSON.exports);
166
+ const pkgJSONPath = join$1(outDir, pkgPath, "package.json");
167
+ await promises.mkdir(dirname(pkgJSONPath), { recursive: true });
168
+ await promises.writeFile(pkgJSONPath, JSON.stringify(pkgJSON, null, 2), "utf8");
169
+ if (opts.traceAlias && opts.traceAlias[pkgPath]) {
170
+ usedAliases[opts.traceAlias[pkgPath]] = version;
171
+ await linkPackage(pkgPath, opts.traceAlias[pkgPath]);
172
+ }
173
+ };
174
+ const linkPackage = async (from, to) => {
175
+ const src = join$1(outDir, from);
176
+ const dst = join$1(outDir, to);
177
+ if ((await promises.lstat(dst).catch(() => null))?.isSymbolicLink()) return;
178
+ await promises.mkdir(dirname(dst), { recursive: true });
179
+ await promises.symlink(relative(dirname(dst), src), dst, isWindows ? "junction" : "dir").catch((error) => {
180
+ if (error.code !== "EEXIST") console.error("Cannot link", from, "to", to, error);
181
+ });
182
+ };
183
+ const findPackageParents = (pkg, version) => {
184
+ const versionFiles = pkg.versions[version].files.map((path$1) => tracedFiles[path$1]);
185
+ return [...new Set(versionFiles.flatMap((file) => file.parents.map((parentPath) => {
186
+ const parentFile = tracedFiles[parentPath];
187
+ if (!parentFile || parentFile.pkgName === pkg.name) return null;
188
+ return `${parentFile.pkgName}@${parentFile.pkgVersion}`;
189
+ }).filter(Boolean)))];
190
+ };
191
+ const multiVersionPkgs = {};
192
+ const singleVersionPackages = [];
193
+ for (const tracedPackage of Object.values(tracedPackages)) {
194
+ const versions = Object.keys(tracedPackage.versions);
195
+ if (versions.length === 1) {
196
+ singleVersionPackages.push(tracedPackage.name);
197
+ continue;
198
+ }
199
+ multiVersionPkgs[tracedPackage.name] = {};
200
+ for (const version of versions) multiVersionPkgs[tracedPackage.name][version] = findPackageParents(tracedPackage, version);
201
+ }
202
+ await Promise.all(singleVersionPackages.map((pkgName) => {
203
+ const pkg = tracedPackages[pkgName];
204
+ const version = Object.keys(pkg.versions)[0];
205
+ return writePackage(pkgName, version);
206
+ }));
207
+ for (const [pkgName, pkgVersions] of Object.entries(multiVersionPkgs)) {
208
+ const versionEntries = Object.entries(pkgVersions).sort(([v1, p1], [v2, p2]) => {
209
+ if (p1.length === 0) return -1;
210
+ if (p2.length === 0) return 1;
211
+ return compareVersions(v1, v2);
212
+ });
213
+ for (const [version, parentPkgs] of versionEntries) {
214
+ await writePackage(pkgName, version, `.nf3/${pkgName}@${version}`);
215
+ await linkPackage(`.nf3/${pkgName}@${version}`, `${pkgName}`);
216
+ for (const parentPkg of parentPkgs) {
217
+ const parentPkgName = parentPkg.replace(/@[^@]+$/, "");
218
+ await (multiVersionPkgs[parentPkgName] ? linkPackage(`.nf3/${pkgName}@${version}`, `.nf3/${parentPkg}/node_modules/${pkgName}`) : linkPackage(`.nf3/${pkgName}@${version}`, `${parentPkgName}/node_modules/${pkgName}`));
219
+ }
220
+ }
221
+ }
222
+ if (opts.writePackageJson) await writePackageJSON(resolve(outDir, "../package.json"), {
223
+ name: "traced-node-modules",
224
+ version: "1.0.0",
225
+ type: "module",
226
+ private: true,
227
+ dependencies: Object.fromEntries([...Object.values(tracedPackages).map((pkg) => [pkg.name, Object.keys(pkg.versions)[0]]), ...Object.entries(usedAliases)].sort(([a], [b]) => a.localeCompare(b)))
228
+ });
229
+ }
230
+ function compareVersions(v1 = "0.0.0", v2 = "0.0.0") {
231
+ try {
232
+ return semver.lt(v1, v2, { loose: true }) ? 1 : -1;
233
+ } catch {
234
+ return v1.localeCompare(v2);
235
+ }
236
+ }
237
+ function applyProductionCondition(exports) {
238
+ if (!exports || typeof exports === "string" || Array.isArray(exports)) return;
239
+ if ("production" in exports) if (typeof exports.production === "string") exports.default = exports.production;
240
+ else Object.assign(exports, exports.production);
241
+ for (const key in exports) applyProductionCondition(exports[key]);
242
+ }
243
+ async function isFile(file) {
244
+ try {
245
+ return (await promises.stat(file)).isFile();
246
+ } catch (error) {
247
+ if (error?.code === "ENOENT") return false;
248
+ throw error;
249
+ }
250
+ }
251
+
252
+ //#endregion
253
+ export { pathRegExp as a, guessSubpath as i, applyProductionCondition as n, toImport as o, traceNodeModules as r, toPathRegExp as s, DEFAULT_CONDITIONS as t };
@@ -0,0 +1,3 @@
1
+ import { n as applyProductionCondition, r as traceNodeModules, t as DEFAULT_CONDITIONS } from "./trace.mjs";
2
+
3
+ export { traceNodeModules };
@@ -0,0 +1,101 @@
1
+ import { NodeFileTraceOptions, NodeFileTraceResult } from "@vercel/nft";
2
+ import { PackageJson } from "pkg-types";
3
+
4
+ //#region src/types.d.ts
5
+ interface ExternalsPluginOptions {
6
+ /**
7
+ * The root directory to use when resolving files. Defaults to `process.cwd()`.
8
+ */
9
+ rootDir?: string;
10
+ /**
11
+ * Patterns to trace or externalize.
12
+ */
13
+ include?: (string | RegExp)[];
14
+ /**
15
+ * Patterns to exclude from tracing or externalizing (makes them to be bundled).
16
+ */
17
+ exclude?: (string | RegExp)[];
18
+ /**
19
+ *
20
+ * Tracing options.
21
+ *
22
+ * If `false`, disables automatic tracing of `node_modules` dependencies and keeps them as absolute external paths.
23
+ */
24
+ trace?: boolean | ExternalsTraceOptions;
25
+ /**
26
+ * Patterns to force trace even if not resolved.
27
+ */
28
+ traceInclude?: string[];
29
+ /**
30
+ * Resolve conditions to use when resolving packages. Defaults to `["node", "import", "default"]`
31
+ */
32
+ conditions?: string[];
33
+ }
34
+ interface ExternalsTraceOptions {
35
+ /**
36
+ * The root directory to use when resolving files. Defaults to `process.cwd()`.
37
+ */
38
+ rootDir?: string;
39
+ /**
40
+ * The output directory where traced files will be copied. Defaults to `dist`.
41
+ */
42
+ outDir?: string;
43
+ /**
44
+ * Options to pass to `@vercel/nft` for file tracing.
45
+ *
46
+ * @see https://github.com/vercel/nft#options
47
+ */
48
+ nft?: NodeFileTraceOptions;
49
+ /**
50
+ * Module resolution conditions to use when resolving packages.
51
+ *
52
+ * Defaults to `["node", "import", "default"]`
53
+ */
54
+ conditions?: string[];
55
+ /**
56
+ * Alias for module paths when tracing files.
57
+ */
58
+ traceAlias?: Record<string, string>;
59
+ /**
60
+ * Preserve file permissions when copying files. If set to `true`, original file permissions are preserved. If set to a number, that value is used as the permission mode (e.g., `0o755`).
61
+ */
62
+ chmod?: boolean | number;
63
+ /**
64
+ * If `true`, writes a `package.json` file to the output directory (parent) with the traced files as dependencies.
65
+ */
66
+ writePackageJson?: boolean;
67
+ /**
68
+ * Hook functions for allow extending tracing behavior.
69
+ */
70
+ hooks?: TraceHooks;
71
+ /** Transform traced files */
72
+ transform?: Transformer[];
73
+ }
74
+ type Transformer = {
75
+ filter: (id: string) => boolean;
76
+ handler: (code: string, id: string) => string | undefined | Promise<string | undefined>;
77
+ };
78
+ type TracedFile = {
79
+ path: string;
80
+ subpath: string;
81
+ parents: string[];
82
+ pkgPath: string;
83
+ pkgName: string;
84
+ pkgVersion: string;
85
+ };
86
+ type TracedPackage = {
87
+ name: string;
88
+ versions: Record<string, {
89
+ pkgJSON: PackageJson;
90
+ path: string;
91
+ files: string[];
92
+ }>;
93
+ };
94
+ interface TraceHooks {
95
+ traceStart?: (files: string[]) => void | Promise<void>;
96
+ traceResult?: (result: NodeFileTraceResult) => void | Promise<void>;
97
+ tracedFiles?: (files: Record<string, TracedFile>) => void | Promise<void>;
98
+ tracedPackages?: (packages: Record<string, TracedPackage>) => void | Promise<void>;
99
+ }
100
+ //#endregion
101
+ export { ExternalsTraceOptions as n, ExternalsPluginOptions as t };
package/dist/index.d.mts CHANGED
@@ -1,101 +1,7 @@
1
- import { NodeFileTraceOptions, NodeFileTraceResult } from "@vercel/nft";
2
- import { Plugin } from "rollup";
1
+ import { n as ExternalsTraceOptions } from "./_chunks/types.mjs";
3
2
  import { PackageJson } from "pkg-types";
4
3
 
5
- //#region src/types.d.ts
6
- interface ExternalsTraceOptions {
7
- /**
8
- * The root directory to use when resolving files. Defaults to `process.cwd()`.
9
- */
10
- rootDir?: string;
11
- /**
12
- * The output directory where traced files will be copied. Defaults to `dist`.
13
- */
14
- outDir?: string;
15
- /**
16
- * Options to pass to `@vercel/nft` for file tracing.
17
- *
18
- * @see https://github.com/vercel/nft#options
19
- */
20
- traceOptions?: NodeFileTraceOptions;
21
- /**
22
- * Module resolution conditions to use when resolving packages.
23
- *
24
- * Defaults to `["node", "import", "default"]`
25
- */
26
- exportConditions?: string[];
27
- /**
28
- * Alias for module paths when tracing files.
29
- */
30
- traceAlias?: Record<string, string>;
31
- /**
32
- * Preserve file permissions when copying files. If set to `true`, original file permissions are preserved. If set to a number, that value is used as the permission mode (e.g., `0o755`).
33
- */
34
- chmod?: boolean | number;
35
- /**
36
- * If `true`, writes a `package.json` file to the output directory (parent) with the traced files as dependencies.
37
- */
38
- writePackageJson?: boolean;
39
- /**
40
- * Hook functions for allow extending tracing behavior.
41
- */
42
- hooks?: TraceHooks;
43
- /** Transform traced files */
44
- transform?: Transformer[];
45
- }
46
- type Transformer = {
47
- filter: (id: string) => boolean;
48
- handler: (code: string, id: string) => string | undefined | Promise<string | undefined>;
49
- };
50
- interface ExternalsPluginOptions extends ExternalsTraceOptions {
51
- /**
52
- * If `true`, disables automatic tracing of `node_modules` dependencies and keeps them as absolute external paths.
53
- */
54
- noTrace?: boolean;
55
- /**
56
- * Patterns to always include (inline) instead of tracing them as externals.
57
- */
58
- inline?: Array<string | RegExp | ((id: string, importer?: string) => Promise<boolean> | boolean)>;
59
- /**
60
- * Patterns to always exclude (trace) instead of inlining them as externals.
61
- */
62
- external?: Array<string | RegExp | ((id: string, importer?: string) => Promise<boolean> | boolean)>;
63
- /**
64
- * `node_modules` directories to use when resolving packages. Defaults to `['node_modules']`.
65
- */
66
- moduleDirectories?: string[];
67
- /**
68
- * Patterns to always include (trace) even if not resolved.
69
- */
70
- traceInclude?: string[];
71
- }
72
- type TracedFile = {
73
- path: string;
74
- subpath: string;
75
- parents: string[];
76
- pkgPath: string;
77
- pkgName: string;
78
- pkgVersion: string;
79
- };
80
- type TracedPackage = {
81
- name: string;
82
- versions: Record<string, {
83
- pkgJSON: PackageJson;
84
- path: string;
85
- files: string[];
86
- }>;
87
- };
88
- interface TraceHooks {
89
- traceStart?: (files: string[]) => void | Promise<void>;
90
- traceResult?: (result: NodeFileTraceResult) => void | Promise<void>;
91
- tracedFiles?: (files: Record<string, TracedFile>) => void | Promise<void>;
92
- tracedPackages?: (packages: Record<string, TracedPackage>) => void | Promise<void>;
93
- }
94
- //#endregion
95
- //#region src/plugin.d.ts
96
- declare function rollupNodeFileTrace(opts?: ExternalsPluginOptions): Plugin;
97
- //#endregion
98
4
  //#region src/trace.d.ts
99
5
  declare function traceNodeModules(input: string[], opts: ExternalsTraceOptions): Promise<void>;
100
6
  //#endregion
101
- export { type ExternalsPluginOptions, type ExternalsTraceOptions, rollupNodeFileTrace, traceNodeModules };
7
+ export { type ExternalsTraceOptions, traceNodeModules };