lakutata 2.0.34 → 2.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/com/cacher.cjs +211 -0
  2. package/com/cacher.d.ts +514 -0
  3. package/com/cacher.mjs +185 -0
  4. package/com/database.cjs +6 -2
  5. package/com/database.mjs +6 -2
  6. package/com/docker.cjs +23 -17
  7. package/com/docker.mjs +19 -13
  8. package/com/entrypoint.cjs +1 -1
  9. package/com/entrypoint.mjs +1 -1
  10. package/com/logger.cjs +6 -2
  11. package/com/logger.mjs +6 -2
  12. package/decorator/ctrl.cjs +1 -1
  13. package/decorator/ctrl.mjs +1 -1
  14. package/decorator/orm.cjs +22 -18
  15. package/decorator/orm.mjs +6 -2
  16. package/helper.cjs +1 -1
  17. package/helper.mjs +1 -1
  18. package/lakutata.cjs +7 -3
  19. package/lakutata.mjs +7 -3
  20. package/orm.cjs +19 -15
  21. package/orm.mjs +15 -11
  22. package/package.json +6 -1
  23. package/provider/database.cjs +6 -2
  24. package/provider/database.mjs +6 -2
  25. package/src/components/Database.cjs +6 -2
  26. package/src/components/Database.mjs +6 -2
  27. package/src/components/Logger.cjs +6 -2
  28. package/src/components/Logger.mjs +6 -2
  29. package/src/components/cacher/Cacher.cjs +193 -0
  30. package/src/components/cacher/Cacher.mjs +183 -0
  31. package/src/components/cacher/options/CacherOptions.cjs +93 -0
  32. package/src/components/cacher/options/CacherOptions.mjs +87 -0
  33. package/src/components/cacher/options/FileCacheOptions.cjs +77 -0
  34. package/src/components/cacher/options/FileCacheOptions.mjs +71 -0
  35. package/src/components/cacher/options/MemcacheCacheOptions.cjs +79 -0
  36. package/src/components/cacher/options/MemcacheCacheOptions.mjs +73 -0
  37. package/src/components/cacher/options/MongoCacheOptions.cjs +83 -0
  38. package/src/components/cacher/options/MongoCacheOptions.mjs +77 -0
  39. package/src/components/cacher/options/MysqlCacheOptions.cjs +83 -0
  40. package/src/components/cacher/options/MysqlCacheOptions.mjs +77 -0
  41. package/src/components/cacher/options/PostgresCacheOptions.cjs +87 -0
  42. package/src/components/cacher/options/PostgresCacheOptions.mjs +81 -0
  43. package/src/components/cacher/options/RedisCacheOptions.cjs +99 -0
  44. package/src/components/cacher/options/RedisCacheOptions.mjs +93 -0
  45. package/src/components/cacher/options/SqliteCacheOptions.cjs +77 -0
  46. package/src/components/cacher/options/SqliteCacheOptions.mjs +71 -0
  47. package/src/components/cacher/types/CacheStoreOptions.cjs +1 -0
  48. package/src/components/cacher/types/CacheStoreOptions.mjs +1 -0
  49. package/src/components/docker/ConnectionOptionsBuilder.cjs +19 -13
  50. package/src/components/docker/ConnectionOptionsBuilder.mjs +19 -13
  51. package/src/components/docker/Docker.cjs +19 -13
  52. package/src/components/docker/Docker.mjs +19 -13
  53. package/src/components/docker/lib/DockerContainer.cjs +26 -20
  54. package/src/components/docker/lib/DockerContainer.mjs +20 -14
  55. package/src/components/docker/lib/DockerContainerTTY.cjs +15 -9
  56. package/src/components/docker/lib/DockerContainerTTY.mjs +15 -9
  57. package/src/components/entrypoint/Entrypoint.cjs +1 -1
  58. package/src/components/entrypoint/Entrypoint.mjs +1 -1
  59. package/src/decorators/ctrl/CLIAction.cjs +1 -1
  60. package/src/decorators/ctrl/CLIAction.mjs +1 -1
  61. package/src/decorators/ctrl/HTTPAction.cjs +1 -1
  62. package/src/decorators/ctrl/HTTPAction.mjs +1 -1
  63. package/src/decorators/ctrl/ServiceAction.cjs +1 -1
  64. package/src/decorators/ctrl/ServiceAction.mjs +1 -1
  65. package/src/decorators/ctrl/http/DELETE.cjs +1 -1
  66. package/src/decorators/ctrl/http/DELETE.mjs +1 -1
  67. package/src/decorators/ctrl/http/GET.cjs +1 -1
  68. package/src/decorators/ctrl/http/GET.mjs +1 -1
  69. package/src/decorators/ctrl/http/HEAD.cjs +1 -1
  70. package/src/decorators/ctrl/http/HEAD.mjs +1 -1
  71. package/src/decorators/ctrl/http/OPTIONS.cjs +1 -1
  72. package/src/decorators/ctrl/http/OPTIONS.mjs +1 -1
  73. package/src/decorators/ctrl/http/PATCH.cjs +1 -1
  74. package/src/decorators/ctrl/http/PATCH.mjs +1 -1
  75. package/src/decorators/ctrl/http/POST.cjs +1 -1
  76. package/src/decorators/ctrl/http/POST.mjs +1 -1
  77. package/src/decorators/ctrl/http/PUT.cjs +1 -1
  78. package/src/decorators/ctrl/http/PUT.mjs +1 -1
  79. package/src/decorators/orm/AfterInsert.cjs +6 -2
  80. package/src/decorators/orm/AfterInsert.mjs +13 -9
  81. package/src/decorators/orm/AfterLoad.cjs +6 -2
  82. package/src/decorators/orm/AfterLoad.mjs +16 -12
  83. package/src/decorators/orm/AfterRecover.cjs +6 -2
  84. package/src/decorators/orm/AfterRecover.mjs +10 -6
  85. package/src/decorators/orm/AfterRemove.cjs +6 -2
  86. package/src/decorators/orm/AfterRemove.mjs +10 -6
  87. package/src/decorators/orm/AfterSoftRemove.cjs +6 -2
  88. package/src/decorators/orm/AfterSoftRemove.mjs +10 -6
  89. package/src/decorators/orm/AfterUpdate.cjs +6 -2
  90. package/src/decorators/orm/AfterUpdate.mjs +14 -10
  91. package/src/decorators/orm/BeforeInsert.cjs +6 -2
  92. package/src/decorators/orm/BeforeInsert.mjs +10 -6
  93. package/src/decorators/orm/BeforeRecover.cjs +13 -9
  94. package/src/decorators/orm/BeforeRecover.mjs +6 -2
  95. package/src/decorators/orm/BeforeRemove.cjs +13 -9
  96. package/src/decorators/orm/BeforeRemove.mjs +6 -2
  97. package/src/decorators/orm/BeforeSoftRemove.cjs +10 -6
  98. package/src/decorators/orm/BeforeSoftRemove.mjs +6 -2
  99. package/src/decorators/orm/BeforeUpdate.cjs +6 -2
  100. package/src/decorators/orm/BeforeUpdate.mjs +11 -7
  101. package/src/decorators/orm/Check.cjs +6 -2
  102. package/src/decorators/orm/Check.mjs +6 -2
  103. package/src/decorators/orm/ChildEntity.cjs +11 -7
  104. package/src/decorators/orm/ChildEntity.mjs +6 -2
  105. package/src/decorators/orm/Column.cjs +23 -19
  106. package/src/decorators/orm/Column.mjs +6 -2
  107. package/src/decorators/orm/CreateDateColumn.cjs +8 -4
  108. package/src/decorators/orm/CreateDateColumn.mjs +6 -2
  109. package/src/decorators/orm/DeleteDateColumn.cjs +6 -2
  110. package/src/decorators/orm/DeleteDateColumn.mjs +6 -2
  111. package/src/decorators/orm/Entity.cjs +6 -2
  112. package/src/decorators/orm/Entity.mjs +12 -8
  113. package/src/decorators/orm/EventSubscriber.cjs +6 -2
  114. package/src/decorators/orm/EventSubscriber.mjs +6 -2
  115. package/src/decorators/orm/Exclusion.cjs +6 -2
  116. package/src/decorators/orm/Exclusion.mjs +12 -8
  117. package/src/decorators/orm/Generated.cjs +10 -6
  118. package/src/decorators/orm/Generated.mjs +12 -8
  119. package/src/decorators/orm/Index.cjs +14 -10
  120. package/src/decorators/orm/Index.mjs +24 -20
  121. package/src/decorators/orm/JoinColumn.cjs +6 -2
  122. package/src/decorators/orm/JoinColumn.mjs +6 -2
  123. package/src/decorators/orm/JoinTable.cjs +6 -2
  124. package/src/decorators/orm/JoinTable.mjs +8 -4
  125. package/src/decorators/orm/ManyToMany.cjs +13 -9
  126. package/src/decorators/orm/ManyToMany.mjs +17 -13
  127. package/src/decorators/orm/ManyToOne.cjs +6 -2
  128. package/src/decorators/orm/ManyToOne.mjs +6 -2
  129. package/src/decorators/orm/ObjectIdColumn.cjs +6 -2
  130. package/src/decorators/orm/ObjectIdColumn.mjs +12 -8
  131. package/src/decorators/orm/OneToMany.cjs +14 -10
  132. package/src/decorators/orm/OneToMany.mjs +6 -2
  133. package/src/decorators/orm/OneToOne.cjs +15 -11
  134. package/src/decorators/orm/OneToOne.mjs +13 -9
  135. package/src/decorators/orm/PrimaryColumn.cjs +6 -2
  136. package/src/decorators/orm/PrimaryColumn.mjs +26 -22
  137. package/src/decorators/orm/PrimaryGeneratedColumn.cjs +6 -2
  138. package/src/decorators/orm/PrimaryGeneratedColumn.mjs +8 -4
  139. package/src/decorators/orm/RelationId.cjs +11 -7
  140. package/src/decorators/orm/RelationId.mjs +12 -8
  141. package/src/decorators/orm/TableInheritance.cjs +6 -2
  142. package/src/decorators/orm/TableInheritance.mjs +10 -6
  143. package/src/decorators/orm/Tree.cjs +6 -2
  144. package/src/decorators/orm/Tree.mjs +6 -2
  145. package/src/decorators/orm/TreeChildren.cjs +6 -2
  146. package/src/decorators/orm/TreeChildren.mjs +17 -13
  147. package/src/decorators/orm/TreeLevelColumn.cjs +6 -2
  148. package/src/decorators/orm/TreeLevelColumn.mjs +6 -2
  149. package/src/decorators/orm/TreeParent.cjs +12 -8
  150. package/src/decorators/orm/TreeParent.mjs +6 -2
  151. package/src/decorators/orm/Unique.cjs +6 -2
  152. package/src/decorators/orm/Unique.mjs +6 -2
  153. package/src/decorators/orm/UpdateDateColumn.cjs +8 -4
  154. package/src/decorators/orm/UpdateDateColumn.mjs +6 -2
  155. package/src/decorators/orm/VersionColumn.cjs +6 -2
  156. package/src/decorators/orm/VersionColumn.mjs +6 -2
  157. package/src/decorators/orm/ViewColumn.cjs +6 -2
  158. package/src/decorators/orm/ViewColumn.mjs +6 -2
  159. package/src/decorators/orm/ViewEntity.cjs +8 -4
  160. package/src/decorators/orm/ViewEntity.mjs +6 -2
  161. package/src/decorators/orm/VirtualColumn.cjs +6 -2
  162. package/src/decorators/orm/VirtualColumn.mjs +10 -6
  163. package/src/lib/base/internal/ControllerEntrypoint.cjs +1 -1
  164. package/src/lib/base/internal/ControllerEntrypoint.mjs +1 -1
  165. package/src/lib/core/Application.cjs +11 -7
  166. package/src/lib/core/Application.mjs +7 -3
  167. package/src/lib/core/Module.cjs +1 -1
  168. package/src/lib/core/Module.mjs +1 -1
  169. package/src/lib/helpers/NonceStr.cjs +1 -1
  170. package/src/lib/helpers/NonceStr.mjs +1 -1
  171. package/src/lib/helpers/ObjectHash.cjs +1 -1
  172. package/src/lib/helpers/ObjectHash.mjs +1 -1
  173. package/src/lib/helpers/RandomString.cjs +1 -1
  174. package/src/lib/helpers/RandomString.mjs +1 -1
  175. package/src/providers/Database.cjs +6 -2
  176. package/src/providers/Database.mjs +6 -2
  177. package/vendor/Package.112.cjs +5498 -5500
  178. package/vendor/Package.112.mjs +5504 -5506
  179. package/vendor/Package.12.cjs +4 -80
  180. package/vendor/Package.12.mjs +4 -74
  181. package/vendor/Package.122.cjs +87 -0
  182. package/vendor/Package.122.mjs +79 -0
  183. package/vendor/Package.13.cjs +1 -1
  184. package/vendor/Package.13.mjs +1 -1
  185. package/vendor/Package.14.cjs +1 -14055
  186. package/vendor/Package.14.mjs +1 -14029
  187. package/vendor/Package.15.cjs +12449 -46635
  188. package/vendor/Package.15.mjs +12435 -46611
  189. package/vendor/Package.16.cjs +3 -0
  190. package/vendor/Package.16.mjs +1 -0
  191. package/vendor/Package.17.cjs +48245 -0
  192. package/vendor/Package.17.mjs +48202 -0
  193. package/vendor/Package.18.cjs +3 -0
  194. package/vendor/Package.18.mjs +1 -0
  195. package/vendor/Package.19.cjs +4466 -0
  196. package/vendor/Package.19.mjs +4442 -0
  197. package/vendor/Package.610.cjs +196 -0
  198. package/vendor/Package.610.mjs +180 -0
  199. package/vendor/Package.62.cjs +1 -1
  200. package/vendor/Package.62.mjs +1 -1
  201. package/vendor/Package.65.cjs +860 -0
  202. package/vendor/Package.65.mjs +832 -0
  203. package/vendor/Package.66.cjs +321 -0
  204. package/vendor/Package.66.mjs +305 -0
  205. package/vendor/Package.67.cjs +341 -0
  206. package/vendor/Package.67.mjs +327 -0
  207. package/vendor/Package.68.cjs +333 -0
  208. package/vendor/Package.68.mjs +315 -0
  209. package/vendor/Package.69.cjs +353 -0
  210. package/vendor/Package.69.mjs +335 -0
@@ -0,0 +1,4466 @@
1
+ "use strict";
2
+
3
+ const e = require("./Package.1.cjs");
4
+
5
+ const t = require("events");
6
+
7
+ const r = require("buffer");
8
+
9
+ const n = require("./Package.5.cjs");
10
+
11
+ const i = require("./Package.12.cjs");
12
+
13
+ require("./Package.8.cjs");
14
+
15
+ require("./Package.18.cjs");
16
+
17
+ const s = require("constants");
18
+
19
+ const o = require("stream");
20
+
21
+ require("./Package.10.cjs");
22
+
23
+ require("./Package.16.cjs");
24
+
25
+ const c = require("fs");
26
+
27
+ const a = require("util");
28
+
29
+ const u = require("assert");
30
+
31
+ const f = require("os");
32
+
33
+ const l = require("path");
34
+
35
+ require("./Package.13.cjs");
36
+
37
+ const h = require("../src/components/cacher/options/CacherOptions.cjs");
38
+
39
+ const p = require("../src/lib/core/Component.cjs");
40
+
41
+ const d = require("../src/decorators/di/Configurable.cjs");
42
+
43
+ const y = require("../src/lib/helpers/URLBuilder.cjs");
44
+
45
+ const m = require("../src/lib/helpers/As.cjs");
46
+
47
+ const v = e => e && e.__esModule ? e : {
48
+ default: e
49
+ };
50
+
51
+ const w = v(t);
52
+
53
+ const S = v(r);
54
+
55
+ const g = v(s);
56
+
57
+ const k = v(o);
58
+
59
+ const _ = v(c);
60
+
61
+ const E = v(a);
62
+
63
+ const b = v(u);
64
+
65
+ const x = v(f);
66
+
67
+ const P = v(l);
68
+
69
+ var O = e => {
70
+ if (e === void 0 || e === null) {
71
+ return "null";
72
+ }
73
+ if (typeof e === "string") {
74
+ return JSON.stringify(e.startsWith(":") ? ":" + e : e);
75
+ }
76
+ if (r.Buffer.isBuffer(e)) {
77
+ return JSON.stringify(":base64:" + e.toString("base64"));
78
+ }
79
+ if (e?.toJSON) {
80
+ e = e.toJSON();
81
+ }
82
+ if (typeof e === "object") {
83
+ let t = "";
84
+ const r = Array.isArray(e);
85
+ t = r ? "[" : "{";
86
+ let n = true;
87
+ for (const i in e) {
88
+ const s = typeof e[i] === "function" || !r && e[i] === void 0;
89
+ if (!Object.hasOwn(e, i) || s) {
90
+ continue;
91
+ }
92
+ if (!n) {
93
+ t += ",";
94
+ }
95
+ n = false;
96
+ if (r) {
97
+ t += O(e[i]);
98
+ } else if (e[i] !== void 0) {
99
+ t += O(i) + ":" + O(e[i]);
100
+ }
101
+ }
102
+ t += r ? "]" : "}";
103
+ return t;
104
+ }
105
+ return JSON.stringify(e);
106
+ };
107
+
108
+ var D = e => JSON.parse(e, ((e, t) => {
109
+ if (typeof t === "string") {
110
+ if (t.startsWith(":base64:")) {
111
+ return r.Buffer.from(t.slice(8), "base64");
112
+ }
113
+ return t.startsWith(":") ? t.slice(1) : t;
114
+ }
115
+ return t;
116
+ }));
117
+
118
+ var j = class {
119
+ _eventListeners;
120
+ _maxListeners;
121
+ constructor() {
122
+ this._eventListeners = new Map;
123
+ this._maxListeners = 100;
124
+ }
125
+ maxListeners() {
126
+ return this._maxListeners;
127
+ }
128
+ addListener(e, t) {
129
+ this.on(e, t);
130
+ }
131
+ on(e, t) {
132
+ if (!this._eventListeners.has(e)) {
133
+ this._eventListeners.set(e, []);
134
+ }
135
+ const r = this._eventListeners.get(e);
136
+ if (r) {
137
+ if (r.length >= this._maxListeners) {
138
+ console.warn(`MaxListenersExceededWarning: Possible event memory leak detected. ${r.length + 1} ${e} listeners added. Use setMaxListeners() to increase limit.`);
139
+ }
140
+ r.push(t);
141
+ }
142
+ return this;
143
+ }
144
+ removeListener(e, t) {
145
+ this.off(e, t);
146
+ }
147
+ off(e, t) {
148
+ const r = this._eventListeners.get(e) ?? [];
149
+ const n = r.indexOf(t);
150
+ if (n !== -1) {
151
+ r.splice(n, 1);
152
+ }
153
+ if (r.length === 0) {
154
+ this._eventListeners.delete(e);
155
+ }
156
+ }
157
+ once(e, t) {
158
+ const r = (...n) => {
159
+ t(...n);
160
+ this.off(e, r);
161
+ };
162
+ this.on(e, r);
163
+ }
164
+ emit(e, ...t) {
165
+ const r = this._eventListeners.get(e);
166
+ if (r && r.length > 0) {
167
+ for (const e of r) {
168
+ e(...t);
169
+ }
170
+ }
171
+ }
172
+ listeners(e) {
173
+ return this._eventListeners.get(e) ?? [];
174
+ }
175
+ removeAllListeners(e) {
176
+ if (e) {
177
+ this._eventListeners.delete(e);
178
+ } else {
179
+ this._eventListeners.clear();
180
+ }
181
+ }
182
+ setMaxListeners(e) {
183
+ this._maxListeners = e;
184
+ }
185
+ };
186
+
187
+ var M = j;
188
+
189
+ var F = class extends M {
190
+ _hookHandlers;
191
+ constructor() {
192
+ super();
193
+ this._hookHandlers = new Map;
194
+ }
195
+ addHandler(e, t) {
196
+ const r = this._hookHandlers.get(e);
197
+ if (r) {
198
+ r.push(t);
199
+ } else {
200
+ this._hookHandlers.set(e, [ t ]);
201
+ }
202
+ }
203
+ removeHandler(e, t) {
204
+ const r = this._hookHandlers.get(e);
205
+ if (r) {
206
+ const e = r.indexOf(t);
207
+ if (e !== -1) {
208
+ r.splice(e, 1);
209
+ }
210
+ }
211
+ }
212
+ trigger(e, t) {
213
+ const r = this._hookHandlers.get(e);
214
+ if (r) {
215
+ for (const n of r) {
216
+ try {
217
+ n(t);
218
+ } catch (t) {
219
+ this.emit("error", new Error(`Error in hook handler for event "${e}": ${t.message}`));
220
+ }
221
+ }
222
+ }
223
+ }
224
+ get handlers() {
225
+ return new Map(this._hookHandlers);
226
+ }
227
+ };
228
+
229
+ var N = F;
230
+
231
+ var T = class extends M {
232
+ enabled=true;
233
+ hits=0;
234
+ misses=0;
235
+ sets=0;
236
+ deletes=0;
237
+ errors=0;
238
+ constructor(e) {
239
+ super();
240
+ if (e !== void 0) {
241
+ this.enabled = e;
242
+ }
243
+ this.reset();
244
+ }
245
+ hit() {
246
+ if (this.enabled) {
247
+ this.hits++;
248
+ }
249
+ }
250
+ miss() {
251
+ if (this.enabled) {
252
+ this.misses++;
253
+ }
254
+ }
255
+ set() {
256
+ if (this.enabled) {
257
+ this.sets++;
258
+ }
259
+ }
260
+ delete() {
261
+ if (this.enabled) {
262
+ this.deletes++;
263
+ }
264
+ }
265
+ reset() {
266
+ this.hits = 0;
267
+ this.misses = 0;
268
+ this.sets = 0;
269
+ this.deletes = 0;
270
+ this.errors = 0;
271
+ }
272
+ };
273
+
274
+ var L = T;
275
+
276
+ var R = (e => {
277
+ e["PRE_SET"] = "preSet";
278
+ e["POST_SET"] = "postSet";
279
+ e["PRE_GET"] = "preGet";
280
+ e["POST_GET"] = "postGet";
281
+ e["PRE_GET_MANY"] = "preGetMany";
282
+ e["POST_GET_MANY"] = "postGetMany";
283
+ e["PRE_DELETE"] = "preDelete";
284
+ e["POST_DELETE"] = "postDelete";
285
+ return e;
286
+ })(R || {});
287
+
288
+ var q = [ "sqlite", "postgres", "mysql", "mongo", "redis", "valkey", "etcd" ];
289
+
290
+ var I = class extends M {
291
+ opts;
292
+ iterator;
293
+ hooks=new N;
294
+ stats=new L(false);
295
+ _ttl;
296
+ _namespace;
297
+ _store=new Map;
298
+ _serialize=O;
299
+ _deserialize=D;
300
+ _compression;
301
+ _useKeyPrefix=true;
302
+ constructor(e, t) {
303
+ super();
304
+ t ??= {};
305
+ e ??= {};
306
+ this.opts = {
307
+ namespace: "keyv",
308
+ serialize: O,
309
+ deserialize: D,
310
+ emitErrors: true,
311
+ store: new Map,
312
+ ...t
313
+ };
314
+ if (e && e.get) {
315
+ this.opts.store = e;
316
+ } else {
317
+ this.opts = {
318
+ ...this.opts,
319
+ ...e
320
+ };
321
+ }
322
+ this._store = this.opts.store ?? new Map;
323
+ this._compression = this.opts.compression;
324
+ this._serialize = this.opts.serialize;
325
+ this._deserialize = this.opts.deserialize;
326
+ if (this.opts.namespace) {
327
+ this._namespace = this.opts.namespace;
328
+ }
329
+ if (this._store) {
330
+ if (!this._isValidStorageAdapter(this._store)) {
331
+ throw new Error("Invalid storage adapter");
332
+ }
333
+ if (typeof this._store.on === "function") {
334
+ this._store.on("error", (e => this.emit("error", e)));
335
+ }
336
+ this._store.namespace = this._namespace;
337
+ if (typeof this._store[Symbol.iterator] === "function" && this._store instanceof Map) {
338
+ this.iterator = this.generateIterator(this._store);
339
+ } else if ("iterator" in this._store && this._store.opts && this._checkIterableAdapter()) {
340
+ this.iterator = this.generateIterator(this._store.iterator.bind(this._store));
341
+ }
342
+ }
343
+ if (this.opts.stats) {
344
+ this.stats.enabled = this.opts.stats;
345
+ }
346
+ if (this.opts.ttl) {
347
+ this._ttl = this.opts.ttl;
348
+ }
349
+ if (this.opts.useKeyPrefix !== void 0) {
350
+ this._useKeyPrefix = this.opts.useKeyPrefix;
351
+ }
352
+ }
353
+ get store() {
354
+ return this._store;
355
+ }
356
+ set store(e) {
357
+ if (this._isValidStorageAdapter(e)) {
358
+ this._store = e;
359
+ this.opts.store = e;
360
+ if (typeof e.on === "function") {
361
+ e.on("error", (e => this.emit("error", e)));
362
+ }
363
+ if (this._namespace) {
364
+ this._store.namespace = this._namespace;
365
+ }
366
+ if (typeof e[Symbol.iterator] === "function" && e instanceof Map) {
367
+ this.iterator = this.generateIterator(e);
368
+ } else if ("iterator" in e && e.opts && this._checkIterableAdapter()) {
369
+ this.iterator = this.generateIterator(e.iterator.bind(e));
370
+ }
371
+ } else {
372
+ throw new Error("Invalid storage adapter");
373
+ }
374
+ }
375
+ get compression() {
376
+ return this._compression;
377
+ }
378
+ set compression(e) {
379
+ this._compression = e;
380
+ }
381
+ get namespace() {
382
+ return this._namespace;
383
+ }
384
+ set namespace(e) {
385
+ this._namespace = e;
386
+ this.opts.namespace = e;
387
+ this._store.namespace = e;
388
+ if (this.opts.store) {
389
+ this.opts.store.namespace = e;
390
+ }
391
+ }
392
+ get ttl() {
393
+ return this._ttl;
394
+ }
395
+ set ttl(e) {
396
+ this.opts.ttl = e;
397
+ this._ttl = e;
398
+ }
399
+ get serialize() {
400
+ return this._serialize;
401
+ }
402
+ set serialize(e) {
403
+ this.opts.serialize = e;
404
+ this._serialize = e;
405
+ }
406
+ get deserialize() {
407
+ return this._deserialize;
408
+ }
409
+ set deserialize(e) {
410
+ this.opts.deserialize = e;
411
+ this._deserialize = e;
412
+ }
413
+ get useKeyPrefix() {
414
+ return this._useKeyPrefix;
415
+ }
416
+ set useKeyPrefix(e) {
417
+ this._useKeyPrefix = e;
418
+ this.opts.useKeyPrefix = e;
419
+ }
420
+ generateIterator(e) {
421
+ const t = async function*() {
422
+ for await (const [t, r] of typeof e === "function" ? e(this._store.namespace) : e) {
423
+ const e = await this.deserializeData(r);
424
+ if (this._useKeyPrefix && this._store.namespace && !t.includes(this._store.namespace)) {
425
+ continue;
426
+ }
427
+ if (typeof e.expires === "number" && Date.now() > e.expires) {
428
+ this.delete(t);
429
+ continue;
430
+ }
431
+ yield [ this._getKeyUnprefix(t), e.value ];
432
+ }
433
+ };
434
+ return t.bind(this);
435
+ }
436
+ _checkIterableAdapter() {
437
+ return q.includes(this._store.opts.dialect) || q.some((e => this._store.opts.url.includes(e)));
438
+ }
439
+ _getKeyPrefix(e) {
440
+ if (!this._useKeyPrefix) {
441
+ return e;
442
+ }
443
+ if (!this._namespace) {
444
+ return e;
445
+ }
446
+ return `${this._namespace}:${e}`;
447
+ }
448
+ _getKeyPrefixArray(e) {
449
+ if (!this._useKeyPrefix) {
450
+ return e;
451
+ }
452
+ if (!this._namespace) {
453
+ return e;
454
+ }
455
+ return e.map((e => `${this._namespace}:${e}`));
456
+ }
457
+ _getKeyUnprefix(e) {
458
+ if (!this._useKeyPrefix) {
459
+ return e;
460
+ }
461
+ return e.split(":").splice(1).join(":");
462
+ }
463
+ _isValidStorageAdapter(e) {
464
+ return e instanceof Map || typeof e.get === "function" && typeof e.set === "function" && typeof e.delete === "function" && typeof e.clear === "function";
465
+ }
466
+ async get(e, t) {
467
+ const {store: r} = this.opts;
468
+ const n = Array.isArray(e);
469
+ const i = n ? this._getKeyPrefixArray(e) : this._getKeyPrefix(e);
470
+ const s = e => typeof e.expires === "number" && Date.now() > e.expires;
471
+ if (n) {
472
+ if (t?.raw === true) {
473
+ return this.getMany(e, {
474
+ raw: true
475
+ });
476
+ }
477
+ return this.getMany(e, {
478
+ raw: false
479
+ });
480
+ }
481
+ this.hooks.trigger("preGet", {
482
+ key: i
483
+ });
484
+ const o = await r.get(i);
485
+ const c = typeof o === "string" || this.opts.compression ? await this.deserializeData(o) : o;
486
+ if (c === void 0 || c === null) {
487
+ this.stats.miss();
488
+ return void 0;
489
+ }
490
+ if (s(c)) {
491
+ await this.delete(e);
492
+ this.stats.miss();
493
+ return void 0;
494
+ }
495
+ this.hooks.trigger("postGet", {
496
+ key: i,
497
+ value: c
498
+ });
499
+ this.stats.hit();
500
+ return t?.raw ? c : c.value;
501
+ }
502
+ async getMany(e, t) {
503
+ const {store: r} = this.opts;
504
+ const n = this._getKeyPrefixArray(e);
505
+ const i = e => typeof e.expires === "number" && Date.now() > e.expires;
506
+ this.hooks.trigger("preGetMany", {
507
+ keys: n
508
+ });
509
+ if (r.getMany === void 0) {
510
+ const e = n.map((async e => {
511
+ const n = await r.get(e);
512
+ const s = typeof n === "string" || this.opts.compression ? await this.deserializeData(n) : n;
513
+ if (s === void 0 || s === null) {
514
+ return void 0;
515
+ }
516
+ if (i(s)) {
517
+ await this.delete(e);
518
+ return void 0;
519
+ }
520
+ return t?.raw ? s : s.value;
521
+ }));
522
+ const s = await Promise.allSettled(e);
523
+ const o = s.map((e => e.value));
524
+ this.hooks.trigger("postGetMany", o);
525
+ if (o.length > 0) {
526
+ this.stats.hit();
527
+ }
528
+ return o;
529
+ }
530
+ const s = await r.getMany(n);
531
+ const o = [];
532
+ for (const r in s) {
533
+ let n = s[r];
534
+ if (typeof n === "string") {
535
+ n = await this.deserializeData(n);
536
+ }
537
+ if (n === void 0 || n === null) {
538
+ o.push(void 0);
539
+ continue;
540
+ }
541
+ if (i(n)) {
542
+ await this.delete(e[r]);
543
+ o.push(void 0);
544
+ continue;
545
+ }
546
+ const c = t?.raw ? n : n.value;
547
+ o.push(c);
548
+ }
549
+ this.hooks.trigger("postGetMany", o);
550
+ if (o.length > 0) {
551
+ this.stats.hit();
552
+ }
553
+ return o;
554
+ }
555
+ async set(e, t, r) {
556
+ const n = {
557
+ key: e,
558
+ value: t,
559
+ ttl: r
560
+ };
561
+ this.hooks.trigger("preSet", n);
562
+ const i = this._getKeyPrefix(n.key);
563
+ n.ttl ??= this._ttl;
564
+ if (n.ttl === 0) {
565
+ n.ttl = void 0;
566
+ }
567
+ const {store: s} = this.opts;
568
+ const o = typeof n.ttl === "number" ? Date.now() + n.ttl : void 0;
569
+ if (typeof n.value === "symbol") {
570
+ this.emit("error", "symbol cannot be serialized");
571
+ throw new Error("symbol cannot be serialized");
572
+ }
573
+ const c = {
574
+ value: n.value,
575
+ expires: o
576
+ };
577
+ const a = await this.serializeData(c);
578
+ let u = true;
579
+ try {
580
+ const e = await s.set(i, a, n.ttl);
581
+ if (typeof e === "boolean") {
582
+ u = e;
583
+ }
584
+ } catch (e) {
585
+ u = false;
586
+ this.emit("error", e);
587
+ }
588
+ this.hooks.trigger("postSet", {
589
+ key: i,
590
+ value: a,
591
+ ttl: r
592
+ });
593
+ this.stats.set();
594
+ return u;
595
+ }
596
+ async setMany(e) {
597
+ let t = [];
598
+ try {
599
+ if (this._store.setMany !== void 0) {
600
+ const r = await Promise.all(e.map((async ({key: e, value: t, ttl: r}) => {
601
+ r ??= this._ttl;
602
+ if (r === 0) {
603
+ r = void 0;
604
+ }
605
+ const n = typeof r === "number" ? Date.now() + r : void 0;
606
+ if (typeof t === "symbol") {
607
+ this.emit("error", "symbol cannot be serialized");
608
+ throw new Error("symbol cannot be serialized");
609
+ }
610
+ const i = {
611
+ value: t,
612
+ expires: n
613
+ };
614
+ const s = await this.serializeData(i);
615
+ return {
616
+ key: e,
617
+ value: s,
618
+ ttl: r
619
+ };
620
+ })));
621
+ t = await this._store.setMany(r);
622
+ }
623
+ const r = [];
624
+ for (const t of e) {
625
+ r.push(this.set(t.key, t.value, t.ttl));
626
+ }
627
+ const n = await Promise.allSettled(r);
628
+ t = n.map((e => e.value));
629
+ } catch (r) {
630
+ this.emit("error", r);
631
+ t = e.map((() => false));
632
+ }
633
+ return t;
634
+ }
635
+ async delete(e) {
636
+ const {store: t} = this.opts;
637
+ if (Array.isArray(e)) {
638
+ return this.deleteMany(e);
639
+ }
640
+ const r = this._getKeyPrefix(e);
641
+ this.hooks.trigger("preDelete", {
642
+ key: r
643
+ });
644
+ let n = true;
645
+ try {
646
+ const e = await t.delete(r);
647
+ if (typeof e === "boolean") {
648
+ n = e;
649
+ }
650
+ } catch (e) {
651
+ n = false;
652
+ this.emit("error", e);
653
+ }
654
+ this.hooks.trigger("postDelete", {
655
+ key: r,
656
+ value: n
657
+ });
658
+ this.stats.delete();
659
+ return n;
660
+ }
661
+ async deleteMany(e) {
662
+ try {
663
+ const {store: t} = this.opts;
664
+ const r = this._getKeyPrefixArray(e);
665
+ this.hooks.trigger("preDelete", {
666
+ key: r
667
+ });
668
+ if (t.deleteMany !== void 0) {
669
+ return await t.deleteMany(r);
670
+ }
671
+ const n = r.map((async e => t.delete(e)));
672
+ const i = await Promise.allSettled(n);
673
+ const s = i.every((e => e.value === true));
674
+ this.hooks.trigger("postDelete", {
675
+ key: r,
676
+ value: s
677
+ });
678
+ return s;
679
+ } catch (e) {
680
+ this.emit("error", e);
681
+ return false;
682
+ }
683
+ }
684
+ async clear() {
685
+ this.emit("clear");
686
+ const {store: e} = this.opts;
687
+ try {
688
+ await e.clear();
689
+ } catch (e) {
690
+ this.emit("error", e);
691
+ }
692
+ }
693
+ async has(e) {
694
+ if (Array.isArray(e)) {
695
+ return this.hasMany(e);
696
+ }
697
+ const t = this._getKeyPrefix(e);
698
+ const {store: r} = this.opts;
699
+ if (r.has !== void 0 && !(r instanceof Map)) {
700
+ return r.has(t);
701
+ }
702
+ let n;
703
+ try {
704
+ n = await r.get(t);
705
+ } catch (e) {
706
+ this.emit("error", e);
707
+ }
708
+ if (n) {
709
+ const e = await this.deserializeData(n);
710
+ if (e) {
711
+ if (e.expires === void 0 || e.expires === null) {
712
+ return true;
713
+ }
714
+ return e.expires > Date.now();
715
+ }
716
+ }
717
+ return false;
718
+ }
719
+ async hasMany(e) {
720
+ const t = this._getKeyPrefixArray(e);
721
+ const {store: r} = this.opts;
722
+ if (r.hasMany !== void 0) {
723
+ return r.hasMany(t);
724
+ }
725
+ const n = [];
726
+ for (const e of t) {
727
+ n.push(await this.has(e));
728
+ }
729
+ return n;
730
+ }
731
+ async disconnect() {
732
+ const {store: e} = this.opts;
733
+ this.emit("disconnect");
734
+ if (typeof e.disconnect === "function") {
735
+ return e.disconnect();
736
+ }
737
+ }
738
+ emit(e, ...t) {
739
+ if (e === "error" && !this.opts.emitErrors) {
740
+ return;
741
+ }
742
+ super.emit(e, ...t);
743
+ }
744
+ async serializeData(e) {
745
+ if (!this._serialize) {
746
+ return e;
747
+ }
748
+ if (this._compression?.compress) {
749
+ return this._serialize({
750
+ value: await this._compression.compress(e.value),
751
+ expires: e.expires
752
+ });
753
+ }
754
+ return this._serialize(e);
755
+ }
756
+ async deserializeData(e) {
757
+ if (!this._deserialize) {
758
+ return e;
759
+ }
760
+ if (this._compression?.decompress && typeof e === "string") {
761
+ const t = await this._deserialize(e);
762
+ return {
763
+ value: await this._compression.decompress(t?.value),
764
+ expires: t?.expires
765
+ };
766
+ }
767
+ if (typeof e === "string") {
768
+ return this._deserialize(e);
769
+ }
770
+ return void 0;
771
+ }
772
+ };
773
+
774
+ var z = I;
775
+
776
+ var A = new Map;
777
+
778
+ function C(e) {
779
+ return A.has(e);
780
+ }
781
+
782
+ function K(e) {
783
+ A.set(e, []);
784
+ }
785
+
786
+ function J(e) {
787
+ A.delete(e);
788
+ }
789
+
790
+ function B(e, t) {
791
+ const r = $(e);
792
+ r.push(t);
793
+ A.set(e, r);
794
+ }
795
+
796
+ function $(e) {
797
+ return A.get(e) ?? [];
798
+ }
799
+
800
+ async function G(e) {
801
+ return new Promise(((t, r) => {
802
+ const n = {
803
+ resolve: t,
804
+ reject: r
805
+ };
806
+ B(e, n);
807
+ }));
808
+ }
809
+
810
+ function W(e) {
811
+ const t = $(e);
812
+ J(e);
813
+ return t;
814
+ }
815
+
816
+ function U(e) {
817
+ const {key: t, error: r, result: n} = e;
818
+ for (const e of W(t)) {
819
+ if (r) {
820
+ e.reject(r);
821
+ } else {
822
+ e.resolve(n);
823
+ }
824
+ }
825
+ }
826
+
827
+ async function Y(e, t) {
828
+ if (!C(e)) {
829
+ K(e);
830
+ try {
831
+ const r = await Promise.resolve(t());
832
+ U({
833
+ key: e,
834
+ result: r
835
+ });
836
+ return r;
837
+ } catch (t) {
838
+ U({
839
+ key: e,
840
+ error: t
841
+ });
842
+ throw t;
843
+ }
844
+ }
845
+ return G(e);
846
+ }
847
+
848
+ function H(e) {
849
+ return e !== null && typeof e === "object" && !Array.isArray(e);
850
+ }
851
+
852
+ function V(e, ...t) {
853
+ return typeof e === "function" ? e(...t) : e;
854
+ }
855
+
856
+ function X(e, t) {
857
+ return typeof e === "number" && typeof t === "number" ? e < t : false;
858
+ }
859
+
860
+ var Q = class {
861
+ opts;
862
+ namespace;
863
+ _cache;
864
+ constructor(e) {
865
+ this._cache = e;
866
+ }
867
+ async get(e) {
868
+ const t = await this._cache.get(e);
869
+ if (t !== void 0 && t !== null) {
870
+ return t;
871
+ }
872
+ return void 0;
873
+ }
874
+ async set(e, t, r) {
875
+ await this._cache.set(e, t, r);
876
+ return true;
877
+ }
878
+ async delete(e) {
879
+ await this._cache.del(e);
880
+ return true;
881
+ }
882
+ async clear() {
883
+ return this._cache.reset?.();
884
+ }
885
+ async has(e) {
886
+ const t = await this._cache.get(e);
887
+ if (t) {
888
+ return true;
889
+ }
890
+ return false;
891
+ }
892
+ async getMany(e) {
893
+ return this._cache.mget(...e).then((e => e.map((e => e))));
894
+ }
895
+ async deleteMany(e) {
896
+ await this._cache.mdel(...e);
897
+ return true;
898
+ }
899
+ on(e, t) {
900
+ this._cache.on?.(e, t);
901
+ return this;
902
+ }
903
+ async disconnect() {
904
+ await (this._cache.disconnect?.());
905
+ }
906
+ };
907
+
908
+ var Z = e => {
909
+ const t = new w.default;
910
+ const r = new I;
911
+ r.serialize = void 0;
912
+ r.deserialize = void 0;
913
+ const n = e?.stores?.length ? e.stores : [ r ];
914
+ const i = e?.nonBlocking ?? false;
915
+ const s = e?.cacheId ?? Math.random().toString(36).slice(2);
916
+ const o = async e => {
917
+ let r;
918
+ if (i) {
919
+ try {
920
+ r = await Promise.race(n.map((async t => t.get(e))));
921
+ if (r === void 0) {
922
+ return void 0;
923
+ }
924
+ } catch (r) {
925
+ t.emit("get", {
926
+ key: e,
927
+ error: r
928
+ });
929
+ }
930
+ } else {
931
+ for (const i of n) {
932
+ try {
933
+ const n = await i.get(e);
934
+ if (n !== void 0) {
935
+ r = n;
936
+ t.emit("get", {
937
+ key: e,
938
+ value: r
939
+ });
940
+ break;
941
+ }
942
+ } catch (r) {
943
+ t.emit("get", {
944
+ key: e,
945
+ error: r
946
+ });
947
+ }
948
+ }
949
+ }
950
+ return r;
951
+ };
952
+ const c = async e => {
953
+ const t = [];
954
+ for (const r of e) {
955
+ const e = await o(r);
956
+ t.push(e);
957
+ }
958
+ return t;
959
+ };
960
+ const a = async e => {
961
+ let r;
962
+ if (i) {
963
+ try {
964
+ r = await Promise.race(n.map((async t => t.get(e, {
965
+ raw: true
966
+ }))));
967
+ if (r === void 0) {
968
+ return void 0;
969
+ }
970
+ } catch (r) {
971
+ t.emit("ttl", {
972
+ key: e,
973
+ error: r
974
+ });
975
+ }
976
+ } else {
977
+ for (const i of n) {
978
+ try {
979
+ const n = await i.get(e, {
980
+ raw: true
981
+ });
982
+ if (n !== void 0) {
983
+ r = n;
984
+ t.emit("ttl", {
985
+ key: e,
986
+ value: r
987
+ });
988
+ break;
989
+ }
990
+ } catch (r) {
991
+ t.emit("ttl", {
992
+ key: e,
993
+ error: r
994
+ });
995
+ }
996
+ }
997
+ }
998
+ if (r?.expires) {
999
+ return r.expires;
1000
+ }
1001
+ return void 0;
1002
+ };
1003
+ const u = async (r, n, s, o) => {
1004
+ try {
1005
+ if (i) {
1006
+ Promise.all(r.map((async t => t.set(n, s, o ?? e?.ttl))));
1007
+ t.emit("set", {
1008
+ key: n,
1009
+ value: s
1010
+ });
1011
+ return s;
1012
+ }
1013
+ await Promise.all(r.map((async t => t.set(n, s, o ?? e?.ttl))));
1014
+ t.emit("set", {
1015
+ key: n,
1016
+ value: s
1017
+ });
1018
+ return s;
1019
+ } catch (e) {
1020
+ t.emit("set", {
1021
+ key: n,
1022
+ value: s,
1023
+ error: e
1024
+ });
1025
+ return Promise.reject(e);
1026
+ }
1027
+ };
1028
+ const f = async (e, r) => {
1029
+ const n = r.map((({key: e, value: t, ttl: r}) => ({
1030
+ key: e,
1031
+ value: t,
1032
+ ttl: r
1033
+ })));
1034
+ try {
1035
+ const n = [];
1036
+ for (const t of r) {
1037
+ n.push(...e.map((async e => e.set(t.key, t.value, t.ttl))));
1038
+ }
1039
+ if (i) {
1040
+ Promise.all(n);
1041
+ t.emit("mset", {
1042
+ list: r
1043
+ });
1044
+ return r;
1045
+ }
1046
+ await Promise.all(n);
1047
+ t.emit("mset", {
1048
+ list: r
1049
+ });
1050
+ return r;
1051
+ } catch (e) {
1052
+ t.emit("mset", {
1053
+ list: r,
1054
+ error: e
1055
+ });
1056
+ return Promise.reject(e);
1057
+ }
1058
+ };
1059
+ const l = async e => {
1060
+ try {
1061
+ if (i) {
1062
+ Promise.all(n.map((async t => t.delete(e))));
1063
+ t.emit("del", {
1064
+ key: e
1065
+ });
1066
+ return true;
1067
+ }
1068
+ await Promise.all(n.map((async t => t.delete(e))));
1069
+ t.emit("del", {
1070
+ key: e
1071
+ });
1072
+ return true;
1073
+ } catch (r) {
1074
+ t.emit("del", {
1075
+ key: e,
1076
+ error: r
1077
+ });
1078
+ return Promise.reject(r);
1079
+ }
1080
+ };
1081
+ const h = async e => {
1082
+ try {
1083
+ const r = [];
1084
+ for (const t of e) {
1085
+ r.push(...n.map((async e => e.delete(t))));
1086
+ }
1087
+ if (i) {
1088
+ Promise.all(r);
1089
+ t.emit("mdel", {
1090
+ keys: e
1091
+ });
1092
+ return true;
1093
+ }
1094
+ await Promise.all(r);
1095
+ t.emit("mdel", {
1096
+ keys: e
1097
+ });
1098
+ return true;
1099
+ } catch (r) {
1100
+ t.emit("mdel", {
1101
+ keys: e,
1102
+ error: r
1103
+ });
1104
+ return Promise.reject(r);
1105
+ }
1106
+ };
1107
+ const p = async () => {
1108
+ try {
1109
+ if (i) {
1110
+ Promise.all(n.map((async e => e.clear())));
1111
+ t.emit("clear");
1112
+ return true;
1113
+ }
1114
+ await Promise.all(n.map((async e => e.clear())));
1115
+ t.emit("clear");
1116
+ return true;
1117
+ } catch (e) {
1118
+ t.emit("clear", e);
1119
+ return Promise.reject(e);
1120
+ }
1121
+ };
1122
+ const d = async (r, i, o, c) => Y(`${s}::${r}`, (async () => {
1123
+ let a;
1124
+ let f;
1125
+ let l = 0;
1126
+ let h;
1127
+ const {ttl: p, refreshThreshold: d, raw: y} = H(o) ? o : {
1128
+ ttl: o,
1129
+ refreshThreshold: c
1130
+ };
1131
+ const m = t => V(p, t) ?? e?.ttl;
1132
+ for (;l < n.length; l++) {
1133
+ try {
1134
+ const e = await n[l].get(r, {
1135
+ raw: true
1136
+ });
1137
+ if (e !== void 0) {
1138
+ a = e.value;
1139
+ f = e;
1140
+ if (typeof e.expires === "number") {
1141
+ h = Math.max(0, e.expires - Date.now());
1142
+ }
1143
+ break;
1144
+ }
1145
+ } catch {}
1146
+ }
1147
+ if (a === void 0) {
1148
+ const e = await i();
1149
+ const t = m(e);
1150
+ await u(n, r, e, t);
1151
+ return y ? {
1152
+ value: e,
1153
+ expires: Date.now() + t
1154
+ } : e;
1155
+ }
1156
+ const v = X(h, V(d, a) ?? e?.refreshThreshold);
1157
+ if (v) {
1158
+ Y(`+++${s}__${r}`, i).then((async i => {
1159
+ try {
1160
+ await u(e?.refreshAllStores ? n : n.slice(0, l + 1), r, i, m(i));
1161
+ t.emit("refresh", {
1162
+ key: r,
1163
+ value: i
1164
+ });
1165
+ } catch (e) {
1166
+ t.emit("refresh", {
1167
+ key: r,
1168
+ value: a,
1169
+ error: e
1170
+ });
1171
+ }
1172
+ })).catch((e => {
1173
+ t.emit("refresh", {
1174
+ key: r,
1175
+ value: a,
1176
+ error: e
1177
+ });
1178
+ }));
1179
+ }
1180
+ if (!v && l > 0) {
1181
+ await u(n.slice(0, l), r, a, m(a));
1182
+ }
1183
+ return y ? f : a;
1184
+ }));
1185
+ const y = (e, r) => t.addListener(e, r);
1186
+ const m = (e, r) => t.removeListener(e, r);
1187
+ const v = async () => {
1188
+ try {
1189
+ await Promise.all(n.map((async e => e.disconnect())));
1190
+ } catch (e) {
1191
+ return Promise.reject(e);
1192
+ }
1193
+ };
1194
+ const S = () => s;
1195
+ return {
1196
+ get: o,
1197
+ mget: c,
1198
+ ttl: a,
1199
+ set: async (e, t, r) => u(n, e, t, r),
1200
+ mset: async e => f(n, e),
1201
+ del: l,
1202
+ mdel: h,
1203
+ clear: p,
1204
+ wrap: d,
1205
+ on: y,
1206
+ off: m,
1207
+ disconnect: v,
1208
+ cacheId: S,
1209
+ stores: n
1210
+ };
1211
+ };
1212
+
1213
+ var ee = {};
1214
+
1215
+ var te;
1216
+
1217
+ var re;
1218
+
1219
+ function ne() {
1220
+ if (re) return te;
1221
+ re = 1;
1222
+ "use strict";
1223
+ function e() {
1224
+ const e = [].slice.call(arguments).filter((e => e));
1225
+ const t = e.shift();
1226
+ e.forEach((e => {
1227
+ Object.keys(e).forEach((r => {
1228
+ t[r] = e[r];
1229
+ }));
1230
+ }));
1231
+ return t;
1232
+ }
1233
+ te = e;
1234
+ return te;
1235
+ }
1236
+
1237
+ var ie = {};
1238
+
1239
+ var se = {};
1240
+
1241
+ var oe;
1242
+
1243
+ function ce() {
1244
+ if (oe) return se;
1245
+ oe = 1;
1246
+ "use strict";
1247
+ se.fromCallback = function(e) {
1248
+ return Object.defineProperty((function() {
1249
+ if (typeof arguments[arguments.length - 1] === "function") e.apply(this, arguments); else {
1250
+ return new Promise(((t, r) => {
1251
+ arguments[arguments.length] = (e, n) => {
1252
+ if (e) return r(e);
1253
+ t(n);
1254
+ };
1255
+ arguments.length++;
1256
+ e.apply(this, arguments);
1257
+ }));
1258
+ }
1259
+ }), "name", {
1260
+ value: e.name
1261
+ });
1262
+ };
1263
+ se.fromPromise = function(e) {
1264
+ return Object.defineProperty((function() {
1265
+ const t = arguments[arguments.length - 1];
1266
+ if (typeof t !== "function") return e.apply(this, arguments); else e.apply(this, arguments).then((e => t(null, e)), t);
1267
+ }), "name", {
1268
+ value: e.name
1269
+ });
1270
+ };
1271
+ return se;
1272
+ }
1273
+
1274
+ var ae;
1275
+
1276
+ var ue;
1277
+
1278
+ function fe() {
1279
+ if (ue) return ae;
1280
+ ue = 1;
1281
+ var e = g.default;
1282
+ var t = process.cwd;
1283
+ var r = null;
1284
+ var n = process.env.GRACEFUL_FS_PLATFORM || process.platform;
1285
+ process.cwd = function() {
1286
+ if (!r) r = t.call(process);
1287
+ return r;
1288
+ };
1289
+ try {
1290
+ process.cwd();
1291
+ } catch (e) {}
1292
+ if (typeof process.chdir === "function") {
1293
+ var i = process.chdir;
1294
+ process.chdir = function(e) {
1295
+ r = null;
1296
+ i.call(process, e);
1297
+ };
1298
+ if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, i);
1299
+ }
1300
+ ae = s;
1301
+ function s(t) {
1302
+ if (e.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) {
1303
+ r(t);
1304
+ }
1305
+ if (!t.lutimes) {
1306
+ i(t);
1307
+ }
1308
+ t.chown = c(t.chown);
1309
+ t.fchown = c(t.fchown);
1310
+ t.lchown = c(t.lchown);
1311
+ t.chmod = s(t.chmod);
1312
+ t.fchmod = s(t.fchmod);
1313
+ t.lchmod = s(t.lchmod);
1314
+ t.chownSync = a(t.chownSync);
1315
+ t.fchownSync = a(t.fchownSync);
1316
+ t.lchownSync = a(t.lchownSync);
1317
+ t.chmodSync = o(t.chmodSync);
1318
+ t.fchmodSync = o(t.fchmodSync);
1319
+ t.lchmodSync = o(t.lchmodSync);
1320
+ t.stat = u(t.stat);
1321
+ t.fstat = u(t.fstat);
1322
+ t.lstat = u(t.lstat);
1323
+ t.statSync = f(t.statSync);
1324
+ t.fstatSync = f(t.fstatSync);
1325
+ t.lstatSync = f(t.lstatSync);
1326
+ if (t.chmod && !t.lchmod) {
1327
+ t.lchmod = function(e, t, r) {
1328
+ if (r) process.nextTick(r);
1329
+ };
1330
+ t.lchmodSync = function() {};
1331
+ }
1332
+ if (t.chown && !t.lchown) {
1333
+ t.lchown = function(e, t, r, n) {
1334
+ if (n) process.nextTick(n);
1335
+ };
1336
+ t.lchownSync = function() {};
1337
+ }
1338
+ if (n === "win32") {
1339
+ t.rename = typeof t.rename !== "function" ? t.rename : function(e) {
1340
+ function r(r, n, i) {
1341
+ var s = Date.now();
1342
+ var o = 0;
1343
+ e(r, n, (function c(a) {
1344
+ if (a && (a.code === "EACCES" || a.code === "EPERM" || a.code === "EBUSY") && Date.now() - s < 6e4) {
1345
+ setTimeout((function() {
1346
+ t.stat(n, (function(t, s) {
1347
+ if (t && t.code === "ENOENT") e(r, n, c); else i(a);
1348
+ }));
1349
+ }), o);
1350
+ if (o < 100) o += 10;
1351
+ return;
1352
+ }
1353
+ if (i) i(a);
1354
+ }));
1355
+ }
1356
+ if (Object.setPrototypeOf) Object.setPrototypeOf(r, e);
1357
+ return r;
1358
+ }(t.rename);
1359
+ }
1360
+ t.read = typeof t.read !== "function" ? t.read : function(e) {
1361
+ function r(r, n, i, s, o, c) {
1362
+ var a;
1363
+ if (c && typeof c === "function") {
1364
+ var u = 0;
1365
+ a = function(f, l, h) {
1366
+ if (f && f.code === "EAGAIN" && u < 10) {
1367
+ u++;
1368
+ return e.call(t, r, n, i, s, o, a);
1369
+ }
1370
+ c.apply(this, arguments);
1371
+ };
1372
+ }
1373
+ return e.call(t, r, n, i, s, o, a);
1374
+ }
1375
+ if (Object.setPrototypeOf) Object.setPrototypeOf(r, e);
1376
+ return r;
1377
+ }(t.read);
1378
+ t.readSync = typeof t.readSync !== "function" ? t.readSync : function(e) {
1379
+ return function(r, n, i, s, o) {
1380
+ var c = 0;
1381
+ while (true) {
1382
+ try {
1383
+ return e.call(t, r, n, i, s, o);
1384
+ } catch (e) {
1385
+ if (e.code === "EAGAIN" && c < 10) {
1386
+ c++;
1387
+ continue;
1388
+ }
1389
+ throw e;
1390
+ }
1391
+ }
1392
+ };
1393
+ }(t.readSync);
1394
+ function r(t) {
1395
+ t.lchmod = function(r, n, i) {
1396
+ t.open(r, e.O_WRONLY | e.O_SYMLINK, n, (function(e, r) {
1397
+ if (e) {
1398
+ if (i) i(e);
1399
+ return;
1400
+ }
1401
+ t.fchmod(r, n, (function(e) {
1402
+ t.close(r, (function(t) {
1403
+ if (i) i(e || t);
1404
+ }));
1405
+ }));
1406
+ }));
1407
+ };
1408
+ t.lchmodSync = function(r, n) {
1409
+ var i = t.openSync(r, e.O_WRONLY | e.O_SYMLINK, n);
1410
+ var s = true;
1411
+ var o;
1412
+ try {
1413
+ o = t.fchmodSync(i, n);
1414
+ s = false;
1415
+ } finally {
1416
+ if (s) {
1417
+ try {
1418
+ t.closeSync(i);
1419
+ } catch (e) {}
1420
+ } else {
1421
+ t.closeSync(i);
1422
+ }
1423
+ }
1424
+ return o;
1425
+ };
1426
+ }
1427
+ function i(t) {
1428
+ if (e.hasOwnProperty("O_SYMLINK") && t.futimes) {
1429
+ t.lutimes = function(r, n, i, s) {
1430
+ t.open(r, e.O_SYMLINK, (function(e, r) {
1431
+ if (e) {
1432
+ if (s) s(e);
1433
+ return;
1434
+ }
1435
+ t.futimes(r, n, i, (function(e) {
1436
+ t.close(r, (function(t) {
1437
+ if (s) s(e || t);
1438
+ }));
1439
+ }));
1440
+ }));
1441
+ };
1442
+ t.lutimesSync = function(r, n, i) {
1443
+ var s = t.openSync(r, e.O_SYMLINK);
1444
+ var o;
1445
+ var c = true;
1446
+ try {
1447
+ o = t.futimesSync(s, n, i);
1448
+ c = false;
1449
+ } finally {
1450
+ if (c) {
1451
+ try {
1452
+ t.closeSync(s);
1453
+ } catch (e) {}
1454
+ } else {
1455
+ t.closeSync(s);
1456
+ }
1457
+ }
1458
+ return o;
1459
+ };
1460
+ } else if (t.futimes) {
1461
+ t.lutimes = function(e, t, r, n) {
1462
+ if (n) process.nextTick(n);
1463
+ };
1464
+ t.lutimesSync = function() {};
1465
+ }
1466
+ }
1467
+ function s(e) {
1468
+ if (!e) return e;
1469
+ return function(r, n, i) {
1470
+ return e.call(t, r, n, (function(e) {
1471
+ if (l(e)) e = null;
1472
+ if (i) i.apply(this, arguments);
1473
+ }));
1474
+ };
1475
+ }
1476
+ function o(e) {
1477
+ if (!e) return e;
1478
+ return function(r, n) {
1479
+ try {
1480
+ return e.call(t, r, n);
1481
+ } catch (e) {
1482
+ if (!l(e)) throw e;
1483
+ }
1484
+ };
1485
+ }
1486
+ function c(e) {
1487
+ if (!e) return e;
1488
+ return function(r, n, i, s) {
1489
+ return e.call(t, r, n, i, (function(e) {
1490
+ if (l(e)) e = null;
1491
+ if (s) s.apply(this, arguments);
1492
+ }));
1493
+ };
1494
+ }
1495
+ function a(e) {
1496
+ if (!e) return e;
1497
+ return function(r, n, i) {
1498
+ try {
1499
+ return e.call(t, r, n, i);
1500
+ } catch (e) {
1501
+ if (!l(e)) throw e;
1502
+ }
1503
+ };
1504
+ }
1505
+ function u(e) {
1506
+ if (!e) return e;
1507
+ return function(r, n, i) {
1508
+ if (typeof n === "function") {
1509
+ i = n;
1510
+ n = null;
1511
+ }
1512
+ function s(e, t) {
1513
+ if (t) {
1514
+ if (t.uid < 0) t.uid += 4294967296;
1515
+ if (t.gid < 0) t.gid += 4294967296;
1516
+ }
1517
+ if (i) i.apply(this, arguments);
1518
+ }
1519
+ return n ? e.call(t, r, n, s) : e.call(t, r, s);
1520
+ };
1521
+ }
1522
+ function f(e) {
1523
+ if (!e) return e;
1524
+ return function(r, n) {
1525
+ var i = n ? e.call(t, r, n) : e.call(t, r);
1526
+ if (i) {
1527
+ if (i.uid < 0) i.uid += 4294967296;
1528
+ if (i.gid < 0) i.gid += 4294967296;
1529
+ }
1530
+ return i;
1531
+ };
1532
+ }
1533
+ function l(e) {
1534
+ if (!e) return true;
1535
+ if (e.code === "ENOSYS") return true;
1536
+ var t = !process.getuid || process.getuid() !== 0;
1537
+ if (t) {
1538
+ if (e.code === "EINVAL" || e.code === "EPERM") return true;
1539
+ }
1540
+ return false;
1541
+ }
1542
+ }
1543
+ return ae;
1544
+ }
1545
+
1546
+ var le;
1547
+
1548
+ var he;
1549
+
1550
+ function pe() {
1551
+ if (he) return le;
1552
+ he = 1;
1553
+ var e = k.default.Stream;
1554
+ le = t;
1555
+ function t(t) {
1556
+ return {
1557
+ ReadStream: r,
1558
+ WriteStream: n
1559
+ };
1560
+ function r(n, i) {
1561
+ if (!(this instanceof r)) return new r(n, i);
1562
+ e.call(this);
1563
+ var s = this;
1564
+ this.path = n;
1565
+ this.fd = null;
1566
+ this.readable = true;
1567
+ this.paused = false;
1568
+ this.flags = "r";
1569
+ this.mode = 438;
1570
+ this.bufferSize = 64 * 1024;
1571
+ i = i || {};
1572
+ var o = Object.keys(i);
1573
+ for (var c = 0, a = o.length; c < a; c++) {
1574
+ var u = o[c];
1575
+ this[u] = i[u];
1576
+ }
1577
+ if (this.encoding) this.setEncoding(this.encoding);
1578
+ if (this.start !== undefined) {
1579
+ if ("number" !== typeof this.start) {
1580
+ throw TypeError("start must be a Number");
1581
+ }
1582
+ if (this.end === undefined) {
1583
+ this.end = Infinity;
1584
+ } else if ("number" !== typeof this.end) {
1585
+ throw TypeError("end must be a Number");
1586
+ }
1587
+ if (this.start > this.end) {
1588
+ throw new Error("start must be <= end");
1589
+ }
1590
+ this.pos = this.start;
1591
+ }
1592
+ if (this.fd !== null) {
1593
+ process.nextTick((function() {
1594
+ s._read();
1595
+ }));
1596
+ return;
1597
+ }
1598
+ t.open(this.path, this.flags, this.mode, (function(e, t) {
1599
+ if (e) {
1600
+ s.emit("error", e);
1601
+ s.readable = false;
1602
+ return;
1603
+ }
1604
+ s.fd = t;
1605
+ s.emit("open", t);
1606
+ s._read();
1607
+ }));
1608
+ }
1609
+ function n(r, i) {
1610
+ if (!(this instanceof n)) return new n(r, i);
1611
+ e.call(this);
1612
+ this.path = r;
1613
+ this.fd = null;
1614
+ this.writable = true;
1615
+ this.flags = "w";
1616
+ this.encoding = "binary";
1617
+ this.mode = 438;
1618
+ this.bytesWritten = 0;
1619
+ i = i || {};
1620
+ var s = Object.keys(i);
1621
+ for (var o = 0, c = s.length; o < c; o++) {
1622
+ var a = s[o];
1623
+ this[a] = i[a];
1624
+ }
1625
+ if (this.start !== undefined) {
1626
+ if ("number" !== typeof this.start) {
1627
+ throw TypeError("start must be a Number");
1628
+ }
1629
+ if (this.start < 0) {
1630
+ throw new Error("start must be >= zero");
1631
+ }
1632
+ this.pos = this.start;
1633
+ }
1634
+ this.busy = false;
1635
+ this._queue = [];
1636
+ if (this.fd === null) {
1637
+ this._open = t.open;
1638
+ this._queue.push([ this._open, this.path, this.flags, this.mode, undefined ]);
1639
+ this.flush();
1640
+ }
1641
+ }
1642
+ }
1643
+ return le;
1644
+ }
1645
+
1646
+ var de;
1647
+
1648
+ var ye;
1649
+
1650
+ function me() {
1651
+ if (ye) return de;
1652
+ ye = 1;
1653
+ "use strict";
1654
+ de = t;
1655
+ var e = Object.getPrototypeOf || function(e) {
1656
+ return e.__proto__;
1657
+ };
1658
+ function t(t) {
1659
+ if (t === null || typeof t !== "object") return t;
1660
+ if (t instanceof Object) var r = {
1661
+ __proto__: e(t)
1662
+ }; else var r = Object.create(null);
1663
+ Object.getOwnPropertyNames(t).forEach((function(e) {
1664
+ Object.defineProperty(r, e, Object.getOwnPropertyDescriptor(t, e));
1665
+ }));
1666
+ return r;
1667
+ }
1668
+ return de;
1669
+ }
1670
+
1671
+ var ve;
1672
+
1673
+ var we;
1674
+
1675
+ function Se() {
1676
+ if (we) return ve;
1677
+ we = 1;
1678
+ var e = _.default;
1679
+ var t = fe();
1680
+ var r = pe();
1681
+ var i = me();
1682
+ var s = E.default;
1683
+ var o;
1684
+ var c;
1685
+ if (typeof Symbol === "function" && typeof Symbol.for === "function") {
1686
+ o = Symbol.for("graceful-fs.queue");
1687
+ c = Symbol.for("graceful-fs.previous");
1688
+ } else {
1689
+ o = "___graceful-fs.queue";
1690
+ c = "___graceful-fs.previous";
1691
+ }
1692
+ function a() {}
1693
+ function u(e, t) {
1694
+ Object.defineProperty(e, o, {
1695
+ get: function() {
1696
+ return t;
1697
+ }
1698
+ });
1699
+ }
1700
+ var f = a;
1701
+ if (s.debuglog) f = s.debuglog("gfs4"); else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) f = function() {
1702
+ var e = s.format.apply(s, arguments);
1703
+ e = "GFS4: " + e.split(/\n/).join("\nGFS4: ");
1704
+ console.error(e);
1705
+ };
1706
+ if (!e[o]) {
1707
+ var l = n.commonjsGlobal[o] || [];
1708
+ u(e, l);
1709
+ e.close = function(t) {
1710
+ function r(r, n) {
1711
+ return t.call(e, r, (function(e) {
1712
+ if (!e) {
1713
+ y();
1714
+ }
1715
+ if (typeof n === "function") n.apply(this, arguments);
1716
+ }));
1717
+ }
1718
+ Object.defineProperty(r, c, {
1719
+ value: t
1720
+ });
1721
+ return r;
1722
+ }(e.close);
1723
+ e.closeSync = function(t) {
1724
+ function r(r) {
1725
+ t.apply(e, arguments);
1726
+ y();
1727
+ }
1728
+ Object.defineProperty(r, c, {
1729
+ value: t
1730
+ });
1731
+ return r;
1732
+ }(e.closeSync);
1733
+ if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
1734
+ process.on("exit", (function() {
1735
+ f(e[o]);
1736
+ b.default.equal(e[o].length, 0);
1737
+ }));
1738
+ }
1739
+ }
1740
+ if (!n.commonjsGlobal[o]) {
1741
+ u(n.commonjsGlobal, e[o]);
1742
+ }
1743
+ ve = h(i(e));
1744
+ if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !e.__patched) {
1745
+ ve = h(e);
1746
+ e.__patched = true;
1747
+ }
1748
+ function h(e) {
1749
+ t(e);
1750
+ e.gracefulify = h;
1751
+ e.createReadStream = x;
1752
+ e.createWriteStream = P;
1753
+ var n = e.readFile;
1754
+ e.readFile = i;
1755
+ function i(e, t, r) {
1756
+ if (typeof t === "function") r = t, t = null;
1757
+ return i(e, t, r);
1758
+ function i(e, t, r, s) {
1759
+ return n(e, t, (function(n) {
1760
+ if (n && (n.code === "EMFILE" || n.code === "ENFILE")) p([ i, [ e, t, r ], n, s || Date.now(), Date.now() ]); else {
1761
+ if (typeof r === "function") r.apply(this, arguments);
1762
+ }
1763
+ }));
1764
+ }
1765
+ }
1766
+ var s = e.writeFile;
1767
+ e.writeFile = o;
1768
+ function o(e, t, r, n) {
1769
+ if (typeof r === "function") n = r, r = null;
1770
+ return i(e, t, r, n);
1771
+ function i(e, t, r, n, o) {
1772
+ return s(e, t, r, (function(s) {
1773
+ if (s && (s.code === "EMFILE" || s.code === "ENFILE")) p([ i, [ e, t, r, n ], s, o || Date.now(), Date.now() ]); else {
1774
+ if (typeof n === "function") n.apply(this, arguments);
1775
+ }
1776
+ }));
1777
+ }
1778
+ }
1779
+ var c = e.appendFile;
1780
+ if (c) e.appendFile = a;
1781
+ function a(e, t, r, n) {
1782
+ if (typeof r === "function") n = r, r = null;
1783
+ return i(e, t, r, n);
1784
+ function i(e, t, r, n, s) {
1785
+ return c(e, t, r, (function(o) {
1786
+ if (o && (o.code === "EMFILE" || o.code === "ENFILE")) p([ i, [ e, t, r, n ], o, s || Date.now(), Date.now() ]); else {
1787
+ if (typeof n === "function") n.apply(this, arguments);
1788
+ }
1789
+ }));
1790
+ }
1791
+ }
1792
+ var u = e.copyFile;
1793
+ if (u) e.copyFile = f;
1794
+ function f(e, t, r, n) {
1795
+ if (typeof r === "function") {
1796
+ n = r;
1797
+ r = 0;
1798
+ }
1799
+ return i(e, t, r, n);
1800
+ function i(e, t, r, n, s) {
1801
+ return u(e, t, r, (function(o) {
1802
+ if (o && (o.code === "EMFILE" || o.code === "ENFILE")) p([ i, [ e, t, r, n ], o, s || Date.now(), Date.now() ]); else {
1803
+ if (typeof n === "function") n.apply(this, arguments);
1804
+ }
1805
+ }));
1806
+ }
1807
+ }
1808
+ var l = e.readdir;
1809
+ e.readdir = y;
1810
+ var d = /^v[0-5]\./;
1811
+ function y(e, t, r) {
1812
+ if (typeof t === "function") r = t, t = null;
1813
+ var n = d.test(process.version) ? function e(t, r, n, s) {
1814
+ return l(t, i(t, r, n, s));
1815
+ } : function e(t, r, n, s) {
1816
+ return l(t, r, i(t, r, n, s));
1817
+ };
1818
+ return n(e, t, r);
1819
+ function i(e, t, r, i) {
1820
+ return function(s, o) {
1821
+ if (s && (s.code === "EMFILE" || s.code === "ENFILE")) p([ n, [ e, t, r ], s, i || Date.now(), Date.now() ]); else {
1822
+ if (o && o.sort) o.sort();
1823
+ if (typeof r === "function") r.call(this, s, o);
1824
+ }
1825
+ };
1826
+ }
1827
+ }
1828
+ if (process.version.substr(0, 4) === "v0.8") {
1829
+ var m = r(e);
1830
+ k = m.ReadStream;
1831
+ E = m.WriteStream;
1832
+ }
1833
+ var v = e.ReadStream;
1834
+ if (v) {
1835
+ k.prototype = Object.create(v.prototype);
1836
+ k.prototype.open = _;
1837
+ }
1838
+ var w = e.WriteStream;
1839
+ if (w) {
1840
+ E.prototype = Object.create(w.prototype);
1841
+ E.prototype.open = b;
1842
+ }
1843
+ Object.defineProperty(e, "ReadStream", {
1844
+ get: function() {
1845
+ return k;
1846
+ },
1847
+ set: function(e) {
1848
+ k = e;
1849
+ },
1850
+ enumerable: true,
1851
+ configurable: true
1852
+ });
1853
+ Object.defineProperty(e, "WriteStream", {
1854
+ get: function() {
1855
+ return E;
1856
+ },
1857
+ set: function(e) {
1858
+ E = e;
1859
+ },
1860
+ enumerable: true,
1861
+ configurable: true
1862
+ });
1863
+ var S = k;
1864
+ Object.defineProperty(e, "FileReadStream", {
1865
+ get: function() {
1866
+ return S;
1867
+ },
1868
+ set: function(e) {
1869
+ S = e;
1870
+ },
1871
+ enumerable: true,
1872
+ configurable: true
1873
+ });
1874
+ var g = E;
1875
+ Object.defineProperty(e, "FileWriteStream", {
1876
+ get: function() {
1877
+ return g;
1878
+ },
1879
+ set: function(e) {
1880
+ g = e;
1881
+ },
1882
+ enumerable: true,
1883
+ configurable: true
1884
+ });
1885
+ function k(e, t) {
1886
+ if (this instanceof k) return v.apply(this, arguments), this; else return k.apply(Object.create(k.prototype), arguments);
1887
+ }
1888
+ function _() {
1889
+ var e = this;
1890
+ D(e.path, e.flags, e.mode, (function(t, r) {
1891
+ if (t) {
1892
+ if (e.autoClose) e.destroy();
1893
+ e.emit("error", t);
1894
+ } else {
1895
+ e.fd = r;
1896
+ e.emit("open", r);
1897
+ e.read();
1898
+ }
1899
+ }));
1900
+ }
1901
+ function E(e, t) {
1902
+ if (this instanceof E) return w.apply(this, arguments), this; else return E.apply(Object.create(E.prototype), arguments);
1903
+ }
1904
+ function b() {
1905
+ var e = this;
1906
+ D(e.path, e.flags, e.mode, (function(t, r) {
1907
+ if (t) {
1908
+ e.destroy();
1909
+ e.emit("error", t);
1910
+ } else {
1911
+ e.fd = r;
1912
+ e.emit("open", r);
1913
+ }
1914
+ }));
1915
+ }
1916
+ function x(t, r) {
1917
+ return new e.ReadStream(t, r);
1918
+ }
1919
+ function P(t, r) {
1920
+ return new e.WriteStream(t, r);
1921
+ }
1922
+ var O = e.open;
1923
+ e.open = D;
1924
+ function D(e, t, r, n) {
1925
+ if (typeof r === "function") n = r, r = null;
1926
+ return i(e, t, r, n);
1927
+ function i(e, t, r, n, s) {
1928
+ return O(e, t, r, (function(o, c) {
1929
+ if (o && (o.code === "EMFILE" || o.code === "ENFILE")) p([ i, [ e, t, r, n ], o, s || Date.now(), Date.now() ]); else {
1930
+ if (typeof n === "function") n.apply(this, arguments);
1931
+ }
1932
+ }));
1933
+ }
1934
+ }
1935
+ return e;
1936
+ }
1937
+ function p(t) {
1938
+ f("ENQUEUE", t[0].name, t[1]);
1939
+ e[o].push(t);
1940
+ m();
1941
+ }
1942
+ var d;
1943
+ function y() {
1944
+ var t = Date.now();
1945
+ for (var r = 0; r < e[o].length; ++r) {
1946
+ if (e[o][r].length > 2) {
1947
+ e[o][r][3] = t;
1948
+ e[o][r][4] = t;
1949
+ }
1950
+ }
1951
+ m();
1952
+ }
1953
+ function m() {
1954
+ clearTimeout(d);
1955
+ d = undefined;
1956
+ if (e[o].length === 0) return;
1957
+ var t = e[o].shift();
1958
+ var r = t[0];
1959
+ var n = t[1];
1960
+ var i = t[2];
1961
+ var s = t[3];
1962
+ var c = t[4];
1963
+ if (s === undefined) {
1964
+ f("RETRY", r.name, n);
1965
+ r.apply(null, n);
1966
+ } else if (Date.now() - s >= 6e4) {
1967
+ f("TIMEOUT", r.name, n);
1968
+ var a = n.pop();
1969
+ if (typeof a === "function") a.call(null, i);
1970
+ } else {
1971
+ var u = Date.now() - c;
1972
+ var l = Math.max(c - s, 1);
1973
+ var h = Math.min(l * 1.2, 100);
1974
+ if (u >= h) {
1975
+ f("RETRY", r.name, n);
1976
+ r.apply(null, n.concat([ s ]));
1977
+ } else {
1978
+ e[o].push(t);
1979
+ }
1980
+ }
1981
+ if (d === undefined) {
1982
+ d = setTimeout(m, 0);
1983
+ }
1984
+ }
1985
+ return ve;
1986
+ }
1987
+
1988
+ var ge;
1989
+
1990
+ function ke() {
1991
+ if (ge) return ie;
1992
+ ge = 1;
1993
+ (function(e) {
1994
+ const t = ce().fromCallback;
1995
+ const r = Se();
1996
+ const n = [ "access", "appendFile", "chmod", "chown", "close", "copyFile", "fchmod", "fchown", "fdatasync", "fstat", "fsync", "ftruncate", "futimes", "lchown", "link", "lstat", "mkdir", "mkdtemp", "open", "readFile", "readdir", "readlink", "realpath", "rename", "rmdir", "stat", "symlink", "truncate", "unlink", "utimes", "writeFile" ].filter((e => typeof r[e] === "function"));
1997
+ Object.keys(r).forEach((t => {
1998
+ e[t] = r[t];
1999
+ }));
2000
+ n.forEach((n => {
2001
+ e[n] = t(r[n]);
2002
+ }));
2003
+ e.exists = function(e, t) {
2004
+ if (typeof t === "function") {
2005
+ return r.exists(e, t);
2006
+ }
2007
+ return new Promise((t => r.exists(e, t)));
2008
+ };
2009
+ e.read = function(e, t, n, i, s, o) {
2010
+ if (typeof o === "function") {
2011
+ return r.read(e, t, n, i, s, o);
2012
+ }
2013
+ return new Promise(((o, c) => {
2014
+ r.read(e, t, n, i, s, ((e, t, r) => {
2015
+ if (e) return c(e);
2016
+ o({
2017
+ bytesRead: t,
2018
+ buffer: r
2019
+ });
2020
+ }));
2021
+ }));
2022
+ };
2023
+ e.write = function(e, t, n, i, s, o) {
2024
+ if (typeof arguments[arguments.length - 1] === "function") {
2025
+ return r.write(e, t, n, i, s, o);
2026
+ }
2027
+ if (typeof t === "string") {
2028
+ return new Promise(((s, o) => {
2029
+ r.write(e, t, n, i, ((e, t, r) => {
2030
+ if (e) return o(e);
2031
+ s({
2032
+ bytesWritten: t,
2033
+ buffer: r
2034
+ });
2035
+ }));
2036
+ }));
2037
+ }
2038
+ return new Promise(((o, c) => {
2039
+ r.write(e, t, n, i, s, ((e, t, r) => {
2040
+ if (e) return c(e);
2041
+ o({
2042
+ bytesWritten: t,
2043
+ buffer: r
2044
+ });
2045
+ }));
2046
+ }));
2047
+ };
2048
+ })(ie);
2049
+ return ie;
2050
+ }
2051
+
2052
+ var _e;
2053
+
2054
+ var Ee;
2055
+
2056
+ function be() {
2057
+ if (Ee) return _e;
2058
+ Ee = 1;
2059
+ "use strict";
2060
+ const e = Se();
2061
+ const t = x.default;
2062
+ const r = P.default;
2063
+ function n() {
2064
+ let n = r.join("millis-test-sync" + Date.now().toString() + Math.random().toString().slice(2));
2065
+ n = r.join(t.tmpdir(), n);
2066
+ const i = new Date(1435410243862);
2067
+ e.writeFileSync(n, "https://github.com/jprichardson/node-fs-extra/pull/141");
2068
+ const s = e.openSync(n, "r+");
2069
+ e.futimesSync(s, i, i);
2070
+ e.closeSync(s);
2071
+ return e.statSync(n).mtime > 1435410243e3;
2072
+ }
2073
+ function i(n) {
2074
+ let i = r.join("millis-test" + Date.now().toString() + Math.random().toString().slice(2));
2075
+ i = r.join(t.tmpdir(), i);
2076
+ const s = new Date(1435410243862);
2077
+ e.writeFile(i, "https://github.com/jprichardson/node-fs-extra/pull/141", (t => {
2078
+ if (t) return n(t);
2079
+ e.open(i, "r+", ((t, r) => {
2080
+ if (t) return n(t);
2081
+ e.futimes(r, s, s, (t => {
2082
+ if (t) return n(t);
2083
+ e.close(r, (t => {
2084
+ if (t) return n(t);
2085
+ e.stat(i, ((e, t) => {
2086
+ if (e) return n(e);
2087
+ n(null, t.mtime > 1435410243e3);
2088
+ }));
2089
+ }));
2090
+ }));
2091
+ }));
2092
+ }));
2093
+ }
2094
+ function s(e) {
2095
+ if (typeof e === "number") {
2096
+ return Math.floor(e / 1e3) * 1e3;
2097
+ } else if (e instanceof Date) {
2098
+ return new Date(Math.floor(e.getTime() / 1e3) * 1e3);
2099
+ } else {
2100
+ throw new Error("fs-extra: timeRemoveMillis() unknown parameter type");
2101
+ }
2102
+ }
2103
+ function o(t, r, n, i) {
2104
+ e.open(t, "r+", ((t, s) => {
2105
+ if (t) return i(t);
2106
+ e.futimes(s, r, n, (t => {
2107
+ e.close(s, (e => {
2108
+ if (i) i(t || e);
2109
+ }));
2110
+ }));
2111
+ }));
2112
+ }
2113
+ _e = {
2114
+ hasMillisRes: i,
2115
+ hasMillisResSync: n,
2116
+ timeRemoveMillis: s,
2117
+ utimesMillis: o
2118
+ };
2119
+ return _e;
2120
+ }
2121
+
2122
+ var xe;
2123
+
2124
+ var Pe;
2125
+
2126
+ function Oe() {
2127
+ if (Pe) return xe;
2128
+ Pe = 1;
2129
+ var e = Se();
2130
+ var t = P.default;
2131
+ var r = be();
2132
+ function n(n, i, s, o) {
2133
+ if (!o) {
2134
+ o = s;
2135
+ s = {};
2136
+ }
2137
+ var c = process.cwd();
2138
+ var a = t.resolve(c, n);
2139
+ var u = t.resolve(c, i);
2140
+ var f = s.filter;
2141
+ var l = s.transform;
2142
+ var h = s.overwrite;
2143
+ if (h === undefined) h = s.clobber;
2144
+ if (h === undefined) h = true;
2145
+ var p = s.errorOnExist;
2146
+ var d = s.dereference;
2147
+ var y = s.preserveTimestamps === true;
2148
+ var m = 0;
2149
+ var v = 0;
2150
+ var w = 0;
2151
+ var S = false;
2152
+ g(a);
2153
+ function g(e) {
2154
+ m++;
2155
+ if (f) {
2156
+ if (f instanceof RegExp) {
2157
+ console.warn("Warning: fs-extra: Passing a RegExp filter is deprecated, use a function");
2158
+ if (!f.test(e)) {
2159
+ return T(true);
2160
+ }
2161
+ } else if (typeof f === "function") {
2162
+ if (!f(e, i)) {
2163
+ return T(true);
2164
+ }
2165
+ }
2166
+ }
2167
+ return k(e);
2168
+ }
2169
+ function k(t) {
2170
+ var r = d ? e.stat : e.lstat;
2171
+ w++;
2172
+ r(t, (function(e, r) {
2173
+ if (e) return N(e);
2174
+ var n = {
2175
+ name: t,
2176
+ mode: r.mode,
2177
+ mtime: r.mtime,
2178
+ atime: r.atime,
2179
+ stats: r
2180
+ };
2181
+ if (r.isDirectory()) {
2182
+ return x(n);
2183
+ } else if (r.isFile() || r.isCharacterDevice() || r.isBlockDevice()) {
2184
+ return _(n);
2185
+ } else if (r.isSymbolicLink()) {
2186
+ return D(t);
2187
+ }
2188
+ }));
2189
+ }
2190
+ function _(e) {
2191
+ var t = e.name.replace(a, u.replace("$", "$$$$"));
2192
+ F(t, (function(r) {
2193
+ if (r) {
2194
+ E(e, t);
2195
+ } else {
2196
+ if (h) {
2197
+ b(t, (function() {
2198
+ E(e, t);
2199
+ }));
2200
+ } else if (p) {
2201
+ N(new Error(t + " already exists"));
2202
+ } else {
2203
+ T();
2204
+ }
2205
+ }
2206
+ }));
2207
+ }
2208
+ function E(t, n) {
2209
+ var i = e.createReadStream(t.name);
2210
+ var s = e.createWriteStream(n, {
2211
+ mode: t.mode
2212
+ });
2213
+ i.on("error", N);
2214
+ s.on("error", N);
2215
+ if (l) {
2216
+ l(i, s, t);
2217
+ } else {
2218
+ s.on("open", (function() {
2219
+ i.pipe(s);
2220
+ }));
2221
+ }
2222
+ s.once("close", (function() {
2223
+ e.chmod(n, t.mode, (function(e) {
2224
+ if (e) return N(e);
2225
+ if (y) {
2226
+ r.utimesMillis(n, t.atime, t.mtime, (function(e) {
2227
+ if (e) return N(e);
2228
+ return T();
2229
+ }));
2230
+ } else {
2231
+ T();
2232
+ }
2233
+ }));
2234
+ }));
2235
+ }
2236
+ function b(t, r) {
2237
+ e.unlink(t, (function(e) {
2238
+ if (e) return N(e);
2239
+ return r();
2240
+ }));
2241
+ }
2242
+ function x(e) {
2243
+ var t = e.name.replace(a, u.replace("$", "$$$$"));
2244
+ F(t, (function(r) {
2245
+ if (r) {
2246
+ return P(e, t);
2247
+ }
2248
+ O(e.name);
2249
+ }));
2250
+ }
2251
+ function P(t, r) {
2252
+ e.mkdir(r, t.mode, (function(n) {
2253
+ if (n) return N(n);
2254
+ e.chmod(r, t.mode, (function(e) {
2255
+ if (e) return N(e);
2256
+ O(t.name);
2257
+ }));
2258
+ }));
2259
+ }
2260
+ function O(r) {
2261
+ e.readdir(r, (function(e, n) {
2262
+ if (e) return N(e);
2263
+ n.forEach((function(e) {
2264
+ g(t.join(r, e));
2265
+ }));
2266
+ return T();
2267
+ }));
2268
+ }
2269
+ function D(t) {
2270
+ var r = t.replace(a, u);
2271
+ e.readlink(t, (function(e, t) {
2272
+ if (e) return N(e);
2273
+ j(t, r);
2274
+ }));
2275
+ }
2276
+ function j(r, n) {
2277
+ if (d) {
2278
+ r = t.resolve(c, r);
2279
+ }
2280
+ F(n, (function(i) {
2281
+ if (i) {
2282
+ return M(r, n);
2283
+ }
2284
+ e.readlink(n, (function(e, i) {
2285
+ if (e) return N(e);
2286
+ if (d) {
2287
+ i = t.resolve(c, i);
2288
+ }
2289
+ if (i === r) {
2290
+ return T();
2291
+ }
2292
+ return b(n, (function() {
2293
+ M(r, n);
2294
+ }));
2295
+ }));
2296
+ }));
2297
+ }
2298
+ function M(t, r) {
2299
+ e.symlink(t, r, (function(e) {
2300
+ if (e) return N(e);
2301
+ return T();
2302
+ }));
2303
+ }
2304
+ function F(t, r) {
2305
+ e.lstat(t, (function(e) {
2306
+ if (e) {
2307
+ if (e.code === "ENOENT") return r(true);
2308
+ return r(false);
2309
+ }
2310
+ return r(false);
2311
+ }));
2312
+ }
2313
+ function N(e) {
2314
+ if (!S && o !== undefined) {
2315
+ S = true;
2316
+ return o(e);
2317
+ }
2318
+ }
2319
+ function T(e) {
2320
+ if (!e) w--;
2321
+ v++;
2322
+ if (m === v && w === 0) {
2323
+ if (o !== undefined) {
2324
+ return o(null);
2325
+ }
2326
+ }
2327
+ }
2328
+ }
2329
+ xe = n;
2330
+ return xe;
2331
+ }
2332
+
2333
+ var De;
2334
+
2335
+ var je;
2336
+
2337
+ function Me() {
2338
+ if (je) return De;
2339
+ je = 1;
2340
+ "use strict";
2341
+ const e = P.default;
2342
+ function t(t) {
2343
+ t = e.normalize(e.resolve(t)).split(e.sep);
2344
+ if (t.length > 0) return t[0];
2345
+ return null;
2346
+ }
2347
+ const r = /[<>:"|?*]/;
2348
+ function n(e) {
2349
+ const n = t(e);
2350
+ e = e.replace(n, "");
2351
+ return r.test(e);
2352
+ }
2353
+ De = {
2354
+ getRootPath: t,
2355
+ invalidWin32Path: n
2356
+ };
2357
+ return De;
2358
+ }
2359
+
2360
+ var Fe;
2361
+
2362
+ var Ne;
2363
+
2364
+ function Te() {
2365
+ if (Ne) return Fe;
2366
+ Ne = 1;
2367
+ "use strict";
2368
+ const e = Se();
2369
+ const t = P.default;
2370
+ const r = Me().invalidWin32Path;
2371
+ const n = parseInt("0777", 8);
2372
+ function i(s, o, c, a) {
2373
+ if (typeof o === "function") {
2374
+ c = o;
2375
+ o = {};
2376
+ } else if (!o || typeof o !== "object") {
2377
+ o = {
2378
+ mode: o
2379
+ };
2380
+ }
2381
+ if (process.platform === "win32" && r(s)) {
2382
+ const e = new Error(s + " contains invalid WIN32 path characters.");
2383
+ e.code = "EINVAL";
2384
+ return c(e);
2385
+ }
2386
+ let u = o.mode;
2387
+ const f = o.fs || e;
2388
+ if (u === undefined) {
2389
+ u = n & ~process.umask();
2390
+ }
2391
+ if (!a) a = null;
2392
+ c = c || function() {};
2393
+ s = t.resolve(s);
2394
+ f.mkdir(s, u, (e => {
2395
+ if (!e) {
2396
+ a = a || s;
2397
+ return c(null, a);
2398
+ }
2399
+ switch (e.code) {
2400
+ case "ENOENT":
2401
+ if (t.dirname(s) === s) return c(e);
2402
+ i(t.dirname(s), o, ((e, t) => {
2403
+ if (e) c(e, t); else i(s, o, c, t);
2404
+ }));
2405
+ break;
2406
+
2407
+ default:
2408
+ f.stat(s, ((t, r) => {
2409
+ if (t || !r.isDirectory()) c(e, a); else c(null, a);
2410
+ }));
2411
+ break;
2412
+ }
2413
+ }));
2414
+ }
2415
+ Fe = i;
2416
+ return Fe;
2417
+ }
2418
+
2419
+ var Le;
2420
+
2421
+ var Re;
2422
+
2423
+ function qe() {
2424
+ if (Re) return Le;
2425
+ Re = 1;
2426
+ "use strict";
2427
+ const e = Se();
2428
+ const t = P.default;
2429
+ const r = Me().invalidWin32Path;
2430
+ const n = parseInt("0777", 8);
2431
+ function i(s, o, c) {
2432
+ if (!o || typeof o !== "object") {
2433
+ o = {
2434
+ mode: o
2435
+ };
2436
+ }
2437
+ let a = o.mode;
2438
+ const u = o.fs || e;
2439
+ if (process.platform === "win32" && r(s)) {
2440
+ const e = new Error(s + " contains invalid WIN32 path characters.");
2441
+ e.code = "EINVAL";
2442
+ throw e;
2443
+ }
2444
+ if (a === undefined) {
2445
+ a = n & ~process.umask();
2446
+ }
2447
+ if (!c) c = null;
2448
+ s = t.resolve(s);
2449
+ try {
2450
+ u.mkdirSync(s, a);
2451
+ c = c || s;
2452
+ } catch (e) {
2453
+ switch (e.code) {
2454
+ case "ENOENT":
2455
+ if (t.dirname(s) === s) throw e;
2456
+ c = i(t.dirname(s), o, c);
2457
+ i(s, o, c);
2458
+ break;
2459
+
2460
+ default:
2461
+ let r;
2462
+ try {
2463
+ r = u.statSync(s);
2464
+ } catch (t) {
2465
+ throw e;
2466
+ }
2467
+ if (!r.isDirectory()) throw e;
2468
+ break;
2469
+ }
2470
+ }
2471
+ return c;
2472
+ }
2473
+ Le = i;
2474
+ return Le;
2475
+ }
2476
+
2477
+ var Ie;
2478
+
2479
+ var ze;
2480
+
2481
+ function Ae() {
2482
+ if (ze) return Ie;
2483
+ ze = 1;
2484
+ "use strict";
2485
+ const e = ce().fromCallback;
2486
+ const t = e(Te());
2487
+ const r = qe();
2488
+ Ie = {
2489
+ mkdirs: t,
2490
+ mkdirsSync: r,
2491
+ mkdirp: t,
2492
+ mkdirpSync: r,
2493
+ ensureDir: t,
2494
+ ensureDirSync: r
2495
+ };
2496
+ return Ie;
2497
+ }
2498
+
2499
+ var Ce;
2500
+
2501
+ var Ke;
2502
+
2503
+ function Je() {
2504
+ if (Ke) return Ce;
2505
+ Ke = 1;
2506
+ "use strict";
2507
+ const e = ce().fromPromise;
2508
+ const t = ke();
2509
+ function r(e) {
2510
+ return t.access(e).then((() => true)).catch((() => false));
2511
+ }
2512
+ Ce = {
2513
+ pathExists: e(r),
2514
+ pathExistsSync: t.existsSync
2515
+ };
2516
+ return Ce;
2517
+ }
2518
+
2519
+ var Be;
2520
+
2521
+ var $e;
2522
+
2523
+ function Ge() {
2524
+ if ($e) return Be;
2525
+ $e = 1;
2526
+ "use strict";
2527
+ const e = Se();
2528
+ const t = P.default;
2529
+ const r = Oe();
2530
+ const n = Ae();
2531
+ const i = Je().pathExists;
2532
+ function s(s, o, c, a) {
2533
+ if (typeof c === "function" && !a) {
2534
+ a = c;
2535
+ c = {};
2536
+ } else if (typeof c === "function" || c instanceof RegExp) {
2537
+ c = {
2538
+ filter: c
2539
+ };
2540
+ }
2541
+ a = a || function() {};
2542
+ c = c || {};
2543
+ if (c.preserveTimestamps && process.arch === "ia32") {
2544
+ 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`);
2545
+ }
2546
+ const u = process.cwd();
2547
+ const f = t.resolve(u, s);
2548
+ const l = t.resolve(u, o);
2549
+ if (f === l) return a(new Error("Source and destination must not be the same."));
2550
+ e.lstat(s, ((e, u) => {
2551
+ if (e) return a(e);
2552
+ let f = null;
2553
+ if (u.isDirectory()) {
2554
+ const e = o.split(t.sep);
2555
+ e.pop();
2556
+ f = e.join(t.sep);
2557
+ } else {
2558
+ f = t.dirname(o);
2559
+ }
2560
+ i(f, ((e, t) => {
2561
+ if (e) return a(e);
2562
+ if (t) return r(s, o, c, a);
2563
+ n.mkdirs(f, (e => {
2564
+ if (e) return a(e);
2565
+ r(s, o, c, a);
2566
+ }));
2567
+ }));
2568
+ }));
2569
+ }
2570
+ Be = s;
2571
+ return Be;
2572
+ }
2573
+
2574
+ var We;
2575
+
2576
+ var Ue;
2577
+
2578
+ function Ye() {
2579
+ if (Ue) return We;
2580
+ Ue = 1;
2581
+ const e = ce().fromCallback;
2582
+ We = {
2583
+ copy: e(Ge())
2584
+ };
2585
+ return We;
2586
+ }
2587
+
2588
+ var He;
2589
+
2590
+ var Ve;
2591
+
2592
+ function Xe() {
2593
+ if (Ve) return He;
2594
+ Ve = 1;
2595
+ He = function(e) {
2596
+ if (typeof Buffer.allocUnsafe === "function") {
2597
+ try {
2598
+ return Buffer.allocUnsafe(e);
2599
+ } catch (t) {
2600
+ return new Buffer(e);
2601
+ }
2602
+ }
2603
+ return new Buffer(e);
2604
+ };
2605
+ return He;
2606
+ }
2607
+
2608
+ var Qe;
2609
+
2610
+ var Ze;
2611
+
2612
+ function et() {
2613
+ if (Ze) return Qe;
2614
+ Ze = 1;
2615
+ "use strict";
2616
+ const e = Se();
2617
+ const t = 64 * 1024;
2618
+ const r = Xe()(t);
2619
+ function n(n, i, s) {
2620
+ const o = s.overwrite;
2621
+ const c = s.errorOnExist;
2622
+ const a = s.preserveTimestamps;
2623
+ if (e.existsSync(i)) {
2624
+ if (o) {
2625
+ e.unlinkSync(i);
2626
+ } else if (c) {
2627
+ throw new Error(`${i} already exists`);
2628
+ } else return;
2629
+ }
2630
+ const u = e.openSync(n, "r");
2631
+ const f = e.fstatSync(u);
2632
+ const l = e.openSync(i, "w", f.mode);
2633
+ let h = 1;
2634
+ let p = 0;
2635
+ while (h > 0) {
2636
+ h = e.readSync(u, r, 0, t, p);
2637
+ e.writeSync(l, r, 0, h);
2638
+ p += h;
2639
+ }
2640
+ if (a) {
2641
+ e.futimesSync(l, f.atime, f.mtime);
2642
+ }
2643
+ e.closeSync(u);
2644
+ e.closeSync(l);
2645
+ }
2646
+ Qe = n;
2647
+ return Qe;
2648
+ }
2649
+
2650
+ var tt;
2651
+
2652
+ var rt;
2653
+
2654
+ function nt() {
2655
+ if (rt) return tt;
2656
+ rt = 1;
2657
+ "use strict";
2658
+ const e = Se();
2659
+ const t = P.default;
2660
+ const r = et();
2661
+ const n = Ae();
2662
+ function i(s, o, c) {
2663
+ if (typeof c === "function" || c instanceof RegExp) {
2664
+ c = {
2665
+ filter: c
2666
+ };
2667
+ }
2668
+ c = c || {};
2669
+ c.recursive = !!c.recursive;
2670
+ c.clobber = "clobber" in c ? !!c.clobber : true;
2671
+ c.overwrite = "overwrite" in c ? !!c.overwrite : c.clobber;
2672
+ c.dereference = "dereference" in c ? !!c.dereference : false;
2673
+ c.preserveTimestamps = "preserveTimestamps" in c ? !!c.preserveTimestamps : false;
2674
+ c.filter = c.filter || function() {
2675
+ return true;
2676
+ };
2677
+ if (c.preserveTimestamps && process.arch === "ia32") {
2678
+ 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`);
2679
+ }
2680
+ const a = c.recursive && !c.dereference ? e.lstatSync(s) : e.statSync(s);
2681
+ const u = t.dirname(o);
2682
+ const f = e.existsSync(u);
2683
+ let l = false;
2684
+ if (c.filter instanceof RegExp) {
2685
+ console.warn("Warning: fs-extra: Passing a RegExp filter is deprecated, use a function");
2686
+ l = c.filter.test(s);
2687
+ } else if (typeof c.filter === "function") l = c.filter(s, o);
2688
+ if (a.isFile() && l) {
2689
+ if (!f) n.mkdirsSync(u);
2690
+ r(s, o, {
2691
+ overwrite: c.overwrite,
2692
+ errorOnExist: c.errorOnExist,
2693
+ preserveTimestamps: c.preserveTimestamps
2694
+ });
2695
+ } else if (a.isDirectory() && l) {
2696
+ if (!e.existsSync(o)) n.mkdirsSync(o);
2697
+ const r = e.readdirSync(s);
2698
+ r.forEach((e => {
2699
+ const r = c;
2700
+ r.recursive = true;
2701
+ i(t.join(s, e), t.join(o, e), r);
2702
+ }));
2703
+ } else if (c.recursive && a.isSymbolicLink() && l) {
2704
+ const t = e.readlinkSync(s);
2705
+ e.symlinkSync(t, o);
2706
+ }
2707
+ }
2708
+ tt = i;
2709
+ return tt;
2710
+ }
2711
+
2712
+ var it;
2713
+
2714
+ var st;
2715
+
2716
+ function ot() {
2717
+ if (st) return it;
2718
+ st = 1;
2719
+ it = {
2720
+ copySync: nt()
2721
+ };
2722
+ return it;
2723
+ }
2724
+
2725
+ var ct;
2726
+
2727
+ var at;
2728
+
2729
+ function ut() {
2730
+ if (at) return ct;
2731
+ at = 1;
2732
+ "use strict";
2733
+ const e = Se();
2734
+ const t = P.default;
2735
+ const r = b.default;
2736
+ const n = process.platform === "win32";
2737
+ function i(t) {
2738
+ const r = [ "unlink", "chmod", "stat", "lstat", "rmdir", "readdir" ];
2739
+ r.forEach((r => {
2740
+ t[r] = t[r] || e[r];
2741
+ r = r + "Sync";
2742
+ t[r] = t[r] || e[r];
2743
+ }));
2744
+ t.maxBusyTries = t.maxBusyTries || 3;
2745
+ }
2746
+ function s(e, t, n) {
2747
+ let s = 0;
2748
+ if (typeof t === "function") {
2749
+ n = t;
2750
+ t = {};
2751
+ }
2752
+ r(e, "rimraf: missing path");
2753
+ r.equal(typeof e, "string", "rimraf: path should be a string");
2754
+ r.equal(typeof n, "function", "rimraf: callback function required");
2755
+ r(t, "rimraf: invalid options argument provided");
2756
+ r.equal(typeof t, "object", "rimraf: options should be object");
2757
+ i(t);
2758
+ o(e, t, (function r(i) {
2759
+ if (i) {
2760
+ if ((i.code === "EBUSY" || i.code === "ENOTEMPTY" || i.code === "EPERM") && s < t.maxBusyTries) {
2761
+ s++;
2762
+ let n = s * 100;
2763
+ return setTimeout((() => o(e, t, r)), n);
2764
+ }
2765
+ if (i.code === "ENOENT") i = null;
2766
+ }
2767
+ n(i);
2768
+ }));
2769
+ }
2770
+ function o(e, t, i) {
2771
+ r(e);
2772
+ r(t);
2773
+ r(typeof i === "function");
2774
+ t.lstat(e, ((r, s) => {
2775
+ if (r && r.code === "ENOENT") {
2776
+ return i(null);
2777
+ }
2778
+ if (r && r.code === "EPERM" && n) {
2779
+ return c(e, t, r, i);
2780
+ }
2781
+ if (s && s.isDirectory()) {
2782
+ return u(e, t, r, i);
2783
+ }
2784
+ t.unlink(e, (r => {
2785
+ if (r) {
2786
+ if (r.code === "ENOENT") {
2787
+ return i(null);
2788
+ }
2789
+ if (r.code === "EPERM") {
2790
+ return n ? c(e, t, r, i) : u(e, t, r, i);
2791
+ }
2792
+ if (r.code === "EISDIR") {
2793
+ return u(e, t, r, i);
2794
+ }
2795
+ }
2796
+ return i(r);
2797
+ }));
2798
+ }));
2799
+ }
2800
+ function c(e, t, n, i) {
2801
+ r(e);
2802
+ r(t);
2803
+ r(typeof i === "function");
2804
+ if (n) {
2805
+ r(n instanceof Error);
2806
+ }
2807
+ t.chmod(e, 438, (r => {
2808
+ if (r) {
2809
+ i(r.code === "ENOENT" ? null : n);
2810
+ } else {
2811
+ t.stat(e, ((r, s) => {
2812
+ if (r) {
2813
+ i(r.code === "ENOENT" ? null : n);
2814
+ } else if (s.isDirectory()) {
2815
+ u(e, t, n, i);
2816
+ } else {
2817
+ t.unlink(e, i);
2818
+ }
2819
+ }));
2820
+ }
2821
+ }));
2822
+ }
2823
+ function a(e, t, n) {
2824
+ let i;
2825
+ r(e);
2826
+ r(t);
2827
+ if (n) {
2828
+ r(n instanceof Error);
2829
+ }
2830
+ try {
2831
+ t.chmodSync(e, 438);
2832
+ } catch (e) {
2833
+ if (e.code === "ENOENT") {
2834
+ return;
2835
+ } else {
2836
+ throw n;
2837
+ }
2838
+ }
2839
+ try {
2840
+ i = t.statSync(e);
2841
+ } catch (e) {
2842
+ if (e.code === "ENOENT") {
2843
+ return;
2844
+ } else {
2845
+ throw n;
2846
+ }
2847
+ }
2848
+ if (i.isDirectory()) {
2849
+ h(e, t, n);
2850
+ } else {
2851
+ t.unlinkSync(e);
2852
+ }
2853
+ }
2854
+ function u(e, t, n, i) {
2855
+ r(e);
2856
+ r(t);
2857
+ if (n) {
2858
+ r(n instanceof Error);
2859
+ }
2860
+ r(typeof i === "function");
2861
+ t.rmdir(e, (r => {
2862
+ if (r && (r.code === "ENOTEMPTY" || r.code === "EEXIST" || r.code === "EPERM")) {
2863
+ f(e, t, i);
2864
+ } else if (r && r.code === "ENOTDIR") {
2865
+ i(n);
2866
+ } else {
2867
+ i(r);
2868
+ }
2869
+ }));
2870
+ }
2871
+ function f(e, n, i) {
2872
+ r(e);
2873
+ r(n);
2874
+ r(typeof i === "function");
2875
+ n.readdir(e, ((r, o) => {
2876
+ if (r) return i(r);
2877
+ let c = o.length;
2878
+ let a;
2879
+ if (c === 0) return n.rmdir(e, i);
2880
+ o.forEach((r => {
2881
+ s(t.join(e, r), n, (t => {
2882
+ if (a) {
2883
+ return;
2884
+ }
2885
+ if (t) return i(a = t);
2886
+ if (--c === 0) {
2887
+ n.rmdir(e, i);
2888
+ }
2889
+ }));
2890
+ }));
2891
+ }));
2892
+ }
2893
+ function l(e, t) {
2894
+ let s;
2895
+ t = t || {};
2896
+ i(t);
2897
+ r(e, "rimraf: missing path");
2898
+ r.equal(typeof e, "string", "rimraf: path should be a string");
2899
+ r(t, "rimraf: missing options");
2900
+ r.equal(typeof t, "object", "rimraf: options should be object");
2901
+ try {
2902
+ s = t.lstatSync(e);
2903
+ } catch (r) {
2904
+ if (r.code === "ENOENT") {
2905
+ return;
2906
+ }
2907
+ if (r.code === "EPERM" && n) {
2908
+ a(e, t, r);
2909
+ }
2910
+ }
2911
+ try {
2912
+ if (s && s.isDirectory()) {
2913
+ h(e, t, null);
2914
+ } else {
2915
+ t.unlinkSync(e);
2916
+ }
2917
+ } catch (r) {
2918
+ if (r.code === "ENOENT") {
2919
+ return;
2920
+ } else if (r.code === "EPERM") {
2921
+ return n ? a(e, t, r) : h(e, t, r);
2922
+ } else if (r.code !== "EISDIR") {
2923
+ throw r;
2924
+ }
2925
+ h(e, t, r);
2926
+ }
2927
+ }
2928
+ function h(e, t, n) {
2929
+ r(e);
2930
+ r(t);
2931
+ if (n) {
2932
+ r(n instanceof Error);
2933
+ }
2934
+ try {
2935
+ t.rmdirSync(e);
2936
+ } catch (r) {
2937
+ if (r.code === "ENOTDIR") {
2938
+ throw n;
2939
+ } else if (r.code === "ENOTEMPTY" || r.code === "EEXIST" || r.code === "EPERM") {
2940
+ p(e, t);
2941
+ } else if (r.code !== "ENOENT") {
2942
+ throw r;
2943
+ }
2944
+ }
2945
+ }
2946
+ function p(e, i) {
2947
+ r(e);
2948
+ r(i);
2949
+ i.readdirSync(e).forEach((r => l(t.join(e, r), i)));
2950
+ const s = n ? 100 : 1;
2951
+ let o = 0;
2952
+ do {
2953
+ let t = true;
2954
+ try {
2955
+ const r = i.rmdirSync(e, i);
2956
+ t = false;
2957
+ return r;
2958
+ } finally {
2959
+ if (++o < s && t) continue;
2960
+ }
2961
+ } while (true);
2962
+ }
2963
+ ct = s;
2964
+ s.sync = l;
2965
+ return ct;
2966
+ }
2967
+
2968
+ var ft;
2969
+
2970
+ var lt;
2971
+
2972
+ function ht() {
2973
+ if (lt) return ft;
2974
+ lt = 1;
2975
+ "use strict";
2976
+ const e = ce().fromCallback;
2977
+ const t = ut();
2978
+ ft = {
2979
+ remove: e(t),
2980
+ removeSync: t.sync
2981
+ };
2982
+ return ft;
2983
+ }
2984
+
2985
+ var pt;
2986
+
2987
+ var dt;
2988
+
2989
+ function yt() {
2990
+ if (dt) return pt;
2991
+ dt = 1;
2992
+ var e;
2993
+ try {
2994
+ e = Se();
2995
+ } catch (t) {
2996
+ e = _.default;
2997
+ }
2998
+ function t(t, r, n) {
2999
+ if (n == null) {
3000
+ n = r;
3001
+ r = {};
3002
+ }
3003
+ if (typeof r === "string") {
3004
+ r = {
3005
+ encoding: r
3006
+ };
3007
+ }
3008
+ r = r || {};
3009
+ var i = r.fs || e;
3010
+ var s = true;
3011
+ if ("throws" in r) {
3012
+ s = r.throws;
3013
+ }
3014
+ i.readFile(t, r, (function(e, i) {
3015
+ if (e) return n(e);
3016
+ i = o(i);
3017
+ var c;
3018
+ try {
3019
+ c = JSON.parse(i, r ? r.reviver : null);
3020
+ } catch (e) {
3021
+ if (s) {
3022
+ e.message = t + ": " + e.message;
3023
+ return n(e);
3024
+ } else {
3025
+ return n(null, null);
3026
+ }
3027
+ }
3028
+ n(null, c);
3029
+ }));
3030
+ }
3031
+ function r(t, r) {
3032
+ r = r || {};
3033
+ if (typeof r === "string") {
3034
+ r = {
3035
+ encoding: r
3036
+ };
3037
+ }
3038
+ var n = r.fs || e;
3039
+ var i = true;
3040
+ if ("throws" in r) {
3041
+ i = r.throws;
3042
+ }
3043
+ try {
3044
+ var s = n.readFileSync(t, r);
3045
+ s = o(s);
3046
+ return JSON.parse(s, r.reviver);
3047
+ } catch (e) {
3048
+ if (i) {
3049
+ e.message = t + ": " + e.message;
3050
+ throw e;
3051
+ } else {
3052
+ return null;
3053
+ }
3054
+ }
3055
+ }
3056
+ function n(e, t) {
3057
+ var r;
3058
+ var n = "\n";
3059
+ if (typeof t === "object" && t !== null) {
3060
+ if (t.spaces) {
3061
+ r = t.spaces;
3062
+ }
3063
+ if (t.EOL) {
3064
+ n = t.EOL;
3065
+ }
3066
+ }
3067
+ var i = JSON.stringify(e, t ? t.replacer : null, r);
3068
+ return i.replace(/\n/g, n) + n;
3069
+ }
3070
+ function i(t, r, i, s) {
3071
+ if (s == null) {
3072
+ s = i;
3073
+ i = {};
3074
+ }
3075
+ i = i || {};
3076
+ var o = i.fs || e;
3077
+ var c = "";
3078
+ try {
3079
+ c = n(r, i);
3080
+ } catch (e) {
3081
+ if (s) s(e, null);
3082
+ return;
3083
+ }
3084
+ o.writeFile(t, c, i, s);
3085
+ }
3086
+ function s(t, r, i) {
3087
+ i = i || {};
3088
+ var s = i.fs || e;
3089
+ var o = n(r, i);
3090
+ return s.writeFileSync(t, o, i);
3091
+ }
3092
+ function o(e) {
3093
+ if (Buffer.isBuffer(e)) e = e.toString("utf8");
3094
+ e = e.replace(/^\uFEFF/, "");
3095
+ return e;
3096
+ }
3097
+ var c = {
3098
+ readFile: t,
3099
+ readFileSync: r,
3100
+ writeFile: i,
3101
+ writeFileSync: s
3102
+ };
3103
+ pt = c;
3104
+ return pt;
3105
+ }
3106
+
3107
+ var mt;
3108
+
3109
+ var vt;
3110
+
3111
+ function wt() {
3112
+ if (vt) return mt;
3113
+ vt = 1;
3114
+ "use strict";
3115
+ const e = ce().fromCallback;
3116
+ const t = yt();
3117
+ mt = {
3118
+ readJson: e(t.readFile),
3119
+ readJsonSync: t.readFileSync,
3120
+ writeJson: e(t.writeFile),
3121
+ writeJsonSync: t.writeFileSync
3122
+ };
3123
+ return mt;
3124
+ }
3125
+
3126
+ var St;
3127
+
3128
+ var gt;
3129
+
3130
+ function kt() {
3131
+ if (gt) return St;
3132
+ gt = 1;
3133
+ "use strict";
3134
+ const e = P.default;
3135
+ const t = Ae();
3136
+ const r = Je().pathExists;
3137
+ const n = wt();
3138
+ function i(i, s, o, c) {
3139
+ if (typeof o === "function") {
3140
+ c = o;
3141
+ o = {};
3142
+ }
3143
+ const a = e.dirname(i);
3144
+ r(a, ((e, r) => {
3145
+ if (e) return c(e);
3146
+ if (r) return n.writeJson(i, s, o, c);
3147
+ t.mkdirs(a, (e => {
3148
+ if (e) return c(e);
3149
+ n.writeJson(i, s, o, c);
3150
+ }));
3151
+ }));
3152
+ }
3153
+ St = i;
3154
+ return St;
3155
+ }
3156
+
3157
+ var _t;
3158
+
3159
+ var Et;
3160
+
3161
+ function bt() {
3162
+ if (Et) return _t;
3163
+ Et = 1;
3164
+ "use strict";
3165
+ const e = Se();
3166
+ const t = P.default;
3167
+ const r = Ae();
3168
+ const n = wt();
3169
+ function i(i, s, o) {
3170
+ const c = t.dirname(i);
3171
+ if (!e.existsSync(c)) {
3172
+ r.mkdirsSync(c);
3173
+ }
3174
+ n.writeJsonSync(i, s, o);
3175
+ }
3176
+ _t = i;
3177
+ return _t;
3178
+ }
3179
+
3180
+ var xt;
3181
+
3182
+ var Pt;
3183
+
3184
+ function Ot() {
3185
+ if (Pt) return xt;
3186
+ Pt = 1;
3187
+ "use strict";
3188
+ const e = ce().fromCallback;
3189
+ const t = wt();
3190
+ t.outputJson = e(kt());
3191
+ t.outputJsonSync = bt();
3192
+ t.outputJSON = t.outputJson;
3193
+ t.outputJSONSync = t.outputJsonSync;
3194
+ t.writeJSON = t.writeJson;
3195
+ t.writeJSONSync = t.writeJsonSync;
3196
+ t.readJSON = t.readJson;
3197
+ t.readJSONSync = t.readJsonSync;
3198
+ xt = t;
3199
+ return xt;
3200
+ }
3201
+
3202
+ var Dt;
3203
+
3204
+ var jt;
3205
+
3206
+ function Mt() {
3207
+ if (jt) return Dt;
3208
+ jt = 1;
3209
+ "use strict";
3210
+ const e = ce().fromCallback;
3211
+ const t = Se();
3212
+ const r = Oe();
3213
+ const n = P.default;
3214
+ const i = ht().remove;
3215
+ const s = Ae().mkdirs;
3216
+ function o(e, r, a, u) {
3217
+ if (typeof a === "function") {
3218
+ u = a;
3219
+ a = {};
3220
+ }
3221
+ const l = a.overwrite || a.clobber || false;
3222
+ f(e, r, ((t, i) => {
3223
+ if (t) return u(t);
3224
+ if (i) return u(new Error(`Cannot move '${e}' to a subdirectory of itself, '${r}'.`));
3225
+ s(n.dirname(r), (e => {
3226
+ if (e) return u(e);
3227
+ h();
3228
+ }));
3229
+ }));
3230
+ function h() {
3231
+ if (n.resolve(e) === n.resolve(r)) {
3232
+ t.access(e, u);
3233
+ } else if (l) {
3234
+ t.rename(e, r, (t => {
3235
+ if (!t) return u();
3236
+ if (t.code === "ENOTEMPTY" || t.code === "EEXIST") {
3237
+ i(r, (t => {
3238
+ if (t) return u(t);
3239
+ a.overwrite = false;
3240
+ o(e, r, a, u);
3241
+ }));
3242
+ return;
3243
+ }
3244
+ if (t.code === "EPERM") {
3245
+ setTimeout((() => {
3246
+ i(r, (t => {
3247
+ if (t) return u(t);
3248
+ a.overwrite = false;
3249
+ o(e, r, a, u);
3250
+ }));
3251
+ }), 200);
3252
+ return;
3253
+ }
3254
+ if (t.code !== "EXDEV") return u(t);
3255
+ c(e, r, l, u);
3256
+ }));
3257
+ } else {
3258
+ t.link(e, r, (n => {
3259
+ if (n) {
3260
+ if (n.code === "EXDEV" || n.code === "EISDIR" || n.code === "EPERM" || n.code === "ENOTSUP") {
3261
+ return c(e, r, l, u);
3262
+ }
3263
+ return u(n);
3264
+ }
3265
+ return t.unlink(e, u);
3266
+ }));
3267
+ }
3268
+ }
3269
+ }
3270
+ function c(e, r, n, i) {
3271
+ t.stat(e, ((t, s) => {
3272
+ if (t) return i(t);
3273
+ if (s.isDirectory()) {
3274
+ u(e, r, n, i);
3275
+ } else {
3276
+ a(e, r, n, i);
3277
+ }
3278
+ }));
3279
+ }
3280
+ function a(e, r, n, i) {
3281
+ const s = n ? "w" : "wx";
3282
+ const o = t.createReadStream(e);
3283
+ const c = t.createWriteStream(r, {
3284
+ flags: s
3285
+ });
3286
+ o.on("error", (s => {
3287
+ o.destroy();
3288
+ c.destroy();
3289
+ c.removeListener("close", a);
3290
+ t.unlink(r, (() => {
3291
+ if (s.code === "EISDIR" || s.code === "EPERM") {
3292
+ u(e, r, n, i);
3293
+ } else {
3294
+ i(s);
3295
+ }
3296
+ }));
3297
+ }));
3298
+ c.on("error", (e => {
3299
+ o.destroy();
3300
+ c.destroy();
3301
+ c.removeListener("close", a);
3302
+ i(e);
3303
+ }));
3304
+ c.once("close", a);
3305
+ o.pipe(c);
3306
+ function a() {
3307
+ t.unlink(e, i);
3308
+ }
3309
+ }
3310
+ function u(e, t, n, s) {
3311
+ const o = {
3312
+ overwrite: false
3313
+ };
3314
+ if (n) {
3315
+ i(t, (e => {
3316
+ if (e) return s(e);
3317
+ c();
3318
+ }));
3319
+ } else {
3320
+ c();
3321
+ }
3322
+ function c() {
3323
+ r(e, t, o, (t => {
3324
+ if (t) return s(t);
3325
+ i(e, s);
3326
+ }));
3327
+ }
3328
+ }
3329
+ function f(e, r, i) {
3330
+ t.stat(e, ((t, s) => {
3331
+ if (t) return i(t);
3332
+ if (s.isDirectory()) {
3333
+ const t = r.split(n.dirname(e) + n.sep)[1];
3334
+ if (t) {
3335
+ const s = t.split(n.sep)[0];
3336
+ if (s) return i(null, e !== r && r.indexOf(e) > -1 && s === n.basename(e));
3337
+ return i(null, false);
3338
+ }
3339
+ return i(null, false);
3340
+ }
3341
+ return i(null, false);
3342
+ }));
3343
+ }
3344
+ Dt = {
3345
+ move: e(o)
3346
+ };
3347
+ return Dt;
3348
+ }
3349
+
3350
+ var Ft;
3351
+
3352
+ var Nt;
3353
+
3354
+ function Tt() {
3355
+ if (Nt) return Ft;
3356
+ Nt = 1;
3357
+ "use strict";
3358
+ const e = Se();
3359
+ const t = P.default;
3360
+ const r = ot().copySync;
3361
+ const n = ht().removeSync;
3362
+ const i = Ae().mkdirsSync;
3363
+ const s = Xe();
3364
+ function o(r, s, a) {
3365
+ a = a || {};
3366
+ const u = a.overwrite || a.clobber || false;
3367
+ r = t.resolve(r);
3368
+ s = t.resolve(s);
3369
+ if (r === s) return e.accessSync(r);
3370
+ if (f(r, s)) throw new Error(`Cannot move '${r}' into itself '${s}'.`);
3371
+ i(t.dirname(s));
3372
+ l();
3373
+ function l() {
3374
+ if (u) {
3375
+ try {
3376
+ return e.renameSync(r, s);
3377
+ } catch (e) {
3378
+ if (e.code === "ENOTEMPTY" || e.code === "EEXIST" || e.code === "EPERM") {
3379
+ n(s);
3380
+ a.overwrite = false;
3381
+ return o(r, s, a);
3382
+ }
3383
+ if (e.code !== "EXDEV") throw e;
3384
+ return c(r, s, u);
3385
+ }
3386
+ } else {
3387
+ try {
3388
+ e.linkSync(r, s);
3389
+ return e.unlinkSync(r);
3390
+ } catch (e) {
3391
+ if (e.code === "EXDEV" || e.code === "EISDIR" || e.code === "EPERM" || e.code === "ENOTSUP") {
3392
+ return c(r, s, u);
3393
+ }
3394
+ throw e;
3395
+ }
3396
+ }
3397
+ }
3398
+ }
3399
+ function c(t, r, n) {
3400
+ const i = e.statSync(t);
3401
+ if (i.isDirectory()) {
3402
+ return u(t, r, n);
3403
+ } else {
3404
+ return a(t, r, n);
3405
+ }
3406
+ }
3407
+ function a(t, r, n) {
3408
+ const i = 64 * 1024;
3409
+ const o = s(i);
3410
+ const c = n ? "w" : "wx";
3411
+ const a = e.openSync(t, "r");
3412
+ const u = e.fstatSync(a);
3413
+ const f = e.openSync(r, c, u.mode);
3414
+ let l = 1;
3415
+ let h = 0;
3416
+ while (l > 0) {
3417
+ l = e.readSync(a, o, 0, i, h);
3418
+ e.writeSync(f, o, 0, l);
3419
+ h += l;
3420
+ }
3421
+ e.closeSync(a);
3422
+ e.closeSync(f);
3423
+ return e.unlinkSync(t);
3424
+ }
3425
+ function u(e, t, i) {
3426
+ const s = {
3427
+ overwrite: false
3428
+ };
3429
+ if (i) {
3430
+ n(t);
3431
+ o();
3432
+ } else {
3433
+ o();
3434
+ }
3435
+ function o() {
3436
+ r(e, t, s);
3437
+ return n(e);
3438
+ }
3439
+ }
3440
+ function f(r, n) {
3441
+ try {
3442
+ return e.statSync(r).isDirectory() && r !== n && n.indexOf(r) > -1 && n.split(t.dirname(r) + t.sep)[1].split(t.sep)[0] === t.basename(r);
3443
+ } catch (e) {
3444
+ return false;
3445
+ }
3446
+ }
3447
+ Ft = {
3448
+ moveSync: o
3449
+ };
3450
+ return Ft;
3451
+ }
3452
+
3453
+ var Lt;
3454
+
3455
+ var Rt;
3456
+
3457
+ function qt() {
3458
+ if (Rt) return Lt;
3459
+ Rt = 1;
3460
+ "use strict";
3461
+ const e = ce().fromCallback;
3462
+ const t = _.default;
3463
+ const r = P.default;
3464
+ const n = Ae();
3465
+ const i = ht();
3466
+ const s = e((function e(s, o) {
3467
+ o = o || function() {};
3468
+ t.readdir(s, ((e, t) => {
3469
+ if (e) return n.mkdirs(s, o);
3470
+ t = t.map((e => r.join(s, e)));
3471
+ c();
3472
+ function c() {
3473
+ const e = t.pop();
3474
+ if (!e) return o();
3475
+ i.remove(e, (e => {
3476
+ if (e) return o(e);
3477
+ c();
3478
+ }));
3479
+ }
3480
+ }));
3481
+ }));
3482
+ function o(e) {
3483
+ let s;
3484
+ try {
3485
+ s = t.readdirSync(e);
3486
+ } catch (t) {
3487
+ return n.mkdirsSync(e);
3488
+ }
3489
+ s.forEach((t => {
3490
+ t = r.join(e, t);
3491
+ i.removeSync(t);
3492
+ }));
3493
+ }
3494
+ Lt = {
3495
+ emptyDirSync: o,
3496
+ emptydirSync: o,
3497
+ emptyDir: s,
3498
+ emptydir: s
3499
+ };
3500
+ return Lt;
3501
+ }
3502
+
3503
+ var It;
3504
+
3505
+ var zt;
3506
+
3507
+ function At() {
3508
+ if (zt) return It;
3509
+ zt = 1;
3510
+ "use strict";
3511
+ const e = ce().fromCallback;
3512
+ const t = P.default;
3513
+ const r = Se();
3514
+ const n = Ae();
3515
+ const i = Je().pathExists;
3516
+ function s(e, s) {
3517
+ function o() {
3518
+ r.writeFile(e, "", (e => {
3519
+ if (e) return s(e);
3520
+ s();
3521
+ }));
3522
+ }
3523
+ r.stat(e, ((r, c) => {
3524
+ if (!r && c.isFile()) return s();
3525
+ const a = t.dirname(e);
3526
+ i(a, ((e, t) => {
3527
+ if (e) return s(e);
3528
+ if (t) return o();
3529
+ n.mkdirs(a, (e => {
3530
+ if (e) return s(e);
3531
+ o();
3532
+ }));
3533
+ }));
3534
+ }));
3535
+ }
3536
+ function o(e) {
3537
+ let i;
3538
+ try {
3539
+ i = r.statSync(e);
3540
+ } catch (e) {}
3541
+ if (i && i.isFile()) return;
3542
+ const s = t.dirname(e);
3543
+ if (!r.existsSync(s)) {
3544
+ n.mkdirsSync(s);
3545
+ }
3546
+ r.writeFileSync(e, "");
3547
+ }
3548
+ It = {
3549
+ createFile: e(s),
3550
+ createFileSync: o
3551
+ };
3552
+ return It;
3553
+ }
3554
+
3555
+ var Ct;
3556
+
3557
+ var Kt;
3558
+
3559
+ function Jt() {
3560
+ if (Kt) return Ct;
3561
+ Kt = 1;
3562
+ "use strict";
3563
+ const e = ce().fromCallback;
3564
+ const t = P.default;
3565
+ const r = Se();
3566
+ const n = Ae();
3567
+ const i = Je().pathExists;
3568
+ function s(e, s, o) {
3569
+ function c(e, t) {
3570
+ r.link(e, t, (e => {
3571
+ if (e) return o(e);
3572
+ o(null);
3573
+ }));
3574
+ }
3575
+ i(s, ((a, u) => {
3576
+ if (a) return o(a);
3577
+ if (u) return o(null);
3578
+ r.lstat(e, ((r, a) => {
3579
+ if (r) {
3580
+ r.message = r.message.replace("lstat", "ensureLink");
3581
+ return o(r);
3582
+ }
3583
+ const u = t.dirname(s);
3584
+ i(u, ((t, r) => {
3585
+ if (t) return o(t);
3586
+ if (r) return c(e, s);
3587
+ n.mkdirs(u, (t => {
3588
+ if (t) return o(t);
3589
+ c(e, s);
3590
+ }));
3591
+ }));
3592
+ }));
3593
+ }));
3594
+ }
3595
+ function o(e, i, s) {
3596
+ const o = r.existsSync(i);
3597
+ if (o) return undefined;
3598
+ try {
3599
+ r.lstatSync(e);
3600
+ } catch (e) {
3601
+ e.message = e.message.replace("lstat", "ensureLink");
3602
+ throw e;
3603
+ }
3604
+ const c = t.dirname(i);
3605
+ const a = r.existsSync(c);
3606
+ if (a) return r.linkSync(e, i);
3607
+ n.mkdirsSync(c);
3608
+ return r.linkSync(e, i);
3609
+ }
3610
+ Ct = {
3611
+ createLink: e(s),
3612
+ createLinkSync: o
3613
+ };
3614
+ return Ct;
3615
+ }
3616
+
3617
+ var Bt;
3618
+
3619
+ var $t;
3620
+
3621
+ function Gt() {
3622
+ if ($t) return Bt;
3623
+ $t = 1;
3624
+ "use strict";
3625
+ const e = P.default;
3626
+ const t = Se();
3627
+ const r = Je().pathExists;
3628
+ function n(n, i, s) {
3629
+ if (e.isAbsolute(n)) {
3630
+ return t.lstat(n, ((e, t) => {
3631
+ if (e) {
3632
+ e.message = e.message.replace("lstat", "ensureSymlink");
3633
+ return s(e);
3634
+ }
3635
+ return s(null, {
3636
+ toCwd: n,
3637
+ toDst: n
3638
+ });
3639
+ }));
3640
+ } else {
3641
+ const o = e.dirname(i);
3642
+ const c = e.join(o, n);
3643
+ return r(c, ((r, i) => {
3644
+ if (r) return s(r);
3645
+ if (i) {
3646
+ return s(null, {
3647
+ toCwd: c,
3648
+ toDst: n
3649
+ });
3650
+ } else {
3651
+ return t.lstat(n, ((t, r) => {
3652
+ if (t) {
3653
+ t.message = t.message.replace("lstat", "ensureSymlink");
3654
+ return s(t);
3655
+ }
3656
+ return s(null, {
3657
+ toCwd: n,
3658
+ toDst: e.relative(o, n)
3659
+ });
3660
+ }));
3661
+ }
3662
+ }));
3663
+ }
3664
+ }
3665
+ function i(r, n) {
3666
+ let i;
3667
+ if (e.isAbsolute(r)) {
3668
+ i = t.existsSync(r);
3669
+ if (!i) throw new Error("absolute srcpath does not exist");
3670
+ return {
3671
+ toCwd: r,
3672
+ toDst: r
3673
+ };
3674
+ } else {
3675
+ const s = e.dirname(n);
3676
+ const o = e.join(s, r);
3677
+ i = t.existsSync(o);
3678
+ if (i) {
3679
+ return {
3680
+ toCwd: o,
3681
+ toDst: r
3682
+ };
3683
+ } else {
3684
+ i = t.existsSync(r);
3685
+ if (!i) throw new Error("relative srcpath does not exist");
3686
+ return {
3687
+ toCwd: r,
3688
+ toDst: e.relative(s, r)
3689
+ };
3690
+ }
3691
+ }
3692
+ }
3693
+ Bt = {
3694
+ symlinkPaths: n,
3695
+ symlinkPathsSync: i
3696
+ };
3697
+ return Bt;
3698
+ }
3699
+
3700
+ var Wt;
3701
+
3702
+ var Ut;
3703
+
3704
+ function Yt() {
3705
+ if (Ut) return Wt;
3706
+ Ut = 1;
3707
+ "use strict";
3708
+ const e = Se();
3709
+ function t(t, r, n) {
3710
+ n = typeof r === "function" ? r : n;
3711
+ r = typeof r === "function" ? false : r;
3712
+ if (r) return n(null, r);
3713
+ e.lstat(t, ((e, t) => {
3714
+ if (e) return n(null, "file");
3715
+ r = t && t.isDirectory() ? "dir" : "file";
3716
+ n(null, r);
3717
+ }));
3718
+ }
3719
+ function r(t, r) {
3720
+ let n;
3721
+ if (r) return r;
3722
+ try {
3723
+ n = e.lstatSync(t);
3724
+ } catch (e) {
3725
+ return "file";
3726
+ }
3727
+ return n && n.isDirectory() ? "dir" : "file";
3728
+ }
3729
+ Wt = {
3730
+ symlinkType: t,
3731
+ symlinkTypeSync: r
3732
+ };
3733
+ return Wt;
3734
+ }
3735
+
3736
+ var Ht;
3737
+
3738
+ var Vt;
3739
+
3740
+ function Xt() {
3741
+ if (Vt) return Ht;
3742
+ Vt = 1;
3743
+ "use strict";
3744
+ const e = ce().fromCallback;
3745
+ const t = P.default;
3746
+ const r = Se();
3747
+ const n = Ae();
3748
+ const i = n.mkdirs;
3749
+ const s = n.mkdirsSync;
3750
+ const o = Gt();
3751
+ const c = o.symlinkPaths;
3752
+ const a = o.symlinkPathsSync;
3753
+ const u = Yt();
3754
+ const f = u.symlinkType;
3755
+ const l = u.symlinkTypeSync;
3756
+ const h = Je().pathExists;
3757
+ function p(e, n, s, o) {
3758
+ o = typeof s === "function" ? s : o;
3759
+ s = typeof s === "function" ? false : s;
3760
+ h(n, ((a, u) => {
3761
+ if (a) return o(a);
3762
+ if (u) return o(null);
3763
+ c(e, n, ((c, a) => {
3764
+ if (c) return o(c);
3765
+ e = a.toDst;
3766
+ f(a.toCwd, s, ((s, c) => {
3767
+ if (s) return o(s);
3768
+ const a = t.dirname(n);
3769
+ h(a, ((t, s) => {
3770
+ if (t) return o(t);
3771
+ if (s) return r.symlink(e, n, c, o);
3772
+ i(a, (t => {
3773
+ if (t) return o(t);
3774
+ r.symlink(e, n, c, o);
3775
+ }));
3776
+ }));
3777
+ }));
3778
+ }));
3779
+ }));
3780
+ }
3781
+ function d(e, n, i, o) {
3782
+ o = typeof i === "function" ? i : o;
3783
+ i = typeof i === "function" ? false : i;
3784
+ const c = r.existsSync(n);
3785
+ if (c) return undefined;
3786
+ const u = a(e, n);
3787
+ e = u.toDst;
3788
+ i = l(u.toCwd, i);
3789
+ const f = t.dirname(n);
3790
+ const h = r.existsSync(f);
3791
+ if (h) return r.symlinkSync(e, n, i);
3792
+ s(f);
3793
+ return r.symlinkSync(e, n, i);
3794
+ }
3795
+ Ht = {
3796
+ createSymlink: e(p),
3797
+ createSymlinkSync: d
3798
+ };
3799
+ return Ht;
3800
+ }
3801
+
3802
+ var Qt;
3803
+
3804
+ var Zt;
3805
+
3806
+ function er() {
3807
+ if (Zt) return Qt;
3808
+ Zt = 1;
3809
+ "use strict";
3810
+ const e = At();
3811
+ const t = Jt();
3812
+ const r = Xt();
3813
+ Qt = {
3814
+ createFile: e.createFile,
3815
+ createFileSync: e.createFileSync,
3816
+ ensureFile: e.createFile,
3817
+ ensureFileSync: e.createFileSync,
3818
+ createLink: t.createLink,
3819
+ createLinkSync: t.createLinkSync,
3820
+ ensureLink: t.createLink,
3821
+ ensureLinkSync: t.createLinkSync,
3822
+ createSymlink: r.createSymlink,
3823
+ createSymlinkSync: r.createSymlinkSync,
3824
+ ensureSymlink: r.createSymlink,
3825
+ ensureSymlinkSync: r.createSymlinkSync
3826
+ };
3827
+ return Qt;
3828
+ }
3829
+
3830
+ var tr;
3831
+
3832
+ var rr;
3833
+
3834
+ function nr() {
3835
+ if (rr) return tr;
3836
+ rr = 1;
3837
+ "use strict";
3838
+ const e = ce().fromCallback;
3839
+ const t = Se();
3840
+ const r = P.default;
3841
+ const n = Ae();
3842
+ const i = Je().pathExists;
3843
+ function s(e, s, o, c) {
3844
+ if (typeof o === "function") {
3845
+ c = o;
3846
+ o = "utf8";
3847
+ }
3848
+ const a = r.dirname(e);
3849
+ i(a, ((r, i) => {
3850
+ if (r) return c(r);
3851
+ if (i) return t.writeFile(e, s, o, c);
3852
+ n.mkdirs(a, (r => {
3853
+ if (r) return c(r);
3854
+ t.writeFile(e, s, o, c);
3855
+ }));
3856
+ }));
3857
+ }
3858
+ function o(e, i, s) {
3859
+ const o = r.dirname(e);
3860
+ if (t.existsSync(o)) {
3861
+ return t.writeFileSync.apply(t, arguments);
3862
+ }
3863
+ n.mkdirsSync(o);
3864
+ t.writeFileSync.apply(t, arguments);
3865
+ }
3866
+ tr = {
3867
+ outputFile: e(s),
3868
+ outputFileSync: o
3869
+ };
3870
+ return tr;
3871
+ }
3872
+
3873
+ var ir;
3874
+
3875
+ var sr;
3876
+
3877
+ function or() {
3878
+ if (sr) return ir;
3879
+ sr = 1;
3880
+ "use strict";
3881
+ const e = ne();
3882
+ const t = {};
3883
+ e(t, ke());
3884
+ e(t, Ye());
3885
+ e(t, ot());
3886
+ e(t, Ae());
3887
+ e(t, ht());
3888
+ e(t, Ot());
3889
+ e(t, Mt());
3890
+ e(t, Tt());
3891
+ e(t, qt());
3892
+ e(t, er());
3893
+ e(t, nr());
3894
+ e(t, Je());
3895
+ ir = t;
3896
+ return ir;
3897
+ }
3898
+
3899
+ var cr;
3900
+
3901
+ var ar;
3902
+
3903
+ function ur() {
3904
+ if (ar) return cr;
3905
+ ar = 1;
3906
+ "use strict";
3907
+ var e = Object.defineProperty;
3908
+ var t = Object.getOwnPropertyDescriptor;
3909
+ var r = Object.getOwnPropertyNames;
3910
+ var n = Object.prototype.hasOwnProperty;
3911
+ var i = (t, r) => {
3912
+ for (var n in r) e(t, n, {
3913
+ get: r[n],
3914
+ enumerable: true
3915
+ });
3916
+ };
3917
+ var s = (i, s, o, c) => {
3918
+ if (s && typeof s === "object" || typeof s === "function") {
3919
+ for (let a of r(s)) if (!n.call(i, a) && a !== o) e(i, a, {
3920
+ get: () => s[a],
3921
+ enumerable: !(c = t(s, a)) || c.enumerable
3922
+ });
3923
+ }
3924
+ return i;
3925
+ };
3926
+ var o = t => s(e({}, "__esModule", {
3927
+ value: true
3928
+ }), t);
3929
+ var c = {};
3930
+ i(c, {
3931
+ defaultDeserialize: () => f,
3932
+ defaultSerialize: () => u
3933
+ });
3934
+ cr = o(c);
3935
+ var a = S.default;
3936
+ var u = e => {
3937
+ if (e === void 0 || e === null) {
3938
+ return "null";
3939
+ }
3940
+ if (typeof e === "string") {
3941
+ return JSON.stringify(e.startsWith(":") ? ":" + e : e);
3942
+ }
3943
+ if (a.Buffer.isBuffer(e)) {
3944
+ return JSON.stringify(":base64:" + e.toString("base64"));
3945
+ }
3946
+ if (e?.toJSON) {
3947
+ e = e.toJSON();
3948
+ }
3949
+ if (typeof e === "object") {
3950
+ let t = "";
3951
+ const r = Array.isArray(e);
3952
+ t = r ? "[" : "{";
3953
+ let n = true;
3954
+ for (const i in e) {
3955
+ const s = typeof e[i] === "function" || !r && e[i] === void 0;
3956
+ if (!Object.hasOwn(e, i) || s) {
3957
+ continue;
3958
+ }
3959
+ if (!n) {
3960
+ t += ",";
3961
+ }
3962
+ n = false;
3963
+ if (r) {
3964
+ t += u(e[i]);
3965
+ } else if (e[i] !== void 0) {
3966
+ t += u(i) + ":" + u(e[i]);
3967
+ }
3968
+ }
3969
+ t += r ? "]" : "}";
3970
+ return t;
3971
+ }
3972
+ return JSON.stringify(e);
3973
+ };
3974
+ var f = e => JSON.parse(e, ((e, t) => {
3975
+ if (typeof t === "string") {
3976
+ if (t.startsWith(":base64:")) {
3977
+ return a.Buffer.from(t.slice(8), "base64");
3978
+ }
3979
+ return t.startsWith(":") ? t.slice(1) : t;
3980
+ }
3981
+ return t;
3982
+ }));
3983
+ 0 && (module.exports = {
3984
+ defaultDeserialize: f,
3985
+ defaultSerialize: u
3986
+ });
3987
+ return cr;
3988
+ }
3989
+
3990
+ (function(e) {
3991
+ "use strict";
3992
+ Object.defineProperty(e, "__esModule", {
3993
+ value: true
3994
+ });
3995
+ e.Field = e.KeyvFile = e.defaultOpts = void 0;
3996
+ e.makeField = a;
3997
+ const t = i.require$$0;
3998
+ const r = t.__importStar(x.default);
3999
+ const n = t.__importStar(or());
4000
+ const s = t.__importDefault(w.default);
4001
+ const o = ur();
4002
+ e.defaultOpts = {
4003
+ deserialize: o.defaultDeserialize,
4004
+ dialect: "redis",
4005
+ expiredCheckDelay: 24 * 3600 * 1e3,
4006
+ filename: `${r.tmpdir()}/keyv-file/default.json`,
4007
+ serialize: o.defaultSerialize,
4008
+ writeDelay: 100,
4009
+ checkFileLock: false
4010
+ };
4011
+ function c(e) {
4012
+ return typeof e === "number";
4013
+ }
4014
+ class KeyvFile extends s.default {
4015
+ constructor(t) {
4016
+ super();
4017
+ this.ttlSupport = true;
4018
+ this.opts = Object.assign({}, e.defaultOpts, t);
4019
+ if (this.opts.checkFileLock) {
4020
+ this.acquireFileLock();
4021
+ }
4022
+ try {
4023
+ const e = this.opts.deserialize(n.readFileSync(this.opts.filename, "utf8"));
4024
+ if (!Array.isArray(e.cache)) {
4025
+ const t = e.cache;
4026
+ e.cache = [];
4027
+ for (const r in t) {
4028
+ if (t.hasOwnProperty(r)) {
4029
+ e.cache.push([ r, t[r] ]);
4030
+ }
4031
+ }
4032
+ }
4033
+ this._cache = new Map(e.cache);
4034
+ this._lastExpire = e.lastExpire;
4035
+ } catch (e) {
4036
+ this._cache = new Map;
4037
+ this._lastExpire = Date.now();
4038
+ }
4039
+ }
4040
+ get _lockFile() {
4041
+ return this.opts.filename + ".lock";
4042
+ }
4043
+ acquireFileLock() {
4044
+ try {
4045
+ let e = n.openSync(this._lockFile, "wx");
4046
+ n.closeSync(e);
4047
+ process.on("SIGINT", (() => {
4048
+ this.releaseFileLock();
4049
+ process.exit(0);
4050
+ }));
4051
+ process.on("exit", (() => {
4052
+ this.releaseFileLock();
4053
+ }));
4054
+ } catch (e) {
4055
+ console.error(`[keyv-file] There is another process using this file`);
4056
+ throw e;
4057
+ }
4058
+ }
4059
+ releaseFileLock() {
4060
+ try {
4061
+ n.unlinkSync(this._lockFile);
4062
+ } catch (e) {}
4063
+ }
4064
+ get(e) {
4065
+ return t.__awaiter(this, void 0, void 0, (function*() {
4066
+ return Promise.resolve(this.getSync(e));
4067
+ }));
4068
+ }
4069
+ getSync(e) {
4070
+ try {
4071
+ const t = this._cache.get(e);
4072
+ if (!t) {
4073
+ return undefined;
4074
+ } else if (this.isExpired(t)) {
4075
+ this.delete(e);
4076
+ return undefined;
4077
+ } else {
4078
+ return t.value;
4079
+ }
4080
+ } catch (e) {}
4081
+ }
4082
+ getMany(e) {
4083
+ return t.__awaiter(this, void 0, void 0, (function*() {
4084
+ const r = yield Promise.all(e.map((e => t.__awaiter(this, void 0, void 0, (function*() {
4085
+ const t = yield this.get(e);
4086
+ return t;
4087
+ })))));
4088
+ return r;
4089
+ }));
4090
+ }
4091
+ set(e, r, n) {
4092
+ return t.__awaiter(this, void 0, void 0, (function*() {
4093
+ if (n === 0) {
4094
+ n = undefined;
4095
+ }
4096
+ this._cache.set(e, {
4097
+ expire: c(n) ? Date.now() + n : undefined,
4098
+ value: r
4099
+ });
4100
+ return this.save();
4101
+ }));
4102
+ }
4103
+ delete(e) {
4104
+ return t.__awaiter(this, void 0, void 0, (function*() {
4105
+ const t = this._cache.delete(e);
4106
+ yield this.save();
4107
+ return t;
4108
+ }));
4109
+ }
4110
+ deleteMany(e) {
4111
+ return t.__awaiter(this, void 0, void 0, (function*() {
4112
+ const t = e.map((e => this.delete(e)));
4113
+ const r = yield Promise.all(t);
4114
+ return r.every((e => e));
4115
+ }));
4116
+ }
4117
+ clear() {
4118
+ return t.__awaiter(this, void 0, void 0, (function*() {
4119
+ this._cache = new Map;
4120
+ this._lastExpire = Date.now();
4121
+ return this.save();
4122
+ }));
4123
+ }
4124
+ has(e) {
4125
+ return t.__awaiter(this, void 0, void 0, (function*() {
4126
+ const t = yield this.get(e);
4127
+ return t !== undefined;
4128
+ }));
4129
+ }
4130
+ isExpired(e) {
4131
+ return c(e.expire) && e.expire <= Date.now();
4132
+ }
4133
+ clearExpire() {
4134
+ const e = Date.now();
4135
+ if (e - this._lastExpire <= this.opts.expiredCheckDelay) {
4136
+ return;
4137
+ }
4138
+ for (const e of this._cache.keys()) {
4139
+ const t = this._cache.get(e);
4140
+ if (this.isExpired(t)) {
4141
+ this._cache.delete(e);
4142
+ }
4143
+ }
4144
+ this._lastExpire = e;
4145
+ }
4146
+ saveToDisk() {
4147
+ const e = [];
4148
+ for (const [t, r] of this._cache) {
4149
+ e.push([ t, r ]);
4150
+ }
4151
+ const t = this.opts.serialize({
4152
+ cache: e,
4153
+ lastExpire: this._lastExpire
4154
+ });
4155
+ return new Promise(((e, r) => {
4156
+ n.outputFile(this.opts.filename, t, (t => {
4157
+ if (t) {
4158
+ r(t);
4159
+ } else {
4160
+ e();
4161
+ }
4162
+ }));
4163
+ }));
4164
+ }
4165
+ save() {
4166
+ this.clearExpire();
4167
+ if (this._savePromise) {
4168
+ return this._savePromise;
4169
+ }
4170
+ this._savePromise = new Promise(((e, t) => {
4171
+ setTimeout((() => {
4172
+ this.saveToDisk().then(e, t).finally((() => {
4173
+ this._savePromise = void 0;
4174
+ }));
4175
+ }), this.opts.writeDelay);
4176
+ }));
4177
+ return this._savePromise;
4178
+ }
4179
+ disconnect() {
4180
+ return Promise.resolve();
4181
+ }
4182
+ iterator(e) {
4183
+ return t.__asyncGenerator(this, arguments, (function* r() {
4184
+ for (const [r, n] of this._cache.entries()) {
4185
+ if (r === undefined) {
4186
+ continue;
4187
+ }
4188
+ if (!e || r.includes(e)) {
4189
+ yield yield t.__await([ r, n.value ]);
4190
+ }
4191
+ }
4192
+ }));
4193
+ }
4194
+ }
4195
+ e.KeyvFile = KeyvFile;
4196
+ e.default = KeyvFile;
4197
+ class Field {
4198
+ constructor(e, t, r) {
4199
+ this.kv = e;
4200
+ this.key = t;
4201
+ this.defaults = r;
4202
+ }
4203
+ get() {
4204
+ return t.__awaiter(this, arguments, void 0, (function*(e = this.defaults) {
4205
+ var t;
4206
+ return (t = yield this.kv.get(this.key)) !== null && t !== void 0 ? t : e;
4207
+ }));
4208
+ }
4209
+ getSync(e = this.defaults) {
4210
+ var t;
4211
+ if ("getSync" in this.kv) {
4212
+ return (t = this.kv.getSync(this.key)) !== null && t !== void 0 ? t : e;
4213
+ }
4214
+ throw new Error("kv does not support getSync");
4215
+ }
4216
+ set(e, t) {
4217
+ return this.kv.set(this.key, e, t);
4218
+ }
4219
+ delete() {
4220
+ return this.kv.delete(this.key);
4221
+ }
4222
+ }
4223
+ e.Field = Field;
4224
+ function a(e, t, r) {
4225
+ return new Field(e, t, r);
4226
+ }
4227
+ })(ee);
4228
+
4229
+ const fr = n.getDefaultExportFromCjs(ee);
4230
+
4231
+ const lr = e => ({
4232
+ class: Cacher,
4233
+ options: e
4234
+ });
4235
+
4236
+ class Cacher extends p.Component {
4237
+ async init() {
4238
+ let e = undefined;
4239
+ const t = this.options?.stores ? Array.isArray(this.options.stores) ? this.options.stores : [ this.options.stores ] : [];
4240
+ for (const r of t) {
4241
+ switch (r.type) {
4242
+ case "file":
4243
+ {
4244
+ if (!e) e = [];
4245
+ e.push(new z({
4246
+ store: new ee.KeyvFile({
4247
+ filename: r.filename,
4248
+ expiredCheckDelay: r.expiredCheckDelay,
4249
+ writeDelay: r.writeDelay
4250
+ }),
4251
+ namespace: r.namespace
4252
+ }));
4253
+ }
4254
+ break;
4255
+
4256
+ case "redis":
4257
+ {
4258
+ try {
4259
+ require.resolve("redis");
4260
+ } catch (e) {
4261
+ throw new Error('Node-Redis package is required for this driver. Run "npm install redis".');
4262
+ }
4263
+ if (!e) e = [];
4264
+ const t = (await Promise.resolve().then((() => require("./Package.65.cjs")))).default;
4265
+ e.push(new z({
4266
+ store: new t({
4267
+ username: r.username,
4268
+ password: r.password,
4269
+ database: r.database,
4270
+ socket: {
4271
+ host: r.host,
4272
+ port: r.port,
4273
+ tls: r.tls,
4274
+ keepAlive: r.keepAlive,
4275
+ reconnectStrategy: r.reconnect ? 10 : false
4276
+ }
4277
+ }, {
4278
+ namespace: r.namespace,
4279
+ keyPrefixSeparator: r.keyPrefixSeparator,
4280
+ clearBatchSize: r.clearBatchSize,
4281
+ useUnlink: r.useUnlink,
4282
+ noNamespaceAffectsAll: r.noNamespaceAffectsAll,
4283
+ connectionTimeout: r.connectTimeout,
4284
+ throwOnConnectError: r.throwOnConnectError
4285
+ }),
4286
+ namespace: r.namespace
4287
+ }));
4288
+ }
4289
+ break;
4290
+
4291
+ case "memcache":
4292
+ {
4293
+ try {
4294
+ require.resolve("memjs");
4295
+ } catch (e) {
4296
+ throw new Error('MemJS package is required for this driver. Run "npm install memjs".');
4297
+ }
4298
+ if (!e) e = [];
4299
+ const t = (await Promise.resolve().then((() => require("./Package.66.cjs")))).KeyvMemcache;
4300
+ const n = new y.URLBuilder;
4301
+ n.host = r.host;
4302
+ n.port = r.port;
4303
+ n.username = r.username;
4304
+ n.password = r.password;
4305
+ e.push(new z({
4306
+ store: new t(n.toString()),
4307
+ namespace: r.namespace
4308
+ }));
4309
+ }
4310
+ break;
4311
+
4312
+ case "mongo":
4313
+ {
4314
+ try {
4315
+ require.resolve("mongodb");
4316
+ } catch (e) {
4317
+ throw new Error('MongoDB package is required for this driver. Run "npm install mongodb".');
4318
+ }
4319
+ if (!e) e = [];
4320
+ const t = (await Promise.resolve().then((() => require("./Package.67.cjs")))).KeyvMongo;
4321
+ const n = new y.URLBuilder;
4322
+ n.protocol = "mongodb";
4323
+ n.host = r.host;
4324
+ n.port = r.port;
4325
+ n.username = r.username;
4326
+ n.password = r.password;
4327
+ e.push(new z({
4328
+ store: new t(n.toString(), {
4329
+ db: r.database,
4330
+ namespace: r.namespace,
4331
+ collection: r.collection
4332
+ }),
4333
+ namespace: r.namespace
4334
+ }));
4335
+ }
4336
+ break;
4337
+
4338
+ case "sqlite":
4339
+ {
4340
+ try {
4341
+ require.resolve("sqlite3");
4342
+ } catch (e) {
4343
+ throw new Error('SQLite3 package is required for this driver. Run "npm install sqlite3".');
4344
+ }
4345
+ if (!e) e = [];
4346
+ const t = (await Promise.resolve().then((() => require("./Package.68.cjs")))).KeyvSqlite;
4347
+ const n = new y.URLBuilder;
4348
+ n.protocol = "sqlite";
4349
+ n.pathname = r.database;
4350
+ e.push(new z({
4351
+ store: new t({
4352
+ uri: n.toString(),
4353
+ table: r.table,
4354
+ busyTimeout: r.busyTimeout
4355
+ }),
4356
+ namespace: r.namespace
4357
+ }));
4358
+ }
4359
+ break;
4360
+
4361
+ case "postgres":
4362
+ {
4363
+ try {
4364
+ require.resolve("pg");
4365
+ } catch (e) {
4366
+ throw new Error('Node-Postgres package is required for this driver. Run "npm install pg".');
4367
+ }
4368
+ if (!e) e = [];
4369
+ const t = (await Promise.resolve().then((() => require("./Package.69.cjs")))).KeyvPostgres;
4370
+ const n = new y.URLBuilder;
4371
+ n.protocol = "postgresql";
4372
+ n.host = r.host;
4373
+ n.port = r.port;
4374
+ n.username = r.username;
4375
+ n.password = r.password;
4376
+ n.pathname = r.database;
4377
+ e.push(new z({
4378
+ store: new t({
4379
+ uri: n.toString(),
4380
+ table: r.table,
4381
+ schema: r.schema,
4382
+ max: r.maxPoolSize
4383
+ }),
4384
+ namespace: r.namespace
4385
+ }));
4386
+ }
4387
+ break;
4388
+
4389
+ case "mysql":
4390
+ {
4391
+ try {
4392
+ require.resolve("mysql2");
4393
+ } catch (e) {
4394
+ throw new Error('MySQL2 package is required for this driver. Run "npm install mysql2".');
4395
+ }
4396
+ if (!e) e = [];
4397
+ const t = (await Promise.resolve().then((() => require("./Package.610.cjs")))).KeyvMysql;
4398
+ e.push(new z({
4399
+ store: new t({
4400
+ host: r.host,
4401
+ port: r.port,
4402
+ user: r.username,
4403
+ password: r.password,
4404
+ database: r.database,
4405
+ table: r.table
4406
+ }),
4407
+ namespace: r.namespace
4408
+ }));
4409
+ }
4410
+ break;
4411
+ }
4412
+ }
4413
+ this.cache = Z({
4414
+ ...this.options,
4415
+ stores: e
4416
+ });
4417
+ this.cache.on("set", (e => this.emit("set", e)));
4418
+ this.cache.on("del", (e => this.emit("del", e)));
4419
+ this.cache.on("clear", (e => this.emit("clear", e)));
4420
+ this.cache.on("refresh", (e => this.emit("refresh", e)));
4421
+ }
4422
+ async destroy() {
4423
+ await this.cache.disconnect();
4424
+ }
4425
+ async set(e, t, r) {
4426
+ return await this.cache.set(e, t, r);
4427
+ }
4428
+ async multipleSet(e) {
4429
+ return await this.cache.mset(e);
4430
+ }
4431
+ async get(e) {
4432
+ return m.As(await this.cache.get(e));
4433
+ }
4434
+ async multipleGet(e) {
4435
+ return await this.cache.mget(e);
4436
+ }
4437
+ async ttl(e) {
4438
+ const t = await this.cache.ttl(e);
4439
+ if (t === undefined) return -1;
4440
+ return t;
4441
+ }
4442
+ async del(e) {
4443
+ return await this.cache.del(e);
4444
+ }
4445
+ async multipleDel(e) {
4446
+ return await this.cache.mdel(e);
4447
+ }
4448
+ async clear() {
4449
+ return await this.cache.clear();
4450
+ }
4451
+ on(e, t) {
4452
+ return super.on(e, t);
4453
+ }
4454
+ }
4455
+
4456
+ e.__decorate([ d.Configurable(h.CacherOptions.optional()), e.__metadata("design:type", h.CacherOptions) ], Cacher.prototype, "options", void 0);
4457
+
4458
+ exports.BuildCacherOptions = lr;
4459
+
4460
+ exports.Cacher = Cacher;
4461
+
4462
+ exports.Keyv = I;
4463
+
4464
+ exports.defaultDeserialize = D;
4465
+
4466
+ exports.index_default = z;