locter 0.3.1 → 0.4.0

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 (68) hide show
  1. package/README.MD +5 -10
  2. package/dist/index.cjs.js +834 -0
  3. package/dist/index.esm.js +813 -0
  4. package/dist/{index.d.ts → types/index.d.ts} +1 -0
  5. package/dist/{loader → types/loader}/file-type/index.d.ts +0 -0
  6. package/dist/{loader → types/loader}/file-type/json.d.ts +0 -0
  7. package/dist/{loader → types/loader}/file-type/script/async.d.ts +0 -0
  8. package/dist/{loader → types/loader}/file-type/script/index.d.ts +0 -0
  9. package/dist/{loader → types/loader}/file-type/script/sync.d.ts +0 -0
  10. package/dist/types/loader/file-type/script/type.d.ts +5 -0
  11. package/dist/{loader → types/loader}/file-type/script/utils.d.ts +0 -0
  12. package/dist/{loader → types/loader}/index.d.ts +0 -0
  13. package/dist/{loader → types/loader}/module.d.ts +0 -0
  14. package/dist/{loader → types/loader}/utils.d.ts +0 -0
  15. package/dist/{locator → types/locator}/async.d.ts +0 -0
  16. package/dist/{locator → types/locator}/index.d.ts +0 -0
  17. package/dist/{locator → types/locator}/sync.d.ts +0 -0
  18. package/dist/{locator → types/locator}/type.d.ts +2 -2
  19. package/dist/{locator → types/locator}/utils.d.ts +0 -0
  20. package/dist/{utils → types/utils}/error.d.ts +0 -0
  21. package/dist/{utils → types/utils}/file-name.d.ts +0 -0
  22. package/dist/{utils → types/utils}/has-own-property.d.ts +0 -0
  23. package/dist/{utils → types/utils}/index.d.ts +0 -0
  24. package/dist/{utils → types/utils}/to-array.d.ts +0 -0
  25. package/package.json +26 -16
  26. package/dist/index.js +0 -25
  27. package/dist/index.js.map +0 -1
  28. package/dist/loader/file-type/index.js +0 -25
  29. package/dist/loader/file-type/index.js.map +0 -1
  30. package/dist/loader/file-type/json.js +0 -46
  31. package/dist/loader/file-type/json.js.map +0 -1
  32. package/dist/loader/file-type/script/async.js +0 -78
  33. package/dist/loader/file-type/script/async.js.map +0 -1
  34. package/dist/loader/file-type/script/index.js +0 -27
  35. package/dist/loader/file-type/script/index.js.map +0 -1
  36. package/dist/loader/file-type/script/sync.js +0 -43
  37. package/dist/loader/file-type/script/sync.js.map +0 -1
  38. package/dist/loader/file-type/script/type.d.ts +0 -5
  39. package/dist/loader/file-type/script/type.js +0 -9
  40. package/dist/loader/file-type/script/type.js.map +0 -1
  41. package/dist/loader/file-type/script/utils.js +0 -33
  42. package/dist/loader/file-type/script/utils.js.map +0 -1
  43. package/dist/loader/index.js +0 -26
  44. package/dist/loader/index.js.map +0 -1
  45. package/dist/loader/module.js +0 -45
  46. package/dist/loader/module.js.map +0 -1
  47. package/dist/loader/utils.js +0 -19
  48. package/dist/loader/utils.js.map +0 -1
  49. package/dist/locator/async.js +0 -85
  50. package/dist/locator/async.js.map +0 -1
  51. package/dist/locator/index.js +0 -27
  52. package/dist/locator/index.js.map +0 -1
  53. package/dist/locator/sync.js +0 -70
  54. package/dist/locator/sync.js.map +0 -1
  55. package/dist/locator/type.js +0 -9
  56. package/dist/locator/type.js.map +0 -1
  57. package/dist/locator/utils.js +0 -40
  58. package/dist/locator/utils.js.map +0 -1
  59. package/dist/utils/error.js +0 -21
  60. package/dist/utils/error.js.map +0 -1
  61. package/dist/utils/file-name.js +0 -22
  62. package/dist/utils/file-name.js.map +0 -1
  63. package/dist/utils/has-own-property.js +0 -8
  64. package/dist/utils/has-own-property.js.map +0 -1
  65. package/dist/utils/index.js +0 -27
  66. package/dist/utils/index.js.map +0 -1
  67. package/dist/utils/to-array.js +0 -14
  68. package/dist/utils/to-array.js.map +0 -1
@@ -0,0 +1,834 @@
1
+ 'use strict';
2
+
3
+ var glob = require('glob');
4
+ var path = require('path');
5
+ var util = require('util');
6
+ var fs = require('fs');
7
+
8
+ function _regeneratorRuntime() {
9
+ _regeneratorRuntime = function () {
10
+ return exports;
11
+ };
12
+ var exports = {},
13
+ Op = Object.prototype,
14
+ hasOwn = Op.hasOwnProperty,
15
+ defineProperty = Object.defineProperty || function (obj, key, desc) {
16
+ obj[key] = desc.value;
17
+ },
18
+ $Symbol = "function" == typeof Symbol ? Symbol : {},
19
+ iteratorSymbol = $Symbol.iterator || "@@iterator",
20
+ asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
21
+ toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
22
+ function define(obj, key, value) {
23
+ return Object.defineProperty(obj, key, {
24
+ value: value,
25
+ enumerable: !0,
26
+ configurable: !0,
27
+ writable: !0
28
+ }), obj[key];
29
+ }
30
+ try {
31
+ define({}, "");
32
+ } catch (err) {
33
+ define = function (obj, key, value) {
34
+ return obj[key] = value;
35
+ };
36
+ }
37
+ function wrap(innerFn, outerFn, self, tryLocsList) {
38
+ var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
39
+ generator = Object.create(protoGenerator.prototype),
40
+ context = new Context(tryLocsList || []);
41
+ return defineProperty(generator, "_invoke", {
42
+ value: makeInvokeMethod(innerFn, self, context)
43
+ }), generator;
44
+ }
45
+ function tryCatch(fn, obj, arg) {
46
+ try {
47
+ return {
48
+ type: "normal",
49
+ arg: fn.call(obj, arg)
50
+ };
51
+ } catch (err) {
52
+ return {
53
+ type: "throw",
54
+ arg: err
55
+ };
56
+ }
57
+ }
58
+ exports.wrap = wrap;
59
+ var ContinueSentinel = {};
60
+ function Generator() {}
61
+ function GeneratorFunction() {}
62
+ function GeneratorFunctionPrototype() {}
63
+ var IteratorPrototype = {};
64
+ define(IteratorPrototype, iteratorSymbol, function () {
65
+ return this;
66
+ });
67
+ var getProto = Object.getPrototypeOf,
68
+ NativeIteratorPrototype = getProto && getProto(getProto(values([])));
69
+ NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
70
+ var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
71
+ function defineIteratorMethods(prototype) {
72
+ ["next", "throw", "return"].forEach(function (method) {
73
+ define(prototype, method, function (arg) {
74
+ return this._invoke(method, arg);
75
+ });
76
+ });
77
+ }
78
+ function AsyncIterator(generator, PromiseImpl) {
79
+ function invoke(method, arg, resolve, reject) {
80
+ var record = tryCatch(generator[method], generator, arg);
81
+ if ("throw" !== record.type) {
82
+ var result = record.arg,
83
+ value = result.value;
84
+ return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
85
+ invoke("next", value, resolve, reject);
86
+ }, function (err) {
87
+ invoke("throw", err, resolve, reject);
88
+ }) : PromiseImpl.resolve(value).then(function (unwrapped) {
89
+ result.value = unwrapped, resolve(result);
90
+ }, function (error) {
91
+ return invoke("throw", error, resolve, reject);
92
+ });
93
+ }
94
+ reject(record.arg);
95
+ }
96
+ var previousPromise;
97
+ defineProperty(this, "_invoke", {
98
+ value: function (method, arg) {
99
+ function callInvokeWithMethodAndArg() {
100
+ return new PromiseImpl(function (resolve, reject) {
101
+ invoke(method, arg, resolve, reject);
102
+ });
103
+ }
104
+ return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
105
+ }
106
+ });
107
+ }
108
+ function makeInvokeMethod(innerFn, self, context) {
109
+ var state = "suspendedStart";
110
+ return function (method, arg) {
111
+ if ("executing" === state) throw new Error("Generator is already running");
112
+ if ("completed" === state) {
113
+ if ("throw" === method) throw arg;
114
+ return doneResult();
115
+ }
116
+ for (context.method = method, context.arg = arg;;) {
117
+ var delegate = context.delegate;
118
+ if (delegate) {
119
+ var delegateResult = maybeInvokeDelegate(delegate, context);
120
+ if (delegateResult) {
121
+ if (delegateResult === ContinueSentinel) continue;
122
+ return delegateResult;
123
+ }
124
+ }
125
+ if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
126
+ if ("suspendedStart" === state) throw state = "completed", context.arg;
127
+ context.dispatchException(context.arg);
128
+ } else "return" === context.method && context.abrupt("return", context.arg);
129
+ state = "executing";
130
+ var record = tryCatch(innerFn, self, context);
131
+ if ("normal" === record.type) {
132
+ if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
133
+ return {
134
+ value: record.arg,
135
+ done: context.done
136
+ };
137
+ }
138
+ "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
139
+ }
140
+ };
141
+ }
142
+ function maybeInvokeDelegate(delegate, context) {
143
+ var methodName = context.method,
144
+ method = delegate.iterator[methodName];
145
+ if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
146
+ var record = tryCatch(method, delegate.iterator, context.arg);
147
+ if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
148
+ var info = record.arg;
149
+ return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
150
+ }
151
+ function pushTryEntry(locs) {
152
+ var entry = {
153
+ tryLoc: locs[0]
154
+ };
155
+ 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
156
+ }
157
+ function resetTryEntry(entry) {
158
+ var record = entry.completion || {};
159
+ record.type = "normal", delete record.arg, entry.completion = record;
160
+ }
161
+ function Context(tryLocsList) {
162
+ this.tryEntries = [{
163
+ tryLoc: "root"
164
+ }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
165
+ }
166
+ function values(iterable) {
167
+ if (iterable) {
168
+ var iteratorMethod = iterable[iteratorSymbol];
169
+ if (iteratorMethod) return iteratorMethod.call(iterable);
170
+ if ("function" == typeof iterable.next) return iterable;
171
+ if (!isNaN(iterable.length)) {
172
+ var i = -1,
173
+ next = function next() {
174
+ for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
175
+ return next.value = undefined, next.done = !0, next;
176
+ };
177
+ return next.next = next;
178
+ }
179
+ }
180
+ return {
181
+ next: doneResult
182
+ };
183
+ }
184
+ function doneResult() {
185
+ return {
186
+ value: undefined,
187
+ done: !0
188
+ };
189
+ }
190
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
191
+ value: GeneratorFunctionPrototype,
192
+ configurable: !0
193
+ }), defineProperty(GeneratorFunctionPrototype, "constructor", {
194
+ value: GeneratorFunction,
195
+ configurable: !0
196
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
197
+ var ctor = "function" == typeof genFun && genFun.constructor;
198
+ return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
199
+ }, exports.mark = function (genFun) {
200
+ return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
201
+ }, exports.awrap = function (arg) {
202
+ return {
203
+ __await: arg
204
+ };
205
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
206
+ return this;
207
+ }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
208
+ void 0 === PromiseImpl && (PromiseImpl = Promise);
209
+ var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
210
+ return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
211
+ return result.done ? result.value : iter.next();
212
+ });
213
+ }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
214
+ return this;
215
+ }), define(Gp, "toString", function () {
216
+ return "[object Generator]";
217
+ }), exports.keys = function (val) {
218
+ var object = Object(val),
219
+ keys = [];
220
+ for (var key in object) keys.push(key);
221
+ return keys.reverse(), function next() {
222
+ for (; keys.length;) {
223
+ var key = keys.pop();
224
+ if (key in object) return next.value = key, next.done = !1, next;
225
+ }
226
+ return next.done = !0, next;
227
+ };
228
+ }, exports.values = values, Context.prototype = {
229
+ constructor: Context,
230
+ reset: function (skipTempReset) {
231
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
232
+ },
233
+ stop: function () {
234
+ this.done = !0;
235
+ var rootRecord = this.tryEntries[0].completion;
236
+ if ("throw" === rootRecord.type) throw rootRecord.arg;
237
+ return this.rval;
238
+ },
239
+ dispatchException: function (exception) {
240
+ if (this.done) throw exception;
241
+ var context = this;
242
+ function handle(loc, caught) {
243
+ return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
244
+ }
245
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
246
+ var entry = this.tryEntries[i],
247
+ record = entry.completion;
248
+ if ("root" === entry.tryLoc) return handle("end");
249
+ if (entry.tryLoc <= this.prev) {
250
+ var hasCatch = hasOwn.call(entry, "catchLoc"),
251
+ hasFinally = hasOwn.call(entry, "finallyLoc");
252
+ if (hasCatch && hasFinally) {
253
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
254
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
255
+ } else if (hasCatch) {
256
+ if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
257
+ } else {
258
+ if (!hasFinally) throw new Error("try statement without catch or finally");
259
+ if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
260
+ }
261
+ }
262
+ }
263
+ },
264
+ abrupt: function (type, arg) {
265
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
266
+ var entry = this.tryEntries[i];
267
+ if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
268
+ var finallyEntry = entry;
269
+ break;
270
+ }
271
+ }
272
+ finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
273
+ var record = finallyEntry ? finallyEntry.completion : {};
274
+ return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
275
+ },
276
+ complete: function (record, afterLoc) {
277
+ if ("throw" === record.type) throw record.arg;
278
+ return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
279
+ },
280
+ finish: function (finallyLoc) {
281
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
282
+ var entry = this.tryEntries[i];
283
+ if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
284
+ }
285
+ },
286
+ catch: function (tryLoc) {
287
+ for (var i = this.tryEntries.length - 1; i >= 0; --i) {
288
+ var entry = this.tryEntries[i];
289
+ if (entry.tryLoc === tryLoc) {
290
+ var record = entry.completion;
291
+ if ("throw" === record.type) {
292
+ var thrown = record.arg;
293
+ resetTryEntry(entry);
294
+ }
295
+ return thrown;
296
+ }
297
+ }
298
+ throw new Error("illegal catch attempt");
299
+ },
300
+ delegateYield: function (iterable, resultName, nextLoc) {
301
+ return this.delegate = {
302
+ iterator: values(iterable),
303
+ resultName: resultName,
304
+ nextLoc: nextLoc
305
+ }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
306
+ }
307
+ }, exports;
308
+ }
309
+ function _typeof(obj) {
310
+ "@babel/helpers - typeof";
311
+
312
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
313
+ return typeof obj;
314
+ } : function (obj) {
315
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
316
+ }, _typeof(obj);
317
+ }
318
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
319
+ try {
320
+ var info = gen[key](arg);
321
+ var value = info.value;
322
+ } catch (error) {
323
+ reject(error);
324
+ return;
325
+ }
326
+ if (info.done) {
327
+ resolve(value);
328
+ } else {
329
+ Promise.resolve(value).then(_next, _throw);
330
+ }
331
+ }
332
+ function _asyncToGenerator(fn) {
333
+ return function () {
334
+ var self = this,
335
+ args = arguments;
336
+ return new Promise(function (resolve, reject) {
337
+ var gen = fn.apply(self, args);
338
+ function _next(value) {
339
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
340
+ }
341
+ function _throw(err) {
342
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
343
+ }
344
+ _next(undefined);
345
+ });
346
+ };
347
+ }
348
+
349
+ /*
350
+ * Copyright (c) 2022.
351
+ * Author Peter Placzek (tada5hi)
352
+ * For the full copyright and license information,
353
+ * view the LICENSE file that was distributed with this source code.
354
+ */
355
+
356
+ /* istanbul ignore next */
357
+ function handleFileLoadError(e) {
358
+ if (e instanceof Error) {
359
+ throw e;
360
+ }
361
+ if (typeof e === 'string') {
362
+ throw new Error(e);
363
+ }
364
+ return undefined;
365
+ }
366
+
367
+ /*
368
+ * Copyright (c) 2022.
369
+ * Author Peter Placzek (tada5hi)
370
+ * For the full copyright and license information,
371
+ * view the LICENSE file that was distributed with this source code.
372
+ */
373
+
374
+ function removeFileNameExtension(input, extensions) {
375
+ if (input.includes('.')) {
376
+ var position = input.lastIndexOf('.');
377
+ var extension = input.substring(position, input.length);
378
+ if (typeof extensions === 'undefined' || extensions.indexOf(extension) !== -1) {
379
+ input = input.substring(0, position);
380
+ }
381
+ }
382
+ return input;
383
+ }
384
+
385
+ function hasOwnProperty(obj, prop) {
386
+ return Object.prototype.hasOwnProperty.call(obj, prop);
387
+ }
388
+
389
+ /*
390
+ * Copyright (c) 2022.
391
+ * Author Peter Placzek (tada5hi)
392
+ * For the full copyright and license information,
393
+ * view the LICENSE file that was distributed with this source code.
394
+ */
395
+
396
+ function toArray(input) {
397
+ return Array.isArray(input) ? input : [input];
398
+ }
399
+
400
+ /*
401
+ * Copyright (c) 2022.
402
+ * Author Peter Placzek (tada5hi)
403
+ * For the full copyright and license information,
404
+ * view the LICENSE file that was distributed with this source code.
405
+ */
406
+ function getExportItem(data, filterFn) {
407
+ if (filterFn) {
408
+ var keys = Object.keys(data);
409
+ for (var i = 0; i < keys.length; i++) {
410
+ if (filterFn(keys[i], data[keys[i]])) {
411
+ return {
412
+ key: keys[i],
413
+ value: data[keys[i]]
414
+ };
415
+ }
416
+ }
417
+ } else {
418
+ return {
419
+ key: 'default',
420
+ value: hasOwnProperty(data, 'default') ? data["default"] : data
421
+ };
422
+ }
423
+
424
+ /* istanbul ignore next */
425
+ return undefined;
426
+ }
427
+
428
+ function buildLocatorOptions(options) {
429
+ var _options, _options$ignore;
430
+ options = options || {};
431
+ options.path = options.path || [];
432
+ options.path = toArray(options.path);
433
+ if (options.path.length === 0) {
434
+ options.path.push(process.cwd());
435
+ }
436
+ (_options$ignore = (_options = options).ignore) !== null && _options$ignore !== void 0 ? _options$ignore : _options.ignore = [];
437
+ return options;
438
+ }
439
+
440
+ /* istanbul ignore next */
441
+ function isLocatorInfo(data) {
442
+ if (_typeof(data) !== 'object') {
443
+ return false;
444
+ }
445
+ if (!hasOwnProperty(data, 'path') || typeof data.path !== 'string') {
446
+ return false;
447
+ }
448
+ if (!hasOwnProperty(data, 'name') || typeof data.name !== 'string') {
449
+ return false;
450
+ }
451
+ return !(!hasOwnProperty(data, 'extension') || typeof data.extension !== 'string');
452
+ }
453
+
454
+ var globAsync = util.promisify(glob.glob);
455
+ function locateFiles(_x, _x2) {
456
+ return _locateFiles.apply(this, arguments);
457
+ }
458
+ function _locateFiles() {
459
+ _locateFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(pattern, options) {
460
+ var patterns, items, i, j, files, k, fileInfo;
461
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
462
+ while (1) {
463
+ switch (_context.prev = _context.next) {
464
+ case 0:
465
+ options = buildLocatorOptions(options);
466
+ patterns = Array.isArray(pattern) ? pattern : [pattern];
467
+ items = [];
468
+ i = 0;
469
+ case 4:
470
+ if (!(i < patterns.length)) {
471
+ _context.next = 17;
472
+ break;
473
+ }
474
+ j = 0;
475
+ case 6:
476
+ if (!(j < options.path.length)) {
477
+ _context.next = 14;
478
+ break;
479
+ }
480
+ _context.next = 9;
481
+ return globAsync(patterns[i], {
482
+ absolute: true,
483
+ cwd: options.path[j],
484
+ nodir: true,
485
+ ignore: options.ignore
486
+ });
487
+ case 9:
488
+ files = _context.sent;
489
+ for (k = 0; k < files.length; k++) {
490
+ fileInfo = path.parse(files[k]);
491
+ items.push({
492
+ path: fileInfo.dir.split('/').join(path.sep),
493
+ name: fileInfo.name,
494
+ extension: fileInfo.ext
495
+ });
496
+ }
497
+ case 11:
498
+ j++;
499
+ _context.next = 6;
500
+ break;
501
+ case 14:
502
+ i++;
503
+ _context.next = 4;
504
+ break;
505
+ case 17:
506
+ return _context.abrupt("return", items);
507
+ case 18:
508
+ case "end":
509
+ return _context.stop();
510
+ }
511
+ }
512
+ }, _callee);
513
+ }));
514
+ return _locateFiles.apply(this, arguments);
515
+ }
516
+ function locateFile(_x3, _x4) {
517
+ return _locateFile.apply(this, arguments);
518
+ }
519
+ function _locateFile() {
520
+ _locateFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(pattern, options) {
521
+ var patterns, i, j, files, element, fileInfo;
522
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
523
+ while (1) {
524
+ switch (_context2.prev = _context2.next) {
525
+ case 0:
526
+ options = buildLocatorOptions(options);
527
+ patterns = Array.isArray(pattern) ? pattern : [pattern];
528
+ i = 0;
529
+ case 3:
530
+ if (!(i < patterns.length)) {
531
+ _context2.next = 19;
532
+ break;
533
+ }
534
+ j = 0;
535
+ case 5:
536
+ if (!(j < options.path.length)) {
537
+ _context2.next = 16;
538
+ break;
539
+ }
540
+ _context2.next = 8;
541
+ return globAsync(patterns[i], {
542
+ absolute: true,
543
+ cwd: options.path[j],
544
+ nodir: true,
545
+ ignore: options.ignore
546
+ });
547
+ case 8:
548
+ files = _context2.sent;
549
+ element = files.shift();
550
+ if (!element) {
551
+ _context2.next = 13;
552
+ break;
553
+ }
554
+ fileInfo = path.parse(element);
555
+ return _context2.abrupt("return", {
556
+ path: fileInfo.dir.split('/').join(path.sep),
557
+ name: fileInfo.name,
558
+ extension: fileInfo.ext
559
+ });
560
+ case 13:
561
+ j++;
562
+ _context2.next = 5;
563
+ break;
564
+ case 16:
565
+ i++;
566
+ _context2.next = 3;
567
+ break;
568
+ case 19:
569
+ return _context2.abrupt("return", undefined);
570
+ case 20:
571
+ case "end":
572
+ return _context2.stop();
573
+ }
574
+ }
575
+ }, _callee2);
576
+ }));
577
+ return _locateFile.apply(this, arguments);
578
+ }
579
+
580
+ /*
581
+ * Copyright (c) 2022.
582
+ * Author Peter Placzek (tada5hi)
583
+ * For the full copyright and license information,
584
+ * view the LICENSE file that was distributed with this source code.
585
+ */
586
+ function locateFilesSync(pattern, options) {
587
+ options = buildLocatorOptions(options);
588
+ var patterns = Array.isArray(pattern) ? pattern : [pattern];
589
+ var items = [];
590
+ for (var i = 0; i < patterns.length; i++) {
591
+ for (var j = 0; j < options.path.length; j++) {
592
+ var files = glob.sync(patterns[i], {
593
+ absolute: true,
594
+ cwd: options.path[j],
595
+ nodir: true,
596
+ ignore: options.ignore
597
+ });
598
+ for (var k = 0; k < files.length; k++) {
599
+ var fileInfo = path.parse(files[k]);
600
+ items.push({
601
+ path: fileInfo.dir.split('/').join(path.sep),
602
+ name: fileInfo.name,
603
+ extension: fileInfo.ext
604
+ });
605
+ }
606
+ }
607
+ }
608
+ return items;
609
+ }
610
+ function locateFileSync(pattern, options) {
611
+ options = buildLocatorOptions(options);
612
+ var patterns = Array.isArray(pattern) ? pattern : [pattern];
613
+ for (var i = 0; i < patterns.length; i++) {
614
+ for (var j = 0; j < options.path.length; j++) {
615
+ var files = glob.sync(patterns[i], {
616
+ absolute: true,
617
+ cwd: options.path[j],
618
+ nodir: true,
619
+ ignore: options.ignore
620
+ });
621
+ var element = files.shift();
622
+ if (element) {
623
+ var fileInfo = path.parse(element);
624
+ return {
625
+ path: fileInfo.dir.split('/').join(path.sep),
626
+ name: fileInfo.name,
627
+ extension: fileInfo.ext
628
+ };
629
+ }
630
+ }
631
+ }
632
+ return undefined;
633
+ }
634
+
635
+ /*
636
+ * Copyright (c) 2022.
637
+ * Author Peter Placzek (tada5hi)
638
+ * For the full copyright and license information,
639
+ * view the LICENSE file that was distributed with this source code.
640
+ */
641
+ function buildLoaderFilePath(info) {
642
+ return path.join(info.path, info.name) + (info.extension === '.json' ? '.json' : '');
643
+ }
644
+
645
+ function loadScriptFile(_x) {
646
+ return _loadScriptFile.apply(this, arguments);
647
+ }
648
+ function _loadScriptFile() {
649
+ _loadScriptFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(data) {
650
+ var filePath;
651
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
652
+ while (1) {
653
+ switch (_context.prev = _context.next) {
654
+ case 0:
655
+ filePath = isLocatorInfo(data) ? buildLoaderFilePath(data) : data;
656
+ _context.prev = 1;
657
+ _context.next = 4;
658
+ return import(filePath);
659
+ case 4:
660
+ return _context.abrupt("return", _context.sent);
661
+ case 7:
662
+ _context.prev = 7;
663
+ _context.t0 = _context["catch"](1);
664
+ return _context.abrupt("return", handleFileLoadError(_context.t0));
665
+ case 10:
666
+ case "end":
667
+ return _context.stop();
668
+ }
669
+ }
670
+ }, _callee, null, [[1, 7]]);
671
+ }));
672
+ return _loadScriptFile.apply(this, arguments);
673
+ }
674
+ function loadScriptFileExport(_x2, _x3) {
675
+ return _loadScriptFileExport.apply(this, arguments);
676
+ }
677
+ function _loadScriptFileExport() {
678
+ _loadScriptFileExport = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(data, filterFn) {
679
+ var filePath, _data;
680
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
681
+ while (1) {
682
+ switch (_context2.prev = _context2.next) {
683
+ case 0:
684
+ filePath = isLocatorInfo(data) ? buildLoaderFilePath(data) : data;
685
+ _context2.prev = 1;
686
+ _context2.next = 4;
687
+ return loadScriptFile(filePath);
688
+ case 4:
689
+ _data = _context2.sent;
690
+ if (!(_typeof(_data) === 'object')) {
691
+ _context2.next = 7;
692
+ break;
693
+ }
694
+ return _context2.abrupt("return", getExportItem(_data, filterFn));
695
+ case 7:
696
+ return _context2.abrupt("return", undefined);
697
+ case 10:
698
+ _context2.prev = 10;
699
+ _context2.t0 = _context2["catch"](1);
700
+ return _context2.abrupt("return", handleFileLoadError(_context2.t0));
701
+ case 13:
702
+ case "end":
703
+ return _context2.stop();
704
+ }
705
+ }
706
+ }, _callee2, null, [[1, 10]]);
707
+ }));
708
+ return _loadScriptFileExport.apply(this, arguments);
709
+ }
710
+
711
+ function loadScriptFileSync(data) {
712
+ var filePath = isLocatorInfo(data) ? buildLoaderFilePath(data) : data;
713
+ try {
714
+ // eslint-disable-next-line @typescript-eslint/no-var-requires, global-require,import/no-dynamic-require
715
+ return require(filePath);
716
+ } catch (e) {
717
+ return handleFileLoadError(e);
718
+ }
719
+ }
720
+ function loadScriptFileExportSync(data, filterFn) {
721
+ var filePath = isLocatorInfo(data) ? buildLoaderFilePath(data) : data;
722
+ try {
723
+ var _data = loadScriptFileSync(filePath);
724
+ if (_typeof(_data) === 'object') {
725
+ return getExportItem(_data, filterFn);
726
+ }
727
+ return undefined;
728
+ } catch (e) {
729
+ return handleFileLoadError(e);
730
+ }
731
+ }
732
+
733
+ function loadJsonFile(_x) {
734
+ return _loadJsonFile.apply(this, arguments);
735
+ }
736
+ function _loadJsonFile() {
737
+ _loadJsonFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(filePath) {
738
+ var file;
739
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
740
+ while (1) {
741
+ switch (_context.prev = _context.next) {
742
+ case 0:
743
+ _context.prev = 0;
744
+ _context.next = 3;
745
+ return fs.promises.readFile(filePath);
746
+ case 3:
747
+ file = _context.sent;
748
+ return _context.abrupt("return", JSON.parse(file.toString('utf-8')));
749
+ case 7:
750
+ _context.prev = 7;
751
+ _context.t0 = _context["catch"](0);
752
+ return _context.abrupt("return", handleFileLoadError(_context.t0));
753
+ case 10:
754
+ case "end":
755
+ return _context.stop();
756
+ }
757
+ }
758
+ }, _callee, null, [[0, 7]]);
759
+ }));
760
+ return _loadJsonFile.apply(this, arguments);
761
+ }
762
+ function loadJsonFileSync(filePath) {
763
+ try {
764
+ var file = fs.readFileSync(filePath);
765
+ return JSON.parse(file.toString('utf-8'));
766
+ } catch (e) {
767
+ return handleFileLoadError(e);
768
+ }
769
+ }
770
+
771
+ function loadFile(_x) {
772
+ return _loadFile.apply(this, arguments);
773
+ }
774
+ function _loadFile() {
775
+ _loadFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(info) {
776
+ var filePath;
777
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
778
+ while (1) {
779
+ switch (_context.prev = _context.next) {
780
+ case 0:
781
+ if (info) {
782
+ _context.next = 2;
783
+ break;
784
+ }
785
+ return _context.abrupt("return", undefined);
786
+ case 2:
787
+ filePath = buildLoaderFilePath(info);
788
+ if (!(info.extension === '.json')) {
789
+ _context.next = 5;
790
+ break;
791
+ }
792
+ return _context.abrupt("return", loadJsonFile(filePath));
793
+ case 5:
794
+ return _context.abrupt("return", loadScriptFile(filePath));
795
+ case 6:
796
+ case "end":
797
+ return _context.stop();
798
+ }
799
+ }
800
+ }, _callee);
801
+ }));
802
+ return _loadFile.apply(this, arguments);
803
+ }
804
+ function loadFileSync(info) {
805
+ if (!info) {
806
+ return undefined;
807
+ }
808
+ var filePath = buildLoaderFilePath(info);
809
+ if (info.extension === '.json') {
810
+ return loadJsonFileSync(filePath);
811
+ }
812
+ return loadScriptFileSync(filePath);
813
+ }
814
+
815
+ exports.buildLoaderFilePath = buildLoaderFilePath;
816
+ exports.buildLocatorOptions = buildLocatorOptions;
817
+ exports.getExportItem = getExportItem;
818
+ exports.handleFileLoadError = handleFileLoadError;
819
+ exports.hasOwnProperty = hasOwnProperty;
820
+ exports.isLocatorInfo = isLocatorInfo;
821
+ exports.loadFile = loadFile;
822
+ exports.loadFileSync = loadFileSync;
823
+ exports.loadJsonFile = loadJsonFile;
824
+ exports.loadJsonFileSync = loadJsonFileSync;
825
+ exports.loadScriptFile = loadScriptFile;
826
+ exports.loadScriptFileExport = loadScriptFileExport;
827
+ exports.loadScriptFileExportSync = loadScriptFileExportSync;
828
+ exports.loadScriptFileSync = loadScriptFileSync;
829
+ exports.locateFile = locateFile;
830
+ exports.locateFileSync = locateFileSync;
831
+ exports.locateFiles = locateFiles;
832
+ exports.locateFilesSync = locateFilesSync;
833
+ exports.removeFileNameExtension = removeFileNameExtension;
834
+ exports.toArray = toArray;