@prisma/composer-prisma-cloud 0.2.0-dev.11 → 0.2.0-dev.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/buckets-main.mjs +795 -0
- package/dist/buckets-main.mjs.map +1 -0
- package/dist/compute-main.mjs +532 -0
- package/dist/compute-main.mjs.map +1 -0
- package/dist/control.mjs +41 -1257
- package/dist/control.mjs.map +1 -1
- package/dist/cron/index.mjs +2 -3
- package/dist/cron/index.mjs.map +1 -1
- package/dist/cron/scheduler-entrypoint.mjs.map +1 -1
- package/dist/cron/scheduler-service.mjs +2 -3
- package/dist/cron/scheduler-service.mjs.map +1 -1
- package/dist/email/email-entrypoint.mjs.map +1 -1
- package/dist/email/email-service.mjs +2 -3
- package/dist/email/email-service.mjs.map +1 -1
- package/dist/email/index.mjs +2 -3
- package/dist/email/index.mjs.map +1 -1
- package/dist/email/testing.mjs.map +1 -1
- package/dist/get-port-BYnpbW5H.mjs +111 -0
- package/dist/get-port-BYnpbW5H.mjs.map +1 -0
- package/dist/index.mjs +4 -2
- package/dist/index.mjs.map +1 -1
- package/dist/local-target.d.mts +12 -0
- package/dist/local-target.d.mts.map +1 -0
- package/dist/local-target.mjs +6129 -0
- package/dist/local-target.mjs.map +1 -0
- package/dist/param-BTzY0ne5-CW6ojZ3E.mjs +66 -0
- package/dist/param-BTzY0ne5-CW6ojZ3E.mjs.map +1 -0
- package/dist/pg-connection-CadPZuEK-CF3FsSQu.mjs +79 -0
- package/dist/pg-connection-CadPZuEK-CF3FsSQu.mjs.map +1 -0
- package/dist/postgres-main.mjs +402 -0
- package/dist/postgres-main.mjs.map +1 -0
- package/dist/preflight-names-BPL-qsZF-BfoRgbgb.mjs +1252 -0
- package/dist/preflight-names-BPL-qsZF-BfoRgbgb.mjs.map +1 -0
- package/dist/{prisma-next-BvBwGCIt-CSauMX4l.mjs → prisma-next-BvBwGCIt-DssgnctU.mjs} +3 -78
- package/dist/prisma-next-BvBwGCIt-DssgnctU.mjs.map +1 -0
- package/dist/prisma-next.mjs +1 -1
- package/dist/{provisioned-edges-B_XS1Mz--NFJgcXK7.mjs → provisioned-edges-C1wSO3cx-YC5C19f9.mjs} +5 -65
- package/dist/provisioned-edges-C1wSO3cx-YC5C19f9.mjs.map +1 -0
- package/dist/secret-rz_ZqNeq-_xd97Jd9.mjs +47 -0
- package/dist/secret-rz_ZqNeq-_xd97Jd9.mjs.map +1 -0
- package/dist/segments-NpKN-46R-B01DmCqy.mjs +1441 -0
- package/dist/segments-NpKN-46R-B01DmCqy.mjs.map +1 -0
- package/dist/{serializer-D8_84XWO-DA2B6YbX.mjs → serializer-CJiOhF2d-DJUjQj1i.mjs} +4 -44
- package/dist/serializer-CJiOhF2d-DJUjQj1i.mjs.map +1 -0
- package/dist/storage/index.mjs +2 -3
- package/dist/storage/index.mjs.map +1 -1
- package/dist/storage/storage-entrypoint.mjs.map +1 -1
- package/dist/storage/storage-service.mjs +2 -3
- package/dist/storage/storage-service.mjs.map +1 -1
- package/dist/streams/index.mjs +2 -3
- package/dist/streams/index.mjs.map +1 -1
- package/dist/streams/streams-entrypoint.mjs.map +1 -1
- package/dist/streams/streams-service.mjs +2 -3
- package/dist/streams/streams-service.mjs.map +1 -1
- package/dist/testing.mjs +1 -1
- package/dist/testing.mjs.map +1 -1
- package/package.json +21 -15
- package/src/exports/local-target.ts +1 -0
- package/dist/prisma-next-BvBwGCIt-CSauMX4l.mjs.map +0 -1
- package/dist/provisioned-edges-B_XS1Mz--NFJgcXK7.mjs.map +0 -1
- package/dist/serializer-D8_84XWO-DA2B6YbX.mjs.map +0 -1
|
@@ -0,0 +1,1441 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import * as fs from "node:fs";
|
|
3
|
+
import "node:child_process";
|
|
4
|
+
import * as fs$1 from "node:fs/promises";
|
|
5
|
+
import * as path from "node:path";
|
|
6
|
+
import { fileURLToPath } from "node:url";
|
|
7
|
+
import { randomUUID } from "node:crypto";
|
|
8
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
9
|
+
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
10
|
+
//#endregion
|
|
11
|
+
//#region ../../../node_modules/graceful-fs/polyfills.js
|
|
12
|
+
var require_polyfills = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
13
|
+
var constants = __require("constants");
|
|
14
|
+
var origCwd = process.cwd;
|
|
15
|
+
var cwd = null;
|
|
16
|
+
var platform = process.env.GRACEFUL_FS_PLATFORM || process.platform;
|
|
17
|
+
process.cwd = function() {
|
|
18
|
+
if (!cwd) cwd = origCwd.call(process);
|
|
19
|
+
return cwd;
|
|
20
|
+
};
|
|
21
|
+
try {
|
|
22
|
+
process.cwd();
|
|
23
|
+
} catch (er) {}
|
|
24
|
+
if (typeof process.chdir === "function") {
|
|
25
|
+
var chdir = process.chdir;
|
|
26
|
+
process.chdir = function(d) {
|
|
27
|
+
cwd = null;
|
|
28
|
+
chdir.call(process, d);
|
|
29
|
+
};
|
|
30
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, chdir);
|
|
31
|
+
}
|
|
32
|
+
module.exports = patch;
|
|
33
|
+
function patch(fs) {
|
|
34
|
+
if (constants.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) patchLchmod(fs);
|
|
35
|
+
if (!fs.lutimes) patchLutimes(fs);
|
|
36
|
+
fs.chown = chownFix(fs.chown);
|
|
37
|
+
fs.fchown = chownFix(fs.fchown);
|
|
38
|
+
fs.lchown = chownFix(fs.lchown);
|
|
39
|
+
fs.chmod = chmodFix(fs.chmod);
|
|
40
|
+
fs.fchmod = chmodFix(fs.fchmod);
|
|
41
|
+
fs.lchmod = chmodFix(fs.lchmod);
|
|
42
|
+
fs.chownSync = chownFixSync(fs.chownSync);
|
|
43
|
+
fs.fchownSync = chownFixSync(fs.fchownSync);
|
|
44
|
+
fs.lchownSync = chownFixSync(fs.lchownSync);
|
|
45
|
+
fs.chmodSync = chmodFixSync(fs.chmodSync);
|
|
46
|
+
fs.fchmodSync = chmodFixSync(fs.fchmodSync);
|
|
47
|
+
fs.lchmodSync = chmodFixSync(fs.lchmodSync);
|
|
48
|
+
fs.stat = statFix(fs.stat);
|
|
49
|
+
fs.fstat = statFix(fs.fstat);
|
|
50
|
+
fs.lstat = statFix(fs.lstat);
|
|
51
|
+
fs.statSync = statFixSync(fs.statSync);
|
|
52
|
+
fs.fstatSync = statFixSync(fs.fstatSync);
|
|
53
|
+
fs.lstatSync = statFixSync(fs.lstatSync);
|
|
54
|
+
if (fs.chmod && !fs.lchmod) {
|
|
55
|
+
fs.lchmod = function(path, mode, cb) {
|
|
56
|
+
if (cb) process.nextTick(cb);
|
|
57
|
+
};
|
|
58
|
+
fs.lchmodSync = function() {};
|
|
59
|
+
}
|
|
60
|
+
if (fs.chown && !fs.lchown) {
|
|
61
|
+
fs.lchown = function(path, uid, gid, cb) {
|
|
62
|
+
if (cb) process.nextTick(cb);
|
|
63
|
+
};
|
|
64
|
+
fs.lchownSync = function() {};
|
|
65
|
+
}
|
|
66
|
+
if (platform === "win32") fs.rename = typeof fs.rename !== "function" ? fs.rename : (function(fs$rename) {
|
|
67
|
+
function rename(from, to, cb) {
|
|
68
|
+
var start = Date.now();
|
|
69
|
+
var backoff = 0;
|
|
70
|
+
fs$rename(from, to, function CB(er) {
|
|
71
|
+
if (er && (er.code === "EACCES" || er.code === "EPERM" || er.code === "EBUSY") && Date.now() - start < 6e4) {
|
|
72
|
+
setTimeout(function() {
|
|
73
|
+
fs.stat(to, function(stater, st) {
|
|
74
|
+
if (stater && stater.code === "ENOENT") fs$rename(from, to, CB);
|
|
75
|
+
else cb(er);
|
|
76
|
+
});
|
|
77
|
+
}, backoff);
|
|
78
|
+
if (backoff < 100) backoff += 10;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
if (cb) cb(er);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(rename, fs$rename);
|
|
85
|
+
return rename;
|
|
86
|
+
})(fs.rename);
|
|
87
|
+
fs.read = typeof fs.read !== "function" ? fs.read : (function(fs$read) {
|
|
88
|
+
function read(fd, buffer, offset, length, position, callback_) {
|
|
89
|
+
var callback;
|
|
90
|
+
if (callback_ && typeof callback_ === "function") {
|
|
91
|
+
var eagCounter = 0;
|
|
92
|
+
callback = function(er, _, __) {
|
|
93
|
+
if (er && er.code === "EAGAIN" && eagCounter < 10) {
|
|
94
|
+
eagCounter++;
|
|
95
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
96
|
+
}
|
|
97
|
+
callback_.apply(this, arguments);
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
return fs$read.call(fs, fd, buffer, offset, length, position, callback);
|
|
101
|
+
}
|
|
102
|
+
if (Object.setPrototypeOf) Object.setPrototypeOf(read, fs$read);
|
|
103
|
+
return read;
|
|
104
|
+
})(fs.read);
|
|
105
|
+
fs.readSync = typeof fs.readSync !== "function" ? fs.readSync : (function(fs$readSync) {
|
|
106
|
+
return function(fd, buffer, offset, length, position) {
|
|
107
|
+
var eagCounter = 0;
|
|
108
|
+
while (true) try {
|
|
109
|
+
return fs$readSync.call(fs, fd, buffer, offset, length, position);
|
|
110
|
+
} catch (er) {
|
|
111
|
+
if (er.code === "EAGAIN" && eagCounter < 10) {
|
|
112
|
+
eagCounter++;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
throw er;
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
})(fs.readSync);
|
|
119
|
+
function patchLchmod(fs) {
|
|
120
|
+
fs.lchmod = function(path, mode, callback) {
|
|
121
|
+
fs.open(path, constants.O_WRONLY | constants.O_SYMLINK, mode, function(err, fd) {
|
|
122
|
+
if (err) {
|
|
123
|
+
if (callback) callback(err);
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
fs.fchmod(fd, mode, function(err) {
|
|
127
|
+
fs.close(fd, function(err2) {
|
|
128
|
+
if (callback) callback(err || err2);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
fs.lchmodSync = function(path, mode) {
|
|
134
|
+
var fd = fs.openSync(path, constants.O_WRONLY | constants.O_SYMLINK, mode);
|
|
135
|
+
var threw = true;
|
|
136
|
+
var ret;
|
|
137
|
+
try {
|
|
138
|
+
ret = fs.fchmodSync(fd, mode);
|
|
139
|
+
threw = false;
|
|
140
|
+
} finally {
|
|
141
|
+
if (threw) try {
|
|
142
|
+
fs.closeSync(fd);
|
|
143
|
+
} catch (er) {}
|
|
144
|
+
else fs.closeSync(fd);
|
|
145
|
+
}
|
|
146
|
+
return ret;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
function patchLutimes(fs) {
|
|
150
|
+
if (constants.hasOwnProperty("O_SYMLINK") && fs.futimes) {
|
|
151
|
+
fs.lutimes = function(path, at, mt, cb) {
|
|
152
|
+
fs.open(path, constants.O_SYMLINK, function(er, fd) {
|
|
153
|
+
if (er) {
|
|
154
|
+
if (cb) cb(er);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
fs.futimes(fd, at, mt, function(er) {
|
|
158
|
+
fs.close(fd, function(er2) {
|
|
159
|
+
if (cb) cb(er || er2);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
fs.lutimesSync = function(path, at, mt) {
|
|
165
|
+
var fd = fs.openSync(path, constants.O_SYMLINK);
|
|
166
|
+
var ret;
|
|
167
|
+
var threw = true;
|
|
168
|
+
try {
|
|
169
|
+
ret = fs.futimesSync(fd, at, mt);
|
|
170
|
+
threw = false;
|
|
171
|
+
} finally {
|
|
172
|
+
if (threw) try {
|
|
173
|
+
fs.closeSync(fd);
|
|
174
|
+
} catch (er) {}
|
|
175
|
+
else fs.closeSync(fd);
|
|
176
|
+
}
|
|
177
|
+
return ret;
|
|
178
|
+
};
|
|
179
|
+
} else if (fs.futimes) {
|
|
180
|
+
fs.lutimes = function(_a, _b, _c, cb) {
|
|
181
|
+
if (cb) process.nextTick(cb);
|
|
182
|
+
};
|
|
183
|
+
fs.lutimesSync = function() {};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function chmodFix(orig) {
|
|
187
|
+
if (!orig) return orig;
|
|
188
|
+
return function(target, mode, cb) {
|
|
189
|
+
return orig.call(fs, target, mode, function(er) {
|
|
190
|
+
if (chownErOk(er)) er = null;
|
|
191
|
+
if (cb) cb.apply(this, arguments);
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
function chmodFixSync(orig) {
|
|
196
|
+
if (!orig) return orig;
|
|
197
|
+
return function(target, mode) {
|
|
198
|
+
try {
|
|
199
|
+
return orig.call(fs, target, mode);
|
|
200
|
+
} catch (er) {
|
|
201
|
+
if (!chownErOk(er)) throw er;
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function chownFix(orig) {
|
|
206
|
+
if (!orig) return orig;
|
|
207
|
+
return function(target, uid, gid, cb) {
|
|
208
|
+
return orig.call(fs, target, uid, gid, function(er) {
|
|
209
|
+
if (chownErOk(er)) er = null;
|
|
210
|
+
if (cb) cb.apply(this, arguments);
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
function chownFixSync(orig) {
|
|
215
|
+
if (!orig) return orig;
|
|
216
|
+
return function(target, uid, gid) {
|
|
217
|
+
try {
|
|
218
|
+
return orig.call(fs, target, uid, gid);
|
|
219
|
+
} catch (er) {
|
|
220
|
+
if (!chownErOk(er)) throw er;
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
function statFix(orig) {
|
|
225
|
+
if (!orig) return orig;
|
|
226
|
+
return function(target, options, cb) {
|
|
227
|
+
if (typeof options === "function") {
|
|
228
|
+
cb = options;
|
|
229
|
+
options = null;
|
|
230
|
+
}
|
|
231
|
+
function callback(er, stats) {
|
|
232
|
+
if (stats) {
|
|
233
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
234
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
235
|
+
}
|
|
236
|
+
if (cb) cb.apply(this, arguments);
|
|
237
|
+
}
|
|
238
|
+
return options ? orig.call(fs, target, options, callback) : orig.call(fs, target, callback);
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
function statFixSync(orig) {
|
|
242
|
+
if (!orig) return orig;
|
|
243
|
+
return function(target, options) {
|
|
244
|
+
var stats = options ? orig.call(fs, target, options) : orig.call(fs, target);
|
|
245
|
+
if (stats) {
|
|
246
|
+
if (stats.uid < 0) stats.uid += 4294967296;
|
|
247
|
+
if (stats.gid < 0) stats.gid += 4294967296;
|
|
248
|
+
}
|
|
249
|
+
return stats;
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function chownErOk(er) {
|
|
253
|
+
if (!er) return true;
|
|
254
|
+
if (er.code === "ENOSYS") return true;
|
|
255
|
+
if (!process.getuid || process.getuid() !== 0) {
|
|
256
|
+
if (er.code === "EINVAL" || er.code === "EPERM") return true;
|
|
257
|
+
}
|
|
258
|
+
return false;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}));
|
|
262
|
+
//#endregion
|
|
263
|
+
//#region ../../../node_modules/graceful-fs/legacy-streams.js
|
|
264
|
+
var require_legacy_streams = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
265
|
+
var Stream = __require("stream").Stream;
|
|
266
|
+
module.exports = legacy;
|
|
267
|
+
function legacy(fs) {
|
|
268
|
+
return {
|
|
269
|
+
ReadStream,
|
|
270
|
+
WriteStream
|
|
271
|
+
};
|
|
272
|
+
function ReadStream(path, options) {
|
|
273
|
+
if (!(this instanceof ReadStream)) return new ReadStream(path, options);
|
|
274
|
+
Stream.call(this);
|
|
275
|
+
var self = this;
|
|
276
|
+
this.path = path;
|
|
277
|
+
this.fd = null;
|
|
278
|
+
this.readable = true;
|
|
279
|
+
this.paused = false;
|
|
280
|
+
this.flags = "r";
|
|
281
|
+
this.mode = 438;
|
|
282
|
+
this.bufferSize = 64 * 1024;
|
|
283
|
+
options = options || {};
|
|
284
|
+
var keys = Object.keys(options);
|
|
285
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
286
|
+
var key = keys[index];
|
|
287
|
+
this[key] = options[key];
|
|
288
|
+
}
|
|
289
|
+
if (this.encoding) this.setEncoding(this.encoding);
|
|
290
|
+
if (this.start !== void 0) {
|
|
291
|
+
if ("number" !== typeof this.start) throw TypeError("start must be a Number");
|
|
292
|
+
if (this.end === void 0) this.end = Infinity;
|
|
293
|
+
else if ("number" !== typeof this.end) throw TypeError("end must be a Number");
|
|
294
|
+
if (this.start > this.end) throw new Error("start must be <= end");
|
|
295
|
+
this.pos = this.start;
|
|
296
|
+
}
|
|
297
|
+
if (this.fd !== null) {
|
|
298
|
+
process.nextTick(function() {
|
|
299
|
+
self._read();
|
|
300
|
+
});
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
fs.open(this.path, this.flags, this.mode, function(err, fd) {
|
|
304
|
+
if (err) {
|
|
305
|
+
self.emit("error", err);
|
|
306
|
+
self.readable = false;
|
|
307
|
+
return;
|
|
308
|
+
}
|
|
309
|
+
self.fd = fd;
|
|
310
|
+
self.emit("open", fd);
|
|
311
|
+
self._read();
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
function WriteStream(path, options) {
|
|
315
|
+
if (!(this instanceof WriteStream)) return new WriteStream(path, options);
|
|
316
|
+
Stream.call(this);
|
|
317
|
+
this.path = path;
|
|
318
|
+
this.fd = null;
|
|
319
|
+
this.writable = true;
|
|
320
|
+
this.flags = "w";
|
|
321
|
+
this.encoding = "binary";
|
|
322
|
+
this.mode = 438;
|
|
323
|
+
this.bytesWritten = 0;
|
|
324
|
+
options = options || {};
|
|
325
|
+
var keys = Object.keys(options);
|
|
326
|
+
for (var index = 0, length = keys.length; index < length; index++) {
|
|
327
|
+
var key = keys[index];
|
|
328
|
+
this[key] = options[key];
|
|
329
|
+
}
|
|
330
|
+
if (this.start !== void 0) {
|
|
331
|
+
if ("number" !== typeof this.start) throw TypeError("start must be a Number");
|
|
332
|
+
if (this.start < 0) throw new Error("start must be >= zero");
|
|
333
|
+
this.pos = this.start;
|
|
334
|
+
}
|
|
335
|
+
this.busy = false;
|
|
336
|
+
this._queue = [];
|
|
337
|
+
if (this.fd === null) {
|
|
338
|
+
this._open = fs.open;
|
|
339
|
+
this._queue.push([
|
|
340
|
+
this._open,
|
|
341
|
+
this.path,
|
|
342
|
+
this.flags,
|
|
343
|
+
this.mode,
|
|
344
|
+
void 0
|
|
345
|
+
]);
|
|
346
|
+
this.flush();
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}));
|
|
351
|
+
//#endregion
|
|
352
|
+
//#region ../../../node_modules/graceful-fs/clone.js
|
|
353
|
+
var require_clone = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
354
|
+
module.exports = clone;
|
|
355
|
+
var getPrototypeOf = Object.getPrototypeOf || function(obj) {
|
|
356
|
+
return obj.__proto__;
|
|
357
|
+
};
|
|
358
|
+
function clone(obj) {
|
|
359
|
+
if (obj === null || typeof obj !== "object") return obj;
|
|
360
|
+
if (obj instanceof Object) var copy = { __proto__: getPrototypeOf(obj) };
|
|
361
|
+
else var copy = Object.create(null);
|
|
362
|
+
Object.getOwnPropertyNames(obj).forEach(function(key) {
|
|
363
|
+
Object.defineProperty(copy, key, Object.getOwnPropertyDescriptor(obj, key));
|
|
364
|
+
});
|
|
365
|
+
return copy;
|
|
366
|
+
}
|
|
367
|
+
}));
|
|
368
|
+
//#endregion
|
|
369
|
+
//#region ../../../node_modules/graceful-fs/graceful-fs.js
|
|
370
|
+
var require_graceful_fs = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
371
|
+
var fs$2 = __require("fs");
|
|
372
|
+
var polyfills = require_polyfills();
|
|
373
|
+
var legacy = require_legacy_streams();
|
|
374
|
+
var clone = require_clone();
|
|
375
|
+
var util = __require("util");
|
|
376
|
+
/* istanbul ignore next - node 0.x polyfill */
|
|
377
|
+
var gracefulQueue;
|
|
378
|
+
var previousSymbol;
|
|
379
|
+
/* istanbul ignore else - node 0.x polyfill */
|
|
380
|
+
if (typeof Symbol === "function" && typeof Symbol.for === "function") {
|
|
381
|
+
gracefulQueue = Symbol.for("graceful-fs.queue");
|
|
382
|
+
previousSymbol = Symbol.for("graceful-fs.previous");
|
|
383
|
+
} else {
|
|
384
|
+
gracefulQueue = "___graceful-fs.queue";
|
|
385
|
+
previousSymbol = "___graceful-fs.previous";
|
|
386
|
+
}
|
|
387
|
+
function noop() {}
|
|
388
|
+
function publishQueue(context, queue) {
|
|
389
|
+
Object.defineProperty(context, gracefulQueue, { get: function() {
|
|
390
|
+
return queue;
|
|
391
|
+
} });
|
|
392
|
+
}
|
|
393
|
+
var debug = noop;
|
|
394
|
+
if (util.debuglog) debug = util.debuglog("gfs4");
|
|
395
|
+
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) debug = function() {
|
|
396
|
+
var m = util.format.apply(util, arguments);
|
|
397
|
+
m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
|
|
398
|
+
console.error(m);
|
|
399
|
+
};
|
|
400
|
+
if (!fs$2[gracefulQueue]) {
|
|
401
|
+
publishQueue(fs$2, global[gracefulQueue] || []);
|
|
402
|
+
fs$2.close = (function(fs$close) {
|
|
403
|
+
function close(fd, cb) {
|
|
404
|
+
return fs$close.call(fs$2, fd, function(err) {
|
|
405
|
+
if (!err) resetQueue();
|
|
406
|
+
if (typeof cb === "function") cb.apply(this, arguments);
|
|
407
|
+
});
|
|
408
|
+
}
|
|
409
|
+
Object.defineProperty(close, previousSymbol, { value: fs$close });
|
|
410
|
+
return close;
|
|
411
|
+
})(fs$2.close);
|
|
412
|
+
fs$2.closeSync = (function(fs$closeSync) {
|
|
413
|
+
function closeSync(fd) {
|
|
414
|
+
fs$closeSync.apply(fs$2, arguments);
|
|
415
|
+
resetQueue();
|
|
416
|
+
}
|
|
417
|
+
Object.defineProperty(closeSync, previousSymbol, { value: fs$closeSync });
|
|
418
|
+
return closeSync;
|
|
419
|
+
})(fs$2.closeSync);
|
|
420
|
+
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) process.on("exit", function() {
|
|
421
|
+
debug(fs$2[gracefulQueue]);
|
|
422
|
+
__require("assert").equal(fs$2[gracefulQueue].length, 0);
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
if (!global[gracefulQueue]) publishQueue(global, fs$2[gracefulQueue]);
|
|
426
|
+
module.exports = patch(clone(fs$2));
|
|
427
|
+
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !fs$2.__patched) {
|
|
428
|
+
module.exports = patch(fs$2);
|
|
429
|
+
fs$2.__patched = true;
|
|
430
|
+
}
|
|
431
|
+
function patch(fs) {
|
|
432
|
+
polyfills(fs);
|
|
433
|
+
fs.gracefulify = patch;
|
|
434
|
+
fs.createReadStream = createReadStream;
|
|
435
|
+
fs.createWriteStream = createWriteStream;
|
|
436
|
+
var fs$readFile = fs.readFile;
|
|
437
|
+
fs.readFile = readFile;
|
|
438
|
+
function readFile(path, options, cb) {
|
|
439
|
+
if (typeof options === "function") cb = options, options = null;
|
|
440
|
+
return go$readFile(path, options, cb);
|
|
441
|
+
function go$readFile(path, options, cb, startTime) {
|
|
442
|
+
return fs$readFile(path, options, function(err) {
|
|
443
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
444
|
+
go$readFile,
|
|
445
|
+
[
|
|
446
|
+
path,
|
|
447
|
+
options,
|
|
448
|
+
cb
|
|
449
|
+
],
|
|
450
|
+
err,
|
|
451
|
+
startTime || Date.now(),
|
|
452
|
+
Date.now()
|
|
453
|
+
]);
|
|
454
|
+
else if (typeof cb === "function") cb.apply(this, arguments);
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
var fs$writeFile = fs.writeFile;
|
|
459
|
+
fs.writeFile = writeFile;
|
|
460
|
+
function writeFile(path, data, options, cb) {
|
|
461
|
+
if (typeof options === "function") cb = options, options = null;
|
|
462
|
+
return go$writeFile(path, data, options, cb);
|
|
463
|
+
function go$writeFile(path, data, options, cb, startTime) {
|
|
464
|
+
return fs$writeFile(path, data, options, function(err) {
|
|
465
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
466
|
+
go$writeFile,
|
|
467
|
+
[
|
|
468
|
+
path,
|
|
469
|
+
data,
|
|
470
|
+
options,
|
|
471
|
+
cb
|
|
472
|
+
],
|
|
473
|
+
err,
|
|
474
|
+
startTime || Date.now(),
|
|
475
|
+
Date.now()
|
|
476
|
+
]);
|
|
477
|
+
else if (typeof cb === "function") cb.apply(this, arguments);
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
var fs$appendFile = fs.appendFile;
|
|
482
|
+
if (fs$appendFile) fs.appendFile = appendFile;
|
|
483
|
+
function appendFile(path, data, options, cb) {
|
|
484
|
+
if (typeof options === "function") cb = options, options = null;
|
|
485
|
+
return go$appendFile(path, data, options, cb);
|
|
486
|
+
function go$appendFile(path, data, options, cb, startTime) {
|
|
487
|
+
return fs$appendFile(path, data, options, function(err) {
|
|
488
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
489
|
+
go$appendFile,
|
|
490
|
+
[
|
|
491
|
+
path,
|
|
492
|
+
data,
|
|
493
|
+
options,
|
|
494
|
+
cb
|
|
495
|
+
],
|
|
496
|
+
err,
|
|
497
|
+
startTime || Date.now(),
|
|
498
|
+
Date.now()
|
|
499
|
+
]);
|
|
500
|
+
else if (typeof cb === "function") cb.apply(this, arguments);
|
|
501
|
+
});
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
var fs$copyFile = fs.copyFile;
|
|
505
|
+
if (fs$copyFile) fs.copyFile = copyFile;
|
|
506
|
+
function copyFile(src, dest, flags, cb) {
|
|
507
|
+
if (typeof flags === "function") {
|
|
508
|
+
cb = flags;
|
|
509
|
+
flags = 0;
|
|
510
|
+
}
|
|
511
|
+
return go$copyFile(src, dest, flags, cb);
|
|
512
|
+
function go$copyFile(src, dest, flags, cb, startTime) {
|
|
513
|
+
return fs$copyFile(src, dest, flags, function(err) {
|
|
514
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
515
|
+
go$copyFile,
|
|
516
|
+
[
|
|
517
|
+
src,
|
|
518
|
+
dest,
|
|
519
|
+
flags,
|
|
520
|
+
cb
|
|
521
|
+
],
|
|
522
|
+
err,
|
|
523
|
+
startTime || Date.now(),
|
|
524
|
+
Date.now()
|
|
525
|
+
]);
|
|
526
|
+
else if (typeof cb === "function") cb.apply(this, arguments);
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
var fs$readdir = fs.readdir;
|
|
531
|
+
fs.readdir = readdir;
|
|
532
|
+
var noReaddirOptionVersions = /^v[0-5]\./;
|
|
533
|
+
function readdir(path, options, cb) {
|
|
534
|
+
if (typeof options === "function") cb = options, options = null;
|
|
535
|
+
var go$readdir = noReaddirOptionVersions.test(process.version) ? function go$readdir(path, options, cb, startTime) {
|
|
536
|
+
return fs$readdir(path, fs$readdirCallback(path, options, cb, startTime));
|
|
537
|
+
} : function go$readdir(path, options, cb, startTime) {
|
|
538
|
+
return fs$readdir(path, options, fs$readdirCallback(path, options, cb, startTime));
|
|
539
|
+
};
|
|
540
|
+
return go$readdir(path, options, cb);
|
|
541
|
+
function fs$readdirCallback(path, options, cb, startTime) {
|
|
542
|
+
return function(err, files) {
|
|
543
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
544
|
+
go$readdir,
|
|
545
|
+
[
|
|
546
|
+
path,
|
|
547
|
+
options,
|
|
548
|
+
cb
|
|
549
|
+
],
|
|
550
|
+
err,
|
|
551
|
+
startTime || Date.now(),
|
|
552
|
+
Date.now()
|
|
553
|
+
]);
|
|
554
|
+
else {
|
|
555
|
+
if (files && files.sort) files.sort();
|
|
556
|
+
if (typeof cb === "function") cb.call(this, err, files);
|
|
557
|
+
}
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
if (process.version.substr(0, 4) === "v0.8") {
|
|
562
|
+
var legStreams = legacy(fs);
|
|
563
|
+
ReadStream = legStreams.ReadStream;
|
|
564
|
+
WriteStream = legStreams.WriteStream;
|
|
565
|
+
}
|
|
566
|
+
var fs$ReadStream = fs.ReadStream;
|
|
567
|
+
if (fs$ReadStream) {
|
|
568
|
+
ReadStream.prototype = Object.create(fs$ReadStream.prototype);
|
|
569
|
+
ReadStream.prototype.open = ReadStream$open;
|
|
570
|
+
}
|
|
571
|
+
var fs$WriteStream = fs.WriteStream;
|
|
572
|
+
if (fs$WriteStream) {
|
|
573
|
+
WriteStream.prototype = Object.create(fs$WriteStream.prototype);
|
|
574
|
+
WriteStream.prototype.open = WriteStream$open;
|
|
575
|
+
}
|
|
576
|
+
Object.defineProperty(fs, "ReadStream", {
|
|
577
|
+
get: function() {
|
|
578
|
+
return ReadStream;
|
|
579
|
+
},
|
|
580
|
+
set: function(val) {
|
|
581
|
+
ReadStream = val;
|
|
582
|
+
},
|
|
583
|
+
enumerable: true,
|
|
584
|
+
configurable: true
|
|
585
|
+
});
|
|
586
|
+
Object.defineProperty(fs, "WriteStream", {
|
|
587
|
+
get: function() {
|
|
588
|
+
return WriteStream;
|
|
589
|
+
},
|
|
590
|
+
set: function(val) {
|
|
591
|
+
WriteStream = val;
|
|
592
|
+
},
|
|
593
|
+
enumerable: true,
|
|
594
|
+
configurable: true
|
|
595
|
+
});
|
|
596
|
+
var FileReadStream = ReadStream;
|
|
597
|
+
Object.defineProperty(fs, "FileReadStream", {
|
|
598
|
+
get: function() {
|
|
599
|
+
return FileReadStream;
|
|
600
|
+
},
|
|
601
|
+
set: function(val) {
|
|
602
|
+
FileReadStream = val;
|
|
603
|
+
},
|
|
604
|
+
enumerable: true,
|
|
605
|
+
configurable: true
|
|
606
|
+
});
|
|
607
|
+
var FileWriteStream = WriteStream;
|
|
608
|
+
Object.defineProperty(fs, "FileWriteStream", {
|
|
609
|
+
get: function() {
|
|
610
|
+
return FileWriteStream;
|
|
611
|
+
},
|
|
612
|
+
set: function(val) {
|
|
613
|
+
FileWriteStream = val;
|
|
614
|
+
},
|
|
615
|
+
enumerable: true,
|
|
616
|
+
configurable: true
|
|
617
|
+
});
|
|
618
|
+
function ReadStream(path, options) {
|
|
619
|
+
if (this instanceof ReadStream) return fs$ReadStream.apply(this, arguments), this;
|
|
620
|
+
else return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
|
|
621
|
+
}
|
|
622
|
+
function ReadStream$open() {
|
|
623
|
+
var that = this;
|
|
624
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
625
|
+
if (err) {
|
|
626
|
+
if (that.autoClose) that.destroy();
|
|
627
|
+
that.emit("error", err);
|
|
628
|
+
} else {
|
|
629
|
+
that.fd = fd;
|
|
630
|
+
that.emit("open", fd);
|
|
631
|
+
that.read();
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
}
|
|
635
|
+
function WriteStream(path, options) {
|
|
636
|
+
if (this instanceof WriteStream) return fs$WriteStream.apply(this, arguments), this;
|
|
637
|
+
else return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
|
|
638
|
+
}
|
|
639
|
+
function WriteStream$open() {
|
|
640
|
+
var that = this;
|
|
641
|
+
open(that.path, that.flags, that.mode, function(err, fd) {
|
|
642
|
+
if (err) {
|
|
643
|
+
that.destroy();
|
|
644
|
+
that.emit("error", err);
|
|
645
|
+
} else {
|
|
646
|
+
that.fd = fd;
|
|
647
|
+
that.emit("open", fd);
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
function createReadStream(path, options) {
|
|
652
|
+
return new fs.ReadStream(path, options);
|
|
653
|
+
}
|
|
654
|
+
function createWriteStream(path, options) {
|
|
655
|
+
return new fs.WriteStream(path, options);
|
|
656
|
+
}
|
|
657
|
+
var fs$open = fs.open;
|
|
658
|
+
fs.open = open;
|
|
659
|
+
function open(path, flags, mode, cb) {
|
|
660
|
+
if (typeof mode === "function") cb = mode, mode = null;
|
|
661
|
+
return go$open(path, flags, mode, cb);
|
|
662
|
+
function go$open(path, flags, mode, cb, startTime) {
|
|
663
|
+
return fs$open(path, flags, mode, function(err, fd) {
|
|
664
|
+
if (err && (err.code === "EMFILE" || err.code === "ENFILE")) enqueue([
|
|
665
|
+
go$open,
|
|
666
|
+
[
|
|
667
|
+
path,
|
|
668
|
+
flags,
|
|
669
|
+
mode,
|
|
670
|
+
cb
|
|
671
|
+
],
|
|
672
|
+
err,
|
|
673
|
+
startTime || Date.now(),
|
|
674
|
+
Date.now()
|
|
675
|
+
]);
|
|
676
|
+
else if (typeof cb === "function") cb.apply(this, arguments);
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
return fs;
|
|
681
|
+
}
|
|
682
|
+
function enqueue(elem) {
|
|
683
|
+
debug("ENQUEUE", elem[0].name, elem[1]);
|
|
684
|
+
fs$2[gracefulQueue].push(elem);
|
|
685
|
+
retry();
|
|
686
|
+
}
|
|
687
|
+
var retryTimer;
|
|
688
|
+
function resetQueue() {
|
|
689
|
+
var now = Date.now();
|
|
690
|
+
for (var i = 0; i < fs$2[gracefulQueue].length; ++i) if (fs$2[gracefulQueue][i].length > 2) {
|
|
691
|
+
fs$2[gracefulQueue][i][3] = now;
|
|
692
|
+
fs$2[gracefulQueue][i][4] = now;
|
|
693
|
+
}
|
|
694
|
+
retry();
|
|
695
|
+
}
|
|
696
|
+
function retry() {
|
|
697
|
+
clearTimeout(retryTimer);
|
|
698
|
+
retryTimer = void 0;
|
|
699
|
+
if (fs$2[gracefulQueue].length === 0) return;
|
|
700
|
+
var elem = fs$2[gracefulQueue].shift();
|
|
701
|
+
var fn = elem[0];
|
|
702
|
+
var args = elem[1];
|
|
703
|
+
var err = elem[2];
|
|
704
|
+
var startTime = elem[3];
|
|
705
|
+
var lastTime = elem[4];
|
|
706
|
+
if (startTime === void 0) {
|
|
707
|
+
debug("RETRY", fn.name, args);
|
|
708
|
+
fn.apply(null, args);
|
|
709
|
+
} else if (Date.now() - startTime >= 6e4) {
|
|
710
|
+
debug("TIMEOUT", fn.name, args);
|
|
711
|
+
var cb = args.pop();
|
|
712
|
+
if (typeof cb === "function") cb.call(null, err);
|
|
713
|
+
} else {
|
|
714
|
+
var sinceAttempt = Date.now() - lastTime;
|
|
715
|
+
var sinceStart = Math.max(lastTime - startTime, 1);
|
|
716
|
+
if (sinceAttempt >= Math.min(sinceStart * 1.2, 100)) {
|
|
717
|
+
debug("RETRY", fn.name, args);
|
|
718
|
+
fn.apply(null, args.concat([startTime]));
|
|
719
|
+
} else fs$2[gracefulQueue].push(elem);
|
|
720
|
+
}
|
|
721
|
+
if (retryTimer === void 0) retryTimer = setTimeout(retry, 0);
|
|
722
|
+
}
|
|
723
|
+
}));
|
|
724
|
+
//#endregion
|
|
725
|
+
//#region ../../../node_modules/retry/lib/retry_operation.js
|
|
726
|
+
var require_retry_operation = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
727
|
+
function RetryOperation(timeouts, options) {
|
|
728
|
+
if (typeof options === "boolean") options = { forever: options };
|
|
729
|
+
this._originalTimeouts = JSON.parse(JSON.stringify(timeouts));
|
|
730
|
+
this._timeouts = timeouts;
|
|
731
|
+
this._options = options || {};
|
|
732
|
+
this._maxRetryTime = options && options.maxRetryTime || Infinity;
|
|
733
|
+
this._fn = null;
|
|
734
|
+
this._errors = [];
|
|
735
|
+
this._attempts = 1;
|
|
736
|
+
this._operationTimeout = null;
|
|
737
|
+
this._operationTimeoutCb = null;
|
|
738
|
+
this._timeout = null;
|
|
739
|
+
this._operationStart = null;
|
|
740
|
+
if (this._options.forever) this._cachedTimeouts = this._timeouts.slice(0);
|
|
741
|
+
}
|
|
742
|
+
module.exports = RetryOperation;
|
|
743
|
+
RetryOperation.prototype.reset = function() {
|
|
744
|
+
this._attempts = 1;
|
|
745
|
+
this._timeouts = this._originalTimeouts;
|
|
746
|
+
};
|
|
747
|
+
RetryOperation.prototype.stop = function() {
|
|
748
|
+
if (this._timeout) clearTimeout(this._timeout);
|
|
749
|
+
this._timeouts = [];
|
|
750
|
+
this._cachedTimeouts = null;
|
|
751
|
+
};
|
|
752
|
+
RetryOperation.prototype.retry = function(err) {
|
|
753
|
+
if (this._timeout) clearTimeout(this._timeout);
|
|
754
|
+
if (!err) return false;
|
|
755
|
+
var currentTime = (/* @__PURE__ */ new Date()).getTime();
|
|
756
|
+
if (err && currentTime - this._operationStart >= this._maxRetryTime) {
|
|
757
|
+
this._errors.unshift(/* @__PURE__ */ new Error("RetryOperation timeout occurred"));
|
|
758
|
+
return false;
|
|
759
|
+
}
|
|
760
|
+
this._errors.push(err);
|
|
761
|
+
var timeout = this._timeouts.shift();
|
|
762
|
+
if (timeout === void 0) if (this._cachedTimeouts) {
|
|
763
|
+
this._errors.splice(this._errors.length - 1, this._errors.length);
|
|
764
|
+
this._timeouts = this._cachedTimeouts.slice(0);
|
|
765
|
+
timeout = this._timeouts.shift();
|
|
766
|
+
} else return false;
|
|
767
|
+
var self = this;
|
|
768
|
+
var timer = setTimeout(function() {
|
|
769
|
+
self._attempts++;
|
|
770
|
+
if (self._operationTimeoutCb) {
|
|
771
|
+
self._timeout = setTimeout(function() {
|
|
772
|
+
self._operationTimeoutCb(self._attempts);
|
|
773
|
+
}, self._operationTimeout);
|
|
774
|
+
if (self._options.unref) self._timeout.unref();
|
|
775
|
+
}
|
|
776
|
+
self._fn(self._attempts);
|
|
777
|
+
}, timeout);
|
|
778
|
+
if (this._options.unref) timer.unref();
|
|
779
|
+
return true;
|
|
780
|
+
};
|
|
781
|
+
RetryOperation.prototype.attempt = function(fn, timeoutOps) {
|
|
782
|
+
this._fn = fn;
|
|
783
|
+
if (timeoutOps) {
|
|
784
|
+
if (timeoutOps.timeout) this._operationTimeout = timeoutOps.timeout;
|
|
785
|
+
if (timeoutOps.cb) this._operationTimeoutCb = timeoutOps.cb;
|
|
786
|
+
}
|
|
787
|
+
var self = this;
|
|
788
|
+
if (this._operationTimeoutCb) this._timeout = setTimeout(function() {
|
|
789
|
+
self._operationTimeoutCb();
|
|
790
|
+
}, self._operationTimeout);
|
|
791
|
+
this._operationStart = (/* @__PURE__ */ new Date()).getTime();
|
|
792
|
+
this._fn(this._attempts);
|
|
793
|
+
};
|
|
794
|
+
RetryOperation.prototype.try = function(fn) {
|
|
795
|
+
console.log("Using RetryOperation.try() is deprecated");
|
|
796
|
+
this.attempt(fn);
|
|
797
|
+
};
|
|
798
|
+
RetryOperation.prototype.start = function(fn) {
|
|
799
|
+
console.log("Using RetryOperation.start() is deprecated");
|
|
800
|
+
this.attempt(fn);
|
|
801
|
+
};
|
|
802
|
+
RetryOperation.prototype.start = RetryOperation.prototype.try;
|
|
803
|
+
RetryOperation.prototype.errors = function() {
|
|
804
|
+
return this._errors;
|
|
805
|
+
};
|
|
806
|
+
RetryOperation.prototype.attempts = function() {
|
|
807
|
+
return this._attempts;
|
|
808
|
+
};
|
|
809
|
+
RetryOperation.prototype.mainError = function() {
|
|
810
|
+
if (this._errors.length === 0) return null;
|
|
811
|
+
var counts = {};
|
|
812
|
+
var mainError = null;
|
|
813
|
+
var mainErrorCount = 0;
|
|
814
|
+
for (var i = 0; i < this._errors.length; i++) {
|
|
815
|
+
var error = this._errors[i];
|
|
816
|
+
var message = error.message;
|
|
817
|
+
var count = (counts[message] || 0) + 1;
|
|
818
|
+
counts[message] = count;
|
|
819
|
+
if (count >= mainErrorCount) {
|
|
820
|
+
mainError = error;
|
|
821
|
+
mainErrorCount = count;
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
return mainError;
|
|
825
|
+
};
|
|
826
|
+
}));
|
|
827
|
+
//#endregion
|
|
828
|
+
//#region ../../../node_modules/retry/lib/retry.js
|
|
829
|
+
var require_retry$1 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
830
|
+
var RetryOperation = require_retry_operation();
|
|
831
|
+
exports.operation = function(options) {
|
|
832
|
+
return new RetryOperation(exports.timeouts(options), {
|
|
833
|
+
forever: options && options.forever,
|
|
834
|
+
unref: options && options.unref,
|
|
835
|
+
maxRetryTime: options && options.maxRetryTime
|
|
836
|
+
});
|
|
837
|
+
};
|
|
838
|
+
exports.timeouts = function(options) {
|
|
839
|
+
if (options instanceof Array) return [].concat(options);
|
|
840
|
+
var opts = {
|
|
841
|
+
retries: 10,
|
|
842
|
+
factor: 2,
|
|
843
|
+
minTimeout: 1 * 1e3,
|
|
844
|
+
maxTimeout: Infinity,
|
|
845
|
+
randomize: false
|
|
846
|
+
};
|
|
847
|
+
for (var key in options) opts[key] = options[key];
|
|
848
|
+
if (opts.minTimeout > opts.maxTimeout) throw new Error("minTimeout is greater than maxTimeout");
|
|
849
|
+
var timeouts = [];
|
|
850
|
+
for (var i = 0; i < opts.retries; i++) timeouts.push(this.createTimeout(i, opts));
|
|
851
|
+
if (options && options.forever && !timeouts.length) timeouts.push(this.createTimeout(i, opts));
|
|
852
|
+
timeouts.sort(function(a, b) {
|
|
853
|
+
return a - b;
|
|
854
|
+
});
|
|
855
|
+
return timeouts;
|
|
856
|
+
};
|
|
857
|
+
exports.createTimeout = function(attempt, opts) {
|
|
858
|
+
var random = opts.randomize ? Math.random() + 1 : 1;
|
|
859
|
+
var timeout = Math.round(random * opts.minTimeout * Math.pow(opts.factor, attempt));
|
|
860
|
+
timeout = Math.min(timeout, opts.maxTimeout);
|
|
861
|
+
return timeout;
|
|
862
|
+
};
|
|
863
|
+
exports.wrap = function(obj, options, methods) {
|
|
864
|
+
if (options instanceof Array) {
|
|
865
|
+
methods = options;
|
|
866
|
+
options = null;
|
|
867
|
+
}
|
|
868
|
+
if (!methods) {
|
|
869
|
+
methods = [];
|
|
870
|
+
for (var key in obj) if (typeof obj[key] === "function") methods.push(key);
|
|
871
|
+
}
|
|
872
|
+
for (var i = 0; i < methods.length; i++) {
|
|
873
|
+
var method = methods[i];
|
|
874
|
+
var original = obj[method];
|
|
875
|
+
obj[method] = function retryWrapper(original) {
|
|
876
|
+
var op = exports.operation(options);
|
|
877
|
+
var args = Array.prototype.slice.call(arguments, 1);
|
|
878
|
+
var callback = args.pop();
|
|
879
|
+
args.push(function(err) {
|
|
880
|
+
if (op.retry(err)) return;
|
|
881
|
+
if (err) arguments[0] = op.mainError();
|
|
882
|
+
callback.apply(this, arguments);
|
|
883
|
+
});
|
|
884
|
+
op.attempt(function() {
|
|
885
|
+
original.apply(obj, args);
|
|
886
|
+
});
|
|
887
|
+
}.bind(obj, original);
|
|
888
|
+
obj[method].options = options;
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
}));
|
|
892
|
+
//#endregion
|
|
893
|
+
//#region ../../../node_modules/retry/index.js
|
|
894
|
+
var require_retry = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
895
|
+
module.exports = require_retry$1();
|
|
896
|
+
}));
|
|
897
|
+
//#endregion
|
|
898
|
+
//#region ../../../node_modules/signal-exit/signals.js
|
|
899
|
+
var require_signals = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
900
|
+
module.exports = [
|
|
901
|
+
"SIGABRT",
|
|
902
|
+
"SIGALRM",
|
|
903
|
+
"SIGHUP",
|
|
904
|
+
"SIGINT",
|
|
905
|
+
"SIGTERM"
|
|
906
|
+
];
|
|
907
|
+
if (process.platform !== "win32") module.exports.push("SIGVTALRM", "SIGXCPU", "SIGXFSZ", "SIGUSR2", "SIGTRAP", "SIGSYS", "SIGQUIT", "SIGIOT");
|
|
908
|
+
if (process.platform === "linux") module.exports.push("SIGIO", "SIGPOLL", "SIGPWR", "SIGSTKFLT", "SIGUNUSED");
|
|
909
|
+
}));
|
|
910
|
+
//#endregion
|
|
911
|
+
//#region ../../../node_modules/signal-exit/index.js
|
|
912
|
+
var require_signal_exit = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
913
|
+
var process = global.process;
|
|
914
|
+
const processOk = function(process) {
|
|
915
|
+
return process && typeof process === "object" && typeof process.removeListener === "function" && typeof process.emit === "function" && typeof process.reallyExit === "function" && typeof process.listeners === "function" && typeof process.kill === "function" && typeof process.pid === "number" && typeof process.on === "function";
|
|
916
|
+
};
|
|
917
|
+
/* istanbul ignore if */
|
|
918
|
+
if (!processOk(process)) module.exports = function() {
|
|
919
|
+
return function() {};
|
|
920
|
+
};
|
|
921
|
+
else {
|
|
922
|
+
var assert = __require("assert");
|
|
923
|
+
var signals = require_signals();
|
|
924
|
+
var isWin = /^win/i.test(process.platform);
|
|
925
|
+
var EE = __require("events");
|
|
926
|
+
/* istanbul ignore if */
|
|
927
|
+
if (typeof EE !== "function") EE = EE.EventEmitter;
|
|
928
|
+
var emitter;
|
|
929
|
+
if (process.__signal_exit_emitter__) emitter = process.__signal_exit_emitter__;
|
|
930
|
+
else {
|
|
931
|
+
emitter = process.__signal_exit_emitter__ = new EE();
|
|
932
|
+
emitter.count = 0;
|
|
933
|
+
emitter.emitted = {};
|
|
934
|
+
}
|
|
935
|
+
if (!emitter.infinite) {
|
|
936
|
+
emitter.setMaxListeners(Infinity);
|
|
937
|
+
emitter.infinite = true;
|
|
938
|
+
}
|
|
939
|
+
module.exports = function(cb, opts) {
|
|
940
|
+
/* istanbul ignore if */
|
|
941
|
+
if (!processOk(global.process)) return function() {};
|
|
942
|
+
assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
|
|
943
|
+
if (loaded === false) load();
|
|
944
|
+
var ev = "exit";
|
|
945
|
+
if (opts && opts.alwaysLast) ev = "afterexit";
|
|
946
|
+
var remove = function() {
|
|
947
|
+
emitter.removeListener(ev, cb);
|
|
948
|
+
if (emitter.listeners("exit").length === 0 && emitter.listeners("afterexit").length === 0) unload();
|
|
949
|
+
};
|
|
950
|
+
emitter.on(ev, cb);
|
|
951
|
+
return remove;
|
|
952
|
+
};
|
|
953
|
+
var unload = function unload() {
|
|
954
|
+
if (!loaded || !processOk(global.process)) return;
|
|
955
|
+
loaded = false;
|
|
956
|
+
signals.forEach(function(sig) {
|
|
957
|
+
try {
|
|
958
|
+
process.removeListener(sig, sigListeners[sig]);
|
|
959
|
+
} catch (er) {}
|
|
960
|
+
});
|
|
961
|
+
process.emit = originalProcessEmit;
|
|
962
|
+
process.reallyExit = originalProcessReallyExit;
|
|
963
|
+
emitter.count -= 1;
|
|
964
|
+
};
|
|
965
|
+
module.exports.unload = unload;
|
|
966
|
+
var emit = function emit(event, code, signal) {
|
|
967
|
+
/* istanbul ignore if */
|
|
968
|
+
if (emitter.emitted[event]) return;
|
|
969
|
+
emitter.emitted[event] = true;
|
|
970
|
+
emitter.emit(event, code, signal);
|
|
971
|
+
};
|
|
972
|
+
var sigListeners = {};
|
|
973
|
+
signals.forEach(function(sig) {
|
|
974
|
+
sigListeners[sig] = function listener() {
|
|
975
|
+
/* istanbul ignore if */
|
|
976
|
+
if (!processOk(global.process)) return;
|
|
977
|
+
if (process.listeners(sig).length === emitter.count) {
|
|
978
|
+
unload();
|
|
979
|
+
emit("exit", null, sig);
|
|
980
|
+
/* istanbul ignore next */
|
|
981
|
+
emit("afterexit", null, sig);
|
|
982
|
+
/* istanbul ignore next */
|
|
983
|
+
if (isWin && sig === "SIGHUP") sig = "SIGINT";
|
|
984
|
+
/* istanbul ignore next */
|
|
985
|
+
process.kill(process.pid, sig);
|
|
986
|
+
}
|
|
987
|
+
};
|
|
988
|
+
});
|
|
989
|
+
module.exports.signals = function() {
|
|
990
|
+
return signals;
|
|
991
|
+
};
|
|
992
|
+
var loaded = false;
|
|
993
|
+
var load = function load() {
|
|
994
|
+
if (loaded || !processOk(global.process)) return;
|
|
995
|
+
loaded = true;
|
|
996
|
+
emitter.count += 1;
|
|
997
|
+
signals = signals.filter(function(sig) {
|
|
998
|
+
try {
|
|
999
|
+
process.on(sig, sigListeners[sig]);
|
|
1000
|
+
return true;
|
|
1001
|
+
} catch (er) {
|
|
1002
|
+
return false;
|
|
1003
|
+
}
|
|
1004
|
+
});
|
|
1005
|
+
process.emit = processEmit;
|
|
1006
|
+
process.reallyExit = processReallyExit;
|
|
1007
|
+
};
|
|
1008
|
+
module.exports.load = load;
|
|
1009
|
+
var originalProcessReallyExit = process.reallyExit;
|
|
1010
|
+
var processReallyExit = function processReallyExit(code) {
|
|
1011
|
+
/* istanbul ignore if */
|
|
1012
|
+
if (!processOk(global.process)) return;
|
|
1013
|
+
process.exitCode = code || 0;
|
|
1014
|
+
emit("exit", process.exitCode, null);
|
|
1015
|
+
/* istanbul ignore next */
|
|
1016
|
+
emit("afterexit", process.exitCode, null);
|
|
1017
|
+
/* istanbul ignore next */
|
|
1018
|
+
originalProcessReallyExit.call(process, process.exitCode);
|
|
1019
|
+
};
|
|
1020
|
+
var originalProcessEmit = process.emit;
|
|
1021
|
+
var processEmit = function processEmit(ev, arg) {
|
|
1022
|
+
if (ev === "exit" && processOk(global.process)) {
|
|
1023
|
+
/* istanbul ignore else */
|
|
1024
|
+
if (arg !== void 0) process.exitCode = arg;
|
|
1025
|
+
var ret = originalProcessEmit.apply(this, arguments);
|
|
1026
|
+
/* istanbul ignore next */
|
|
1027
|
+
emit("exit", process.exitCode, null);
|
|
1028
|
+
/* istanbul ignore next */
|
|
1029
|
+
emit("afterexit", process.exitCode, null);
|
|
1030
|
+
/* istanbul ignore next */
|
|
1031
|
+
return ret;
|
|
1032
|
+
} else return originalProcessEmit.apply(this, arguments);
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
}));
|
|
1036
|
+
//#endregion
|
|
1037
|
+
//#region ../../../node_modules/proper-lockfile/lib/mtime-precision.js
|
|
1038
|
+
var require_mtime_precision = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1039
|
+
const cacheSymbol = Symbol();
|
|
1040
|
+
function probe(file, fs, callback) {
|
|
1041
|
+
const cachedPrecision = fs[cacheSymbol];
|
|
1042
|
+
if (cachedPrecision) return fs.stat(file, (err, stat) => {
|
|
1043
|
+
/* istanbul ignore if */
|
|
1044
|
+
if (err) return callback(err);
|
|
1045
|
+
callback(null, stat.mtime, cachedPrecision);
|
|
1046
|
+
});
|
|
1047
|
+
const mtime = /* @__PURE__ */ new Date(Math.ceil(Date.now() / 1e3) * 1e3 + 5);
|
|
1048
|
+
fs.utimes(file, mtime, mtime, (err) => {
|
|
1049
|
+
/* istanbul ignore if */
|
|
1050
|
+
if (err) return callback(err);
|
|
1051
|
+
fs.stat(file, (err, stat) => {
|
|
1052
|
+
/* istanbul ignore if */
|
|
1053
|
+
if (err) return callback(err);
|
|
1054
|
+
const precision = stat.mtime.getTime() % 1e3 === 0 ? "s" : "ms";
|
|
1055
|
+
Object.defineProperty(fs, cacheSymbol, { value: precision });
|
|
1056
|
+
callback(null, stat.mtime, precision);
|
|
1057
|
+
});
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
function getMtime(precision) {
|
|
1061
|
+
let now = Date.now();
|
|
1062
|
+
if (precision === "s") now = Math.ceil(now / 1e3) * 1e3;
|
|
1063
|
+
return new Date(now);
|
|
1064
|
+
}
|
|
1065
|
+
module.exports.probe = probe;
|
|
1066
|
+
module.exports.getMtime = getMtime;
|
|
1067
|
+
}));
|
|
1068
|
+
//#endregion
|
|
1069
|
+
//#region ../../../node_modules/proper-lockfile/lib/lockfile.js
|
|
1070
|
+
var require_lockfile = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1071
|
+
const path$1 = __require("path");
|
|
1072
|
+
const fs = require_graceful_fs();
|
|
1073
|
+
const retry = require_retry();
|
|
1074
|
+
const onExit = require_signal_exit();
|
|
1075
|
+
const mtimePrecision = require_mtime_precision();
|
|
1076
|
+
const locks = {};
|
|
1077
|
+
function getLockFile(file, options) {
|
|
1078
|
+
return options.lockfilePath || `${file}.lock`;
|
|
1079
|
+
}
|
|
1080
|
+
function resolveCanonicalPath(file, options, callback) {
|
|
1081
|
+
if (!options.realpath) return callback(null, path$1.resolve(file));
|
|
1082
|
+
options.fs.realpath(file, callback);
|
|
1083
|
+
}
|
|
1084
|
+
function acquireLock(file, options, callback) {
|
|
1085
|
+
const lockfilePath = getLockFile(file, options);
|
|
1086
|
+
options.fs.mkdir(lockfilePath, (err) => {
|
|
1087
|
+
if (!err) return mtimePrecision.probe(lockfilePath, options.fs, (err, mtime, mtimePrecision) => {
|
|
1088
|
+
/* istanbul ignore if */
|
|
1089
|
+
if (err) {
|
|
1090
|
+
options.fs.rmdir(lockfilePath, () => {});
|
|
1091
|
+
return callback(err);
|
|
1092
|
+
}
|
|
1093
|
+
callback(null, mtime, mtimePrecision);
|
|
1094
|
+
});
|
|
1095
|
+
if (err.code !== "EEXIST") return callback(err);
|
|
1096
|
+
if (options.stale <= 0) return callback(Object.assign(/* @__PURE__ */ new Error("Lock file is already being held"), {
|
|
1097
|
+
code: "ELOCKED",
|
|
1098
|
+
file
|
|
1099
|
+
}));
|
|
1100
|
+
options.fs.stat(lockfilePath, (err, stat) => {
|
|
1101
|
+
if (err) {
|
|
1102
|
+
if (err.code === "ENOENT") return acquireLock(file, {
|
|
1103
|
+
...options,
|
|
1104
|
+
stale: 0
|
|
1105
|
+
}, callback);
|
|
1106
|
+
return callback(err);
|
|
1107
|
+
}
|
|
1108
|
+
if (!isLockStale(stat, options)) return callback(Object.assign(/* @__PURE__ */ new Error("Lock file is already being held"), {
|
|
1109
|
+
code: "ELOCKED",
|
|
1110
|
+
file
|
|
1111
|
+
}));
|
|
1112
|
+
removeLock(file, options, (err) => {
|
|
1113
|
+
if (err) return callback(err);
|
|
1114
|
+
acquireLock(file, {
|
|
1115
|
+
...options,
|
|
1116
|
+
stale: 0
|
|
1117
|
+
}, callback);
|
|
1118
|
+
});
|
|
1119
|
+
});
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
function isLockStale(stat, options) {
|
|
1123
|
+
return stat.mtime.getTime() < Date.now() - options.stale;
|
|
1124
|
+
}
|
|
1125
|
+
function removeLock(file, options, callback) {
|
|
1126
|
+
options.fs.rmdir(getLockFile(file, options), (err) => {
|
|
1127
|
+
if (err && err.code !== "ENOENT") return callback(err);
|
|
1128
|
+
callback();
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
function updateLock(file, options) {
|
|
1132
|
+
const lock = locks[file];
|
|
1133
|
+
/* istanbul ignore if */
|
|
1134
|
+
if (lock.updateTimeout) return;
|
|
1135
|
+
lock.updateDelay = lock.updateDelay || options.update;
|
|
1136
|
+
lock.updateTimeout = setTimeout(() => {
|
|
1137
|
+
lock.updateTimeout = null;
|
|
1138
|
+
options.fs.stat(lock.lockfilePath, (err, stat) => {
|
|
1139
|
+
const isOverThreshold = lock.lastUpdate + options.stale < Date.now();
|
|
1140
|
+
if (err) {
|
|
1141
|
+
if (err.code === "ENOENT" || isOverThreshold) return setLockAsCompromised(file, lock, Object.assign(err, { code: "ECOMPROMISED" }));
|
|
1142
|
+
lock.updateDelay = 1e3;
|
|
1143
|
+
return updateLock(file, options);
|
|
1144
|
+
}
|
|
1145
|
+
if (!(lock.mtime.getTime() === stat.mtime.getTime())) return setLockAsCompromised(file, lock, Object.assign(/* @__PURE__ */ new Error("Unable to update lock within the stale threshold"), { code: "ECOMPROMISED" }));
|
|
1146
|
+
const mtime = mtimePrecision.getMtime(lock.mtimePrecision);
|
|
1147
|
+
options.fs.utimes(lock.lockfilePath, mtime, mtime, (err) => {
|
|
1148
|
+
const isOverThreshold = lock.lastUpdate + options.stale < Date.now();
|
|
1149
|
+
if (lock.released) return;
|
|
1150
|
+
if (err) {
|
|
1151
|
+
if (err.code === "ENOENT" || isOverThreshold) return setLockAsCompromised(file, lock, Object.assign(err, { code: "ECOMPROMISED" }));
|
|
1152
|
+
lock.updateDelay = 1e3;
|
|
1153
|
+
return updateLock(file, options);
|
|
1154
|
+
}
|
|
1155
|
+
lock.mtime = mtime;
|
|
1156
|
+
lock.lastUpdate = Date.now();
|
|
1157
|
+
lock.updateDelay = null;
|
|
1158
|
+
updateLock(file, options);
|
|
1159
|
+
});
|
|
1160
|
+
});
|
|
1161
|
+
}, lock.updateDelay);
|
|
1162
|
+
/* istanbul ignore else */
|
|
1163
|
+
if (lock.updateTimeout.unref) lock.updateTimeout.unref();
|
|
1164
|
+
}
|
|
1165
|
+
function setLockAsCompromised(file, lock, err) {
|
|
1166
|
+
lock.released = true;
|
|
1167
|
+
/* istanbul ignore if */
|
|
1168
|
+
if (lock.updateTimeout) clearTimeout(lock.updateTimeout);
|
|
1169
|
+
if (locks[file] === lock) delete locks[file];
|
|
1170
|
+
lock.options.onCompromised(err);
|
|
1171
|
+
}
|
|
1172
|
+
function lock(file, options, callback) {
|
|
1173
|
+
/* istanbul ignore next */
|
|
1174
|
+
options = {
|
|
1175
|
+
stale: 1e4,
|
|
1176
|
+
update: null,
|
|
1177
|
+
realpath: true,
|
|
1178
|
+
retries: 0,
|
|
1179
|
+
fs,
|
|
1180
|
+
onCompromised: (err) => {
|
|
1181
|
+
throw err;
|
|
1182
|
+
},
|
|
1183
|
+
...options
|
|
1184
|
+
};
|
|
1185
|
+
options.retries = options.retries || 0;
|
|
1186
|
+
options.retries = typeof options.retries === "number" ? { retries: options.retries } : options.retries;
|
|
1187
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
1188
|
+
options.update = options.update == null ? options.stale / 2 : options.update || 0;
|
|
1189
|
+
options.update = Math.max(Math.min(options.update, options.stale / 2), 1e3);
|
|
1190
|
+
resolveCanonicalPath(file, options, (err, file) => {
|
|
1191
|
+
if (err) return callback(err);
|
|
1192
|
+
const operation = retry.operation(options.retries);
|
|
1193
|
+
operation.attempt(() => {
|
|
1194
|
+
acquireLock(file, options, (err, mtime, mtimePrecision) => {
|
|
1195
|
+
if (operation.retry(err)) return;
|
|
1196
|
+
if (err) return callback(operation.mainError());
|
|
1197
|
+
const lock = locks[file] = {
|
|
1198
|
+
lockfilePath: getLockFile(file, options),
|
|
1199
|
+
mtime,
|
|
1200
|
+
mtimePrecision,
|
|
1201
|
+
options,
|
|
1202
|
+
lastUpdate: Date.now()
|
|
1203
|
+
};
|
|
1204
|
+
updateLock(file, options);
|
|
1205
|
+
callback(null, (releasedCallback) => {
|
|
1206
|
+
if (lock.released) return releasedCallback && releasedCallback(Object.assign(/* @__PURE__ */ new Error("Lock is already released"), { code: "ERELEASED" }));
|
|
1207
|
+
unlock(file, {
|
|
1208
|
+
...options,
|
|
1209
|
+
realpath: false
|
|
1210
|
+
}, releasedCallback);
|
|
1211
|
+
});
|
|
1212
|
+
});
|
|
1213
|
+
});
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
function unlock(file, options, callback) {
|
|
1217
|
+
options = {
|
|
1218
|
+
fs,
|
|
1219
|
+
realpath: true,
|
|
1220
|
+
...options
|
|
1221
|
+
};
|
|
1222
|
+
resolveCanonicalPath(file, options, (err, file) => {
|
|
1223
|
+
if (err) return callback(err);
|
|
1224
|
+
const lock = locks[file];
|
|
1225
|
+
if (!lock) return callback(Object.assign(/* @__PURE__ */ new Error("Lock is not acquired/owned by you"), { code: "ENOTACQUIRED" }));
|
|
1226
|
+
lock.updateTimeout && clearTimeout(lock.updateTimeout);
|
|
1227
|
+
lock.released = true;
|
|
1228
|
+
delete locks[file];
|
|
1229
|
+
removeLock(file, options, callback);
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
function check(file, options, callback) {
|
|
1233
|
+
options = {
|
|
1234
|
+
stale: 1e4,
|
|
1235
|
+
realpath: true,
|
|
1236
|
+
fs,
|
|
1237
|
+
...options
|
|
1238
|
+
};
|
|
1239
|
+
options.stale = Math.max(options.stale || 0, 2e3);
|
|
1240
|
+
resolveCanonicalPath(file, options, (err, file) => {
|
|
1241
|
+
if (err) return callback(err);
|
|
1242
|
+
options.fs.stat(getLockFile(file, options), (err, stat) => {
|
|
1243
|
+
if (err) return err.code === "ENOENT" ? callback(null, false) : callback(err);
|
|
1244
|
+
return callback(null, !isLockStale(stat, options));
|
|
1245
|
+
});
|
|
1246
|
+
});
|
|
1247
|
+
}
|
|
1248
|
+
function getLocks() {
|
|
1249
|
+
return locks;
|
|
1250
|
+
}
|
|
1251
|
+
/* istanbul ignore next */
|
|
1252
|
+
onExit(() => {
|
|
1253
|
+
for (const file in locks) {
|
|
1254
|
+
const options = locks[file].options;
|
|
1255
|
+
try {
|
|
1256
|
+
options.fs.rmdirSync(getLockFile(file, options));
|
|
1257
|
+
} catch (e) {}
|
|
1258
|
+
}
|
|
1259
|
+
});
|
|
1260
|
+
module.exports.lock = lock;
|
|
1261
|
+
module.exports.unlock = unlock;
|
|
1262
|
+
module.exports.check = check;
|
|
1263
|
+
module.exports.getLocks = getLocks;
|
|
1264
|
+
}));
|
|
1265
|
+
//#endregion
|
|
1266
|
+
//#region ../../../node_modules/proper-lockfile/lib/adapter.js
|
|
1267
|
+
var require_adapter = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1268
|
+
const fs = require_graceful_fs();
|
|
1269
|
+
function createSyncFs(fs) {
|
|
1270
|
+
const methods = [
|
|
1271
|
+
"mkdir",
|
|
1272
|
+
"realpath",
|
|
1273
|
+
"stat",
|
|
1274
|
+
"rmdir",
|
|
1275
|
+
"utimes"
|
|
1276
|
+
];
|
|
1277
|
+
const newFs = { ...fs };
|
|
1278
|
+
methods.forEach((method) => {
|
|
1279
|
+
newFs[method] = (...args) => {
|
|
1280
|
+
const callback = args.pop();
|
|
1281
|
+
let ret;
|
|
1282
|
+
try {
|
|
1283
|
+
ret = fs[`${method}Sync`](...args);
|
|
1284
|
+
} catch (err) {
|
|
1285
|
+
return callback(err);
|
|
1286
|
+
}
|
|
1287
|
+
callback(null, ret);
|
|
1288
|
+
};
|
|
1289
|
+
});
|
|
1290
|
+
return newFs;
|
|
1291
|
+
}
|
|
1292
|
+
function toPromise(method) {
|
|
1293
|
+
return (...args) => new Promise((resolve, reject) => {
|
|
1294
|
+
args.push((err, result) => {
|
|
1295
|
+
if (err) reject(err);
|
|
1296
|
+
else resolve(result);
|
|
1297
|
+
});
|
|
1298
|
+
method(...args);
|
|
1299
|
+
});
|
|
1300
|
+
}
|
|
1301
|
+
function toSync(method) {
|
|
1302
|
+
return (...args) => {
|
|
1303
|
+
let err;
|
|
1304
|
+
let result;
|
|
1305
|
+
args.push((_err, _result) => {
|
|
1306
|
+
err = _err;
|
|
1307
|
+
result = _result;
|
|
1308
|
+
});
|
|
1309
|
+
method(...args);
|
|
1310
|
+
if (err) throw err;
|
|
1311
|
+
return result;
|
|
1312
|
+
};
|
|
1313
|
+
}
|
|
1314
|
+
function toSyncOptions(options) {
|
|
1315
|
+
options = { ...options };
|
|
1316
|
+
options.fs = createSyncFs(options.fs || fs);
|
|
1317
|
+
if (typeof options.retries === "number" && options.retries > 0 || options.retries && typeof options.retries.retries === "number" && options.retries.retries > 0) throw Object.assign(/* @__PURE__ */ new Error("Cannot use retries with the sync api"), { code: "ESYNC" });
|
|
1318
|
+
return options;
|
|
1319
|
+
}
|
|
1320
|
+
module.exports = {
|
|
1321
|
+
toPromise,
|
|
1322
|
+
toSync,
|
|
1323
|
+
toSyncOptions
|
|
1324
|
+
};
|
|
1325
|
+
}));
|
|
1326
|
+
(/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1327
|
+
const lockfile = require_lockfile();
|
|
1328
|
+
const { toPromise, toSync, toSyncOptions } = require_adapter();
|
|
1329
|
+
async function lock(file, options) {
|
|
1330
|
+
const release = await toPromise(lockfile.lock)(file, options);
|
|
1331
|
+
return toPromise(release);
|
|
1332
|
+
}
|
|
1333
|
+
function lockSync(file, options) {
|
|
1334
|
+
const release = toSync(lockfile.lock)(file, toSyncOptions(options));
|
|
1335
|
+
return toSync(release);
|
|
1336
|
+
}
|
|
1337
|
+
function unlock(file, options) {
|
|
1338
|
+
return toPromise(lockfile.unlock)(file, options);
|
|
1339
|
+
}
|
|
1340
|
+
function unlockSync(file, options) {
|
|
1341
|
+
return toSync(lockfile.unlock)(file, toSyncOptions(options));
|
|
1342
|
+
}
|
|
1343
|
+
function check(file, options) {
|
|
1344
|
+
return toPromise(lockfile.check)(file, options);
|
|
1345
|
+
}
|
|
1346
|
+
function checkSync(file, options) {
|
|
1347
|
+
return toSync(lockfile.check)(file, toSyncOptions(options));
|
|
1348
|
+
}
|
|
1349
|
+
module.exports = lock;
|
|
1350
|
+
module.exports.lock = lock;
|
|
1351
|
+
module.exports.unlock = unlock;
|
|
1352
|
+
module.exports.lockSync = lockSync;
|
|
1353
|
+
module.exports.unlockSync = unlockSync;
|
|
1354
|
+
module.exports.check = check;
|
|
1355
|
+
module.exports.checkSync = checkSync;
|
|
1356
|
+
})))();
|
|
1357
|
+
/**
|
|
1358
|
+
* Temp-then-rename JSON state-file writes behind one in-process queue (spec
|
|
1359
|
+
* local-dev § 2, "API hygiene, both daemons"): each daemon is single-process,
|
|
1360
|
+
* so concurrent HTTP handlers mutating the same state file serialize their
|
|
1361
|
+
* writes through a `StateFile` instance instead of racing each other on disk.
|
|
1362
|
+
*/
|
|
1363
|
+
var StateFile = class {
|
|
1364
|
+
filePath;
|
|
1365
|
+
mode;
|
|
1366
|
+
queue = Promise.resolve();
|
|
1367
|
+
constructor(filePath, mode) {
|
|
1368
|
+
this.filePath = filePath;
|
|
1369
|
+
this.mode = mode;
|
|
1370
|
+
}
|
|
1371
|
+
/** Serializes `value` to disk, temp-then-rename, behind this file's write queue. */
|
|
1372
|
+
write(value) {
|
|
1373
|
+
const next = this.queue.then(() => this.writeNow(value));
|
|
1374
|
+
this.queue = next.catch(() => void 0);
|
|
1375
|
+
return next;
|
|
1376
|
+
}
|
|
1377
|
+
/** Resolves once every write() call made so far has landed on disk — for graceful shutdown, so a SIGTERM can't race an in-flight write and lose it. */
|
|
1378
|
+
flush() {
|
|
1379
|
+
return this.queue;
|
|
1380
|
+
}
|
|
1381
|
+
async writeNow(value) {
|
|
1382
|
+
const dir = path.dirname(this.filePath);
|
|
1383
|
+
await fs$1.mkdir(dir, { recursive: true });
|
|
1384
|
+
const tmpPath = path.join(dir, `.${path.basename(this.filePath)}.${randomUUID()}.tmp`);
|
|
1385
|
+
const json = `${JSON.stringify(value, null, 2)}\n`;
|
|
1386
|
+
await fs$1.writeFile(tmpPath, json, this.mode !== void 0 ? { mode: this.mode } : void 0);
|
|
1387
|
+
await fs$1.rename(tmpPath, this.filePath);
|
|
1388
|
+
if (this.mode !== void 0) await fs$1.chmod(this.filePath, this.mode);
|
|
1389
|
+
}
|
|
1390
|
+
};
|
|
1391
|
+
function isEnoent$1(err) {
|
|
1392
|
+
return err instanceof Error && "code" in err && err.code === "ENOENT";
|
|
1393
|
+
}
|
|
1394
|
+
/**
|
|
1395
|
+
* Reads and parses a JSON state file, narrowing the parsed value with
|
|
1396
|
+
* `isValid` (a real type predicate, not a cast — the file's shape is only
|
|
1397
|
+
* trustworthy because this daemon is its only writer, but a foreign or
|
|
1398
|
+
* corrupt file on disk must not be treated as valid state). `undefined` when
|
|
1399
|
+
* absent, unreadable, or shaped wrong.
|
|
1400
|
+
*/
|
|
1401
|
+
async function readJsonFile(filePath, isValid) {
|
|
1402
|
+
let raw;
|
|
1403
|
+
try {
|
|
1404
|
+
raw = await fs$1.readFile(filePath, "utf8");
|
|
1405
|
+
} catch (err) {
|
|
1406
|
+
if (isEnoent$1(err)) return void 0;
|
|
1407
|
+
throw err;
|
|
1408
|
+
}
|
|
1409
|
+
let parsed;
|
|
1410
|
+
try {
|
|
1411
|
+
parsed = JSON.parse(raw);
|
|
1412
|
+
} catch {
|
|
1413
|
+
return;
|
|
1414
|
+
}
|
|
1415
|
+
return isValid(parsed) ? parsed : void 0;
|
|
1416
|
+
}
|
|
1417
|
+
function isPackageJson(value) {
|
|
1418
|
+
return typeof value === "object" && value !== null && "version" in value && typeof value.version === "string";
|
|
1419
|
+
}
|
|
1420
|
+
/** `@internal/dev-emulators`'s own `package.json` version — what "version" means everywhere in this package. */
|
|
1421
|
+
function readOwnVersion() {
|
|
1422
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
1423
|
+
const pkgPath = path.join(here, "..", "package.json");
|
|
1424
|
+
const raw = fs.readFileSync(pkgPath, "utf8");
|
|
1425
|
+
const parsed = JSON.parse(raw);
|
|
1426
|
+
if (!isPackageJson(parsed)) throw new Error(`could not read a version string from ${pkgPath}`);
|
|
1427
|
+
return parsed.version;
|
|
1428
|
+
}
|
|
1429
|
+
/**
|
|
1430
|
+
* API hygiene shared by both daemons (local-dev spec § 2): every `<app>`,
|
|
1431
|
+
* `<id>`, and `<name>` path segment must match this shape or the request is
|
|
1432
|
+
* a 400 naming the segment.
|
|
1433
|
+
*/
|
|
1434
|
+
const SEGMENT_RE = /^[a-z0-9][a-z0-9-]*$/;
|
|
1435
|
+
function isValidSegment(segment) {
|
|
1436
|
+
return segment.length <= 63 && SEGMENT_RE.test(segment);
|
|
1437
|
+
}
|
|
1438
|
+
//#endregion
|
|
1439
|
+
export { readOwnVersion as i, isValidSegment as n, readJsonFile as r, StateFile as t };
|
|
1440
|
+
|
|
1441
|
+
//# sourceMappingURL=segments-NpKN-46R-B01DmCqy.mjs.map
|