@rspress/plugin-preview 0.0.0-next-20230926070920 → 0.0.0-next-20231020055855

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/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -7,2528 +8,27 @@ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  var __esm = (fn, res) => function __init() {
8
9
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
10
  };
10
- var __commonJS = (cb, mod) => function __require() {
11
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
- };
13
- var __export = (target, all) => {
14
- for (var name in all)
15
- __defProp(target, name, { get: all[name], enumerable: true });
16
- };
17
- var __copyProps = (to, from, except, desc) => {
18
- if (from && typeof from === "object" || typeof from === "function") {
19
- for (let key of __getOwnPropNames(from))
20
- if (!__hasOwnProp.call(to, key) && key !== except)
21
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
- }
23
- return to;
24
- };
25
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
26
- // If the importer is in node compatibility mode or this is not an ESM
27
- // file that has been converted to a CommonJS file using a Babel-
28
- // compatible transform (i.e. "__esModule" has not been set), then set
29
- // "default" to the CommonJS "module.exports" for node compatibility.
30
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
31
- mod
32
- ));
33
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
-
35
- // ../../node_modules/.pnpm/universalify@2.0.0/node_modules/universalify/index.js
36
- var require_universalify = __commonJS({
37
- "../../node_modules/.pnpm/universalify@2.0.0/node_modules/universalify/index.js"(exports) {
38
- "use strict";
39
- exports.fromCallback = function(fn) {
40
- return Object.defineProperty(function(...args) {
41
- if (typeof args[args.length - 1] === "function")
42
- fn.apply(this, args);
43
- else {
44
- return new Promise((resolve, reject) => {
45
- fn.call(
46
- this,
47
- ...args,
48
- (err, res) => err != null ? reject(err) : resolve(res)
49
- );
50
- });
51
- }
52
- }, "name", { value: fn.name });
53
- };
54
- exports.fromPromise = function(fn) {
55
- return Object.defineProperty(function(...args) {
56
- const cb = args[args.length - 1];
57
- if (typeof cb !== "function")
58
- return fn.apply(this, args);
59
- else
60
- fn.apply(this, args.slice(0, -1)).then((r) => cb(null, r), cb);
61
- }, "name", { value: fn.name });
62
- };
63
- }
64
- });
65
-
66
- // ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js
67
- var require_polyfills = __commonJS({
68
- "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/polyfills.js"(exports, module2) {
69
- var constants = require("constants");
70
- var origCwd = process.cwd;
71
- var cwd = null;
72
- var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
73
- process.cwd = function() {
74
- if (!cwd)
75
- cwd = origCwd.call(process);
76
- return cwd;
77
- };
78
- try {
79
- process.cwd();
80
- } catch (er) {
81
- }
82
- if (typeof process.chdir === "function") {
83
- chdir = process.chdir;
84
- process.chdir = function(d) {
85
- cwd = null;
86
- chdir.call(process, d);
87
- };
88
- if (Object.setPrototypeOf)
89
- Object.setPrototypeOf(process.chdir, chdir);
90
- }
91
- var chdir;
92
- module2.exports = patch;
93
- function patch(fs2) {
94
- if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
95
- patchLchmod(fs2);
96
- }
97
- if (!fs2.lutimes) {
98
- patchLutimes(fs2);
99
- }
100
- fs2.chown = chownFix(fs2.chown);
101
- fs2.fchown = chownFix(fs2.fchown);
102
- fs2.lchown = chownFix(fs2.lchown);
103
- fs2.chmod = chmodFix(fs2.chmod);
104
- fs2.fchmod = chmodFix(fs2.fchmod);
105
- fs2.lchmod = chmodFix(fs2.lchmod);
106
- fs2.chownSync = chownFixSync(fs2.chownSync);
107
- fs2.fchownSync = chownFixSync(fs2.fchownSync);
108
- fs2.lchownSync = chownFixSync(fs2.lchownSync);
109
- fs2.chmodSync = chmodFixSync(fs2.chmodSync);
110
- fs2.fchmodSync = chmodFixSync(fs2.fchmodSync);
111
- fs2.lchmodSync = chmodFixSync(fs2.lchmodSync);
112
- fs2.stat = statFix(fs2.stat);
113
- fs2.fstat = statFix(fs2.fstat);
114
- fs2.lstat = statFix(fs2.lstat);
115
- fs2.statSync = statFixSync(fs2.statSync);
116
- fs2.fstatSync = statFixSync(fs2.fstatSync);
117
- fs2.lstatSync = statFixSync(fs2.lstatSync);
118
- if (fs2.chmod && !fs2.lchmod) {
119
- fs2.lchmod = function(path3, mode, cb) {
120
- if (cb)
121
- process.nextTick(cb);
122
- };
123
- fs2.lchmodSync = function() {
124
- };
125
- }
126
- if (fs2.chown && !fs2.lchown) {
127
- fs2.lchown = function(path3, uid, gid, cb) {
128
- if (cb)
129
- process.nextTick(cb);
130
- };
131
- fs2.lchownSync = function() {
132
- };
133
- }
134
- if (platform === "win32") {
135
- fs2.rename = typeof fs2.rename !== "function" ? fs2.rename : function(fs$rename) {
136
- function rename(from, to, cb) {
137
- var start = Date.now();
138
- var backoff = 0;
139
- fs$rename(from, to, function CB(er) {
140
- if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
141
- setTimeout(function() {
142
- fs2.stat(to, function(stater, st) {
143
- if (stater && stater.code === "ENOENT")
144
- fs$rename(from, to, CB);
145
- else
146
- cb(er);
147
- });
148
- }, backoff);
149
- if (backoff < 100)
150
- backoff += 10;
151
- return;
152
- }
153
- if (cb)
154
- cb(er);
155
- });
156
- }
157
- if (Object.setPrototypeOf)
158
- Object.setPrototypeOf(rename, fs$rename);
159
- return rename;
160
- }(fs2.rename);
161
- }
162
- fs2.read = typeof fs2.read !== "function" ? fs2.read : function(fs$read) {
163
- function read(fd, buffer, offset, length, position, callback_) {
164
- var callback;
165
- if (callback_ && typeof callback_ === "function") {
166
- var eagCounter = 0;
167
- callback = function(er, _, __) {
168
- if (er && er.code === "EAGAIN" && eagCounter < 10) {
169
- eagCounter++;
170
- return fs$read.call(fs2, fd, buffer, offset, length, position, callback);
171
- }
172
- callback_.apply(this, arguments);
173
- };
174
- }
175
- return fs$read.call(fs2, fd, buffer, offset, length, position, callback);
176
- }
177
- if (Object.setPrototypeOf)
178
- Object.setPrototypeOf(read, fs$read);
179
- return read;
180
- }(fs2.read);
181
- fs2.readSync = typeof fs2.readSync !== "function" ? fs2.readSync : function(fs$readSync) {
182
- return function(fd, buffer, offset, length, position) {
183
- var eagCounter = 0;
184
- while (true) {
185
- try {
186
- return fs$readSync.call(fs2, fd, buffer, offset, length, position);
187
- } catch (er) {
188
- if (er.code === "EAGAIN" && eagCounter < 10) {
189
- eagCounter++;
190
- continue;
191
- }
192
- throw er;
193
- }
194
- }
195
- };
196
- }(fs2.readSync);
197
- function patchLchmod(fs3) {
198
- fs3.lchmod = function(path3, mode, callback) {
199
- fs3.open(
200
- path3,
201
- constants.O_WRONLY | constants.O_SYMLINK,
202
- mode,
203
- function(err, fd) {
204
- if (err) {
205
- if (callback)
206
- callback(err);
207
- return;
208
- }
209
- fs3.fchmod(fd, mode, function(err2) {
210
- fs3.close(fd, function(err22) {
211
- if (callback)
212
- callback(err2 || err22);
213
- });
214
- });
215
- }
216
- );
217
- };
218
- fs3.lchmodSync = function(path3, mode) {
219
- var fd = fs3.openSync(path3, constants.O_WRONLY | constants.O_SYMLINK, mode);
220
- var threw = true;
221
- var ret;
222
- try {
223
- ret = fs3.fchmodSync(fd, mode);
224
- threw = false;
225
- } finally {
226
- if (threw) {
227
- try {
228
- fs3.closeSync(fd);
229
- } catch (er) {
230
- }
231
- } else {
232
- fs3.closeSync(fd);
233
- }
234
- }
235
- return ret;
236
- };
237
- }
238
- function patchLutimes(fs3) {
239
- if (constants.hasOwnProperty("O_SYMLINK") && fs3.futimes) {
240
- fs3.lutimes = function(path3, at, mt, cb) {
241
- fs3.open(path3, constants.O_SYMLINK, function(er, fd) {
242
- if (er) {
243
- if (cb)
244
- cb(er);
245
- return;
246
- }
247
- fs3.futimes(fd, at, mt, function(er2) {
248
- fs3.close(fd, function(er22) {
249
- if (cb)
250
- cb(er2 || er22);
251
- });
252
- });
253
- });
254
- };
255
- fs3.lutimesSync = function(path3, at, mt) {
256
- var fd = fs3.openSync(path3, constants.O_SYMLINK);
257
- var ret;
258
- var threw = true;
259
- try {
260
- ret = fs3.futimesSync(fd, at, mt);
261
- threw = false;
262
- } finally {
263
- if (threw) {
264
- try {
265
- fs3.closeSync(fd);
266
- } catch (er) {
267
- }
268
- } else {
269
- fs3.closeSync(fd);
270
- }
271
- }
272
- return ret;
273
- };
274
- } else if (fs3.futimes) {
275
- fs3.lutimes = function(_a, _b, _c, cb) {
276
- if (cb)
277
- process.nextTick(cb);
278
- };
279
- fs3.lutimesSync = function() {
280
- };
281
- }
282
- }
283
- function chmodFix(orig) {
284
- if (!orig)
285
- return orig;
286
- return function(target, mode, cb) {
287
- return orig.call(fs2, target, mode, function(er) {
288
- if (chownErOk(er))
289
- er = null;
290
- if (cb)
291
- cb.apply(this, arguments);
292
- });
293
- };
294
- }
295
- function chmodFixSync(orig) {
296
- if (!orig)
297
- return orig;
298
- return function(target, mode) {
299
- try {
300
- return orig.call(fs2, target, mode);
301
- } catch (er) {
302
- if (!chownErOk(er))
303
- throw er;
304
- }
305
- };
306
- }
307
- function chownFix(orig) {
308
- if (!orig)
309
- return orig;
310
- return function(target, uid, gid, cb) {
311
- return orig.call(fs2, target, uid, gid, function(er) {
312
- if (chownErOk(er))
313
- er = null;
314
- if (cb)
315
- cb.apply(this, arguments);
316
- });
317
- };
318
- }
319
- function chownFixSync(orig) {
320
- if (!orig)
321
- return orig;
322
- return function(target, uid, gid) {
323
- try {
324
- return orig.call(fs2, target, uid, gid);
325
- } catch (er) {
326
- if (!chownErOk(er))
327
- throw er;
328
- }
329
- };
330
- }
331
- function statFix(orig) {
332
- if (!orig)
333
- return orig;
334
- return function(target, options, cb) {
335
- if (typeof options === "function") {
336
- cb = options;
337
- options = null;
338
- }
339
- function callback(er, stats) {
340
- if (stats) {
341
- if (stats.uid < 0)
342
- stats.uid += 4294967296;
343
- if (stats.gid < 0)
344
- stats.gid += 4294967296;
345
- }
346
- if (cb)
347
- cb.apply(this, arguments);
348
- }
349
- return options ? orig.call(fs2, target, options, callback) : orig.call(fs2, target, callback);
350
- };
351
- }
352
- function statFixSync(orig) {
353
- if (!orig)
354
- return orig;
355
- return function(target, options) {
356
- var stats = options ? orig.call(fs2, target, options) : orig.call(fs2, target);
357
- if (stats) {
358
- if (stats.uid < 0)
359
- stats.uid += 4294967296;
360
- if (stats.gid < 0)
361
- stats.gid += 4294967296;
362
- }
363
- return stats;
364
- };
365
- }
366
- function chownErOk(er) {
367
- if (!er)
368
- return true;
369
- if (er.code === "ENOSYS")
370
- return true;
371
- var nonroot = !process.getuid || process.getuid() !== 0;
372
- if (nonroot) {
373
- if (er.code === "EINVAL" || er.code === "EPERM")
374
- return true;
375
- }
376
- return false;
377
- }
378
- }
379
- }
380
- });
381
-
382
- // ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js
383
- var require_legacy_streams = __commonJS({
384
- "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/legacy-streams.js"(exports, module2) {
385
- var Stream = require("stream").Stream;
386
- module2.exports = legacy;
387
- function legacy(fs2) {
388
- return {
389
- ReadStream,
390
- WriteStream
391
- };
392
- function ReadStream(path3, options) {
393
- if (!(this instanceof ReadStream))
394
- return new ReadStream(path3, options);
395
- Stream.call(this);
396
- var self = this;
397
- this.path = path3;
398
- this.fd = null;
399
- this.readable = true;
400
- this.paused = false;
401
- this.flags = "r";
402
- this.mode = 438;
403
- this.bufferSize = 64 * 1024;
404
- options = options || {};
405
- var keys = Object.keys(options);
406
- for (var index = 0, length = keys.length; index < length; index++) {
407
- var key = keys[index];
408
- this[key] = options[key];
409
- }
410
- if (this.encoding)
411
- this.setEncoding(this.encoding);
412
- if (this.start !== void 0) {
413
- if ("number" !== typeof this.start) {
414
- throw TypeError("start must be a Number");
415
- }
416
- if (this.end === void 0) {
417
- this.end = Infinity;
418
- } else if ("number" !== typeof this.end) {
419
- throw TypeError("end must be a Number");
420
- }
421
- if (this.start > this.end) {
422
- throw new Error("start must be <= end");
423
- }
424
- this.pos = this.start;
425
- }
426
- if (this.fd !== null) {
427
- process.nextTick(function() {
428
- self._read();
429
- });
430
- return;
431
- }
432
- fs2.open(this.path, this.flags, this.mode, function(err, fd) {
433
- if (err) {
434
- self.emit("error", err);
435
- self.readable = false;
436
- return;
437
- }
438
- self.fd = fd;
439
- self.emit("open", fd);
440
- self._read();
441
- });
442
- }
443
- function WriteStream(path3, options) {
444
- if (!(this instanceof WriteStream))
445
- return new WriteStream(path3, options);
446
- Stream.call(this);
447
- this.path = path3;
448
- this.fd = null;
449
- this.writable = true;
450
- this.flags = "w";
451
- this.encoding = "binary";
452
- this.mode = 438;
453
- this.bytesWritten = 0;
454
- options = options || {};
455
- var keys = Object.keys(options);
456
- for (var index = 0, length = keys.length; index < length; index++) {
457
- var key = keys[index];
458
- this[key] = options[key];
459
- }
460
- if (this.start !== void 0) {
461
- if ("number" !== typeof this.start) {
462
- throw TypeError("start must be a Number");
463
- }
464
- if (this.start < 0) {
465
- throw new Error("start must be >= zero");
466
- }
467
- this.pos = this.start;
468
- }
469
- this.busy = false;
470
- this._queue = [];
471
- if (this.fd === null) {
472
- this._open = fs2.open;
473
- this._queue.push([this._open, this.path, this.flags, this.mode, void 0]);
474
- this.flush();
475
- }
476
- }
477
- }
478
- }
479
- });
480
-
481
- // ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/clone.js
482
- var require_clone = __commonJS({
483
- "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/clone.js"(exports, module2) {
484
- "use strict";
485
- module2.exports = clone;
486
- var getPrototypeOf = Object.getPrototypeOf || function(obj) {
487
- return obj.__proto__;
488
- };
489
- function clone(obj) {
490
- if (obj === null || typeof obj !== "object")
491
- return obj;
492
- if (obj instanceof Object)
493
- var copy = { __proto__: getPrototypeOf(obj) };
494
- else
495
- var copy = /* @__PURE__ */ Object.create(null);
496
- Object.getOwnPropertyNames(obj).forEach(function(key) {
497
- Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
498
- });
499
- return copy;
500
- }
501
- }
502
- });
503
-
504
- // ../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js
505
- var require_graceful_fs = __commonJS({
506
- "../../node_modules/.pnpm/graceful-fs@4.2.11/node_modules/graceful-fs/graceful-fs.js"(exports, module2) {
507
- var fs2 = require("fs");
508
- var polyfills = require_polyfills();
509
- var legacy = require_legacy_streams();
510
- var clone = require_clone();
511
- var util = require("util");
512
- var gracefulQueue;
513
- var previousSymbol;
514
- if (typeof Symbol === "function" && typeof Symbol.for === "function") {
515
- gracefulQueue = Symbol.for("graceful-fs.queue");
516
- previousSymbol = Symbol.for("graceful-fs.previous");
517
- } else {
518
- gracefulQueue = "___graceful-fs.queue";
519
- previousSymbol = "___graceful-fs.previous";
520
- }
521
- function noop() {
522
- }
523
- function publishQueue(context, queue2) {
524
- Object.defineProperty(context, gracefulQueue, {
525
- get: function() {
526
- return queue2;
527
- }
528
- });
529
- }
530
- var debug = noop;
531
- if (util.debuglog)
532
- debug = util.debuglog("gfs4");
533
- else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
534
- debug = function() {
535
- var m = util.format.apply(util, arguments);
536
- m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
537
- console.error(m);
538
- };
539
- if (!fs2[gracefulQueue]) {
540
- queue = global[gracefulQueue] || [];
541
- publishQueue(fs2, queue);
542
- fs2.close = function(fs$close) {
543
- function close(fd, cb) {
544
- return fs$close.call(fs2, fd, function(err) {
545
- if (!err) {
546
- resetQueue();
547
- }
548
- if (typeof cb === "function")
549
- cb.apply(this, arguments);
550
- });
551
- }
552
- Object.defineProperty(close, previousSymbol, {
553
- value: fs$close
554
- });
555
- return close;
556
- }(fs2.close);
557
- fs2.closeSync = function(fs$closeSync) {
558
- function closeSync(fd) {
559
- fs$closeSync.apply(fs2, arguments);
560
- resetQueue();
561
- }
562
- Object.defineProperty(closeSync, previousSymbol, {
563
- value: fs$closeSync
564
- });
565
- return closeSync;
566
- }(fs2.closeSync);
567
- if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
568
- process.on("exit", function() {
569
- debug(fs2[gracefulQueue]);
570
- require("assert").equal(fs2[gracefulQueue].length, 0);
571
- });
572
- }
573
- }
574
- var queue;
575
- if (!global[gracefulQueue]) {
576
- publishQueue(global, fs2[gracefulQueue]);
577
- }
578
- module2.exports = patch(clone(fs2));
579
- if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs2.__patched) {
580
- module2.exports = patch(fs2);
581
- fs2.__patched = true;
582
- }
583
- function patch(fs3) {
584
- polyfills(fs3);
585
- fs3.gracefulify = patch;
586
- fs3.createReadStream = createReadStream;
587
- fs3.createWriteStream = createWriteStream;
588
- var fs$readFile = fs3.readFile;
589
- fs3.readFile = readFile;
590
- function readFile(path3, options, cb) {
591
- if (typeof options === "function")
592
- cb = options, options = null;
593
- return go$readFile(path3, options, cb);
594
- function go$readFile(path4, options2, cb2, startTime) {
595
- return fs$readFile(path4, options2, function(err) {
596
- if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
597
- enqueue([go$readFile, [path4, options2, cb2], err, startTime || Date.now(), Date.now()]);
598
- else {
599
- if (typeof cb2 === "function")
600
- cb2.apply(this, arguments);
601
- }
602
- });
603
- }
604
- }
605
- var fs$writeFile = fs3.writeFile;
606
- fs3.writeFile = writeFile;
607
- function writeFile(path3, data, options, cb) {
608
- if (typeof options === "function")
609
- cb = options, options = null;
610
- return go$writeFile(path3, data, options, cb);
611
- function go$writeFile(path4, data2, options2, cb2, startTime) {
612
- return fs$writeFile(path4, data2, options2, function(err) {
613
- if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
614
- enqueue([go$writeFile, [path4, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
615
- else {
616
- if (typeof cb2 === "function")
617
- cb2.apply(this, arguments);
618
- }
619
- });
620
- }
621
- }
622
- var fs$appendFile = fs3.appendFile;
623
- if (fs$appendFile)
624
- fs3.appendFile = appendFile;
625
- function appendFile(path3, data, options, cb) {
626
- if (typeof options === "function")
627
- cb = options, options = null;
628
- return go$appendFile(path3, data, options, cb);
629
- function go$appendFile(path4, data2, options2, cb2, startTime) {
630
- return fs$appendFile(path4, data2, options2, function(err) {
631
- if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
632
- enqueue([go$appendFile, [path4, data2, options2, cb2], err, startTime || Date.now(), Date.now()]);
633
- else {
634
- if (typeof cb2 === "function")
635
- cb2.apply(this, arguments);
636
- }
637
- });
638
- }
639
- }
640
- var fs$copyFile = fs3.copyFile;
641
- if (fs$copyFile)
642
- fs3.copyFile = copyFile;
643
- function copyFile(src, dest, flags, cb) {
644
- if (typeof flags === "function") {
645
- cb = flags;
646
- flags = 0;
647
- }
648
- return go$copyFile(src, dest, flags, cb);
649
- function go$copyFile(src2, dest2, flags2, cb2, startTime) {
650
- return fs$copyFile(src2, dest2, flags2, function(err) {
651
- if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
652
- enqueue([go$copyFile, [src2, dest2, flags2, cb2], err, startTime || Date.now(), Date.now()]);
653
- else {
654
- if (typeof cb2 === "function")
655
- cb2.apply(this, arguments);
656
- }
657
- });
658
- }
659
- }
660
- var fs$readdir = fs3.readdir;
661
- fs3.readdir = readdir;
662
- var noReaddirOptionVersions = /^v[0-5]\./;
663
- function readdir(path3, options, cb) {
664
- if (typeof options === "function")
665
- cb = options, options = null;
666
- var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir2(path4, options2, cb2, startTime) {
667
- return fs$readdir(path4, fs$readdirCallback(
668
- path4,
669
- options2,
670
- cb2,
671
- startTime
672
- ));
673
- } : function go$readdir2(path4, options2, cb2, startTime) {
674
- return fs$readdir(path4, options2, fs$readdirCallback(
675
- path4,
676
- options2,
677
- cb2,
678
- startTime
679
- ));
680
- };
681
- return go$readdir(path3, options, cb);
682
- function fs$readdirCallback(path4, options2, cb2, startTime) {
683
- return function(err, files) {
684
- if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
685
- enqueue([
686
- go$readdir,
687
- [path4, options2, cb2],
688
- err,
689
- startTime || Date.now(),
690
- Date.now()
691
- ]);
692
- else {
693
- if (files && files.sort)
694
- files.sort();
695
- if (typeof cb2 === "function")
696
- cb2.call(this, err, files);
697
- }
698
- };
699
- }
700
- }
701
- if (process.version.substr(0, 4) === "v0.8") {
702
- var legStreams = legacy(fs3);
703
- ReadStream = legStreams.ReadStream;
704
- WriteStream = legStreams.WriteStream;
705
- }
706
- var fs$ReadStream = fs3.ReadStream;
707
- if (fs$ReadStream) {
708
- ReadStream.prototype = Object.create(fs$ReadStream.prototype);
709
- ReadStream.prototype.open = ReadStream$open;
710
- }
711
- var fs$WriteStream = fs3.WriteStream;
712
- if (fs$WriteStream) {
713
- WriteStream.prototype = Object.create(fs$WriteStream.prototype);
714
- WriteStream.prototype.open = WriteStream$open;
715
- }
716
- Object.defineProperty(fs3, "ReadStream", {
717
- get: function() {
718
- return ReadStream;
719
- },
720
- set: function(val) {
721
- ReadStream = val;
722
- },
723
- enumerable: true,
724
- configurable: true
725
- });
726
- Object.defineProperty(fs3, "WriteStream", {
727
- get: function() {
728
- return WriteStream;
729
- },
730
- set: function(val) {
731
- WriteStream = val;
732
- },
733
- enumerable: true,
734
- configurable: true
735
- });
736
- var FileReadStream = ReadStream;
737
- Object.defineProperty(fs3, "FileReadStream", {
738
- get: function() {
739
- return FileReadStream;
740
- },
741
- set: function(val) {
742
- FileReadStream = val;
743
- },
744
- enumerable: true,
745
- configurable: true
746
- });
747
- var FileWriteStream = WriteStream;
748
- Object.defineProperty(fs3, "FileWriteStream", {
749
- get: function() {
750
- return FileWriteStream;
751
- },
752
- set: function(val) {
753
- FileWriteStream = val;
754
- },
755
- enumerable: true,
756
- configurable: true
757
- });
758
- function ReadStream(path3, options) {
759
- if (this instanceof ReadStream)
760
- return fs$ReadStream.apply(this, arguments), this;
761
- else
762
- return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
763
- }
764
- function ReadStream$open() {
765
- var that = this;
766
- open(that.path, that.flags, that.mode, function(err, fd) {
767
- if (err) {
768
- if (that.autoClose)
769
- that.destroy();
770
- that.emit("error", err);
771
- } else {
772
- that.fd = fd;
773
- that.emit("open", fd);
774
- that.read();
775
- }
776
- });
777
- }
778
- function WriteStream(path3, options) {
779
- if (this instanceof WriteStream)
780
- return fs$WriteStream.apply(this, arguments), this;
781
- else
782
- return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
783
- }
784
- function WriteStream$open() {
785
- var that = this;
786
- open(that.path, that.flags, that.mode, function(err, fd) {
787
- if (err) {
788
- that.destroy();
789
- that.emit("error", err);
790
- } else {
791
- that.fd = fd;
792
- that.emit("open", fd);
793
- }
794
- });
795
- }
796
- function createReadStream(path3, options) {
797
- return new fs3.ReadStream(path3, options);
798
- }
799
- function createWriteStream(path3, options) {
800
- return new fs3.WriteStream(path3, options);
801
- }
802
- var fs$open = fs3.open;
803
- fs3.open = open;
804
- function open(path3, flags, mode, cb) {
805
- if (typeof mode === "function")
806
- cb = mode, mode = null;
807
- return go$open(path3, flags, mode, cb);
808
- function go$open(path4, flags2, mode2, cb2, startTime) {
809
- return fs$open(path4, flags2, mode2, function(err, fd) {
810
- if (err && (err.code === "EMFILE" || err.code === "ENFILE"))
811
- enqueue([go$open, [path4, flags2, mode2, cb2], err, startTime || Date.now(), Date.now()]);
812
- else {
813
- if (typeof cb2 === "function")
814
- cb2.apply(this, arguments);
815
- }
816
- });
817
- }
818
- }
819
- return fs3;
820
- }
821
- function enqueue(elem) {
822
- debug("ENQUEUE", elem[0].name, elem[1]);
823
- fs2[gracefulQueue].push(elem);
824
- retry();
825
- }
826
- var retryTimer;
827
- function resetQueue() {
828
- var now = Date.now();
829
- for (var i = 0; i < fs2[gracefulQueue].length; ++i) {
830
- if (fs2[gracefulQueue][i].length > 2) {
831
- fs2[gracefulQueue][i][3] = now;
832
- fs2[gracefulQueue][i][4] = now;
833
- }
834
- }
835
- retry();
836
- }
837
- function retry() {
838
- clearTimeout(retryTimer);
839
- retryTimer = void 0;
840
- if (fs2[gracefulQueue].length === 0)
841
- return;
842
- var elem = fs2[gracefulQueue].shift();
843
- var fn = elem[0];
844
- var args = elem[1];
845
- var err = elem[2];
846
- var startTime = elem[3];
847
- var lastTime = elem[4];
848
- if (startTime === void 0) {
849
- debug("RETRY", fn.name, args);
850
- fn.apply(null, args);
851
- } else if (Date.now() - startTime >= 6e4) {
852
- debug("TIMEOUT", fn.name, args);
853
- var cb = args.pop();
854
- if (typeof cb === "function")
855
- cb.call(null, err);
856
- } else {
857
- var sinceAttempt = Date.now() - lastTime;
858
- var sinceStart = Math.max(lastTime - startTime, 1);
859
- var desiredDelay = Math.min(sinceStart * 1.2, 100);
860
- if (sinceAttempt >= desiredDelay) {
861
- debug("RETRY", fn.name, args);
862
- fn.apply(null, args.concat([startTime]));
863
- } else {
864
- fs2[gracefulQueue].push(elem);
865
- }
866
- }
867
- if (retryTimer === void 0) {
868
- retryTimer = setTimeout(retry, 0);
869
- }
870
- }
871
- }
872
- });
873
-
874
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/fs/index.js
875
- var require_fs = __commonJS({
876
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/fs/index.js"(exports) {
877
- "use strict";
878
- var u = require_universalify().fromCallback;
879
- var fs2 = require_graceful_fs();
880
- var api = [
881
- "access",
882
- "appendFile",
883
- "chmod",
884
- "chown",
885
- "close",
886
- "copyFile",
887
- "fchmod",
888
- "fchown",
889
- "fdatasync",
890
- "fstat",
891
- "fsync",
892
- "ftruncate",
893
- "futimes",
894
- "lchmod",
895
- "lchown",
896
- "link",
897
- "lstat",
898
- "mkdir",
899
- "mkdtemp",
900
- "open",
901
- "opendir",
902
- "readdir",
903
- "readFile",
904
- "readlink",
905
- "realpath",
906
- "rename",
907
- "rm",
908
- "rmdir",
909
- "stat",
910
- "symlink",
911
- "truncate",
912
- "unlink",
913
- "utimes",
914
- "writeFile"
915
- ].filter((key) => {
916
- return typeof fs2[key] === "function";
917
- });
918
- Object.assign(exports, fs2);
919
- api.forEach((method) => {
920
- exports[method] = u(fs2[method]);
921
- });
922
- exports.exists = function(filename, callback) {
923
- if (typeof callback === "function") {
924
- return fs2.exists(filename, callback);
925
- }
926
- return new Promise((resolve) => {
927
- return fs2.exists(filename, resolve);
928
- });
929
- };
930
- exports.read = function(fd, buffer, offset, length, position, callback) {
931
- if (typeof callback === "function") {
932
- return fs2.read(fd, buffer, offset, length, position, callback);
933
- }
934
- return new Promise((resolve, reject) => {
935
- fs2.read(fd, buffer, offset, length, position, (err, bytesRead, buffer2) => {
936
- if (err)
937
- return reject(err);
938
- resolve({ bytesRead, buffer: buffer2 });
939
- });
940
- });
941
- };
942
- exports.write = function(fd, buffer, ...args) {
943
- if (typeof args[args.length - 1] === "function") {
944
- return fs2.write(fd, buffer, ...args);
945
- }
946
- return new Promise((resolve, reject) => {
947
- fs2.write(fd, buffer, ...args, (err, bytesWritten, buffer2) => {
948
- if (err)
949
- return reject(err);
950
- resolve({ bytesWritten, buffer: buffer2 });
951
- });
952
- });
953
- };
954
- exports.readv = function(fd, buffers, ...args) {
955
- if (typeof args[args.length - 1] === "function") {
956
- return fs2.readv(fd, buffers, ...args);
957
- }
958
- return new Promise((resolve, reject) => {
959
- fs2.readv(fd, buffers, ...args, (err, bytesRead, buffers2) => {
960
- if (err)
961
- return reject(err);
962
- resolve({ bytesRead, buffers: buffers2 });
963
- });
964
- });
965
- };
966
- exports.writev = function(fd, buffers, ...args) {
967
- if (typeof args[args.length - 1] === "function") {
968
- return fs2.writev(fd, buffers, ...args);
969
- }
970
- return new Promise((resolve, reject) => {
971
- fs2.writev(fd, buffers, ...args, (err, bytesWritten, buffers2) => {
972
- if (err)
973
- return reject(err);
974
- resolve({ bytesWritten, buffers: buffers2 });
975
- });
976
- });
977
- };
978
- if (typeof fs2.realpath.native === "function") {
979
- exports.realpath.native = u(fs2.realpath.native);
980
- } else {
981
- process.emitWarning(
982
- "fs.realpath.native is not a function. Is fs being monkey-patched?",
983
- "Warning",
984
- "fs-extra-WARN0003"
985
- );
986
- }
987
- }
988
- });
989
-
990
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/mkdirs/utils.js
991
- var require_utils = __commonJS({
992
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/mkdirs/utils.js"(exports, module2) {
993
- "use strict";
994
- var path3 = require("path");
995
- module2.exports.checkPath = function checkPath(pth) {
996
- if (process.platform === "win32") {
997
- const pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path3.parse(pth).root, ""));
998
- if (pathHasInvalidWinCharacters) {
999
- const error = new Error(`Path contains invalid characters: ${pth}`);
1000
- error.code = "EINVAL";
1001
- throw error;
1002
- }
1003
- }
1004
- };
1005
- }
1006
- });
1007
-
1008
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/mkdirs/make-dir.js
1009
- var require_make_dir = __commonJS({
1010
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/mkdirs/make-dir.js"(exports, module2) {
1011
- "use strict";
1012
- var fs2 = require_fs();
1013
- var { checkPath } = require_utils();
1014
- var getMode = (options) => {
1015
- const defaults = { mode: 511 };
1016
- if (typeof options === "number")
1017
- return options;
1018
- return { ...defaults, ...options }.mode;
1019
- };
1020
- module2.exports.makeDir = async (dir, options) => {
1021
- checkPath(dir);
1022
- return fs2.mkdir(dir, {
1023
- mode: getMode(options),
1024
- recursive: true
1025
- });
1026
- };
1027
- module2.exports.makeDirSync = (dir, options) => {
1028
- checkPath(dir);
1029
- return fs2.mkdirSync(dir, {
1030
- mode: getMode(options),
1031
- recursive: true
1032
- });
1033
- };
1034
- }
1035
- });
1036
-
1037
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/mkdirs/index.js
1038
- var require_mkdirs = __commonJS({
1039
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/mkdirs/index.js"(exports, module2) {
1040
- "use strict";
1041
- var u = require_universalify().fromPromise;
1042
- var { makeDir: _makeDir, makeDirSync } = require_make_dir();
1043
- var makeDir = u(_makeDir);
1044
- module2.exports = {
1045
- mkdirs: makeDir,
1046
- mkdirsSync: makeDirSync,
1047
- // alias
1048
- mkdirp: makeDir,
1049
- mkdirpSync: makeDirSync,
1050
- ensureDir: makeDir,
1051
- ensureDirSync: makeDirSync
1052
- };
1053
- }
1054
- });
1055
-
1056
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/path-exists/index.js
1057
- var require_path_exists = __commonJS({
1058
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/path-exists/index.js"(exports, module2) {
1059
- "use strict";
1060
- var u = require_universalify().fromPromise;
1061
- var fs2 = require_fs();
1062
- function pathExists(path3) {
1063
- return fs2.access(path3).then(() => true).catch(() => false);
1064
- }
1065
- module2.exports = {
1066
- pathExists: u(pathExists),
1067
- pathExistsSync: fs2.existsSync
1068
- };
1069
- }
1070
- });
1071
-
1072
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/util/utimes.js
1073
- var require_utimes = __commonJS({
1074
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/util/utimes.js"(exports, module2) {
1075
- "use strict";
1076
- var fs2 = require_graceful_fs();
1077
- function utimesMillis(path3, atime, mtime, callback) {
1078
- fs2.open(path3, "r+", (err, fd) => {
1079
- if (err)
1080
- return callback(err);
1081
- fs2.futimes(fd, atime, mtime, (futimesErr) => {
1082
- fs2.close(fd, (closeErr) => {
1083
- if (callback)
1084
- callback(futimesErr || closeErr);
1085
- });
1086
- });
1087
- });
1088
- }
1089
- function utimesMillisSync(path3, atime, mtime) {
1090
- const fd = fs2.openSync(path3, "r+");
1091
- fs2.futimesSync(fd, atime, mtime);
1092
- return fs2.closeSync(fd);
1093
- }
1094
- module2.exports = {
1095
- utimesMillis,
1096
- utimesMillisSync
1097
- };
1098
- }
1099
- });
1100
-
1101
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/util/stat.js
1102
- var require_stat = __commonJS({
1103
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/util/stat.js"(exports, module2) {
1104
- "use strict";
1105
- var fs2 = require_fs();
1106
- var path3 = require("path");
1107
- var util = require("util");
1108
- function getStats(src, dest, opts) {
1109
- const statFunc = opts.dereference ? (file) => fs2.stat(file, { bigint: true }) : (file) => fs2.lstat(file, { bigint: true });
1110
- return Promise.all([
1111
- statFunc(src),
1112
- statFunc(dest).catch((err) => {
1113
- if (err.code === "ENOENT")
1114
- return null;
1115
- throw err;
1116
- })
1117
- ]).then(([srcStat, destStat]) => ({ srcStat, destStat }));
1118
- }
1119
- function getStatsSync(src, dest, opts) {
1120
- let destStat;
1121
- const statFunc = opts.dereference ? (file) => fs2.statSync(file, { bigint: true }) : (file) => fs2.lstatSync(file, { bigint: true });
1122
- const srcStat = statFunc(src);
1123
- try {
1124
- destStat = statFunc(dest);
1125
- } catch (err) {
1126
- if (err.code === "ENOENT")
1127
- return { srcStat, destStat: null };
1128
- throw err;
1129
- }
1130
- return { srcStat, destStat };
1131
- }
1132
- function checkPaths(src, dest, funcName, opts, cb) {
1133
- util.callbackify(getStats)(src, dest, opts, (err, stats) => {
1134
- if (err)
1135
- return cb(err);
1136
- const { srcStat, destStat } = stats;
1137
- if (destStat) {
1138
- if (areIdentical(srcStat, destStat)) {
1139
- const srcBaseName = path3.basename(src);
1140
- const destBaseName = path3.basename(dest);
1141
- if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
1142
- return cb(null, { srcStat, destStat, isChangingCase: true });
1143
- }
1144
- return cb(new Error("Source and destination must not be the same."));
1145
- }
1146
- if (srcStat.isDirectory() && !destStat.isDirectory()) {
1147
- return cb(new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`));
1148
- }
1149
- if (!srcStat.isDirectory() && destStat.isDirectory()) {
1150
- return cb(new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`));
1151
- }
1152
- }
1153
- if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
1154
- return cb(new Error(errMsg(src, dest, funcName)));
1155
- }
1156
- return cb(null, { srcStat, destStat });
1157
- });
1158
- }
1159
- function checkPathsSync(src, dest, funcName, opts) {
1160
- const { srcStat, destStat } = getStatsSync(src, dest, opts);
1161
- if (destStat) {
1162
- if (areIdentical(srcStat, destStat)) {
1163
- const srcBaseName = path3.basename(src);
1164
- const destBaseName = path3.basename(dest);
1165
- if (funcName === "move" && srcBaseName !== destBaseName && srcBaseName.toLowerCase() === destBaseName.toLowerCase()) {
1166
- return { srcStat, destStat, isChangingCase: true };
1167
- }
1168
- throw new Error("Source and destination must not be the same.");
1169
- }
1170
- if (srcStat.isDirectory() && !destStat.isDirectory()) {
1171
- throw new Error(`Cannot overwrite non-directory '${dest}' with directory '${src}'.`);
1172
- }
1173
- if (!srcStat.isDirectory() && destStat.isDirectory()) {
1174
- throw new Error(`Cannot overwrite directory '${dest}' with non-directory '${src}'.`);
1175
- }
1176
- }
1177
- if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
1178
- throw new Error(errMsg(src, dest, funcName));
1179
- }
1180
- return { srcStat, destStat };
1181
- }
1182
- function checkParentPaths(src, srcStat, dest, funcName, cb) {
1183
- const srcParent = path3.resolve(path3.dirname(src));
1184
- const destParent = path3.resolve(path3.dirname(dest));
1185
- if (destParent === srcParent || destParent === path3.parse(destParent).root)
1186
- return cb();
1187
- fs2.stat(destParent, { bigint: true }, (err, destStat) => {
1188
- if (err) {
1189
- if (err.code === "ENOENT")
1190
- return cb();
1191
- return cb(err);
1192
- }
1193
- if (areIdentical(srcStat, destStat)) {
1194
- return cb(new Error(errMsg(src, dest, funcName)));
1195
- }
1196
- return checkParentPaths(src, srcStat, destParent, funcName, cb);
1197
- });
1198
- }
1199
- function checkParentPathsSync(src, srcStat, dest, funcName) {
1200
- const srcParent = path3.resolve(path3.dirname(src));
1201
- const destParent = path3.resolve(path3.dirname(dest));
1202
- if (destParent === srcParent || destParent === path3.parse(destParent).root)
1203
- return;
1204
- let destStat;
1205
- try {
1206
- destStat = fs2.statSync(destParent, { bigint: true });
1207
- } catch (err) {
1208
- if (err.code === "ENOENT")
1209
- return;
1210
- throw err;
1211
- }
1212
- if (areIdentical(srcStat, destStat)) {
1213
- throw new Error(errMsg(src, dest, funcName));
1214
- }
1215
- return checkParentPathsSync(src, srcStat, destParent, funcName);
1216
- }
1217
- function areIdentical(srcStat, destStat) {
1218
- return destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev;
1219
- }
1220
- function isSrcSubdir(src, dest) {
1221
- const srcArr = path3.resolve(src).split(path3.sep).filter((i) => i);
1222
- const destArr = path3.resolve(dest).split(path3.sep).filter((i) => i);
1223
- return srcArr.reduce((acc, cur, i) => acc && destArr[i] === cur, true);
1224
- }
1225
- function errMsg(src, dest, funcName) {
1226
- return `Cannot ${funcName} '${src}' to a subdirectory of itself, '${dest}'.`;
1227
- }
1228
- module2.exports = {
1229
- checkPaths,
1230
- checkPathsSync,
1231
- checkParentPaths,
1232
- checkParentPathsSync,
1233
- isSrcSubdir,
1234
- areIdentical
1235
- };
1236
- }
1237
- });
1238
-
1239
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/copy/copy.js
1240
- var require_copy = __commonJS({
1241
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/copy/copy.js"(exports, module2) {
1242
- "use strict";
1243
- var fs2 = require_graceful_fs();
1244
- var path3 = require("path");
1245
- var mkdirs = require_mkdirs().mkdirs;
1246
- var pathExists = require_path_exists().pathExists;
1247
- var utimesMillis = require_utimes().utimesMillis;
1248
- var stat = require_stat();
1249
- function copy(src, dest, opts, cb) {
1250
- if (typeof opts === "function" && !cb) {
1251
- cb = opts;
1252
- opts = {};
1253
- } else if (typeof opts === "function") {
1254
- opts = { filter: opts };
1255
- }
1256
- cb = cb || function() {
1257
- };
1258
- opts = opts || {};
1259
- opts.clobber = "clobber" in opts ? !!opts.clobber : true;
1260
- opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
1261
- if (opts.preserveTimestamps && process.arch === "ia32") {
1262
- process.emitWarning(
1263
- "Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269",
1264
- "Warning",
1265
- "fs-extra-WARN0001"
1266
- );
1267
- }
1268
- stat.checkPaths(src, dest, "copy", opts, (err, stats) => {
1269
- if (err)
1270
- return cb(err);
1271
- const { srcStat, destStat } = stats;
1272
- stat.checkParentPaths(src, srcStat, dest, "copy", (err2) => {
1273
- if (err2)
1274
- return cb(err2);
1275
- runFilter(src, dest, opts, (err3, include) => {
1276
- if (err3)
1277
- return cb(err3);
1278
- if (!include)
1279
- return cb();
1280
- checkParentDir(destStat, src, dest, opts, cb);
1281
- });
1282
- });
1283
- });
1284
- }
1285
- function checkParentDir(destStat, src, dest, opts, cb) {
1286
- const destParent = path3.dirname(dest);
1287
- pathExists(destParent, (err, dirExists) => {
1288
- if (err)
1289
- return cb(err);
1290
- if (dirExists)
1291
- return getStats(destStat, src, dest, opts, cb);
1292
- mkdirs(destParent, (err2) => {
1293
- if (err2)
1294
- return cb(err2);
1295
- return getStats(destStat, src, dest, opts, cb);
1296
- });
1297
- });
1298
- }
1299
- function runFilter(src, dest, opts, cb) {
1300
- if (!opts.filter)
1301
- return cb(null, true);
1302
- Promise.resolve(opts.filter(src, dest)).then((include) => cb(null, include), (error) => cb(error));
1303
- }
1304
- function getStats(destStat, src, dest, opts, cb) {
1305
- const stat2 = opts.dereference ? fs2.stat : fs2.lstat;
1306
- stat2(src, (err, srcStat) => {
1307
- if (err)
1308
- return cb(err);
1309
- if (srcStat.isDirectory())
1310
- return onDir(srcStat, destStat, src, dest, opts, cb);
1311
- else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice())
1312
- return onFile(srcStat, destStat, src, dest, opts, cb);
1313
- else if (srcStat.isSymbolicLink())
1314
- return onLink(destStat, src, dest, opts, cb);
1315
- else if (srcStat.isSocket())
1316
- return cb(new Error(`Cannot copy a socket file: ${src}`));
1317
- else if (srcStat.isFIFO())
1318
- return cb(new Error(`Cannot copy a FIFO pipe: ${src}`));
1319
- return cb(new Error(`Unknown file: ${src}`));
1320
- });
1321
- }
1322
- function onFile(srcStat, destStat, src, dest, opts, cb) {
1323
- if (!destStat)
1324
- return copyFile(srcStat, src, dest, opts, cb);
1325
- return mayCopyFile(srcStat, src, dest, opts, cb);
1326
- }
1327
- function mayCopyFile(srcStat, src, dest, opts, cb) {
1328
- if (opts.overwrite) {
1329
- fs2.unlink(dest, (err) => {
1330
- if (err)
1331
- return cb(err);
1332
- return copyFile(srcStat, src, dest, opts, cb);
1333
- });
1334
- } else if (opts.errorOnExist) {
1335
- return cb(new Error(`'${dest}' already exists`));
1336
- } else
1337
- return cb();
1338
- }
1339
- function copyFile(srcStat, src, dest, opts, cb) {
1340
- fs2.copyFile(src, dest, (err) => {
1341
- if (err)
1342
- return cb(err);
1343
- if (opts.preserveTimestamps)
1344
- return handleTimestampsAndMode(srcStat.mode, src, dest, cb);
1345
- return setDestMode(dest, srcStat.mode, cb);
1346
- });
1347
- }
1348
- function handleTimestampsAndMode(srcMode, src, dest, cb) {
1349
- if (fileIsNotWritable(srcMode)) {
1350
- return makeFileWritable(dest, srcMode, (err) => {
1351
- if (err)
1352
- return cb(err);
1353
- return setDestTimestampsAndMode(srcMode, src, dest, cb);
1354
- });
1355
- }
1356
- return setDestTimestampsAndMode(srcMode, src, dest, cb);
1357
- }
1358
- function fileIsNotWritable(srcMode) {
1359
- return (srcMode & 128) === 0;
1360
- }
1361
- function makeFileWritable(dest, srcMode, cb) {
1362
- return setDestMode(dest, srcMode | 128, cb);
1363
- }
1364
- function setDestTimestampsAndMode(srcMode, src, dest, cb) {
1365
- setDestTimestamps(src, dest, (err) => {
1366
- if (err)
1367
- return cb(err);
1368
- return setDestMode(dest, srcMode, cb);
1369
- });
1370
- }
1371
- function setDestMode(dest, srcMode, cb) {
1372
- return fs2.chmod(dest, srcMode, cb);
1373
- }
1374
- function setDestTimestamps(src, dest, cb) {
1375
- fs2.stat(src, (err, updatedSrcStat) => {
1376
- if (err)
1377
- return cb(err);
1378
- return utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime, cb);
1379
- });
1380
- }
1381
- function onDir(srcStat, destStat, src, dest, opts, cb) {
1382
- if (!destStat)
1383
- return mkDirAndCopy(srcStat.mode, src, dest, opts, cb);
1384
- return copyDir(src, dest, opts, cb);
1385
- }
1386
- function mkDirAndCopy(srcMode, src, dest, opts, cb) {
1387
- fs2.mkdir(dest, (err) => {
1388
- if (err)
1389
- return cb(err);
1390
- copyDir(src, dest, opts, (err2) => {
1391
- if (err2)
1392
- return cb(err2);
1393
- return setDestMode(dest, srcMode, cb);
1394
- });
1395
- });
1396
- }
1397
- function copyDir(src, dest, opts, cb) {
1398
- fs2.readdir(src, (err, items) => {
1399
- if (err)
1400
- return cb(err);
1401
- return copyDirItems(items, src, dest, opts, cb);
1402
- });
1403
- }
1404
- function copyDirItems(items, src, dest, opts, cb) {
1405
- const item = items.pop();
1406
- if (!item)
1407
- return cb();
1408
- return copyDirItem(items, item, src, dest, opts, cb);
1409
- }
1410
- function copyDirItem(items, item, src, dest, opts, cb) {
1411
- const srcItem = path3.join(src, item);
1412
- const destItem = path3.join(dest, item);
1413
- runFilter(srcItem, destItem, opts, (err, include) => {
1414
- if (err)
1415
- return cb(err);
1416
- if (!include)
1417
- return copyDirItems(items, src, dest, opts, cb);
1418
- stat.checkPaths(srcItem, destItem, "copy", opts, (err2, stats) => {
1419
- if (err2)
1420
- return cb(err2);
1421
- const { destStat } = stats;
1422
- getStats(destStat, srcItem, destItem, opts, (err3) => {
1423
- if (err3)
1424
- return cb(err3);
1425
- return copyDirItems(items, src, dest, opts, cb);
1426
- });
1427
- });
1428
- });
1429
- }
1430
- function onLink(destStat, src, dest, opts, cb) {
1431
- fs2.readlink(src, (err, resolvedSrc) => {
1432
- if (err)
1433
- return cb(err);
1434
- if (opts.dereference) {
1435
- resolvedSrc = path3.resolve(process.cwd(), resolvedSrc);
1436
- }
1437
- if (!destStat) {
1438
- return fs2.symlink(resolvedSrc, dest, cb);
1439
- } else {
1440
- fs2.readlink(dest, (err2, resolvedDest) => {
1441
- if (err2) {
1442
- if (err2.code === "EINVAL" || err2.code === "UNKNOWN")
1443
- return fs2.symlink(resolvedSrc, dest, cb);
1444
- return cb(err2);
1445
- }
1446
- if (opts.dereference) {
1447
- resolvedDest = path3.resolve(process.cwd(), resolvedDest);
1448
- }
1449
- if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
1450
- return cb(new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`));
1451
- }
1452
- if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
1453
- return cb(new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`));
1454
- }
1455
- return copyLink(resolvedSrc, dest, cb);
1456
- });
1457
- }
1458
- });
1459
- }
1460
- function copyLink(resolvedSrc, dest, cb) {
1461
- fs2.unlink(dest, (err) => {
1462
- if (err)
1463
- return cb(err);
1464
- return fs2.symlink(resolvedSrc, dest, cb);
1465
- });
1466
- }
1467
- module2.exports = copy;
1468
- }
1469
- });
1470
-
1471
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/copy/copy-sync.js
1472
- var require_copy_sync = __commonJS({
1473
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/copy/copy-sync.js"(exports, module2) {
1474
- "use strict";
1475
- var fs2 = require_graceful_fs();
1476
- var path3 = require("path");
1477
- var mkdirsSync = require_mkdirs().mkdirsSync;
1478
- var utimesMillisSync = require_utimes().utimesMillisSync;
1479
- var stat = require_stat();
1480
- function copySync(src, dest, opts) {
1481
- if (typeof opts === "function") {
1482
- opts = { filter: opts };
1483
- }
1484
- opts = opts || {};
1485
- opts.clobber = "clobber" in opts ? !!opts.clobber : true;
1486
- opts.overwrite = "overwrite" in opts ? !!opts.overwrite : opts.clobber;
1487
- if (opts.preserveTimestamps && process.arch === "ia32") {
1488
- process.emitWarning(
1489
- "Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269",
1490
- "Warning",
1491
- "fs-extra-WARN0002"
1492
- );
1493
- }
1494
- const { srcStat, destStat } = stat.checkPathsSync(src, dest, "copy", opts);
1495
- stat.checkParentPathsSync(src, srcStat, dest, "copy");
1496
- if (opts.filter && !opts.filter(src, dest))
1497
- return;
1498
- const destParent = path3.dirname(dest);
1499
- if (!fs2.existsSync(destParent))
1500
- mkdirsSync(destParent);
1501
- return getStats(destStat, src, dest, opts);
1502
- }
1503
- function getStats(destStat, src, dest, opts) {
1504
- const statSync = opts.dereference ? fs2.statSync : fs2.lstatSync;
1505
- const srcStat = statSync(src);
1506
- if (srcStat.isDirectory())
1507
- return onDir(srcStat, destStat, src, dest, opts);
1508
- else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice())
1509
- return onFile(srcStat, destStat, src, dest, opts);
1510
- else if (srcStat.isSymbolicLink())
1511
- return onLink(destStat, src, dest, opts);
1512
- else if (srcStat.isSocket())
1513
- throw new Error(`Cannot copy a socket file: ${src}`);
1514
- else if (srcStat.isFIFO())
1515
- throw new Error(`Cannot copy a FIFO pipe: ${src}`);
1516
- throw new Error(`Unknown file: ${src}`);
1517
- }
1518
- function onFile(srcStat, destStat, src, dest, opts) {
1519
- if (!destStat)
1520
- return copyFile(srcStat, src, dest, opts);
1521
- return mayCopyFile(srcStat, src, dest, opts);
1522
- }
1523
- function mayCopyFile(srcStat, src, dest, opts) {
1524
- if (opts.overwrite) {
1525
- fs2.unlinkSync(dest);
1526
- return copyFile(srcStat, src, dest, opts);
1527
- } else if (opts.errorOnExist) {
1528
- throw new Error(`'${dest}' already exists`);
1529
- }
1530
- }
1531
- function copyFile(srcStat, src, dest, opts) {
1532
- fs2.copyFileSync(src, dest);
1533
- if (opts.preserveTimestamps)
1534
- handleTimestamps(srcStat.mode, src, dest);
1535
- return setDestMode(dest, srcStat.mode);
1536
- }
1537
- function handleTimestamps(srcMode, src, dest) {
1538
- if (fileIsNotWritable(srcMode))
1539
- makeFileWritable(dest, srcMode);
1540
- return setDestTimestamps(src, dest);
1541
- }
1542
- function fileIsNotWritable(srcMode) {
1543
- return (srcMode & 128) === 0;
1544
- }
1545
- function makeFileWritable(dest, srcMode) {
1546
- return setDestMode(dest, srcMode | 128);
1547
- }
1548
- function setDestMode(dest, srcMode) {
1549
- return fs2.chmodSync(dest, srcMode);
1550
- }
1551
- function setDestTimestamps(src, dest) {
1552
- const updatedSrcStat = fs2.statSync(src);
1553
- return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
1554
- }
1555
- function onDir(srcStat, destStat, src, dest, opts) {
1556
- if (!destStat)
1557
- return mkDirAndCopy(srcStat.mode, src, dest, opts);
1558
- return copyDir(src, dest, opts);
1559
- }
1560
- function mkDirAndCopy(srcMode, src, dest, opts) {
1561
- fs2.mkdirSync(dest);
1562
- copyDir(src, dest, opts);
1563
- return setDestMode(dest, srcMode);
1564
- }
1565
- function copyDir(src, dest, opts) {
1566
- fs2.readdirSync(src).forEach((item) => copyDirItem(item, src, dest, opts));
1567
- }
1568
- function copyDirItem(item, src, dest, opts) {
1569
- const srcItem = path3.join(src, item);
1570
- const destItem = path3.join(dest, item);
1571
- if (opts.filter && !opts.filter(srcItem, destItem))
1572
- return;
1573
- const { destStat } = stat.checkPathsSync(srcItem, destItem, "copy", opts);
1574
- return getStats(destStat, srcItem, destItem, opts);
1575
- }
1576
- function onLink(destStat, src, dest, opts) {
1577
- let resolvedSrc = fs2.readlinkSync(src);
1578
- if (opts.dereference) {
1579
- resolvedSrc = path3.resolve(process.cwd(), resolvedSrc);
1580
- }
1581
- if (!destStat) {
1582
- return fs2.symlinkSync(resolvedSrc, dest);
1583
- } else {
1584
- let resolvedDest;
1585
- try {
1586
- resolvedDest = fs2.readlinkSync(dest);
1587
- } catch (err) {
1588
- if (err.code === "EINVAL" || err.code === "UNKNOWN")
1589
- return fs2.symlinkSync(resolvedSrc, dest);
1590
- throw err;
1591
- }
1592
- if (opts.dereference) {
1593
- resolvedDest = path3.resolve(process.cwd(), resolvedDest);
1594
- }
1595
- if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
1596
- throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
1597
- }
1598
- if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
1599
- throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
1600
- }
1601
- return copyLink(resolvedSrc, dest);
1602
- }
1603
- }
1604
- function copyLink(resolvedSrc, dest) {
1605
- fs2.unlinkSync(dest);
1606
- return fs2.symlinkSync(resolvedSrc, dest);
1607
- }
1608
- module2.exports = copySync;
1609
- }
1610
- });
1611
-
1612
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/copy/index.js
1613
- var require_copy2 = __commonJS({
1614
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/copy/index.js"(exports, module2) {
1615
- "use strict";
1616
- var u = require_universalify().fromCallback;
1617
- module2.exports = {
1618
- copy: u(require_copy()),
1619
- copySync: require_copy_sync()
1620
- };
1621
- }
1622
- });
1623
-
1624
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/remove/index.js
1625
- var require_remove = __commonJS({
1626
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/remove/index.js"(exports, module2) {
1627
- "use strict";
1628
- var fs2 = require_graceful_fs();
1629
- var u = require_universalify().fromCallback;
1630
- function remove(path3, callback) {
1631
- fs2.rm(path3, { recursive: true, force: true }, callback);
1632
- }
1633
- function removeSync(path3) {
1634
- fs2.rmSync(path3, { recursive: true, force: true });
1635
- }
1636
- module2.exports = {
1637
- remove: u(remove),
1638
- removeSync
1639
- };
1640
- }
1641
- });
1642
-
1643
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/empty/index.js
1644
- var require_empty = __commonJS({
1645
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/empty/index.js"(exports, module2) {
1646
- "use strict";
1647
- var u = require_universalify().fromPromise;
1648
- var fs2 = require_fs();
1649
- var path3 = require("path");
1650
- var mkdir = require_mkdirs();
1651
- var remove = require_remove();
1652
- var emptyDir = u(async function emptyDir2(dir) {
1653
- let items;
1654
- try {
1655
- items = await fs2.readdir(dir);
1656
- } catch {
1657
- return mkdir.mkdirs(dir);
1658
- }
1659
- return Promise.all(items.map((item) => remove.remove(path3.join(dir, item))));
1660
- });
1661
- function emptyDirSync(dir) {
1662
- let items;
1663
- try {
1664
- items = fs2.readdirSync(dir);
1665
- } catch {
1666
- return mkdir.mkdirsSync(dir);
1667
- }
1668
- items.forEach((item) => {
1669
- item = path3.join(dir, item);
1670
- remove.removeSync(item);
1671
- });
1672
- }
1673
- module2.exports = {
1674
- emptyDirSync,
1675
- emptydirSync: emptyDirSync,
1676
- emptyDir,
1677
- emptydir: emptyDir
1678
- };
1679
- }
1680
- });
1681
-
1682
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/ensure/file.js
1683
- var require_file = __commonJS({
1684
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/ensure/file.js"(exports, module2) {
1685
- "use strict";
1686
- var u = require_universalify().fromCallback;
1687
- var path3 = require("path");
1688
- var fs2 = require_graceful_fs();
1689
- var mkdir = require_mkdirs();
1690
- function createFile(file, callback) {
1691
- function makeFile() {
1692
- fs2.writeFile(file, "", (err) => {
1693
- if (err)
1694
- return callback(err);
1695
- callback();
1696
- });
1697
- }
1698
- fs2.stat(file, (err, stats) => {
1699
- if (!err && stats.isFile())
1700
- return callback();
1701
- const dir = path3.dirname(file);
1702
- fs2.stat(dir, (err2, stats2) => {
1703
- if (err2) {
1704
- if (err2.code === "ENOENT") {
1705
- return mkdir.mkdirs(dir, (err3) => {
1706
- if (err3)
1707
- return callback(err3);
1708
- makeFile();
1709
- });
1710
- }
1711
- return callback(err2);
1712
- }
1713
- if (stats2.isDirectory())
1714
- makeFile();
1715
- else {
1716
- fs2.readdir(dir, (err3) => {
1717
- if (err3)
1718
- return callback(err3);
1719
- });
1720
- }
1721
- });
1722
- });
1723
- }
1724
- function createFileSync(file) {
1725
- let stats;
1726
- try {
1727
- stats = fs2.statSync(file);
1728
- } catch {
1729
- }
1730
- if (stats && stats.isFile())
1731
- return;
1732
- const dir = path3.dirname(file);
1733
- try {
1734
- if (!fs2.statSync(dir).isDirectory()) {
1735
- fs2.readdirSync(dir);
1736
- }
1737
- } catch (err) {
1738
- if (err && err.code === "ENOENT")
1739
- mkdir.mkdirsSync(dir);
1740
- else
1741
- throw err;
1742
- }
1743
- fs2.writeFileSync(file, "");
1744
- }
1745
- module2.exports = {
1746
- createFile: u(createFile),
1747
- createFileSync
1748
- };
1749
- }
1750
- });
1751
-
1752
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/ensure/link.js
1753
- var require_link = __commonJS({
1754
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/ensure/link.js"(exports, module2) {
1755
- "use strict";
1756
- var u = require_universalify().fromCallback;
1757
- var path3 = require("path");
1758
- var fs2 = require_graceful_fs();
1759
- var mkdir = require_mkdirs();
1760
- var pathExists = require_path_exists().pathExists;
1761
- var { areIdentical } = require_stat();
1762
- function createLink(srcpath, dstpath, callback) {
1763
- function makeLink(srcpath2, dstpath2) {
1764
- fs2.link(srcpath2, dstpath2, (err) => {
1765
- if (err)
1766
- return callback(err);
1767
- callback(null);
1768
- });
1769
- }
1770
- fs2.lstat(dstpath, (_, dstStat) => {
1771
- fs2.lstat(srcpath, (err, srcStat) => {
1772
- if (err) {
1773
- err.message = err.message.replace("lstat", "ensureLink");
1774
- return callback(err);
1775
- }
1776
- if (dstStat && areIdentical(srcStat, dstStat))
1777
- return callback(null);
1778
- const dir = path3.dirname(dstpath);
1779
- pathExists(dir, (err2, dirExists) => {
1780
- if (err2)
1781
- return callback(err2);
1782
- if (dirExists)
1783
- return makeLink(srcpath, dstpath);
1784
- mkdir.mkdirs(dir, (err3) => {
1785
- if (err3)
1786
- return callback(err3);
1787
- makeLink(srcpath, dstpath);
1788
- });
1789
- });
1790
- });
1791
- });
1792
- }
1793
- function createLinkSync(srcpath, dstpath) {
1794
- let dstStat;
1795
- try {
1796
- dstStat = fs2.lstatSync(dstpath);
1797
- } catch {
1798
- }
1799
- try {
1800
- const srcStat = fs2.lstatSync(srcpath);
1801
- if (dstStat && areIdentical(srcStat, dstStat))
1802
- return;
1803
- } catch (err) {
1804
- err.message = err.message.replace("lstat", "ensureLink");
1805
- throw err;
1806
- }
1807
- const dir = path3.dirname(dstpath);
1808
- const dirExists = fs2.existsSync(dir);
1809
- if (dirExists)
1810
- return fs2.linkSync(srcpath, dstpath);
1811
- mkdir.mkdirsSync(dir);
1812
- return fs2.linkSync(srcpath, dstpath);
1813
- }
1814
- module2.exports = {
1815
- createLink: u(createLink),
1816
- createLinkSync
1817
- };
1818
- }
1819
- });
1820
-
1821
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/ensure/symlink-paths.js
1822
- var require_symlink_paths = __commonJS({
1823
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/ensure/symlink-paths.js"(exports, module2) {
1824
- "use strict";
1825
- var path3 = require("path");
1826
- var fs2 = require_graceful_fs();
1827
- var pathExists = require_path_exists().pathExists;
1828
- function symlinkPaths(srcpath, dstpath, callback) {
1829
- if (path3.isAbsolute(srcpath)) {
1830
- return fs2.lstat(srcpath, (err) => {
1831
- if (err) {
1832
- err.message = err.message.replace("lstat", "ensureSymlink");
1833
- return callback(err);
1834
- }
1835
- return callback(null, {
1836
- toCwd: srcpath,
1837
- toDst: srcpath
1838
- });
1839
- });
1840
- } else {
1841
- const dstdir = path3.dirname(dstpath);
1842
- const relativeToDst = path3.join(dstdir, srcpath);
1843
- return pathExists(relativeToDst, (err, exists) => {
1844
- if (err)
1845
- return callback(err);
1846
- if (exists) {
1847
- return callback(null, {
1848
- toCwd: relativeToDst,
1849
- toDst: srcpath
1850
- });
1851
- } else {
1852
- return fs2.lstat(srcpath, (err2) => {
1853
- if (err2) {
1854
- err2.message = err2.message.replace("lstat", "ensureSymlink");
1855
- return callback(err2);
1856
- }
1857
- return callback(null, {
1858
- toCwd: srcpath,
1859
- toDst: path3.relative(dstdir, srcpath)
1860
- });
1861
- });
1862
- }
1863
- });
1864
- }
1865
- }
1866
- function symlinkPathsSync(srcpath, dstpath) {
1867
- let exists;
1868
- if (path3.isAbsolute(srcpath)) {
1869
- exists = fs2.existsSync(srcpath);
1870
- if (!exists)
1871
- throw new Error("absolute srcpath does not exist");
1872
- return {
1873
- toCwd: srcpath,
1874
- toDst: srcpath
1875
- };
1876
- } else {
1877
- const dstdir = path3.dirname(dstpath);
1878
- const relativeToDst = path3.join(dstdir, srcpath);
1879
- exists = fs2.existsSync(relativeToDst);
1880
- if (exists) {
1881
- return {
1882
- toCwd: relativeToDst,
1883
- toDst: srcpath
1884
- };
1885
- } else {
1886
- exists = fs2.existsSync(srcpath);
1887
- if (!exists)
1888
- throw new Error("relative srcpath does not exist");
1889
- return {
1890
- toCwd: srcpath,
1891
- toDst: path3.relative(dstdir, srcpath)
1892
- };
1893
- }
1894
- }
1895
- }
1896
- module2.exports = {
1897
- symlinkPaths,
1898
- symlinkPathsSync
1899
- };
1900
- }
1901
- });
1902
-
1903
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/ensure/symlink-type.js
1904
- var require_symlink_type = __commonJS({
1905
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/ensure/symlink-type.js"(exports, module2) {
1906
- "use strict";
1907
- var fs2 = require_graceful_fs();
1908
- function symlinkType(srcpath, type, callback) {
1909
- callback = typeof type === "function" ? type : callback;
1910
- type = typeof type === "function" ? false : type;
1911
- if (type)
1912
- return callback(null, type);
1913
- fs2.lstat(srcpath, (err, stats) => {
1914
- if (err)
1915
- return callback(null, "file");
1916
- type = stats && stats.isDirectory() ? "dir" : "file";
1917
- callback(null, type);
1918
- });
1919
- }
1920
- function symlinkTypeSync(srcpath, type) {
1921
- let stats;
1922
- if (type)
1923
- return type;
1924
- try {
1925
- stats = fs2.lstatSync(srcpath);
1926
- } catch {
1927
- return "file";
1928
- }
1929
- return stats && stats.isDirectory() ? "dir" : "file";
1930
- }
1931
- module2.exports = {
1932
- symlinkType,
1933
- symlinkTypeSync
1934
- };
1935
- }
1936
- });
1937
-
1938
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/ensure/symlink.js
1939
- var require_symlink = __commonJS({
1940
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/ensure/symlink.js"(exports, module2) {
1941
- "use strict";
1942
- var u = require_universalify().fromCallback;
1943
- var path3 = require("path");
1944
- var fs2 = require_fs();
1945
- var _mkdirs = require_mkdirs();
1946
- var mkdirs = _mkdirs.mkdirs;
1947
- var mkdirsSync = _mkdirs.mkdirsSync;
1948
- var _symlinkPaths = require_symlink_paths();
1949
- var symlinkPaths = _symlinkPaths.symlinkPaths;
1950
- var symlinkPathsSync = _symlinkPaths.symlinkPathsSync;
1951
- var _symlinkType = require_symlink_type();
1952
- var symlinkType = _symlinkType.symlinkType;
1953
- var symlinkTypeSync = _symlinkType.symlinkTypeSync;
1954
- var pathExists = require_path_exists().pathExists;
1955
- var { areIdentical } = require_stat();
1956
- function createSymlink(srcpath, dstpath, type, callback) {
1957
- callback = typeof type === "function" ? type : callback;
1958
- type = typeof type === "function" ? false : type;
1959
- fs2.lstat(dstpath, (err, stats) => {
1960
- if (!err && stats.isSymbolicLink()) {
1961
- Promise.all([
1962
- fs2.stat(srcpath),
1963
- fs2.stat(dstpath)
1964
- ]).then(([srcStat, dstStat]) => {
1965
- if (areIdentical(srcStat, dstStat))
1966
- return callback(null);
1967
- _createSymlink(srcpath, dstpath, type, callback);
1968
- });
1969
- } else
1970
- _createSymlink(srcpath, dstpath, type, callback);
1971
- });
1972
- }
1973
- function _createSymlink(srcpath, dstpath, type, callback) {
1974
- symlinkPaths(srcpath, dstpath, (err, relative) => {
1975
- if (err)
1976
- return callback(err);
1977
- srcpath = relative.toDst;
1978
- symlinkType(relative.toCwd, type, (err2, type2) => {
1979
- if (err2)
1980
- return callback(err2);
1981
- const dir = path3.dirname(dstpath);
1982
- pathExists(dir, (err3, dirExists) => {
1983
- if (err3)
1984
- return callback(err3);
1985
- if (dirExists)
1986
- return fs2.symlink(srcpath, dstpath, type2, callback);
1987
- mkdirs(dir, (err4) => {
1988
- if (err4)
1989
- return callback(err4);
1990
- fs2.symlink(srcpath, dstpath, type2, callback);
1991
- });
1992
- });
1993
- });
1994
- });
1995
- }
1996
- function createSymlinkSync(srcpath, dstpath, type) {
1997
- let stats;
1998
- try {
1999
- stats = fs2.lstatSync(dstpath);
2000
- } catch {
2001
- }
2002
- if (stats && stats.isSymbolicLink()) {
2003
- const srcStat = fs2.statSync(srcpath);
2004
- const dstStat = fs2.statSync(dstpath);
2005
- if (areIdentical(srcStat, dstStat))
2006
- return;
2007
- }
2008
- const relative = symlinkPathsSync(srcpath, dstpath);
2009
- srcpath = relative.toDst;
2010
- type = symlinkTypeSync(relative.toCwd, type);
2011
- const dir = path3.dirname(dstpath);
2012
- const exists = fs2.existsSync(dir);
2013
- if (exists)
2014
- return fs2.symlinkSync(srcpath, dstpath, type);
2015
- mkdirsSync(dir);
2016
- return fs2.symlinkSync(srcpath, dstpath, type);
2017
- }
2018
- module2.exports = {
2019
- createSymlink: u(createSymlink),
2020
- createSymlinkSync
2021
- };
2022
- }
2023
- });
2024
-
2025
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/ensure/index.js
2026
- var require_ensure = __commonJS({
2027
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/ensure/index.js"(exports, module2) {
2028
- "use strict";
2029
- var { createFile, createFileSync } = require_file();
2030
- var { createLink, createLinkSync } = require_link();
2031
- var { createSymlink, createSymlinkSync } = require_symlink();
2032
- module2.exports = {
2033
- // file
2034
- createFile,
2035
- createFileSync,
2036
- ensureFile: createFile,
2037
- ensureFileSync: createFileSync,
2038
- // link
2039
- createLink,
2040
- createLinkSync,
2041
- ensureLink: createLink,
2042
- ensureLinkSync: createLinkSync,
2043
- // symlink
2044
- createSymlink,
2045
- createSymlinkSync,
2046
- ensureSymlink: createSymlink,
2047
- ensureSymlinkSync: createSymlinkSync
2048
- };
2049
- }
2050
- });
2051
-
2052
- // ../../node_modules/.pnpm/jsonfile@6.1.0/node_modules/jsonfile/utils.js
2053
- var require_utils2 = __commonJS({
2054
- "../../node_modules/.pnpm/jsonfile@6.1.0/node_modules/jsonfile/utils.js"(exports, module2) {
2055
- function stringify(obj, { EOL = "\n", finalEOL = true, replacer = null, spaces } = {}) {
2056
- const EOF = finalEOL ? EOL : "";
2057
- const str = JSON.stringify(obj, replacer, spaces);
2058
- return str.replace(/\n/g, EOL) + EOF;
2059
- }
2060
- function stripBom(content) {
2061
- if (Buffer.isBuffer(content))
2062
- content = content.toString("utf8");
2063
- return content.replace(/^\uFEFF/, "");
2064
- }
2065
- module2.exports = { stringify, stripBom };
2066
- }
2067
- });
2068
-
2069
- // ../../node_modules/.pnpm/jsonfile@6.1.0/node_modules/jsonfile/index.js
2070
- var require_jsonfile = __commonJS({
2071
- "../../node_modules/.pnpm/jsonfile@6.1.0/node_modules/jsonfile/index.js"(exports, module2) {
2072
- var _fs;
2073
- try {
2074
- _fs = require_graceful_fs();
2075
- } catch (_) {
2076
- _fs = require("fs");
2077
- }
2078
- var universalify = require_universalify();
2079
- var { stringify, stripBom } = require_utils2();
2080
- async function _readFile(file, options = {}) {
2081
- if (typeof options === "string") {
2082
- options = { encoding: options };
2083
- }
2084
- const fs2 = options.fs || _fs;
2085
- const shouldThrow = "throws" in options ? options.throws : true;
2086
- let data = await universalify.fromCallback(fs2.readFile)(file, options);
2087
- data = stripBom(data);
2088
- let obj;
2089
- try {
2090
- obj = JSON.parse(data, options ? options.reviver : null);
2091
- } catch (err) {
2092
- if (shouldThrow) {
2093
- err.message = `${file}: ${err.message}`;
2094
- throw err;
2095
- } else {
2096
- return null;
2097
- }
2098
- }
2099
- return obj;
2100
- }
2101
- var readFile = universalify.fromPromise(_readFile);
2102
- function readFileSync(file, options = {}) {
2103
- if (typeof options === "string") {
2104
- options = { encoding: options };
2105
- }
2106
- const fs2 = options.fs || _fs;
2107
- const shouldThrow = "throws" in options ? options.throws : true;
2108
- try {
2109
- let content = fs2.readFileSync(file, options);
2110
- content = stripBom(content);
2111
- return JSON.parse(content, options.reviver);
2112
- } catch (err) {
2113
- if (shouldThrow) {
2114
- err.message = `${file}: ${err.message}`;
2115
- throw err;
2116
- } else {
2117
- return null;
2118
- }
2119
- }
2120
- }
2121
- async function _writeFile(file, obj, options = {}) {
2122
- const fs2 = options.fs || _fs;
2123
- const str = stringify(obj, options);
2124
- await universalify.fromCallback(fs2.writeFile)(file, str, options);
2125
- }
2126
- var writeFile = universalify.fromPromise(_writeFile);
2127
- function writeFileSync(file, obj, options = {}) {
2128
- const fs2 = options.fs || _fs;
2129
- const str = stringify(obj, options);
2130
- return fs2.writeFileSync(file, str, options);
2131
- }
2132
- var jsonfile = {
2133
- readFile,
2134
- readFileSync,
2135
- writeFile,
2136
- writeFileSync
2137
- };
2138
- module2.exports = jsonfile;
2139
- }
2140
- });
2141
-
2142
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/json/jsonfile.js
2143
- var require_jsonfile2 = __commonJS({
2144
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/json/jsonfile.js"(exports, module2) {
2145
- "use strict";
2146
- var jsonFile = require_jsonfile();
2147
- module2.exports = {
2148
- // jsonfile exports
2149
- readJson: jsonFile.readFile,
2150
- readJsonSync: jsonFile.readFileSync,
2151
- writeJson: jsonFile.writeFile,
2152
- writeJsonSync: jsonFile.writeFileSync
2153
- };
2154
- }
2155
- });
2156
-
2157
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/output-file/index.js
2158
- var require_output_file = __commonJS({
2159
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/output-file/index.js"(exports, module2) {
2160
- "use strict";
2161
- var u = require_universalify().fromCallback;
2162
- var fs2 = require_graceful_fs();
2163
- var path3 = require("path");
2164
- var mkdir = require_mkdirs();
2165
- var pathExists = require_path_exists().pathExists;
2166
- function outputFile(file, data, encoding, callback) {
2167
- if (typeof encoding === "function") {
2168
- callback = encoding;
2169
- encoding = "utf8";
2170
- }
2171
- const dir = path3.dirname(file);
2172
- pathExists(dir, (err, itDoes) => {
2173
- if (err)
2174
- return callback(err);
2175
- if (itDoes)
2176
- return fs2.writeFile(file, data, encoding, callback);
2177
- mkdir.mkdirs(dir, (err2) => {
2178
- if (err2)
2179
- return callback(err2);
2180
- fs2.writeFile(file, data, encoding, callback);
2181
- });
2182
- });
2183
- }
2184
- function outputFileSync(file, ...args) {
2185
- const dir = path3.dirname(file);
2186
- if (fs2.existsSync(dir)) {
2187
- return fs2.writeFileSync(file, ...args);
2188
- }
2189
- mkdir.mkdirsSync(dir);
2190
- fs2.writeFileSync(file, ...args);
2191
- }
2192
- module2.exports = {
2193
- outputFile: u(outputFile),
2194
- outputFileSync
2195
- };
2196
- }
2197
- });
2198
-
2199
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/json/output-json.js
2200
- var require_output_json = __commonJS({
2201
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/json/output-json.js"(exports, module2) {
2202
- "use strict";
2203
- var { stringify } = require_utils2();
2204
- var { outputFile } = require_output_file();
2205
- async function outputJson(file, data, options = {}) {
2206
- const str = stringify(data, options);
2207
- await outputFile(file, str, options);
2208
- }
2209
- module2.exports = outputJson;
2210
- }
2211
- });
2212
-
2213
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/json/output-json-sync.js
2214
- var require_output_json_sync = __commonJS({
2215
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/json/output-json-sync.js"(exports, module2) {
2216
- "use strict";
2217
- var { stringify } = require_utils2();
2218
- var { outputFileSync } = require_output_file();
2219
- function outputJsonSync(file, data, options) {
2220
- const str = stringify(data, options);
2221
- outputFileSync(file, str, options);
2222
- }
2223
- module2.exports = outputJsonSync;
2224
- }
2225
- });
2226
-
2227
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/json/index.js
2228
- var require_json = __commonJS({
2229
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/json/index.js"(exports, module2) {
2230
- "use strict";
2231
- var u = require_universalify().fromPromise;
2232
- var jsonFile = require_jsonfile2();
2233
- jsonFile.outputJson = u(require_output_json());
2234
- jsonFile.outputJsonSync = require_output_json_sync();
2235
- jsonFile.outputJSON = jsonFile.outputJson;
2236
- jsonFile.outputJSONSync = jsonFile.outputJsonSync;
2237
- jsonFile.writeJSON = jsonFile.writeJson;
2238
- jsonFile.writeJSONSync = jsonFile.writeJsonSync;
2239
- jsonFile.readJSON = jsonFile.readJson;
2240
- jsonFile.readJSONSync = jsonFile.readJsonSync;
2241
- module2.exports = jsonFile;
2242
- }
2243
- });
2244
-
2245
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/move/move.js
2246
- var require_move = __commonJS({
2247
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/move/move.js"(exports, module2) {
2248
- "use strict";
2249
- var fs2 = require_graceful_fs();
2250
- var path3 = require("path");
2251
- var copy = require_copy2().copy;
2252
- var remove = require_remove().remove;
2253
- var mkdirp = require_mkdirs().mkdirp;
2254
- var pathExists = require_path_exists().pathExists;
2255
- var stat = require_stat();
2256
- function move(src, dest, opts, cb) {
2257
- if (typeof opts === "function") {
2258
- cb = opts;
2259
- opts = {};
2260
- }
2261
- opts = opts || {};
2262
- const overwrite = opts.overwrite || opts.clobber || false;
2263
- stat.checkPaths(src, dest, "move", opts, (err, stats) => {
2264
- if (err)
2265
- return cb(err);
2266
- const { srcStat, isChangingCase = false } = stats;
2267
- stat.checkParentPaths(src, srcStat, dest, "move", (err2) => {
2268
- if (err2)
2269
- return cb(err2);
2270
- if (isParentRoot(dest))
2271
- return doRename(src, dest, overwrite, isChangingCase, cb);
2272
- mkdirp(path3.dirname(dest), (err3) => {
2273
- if (err3)
2274
- return cb(err3);
2275
- return doRename(src, dest, overwrite, isChangingCase, cb);
2276
- });
2277
- });
2278
- });
2279
- }
2280
- function isParentRoot(dest) {
2281
- const parent = path3.dirname(dest);
2282
- const parsedPath = path3.parse(parent);
2283
- return parsedPath.root === parent;
2284
- }
2285
- function doRename(src, dest, overwrite, isChangingCase, cb) {
2286
- if (isChangingCase)
2287
- return rename(src, dest, overwrite, cb);
2288
- if (overwrite) {
2289
- return remove(dest, (err) => {
2290
- if (err)
2291
- return cb(err);
2292
- return rename(src, dest, overwrite, cb);
2293
- });
2294
- }
2295
- pathExists(dest, (err, destExists) => {
2296
- if (err)
2297
- return cb(err);
2298
- if (destExists)
2299
- return cb(new Error("dest already exists."));
2300
- return rename(src, dest, overwrite, cb);
2301
- });
2302
- }
2303
- function rename(src, dest, overwrite, cb) {
2304
- fs2.rename(src, dest, (err) => {
2305
- if (!err)
2306
- return cb();
2307
- if (err.code !== "EXDEV")
2308
- return cb(err);
2309
- return moveAcrossDevice(src, dest, overwrite, cb);
2310
- });
2311
- }
2312
- function moveAcrossDevice(src, dest, overwrite, cb) {
2313
- const opts = {
2314
- overwrite,
2315
- errorOnExist: true,
2316
- preserveTimestamps: true
2317
- };
2318
- copy(src, dest, opts, (err) => {
2319
- if (err)
2320
- return cb(err);
2321
- return remove(src, cb);
2322
- });
2323
- }
2324
- module2.exports = move;
2325
- }
2326
- });
2327
-
2328
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/move/move-sync.js
2329
- var require_move_sync = __commonJS({
2330
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/move/move-sync.js"(exports, module2) {
2331
- "use strict";
2332
- var fs2 = require_graceful_fs();
2333
- var path3 = require("path");
2334
- var copySync = require_copy2().copySync;
2335
- var removeSync = require_remove().removeSync;
2336
- var mkdirpSync = require_mkdirs().mkdirpSync;
2337
- var stat = require_stat();
2338
- function moveSync(src, dest, opts) {
2339
- opts = opts || {};
2340
- const overwrite = opts.overwrite || opts.clobber || false;
2341
- const { srcStat, isChangingCase = false } = stat.checkPathsSync(src, dest, "move", opts);
2342
- stat.checkParentPathsSync(src, srcStat, dest, "move");
2343
- if (!isParentRoot(dest))
2344
- mkdirpSync(path3.dirname(dest));
2345
- return doRename(src, dest, overwrite, isChangingCase);
2346
- }
2347
- function isParentRoot(dest) {
2348
- const parent = path3.dirname(dest);
2349
- const parsedPath = path3.parse(parent);
2350
- return parsedPath.root === parent;
2351
- }
2352
- function doRename(src, dest, overwrite, isChangingCase) {
2353
- if (isChangingCase)
2354
- return rename(src, dest, overwrite);
2355
- if (overwrite) {
2356
- removeSync(dest);
2357
- return rename(src, dest, overwrite);
2358
- }
2359
- if (fs2.existsSync(dest))
2360
- throw new Error("dest already exists.");
2361
- return rename(src, dest, overwrite);
2362
- }
2363
- function rename(src, dest, overwrite) {
2364
- try {
2365
- fs2.renameSync(src, dest);
2366
- } catch (err) {
2367
- if (err.code !== "EXDEV")
2368
- throw err;
2369
- return moveAcrossDevice(src, dest, overwrite);
2370
- }
2371
- }
2372
- function moveAcrossDevice(src, dest, overwrite) {
2373
- const opts = {
2374
- overwrite,
2375
- errorOnExist: true,
2376
- preserveTimestamps: true
2377
- };
2378
- copySync(src, dest, opts);
2379
- return removeSync(src);
2380
- }
2381
- module2.exports = moveSync;
2382
- }
2383
- });
2384
-
2385
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/move/index.js
2386
- var require_move2 = __commonJS({
2387
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/move/index.js"(exports, module2) {
2388
- "use strict";
2389
- var u = require_universalify().fromCallback;
2390
- module2.exports = {
2391
- move: u(require_move()),
2392
- moveSync: require_move_sync()
2393
- };
2394
- }
2395
- });
2396
-
2397
- // ../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/index.js
2398
- var require_lib = __commonJS({
2399
- "../../node_modules/.pnpm/fs-extra@11.1.1/node_modules/fs-extra/lib/index.js"(exports, module2) {
2400
- "use strict";
2401
- module2.exports = {
2402
- // Export promiseified graceful-fs:
2403
- ...require_fs(),
2404
- // Export extra methods:
2405
- ...require_copy2(),
2406
- ...require_empty(),
2407
- ...require_ensure(),
2408
- ...require_json(),
2409
- ...require_mkdirs(),
2410
- ...require_move2(),
2411
- ...require_output_file(),
2412
- ...require_path_exists(),
2413
- ...require_remove()
2414
- };
2415
- }
2416
- });
2417
-
2418
- // ../../node_modules/.pnpm/rspack-plugin-virtual-module@0.1.11/node_modules/rspack-plugin-virtual-module/dist/index.js
2419
- var require_dist = __commonJS({
2420
- "../../node_modules/.pnpm/rspack-plugin-virtual-module@0.1.11/node_modules/rspack-plugin-virtual-module/dist/index.js"(exports) {
2421
- "use strict";
2422
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
2423
- if (k2 === void 0)
2424
- k2 = k;
2425
- var desc = Object.getOwnPropertyDescriptor(m, k);
2426
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
2427
- desc = { enumerable: true, get: function() {
2428
- return m[k];
2429
- } };
2430
- }
2431
- Object.defineProperty(o, k2, desc);
2432
- } : function(o, m, k, k2) {
2433
- if (k2 === void 0)
2434
- k2 = k;
2435
- o[k2] = m[k];
2436
- });
2437
- var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? function(o, v) {
2438
- Object.defineProperty(o, "default", { enumerable: true, value: v });
2439
- } : function(o, v) {
2440
- o["default"] = v;
2441
- });
2442
- var __importStar = exports && exports.__importStar || function(mod) {
2443
- if (mod && mod.__esModule)
2444
- return mod;
2445
- var result = {};
2446
- if (mod != null) {
2447
- for (var k in mod)
2448
- if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k))
2449
- __createBinding(result, mod, k);
2450
- }
2451
- __setModuleDefault(result, mod);
2452
- return result;
2453
- };
2454
- var __classPrivateFieldSet = exports && exports.__classPrivateFieldSet || function(receiver, state, value, kind, f) {
2455
- if (kind === "m")
2456
- throw new TypeError("Private method is not writable");
2457
- if (kind === "a" && !f)
2458
- throw new TypeError("Private accessor was defined without a setter");
2459
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2460
- throw new TypeError("Cannot write private member to an object whose class did not declare it");
2461
- return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
2462
- };
2463
- var __classPrivateFieldGet = exports && exports.__classPrivateFieldGet || function(receiver, state, kind, f) {
2464
- if (kind === "a" && !f)
2465
- throw new TypeError("Private accessor was defined without a getter");
2466
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
2467
- throw new TypeError("Cannot read private member from an object whose class did not declare it");
2468
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
2469
- };
2470
- var __importDefault = exports && exports.__importDefault || function(mod) {
2471
- return mod && mod.__esModule ? mod : { "default": mod };
2472
- };
2473
- var _RspackVirtualModulePlugin_instances;
2474
- var _RspackVirtualModulePlugin_staticModules;
2475
- var _RspackVirtualModulePlugin_tempDir;
2476
- var _RspackVirtualModulePlugin_normalizePath;
2477
- Object.defineProperty(exports, "__esModule", { value: true });
2478
- exports.RspackVirtualModulePlugin = void 0;
2479
- var path_1 = __importStar(require("path"));
2480
- var crypto_1 = __importDefault(require("crypto"));
2481
- var fs_extra_1 = __importDefault(require_lib());
2482
- var RspackVirtualModulePlugin2 = class {
2483
- constructor(staticModules) {
2484
- _RspackVirtualModulePlugin_instances.add(this);
2485
- _RspackVirtualModulePlugin_staticModules.set(this, void 0);
2486
- _RspackVirtualModulePlugin_tempDir.set(this, void 0);
2487
- __classPrivateFieldSet(this, _RspackVirtualModulePlugin_staticModules, staticModules, "f");
2488
- const nodeModulesDir = (0, path_1.join)(process.cwd(), "node_modules");
2489
- if (!fs_extra_1.default.existsSync(nodeModulesDir)) {
2490
- fs_extra_1.default.mkdirSync(nodeModulesDir);
2491
- }
2492
- const hash = crypto_1.default.createHash("md5").update(JSON.stringify(__classPrivateFieldGet(this, _RspackVirtualModulePlugin_staticModules, "f"))).digest("hex").slice(0, 8);
2493
- __classPrivateFieldSet(this, _RspackVirtualModulePlugin_tempDir, path_1.default.join(nodeModulesDir, `rspack-virtual-module-${hash}`), "f");
2494
- if (!fs_extra_1.default.existsSync(__classPrivateFieldGet(this, _RspackVirtualModulePlugin_tempDir, "f"))) {
2495
- fs_extra_1.default.mkdirSync(__classPrivateFieldGet(this, _RspackVirtualModulePlugin_tempDir, "f"));
2496
- }
2497
- }
2498
- apply(compiler) {
2499
- Object.entries(__classPrivateFieldGet(this, _RspackVirtualModulePlugin_staticModules, "f")).forEach(([path3, content]) => {
2500
- fs_extra_1.default.writeFileSync(__classPrivateFieldGet(this, _RspackVirtualModulePlugin_instances, "m", _RspackVirtualModulePlugin_normalizePath).call(this, path3), content);
2501
- });
2502
- const originalResolveModulesDir = compiler.options.resolve.modules || [
2503
- "node_modules"
2504
- ];
2505
- compiler.options.resolve.modules = [
2506
- ...originalResolveModulesDir,
2507
- __classPrivateFieldGet(this, _RspackVirtualModulePlugin_tempDir, "f")
2508
- ];
2509
- compiler.options.resolve.alias = Object.assign(Object.assign({}, compiler.options.resolve.alias), Object.keys(__classPrivateFieldGet(this, _RspackVirtualModulePlugin_staticModules, "f")).reduce((acc, p) => {
2510
- acc[p] = __classPrivateFieldGet(this, _RspackVirtualModulePlugin_instances, "m", _RspackVirtualModulePlugin_normalizePath).call(this, p);
2511
- return acc;
2512
- }, {}));
2513
- process.on("exit", this.clear.bind(this));
2514
- }
2515
- writeModule(path3, content) {
2516
- const normalizedPath = __classPrivateFieldGet(this, _RspackVirtualModulePlugin_instances, "m", _RspackVirtualModulePlugin_normalizePath).call(this, path3);
2517
- fs_extra_1.default.ensureDirSync((0, path_1.dirname)(normalizedPath));
2518
- fs_extra_1.default.writeFileSync(normalizedPath, content);
2519
- }
2520
- clear() {
2521
- fs_extra_1.default.removeSync(__classPrivateFieldGet(this, _RspackVirtualModulePlugin_tempDir, "f"));
2522
- }
2523
- };
2524
- exports.RspackVirtualModulePlugin = RspackVirtualModulePlugin2;
2525
- _RspackVirtualModulePlugin_staticModules = /* @__PURE__ */ new WeakMap(), _RspackVirtualModulePlugin_tempDir = /* @__PURE__ */ new WeakMap(), _RspackVirtualModulePlugin_instances = /* @__PURE__ */ new WeakSet(), _RspackVirtualModulePlugin_normalizePath = function _RspackVirtualModulePlugin_normalizePath2(p) {
2526
- const ext = (0, path_1.extname)(p);
2527
- return (0, path_1.join)(__classPrivateFieldGet(this, _RspackVirtualModulePlugin_tempDir, "f"), ext ? p : `${p}.js`);
2528
- };
2529
- exports.default = RspackVirtualModulePlugin2;
11
+ var __export = (target, all) => {
12
+ for (var name in all)
13
+ __defProp(target, name, { get: all[name], enumerable: true });
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
2530
20
  }
2531
- });
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2532
32
 
2533
33
  // ../../node_modules/.pnpm/unist-util-is@5.2.1/node_modules/unist-util-is/lib/index.js
2534
34
  function anyFactory(tests) {
@@ -2579,6 +79,7 @@ function ok() {
2579
79
  var convert;
2580
80
  var init_lib = __esm({
2581
81
  "../../node_modules/.pnpm/unist-util-is@5.2.1/node_modules/unist-util-is/lib/index.js"() {
82
+ "use strict";
2582
83
  convert = /**
2583
84
  * @type {(
2584
85
  * (<Kind extends Node>(test: PredicateTest<Kind>) => AssertPredicate<Kind>) &
@@ -2610,6 +111,7 @@ var init_lib = __esm({
2610
111
  // ../../node_modules/.pnpm/unist-util-is@5.2.1/node_modules/unist-util-is/index.js
2611
112
  var init_unist_util_is = __esm({
2612
113
  "../../node_modules/.pnpm/unist-util-is@5.2.1/node_modules/unist-util-is/index.js"() {
114
+ "use strict";
2613
115
  init_lib();
2614
116
  }
2615
117
  });
@@ -2620,6 +122,7 @@ function color(d) {
2620
122
  }
2621
123
  var init_color = __esm({
2622
124
  "../../node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/lib/color.js"() {
125
+ "use strict";
2623
126
  }
2624
127
  });
2625
128
 
@@ -2636,6 +139,7 @@ function toResult(value) {
2636
139
  var CONTINUE, EXIT, SKIP, visitParents;
2637
140
  var init_lib2 = __esm({
2638
141
  "../../node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/lib/index.js"() {
142
+ "use strict";
2639
143
  init_unist_util_is();
2640
144
  init_color();
2641
145
  CONTINUE = true;
@@ -2710,6 +214,7 @@ var init_lib2 = __esm({
2710
214
  // ../../node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/index.js
2711
215
  var init_unist_util_visit_parents = __esm({
2712
216
  "../../node_modules/.pnpm/unist-util-visit-parents@5.1.3/node_modules/unist-util-visit-parents/index.js"() {
217
+ "use strict";
2713
218
  init_lib2();
2714
219
  }
2715
220
  });
@@ -2725,6 +230,7 @@ __export(unist_util_visit_exports, {
2725
230
  var visit;
2726
231
  var init_unist_util_visit = __esm({
2727
232
  "../../node_modules/.pnpm/unist-util-visit@4.1.1/node_modules/unist-util-visit/index.js"() {
233
+ "use strict";
2728
234
  init_unist_util_visit_parents();
2729
235
  init_unist_util_visit_parents();
2730
236
  visit = /**
@@ -2767,8 +273,8 @@ __export(src_exports, {
2767
273
  routeMeta: () => routeMeta
2768
274
  });
2769
275
  module.exports = __toCommonJS(src_exports);
2770
- var import_path3 = __toESM(require("path"));
2771
- var import_rspack_plugin_virtual_module = __toESM(require_dist());
276
+ var import_path3 = require("path");
277
+ var import_rspack_plugin_virtual_module = require("rspack-plugin-virtual-module");
2772
278
  var import_shared2 = require("@rspress/shared");
2773
279
 
2774
280
  // src/codeToDemo.ts
@@ -2785,9 +291,12 @@ var toValidVarName = (str) => {
2785
291
  return str.replace(/[^0-9a-zA-Z_$]/g, "_").replace(/^([0-9])/, "_$1");
2786
292
  }
2787
293
  };
2788
- var injectDemoBlockImport = (str, path3) => {
294
+ var generateId = (pageName, index) => {
295
+ return `_${toValidVarName(pageName)}_${index}`;
296
+ };
297
+ var injectDemoBlockImport = (str, path2) => {
2789
298
  return `
2790
- import DemoBlock from '${path3}';
299
+ import DemoBlock from '${path2}';
2791
300
  ${str}
2792
301
  `;
2793
302
  };
@@ -2808,12 +317,15 @@ var demoBlockComponentPath = import_path.default.join(
2808
317
  );
2809
318
 
2810
319
  // src/codeToDemo.ts
2811
- var remarkCodeToDemo = ({ isMobile, getRouteMeta, iframePosition }) => {
320
+ var json = JSON.parse(
321
+ import_fs_extra.default.readFileSync((0, import_path2.resolve)(process.cwd(), "./package.json"), "utf8")
322
+ );
323
+ var remarkCodeToDemo = ({ isMobile, getRouteMeta, iframePosition, enableCodesandbox }) => {
2812
324
  const routeMeta2 = getRouteMeta();
2813
325
  return (tree, vfile) => {
2814
326
  const demos = [];
2815
327
  const route = routeMeta2.find(
2816
- (meta) => meta.absolutePath === (vfile.path || vfile.history[0])
328
+ (meta) => (0, import_shared.normalizePosixPath)(meta.absolutePath) === (0, import_shared.normalizePosixPath)(vfile.path || vfile.history[0])
2817
329
  );
2818
330
  if (!route) {
2819
331
  return;
@@ -2850,6 +362,21 @@ var remarkCodeToDemo = ({ isMobile, getRouteMeta, iframePosition }) => {
2850
362
  type: "mdxJsxAttribute",
2851
363
  name: "url",
2852
364
  value: demoRoute
365
+ },
366
+ {
367
+ type: "mdxJsxAttribute",
368
+ name: "content",
369
+ value: currentNode.value
370
+ },
371
+ {
372
+ type: "mdxJsxAttribute",
373
+ name: "packageName",
374
+ value: json.name
375
+ },
376
+ {
377
+ type: "mdxJsxAttribute",
378
+ name: "enableCodesandbox",
379
+ value: enableCodesandbox
2853
380
  }
2854
381
  ],
2855
382
  children: [
@@ -2879,7 +406,7 @@ var remarkCodeToDemo = ({ isMobile, getRouteMeta, iframePosition }) => {
2879
406
  if (!src) {
2880
407
  return;
2881
408
  }
2882
- const id = `${toValidVarName(pageName)}_${index++}`;
409
+ const id = generateId(pageName, index++);
2883
410
  constructDemoNode(id, src, node, isMobileMode, externalDemoIndex++);
2884
411
  }
2885
412
  });
@@ -2900,7 +427,7 @@ var remarkCodeToDemo = ({ isMobile, getRouteMeta, iframePosition }) => {
2900
427
  import_shared.RSPRESS_TEMP_DIR,
2901
428
  `virtual-demo`
2902
429
  );
2903
- const id = `${toValidVarName(pageName)}_${index++}`;
430
+ const id = generateId(pageName, index++);
2904
431
  const virtualModulePath = (0, import_path2.join)(demoDir, `${id}.tsx`);
2905
432
  import_fs_extra.default.ensureDirSync((0, import_path2.join)(demoDir));
2906
433
  if (import_fs_extra.default.existsSync(virtualModulePath)) {
@@ -2988,11 +515,17 @@ var demoMeta = {};
2988
515
  function pluginPreview(options) {
2989
516
  const isMobile = options?.isMobile ?? false;
2990
517
  const iframePosition = options?.iframePosition ?? "follow";
518
+ const enableCodesandbox = options?.enableCodesandbox ?? false;
2991
519
  const demoRuntimeModule = new import_rspack_plugin_virtual_module.RspackVirtualModulePlugin({});
2992
- const globalUIComponents = iframePosition === "fixed" ? [import_path3.default.join(staticPath, "global-components", "Device.tsx")] : [];
520
+ const globalUIComponents = iframePosition === "fixed" ? [(0, import_path3.join)(staticPath, "global-components", "Device.tsx")] : [];
2993
521
  const getRouteMeta = () => routeMeta;
2994
522
  return {
2995
523
  name: "@rspress/plugin-preview",
524
+ config(config) {
525
+ config.markdown = config.markdown || {};
526
+ config.markdown.mdxRs = false;
527
+ return config;
528
+ },
2996
529
  addPages(_config, _isProd) {
2997
530
  return [
2998
531
  {
@@ -3021,17 +554,17 @@ import Demo from ${JSON.stringify(demoComponentPath)}
3021
554
  const { visit: visit2 } = await Promise.resolve().then(() => (init_unist_util_visit(), unist_util_visit_exports));
3022
555
  const { default: fs2 } = await import("@modern-js/utils/fs-extra");
3023
556
  const { default: remarkGFM } = await import("remark-gfm");
3024
- let title = import_path3.default.parse(filepath).name;
557
+ let title = (0, import_path3.parse)(filepath).name;
3025
558
  try {
3026
559
  const processor = createProcessor({
3027
- format: import_path3.default.extname(filepath).slice(1),
560
+ format: (0, import_path3.extname)(filepath).slice(1),
3028
561
  remarkPlugins: [remarkGFM]
3029
562
  });
3030
563
  const source = await fs2.readFile(filepath, "utf-8");
3031
564
  const ast = processor.parse(source);
3032
565
  let index = 1;
3033
566
  const { pageName } = routeMeta.find(
3034
- (meta) => meta.absolutePath === filepath
567
+ (meta) => (0, import_shared2.normalizePosixPath)(meta.absolutePath) === (0, import_shared2.normalizePosixPath)(filepath)
3035
568
  );
3036
569
  const registerDemo = (demoId, demoPath, isMobileMode) => {
3037
570
  if (isMobileMode) {
@@ -3066,7 +599,7 @@ import Demo from ${JSON.stringify(demoComponentPath)}
3066
599
  if (!src) {
3067
600
  return;
3068
601
  }
3069
- const id = `${toValidVarName(pageName)}_${index++}`;
602
+ const id = generateId(pageName, index++);
3070
603
  registerDemo(id, src, isMobileMode);
3071
604
  }
3072
605
  });
@@ -3079,9 +612,9 @@ import Demo from ${JSON.stringify(demoComponentPath)}
3079
612
  }
3080
613
  const isMobileMode = node?.meta?.includes("mobile") || !node?.meta?.includes("web") && isMobile;
3081
614
  const { pageName: pageName2 } = routeMeta.find(
3082
- (meta) => meta.absolutePath === filepath
615
+ (meta) => (0, import_shared2.normalizePosixPath)(meta.absolutePath) === (0, import_shared2.normalizePosixPath)(filepath)
3083
616
  );
3084
- const id = `${toValidVarName(pageName2)}_${index++}`;
617
+ const id = generateId(pageName2, index++);
3085
618
  const demoDir = (0, import_path3.join)(
3086
619
  process.cwd(),
3087
620
  "node_modules",
@@ -3113,27 +646,30 @@ import Demo from ${JSON.stringify(demoComponentPath)}
3113
646
  },
3114
647
  builderConfig: {
3115
648
  tools: {
649
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error
650
+ // @ts-ignore
3116
651
  rspack: {
3117
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error
3118
- // @ts-ignore
3119
652
  plugins: [demoRuntimeModule]
3120
653
  },
3121
654
  bundlerChain(chain) {
3122
- chain.module.rule("Raw").resourceQuery(/raw/).type("asset/source").end().rule("MDX").oneOf("MDXMeta").before("MDXCompile").resourceQuery(/meta/).use("mdx-meta-loader").loader(import_path3.default.join(__dirname, "../mdx-meta-loader.cjs")).end();
655
+ chain.module.rule("Raw").resourceQuery(/raw/).type("asset/source").end().rule("MDX").oneOf("MDXMeta").before("MDXCompile").resourceQuery(/meta/).use("mdx-meta-loader").loader((0, import_path3.join)(__dirname, "../mdx-meta-loader.cjs")).end();
3123
656
  chain.resolve.extensions.prepend(".md").prepend(".mdx");
3124
657
  }
3125
658
  }
3126
659
  },
3127
660
  markdown: {
3128
661
  remarkPlugins: [
3129
- [remarkCodeToDemo, { isMobile, getRouteMeta, iframePosition }]
662
+ [
663
+ remarkCodeToDemo,
664
+ { isMobile, getRouteMeta, iframePosition, enableCodesandbox }
665
+ ]
3130
666
  ],
3131
667
  globalComponents: [
3132
- import_path3.default.join(staticPath, "global-components", "Container.tsx")
668
+ (0, import_path3.join)(staticPath, "global-components", "Container.tsx")
3133
669
  ]
3134
670
  },
3135
671
  globalUIComponents,
3136
- globalStyles: import_path3.default.join(
672
+ globalStyles: (0, import_path3.join)(
3137
673
  staticPath,
3138
674
  "global-styles",
3139
675
  `${isMobile ? "mobile" : "web"}.css`