nf3 0.3.11 → 0.3.13
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 +20 -1
- package/dist/_chunks/libs/exsolve.mjs +196 -196
- package/dist/_chunks/trace.mjs +44 -19
- package/dist/_chunks/types.d.mts +18 -0
- package/dist/node_modules/.nf3/minipass@7.1.2/dist/commonjs/index.js +1 -0
- package/dist/node_modules/.nf3/minipass@7.1.2/dist/commonjs/package.json +3 -0
- package/dist/node_modules/.nf3/minipass@7.1.2/package.json +19 -0
- package/dist/node_modules/.nf3/minipass@7.1.3/dist/commonjs/index.js +1 -0
- package/dist/node_modules/.nf3/minipass@7.1.3/dist/commonjs/package.json +3 -0
- package/dist/node_modules/.nf3/minipass@7.1.3/package.json +19 -0
- package/dist/node_modules/@isaacs/fs-minipass/dist/commonjs/index.js +1 -0
- package/dist/node_modules/@isaacs/fs-minipass/dist/commonjs/package.json +3 -0
- package/dist/node_modules/@isaacs/fs-minipass/package.json +19 -0
- package/dist/node_modules/@vercel/nft/out/analyze.js +1 -1
- package/dist/node_modules/@vercel/nft/package.json +1 -1
- package/dist/plugin.mjs +7 -1
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -48,12 +48,31 @@ export default {
|
|
|
48
48
|
// include: [/^@my-scope\//],
|
|
49
49
|
// exclude: ["fsevents"],
|
|
50
50
|
// traceInclude: ["some-lib"],
|
|
51
|
-
// trace: {
|
|
51
|
+
// trace: {
|
|
52
|
+
// fullTraceInclude: ["some-lib"],
|
|
53
|
+
// }
|
|
52
54
|
}),
|
|
53
55
|
],
|
|
54
56
|
};
|
|
55
57
|
```
|
|
56
58
|
|
|
59
|
+
### Full Trace Include
|
|
60
|
+
|
|
61
|
+
By default, only files detected by [`@vercel/nft`](https://github.com/vercel/nft) are included in the output. Some packages may require all their files to be present at runtime (e.g., packages with dynamic requires or asset files).
|
|
62
|
+
|
|
63
|
+
Use `fullTraceInclude` to specify package names that should have **all** files copied to the output:
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
rollupNodeFileTrace({
|
|
67
|
+
trace: {
|
|
68
|
+
fullTraceInclude: ["some-package", "@scope/another-package"],
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
> [!NOTE]
|
|
74
|
+
> Requires Node.js >= 22.0.0 (`fs.promises.glob`).
|
|
75
|
+
|
|
57
76
|
### Hooks
|
|
58
77
|
|
|
59
78
|
After the Rollup plugin traces the required files, `traceNodeModules` processes them into an optimized `node_modules` output.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import { URL as e, fileURLToPath as t, pathToFileURL as n } from "node:url";
|
|
2
|
+
import r, { lstatSync as i, realpathSync as a, statSync as o } from "node:fs";
|
|
3
3
|
import s, { isAbsolute as c } from "node:path";
|
|
4
4
|
import l from "node:assert";
|
|
5
5
|
import u from "node:process";
|
|
@@ -105,19 +105,19 @@ b(`ERR_INVALID_ARG_VALUE`, (e, t, n = `is invalid`) => {
|
|
|
105
105
|
return r.length > 128 && (r = `${r.slice(0, 128)}...`), `The ${e.includes(`.`) ? `property` : `argument`} '${e}' ${n}. Received ${r}`;
|
|
106
106
|
}, TypeError);
|
|
107
107
|
const A = {}.hasOwnProperty, j = /* @__PURE__ */ new Map();
|
|
108
|
-
function M(
|
|
109
|
-
let
|
|
110
|
-
if (
|
|
108
|
+
function M(e, { base: n, specifier: i }) {
|
|
109
|
+
let a = j.get(e);
|
|
110
|
+
if (a) return a;
|
|
111
111
|
let o;
|
|
112
112
|
try {
|
|
113
|
-
o =
|
|
113
|
+
o = r.readFileSync(s.toNamespacedPath(e), `utf8`);
|
|
114
114
|
} catch (e) {
|
|
115
115
|
let t = e;
|
|
116
116
|
if (t.code !== `ENOENT`) throw t;
|
|
117
117
|
}
|
|
118
118
|
let c = {
|
|
119
119
|
exists: !1,
|
|
120
|
-
pjsonPath:
|
|
120
|
+
pjsonPath: e,
|
|
121
121
|
main: void 0,
|
|
122
122
|
name: void 0,
|
|
123
123
|
type: `none`,
|
|
@@ -125,27 +125,27 @@ function M(t, { base: n, specifier: r }) {
|
|
|
125
125
|
imports: void 0
|
|
126
126
|
};
|
|
127
127
|
if (o !== void 0) {
|
|
128
|
-
let
|
|
128
|
+
let r;
|
|
129
129
|
try {
|
|
130
|
-
|
|
131
|
-
} catch (
|
|
132
|
-
let
|
|
133
|
-
throw
|
|
130
|
+
r = JSON.parse(o);
|
|
131
|
+
} catch (r) {
|
|
132
|
+
let a = new w(e, (n ? `"${i}" from ` : ``) + t(n || i), r.message);
|
|
133
|
+
throw a.cause = r, a;
|
|
134
134
|
}
|
|
135
|
-
c.exists = !0, A.call(
|
|
135
|
+
c.exists = !0, A.call(r, `name`) && typeof r.name == `string` && (c.name = r.name), A.call(r, `main`) && typeof r.main == `string` && (c.main = r.main), A.call(r, `exports`) && (c.exports = r.exports), A.call(r, `imports`) && (c.imports = r.imports), A.call(r, `type`) && (r.type === `commonjs` || r.type === `module`) && (c.type = r.type);
|
|
136
136
|
}
|
|
137
|
-
return j.set(
|
|
137
|
+
return j.set(e, c), c;
|
|
138
138
|
}
|
|
139
139
|
function N(e) {
|
|
140
|
-
let
|
|
141
|
-
for (; !
|
|
142
|
-
let
|
|
143
|
-
if (
|
|
144
|
-
let
|
|
145
|
-
if (
|
|
140
|
+
let n = new URL(`package.json`, e);
|
|
141
|
+
for (; !n.pathname.endsWith(`node_modules/package.json`);) {
|
|
142
|
+
let r = M(t(n), { specifier: e });
|
|
143
|
+
if (r.exists) return r;
|
|
144
|
+
let i = n;
|
|
145
|
+
if (n = new URL(`../package.json`, n), n.pathname === i.pathname) break;
|
|
146
146
|
}
|
|
147
147
|
return {
|
|
148
|
-
pjsonPath:
|
|
148
|
+
pjsonPath: t(n),
|
|
149
149
|
exists: !1,
|
|
150
150
|
type: `none`
|
|
151
151
|
};
|
|
@@ -185,144 +185,144 @@ function de(e) {
|
|
|
185
185
|
}
|
|
186
186
|
return ``;
|
|
187
187
|
}
|
|
188
|
-
function fe(e,
|
|
189
|
-
let
|
|
190
|
-
if (
|
|
188
|
+
function fe(e, n, r) {
|
|
189
|
+
let i = de(e);
|
|
190
|
+
if (i === `.js`) {
|
|
191
191
|
let { type: t } = N(e);
|
|
192
192
|
return t === `none` ? `commonjs` : t;
|
|
193
193
|
}
|
|
194
|
-
if (
|
|
194
|
+
if (i === ``) {
|
|
195
195
|
let { type: t } = N(e);
|
|
196
196
|
return t === `none` || t === `commonjs` ? `commonjs` : `module`;
|
|
197
197
|
}
|
|
198
|
-
let
|
|
199
|
-
if (
|
|
200
|
-
if (!
|
|
198
|
+
let a = ce[i];
|
|
199
|
+
if (a) return a;
|
|
200
|
+
if (!r) throw new oe(i, t(e));
|
|
201
201
|
}
|
|
202
202
|
function pe(e, t) {
|
|
203
203
|
let n = e.protocol;
|
|
204
204
|
return se.call(P, n) && P[n](e, t, !0) || null;
|
|
205
205
|
}
|
|
206
206
|
const F = RegExp.prototype[Symbol.replace], I = {}.hasOwnProperty, L = /(^|\\|\/)((\.|%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, R = /(^|\\|\/)((\.|%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, z = /^\.|%|\\/, B = /\*/g, me = /%2f|%5c/i, V = /* @__PURE__ */ new Set(), he = /[/\\]{2}/;
|
|
207
|
-
function H(e,
|
|
207
|
+
function H(e, n, r, i, a, o, s) {
|
|
208
208
|
if (u.noDeprecation) return;
|
|
209
|
-
let c =
|
|
210
|
-
u.emitWarning(`Use of deprecated ${l ? `double slash` : `leading or trailing slash matching`} resolving "${e}" for module request "${
|
|
209
|
+
let c = t(i), l = he.exec(s ? e : n) !== null;
|
|
210
|
+
u.emitWarning(`Use of deprecated ${l ? `double slash` : `leading or trailing slash matching`} resolving "${e}" for module request "${n}" ${n === r ? `` : `matched to "${r}" `}in the "${a ? `imports` : `exports`}" field module resolution of the package at ${c}${o ? ` imported from ${t(o)}` : ``}.`, `DeprecationWarning`, `DEP0166`);
|
|
211
211
|
}
|
|
212
|
-
function U(
|
|
213
|
-
if (u.noDeprecation || pe(
|
|
214
|
-
let o =
|
|
215
|
-
|
|
212
|
+
function U(n, r, i, a) {
|
|
213
|
+
if (u.noDeprecation || pe(n, { parentURL: i.href }) !== `module`) return;
|
|
214
|
+
let o = t(n.href), c = t(new e(`.`, r)), l = t(i);
|
|
215
|
+
a ? s.resolve(c, a) !== o && u.emitWarning(`Package ${c} has a "main" field set to "${a}", excluding the full filename and extension to the resolved file at "${o.slice(c.length)}", imported from ${l}.\n Automatic extension resolution of the "main" field is deprecated for ES modules.`, `DeprecationWarning`, `DEP0151`) : u.emitWarning(`No "main" or "exports" field defined in the package.json for ${c} resolving the main entry point "${o.slice(c.length)}", imported from ${l}.\nDefault "index" lookups for the main are deprecated for ES modules.`, `DeprecationWarning`, `DEP0151`);
|
|
216
216
|
}
|
|
217
217
|
function W(e) {
|
|
218
218
|
try {
|
|
219
|
-
return
|
|
219
|
+
return o(e);
|
|
220
220
|
} catch {}
|
|
221
221
|
}
|
|
222
222
|
function G(e) {
|
|
223
|
-
let t =
|
|
223
|
+
let t = o(e, { throwIfNoEntry: !1 });
|
|
224
224
|
return (t ? t.isFile() : void 0) ?? !1;
|
|
225
225
|
}
|
|
226
|
-
function ge(
|
|
227
|
-
let
|
|
228
|
-
if (
|
|
229
|
-
if (
|
|
230
|
-
let
|
|
231
|
-
`./${
|
|
232
|
-
`./${
|
|
233
|
-
`./${
|
|
234
|
-
`./${
|
|
235
|
-
`./${
|
|
236
|
-
`./${
|
|
226
|
+
function ge(n, r, i) {
|
|
227
|
+
let a;
|
|
228
|
+
if (r.main !== void 0) {
|
|
229
|
+
if (a = new e(r.main, n), G(a)) return a;
|
|
230
|
+
let t = [
|
|
231
|
+
`./${r.main}.js`,
|
|
232
|
+
`./${r.main}.json`,
|
|
233
|
+
`./${r.main}.node`,
|
|
234
|
+
`./${r.main}/index.js`,
|
|
235
|
+
`./${r.main}/index.json`,
|
|
236
|
+
`./${r.main}/index.node`
|
|
237
237
|
], o = -1;
|
|
238
|
-
for (; ++o <
|
|
239
|
-
if (
|
|
238
|
+
for (; ++o < t.length && (a = new e(t[o], n), !G(a));) a = void 0;
|
|
239
|
+
if (a) return U(a, n, i, r.main), a;
|
|
240
240
|
}
|
|
241
241
|
let o = [
|
|
242
242
|
`./index.js`,
|
|
243
243
|
`./index.json`,
|
|
244
244
|
`./index.node`
|
|
245
245
|
], s = -1;
|
|
246
|
-
for (; ++s < o.length && (
|
|
247
|
-
if (
|
|
248
|
-
throw new T(
|
|
246
|
+
for (; ++s < o.length && (a = new e(o[s], n), !G(a));) a = void 0;
|
|
247
|
+
if (a) return U(a, n, i, r.main), a;
|
|
248
|
+
throw new T(t(new e(`.`, n)), t(i));
|
|
249
249
|
}
|
|
250
|
-
function _e(e,
|
|
251
|
-
if (me.exec(e.pathname) !== null) throw new C(e.pathname, String.raw`must not include encoded "/" or "\" characters`,
|
|
252
|
-
let
|
|
250
|
+
function _e(e, r, i) {
|
|
251
|
+
if (me.exec(e.pathname) !== null) throw new C(e.pathname, String.raw`must not include encoded "/" or "\" characters`, t(r));
|
|
252
|
+
let o;
|
|
253
253
|
try {
|
|
254
|
-
|
|
255
|
-
} catch (
|
|
256
|
-
throw Object.defineProperty(
|
|
254
|
+
o = t(e);
|
|
255
|
+
} catch (t) {
|
|
256
|
+
throw Object.defineProperty(t, `input`, { value: String(e) }), Object.defineProperty(t, `module`, { value: String(r) }), t;
|
|
257
257
|
}
|
|
258
|
-
let c = W(
|
|
258
|
+
let c = W(o.endsWith(`/`) ? o.slice(-1) : o);
|
|
259
259
|
if (c && c.isDirectory()) {
|
|
260
|
-
let n = new O(
|
|
260
|
+
let n = new O(o, t(r));
|
|
261
261
|
throw n.url = String(e), n;
|
|
262
262
|
}
|
|
263
263
|
if (!c || !c.isFile()) {
|
|
264
|
-
let n = new T(
|
|
264
|
+
let n = new T(o || e.pathname, r && t(r), !0);
|
|
265
265
|
throw n.url = String(e), n;
|
|
266
266
|
}
|
|
267
|
-
if (!
|
|
268
|
-
let t =
|
|
269
|
-
e =
|
|
267
|
+
if (!i) {
|
|
268
|
+
let t = a(o), { search: r, hash: i } = e;
|
|
269
|
+
e = n(t + (o.endsWith(s.sep) ? `/` : ``)), e.search = r, e.hash = i;
|
|
270
270
|
}
|
|
271
271
|
return e;
|
|
272
272
|
}
|
|
273
|
-
function ve(
|
|
274
|
-
return new E(
|
|
273
|
+
function ve(n, r, i) {
|
|
274
|
+
return new E(n, r && t(new e(`.`, r)), t(i));
|
|
275
275
|
}
|
|
276
|
-
function K(
|
|
277
|
-
return new D(
|
|
276
|
+
function K(n, r, i) {
|
|
277
|
+
return new D(t(new e(`.`, r)), n, i && t(i));
|
|
278
278
|
}
|
|
279
|
-
function ye(e,
|
|
280
|
-
throw new C(e, `request is not a valid match in pattern "${
|
|
279
|
+
function ye(e, n, r, i, a) {
|
|
280
|
+
throw new C(e, `request is not a valid match in pattern "${n}" for the "${i ? `imports` : `exports`}" resolution of ${t(r)}`, a && t(a));
|
|
281
281
|
}
|
|
282
|
-
function q(
|
|
283
|
-
return
|
|
282
|
+
function q(n, r, i, a, o) {
|
|
283
|
+
return r = typeof r == `object` && r ? JSON.stringify(r, null, ``) : `${r}`, new ae(t(new e(`.`, i)), n, r, a, o && t(o));
|
|
284
284
|
}
|
|
285
|
-
function be(
|
|
286
|
-
if (
|
|
287
|
-
if (!
|
|
288
|
-
if (s && !
|
|
289
|
-
let
|
|
285
|
+
function be(t, n, r, i, a, o, s, c, l) {
|
|
286
|
+
if (n !== `` && !o && t.at(-1) !== `/`) throw q(r, t, i, s, a);
|
|
287
|
+
if (!t.startsWith(`./`)) {
|
|
288
|
+
if (s && !t.startsWith(`../`) && !t.startsWith(`/`)) {
|
|
289
|
+
let r = !1;
|
|
290
290
|
try {
|
|
291
|
-
new
|
|
291
|
+
new e(t), r = !0;
|
|
292
292
|
} catch {}
|
|
293
|
-
if (!
|
|
293
|
+
if (!r) return Z(o ? F.call(B, t, () => n) : t + n, i, l);
|
|
294
294
|
}
|
|
295
|
-
throw q(
|
|
295
|
+
throw q(r, t, i, s, a);
|
|
296
296
|
}
|
|
297
|
-
if (L.exec(
|
|
297
|
+
if (L.exec(t.slice(2)) !== null) if (R.exec(t.slice(2)) === null) {
|
|
298
298
|
if (!c) {
|
|
299
|
-
let
|
|
300
|
-
H(o ? F.call(B,
|
|
299
|
+
let e = o ? r.replace(`*`, () => n) : r + n;
|
|
300
|
+
H(o ? F.call(B, t, () => n) : t, e, r, i, s, a, !0);
|
|
301
301
|
}
|
|
302
|
-
} else throw q(
|
|
303
|
-
let u = new
|
|
304
|
-
if (!d.startsWith(f)) throw q(
|
|
305
|
-
if (
|
|
306
|
-
if (L.exec(
|
|
307
|
-
let
|
|
308
|
-
R.exec(
|
|
302
|
+
} else throw q(r, t, i, s, a);
|
|
303
|
+
let u = new e(t, i), d = u.pathname, f = new e(`.`, i).pathname;
|
|
304
|
+
if (!d.startsWith(f)) throw q(r, t, i, s, a);
|
|
305
|
+
if (n === ``) return u;
|
|
306
|
+
if (L.exec(n) !== null) {
|
|
307
|
+
let e = o ? r.replace(`*`, () => n) : r + n;
|
|
308
|
+
R.exec(n) === null ? c || H(o ? F.call(B, t, () => n) : t, e, r, i, s, a, !1) : ye(e, r, i, s, a);
|
|
309
309
|
}
|
|
310
|
-
return o ? new
|
|
310
|
+
return o ? new e(F.call(B, u.href, () => n)) : new e(n, u);
|
|
311
311
|
}
|
|
312
312
|
function xe(e) {
|
|
313
313
|
let t = Number(e);
|
|
314
314
|
return `${t}` === e ? t >= 0 && t < 4294967295 : !1;
|
|
315
315
|
}
|
|
316
|
-
function J(e,
|
|
317
|
-
if (typeof
|
|
318
|
-
if (Array.isArray(
|
|
319
|
-
let
|
|
320
|
-
if (
|
|
316
|
+
function J(e, n, r, i, a, o, s, c, l) {
|
|
317
|
+
if (typeof n == `string`) return be(n, r, i, e, a, o, s, c, l);
|
|
318
|
+
if (Array.isArray(n)) {
|
|
319
|
+
let t = n;
|
|
320
|
+
if (t.length === 0) return null;
|
|
321
321
|
let u, d = -1;
|
|
322
|
-
for (; ++d <
|
|
323
|
-
let
|
|
322
|
+
for (; ++d < t.length;) {
|
|
323
|
+
let n = t[d], f;
|
|
324
324
|
try {
|
|
325
|
-
f = J(e,
|
|
325
|
+
f = J(e, n, r, i, a, o, s, c, l);
|
|
326
326
|
} catch (e) {
|
|
327
327
|
let t = e;
|
|
328
328
|
if (u = t, t.code === `ERR_INVALID_PACKAGE_TARGET`) continue;
|
|
@@ -339,40 +339,40 @@ function J(e, t, n, r, i, o, s, c, l) {
|
|
|
339
339
|
if (u == null) return null;
|
|
340
340
|
throw u;
|
|
341
341
|
}
|
|
342
|
-
if (typeof
|
|
343
|
-
let u = Object.getOwnPropertyNames(
|
|
342
|
+
if (typeof n == `object` && n) {
|
|
343
|
+
let u = Object.getOwnPropertyNames(n), d = -1;
|
|
344
344
|
for (; ++d < u.length;) {
|
|
345
|
-
let
|
|
346
|
-
if (xe(
|
|
345
|
+
let n = u[d];
|
|
346
|
+
if (xe(n)) throw new w(t(e), t(a), `"exports" cannot contain numeric property keys.`);
|
|
347
347
|
}
|
|
348
348
|
for (d = -1; ++d < u.length;) {
|
|
349
|
-
let
|
|
350
|
-
if (
|
|
351
|
-
let u = t
|
|
349
|
+
let t = u[d];
|
|
350
|
+
if (t === `default` || l && l.has(t)) {
|
|
351
|
+
let u = n[t], d = J(e, u, r, i, a, o, s, c, l);
|
|
352
352
|
if (d === void 0) continue;
|
|
353
353
|
return d;
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
356
|
return null;
|
|
357
357
|
}
|
|
358
|
-
if (
|
|
359
|
-
throw q(
|
|
358
|
+
if (n === null) return null;
|
|
359
|
+
throw q(i, n, e, s, a);
|
|
360
360
|
}
|
|
361
|
-
function Se(e,
|
|
361
|
+
function Se(e, n, r) {
|
|
362
362
|
if (typeof e == `string` || Array.isArray(e)) return !0;
|
|
363
363
|
if (typeof e != `object` || !e) return !1;
|
|
364
|
-
let
|
|
365
|
-
for (; ++s <
|
|
366
|
-
let e =
|
|
367
|
-
if (o++ === 0)
|
|
368
|
-
else if (
|
|
364
|
+
let i = Object.getOwnPropertyNames(e), a = !1, o = 0, s = -1;
|
|
365
|
+
for (; ++s < i.length;) {
|
|
366
|
+
let e = i[s], c = e === `` || e[0] !== `.`;
|
|
367
|
+
if (o++ === 0) a = c;
|
|
368
|
+
else if (a !== c) throw new w(t(n), t(r), `"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.`);
|
|
369
369
|
}
|
|
370
|
-
return
|
|
370
|
+
return a;
|
|
371
371
|
}
|
|
372
|
-
function Ce(e,
|
|
372
|
+
function Ce(e, n, r) {
|
|
373
373
|
if (u.noDeprecation) return;
|
|
374
|
-
let
|
|
375
|
-
V.has(
|
|
374
|
+
let i = t(n);
|
|
375
|
+
V.has(i + `|` + e) || (V.add(i + `|` + e), u.emitWarning(`Use of deprecated trailing slash pattern mapping "${e}" in the "exports" field module resolution of the package at ${i}${r ? ` imported from ${t(r)}` : ``}. Mapping specifiers ending in "/" is no longer supported.`, `DeprecationWarning`, `DEP0155`));
|
|
376
376
|
}
|
|
377
377
|
function Y(e, t, n, r, i) {
|
|
378
378
|
let a = n.exports;
|
|
@@ -401,61 +401,61 @@ function X(e, t) {
|
|
|
401
401
|
let n = e.indexOf(`*`), r = t.indexOf(`*`), i = n === -1 ? e.length : n + 1, a = r === -1 ? t.length : r + 1;
|
|
402
402
|
return i > a ? -1 : a > i || n === -1 ? 1 : r === -1 || e.length > t.length ? -1 : t.length > e.length ? 1 : 0;
|
|
403
403
|
}
|
|
404
|
-
function we(e,
|
|
405
|
-
if (e === `#` || e.startsWith(`#/`) || e.endsWith(`/`)) throw new C(e, `is not a valid internal imports specifier name`,
|
|
406
|
-
let
|
|
407
|
-
if (
|
|
408
|
-
|
|
409
|
-
let
|
|
410
|
-
if (
|
|
411
|
-
let
|
|
412
|
-
if (
|
|
404
|
+
function we(e, r, i) {
|
|
405
|
+
if (e === `#` || e.startsWith(`#/`) || e.endsWith(`/`)) throw new C(e, `is not a valid internal imports specifier name`, t(r));
|
|
406
|
+
let a, o = N(r);
|
|
407
|
+
if (o.exists) {
|
|
408
|
+
a = n(o.pjsonPath);
|
|
409
|
+
let t = o.imports;
|
|
410
|
+
if (t) if (I.call(t, e) && !e.includes(`*`)) {
|
|
411
|
+
let n = J(a, t[e], ``, e, r, !1, !0, !1, i);
|
|
412
|
+
if (n != null) return n;
|
|
413
413
|
} else {
|
|
414
|
-
let
|
|
414
|
+
let n = ``, o = ``, s = Object.getOwnPropertyNames(t), c = -1;
|
|
415
415
|
for (; ++c < s.length;) {
|
|
416
|
-
let t = s[c],
|
|
417
|
-
if (
|
|
418
|
-
let
|
|
419
|
-
e.length >= t.length && e.endsWith(
|
|
416
|
+
let t = s[c], r = t.indexOf(`*`);
|
|
417
|
+
if (r !== -1 && e.startsWith(t.slice(0, -1))) {
|
|
418
|
+
let i = t.slice(r + 1);
|
|
419
|
+
e.length >= t.length && e.endsWith(i) && X(n, t) === 1 && t.lastIndexOf(`*`) === r && (n = t, o = e.slice(r, e.length - i.length));
|
|
420
420
|
}
|
|
421
421
|
}
|
|
422
|
-
if (
|
|
423
|
-
let e =
|
|
422
|
+
if (n) {
|
|
423
|
+
let e = t[n], s = J(a, e, o, n, r, !0, !0, !1, i);
|
|
424
424
|
if (s != null) return s;
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
427
|
}
|
|
428
|
-
throw ve(e,
|
|
428
|
+
throw ve(e, a, r);
|
|
429
429
|
}
|
|
430
|
-
function Te(e,
|
|
431
|
-
let
|
|
432
|
-
e[0] === `@` && (
|
|
433
|
-
let o =
|
|
434
|
-
if (z.exec(o) !== null && (
|
|
430
|
+
function Te(e, n) {
|
|
431
|
+
let r = e.indexOf(`/`), i = !0, a = !1;
|
|
432
|
+
e[0] === `@` && (a = !0, r === -1 || e.length === 0 ? i = !1 : r = e.indexOf(`/`, r + 1));
|
|
433
|
+
let o = r === -1 ? e : e.slice(0, r);
|
|
434
|
+
if (z.exec(o) !== null && (i = !1), !i) throw new C(e, `is not a valid package name`, t(n));
|
|
435
435
|
return {
|
|
436
436
|
packageName: o,
|
|
437
|
-
packageSubpath: `.` + (
|
|
438
|
-
isScoped:
|
|
437
|
+
packageSubpath: `.` + (r === -1 ? `` : e.slice(r)),
|
|
438
|
+
isScoped: a
|
|
439
439
|
};
|
|
440
440
|
}
|
|
441
|
-
function Z(
|
|
442
|
-
if (m.includes(
|
|
443
|
-
let { packageName:
|
|
444
|
-
if (l.exists && l.name ===
|
|
445
|
-
let u = new
|
|
441
|
+
function Z(r, i, a) {
|
|
442
|
+
if (m.includes(r)) return new e(`node:` + r);
|
|
443
|
+
let { packageName: o, packageSubpath: s, isScoped: c } = Te(r, i), l = N(i);
|
|
444
|
+
if (l.exists && l.name === o && l.exports !== void 0 && l.exports !== null) return Y(n(l.pjsonPath), s, l, i, a);
|
|
445
|
+
let u = new e(`./node_modules/` + o + `/package.json`, i), d = t(u), f;
|
|
446
446
|
do {
|
|
447
|
-
let
|
|
448
|
-
if (!
|
|
449
|
-
f = d, u = new
|
|
447
|
+
let n = W(d.slice(0, -13));
|
|
448
|
+
if (!n || !n.isDirectory()) {
|
|
449
|
+
f = d, u = new e((c ? `../../../../node_modules/` : `../../../node_modules/`) + o + `/package.json`, u), d = t(u);
|
|
450
450
|
continue;
|
|
451
451
|
}
|
|
452
452
|
let l = M(d, {
|
|
453
|
-
base:
|
|
454
|
-
specifier:
|
|
453
|
+
base: i,
|
|
454
|
+
specifier: r
|
|
455
455
|
});
|
|
456
|
-
return l.exports !== void 0 && l.exports !== null ? Y(u, s, l,
|
|
456
|
+
return l.exports !== void 0 && l.exports !== null ? Y(u, s, l, i, a) : s === `.` ? ge(u, l, i) : new e(s, u);
|
|
457
457
|
} while (d.length !== f.length);
|
|
458
|
-
throw new T(
|
|
458
|
+
throw new T(o, t(i), !1);
|
|
459
459
|
}
|
|
460
460
|
function Ee(e) {
|
|
461
461
|
return e[0] === `.` && (e.length === 1 || e[1] === `/` || e[1] === `.` && (e.length === 2 || e[2] === `/`));
|
|
@@ -463,46 +463,46 @@ function Ee(e) {
|
|
|
463
463
|
function De(e) {
|
|
464
464
|
return e === `` ? !1 : e[0] === `/` ? !0 : Ee(e);
|
|
465
465
|
}
|
|
466
|
-
function Oe(
|
|
467
|
-
let a =
|
|
468
|
-
if (De(
|
|
469
|
-
s = new
|
|
470
|
-
} catch (
|
|
471
|
-
let r = new k(
|
|
472
|
-
throw r.cause =
|
|
466
|
+
function Oe(t, n, r, i) {
|
|
467
|
+
let a = n.protocol, o = a === `data:`, s;
|
|
468
|
+
if (De(t)) try {
|
|
469
|
+
s = new e(t, n);
|
|
470
|
+
} catch (e) {
|
|
471
|
+
let r = new k(t, n);
|
|
472
|
+
throw r.cause = e, r;
|
|
473
473
|
}
|
|
474
|
-
else if (a === `file:` &&
|
|
474
|
+
else if (a === `file:` && t[0] === `#`) s = we(t, n, r);
|
|
475
475
|
else try {
|
|
476
|
-
s = new
|
|
477
|
-
} catch (
|
|
478
|
-
if (o && !m.includes(
|
|
479
|
-
let
|
|
480
|
-
throw
|
|
476
|
+
s = new e(t);
|
|
477
|
+
} catch (e) {
|
|
478
|
+
if (o && !m.includes(t)) {
|
|
479
|
+
let r = new k(t, n);
|
|
480
|
+
throw r.cause = e, r;
|
|
481
481
|
}
|
|
482
|
-
s = Z(
|
|
482
|
+
s = Z(t, n, r);
|
|
483
483
|
}
|
|
484
|
-
return l.ok(s !== void 0, `expected to be defined`), s.protocol === `file:` ? _e(s,
|
|
484
|
+
return l.ok(s !== void 0, `expected to be defined`), s.protocol === `file:` ? _e(s, n, i) : s;
|
|
485
485
|
}
|
|
486
486
|
const ke = new Set([`node`, `import`]), Ae = process.platform === `win32`, je = globalThis.__EXSOLVE_CACHE__ ||= /* @__PURE__ */ new Map();
|
|
487
|
-
function Q(e,
|
|
488
|
-
let
|
|
489
|
-
if (`external` in
|
|
490
|
-
let
|
|
491
|
-
if (
|
|
487
|
+
function Q(e, t) {
|
|
488
|
+
let r = Be(e);
|
|
489
|
+
if (`external` in r) return r.external;
|
|
490
|
+
let o = r.specifier, s = r.url, c = r.absolutePath, l, u;
|
|
491
|
+
if (t?.cache !== !1 && (l = Le(c || o, t), u = t?.cache && typeof t?.cache == `object` ? t.cache : je), u) {
|
|
492
492
|
let e = u.get(l);
|
|
493
493
|
if (typeof e == `string`) return e;
|
|
494
494
|
if (e instanceof Error) {
|
|
495
|
-
if (
|
|
495
|
+
if (t?.try) return;
|
|
496
496
|
throw e;
|
|
497
497
|
}
|
|
498
498
|
}
|
|
499
499
|
if (c) try {
|
|
500
|
-
let e =
|
|
501
|
-
if (e.isSymbolicLink() && (c =
|
|
500
|
+
let e = i(c);
|
|
501
|
+
if (e.isSymbolicLink() && (c = a(c), s = n(c)), e.isFile()) return u && u.set(l, s.href), s.href;
|
|
502
502
|
} catch (e) {
|
|
503
503
|
if (e?.code !== `ENOENT`) throw u && u.set(l, e), e;
|
|
504
504
|
}
|
|
505
|
-
let d =
|
|
505
|
+
let d = t?.conditions ? new Set(t.conditions) : ke, f = o || s.href, p = Pe(t?.from), m = t?.suffixes || [``], h = t?.extensions ? [``, ...t.extensions] : [``], g;
|
|
506
506
|
for (let e of p) {
|
|
507
507
|
for (let t of m) {
|
|
508
508
|
let n = Re(f, t);
|
|
@@ -513,17 +513,17 @@ function Q(e, r) {
|
|
|
513
513
|
if (g) break;
|
|
514
514
|
}
|
|
515
515
|
if (!g) {
|
|
516
|
-
let
|
|
517
|
-
if (
|
|
518
|
-
throw
|
|
516
|
+
let n = Error(`Cannot resolve module "${e}" (from: ${p.map((e) => Ie(e)).join(`, `)})`);
|
|
517
|
+
if (n.code = `ERR_MODULE_NOT_FOUND`, u && u.set(l, n), t?.try) return;
|
|
518
|
+
throw n;
|
|
519
519
|
}
|
|
520
520
|
return u && u.set(l, g.href), g.href;
|
|
521
521
|
}
|
|
522
|
-
function Me(e,
|
|
523
|
-
let
|
|
524
|
-
if (!
|
|
525
|
-
let
|
|
526
|
-
return Ae ? ze(
|
|
522
|
+
function Me(e, n) {
|
|
523
|
+
let r = Q(e, n);
|
|
524
|
+
if (!r || !r.startsWith(`file://`) && n?.try) return;
|
|
525
|
+
let i = t(r);
|
|
526
|
+
return Ae ? ze(i) : i;
|
|
527
527
|
}
|
|
528
528
|
function Ne(e, t, n) {
|
|
529
529
|
try {
|
|
@@ -532,7 +532,7 @@ function Ne(e, t, n) {
|
|
|
532
532
|
}
|
|
533
533
|
function Pe(e) {
|
|
534
534
|
let t = (Array.isArray(e) ? e : [e]).flatMap((e) => Fe(e));
|
|
535
|
-
return t.length === 0 ? [
|
|
535
|
+
return t.length === 0 ? [n(`./`)] : t;
|
|
536
536
|
}
|
|
537
537
|
function Fe(e) {
|
|
538
538
|
if (!e) return [];
|
|
@@ -540,14 +540,14 @@ function Fe(e) {
|
|
|
540
540
|
if (typeof e != `string`) return [];
|
|
541
541
|
if (/^(?:node|data|http|https|file):/.test(e)) return new URL(e);
|
|
542
542
|
try {
|
|
543
|
-
return e.endsWith(`/`) ||
|
|
543
|
+
return e.endsWith(`/`) || o(e).isDirectory() ? n(e + `/`) : n(e);
|
|
544
544
|
} catch {
|
|
545
|
-
return [
|
|
545
|
+
return [n(e + `/`), n(e)];
|
|
546
546
|
}
|
|
547
547
|
}
|
|
548
548
|
function Ie(e) {
|
|
549
549
|
try {
|
|
550
|
-
return
|
|
550
|
+
return t(e);
|
|
551
551
|
} catch {
|
|
552
552
|
return e;
|
|
553
553
|
}
|
|
@@ -573,20 +573,20 @@ function $(e) {
|
|
|
573
573
|
function Be(e) {
|
|
574
574
|
if (typeof e == `string`) {
|
|
575
575
|
if (e.startsWith(`file:`)) {
|
|
576
|
-
let
|
|
576
|
+
let n = new URL(e);
|
|
577
577
|
return {
|
|
578
|
-
url:
|
|
579
|
-
absolutePath:
|
|
578
|
+
url: n,
|
|
579
|
+
absolutePath: t(n)
|
|
580
580
|
};
|
|
581
581
|
}
|
|
582
582
|
return c(e) ? {
|
|
583
|
-
url:
|
|
583
|
+
url: n(e),
|
|
584
584
|
absolutePath: e
|
|
585
585
|
} : /^(?:node|data|http|https):/.test(e) ? { external: e } : m.includes(e) && !e.includes(`:`) ? { external: `node:${e}` } : { specifier: e };
|
|
586
586
|
}
|
|
587
587
|
if ($(e)) return e.protocol === `file:` ? {
|
|
588
588
|
url: e,
|
|
589
|
-
absolutePath:
|
|
589
|
+
absolutePath: t(e)
|
|
590
590
|
} : { external: e.href };
|
|
591
591
|
throw TypeError("id must be a `string` or `URL`");
|
|
592
592
|
}
|
package/dist/_chunks/trace.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { a as relative, i as normalize, n as isAbsolute, o as resolve, r as join, t as dirname } from "./libs/pathe.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
|
-
import
|
|
3
|
+
import * as fsp from "node:fs/promises";
|
|
4
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
4
5
|
import { nodeFileTrace } from "@vercel/nft";
|
|
5
6
|
import semver from "semver";
|
|
6
|
-
import { readFile, writeFile } from "node:fs/promises";
|
|
7
7
|
//#region \0rolldown/runtime.js
|
|
8
8
|
var __defProp = Object.defineProperty;
|
|
9
9
|
var __exportAll = (all, no_symbols) => {
|
|
@@ -114,7 +114,7 @@ async function traceNodeModules(input, opts) {
|
|
|
114
114
|
...opts.nft
|
|
115
115
|
});
|
|
116
116
|
await opts?.hooks?.traceResult?.(traceResult);
|
|
117
|
-
const _resolveTracedPath = (p) =>
|
|
117
|
+
const _resolveTracedPath = (p) => fsp.realpath(resolve(opts.nft?.base || "/", p)).then((p) => normalize(p));
|
|
118
118
|
const tracedFiles = Object.fromEntries(await Promise.all([...traceResult.reasons.entries()].map(async ([_path, reasons]) => {
|
|
119
119
|
if (reasons.ignored) return;
|
|
120
120
|
const path = await _resolveTracedPath(_path);
|
|
@@ -162,6 +162,18 @@ async function traceNodeModules(input, opts) {
|
|
|
162
162
|
pkgJSON
|
|
163
163
|
};
|
|
164
164
|
tracedPackage.versions[pkgJSON.version || "0.0.0"] = tracedPackageVersion;
|
|
165
|
+
const fullTraceEntry = resolveFullTraceEntry(opts.fullTraceInclude, pkgName);
|
|
166
|
+
if (fullTraceEntry) {
|
|
167
|
+
if (!fsp.glob) throw new Error("`fullTraceInclude` requires Node.js >= 22.0.0 (fs.promises.glob)");
|
|
168
|
+
const globPattern = fullTraceEntry.glob || "{**,.**}/{.*,*}";
|
|
169
|
+
for await (const file of fsp.glob(globPattern, {
|
|
170
|
+
cwd: tracedFile.pkgPath,
|
|
171
|
+
exclude: (name) => name === "node_modules"
|
|
172
|
+
})) {
|
|
173
|
+
const fullPath = join(tracedFile.pkgPath, file);
|
|
174
|
+
if (await isFile(fullPath)) tracedPackageVersion.files.push(fullPath);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
165
177
|
}
|
|
166
178
|
tracedPackageVersion.files.push(tracedFile.path);
|
|
167
179
|
tracedFile.pkgName = pkgName;
|
|
@@ -177,20 +189,23 @@ async function traceNodeModules(input, opts) {
|
|
|
177
189
|
const { subpath } = parseNodeModulePath(src);
|
|
178
190
|
if (!subpath) continue;
|
|
179
191
|
const dst = resolve(outDir, pkgPath, subpath);
|
|
180
|
-
await
|
|
192
|
+
await fsp.mkdir(dirname(dst), { recursive: true });
|
|
181
193
|
const transformers = (opts.transform || []).filter((t) => t?.filter?.(src) && t.handler);
|
|
182
194
|
if (transformers.length > 0) {
|
|
183
|
-
let content = await
|
|
195
|
+
let content = await fsp.readFile(src, "utf8");
|
|
184
196
|
for (const transformer of transformers) content = await transformer.handler(content, src) ?? content;
|
|
185
|
-
await
|
|
186
|
-
} else await
|
|
187
|
-
if (opts.chmod) await
|
|
197
|
+
await fsp.writeFile(dst, content, "utf8");
|
|
198
|
+
} else await fsp.copyFile(src, dst);
|
|
199
|
+
if (opts.chmod) await fsp.chmod(dst, opts.chmod === true ? 420 : opts.chmod);
|
|
188
200
|
}
|
|
189
201
|
const pkgJSON = pkg.versions[version].pkgJSON;
|
|
190
|
-
|
|
202
|
+
if (pkgJSON.exports) {
|
|
203
|
+
pkgJSON.exports = JSON.parse(JSON.stringify(pkgJSON.exports));
|
|
204
|
+
applyProductionCondition(pkgJSON.exports);
|
|
205
|
+
}
|
|
191
206
|
const pkgJSONPath = join(outDir, pkgPath, "package.json");
|
|
192
|
-
await
|
|
193
|
-
await
|
|
207
|
+
await fsp.mkdir(dirname(pkgJSONPath), { recursive: true });
|
|
208
|
+
await fsp.writeFile(pkgJSONPath, JSON.stringify(pkgJSON, null, 2), "utf8");
|
|
194
209
|
if (opts.traceAlias && opts.traceAlias[pkgPath]) {
|
|
195
210
|
usedAliases[opts.traceAlias[pkgPath]] = version;
|
|
196
211
|
await linkPackage(pkgPath, opts.traceAlias[pkgPath]);
|
|
@@ -199,14 +214,14 @@ async function traceNodeModules(input, opts) {
|
|
|
199
214
|
const linkPackage = async (from, to) => {
|
|
200
215
|
const src = join(outDir, from);
|
|
201
216
|
const dst = join(outDir, to);
|
|
202
|
-
if ((await
|
|
203
|
-
await
|
|
204
|
-
await
|
|
217
|
+
if ((await fsp.lstat(dst).catch(() => null))?.isSymbolicLink()) return;
|
|
218
|
+
await fsp.mkdir(dirname(dst), { recursive: true });
|
|
219
|
+
await fsp.symlink(relative(dirname(dst), src), dst, isWindows ? "junction" : "dir").catch((error) => {
|
|
205
220
|
if (error.code !== "EEXIST") console.error("Cannot link", from, "to", to, error);
|
|
206
221
|
});
|
|
207
222
|
};
|
|
208
223
|
const findPackageParents = (pkg, version) => {
|
|
209
|
-
const versionFiles = pkg.versions[version].files.map((path) => tracedFiles[path]);
|
|
224
|
+
const versionFiles = pkg.versions[version].files.map((path) => tracedFiles[path]).filter((x) => x !== void 0);
|
|
210
225
|
return [...new Set(versionFiles.flatMap((file) => file.parents.map((parentPath) => {
|
|
211
226
|
const parentFile = tracedFiles[parentPath];
|
|
212
227
|
if (!parentFile || parentFile.pkgName === pkg.name) return null;
|
|
@@ -231,8 +246,9 @@ async function traceNodeModules(input, opts) {
|
|
|
231
246
|
}));
|
|
232
247
|
for (const [pkgName, pkgVersions] of Object.entries(multiVersionPkgs)) {
|
|
233
248
|
const versionEntries = Object.entries(pkgVersions).sort(([v1, p1], [v2, p2]) => {
|
|
234
|
-
|
|
235
|
-
|
|
249
|
+
const d1 = p1.length === 0 ? Infinity : p1.length;
|
|
250
|
+
const d2 = p2.length === 0 ? Infinity : p2.length;
|
|
251
|
+
if (d1 !== d2) return d2 - d1;
|
|
236
252
|
return compareVersions(v1, v2);
|
|
237
253
|
});
|
|
238
254
|
for (const [version, parentPkgs] of versionEntries) {
|
|
@@ -263,11 +279,20 @@ function applyProductionCondition(exports) {
|
|
|
263
279
|
if (!exports || typeof exports === "string" || Array.isArray(exports)) return;
|
|
264
280
|
if ("production" in exports) if (typeof exports.production === "string") exports.default = exports.production;
|
|
265
281
|
else Object.assign(exports, exports.production);
|
|
266
|
-
for (const key in exports)
|
|
282
|
+
for (const key in exports) {
|
|
283
|
+
if (key === "production") continue;
|
|
284
|
+
applyProductionCondition(exports[key]);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function resolveFullTraceEntry(entries, pkgName) {
|
|
288
|
+
if (!entries) return;
|
|
289
|
+
for (const entry of entries) if (typeof entry === "string") {
|
|
290
|
+
if (entry === pkgName) return {};
|
|
291
|
+
} else if (entry[0] === pkgName) return entry[1];
|
|
267
292
|
}
|
|
268
293
|
async function isFile(file) {
|
|
269
294
|
try {
|
|
270
|
-
return (await
|
|
295
|
+
return (await fsp.stat(file)).isFile();
|
|
271
296
|
} catch (error) {
|
|
272
297
|
if (error?.code === "ENOENT") return false;
|
|
273
298
|
throw error;
|
package/dist/_chunks/types.d.mts
CHANGED
|
@@ -64,6 +64,24 @@ interface ExternalsTraceOptions {
|
|
|
64
64
|
* If `true`, writes a `package.json` file to the output directory (parent) with the traced files as dependencies.
|
|
65
65
|
*/
|
|
66
66
|
writePackageJson?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* List of package names to include all files for in the trace (not just nft-detected ones).
|
|
69
|
+
*
|
|
70
|
+
* Each item can be a package name string or a tuple of `[packageName, { glob }]` to customize the glob pattern.
|
|
71
|
+
*
|
|
72
|
+
* Requires Node.js >= 22.0.0 (`fs.promises.glob`).
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* fullTraceInclude: [
|
|
77
|
+
* "some-pkg",
|
|
78
|
+
* ["other-pkg", { glob: "dist/**" }],
|
|
79
|
+
* ]
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
fullTraceInclude?: (string | [name: string, options: {
|
|
83
|
+
glob?: string;
|
|
84
|
+
}])[];
|
|
67
85
|
/**
|
|
68
86
|
* Hook functions for allow extending tracing behavior.
|
|
69
87
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,`__esModule`,{value:!0}),exports.Minipass=exports.isWritable=exports.isReadable=exports.isStream=void 0;const proc=typeof process==`object`&&process?process:{stdout:null,stderr:null},node_events_1=require(`node:events`),node_stream_1=__importDefault(require(`node:stream`)),node_string_decoder_1=require(`node:string_decoder`),isStream=e=>!!e&&typeof e==`object`&&(e instanceof Minipass||e instanceof node_stream_1.default||(0,exports.isReadable)(e)||(0,exports.isWritable)(e));exports.isStream=isStream;const isReadable=e=>!!e&&typeof e==`object`&&e instanceof node_events_1.EventEmitter&&typeof e.pipe==`function`&&e.pipe!==node_stream_1.default.Writable.prototype.pipe;exports.isReadable=isReadable;const isWritable=e=>!!e&&typeof e==`object`&&e instanceof node_events_1.EventEmitter&&typeof e.write==`function`&&typeof e.end==`function`;exports.isWritable=isWritable;const EOF=Symbol(`EOF`),MAYBE_EMIT_END=Symbol(`maybeEmitEnd`),EMITTED_END=Symbol(`emittedEnd`),EMITTING_END=Symbol(`emittingEnd`),EMITTED_ERROR=Symbol(`emittedError`),CLOSED=Symbol(`closed`),READ=Symbol(`read`),FLUSH=Symbol(`flush`),FLUSHCHUNK=Symbol(`flushChunk`),ENCODING=Symbol(`encoding`),DECODER=Symbol(`decoder`),FLOWING=Symbol(`flowing`),PAUSED=Symbol(`paused`),RESUME=Symbol(`resume`),BUFFER=Symbol(`buffer`),PIPES=Symbol(`pipes`),BUFFERLENGTH=Symbol(`bufferLength`),BUFFERPUSH=Symbol(`bufferPush`),BUFFERSHIFT=Symbol(`bufferShift`),OBJECTMODE=Symbol(`objectMode`),DESTROYED=Symbol(`destroyed`),ERROR=Symbol(`error`),EMITDATA=Symbol(`emitData`),EMITEND=Symbol(`emitEnd`),EMITEND2=Symbol(`emitEnd2`),ASYNC=Symbol(`async`),ABORT=Symbol(`abort`),ABORTED=Symbol(`aborted`),SIGNAL=Symbol(`signal`),DATALISTENERS=Symbol(`dataListeners`),DISCARDED=Symbol(`discarded`),defer=e=>Promise.resolve().then(e),nodefer=e=>e(),isEndish=e=>e===`end`||e===`finish`||e===`prefinish`,isArrayBufferLike=e=>e instanceof ArrayBuffer||!!e&&typeof e==`object`&&e.constructor&&e.constructor.name===`ArrayBuffer`&&e.byteLength>=0,isArrayBufferView=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e);class Pipe{src;dest;opts;ondrain;constructor(e,t,n){this.src=e,this.dest=t,this.opts=n,this.ondrain=()=>e[RESUME](),this.dest.on(`drain`,this.ondrain)}unpipe(){this.dest.removeListener(`drain`,this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}}class PipeProxyErrors extends Pipe{unpipe(){this.src.removeListener(`error`,this.proxyErrors),super.unpipe()}constructor(e,t,n){super(e,t,n),this.proxyErrors=e=>t.emit(`error`,e),e.on(`error`,this.proxyErrors)}}const isObjectModeOptions=e=>!!e.objectMode,isEncodingOptions=e=>!e.objectMode&&!!e.encoding&&e.encoding!==`buffer`;class Minipass extends node_events_1.EventEmitter{[FLOWING]=!1;[PAUSED]=!1;[PIPES]=[];[BUFFER]=[];[OBJECTMODE];[ENCODING];[ASYNC];[DECODER];[EOF]=!1;[EMITTED_END]=!1;[EMITTING_END]=!1;[CLOSED]=!1;[EMITTED_ERROR]=null;[BUFFERLENGTH]=0;[DESTROYED]=!1;[SIGNAL];[ABORTED]=!1;[DATALISTENERS]=0;[DISCARDED]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding==`string`)throw TypeError(`Encoding and objectMode may not be used together`);isObjectModeOptions(t)?(this[OBJECTMODE]=!0,this[ENCODING]=null):isEncodingOptions(t)?(this[ENCODING]=t.encoding,this[OBJECTMODE]=!1):(this[OBJECTMODE]=!1,this[ENCODING]=null),this[ASYNC]=!!t.async,this[DECODER]=this[ENCODING]?new node_string_decoder_1.StringDecoder(this[ENCODING]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,`buffer`,{get:()=>this[BUFFER]}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,`pipes`,{get:()=>this[PIPES]});let{signal:n}=t;n&&(this[SIGNAL]=n,n.aborted?this[ABORT]():n.addEventListener(`abort`,()=>this[ABORT]()))}get bufferLength(){return this[BUFFERLENGTH]}get encoding(){return this[ENCODING]}set encoding(e){throw Error(`Encoding must be set at instantiation time`)}setEncoding(e){throw Error(`Encoding must be set at instantiation time`)}get objectMode(){return this[OBJECTMODE]}set objectMode(e){throw Error(`objectMode must be set at instantiation time`)}get async(){return this[ASYNC]}set async(e){this[ASYNC]=this[ASYNC]||!!e}[ABORT](){this[ABORTED]=!0,this.emit(`abort`,this[SIGNAL]?.reason),this.destroy(this[SIGNAL]?.reason)}get aborted(){return this[ABORTED]}set aborted(e){}write(e,t,n){if(this[ABORTED])return!1;if(this[EOF])throw Error(`write after end`);if(this[DESTROYED])return this.emit(`error`,Object.assign(Error(`Cannot call write after a stream was destroyed`),{code:`ERR_STREAM_DESTROYED`})),!0;typeof t==`function`&&(n=t,t=`utf8`),t||=`utf8`;let r=this[ASYNC]?defer:nodefer;if(!this[OBJECTMODE]&&!Buffer.isBuffer(e)){if(isArrayBufferView(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(isArrayBufferLike(e))e=Buffer.from(e);else if(typeof e!=`string`)throw Error(`Non-contiguous data written to non-objectMode stream`)}return this[OBJECTMODE]?(this[FLOWING]&&this[BUFFERLENGTH]!==0&&this[FLUSH](!0),this[FLOWING]?this.emit(`data`,e):this[BUFFERPUSH](e),this[BUFFERLENGTH]!==0&&this.emit(`readable`),n&&r(n),this[FLOWING]):e.length?(typeof e==`string`&&!(t===this[ENCODING]&&!this[DECODER]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[ENCODING]&&(e=this[DECODER].write(e)),this[FLOWING]&&this[BUFFERLENGTH]!==0&&this[FLUSH](!0),this[FLOWING]?this.emit(`data`,e):this[BUFFERPUSH](e),this[BUFFERLENGTH]!==0&&this.emit(`readable`),n&&r(n),this[FLOWING]):(this[BUFFERLENGTH]!==0&&this.emit(`readable`),n&&r(n),this[FLOWING])}read(e){if(this[DESTROYED])return null;if(this[DISCARDED]=!1,this[BUFFERLENGTH]===0||e===0||e&&e>this[BUFFERLENGTH])return this[MAYBE_EMIT_END](),null;this[OBJECTMODE]&&(e=null),this[BUFFER].length>1&&!this[OBJECTMODE]&&(this[BUFFER]=[this[ENCODING]?this[BUFFER].join(``):Buffer.concat(this[BUFFER],this[BUFFERLENGTH])]);let t=this[READ](e||null,this[BUFFER][0]);return this[MAYBE_EMIT_END](),t}[READ](e,t){if(this[OBJECTMODE])this[BUFFERSHIFT]();else{let n=t;e===n.length||e===null?this[BUFFERSHIFT]():typeof n==`string`?(this[BUFFER][0]=n.slice(e),t=n.slice(0,e),this[BUFFERLENGTH]-=e):(this[BUFFER][0]=n.subarray(e),t=n.subarray(0,e),this[BUFFERLENGTH]-=e)}return this.emit(`data`,t),!this[BUFFER].length&&!this[EOF]&&this.emit(`drain`),t}end(e,t,n){return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=`utf8`),e!==void 0&&this.write(e,t),n&&this.once(`end`,n),this[EOF]=!0,this.writable=!1,(this[FLOWING]||!this[PAUSED])&&this[MAYBE_EMIT_END](),this}[RESUME](){this[DESTROYED]||(!this[DATALISTENERS]&&!this[PIPES].length&&(this[DISCARDED]=!0),this[PAUSED]=!1,this[FLOWING]=!0,this.emit(`resume`),this[BUFFER].length?this[FLUSH]():this[EOF]?this[MAYBE_EMIT_END]():this.emit(`drain`))}resume(){return this[RESUME]()}pause(){this[FLOWING]=!1,this[PAUSED]=!0,this[DISCARDED]=!1}get destroyed(){return this[DESTROYED]}get flowing(){return this[FLOWING]}get paused(){return this[PAUSED]}[BUFFERPUSH](e){this[OBJECTMODE]?this[BUFFERLENGTH]+=1:this[BUFFERLENGTH]+=e.length,this[BUFFER].push(e)}[BUFFERSHIFT](){return this[OBJECTMODE]?--this[BUFFERLENGTH]:this[BUFFERLENGTH]-=this[BUFFER][0].length,this[BUFFER].shift()}[FLUSH](e=!1){do;while(this[FLUSHCHUNK](this[BUFFERSHIFT]())&&this[BUFFER].length);!e&&!this[BUFFER].length&&!this[EOF]&&this.emit(`drain`)}[FLUSHCHUNK](e){return this.emit(`data`,e),this[FLOWING]}pipe(e,n){if(this[DESTROYED])return e;this[DISCARDED]=!1;let r=this[EMITTED_END];return n||={},e===proc.stdout||e===proc.stderr?n.end=!1:n.end=n.end!==!1,n.proxyErrors=!!n.proxyErrors,r?n.end&&e.end():(this[PIPES].push(n.proxyErrors?new PipeProxyErrors(this,e,n):new Pipe(this,e,n)),this[ASYNC]?defer(()=>this[RESUME]()):this[RESUME]()),e}unpipe(e){let t=this[PIPES].find(t=>t.dest===e);t&&(this[PIPES].length===1?(this[FLOWING]&&this[DATALISTENERS]===0&&(this[FLOWING]=!1),this[PIPES]=[]):this[PIPES].splice(this[PIPES].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let n=super.on(e,t);if(e===`data`)this[DISCARDED]=!1,this[DATALISTENERS]++,!this[PIPES].length&&!this[FLOWING]&&this[RESUME]();else if(e===`readable`&&this[BUFFERLENGTH]!==0)super.emit(`readable`);else if(isEndish(e)&&this[EMITTED_END])super.emit(e),this.removeAllListeners(e);else if(e===`error`&&this[EMITTED_ERROR]){let e=t;this[ASYNC]?defer(()=>e.call(this,this[EMITTED_ERROR])):e.call(this,this[EMITTED_ERROR])}return n}removeListener(e,t){return this.off(e,t)}off(e,t){let n=super.off(e,t);return e===`data`&&(this[DATALISTENERS]=this.listeners(`data`).length,this[DATALISTENERS]===0&&!this[DISCARDED]&&!this[PIPES].length&&(this[FLOWING]=!1)),n}removeAllListeners(e){let t=super.removeAllListeners(e);return(e===`data`||e===void 0)&&(this[DATALISTENERS]=0,!this[DISCARDED]&&!this[PIPES].length&&(this[FLOWING]=!1)),t}get emittedEnd(){return this[EMITTED_END]}[MAYBE_EMIT_END](){!this[EMITTING_END]&&!this[EMITTED_END]&&!this[DESTROYED]&&this[BUFFER].length===0&&this[EOF]&&(this[EMITTING_END]=!0,this.emit(`end`),this.emit(`prefinish`),this.emit(`finish`),this[CLOSED]&&this.emit(`close`),this[EMITTING_END]=!1)}emit(e,...t){let n=t[0];if(e!==`error`&&e!==`close`&&e!==DESTROYED&&this[DESTROYED])return!1;if(e===`data`)return!this[OBJECTMODE]&&!n?!1:this[ASYNC]?(defer(()=>this[EMITDATA](n)),!0):this[EMITDATA](n);if(e===`end`)return this[EMITEND]();if(e===`close`){if(this[CLOSED]=!0,!this[EMITTED_END]&&!this[DESTROYED])return!1;let e=super.emit(`close`);return this.removeAllListeners(`close`),e}else if(e===`error`){this[EMITTED_ERROR]=n,super.emit(ERROR,n);let e=!this[SIGNAL]||this.listeners(`error`).length?super.emit(`error`,n):!1;return this[MAYBE_EMIT_END](),e}else if(e===`resume`){let e=super.emit(`resume`);return this[MAYBE_EMIT_END](),e}else if(e===`finish`||e===`prefinish`){let t=super.emit(e);return this.removeAllListeners(e),t}let r=super.emit(e,...t);return this[MAYBE_EMIT_END](),r}[EMITDATA](e){for(let t of this[PIPES])t.dest.write(e)===!1&&this.pause();let t=this[DISCARDED]?!1:super.emit(`data`,e);return this[MAYBE_EMIT_END](),t}[EMITEND](){return this[EMITTED_END]?!1:(this[EMITTED_END]=!0,this.readable=!1,this[ASYNC]?(defer(()=>this[EMITEND2]()),!0):this[EMITEND2]())}[EMITEND2](){if(this[DECODER]){let e=this[DECODER].end();if(e){for(let t of this[PIPES])t.dest.write(e);this[DISCARDED]||super.emit(`data`,e)}}for(let e of this[PIPES])e.end();let e=super.emit(`end`);return this.removeAllListeners(`end`),e}async collect(){let e=Object.assign([],{dataLength:0});this[OBJECTMODE]||(e.dataLength=0);let t=this.promise();return this.on(`data`,t=>{e.push(t),this[OBJECTMODE]||(e.dataLength+=t.length)}),await t,e}async concat(){if(this[OBJECTMODE])throw Error(`cannot concat in objectMode`);let e=await this.collect();return this[ENCODING]?e.join(``):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(DESTROYED,()=>t(Error(`stream destroyed`))),this.on(`error`,e=>t(e)),this.on(`end`,()=>e())})}[Symbol.asyncIterator](){this[DISCARDED]=!1;let e=!1,t=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return t();let n=this.read();if(n!==null)return Promise.resolve({done:!1,value:n});if(this[EOF])return t();let r,i,a=e=>{this.off(`data`,o),this.off(`end`,s),this.off(DESTROYED,c),t(),i(e)},o=e=>{this.off(`error`,a),this.off(`end`,s),this.off(DESTROYED,c),this.pause(),r({value:e,done:!!this[EOF]})},s=()=>{this.off(`error`,a),this.off(`data`,o),this.off(DESTROYED,c),t(),r({done:!0,value:void 0})},c=()=>a(Error(`stream destroyed`));return new Promise((e,t)=>{i=t,r=e,this.once(DESTROYED,c),this.once(`error`,a),this.once(`end`,s),this.once(`data`,o)})},throw:t,return:t,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[DISCARDED]=!1;let e=!1,t=()=>(this.pause(),this.off(ERROR,t),this.off(DESTROYED,t),this.off(`end`,t),e=!0,{done:!0,value:void 0});return this.once(`end`,t),this.once(ERROR,t),this.once(DESTROYED,t),{next:()=>{if(e)return t();let n=this.read();return n===null?t():{done:!1,value:n}},throw:t,return:t,[Symbol.iterator](){return this}}}destroy(e){if(this[DESTROYED])return e?this.emit(`error`,e):this.emit(DESTROYED),this;this[DESTROYED]=!0,this[DISCARDED]=!0,this[BUFFER].length=0,this[BUFFERLENGTH]=0;let t=this;return typeof t.close==`function`&&!this[CLOSED]&&t.close(),e?this.emit(`error`,e):this.emit(DESTROYED),this}static get isStream(){return exports.isStream}}exports.Minipass=Minipass;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "minipass",
|
|
3
|
+
"version": "7.1.2",
|
|
4
|
+
"main": "./dist/commonjs/index.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./package.json": "./package.json",
|
|
8
|
+
".": {
|
|
9
|
+
"import": {
|
|
10
|
+
"types": "./dist/esm/index.d.ts",
|
|
11
|
+
"default": "./dist/esm/index.js"
|
|
12
|
+
},
|
|
13
|
+
"require": {
|
|
14
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
15
|
+
"default": "./dist/commonjs/index.js"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,`__esModule`,{value:!0}),exports.Minipass=exports.isWritable=exports.isReadable=exports.isStream=void 0;const proc=typeof process==`object`&&process?process:{stdout:null,stderr:null},node_events_1=require(`node:events`),node_stream_1=__importDefault(require(`node:stream`)),node_string_decoder_1=require(`node:string_decoder`),isStream=e=>!!e&&typeof e==`object`&&(e instanceof Minipass||e instanceof node_stream_1.default||(0,exports.isReadable)(e)||(0,exports.isWritable)(e));exports.isStream=isStream;const isReadable=e=>!!e&&typeof e==`object`&&e instanceof node_events_1.EventEmitter&&typeof e.pipe==`function`&&e.pipe!==node_stream_1.default.Writable.prototype.pipe;exports.isReadable=isReadable;const isWritable=e=>!!e&&typeof e==`object`&&e instanceof node_events_1.EventEmitter&&typeof e.write==`function`&&typeof e.end==`function`;exports.isWritable=isWritable;const EOF=Symbol(`EOF`),MAYBE_EMIT_END=Symbol(`maybeEmitEnd`),EMITTED_END=Symbol(`emittedEnd`),EMITTING_END=Symbol(`emittingEnd`),EMITTED_ERROR=Symbol(`emittedError`),CLOSED=Symbol(`closed`),READ=Symbol(`read`),FLUSH=Symbol(`flush`),FLUSHCHUNK=Symbol(`flushChunk`),ENCODING=Symbol(`encoding`),DECODER=Symbol(`decoder`),FLOWING=Symbol(`flowing`),PAUSED=Symbol(`paused`),RESUME=Symbol(`resume`),BUFFER=Symbol(`buffer`),PIPES=Symbol(`pipes`),BUFFERLENGTH=Symbol(`bufferLength`),BUFFERPUSH=Symbol(`bufferPush`),BUFFERSHIFT=Symbol(`bufferShift`),OBJECTMODE=Symbol(`objectMode`),DESTROYED=Symbol(`destroyed`),ERROR=Symbol(`error`),EMITDATA=Symbol(`emitData`),EMITEND=Symbol(`emitEnd`),EMITEND2=Symbol(`emitEnd2`),ASYNC=Symbol(`async`),ABORT=Symbol(`abort`),ABORTED=Symbol(`aborted`),SIGNAL=Symbol(`signal`),DATALISTENERS=Symbol(`dataListeners`),DISCARDED=Symbol(`discarded`),defer=e=>Promise.resolve().then(e),nodefer=e=>e(),isEndish=e=>e===`end`||e===`finish`||e===`prefinish`,isArrayBufferLike=e=>e instanceof ArrayBuffer||!!e&&typeof e==`object`&&e.constructor&&e.constructor.name===`ArrayBuffer`&&e.byteLength>=0,isArrayBufferView=e=>!Buffer.isBuffer(e)&&ArrayBuffer.isView(e);class Pipe{src;dest;opts;ondrain;constructor(e,t,n){this.src=e,this.dest=t,this.opts=n,this.ondrain=()=>e[RESUME](),this.dest.on(`drain`,this.ondrain)}unpipe(){this.dest.removeListener(`drain`,this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}}class PipeProxyErrors extends Pipe{unpipe(){this.src.removeListener(`error`,this.proxyErrors),super.unpipe()}constructor(e,t,n){super(e,t,n),this.proxyErrors=e=>this.dest.emit(`error`,e),e.on(`error`,this.proxyErrors)}}const isObjectModeOptions=e=>!!e.objectMode,isEncodingOptions=e=>!e.objectMode&&!!e.encoding&&e.encoding!==`buffer`;class Minipass extends node_events_1.EventEmitter{[FLOWING]=!1;[PAUSED]=!1;[PIPES]=[];[BUFFER]=[];[OBJECTMODE];[ENCODING];[ASYNC];[DECODER];[EOF]=!1;[EMITTED_END]=!1;[EMITTING_END]=!1;[CLOSED]=!1;[EMITTED_ERROR]=null;[BUFFERLENGTH]=0;[DESTROYED]=!1;[SIGNAL];[ABORTED]=!1;[DATALISTENERS]=0;[DISCARDED]=!1;writable=!0;readable=!0;constructor(...e){let t=e[0]||{};if(super(),t.objectMode&&typeof t.encoding==`string`)throw TypeError(`Encoding and objectMode may not be used together`);isObjectModeOptions(t)?(this[OBJECTMODE]=!0,this[ENCODING]=null):isEncodingOptions(t)?(this[ENCODING]=t.encoding,this[OBJECTMODE]=!1):(this[OBJECTMODE]=!1,this[ENCODING]=null),this[ASYNC]=!!t.async,this[DECODER]=this[ENCODING]?new node_string_decoder_1.StringDecoder(this[ENCODING]):null,t&&t.debugExposeBuffer===!0&&Object.defineProperty(this,`buffer`,{get:()=>this[BUFFER]}),t&&t.debugExposePipes===!0&&Object.defineProperty(this,`pipes`,{get:()=>this[PIPES]});let{signal:n}=t;n&&(this[SIGNAL]=n,n.aborted?this[ABORT]():n.addEventListener(`abort`,()=>this[ABORT]()))}get bufferLength(){return this[BUFFERLENGTH]}get encoding(){return this[ENCODING]}set encoding(e){throw Error(`Encoding must be set at instantiation time`)}setEncoding(e){throw Error(`Encoding must be set at instantiation time`)}get objectMode(){return this[OBJECTMODE]}set objectMode(e){throw Error(`objectMode must be set at instantiation time`)}get async(){return this[ASYNC]}set async(e){this[ASYNC]=this[ASYNC]||!!e}[ABORT](){this[ABORTED]=!0,this.emit(`abort`,this[SIGNAL]?.reason),this.destroy(this[SIGNAL]?.reason)}get aborted(){return this[ABORTED]}set aborted(e){}write(e,t,n){if(this[ABORTED])return!1;if(this[EOF])throw Error(`write after end`);if(this[DESTROYED])return this.emit(`error`,Object.assign(Error(`Cannot call write after a stream was destroyed`),{code:`ERR_STREAM_DESTROYED`})),!0;typeof t==`function`&&(n=t,t=`utf8`),t||=`utf8`;let r=this[ASYNC]?defer:nodefer;if(!this[OBJECTMODE]&&!Buffer.isBuffer(e)){if(isArrayBufferView(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(isArrayBufferLike(e))e=Buffer.from(e);else if(typeof e!=`string`)throw Error(`Non-contiguous data written to non-objectMode stream`)}return this[OBJECTMODE]?(this[FLOWING]&&this[BUFFERLENGTH]!==0&&this[FLUSH](!0),this[FLOWING]?this.emit(`data`,e):this[BUFFERPUSH](e),this[BUFFERLENGTH]!==0&&this.emit(`readable`),n&&r(n),this[FLOWING]):e.length?(typeof e==`string`&&!(t===this[ENCODING]&&!this[DECODER]?.lastNeed)&&(e=Buffer.from(e,t)),Buffer.isBuffer(e)&&this[ENCODING]&&(e=this[DECODER].write(e)),this[FLOWING]&&this[BUFFERLENGTH]!==0&&this[FLUSH](!0),this[FLOWING]?this.emit(`data`,e):this[BUFFERPUSH](e),this[BUFFERLENGTH]!==0&&this.emit(`readable`),n&&r(n),this[FLOWING]):(this[BUFFERLENGTH]!==0&&this.emit(`readable`),n&&r(n),this[FLOWING])}read(e){if(this[DESTROYED])return null;if(this[DISCARDED]=!1,this[BUFFERLENGTH]===0||e===0||e&&e>this[BUFFERLENGTH])return this[MAYBE_EMIT_END](),null;this[OBJECTMODE]&&(e=null),this[BUFFER].length>1&&!this[OBJECTMODE]&&(this[BUFFER]=[this[ENCODING]?this[BUFFER].join(``):Buffer.concat(this[BUFFER],this[BUFFERLENGTH])]);let t=this[READ](e||null,this[BUFFER][0]);return this[MAYBE_EMIT_END](),t}[READ](e,t){if(this[OBJECTMODE])this[BUFFERSHIFT]();else{let n=t;e===n.length||e===null?this[BUFFERSHIFT]():typeof n==`string`?(this[BUFFER][0]=n.slice(e),t=n.slice(0,e),this[BUFFERLENGTH]-=e):(this[BUFFER][0]=n.subarray(e),t=n.subarray(0,e),this[BUFFERLENGTH]-=e)}return this.emit(`data`,t),!this[BUFFER].length&&!this[EOF]&&this.emit(`drain`),t}end(e,t,n){return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=`utf8`),e!==void 0&&this.write(e,t),n&&this.once(`end`,n),this[EOF]=!0,this.writable=!1,(this[FLOWING]||!this[PAUSED])&&this[MAYBE_EMIT_END](),this}[RESUME](){this[DESTROYED]||(!this[DATALISTENERS]&&!this[PIPES].length&&(this[DISCARDED]=!0),this[PAUSED]=!1,this[FLOWING]=!0,this.emit(`resume`),this[BUFFER].length?this[FLUSH]():this[EOF]?this[MAYBE_EMIT_END]():this.emit(`drain`))}resume(){return this[RESUME]()}pause(){this[FLOWING]=!1,this[PAUSED]=!0,this[DISCARDED]=!1}get destroyed(){return this[DESTROYED]}get flowing(){return this[FLOWING]}get paused(){return this[PAUSED]}[BUFFERPUSH](e){this[OBJECTMODE]?this[BUFFERLENGTH]+=1:this[BUFFERLENGTH]+=e.length,this[BUFFER].push(e)}[BUFFERSHIFT](){return this[OBJECTMODE]?--this[BUFFERLENGTH]:this[BUFFERLENGTH]-=this[BUFFER][0].length,this[BUFFER].shift()}[FLUSH](e=!1){do;while(this[FLUSHCHUNK](this[BUFFERSHIFT]())&&this[BUFFER].length);!e&&!this[BUFFER].length&&!this[EOF]&&this.emit(`drain`)}[FLUSHCHUNK](e){return this.emit(`data`,e),this[FLOWING]}pipe(e,n){if(this[DESTROYED])return e;this[DISCARDED]=!1;let r=this[EMITTED_END];return n||={},e===proc.stdout||e===proc.stderr?n.end=!1:n.end=n.end!==!1,n.proxyErrors=!!n.proxyErrors,r?n.end&&e.end():(this[PIPES].push(n.proxyErrors?new PipeProxyErrors(this,e,n):new Pipe(this,e,n)),this[ASYNC]?defer(()=>this[RESUME]()):this[RESUME]()),e}unpipe(e){let t=this[PIPES].find(t=>t.dest===e);t&&(this[PIPES].length===1?(this[FLOWING]&&this[DATALISTENERS]===0&&(this[FLOWING]=!1),this[PIPES]=[]):this[PIPES].splice(this[PIPES].indexOf(t),1),t.unpipe())}addListener(e,t){return this.on(e,t)}on(e,t){let n=super.on(e,t);if(e===`data`)this[DISCARDED]=!1,this[DATALISTENERS]++,!this[PIPES].length&&!this[FLOWING]&&this[RESUME]();else if(e===`readable`&&this[BUFFERLENGTH]!==0)super.emit(`readable`);else if(isEndish(e)&&this[EMITTED_END])super.emit(e),this.removeAllListeners(e);else if(e===`error`&&this[EMITTED_ERROR]){let e=t;this[ASYNC]?defer(()=>e.call(this,this[EMITTED_ERROR])):e.call(this,this[EMITTED_ERROR])}return n}removeListener(e,t){return this.off(e,t)}off(e,t){let n=super.off(e,t);return e===`data`&&(this[DATALISTENERS]=this.listeners(`data`).length,this[DATALISTENERS]===0&&!this[DISCARDED]&&!this[PIPES].length&&(this[FLOWING]=!1)),n}removeAllListeners(e){let t=super.removeAllListeners(e);return(e===`data`||e===void 0)&&(this[DATALISTENERS]=0,!this[DISCARDED]&&!this[PIPES].length&&(this[FLOWING]=!1)),t}get emittedEnd(){return this[EMITTED_END]}[MAYBE_EMIT_END](){!this[EMITTING_END]&&!this[EMITTED_END]&&!this[DESTROYED]&&this[BUFFER].length===0&&this[EOF]&&(this[EMITTING_END]=!0,this.emit(`end`),this.emit(`prefinish`),this.emit(`finish`),this[CLOSED]&&this.emit(`close`),this[EMITTING_END]=!1)}emit(e,...t){let n=t[0];if(e!==`error`&&e!==`close`&&e!==DESTROYED&&this[DESTROYED])return!1;if(e===`data`)return!this[OBJECTMODE]&&!n?!1:this[ASYNC]?(defer(()=>this[EMITDATA](n)),!0):this[EMITDATA](n);if(e===`end`)return this[EMITEND]();if(e===`close`){if(this[CLOSED]=!0,!this[EMITTED_END]&&!this[DESTROYED])return!1;let e=super.emit(`close`);return this.removeAllListeners(`close`),e}else if(e===`error`){this[EMITTED_ERROR]=n,super.emit(ERROR,n);let e=!this[SIGNAL]||this.listeners(`error`).length?super.emit(`error`,n):!1;return this[MAYBE_EMIT_END](),e}else if(e===`resume`){let e=super.emit(`resume`);return this[MAYBE_EMIT_END](),e}else if(e===`finish`||e===`prefinish`){let t=super.emit(e);return this.removeAllListeners(e),t}let r=super.emit(e,...t);return this[MAYBE_EMIT_END](),r}[EMITDATA](e){for(let t of this[PIPES])t.dest.write(e)===!1&&this.pause();let t=this[DISCARDED]?!1:super.emit(`data`,e);return this[MAYBE_EMIT_END](),t}[EMITEND](){return this[EMITTED_END]?!1:(this[EMITTED_END]=!0,this.readable=!1,this[ASYNC]?(defer(()=>this[EMITEND2]()),!0):this[EMITEND2]())}[EMITEND2](){if(this[DECODER]){let e=this[DECODER].end();if(e){for(let t of this[PIPES])t.dest.write(e);this[DISCARDED]||super.emit(`data`,e)}}for(let e of this[PIPES])e.end();let e=super.emit(`end`);return this.removeAllListeners(`end`),e}async collect(){let e=Object.assign([],{dataLength:0});this[OBJECTMODE]||(e.dataLength=0);let t=this.promise();return this.on(`data`,t=>{e.push(t),this[OBJECTMODE]||(e.dataLength+=t.length)}),await t,e}async concat(){if(this[OBJECTMODE])throw Error(`cannot concat in objectMode`);let e=await this.collect();return this[ENCODING]?e.join(``):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,t)=>{this.on(DESTROYED,()=>t(Error(`stream destroyed`))),this.on(`error`,e=>t(e)),this.on(`end`,()=>e())})}[Symbol.asyncIterator](){this[DISCARDED]=!1;let e=!1,t=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return t();let n=this.read();if(n!==null)return Promise.resolve({done:!1,value:n});if(this[EOF])return t();let r,i,a=e=>{this.off(`data`,o),this.off(`end`,s),this.off(DESTROYED,c),t(),i(e)},o=e=>{this.off(`error`,a),this.off(`end`,s),this.off(DESTROYED,c),this.pause(),r({value:e,done:!!this[EOF]})},s=()=>{this.off(`error`,a),this.off(`data`,o),this.off(DESTROYED,c),t(),r({done:!0,value:void 0})},c=()=>a(Error(`stream destroyed`));return new Promise((e,t)=>{i=t,r=e,this.once(DESTROYED,c),this.once(`error`,a),this.once(`end`,s),this.once(`data`,o)})},throw:t,return:t,[Symbol.asyncIterator](){return this},[Symbol.asyncDispose]:async()=>{}}}[Symbol.iterator](){this[DISCARDED]=!1;let e=!1,t=()=>(this.pause(),this.off(ERROR,t),this.off(DESTROYED,t),this.off(`end`,t),e=!0,{done:!0,value:void 0});return this.once(`end`,t),this.once(ERROR,t),this.once(DESTROYED,t),{next:()=>{if(e)return t();let n=this.read();return n===null?t():{done:!1,value:n}},throw:t,return:t,[Symbol.iterator](){return this},[Symbol.dispose]:()=>{}}}destroy(e){if(this[DESTROYED])return e?this.emit(`error`,e):this.emit(DESTROYED),this;this[DESTROYED]=!0,this[DISCARDED]=!0,this[BUFFER].length=0,this[BUFFERLENGTH]=0;let t=this;return typeof t.close==`function`&&!this[CLOSED]&&t.close(),e?this.emit(`error`,e):this.emit(DESTROYED),this}static get isStream(){return exports.isStream}}exports.Minipass=Minipass;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "minipass",
|
|
3
|
+
"version": "7.1.3",
|
|
4
|
+
"main": "./dist/commonjs/index.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./package.json": "./package.json",
|
|
8
|
+
".": {
|
|
9
|
+
"import": {
|
|
10
|
+
"types": "./dist/esm/index.d.ts",
|
|
11
|
+
"default": "./dist/esm/index.js"
|
|
12
|
+
},
|
|
13
|
+
"require": {
|
|
14
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
15
|
+
"default": "./dist/commonjs/index.js"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,`__esModule`,{value:!0}),exports.WriteStreamSync=exports.WriteStream=exports.ReadStreamSync=exports.ReadStream=void 0;const events_1=__importDefault(require(`events`)),fs_1=__importDefault(require(`fs`)),minipass_1=require(`minipass`),writev=fs_1.default.writev,_autoClose=Symbol(`_autoClose`),_close=Symbol(`_close`),_ended=Symbol(`_ended`),_fd=Symbol(`_fd`),_finished=Symbol(`_finished`),_flags=Symbol(`_flags`),_flush=Symbol(`_flush`),_handleChunk=Symbol(`_handleChunk`),_makeBuf=Symbol(`_makeBuf`),_mode=Symbol(`_mode`),_needDrain=Symbol(`_needDrain`),_onerror=Symbol(`_onerror`),_onopen=Symbol(`_onopen`),_onread=Symbol(`_onread`),_onwrite=Symbol(`_onwrite`),_open=Symbol(`_open`),_path=Symbol(`_path`),_pos=Symbol(`_pos`),_queue=Symbol(`_queue`),_read=Symbol(`_read`),_readSize=Symbol(`_readSize`),_reading=Symbol(`_reading`),_remain=Symbol(`_remain`),_size=Symbol(`_size`),_write=Symbol(`_write`),_writing=Symbol(`_writing`),_defaultFlag=Symbol(`_defaultFlag`),_errored=Symbol(`_errored`);class ReadStream extends minipass_1.Minipass{[_errored]=!1;[_fd];[_path];[_readSize];[_reading]=!1;[_size];[_remain];[_autoClose];constructor(e,t){if(t||={},super(t),this.readable=!0,this.writable=!1,typeof e!=`string`)throw TypeError(`path must be a string`);this[_errored]=!1,this[_fd]=typeof t.fd==`number`?t.fd:void 0,this[_path]=e,this[_readSize]=t.readSize||16*1024*1024,this[_reading]=!1,this[_size]=typeof t.size==`number`?t.size:1/0,this[_remain]=this[_size],this[_autoClose]=typeof t.autoClose==`boolean`?t.autoClose:!0,typeof this[_fd]==`number`?this[_read]():this[_open]()}get fd(){return this[_fd]}get path(){return this[_path]}write(){throw TypeError(`this is a readable stream`)}end(){throw TypeError(`this is a readable stream`)}[_open](){fs_1.default.open(this[_path],`r`,(e,t)=>this[_onopen](e,t))}[_onopen](e,t){e?this[_onerror](e):(this[_fd]=t,this.emit(`open`,t),this[_read]())}[_makeBuf](){return Buffer.allocUnsafe(Math.min(this[_readSize],this[_remain]))}[_read](){if(!this[_reading]){this[_reading]=!0;let e=this[_makeBuf]();if(e.length===0)return process.nextTick(()=>this[_onread](null,0,e));fs_1.default.read(this[_fd],e,0,e.length,null,(e,t,n)=>this[_onread](e,t,n))}}[_onread](e,t,n){this[_reading]=!1,e?this[_onerror](e):this[_handleChunk](t,n)&&this[_read]()}[_close](){if(this[_autoClose]&&typeof this[_fd]==`number`){let e=this[_fd];this[_fd]=void 0,fs_1.default.close(e,e=>e?this.emit(`error`,e):this.emit(`close`))}}[_onerror](e){this[_reading]=!0,this[_close](),this.emit(`error`,e)}[_handleChunk](e,t){let n=!1;return this[_remain]-=e,e>0&&(n=super.write(e<t.length?t.subarray(0,e):t)),(e===0||this[_remain]<=0)&&(n=!1,this[_close](),super.end()),n}emit(e,...t){switch(e){case`prefinish`:case`finish`:return!1;case`drain`:return typeof this[_fd]==`number`&&this[_read](),!1;case`error`:return this[_errored]?!1:(this[_errored]=!0,super.emit(e,...t));default:return super.emit(e,...t)}}}exports.ReadStream=ReadStream;class ReadStreamSync extends ReadStream{[_open](){let e=!0;try{this[_onopen](null,fs_1.default.openSync(this[_path],`r`)),e=!1}finally{e&&this[_close]()}}[_read](){let e=!0;try{if(!this[_reading]){this[_reading]=!0;do{let e=this[_makeBuf](),t=e.length===0?0:fs_1.default.readSync(this[_fd],e,0,e.length,null);if(!this[_handleChunk](t,e))break}while(!0);this[_reading]=!1}e=!1}finally{e&&this[_close]()}}[_close](){if(this[_autoClose]&&typeof this[_fd]==`number`){let e=this[_fd];this[_fd]=void 0,fs_1.default.closeSync(e),this.emit(`close`)}}}exports.ReadStreamSync=ReadStreamSync;class WriteStream extends events_1.default{readable=!1;writable=!0;[_errored]=!1;[_writing]=!1;[_ended]=!1;[_queue]=[];[_needDrain]=!1;[_path];[_mode];[_autoClose];[_fd];[_defaultFlag];[_flags];[_finished]=!1;[_pos];constructor(e,t){t||={},super(t),this[_path]=e,this[_fd]=typeof t.fd==`number`?t.fd:void 0,this[_mode]=t.mode===void 0?438:t.mode,this[_pos]=typeof t.start==`number`?t.start:void 0,this[_autoClose]=typeof t.autoClose==`boolean`?t.autoClose:!0;let n=this[_pos]===void 0?`w`:`r+`;this[_defaultFlag]=t.flags===void 0,this[_flags]=t.flags===void 0?n:t.flags,this[_fd]===void 0&&this[_open]()}emit(e,...t){if(e===`error`){if(this[_errored])return!1;this[_errored]=!0}return super.emit(e,...t)}get fd(){return this[_fd]}get path(){return this[_path]}[_onerror](e){this[_close](),this[_writing]=!0,this.emit(`error`,e)}[_open](){fs_1.default.open(this[_path],this[_flags],this[_mode],(e,t)=>this[_onopen](e,t))}[_onopen](e,t){this[_defaultFlag]&&this[_flags]===`r+`&&e&&e.code===`ENOENT`?(this[_flags]=`w`,this[_open]()):e?this[_onerror](e):(this[_fd]=t,this.emit(`open`,t),this[_writing]||this[_flush]())}end(e,t){return e&&this.write(e,t),this[_ended]=!0,!this[_writing]&&!this[_queue].length&&typeof this[_fd]==`number`&&this[_onwrite](null,0),this}write(e,t){return typeof e==`string`&&(e=Buffer.from(e,t)),this[_ended]?(this.emit(`error`,Error(`write() after end()`)),!1):this[_fd]===void 0||this[_writing]||this[_queue].length?(this[_queue].push(e),this[_needDrain]=!0,!1):(this[_writing]=!0,this[_write](e),!0)}[_write](e){fs_1.default.write(this[_fd],e,0,e.length,this[_pos],(e,t)=>this[_onwrite](e,t))}[_onwrite](e,t){e?this[_onerror](e):(this[_pos]!==void 0&&typeof t==`number`&&(this[_pos]+=t),this[_queue].length?this[_flush]():(this[_writing]=!1,this[_ended]&&!this[_finished]?(this[_finished]=!0,this[_close](),this.emit(`finish`)):this[_needDrain]&&(this[_needDrain]=!1,this.emit(`drain`))))}[_flush](){if(this[_queue].length===0)this[_ended]&&this[_onwrite](null,0);else if(this[_queue].length===1)this[_write](this[_queue].pop());else{let e=this[_queue];this[_queue]=[],writev(this[_fd],e,this[_pos],(e,t)=>this[_onwrite](e,t))}}[_close](){if(this[_autoClose]&&typeof this[_fd]==`number`){let e=this[_fd];this[_fd]=void 0,fs_1.default.close(e,e=>e?this.emit(`error`,e):this.emit(`close`))}}}exports.WriteStream=WriteStream;class WriteStreamSync extends WriteStream{[_open](){let e;if(this[_defaultFlag]&&this[_flags]===`r+`)try{e=fs_1.default.openSync(this[_path],this[_flags],this[_mode])}catch(e){if(e?.code===`ENOENT`)return this[_flags]=`w`,this[_open]();throw e}else e=fs_1.default.openSync(this[_path],this[_flags],this[_mode]);this[_onopen](null,e)}[_close](){if(this[_autoClose]&&typeof this[_fd]==`number`){let e=this[_fd];this[_fd]=void 0,fs_1.default.closeSync(e),this.emit(`close`)}}[_write](e){let t=!0;try{this[_onwrite](null,fs_1.default.writeSync(this[_fd],e,0,e.length,this[_pos])),t=!1}finally{if(t)try{this[_close]()}catch{}}}}exports.WriteStreamSync=WriteStreamSync;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@isaacs/fs-minipass",
|
|
3
|
+
"version": "4.0.1",
|
|
4
|
+
"main": "./dist/commonjs/index.js",
|
|
5
|
+
"exports": {
|
|
6
|
+
"./package.json": "./package.json",
|
|
7
|
+
".": {
|
|
8
|
+
"import": {
|
|
9
|
+
"types": "./dist/esm/index.d.ts",
|
|
10
|
+
"default": "./dist/esm/index.js"
|
|
11
|
+
},
|
|
12
|
+
"require": {
|
|
13
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
14
|
+
"default": "./dist/commonjs/index.js"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"type": "module"
|
|
19
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=analyze;const path_1=__importDefault(require(`path`)),estree_walker_1=require(`estree-walker`),pluginutils_1=require(`@rollup/pluginutils`),static_eval_1=require(`./utils/static-eval`),acorn_1=require(`acorn`),bindings_1=__importDefault(require(`bindings`)),ast_helpers_1=require(`./utils/ast-helpers`),glob_1=require(`glob`),get_package_base_1=require(`./utils/get-package-base`),binary_locators_1=require(`./utils/binary-locators`),interop_require_1=require(`./utils/interop-require`),special_cases_1=__importDefault(require(`./utils/special-cases`)),resolve_dependency_js_1=__importDefault(require(`./resolve-dependency.js`)),node_gyp_build_1=__importDefault(require(`node-gyp-build`)),node_pre_gyp_1=__importDefault(require(`@mapbox/node-pre-gyp`)),url_1=require(`url`),acorn=acorn_1.Parser.extend(require(`acorn-import-attributes`).importAttributesOrAssertions),os_1=__importDefault(require(`os`)),url_2=__importDefault(require(`url`)),wrappers_1=require(`./utils/wrappers`),resolve_from_1=__importDefault(require(`resolve-from`)),staticProcess={cwd:()=>cwd,env:{NODE_ENV:static_eval_1.UNKNOWN,[static_eval_1.UNKNOWN]:!0},[static_eval_1.UNKNOWN]:!0},EXPRESS_SET=Symbol(),EXPRESS_ENGINE=Symbol(),NBIND_INIT=Symbol(),SET_ROOT_DIR=Symbol(),PKG_INFO=Symbol(),FS_FN=Symbol(),FS_DIR_FN=Symbol(),BINDINGS=Symbol(),NODE_GYP_BUILD=Symbol(),fsSymbols={access:FS_FN,accessSync:FS_FN,createReadStream:FS_FN,exists:FS_FN,existsSync:FS_FN,fstat:FS_FN,fstatSync:FS_FN,lstat:FS_FN,lstatSync:FS_FN,open:FS_FN,readdir:FS_DIR_FN,readdirSync:FS_DIR_FN,readFile:FS_FN,readFileSync:FS_FN,stat:FS_FN,statSync:FS_FN},fsExtraSymbols={...fsSymbols,pathExists:FS_FN,pathExistsSync:FS_FN,readJson:FS_FN,readJSON:FS_FN,readJsonSync:FS_FN,readJSONSync:FS_FN},MODULE_FN=Symbol(),CREATE_REQUIRE=Symbol(),moduleSymbols={register:MODULE_FN,createRequire:CREATE_REQUIRE},staticModules=Object.assign(Object.create(null),{bindings:{default:BINDINGS},express:{default:function(){return{[static_eval_1.UNKNOWN]:!0,set:EXPRESS_SET,engine:EXPRESS_ENGINE}}},fs:{default:fsSymbols,...fsSymbols},module:{default:moduleSymbols,...moduleSymbols},"fs-extra":{default:fsExtraSymbols,...fsExtraSymbols},"graceful-fs":{default:fsSymbols,...fsSymbols},process:{default:staticProcess,...staticProcess},path:{default:{}},os:{default:os_1.default,...os_1.default},url:{default:url_2.default,...url_2.default},"@mapbox/node-pre-gyp":{default:node_pre_gyp_1.default,...node_pre_gyp_1.default},"node-pre-gyp":binary_locators_1.pregyp,"node-pre-gyp/lib/pre-binding":binary_locators_1.pregyp,"node-pre-gyp/lib/pre-binding.js":binary_locators_1.pregyp,"node-gyp-build":{default:NODE_GYP_BUILD},"@aminya/node-gyp-build":{default:NODE_GYP_BUILD},nbind:{init:NBIND_INIT,default:{init:NBIND_INIT}},"resolve-from":{default:resolve_from_1.default},"strong-globalize":{default:{SetRootDir:SET_ROOT_DIR},SetRootDir:SET_ROOT_DIR},pkginfo:{default:PKG_INFO}}),globalBindings={_interopRequireDefault:interop_require_1.normalizeDefaultRequire,_interopRequireWildcard:interop_require_1.normalizeWildcardRequire,__importDefault:interop_require_1.normalizeDefaultRequire,__importStar:interop_require_1.normalizeWildcardRequire,MONGOOSE_DRIVER_PATH:void 0,URL:url_1.URL,Object:{assign:Object.assign}};globalBindings.global=globalBindings.GLOBAL=globalBindings.globalThis=globalBindings;const TRIGGER=Symbol();binary_locators_1.pregyp.find[TRIGGER]=!0;const staticPath=staticModules.path;Object.keys(path_1.default).forEach(e=>{let n=path_1.default[e];if(typeof n==`function`){let t=function e(){return n.apply(e,arguments)};t[TRIGGER]=!0,staticPath[e]=staticPath.default[e]=t}else staticPath[e]=staticPath.default[e]=n}),staticPath.resolve=staticPath.default.resolve=function(...e){return path_1.default.resolve.apply(this,[cwd,...e])},staticPath.resolve[TRIGGER]=!0;const excludeAssetExtensions=new Set([`.h`,`.cmake`,`.c`,`.cpp`]),excludeAssetFiles=new Set([`CHANGELOG.md`,`README.md`,`readme.md`,`changelog.md`]);let cwd;const absoluteRegEx=/^\/[^\/]+|^[a-z]:[\\/][^\\/]+/i;function isAbsolutePathOrUrl(e){if(e instanceof url_1.URL)return e.protocol===`file:`;if(typeof e==`string`){if(e.startsWith(`file:`))try{return new url_1.URL(e),!0}catch{return!1}return absoluteRegEx.test(e)}return!1}const BOUND_REQUIRE=Symbol(),repeatGlobRegEx=/([\/\\]\*\*[\/\\]\*)+/g;async function analyze(e,a,c){let l=new Set,u=new Set,d=new Set,f=path_1.default.dirname(e);cwd=c.cwd;let p=(0,get_package_base_1.getPackageBase)(e),m=e=>{if(!c.analysis.emitGlobs)return;e=e.replaceAll(path_1.default.sep,path_1.default.posix.sep);let n=e.indexOf(static_eval_1.WILDCARD),r=n===-1?e.length:e.lastIndexOf(path_1.default.posix.sep,n),a=e.substring(0,r),o=e.slice(r),s=o.replace(static_eval_1.wildcardRegEx,(e,n)=>o[n-1]===path_1.default.posix.sep?`**/*`:`*`).replace(repeatGlobRegEx,`/**/*`)||`/**/*`;c.ignoreFn(path_1.default.relative(c.base,a+s))||(h=h.then(async()=>{c.log&&console.log(`Globbing `+a+s),(await(0,glob_1.glob)(a+s,{mark:!0,ignore:a+`/**/node_modules/**/*`,dot:!0,nodir:!0})).filter(e=>!excludeAssetExtensions.has(path_1.default.extname(e))&&!excludeAssetFiles.has(path_1.default.basename(e))).forEach(e=>l.add(e))}))},h=Promise.resolve();a=a.replace(/^#![^\n\r]*[\r\n]/,``);let g,_=!1;try{g=acorn.parse(a,{ecmaVersion:`latest`,allowReturnOutsideFunction:!0}),_=!1}catch(t){t&&t.message&&t.message.includes(`sourceType: module`)||c.warnings.add(Error(`Failed to parse ${e} as script:\n${t&&t.message}`))}if(!g)try{g=acorn.parse(a,{ecmaVersion:`latest`,sourceType:`module`,allowAwaitOutsideFunction:!0}),_=!0}catch(t){return c.warnings.add(Error(`Failed to parse ${e} as module:\n${t&&t.message}`)),{assets:l,deps:u,imports:d,isESM:!1}}let v=(0,url_1.pathToFileURL)(e).href,y=Object.assign(Object.create(null),{__dirname:{shadowDepth:0,value:{value:path_1.default.resolve(e,`..`)}},__filename:{shadowDepth:0,value:{value:e}},process:{shadowDepth:0,value:{value:staticProcess}}});(!_||c.mixedModules)&&(y.require={shadowDepth:0,value:{value:{[static_eval_1.FUNCTION](e){return u.add(e),staticModules[e.startsWith(`node:`)?e.slice(5):e].default},resolve(t){return(0,resolve_dependency_js_1.default)(t,e,c)}}}},y.require.value.value.resolve[TRIGGER]=!0);function b(e,t){e===`require`&&`value`in t&&t.value!==BOUND_REQUIRE||(y[e]={shadowDepth:0,value:t})}function x(e){let t=y[e];if(t&&t.shadowDepth===0)return t.value}function S(e){let t=y[e];return t&&t.shadowDepth===0}if((_||c.mixedModules)&&isAst(g))for(let e of g.body)if(e.type===`ImportDeclaration`){let t=String(e.source.value);u.add(t);let n=staticModules[t.startsWith(`node:`)?t.slice(5):t];if(n)for(let t of e.specifiers)t.type===`ImportNamespaceSpecifier`?b(t.local.name,{value:n}):t.type===`ImportDefaultSpecifier`&&`default`in n?b(t.local.name,{value:n.default}):t.type===`ImportSpecifier`&&t.imported.name in n&&b(t.local.name,{value:n[t.imported.name]})}else (e.type===`ExportNamedDeclaration`||e.type===`ExportAllDeclaration`)&&e.source&&u.add(String(e.source.value));async function C(e,t=!0){let n=Object.create(null);return Object.keys(globalBindings).forEach(e=>{n[e]={value:globalBindings[e]}}),Object.keys(y).forEach(e=>{n[e]=x(e)}),n[`import.meta`]={url:v},await(0,static_eval_1.evaluate)(e,n,t)}let w,T,E=!1;function D(e){if(!c.analysis.emitGlobs||!e.startsWith(`./`)&&!e.startsWith(`../`))return;e=path_1.default.resolve(f,e).replaceAll(path_1.default.sep,path_1.default.posix.sep);let n=e.indexOf(static_eval_1.WILDCARD),r=n===-1?e.length:e.lastIndexOf(path_1.default.posix.sep,n),a=e.substring(0,r),o=e.slice(r),s=o.replace(static_eval_1.wildcardRegEx,(e,n)=>o[n-1]===path_1.default.posix.sep?`**/*`:`*`)||`/**/*`;s.endsWith(`*`)||(s+=`?(`+(c.ts?`.ts|.tsx|`:``)+`.js|.json|.node)`),!c.ignoreFn(path_1.default.relative(c.base,a+s))&&(h=h.then(async()=>{c.log&&console.log(`Globbing `+a+s),(await(0,glob_1.glob)(a+s,{mark:!0,ignore:a+`/**/node_modules/**/*`,nodir:!0})).filter(e=>!excludeAssetExtensions.has(path_1.default.extname(e))&&!excludeAssetFiles.has(path_1.default.basename(e))).forEach(e=>u.add(e))}))}async function O(e,t=!1){if(e.type===`ConditionalExpression`){await O(e.consequent,t),await O(e.alternate,t);return}if(e.type===`LogicalExpression`){await O(e.left,t),await O(e.right,t);return}let n=await C(e,!0);if(!n)return;function r(e){(t?d:u).add(e)}`value`in n&&typeof n.value==`string`?n.wildcards?n.wildcards.length>=1&&D(n.value):r(n.value):(`ifTrue`in n&&typeof n.ifTrue==`string`&&r(n.ifTrue),`else`in n&&typeof n.else==`string`&&r(n.else))}let k=(0,pluginutils_1.attachScopes)(g,`scope`);isAst(g)&&((0,wrappers_1.handleWrappers)(g),await(0,special_cases_1.default)({id:e,ast:g,emitDependency:e=>u.add(e),emitAsset:e=>l.add(e),emitAssetDirectory:m,job:c}));async function A(e,t){if(!w)throw Error(`Internal error: No staticChildNode for backtrack.`);let n=await C(e,!0);if(n&&(`value`in n&&typeof n.value!=`symbol`||`ifTrue`in n&&typeof n.ifTrue!=`symbol`&&typeof n.else!=`symbol`)){T=n,w=e,t&&t.skip();return}await P()}return await(0,estree_walker_1.asyncWalk)(g,{async enter(n,r){let i=n,a=r;if(i.scope){k=i.scope;for(let e in i.scope.declarations)e in y&&y[e].shadowDepth++}if(!w&&a){if(i.type===`Identifier`){if((0,ast_helpers_1.isIdentifierRead)(i,a)&&c.analysis.computeFileReferences){let e;(typeof(e=x(i.name)?.value)==`string`&&e.match(absoluteRegEx)||e&&(typeof e==`function`||typeof e==`object`)&&e[TRIGGER])&&(T={value:typeof e==`string`?e:void 0},w=i,await A(a,this))}}else if(c.analysis.computeFileReferences&&i.type===`MemberExpression`&&i.object.type===`MetaProperty`&&i.object.meta.name===`import`&&i.object.property.name===`meta`&&(i.property.computed?i.property.value:i.property.name)===`url`)T={value:v},w=i,await A(a,this);else if(i.type===`ImportExpression`){await O(i.source,!0);return}else if(i.type===`CallExpression`){if((!_||c.mixedModules)&&i.callee.type===`Identifier`&&i.arguments.length){if(i.callee.name===`require`&&y.require&&y.require.shadowDepth===0){await O(i.arguments[0]);return}}else if((!_||c.mixedModules)&&i.callee.type===`MemberExpression`&&i.callee.object.type===`Identifier`&&i.callee.object.name===`module`&&!(`module`in y)&&i.callee.property.type===`Identifier`&&!i.callee.computed&&i.callee.property.name===`require`&&i.arguments.length){await O(i.arguments[0]);return}else if((!_||c.mixedModules)&&i.callee.type===`MemberExpression`&&i.callee.object.type===`Identifier`&&i.callee.object.name===`require`&&y.require&&y.require.shadowDepth===0&&i.callee.property.type===`Identifier`&&!i.callee.computed&&i.callee.property.name===`resolve`&&i.arguments.length){await O(i.arguments[0]);return}let n=c.analysis.evaluatePureExpressions&&await C(i.callee,!1);if(n&&`value`in n&&typeof n.value==`function`&&n.value[TRIGGER]&&c.analysis.computeFileReferences)T=await C(i,!0),T&&a&&(w=i,await A(a,this));else if(n&&`value`in n&&typeof n.value==`symbol`)switch(n.value){case BOUND_REQUIRE:i.arguments.length===1&&i.arguments[0].type===`Literal`&&i.callee.type===`Identifier`&&(!y.require||y.require.shadowDepth===0)&&await O(i.arguments[0]);break;case BINDINGS:if(i.arguments.length){let e=await C(i.arguments[0],!1);if(e&&`value`in e&&e.value){let t;typeof e.value==`object`?t=e.value:typeof e.value==`string`&&(t={bindings:e.value}),t.path||=!0,t.module_root=p;let n;try{n=(0,bindings_1.default)(t)}catch{}n&&(T={value:n},w=i,await P())}}break;case NODE_GYP_BUILD:if(i.arguments.length){let e=await C(i.arguments[0],!1);if(e&&`value`in e&&e.value){let t=e.value,n;try{let e=i?.callee?.arguments?.[0]?.value||`node-gyp-build`,r=(0,resolve_from_1.default)(t,e);n=require(r).path(t)}catch{try{n=node_gyp_build_1.default.path(t)}catch{}}n&&(T={value:n},w=i,await P())}}break;case NBIND_INIT:if(i.arguments.length){let e=await C(i.arguments[0],!1);if(e&&`value`in e&&(typeof e.value==`string`||e.value===void 0)){let n=(0,binary_locators_1.nbind)(e.value);if(n&&n.path)return u.add(path_1.default.relative(f,n.path).replace(/\\/g,`/`)),this.skip()}}break;case EXPRESS_SET:if(i.arguments.length===2&&i.arguments[0].type===`Literal`&&i.arguments[0].value===`view engine`&&!E)return await O(i.arguments[1]),this.skip();break;case EXPRESS_ENGINE:E=!0;break;case FS_FN:case FS_DIR_FN:if(i.arguments[0]&&c.analysis.computeFileReferences&&(T=await C(i.arguments[0],!0),T))return w=i.arguments[0],n.value===FS_DIR_FN&&i.arguments[0].type===`Identifier`&&i.arguments[0].name===`__dirname`?m(f):await A(a,this),this.skip();break;case SET_ROOT_DIR:if(i.arguments[0]){let e=await C(i.arguments[0],!1);return e&&`value`in e&&e.value&&m(e.value+`/intl`),this.skip()}break;case PKG_INFO:let r=path_1.default.resolve(e,`../package.json`),s=path_1.default.resolve(`/package.json`);for(;r!==s&&await c.stat(r)===null;)r=path_1.default.resolve(r,`../../package.json`);r!==s&&l.add(r);break;case MODULE_FN:if(i.arguments.length&&i.arguments[0].type===`Literal`){let e=i.arguments[0].value;if(e.startsWith(`.`)){let n=i.arguments.length>1?await C(i.arguments[1]):void 0;if(n&&`value`in n){let r=n.value instanceof url_1.URL?n.value.href:typeof n.value==`string`?n.value:n.value.parentURL,i=new url_1.URL(e,r).href,a=v.slice(0,v.lastIndexOf(`/`)),o=path_1.default.relative(a,i),s=o.startsWith(`.`)?o:`./`+o;d.add(s)}}else d.add(e)}break}}else if(i.type===`VariableDeclaration`&&a&&!(0,ast_helpers_1.isVarLoop)(a)&&c.analysis.evaluatePureExpressions)for(let e of i.declarations){if(!e.init)continue;let t=await C(e.init,!0);if(t){if(e.id.type===`Identifier`)b(e.id.name,t);else if(e.id.type===`ObjectPattern`&&`value`in t)for(let n of e.id.properties)n.type!==`Property`||n.key.type!==`Identifier`||n.value.type!==`Identifier`||typeof t.value!=`object`||t.value===null||!(n.key.name in t.value)||b(n.value.name,{value:t.value[n.key.name]});!(`value`in t)&&isAbsolutePathOrUrl(t.ifTrue)&&isAbsolutePathOrUrl(t.else)&&(T=t,w=e.init,await P())}}else if(i.type===`AssignmentExpression`&&a&&!(0,ast_helpers_1.isLoop)(a)&&c.analysis.evaluatePureExpressions){if(!S(i.left.name)){let e=await C(i.right,!1);if(e&&`value`in e){if(i.left.type===`Identifier`)b(i.left.name,e);else if(i.left.type===`ObjectPattern`)for(let t of i.left.properties)t.type!==`Property`||t.key.type!==`Identifier`||t.value.type!==`Identifier`||typeof e.value!=`object`||e.value===null||!(t.key.name in e.value)||b(t.value.name,{value:e.value[t.key.name]});isAbsolutePathOrUrl(e.value)&&(T=e,w=i.right,await P())}}}else if((!_||c.mixedModules)&&(i.type===`FunctionDeclaration`||i.type===`FunctionExpression`||i.type===`ArrowFunctionExpression`)&&(i.arguments||i.params)[0]&&(i.arguments||i.params)[0].type===`Identifier`){let e,t;if((i.type===`ArrowFunctionExpression`||i.type===`FunctionExpression`)&&a&&a.type===`VariableDeclarator`&&a.id.type===`Identifier`?(e=a.id,t=i.arguments||i.params):i.id&&(e=i.id,t=i.arguments||i.params),e&&i.body.body){let n,r=!1;for(let e=0;e<i.body.body.length;e++)if(i.body.body[e].type===`VariableDeclaration`&&!n&&(n=i.body.body[e].declarations.find(e=>e&&e.id&&e.id.type===`Identifier`&&e.init&&e.init.type===`CallExpression`&&e.init.callee.type===`Identifier`&&e.init.callee.name===`require`&&y.require.shadowDepth===0&&e.init.arguments[0]&&e.init.arguments[0].type===`Identifier`&&e.init.arguments[0].name===t[0].name)),n&&i.body.body[e].type===`ReturnStatement`&&i.body.body[e].argument&&i.body.body[e].argument.type===`Identifier`&&i.body.body[e].argument.name===n.id.name){r=!0;break}r&&b(e.name,{value:BOUND_REQUIRE})}}if(i.type===`CallExpression`&&i.callee.type===`MemberExpression`&&i.callee.object.type===`Identifier`&&i.callee.object.name===`module`&&i.callee.property.type===`Identifier`&&i.callee.property.name===`createRequire`&&a.type===`VariableDeclarator`&&a.id.type===`Identifier`){let e=a.id.name;b(e,{value:BOUND_REQUIRE})}if(i.type===`CallExpression`&&i.callee.type===`Identifier`&&i.callee.name===`createRequire`){let e=x(`createRequire`);if(e&&`value`in e&&e.value===CREATE_REQUIRE&&a.type===`VariableDeclarator`&&a.id.type===`Identifier`){let e=a.id.name;b(e,{value:BOUND_REQUIRE})}}}},async leave(e,t){let n=e,r=t;if(n.scope){k.parent&&(k=k.parent);for(let e in n.scope.declarations)e in y&&(y[e].shadowDepth>0?y[e].shadowDepth--:delete y[e])}w&&r&&await A(r,this)}}),await h,{assets:l,deps:u,imports:d,isESM:_};async function j(n){let r=n.indexOf(static_eval_1.WILDCARD),a=r===-1?n.length:n.lastIndexOf(path_1.default.sep,r),o=n.substring(0,a);try{var s=await c.stat(o);if(s===null)throw Error(`file not found`)}catch{return}if(!(r!==-1&&s.isFile())){if(p){let r=e.substring(0,e.indexOf(path_1.default.sep+`node_modules`))+path_1.default.sep+`node_modules`+path_1.default.sep;if(!n.startsWith(r)){c.log&&console.log(`Skipping asset emission of `+n+` for `+e+` as it is outside the package base `+p);return}}if(s.isFile()){if(c.ignoreFn(path_1.default.relative(c.base,n)))return;l.add(n)}else if(s.isDirectory()){if(c.ignoreFn(path_1.default.relative(c.base,n)))return;M(n)&&m(n)}}}function M(n){let r=``;if(n.endsWith(path_1.default.sep)?r=path_1.default.sep:n.endsWith(path_1.default.sep+static_eval_1.WILDCARD)?r=path_1.default.sep+static_eval_1.WILDCARD:n.endsWith(static_eval_1.WILDCARD)&&(r=static_eval_1.WILDCARD),n===f+r||n===cwd+r||n.endsWith(path_1.default.sep+`node_modules`+r)||f.startsWith(n.slice(0,n.length-r.length)+path_1.default.sep))return!1;if(p){let r=e.substring(0,e.indexOf(path_1.default.sep+`node_modules`))+path_1.default.sep+`node_modules`+path_1.default.sep;if(!n.startsWith(r))return c.log&&console.log(`Skipping asset emission of `+n.replace(static_eval_1.wildcardRegEx,`*`)+` for `+e+` as it is outside the package base `+p),!1}return!0}function N(e){return e instanceof url_1.URL?(0,url_1.fileURLToPath)(e):e.startsWith(`file:`)?(0,url_1.fileURLToPath)(new url_1.URL(e)):path_1.default.resolve(e)}async function P(){if(T){if(`value`in T&&isAbsolutePathOrUrl(T.value))try{await j(N(T.value))}catch{}else if(`ifTrue`in T&&`else`in T&&isAbsolutePathOrUrl(T.ifTrue)&&isAbsolutePathOrUrl(T.else)){let e;try{e=N(T.ifTrue)}catch{}let t;try{t=N(T.else)}catch{}e&&await j(e),t&&await j(t)}else if(w&&w.type===`ArrayExpression`&&`value`in T&&T.value instanceof Array)for(let e of T.value)try{await j(N(e))}catch{}w=T=void 0}}}function isAst(e){return`body`in e}
|
|
1
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,`__esModule`,{value:!0}),exports.default=analyze;const path_1=__importDefault(require(`path`)),estree_walker_1=require(`estree-walker`),pluginutils_1=require(`@rollup/pluginutils`),static_eval_1=require(`./utils/static-eval`),acorn_1=require(`acorn`),bindings_1=__importDefault(require(`bindings`)),ast_helpers_1=require(`./utils/ast-helpers`),glob_1=require(`glob`),get_package_base_1=require(`./utils/get-package-base`),binary_locators_1=require(`./utils/binary-locators`),interop_require_1=require(`./utils/interop-require`),special_cases_1=__importDefault(require(`./utils/special-cases`)),resolve_dependency_js_1=__importDefault(require(`./resolve-dependency.js`)),node_gyp_build_1=__importDefault(require(`node-gyp-build`)),node_pre_gyp_1=__importDefault(require(`@mapbox/node-pre-gyp`)),url_1=require(`url`),acorn=acorn_1.Parser.extend(require(`acorn-import-attributes`).importAttributesOrAssertions),os_1=__importDefault(require(`os`)),url_2=__importDefault(require(`url`)),wrappers_1=require(`./utils/wrappers`),resolve_from_1=__importDefault(require(`resolve-from`)),staticProcess={cwd:()=>cwd,env:{NODE_ENV:static_eval_1.UNKNOWN,[static_eval_1.UNKNOWN]:!0},[static_eval_1.UNKNOWN]:!0},EXPRESS_SET=Symbol(),EXPRESS_ENGINE=Symbol(),NBIND_INIT=Symbol(),SET_ROOT_DIR=Symbol(),PINO_TRANSPORT=Symbol(),PKG_INFO=Symbol(),FS_FN=Symbol(),FS_DIR_FN=Symbol(),BINDINGS=Symbol(),NODE_GYP_BUILD=Symbol(),fsSymbols={access:FS_FN,accessSync:FS_FN,createReadStream:FS_FN,exists:FS_FN,existsSync:FS_FN,fstat:FS_FN,fstatSync:FS_FN,lstat:FS_FN,lstatSync:FS_FN,open:FS_FN,readdir:FS_DIR_FN,readdirSync:FS_DIR_FN,readFile:FS_FN,readFileSync:FS_FN,stat:FS_FN,statSync:FS_FN},fsExtraSymbols={...fsSymbols,pathExists:FS_FN,pathExistsSync:FS_FN,readJson:FS_FN,readJSON:FS_FN,readJsonSync:FS_FN,readJSONSync:FS_FN},MODULE_FN=Symbol(),CREATE_REQUIRE=Symbol(),moduleSymbols={register:MODULE_FN,createRequire:CREATE_REQUIRE},staticModules=Object.assign(Object.create(null),{bindings:{default:BINDINGS},express:{default:function(){return{[static_eval_1.UNKNOWN]:!0,set:EXPRESS_SET,engine:EXPRESS_ENGINE}}},fs:{default:fsSymbols,...fsSymbols},module:{default:moduleSymbols,...moduleSymbols},"fs-extra":{default:fsExtraSymbols,...fsExtraSymbols},"graceful-fs":{default:fsSymbols,...fsSymbols},process:{default:staticProcess,...staticProcess},path:{default:{}},os:{default:os_1.default,...os_1.default},url:{default:url_2.default,...url_2.default},"@mapbox/node-pre-gyp":{default:node_pre_gyp_1.default,...node_pre_gyp_1.default},"node-pre-gyp":binary_locators_1.pregyp,"node-pre-gyp/lib/pre-binding":binary_locators_1.pregyp,"node-pre-gyp/lib/pre-binding.js":binary_locators_1.pregyp,"node-gyp-build":{default:NODE_GYP_BUILD},"@aminya/node-gyp-build":{default:NODE_GYP_BUILD},nbind:{init:NBIND_INIT,default:{init:NBIND_INIT}},"resolve-from":{default:resolve_from_1.default},"strong-globalize":{default:{SetRootDir:SET_ROOT_DIR},SetRootDir:SET_ROOT_DIR},pkginfo:{default:PKG_INFO},pino:{default:{[static_eval_1.UNKNOWN]:!0,transport:PINO_TRANSPORT},transport:PINO_TRANSPORT}}),globalBindings={_interopRequireDefault:interop_require_1.normalizeDefaultRequire,_interopRequireWildcard:interop_require_1.normalizeWildcardRequire,__importDefault:interop_require_1.normalizeDefaultRequire,__importStar:interop_require_1.normalizeWildcardRequire,MONGOOSE_DRIVER_PATH:void 0,URL:url_1.URL,Object:{assign:Object.assign}};globalBindings.global=globalBindings.GLOBAL=globalBindings.globalThis=globalBindings;const TRIGGER=Symbol();binary_locators_1.pregyp.find[TRIGGER]=!0;const staticPath=staticModules.path;Object.keys(path_1.default).forEach(e=>{let n=path_1.default[e];if(typeof n==`function`){let t=function e(){return n.apply(e,arguments)};t[TRIGGER]=!0,staticPath[e]=staticPath.default[e]=t}else staticPath[e]=staticPath.default[e]=n}),staticPath.resolve=staticPath.default.resolve=function(...e){return path_1.default.resolve.apply(this,[cwd,...e])},staticPath.resolve[TRIGGER]=!0;const excludeAssetExtensions=new Set([`.h`,`.cmake`,`.c`,`.cpp`]),excludeAssetFiles=new Set([`CHANGELOG.md`,`README.md`,`readme.md`,`changelog.md`]);let cwd;const absoluteRegEx=/^\/[^\/]+|^[a-z]:[\\/][^\\/]+/i;function isAbsolutePathOrUrl(e){if(e instanceof url_1.URL)return e.protocol===`file:`;if(typeof e==`string`){if(e.startsWith(`file:`))try{return new url_1.URL(e),!0}catch{return!1}return absoluteRegEx.test(e)}return!1}const BOUND_REQUIRE=Symbol(),repeatGlobRegEx=/([\/\\]\*\*[\/\\]\*)+/g;async function analyze(e,a,c){let l=new Set,u=new Set,d=new Set,f=path_1.default.dirname(e);cwd=c.cwd;let p=(0,get_package_base_1.getPackageBase)(e),m=e=>{if(!c.analysis.emitGlobs)return;e=e.replaceAll(path_1.default.sep,path_1.default.posix.sep);let n=e.indexOf(static_eval_1.WILDCARD),r=n===-1?e.length:e.lastIndexOf(path_1.default.posix.sep,n),a=e.substring(0,r),o=e.slice(r),s=o.replace(static_eval_1.wildcardRegEx,(e,n)=>o[n-1]===path_1.default.posix.sep?`**/*`:`*`).replace(repeatGlobRegEx,`/**/*`)||`/**/*`;c.ignoreFn(path_1.default.relative(c.base,a+s))||(h=h.then(async()=>{c.log&&console.log(`Globbing `+a+s),(await(0,glob_1.glob)(a+s,{mark:!0,ignore:a+`/**/node_modules/**/*`,dot:!0,nodir:!0})).filter(e=>!excludeAssetExtensions.has(path_1.default.extname(e))&&!excludeAssetFiles.has(path_1.default.basename(e))).forEach(e=>l.add(e))}))},h=Promise.resolve();a=a.replace(/^#![^\n\r]*[\r\n]/,``);let g,_=!1;try{g=acorn.parse(a,{ecmaVersion:`latest`,allowReturnOutsideFunction:!0}),_=!1}catch(t){t&&t.message&&t.message.includes(`sourceType: module`)||c.warnings.add(Error(`Failed to parse ${e} as script:\n${t&&t.message}`))}if(!g)try{g=acorn.parse(a,{ecmaVersion:`latest`,sourceType:`module`,allowAwaitOutsideFunction:!0}),_=!0}catch(t){return c.warnings.add(Error(`Failed to parse ${e} as module:\n${t&&t.message}`)),{assets:l,deps:u,imports:d,isESM:!1}}let v=(0,url_1.pathToFileURL)(e).href,y=Object.assign(Object.create(null),{__dirname:{shadowDepth:0,value:{value:path_1.default.resolve(e,`..`)}},__filename:{shadowDepth:0,value:{value:e}},process:{shadowDepth:0,value:{value:staticProcess}}});(!_||c.mixedModules)&&(y.require={shadowDepth:0,value:{value:{[static_eval_1.FUNCTION](e){return u.add(e),staticModules[e.startsWith(`node:`)?e.slice(5):e].default},resolve(t){return(0,resolve_dependency_js_1.default)(t,e,c)}}}},y.require.value.value.resolve[TRIGGER]=!0);function b(e,t){e===`require`&&`value`in t&&t.value!==BOUND_REQUIRE||(y[e]={shadowDepth:0,value:t})}function x(e){let t=y[e];if(t&&t.shadowDepth===0)return t.value}function S(e){let t=y[e];return t&&t.shadowDepth===0}if((_||c.mixedModules)&&isAst(g))for(let e of g.body)if(e.type===`ImportDeclaration`){let t=String(e.source.value);u.add(t);let n=staticModules[t.startsWith(`node:`)?t.slice(5):t];if(n)for(let t of e.specifiers)t.type===`ImportNamespaceSpecifier`?b(t.local.name,{value:n}):t.type===`ImportDefaultSpecifier`&&`default`in n?b(t.local.name,{value:n.default}):t.type===`ImportSpecifier`&&t.imported.name in n&&b(t.local.name,{value:n[t.imported.name]})}else (e.type===`ExportNamedDeclaration`||e.type===`ExportAllDeclaration`)&&e.source&&u.add(String(e.source.value));async function C(e,t=!0){let n=Object.create(null);return Object.keys(globalBindings).forEach(e=>{n[e]={value:globalBindings[e]}}),Object.keys(y).forEach(e=>{n[e]=x(e)}),n[`import.meta`]={url:v},await(0,static_eval_1.evaluate)(e,n,t)}let w,T,E=!1;function D(e){if(!c.analysis.emitGlobs||!e.startsWith(`./`)&&!e.startsWith(`../`))return;e=path_1.default.resolve(f,e).replaceAll(path_1.default.sep,path_1.default.posix.sep);let n=e.indexOf(static_eval_1.WILDCARD),r=n===-1?e.length:e.lastIndexOf(path_1.default.posix.sep,n),a=e.substring(0,r),o=e.slice(r),s=o.replace(static_eval_1.wildcardRegEx,(e,n)=>o[n-1]===path_1.default.posix.sep?`**/*`:`*`)||`/**/*`;s.endsWith(`*`)||(s+=`?(`+(c.ts?`.ts|.tsx|`:``)+`.js|.json|.node)`),!c.ignoreFn(path_1.default.relative(c.base,a+s))&&(h=h.then(async()=>{c.log&&console.log(`Globbing `+a+s),(await(0,glob_1.glob)(a+s,{mark:!0,ignore:a+`/**/node_modules/**/*`,nodir:!0})).filter(e=>!excludeAssetExtensions.has(path_1.default.extname(e))&&!excludeAssetFiles.has(path_1.default.basename(e))).forEach(e=>u.add(e))}))}async function O(e,t=!1){if(e.type===`ConditionalExpression`){await O(e.consequent,t),await O(e.alternate,t);return}if(e.type===`LogicalExpression`){await O(e.left,t),await O(e.right,t);return}let n=await C(e,!0);if(!n)return;function r(e){(t?d:u).add(e)}`value`in n&&typeof n.value==`string`?n.wildcards?n.wildcards.length>=1&&D(n.value):r(n.value):(`ifTrue`in n&&typeof n.ifTrue==`string`&&r(n.ifTrue),`else`in n&&typeof n.else==`string`&&r(n.else))}let k=(0,pluginutils_1.attachScopes)(g,`scope`);isAst(g)&&((0,wrappers_1.handleWrappers)(g),await(0,special_cases_1.default)({id:e,ast:g,emitDependency:e=>u.add(e),emitAsset:e=>l.add(e),emitAssetDirectory:m,job:c}));async function A(e,t){if(!w)throw Error(`Internal error: No staticChildNode for backtrack.`);let n=await C(e,!0);if(n&&(`value`in n&&typeof n.value!=`symbol`||`ifTrue`in n&&typeof n.ifTrue!=`symbol`&&typeof n.else!=`symbol`)){T=n,w=e,t&&t.skip();return}await P()}return await(0,estree_walker_1.asyncWalk)(g,{async enter(n,r){let i=n,a=r;if(i.scope){k=i.scope;for(let e in i.scope.declarations)e in y&&y[e].shadowDepth++}if(!w&&a){if(i.type===`Identifier`){if((0,ast_helpers_1.isIdentifierRead)(i,a)&&c.analysis.computeFileReferences){let e;(typeof(e=x(i.name)?.value)==`string`&&e.match(absoluteRegEx)||e&&(typeof e==`function`||typeof e==`object`)&&e[TRIGGER])&&(T={value:typeof e==`string`?e:void 0},w=i,await A(a,this))}}else if(c.analysis.computeFileReferences&&i.type===`MemberExpression`&&i.object.type===`MetaProperty`&&i.object.meta.name===`import`&&i.object.property.name===`meta`&&(i.property.computed?i.property.value:i.property.name)===`url`)T={value:v},w=i,await A(a,this);else if(i.type===`ImportExpression`){await O(i.source,!0);return}else if(i.type===`CallExpression`){if((!_||c.mixedModules)&&i.callee.type===`Identifier`&&i.arguments.length){if(i.callee.name===`require`&&y.require&&y.require.shadowDepth===0){await O(i.arguments[0]);return}}else if((!_||c.mixedModules)&&i.callee.type===`MemberExpression`&&i.callee.object.type===`Identifier`&&i.callee.object.name===`module`&&!(`module`in y)&&i.callee.property.type===`Identifier`&&!i.callee.computed&&i.callee.property.name===`require`&&i.arguments.length){await O(i.arguments[0]);return}else if((!_||c.mixedModules)&&i.callee.type===`MemberExpression`&&i.callee.object.type===`Identifier`&&i.callee.object.name===`require`&&y.require&&y.require.shadowDepth===0&&i.callee.property.type===`Identifier`&&!i.callee.computed&&i.callee.property.name===`resolve`&&i.arguments.length){await O(i.arguments[0]);return}let n=c.analysis.evaluatePureExpressions&&await C(i.callee,!1);if(n&&`value`in n&&typeof n.value==`function`&&n.value[TRIGGER]&&c.analysis.computeFileReferences)T=await C(i,!0),T&&a&&(w=i,await A(a,this));else if(n&&`value`in n&&typeof n.value==`symbol`)switch(n.value){case BOUND_REQUIRE:i.arguments.length===1&&i.arguments[0].type===`Literal`&&i.callee.type===`Identifier`&&(!y.require||y.require.shadowDepth===0)&&await O(i.arguments[0]);break;case BINDINGS:if(i.arguments.length){let e=await C(i.arguments[0],!1);if(e&&`value`in e&&e.value){let t;typeof e.value==`object`?t=e.value:typeof e.value==`string`&&(t={bindings:e.value}),t.path||=!0,t.module_root=p;let n;try{n=(0,bindings_1.default)(t)}catch{}n&&(T={value:n},w=i,await P())}}break;case NODE_GYP_BUILD:if(i.arguments.length){let e=await C(i.arguments[0],!1);if(e&&`value`in e&&e.value){let t=e.value,n;try{let e=i?.callee?.arguments?.[0]?.value||`node-gyp-build`,r=(0,resolve_from_1.default)(t,e);n=require(r).path(t)}catch{try{n=node_gyp_build_1.default.path(t)}catch{}}n&&(T={value:n},w=i,await P())}}break;case NBIND_INIT:if(i.arguments.length){let e=await C(i.arguments[0],!1);if(e&&`value`in e&&(typeof e.value==`string`||e.value===void 0)){let n=(0,binary_locators_1.nbind)(e.value);if(n&&n.path)return u.add(path_1.default.relative(f,n.path).replace(/\\/g,`/`)),this.skip()}}break;case EXPRESS_SET:if(i.arguments.length===2&&i.arguments[0].type===`Literal`&&i.arguments[0].value===`view engine`&&!E)return await O(i.arguments[1]),this.skip();break;case EXPRESS_ENGINE:E=!0;break;case PINO_TRANSPORT:if(i.arguments.length>=1&&i.arguments[0].type===`ObjectExpression`){for(let e of i.arguments[0].properties)if(e.type===`Property`&&!e.computed&&e.key.type===`Identifier`){if(e.key.name===`target`&&e.value.type===`Literal`)await O(e.value);else if((e.key.name===`targets`||e.key.name===`pipeline`)&&e.value.type===`ArrayExpression`){for(let t of e.value.elements)if(t&&t.type===`ObjectExpression`)for(let e of t.properties)e.type===`Property`&&!e.computed&&e.key.type===`Identifier`&&e.key.name===`target`&&e.value.type===`Literal`&&await O(e.value)}}return this.skip()}break;case FS_FN:case FS_DIR_FN:if(i.arguments[0]&&c.analysis.computeFileReferences&&(T=await C(i.arguments[0],!0),T))return w=i.arguments[0],n.value===FS_DIR_FN&&i.arguments[0].type===`Identifier`&&i.arguments[0].name===`__dirname`?m(f):await A(a,this),this.skip();break;case SET_ROOT_DIR:if(i.arguments[0]){let e=await C(i.arguments[0],!1);return e&&`value`in e&&e.value&&m(e.value+`/intl`),this.skip()}break;case PKG_INFO:let r=path_1.default.resolve(e,`../package.json`),s=path_1.default.resolve(`/package.json`);for(;r!==s&&await c.stat(r)===null;)r=path_1.default.resolve(r,`../../package.json`);r!==s&&l.add(r);break;case MODULE_FN:if(i.arguments.length&&i.arguments[0].type===`Literal`){let e=i.arguments[0].value;if(e.startsWith(`.`)){let n=i.arguments.length>1?await C(i.arguments[1]):void 0;if(n&&`value`in n){let r=n.value instanceof url_1.URL?n.value.href:typeof n.value==`string`?n.value:n.value.parentURL,i=new url_1.URL(e,r).href,a=v.slice(0,v.lastIndexOf(`/`)),o=path_1.default.relative(a,i),s=o.startsWith(`.`)?o:`./`+o;d.add(s)}}else d.add(e)}break}}else if(i.type===`VariableDeclaration`&&a&&!(0,ast_helpers_1.isVarLoop)(a)&&c.analysis.evaluatePureExpressions)for(let e of i.declarations){if(!e.init)continue;let t=await C(e.init,!0);if(t){if(e.id.type===`Identifier`)b(e.id.name,t);else if(e.id.type===`ObjectPattern`&&`value`in t)for(let n of e.id.properties)n.type!==`Property`||n.key.type!==`Identifier`||n.value.type!==`Identifier`||typeof t.value!=`object`||t.value===null||!(n.key.name in t.value)||b(n.value.name,{value:t.value[n.key.name]});!(`value`in t)&&isAbsolutePathOrUrl(t.ifTrue)&&isAbsolutePathOrUrl(t.else)&&(T=t,w=e.init,await P())}}else if(i.type===`AssignmentExpression`&&a&&!(0,ast_helpers_1.isLoop)(a)&&c.analysis.evaluatePureExpressions){if(!S(i.left.name)){let e=await C(i.right,!1);if(e&&`value`in e){if(i.left.type===`Identifier`)b(i.left.name,e);else if(i.left.type===`ObjectPattern`)for(let t of i.left.properties)t.type!==`Property`||t.key.type!==`Identifier`||t.value.type!==`Identifier`||typeof e.value!=`object`||e.value===null||!(t.key.name in e.value)||b(t.value.name,{value:e.value[t.key.name]});isAbsolutePathOrUrl(e.value)&&(T=e,w=i.right,await P())}}}else if((!_||c.mixedModules)&&(i.type===`FunctionDeclaration`||i.type===`FunctionExpression`||i.type===`ArrowFunctionExpression`)&&(i.arguments||i.params)[0]&&(i.arguments||i.params)[0].type===`Identifier`){let e,t;if((i.type===`ArrowFunctionExpression`||i.type===`FunctionExpression`)&&a&&a.type===`VariableDeclarator`&&a.id.type===`Identifier`?(e=a.id,t=i.arguments||i.params):i.id&&(e=i.id,t=i.arguments||i.params),e&&i.body.body){let n,r=!1;for(let e=0;e<i.body.body.length;e++)if(i.body.body[e].type===`VariableDeclaration`&&!n&&(n=i.body.body[e].declarations.find(e=>e&&e.id&&e.id.type===`Identifier`&&e.init&&e.init.type===`CallExpression`&&e.init.callee.type===`Identifier`&&e.init.callee.name===`require`&&y.require.shadowDepth===0&&e.init.arguments[0]&&e.init.arguments[0].type===`Identifier`&&e.init.arguments[0].name===t[0].name)),n&&i.body.body[e].type===`ReturnStatement`&&i.body.body[e].argument&&i.body.body[e].argument.type===`Identifier`&&i.body.body[e].argument.name===n.id.name){r=!0;break}r&&b(e.name,{value:BOUND_REQUIRE})}}if(i.type===`CallExpression`&&i.callee.type===`MemberExpression`&&i.callee.object.type===`Identifier`&&i.callee.object.name===`module`&&i.callee.property.type===`Identifier`&&i.callee.property.name===`createRequire`&&a.type===`VariableDeclarator`&&a.id.type===`Identifier`){let e=a.id.name;b(e,{value:BOUND_REQUIRE})}if(i.type===`CallExpression`&&i.callee.type===`Identifier`&&i.callee.name===`createRequire`){let e=x(`createRequire`);if(e&&`value`in e&&e.value===CREATE_REQUIRE&&a.type===`VariableDeclarator`&&a.id.type===`Identifier`){let e=a.id.name;b(e,{value:BOUND_REQUIRE})}}}},async leave(e,t){let n=e,r=t;if(n.scope){k.parent&&(k=k.parent);for(let e in n.scope.declarations)e in y&&(y[e].shadowDepth>0?y[e].shadowDepth--:delete y[e])}w&&r&&await A(r,this)}}),await h,{assets:l,deps:u,imports:d,isESM:_};async function j(n){let r=n.indexOf(static_eval_1.WILDCARD),a=r===-1?n.length:n.lastIndexOf(path_1.default.sep,r),o=n.substring(0,a);try{var s=await c.stat(o);if(s===null)throw Error(`file not found`)}catch{return}if(!(r!==-1&&s.isFile())){if(p){let r=e.substring(0,e.indexOf(path_1.default.sep+`node_modules`))+path_1.default.sep+`node_modules`+path_1.default.sep;if(!n.startsWith(r)){c.log&&console.log(`Skipping asset emission of `+n+` for `+e+` as it is outside the package base `+p);return}}if(s.isFile()){if(c.ignoreFn(path_1.default.relative(c.base,n)))return;l.add(n)}else if(s.isDirectory()){if(c.ignoreFn(path_1.default.relative(c.base,n)))return;M(n)&&m(n)}}}function M(n){let r=``;if(n.endsWith(path_1.default.sep)?r=path_1.default.sep:n.endsWith(path_1.default.sep+static_eval_1.WILDCARD)?r=path_1.default.sep+static_eval_1.WILDCARD:n.endsWith(static_eval_1.WILDCARD)&&(r=static_eval_1.WILDCARD),n===f+r||n===cwd+r||n.endsWith(path_1.default.sep+`node_modules`+r)||f.startsWith(n.slice(0,n.length-r.length)+path_1.default.sep))return!1;if(p){let r=e.substring(0,e.indexOf(path_1.default.sep+`node_modules`))+path_1.default.sep+`node_modules`+path_1.default.sep;if(!n.startsWith(r))return c.log&&console.log(`Skipping asset emission of `+n.replace(static_eval_1.wildcardRegEx,`*`)+` for `+e+` as it is outside the package base `+p),!1}return!0}function N(e){return e instanceof url_1.URL?(0,url_1.fileURLToPath)(e):e.startsWith(`file:`)?(0,url_1.fileURLToPath)(new url_1.URL(e)):path_1.default.resolve(e)}async function P(){if(T){if(`value`in T&&isAbsolutePathOrUrl(T.value))try{await j(N(T.value))}catch{}else if(`ifTrue`in T&&`else`in T&&isAbsolutePathOrUrl(T.ifTrue)&&isAbsolutePathOrUrl(T.else)){let e;try{e=N(T.ifTrue)}catch{}let t;try{t=N(T.else)}catch{}e&&await j(e),t&&await j(t)}else if(w&&w.type===`ArrayExpression`&&`value`in T&&T.value instanceof Array)for(let e of T.value)try{await j(N(e))}catch{}w=T=void 0}}}function isAst(e){return`body`in e}
|
package/dist/plugin.mjs
CHANGED
|
@@ -75,12 +75,18 @@ function externals(opts) {
|
|
|
75
75
|
writeBundle: {
|
|
76
76
|
order: "post",
|
|
77
77
|
async handler() {
|
|
78
|
+
for (const entry of opts.traceInclude || []) tracedPaths.add(isAbsolute(entry) ? entry : tryResolve(entry, void 0) ?? resolve(rootDir, entry));
|
|
78
79
|
if (opts.trace === false || tracedPaths.size === 0) return;
|
|
80
|
+
const traceOpts = opts.trace === true ? {} : opts.trace;
|
|
81
|
+
if (traceOpts?.fullTraceInclude) for (const pkg of traceOpts.fullTraceInclude) {
|
|
82
|
+
const resolved = tryResolve(Array.isArray(pkg) ? pkg[0] : pkg, void 0);
|
|
83
|
+
if (resolved) tracedPaths.add(resolved);
|
|
84
|
+
}
|
|
79
85
|
const { traceNodeModules } = await import("./_chunks/trace.mjs").then((n) => n.r);
|
|
80
86
|
await traceNodeModules([...tracedPaths], {
|
|
81
87
|
conditions: opts.conditions,
|
|
82
88
|
rootDir,
|
|
83
|
-
...
|
|
89
|
+
...traceOpts
|
|
84
90
|
});
|
|
85
91
|
}
|
|
86
92
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nf3",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.13",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "unjs/nf3",
|
|
@@ -27,27 +27,27 @@
|
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
30
|
-
"@types/node": "^25.
|
|
30
|
+
"@types/node": "^25.5.0",
|
|
31
31
|
"@types/semver": "^7.7.1",
|
|
32
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
33
|
-
"@vercel/nft": "^1.
|
|
34
|
-
"@vitest/coverage-v8": "^4.0
|
|
32
|
+
"@typescript/native-preview": "^7.0.0-dev.20260319.1",
|
|
33
|
+
"@vercel/nft": "^1.4.0",
|
|
34
|
+
"@vitest/coverage-v8": "^4.1.0",
|
|
35
35
|
"automd": "^0.4.3",
|
|
36
36
|
"changelogen": "^0.6.2",
|
|
37
37
|
"eslint-config-unjs": "^0.6.2",
|
|
38
38
|
"exsolve": "^1.0.8",
|
|
39
39
|
"obuild": "^0.4.32",
|
|
40
|
-
"oxc-minify": "^0.
|
|
41
|
-
"oxfmt": "^0.
|
|
42
|
-
"oxlint": "^1.
|
|
40
|
+
"oxc-minify": "^0.121.0",
|
|
41
|
+
"oxfmt": "^0.41.0",
|
|
42
|
+
"oxlint": "^1.56.0",
|
|
43
43
|
"pathe": "^2.0.3",
|
|
44
44
|
"pkg-types": "^2.3.0",
|
|
45
|
-
"rolldown": "^1.0.0-rc.
|
|
45
|
+
"rolldown": "^1.0.0-rc.10",
|
|
46
46
|
"rollup": "^4.59.0",
|
|
47
47
|
"rollup-plugin-esbuild": "^6.2.1",
|
|
48
48
|
"semver": "^7.7.4",
|
|
49
49
|
"typescript": "^5.9.3",
|
|
50
|
-
"vitest": "^4.0
|
|
50
|
+
"vitest": "^4.1.0"
|
|
51
51
|
},
|
|
52
|
-
"packageManager": "pnpm@10.
|
|
52
|
+
"packageManager": "pnpm@10.32.1"
|
|
53
53
|
}
|