locter 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -4,23 +4,39 @@ var ebec = require('ebec');
4
4
  var createJITI = require('jiti');
5
5
  var node_url = require('node:url');
6
6
  var glob = require('glob');
7
- var node_util = require('node:util');
8
7
  var path = require('node:path');
9
8
  var fs = require('node:fs');
10
9
 
10
+ function hasOwnProperty(obj, prop) {
11
+ return Object.prototype.hasOwnProperty.call(obj, prop);
12
+ }
13
+ function hasStringProperty(obj, prop) {
14
+ return hasOwnProperty(obj, prop) && typeof obj[prop] === 'string';
15
+ }
16
+
11
17
  /*
12
18
  * Copyright (c) 2022.
13
19
  * Author Peter Placzek (tada5hi)
14
20
  * For the full copyright and license information,
15
21
  * view the LICENSE file that was distributed with this source code.
16
- */ /* istanbul ignore next */ function handleFileLoadError(e) {
22
+ */ function isObject(item) {
23
+ return !!item && typeof item === 'object' && !Array.isArray(item);
24
+ }
25
+
26
+ function handleException(e) {
17
27
  if (e instanceof Error) {
18
28
  throw e;
19
29
  }
20
- if (typeof e === 'string') {
21
- throw new Error(e);
30
+ const error = new Error('Can not process thrown exception.');
31
+ if (isObject(e)) {
32
+ if (hasOwnProperty(e, 'message') && typeof e.message === 'string') {
33
+ error.message = e.message;
34
+ }
35
+ if (hasOwnProperty(e, 'stack') && typeof e.stack === 'string') {
36
+ error.stack = e.stack;
37
+ }
22
38
  }
23
- throw new Error('Cannot determine file loading error.');
39
+ throw error;
24
40
  }
25
41
 
26
42
  /*
@@ -39,22 +55,6 @@ var fs = require('node:fs');
39
55
  return input;
40
56
  }
41
57
 
42
- function hasOwnProperty(obj, prop) {
43
- return Object.prototype.hasOwnProperty.call(obj, prop);
44
- }
45
- function hasStringProperty(obj, prop) {
46
- return hasOwnProperty(obj, prop) && typeof obj[prop] === 'string';
47
- }
48
-
49
- /*
50
- * Copyright (c) 2022.
51
- * Author Peter Placzek (tada5hi)
52
- * For the full copyright and license information,
53
- * view the LICENSE file that was distributed with this source code.
54
- */ function isObject(item) {
55
- return !!item && typeof item === 'object' && !Array.isArray(item);
56
- }
57
-
58
58
  /*
59
59
  * Copyright (c) 2022.
60
60
  * Author Peter Placzek (tada5hi)
@@ -66,6 +66,25 @@ function hasStringProperty(obj, prop) {
66
66
  ];
67
67
  }
68
68
 
69
+ function buildFilePath(input) {
70
+ if (typeof input === 'string') {
71
+ return input;
72
+ }
73
+ if (input.extension) {
74
+ return path.join(input.path, input.name) + input.extension;
75
+ }
76
+ return path.join(input.path, input.name);
77
+ }
78
+ function buildFilePathWithoutExtension(input) {
79
+ let info;
80
+ if (typeof input === 'string') {
81
+ info = pathToLocatorInfo(input);
82
+ } else {
83
+ info = input;
84
+ }
85
+ return path.join(info.path, info.name);
86
+ }
87
+
69
88
  /*
70
89
  * Copyright (c) 2022.
71
90
  * Author Peter Placzek (tada5hi)
@@ -98,7 +117,6 @@ function pathToLocatorInfo(input, skipResolve) {
98
117
  };
99
118
  }
100
119
 
101
- const globAsync = node_util.promisify(glob);
102
120
  async function locateMany(pattern, options) {
103
121
  options = buildLocatorOptions(options);
104
122
  const patterns = Array.isArray(pattern) ? pattern : [
@@ -107,7 +125,7 @@ async function locateMany(pattern, options) {
107
125
  const items = [];
108
126
  for(let i = 0; i < patterns.length; i++){
109
127
  for(let j = 0; j < options.path.length; j++){
110
- const files = await globAsync(patterns[i], {
128
+ const files = await glob.glob(patterns[i], {
111
129
  absolute: true,
112
130
  cwd: options.path[j],
113
131
  nodir: true,
@@ -127,7 +145,7 @@ async function locate(pattern, options) {
127
145
  ];
128
146
  for(let i = 0; i < patterns.length; i++){
129
147
  for(let j = 0; j < options.path.length; j++){
130
- const files = await globAsync(patterns[i], {
148
+ const files = await glob.glob(patterns[i], {
131
149
  absolute: true,
132
150
  cwd: options.path[j],
133
151
  nodir: true,
@@ -150,7 +168,7 @@ function locateManySync(pattern, options) {
150
168
  const items = [];
151
169
  for(let i = 0; i < patterns.length; i++){
152
170
  for(let j = 0; j < options.path.length; j++){
153
- const files = glob.sync(patterns[i], {
171
+ const files = glob.globSync(patterns[i], {
154
172
  absolute: true,
155
173
  cwd: options.path[j],
156
174
  nodir: true,
@@ -170,7 +188,7 @@ function locateSync(pattern, options) {
170
188
  ];
171
189
  for(let i = 0; i < patterns.length; i++){
172
190
  for(let j = 0; j < options.path.length; j++){
173
- const files = glob.sync(patterns[i], {
191
+ const files = glob.globSync(patterns[i], {
174
192
  absolute: true,
175
193
  cwd: options.path[j],
176
194
  nodir: true,
@@ -185,37 +203,6 @@ function locateSync(pattern, options) {
185
203
  return undefined;
186
204
  }
187
205
 
188
- function buildLoaderFilePath(input, withExtension) {
189
- let info;
190
- if (typeof input === 'string') {
191
- info = pathToLocatorInfo(input);
192
- } else {
193
- info = input;
194
- }
195
- if (withExtension && info.extension) {
196
- return path.join(info.path, info.name) + info.extension;
197
- }
198
- return path.join(info.path, info.name);
199
- }
200
- function getExportItem(data, filterFn) {
201
- if (filterFn) {
202
- const keys = Object.keys(data);
203
- for(let i = 0; i < keys.length; i++){
204
- if (filterFn(keys[i], data[keys[i]])) {
205
- return {
206
- key: keys[i],
207
- value: data[keys[i]]
208
- };
209
- }
210
- }
211
- throw new ebec.BaseError('Cannot find specific module export.');
212
- }
213
- return {
214
- key: 'default',
215
- value: hasOwnProperty(data, 'default') ? data.default : data
216
- };
217
- }
218
-
219
206
  /*
220
207
  * Copyright (c) 2022.
221
208
  * Author Peter Placzek (tada5hi)
@@ -257,14 +244,14 @@ class ModuleLoader {
257
244
  }
258
245
  // ---------------------------------------------------------------------------
259
246
  async load(data, options) {
260
- let locatorInfo;
261
- if (typeof data === 'string') {
262
- locatorInfo = pathToLocatorInfo(data);
247
+ const locatorInfo = this.buildLocatorInfo(data);
248
+ options = options || {};
249
+ let filePath;
250
+ if (options.withExtension) {
251
+ filePath = buildFilePath(locatorInfo);
263
252
  } else {
264
- locatorInfo = data;
253
+ filePath = buildFilePathWithoutExtension(locatorInfo);
265
254
  }
266
- options = options || {};
267
- let filePath = buildLoaderFilePath(locatorInfo, options.withExtension);
268
255
  if (options.withFilePrefix) {
269
256
  filePath = node_url.pathToFileURL(filePath).href;
270
257
  }
@@ -296,18 +283,18 @@ class ModuleLoader {
296
283
  stack: hasStringProperty(e, 'stack') ? e.stack : undefined
297
284
  });
298
285
  }
299
- /* istanbul ignore next */ return handleFileLoadError(e);
286
+ /* istanbul ignore next */ return handleException(e);
300
287
  }
301
288
  }
302
289
  loadSync(data, options) {
303
- let locatorInfo;
304
- if (typeof data === 'string') {
305
- locatorInfo = pathToLocatorInfo(data);
290
+ const locatorInfo = this.buildLocatorInfo(data);
291
+ options = options || {};
292
+ let filePath;
293
+ if (options.withExtension) {
294
+ filePath = buildFilePath(locatorInfo);
306
295
  } else {
307
- locatorInfo = data;
296
+ filePath = buildFilePathWithoutExtension(locatorInfo);
308
297
  }
309
- options = options || {};
310
- const filePath = buildLoaderFilePath(locatorInfo, options.withExtension);
311
298
  try {
312
299
  // eslint-disable-next-line global-require,import/no-dynamic-require
313
300
  return require(filePath);
@@ -325,8 +312,14 @@ class ModuleLoader {
325
312
  stack: hasStringProperty(e, 'stack') ? e.stack : undefined
326
313
  });
327
314
  }
328
- return handleFileLoadError(e);
315
+ return handleException(e);
316
+ }
317
+ }
318
+ buildLocatorInfo(input) {
319
+ if (typeof input === 'string') {
320
+ return pathToLocatorInfo(input);
329
321
  }
322
+ return input;
330
323
  }
331
324
  constructor(){
332
325
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -346,21 +339,21 @@ class ModuleLoader {
346
339
 
347
340
  class JSONLoader {
348
341
  async execute(input) {
349
- const filePath = buildLoaderFilePath(input, true);
342
+ const filePath = buildFilePath(input);
350
343
  try {
351
344
  const file = await fs.promises.readFile(filePath);
352
345
  return JSON.parse(file.toString('utf-8'));
353
346
  } catch (e) {
354
- return handleFileLoadError(e);
347
+ return handleException(e);
355
348
  }
356
349
  }
357
350
  executeSync(input) {
358
- const filePath = buildLoaderFilePath(input, true);
351
+ const filePath = buildFilePath(input);
359
352
  try {
360
353
  const file = fs.readFileSync(filePath);
361
354
  return JSON.parse(file.toString('utf-8'));
362
355
  } catch (e) {
363
- return handleFileLoadError(e);
356
+ return handleException(e);
364
357
  }
365
358
  }
366
359
  }
@@ -416,7 +409,7 @@ class LoaderManager {
416
409
  if (test.indexOf(info.extension) !== -1) {
417
410
  return this.rules[i].loader;
418
411
  }
419
- } else if (test.test(buildLoaderFilePath(info))) {
412
+ } else if (test.test(buildFilePath(info))) {
420
413
  return this.rules[i].loader;
421
414
  }
422
415
  }
@@ -518,23 +511,43 @@ async function load(input) {
518
511
  if (typeof input === 'string') {
519
512
  return manager.execute(input);
520
513
  }
521
- return manager.execute(buildLoaderFilePath(input, true));
514
+ return manager.execute(buildFilePath(input));
522
515
  }
523
516
  function loadSync(input) {
524
517
  const manager = useLoader();
525
518
  if (typeof input === 'string') {
526
519
  return manager.executeSync(input);
527
520
  }
528
- return manager.executeSync(buildLoaderFilePath(input, true));
521
+ return manager.executeSync(buildFilePath(input));
522
+ }
523
+
524
+ function getExportItem(data, filterFn) {
525
+ if (filterFn) {
526
+ const keys = Object.keys(data);
527
+ for(let i = 0; i < keys.length; i++){
528
+ if (filterFn(keys[i], data[keys[i]])) {
529
+ return {
530
+ key: keys[i],
531
+ value: data[keys[i]]
532
+ };
533
+ }
534
+ }
535
+ throw new ebec.BaseError('Cannot find specific module export.');
536
+ }
537
+ return {
538
+ key: 'default',
539
+ value: hasOwnProperty(data, 'default') ? data.default : data
540
+ };
529
541
  }
530
542
 
531
543
  exports.JSONLoader = JSONLoader;
532
544
  exports.LoaderManager = LoaderManager;
533
545
  exports.ModuleLoader = ModuleLoader;
534
- exports.buildLoaderFilePath = buildLoaderFilePath;
546
+ exports.buildFilePath = buildFilePath;
547
+ exports.buildFilePathWithoutExtension = buildFilePathWithoutExtension;
535
548
  exports.buildLocatorOptions = buildLocatorOptions;
536
549
  exports.getExportItem = getExportItem;
537
- exports.handleFileLoadError = handleFileLoadError;
550
+ exports.handleException = handleException;
538
551
  exports.hasOwnProperty = hasOwnProperty;
539
552
  exports.hasStringProperty = hasStringProperty;
540
553
  exports.isFilePath = isFilePath;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/utils/error.ts","../src/utils/file-name.ts","../src/utils/has-property.ts","../src/utils/object.ts","../src/utils/to-array.ts","../src/locator/utils.ts","../src/locator/async.ts","../src/locator/sync.ts","../src/loader/utils.ts","../src/loader/built-in/module/utils.ts","../src/loader/built-in/module/module.ts","../src/loader/built-in/json/module.ts","../src/loader/constants.ts","../src/loader/module.ts","../src/loader/singleton.ts","../src/loader/helpers.ts"],"sourcesContent":["/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\n/* istanbul ignore next */\nexport function handleFileLoadError(e: unknown) : void {\n if (e instanceof Error) {\n throw e;\n }\n\n if (typeof e === 'string') {\n throw new Error(e);\n }\n\n throw new Error('Cannot determine file loading error.');\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function removeFileNameExtension(\n input: string,\n extensions?: string[],\n) {\n if (input.includes('.')) {\n const position = input.lastIndexOf('.');\n const extension = input.substring(\n position,\n input.length,\n );\n\n if (\n typeof extensions === 'undefined' ||\n extensions.indexOf(extension) !== -1\n ) {\n input = input.substring(0, position);\n }\n }\n\n return input;\n}\n","export function hasOwnProperty<X extends Record<string, any>, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown> {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nexport function hasStringProperty<X extends Record<string, any>, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, string> {\n return hasOwnProperty(obj, prop) && typeof obj[prop] === 'string';\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function isObject(item: unknown) : item is Record<string, any> {\n return (\n !!item &&\n typeof item === 'object' &&\n !Array.isArray(item)\n );\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function toArray(input: string | string[]) : string[] {\n return Array.isArray(input) ? input : [input];\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\nimport type { LocatorInfo, LocatorOptions } from './type';\nimport { toArray } from '../utils';\n\nexport function buildLocatorOptions(options?: Partial<LocatorOptions>) : LocatorOptions {\n options = options || {};\n\n options.path = options.path || [];\n options.path = toArray(options.path);\n if (options.path.length === 0) {\n options.path.push(process.cwd());\n }\n\n options.ignore ??= [];\n\n return options as LocatorOptions;\n}\n\nexport function isFilePath(input: string) {\n const info = path.parse(input);\n return info.ext !== '';\n}\n\nexport function pathToLocatorInfo(\n input: string,\n skipResolve?: boolean,\n) : LocatorInfo {\n if (\n !skipResolve &&\n !path.isAbsolute(input)\n ) {\n input = path.resolve(process.cwd(), input);\n }\n\n const info = path.parse(input);\n\n return {\n path: info.dir.split('/').join(path.sep),\n name: info.name,\n extension: info.ext,\n };\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport glob from 'glob';\nimport { promisify } from 'node:util';\nimport type { LocatorInfo, LocatorOptions } from './type';\nimport { buildLocatorOptions, pathToLocatorInfo } from './utils';\n\nconst globAsync = promisify(glob);\n\nexport async function locateMany(\n pattern: string | string[],\n options?: Partial<LocatorOptions>,\n) : Promise<LocatorInfo[]> {\n options = buildLocatorOptions(options);\n\n const patterns = Array.isArray(pattern) ?\n pattern :\n [pattern];\n\n const items : LocatorInfo[] = [];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < (options as LocatorOptions).path.length; j++) {\n const files = await globAsync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n nodir: true,\n ignore: options.ignore,\n });\n\n for (let k = 0; k < files.length; k++) {\n items.push(pathToLocatorInfo(files[k] as string, true));\n }\n }\n }\n\n return items;\n}\n\nexport async function locate(\n pattern: string | string[],\n options?: Partial<LocatorOptions>,\n) : Promise<LocatorInfo | undefined> {\n options = buildLocatorOptions(options);\n\n const patterns = Array.isArray(pattern) ?\n pattern :\n [pattern];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < (options as LocatorOptions).path.length; j++) {\n const files = await globAsync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n nodir: true,\n ignore: options.ignore,\n });\n\n const element = files.shift();\n if (element) {\n return pathToLocatorInfo(element, true);\n }\n }\n }\n\n return undefined;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport glob from 'glob';\nimport type { LocatorInfo, LocatorOptions } from './type';\nimport { buildLocatorOptions, pathToLocatorInfo } from './utils';\n\nexport function locateManySync(\n pattern: string | string[],\n options?: Partial<LocatorOptions>,\n) : LocatorInfo[] {\n options = buildLocatorOptions(options);\n\n const patterns = Array.isArray(pattern) ?\n pattern :\n [pattern];\n\n const items : LocatorInfo[] = [];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < (options as LocatorOptions).path.length; j++) {\n const files = glob.sync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n nodir: true,\n ignore: options.ignore,\n });\n\n for (let k = 0; k < files.length; k++) {\n items.push(pathToLocatorInfo(files[k] as string, true));\n }\n }\n }\n\n return items;\n}\n\nexport function locateSync(\n pattern: string | string[],\n options?: Partial<LocatorOptions>,\n) : LocatorInfo | undefined {\n options = buildLocatorOptions(options);\n\n const patterns = Array.isArray(pattern) ?\n pattern :\n [pattern];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < (options as LocatorOptions).path.length; j++) {\n const files = glob.sync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n nodir: true,\n ignore: options.ignore,\n });\n\n const element = files.shift();\n if (element) {\n return pathToLocatorInfo(element, true);\n }\n }\n }\n\n return undefined;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { BaseError } from 'ebec';\nimport path from 'node:path';\nimport type { LocatorInfo } from '../locator';\nimport { pathToLocatorInfo } from '../locator';\nimport { hasOwnProperty } from '../utils';\nimport type { LoaderFilterFn, ScriptFileExportItem } from './built-in';\n\nexport function buildLoaderFilePath(input: LocatorInfo | string, withExtension?: boolean) {\n let info: LocatorInfo;\n\n if (typeof input === 'string') {\n info = pathToLocatorInfo(input);\n } else {\n info = input;\n }\n\n if (\n withExtension &&\n info.extension\n ) {\n return path.join(info.path, info.name) + info.extension;\n }\n\n return path.join(info.path, info.name);\n}\n\nexport function getExportItem(\n data: Record<string, any>,\n filterFn?: LoaderFilterFn,\n): ScriptFileExportItem {\n if (filterFn) {\n const keys = Object.keys(data);\n for (let i = 0; i < keys.length; i++) {\n if (filterFn(keys[i] as string, data[keys[i] as string])) {\n return {\n key: keys[i] as string,\n value: data[keys[i] as string],\n };\n }\n }\n\n throw new BaseError('Cannot find specific module export.');\n }\n\n return {\n key: 'default',\n value: hasOwnProperty(data, 'default') ? data.default : data,\n };\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function isJestRuntimeEnvironment() : boolean {\n return process.env &&\n process.env.JEST_WORKER_ID !== undefined;\n}\n\nexport function isTsNodeRuntimeEnvironment() : boolean {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return !!process[Symbol.for('ts-node.register.instance')];\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { BaseError } from 'ebec';\nimport type { JITI } from 'jiti';\nimport createJITI from 'jiti';\nimport { pathToFileURL } from 'node:url';\nimport type { LocatorInfo } from '../../../locator';\nimport { pathToLocatorInfo } from '../../../locator';\nimport { handleFileLoadError, hasStringProperty, isObject } from '../../../utils';\nimport type { Loader } from '../../type';\nimport { buildLoaderFilePath } from '../../utils';\nimport type { ScriptFileLoadOptions } from './type';\nimport { isJestRuntimeEnvironment, isTsNodeRuntimeEnvironment } from './utils';\n\nexport class ModuleLoader implements Loader {\n protected jiti : JITI;\n\n constructor() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.jiti = createJITI(undefined, {\n extensions: ['.js', '.mjs', '.mts', '.cjs', '.cts', '.ts'],\n });\n }\n\n async execute(input: string) {\n let output : any;\n\n try {\n output = await this.load(input);\n } catch (e) {\n // jiti + ts-node\n // issue: https://github.com/nuxt/bridge/issues/228\n if (isTsNodeRuntimeEnvironment()) {\n output = this.loadSync(input);\n } else {\n output = this.jiti(input);\n }\n }\n\n return output;\n }\n\n executeSync(input: string) {\n let output : any;\n\n try {\n output = this.loadSync(input);\n } catch (e) {\n output = this.jiti(input);\n }\n\n return output;\n }\n\n // ---------------------------------------------------------------------------\n\n async load(\n data: LocatorInfo | string,\n options?: ScriptFileLoadOptions,\n ) : Promise<unknown> {\n let locatorInfo : LocatorInfo;\n\n if (typeof data === 'string') {\n locatorInfo = pathToLocatorInfo(data);\n } else {\n locatorInfo = data;\n }\n\n options = options || {};\n\n let filePath = buildLoaderFilePath(locatorInfo, options.withExtension);\n if (options.withFilePrefix) {\n filePath = pathToFileURL(filePath).href;\n }\n\n try {\n // segmentation fault\n // issue: https://github.com/nodejs/node/issues/35889\n if (isJestRuntimeEnvironment()) {\n // eslint-disable-next-line global-require,import/no-dynamic-require\n return require(filePath);\n }\n\n return await import(filePath);\n } catch (e) {\n /* istanbul ignore next */\n if (\n isObject(e) &&\n hasStringProperty(e, 'code')\n ) {\n if (\n !options.withExtension &&\n (\n e.code === 'ERR_MODULE_NOT_FOUND' ||\n e.code === 'MODULE_NOT_FOUND'\n )\n ) {\n return this.load(locatorInfo, {\n ...options,\n withExtension: true,\n });\n }\n\n if (\n !options.withFilePrefix &&\n (\n e.code === 'ERR_UNSUPPORTED_ESM_URL_SCHEME' ||\n e.code === 'UNSUPPORTED_ESM_URL_SCHEME'\n )\n ) {\n return this.load(locatorInfo, {\n ...options,\n withFilePrefix: true,\n });\n }\n\n throw new BaseError({\n code: e.code,\n message: hasStringProperty(e, 'message') ? e.message : undefined,\n stack: hasStringProperty(e, 'stack') ? e.stack : undefined,\n });\n }\n\n /* istanbul ignore next */\n return handleFileLoadError(e);\n }\n }\n\n loadSync(\n data: LocatorInfo | string,\n options?: ScriptFileLoadOptions,\n ) : unknown {\n let locatorInfo : LocatorInfo;\n\n if (typeof data === 'string') {\n locatorInfo = pathToLocatorInfo(data);\n } else {\n locatorInfo = data;\n }\n\n options = options || {};\n\n const filePath = buildLoaderFilePath(locatorInfo, options.withExtension);\n\n try {\n // eslint-disable-next-line global-require,import/no-dynamic-require\n return require(filePath);\n } catch (e) {\n /* istanbul ignore next */\n if (\n isObject(e) &&\n hasStringProperty(e, 'code')\n ) {\n if (\n !options.withExtension &&\n (\n e.code === 'ERR_MODULE_NOT_FOUND' ||\n e.code === 'MODULE_NOT_FOUND'\n )\n ) {\n return this.loadSync(locatorInfo, {\n ...options,\n withExtension: true,\n });\n }\n\n throw new BaseError({\n code: e.code,\n message: hasStringProperty(e, 'message') ? e.message : undefined,\n stack: hasStringProperty(e, 'stack') ? e.stack : undefined,\n });\n }\n\n return handleFileLoadError(e);\n }\n }\n}\n","/*\n * Copyright (c) 2022-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport fs from 'node:fs';\nimport { handleFileLoadError } from '../../../utils';\nimport type { Loader } from '../../type';\nimport { buildLoaderFilePath } from '../../utils';\n\nexport class JSONLoader implements Loader {\n async execute(input: string) {\n const filePath = buildLoaderFilePath(input, true);\n\n try {\n const file = await fs.promises.readFile(filePath);\n return JSON.parse(file.toString('utf-8'));\n } catch (e) {\n return handleFileLoadError(e);\n }\n }\n\n executeSync(input: string) {\n const filePath = buildLoaderFilePath(input, true);\n\n try {\n const file = fs.readFileSync(filePath);\n return JSON.parse(file.toString('utf-8'));\n } catch (e) {\n return handleFileLoadError(e);\n }\n }\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum LoaderId {\n MODULE = 'module',\n JSON = 'json',\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\nimport { isFilePath, pathToLocatorInfo } from '../locator';\nimport { JSONLoader, ModuleLoader } from './built-in';\nimport { LoaderId } from './constants';\nimport type { Loader, Rule } from './type';\nimport { buildLoaderFilePath } from './utils';\n\nexport class LoaderManager implements Loader {\n protected loaders : Record<string, Loader>;\n\n protected rules : Rule[];\n\n constructor() {\n this.loaders = {};\n this.rules = [\n {\n test: ['.js', '.mjs', '.mts', '.cjs', '.cts', '.ts'],\n loader: LoaderId.MODULE,\n },\n {\n test: ['.json'], loader: LoaderId.JSON,\n },\n ];\n }\n\n register(rule: Rule) : void;\n\n register(test: string[] | RegExp, loader: Loader) : void;\n\n register(test: any, loader?: Loader) : void {\n if (typeof loader !== 'undefined') {\n this.rules.push({ test, loader });\n return;\n }\n\n this.rules.push(test);\n }\n\n async execute(input: string) : Promise<any> {\n const id = this.findLoader(input);\n if (!id) {\n const info = pathToLocatorInfo(input);\n throw new Error(`No loader registered for extension: \"${info.extension}\"`);\n }\n\n const loader = this.resolve(id);\n return loader.execute(input);\n }\n\n executeSync(input: string) : any {\n const id = this.findLoader(input);\n if (!id) {\n const info = pathToLocatorInfo(input);\n throw new Error(`No loader registered for extension: ${info.extension || 'unknown'}`);\n }\n\n const loader = this.resolve(id);\n return loader.executeSync(input);\n }\n\n findLoader(input: string) : Loader | string | undefined {\n if (!isFilePath(input)) {\n return LoaderId.MODULE;\n }\n\n const info = pathToLocatorInfo(input);\n for (let i = 0; i < this.rules.length; i++) {\n const { test } = this.rules[i] as Rule;\n if (Array.isArray(test)) {\n if (test.indexOf(info.extension) !== -1) {\n return this.rules[i].loader;\n }\n } else if (test.test(buildLoaderFilePath(info))) {\n return this.rules[i].loader;\n }\n }\n\n return undefined;\n }\n\n /**\n * Resolve loader by id.\n *\n * @param id\n */\n resolve(id: string | Loader) : Loader {\n if (typeof id !== 'string') {\n return id;\n }\n\n if (Object.prototype.hasOwnProperty.call(this.loaders, id)) {\n return this.loaders[id] as Loader;\n }\n\n let loader : Loader | undefined;\n\n // built-in\n switch (id) {\n case LoaderId.MODULE: {\n loader = new ModuleLoader();\n break;\n }\n case LoaderId.JSON: {\n loader = new JSONLoader();\n break;\n }\n /* istanbul ignore next */\n default: {\n const pluginPath = this.normalizePath(id);\n const moduleLoader = this.resolve(LoaderId.MODULE);\n loader = moduleLoader.executeSync(pluginPath);\n\n break;\n }\n }\n\n if (typeof loader !== 'undefined') {\n this.loaders[id] = loader;\n\n return loader;\n }\n\n throw new Error(`The loader ${id} could not be resolved.`);\n }\n\n /* istanbul ignore next */\n normalizePath(input: string) {\n if (path.isAbsolute(input) || input.startsWith('./')) {\n return input;\n }\n\n if (input.startsWith('module:')) {\n return input.substring(0, 'module:'.length);\n }\n\n if (!input.startsWith('@')) {\n return `@locter/${input}`;\n }\n\n return input;\n }\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { LoaderManager } from './module';\n\nlet instance : LoaderManager;\nexport function useLoader() {\n if (typeof instance !== 'undefined') {\n return instance;\n }\n\n instance = new LoaderManager();\n\n return instance;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { LocatorInfo } from '../locator';\nimport { useLoader } from './singleton';\nimport type { Loader, Rule } from './type';\nimport { buildLoaderFilePath } from './utils';\n\nexport function registerLoader(rule: Rule) : void;\nexport function registerLoader(test: string[] | RegExp, loader: Loader) : void;\nexport function registerLoader(test: any, loader?: Loader) : void {\n const manager = useLoader();\n if (typeof loader !== 'undefined') {\n manager.register(test, loader);\n\n return;\n }\n\n manager.register(test);\n}\n\nexport async function load(input: LocatorInfo | string) : Promise<any> {\n const manager = useLoader();\n if (typeof input === 'string') {\n return manager.execute(input);\n }\n\n return manager.execute(buildLoaderFilePath(input, true));\n}\n\nexport function loadSync(input: LocatorInfo | string) : any {\n const manager = useLoader();\n if (typeof input === 'string') {\n return manager.executeSync(input);\n }\n\n return manager.executeSync(buildLoaderFilePath(input, true));\n}\n"],"names":["handleFileLoadError","e","Error","removeFileNameExtension","input","extensions","includes","position","lastIndexOf","extension","substring","length","indexOf","hasOwnProperty","obj","prop","Object","prototype","call","hasStringProperty","isObject","item","Array","isArray","toArray","options","buildLocatorOptions","path","push","process","cwd","ignore","isFilePath","info","parse","ext","pathToLocatorInfo","skipResolve","isAbsolute","resolve","dir","split","join","sep","name","globAsync","promisify","glob","locateMany","pattern","patterns","items","i","j","files","absolute","nodir","k","locate","element","shift","undefined","locateManySync","sync","locateSync","buildLoaderFilePath","withExtension","getExportItem","data","filterFn","keys","key","value","BaseError","default","isJestRuntimeEnvironment","env","JEST_WORKER_ID","isTsNodeRuntimeEnvironment","Symbol","for","ModuleLoader","execute","output","load","loadSync","jiti","executeSync","locatorInfo","filePath","withFilePrefix","pathToFileURL","href","require","code","message","stack","constructor","createJITI","JSONLoader","file","fs","promises","readFile","JSON","toString","readFileSync","LoaderId","MODULE","LoaderManager","register","test","loader","rules","id","findLoader","loaders","pluginPath","normalizePath","moduleLoader","startsWith","instance","useLoader","registerLoader","manager"],"mappings":";;;;;;;;;;AAAA;;;;;AAKC,+BAGM,SAASA,mBAAAA,CAAoBC,CAAU,EAAS;AACnD,IAAA,IAAIA,aAAaC,KAAO,EAAA;AACpB,QAAA,MAAMD,CAAE,CAAA;KACX;IAED,IAAI,OAAOA,MAAM,QAAU,EAAA;QACvB,MAAM,IAAIC,MAAMD,CAAG,CAAA,CAAA;KACtB;IAED,MAAM,IAAIC,MAAM,sCAAwC,CAAA,CAAA;AAC5D;;AClBA;;;;;AAKC,IAEM,SAASC,uBAAAA,CACZC,KAAa,EACbC,UAAqB,EACvB;IACE,IAAID,KAAAA,CAAME,QAAQ,CAAC,GAAM,CAAA,EAAA;QACrB,MAAMC,QAAAA,GAAWH,KAAMI,CAAAA,WAAW,CAAC,GAAA,CAAA,CAAA;AACnC,QAAA,MAAMC,YAAYL,KAAMM,CAAAA,SAAS,CAC7BH,QAAAA,EACAH,MAAMO,MAAM,CAAA,CAAA;QAGhB,IACI,OAAON,eAAe,WACtBA,IAAAA,UAAAA,CAAWO,OAAO,CAACH,SAAAA,CAAAA,KAAe,CAAC,CACrC,EAAA;YACEL,KAAQA,GAAAA,KAAAA,CAAMM,SAAS,CAAC,CAAGH,EAAAA,QAAAA,CAAAA,CAAAA;SAC9B;KACJ;IAED,OAAOH,KAAAA,CAAAA;AACX;;AC3BO,SAASS,cAAAA,CAAqEC,GAAM,EAAEC,IAAO,EAAiC;AACjI,IAAA,OAAOC,OAAOC,SAAS,CAACJ,cAAc,CAACK,IAAI,CAACJ,GAAKC,EAAAA,IAAAA,CAAAA,CAAAA;AACrD,CAAC;AAEM,SAASI,iBAAAA,CAAwEL,GAAM,EAAEC,IAAO,EAAgC;AACnI,IAAA,OAAOF,eAAeC,GA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error.ts","../src/utils/file-name.ts","../src/utils/to-array.ts","../src/utils/file-path.ts","../src/locator/utils.ts","../src/locator/async.ts","../src/locator/sync.ts","../src/loader/built-in/module/utils.ts","../src/loader/built-in/module/module.ts","../src/loader/built-in/json/module.ts","../src/loader/constants.ts","../src/loader/module.ts","../src/loader/singleton.ts","../src/loader/helpers.ts","../src/loader/utils.ts"],"sourcesContent":["export function hasOwnProperty<X extends Record<string, any>, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown> {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nexport function hasStringProperty<X extends Record<string, any>, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, string> {\n return hasOwnProperty(obj, prop) && typeof obj[prop] === 'string';\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function isObject(item: unknown) : item is Record<string, any> {\n return (\n !!item &&\n typeof item === 'object' &&\n !Array.isArray(item)\n );\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { hasOwnProperty } from './has-property';\nimport { isObject } from './object';\n\nexport function handleException(e: unknown) : void {\n if (e instanceof Error) {\n throw e;\n }\n\n const error = new Error('Can not process thrown exception.');\n\n if (isObject(e)) {\n if (\n hasOwnProperty(e, 'message') &&\n typeof e.message === 'string'\n ) {\n error.message = e.message;\n }\n\n if (\n hasOwnProperty(e, 'stack') &&\n typeof e.stack === 'string'\n ) {\n error.stack = e.stack;\n }\n }\n\n throw error;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function removeFileNameExtension(\n input: string,\n extensions?: string[],\n) {\n if (input.includes('.')) {\n const position = input.lastIndexOf('.');\n const extension = input.substring(\n position,\n input.length,\n );\n\n if (\n typeof extensions === 'undefined' ||\n extensions.indexOf(extension) !== -1\n ) {\n input = input.substring(0, position);\n }\n }\n\n return input;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function toArray(input: string | string[]) : string[] {\n return Array.isArray(input) ? input : [input];\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\nimport path from 'node:path';\nimport type { LocatorInfo } from '../locator';\nimport { pathToLocatorInfo } from '../locator';\n\nexport function buildFilePath(input: LocatorInfo | string) {\n if (typeof input === 'string') {\n return input;\n }\n\n if (input.extension) {\n return path.join(input.path, input.name) + input.extension;\n }\n\n return path.join(input.path, input.name);\n}\n\nexport function buildFilePathWithoutExtension(input: LocatorInfo | string) {\n let info: LocatorInfo;\n\n if (typeof input === 'string') {\n info = pathToLocatorInfo(input);\n } else {\n info = input;\n }\n\n return path.join(info.path, info.name);\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\nimport type { LocatorInfo, LocatorOptions } from './type';\nimport { toArray } from '../utils';\n\nexport function buildLocatorOptions(options?: Partial<LocatorOptions>) : LocatorOptions {\n options = options || {};\n\n options.path = options.path || [];\n options.path = toArray(options.path);\n if (options.path.length === 0) {\n options.path.push(process.cwd());\n }\n\n options.ignore ??= [];\n\n return options as LocatorOptions;\n}\n\nexport function isFilePath(input: string) {\n const info = path.parse(input);\n return info.ext !== '';\n}\n\nexport function pathToLocatorInfo(\n input: string,\n skipResolve?: boolean,\n) : LocatorInfo {\n if (\n !skipResolve &&\n !path.isAbsolute(input)\n ) {\n input = path.resolve(process.cwd(), input);\n }\n\n const info = path.parse(input);\n\n return {\n path: info.dir.split('/').join(path.sep),\n name: info.name,\n extension: info.ext,\n };\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { glob } from 'glob';\nimport type { LocatorInfo, LocatorOptions } from './type';\nimport { buildLocatorOptions, pathToLocatorInfo } from './utils';\n\nexport async function locateMany(\n pattern: string | string[],\n options?: Partial<LocatorOptions>,\n) : Promise<LocatorInfo[]> {\n options = buildLocatorOptions(options);\n\n const patterns = Array.isArray(pattern) ?\n pattern :\n [pattern];\n\n const items : LocatorInfo[] = [];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < (options as LocatorOptions).path.length; j++) {\n const files = await glob(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n nodir: true,\n ignore: options.ignore,\n });\n\n for (let k = 0; k < files.length; k++) {\n items.push(pathToLocatorInfo(files[k] as string, true));\n }\n }\n }\n\n return items;\n}\n\nexport async function locate(\n pattern: string | string[],\n options?: Partial<LocatorOptions>,\n) : Promise<LocatorInfo | undefined> {\n options = buildLocatorOptions(options);\n\n const patterns = Array.isArray(pattern) ?\n pattern :\n [pattern];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < (options as LocatorOptions).path.length; j++) {\n const files = await glob(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n nodir: true,\n ignore: options.ignore,\n });\n\n const element = files.shift();\n if (element) {\n return pathToLocatorInfo(element, true);\n }\n }\n }\n\n return undefined;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { globSync } from 'glob';\nimport type { LocatorInfo, LocatorOptions } from './type';\nimport { buildLocatorOptions, pathToLocatorInfo } from './utils';\n\nexport function locateManySync(\n pattern: string | string[],\n options?: Partial<LocatorOptions>,\n) : LocatorInfo[] {\n options = buildLocatorOptions(options);\n\n const patterns = Array.isArray(pattern) ?\n pattern :\n [pattern];\n\n const items : LocatorInfo[] = [];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < (options as LocatorOptions).path.length; j++) {\n const files = globSync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n nodir: true,\n ignore: options.ignore,\n });\n\n for (let k = 0; k < files.length; k++) {\n items.push(pathToLocatorInfo(files[k] as string, true));\n }\n }\n }\n\n return items;\n}\n\nexport function locateSync(\n pattern: string | string[],\n options?: Partial<LocatorOptions>,\n) : LocatorInfo | undefined {\n options = buildLocatorOptions(options);\n\n const patterns = Array.isArray(pattern) ?\n pattern :\n [pattern];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < (options as LocatorOptions).path.length; j++) {\n const files = globSync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n nodir: true,\n ignore: options.ignore,\n });\n\n const element = files.shift();\n if (element) {\n return pathToLocatorInfo(element, true);\n }\n }\n }\n\n return undefined;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function isJestRuntimeEnvironment() : boolean {\n return process.env &&\n process.env.JEST_WORKER_ID !== undefined;\n}\n\nexport function isTsNodeRuntimeEnvironment() : boolean {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return !!process[Symbol.for('ts-node.register.instance')];\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { BaseError } from 'ebec';\nimport type { JITI } from 'jiti';\nimport createJITI from 'jiti';\nimport { pathToFileURL } from 'node:url';\nimport type { LocatorInfo } from '../../../locator';\nimport { pathToLocatorInfo } from '../../../locator';\nimport {\n buildFilePath, buildFilePathWithoutExtension, handleException, hasStringProperty, isObject,\n} from '../../../utils';\nimport type { Loader } from '../../type';\nimport type { ScriptFileLoadOptions } from './type';\nimport { isJestRuntimeEnvironment, isTsNodeRuntimeEnvironment } from './utils';\n\nexport class ModuleLoader implements Loader {\n protected jiti : JITI;\n\n constructor() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.jiti = createJITI(undefined, {\n extensions: ['.js', '.mjs', '.mts', '.cjs', '.cts', '.ts'],\n });\n }\n\n async execute(input: string) {\n let output : any;\n\n try {\n output = await this.load(input);\n } catch (e) {\n // jiti + ts-node\n // issue: https://github.com/nuxt/bridge/issues/228\n if (isTsNodeRuntimeEnvironment()) {\n output = this.loadSync(input);\n } else {\n output = this.jiti(input);\n }\n }\n\n return output;\n }\n\n executeSync(input: string) {\n let output : any;\n\n try {\n output = this.loadSync(input);\n } catch (e) {\n output = this.jiti(input);\n }\n\n return output;\n }\n\n // ---------------------------------------------------------------------------\n\n async load(\n data: LocatorInfo | string,\n options?: ScriptFileLoadOptions,\n ) : Promise<unknown> {\n const locatorInfo = this.buildLocatorInfo(data);\n\n options = options || {};\n\n let filePath : string;\n if (options.withExtension) {\n filePath = buildFilePath(locatorInfo);\n } else {\n filePath = buildFilePathWithoutExtension(locatorInfo);\n }\n\n if (options.withFilePrefix) {\n filePath = pathToFileURL(filePath).href;\n }\n\n try {\n // segmentation fault\n // issue: https://github.com/nodejs/node/issues/35889\n if (isJestRuntimeEnvironment()) {\n // eslint-disable-next-line global-require,import/no-dynamic-require\n return require(filePath);\n }\n\n return await import(filePath);\n } catch (e) {\n /* istanbul ignore next */\n if (\n isObject(e) &&\n hasStringProperty(e, 'code')\n ) {\n if (\n !options.withExtension &&\n (\n e.code === 'ERR_MODULE_NOT_FOUND' ||\n e.code === 'MODULE_NOT_FOUND'\n )\n ) {\n return this.load(locatorInfo, {\n ...options,\n withExtension: true,\n });\n }\n\n if (\n !options.withFilePrefix &&\n (\n e.code === 'ERR_UNSUPPORTED_ESM_URL_SCHEME' ||\n e.code === 'UNSUPPORTED_ESM_URL_SCHEME'\n )\n ) {\n return this.load(locatorInfo, {\n ...options,\n withFilePrefix: true,\n });\n }\n\n throw new BaseError({\n code: e.code,\n message: hasStringProperty(e, 'message') ? e.message : undefined,\n stack: hasStringProperty(e, 'stack') ? e.stack : undefined,\n });\n }\n\n /* istanbul ignore next */\n return handleException(e);\n }\n }\n\n loadSync(\n data: LocatorInfo | string,\n options?: ScriptFileLoadOptions,\n ) : unknown {\n const locatorInfo = this.buildLocatorInfo(data);\n\n options = options || {};\n\n let filePath : string;\n if (options.withExtension) {\n filePath = buildFilePath(locatorInfo);\n } else {\n filePath = buildFilePathWithoutExtension(locatorInfo);\n }\n\n try {\n // eslint-disable-next-line global-require,import/no-dynamic-require\n return require(filePath);\n } catch (e) {\n /* istanbul ignore next */\n if (\n isObject(e) &&\n hasStringProperty(e, 'code')\n ) {\n if (\n !options.withExtension &&\n (\n e.code === 'ERR_MODULE_NOT_FOUND' ||\n e.code === 'MODULE_NOT_FOUND'\n )\n ) {\n return this.loadSync(locatorInfo, {\n ...options,\n withExtension: true,\n });\n }\n\n throw new BaseError({\n code: e.code,\n message: hasStringProperty(e, 'message') ? e.message : undefined,\n stack: hasStringProperty(e, 'stack') ? e.stack : undefined,\n });\n }\n\n return handleException(e);\n }\n }\n\n private buildLocatorInfo(input: LocatorInfo | string) : LocatorInfo {\n if (typeof input === 'string') {\n return pathToLocatorInfo(input);\n }\n\n return input;\n }\n}\n","/*\n * Copyright (c) 2022-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport fs from 'node:fs';\nimport { buildFilePath, handleException } from '../../../utils';\nimport type { Loader } from '../../type';\n\nexport class JSONLoader implements Loader {\n async execute(input: string) {\n const filePath = buildFilePath(input);\n\n try {\n const file = await fs.promises.readFile(filePath);\n return JSON.parse(file.toString('utf-8'));\n } catch (e) {\n return handleException(e);\n }\n }\n\n executeSync(input: string) {\n const filePath = buildFilePath(input);\n\n try {\n const file = fs.readFileSync(filePath);\n return JSON.parse(file.toString('utf-8'));\n } catch (e) {\n return handleException(e);\n }\n }\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum LoaderId {\n MODULE = 'module',\n JSON = 'json',\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\nimport { isFilePath, pathToLocatorInfo } from '../locator';\nimport { buildFilePath } from '../utils';\nimport { JSONLoader, ModuleLoader } from './built-in';\nimport { LoaderId } from './constants';\nimport type { Loader, Rule } from './type';\n\nexport class LoaderManager implements Loader {\n protected loaders : Record<string, Loader>;\n\n protected rules : Rule[];\n\n constructor() {\n this.loaders = {};\n this.rules = [\n {\n test: ['.js', '.mjs', '.mts', '.cjs', '.cts', '.ts'],\n loader: LoaderId.MODULE,\n },\n {\n test: ['.json'], loader: LoaderId.JSON,\n },\n ];\n }\n\n register(rule: Rule) : void;\n\n register(test: string[] | RegExp, loader: Loader) : void;\n\n register(test: any, loader?: Loader) : void {\n if (typeof loader !== 'undefined') {\n this.rules.push({ test, loader });\n return;\n }\n\n this.rules.push(test);\n }\n\n async execute(input: string) : Promise<any> {\n const id = this.findLoader(input);\n if (!id) {\n const info = pathToLocatorInfo(input);\n throw new Error(`No loader registered for extension: \"${info.extension}\"`);\n }\n\n const loader = this.resolve(id);\n return loader.execute(input);\n }\n\n executeSync(input: string) : any {\n const id = this.findLoader(input);\n if (!id) {\n const info = pathToLocatorInfo(input);\n throw new Error(`No loader registered for extension: ${info.extension || 'unknown'}`);\n }\n\n const loader = this.resolve(id);\n return loader.executeSync(input);\n }\n\n findLoader(input: string) : Loader | string | undefined {\n if (!isFilePath(input)) {\n return LoaderId.MODULE;\n }\n\n const info = pathToLocatorInfo(input);\n for (let i = 0; i < this.rules.length; i++) {\n const { test } = this.rules[i] as Rule;\n if (Array.isArray(test)) {\n if (test.indexOf(info.extension) !== -1) {\n return this.rules[i].loader;\n }\n } else if (test.test(buildFilePath(info))) {\n return this.rules[i].loader;\n }\n }\n\n return undefined;\n }\n\n /**\n * Resolve loader by id.\n *\n * @param id\n */\n resolve(id: string | Loader) : Loader {\n if (typeof id !== 'string') {\n return id;\n }\n\n if (Object.prototype.hasOwnProperty.call(this.loaders, id)) {\n return this.loaders[id] as Loader;\n }\n\n let loader : Loader | undefined;\n\n // built-in\n switch (id) {\n case LoaderId.MODULE: {\n loader = new ModuleLoader();\n break;\n }\n case LoaderId.JSON: {\n loader = new JSONLoader();\n break;\n }\n /* istanbul ignore next */\n default: {\n const pluginPath = this.normalizePath(id);\n const moduleLoader = this.resolve(LoaderId.MODULE);\n loader = moduleLoader.executeSync(pluginPath);\n\n break;\n }\n }\n\n if (typeof loader !== 'undefined') {\n this.loaders[id] = loader;\n\n return loader;\n }\n\n throw new Error(`The loader ${id} could not be resolved.`);\n }\n\n /* istanbul ignore next */\n normalizePath(input: string) {\n if (path.isAbsolute(input) || input.startsWith('./')) {\n return input;\n }\n\n if (input.startsWith('module:')) {\n return input.substring(0, 'module:'.length);\n }\n\n if (!input.startsWith('@')) {\n return `@locter/${input}`;\n }\n\n return input;\n }\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { LoaderManager } from './module';\n\nlet instance : LoaderManager;\nexport function useLoader() {\n if (typeof instance !== 'undefined') {\n return instance;\n }\n\n instance = new LoaderManager();\n\n return instance;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { LocatorInfo } from '../locator';\nimport { buildFilePath } from '../utils';\nimport { useLoader } from './singleton';\nimport type { Loader, Rule } from './type';\n\nexport function registerLoader(rule: Rule) : void;\nexport function registerLoader(test: string[] | RegExp, loader: Loader) : void;\nexport function registerLoader(test: any, loader?: Loader) : void {\n const manager = useLoader();\n if (typeof loader !== 'undefined') {\n manager.register(test, loader);\n\n return;\n }\n\n manager.register(test);\n}\n\nexport async function load(input: LocatorInfo | string) : Promise<any> {\n const manager = useLoader();\n if (typeof input === 'string') {\n return manager.execute(input);\n }\n\n return manager.execute(buildFilePath(input));\n}\n\nexport function loadSync(input: LocatorInfo | string) : any {\n const manager = useLoader();\n if (typeof input === 'string') {\n return manager.executeSync(input);\n }\n\n return manager.executeSync(buildFilePath(input));\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { BaseError } from 'ebec';\nimport { hasOwnProperty } from '../utils';\nimport type { LoaderFilterFn, ScriptFileExportItem } from './built-in';\n\nexport function getExportItem(\n data: Record<string, any>,\n filterFn?: LoaderFilterFn,\n): ScriptFileExportItem {\n if (filterFn) {\n const keys = Object.keys(data);\n for (let i = 0; i < keys.length; i++) {\n if (filterFn(keys[i] as string, data[keys[i] as string])) {\n return {\n key: keys[i] as string,\n value: data[keys[i] as string],\n };\n }\n }\n\n throw new BaseError('Cannot find specific module export.');\n }\n\n return {\n key: 'default',\n value: hasOwnProperty(data, 'default') ? data.default : data,\n };\n}\n"],"names":["hasOwnProperty","obj","prop","Object","prototype","call","hasStringProperty","isObject","item","Array","isArray","handleException","e","Error","error","message","stack","removeFileNameExtension","input","extensions","includes","position","lastIndexOf","extension","substring","length","indexOf","toArray","buildFilePath","path","join","name","buildFilePathWithoutExtension","info","pathToLocatorInfo","options","buildLocatorOptions","push","process","cwd","ignore","isFilePath","parse","ext","skipResolve","isAbsolute","resolve","dir","split","sep","locateMany","pattern","patterns","items","i","j","files","glob","absolute","nodir","k","locate","element","shift","undefined","locateManySync","globSync","locateSync","isJestRuntimeEnvironment","env","JEST_WORKER_ID","isTsNodeRuntimeEnvironment","Symbol","for","ModuleLoader","execute","output","load","loadSync","jiti","executeSync","data","locatorInfo","buildLocatorInfo","filePath","withExtension","withFilePrefix","pathToFileURL","href","require","code","BaseError","constructor","createJITI","JSONLoader","file","fs","promises","readFile","JSON","toString","readFileSync","LoaderId","MODULE","LoaderManager","register","test","loader","rules","id","findLoader","loaders","pluginPath","normalizePath","moduleLoader","startsWith","instance","useLoader","registerLoader","manager","getExportItem","filterFn","keys","key","value","default"],"mappings":";;;;;;;;;AAAO,SAASA,cAAAA,CAAqEC,GAAM,EAAEC,IAAO,EAAiC;AACjI,IAAA,OAAOC,OAAOC,SAAS,CAACJ,cAAc,CAACK,IAAI,CAACJ,GAAKC,EAAAA,IAAAA,CAAAA,CAAAA;AACrD,CAAC;AAEM,SAASI,iBAAAA,CAAwEL,GAAM,EAAEC,IAAO,EAAgC;AACnI,IAAA,OAAOF,eAAeC,GAAKC,EAAAA,IAAAA,CAAAA,IAAS,OAAOD,GAAG,CAACC,KAAK,KAAK,QAAA,CAAA;AAC7D;;ACNA;;;;;AAKC,IAEM,SAASK,QAASC,CAAAA,IAAa,EAAgC;IAClE,OACI,CAAC,CAACA,IACF,IAAA,OAAOA,SAAS,QAChB,IAAA,CAACC,KAAMC,CAAAA,OAAO,CAACF,IAAAA,CAAAA,CAAAA;AAEvB;;ACHO,SAASG,eAAgBC,CAAAA,CAAU,EAAS;AAC/C,IAAA,IAAIA,aAAaC,KAAO,EAAA;AACpB,QAAA,MAAMD,CAAE,CAAA;KACX;IAED,MAAME,KAAAA,GAAQ,IAAID,KAAM,CAAA,mCAAA,CAAA,CAAA;AAExB,IAAA,IAAIN,SAASK,CAAI,CAAA,EAAA;AACb,QAAA,IACIZ,eAAeY,CAAG,EAAA,SAAA,CAAA,IAClB,OAAOA,CAAEG,CAAAA,OAAO,KAAK,QACvB,EAAA;YACED,KAAMC,CAAAA,OAAO,GAAGH,CAAAA,CAAEG,OAAO,CAAA;SAC5B;AAED,QAAA,IACIf,eAAeY,CAAG,EAAA,OAAA,CAAA,IAClB,OAAOA,CAAEI,CAAAA,KAAK,KAAK,QACrB,EAAA;YACEF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AAA,CAASC,IAAI,CAACpE,CAAE,CAAA,EAAY2B,IAAI,CAACyC,IAAI,CAACpE,CAAE,CAAA,CAAW,CAAG,EAAA;gBACtD,OAAO;oBACHqE,GAAKD,EAAAA,IAAI,CAACpE,CAAE,CAAA;AACZsE,oBAAAA,KAAAA,EAAO3C,IAAI,CAACyC,IAAI,CAACpE,EAAE,CAAW;AAClC,iBAAA,CAAA;aACH;AACL,SAAA;QAEA,MAAM,IAAIqC,eAAU,qCAAuC,CAAA,CAAA;KAC9D;IAED,OAAO;QACHgC,GAAK,EAAA,SAAA;AACLC,QAAAA,KAAAA,EAAO5H,eAAeiF,IAAM,EAAA,SAAA,CAAA,GAAaA,IAAK4C,CAAAA,OAAO,GAAG5C,IAAI;AAChE,KAAA,CAAA;AACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.mjs CHANGED
@@ -1,8 +1,7 @@
1
1
  import { BaseError } from 'ebec';
2
2
  import createJITI from 'jiti';
3
3
  import { pathToFileURL } from 'node:url';
4
- import glob from 'glob';
5
- import { promisify } from 'node:util';
4
+ import { glob, globSync } from 'glob';
6
5
  import path from 'node:path';
7
6
  import fs from 'node:fs';
8
7
 
@@ -13,19 +12,36 @@ import __cjs_mod__ from 'module';
13
12
  const __filename = __cjs_url__.fileURLToPath(import.meta.url);
14
13
  const __dirname = __cjs_path__.dirname(__filename);
15
14
  const require = __cjs_mod__.createRequire(import.meta.url);
15
+ function hasOwnProperty(obj, prop) {
16
+ return Object.prototype.hasOwnProperty.call(obj, prop);
17
+ }
18
+ function hasStringProperty(obj, prop) {
19
+ return hasOwnProperty(obj, prop) && typeof obj[prop] === 'string';
20
+ }
21
+
16
22
  /*
17
23
  * Copyright (c) 2022.
18
24
  * Author Peter Placzek (tada5hi)
19
25
  * For the full copyright and license information,
20
26
  * view the LICENSE file that was distributed with this source code.
21
- */ /* istanbul ignore next */ function handleFileLoadError(e) {
27
+ */ function isObject(item) {
28
+ return !!item && typeof item === 'object' && !Array.isArray(item);
29
+ }
30
+
31
+ function handleException(e) {
22
32
  if (e instanceof Error) {
23
33
  throw e;
24
34
  }
25
- if (typeof e === 'string') {
26
- throw new Error(e);
35
+ const error = new Error('Can not process thrown exception.');
36
+ if (isObject(e)) {
37
+ if (hasOwnProperty(e, 'message') && typeof e.message === 'string') {
38
+ error.message = e.message;
39
+ }
40
+ if (hasOwnProperty(e, 'stack') && typeof e.stack === 'string') {
41
+ error.stack = e.stack;
42
+ }
27
43
  }
28
- throw new Error('Cannot determine file loading error.');
44
+ throw error;
29
45
  }
30
46
 
31
47
  /*
@@ -44,22 +60,6 @@ const require = __cjs_mod__.createRequire(import.meta.url);
44
60
  return input;
45
61
  }
46
62
 
47
- function hasOwnProperty(obj, prop) {
48
- return Object.prototype.hasOwnProperty.call(obj, prop);
49
- }
50
- function hasStringProperty(obj, prop) {
51
- return hasOwnProperty(obj, prop) && typeof obj[prop] === 'string';
52
- }
53
-
54
- /*
55
- * Copyright (c) 2022.
56
- * Author Peter Placzek (tada5hi)
57
- * For the full copyright and license information,
58
- * view the LICENSE file that was distributed with this source code.
59
- */ function isObject(item) {
60
- return !!item && typeof item === 'object' && !Array.isArray(item);
61
- }
62
-
63
63
  /*
64
64
  * Copyright (c) 2022.
65
65
  * Author Peter Placzek (tada5hi)
@@ -71,6 +71,25 @@ function hasStringProperty(obj, prop) {
71
71
  ];
72
72
  }
73
73
 
74
+ function buildFilePath(input) {
75
+ if (typeof input === 'string') {
76
+ return input;
77
+ }
78
+ if (input.extension) {
79
+ return path.join(input.path, input.name) + input.extension;
80
+ }
81
+ return path.join(input.path, input.name);
82
+ }
83
+ function buildFilePathWithoutExtension(input) {
84
+ let info;
85
+ if (typeof input === 'string') {
86
+ info = pathToLocatorInfo(input);
87
+ } else {
88
+ info = input;
89
+ }
90
+ return path.join(info.path, info.name);
91
+ }
92
+
74
93
  /*
75
94
  * Copyright (c) 2022.
76
95
  * Author Peter Placzek (tada5hi)
@@ -103,7 +122,6 @@ function pathToLocatorInfo(input, skipResolve) {
103
122
  };
104
123
  }
105
124
 
106
- const globAsync = promisify(glob);
107
125
  async function locateMany(pattern, options) {
108
126
  options = buildLocatorOptions(options);
109
127
  const patterns = Array.isArray(pattern) ? pattern : [
@@ -112,7 +130,7 @@ async function locateMany(pattern, options) {
112
130
  const items = [];
113
131
  for(let i = 0; i < patterns.length; i++){
114
132
  for(let j = 0; j < options.path.length; j++){
115
- const files = await globAsync(patterns[i], {
133
+ const files = await glob(patterns[i], {
116
134
  absolute: true,
117
135
  cwd: options.path[j],
118
136
  nodir: true,
@@ -132,7 +150,7 @@ async function locate(pattern, options) {
132
150
  ];
133
151
  for(let i = 0; i < patterns.length; i++){
134
152
  for(let j = 0; j < options.path.length; j++){
135
- const files = await globAsync(patterns[i], {
153
+ const files = await glob(patterns[i], {
136
154
  absolute: true,
137
155
  cwd: options.path[j],
138
156
  nodir: true,
@@ -155,7 +173,7 @@ function locateManySync(pattern, options) {
155
173
  const items = [];
156
174
  for(let i = 0; i < patterns.length; i++){
157
175
  for(let j = 0; j < options.path.length; j++){
158
- const files = glob.sync(patterns[i], {
176
+ const files = globSync(patterns[i], {
159
177
  absolute: true,
160
178
  cwd: options.path[j],
161
179
  nodir: true,
@@ -175,7 +193,7 @@ function locateSync(pattern, options) {
175
193
  ];
176
194
  for(let i = 0; i < patterns.length; i++){
177
195
  for(let j = 0; j < options.path.length; j++){
178
- const files = glob.sync(patterns[i], {
196
+ const files = globSync(patterns[i], {
179
197
  absolute: true,
180
198
  cwd: options.path[j],
181
199
  nodir: true,
@@ -190,37 +208,6 @@ function locateSync(pattern, options) {
190
208
  return undefined;
191
209
  }
192
210
 
193
- function buildLoaderFilePath(input, withExtension) {
194
- let info;
195
- if (typeof input === 'string') {
196
- info = pathToLocatorInfo(input);
197
- } else {
198
- info = input;
199
- }
200
- if (withExtension && info.extension) {
201
- return path.join(info.path, info.name) + info.extension;
202
- }
203
- return path.join(info.path, info.name);
204
- }
205
- function getExportItem(data, filterFn) {
206
- if (filterFn) {
207
- const keys = Object.keys(data);
208
- for(let i = 0; i < keys.length; i++){
209
- if (filterFn(keys[i], data[keys[i]])) {
210
- return {
211
- key: keys[i],
212
- value: data[keys[i]]
213
- };
214
- }
215
- }
216
- throw new BaseError('Cannot find specific module export.');
217
- }
218
- return {
219
- key: 'default',
220
- value: hasOwnProperty(data, 'default') ? data.default : data
221
- };
222
- }
223
-
224
211
  /*
225
212
  * Copyright (c) 2022.
226
213
  * Author Peter Placzek (tada5hi)
@@ -262,14 +249,14 @@ class ModuleLoader {
262
249
  }
263
250
  // ---------------------------------------------------------------------------
264
251
  async load(data, options) {
265
- let locatorInfo;
266
- if (typeof data === 'string') {
267
- locatorInfo = pathToLocatorInfo(data);
252
+ const locatorInfo = this.buildLocatorInfo(data);
253
+ options = options || {};
254
+ let filePath;
255
+ if (options.withExtension) {
256
+ filePath = buildFilePath(locatorInfo);
268
257
  } else {
269
- locatorInfo = data;
258
+ filePath = buildFilePathWithoutExtension(locatorInfo);
270
259
  }
271
- options = options || {};
272
- let filePath = buildLoaderFilePath(locatorInfo, options.withExtension);
273
260
  if (options.withFilePrefix) {
274
261
  filePath = pathToFileURL(filePath).href;
275
262
  }
@@ -301,18 +288,18 @@ class ModuleLoader {
301
288
  stack: hasStringProperty(e, 'stack') ? e.stack : undefined
302
289
  });
303
290
  }
304
- /* istanbul ignore next */ return handleFileLoadError(e);
291
+ /* istanbul ignore next */ return handleException(e);
305
292
  }
306
293
  }
307
294
  loadSync(data, options) {
308
- let locatorInfo;
309
- if (typeof data === 'string') {
310
- locatorInfo = pathToLocatorInfo(data);
295
+ const locatorInfo = this.buildLocatorInfo(data);
296
+ options = options || {};
297
+ let filePath;
298
+ if (options.withExtension) {
299
+ filePath = buildFilePath(locatorInfo);
311
300
  } else {
312
- locatorInfo = data;
301
+ filePath = buildFilePathWithoutExtension(locatorInfo);
313
302
  }
314
- options = options || {};
315
- const filePath = buildLoaderFilePath(locatorInfo, options.withExtension);
316
303
  try {
317
304
  // eslint-disable-next-line global-require,import/no-dynamic-require
318
305
  return require(filePath);
@@ -330,8 +317,14 @@ class ModuleLoader {
330
317
  stack: hasStringProperty(e, 'stack') ? e.stack : undefined
331
318
  });
332
319
  }
333
- return handleFileLoadError(e);
320
+ return handleException(e);
321
+ }
322
+ }
323
+ buildLocatorInfo(input) {
324
+ if (typeof input === 'string') {
325
+ return pathToLocatorInfo(input);
334
326
  }
327
+ return input;
335
328
  }
336
329
  constructor(){
337
330
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -351,21 +344,21 @@ class ModuleLoader {
351
344
 
352
345
  class JSONLoader {
353
346
  async execute(input) {
354
- const filePath = buildLoaderFilePath(input, true);
347
+ const filePath = buildFilePath(input);
355
348
  try {
356
349
  const file = await fs.promises.readFile(filePath);
357
350
  return JSON.parse(file.toString('utf-8'));
358
351
  } catch (e) {
359
- return handleFileLoadError(e);
352
+ return handleException(e);
360
353
  }
361
354
  }
362
355
  executeSync(input) {
363
- const filePath = buildLoaderFilePath(input, true);
356
+ const filePath = buildFilePath(input);
364
357
  try {
365
358
  const file = fs.readFileSync(filePath);
366
359
  return JSON.parse(file.toString('utf-8'));
367
360
  } catch (e) {
368
- return handleFileLoadError(e);
361
+ return handleException(e);
369
362
  }
370
363
  }
371
364
  }
@@ -421,7 +414,7 @@ class LoaderManager {
421
414
  if (test.indexOf(info.extension) !== -1) {
422
415
  return this.rules[i].loader;
423
416
  }
424
- } else if (test.test(buildLoaderFilePath(info))) {
417
+ } else if (test.test(buildFilePath(info))) {
425
418
  return this.rules[i].loader;
426
419
  }
427
420
  }
@@ -523,15 +516,34 @@ async function load(input) {
523
516
  if (typeof input === 'string') {
524
517
  return manager.execute(input);
525
518
  }
526
- return manager.execute(buildLoaderFilePath(input, true));
519
+ return manager.execute(buildFilePath(input));
527
520
  }
528
521
  function loadSync(input) {
529
522
  const manager = useLoader();
530
523
  if (typeof input === 'string') {
531
524
  return manager.executeSync(input);
532
525
  }
533
- return manager.executeSync(buildLoaderFilePath(input, true));
526
+ return manager.executeSync(buildFilePath(input));
527
+ }
528
+
529
+ function getExportItem(data, filterFn) {
530
+ if (filterFn) {
531
+ const keys = Object.keys(data);
532
+ for(let i = 0; i < keys.length; i++){
533
+ if (filterFn(keys[i], data[keys[i]])) {
534
+ return {
535
+ key: keys[i],
536
+ value: data[keys[i]]
537
+ };
538
+ }
539
+ }
540
+ throw new BaseError('Cannot find specific module export.');
541
+ }
542
+ return {
543
+ key: 'default',
544
+ value: hasOwnProperty(data, 'default') ? data.default : data
545
+ };
534
546
  }
535
547
 
536
- export { JSONLoader, LoaderManager, ModuleLoader, buildLoaderFilePath, buildLocatorOptions, getExportItem, handleFileLoadError, hasOwnProperty, hasStringProperty, isFilePath, isJestRuntimeEnvironment, isObject, isTsNodeRuntimeEnvironment, load, loadSync, locate, locateMany, locateManySync, locateSync, pathToLocatorInfo, registerLoader, removeFileNameExtension, toArray };
548
+ export { JSONLoader, LoaderManager, ModuleLoader, buildFilePath, buildFilePathWithoutExtension, buildLocatorOptions, getExportItem, handleException, hasOwnProperty, hasStringProperty, isFilePath, isJestRuntimeEnvironment, isObject, isTsNodeRuntimeEnvironment, load, loadSync, locate, locateMany, locateManySync, locateSync, pathToLocatorInfo, registerLoader, removeFileNameExtension, toArray };
537
549
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/utils/error.ts","../src/utils/file-name.ts","../src/utils/has-property.ts","../src/utils/object.ts","../src/utils/to-array.ts","../src/locator/utils.ts","../src/locator/async.ts","../src/locator/sync.ts","../src/loader/utils.ts","../src/loader/built-in/module/utils.ts","../src/loader/built-in/module/module.ts","../src/loader/built-in/json/module.ts","../src/loader/constants.ts","../src/loader/module.ts","../src/loader/singleton.ts","../src/loader/helpers.ts"],"sourcesContent":["/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\n/* istanbul ignore next */\nexport function handleFileLoadError(e: unknown) : void {\n if (e instanceof Error) {\n throw e;\n }\n\n if (typeof e === 'string') {\n throw new Error(e);\n }\n\n throw new Error('Cannot determine file loading error.');\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function removeFileNameExtension(\n input: string,\n extensions?: string[],\n) {\n if (input.includes('.')) {\n const position = input.lastIndexOf('.');\n const extension = input.substring(\n position,\n input.length,\n );\n\n if (\n typeof extensions === 'undefined' ||\n extensions.indexOf(extension) !== -1\n ) {\n input = input.substring(0, position);\n }\n }\n\n return input;\n}\n","export function hasOwnProperty<X extends Record<string, any>, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown> {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nexport function hasStringProperty<X extends Record<string, any>, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, string> {\n return hasOwnProperty(obj, prop) && typeof obj[prop] === 'string';\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function isObject(item: unknown) : item is Record<string, any> {\n return (\n !!item &&\n typeof item === 'object' &&\n !Array.isArray(item)\n );\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function toArray(input: string | string[]) : string[] {\n return Array.isArray(input) ? input : [input];\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\nimport type { LocatorInfo, LocatorOptions } from './type';\nimport { toArray } from '../utils';\n\nexport function buildLocatorOptions(options?: Partial<LocatorOptions>) : LocatorOptions {\n options = options || {};\n\n options.path = options.path || [];\n options.path = toArray(options.path);\n if (options.path.length === 0) {\n options.path.push(process.cwd());\n }\n\n options.ignore ??= [];\n\n return options as LocatorOptions;\n}\n\nexport function isFilePath(input: string) {\n const info = path.parse(input);\n return info.ext !== '';\n}\n\nexport function pathToLocatorInfo(\n input: string,\n skipResolve?: boolean,\n) : LocatorInfo {\n if (\n !skipResolve &&\n !path.isAbsolute(input)\n ) {\n input = path.resolve(process.cwd(), input);\n }\n\n const info = path.parse(input);\n\n return {\n path: info.dir.split('/').join(path.sep),\n name: info.name,\n extension: info.ext,\n };\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport glob from 'glob';\nimport { promisify } from 'node:util';\nimport type { LocatorInfo, LocatorOptions } from './type';\nimport { buildLocatorOptions, pathToLocatorInfo } from './utils';\n\nconst globAsync = promisify(glob);\n\nexport async function locateMany(\n pattern: string | string[],\n options?: Partial<LocatorOptions>,\n) : Promise<LocatorInfo[]> {\n options = buildLocatorOptions(options);\n\n const patterns = Array.isArray(pattern) ?\n pattern :\n [pattern];\n\n const items : LocatorInfo[] = [];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < (options as LocatorOptions).path.length; j++) {\n const files = await globAsync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n nodir: true,\n ignore: options.ignore,\n });\n\n for (let k = 0; k < files.length; k++) {\n items.push(pathToLocatorInfo(files[k] as string, true));\n }\n }\n }\n\n return items;\n}\n\nexport async function locate(\n pattern: string | string[],\n options?: Partial<LocatorOptions>,\n) : Promise<LocatorInfo | undefined> {\n options = buildLocatorOptions(options);\n\n const patterns = Array.isArray(pattern) ?\n pattern :\n [pattern];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < (options as LocatorOptions).path.length; j++) {\n const files = await globAsync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n nodir: true,\n ignore: options.ignore,\n });\n\n const element = files.shift();\n if (element) {\n return pathToLocatorInfo(element, true);\n }\n }\n }\n\n return undefined;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport glob from 'glob';\nimport type { LocatorInfo, LocatorOptions } from './type';\nimport { buildLocatorOptions, pathToLocatorInfo } from './utils';\n\nexport function locateManySync(\n pattern: string | string[],\n options?: Partial<LocatorOptions>,\n) : LocatorInfo[] {\n options = buildLocatorOptions(options);\n\n const patterns = Array.isArray(pattern) ?\n pattern :\n [pattern];\n\n const items : LocatorInfo[] = [];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < (options as LocatorOptions).path.length; j++) {\n const files = glob.sync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n nodir: true,\n ignore: options.ignore,\n });\n\n for (let k = 0; k < files.length; k++) {\n items.push(pathToLocatorInfo(files[k] as string, true));\n }\n }\n }\n\n return items;\n}\n\nexport function locateSync(\n pattern: string | string[],\n options?: Partial<LocatorOptions>,\n) : LocatorInfo | undefined {\n options = buildLocatorOptions(options);\n\n const patterns = Array.isArray(pattern) ?\n pattern :\n [pattern];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < (options as LocatorOptions).path.length; j++) {\n const files = glob.sync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n nodir: true,\n ignore: options.ignore,\n });\n\n const element = files.shift();\n if (element) {\n return pathToLocatorInfo(element, true);\n }\n }\n }\n\n return undefined;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { BaseError } from 'ebec';\nimport path from 'node:path';\nimport type { LocatorInfo } from '../locator';\nimport { pathToLocatorInfo } from '../locator';\nimport { hasOwnProperty } from '../utils';\nimport type { LoaderFilterFn, ScriptFileExportItem } from './built-in';\n\nexport function buildLoaderFilePath(input: LocatorInfo | string, withExtension?: boolean) {\n let info: LocatorInfo;\n\n if (typeof input === 'string') {\n info = pathToLocatorInfo(input);\n } else {\n info = input;\n }\n\n if (\n withExtension &&\n info.extension\n ) {\n return path.join(info.path, info.name) + info.extension;\n }\n\n return path.join(info.path, info.name);\n}\n\nexport function getExportItem(\n data: Record<string, any>,\n filterFn?: LoaderFilterFn,\n): ScriptFileExportItem {\n if (filterFn) {\n const keys = Object.keys(data);\n for (let i = 0; i < keys.length; i++) {\n if (filterFn(keys[i] as string, data[keys[i] as string])) {\n return {\n key: keys[i] as string,\n value: data[keys[i] as string],\n };\n }\n }\n\n throw new BaseError('Cannot find specific module export.');\n }\n\n return {\n key: 'default',\n value: hasOwnProperty(data, 'default') ? data.default : data,\n };\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function isJestRuntimeEnvironment() : boolean {\n return process.env &&\n process.env.JEST_WORKER_ID !== undefined;\n}\n\nexport function isTsNodeRuntimeEnvironment() : boolean {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return !!process[Symbol.for('ts-node.register.instance')];\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { BaseError } from 'ebec';\nimport type { JITI } from 'jiti';\nimport createJITI from 'jiti';\nimport { pathToFileURL } from 'node:url';\nimport type { LocatorInfo } from '../../../locator';\nimport { pathToLocatorInfo } from '../../../locator';\nimport { handleFileLoadError, hasStringProperty, isObject } from '../../../utils';\nimport type { Loader } from '../../type';\nimport { buildLoaderFilePath } from '../../utils';\nimport type { ScriptFileLoadOptions } from './type';\nimport { isJestRuntimeEnvironment, isTsNodeRuntimeEnvironment } from './utils';\n\nexport class ModuleLoader implements Loader {\n protected jiti : JITI;\n\n constructor() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.jiti = createJITI(undefined, {\n extensions: ['.js', '.mjs', '.mts', '.cjs', '.cts', '.ts'],\n });\n }\n\n async execute(input: string) {\n let output : any;\n\n try {\n output = await this.load(input);\n } catch (e) {\n // jiti + ts-node\n // issue: https://github.com/nuxt/bridge/issues/228\n if (isTsNodeRuntimeEnvironment()) {\n output = this.loadSync(input);\n } else {\n output = this.jiti(input);\n }\n }\n\n return output;\n }\n\n executeSync(input: string) {\n let output : any;\n\n try {\n output = this.loadSync(input);\n } catch (e) {\n output = this.jiti(input);\n }\n\n return output;\n }\n\n // ---------------------------------------------------------------------------\n\n async load(\n data: LocatorInfo | string,\n options?: ScriptFileLoadOptions,\n ) : Promise<unknown> {\n let locatorInfo : LocatorInfo;\n\n if (typeof data === 'string') {\n locatorInfo = pathToLocatorInfo(data);\n } else {\n locatorInfo = data;\n }\n\n options = options || {};\n\n let filePath = buildLoaderFilePath(locatorInfo, options.withExtension);\n if (options.withFilePrefix) {\n filePath = pathToFileURL(filePath).href;\n }\n\n try {\n // segmentation fault\n // issue: https://github.com/nodejs/node/issues/35889\n if (isJestRuntimeEnvironment()) {\n // eslint-disable-next-line global-require,import/no-dynamic-require\n return require(filePath);\n }\n\n return await import(filePath);\n } catch (e) {\n /* istanbul ignore next */\n if (\n isObject(e) &&\n hasStringProperty(e, 'code')\n ) {\n if (\n !options.withExtension &&\n (\n e.code === 'ERR_MODULE_NOT_FOUND' ||\n e.code === 'MODULE_NOT_FOUND'\n )\n ) {\n return this.load(locatorInfo, {\n ...options,\n withExtension: true,\n });\n }\n\n if (\n !options.withFilePrefix &&\n (\n e.code === 'ERR_UNSUPPORTED_ESM_URL_SCHEME' ||\n e.code === 'UNSUPPORTED_ESM_URL_SCHEME'\n )\n ) {\n return this.load(locatorInfo, {\n ...options,\n withFilePrefix: true,\n });\n }\n\n throw new BaseError({\n code: e.code,\n message: hasStringProperty(e, 'message') ? e.message : undefined,\n stack: hasStringProperty(e, 'stack') ? e.stack : undefined,\n });\n }\n\n /* istanbul ignore next */\n return handleFileLoadError(e);\n }\n }\n\n loadSync(\n data: LocatorInfo | string,\n options?: ScriptFileLoadOptions,\n ) : unknown {\n let locatorInfo : LocatorInfo;\n\n if (typeof data === 'string') {\n locatorInfo = pathToLocatorInfo(data);\n } else {\n locatorInfo = data;\n }\n\n options = options || {};\n\n const filePath = buildLoaderFilePath(locatorInfo, options.withExtension);\n\n try {\n // eslint-disable-next-line global-require,import/no-dynamic-require\n return require(filePath);\n } catch (e) {\n /* istanbul ignore next */\n if (\n isObject(e) &&\n hasStringProperty(e, 'code')\n ) {\n if (\n !options.withExtension &&\n (\n e.code === 'ERR_MODULE_NOT_FOUND' ||\n e.code === 'MODULE_NOT_FOUND'\n )\n ) {\n return this.loadSync(locatorInfo, {\n ...options,\n withExtension: true,\n });\n }\n\n throw new BaseError({\n code: e.code,\n message: hasStringProperty(e, 'message') ? e.message : undefined,\n stack: hasStringProperty(e, 'stack') ? e.stack : undefined,\n });\n }\n\n return handleFileLoadError(e);\n }\n }\n}\n","/*\n * Copyright (c) 2022-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport fs from 'node:fs';\nimport { handleFileLoadError } from '../../../utils';\nimport type { Loader } from '../../type';\nimport { buildLoaderFilePath } from '../../utils';\n\nexport class JSONLoader implements Loader {\n async execute(input: string) {\n const filePath = buildLoaderFilePath(input, true);\n\n try {\n const file = await fs.promises.readFile(filePath);\n return JSON.parse(file.toString('utf-8'));\n } catch (e) {\n return handleFileLoadError(e);\n }\n }\n\n executeSync(input: string) {\n const filePath = buildLoaderFilePath(input, true);\n\n try {\n const file = fs.readFileSync(filePath);\n return JSON.parse(file.toString('utf-8'));\n } catch (e) {\n return handleFileLoadError(e);\n }\n }\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum LoaderId {\n MODULE = 'module',\n JSON = 'json',\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\nimport { isFilePath, pathToLocatorInfo } from '../locator';\nimport { JSONLoader, ModuleLoader } from './built-in';\nimport { LoaderId } from './constants';\nimport type { Loader, Rule } from './type';\nimport { buildLoaderFilePath } from './utils';\n\nexport class LoaderManager implements Loader {\n protected loaders : Record<string, Loader>;\n\n protected rules : Rule[];\n\n constructor() {\n this.loaders = {};\n this.rules = [\n {\n test: ['.js', '.mjs', '.mts', '.cjs', '.cts', '.ts'],\n loader: LoaderId.MODULE,\n },\n {\n test: ['.json'], loader: LoaderId.JSON,\n },\n ];\n }\n\n register(rule: Rule) : void;\n\n register(test: string[] | RegExp, loader: Loader) : void;\n\n register(test: any, loader?: Loader) : void {\n if (typeof loader !== 'undefined') {\n this.rules.push({ test, loader });\n return;\n }\n\n this.rules.push(test);\n }\n\n async execute(input: string) : Promise<any> {\n const id = this.findLoader(input);\n if (!id) {\n const info = pathToLocatorInfo(input);\n throw new Error(`No loader registered for extension: \"${info.extension}\"`);\n }\n\n const loader = this.resolve(id);\n return loader.execute(input);\n }\n\n executeSync(input: string) : any {\n const id = this.findLoader(input);\n if (!id) {\n const info = pathToLocatorInfo(input);\n throw new Error(`No loader registered for extension: ${info.extension || 'unknown'}`);\n }\n\n const loader = this.resolve(id);\n return loader.executeSync(input);\n }\n\n findLoader(input: string) : Loader | string | undefined {\n if (!isFilePath(input)) {\n return LoaderId.MODULE;\n }\n\n const info = pathToLocatorInfo(input);\n for (let i = 0; i < this.rules.length; i++) {\n const { test } = this.rules[i] as Rule;\n if (Array.isArray(test)) {\n if (test.indexOf(info.extension) !== -1) {\n return this.rules[i].loader;\n }\n } else if (test.test(buildLoaderFilePath(info))) {\n return this.rules[i].loader;\n }\n }\n\n return undefined;\n }\n\n /**\n * Resolve loader by id.\n *\n * @param id\n */\n resolve(id: string | Loader) : Loader {\n if (typeof id !== 'string') {\n return id;\n }\n\n if (Object.prototype.hasOwnProperty.call(this.loaders, id)) {\n return this.loaders[id] as Loader;\n }\n\n let loader : Loader | undefined;\n\n // built-in\n switch (id) {\n case LoaderId.MODULE: {\n loader = new ModuleLoader();\n break;\n }\n case LoaderId.JSON: {\n loader = new JSONLoader();\n break;\n }\n /* istanbul ignore next */\n default: {\n const pluginPath = this.normalizePath(id);\n const moduleLoader = this.resolve(LoaderId.MODULE);\n loader = moduleLoader.executeSync(pluginPath);\n\n break;\n }\n }\n\n if (typeof loader !== 'undefined') {\n this.loaders[id] = loader;\n\n return loader;\n }\n\n throw new Error(`The loader ${id} could not be resolved.`);\n }\n\n /* istanbul ignore next */\n normalizePath(input: string) {\n if (path.isAbsolute(input) || input.startsWith('./')) {\n return input;\n }\n\n if (input.startsWith('module:')) {\n return input.substring(0, 'module:'.length);\n }\n\n if (!input.startsWith('@')) {\n return `@locter/${input}`;\n }\n\n return input;\n }\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { LoaderManager } from './module';\n\nlet instance : LoaderManager;\nexport function useLoader() {\n if (typeof instance !== 'undefined') {\n return instance;\n }\n\n instance = new LoaderManager();\n\n return instance;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { LocatorInfo } from '../locator';\nimport { useLoader } from './singleton';\nimport type { Loader, Rule } from './type';\nimport { buildLoaderFilePath } from './utils';\n\nexport function registerLoader(rule: Rule) : void;\nexport function registerLoader(test: string[] | RegExp, loader: Loader) : void;\nexport function registerLoader(test: any, loader?: Loader) : void {\n const manager = useLoader();\n if (typeof loader !== 'undefined') {\n manager.register(test, loader);\n\n return;\n }\n\n manager.register(test);\n}\n\nexport async function load(input: LocatorInfo | string) : Promise<any> {\n const manager = useLoader();\n if (typeof input === 'string') {\n return manager.execute(input);\n }\n\n return manager.execute(buildLoaderFilePath(input, true));\n}\n\nexport function loadSync(input: LocatorInfo | string) : any {\n const manager = useLoader();\n if (typeof input === 'string') {\n return manager.executeSync(input);\n }\n\n return manager.executeSync(buildLoaderFilePath(input, true));\n}\n"],"names":["input","options","name","extension","pattern","absolute","cwd","nodir","ignore","items","info","value","output","executeSync","locatorInfo","withExtension","withFilePrefix","code","message","stack","LoaderId","test","loader","findLoader","instance","manager"],"mappings":";;;;;;;;;;;;;;;AAAA;;;;;AAKC;AAIG;AACI;;;;;;AAQR;;AClBA;;;;;AAKC;;;AAQO;;;;;;AAcR;;AC3BO;AACH;AACJ;AAEO;AACH;AACJ;;ACNA;;;;;AAKC;;AAQD;;ACbA;;;;;AAKC;AAGG;AAAuCA;AAAM;AACjD;;ACTA;;;;;;AAWO;AACHC;AAEAA;AACAA;AACA;AACIA;;AAGJA;;AAGJ;AAEO;;;AAGP;AAEO;AAIH;AAIID;;;;;AAOAE;AACAC;AACJ;AACJ;;ACpCA;AAEO;AAIHF;AAEA;AAEKG;AAAQ;AAEb;AAEA;;AAEQ;AACIC;AACAC;AACAC;AACAC;AACJ;AAEA;AACIC;AACJ;AACJ;AACJ;;AAGJ;AAEO;AAIHR;AAEA;AAEKG;AAAQ;AAEb;;AAEQ;AACIC;AACAC;AACAC;AACAC;AACJ;;AAGA;;;AAGJ;AACJ;;AAGJ;;AC5DO;AAIHP;AAEA;AAEKG;AAAQ;AAEb;AAEA;;AAEQ;AACIC;AACAC;AACAC;AACAC;AACJ;AAEA;AACIC;AACJ;AACJ;AACJ;;AAGJ;AAEO;AAIHR;AAEA;AAEKG;AAAQ;AAEb;;AAEQ;AACIC;AACAC;AACAC;AACAC;AACJ;;AAGA;;;AAGJ;AACJ;;AAGJ;;ACtDO;;;AAICE;;;;;;;AAYJ;AACJ;AAEO;AAIH;;AAEI;;;;AAIYC;AACJ;;AAER;;;;;AAOAA;AACJ;AACJ;;ACvDA;;;;;;AAQ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 {"version":3,"file":"index.mjs","sources":["../src/utils/has-property.ts","../src/utils/object.ts","../src/utils/error.ts","../src/utils/file-name.ts","../src/utils/to-array.ts","../src/utils/file-path.ts","../src/locator/utils.ts","../src/locator/async.ts","../src/locator/sync.ts","../src/loader/built-in/module/utils.ts","../src/loader/built-in/module/module.ts","../src/loader/built-in/json/module.ts","../src/loader/constants.ts","../src/loader/module.ts","../src/loader/singleton.ts","../src/loader/helpers.ts","../src/loader/utils.ts"],"sourcesContent":["export function hasOwnProperty<X extends Record<string, any>, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown> {\n return Object.prototype.hasOwnProperty.call(obj, prop);\n}\n\nexport function hasStringProperty<X extends Record<string, any>, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, string> {\n return hasOwnProperty(obj, prop) && typeof obj[prop] === 'string';\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function isObject(item: unknown) : item is Record<string, any> {\n return (\n !!item &&\n typeof item === 'object' &&\n !Array.isArray(item)\n );\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { hasOwnProperty } from './has-property';\nimport { isObject } from './object';\n\nexport function handleException(e: unknown) : void {\n if (e instanceof Error) {\n throw e;\n }\n\n const error = new Error('Can not process thrown exception.');\n\n if (isObject(e)) {\n if (\n hasOwnProperty(e, 'message') &&\n typeof e.message === 'string'\n ) {\n error.message = e.message;\n }\n\n if (\n hasOwnProperty(e, 'stack') &&\n typeof e.stack === 'string'\n ) {\n error.stack = e.stack;\n }\n }\n\n throw error;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function removeFileNameExtension(\n input: string,\n extensions?: string[],\n) {\n if (input.includes('.')) {\n const position = input.lastIndexOf('.');\n const extension = input.substring(\n position,\n input.length,\n );\n\n if (\n typeof extensions === 'undefined' ||\n extensions.indexOf(extension) !== -1\n ) {\n input = input.substring(0, position);\n }\n }\n\n return input;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function toArray(input: string | string[]) : string[] {\n return Array.isArray(input) ? input : [input];\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\nimport path from 'node:path';\nimport type { LocatorInfo } from '../locator';\nimport { pathToLocatorInfo } from '../locator';\n\nexport function buildFilePath(input: LocatorInfo | string) {\n if (typeof input === 'string') {\n return input;\n }\n\n if (input.extension) {\n return path.join(input.path, input.name) + input.extension;\n }\n\n return path.join(input.path, input.name);\n}\n\nexport function buildFilePathWithoutExtension(input: LocatorInfo | string) {\n let info: LocatorInfo;\n\n if (typeof input === 'string') {\n info = pathToLocatorInfo(input);\n } else {\n info = input;\n }\n\n return path.join(info.path, info.name);\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\nimport type { LocatorInfo, LocatorOptions } from './type';\nimport { toArray } from '../utils';\n\nexport function buildLocatorOptions(options?: Partial<LocatorOptions>) : LocatorOptions {\n options = options || {};\n\n options.path = options.path || [];\n options.path = toArray(options.path);\n if (options.path.length === 0) {\n options.path.push(process.cwd());\n }\n\n options.ignore ??= [];\n\n return options as LocatorOptions;\n}\n\nexport function isFilePath(input: string) {\n const info = path.parse(input);\n return info.ext !== '';\n}\n\nexport function pathToLocatorInfo(\n input: string,\n skipResolve?: boolean,\n) : LocatorInfo {\n if (\n !skipResolve &&\n !path.isAbsolute(input)\n ) {\n input = path.resolve(process.cwd(), input);\n }\n\n const info = path.parse(input);\n\n return {\n path: info.dir.split('/').join(path.sep),\n name: info.name,\n extension: info.ext,\n };\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { glob } from 'glob';\nimport type { LocatorInfo, LocatorOptions } from './type';\nimport { buildLocatorOptions, pathToLocatorInfo } from './utils';\n\nexport async function locateMany(\n pattern: string | string[],\n options?: Partial<LocatorOptions>,\n) : Promise<LocatorInfo[]> {\n options = buildLocatorOptions(options);\n\n const patterns = Array.isArray(pattern) ?\n pattern :\n [pattern];\n\n const items : LocatorInfo[] = [];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < (options as LocatorOptions).path.length; j++) {\n const files = await glob(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n nodir: true,\n ignore: options.ignore,\n });\n\n for (let k = 0; k < files.length; k++) {\n items.push(pathToLocatorInfo(files[k] as string, true));\n }\n }\n }\n\n return items;\n}\n\nexport async function locate(\n pattern: string | string[],\n options?: Partial<LocatorOptions>,\n) : Promise<LocatorInfo | undefined> {\n options = buildLocatorOptions(options);\n\n const patterns = Array.isArray(pattern) ?\n pattern :\n [pattern];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < (options as LocatorOptions).path.length; j++) {\n const files = await glob(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n nodir: true,\n ignore: options.ignore,\n });\n\n const element = files.shift();\n if (element) {\n return pathToLocatorInfo(element, true);\n }\n }\n }\n\n return undefined;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { globSync } from 'glob';\nimport type { LocatorInfo, LocatorOptions } from './type';\nimport { buildLocatorOptions, pathToLocatorInfo } from './utils';\n\nexport function locateManySync(\n pattern: string | string[],\n options?: Partial<LocatorOptions>,\n) : LocatorInfo[] {\n options = buildLocatorOptions(options);\n\n const patterns = Array.isArray(pattern) ?\n pattern :\n [pattern];\n\n const items : LocatorInfo[] = [];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < (options as LocatorOptions).path.length; j++) {\n const files = globSync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n nodir: true,\n ignore: options.ignore,\n });\n\n for (let k = 0; k < files.length; k++) {\n items.push(pathToLocatorInfo(files[k] as string, true));\n }\n }\n }\n\n return items;\n}\n\nexport function locateSync(\n pattern: string | string[],\n options?: Partial<LocatorOptions>,\n) : LocatorInfo | undefined {\n options = buildLocatorOptions(options);\n\n const patterns = Array.isArray(pattern) ?\n pattern :\n [pattern];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < (options as LocatorOptions).path.length; j++) {\n const files = globSync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n nodir: true,\n ignore: options.ignore,\n });\n\n const element = files.shift();\n if (element) {\n return pathToLocatorInfo(element, true);\n }\n }\n }\n\n return undefined;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport function isJestRuntimeEnvironment() : boolean {\n return process.env &&\n process.env.JEST_WORKER_ID !== undefined;\n}\n\nexport function isTsNodeRuntimeEnvironment() : boolean {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return !!process[Symbol.for('ts-node.register.instance')];\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { BaseError } from 'ebec';\nimport type { JITI } from 'jiti';\nimport createJITI from 'jiti';\nimport { pathToFileURL } from 'node:url';\nimport type { LocatorInfo } from '../../../locator';\nimport { pathToLocatorInfo } from '../../../locator';\nimport {\n buildFilePath, buildFilePathWithoutExtension, handleException, hasStringProperty, isObject,\n} from '../../../utils';\nimport type { Loader } from '../../type';\nimport type { ScriptFileLoadOptions } from './type';\nimport { isJestRuntimeEnvironment, isTsNodeRuntimeEnvironment } from './utils';\n\nexport class ModuleLoader implements Loader {\n protected jiti : JITI;\n\n constructor() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.jiti = createJITI(undefined, {\n extensions: ['.js', '.mjs', '.mts', '.cjs', '.cts', '.ts'],\n });\n }\n\n async execute(input: string) {\n let output : any;\n\n try {\n output = await this.load(input);\n } catch (e) {\n // jiti + ts-node\n // issue: https://github.com/nuxt/bridge/issues/228\n if (isTsNodeRuntimeEnvironment()) {\n output = this.loadSync(input);\n } else {\n output = this.jiti(input);\n }\n }\n\n return output;\n }\n\n executeSync(input: string) {\n let output : any;\n\n try {\n output = this.loadSync(input);\n } catch (e) {\n output = this.jiti(input);\n }\n\n return output;\n }\n\n // ---------------------------------------------------------------------------\n\n async load(\n data: LocatorInfo | string,\n options?: ScriptFileLoadOptions,\n ) : Promise<unknown> {\n const locatorInfo = this.buildLocatorInfo(data);\n\n options = options || {};\n\n let filePath : string;\n if (options.withExtension) {\n filePath = buildFilePath(locatorInfo);\n } else {\n filePath = buildFilePathWithoutExtension(locatorInfo);\n }\n\n if (options.withFilePrefix) {\n filePath = pathToFileURL(filePath).href;\n }\n\n try {\n // segmentation fault\n // issue: https://github.com/nodejs/node/issues/35889\n if (isJestRuntimeEnvironment()) {\n // eslint-disable-next-line global-require,import/no-dynamic-require\n return require(filePath);\n }\n\n return await import(filePath);\n } catch (e) {\n /* istanbul ignore next */\n if (\n isObject(e) &&\n hasStringProperty(e, 'code')\n ) {\n if (\n !options.withExtension &&\n (\n e.code === 'ERR_MODULE_NOT_FOUND' ||\n e.code === 'MODULE_NOT_FOUND'\n )\n ) {\n return this.load(locatorInfo, {\n ...options,\n withExtension: true,\n });\n }\n\n if (\n !options.withFilePrefix &&\n (\n e.code === 'ERR_UNSUPPORTED_ESM_URL_SCHEME' ||\n e.code === 'UNSUPPORTED_ESM_URL_SCHEME'\n )\n ) {\n return this.load(locatorInfo, {\n ...options,\n withFilePrefix: true,\n });\n }\n\n throw new BaseError({\n code: e.code,\n message: hasStringProperty(e, 'message') ? e.message : undefined,\n stack: hasStringProperty(e, 'stack') ? e.stack : undefined,\n });\n }\n\n /* istanbul ignore next */\n return handleException(e);\n }\n }\n\n loadSync(\n data: LocatorInfo | string,\n options?: ScriptFileLoadOptions,\n ) : unknown {\n const locatorInfo = this.buildLocatorInfo(data);\n\n options = options || {};\n\n let filePath : string;\n if (options.withExtension) {\n filePath = buildFilePath(locatorInfo);\n } else {\n filePath = buildFilePathWithoutExtension(locatorInfo);\n }\n\n try {\n // eslint-disable-next-line global-require,import/no-dynamic-require\n return require(filePath);\n } catch (e) {\n /* istanbul ignore next */\n if (\n isObject(e) &&\n hasStringProperty(e, 'code')\n ) {\n if (\n !options.withExtension &&\n (\n e.code === 'ERR_MODULE_NOT_FOUND' ||\n e.code === 'MODULE_NOT_FOUND'\n )\n ) {\n return this.loadSync(locatorInfo, {\n ...options,\n withExtension: true,\n });\n }\n\n throw new BaseError({\n code: e.code,\n message: hasStringProperty(e, 'message') ? e.message : undefined,\n stack: hasStringProperty(e, 'stack') ? e.stack : undefined,\n });\n }\n\n return handleException(e);\n }\n }\n\n private buildLocatorInfo(input: LocatorInfo | string) : LocatorInfo {\n if (typeof input === 'string') {\n return pathToLocatorInfo(input);\n }\n\n return input;\n }\n}\n","/*\n * Copyright (c) 2022-2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport fs from 'node:fs';\nimport { buildFilePath, handleException } from '../../../utils';\nimport type { Loader } from '../../type';\n\nexport class JSONLoader implements Loader {\n async execute(input: string) {\n const filePath = buildFilePath(input);\n\n try {\n const file = await fs.promises.readFile(filePath);\n return JSON.parse(file.toString('utf-8'));\n } catch (e) {\n return handleException(e);\n }\n }\n\n executeSync(input: string) {\n const filePath = buildFilePath(input);\n\n try {\n const file = fs.readFileSync(filePath);\n return JSON.parse(file.toString('utf-8'));\n } catch (e) {\n return handleException(e);\n }\n }\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nexport enum LoaderId {\n MODULE = 'module',\n JSON = 'json',\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport path from 'node:path';\nimport { isFilePath, pathToLocatorInfo } from '../locator';\nimport { buildFilePath } from '../utils';\nimport { JSONLoader, ModuleLoader } from './built-in';\nimport { LoaderId } from './constants';\nimport type { Loader, Rule } from './type';\n\nexport class LoaderManager implements Loader {\n protected loaders : Record<string, Loader>;\n\n protected rules : Rule[];\n\n constructor() {\n this.loaders = {};\n this.rules = [\n {\n test: ['.js', '.mjs', '.mts', '.cjs', '.cts', '.ts'],\n loader: LoaderId.MODULE,\n },\n {\n test: ['.json'], loader: LoaderId.JSON,\n },\n ];\n }\n\n register(rule: Rule) : void;\n\n register(test: string[] | RegExp, loader: Loader) : void;\n\n register(test: any, loader?: Loader) : void {\n if (typeof loader !== 'undefined') {\n this.rules.push({ test, loader });\n return;\n }\n\n this.rules.push(test);\n }\n\n async execute(input: string) : Promise<any> {\n const id = this.findLoader(input);\n if (!id) {\n const info = pathToLocatorInfo(input);\n throw new Error(`No loader registered for extension: \"${info.extension}\"`);\n }\n\n const loader = this.resolve(id);\n return loader.execute(input);\n }\n\n executeSync(input: string) : any {\n const id = this.findLoader(input);\n if (!id) {\n const info = pathToLocatorInfo(input);\n throw new Error(`No loader registered for extension: ${info.extension || 'unknown'}`);\n }\n\n const loader = this.resolve(id);\n return loader.executeSync(input);\n }\n\n findLoader(input: string) : Loader | string | undefined {\n if (!isFilePath(input)) {\n return LoaderId.MODULE;\n }\n\n const info = pathToLocatorInfo(input);\n for (let i = 0; i < this.rules.length; i++) {\n const { test } = this.rules[i] as Rule;\n if (Array.isArray(test)) {\n if (test.indexOf(info.extension) !== -1) {\n return this.rules[i].loader;\n }\n } else if (test.test(buildFilePath(info))) {\n return this.rules[i].loader;\n }\n }\n\n return undefined;\n }\n\n /**\n * Resolve loader by id.\n *\n * @param id\n */\n resolve(id: string | Loader) : Loader {\n if (typeof id !== 'string') {\n return id;\n }\n\n if (Object.prototype.hasOwnProperty.call(this.loaders, id)) {\n return this.loaders[id] as Loader;\n }\n\n let loader : Loader | undefined;\n\n // built-in\n switch (id) {\n case LoaderId.MODULE: {\n loader = new ModuleLoader();\n break;\n }\n case LoaderId.JSON: {\n loader = new JSONLoader();\n break;\n }\n /* istanbul ignore next */\n default: {\n const pluginPath = this.normalizePath(id);\n const moduleLoader = this.resolve(LoaderId.MODULE);\n loader = moduleLoader.executeSync(pluginPath);\n\n break;\n }\n }\n\n if (typeof loader !== 'undefined') {\n this.loaders[id] = loader;\n\n return loader;\n }\n\n throw new Error(`The loader ${id} could not be resolved.`);\n }\n\n /* istanbul ignore next */\n normalizePath(input: string) {\n if (path.isAbsolute(input) || input.startsWith('./')) {\n return input;\n }\n\n if (input.startsWith('module:')) {\n return input.substring(0, 'module:'.length);\n }\n\n if (!input.startsWith('@')) {\n return `@locter/${input}`;\n }\n\n return input;\n }\n}\n","/*\n * Copyright (c) 2023.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { LoaderManager } from './module';\n\nlet instance : LoaderManager;\nexport function useLoader() {\n if (typeof instance !== 'undefined') {\n return instance;\n }\n\n instance = new LoaderManager();\n\n return instance;\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport type { LocatorInfo } from '../locator';\nimport { buildFilePath } from '../utils';\nimport { useLoader } from './singleton';\nimport type { Loader, Rule } from './type';\n\nexport function registerLoader(rule: Rule) : void;\nexport function registerLoader(test: string[] | RegExp, loader: Loader) : void;\nexport function registerLoader(test: any, loader?: Loader) : void {\n const manager = useLoader();\n if (typeof loader !== 'undefined') {\n manager.register(test, loader);\n\n return;\n }\n\n manager.register(test);\n}\n\nexport async function load(input: LocatorInfo | string) : Promise<any> {\n const manager = useLoader();\n if (typeof input === 'string') {\n return manager.execute(input);\n }\n\n return manager.execute(buildFilePath(input));\n}\n\nexport function loadSync(input: LocatorInfo | string) : any {\n const manager = useLoader();\n if (typeof input === 'string') {\n return manager.executeSync(input);\n }\n\n return manager.executeSync(buildFilePath(input));\n}\n","/*\n * Copyright (c) 2022.\n * Author Peter Placzek (tada5hi)\n * For the full copyright and license information,\n * view the LICENSE file that was distributed with this source code.\n */\n\nimport { BaseError } from 'ebec';\nimport { hasOwnProperty } from '../utils';\nimport type { LoaderFilterFn, ScriptFileExportItem } from './built-in';\n\nexport function getExportItem(\n data: Record<string, any>,\n filterFn?: LoaderFilterFn,\n): ScriptFileExportItem {\n if (filterFn) {\n const keys = Object.keys(data);\n for (let i = 0; i < keys.length; i++) {\n if (filterFn(keys[i] as string, data[keys[i] as string])) {\n return {\n key: keys[i] as string,\n value: data[keys[i] as string],\n };\n }\n }\n\n throw new BaseError('Cannot find specific module export.');\n }\n\n return {\n key: 'default',\n value: hasOwnProperty(data, 'default') ? data.default : data,\n };\n}\n"],"names":["input","info","options","name","extension","pattern","absolute","cwd","nodir","ignore","items","output","executeSync","filePath","withExtension","withFilePrefix","code","message","stack","buildLocatorInfo","LoaderId","test","loader","findLoader","instance","manager","value"],"mappings":";;;;;;;;;;;;;;AAAO;AACH;AACJ;AAEO;AACH;AACJ;;ACNA;;;;;AAKC;;AAQD;;ACHO;AACH;AACI;;;AAKJ;AACI;;;AAOA;;;;AAQJ;AACJ;;AClCA;;;;;AAKC;;;AAQO;;;;;;AAcR;;AC3BA;;;;;AAKC;AAGG;AAAuCA;AAAM;AACjD;;ACCO;;;;;;;AASH;AACJ;AAEO;;;AAICC;;;;AA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;AACJ;AACJ;AACJ;;ACjCA;;;;;;;AAOYQ;AAAAA;;;ACOL;;;AAwBK;AAAkBC;AAAMC;AAAO;AAC/B;;AAGJ;AACJ;;AAGI;AACA;AACI;;;AAIJ;;AAEJ;AAEAV;AACI;AACA;AACI;;;AAIJ;;AAEJ;AAEAW;;AAEQ;;AAGJ;;;;AAIQ;AACI;;AAER;AACI;;AAER;;AAGJ;AAEA;;;;;;;;;AAWQ;;;;;AAOA;AAAsB;AAClBD;;AAEJ;AACA;AAAoB;AAChBA;;AAEJ;AACA;AACS;AACL;AACA;;;AAIJ;AACJ;;AAGI;;;;AAMR;;AAII;;;;AAKI;;AAGJ;AACI;;;AAIR;;;;AA7HQ;;AACW;AAAO;AAAQ;AAAQ;AAAQ;AAAQ;AAAM;AACpDA;AACJ;AACA;;AACW;AAAQ;AAAEA;AACrB;AACH;AACL;AAsHJ;;AC3IA;AACO;;;;AAKHE;;AAGJ;;ACJO;AACH;;;AAII;;AAGJC;AACJ;AAEO;AACH;;;;;AAMJ;AAEO;AACH;;;;;AAMJ;;AC9BO;AAIH;;AAEI;;;;AAIYC;AACJ;;AAER;;;;;AAOAA;AACJ;AACJ;;"}
@@ -9,4 +9,5 @@ export declare class ModuleLoader implements Loader {
9
9
  executeSync(input: string): any;
10
10
  load(data: LocatorInfo | string, options?: ScriptFileLoadOptions): Promise<unknown>;
11
11
  loadSync(data: LocatorInfo | string, options?: ScriptFileLoadOptions): unknown;
12
+ private buildLocatorInfo;
12
13
  }
@@ -1,4 +1,2 @@
1
- import type { LocatorInfo } from '../locator';
2
1
  import type { LoaderFilterFn, ScriptFileExportItem } from './built-in';
3
- export declare function buildLoaderFilePath(input: LocatorInfo | string, withExtension?: boolean): string;
4
2
  export declare function getExportItem(data: Record<string, any>, filterFn?: LoaderFilterFn): ScriptFileExportItem;
@@ -1 +1 @@
1
- export declare function handleFileLoadError(e: unknown): void;
1
+ export declare function handleException(e: unknown): void;
@@ -0,0 +1,3 @@
1
+ import type { LocatorInfo } from '../locator';
2
+ export declare function buildFilePath(input: LocatorInfo | string): string;
3
+ export declare function buildFilePathWithoutExtension(input: LocatorInfo | string): string;
@@ -3,3 +3,4 @@ export * from './file-name';
3
3
  export * from './has-property';
4
4
  export * from './object';
5
5
  export * from './to-array';
6
+ export * from './file-path';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "locter",
3
- "version": "1.0.5",
4
- "description": "A library to locate a file by criteria and load it",
3
+ "version": "1.0.7",
4
+ "description": "A library to locate a file/module by criteria and load it!",
5
5
  "author": {
6
6
  "name": "Peter Placzek",
7
7
  "email": "contact@tada5hi.net",
@@ -44,14 +44,12 @@
44
44
  "loading",
45
45
  "on-demand-transpiling",
46
46
  "locator",
47
- "file-extension"
47
+ "file-extension",
48
+ "transpiling",
49
+ "typescript"
48
50
  ],
49
51
  "license": "MIT",
50
52
  "devDependencies": {
51
- "@commitlint/cli": "^17.4.3",
52
- "@commitlint/config-angular": "^17.4.3",
53
- "@commitlint/config-conventional": "^17.4.3",
54
- "@commitlint/cz-commitlint": "^17.4.2",
55
53
  "@rollup/plugin-node-resolve": "^15.0.0",
56
54
  "@semantic-release/changelog": "^6.0.2",
57
55
  "@semantic-release/commit-analyzer": "^9.0.2",
@@ -59,33 +57,28 @@
59
57
  "@semantic-release/github": "^8.0.7",
60
58
  "@semantic-release/npm": "^9.0.1",
61
59
  "@semantic-release/release-notes-generator": "^10.0.3",
62
- "@swc/core": "^1.3.35",
60
+ "@swc/core": "^1.3.37",
63
61
  "@swc/jest": "^0.2.24",
62
+ "@tada5hi/commitlint-config": "^1.0.0",
64
63
  "@tada5hi/eslint-config-typescript": "^1.1.4",
65
64
  "@tada5hi/tsconfig": "^0.4.0",
66
- "@types/glob": "^8.0.1",
67
65
  "@types/jest": "^27.5.2",
68
- "@types/node": "^18.13.0",
66
+ "@types/node": "^18.14.5",
69
67
  "cross-env": "^7.0.3",
70
- "eslint": "^8.34.0",
68
+ "eslint": "^8.35.0",
71
69
  "husky": "^8.0.3",
72
70
  "jest": "^27.5.1",
73
- "magic-string": "^0.29.0",
71
+ "magic-string": "^0.30.0",
74
72
  "mlly": "^1.1.1",
75
- "rimraf": "^4.1.2",
76
- "rollup": "^3.15.0",
73
+ "rimraf": "^4.2.0",
74
+ "rollup": "^3.18.0",
77
75
  "semantic-release": "^19.0.5",
78
76
  "sourcemap-codec": "^1.4.8",
79
77
  "typescript": "^4.9.5"
80
78
  },
81
79
  "dependencies": {
82
80
  "ebec": "^0.2.1",
83
- "glob": "^8.1.0",
81
+ "glob": "^9.0.1",
84
82
  "jiti": "^1.17.1"
85
- },
86
- "config": {
87
- "commitizen": {
88
- "path": "@commitlint/cz-commitlint"
89
- }
90
83
  }
91
84
  }