@module-federation/data-prefetch 0.6.7 → 0.6.8
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/.swcrc +29 -0
- package/CHANGELOG.md +11 -0
- package/dist/babel.cjs.js +23 -35
- package/dist/babel.esm.d.ts +2 -0
- package/dist/babel.esm.js +23 -31
- package/dist/cli.cjs.js +122 -3546
- package/dist/cli.esm.d.ts +1 -0
- package/dist/cli.esm.js +123 -3536
- package/dist/index.cjs.js +0 -2
- package/dist/index.esm.d.ts +1 -0
- package/dist/package.json +7 -6
- package/dist/plugin.cjs.js +95 -298
- package/dist/plugin.esm.d.ts +2 -0
- package/dist/plugin.esm.js +94 -297
- package/dist/polyfills.cjs.js +14 -0
- package/dist/polyfills.esm.js +12 -0
- package/dist/prefetch.cjs.js +118 -327
- package/dist/prefetch.esm.js +119 -328
- package/dist/react.cjs.js +31 -117
- package/dist/react.esm.d.ts +1 -0
- package/dist/react.esm.js +32 -116
- package/dist/runtime-utils.cjs.js +4 -8
- package/dist/runtime-utils.esm.js +5 -9
- package/dist/shared.cjs.js +10 -12
- package/dist/shared.esm.d.ts +2 -0
- package/dist/shared.esm.js +10 -12
- package/dist/universal.cjs.js +8 -17
- package/dist/universal.esm.d.ts +1 -0
- package/dist/universal.esm.js +9 -16
- package/package.json +5 -5
- package/project.json +2 -2
- package/rollup.config.js +22 -1
package/dist/cli.cjs.js
CHANGED
|
@@ -1,3579 +1,155 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var require$$1 = require('path');
|
|
6
|
-
var require$$0$2 = require('fs');
|
|
7
|
-
var require$$0 = require('constants');
|
|
8
|
-
var require$$0$1 = require('stream');
|
|
9
|
-
var require$$4 = require('util');
|
|
10
|
-
var require$$5 = require('assert');
|
|
3
|
+
var path = require('path');
|
|
4
|
+
var fs = require('fs-extra');
|
|
11
5
|
var sdk = require('@module-federation/sdk');
|
|
12
6
|
var normalizeWebpackPath = require('@module-federation/sdk/normalize-webpack-path');
|
|
13
7
|
var runtimeUtils = require('./runtime-utils.cjs.js');
|
|
14
8
|
require('@module-federation/runtime');
|
|
15
9
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
19
|
-
var require$$0__default$2 = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
|
|
20
|
-
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
21
|
-
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
|
22
|
-
var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);
|
|
23
|
-
var require$$5__default = /*#__PURE__*/_interopDefaultLegacy(require$$5);
|
|
24
|
-
|
|
25
|
-
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
26
|
-
|
|
27
|
-
var lib = {
|
|
28
|
-
exports: {}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
var fs$i = {};
|
|
32
|
-
|
|
33
|
-
var universalify$1 = {};
|
|
34
|
-
|
|
35
|
-
universalify$1.fromCallback = function(fn) {
|
|
36
|
-
return Object.defineProperty(function() {
|
|
37
|
-
var _this = this;
|
|
38
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
39
|
-
args[_key] = arguments[_key];
|
|
40
|
-
}
|
|
41
|
-
if (typeof args[args.length - 1] === 'function') fn.apply(this, args);
|
|
42
|
-
else {
|
|
43
|
-
return new Promise(function(resolve, reject) {
|
|
44
|
-
args.push(function(err, res) {
|
|
45
|
-
return err != null ? reject(err) : resolve(res);
|
|
46
|
-
});
|
|
47
|
-
fn.apply(_this, args);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}, 'name', {
|
|
51
|
-
value: fn.name
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
universalify$1.fromPromise = function(fn) {
|
|
55
|
-
return Object.defineProperty(function() {
|
|
56
|
-
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
57
|
-
args[_key] = arguments[_key];
|
|
58
|
-
}
|
|
59
|
-
var cb = args[args.length - 1];
|
|
60
|
-
if (typeof cb !== 'function') return fn.apply(this, args);
|
|
61
|
-
else {
|
|
62
|
-
args.pop();
|
|
63
|
-
fn.apply(this, args).then(function(r) {
|
|
64
|
-
return cb(null, r);
|
|
65
|
-
}, cb);
|
|
66
|
-
}
|
|
67
|
-
}, 'name', {
|
|
68
|
-
value: fn.name
|
|
69
|
-
});
|
|
70
|
-
};
|
|
10
|
+
const TEMP_DIR = '.mf';
|
|
71
11
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
process.cwd = function() {
|
|
77
|
-
if (!cwd) cwd = origCwd.call(process);
|
|
78
|
-
return cwd;
|
|
79
|
-
};
|
|
80
|
-
try {
|
|
81
|
-
process.cwd();
|
|
82
|
-
} catch (er) {}
|
|
83
|
-
// This check is needed until node.js 12 is required
|
|
84
|
-
if (typeof process.chdir === 'function') {
|
|
85
|
-
var chdir = process.chdir;
|
|
86
|
-
process.chdir = function(d) {
|
|
87
|
-
cwd = null;
|
|
88
|
-
chdir.call(process, d);
|
|
89
|
-
};
|
|
90
|
-
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
|
|
91
|
-
}
|
|
92
|
-
var polyfills$1 = patch$1;
|
|
93
|
-
function patch$1(fs) {
|
|
94
|
-
// (re-)implement some things that are known busted or missing.
|
|
95
|
-
// lchmod, broken prior to 0.6.2
|
|
96
|
-
// back-port the fix here.
|
|
97
|
-
if (constants.hasOwnProperty('O_SYMLINK') && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
|
|
98
|
-
patchLchmod(fs);
|
|
99
|
-
}
|
|
100
|
-
// lutimes implementation, or no-op
|
|
101
|
-
if (!fs.lutimes) {
|
|
102
|
-
patchLutimes(fs);
|
|
103
|
-
}
|
|
104
|
-
// https://github.com/isaacs/node-graceful-fs/issues/4
|
|
105
|
-
// Chown should not fail on einval or eperm if non-root.
|
|
106
|
-
// It should not fail on enosys ever, as this just indicates
|
|
107
|
-
// that a fs doesn't support the intended operation.
|
|
108
|
-
fs.chown = chownFix(fs.chown);
|
|
109
|
-
fs.fchown = chownFix(fs.fchown);
|
|
110
|
-
fs.lchown = chownFix(fs.lchown);
|
|
111
|
-
fs.chmod = chmodFix(fs.chmod);
|
|
112
|
-
fs.fchmod = chmodFix(fs.fchmod);
|
|
113
|
-
fs.lchmod = chmodFix(fs.lchmod);
|
|
114
|
-
fs.chownSync = chownFixSync(fs.chownSync);
|
|
115
|
-
fs.fchownSync = chownFixSync(fs.fchownSync);
|
|
116
|
-
fs.lchownSync = chownFixSync(fs.lchownSync);
|
|
117
|
-
fs.chmodSync = chmodFixSync(fs.chmodSync);
|
|
118
|
-
fs.fchmodSync = chmodFixSync(fs.fchmodSync);
|
|
119
|
-
fs.lchmodSync = chmodFixSync(fs.lchmodSync);
|
|
120
|
-
fs.stat = statFix(fs.stat);
|
|
121
|
-
fs.fstat = statFix(fs.fstat);
|
|
122
|
-
fs.lstat = statFix(fs.lstat);
|
|
123
|
-
fs.statSync = statFixSync(fs.statSync);
|
|
124
|
-
fs.fstatSync = statFixSync(fs.fstatSync);
|
|
125
|
-
fs.lstatSync = statFixSync(fs.lstatSync);
|
|
126
|
-
// if lchmod/lchown do not exist, then make them no-ops
|
|
127
|
-
if (fs.chmod && !fs.lchmod) {
|
|
128
|
-
fs.lchmod = function(path, mode, cb) {
|
|
129
|
-
if (cb) process.nextTick(cb);
|
|
130
|
-
};
|
|
131
|
-
fs.lchmodSync = function() {};
|
|
132
|
-
}
|
|
133
|
-
if (fs.chown && !fs.lchown) {
|
|
134
|
-
fs.lchown = function(path, uid, gid, cb) {
|
|
135
|
-
if (cb) process.nextTick(cb);
|
|
136
|
-
};
|
|
137
|
-
fs.lchownSync = function() {};
|
|
138
|
-
}
|
|
139
|
-
// on Windows, A/V software can lock the directory, causing this
|
|
140
|
-
// to fail with an EACCES or EPERM if the directory contains newly
|
|
141
|
-
// created files. Try again on failure, for up to 60 seconds.
|
|
142
|
-
// Set the timeout this long because some Windows Anti-Virus, such as Parity
|
|
143
|
-
// bit9, may lock files for up to a minute, causing npm package install
|
|
144
|
-
// failures. Also, take care to yield the scheduler. Windows scheduling gives
|
|
145
|
-
// CPU to a busy looping process, which can cause the program causing the lock
|
|
146
|
-
// contention to be starved of CPU by node, so the contention doesn't resolve.
|
|
147
|
-
if (platform === "win32") {
|
|
148
|
-
fs.rename = typeof fs.rename !== 'function' ? fs.rename : function(fs$rename) {
|
|
149
|
-
function rename(from, to, cb) {
|
|
150
|
-
var start = Date.now();
|
|
151
|
-
var backoff = 0;
|
|
152
|
-
fs$rename(from, to, function CB(er) {
|
|
153
|
-
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 60000) {
|
|
154
|
-
setTimeout(function() {
|
|
155
|
-
fs.stat(to, function(stater, st) {
|
|
156
|
-
if (stater && stater.code === "ENOENT") fs$rename(from, to, CB);
|
|
157
|
-
else cb(er);
|
|
158
|
-
});
|
|
159
|
-
}, backoff);
|
|
160
|
-
if (backoff < 100) backoff += 10;
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
if (cb) cb(er);
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
|
|
167
|
-
return rename;
|
|
168
|
-
}(fs.rename);
|
|
169
|
-
}
|
|
170
|
-
// if read() returns EAGAIN, then just try it again.
|
|
171
|
-
fs.read = typeof fs.read !== 'function' ? fs.read : function(fs$read) {
|
|
172
|
-
function read(fd, buffer, offset, length, position, callback_) {
|
|
173
|
-
var callback;
|
|
174
|
-
if (callback_ && typeof callback_ === 'function') {
|
|
175
|
-
var eagCounter = 0;
|
|
176
|
-
callback = function(er, _, __) {
|
|
177
|
-
if (er && er.code === 'EAGAIN' && eagCounter < 10) {
|
|
178
|
-
eagCounter++;
|
|
179
|
-
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
180
|
-
}
|
|
181
|
-
callback_.apply(this, arguments);
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
185
|
-
}
|
|
186
|
-
// This ensures `util.promisify` works as it does for native `fs.read`.
|
|
187
|
-
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
188
|
-
return read;
|
|
189
|
-
}(fs.read);
|
|
190
|
-
fs.readSync = typeof fs.readSync !== 'function' ? fs.readSync : function(fs$readSync) {
|
|
191
|
-
return function(fd, buffer, offset, length, position) {
|
|
192
|
-
var eagCounter = 0;
|
|
193
|
-
while(true){
|
|
194
|
-
try {
|
|
195
|
-
return fs$readSync.call(fs, fd, buffer, offset, length, position);
|
|
196
|
-
} catch (er) {
|
|
197
|
-
if (er.code === 'EAGAIN' && eagCounter < 10) {
|
|
198
|
-
eagCounter++;
|
|
199
|
-
continue;
|
|
200
|
-
}
|
|
201
|
-
throw er;
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
}(fs.readSync);
|
|
206
|
-
function patchLchmod(fs) {
|
|
207
|
-
fs.lchmod = function(path, mode, callback) {
|
|
208
|
-
fs.open(path, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
|
|
209
|
-
if (err) {
|
|
210
|
-
if (callback) callback(err);
|
|
211
|
-
return;
|
|
212
|
-
}
|
|
213
|
-
// prefer to return the chmod error, if one occurs,
|
|
214
|
-
// but still try to close, and report closing errors if they occur.
|
|
215
|
-
fs.fchmod(fd, mode, function(err) {
|
|
216
|
-
fs.close(fd, function(err2) {
|
|
217
|
-
if (callback) callback(err || err2);
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
};
|
|
222
|
-
fs.lchmodSync = function(path, mode) {
|
|
223
|
-
var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
224
|
-
// prefer to return the chmod error, if one occurs,
|
|
225
|
-
// but still try to close, and report closing errors if they occur.
|
|
226
|
-
var threw = true;
|
|
227
|
-
var ret;
|
|
228
|
-
try {
|
|
229
|
-
ret = fs.fchmodSync(fd, mode);
|
|
230
|
-
threw = false;
|
|
231
|
-
} finally{
|
|
232
|
-
if (threw) {
|
|
233
|
-
try {
|
|
234
|
-
fs.closeSync(fd);
|
|
235
|
-
} catch (er) {}
|
|
236
|
-
} else {
|
|
237
|
-
fs.closeSync(fd);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
return ret;
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
function patchLutimes(fs) {
|
|
244
|
-
if (constants.hasOwnProperty("O_SYMLINK") && fs.futimes) {
|
|
245
|
-
fs.lutimes = function(path, at, mt, cb) {
|
|
246
|
-
fs.open(path, constants.O_SYMLINK, function(er, fd) {
|
|
247
|
-
if (er) {
|
|
248
|
-
if (cb) cb(er);
|
|
249
|
-
return;
|
|
250
|
-
}
|
|
251
|
-
fs.futimes(fd, at, mt, function(er) {
|
|
252
|
-
fs.close(fd, function(er2) {
|
|
253
|
-
if (cb) cb(er || er2);
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
});
|
|
257
|
-
};
|
|
258
|
-
fs.lutimesSync = function(path, at, mt) {
|
|
259
|
-
var fd = fs.openSync(path, constants.O_SYMLINK);
|
|
260
|
-
var ret;
|
|
261
|
-
var threw = true;
|
|
262
|
-
try {
|
|
263
|
-
ret = fs.futimesSync(fd, at, mt);
|
|
264
|
-
threw = false;
|
|
265
|
-
} finally{
|
|
266
|
-
if (threw) {
|
|
267
|
-
try {
|
|
268
|
-
fs.closeSync(fd);
|
|
269
|
-
} catch (er) {}
|
|
270
|
-
} else {
|
|
271
|
-
fs.closeSync(fd);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
return ret;
|
|
275
|
-
};
|
|
276
|
-
} else if (fs.futimes) {
|
|
277
|
-
fs.lutimes = function(_a, _b, _c, cb) {
|
|
278
|
-
if (cb) process.nextTick(cb);
|
|
279
|
-
};
|
|
280
|
-
fs.lutimesSync = function() {};
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
function chmodFix(orig) {
|
|
284
|
-
if (!orig) return orig;
|
|
285
|
-
return function(target, mode, cb) {
|
|
286
|
-
return orig.call(fs, target, mode, function(er) {
|
|
287
|
-
if (chownErOk(er)) er = null;
|
|
288
|
-
if (cb) cb.apply(this, arguments);
|
|
289
|
-
});
|
|
290
|
-
};
|
|
291
|
-
}
|
|
292
|
-
function chmodFixSync(orig) {
|
|
293
|
-
if (!orig) return orig;
|
|
294
|
-
return function(target, mode) {
|
|
295
|
-
try {
|
|
296
|
-
return orig.call(fs, target, mode);
|
|
297
|
-
} catch (er) {
|
|
298
|
-
if (!chownErOk(er)) throw er;
|
|
299
|
-
}
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
function chownFix(orig) {
|
|
303
|
-
if (!orig) return orig;
|
|
304
|
-
return function(target, uid, gid, cb) {
|
|
305
|
-
return orig.call(fs, target, uid, gid, function(er) {
|
|
306
|
-
if (chownErOk(er)) er = null;
|
|
307
|
-
if (cb) cb.apply(this, arguments);
|
|
308
|
-
});
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
function chownFixSync(orig) {
|
|
312
|
-
if (!orig) return orig;
|
|
313
|
-
return function(target, uid, gid) {
|
|
314
|
-
try {
|
|
315
|
-
return orig.call(fs, target, uid, gid);
|
|
316
|
-
} catch (er) {
|
|
317
|
-
if (!chownErOk(er)) throw er;
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
function statFix(orig) {
|
|
322
|
-
if (!orig) return orig;
|
|
323
|
-
// Older versions of Node erroneously returned signed integers for
|
|
324
|
-
// uid + gid.
|
|
325
|
-
return function(target, options, cb) {
|
|
326
|
-
if (typeof options === 'function') {
|
|
327
|
-
cb = options;
|
|
328
|
-
options = null;
|
|
329
|
-
}
|
|
330
|
-
function callback(er, stats) {
|
|
331
|
-
if (stats) {
|
|
332
|
-
if (stats.uid < 0) stats.uid += 0x100000000;
|
|
333
|
-
if (stats.gid < 0) stats.gid += 0x100000000;
|
|
334
|
-
}
|
|
335
|
-
if (cb) cb.apply(this, arguments);
|
|
336
|
-
}
|
|
337
|
-
return options ? orig.call(fs, target, options, callback) : orig.call(fs, target, callback);
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
function statFixSync(orig) {
|
|
341
|
-
if (!orig) return orig;
|
|
342
|
-
// Older versions of Node erroneously returned signed integers for
|
|
343
|
-
// uid + gid.
|
|
344
|
-
return function(target, options) {
|
|
345
|
-
var stats = options ? orig.call(fs, target, options) : orig.call(fs, target);
|
|
346
|
-
if (stats) {
|
|
347
|
-
if (stats.uid < 0) stats.uid += 0x100000000;
|
|
348
|
-
if (stats.gid < 0) stats.gid += 0x100000000;
|
|
349
|
-
}
|
|
350
|
-
return stats;
|
|
351
|
-
};
|
|
12
|
+
const fileExistsWithCaseSync = (filepath)=>{
|
|
13
|
+
const dir = path.dirname(filepath);
|
|
14
|
+
if (filepath === '/' || filepath === '.') {
|
|
15
|
+
return true;
|
|
352
16
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
//
|
|
356
|
-
// if there's no getuid, or if getuid() is something other
|
|
357
|
-
// than 0, and the error is EINVAL or EPERM, then just ignore
|
|
358
|
-
// it.
|
|
359
|
-
//
|
|
360
|
-
// This specific case is a silent failure in cp, install, tar,
|
|
361
|
-
// and most other unix tools that manage permissions.
|
|
362
|
-
//
|
|
363
|
-
// When running as root, or if other types of errors are
|
|
364
|
-
// encountered, then it's strict.
|
|
365
|
-
function chownErOk(er) {
|
|
366
|
-
if (!er) return true;
|
|
367
|
-
if (er.code === "ENOSYS") return true;
|
|
368
|
-
var nonroot = !process.getuid || process.getuid() !== 0;
|
|
369
|
-
if (nonroot) {
|
|
370
|
-
if (er.code === "EINVAL" || er.code === "EPERM") return true;
|
|
371
|
-
}
|
|
17
|
+
const filenames = fs.readdirSync(dir);
|
|
18
|
+
if (filenames.indexOf(path.basename(filepath)) === -1) {
|
|
372
19
|
return false;
|
|
373
20
|
}
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
function _instanceof$2(left, right) {
|
|
377
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
378
|
-
return !!right[Symbol.hasInstance](left);
|
|
379
|
-
} else {
|
|
380
|
-
return left instanceof right;
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
var Stream = require$$0__default$1["default"].Stream;
|
|
384
|
-
var legacyStreams = legacy$1;
|
|
385
|
-
function legacy$1(fs) {
|
|
386
|
-
return {
|
|
387
|
-
ReadStream: ReadStream,
|
|
388
|
-
WriteStream: WriteStream
|
|
389
|
-
};
|
|
390
|
-
function ReadStream(path, options) {
|
|
391
|
-
if (!_instanceof$2(this, ReadStream)) return new ReadStream(path, options);
|
|
392
|
-
Stream.call(this);
|
|
393
|
-
var self = this;
|
|
394
|
-
this.path = path;
|
|
395
|
-
this.fd = null;
|
|
396
|
-
this.readable = true;
|
|
397
|
-
this.paused = false;
|
|
398
|
-
this.flags = 'r';
|
|
399
|
-
this.mode = 438; /*=0666*/
|
|
400
|
-
this.bufferSize = 64 * 1024;
|
|
401
|
-
options = options || {};
|
|
402
|
-
// Mixin options into this
|
|
403
|
-
var keys = Object.keys(options);
|
|
404
|
-
for(var index = 0, length = keys.length; index < length; index++){
|
|
405
|
-
var key = keys[index];
|
|
406
|
-
this[key] = options[key];
|
|
407
|
-
}
|
|
408
|
-
if (this.encoding) this.setEncoding(this.encoding);
|
|
409
|
-
if (this.start !== undefined) {
|
|
410
|
-
if ('number' !== typeof this.start) {
|
|
411
|
-
throw TypeError('start must be a Number');
|
|
412
|
-
}
|
|
413
|
-
if (this.end === undefined) {
|
|
414
|
-
this.end = Infinity;
|
|
415
|
-
} else if ('number' !== typeof this.end) {
|
|
416
|
-
throw TypeError('end must be a Number');
|
|
417
|
-
}
|
|
418
|
-
if (this.start > this.end) {
|
|
419
|
-
throw new Error('start must be <= end');
|
|
420
|
-
}
|
|
421
|
-
this.pos = this.start;
|
|
422
|
-
}
|
|
423
|
-
if (this.fd !== null) {
|
|
424
|
-
process.nextTick(function() {
|
|
425
|
-
self._read();
|
|
426
|
-
});
|
|
427
|
-
return;
|
|
428
|
-
}
|
|
429
|
-
fs.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
430
|
-
if (err) {
|
|
431
|
-
self.emit('error', err);
|
|
432
|
-
self.readable = false;
|
|
433
|
-
return;
|
|
434
|
-
}
|
|
435
|
-
self.fd = fd;
|
|
436
|
-
self.emit('open', fd);
|
|
437
|
-
self._read();
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
function WriteStream(path, options) {
|
|
441
|
-
if (!_instanceof$2(this, WriteStream)) return new WriteStream(path, options);
|
|
442
|
-
Stream.call(this);
|
|
443
|
-
this.path = path;
|
|
444
|
-
this.fd = null;
|
|
445
|
-
this.writable = true;
|
|
446
|
-
this.flags = 'w';
|
|
447
|
-
this.encoding = 'binary';
|
|
448
|
-
this.mode = 438; /*=0666*/
|
|
449
|
-
this.bytesWritten = 0;
|
|
450
|
-
options = options || {};
|
|
451
|
-
// Mixin options into this
|
|
452
|
-
var keys = Object.keys(options);
|
|
453
|
-
for(var index = 0, length = keys.length; index < length; index++){
|
|
454
|
-
var key = keys[index];
|
|
455
|
-
this[key] = options[key];
|
|
456
|
-
}
|
|
457
|
-
if (this.start !== undefined) {
|
|
458
|
-
if ('number' !== typeof this.start) {
|
|
459
|
-
throw TypeError('start must be a Number');
|
|
460
|
-
}
|
|
461
|
-
if (this.start < 0) {
|
|
462
|
-
throw new Error('start must be >= zero');
|
|
463
|
-
}
|
|
464
|
-
this.pos = this.start;
|
|
465
|
-
}
|
|
466
|
-
this.busy = false;
|
|
467
|
-
this._queue = [];
|
|
468
|
-
if (this.fd === null) {
|
|
469
|
-
this._open = fs.open;
|
|
470
|
-
this._queue.push([
|
|
471
|
-
this._open,
|
|
472
|
-
this.path,
|
|
473
|
-
this.flags,
|
|
474
|
-
this.mode,
|
|
475
|
-
undefined
|
|
476
|
-
]);
|
|
477
|
-
this.flush();
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
function _instanceof$1(left, right) {
|
|
483
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
484
|
-
return !!right[Symbol.hasInstance](left);
|
|
485
|
-
} else {
|
|
486
|
-
return left instanceof right;
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
function _type_of$1(obj) {
|
|
490
|
-
"@swc/helpers - typeof";
|
|
491
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
492
|
-
}
|
|
493
|
-
var clone_1 = clone$1;
|
|
494
|
-
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
|
495
|
-
return obj.__proto__;
|
|
21
|
+
return fileExistsWithCaseSync(dir);
|
|
496
22
|
};
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
});
|
|
506
|
-
return copy;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
function _instanceof(left, right) {
|
|
510
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
511
|
-
return !!right[Symbol.hasInstance](left);
|
|
23
|
+
const fixPrefetchPath = (exposePath)=>{
|
|
24
|
+
const pathExt = [
|
|
25
|
+
'.js',
|
|
26
|
+
'.ts'
|
|
27
|
+
];
|
|
28
|
+
const extReg = /\.(ts|js|tsx|jsx)$/;
|
|
29
|
+
if (extReg.test(exposePath)) {
|
|
30
|
+
return pathExt.map((ext)=>exposePath.replace(extReg, `.prefetch${ext}`));
|
|
512
31
|
} else {
|
|
513
|
-
return
|
|
32
|
+
return pathExt.map((ext)=>exposePath + `.prefetch${ext}`);
|
|
514
33
|
}
|
|
515
|
-
}
|
|
516
|
-
var fs$h = require$$0__default$2["default"];
|
|
517
|
-
var polyfills = polyfills$1;
|
|
518
|
-
var legacy = legacyStreams;
|
|
519
|
-
var clone = clone_1;
|
|
520
|
-
var util$1 = require$$4__default["default"];
|
|
521
|
-
/* istanbul ignore next - node 0.x polyfill */ var gracefulQueue;
|
|
522
|
-
var previousSymbol;
|
|
523
|
-
/* istanbul ignore else - node 0.x polyfill */ if (typeof Symbol === 'function' && typeof Symbol.for === 'function') {
|
|
524
|
-
gracefulQueue = Symbol.for('graceful-fs.queue');
|
|
525
|
-
// This is used in testing by future versions
|
|
526
|
-
previousSymbol = Symbol.for('graceful-fs.previous');
|
|
527
|
-
} else {
|
|
528
|
-
gracefulQueue = '___graceful-fs.queue';
|
|
529
|
-
previousSymbol = '___graceful-fs.previous';
|
|
530
|
-
}
|
|
531
|
-
function noop() {}
|
|
532
|
-
function publishQueue(context, queue) {
|
|
533
|
-
Object.defineProperty(context, gracefulQueue, {
|
|
534
|
-
get: function get() {
|
|
535
|
-
return queue;
|
|
536
|
-
}
|
|
537
|
-
});
|
|
538
|
-
}
|
|
539
|
-
var debug = noop;
|
|
540
|
-
if (util$1.debuglog) debug = util$1.debuglog('gfs4');
|
|
541
|
-
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) debug = function debug() {
|
|
542
|
-
var m = util$1.format.apply(util$1, arguments);
|
|
543
|
-
m = 'GFS4: ' + m.split(/\n/).join('\nGFS4: ');
|
|
544
|
-
console.error(m);
|
|
545
34
|
};
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
//
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
return
|
|
558
|
-
// This function uses the graceful-fs shared queue
|
|
559
|
-
if (!err) {
|
|
560
|
-
resetQueue();
|
|
561
|
-
}
|
|
562
|
-
if (typeof cb === 'function') cb.apply(this, arguments);
|
|
563
|
-
});
|
|
564
|
-
}
|
|
565
|
-
Object.defineProperty(close, previousSymbol, {
|
|
566
|
-
value: fs$close
|
|
567
|
-
});
|
|
568
|
-
return close;
|
|
569
|
-
}(fs$h.close);
|
|
570
|
-
fs$h.closeSync = function(fs$closeSync) {
|
|
571
|
-
function closeSync(fd) {
|
|
572
|
-
// This function uses the graceful-fs shared queue
|
|
573
|
-
fs$closeSync.apply(fs$h, arguments);
|
|
574
|
-
resetQueue();
|
|
35
|
+
|
|
36
|
+
const { RuntimeGlobals, Template } = require(normalizeWebpackPath.normalizeWebpackPath('webpack'));
|
|
37
|
+
function getFederationGlobalScope(runtimeGlobals) {
|
|
38
|
+
return `${runtimeGlobals.require || '__webpack_require__'}.federation`;
|
|
39
|
+
}
|
|
40
|
+
class PrefetchPlugin {
|
|
41
|
+
// eslint-disable-next-line max-lines-per-function
|
|
42
|
+
apply(compiler) {
|
|
43
|
+
var _this_options_runtimePlugins, _this_options_runtimePlugins1;
|
|
44
|
+
const { name, exposes } = this.options;
|
|
45
|
+
if (!exposes) {
|
|
46
|
+
return;
|
|
575
47
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
});
|
|
579
|
-
return closeSync;
|
|
580
|
-
}(fs$h.closeSync);
|
|
581
|
-
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || '')) {
|
|
582
|
-
process.on('exit', function() {
|
|
583
|
-
debug(fs$h[gracefulQueue]);
|
|
584
|
-
require$$5__default["default"].equal(fs$h[gracefulQueue].length, 0);
|
|
585
|
-
});
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
if (!commonjsGlobal[gracefulQueue]) {
|
|
589
|
-
publishQueue(commonjsGlobal, fs$h[gracefulQueue]);
|
|
590
|
-
}
|
|
591
|
-
var gracefulFs = patch(clone(fs$h));
|
|
592
|
-
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs$h.__patched) {
|
|
593
|
-
gracefulFs = patch(fs$h);
|
|
594
|
-
fs$h.__patched = true;
|
|
595
|
-
}
|
|
596
|
-
function patch(fs) {
|
|
597
|
-
// Everything that references the open() function needs to be in here
|
|
598
|
-
polyfills(fs);
|
|
599
|
-
fs.gracefulify = patch;
|
|
600
|
-
fs.createReadStream = createReadStream;
|
|
601
|
-
fs.createWriteStream = createWriteStream;
|
|
602
|
-
var fs$readFile = fs.readFile;
|
|
603
|
-
fs.readFile = readFile;
|
|
604
|
-
function readFile(path, options, cb) {
|
|
605
|
-
if (typeof options === 'function') cb = options, options = null;
|
|
606
|
-
return go$readFile(path, options, cb);
|
|
607
|
-
function go$readFile(path, options, cb, startTime) {
|
|
608
|
-
return fs$readFile(path, options, function(err) {
|
|
609
|
-
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) enqueue([
|
|
610
|
-
go$readFile,
|
|
611
|
-
[
|
|
612
|
-
path,
|
|
613
|
-
options,
|
|
614
|
-
cb
|
|
615
|
-
],
|
|
616
|
-
err,
|
|
617
|
-
startTime || Date.now(),
|
|
618
|
-
Date.now()
|
|
619
|
-
]);
|
|
620
|
-
else {
|
|
621
|
-
if (typeof cb === 'function') cb.apply(this, arguments);
|
|
622
|
-
}
|
|
623
|
-
});
|
|
48
|
+
if (!compiler.options.context) {
|
|
49
|
+
throw new Error('compiler.options.context is not defined');
|
|
624
50
|
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
function writeFile(path, data, options, cb) {
|
|
629
|
-
if (typeof options === 'function') cb = options, options = null;
|
|
630
|
-
return go$writeFile(path, data, options, cb);
|
|
631
|
-
function go$writeFile(path, data, options, cb, startTime) {
|
|
632
|
-
return fs$writeFile(path, data, options, function(err) {
|
|
633
|
-
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) enqueue([
|
|
634
|
-
go$writeFile,
|
|
635
|
-
[
|
|
636
|
-
path,
|
|
637
|
-
data,
|
|
638
|
-
options,
|
|
639
|
-
cb
|
|
640
|
-
],
|
|
641
|
-
err,
|
|
642
|
-
startTime || Date.now(),
|
|
643
|
-
Date.now()
|
|
644
|
-
]);
|
|
645
|
-
else {
|
|
646
|
-
if (typeof cb === 'function') cb.apply(this, arguments);
|
|
647
|
-
}
|
|
648
|
-
});
|
|
51
|
+
const { runtimePlugins } = this.options;
|
|
52
|
+
if (!Array.isArray(runtimePlugins)) {
|
|
53
|
+
this.options.runtimePlugins = [];
|
|
649
54
|
}
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
if (typeof options === 'function') cb = options, options = null;
|
|
655
|
-
return go$appendFile(path, data, options, cb);
|
|
656
|
-
function go$appendFile(path, data, options, cb, startTime) {
|
|
657
|
-
return fs$appendFile(path, data, options, function(err) {
|
|
658
|
-
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) enqueue([
|
|
659
|
-
go$appendFile,
|
|
660
|
-
[
|
|
661
|
-
path,
|
|
662
|
-
data,
|
|
663
|
-
options,
|
|
664
|
-
cb
|
|
665
|
-
],
|
|
666
|
-
err,
|
|
667
|
-
startTime || Date.now(),
|
|
668
|
-
Date.now()
|
|
669
|
-
]);
|
|
670
|
-
else {
|
|
671
|
-
if (typeof cb === 'function') cb.apply(this, arguments);
|
|
672
|
-
}
|
|
673
|
-
});
|
|
55
|
+
const runtimePath = path.resolve(__dirname, './plugin.esm.js');
|
|
56
|
+
const sharedPath = path.resolve(__dirname, './shared.esm.js');
|
|
57
|
+
if (!((_this_options_runtimePlugins = this.options.runtimePlugins) == null ? void 0 : _this_options_runtimePlugins.includes(runtimePath))) {
|
|
58
|
+
this.options.runtimePlugins.push(runtimePath);
|
|
674
59
|
}
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
if (fs$copyFile) fs.copyFile = copyFile;
|
|
678
|
-
function copyFile(src, dest, flags, cb) {
|
|
679
|
-
if (typeof flags === 'function') {
|
|
680
|
-
cb = flags;
|
|
681
|
-
flags = 0;
|
|
60
|
+
if (!((_this_options_runtimePlugins1 = this.options.runtimePlugins) == null ? void 0 : _this_options_runtimePlugins1.includes(sharedPath))) {
|
|
61
|
+
this.options.runtimePlugins.push(sharedPath);
|
|
682
62
|
}
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
go$copyFile,
|
|
688
|
-
[
|
|
689
|
-
src,
|
|
690
|
-
dest,
|
|
691
|
-
flags,
|
|
692
|
-
cb
|
|
693
|
-
],
|
|
694
|
-
err,
|
|
695
|
-
startTime || Date.now(),
|
|
696
|
-
Date.now()
|
|
697
|
-
]);
|
|
698
|
-
else {
|
|
699
|
-
if (typeof cb === 'function') cb.apply(this, arguments);
|
|
700
|
-
}
|
|
701
|
-
});
|
|
63
|
+
const encodedName = sdk.encodeName(name);
|
|
64
|
+
const asyncEntryPath = path.resolve(compiler.options.context, `node_modules/${TEMP_DIR}/${encodedName}/bootstrap.js`);
|
|
65
|
+
if (fs.existsSync(asyncEntryPath)) {
|
|
66
|
+
fs.unlinkSync(asyncEntryPath);
|
|
702
67
|
}
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
fs.readdir = readdir;
|
|
706
|
-
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
707
|
-
function readdir(path, options, cb) {
|
|
708
|
-
if (typeof options === 'function') cb = options, options = null;
|
|
709
|
-
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir(path, options, cb, startTime) {
|
|
710
|
-
return fs$readdir(path, fs$readdirCallback(path, options, cb, startTime));
|
|
711
|
-
} : function go$readdir(path, options, cb, startTime) {
|
|
712
|
-
return fs$readdir(path, options, fs$readdirCallback(path, options, cb, startTime));
|
|
713
|
-
};
|
|
714
|
-
return go$readdir(path, options, cb);
|
|
715
|
-
function fs$readdirCallback(path, options, cb, startTime) {
|
|
716
|
-
return function(err, files) {
|
|
717
|
-
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) enqueue([
|
|
718
|
-
go$readdir,
|
|
719
|
-
[
|
|
720
|
-
path,
|
|
721
|
-
options,
|
|
722
|
-
cb
|
|
723
|
-
],
|
|
724
|
-
err,
|
|
725
|
-
startTime || Date.now(),
|
|
726
|
-
Date.now()
|
|
727
|
-
]);
|
|
728
|
-
else {
|
|
729
|
-
if (files && files.sort) files.sort();
|
|
730
|
-
if (typeof cb === 'function') cb.call(this, err, files);
|
|
731
|
-
}
|
|
732
|
-
};
|
|
68
|
+
if (!this.options.dataPrefetch) {
|
|
69
|
+
return;
|
|
733
70
|
}
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
if (fs$ReadStream) {
|
|
742
|
-
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
743
|
-
ReadStream.prototype.open = ReadStream$open;
|
|
744
|
-
}
|
|
745
|
-
var fs$WriteStream = fs.WriteStream;
|
|
746
|
-
if (fs$WriteStream) {
|
|
747
|
-
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
748
|
-
WriteStream.prototype.open = WriteStream$open;
|
|
749
|
-
}
|
|
750
|
-
Object.defineProperty(fs, 'ReadStream', {
|
|
751
|
-
get: function get() {
|
|
752
|
-
return ReadStream;
|
|
753
|
-
},
|
|
754
|
-
set: function set(val) {
|
|
755
|
-
ReadStream = val;
|
|
756
|
-
},
|
|
757
|
-
enumerable: true,
|
|
758
|
-
configurable: true
|
|
759
|
-
});
|
|
760
|
-
Object.defineProperty(fs, 'WriteStream', {
|
|
761
|
-
get: function get() {
|
|
762
|
-
return WriteStream;
|
|
763
|
-
},
|
|
764
|
-
set: function set(val) {
|
|
765
|
-
WriteStream = val;
|
|
766
|
-
},
|
|
767
|
-
enumerable: true,
|
|
768
|
-
configurable: true
|
|
769
|
-
});
|
|
770
|
-
// legacy names
|
|
771
|
-
var FileReadStream = ReadStream;
|
|
772
|
-
Object.defineProperty(fs, 'FileReadStream', {
|
|
773
|
-
get: function get() {
|
|
774
|
-
return FileReadStream;
|
|
775
|
-
},
|
|
776
|
-
set: function set(val) {
|
|
777
|
-
FileReadStream = val;
|
|
778
|
-
},
|
|
779
|
-
enumerable: true,
|
|
780
|
-
configurable: true
|
|
781
|
-
});
|
|
782
|
-
var FileWriteStream = WriteStream;
|
|
783
|
-
Object.defineProperty(fs, 'FileWriteStream', {
|
|
784
|
-
get: function get() {
|
|
785
|
-
return FileWriteStream;
|
|
786
|
-
},
|
|
787
|
-
set: function set(val) {
|
|
788
|
-
FileWriteStream = val;
|
|
789
|
-
},
|
|
790
|
-
enumerable: true,
|
|
791
|
-
configurable: true
|
|
792
|
-
});
|
|
793
|
-
function ReadStream(path, options) {
|
|
794
|
-
if (_instanceof(this, ReadStream)) return fs$ReadStream.apply(this, arguments), this;
|
|
795
|
-
else return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
796
|
-
}
|
|
797
|
-
function ReadStream$open() {
|
|
798
|
-
var that = this;
|
|
799
|
-
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
800
|
-
if (err) {
|
|
801
|
-
if (that.autoClose) that.destroy();
|
|
802
|
-
that.emit('error', err);
|
|
71
|
+
const exposeAlias = Object.keys(exposes);
|
|
72
|
+
exposeAlias.forEach((alias)=>{
|
|
73
|
+
let exposePath;
|
|
74
|
+
// @ts-ignore
|
|
75
|
+
const exposeValue = exposes[alias];
|
|
76
|
+
if (typeof exposeValue === 'string') {
|
|
77
|
+
exposePath = exposeValue;
|
|
803
78
|
} else {
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
else return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
813
|
-
}
|
|
814
|
-
function WriteStream$open() {
|
|
815
|
-
var that = this;
|
|
816
|
-
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
817
|
-
if (err) {
|
|
818
|
-
that.destroy();
|
|
819
|
-
that.emit('error', err);
|
|
820
|
-
} else {
|
|
821
|
-
that.fd = fd;
|
|
822
|
-
that.emit('open', fd);
|
|
823
|
-
}
|
|
824
|
-
});
|
|
825
|
-
}
|
|
826
|
-
function createReadStream(path, options) {
|
|
827
|
-
return new fs.ReadStream(path, options);
|
|
828
|
-
}
|
|
829
|
-
function createWriteStream(path, options) {
|
|
830
|
-
return new fs.WriteStream(path, options);
|
|
831
|
-
}
|
|
832
|
-
var fs$open = fs.open;
|
|
833
|
-
fs.open = open;
|
|
834
|
-
function open(path, flags, mode, cb) {
|
|
835
|
-
if (typeof mode === 'function') cb = mode, mode = null;
|
|
836
|
-
return go$open(path, flags, mode, cb);
|
|
837
|
-
function go$open(path, flags, mode, cb, startTime) {
|
|
838
|
-
return fs$open(path, flags, mode, function(err, fd) {
|
|
839
|
-
if (err && (err.code === 'EMFILE' || err.code === 'ENFILE')) enqueue([
|
|
840
|
-
go$open,
|
|
841
|
-
[
|
|
842
|
-
path,
|
|
843
|
-
flags,
|
|
844
|
-
mode,
|
|
845
|
-
cb
|
|
846
|
-
],
|
|
847
|
-
err,
|
|
848
|
-
startTime || Date.now(),
|
|
849
|
-
Date.now()
|
|
850
|
-
]);
|
|
851
|
-
else {
|
|
852
|
-
if (typeof cb === 'function') cb.apply(this, arguments);
|
|
853
|
-
}
|
|
854
|
-
});
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
return fs;
|
|
858
|
-
}
|
|
859
|
-
function enqueue(elem) {
|
|
860
|
-
debug('ENQUEUE', elem[0].name, elem[1]);
|
|
861
|
-
fs$h[gracefulQueue].push(elem);
|
|
862
|
-
retry();
|
|
863
|
-
}
|
|
864
|
-
// keep track of the timeout between retry() calls
|
|
865
|
-
var retryTimer;
|
|
866
|
-
// reset the startTime and lastTime to now
|
|
867
|
-
// this resets the start of the 60 second overall timeout as well as the
|
|
868
|
-
// delay between attempts so that we'll retry these jobs sooner
|
|
869
|
-
function resetQueue() {
|
|
870
|
-
var now = Date.now();
|
|
871
|
-
for(var i = 0; i < fs$h[gracefulQueue].length; ++i){
|
|
872
|
-
// entries that are only a length of 2 are from an older version, don't
|
|
873
|
-
// bother modifying those since they'll be retried anyway.
|
|
874
|
-
if (fs$h[gracefulQueue][i].length > 2) {
|
|
875
|
-
fs$h[gracefulQueue][i][3] = now // startTime
|
|
876
|
-
;
|
|
877
|
-
fs$h[gracefulQueue][i][4] = now // lastTime
|
|
878
|
-
;
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
// call retry to make sure we're actively processing the queue
|
|
882
|
-
retry();
|
|
883
|
-
}
|
|
884
|
-
function retry() {
|
|
885
|
-
// clear the timer and remove it to help prevent unintended concurrency
|
|
886
|
-
clearTimeout(retryTimer);
|
|
887
|
-
retryTimer = undefined;
|
|
888
|
-
if (fs$h[gracefulQueue].length === 0) return;
|
|
889
|
-
var elem = fs$h[gracefulQueue].shift();
|
|
890
|
-
var fn = elem[0];
|
|
891
|
-
var args = elem[1];
|
|
892
|
-
// these items may be unset if they were added by an older graceful-fs
|
|
893
|
-
var err = elem[2];
|
|
894
|
-
var startTime = elem[3];
|
|
895
|
-
var lastTime = elem[4];
|
|
896
|
-
// if we don't have a startTime we have no way of knowing if we've waited
|
|
897
|
-
// long enough, so go ahead and retry this item now
|
|
898
|
-
if (startTime === undefined) {
|
|
899
|
-
debug('RETRY', fn.name, args);
|
|
900
|
-
fn.apply(null, args);
|
|
901
|
-
} else if (Date.now() - startTime >= 60000) {
|
|
902
|
-
// it's been more than 60 seconds total, bail now
|
|
903
|
-
debug('TIMEOUT', fn.name, args);
|
|
904
|
-
var cb = args.pop();
|
|
905
|
-
if (typeof cb === 'function') cb.call(null, err);
|
|
906
|
-
} else {
|
|
907
|
-
// the amount of time between the last attempt and right now
|
|
908
|
-
var sinceAttempt = Date.now() - lastTime;
|
|
909
|
-
// the amount of time between when we first tried, and when we last tried
|
|
910
|
-
// rounded up to at least 1
|
|
911
|
-
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
912
|
-
// backoff. wait longer than the total time we've been retrying, but only
|
|
913
|
-
// up to a maximum of 100ms
|
|
914
|
-
var desiredDelay = Math.min(sinceStart * 1.2, 100);
|
|
915
|
-
// it's been long enough since the last retry, do it again
|
|
916
|
-
if (sinceAttempt >= desiredDelay) {
|
|
917
|
-
debug('RETRY', fn.name, args);
|
|
918
|
-
fn.apply(null, args.concat([
|
|
919
|
-
startTime
|
|
920
|
-
]));
|
|
921
|
-
} else {
|
|
922
|
-
// if we can't do this job yet, push it to the end of the queue
|
|
923
|
-
// and let the next iteration check again
|
|
924
|
-
fs$h[gracefulQueue].push(elem);
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
// schedule our next run if one isn't already scheduled
|
|
928
|
-
if (retryTimer === undefined) {
|
|
929
|
-
retryTimer = setTimeout(retry, 0);
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
|
|
933
|
-
(function (exports) {
|
|
934
|
-
function _array_like_to_array(arr, len) {
|
|
935
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
936
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
937
|
-
return arr2;
|
|
938
|
-
}
|
|
939
|
-
function _array_without_holes(arr) {
|
|
940
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
941
|
-
}
|
|
942
|
-
function _iterable_to_array(iter) {
|
|
943
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
944
|
-
}
|
|
945
|
-
function _non_iterable_spread() {
|
|
946
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
947
|
-
}
|
|
948
|
-
function _to_consumable_array(arr) {
|
|
949
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
950
|
-
}
|
|
951
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
952
|
-
if (!o) return;
|
|
953
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
954
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
955
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
956
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
957
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
958
|
-
}
|
|
959
|
-
// This is adapted from https://github.com/normalize/mz
|
|
960
|
-
// Copyright (c) 2014-2016 Jonathan Ong me@jongleberry.com and Contributors
|
|
961
|
-
var u = universalify$1.fromCallback;
|
|
962
|
-
var fs = gracefulFs;
|
|
963
|
-
var api = [
|
|
964
|
-
'access',
|
|
965
|
-
'appendFile',
|
|
966
|
-
'chmod',
|
|
967
|
-
'chown',
|
|
968
|
-
'close',
|
|
969
|
-
'copyFile',
|
|
970
|
-
'fchmod',
|
|
971
|
-
'fchown',
|
|
972
|
-
'fdatasync',
|
|
973
|
-
'fstat',
|
|
974
|
-
'fsync',
|
|
975
|
-
'ftruncate',
|
|
976
|
-
'futimes',
|
|
977
|
-
'lchmod',
|
|
978
|
-
'lchown',
|
|
979
|
-
'link',
|
|
980
|
-
'lstat',
|
|
981
|
-
'mkdir',
|
|
982
|
-
'mkdtemp',
|
|
983
|
-
'open',
|
|
984
|
-
'opendir',
|
|
985
|
-
'readdir',
|
|
986
|
-
'readFile',
|
|
987
|
-
'readlink',
|
|
988
|
-
'realpath',
|
|
989
|
-
'rename',
|
|
990
|
-
'rm',
|
|
991
|
-
'rmdir',
|
|
992
|
-
'stat',
|
|
993
|
-
'symlink',
|
|
994
|
-
'truncate',
|
|
995
|
-
'unlink',
|
|
996
|
-
'utimes',
|
|
997
|
-
'writeFile'
|
|
998
|
-
].filter(function(key) {
|
|
999
|
-
// Some commands are not available on some systems. Ex:
|
|
1000
|
-
// fs.opendir was added in Node.js v12.12.0
|
|
1001
|
-
// fs.rm was added in Node.js v14.14.0
|
|
1002
|
-
// fs.lchown is not available on at least some Linux
|
|
1003
|
-
return typeof fs[key] === 'function';
|
|
1004
|
-
});
|
|
1005
|
-
// Export all keys:
|
|
1006
|
-
Object.keys(fs).forEach(function(key) {
|
|
1007
|
-
if (key === 'promises') {
|
|
1008
|
-
// fs.promises is a getter property that triggers ExperimentalWarning
|
|
1009
|
-
// Don't re-export it here, the getter is defined in "lib/index.js"
|
|
1010
|
-
return;
|
|
1011
|
-
}
|
|
1012
|
-
exports[key] = fs[key];
|
|
1013
|
-
});
|
|
1014
|
-
// Universalify async methods:
|
|
1015
|
-
api.forEach(function(method) {
|
|
1016
|
-
exports[method] = u(fs[method]);
|
|
1017
|
-
});
|
|
1018
|
-
// We differ from mz/fs in that we still ship the old, broken, fs.exists()
|
|
1019
|
-
// since we are a drop-in replacement for the native module
|
|
1020
|
-
exports.exists = function(filename, callback) {
|
|
1021
|
-
if (typeof callback === 'function') {
|
|
1022
|
-
return fs.exists(filename, callback);
|
|
1023
|
-
}
|
|
1024
|
-
return new Promise(function(resolve) {
|
|
1025
|
-
return fs.exists(filename, resolve);
|
|
1026
|
-
});
|
|
1027
|
-
};
|
|
1028
|
-
// fs.read(), fs.write(), & fs.writev() need special treatment due to multiple callback args
|
|
1029
|
-
exports.read = function(fd, buffer, offset, length, position, callback) {
|
|
1030
|
-
if (typeof callback === 'function') {
|
|
1031
|
-
return fs.read(fd, buffer, offset, length, position, callback);
|
|
1032
|
-
}
|
|
1033
|
-
return new Promise(function(resolve, reject) {
|
|
1034
|
-
fs.read(fd, buffer, offset, length, position, function(err, bytesRead, buffer) {
|
|
1035
|
-
if (err) return reject(err);
|
|
1036
|
-
resolve({
|
|
1037
|
-
bytesRead: bytesRead,
|
|
1038
|
-
buffer: buffer
|
|
1039
|
-
});
|
|
1040
|
-
});
|
|
1041
|
-
});
|
|
1042
|
-
};
|
|
1043
|
-
// Function signature can be
|
|
1044
|
-
// fs.write(fd, buffer[, offset[, length[, position]]], callback)
|
|
1045
|
-
// OR
|
|
1046
|
-
// fs.write(fd, string[, position[, encoding]], callback)
|
|
1047
|
-
// We need to handle both cases, so we use ...args
|
|
1048
|
-
exports.write = function(fd, buffer) {
|
|
1049
|
-
for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
|
1050
|
-
args[_key - 2] = arguments[_key];
|
|
1051
|
-
}
|
|
1052
|
-
if (typeof args[args.length - 1] === 'function') {
|
|
1053
|
-
var _fs;
|
|
1054
|
-
return (_fs = fs).write.apply(_fs, [
|
|
1055
|
-
fd,
|
|
1056
|
-
buffer
|
|
1057
|
-
].concat(_to_consumable_array(args)));
|
|
1058
|
-
}
|
|
1059
|
-
return new Promise(function(resolve, reject) {
|
|
1060
|
-
var _fs;
|
|
1061
|
-
(_fs = fs).write.apply(_fs, [
|
|
1062
|
-
fd,
|
|
1063
|
-
buffer
|
|
1064
|
-
].concat(_to_consumable_array(args), [
|
|
1065
|
-
function(err, bytesWritten, buffer) {
|
|
1066
|
-
if (err) return reject(err);
|
|
1067
|
-
resolve({
|
|
1068
|
-
bytesWritten: bytesWritten,
|
|
1069
|
-
buffer: buffer
|
|
1070
|
-
});
|
|
1071
|
-
}
|
|
1072
|
-
]));
|
|
1073
|
-
});
|
|
1074
|
-
};
|
|
1075
|
-
// fs.writev only available in Node v12.9.0+
|
|
1076
|
-
if (typeof fs.writev === 'function') {
|
|
1077
|
-
// Function signature is
|
|
1078
|
-
// s.writev(fd, buffers[, position], callback)
|
|
1079
|
-
// We need to handle the optional arg, so we use ...args
|
|
1080
|
-
exports.writev = function(fd, buffers) {
|
|
1081
|
-
for(var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++){
|
|
1082
|
-
args[_key - 2] = arguments[_key];
|
|
1083
|
-
}
|
|
1084
|
-
if (typeof args[args.length - 1] === 'function') {
|
|
1085
|
-
var _fs;
|
|
1086
|
-
return (_fs = fs).writev.apply(_fs, [
|
|
1087
|
-
fd,
|
|
1088
|
-
buffers
|
|
1089
|
-
].concat(_to_consumable_array(args)));
|
|
1090
|
-
}
|
|
1091
|
-
return new Promise(function(resolve, reject) {
|
|
1092
|
-
var _fs;
|
|
1093
|
-
(_fs = fs).writev.apply(_fs, [
|
|
1094
|
-
fd,
|
|
1095
|
-
buffers
|
|
1096
|
-
].concat(_to_consumable_array(args), [
|
|
1097
|
-
function(err, bytesWritten, buffers) {
|
|
1098
|
-
if (err) return reject(err);
|
|
1099
|
-
resolve({
|
|
1100
|
-
bytesWritten: bytesWritten,
|
|
1101
|
-
buffers: buffers
|
|
1102
|
-
});
|
|
1103
|
-
}
|
|
1104
|
-
]));
|
|
1105
|
-
});
|
|
1106
|
-
};
|
|
1107
|
-
}
|
|
1108
|
-
// fs.realpath.native only available in Node v9.2+
|
|
1109
|
-
if (typeof fs.realpath.native === 'function') {
|
|
1110
|
-
exports.realpath.native = u(fs.realpath.native);
|
|
1111
|
-
}
|
|
1112
|
-
}(fs$i));
|
|
1113
|
-
|
|
1114
|
-
var makeDir$1 = {};
|
|
1115
|
-
|
|
1116
|
-
var atLeastNode$2 = function(r) {
|
|
1117
|
-
var n = process.versions.node.split('.').map(function(x) {
|
|
1118
|
-
return parseInt(x, 10);
|
|
1119
|
-
});
|
|
1120
|
-
r = r.split('.').map(function(x) {
|
|
1121
|
-
return parseInt(x, 10);
|
|
1122
|
-
});
|
|
1123
|
-
return n[0] > r[0] || n[0] === r[0] && (n[1] > r[1] || n[1] === r[1] && n[2] >= r[2]);
|
|
1124
|
-
};
|
|
1125
|
-
|
|
1126
|
-
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
1127
|
-
try {
|
|
1128
|
-
var info = gen[key](arg);
|
|
1129
|
-
var value = info.value;
|
|
1130
|
-
} catch (error) {
|
|
1131
|
-
reject(error);
|
|
1132
|
-
return;
|
|
1133
|
-
}
|
|
1134
|
-
if (info.done) {
|
|
1135
|
-
resolve(value);
|
|
1136
|
-
} else {
|
|
1137
|
-
Promise.resolve(value).then(_next, _throw);
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
function _async_to_generator$2(fn) {
|
|
1141
|
-
return function() {
|
|
1142
|
-
var self = this, args = arguments;
|
|
1143
|
-
return new Promise(function(resolve, reject) {
|
|
1144
|
-
var gen = fn.apply(self, args);
|
|
1145
|
-
function _next(value) {
|
|
1146
|
-
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
1147
|
-
}
|
|
1148
|
-
function _throw(err) {
|
|
1149
|
-
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
1150
|
-
}
|
|
1151
|
-
_next(undefined);
|
|
1152
|
-
});
|
|
1153
|
-
};
|
|
1154
|
-
}
|
|
1155
|
-
function _define_property$1(obj, key, value) {
|
|
1156
|
-
if (key in obj) {
|
|
1157
|
-
Object.defineProperty(obj, key, {
|
|
1158
|
-
value: value,
|
|
1159
|
-
enumerable: true,
|
|
1160
|
-
configurable: true,
|
|
1161
|
-
writable: true
|
|
1162
|
-
});
|
|
1163
|
-
} else {
|
|
1164
|
-
obj[key] = value;
|
|
1165
|
-
}
|
|
1166
|
-
return obj;
|
|
1167
|
-
}
|
|
1168
|
-
function _object_spread(target) {
|
|
1169
|
-
for(var i = 1; i < arguments.length; i++){
|
|
1170
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
1171
|
-
var ownKeys = Object.keys(source);
|
|
1172
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
1173
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
1174
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
1175
|
-
}));
|
|
1176
|
-
}
|
|
1177
|
-
ownKeys.forEach(function(key) {
|
|
1178
|
-
_define_property$1(target, key, source[key]);
|
|
1179
|
-
});
|
|
1180
|
-
}
|
|
1181
|
-
return target;
|
|
1182
|
-
}
|
|
1183
|
-
function _ts_generator$2(thisArg, body) {
|
|
1184
|
-
var f, y, t, g, _ = {
|
|
1185
|
-
label: 0,
|
|
1186
|
-
sent: function() {
|
|
1187
|
-
if (t[0] & 1) throw t[1];
|
|
1188
|
-
return t[1];
|
|
1189
|
-
},
|
|
1190
|
-
trys: [],
|
|
1191
|
-
ops: []
|
|
1192
|
-
};
|
|
1193
|
-
return g = {
|
|
1194
|
-
next: verb(0),
|
|
1195
|
-
"throw": verb(1),
|
|
1196
|
-
"return": verb(2)
|
|
1197
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
1198
|
-
return this;
|
|
1199
|
-
}), g;
|
|
1200
|
-
function verb(n) {
|
|
1201
|
-
return function(v) {
|
|
1202
|
-
return step([
|
|
1203
|
-
n,
|
|
1204
|
-
v
|
|
1205
|
-
]);
|
|
1206
|
-
};
|
|
1207
|
-
}
|
|
1208
|
-
function step(op) {
|
|
1209
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
1210
|
-
while(_)try {
|
|
1211
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
1212
|
-
if (y = 0, t) op = [
|
|
1213
|
-
op[0] & 2,
|
|
1214
|
-
t.value
|
|
1215
|
-
];
|
|
1216
|
-
switch(op[0]){
|
|
1217
|
-
case 0:
|
|
1218
|
-
case 1:
|
|
1219
|
-
t = op;
|
|
79
|
+
exposePath = exposeValue.import[0];
|
|
80
|
+
}
|
|
81
|
+
const targetPaths = fixPrefetchPath(exposePath);
|
|
82
|
+
for (const pathItem of targetPaths){
|
|
83
|
+
const absolutePath = path.resolve(compiler.options.context, pathItem);
|
|
84
|
+
if (fileExistsWithCaseSync(absolutePath)) {
|
|
85
|
+
const absoluteAlias = alias.replace('.', '');
|
|
86
|
+
this._reWriteExports += `export * as ${runtimeUtils.getPrefetchId(`${name}${absoluteAlias}`)} from '${absolutePath}';\n`;
|
|
1220
87
|
break;
|
|
1221
|
-
case 4:
|
|
1222
|
-
_.label++;
|
|
1223
|
-
return {
|
|
1224
|
-
value: op[1],
|
|
1225
|
-
done: false
|
|
1226
|
-
};
|
|
1227
|
-
case 5:
|
|
1228
|
-
_.label++;
|
|
1229
|
-
y = op[1];
|
|
1230
|
-
op = [
|
|
1231
|
-
0
|
|
1232
|
-
];
|
|
1233
|
-
continue;
|
|
1234
|
-
case 7:
|
|
1235
|
-
op = _.ops.pop();
|
|
1236
|
-
_.trys.pop();
|
|
1237
|
-
continue;
|
|
1238
|
-
default:
|
|
1239
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
1240
|
-
_ = 0;
|
|
1241
|
-
continue;
|
|
1242
|
-
}
|
|
1243
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
1244
|
-
_.label = op[1];
|
|
1245
|
-
break;
|
|
1246
|
-
}
|
|
1247
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
1248
|
-
_.label = t[1];
|
|
1249
|
-
t = op;
|
|
1250
|
-
break;
|
|
1251
|
-
}
|
|
1252
|
-
if (t && _.label < t[2]) {
|
|
1253
|
-
_.label = t[2];
|
|
1254
|
-
_.ops.push(op);
|
|
1255
|
-
break;
|
|
1256
|
-
}
|
|
1257
|
-
if (t[2]) _.ops.pop();
|
|
1258
|
-
_.trys.pop();
|
|
1259
|
-
continue;
|
|
1260
|
-
}
|
|
1261
|
-
op = body.call(thisArg, _);
|
|
1262
|
-
} catch (e) {
|
|
1263
|
-
op = [
|
|
1264
|
-
6,
|
|
1265
|
-
e
|
|
1266
|
-
];
|
|
1267
|
-
y = 0;
|
|
1268
|
-
} finally{
|
|
1269
|
-
f = t = 0;
|
|
1270
|
-
}
|
|
1271
|
-
if (op[0] & 5) throw op[1];
|
|
1272
|
-
return {
|
|
1273
|
-
value: op[0] ? op[1] : void 0,
|
|
1274
|
-
done: true
|
|
1275
|
-
};
|
|
1276
|
-
}
|
|
1277
|
-
}
|
|
1278
|
-
var fs$g = fs$i;
|
|
1279
|
-
var path$c = require$$1__default["default"];
|
|
1280
|
-
var atLeastNode$1 = atLeastNode$2;
|
|
1281
|
-
var useNativeRecursiveOption = atLeastNode$1('10.12.0');
|
|
1282
|
-
// https://github.com/nodejs/node/issues/8987
|
|
1283
|
-
// https://github.com/libuv/libuv/pull/1088
|
|
1284
|
-
var checkPath = function(pth) {
|
|
1285
|
-
if (process.platform === 'win32') {
|
|
1286
|
-
var pathHasInvalidWinCharacters = /[<>:"|?*]/.test(pth.replace(path$c.parse(pth).root, ''));
|
|
1287
|
-
if (pathHasInvalidWinCharacters) {
|
|
1288
|
-
var error = new Error("Path contains invalid characters: ".concat(pth));
|
|
1289
|
-
error.code = 'EINVAL';
|
|
1290
|
-
throw error;
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
};
|
|
1294
|
-
var processOptions = function(options) {
|
|
1295
|
-
var defaults = {
|
|
1296
|
-
mode: 511
|
|
1297
|
-
};
|
|
1298
|
-
if (typeof options === 'number') options = {
|
|
1299
|
-
mode: options
|
|
1300
|
-
};
|
|
1301
|
-
return _object_spread({}, defaults, options);
|
|
1302
|
-
};
|
|
1303
|
-
var permissionError = function(pth) {
|
|
1304
|
-
// This replicates the exception of `fs.mkdir` with native the
|
|
1305
|
-
// `recusive` option when run on an invalid drive under Windows.
|
|
1306
|
-
var error = new Error("operation not permitted, mkdir '".concat(pth, "'"));
|
|
1307
|
-
error.code = 'EPERM';
|
|
1308
|
-
error.errno = -4048;
|
|
1309
|
-
error.path = pth;
|
|
1310
|
-
error.syscall = 'mkdir';
|
|
1311
|
-
return error;
|
|
1312
|
-
};
|
|
1313
|
-
makeDir$1.makeDir = function() {
|
|
1314
|
-
var _ref = _async_to_generator$2(function(input, options) {
|
|
1315
|
-
var pth, make;
|
|
1316
|
-
return _ts_generator$2(this, function(_state) {
|
|
1317
|
-
checkPath(input);
|
|
1318
|
-
options = processOptions(options);
|
|
1319
|
-
if (useNativeRecursiveOption) {
|
|
1320
|
-
pth = path$c.resolve(input);
|
|
1321
|
-
return [
|
|
1322
|
-
2,
|
|
1323
|
-
fs$g.mkdir(pth, {
|
|
1324
|
-
mode: options.mode,
|
|
1325
|
-
recursive: true
|
|
1326
|
-
})
|
|
1327
|
-
];
|
|
1328
|
-
}
|
|
1329
|
-
make = function() {
|
|
1330
|
-
var _ref = _async_to_generator$2(function(pth) {
|
|
1331
|
-
var error, stats;
|
|
1332
|
-
return _ts_generator$2(this, function(_state) {
|
|
1333
|
-
switch(_state.label){
|
|
1334
|
-
case 0:
|
|
1335
|
-
_state.trys.push([
|
|
1336
|
-
0,
|
|
1337
|
-
2,
|
|
1338
|
-
,
|
|
1339
|
-
8
|
|
1340
|
-
]);
|
|
1341
|
-
return [
|
|
1342
|
-
4,
|
|
1343
|
-
fs$g.mkdir(pth, options.mode)
|
|
1344
|
-
];
|
|
1345
|
-
case 1:
|
|
1346
|
-
_state.sent();
|
|
1347
|
-
return [
|
|
1348
|
-
3,
|
|
1349
|
-
8
|
|
1350
|
-
];
|
|
1351
|
-
case 2:
|
|
1352
|
-
error = _state.sent();
|
|
1353
|
-
if (error.code === 'EPERM') {
|
|
1354
|
-
throw error;
|
|
1355
|
-
}
|
|
1356
|
-
if (!(error.code === 'ENOENT')) return [
|
|
1357
|
-
3,
|
|
1358
|
-
4
|
|
1359
|
-
];
|
|
1360
|
-
if (path$c.dirname(pth) === pth) {
|
|
1361
|
-
throw permissionError(pth);
|
|
1362
|
-
}
|
|
1363
|
-
if (error.message.includes('null bytes')) {
|
|
1364
|
-
throw error;
|
|
1365
|
-
}
|
|
1366
|
-
return [
|
|
1367
|
-
4,
|
|
1368
|
-
make(path$c.dirname(pth))
|
|
1369
|
-
];
|
|
1370
|
-
case 3:
|
|
1371
|
-
_state.sent();
|
|
1372
|
-
return [
|
|
1373
|
-
2,
|
|
1374
|
-
make(pth)
|
|
1375
|
-
];
|
|
1376
|
-
case 4:
|
|
1377
|
-
_state.trys.push([
|
|
1378
|
-
4,
|
|
1379
|
-
6,
|
|
1380
|
-
,
|
|
1381
|
-
7
|
|
1382
|
-
]);
|
|
1383
|
-
return [
|
|
1384
|
-
4,
|
|
1385
|
-
fs$g.stat(pth)
|
|
1386
|
-
];
|
|
1387
|
-
case 5:
|
|
1388
|
-
stats = _state.sent();
|
|
1389
|
-
if (!stats.isDirectory()) {
|
|
1390
|
-
// This error is never exposed to the user
|
|
1391
|
-
// it is caught below, and the original error is thrown
|
|
1392
|
-
throw new Error('The path is not a directory');
|
|
1393
|
-
}
|
|
1394
|
-
return [
|
|
1395
|
-
3,
|
|
1396
|
-
7
|
|
1397
|
-
];
|
|
1398
|
-
case 6:
|
|
1399
|
-
_state.sent();
|
|
1400
|
-
throw error;
|
|
1401
|
-
case 7:
|
|
1402
|
-
return [
|
|
1403
|
-
3,
|
|
1404
|
-
8
|
|
1405
|
-
];
|
|
1406
|
-
case 8:
|
|
1407
|
-
return [
|
|
1408
|
-
2
|
|
1409
|
-
];
|
|
1410
|
-
}
|
|
1411
|
-
});
|
|
1412
|
-
});
|
|
1413
|
-
return function make(pth) {
|
|
1414
|
-
return _ref.apply(this, arguments);
|
|
1415
|
-
};
|
|
1416
|
-
}();
|
|
1417
|
-
return [
|
|
1418
|
-
2,
|
|
1419
|
-
make(path$c.resolve(input))
|
|
1420
|
-
];
|
|
1421
|
-
});
|
|
1422
|
-
});
|
|
1423
|
-
return function(input, options) {
|
|
1424
|
-
return _ref.apply(this, arguments);
|
|
1425
|
-
};
|
|
1426
|
-
}();
|
|
1427
|
-
makeDir$1.makeDirSync = function(input, options) {
|
|
1428
|
-
checkPath(input);
|
|
1429
|
-
options = processOptions(options);
|
|
1430
|
-
if (useNativeRecursiveOption) {
|
|
1431
|
-
var pth = path$c.resolve(input);
|
|
1432
|
-
return fs$g.mkdirSync(pth, {
|
|
1433
|
-
mode: options.mode,
|
|
1434
|
-
recursive: true
|
|
1435
|
-
});
|
|
1436
|
-
}
|
|
1437
|
-
var make = function(pth) {
|
|
1438
|
-
try {
|
|
1439
|
-
fs$g.mkdirSync(pth, options.mode);
|
|
1440
|
-
} catch (error) {
|
|
1441
|
-
if (error.code === 'EPERM') {
|
|
1442
|
-
throw error;
|
|
1443
|
-
}
|
|
1444
|
-
if (error.code === 'ENOENT') {
|
|
1445
|
-
if (path$c.dirname(pth) === pth) {
|
|
1446
|
-
throw permissionError(pth);
|
|
1447
|
-
}
|
|
1448
|
-
if (error.message.includes('null bytes')) {
|
|
1449
|
-
throw error;
|
|
1450
|
-
}
|
|
1451
|
-
make(path$c.dirname(pth));
|
|
1452
|
-
return make(pth);
|
|
1453
|
-
}
|
|
1454
|
-
try {
|
|
1455
|
-
if (!fs$g.statSync(pth).isDirectory()) {
|
|
1456
|
-
// This error is never exposed to the user
|
|
1457
|
-
// it is caught below, and the original error is thrown
|
|
1458
|
-
throw new Error('The path is not a directory');
|
|
1459
88
|
}
|
|
1460
|
-
} catch (e) {
|
|
1461
|
-
throw error;
|
|
1462
89
|
}
|
|
1463
|
-
}
|
|
1464
|
-
};
|
|
1465
|
-
return make(path$c.resolve(input));
|
|
1466
|
-
};
|
|
1467
|
-
|
|
1468
|
-
var u$a = universalify$1.fromPromise;
|
|
1469
|
-
var _require$2 = makeDir$1, _makeDir = _require$2.makeDir, makeDirSync = _require$2.makeDirSync;
|
|
1470
|
-
var makeDir = u$a(_makeDir);
|
|
1471
|
-
var mkdirs$2 = {
|
|
1472
|
-
mkdirs: makeDir,
|
|
1473
|
-
mkdirsSync: makeDirSync,
|
|
1474
|
-
// alias
|
|
1475
|
-
mkdirp: makeDir,
|
|
1476
|
-
mkdirpSync: makeDirSync,
|
|
1477
|
-
ensureDir: makeDir,
|
|
1478
|
-
ensureDirSync: makeDirSync
|
|
1479
|
-
};
|
|
1480
|
-
|
|
1481
|
-
var fs$f = gracefulFs;
|
|
1482
|
-
function utimesMillis$1(path, atime, mtime, callback) {
|
|
1483
|
-
// if (!HAS_MILLIS_RES) return fs.utimes(path, atime, mtime, callback)
|
|
1484
|
-
fs$f.open(path, 'r+', function(err, fd) {
|
|
1485
|
-
if (err) return callback(err);
|
|
1486
|
-
fs$f.futimes(fd, atime, mtime, function(futimesErr) {
|
|
1487
|
-
fs$f.close(fd, function(closeErr) {
|
|
1488
|
-
if (callback) callback(futimesErr || closeErr);
|
|
1489
|
-
});
|
|
1490
|
-
});
|
|
1491
|
-
});
|
|
1492
|
-
}
|
|
1493
|
-
function utimesMillisSync$1(path, atime, mtime) {
|
|
1494
|
-
var fd = fs$f.openSync(path, 'r+');
|
|
1495
|
-
fs$f.futimesSync(fd, atime, mtime);
|
|
1496
|
-
return fs$f.closeSync(fd);
|
|
1497
|
-
}
|
|
1498
|
-
var utimes = {
|
|
1499
|
-
utimesMillis: utimesMillis$1,
|
|
1500
|
-
utimesMillisSync: utimesMillisSync$1
|
|
1501
|
-
};
|
|
1502
|
-
|
|
1503
|
-
function _array_like_to_array$1(arr, len) {
|
|
1504
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
1505
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
1506
|
-
return arr2;
|
|
1507
|
-
}
|
|
1508
|
-
function _array_with_holes(arr) {
|
|
1509
|
-
if (Array.isArray(arr)) return arr;
|
|
1510
|
-
}
|
|
1511
|
-
function _iterable_to_array_limit(arr, i) {
|
|
1512
|
-
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
1513
|
-
if (_i == null) return;
|
|
1514
|
-
var _arr = [];
|
|
1515
|
-
var _n = true;
|
|
1516
|
-
var _d = false;
|
|
1517
|
-
var _s, _e;
|
|
1518
|
-
try {
|
|
1519
|
-
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
1520
|
-
_arr.push(_s.value);
|
|
1521
|
-
if (i && _arr.length === i) break;
|
|
1522
|
-
}
|
|
1523
|
-
} catch (err) {
|
|
1524
|
-
_d = true;
|
|
1525
|
-
_e = err;
|
|
1526
|
-
} finally{
|
|
1527
|
-
try {
|
|
1528
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
1529
|
-
} finally{
|
|
1530
|
-
if (_d) throw _e;
|
|
1531
|
-
}
|
|
1532
|
-
}
|
|
1533
|
-
return _arr;
|
|
1534
|
-
}
|
|
1535
|
-
function _non_iterable_rest() {
|
|
1536
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1537
|
-
}
|
|
1538
|
-
function _sliced_to_array(arr, i) {
|
|
1539
|
-
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array$1(arr, i) || _non_iterable_rest();
|
|
1540
|
-
}
|
|
1541
|
-
function _unsupported_iterable_to_array$1(o, minLen) {
|
|
1542
|
-
if (!o) return;
|
|
1543
|
-
if (typeof o === "string") return _array_like_to_array$1(o, minLen);
|
|
1544
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
1545
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
1546
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
1547
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array$1(o, minLen);
|
|
1548
|
-
}
|
|
1549
|
-
var fs$e = fs$i;
|
|
1550
|
-
var path$b = require$$1__default["default"];
|
|
1551
|
-
var util = require$$4__default["default"];
|
|
1552
|
-
var atLeastNode = atLeastNode$2;
|
|
1553
|
-
var nodeSupportsBigInt = atLeastNode('10.5.0');
|
|
1554
|
-
var stat$4 = function(file) {
|
|
1555
|
-
return nodeSupportsBigInt ? fs$e.stat(file, {
|
|
1556
|
-
bigint: true
|
|
1557
|
-
}) : fs$e.stat(file);
|
|
1558
|
-
};
|
|
1559
|
-
var statSync = function(file) {
|
|
1560
|
-
return nodeSupportsBigInt ? fs$e.statSync(file, {
|
|
1561
|
-
bigint: true
|
|
1562
|
-
}) : fs$e.statSync(file);
|
|
1563
|
-
};
|
|
1564
|
-
function getStats$2(src, dest) {
|
|
1565
|
-
return Promise.all([
|
|
1566
|
-
stat$4(src),
|
|
1567
|
-
stat$4(dest).catch(function(err) {
|
|
1568
|
-
if (err.code === 'ENOENT') return null;
|
|
1569
|
-
throw err;
|
|
1570
|
-
})
|
|
1571
|
-
]).then(function(param) {
|
|
1572
|
-
var _param = _sliced_to_array(param, 2), srcStat = _param[0], destStat = _param[1];
|
|
1573
|
-
return {
|
|
1574
|
-
srcStat: srcStat,
|
|
1575
|
-
destStat: destStat
|
|
1576
|
-
};
|
|
1577
|
-
});
|
|
1578
|
-
}
|
|
1579
|
-
function getStatsSync(src, dest) {
|
|
1580
|
-
var destStat;
|
|
1581
|
-
var srcStat = statSync(src);
|
|
1582
|
-
try {
|
|
1583
|
-
destStat = statSync(dest);
|
|
1584
|
-
} catch (err) {
|
|
1585
|
-
if (err.code === 'ENOENT') return {
|
|
1586
|
-
srcStat: srcStat,
|
|
1587
|
-
destStat: null
|
|
1588
|
-
};
|
|
1589
|
-
throw err;
|
|
1590
|
-
}
|
|
1591
|
-
return {
|
|
1592
|
-
srcStat: srcStat,
|
|
1593
|
-
destStat: destStat
|
|
1594
|
-
};
|
|
1595
|
-
}
|
|
1596
|
-
function checkPaths(src, dest, funcName, cb) {
|
|
1597
|
-
util.callbackify(getStats$2)(src, dest, function(err, stats) {
|
|
1598
|
-
if (err) return cb(err);
|
|
1599
|
-
var srcStat = stats.srcStat, destStat = stats.destStat;
|
|
1600
|
-
if (destStat && areIdentical(srcStat, destStat)) {
|
|
1601
|
-
return cb(new Error('Source and destination must not be the same.'));
|
|
1602
|
-
}
|
|
1603
|
-
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
|
1604
|
-
return cb(new Error(errMsg(src, dest, funcName)));
|
|
1605
|
-
}
|
|
1606
|
-
return cb(null, {
|
|
1607
|
-
srcStat: srcStat,
|
|
1608
|
-
destStat: destStat
|
|
1609
90
|
});
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
function checkPathsSync(src, dest, funcName) {
|
|
1613
|
-
var _getStatsSync = getStatsSync(src, dest), srcStat = _getStatsSync.srcStat, destStat = _getStatsSync.destStat;
|
|
1614
|
-
if (destStat && areIdentical(srcStat, destStat)) {
|
|
1615
|
-
throw new Error('Source and destination must not be the same.');
|
|
1616
|
-
}
|
|
1617
|
-
if (srcStat.isDirectory() && isSrcSubdir(src, dest)) {
|
|
1618
|
-
throw new Error(errMsg(src, dest, funcName));
|
|
1619
|
-
}
|
|
1620
|
-
return {
|
|
1621
|
-
srcStat: srcStat,
|
|
1622
|
-
destStat: destStat
|
|
1623
|
-
};
|
|
1624
|
-
}
|
|
1625
|
-
// recursively check if dest parent is a subdirectory of src.
|
|
1626
|
-
// It works for all file types including symlinks since it
|
|
1627
|
-
// checks the src and dest inodes. It starts from the deepest
|
|
1628
|
-
// parent and stops once it reaches the src parent or the root path.
|
|
1629
|
-
function checkParentPaths(src, srcStat, dest, funcName, cb) {
|
|
1630
|
-
var srcParent = path$b.resolve(path$b.dirname(src));
|
|
1631
|
-
var destParent = path$b.resolve(path$b.dirname(dest));
|
|
1632
|
-
if (destParent === srcParent || destParent === path$b.parse(destParent).root) return cb();
|
|
1633
|
-
var callback = function(err, destStat) {
|
|
1634
|
-
if (err) {
|
|
1635
|
-
if (err.code === 'ENOENT') return cb();
|
|
1636
|
-
return cb(err);
|
|
1637
|
-
}
|
|
1638
|
-
if (areIdentical(srcStat, destStat)) {
|
|
1639
|
-
return cb(new Error(errMsg(src, dest, funcName)));
|
|
1640
|
-
}
|
|
1641
|
-
return checkParentPaths(src, srcStat, destParent, funcName, cb);
|
|
1642
|
-
};
|
|
1643
|
-
if (nodeSupportsBigInt) fs$e.stat(destParent, {
|
|
1644
|
-
bigint: true
|
|
1645
|
-
}, callback);
|
|
1646
|
-
else fs$e.stat(destParent, callback);
|
|
1647
|
-
}
|
|
1648
|
-
function checkParentPathsSync(src, srcStat, dest, funcName) {
|
|
1649
|
-
var srcParent = path$b.resolve(path$b.dirname(src));
|
|
1650
|
-
var destParent = path$b.resolve(path$b.dirname(dest));
|
|
1651
|
-
if (destParent === srcParent || destParent === path$b.parse(destParent).root) return;
|
|
1652
|
-
var destStat;
|
|
1653
|
-
try {
|
|
1654
|
-
destStat = statSync(destParent);
|
|
1655
|
-
} catch (err) {
|
|
1656
|
-
if (err.code === 'ENOENT') return;
|
|
1657
|
-
throw err;
|
|
1658
|
-
}
|
|
1659
|
-
if (areIdentical(srcStat, destStat)) {
|
|
1660
|
-
throw new Error(errMsg(src, dest, funcName));
|
|
1661
|
-
}
|
|
1662
|
-
return checkParentPathsSync(src, srcStat, destParent, funcName);
|
|
1663
|
-
}
|
|
1664
|
-
function areIdentical(srcStat, destStat) {
|
|
1665
|
-
if (destStat.ino && destStat.dev && destStat.ino === srcStat.ino && destStat.dev === srcStat.dev) {
|
|
1666
|
-
if (nodeSupportsBigInt || destStat.ino < Number.MAX_SAFE_INTEGER) {
|
|
1667
|
-
// definitive answer
|
|
1668
|
-
return true;
|
|
1669
|
-
}
|
|
1670
|
-
// Use additional heuristics if we can't use 'bigint'.
|
|
1671
|
-
// Different 'ino' could be represented the same if they are >= Number.MAX_SAFE_INTEGER
|
|
1672
|
-
// See issue 657
|
|
1673
|
-
if (destStat.size === srcStat.size && destStat.mode === srcStat.mode && destStat.nlink === srcStat.nlink && destStat.atimeMs === srcStat.atimeMs && destStat.mtimeMs === srcStat.mtimeMs && destStat.ctimeMs === srcStat.ctimeMs && destStat.birthtimeMs === srcStat.birthtimeMs) {
|
|
1674
|
-
// heuristic answer
|
|
1675
|
-
return true;
|
|
91
|
+
if (!this._reWriteExports) {
|
|
92
|
+
return;
|
|
1676
93
|
}
|
|
94
|
+
const tempDirRealPath = path.resolve(compiler.options.context, 'node_modules', TEMP_DIR);
|
|
95
|
+
if (!fs.existsSync(tempDirRealPath)) {
|
|
96
|
+
fs.mkdirSync(tempDirRealPath);
|
|
97
|
+
}
|
|
98
|
+
if (!fs.existsSync(`${tempDirRealPath}/${encodedName}`)) {
|
|
99
|
+
fs.mkdirSync(`${tempDirRealPath}/${encodedName}`);
|
|
100
|
+
}
|
|
101
|
+
fs.writeFileSync(asyncEntryPath, this._reWriteExports);
|
|
102
|
+
new compiler.webpack.DefinePlugin({
|
|
103
|
+
FederationDataPrefetch: JSON.stringify(asyncEntryPath)
|
|
104
|
+
}).apply(compiler);
|
|
105
|
+
}
|
|
106
|
+
static addRuntime(compiler, options) {
|
|
107
|
+
const encodedName = sdk.encodeName(options.name);
|
|
108
|
+
if (!compiler.options.context) {
|
|
109
|
+
throw new Error('compiler.options.context is not defined');
|
|
110
|
+
}
|
|
111
|
+
const prefetchEntry = path.resolve(compiler.options.context, `node_modules/.mf/${encodedName}/bootstrap.js`);
|
|
112
|
+
const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});
|
|
113
|
+
return Template.asString([
|
|
114
|
+
fs.existsSync(prefetchEntry) ? Template.indent([
|
|
115
|
+
'function injectPrefetch() {',
|
|
116
|
+
Template.indent([
|
|
117
|
+
`globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};`,
|
|
118
|
+
`globalThis.__FEDERATION__['${sdk.MFPrefetchCommon.globalKey}'] = globalThis.__FEDERATION__['${sdk.MFPrefetchCommon.globalKey}'] || {`,
|
|
119
|
+
`entryLoading: {},`,
|
|
120
|
+
`instance: new Map(),`,
|
|
121
|
+
`__PREFETCH_EXPORTS__: {},`,
|
|
122
|
+
`};`,
|
|
123
|
+
`globalThis.__FEDERATION__['${sdk.MFPrefetchCommon.globalKey}']['${sdk.MFPrefetchCommon.exportsKey}'] = globalThis.__FEDERATION__['${sdk.MFPrefetchCommon.globalKey}']['${sdk.MFPrefetchCommon.exportsKey}'] || {};`,
|
|
124
|
+
`globalThis.__FEDERATION__['${sdk.MFPrefetchCommon.globalKey}']['${sdk.MFPrefetchCommon.exportsKey}']['${options.name}'] = function(){ return import('${prefetchEntry}');}`
|
|
125
|
+
]),
|
|
126
|
+
'}',
|
|
127
|
+
`${federationGlobal}.prefetch = injectPrefetch`
|
|
128
|
+
]) : '',
|
|
129
|
+
Template.indent([
|
|
130
|
+
`if(!${federationGlobal}.isMFRemote && ${federationGlobal}.prefetch){`,
|
|
131
|
+
`${federationGlobal}.prefetch()`,
|
|
132
|
+
'}'
|
|
133
|
+
])
|
|
134
|
+
]);
|
|
135
|
+
}
|
|
136
|
+
static setRemoteIdentifier() {
|
|
137
|
+
const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});
|
|
138
|
+
return Template.indent([
|
|
139
|
+
`${federationGlobal}.isMFRemote = true;`
|
|
140
|
+
]);
|
|
141
|
+
}
|
|
142
|
+
static removeRemoteIdentifier() {
|
|
143
|
+
const federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});
|
|
144
|
+
return Template.indent([
|
|
145
|
+
`${federationGlobal}.isMFRemote = false;`
|
|
146
|
+
]);
|
|
147
|
+
}
|
|
148
|
+
constructor(options){
|
|
149
|
+
this.options = options;
|
|
150
|
+
this._reWriteExports = '';
|
|
1677
151
|
}
|
|
1678
|
-
return false;
|
|
1679
|
-
}
|
|
1680
|
-
// return true if dest is a subdir of src, otherwise false.
|
|
1681
|
-
// It only checks the path strings.
|
|
1682
|
-
function isSrcSubdir(src, dest) {
|
|
1683
|
-
var srcArr = path$b.resolve(src).split(path$b.sep).filter(function(i) {
|
|
1684
|
-
return i;
|
|
1685
|
-
});
|
|
1686
|
-
var destArr = path$b.resolve(dest).split(path$b.sep).filter(function(i) {
|
|
1687
|
-
return i;
|
|
1688
|
-
});
|
|
1689
|
-
return srcArr.reduce(function(acc, cur, i) {
|
|
1690
|
-
return acc && destArr[i] === cur;
|
|
1691
|
-
}, true);
|
|
1692
|
-
}
|
|
1693
|
-
function errMsg(src, dest, funcName) {
|
|
1694
|
-
return "Cannot ".concat(funcName, " '").concat(src, "' to a subdirectory of itself, '").concat(dest, "'.");
|
|
1695
|
-
}
|
|
1696
|
-
var stat_1 = {
|
|
1697
|
-
checkPaths: checkPaths,
|
|
1698
|
-
checkPathsSync: checkPathsSync,
|
|
1699
|
-
checkParentPaths: checkParentPaths,
|
|
1700
|
-
checkParentPathsSync: checkParentPathsSync,
|
|
1701
|
-
isSrcSubdir: isSrcSubdir
|
|
1702
|
-
};
|
|
1703
|
-
|
|
1704
|
-
var fs$d = gracefulFs;
|
|
1705
|
-
var path$a = require$$1__default["default"];
|
|
1706
|
-
var mkdirsSync$1 = mkdirs$2.mkdirsSync;
|
|
1707
|
-
var utimesMillisSync = utimes.utimesMillisSync;
|
|
1708
|
-
var stat$3 = stat_1;
|
|
1709
|
-
function copySync$2(src, dest, opts) {
|
|
1710
|
-
if (typeof opts === 'function') {
|
|
1711
|
-
opts = {
|
|
1712
|
-
filter: opts
|
|
1713
|
-
};
|
|
1714
|
-
}
|
|
1715
|
-
opts = opts || {};
|
|
1716
|
-
opts.clobber = 'clobber' in opts ? !!opts.clobber : true // default to true for now
|
|
1717
|
-
;
|
|
1718
|
-
opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber // overwrite falls back to clobber
|
|
1719
|
-
;
|
|
1720
|
-
// Warn about using preserveTimestamps on 32-bit node
|
|
1721
|
-
if (opts.preserveTimestamps && process.arch === 'ia32') {
|
|
1722
|
-
console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269");
|
|
1723
|
-
}
|
|
1724
|
-
var _stat_checkPathsSync = stat$3.checkPathsSync(src, dest, 'copy'), srcStat = _stat_checkPathsSync.srcStat, destStat = _stat_checkPathsSync.destStat;
|
|
1725
|
-
stat$3.checkParentPathsSync(src, srcStat, dest, 'copy');
|
|
1726
|
-
return handleFilterAndCopy(destStat, src, dest, opts);
|
|
1727
|
-
}
|
|
1728
|
-
function handleFilterAndCopy(destStat, src, dest, opts) {
|
|
1729
|
-
if (opts.filter && !opts.filter(src, dest)) return;
|
|
1730
|
-
var destParent = path$a.dirname(dest);
|
|
1731
|
-
if (!fs$d.existsSync(destParent)) mkdirsSync$1(destParent);
|
|
1732
|
-
return startCopy$1(destStat, src, dest, opts);
|
|
1733
|
-
}
|
|
1734
|
-
function startCopy$1(destStat, src, dest, opts) {
|
|
1735
|
-
if (opts.filter && !opts.filter(src, dest)) return;
|
|
1736
|
-
return getStats$1(destStat, src, dest, opts);
|
|
1737
|
-
}
|
|
1738
|
-
function getStats$1(destStat, src, dest, opts) {
|
|
1739
|
-
var statSync = opts.dereference ? fs$d.statSync : fs$d.lstatSync;
|
|
1740
|
-
var srcStat = statSync(src);
|
|
1741
|
-
if (srcStat.isDirectory()) return onDir$1(srcStat, destStat, src, dest, opts);
|
|
1742
|
-
else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile$1(srcStat, destStat, src, dest, opts);
|
|
1743
|
-
else if (srcStat.isSymbolicLink()) return onLink$1(destStat, src, dest, opts);
|
|
1744
|
-
}
|
|
1745
|
-
function onFile$1(srcStat, destStat, src, dest, opts) {
|
|
1746
|
-
if (!destStat) return copyFile$1(srcStat, src, dest, opts);
|
|
1747
|
-
return mayCopyFile$1(srcStat, src, dest, opts);
|
|
1748
|
-
}
|
|
1749
|
-
function mayCopyFile$1(srcStat, src, dest, opts) {
|
|
1750
|
-
if (opts.overwrite) {
|
|
1751
|
-
fs$d.unlinkSync(dest);
|
|
1752
|
-
return copyFile$1(srcStat, src, dest, opts);
|
|
1753
|
-
} else if (opts.errorOnExist) {
|
|
1754
|
-
throw new Error("'".concat(dest, "' already exists"));
|
|
1755
|
-
}
|
|
1756
|
-
}
|
|
1757
|
-
function copyFile$1(srcStat, src, dest, opts) {
|
|
1758
|
-
fs$d.copyFileSync(src, dest);
|
|
1759
|
-
if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest);
|
|
1760
|
-
return setDestMode$1(dest, srcStat.mode);
|
|
1761
|
-
}
|
|
1762
|
-
function handleTimestamps(srcMode, src, dest) {
|
|
1763
|
-
// Make sure the file is writable before setting the timestamp
|
|
1764
|
-
// otherwise open fails with EPERM when invoked with 'r+'
|
|
1765
|
-
// (through utimes call)
|
|
1766
|
-
if (fileIsNotWritable$1(srcMode)) makeFileWritable$1(dest, srcMode);
|
|
1767
|
-
return setDestTimestamps$1(src, dest);
|
|
1768
|
-
}
|
|
1769
|
-
function fileIsNotWritable$1(srcMode) {
|
|
1770
|
-
return (srcMode & 128) === 0;
|
|
1771
152
|
}
|
|
1772
|
-
function makeFileWritable$1(dest, srcMode) {
|
|
1773
|
-
return setDestMode$1(dest, srcMode | 128);
|
|
1774
|
-
}
|
|
1775
|
-
function setDestMode$1(dest, srcMode) {
|
|
1776
|
-
return fs$d.chmodSync(dest, srcMode);
|
|
1777
|
-
}
|
|
1778
|
-
function setDestTimestamps$1(src, dest) {
|
|
1779
|
-
// The initial srcStat.atime cannot be trusted
|
|
1780
|
-
// because it is modified by the read(2) system call
|
|
1781
|
-
// (See https://nodejs.org/api/fs.html#fs_stat_time_values)
|
|
1782
|
-
var updatedSrcStat = fs$d.statSync(src);
|
|
1783
|
-
return utimesMillisSync(dest, updatedSrcStat.atime, updatedSrcStat.mtime);
|
|
1784
|
-
}
|
|
1785
|
-
function onDir$1(srcStat, destStat, src, dest, opts) {
|
|
1786
|
-
if (!destStat) return mkDirAndCopy$1(srcStat.mode, src, dest, opts);
|
|
1787
|
-
if (destStat && !destStat.isDirectory()) {
|
|
1788
|
-
throw new Error("Cannot overwrite non-directory '".concat(dest, "' with directory '").concat(src, "'."));
|
|
1789
|
-
}
|
|
1790
|
-
return copyDir$1(src, dest, opts);
|
|
1791
|
-
}
|
|
1792
|
-
function mkDirAndCopy$1(srcMode, src, dest, opts) {
|
|
1793
|
-
fs$d.mkdirSync(dest);
|
|
1794
|
-
copyDir$1(src, dest, opts);
|
|
1795
|
-
return setDestMode$1(dest, srcMode);
|
|
1796
|
-
}
|
|
1797
|
-
function copyDir$1(src, dest, opts) {
|
|
1798
|
-
fs$d.readdirSync(src).forEach(function(item) {
|
|
1799
|
-
return copyDirItem$1(item, src, dest, opts);
|
|
1800
|
-
});
|
|
1801
|
-
}
|
|
1802
|
-
function copyDirItem$1(item, src, dest, opts) {
|
|
1803
|
-
var srcItem = path$a.join(src, item);
|
|
1804
|
-
var destItem = path$a.join(dest, item);
|
|
1805
|
-
var destStat = stat$3.checkPathsSync(srcItem, destItem, 'copy').destStat;
|
|
1806
|
-
return startCopy$1(destStat, srcItem, destItem, opts);
|
|
1807
|
-
}
|
|
1808
|
-
function onLink$1(destStat, src, dest, opts) {
|
|
1809
|
-
var resolvedSrc = fs$d.readlinkSync(src);
|
|
1810
|
-
if (opts.dereference) {
|
|
1811
|
-
resolvedSrc = path$a.resolve(process.cwd(), resolvedSrc);
|
|
1812
|
-
}
|
|
1813
|
-
if (!destStat) {
|
|
1814
|
-
return fs$d.symlinkSync(resolvedSrc, dest);
|
|
1815
|
-
} else {
|
|
1816
|
-
var resolvedDest;
|
|
1817
|
-
try {
|
|
1818
|
-
resolvedDest = fs$d.readlinkSync(dest);
|
|
1819
|
-
} catch (err) {
|
|
1820
|
-
// dest exists and is a regular file or directory,
|
|
1821
|
-
// Windows may throw UNKNOWN error. If dest already exists,
|
|
1822
|
-
// fs throws error anyway, so no need to guard against it here.
|
|
1823
|
-
if (err.code === 'EINVAL' || err.code === 'UNKNOWN') return fs$d.symlinkSync(resolvedSrc, dest);
|
|
1824
|
-
throw err;
|
|
1825
|
-
}
|
|
1826
|
-
if (opts.dereference) {
|
|
1827
|
-
resolvedDest = path$a.resolve(process.cwd(), resolvedDest);
|
|
1828
|
-
}
|
|
1829
|
-
if (stat$3.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
1830
|
-
throw new Error("Cannot copy '".concat(resolvedSrc, "' to a subdirectory of itself, '").concat(resolvedDest, "'."));
|
|
1831
|
-
}
|
|
1832
|
-
// prevent copy if src is a subdir of dest since unlinking
|
|
1833
|
-
// dest in this case would result in removing src contents
|
|
1834
|
-
// and therefore a broken symlink would be created.
|
|
1835
|
-
if (fs$d.statSync(dest).isDirectory() && stat$3.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
|
1836
|
-
throw new Error("Cannot overwrite '".concat(resolvedDest, "' with '").concat(resolvedSrc, "'."));
|
|
1837
|
-
}
|
|
1838
|
-
return copyLink$1(resolvedSrc, dest);
|
|
1839
|
-
}
|
|
1840
|
-
}
|
|
1841
|
-
function copyLink$1(resolvedSrc, dest) {
|
|
1842
|
-
fs$d.unlinkSync(dest);
|
|
1843
|
-
return fs$d.symlinkSync(resolvedSrc, dest);
|
|
1844
|
-
}
|
|
1845
|
-
var copySync_1 = copySync$2;
|
|
1846
|
-
|
|
1847
|
-
var copySync$1 = {
|
|
1848
|
-
copySync: copySync_1
|
|
1849
|
-
};
|
|
1850
|
-
|
|
1851
|
-
var u$9 = universalify$1.fromPromise;
|
|
1852
|
-
var fs$c = fs$i;
|
|
1853
|
-
function pathExists$6(path) {
|
|
1854
|
-
return fs$c.access(path).then(function() {
|
|
1855
|
-
return true;
|
|
1856
|
-
}).catch(function() {
|
|
1857
|
-
return false;
|
|
1858
|
-
});
|
|
1859
|
-
}
|
|
1860
|
-
var pathExists_1 = {
|
|
1861
|
-
pathExists: u$9(pathExists$6),
|
|
1862
|
-
pathExistsSync: fs$c.existsSync
|
|
1863
|
-
};
|
|
1864
|
-
|
|
1865
|
-
var fs$b = gracefulFs;
|
|
1866
|
-
var path$9 = require$$1__default["default"];
|
|
1867
|
-
var mkdirs$1 = mkdirs$2.mkdirs;
|
|
1868
|
-
var pathExists$5 = pathExists_1.pathExists;
|
|
1869
|
-
var utimesMillis = utimes.utimesMillis;
|
|
1870
|
-
var stat$2 = stat_1;
|
|
1871
|
-
function copy$2(src, dest, opts, cb) {
|
|
1872
|
-
if (typeof opts === 'function' && !cb) {
|
|
1873
|
-
cb = opts;
|
|
1874
|
-
opts = {};
|
|
1875
|
-
} else if (typeof opts === 'function') {
|
|
1876
|
-
opts = {
|
|
1877
|
-
filter: opts
|
|
1878
|
-
};
|
|
1879
|
-
}
|
|
1880
|
-
cb = cb || function() {};
|
|
1881
|
-
opts = opts || {};
|
|
1882
|
-
opts.clobber = 'clobber' in opts ? !!opts.clobber : true // default to true for now
|
|
1883
|
-
;
|
|
1884
|
-
opts.overwrite = 'overwrite' in opts ? !!opts.overwrite : opts.clobber // overwrite falls back to clobber
|
|
1885
|
-
;
|
|
1886
|
-
// Warn about using preserveTimestamps on 32-bit node
|
|
1887
|
-
if (opts.preserveTimestamps && process.arch === 'ia32') {
|
|
1888
|
-
console.warn("fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269");
|
|
1889
|
-
}
|
|
1890
|
-
stat$2.checkPaths(src, dest, 'copy', function(err, stats) {
|
|
1891
|
-
if (err) return cb(err);
|
|
1892
|
-
var srcStat = stats.srcStat, destStat = stats.destStat;
|
|
1893
|
-
stat$2.checkParentPaths(src, srcStat, dest, 'copy', function(err) {
|
|
1894
|
-
if (err) return cb(err);
|
|
1895
|
-
if (opts.filter) return handleFilter(checkParentDir, destStat, src, dest, opts, cb);
|
|
1896
|
-
return checkParentDir(destStat, src, dest, opts, cb);
|
|
1897
|
-
});
|
|
1898
|
-
});
|
|
1899
|
-
}
|
|
1900
|
-
function checkParentDir(destStat, src, dest, opts, cb) {
|
|
1901
|
-
var destParent = path$9.dirname(dest);
|
|
1902
|
-
pathExists$5(destParent, function(err, dirExists) {
|
|
1903
|
-
if (err) return cb(err);
|
|
1904
|
-
if (dirExists) return startCopy(destStat, src, dest, opts, cb);
|
|
1905
|
-
mkdirs$1(destParent, function(err) {
|
|
1906
|
-
if (err) return cb(err);
|
|
1907
|
-
return startCopy(destStat, src, dest, opts, cb);
|
|
1908
|
-
});
|
|
1909
|
-
});
|
|
1910
|
-
}
|
|
1911
|
-
function handleFilter(onInclude, destStat, src, dest, opts, cb) {
|
|
1912
|
-
Promise.resolve(opts.filter(src, dest)).then(function(include) {
|
|
1913
|
-
if (include) return onInclude(destStat, src, dest, opts, cb);
|
|
1914
|
-
return cb();
|
|
1915
|
-
}, function(error) {
|
|
1916
|
-
return cb(error);
|
|
1917
|
-
});
|
|
1918
|
-
}
|
|
1919
|
-
function startCopy(destStat, src, dest, opts, cb) {
|
|
1920
|
-
if (opts.filter) return handleFilter(getStats, destStat, src, dest, opts, cb);
|
|
1921
|
-
return getStats(destStat, src, dest, opts, cb);
|
|
1922
|
-
}
|
|
1923
|
-
function getStats(destStat, src, dest, opts, cb) {
|
|
1924
|
-
var stat = opts.dereference ? fs$b.stat : fs$b.lstat;
|
|
1925
|
-
stat(src, function(err, srcStat) {
|
|
1926
|
-
if (err) return cb(err);
|
|
1927
|
-
if (srcStat.isDirectory()) return onDir(srcStat, destStat, src, dest, opts, cb);
|
|
1928
|
-
else if (srcStat.isFile() || srcStat.isCharacterDevice() || srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts, cb);
|
|
1929
|
-
else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts, cb);
|
|
1930
|
-
});
|
|
1931
|
-
}
|
|
1932
|
-
function onFile(srcStat, destStat, src, dest, opts, cb) {
|
|
1933
|
-
if (!destStat) return copyFile(srcStat, src, dest, opts, cb);
|
|
1934
|
-
return mayCopyFile(srcStat, src, dest, opts, cb);
|
|
1935
|
-
}
|
|
1936
|
-
function mayCopyFile(srcStat, src, dest, opts, cb) {
|
|
1937
|
-
if (opts.overwrite) {
|
|
1938
|
-
fs$b.unlink(dest, function(err) {
|
|
1939
|
-
if (err) return cb(err);
|
|
1940
|
-
return copyFile(srcStat, src, dest, opts, cb);
|
|
1941
|
-
});
|
|
1942
|
-
} else if (opts.errorOnExist) {
|
|
1943
|
-
return cb(new Error("'".concat(dest, "' already exists")));
|
|
1944
|
-
} else return cb();
|
|
1945
|
-
}
|
|
1946
|
-
function copyFile(srcStat, src, dest, opts, cb) {
|
|
1947
|
-
fs$b.copyFile(src, dest, function(err) {
|
|
1948
|
-
if (err) return cb(err);
|
|
1949
|
-
if (opts.preserveTimestamps) return handleTimestampsAndMode(srcStat.mode, src, dest, cb);
|
|
1950
|
-
return setDestMode(dest, srcStat.mode, cb);
|
|
1951
|
-
});
|
|
1952
|
-
}
|
|
1953
|
-
function handleTimestampsAndMode(srcMode, src, dest, cb) {
|
|
1954
|
-
// Make sure the file is writable before setting the timestamp
|
|
1955
|
-
// otherwise open fails with EPERM when invoked with 'r+'
|
|
1956
|
-
// (through utimes call)
|
|
1957
|
-
if (fileIsNotWritable(srcMode)) {
|
|
1958
|
-
return makeFileWritable(dest, srcMode, function(err) {
|
|
1959
|
-
if (err) return cb(err);
|
|
1960
|
-
return setDestTimestampsAndMode(srcMode, src, dest, cb);
|
|
1961
|
-
});
|
|
1962
|
-
}
|
|
1963
|
-
return setDestTimestampsAndMode(srcMode, src, dest, cb);
|
|
1964
|
-
}
|
|
1965
|
-
function fileIsNotWritable(srcMode) {
|
|
1966
|
-
return (srcMode & 128) === 0;
|
|
1967
|
-
}
|
|
1968
|
-
function makeFileWritable(dest, srcMode, cb) {
|
|
1969
|
-
return setDestMode(dest, srcMode | 128, cb);
|
|
1970
|
-
}
|
|
1971
|
-
function setDestTimestampsAndMode(srcMode, src, dest, cb) {
|
|
1972
|
-
setDestTimestamps(src, dest, function(err) {
|
|
1973
|
-
if (err) return cb(err);
|
|
1974
|
-
return setDestMode(dest, srcMode, cb);
|
|
1975
|
-
});
|
|
1976
|
-
}
|
|
1977
|
-
function setDestMode(dest, srcMode, cb) {
|
|
1978
|
-
return fs$b.chmod(dest, srcMode, cb);
|
|
1979
|
-
}
|
|
1980
|
-
function setDestTimestamps(src, dest, cb) {
|
|
1981
|
-
// The initial srcStat.atime cannot be trusted
|
|
1982
|
-
// because it is modified by the read(2) system call
|
|
1983
|
-
// (See https://nodejs.org/api/fs.html#fs_stat_time_values)
|
|
1984
|
-
fs$b.stat(src, function(err, updatedSrcStat) {
|
|
1985
|
-
if (err) return cb(err);
|
|
1986
|
-
return utimesMillis(dest, updatedSrcStat.atime, updatedSrcStat.mtime, cb);
|
|
1987
|
-
});
|
|
1988
|
-
}
|
|
1989
|
-
function onDir(srcStat, destStat, src, dest, opts, cb) {
|
|
1990
|
-
if (!destStat) return mkDirAndCopy(srcStat.mode, src, dest, opts, cb);
|
|
1991
|
-
if (destStat && !destStat.isDirectory()) {
|
|
1992
|
-
return cb(new Error("Cannot overwrite non-directory '".concat(dest, "' with directory '").concat(src, "'.")));
|
|
1993
|
-
}
|
|
1994
|
-
return copyDir(src, dest, opts, cb);
|
|
1995
|
-
}
|
|
1996
|
-
function mkDirAndCopy(srcMode, src, dest, opts, cb) {
|
|
1997
|
-
fs$b.mkdir(dest, function(err) {
|
|
1998
|
-
if (err) return cb(err);
|
|
1999
|
-
copyDir(src, dest, opts, function(err) {
|
|
2000
|
-
if (err) return cb(err);
|
|
2001
|
-
return setDestMode(dest, srcMode, cb);
|
|
2002
|
-
});
|
|
2003
|
-
});
|
|
2004
|
-
}
|
|
2005
|
-
function copyDir(src, dest, opts, cb) {
|
|
2006
|
-
fs$b.readdir(src, function(err, items) {
|
|
2007
|
-
if (err) return cb(err);
|
|
2008
|
-
return copyDirItems(items, src, dest, opts, cb);
|
|
2009
|
-
});
|
|
2010
|
-
}
|
|
2011
|
-
function copyDirItems(items, src, dest, opts, cb) {
|
|
2012
|
-
var item = items.pop();
|
|
2013
|
-
if (!item) return cb();
|
|
2014
|
-
return copyDirItem(items, item, src, dest, opts, cb);
|
|
2015
|
-
}
|
|
2016
|
-
function copyDirItem(items, item, src, dest, opts, cb) {
|
|
2017
|
-
var srcItem = path$9.join(src, item);
|
|
2018
|
-
var destItem = path$9.join(dest, item);
|
|
2019
|
-
stat$2.checkPaths(srcItem, destItem, 'copy', function(err, stats) {
|
|
2020
|
-
if (err) return cb(err);
|
|
2021
|
-
var destStat = stats.destStat;
|
|
2022
|
-
startCopy(destStat, srcItem, destItem, opts, function(err) {
|
|
2023
|
-
if (err) return cb(err);
|
|
2024
|
-
return copyDirItems(items, src, dest, opts, cb);
|
|
2025
|
-
});
|
|
2026
|
-
});
|
|
2027
|
-
}
|
|
2028
|
-
function onLink(destStat, src, dest, opts, cb) {
|
|
2029
|
-
fs$b.readlink(src, function(err, resolvedSrc) {
|
|
2030
|
-
if (err) return cb(err);
|
|
2031
|
-
if (opts.dereference) {
|
|
2032
|
-
resolvedSrc = path$9.resolve(process.cwd(), resolvedSrc);
|
|
2033
|
-
}
|
|
2034
|
-
if (!destStat) {
|
|
2035
|
-
return fs$b.symlink(resolvedSrc, dest, cb);
|
|
2036
|
-
} else {
|
|
2037
|
-
fs$b.readlink(dest, function(err, resolvedDest) {
|
|
2038
|
-
if (err) {
|
|
2039
|
-
// dest exists and is a regular file or directory,
|
|
2040
|
-
// Windows may throw UNKNOWN error. If dest already exists,
|
|
2041
|
-
// fs throws error anyway, so no need to guard against it here.
|
|
2042
|
-
if (err.code === 'EINVAL' || err.code === 'UNKNOWN') return fs$b.symlink(resolvedSrc, dest, cb);
|
|
2043
|
-
return cb(err);
|
|
2044
|
-
}
|
|
2045
|
-
if (opts.dereference) {
|
|
2046
|
-
resolvedDest = path$9.resolve(process.cwd(), resolvedDest);
|
|
2047
|
-
}
|
|
2048
|
-
if (stat$2.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
2049
|
-
return cb(new Error("Cannot copy '".concat(resolvedSrc, "' to a subdirectory of itself, '").concat(resolvedDest, "'.")));
|
|
2050
|
-
}
|
|
2051
|
-
// do not copy if src is a subdir of dest since unlinking
|
|
2052
|
-
// dest in this case would result in removing src contents
|
|
2053
|
-
// and therefore a broken symlink would be created.
|
|
2054
|
-
if (destStat.isDirectory() && stat$2.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
|
2055
|
-
return cb(new Error("Cannot overwrite '".concat(resolvedDest, "' with '").concat(resolvedSrc, "'.")));
|
|
2056
|
-
}
|
|
2057
|
-
return copyLink(resolvedSrc, dest, cb);
|
|
2058
|
-
});
|
|
2059
|
-
}
|
|
2060
|
-
});
|
|
2061
|
-
}
|
|
2062
|
-
function copyLink(resolvedSrc, dest, cb) {
|
|
2063
|
-
fs$b.unlink(dest, function(err) {
|
|
2064
|
-
if (err) return cb(err);
|
|
2065
|
-
return fs$b.symlink(resolvedSrc, dest, cb);
|
|
2066
|
-
});
|
|
2067
|
-
}
|
|
2068
|
-
var copy_1 = copy$2;
|
|
2069
|
-
|
|
2070
|
-
var u$8 = universalify$1.fromCallback;
|
|
2071
|
-
var copy$1 = {
|
|
2072
|
-
copy: u$8(copy_1)
|
|
2073
|
-
};
|
|
2074
|
-
|
|
2075
|
-
function _type_of(obj) {
|
|
2076
|
-
"@swc/helpers - typeof";
|
|
2077
|
-
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
2078
|
-
}
|
|
2079
|
-
var fs$a = gracefulFs;
|
|
2080
|
-
var path$8 = require$$1__default["default"];
|
|
2081
|
-
var assert = require$$5__default["default"];
|
|
2082
|
-
var isWindows = process.platform === 'win32';
|
|
2083
|
-
function defaults(options) {
|
|
2084
|
-
var methods = [
|
|
2085
|
-
'unlink',
|
|
2086
|
-
'chmod',
|
|
2087
|
-
'stat',
|
|
2088
|
-
'lstat',
|
|
2089
|
-
'rmdir',
|
|
2090
|
-
'readdir'
|
|
2091
|
-
];
|
|
2092
|
-
methods.forEach(function(m) {
|
|
2093
|
-
options[m] = options[m] || fs$a[m];
|
|
2094
|
-
m = m + 'Sync';
|
|
2095
|
-
options[m] = options[m] || fs$a[m];
|
|
2096
|
-
});
|
|
2097
|
-
options.maxBusyTries = options.maxBusyTries || 3;
|
|
2098
|
-
}
|
|
2099
|
-
function rimraf$1(p, options, cb) {
|
|
2100
|
-
var busyTries = 0;
|
|
2101
|
-
if (typeof options === 'function') {
|
|
2102
|
-
cb = options;
|
|
2103
|
-
options = {};
|
|
2104
|
-
}
|
|
2105
|
-
assert(p, 'rimraf: missing path');
|
|
2106
|
-
assert.strictEqual(typeof p === "undefined" ? "undefined" : _type_of(p), 'string', 'rimraf: path should be a string');
|
|
2107
|
-
assert.strictEqual(typeof cb === "undefined" ? "undefined" : _type_of(cb), 'function', 'rimraf: callback function required');
|
|
2108
|
-
assert(options, 'rimraf: invalid options argument provided');
|
|
2109
|
-
assert.strictEqual(typeof options === "undefined" ? "undefined" : _type_of(options), 'object', 'rimraf: options should be object');
|
|
2110
|
-
defaults(options);
|
|
2111
|
-
rimraf_(p, options, function CB(er) {
|
|
2112
|
-
if (er) {
|
|
2113
|
-
if ((er.code === 'EBUSY' || er.code === 'ENOTEMPTY' || er.code === 'EPERM') && busyTries < options.maxBusyTries) {
|
|
2114
|
-
busyTries++;
|
|
2115
|
-
var time = busyTries * 100;
|
|
2116
|
-
// try again, with the same exact callback as this one.
|
|
2117
|
-
return setTimeout(function() {
|
|
2118
|
-
return rimraf_(p, options, CB);
|
|
2119
|
-
}, time);
|
|
2120
|
-
}
|
|
2121
|
-
// already gone
|
|
2122
|
-
if (er.code === 'ENOENT') er = null;
|
|
2123
|
-
}
|
|
2124
|
-
cb(er);
|
|
2125
|
-
});
|
|
2126
|
-
}
|
|
2127
|
-
// Two possible strategies.
|
|
2128
|
-
// 1. Assume it's a file. unlink it, then do the dir stuff on EPERM or EISDIR
|
|
2129
|
-
// 2. Assume it's a directory. readdir, then do the file stuff on ENOTDIR
|
|
2130
|
-
//
|
|
2131
|
-
// Both result in an extra syscall when you guess wrong. However, there
|
|
2132
|
-
// are likely far more normal files in the world than directories. This
|
|
2133
|
-
// is based on the assumption that a the average number of files per
|
|
2134
|
-
// directory is >= 1.
|
|
2135
|
-
//
|
|
2136
|
-
// If anyone ever complains about this, then I guess the strategy could
|
|
2137
|
-
// be made configurable somehow. But until then, YAGNI.
|
|
2138
|
-
function rimraf_(p, options, cb) {
|
|
2139
|
-
assert(p);
|
|
2140
|
-
assert(options);
|
|
2141
|
-
assert(typeof cb === 'function');
|
|
2142
|
-
// sunos lets the root user unlink directories, which is... weird.
|
|
2143
|
-
// so we have to lstat here and make sure it's not a dir.
|
|
2144
|
-
options.lstat(p, function(er, st) {
|
|
2145
|
-
if (er && er.code === 'ENOENT') {
|
|
2146
|
-
return cb(null);
|
|
2147
|
-
}
|
|
2148
|
-
// Windows can EPERM on stat. Life is suffering.
|
|
2149
|
-
if (er && er.code === 'EPERM' && isWindows) {
|
|
2150
|
-
return fixWinEPERM(p, options, er, cb);
|
|
2151
|
-
}
|
|
2152
|
-
if (st && st.isDirectory()) {
|
|
2153
|
-
return rmdir(p, options, er, cb);
|
|
2154
|
-
}
|
|
2155
|
-
options.unlink(p, function(er) {
|
|
2156
|
-
if (er) {
|
|
2157
|
-
if (er.code === 'ENOENT') {
|
|
2158
|
-
return cb(null);
|
|
2159
|
-
}
|
|
2160
|
-
if (er.code === 'EPERM') {
|
|
2161
|
-
return isWindows ? fixWinEPERM(p, options, er, cb) : rmdir(p, options, er, cb);
|
|
2162
|
-
}
|
|
2163
|
-
if (er.code === 'EISDIR') {
|
|
2164
|
-
return rmdir(p, options, er, cb);
|
|
2165
|
-
}
|
|
2166
|
-
}
|
|
2167
|
-
return cb(er);
|
|
2168
|
-
});
|
|
2169
|
-
});
|
|
2170
|
-
}
|
|
2171
|
-
function fixWinEPERM(p, options, er, cb) {
|
|
2172
|
-
assert(p);
|
|
2173
|
-
assert(options);
|
|
2174
|
-
assert(typeof cb === 'function');
|
|
2175
|
-
options.chmod(p, 438, function(er2) {
|
|
2176
|
-
if (er2) {
|
|
2177
|
-
cb(er2.code === 'ENOENT' ? null : er);
|
|
2178
|
-
} else {
|
|
2179
|
-
options.stat(p, function(er3, stats) {
|
|
2180
|
-
if (er3) {
|
|
2181
|
-
cb(er3.code === 'ENOENT' ? null : er);
|
|
2182
|
-
} else if (stats.isDirectory()) {
|
|
2183
|
-
rmdir(p, options, er, cb);
|
|
2184
|
-
} else {
|
|
2185
|
-
options.unlink(p, cb);
|
|
2186
|
-
}
|
|
2187
|
-
});
|
|
2188
|
-
}
|
|
2189
|
-
});
|
|
2190
|
-
}
|
|
2191
|
-
function fixWinEPERMSync(p, options, er) {
|
|
2192
|
-
var stats;
|
|
2193
|
-
assert(p);
|
|
2194
|
-
assert(options);
|
|
2195
|
-
try {
|
|
2196
|
-
options.chmodSync(p, 438);
|
|
2197
|
-
} catch (er2) {
|
|
2198
|
-
if (er2.code === 'ENOENT') {
|
|
2199
|
-
return;
|
|
2200
|
-
} else {
|
|
2201
|
-
throw er;
|
|
2202
|
-
}
|
|
2203
|
-
}
|
|
2204
|
-
try {
|
|
2205
|
-
stats = options.statSync(p);
|
|
2206
|
-
} catch (er3) {
|
|
2207
|
-
if (er3.code === 'ENOENT') {
|
|
2208
|
-
return;
|
|
2209
|
-
} else {
|
|
2210
|
-
throw er;
|
|
2211
|
-
}
|
|
2212
|
-
}
|
|
2213
|
-
if (stats.isDirectory()) {
|
|
2214
|
-
rmdirSync(p, options, er);
|
|
2215
|
-
} else {
|
|
2216
|
-
options.unlinkSync(p);
|
|
2217
|
-
}
|
|
2218
|
-
}
|
|
2219
|
-
function rmdir(p, options, originalEr, cb) {
|
|
2220
|
-
assert(p);
|
|
2221
|
-
assert(options);
|
|
2222
|
-
assert(typeof cb === 'function');
|
|
2223
|
-
// try to rmdir first, and only readdir on ENOTEMPTY or EEXIST (SunOS)
|
|
2224
|
-
// if we guessed wrong, and it's not a directory, then
|
|
2225
|
-
// raise the original error.
|
|
2226
|
-
options.rmdir(p, function(er) {
|
|
2227
|
-
if (er && (er.code === 'ENOTEMPTY' || er.code === 'EEXIST' || er.code === 'EPERM')) {
|
|
2228
|
-
rmkids(p, options, cb);
|
|
2229
|
-
} else if (er && er.code === 'ENOTDIR') {
|
|
2230
|
-
cb(originalEr);
|
|
2231
|
-
} else {
|
|
2232
|
-
cb(er);
|
|
2233
|
-
}
|
|
2234
|
-
});
|
|
2235
|
-
}
|
|
2236
|
-
function rmkids(p, options, cb) {
|
|
2237
|
-
assert(p);
|
|
2238
|
-
assert(options);
|
|
2239
|
-
assert(typeof cb === 'function');
|
|
2240
|
-
options.readdir(p, function(er, files) {
|
|
2241
|
-
if (er) return cb(er);
|
|
2242
|
-
var n = files.length;
|
|
2243
|
-
var errState;
|
|
2244
|
-
if (n === 0) return options.rmdir(p, cb);
|
|
2245
|
-
files.forEach(function(f) {
|
|
2246
|
-
rimraf$1(path$8.join(p, f), options, function(er) {
|
|
2247
|
-
if (errState) {
|
|
2248
|
-
return;
|
|
2249
|
-
}
|
|
2250
|
-
if (er) return cb(errState = er);
|
|
2251
|
-
if (--n === 0) {
|
|
2252
|
-
options.rmdir(p, cb);
|
|
2253
|
-
}
|
|
2254
|
-
});
|
|
2255
|
-
});
|
|
2256
|
-
});
|
|
2257
|
-
}
|
|
2258
|
-
// this looks simpler, and is strictly *faster*, but will
|
|
2259
|
-
// tie up the JavaScript thread and fail on excessively
|
|
2260
|
-
// deep directory trees.
|
|
2261
|
-
function rimrafSync(p, options) {
|
|
2262
|
-
var st;
|
|
2263
|
-
options = options || {};
|
|
2264
|
-
defaults(options);
|
|
2265
|
-
assert(p, 'rimraf: missing path');
|
|
2266
|
-
assert.strictEqual(typeof p === "undefined" ? "undefined" : _type_of(p), 'string', 'rimraf: path should be a string');
|
|
2267
|
-
assert(options, 'rimraf: missing options');
|
|
2268
|
-
assert.strictEqual(typeof options === "undefined" ? "undefined" : _type_of(options), 'object', 'rimraf: options should be object');
|
|
2269
|
-
try {
|
|
2270
|
-
st = options.lstatSync(p);
|
|
2271
|
-
} catch (er) {
|
|
2272
|
-
if (er.code === 'ENOENT') {
|
|
2273
|
-
return;
|
|
2274
|
-
}
|
|
2275
|
-
// Windows can EPERM on stat. Life is suffering.
|
|
2276
|
-
if (er.code === 'EPERM' && isWindows) {
|
|
2277
|
-
fixWinEPERMSync(p, options, er);
|
|
2278
|
-
}
|
|
2279
|
-
}
|
|
2280
|
-
try {
|
|
2281
|
-
// sunos lets the root user unlink directories, which is... weird.
|
|
2282
|
-
if (st && st.isDirectory()) {
|
|
2283
|
-
rmdirSync(p, options, null);
|
|
2284
|
-
} else {
|
|
2285
|
-
options.unlinkSync(p);
|
|
2286
|
-
}
|
|
2287
|
-
} catch (er) {
|
|
2288
|
-
if (er.code === 'ENOENT') {
|
|
2289
|
-
return;
|
|
2290
|
-
} else if (er.code === 'EPERM') {
|
|
2291
|
-
return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er);
|
|
2292
|
-
} else if (er.code !== 'EISDIR') {
|
|
2293
|
-
throw er;
|
|
2294
|
-
}
|
|
2295
|
-
rmdirSync(p, options, er);
|
|
2296
|
-
}
|
|
2297
|
-
}
|
|
2298
|
-
function rmdirSync(p, options, originalEr) {
|
|
2299
|
-
assert(p);
|
|
2300
|
-
assert(options);
|
|
2301
|
-
try {
|
|
2302
|
-
options.rmdirSync(p);
|
|
2303
|
-
} catch (er) {
|
|
2304
|
-
if (er.code === 'ENOTDIR') {
|
|
2305
|
-
throw originalEr;
|
|
2306
|
-
} else if (er.code === 'ENOTEMPTY' || er.code === 'EEXIST' || er.code === 'EPERM') {
|
|
2307
|
-
rmkidsSync(p, options);
|
|
2308
|
-
} else if (er.code !== 'ENOENT') {
|
|
2309
|
-
throw er;
|
|
2310
|
-
}
|
|
2311
|
-
}
|
|
2312
|
-
}
|
|
2313
|
-
function rmkidsSync(p, options) {
|
|
2314
|
-
assert(p);
|
|
2315
|
-
assert(options);
|
|
2316
|
-
options.readdirSync(p).forEach(function(f) {
|
|
2317
|
-
return rimrafSync(path$8.join(p, f), options);
|
|
2318
|
-
});
|
|
2319
|
-
if (isWindows) {
|
|
2320
|
-
// We only end up here once we got ENOTEMPTY at least once, and
|
|
2321
|
-
// at this point, we are guaranteed to have removed all the kids.
|
|
2322
|
-
// So, we know that it won't be ENOENT or ENOTDIR or anything else.
|
|
2323
|
-
// try really hard to delete stuff on windows, because it has a
|
|
2324
|
-
// PROFOUNDLY annoying habit of not closing handles promptly when
|
|
2325
|
-
// files are deleted, resulting in spurious ENOTEMPTY errors.
|
|
2326
|
-
var startTime = Date.now();
|
|
2327
|
-
do {
|
|
2328
|
-
try {
|
|
2329
|
-
var ret = options.rmdirSync(p, options);
|
|
2330
|
-
return ret;
|
|
2331
|
-
} catch (e) {}
|
|
2332
|
-
}while (Date.now() - startTime < 500); // give up after 500ms
|
|
2333
|
-
} else {
|
|
2334
|
-
var ret1 = options.rmdirSync(p, options);
|
|
2335
|
-
return ret1;
|
|
2336
|
-
}
|
|
2337
|
-
}
|
|
2338
|
-
var rimraf_1 = rimraf$1;
|
|
2339
|
-
rimraf$1.sync = rimrafSync;
|
|
2340
|
-
|
|
2341
|
-
var u$7 = universalify$1.fromCallback;
|
|
2342
|
-
var rimraf = rimraf_1;
|
|
2343
|
-
var remove$2 = {
|
|
2344
|
-
remove: u$7(rimraf),
|
|
2345
|
-
removeSync: rimraf.sync
|
|
2346
|
-
};
|
|
2347
|
-
|
|
2348
|
-
var u$6 = universalify$1.fromCallback;
|
|
2349
|
-
var fs$9 = gracefulFs;
|
|
2350
|
-
var path$7 = require$$1__default["default"];
|
|
2351
|
-
var mkdir$3 = mkdirs$2;
|
|
2352
|
-
var remove$1 = remove$2;
|
|
2353
|
-
var emptyDir = u$6(function emptyDir(dir, callback) {
|
|
2354
|
-
callback = callback || function() {};
|
|
2355
|
-
fs$9.readdir(dir, function(err, items) {
|
|
2356
|
-
if (err) return mkdir$3.mkdirs(dir, callback);
|
|
2357
|
-
items = items.map(function(item) {
|
|
2358
|
-
return path$7.join(dir, item);
|
|
2359
|
-
});
|
|
2360
|
-
deleteItem();
|
|
2361
|
-
function deleteItem() {
|
|
2362
|
-
var item = items.pop();
|
|
2363
|
-
if (!item) return callback();
|
|
2364
|
-
remove$1.remove(item, function(err) {
|
|
2365
|
-
if (err) return callback(err);
|
|
2366
|
-
deleteItem();
|
|
2367
|
-
});
|
|
2368
|
-
}
|
|
2369
|
-
});
|
|
2370
|
-
});
|
|
2371
|
-
function emptyDirSync(dir) {
|
|
2372
|
-
var items;
|
|
2373
|
-
try {
|
|
2374
|
-
items = fs$9.readdirSync(dir);
|
|
2375
|
-
} catch (e) {
|
|
2376
|
-
return mkdir$3.mkdirsSync(dir);
|
|
2377
|
-
}
|
|
2378
|
-
items.forEach(function(item) {
|
|
2379
|
-
item = path$7.join(dir, item);
|
|
2380
|
-
remove$1.removeSync(item);
|
|
2381
|
-
});
|
|
2382
|
-
}
|
|
2383
|
-
var empty = {
|
|
2384
|
-
emptyDirSync: emptyDirSync,
|
|
2385
|
-
emptydirSync: emptyDirSync,
|
|
2386
|
-
emptyDir: emptyDir,
|
|
2387
|
-
emptydir: emptyDir
|
|
2388
|
-
};
|
|
2389
|
-
|
|
2390
|
-
var u$5 = universalify$1.fromCallback;
|
|
2391
|
-
var path$6 = require$$1__default["default"];
|
|
2392
|
-
var fs$8 = gracefulFs;
|
|
2393
|
-
var mkdir$2 = mkdirs$2;
|
|
2394
|
-
function createFile(file, callback) {
|
|
2395
|
-
function makeFile() {
|
|
2396
|
-
fs$8.writeFile(file, '', function(err) {
|
|
2397
|
-
if (err) return callback(err);
|
|
2398
|
-
callback();
|
|
2399
|
-
});
|
|
2400
|
-
}
|
|
2401
|
-
fs$8.stat(file, function(err, stats) {
|
|
2402
|
-
if (!err && stats.isFile()) return callback();
|
|
2403
|
-
var dir = path$6.dirname(file);
|
|
2404
|
-
fs$8.stat(dir, function(err, stats) {
|
|
2405
|
-
if (err) {
|
|
2406
|
-
// if the directory doesn't exist, make it
|
|
2407
|
-
if (err.code === 'ENOENT') {
|
|
2408
|
-
return mkdir$2.mkdirs(dir, function(err) {
|
|
2409
|
-
if (err) return callback(err);
|
|
2410
|
-
makeFile();
|
|
2411
|
-
});
|
|
2412
|
-
}
|
|
2413
|
-
return callback(err);
|
|
2414
|
-
}
|
|
2415
|
-
if (stats.isDirectory()) makeFile();
|
|
2416
|
-
else {
|
|
2417
|
-
// parent is not a directory
|
|
2418
|
-
// This is just to cause an internal ENOTDIR error to be thrown
|
|
2419
|
-
fs$8.readdir(dir, function(err) {
|
|
2420
|
-
if (err) return callback(err);
|
|
2421
|
-
});
|
|
2422
|
-
}
|
|
2423
|
-
});
|
|
2424
|
-
});
|
|
2425
|
-
}
|
|
2426
|
-
function createFileSync(file) {
|
|
2427
|
-
var stats;
|
|
2428
|
-
try {
|
|
2429
|
-
stats = fs$8.statSync(file);
|
|
2430
|
-
} catch (e) {}
|
|
2431
|
-
if (stats && stats.isFile()) return;
|
|
2432
|
-
var dir = path$6.dirname(file);
|
|
2433
|
-
try {
|
|
2434
|
-
if (!fs$8.statSync(dir).isDirectory()) {
|
|
2435
|
-
// parent is not a directory
|
|
2436
|
-
// This is just to cause an internal ENOTDIR error to be thrown
|
|
2437
|
-
fs$8.readdirSync(dir);
|
|
2438
|
-
}
|
|
2439
|
-
} catch (err) {
|
|
2440
|
-
// If the stat call above failed because the directory doesn't exist, create it
|
|
2441
|
-
if (err && err.code === 'ENOENT') mkdir$2.mkdirsSync(dir);
|
|
2442
|
-
else throw err;
|
|
2443
|
-
}
|
|
2444
|
-
fs$8.writeFileSync(file, '');
|
|
2445
|
-
}
|
|
2446
|
-
var file$1 = {
|
|
2447
|
-
createFile: u$5(createFile),
|
|
2448
|
-
createFileSync: createFileSync
|
|
2449
|
-
};
|
|
2450
|
-
|
|
2451
|
-
var u$4 = universalify$1.fromCallback;
|
|
2452
|
-
var path$5 = require$$1__default["default"];
|
|
2453
|
-
var fs$7 = gracefulFs;
|
|
2454
|
-
var mkdir$1 = mkdirs$2;
|
|
2455
|
-
var pathExists$4 = pathExists_1.pathExists;
|
|
2456
|
-
function createLink(srcpath, dstpath, callback) {
|
|
2457
|
-
function makeLink(srcpath, dstpath) {
|
|
2458
|
-
fs$7.link(srcpath, dstpath, function(err) {
|
|
2459
|
-
if (err) return callback(err);
|
|
2460
|
-
callback(null);
|
|
2461
|
-
});
|
|
2462
|
-
}
|
|
2463
|
-
pathExists$4(dstpath, function(err, destinationExists) {
|
|
2464
|
-
if (err) return callback(err);
|
|
2465
|
-
if (destinationExists) return callback(null);
|
|
2466
|
-
fs$7.lstat(srcpath, function(err) {
|
|
2467
|
-
if (err) {
|
|
2468
|
-
err.message = err.message.replace('lstat', 'ensureLink');
|
|
2469
|
-
return callback(err);
|
|
2470
|
-
}
|
|
2471
|
-
var dir = path$5.dirname(dstpath);
|
|
2472
|
-
pathExists$4(dir, function(err, dirExists) {
|
|
2473
|
-
if (err) return callback(err);
|
|
2474
|
-
if (dirExists) return makeLink(srcpath, dstpath);
|
|
2475
|
-
mkdir$1.mkdirs(dir, function(err) {
|
|
2476
|
-
if (err) return callback(err);
|
|
2477
|
-
makeLink(srcpath, dstpath);
|
|
2478
|
-
});
|
|
2479
|
-
});
|
|
2480
|
-
});
|
|
2481
|
-
});
|
|
2482
|
-
}
|
|
2483
|
-
function createLinkSync(srcpath, dstpath) {
|
|
2484
|
-
var destinationExists = fs$7.existsSync(dstpath);
|
|
2485
|
-
if (destinationExists) return undefined;
|
|
2486
|
-
try {
|
|
2487
|
-
fs$7.lstatSync(srcpath);
|
|
2488
|
-
} catch (err) {
|
|
2489
|
-
err.message = err.message.replace('lstat', 'ensureLink');
|
|
2490
|
-
throw err;
|
|
2491
|
-
}
|
|
2492
|
-
var dir = path$5.dirname(dstpath);
|
|
2493
|
-
var dirExists = fs$7.existsSync(dir);
|
|
2494
|
-
if (dirExists) return fs$7.linkSync(srcpath, dstpath);
|
|
2495
|
-
mkdir$1.mkdirsSync(dir);
|
|
2496
|
-
return fs$7.linkSync(srcpath, dstpath);
|
|
2497
|
-
}
|
|
2498
|
-
var link$1 = {
|
|
2499
|
-
createLink: u$4(createLink),
|
|
2500
|
-
createLinkSync: createLinkSync
|
|
2501
|
-
};
|
|
2502
|
-
|
|
2503
|
-
var path$4 = require$$1__default["default"];
|
|
2504
|
-
var fs$6 = gracefulFs;
|
|
2505
|
-
var pathExists$3 = pathExists_1.pathExists;
|
|
2506
|
-
/**
|
|
2507
|
-
* Function that returns two types of paths, one relative to symlink, and one
|
|
2508
|
-
* relative to the current working directory. Checks if path is absolute or
|
|
2509
|
-
* relative. If the path is relative, this function checks if the path is
|
|
2510
|
-
* relative to symlink or relative to current working directory. This is an
|
|
2511
|
-
* initiative to find a smarter `srcpath` to supply when building symlinks.
|
|
2512
|
-
* This allows you to determine which path to use out of one of three possible
|
|
2513
|
-
* types of source paths. The first is an absolute path. This is detected by
|
|
2514
|
-
* `path.isAbsolute()`. When an absolute path is provided, it is checked to
|
|
2515
|
-
* see if it exists. If it does it's used, if not an error is returned
|
|
2516
|
-
* (callback)/ thrown (sync). The other two options for `srcpath` are a
|
|
2517
|
-
* relative url. By default Node's `fs.symlink` works by creating a symlink
|
|
2518
|
-
* using `dstpath` and expects the `srcpath` to be relative to the newly
|
|
2519
|
-
* created symlink. If you provide a `srcpath` that does not exist on the file
|
|
2520
|
-
* system it results in a broken symlink. To minimize this, the function
|
|
2521
|
-
* checks to see if the 'relative to symlink' source file exists, and if it
|
|
2522
|
-
* does it will use it. If it does not, it checks if there's a file that
|
|
2523
|
-
* exists that is relative to the current working directory, if does its used.
|
|
2524
|
-
* This preserves the expectations of the original fs.symlink spec and adds
|
|
2525
|
-
* the ability to pass in `relative to current working direcotry` paths.
|
|
2526
|
-
*/ function symlinkPaths$1(srcpath, dstpath, callback) {
|
|
2527
|
-
if (path$4.isAbsolute(srcpath)) {
|
|
2528
|
-
return fs$6.lstat(srcpath, function(err) {
|
|
2529
|
-
if (err) {
|
|
2530
|
-
err.message = err.message.replace('lstat', 'ensureSymlink');
|
|
2531
|
-
return callback(err);
|
|
2532
|
-
}
|
|
2533
|
-
return callback(null, {
|
|
2534
|
-
toCwd: srcpath,
|
|
2535
|
-
toDst: srcpath
|
|
2536
|
-
});
|
|
2537
|
-
});
|
|
2538
|
-
} else {
|
|
2539
|
-
var dstdir = path$4.dirname(dstpath);
|
|
2540
|
-
var relativeToDst = path$4.join(dstdir, srcpath);
|
|
2541
|
-
return pathExists$3(relativeToDst, function(err, exists) {
|
|
2542
|
-
if (err) return callback(err);
|
|
2543
|
-
if (exists) {
|
|
2544
|
-
return callback(null, {
|
|
2545
|
-
toCwd: relativeToDst,
|
|
2546
|
-
toDst: srcpath
|
|
2547
|
-
});
|
|
2548
|
-
} else {
|
|
2549
|
-
return fs$6.lstat(srcpath, function(err) {
|
|
2550
|
-
if (err) {
|
|
2551
|
-
err.message = err.message.replace('lstat', 'ensureSymlink');
|
|
2552
|
-
return callback(err);
|
|
2553
|
-
}
|
|
2554
|
-
return callback(null, {
|
|
2555
|
-
toCwd: srcpath,
|
|
2556
|
-
toDst: path$4.relative(dstdir, srcpath)
|
|
2557
|
-
});
|
|
2558
|
-
});
|
|
2559
|
-
}
|
|
2560
|
-
});
|
|
2561
|
-
}
|
|
2562
|
-
}
|
|
2563
|
-
function symlinkPathsSync$1(srcpath, dstpath) {
|
|
2564
|
-
var exists;
|
|
2565
|
-
if (path$4.isAbsolute(srcpath)) {
|
|
2566
|
-
exists = fs$6.existsSync(srcpath);
|
|
2567
|
-
if (!exists) throw new Error('absolute srcpath does not exist');
|
|
2568
|
-
return {
|
|
2569
|
-
toCwd: srcpath,
|
|
2570
|
-
toDst: srcpath
|
|
2571
|
-
};
|
|
2572
|
-
} else {
|
|
2573
|
-
var dstdir = path$4.dirname(dstpath);
|
|
2574
|
-
var relativeToDst = path$4.join(dstdir, srcpath);
|
|
2575
|
-
exists = fs$6.existsSync(relativeToDst);
|
|
2576
|
-
if (exists) {
|
|
2577
|
-
return {
|
|
2578
|
-
toCwd: relativeToDst,
|
|
2579
|
-
toDst: srcpath
|
|
2580
|
-
};
|
|
2581
|
-
} else {
|
|
2582
|
-
exists = fs$6.existsSync(srcpath);
|
|
2583
|
-
if (!exists) throw new Error('relative srcpath does not exist');
|
|
2584
|
-
return {
|
|
2585
|
-
toCwd: srcpath,
|
|
2586
|
-
toDst: path$4.relative(dstdir, srcpath)
|
|
2587
|
-
};
|
|
2588
|
-
}
|
|
2589
|
-
}
|
|
2590
|
-
}
|
|
2591
|
-
var symlinkPaths_1 = {
|
|
2592
|
-
symlinkPaths: symlinkPaths$1,
|
|
2593
|
-
symlinkPathsSync: symlinkPathsSync$1
|
|
2594
|
-
};
|
|
2595
|
-
|
|
2596
|
-
var fs$5 = gracefulFs;
|
|
2597
|
-
function symlinkType$1(srcpath, type, callback) {
|
|
2598
|
-
callback = typeof type === 'function' ? type : callback;
|
|
2599
|
-
type = typeof type === 'function' ? false : type;
|
|
2600
|
-
if (type) return callback(null, type);
|
|
2601
|
-
fs$5.lstat(srcpath, function(err, stats) {
|
|
2602
|
-
if (err) return callback(null, 'file');
|
|
2603
|
-
type = stats && stats.isDirectory() ? 'dir' : 'file';
|
|
2604
|
-
callback(null, type);
|
|
2605
|
-
});
|
|
2606
|
-
}
|
|
2607
|
-
function symlinkTypeSync$1(srcpath, type) {
|
|
2608
|
-
var stats;
|
|
2609
|
-
if (type) return type;
|
|
2610
|
-
try {
|
|
2611
|
-
stats = fs$5.lstatSync(srcpath);
|
|
2612
|
-
} catch (e) {
|
|
2613
|
-
return 'file';
|
|
2614
|
-
}
|
|
2615
|
-
return stats && stats.isDirectory() ? 'dir' : 'file';
|
|
2616
|
-
}
|
|
2617
|
-
var symlinkType_1 = {
|
|
2618
|
-
symlinkType: symlinkType$1,
|
|
2619
|
-
symlinkTypeSync: symlinkTypeSync$1
|
|
2620
|
-
};
|
|
2621
|
-
|
|
2622
|
-
var u$3 = universalify$1.fromCallback;
|
|
2623
|
-
var path$3 = require$$1__default["default"];
|
|
2624
|
-
var fs$4 = gracefulFs;
|
|
2625
|
-
var _mkdirs = mkdirs$2;
|
|
2626
|
-
var mkdirs = _mkdirs.mkdirs;
|
|
2627
|
-
var mkdirsSync = _mkdirs.mkdirsSync;
|
|
2628
|
-
var _symlinkPaths = symlinkPaths_1;
|
|
2629
|
-
var symlinkPaths = _symlinkPaths.symlinkPaths;
|
|
2630
|
-
var symlinkPathsSync = _symlinkPaths.symlinkPathsSync;
|
|
2631
|
-
var _symlinkType = symlinkType_1;
|
|
2632
|
-
var symlinkType = _symlinkType.symlinkType;
|
|
2633
|
-
var symlinkTypeSync = _symlinkType.symlinkTypeSync;
|
|
2634
|
-
var pathExists$2 = pathExists_1.pathExists;
|
|
2635
|
-
function createSymlink(srcpath, dstpath, type, callback) {
|
|
2636
|
-
callback = typeof type === 'function' ? type : callback;
|
|
2637
|
-
type = typeof type === 'function' ? false : type;
|
|
2638
|
-
pathExists$2(dstpath, function(err, destinationExists) {
|
|
2639
|
-
if (err) return callback(err);
|
|
2640
|
-
if (destinationExists) return callback(null);
|
|
2641
|
-
symlinkPaths(srcpath, dstpath, function(err, relative) {
|
|
2642
|
-
if (err) return callback(err);
|
|
2643
|
-
srcpath = relative.toDst;
|
|
2644
|
-
symlinkType(relative.toCwd, type, function(err, type) {
|
|
2645
|
-
if (err) return callback(err);
|
|
2646
|
-
var dir = path$3.dirname(dstpath);
|
|
2647
|
-
pathExists$2(dir, function(err, dirExists) {
|
|
2648
|
-
if (err) return callback(err);
|
|
2649
|
-
if (dirExists) return fs$4.symlink(srcpath, dstpath, type, callback);
|
|
2650
|
-
mkdirs(dir, function(err) {
|
|
2651
|
-
if (err) return callback(err);
|
|
2652
|
-
fs$4.symlink(srcpath, dstpath, type, callback);
|
|
2653
|
-
});
|
|
2654
|
-
});
|
|
2655
|
-
});
|
|
2656
|
-
});
|
|
2657
|
-
});
|
|
2658
|
-
}
|
|
2659
|
-
function createSymlinkSync(srcpath, dstpath, type) {
|
|
2660
|
-
var destinationExists = fs$4.existsSync(dstpath);
|
|
2661
|
-
if (destinationExists) return undefined;
|
|
2662
|
-
var relative = symlinkPathsSync(srcpath, dstpath);
|
|
2663
|
-
srcpath = relative.toDst;
|
|
2664
|
-
type = symlinkTypeSync(relative.toCwd, type);
|
|
2665
|
-
var dir = path$3.dirname(dstpath);
|
|
2666
|
-
var exists = fs$4.existsSync(dir);
|
|
2667
|
-
if (exists) return fs$4.symlinkSync(srcpath, dstpath, type);
|
|
2668
|
-
mkdirsSync(dir);
|
|
2669
|
-
return fs$4.symlinkSync(srcpath, dstpath, type);
|
|
2670
|
-
}
|
|
2671
|
-
var symlink$1 = {
|
|
2672
|
-
createSymlink: u$3(createSymlink),
|
|
2673
|
-
createSymlinkSync: createSymlinkSync
|
|
2674
|
-
};
|
|
2675
|
-
|
|
2676
|
-
var file = file$1;
|
|
2677
|
-
var link = link$1;
|
|
2678
|
-
var symlink = symlink$1;
|
|
2679
|
-
var ensure = {
|
|
2680
|
-
// file
|
|
2681
|
-
createFile: file.createFile,
|
|
2682
|
-
createFileSync: file.createFileSync,
|
|
2683
|
-
ensureFile: file.createFile,
|
|
2684
|
-
ensureFileSync: file.createFileSync,
|
|
2685
|
-
// link
|
|
2686
|
-
createLink: link.createLink,
|
|
2687
|
-
createLinkSync: link.createLinkSync,
|
|
2688
|
-
ensureLink: link.createLink,
|
|
2689
|
-
ensureLinkSync: link.createLinkSync,
|
|
2690
|
-
// symlink
|
|
2691
|
-
createSymlink: symlink.createSymlink,
|
|
2692
|
-
createSymlinkSync: symlink.createSymlinkSync,
|
|
2693
|
-
ensureSymlink: symlink.createSymlink,
|
|
2694
|
-
ensureSymlinkSync: symlink.createSymlinkSync
|
|
2695
|
-
};
|
|
2696
|
-
|
|
2697
|
-
function stringify$3(obj) {
|
|
2698
|
-
var _ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, _ref_EOL = _ref.EOL, EOL = _ref_EOL === void 0 ? '\n' : _ref_EOL, _ref_finalEOL = _ref.finalEOL, finalEOL = _ref_finalEOL === void 0 ? true : _ref_finalEOL, _ref_replacer = _ref.replacer, replacer = _ref_replacer === void 0 ? null : _ref_replacer, spaces = _ref.spaces;
|
|
2699
|
-
var EOF = finalEOL ? EOL : '';
|
|
2700
|
-
var str = JSON.stringify(obj, replacer, spaces);
|
|
2701
|
-
return str.replace(/\n/g, EOL) + EOF;
|
|
2702
|
-
}
|
|
2703
|
-
function stripBom$1(content) {
|
|
2704
|
-
// we do this because JSON.parse would convert it to a utf8 string if encoding wasn't specified
|
|
2705
|
-
if (Buffer.isBuffer(content)) content = content.toString('utf8');
|
|
2706
|
-
return content.replace(/^\uFEFF/, '');
|
|
2707
|
-
}
|
|
2708
|
-
var utils = {
|
|
2709
|
-
stringify: stringify$3,
|
|
2710
|
-
stripBom: stripBom$1
|
|
2711
|
-
};
|
|
2712
|
-
|
|
2713
|
-
function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2714
|
-
try {
|
|
2715
|
-
var info = gen[key](arg);
|
|
2716
|
-
var value = info.value;
|
|
2717
|
-
} catch (error) {
|
|
2718
|
-
reject(error);
|
|
2719
|
-
return;
|
|
2720
|
-
}
|
|
2721
|
-
if (info.done) {
|
|
2722
|
-
resolve(value);
|
|
2723
|
-
} else {
|
|
2724
|
-
Promise.resolve(value).then(_next, _throw);
|
|
2725
|
-
}
|
|
2726
|
-
}
|
|
2727
|
-
function _async_to_generator$1(fn) {
|
|
2728
|
-
return function() {
|
|
2729
|
-
var self = this, args = arguments;
|
|
2730
|
-
return new Promise(function(resolve, reject) {
|
|
2731
|
-
var gen = fn.apply(self, args);
|
|
2732
|
-
function _next(value) {
|
|
2733
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "next", value);
|
|
2734
|
-
}
|
|
2735
|
-
function _throw(err) {
|
|
2736
|
-
asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, "throw", err);
|
|
2737
|
-
}
|
|
2738
|
-
_next(undefined);
|
|
2739
|
-
});
|
|
2740
|
-
};
|
|
2741
|
-
}
|
|
2742
|
-
function _ts_generator$1(thisArg, body) {
|
|
2743
|
-
var f, y, t, g, _ = {
|
|
2744
|
-
label: 0,
|
|
2745
|
-
sent: function() {
|
|
2746
|
-
if (t[0] & 1) throw t[1];
|
|
2747
|
-
return t[1];
|
|
2748
|
-
},
|
|
2749
|
-
trys: [],
|
|
2750
|
-
ops: []
|
|
2751
|
-
};
|
|
2752
|
-
return g = {
|
|
2753
|
-
next: verb(0),
|
|
2754
|
-
"throw": verb(1),
|
|
2755
|
-
"return": verb(2)
|
|
2756
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
2757
|
-
return this;
|
|
2758
|
-
}), g;
|
|
2759
|
-
function verb(n) {
|
|
2760
|
-
return function(v) {
|
|
2761
|
-
return step([
|
|
2762
|
-
n,
|
|
2763
|
-
v
|
|
2764
|
-
]);
|
|
2765
|
-
};
|
|
2766
|
-
}
|
|
2767
|
-
function step(op) {
|
|
2768
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
2769
|
-
while(_)try {
|
|
2770
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
2771
|
-
if (y = 0, t) op = [
|
|
2772
|
-
op[0] & 2,
|
|
2773
|
-
t.value
|
|
2774
|
-
];
|
|
2775
|
-
switch(op[0]){
|
|
2776
|
-
case 0:
|
|
2777
|
-
case 1:
|
|
2778
|
-
t = op;
|
|
2779
|
-
break;
|
|
2780
|
-
case 4:
|
|
2781
|
-
_.label++;
|
|
2782
|
-
return {
|
|
2783
|
-
value: op[1],
|
|
2784
|
-
done: false
|
|
2785
|
-
};
|
|
2786
|
-
case 5:
|
|
2787
|
-
_.label++;
|
|
2788
|
-
y = op[1];
|
|
2789
|
-
op = [
|
|
2790
|
-
0
|
|
2791
|
-
];
|
|
2792
|
-
continue;
|
|
2793
|
-
case 7:
|
|
2794
|
-
op = _.ops.pop();
|
|
2795
|
-
_.trys.pop();
|
|
2796
|
-
continue;
|
|
2797
|
-
default:
|
|
2798
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
2799
|
-
_ = 0;
|
|
2800
|
-
continue;
|
|
2801
|
-
}
|
|
2802
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
2803
|
-
_.label = op[1];
|
|
2804
|
-
break;
|
|
2805
|
-
}
|
|
2806
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
2807
|
-
_.label = t[1];
|
|
2808
|
-
t = op;
|
|
2809
|
-
break;
|
|
2810
|
-
}
|
|
2811
|
-
if (t && _.label < t[2]) {
|
|
2812
|
-
_.label = t[2];
|
|
2813
|
-
_.ops.push(op);
|
|
2814
|
-
break;
|
|
2815
|
-
}
|
|
2816
|
-
if (t[2]) _.ops.pop();
|
|
2817
|
-
_.trys.pop();
|
|
2818
|
-
continue;
|
|
2819
|
-
}
|
|
2820
|
-
op = body.call(thisArg, _);
|
|
2821
|
-
} catch (e) {
|
|
2822
|
-
op = [
|
|
2823
|
-
6,
|
|
2824
|
-
e
|
|
2825
|
-
];
|
|
2826
|
-
y = 0;
|
|
2827
|
-
} finally{
|
|
2828
|
-
f = t = 0;
|
|
2829
|
-
}
|
|
2830
|
-
if (op[0] & 5) throw op[1];
|
|
2831
|
-
return {
|
|
2832
|
-
value: op[0] ? op[1] : void 0,
|
|
2833
|
-
done: true
|
|
2834
|
-
};
|
|
2835
|
-
}
|
|
2836
|
-
}
|
|
2837
|
-
var _fs;
|
|
2838
|
-
try {
|
|
2839
|
-
_fs = gracefulFs;
|
|
2840
|
-
} catch (_) {
|
|
2841
|
-
_fs = require$$0__default$2["default"];
|
|
2842
|
-
}
|
|
2843
|
-
var universalify = universalify$1;
|
|
2844
|
-
var _require$1 = utils, stringify$2 = _require$1.stringify, stripBom = _require$1.stripBom;
|
|
2845
|
-
function _readFile(file) {
|
|
2846
|
-
return __readFile.apply(this, arguments);
|
|
2847
|
-
}
|
|
2848
|
-
function __readFile() {
|
|
2849
|
-
__readFile = _async_to_generator$1(function(file) {
|
|
2850
|
-
var options, fs, shouldThrow, data, obj;
|
|
2851
|
-
var _arguments = arguments;
|
|
2852
|
-
return _ts_generator$1(this, function(_state) {
|
|
2853
|
-
switch(_state.label){
|
|
2854
|
-
case 0:
|
|
2855
|
-
options = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2856
|
-
if (typeof options === 'string') {
|
|
2857
|
-
options = {
|
|
2858
|
-
encoding: options
|
|
2859
|
-
};
|
|
2860
|
-
}
|
|
2861
|
-
fs = options.fs || _fs;
|
|
2862
|
-
shouldThrow = 'throws' in options ? options.throws : true;
|
|
2863
|
-
return [
|
|
2864
|
-
4,
|
|
2865
|
-
universalify.fromCallback(fs.readFile)(file, options)
|
|
2866
|
-
];
|
|
2867
|
-
case 1:
|
|
2868
|
-
data = _state.sent();
|
|
2869
|
-
data = stripBom(data);
|
|
2870
|
-
try {
|
|
2871
|
-
obj = JSON.parse(data, options ? options.reviver : null);
|
|
2872
|
-
} catch (err) {
|
|
2873
|
-
if (shouldThrow) {
|
|
2874
|
-
err.message = "".concat(file, ": ").concat(err.message);
|
|
2875
|
-
throw err;
|
|
2876
|
-
} else {
|
|
2877
|
-
return [
|
|
2878
|
-
2,
|
|
2879
|
-
null
|
|
2880
|
-
];
|
|
2881
|
-
}
|
|
2882
|
-
}
|
|
2883
|
-
return [
|
|
2884
|
-
2,
|
|
2885
|
-
obj
|
|
2886
|
-
];
|
|
2887
|
-
}
|
|
2888
|
-
});
|
|
2889
|
-
});
|
|
2890
|
-
return __readFile.apply(this, arguments);
|
|
2891
|
-
}
|
|
2892
|
-
var readFile = universalify.fromPromise(_readFile);
|
|
2893
|
-
function readFileSync(file) {
|
|
2894
|
-
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
2895
|
-
if (typeof options === 'string') {
|
|
2896
|
-
options = {
|
|
2897
|
-
encoding: options
|
|
2898
|
-
};
|
|
2899
|
-
}
|
|
2900
|
-
var fs = options.fs || _fs;
|
|
2901
|
-
var shouldThrow = 'throws' in options ? options.throws : true;
|
|
2902
|
-
try {
|
|
2903
|
-
var content = fs.readFileSync(file, options);
|
|
2904
|
-
content = stripBom(content);
|
|
2905
|
-
return JSON.parse(content, options.reviver);
|
|
2906
|
-
} catch (err) {
|
|
2907
|
-
if (shouldThrow) {
|
|
2908
|
-
err.message = "".concat(file, ": ").concat(err.message);
|
|
2909
|
-
throw err;
|
|
2910
|
-
} else {
|
|
2911
|
-
return null;
|
|
2912
|
-
}
|
|
2913
|
-
}
|
|
2914
|
-
}
|
|
2915
|
-
function _writeFile(file, obj) {
|
|
2916
|
-
return __writeFile.apply(this, arguments);
|
|
2917
|
-
}
|
|
2918
|
-
function __writeFile() {
|
|
2919
|
-
__writeFile = _async_to_generator$1(function(file, obj) {
|
|
2920
|
-
var options, fs, str;
|
|
2921
|
-
var _arguments = arguments;
|
|
2922
|
-
return _ts_generator$1(this, function(_state) {
|
|
2923
|
-
switch(_state.label){
|
|
2924
|
-
case 0:
|
|
2925
|
-
options = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2926
|
-
fs = options.fs || _fs;
|
|
2927
|
-
str = stringify$2(obj, options);
|
|
2928
|
-
return [
|
|
2929
|
-
4,
|
|
2930
|
-
universalify.fromCallback(fs.writeFile)(file, str, options)
|
|
2931
|
-
];
|
|
2932
|
-
case 1:
|
|
2933
|
-
_state.sent();
|
|
2934
|
-
return [
|
|
2935
|
-
2
|
|
2936
|
-
];
|
|
2937
|
-
}
|
|
2938
|
-
});
|
|
2939
|
-
});
|
|
2940
|
-
return __writeFile.apply(this, arguments);
|
|
2941
|
-
}
|
|
2942
|
-
var writeFile = universalify.fromPromise(_writeFile);
|
|
2943
|
-
function writeFileSync(file, obj) {
|
|
2944
|
-
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
2945
|
-
var fs = options.fs || _fs;
|
|
2946
|
-
var str = stringify$2(obj, options);
|
|
2947
|
-
// not sure if fs.writeFileSync returns anything, but just in case
|
|
2948
|
-
return fs.writeFileSync(file, str, options);
|
|
2949
|
-
}
|
|
2950
|
-
var jsonfile$1 = {
|
|
2951
|
-
readFile: readFile,
|
|
2952
|
-
readFileSync: readFileSync,
|
|
2953
|
-
writeFile: writeFile,
|
|
2954
|
-
writeFileSync: writeFileSync
|
|
2955
|
-
};
|
|
2956
|
-
var jsonfile_1 = jsonfile$1;
|
|
2957
|
-
|
|
2958
|
-
var jsonFile$1 = jsonfile_1;
|
|
2959
|
-
var jsonfile = {
|
|
2960
|
-
// jsonfile exports
|
|
2961
|
-
readJson: jsonFile$1.readFile,
|
|
2962
|
-
readJsonSync: jsonFile$1.readFileSync,
|
|
2963
|
-
writeJson: jsonFile$1.writeFile,
|
|
2964
|
-
writeJsonSync: jsonFile$1.writeFileSync
|
|
2965
|
-
};
|
|
2966
|
-
|
|
2967
|
-
function _array_like_to_array(arr, len) {
|
|
2968
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
2969
|
-
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
2970
|
-
return arr2;
|
|
2971
|
-
}
|
|
2972
|
-
function _array_without_holes(arr) {
|
|
2973
|
-
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
2974
|
-
}
|
|
2975
|
-
function _iterable_to_array(iter) {
|
|
2976
|
-
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
2977
|
-
}
|
|
2978
|
-
function _non_iterable_spread() {
|
|
2979
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2980
|
-
}
|
|
2981
|
-
function _to_consumable_array(arr) {
|
|
2982
|
-
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
2983
|
-
}
|
|
2984
|
-
function _unsupported_iterable_to_array(o, minLen) {
|
|
2985
|
-
if (!o) return;
|
|
2986
|
-
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
2987
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
2988
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
2989
|
-
if (n === "Map" || n === "Set") return Array.from(n);
|
|
2990
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
2991
|
-
}
|
|
2992
|
-
var u$2 = universalify$1.fromCallback;
|
|
2993
|
-
var fs$3 = gracefulFs;
|
|
2994
|
-
var path$2 = require$$1__default["default"];
|
|
2995
|
-
var mkdir = mkdirs$2;
|
|
2996
|
-
var pathExists$1 = pathExists_1.pathExists;
|
|
2997
|
-
function outputFile$1(file, data, encoding, callback) {
|
|
2998
|
-
if (typeof encoding === 'function') {
|
|
2999
|
-
callback = encoding;
|
|
3000
|
-
encoding = 'utf8';
|
|
3001
|
-
}
|
|
3002
|
-
var dir = path$2.dirname(file);
|
|
3003
|
-
pathExists$1(dir, function(err, itDoes) {
|
|
3004
|
-
if (err) return callback(err);
|
|
3005
|
-
if (itDoes) return fs$3.writeFile(file, data, encoding, callback);
|
|
3006
|
-
mkdir.mkdirs(dir, function(err) {
|
|
3007
|
-
if (err) return callback(err);
|
|
3008
|
-
fs$3.writeFile(file, data, encoding, callback);
|
|
3009
|
-
});
|
|
3010
|
-
});
|
|
3011
|
-
}
|
|
3012
|
-
function outputFileSync$1(file) {
|
|
3013
|
-
for(var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
|
|
3014
|
-
args[_key - 1] = arguments[_key];
|
|
3015
|
-
}
|
|
3016
|
-
var _fs;
|
|
3017
|
-
var dir = path$2.dirname(file);
|
|
3018
|
-
if (fs$3.existsSync(dir)) {
|
|
3019
|
-
var _fs1;
|
|
3020
|
-
return (_fs1 = fs$3).writeFileSync.apply(_fs1, [
|
|
3021
|
-
file
|
|
3022
|
-
].concat(_to_consumable_array(args)));
|
|
3023
|
-
}
|
|
3024
|
-
mkdir.mkdirsSync(dir);
|
|
3025
|
-
(_fs = fs$3).writeFileSync.apply(_fs, [
|
|
3026
|
-
file
|
|
3027
|
-
].concat(_to_consumable_array(args)));
|
|
3028
|
-
}
|
|
3029
|
-
var output = {
|
|
3030
|
-
outputFile: u$2(outputFile$1),
|
|
3031
|
-
outputFileSync: outputFileSync$1
|
|
3032
|
-
};
|
|
3033
|
-
|
|
3034
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
3035
|
-
try {
|
|
3036
|
-
var info = gen[key](arg);
|
|
3037
|
-
var value = info.value;
|
|
3038
|
-
} catch (error) {
|
|
3039
|
-
reject(error);
|
|
3040
|
-
return;
|
|
3041
|
-
}
|
|
3042
|
-
if (info.done) {
|
|
3043
|
-
resolve(value);
|
|
3044
|
-
} else {
|
|
3045
|
-
Promise.resolve(value).then(_next, _throw);
|
|
3046
|
-
}
|
|
3047
|
-
}
|
|
3048
|
-
function _async_to_generator(fn) {
|
|
3049
|
-
return function() {
|
|
3050
|
-
var self = this, args = arguments;
|
|
3051
|
-
return new Promise(function(resolve, reject) {
|
|
3052
|
-
var gen = fn.apply(self, args);
|
|
3053
|
-
function _next(value) {
|
|
3054
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
3055
|
-
}
|
|
3056
|
-
function _throw(err) {
|
|
3057
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
3058
|
-
}
|
|
3059
|
-
_next(undefined);
|
|
3060
|
-
});
|
|
3061
|
-
};
|
|
3062
|
-
}
|
|
3063
|
-
function _ts_generator(thisArg, body) {
|
|
3064
|
-
var f, y, t, g, _ = {
|
|
3065
|
-
label: 0,
|
|
3066
|
-
sent: function() {
|
|
3067
|
-
if (t[0] & 1) throw t[1];
|
|
3068
|
-
return t[1];
|
|
3069
|
-
},
|
|
3070
|
-
trys: [],
|
|
3071
|
-
ops: []
|
|
3072
|
-
};
|
|
3073
|
-
return g = {
|
|
3074
|
-
next: verb(0),
|
|
3075
|
-
"throw": verb(1),
|
|
3076
|
-
"return": verb(2)
|
|
3077
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
3078
|
-
return this;
|
|
3079
|
-
}), g;
|
|
3080
|
-
function verb(n) {
|
|
3081
|
-
return function(v) {
|
|
3082
|
-
return step([
|
|
3083
|
-
n,
|
|
3084
|
-
v
|
|
3085
|
-
]);
|
|
3086
|
-
};
|
|
3087
|
-
}
|
|
3088
|
-
function step(op) {
|
|
3089
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
3090
|
-
while(_)try {
|
|
3091
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
3092
|
-
if (y = 0, t) op = [
|
|
3093
|
-
op[0] & 2,
|
|
3094
|
-
t.value
|
|
3095
|
-
];
|
|
3096
|
-
switch(op[0]){
|
|
3097
|
-
case 0:
|
|
3098
|
-
case 1:
|
|
3099
|
-
t = op;
|
|
3100
|
-
break;
|
|
3101
|
-
case 4:
|
|
3102
|
-
_.label++;
|
|
3103
|
-
return {
|
|
3104
|
-
value: op[1],
|
|
3105
|
-
done: false
|
|
3106
|
-
};
|
|
3107
|
-
case 5:
|
|
3108
|
-
_.label++;
|
|
3109
|
-
y = op[1];
|
|
3110
|
-
op = [
|
|
3111
|
-
0
|
|
3112
|
-
];
|
|
3113
|
-
continue;
|
|
3114
|
-
case 7:
|
|
3115
|
-
op = _.ops.pop();
|
|
3116
|
-
_.trys.pop();
|
|
3117
|
-
continue;
|
|
3118
|
-
default:
|
|
3119
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
3120
|
-
_ = 0;
|
|
3121
|
-
continue;
|
|
3122
|
-
}
|
|
3123
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
3124
|
-
_.label = op[1];
|
|
3125
|
-
break;
|
|
3126
|
-
}
|
|
3127
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
3128
|
-
_.label = t[1];
|
|
3129
|
-
t = op;
|
|
3130
|
-
break;
|
|
3131
|
-
}
|
|
3132
|
-
if (t && _.label < t[2]) {
|
|
3133
|
-
_.label = t[2];
|
|
3134
|
-
_.ops.push(op);
|
|
3135
|
-
break;
|
|
3136
|
-
}
|
|
3137
|
-
if (t[2]) _.ops.pop();
|
|
3138
|
-
_.trys.pop();
|
|
3139
|
-
continue;
|
|
3140
|
-
}
|
|
3141
|
-
op = body.call(thisArg, _);
|
|
3142
|
-
} catch (e) {
|
|
3143
|
-
op = [
|
|
3144
|
-
6,
|
|
3145
|
-
e
|
|
3146
|
-
];
|
|
3147
|
-
y = 0;
|
|
3148
|
-
} finally{
|
|
3149
|
-
f = t = 0;
|
|
3150
|
-
}
|
|
3151
|
-
if (op[0] & 5) throw op[1];
|
|
3152
|
-
return {
|
|
3153
|
-
value: op[0] ? op[1] : void 0,
|
|
3154
|
-
done: true
|
|
3155
|
-
};
|
|
3156
|
-
}
|
|
3157
|
-
}
|
|
3158
|
-
var stringify$1 = utils.stringify;
|
|
3159
|
-
var outputFile = output.outputFile;
|
|
3160
|
-
function outputJson(file, data) {
|
|
3161
|
-
return _outputJson.apply(this, arguments);
|
|
3162
|
-
}
|
|
3163
|
-
function _outputJson() {
|
|
3164
|
-
_outputJson = _async_to_generator(function(file, data) {
|
|
3165
|
-
var options, str;
|
|
3166
|
-
var _arguments = arguments;
|
|
3167
|
-
return _ts_generator(this, function(_state) {
|
|
3168
|
-
switch(_state.label){
|
|
3169
|
-
case 0:
|
|
3170
|
-
options = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
3171
|
-
str = stringify$1(data, options);
|
|
3172
|
-
return [
|
|
3173
|
-
4,
|
|
3174
|
-
outputFile(file, str, options)
|
|
3175
|
-
];
|
|
3176
|
-
case 1:
|
|
3177
|
-
_state.sent();
|
|
3178
|
-
return [
|
|
3179
|
-
2
|
|
3180
|
-
];
|
|
3181
|
-
}
|
|
3182
|
-
});
|
|
3183
|
-
});
|
|
3184
|
-
return _outputJson.apply(this, arguments);
|
|
3185
|
-
}
|
|
3186
|
-
var outputJson_1 = outputJson;
|
|
3187
|
-
|
|
3188
|
-
var stringify = utils.stringify;
|
|
3189
|
-
var outputFileSync = output.outputFileSync;
|
|
3190
|
-
function outputJsonSync(file, data, options) {
|
|
3191
|
-
var str = stringify(data, options);
|
|
3192
|
-
outputFileSync(file, str, options);
|
|
3193
|
-
}
|
|
3194
|
-
var outputJsonSync_1 = outputJsonSync;
|
|
3195
|
-
|
|
3196
|
-
var u$1 = universalify$1.fromPromise;
|
|
3197
|
-
var jsonFile = jsonfile;
|
|
3198
|
-
jsonFile.outputJson = u$1(outputJson_1);
|
|
3199
|
-
jsonFile.outputJsonSync = outputJsonSync_1;
|
|
3200
|
-
// aliases
|
|
3201
|
-
jsonFile.outputJSON = jsonFile.outputJson;
|
|
3202
|
-
jsonFile.outputJSONSync = jsonFile.outputJsonSync;
|
|
3203
|
-
jsonFile.writeJSON = jsonFile.writeJson;
|
|
3204
|
-
jsonFile.writeJSONSync = jsonFile.writeJsonSync;
|
|
3205
|
-
jsonFile.readJSON = jsonFile.readJson;
|
|
3206
|
-
jsonFile.readJSONSync = jsonFile.readJsonSync;
|
|
3207
|
-
var json = jsonFile;
|
|
3208
|
-
|
|
3209
|
-
var fs$2 = gracefulFs;
|
|
3210
|
-
var path$1 = require$$1__default["default"];
|
|
3211
|
-
var copySync = copySync$1.copySync;
|
|
3212
|
-
var removeSync = remove$2.removeSync;
|
|
3213
|
-
var mkdirpSync = mkdirs$2.mkdirpSync;
|
|
3214
|
-
var stat$1 = stat_1;
|
|
3215
|
-
function moveSync$1(src, dest, opts) {
|
|
3216
|
-
opts = opts || {};
|
|
3217
|
-
var overwrite = opts.overwrite || opts.clobber || false;
|
|
3218
|
-
var srcStat = stat$1.checkPathsSync(src, dest, 'move').srcStat;
|
|
3219
|
-
stat$1.checkParentPathsSync(src, srcStat, dest, 'move');
|
|
3220
|
-
mkdirpSync(path$1.dirname(dest));
|
|
3221
|
-
return doRename$1(src, dest, overwrite);
|
|
3222
|
-
}
|
|
3223
|
-
function doRename$1(src, dest, overwrite) {
|
|
3224
|
-
if (overwrite) {
|
|
3225
|
-
removeSync(dest);
|
|
3226
|
-
return rename$1(src, dest, overwrite);
|
|
3227
|
-
}
|
|
3228
|
-
if (fs$2.existsSync(dest)) throw new Error('dest already exists.');
|
|
3229
|
-
return rename$1(src, dest, overwrite);
|
|
3230
|
-
}
|
|
3231
|
-
function rename$1(src, dest, overwrite) {
|
|
3232
|
-
try {
|
|
3233
|
-
fs$2.renameSync(src, dest);
|
|
3234
|
-
} catch (err) {
|
|
3235
|
-
if (err.code !== 'EXDEV') throw err;
|
|
3236
|
-
return moveAcrossDevice$1(src, dest, overwrite);
|
|
3237
|
-
}
|
|
3238
|
-
}
|
|
3239
|
-
function moveAcrossDevice$1(src, dest, overwrite) {
|
|
3240
|
-
var opts = {
|
|
3241
|
-
overwrite: overwrite,
|
|
3242
|
-
errorOnExist: true
|
|
3243
|
-
};
|
|
3244
|
-
copySync(src, dest, opts);
|
|
3245
|
-
return removeSync(src);
|
|
3246
|
-
}
|
|
3247
|
-
var moveSync_1 = moveSync$1;
|
|
3248
|
-
|
|
3249
|
-
var moveSync = {
|
|
3250
|
-
moveSync: moveSync_1
|
|
3251
|
-
};
|
|
3252
|
-
|
|
3253
|
-
var fs$1 = gracefulFs;
|
|
3254
|
-
var path = require$$1__default["default"];
|
|
3255
|
-
var copy = copy$1.copy;
|
|
3256
|
-
var remove = remove$2.remove;
|
|
3257
|
-
var mkdirp = mkdirs$2.mkdirp;
|
|
3258
|
-
var pathExists = pathExists_1.pathExists;
|
|
3259
|
-
var stat = stat_1;
|
|
3260
|
-
function move$1(src, dest, opts, cb) {
|
|
3261
|
-
if (typeof opts === 'function') {
|
|
3262
|
-
cb = opts;
|
|
3263
|
-
opts = {};
|
|
3264
|
-
}
|
|
3265
|
-
var overwrite = opts.overwrite || opts.clobber || false;
|
|
3266
|
-
stat.checkPaths(src, dest, 'move', function(err, stats) {
|
|
3267
|
-
if (err) return cb(err);
|
|
3268
|
-
var srcStat = stats.srcStat;
|
|
3269
|
-
stat.checkParentPaths(src, srcStat, dest, 'move', function(err) {
|
|
3270
|
-
if (err) return cb(err);
|
|
3271
|
-
mkdirp(path.dirname(dest), function(err) {
|
|
3272
|
-
if (err) return cb(err);
|
|
3273
|
-
return doRename(src, dest, overwrite, cb);
|
|
3274
|
-
});
|
|
3275
|
-
});
|
|
3276
|
-
});
|
|
3277
|
-
}
|
|
3278
|
-
function doRename(src, dest, overwrite, cb) {
|
|
3279
|
-
if (overwrite) {
|
|
3280
|
-
return remove(dest, function(err) {
|
|
3281
|
-
if (err) return cb(err);
|
|
3282
|
-
return rename(src, dest, overwrite, cb);
|
|
3283
|
-
});
|
|
3284
|
-
}
|
|
3285
|
-
pathExists(dest, function(err, destExists) {
|
|
3286
|
-
if (err) return cb(err);
|
|
3287
|
-
if (destExists) return cb(new Error('dest already exists.'));
|
|
3288
|
-
return rename(src, dest, overwrite, cb);
|
|
3289
|
-
});
|
|
3290
|
-
}
|
|
3291
|
-
function rename(src, dest, overwrite, cb) {
|
|
3292
|
-
fs$1.rename(src, dest, function(err) {
|
|
3293
|
-
if (!err) return cb();
|
|
3294
|
-
if (err.code !== 'EXDEV') return cb(err);
|
|
3295
|
-
return moveAcrossDevice(src, dest, overwrite, cb);
|
|
3296
|
-
});
|
|
3297
|
-
}
|
|
3298
|
-
function moveAcrossDevice(src, dest, overwrite, cb) {
|
|
3299
|
-
var opts = {
|
|
3300
|
-
overwrite: overwrite,
|
|
3301
|
-
errorOnExist: true
|
|
3302
|
-
};
|
|
3303
|
-
copy(src, dest, opts, function(err) {
|
|
3304
|
-
if (err) return cb(err);
|
|
3305
|
-
return remove(src, cb);
|
|
3306
|
-
});
|
|
3307
|
-
}
|
|
3308
|
-
var move_1 = move$1;
|
|
3309
|
-
|
|
3310
|
-
var u = universalify$1.fromCallback;
|
|
3311
|
-
var move = {
|
|
3312
|
-
move: u(move_1)
|
|
3313
|
-
};
|
|
3314
|
-
|
|
3315
|
-
(function (module) {
|
|
3316
|
-
function _define_property(obj, key, value) {
|
|
3317
|
-
if (key in obj) {
|
|
3318
|
-
Object.defineProperty(obj, key, {
|
|
3319
|
-
value: value,
|
|
3320
|
-
enumerable: true,
|
|
3321
|
-
configurable: true,
|
|
3322
|
-
writable: true
|
|
3323
|
-
});
|
|
3324
|
-
} else {
|
|
3325
|
-
obj[key] = value;
|
|
3326
|
-
}
|
|
3327
|
-
return obj;
|
|
3328
|
-
}
|
|
3329
|
-
function _object_spread(target) {
|
|
3330
|
-
for(var i = 1; i < arguments.length; i++){
|
|
3331
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
3332
|
-
var ownKeys = Object.keys(source);
|
|
3333
|
-
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
3334
|
-
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
3335
|
-
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
3336
|
-
}));
|
|
3337
|
-
}
|
|
3338
|
-
ownKeys.forEach(function(key) {
|
|
3339
|
-
_define_property(target, key, source[key]);
|
|
3340
|
-
});
|
|
3341
|
-
}
|
|
3342
|
-
return target;
|
|
3343
|
-
}
|
|
3344
|
-
module.exports = _object_spread({}, fs$i, copySync$1, copy$1, empty, ensure, json, mkdirs$2, moveSync, move, output, pathExists_1, remove$2);
|
|
3345
|
-
// Export fs.promises as a getter property so that we don't trigger
|
|
3346
|
-
// ExperimentalWarning before fs.promises is actually accessed.
|
|
3347
|
-
var fs = require$$0__default$2["default"];
|
|
3348
|
-
if (Object.getOwnPropertyDescriptor(fs, 'promises')) {
|
|
3349
|
-
Object.defineProperty(module.exports, 'promises', {
|
|
3350
|
-
get: function get() {
|
|
3351
|
-
return fs.promises;
|
|
3352
|
-
}
|
|
3353
|
-
});
|
|
3354
|
-
}
|
|
3355
|
-
}(lib));
|
|
3356
|
-
|
|
3357
|
-
var fs = lib.exports;
|
|
3358
|
-
|
|
3359
|
-
var TEMP_DIR = '.mf';
|
|
3360
|
-
|
|
3361
|
-
var fileExistsWithCaseSync = function(filepath) {
|
|
3362
|
-
var dir = require$$1__default["default"].dirname(filepath);
|
|
3363
|
-
if (filepath === '/' || filepath === '.') {
|
|
3364
|
-
return true;
|
|
3365
|
-
}
|
|
3366
|
-
var filenames = fs.readdirSync(dir);
|
|
3367
|
-
if (filenames.indexOf(require$$1__default["default"].basename(filepath)) === -1) {
|
|
3368
|
-
return false;
|
|
3369
|
-
}
|
|
3370
|
-
return fileExistsWithCaseSync(dir);
|
|
3371
|
-
};
|
|
3372
|
-
var fixPrefetchPath = function(exposePath) {
|
|
3373
|
-
var pathExt = [
|
|
3374
|
-
'.js',
|
|
3375
|
-
'.ts'
|
|
3376
|
-
];
|
|
3377
|
-
var extReg = /\.(ts|js|tsx|jsx)$/;
|
|
3378
|
-
if (extReg.test(exposePath)) {
|
|
3379
|
-
return pathExt.map(function(ext) {
|
|
3380
|
-
return exposePath.replace(extReg, ".prefetch".concat(ext));
|
|
3381
|
-
});
|
|
3382
|
-
} else {
|
|
3383
|
-
return pathExt.map(function(ext) {
|
|
3384
|
-
return exposePath + ".prefetch".concat(ext);
|
|
3385
|
-
});
|
|
3386
|
-
}
|
|
3387
|
-
};
|
|
3388
|
-
|
|
3389
|
-
function _class_call_check(instance, Constructor) {
|
|
3390
|
-
if (!(instance instanceof Constructor)) {
|
|
3391
|
-
throw new TypeError("Cannot call a class as a function");
|
|
3392
|
-
}
|
|
3393
|
-
}
|
|
3394
|
-
function _defineProperties(target, props) {
|
|
3395
|
-
for(var i = 0; i < props.length; i++){
|
|
3396
|
-
var descriptor = props[i];
|
|
3397
|
-
descriptor.enumerable = descriptor.enumerable || false;
|
|
3398
|
-
descriptor.configurable = true;
|
|
3399
|
-
if ("value" in descriptor) descriptor.writable = true;
|
|
3400
|
-
Object.defineProperty(target, descriptor.key, descriptor);
|
|
3401
|
-
}
|
|
3402
|
-
}
|
|
3403
|
-
function _create_class(Constructor, protoProps, staticProps) {
|
|
3404
|
-
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
3405
|
-
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
3406
|
-
return Constructor;
|
|
3407
|
-
}
|
|
3408
|
-
function _define_property(obj, key, value) {
|
|
3409
|
-
if (key in obj) {
|
|
3410
|
-
Object.defineProperty(obj, key, {
|
|
3411
|
-
value: value,
|
|
3412
|
-
enumerable: true,
|
|
3413
|
-
configurable: true,
|
|
3414
|
-
writable: true
|
|
3415
|
-
});
|
|
3416
|
-
} else {
|
|
3417
|
-
obj[key] = value;
|
|
3418
|
-
}
|
|
3419
|
-
return obj;
|
|
3420
|
-
}
|
|
3421
|
-
var _require = require(normalizeWebpackPath.normalizeWebpackPath('webpack')), RuntimeGlobals = _require.RuntimeGlobals, Template = _require.Template;
|
|
3422
|
-
function getFederationGlobalScope(runtimeGlobals) {
|
|
3423
|
-
return "".concat(runtimeGlobals.require || '__webpack_require__', ".federation");
|
|
3424
|
-
}
|
|
3425
|
-
var PrefetchPlugin = /*#__PURE__*/ function() {
|
|
3426
|
-
function PrefetchPlugin(options) {
|
|
3427
|
-
_class_call_check(this, PrefetchPlugin);
|
|
3428
|
-
_define_property(this, "options", void 0);
|
|
3429
|
-
_define_property(this, "_reWriteExports", void 0);
|
|
3430
|
-
this.options = options;
|
|
3431
|
-
this._reWriteExports = '';
|
|
3432
|
-
}
|
|
3433
|
-
_create_class(PrefetchPlugin, [
|
|
3434
|
-
{
|
|
3435
|
-
// eslint-disable-next-line max-lines-per-function
|
|
3436
|
-
key: "apply",
|
|
3437
|
-
value: function apply(compiler) {
|
|
3438
|
-
var _this = this;
|
|
3439
|
-
var _this_options_runtimePlugins, _this_options_runtimePlugins1;
|
|
3440
|
-
var _this_options = this.options, name = _this_options.name, exposes = _this_options.exposes;
|
|
3441
|
-
if (!exposes) {
|
|
3442
|
-
return;
|
|
3443
|
-
}
|
|
3444
|
-
if (!compiler.options.context) {
|
|
3445
|
-
throw new Error('compiler.options.context is not defined');
|
|
3446
|
-
}
|
|
3447
|
-
var runtimePlugins = this.options.runtimePlugins;
|
|
3448
|
-
if (!Array.isArray(runtimePlugins)) {
|
|
3449
|
-
this.options.runtimePlugins = [];
|
|
3450
|
-
}
|
|
3451
|
-
var runtimePath = require$$1__default["default"].resolve(__dirname, './plugin.esm.js');
|
|
3452
|
-
var sharedPath = require$$1__default["default"].resolve(__dirname, './shared.esm.js');
|
|
3453
|
-
if (!((_this_options_runtimePlugins = this.options.runtimePlugins) === null || _this_options_runtimePlugins === void 0 ? void 0 : _this_options_runtimePlugins.includes(runtimePath))) {
|
|
3454
|
-
this.options.runtimePlugins.push(runtimePath);
|
|
3455
|
-
}
|
|
3456
|
-
if (!((_this_options_runtimePlugins1 = this.options.runtimePlugins) === null || _this_options_runtimePlugins1 === void 0 ? void 0 : _this_options_runtimePlugins1.includes(sharedPath))) {
|
|
3457
|
-
this.options.runtimePlugins.push(sharedPath);
|
|
3458
|
-
}
|
|
3459
|
-
var encodedName = sdk.encodeName(name);
|
|
3460
|
-
var asyncEntryPath = require$$1__default["default"].resolve(compiler.options.context, "node_modules/".concat(TEMP_DIR, "/").concat(encodedName, "/bootstrap.js"));
|
|
3461
|
-
if (fs.existsSync(asyncEntryPath)) {
|
|
3462
|
-
fs.unlinkSync(asyncEntryPath);
|
|
3463
|
-
}
|
|
3464
|
-
if (!this.options.dataPrefetch) {
|
|
3465
|
-
return;
|
|
3466
|
-
}
|
|
3467
|
-
var prefetchs = [];
|
|
3468
|
-
var exposeAlias = Object.keys(exposes);
|
|
3469
|
-
exposeAlias.forEach(function(alias) {
|
|
3470
|
-
var exposePath;
|
|
3471
|
-
// @ts-ignore
|
|
3472
|
-
var exposeValue = exposes[alias];
|
|
3473
|
-
if (typeof exposeValue === 'string') {
|
|
3474
|
-
exposePath = exposeValue;
|
|
3475
|
-
} else {
|
|
3476
|
-
exposePath = exposeValue.import[0];
|
|
3477
|
-
}
|
|
3478
|
-
var targetPaths = fixPrefetchPath(exposePath);
|
|
3479
|
-
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
3480
|
-
try {
|
|
3481
|
-
for(var _iterator = targetPaths[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
3482
|
-
var pathItem = _step.value;
|
|
3483
|
-
var absolutePath = require$$1__default["default"].resolve(compiler.options.context, pathItem);
|
|
3484
|
-
if (fileExistsWithCaseSync(absolutePath)) {
|
|
3485
|
-
prefetchs.push(pathItem);
|
|
3486
|
-
var absoluteAlias = alias.replace('.', '');
|
|
3487
|
-
_this._reWriteExports += "export * as ".concat(runtimeUtils.getPrefetchId("".concat(name).concat(absoluteAlias)), " from '").concat(absolutePath, "';\n");
|
|
3488
|
-
break;
|
|
3489
|
-
}
|
|
3490
|
-
}
|
|
3491
|
-
} catch (err) {
|
|
3492
|
-
_didIteratorError = true;
|
|
3493
|
-
_iteratorError = err;
|
|
3494
|
-
} finally{
|
|
3495
|
-
try {
|
|
3496
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
3497
|
-
_iterator.return();
|
|
3498
|
-
}
|
|
3499
|
-
} finally{
|
|
3500
|
-
if (_didIteratorError) {
|
|
3501
|
-
throw _iteratorError;
|
|
3502
|
-
}
|
|
3503
|
-
}
|
|
3504
|
-
}
|
|
3505
|
-
});
|
|
3506
|
-
if (!this._reWriteExports) {
|
|
3507
|
-
return;
|
|
3508
|
-
}
|
|
3509
|
-
var tempDirRealPath = require$$1__default["default"].resolve(compiler.options.context, 'node_modules', TEMP_DIR);
|
|
3510
|
-
if (!fs.existsSync(tempDirRealPath)) {
|
|
3511
|
-
fs.mkdirSync(tempDirRealPath);
|
|
3512
|
-
}
|
|
3513
|
-
if (!fs.existsSync("".concat(tempDirRealPath, "/").concat(encodedName))) {
|
|
3514
|
-
fs.mkdirSync("".concat(tempDirRealPath, "/").concat(encodedName));
|
|
3515
|
-
}
|
|
3516
|
-
fs.writeFileSync(asyncEntryPath, this._reWriteExports);
|
|
3517
|
-
new compiler.webpack.DefinePlugin({
|
|
3518
|
-
FederationDataPrefetch: JSON.stringify(asyncEntryPath)
|
|
3519
|
-
}).apply(compiler);
|
|
3520
|
-
}
|
|
3521
|
-
}
|
|
3522
|
-
], [
|
|
3523
|
-
{
|
|
3524
|
-
key: "addRuntime",
|
|
3525
|
-
value: function addRuntime(compiler, options) {
|
|
3526
|
-
var encodedName = sdk.encodeName(options.name);
|
|
3527
|
-
if (!compiler.options.context) {
|
|
3528
|
-
throw new Error('compiler.options.context is not defined');
|
|
3529
|
-
}
|
|
3530
|
-
var prefetchEntry = require$$1__default["default"].resolve(compiler.options.context, "node_modules/.mf/".concat(encodedName, "/bootstrap.js"));
|
|
3531
|
-
var federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});
|
|
3532
|
-
return Template.asString([
|
|
3533
|
-
fs.existsSync(prefetchEntry) ? Template.indent([
|
|
3534
|
-
'function injectPrefetch() {',
|
|
3535
|
-
Template.indent([
|
|
3536
|
-
"globalThis.__FEDERATION__ = globalThis.__FEDERATION__ || {};",
|
|
3537
|
-
"globalThis.__FEDERATION__['".concat(sdk.MFPrefetchCommon.globalKey, "'] = globalThis.__FEDERATION__['").concat(sdk.MFPrefetchCommon.globalKey, "'] || {"),
|
|
3538
|
-
"entryLoading: {},",
|
|
3539
|
-
"instance: new Map(),",
|
|
3540
|
-
"__PREFETCH_EXPORTS__: {},",
|
|
3541
|
-
"};",
|
|
3542
|
-
"globalThis.__FEDERATION__['".concat(sdk.MFPrefetchCommon.globalKey, "']['").concat(sdk.MFPrefetchCommon.exportsKey, "'] = globalThis.__FEDERATION__['").concat(sdk.MFPrefetchCommon.globalKey, "']['").concat(sdk.MFPrefetchCommon.exportsKey, "'] || {};"),
|
|
3543
|
-
"globalThis.__FEDERATION__['".concat(sdk.MFPrefetchCommon.globalKey, "']['").concat(sdk.MFPrefetchCommon.exportsKey, "']['").concat(options.name, "'] = function(){ return import('").concat(prefetchEntry, "');}")
|
|
3544
|
-
]),
|
|
3545
|
-
'}',
|
|
3546
|
-
"".concat(federationGlobal, ".prefetch = injectPrefetch")
|
|
3547
|
-
]) : '',
|
|
3548
|
-
Template.indent([
|
|
3549
|
-
"if(!".concat(federationGlobal, ".isMFRemote && ").concat(federationGlobal, ".prefetch){"),
|
|
3550
|
-
"".concat(federationGlobal, ".prefetch()"),
|
|
3551
|
-
'}'
|
|
3552
|
-
])
|
|
3553
|
-
]);
|
|
3554
|
-
}
|
|
3555
|
-
},
|
|
3556
|
-
{
|
|
3557
|
-
key: "setRemoteIdentifier",
|
|
3558
|
-
value: function setRemoteIdentifier() {
|
|
3559
|
-
var federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});
|
|
3560
|
-
return Template.indent([
|
|
3561
|
-
"".concat(federationGlobal, ".isMFRemote = true;")
|
|
3562
|
-
]);
|
|
3563
|
-
}
|
|
3564
|
-
},
|
|
3565
|
-
{
|
|
3566
|
-
key: "removeRemoteIdentifier",
|
|
3567
|
-
value: function removeRemoteIdentifier() {
|
|
3568
|
-
var federationGlobal = getFederationGlobalScope(RuntimeGlobals || {});
|
|
3569
|
-
return Template.indent([
|
|
3570
|
-
"".concat(federationGlobal, ".isMFRemote = false;")
|
|
3571
|
-
]);
|
|
3572
|
-
}
|
|
3573
|
-
}
|
|
3574
|
-
]);
|
|
3575
|
-
return PrefetchPlugin;
|
|
3576
|
-
}();
|
|
3577
153
|
|
|
3578
154
|
exports.PrefetchPlugin = PrefetchPlugin;
|
|
3579
155
|
exports.getFederationGlobalScope = getFederationGlobalScope;
|