locter 1.3.0 → 2.0.1

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
@@ -79,6 +79,30 @@ function isFilePath(input) {
79
79
  return extension && extension !== '';
80
80
  }
81
81
 
82
+ /*
83
+ * Copyright (c) 2024.
84
+ * Author Peter Placzek (tada5hi)
85
+ * For the full copyright and license information,
86
+ * view the LICENSE file that was distributed with this source code.
87
+ */ function isJestRuntimeEnvironment() {
88
+ return process.env && process.env.JEST_WORKER_ID !== undefined;
89
+ }
90
+ function isTsNodeRuntimeEnvironment() {
91
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
92
+ // @ts-ignore
93
+ return !!process[Symbol.for('ts-node.register.instance')];
94
+ }
95
+
96
+ function isTypeScriptError(input) {
97
+ if (!isObject(input)) {
98
+ return false;
99
+ }
100
+ if (typeof input.diagnosticCodes !== 'undefined') {
101
+ return true;
102
+ }
103
+ return typeof input.message === 'string' && /TS\d+/.test(input.message);
104
+ }
105
+
82
106
  function buildLocatorOptions(options) {
83
107
  var _options;
84
108
  options = options || {};
@@ -289,38 +313,60 @@ class ConfLoader {
289
313
  }
290
314
  }
291
315
 
292
- function isJestRuntimeEnvironment() {
293
- return process.env && process.env.JEST_WORKER_ID !== undefined;
294
- }
295
- function isTsNodeRuntimeEnvironment() {
296
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
297
- // @ts-ignore
298
- return !!process[Symbol.for('ts-node.register.instance')];
316
+ function isESModule(input) {
317
+ return isObject(input) && // eslint-disable-next-line no-underscore-dangle
318
+ typeof input.__esModule !== 'undefined';
299
319
  }
300
- function getModuleExport(data, filterFn) {
301
- if (filterFn) {
302
- const keys = Object.keys(data);
303
- for(let i = 0; i < keys.length; i++){
304
- if (filterFn(keys[i], data[keys[i]])) {
305
- return {
306
- key: keys[i],
307
- value: data[keys[i]]
320
+ // https://2ality.com/2017/01/babel-esm-spec-mode.html
321
+ function toModuleRecord(data) {
322
+ if (isESModule(data)) {
323
+ return data;
324
+ }
325
+ const output = Object.create(null, {
326
+ __esModule: {
327
+ value: true
328
+ },
329
+ [Symbol.toStringTag]: {
330
+ value: 'Module'
331
+ }
332
+ });
333
+ if (isObject(data)) {
334
+ // eslint-disable-next-line no-restricted-syntax
335
+ for(const key in data){
336
+ if (hasOwnProperty(output, key)) {
337
+ continue;
338
+ }
339
+ let descriptor = Object.getOwnPropertyDescriptor(data, key);
340
+ if (!descriptor || 'get' in descriptor || descriptor.writable || descriptor.configurable) {
341
+ descriptor = {
342
+ enumerable: true,
343
+ get () {
344
+ return data[key];
345
+ }
308
346
  };
309
347
  }
348
+ Object.defineProperty(output, key, descriptor);
310
349
  }
311
- throw new ebec.BaseError('Cannot find specific module export.');
312
350
  }
313
- if (// eslint-disable-next-line no-underscore-dangle
314
- typeof data.__esModule !== 'undefined' && typeof data.default !== 'undefined') {
315
- return {
316
- key: 'default',
317
- value: data.default
318
- };
351
+ if (!hasOwnProperty(output, 'default')) {
352
+ Object.defineProperty(output, 'default', {
353
+ value: data,
354
+ enumerable: true
355
+ });
319
356
  }
320
- return {
321
- key: 'default',
322
- value: data
323
- };
357
+ return Object.freeze(output);
358
+ }
359
+ function getModuleExport(data, filterFn) {
360
+ const keys = Object.keys(data);
361
+ for(let i = 0; i < keys.length; i++){
362
+ if (filterFn(keys[i], data[keys[i]])) {
363
+ return {
364
+ key: keys[i],
365
+ value: data[keys[i]]
366
+ };
367
+ }
368
+ }
369
+ return undefined;
324
370
  }
325
371
 
326
372
  class ModuleLoader {
@@ -329,7 +375,7 @@ class ModuleLoader {
329
375
  try {
330
376
  output = await this.load(input);
331
377
  } catch (e) {
332
- if (e instanceof SyntaxError || e instanceof ReferenceError) {
378
+ if (e instanceof SyntaxError || e instanceof ReferenceError || isTypeScriptError(e)) {
333
379
  throw e;
334
380
  }
335
381
  // jiti + ts-node
@@ -340,48 +386,38 @@ class ModuleLoader {
340
386
  output = this.jiti(input);
341
387
  }
342
388
  }
343
- return output;
389
+ return toModuleRecord(output);
344
390
  }
345
391
  executeSync(input) {
346
392
  let output;
347
393
  try {
348
394
  output = this.loadSync(input);
349
395
  } catch (e) {
350
- if (e instanceof SyntaxError || e instanceof ReferenceError) {
396
+ if (e instanceof SyntaxError || e instanceof ReferenceError || isTypeScriptError(e)) {
351
397
  throw e;
352
398
  }
353
399
  output = this.jiti(input);
354
400
  }
355
- return output;
401
+ return toModuleRecord(output);
356
402
  }
357
403
  // ---------------------------------------------------------------------------
358
- async load(data, options) {
359
- options = options || {};
360
- const [name, locatorInfo] = this.build(data, options);
404
+ async load(data, options = {}) {
405
+ const id = this.build(data, options);
361
406
  try {
362
407
  // segmentation fault
363
408
  // issue: https://github.com/nodejs/node/issues/35889
364
409
  if (isJestRuntimeEnvironment()) {
365
410
  // eslint-disable-next-line global-require,import/no-dynamic-require
366
- return require(name);
411
+ return require(id);
367
412
  }
368
- return await import(name);
413
+ return await import(id);
369
414
  } catch (e) {
370
415
  /* istanbul ignore next */ if (isObject(e) && hasStringProperty(e, 'code')) {
371
- if (locatorInfo) {
372
- if (!options.withExtension && (e.code === 'ERR_MODULE_NOT_FOUND' || e.code === 'MODULE_NOT_FOUND')) {
373
- return this.load(locatorInfo, {
374
- ...options,
375
- withExtension: true
376
- });
377
- }
378
- if (!options.withFilePrefix && (e.code === 'ERR_UNSUPPORTED_ESM_URL_SCHEME' || e.code === 'UNSUPPORTED_ESM_URL_SCHEME')) {
379
- return this.load(locatorInfo, {
380
- ...options,
381
- withExtension: true,
382
- withFilePrefix: true
383
- });
384
- }
416
+ if (!options.withFilePrefix && (e.code === 'ERR_UNSUPPORTED_ESM_URL_SCHEME' || e.code === 'UNSUPPORTED_ESM_URL_SCHEME')) {
417
+ return this.load(data, {
418
+ ...options,
419
+ withFilePrefix: true
420
+ });
385
421
  }
386
422
  throw new ebec.BaseError({
387
423
  code: e.code,
@@ -392,22 +428,13 @@ class ModuleLoader {
392
428
  /* istanbul ignore next */ return handleException(e);
393
429
  }
394
430
  }
395
- loadSync(data, options) {
396
- options = options || {};
397
- const [name, locatorInfo] = this.build(data, options);
431
+ loadSync(data, options = {}) {
432
+ const id = this.build(data, options);
398
433
  try {
399
434
  // eslint-disable-next-line global-require,import/no-dynamic-require
400
- return require(name);
435
+ return require(id);
401
436
  } catch (e) {
402
437
  /* istanbul ignore next */ if (isObject(e) && hasStringProperty(e, 'code')) {
403
- if (locatorInfo) {
404
- if (!options.withExtension && (e.code === 'ERR_MODULE_NOT_FOUND' || e.code === 'MODULE_NOT_FOUND')) {
405
- return this.loadSync(locatorInfo, {
406
- ...options,
407
- withExtension: true
408
- });
409
- }
410
- }
411
438
  throw new ebec.BaseError({
412
439
  code: e.code,
413
440
  message: hasStringProperty(e, 'message') ? e.message : undefined,
@@ -417,31 +444,16 @@ class ModuleLoader {
417
444
  return handleException(e);
418
445
  }
419
446
  }
420
- build(data, options) {
421
- let name;
422
- let locatorInfo;
423
- options = options || {};
447
+ build(data, options = {}) {
424
448
  if (isLocatorInfo(data) || isFilePath(data)) {
425
- if (typeof data === 'string') {
426
- locatorInfo = pathToLocatorInfo(data);
427
- } else {
428
- locatorInfo = data;
429
- }
430
- if (options.withExtension) {
431
- name = buildFilePath(locatorInfo);
432
- } else {
433
- name = buildFilePathWithoutExtension(locatorInfo);
449
+ if (typeof data !== 'string') {
450
+ data = buildFilePath(data);
434
451
  }
435
452
  if (options.withFilePrefix) {
436
- name = node_url.pathToFileURL(name).href;
453
+ data = node_url.pathToFileURL(data).href;
437
454
  }
438
- } else {
439
- name = data;
440
455
  }
441
- return [
442
- name,
443
- locatorInfo
444
- ];
456
+ return data;
445
457
  }
446
458
  constructor(){
447
459
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -708,12 +720,14 @@ exports.getModuleExport = getModuleExport;
708
720
  exports.handleException = handleException;
709
721
  exports.hasOwnProperty = hasOwnProperty;
710
722
  exports.hasStringProperty = hasStringProperty;
723
+ exports.isESModule = isESModule;
711
724
  exports.isFilePath = isFilePath;
712
725
  exports.isJestRuntimeEnvironment = isJestRuntimeEnvironment;
713
726
  exports.isLocatorInfo = isLocatorInfo;
714
727
  exports.isObject = isObject;
715
728
  exports.isSafeObjectKey = isSafeObjectKey;
716
729
  exports.isTsNodeRuntimeEnvironment = isTsNodeRuntimeEnvironment;
730
+ exports.isTypeScriptError = isTypeScriptError;
717
731
  exports.load = load;
718
732
  exports.loadSync = loadSync;
719
733
  exports.locate = locate;
@@ -724,4 +738,5 @@ exports.pathToLocatorInfo = pathToLocatorInfo;
724
738
  exports.registerLoader = registerLoader;
725
739
  exports.removeFileNameExtension = removeFileNameExtension;
726
740
  exports.toArray = toArray;
741
+ exports.toModuleRecord = toModuleRecord;
727
742
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","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/conf/module.ts","../src/loader/built-in/module/utils.ts","../src/loader/built-in/module/module.ts","../src/loader/built-in/json/module.ts","../src/loader/built-in/yaml/module.ts","../src/loader/constants.ts","../src/loader/module.ts","../src/loader/singleton.ts","../src/loader/helpers.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\nexport function isSafeObjectKey(key: string) : boolean {\n return key !== '__proto__' &&\n key !== 'prototype' &&\n key !== 'constructor';\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\nimport path from 'node:path';\n\nexport function getFileNameExtension(\n input: string,\n allowed?: string[],\n) : string | undefined {\n const extension = path.extname(input);\n if (extension === '' || extension === '.') {\n return undefined;\n }\n\n if (\n typeof allowed === 'undefined' ||\n allowed.indexOf(extension) !== -1\n ) {\n return extension;\n }\n\n return undefined;\n}\n\nexport function removeFileNameExtension(\n input: string,\n extensions?: string[],\n) {\n const extension = getFileNameExtension(input, extensions);\n if (extension) {\n return input.substring(0, input.length - extension.length);\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';\n\nexport function isFilePath(input: string) {\n const extension = path.extname(input);\n return extension && extension !== '';\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 { isObject, toArray } from '../utils';\nimport type { LocatorInfo, LocatorOptions } from './type';\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 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\nexport function isLocatorInfo(\n input: unknown,\n) : input is LocatorInfo {\n return isObject(input) &&\n typeof input.path === 'string' &&\n typeof input.name === 'string' &&\n typeof input.extension === 'string';\n}\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 fg from 'fast-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 let ignore : string[] | undefined;\n if (options.ignore) {\n ignore = Array.isArray(options.ignore) ? options.ignore : [options.ignore];\n }\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 fg(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n ignore,\n onlyFiles: true,\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 let ignore : string[] | undefined;\n if (options.ignore) {\n ignore = Array.isArray(options.ignore) ? options.ignore : [options.ignore];\n }\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 fg(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n ignore,\n onlyFiles: true,\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 fg from 'fast-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 let ignore : string[] | undefined;\n if (options.ignore) {\n ignore = Array.isArray(options.ignore) ? options.ignore : [options.ignore];\n }\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 = fg.sync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n ignore,\n onlyFiles: true,\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 let ignore : string[] | undefined;\n if (options.ignore) {\n ignore = Array.isArray(options.ignore) ? options.ignore : [options.ignore];\n }\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 = fg.sync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n ignore,\n onlyFiles: true,\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-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\n// Based on https://github.com/unjs/rc9 (MIT)\n\nimport { destr } from 'destr';\nimport flat from 'flat';\nimport fs from 'node:fs';\nimport { buildFilePath } from '../../../locator';\nimport { handleException, isSafeObjectKey } from '../../../utils';\nimport type { Loader } from '../../type';\n\nexport class ConfLoader implements Loader {\n async execute(input: string) {\n const filePath = buildFilePath(input);\n\n try {\n const file = await fs.promises.readFile(filePath, { encoding: 'utf-8' });\n\n return this.parse(file);\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, { encoding: 'utf-8' });\n\n return this.parse(file);\n } catch (e) {\n return handleException(e);\n }\n }\n\n parse(contents: string): Record<string, any> {\n const config: Record<string, any> = {};\n\n const lines = contents.split(/\\n|\\r|\\r\\n/);\n\n for (let i = 0; i < lines.length; i++) {\n const match = lines[i].match(/^\\s*([^\\s=]+)\\s*=\\s*(.*)?\\s*$/);\n if (!match) {\n continue;\n }\n\n // Key\n const key = match[1];\n\n if (!key || !isSafeObjectKey(key)) {\n continue;\n }\n\n const value = destr(match[2].trim() /* val */);\n\n if (key.endsWith('[]')) {\n const arrKey = key.slice(0, Math.max(0, key.length - 2));\n config[arrKey] = (config[arrKey] || []).concat(value);\n continue;\n }\n\n config[key] = value;\n }\n\n return flat.unflatten(config, { overwrite: true });\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 { BaseError } from 'ebec';\nimport type { LoaderFilterFn, ModuleExport } from './type';\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\nexport function getModuleExport(\n data: Record<string, any>,\n filterFn?: LoaderFilterFn,\n): ModuleExport {\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 if (\n // eslint-disable-next-line no-underscore-dangle\n typeof data.__esModule !== 'undefined' &&\n typeof data.default !== 'undefined'\n ) {\n return {\n key: 'default',\n value: data.default,\n };\n }\n\n return {\n key: 'default',\n value: data,\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 { BaseError } from 'ebec';\nimport type { JITI } from 'jiti';\nimport createJITI from 'jiti';\nimport { pathToFileURL } from 'node:url';\nimport type { LocatorInfo } from '../../../locator';\nimport {\n buildFilePath,\n buildFilePathWithoutExtension,\n isLocatorInfo,\n pathToLocatorInfo,\n} from '../../../locator';\nimport {\n handleException,\n hasStringProperty, isFilePath,\n isObject,\n} from '../../../utils';\nimport type { Loader } from '../../type';\nimport type { ModuleLoadOptions } 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 if (\n e instanceof SyntaxError ||\n e instanceof ReferenceError\n ) {\n throw e;\n }\n\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 if (\n e instanceof SyntaxError ||\n e instanceof ReferenceError\n ) {\n throw e;\n }\n\n output = this.jiti(input);\n }\n\n return output;\n }\n\n // ---------------------------------------------------------------------------\n\n async load(\n data: LocatorInfo | string,\n options?: ModuleLoadOptions,\n ) : Promise<unknown> {\n options = options || {};\n const [name, locatorInfo] = this.build(data, options);\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(name);\n }\n\n return await import(name);\n } catch (e) {\n /* istanbul ignore next */\n if (\n isObject(e) &&\n hasStringProperty(e, 'code')\n ) {\n if (locatorInfo) {\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 withExtension: true,\n withFilePrefix: true,\n });\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?: ModuleLoadOptions,\n ) : unknown {\n options = options || {};\n const [name, locatorInfo] = this.build(data, options);\n\n try {\n // eslint-disable-next-line global-require,import/no-dynamic-require\n return require(name);\n } catch (e) {\n /* istanbul ignore next */\n if (\n isObject(e) &&\n hasStringProperty(e, 'code')\n ) {\n if (locatorInfo) {\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\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 build(\n data: LocatorInfo | string,\n options: ModuleLoadOptions,\n ) : [string, LocatorInfo | undefined] {\n let name : string;\n let locatorInfo : LocatorInfo | undefined;\n\n options = options || {};\n\n if (isLocatorInfo(data) || isFilePath(data)) {\n if (typeof data === 'string') {\n locatorInfo = pathToLocatorInfo(data);\n } else {\n locatorInfo = data;\n }\n\n if (options.withExtension) {\n name = buildFilePath(locatorInfo);\n } else {\n name = buildFilePathWithoutExtension(locatorInfo);\n }\n\n if (options.withFilePrefix) {\n name = pathToFileURL(name).href;\n }\n } else {\n name = data;\n }\n\n return [name, locatorInfo];\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 } from '../../../locator';\nimport { 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, { encoding: 'utf-8' });\n return JSON.parse(file);\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, { encoding: 'utf-8' });\n return JSON.parse(file);\n } catch (e) {\n return handleException(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 { parse } from 'yaml';\nimport fs from 'node:fs';\nimport { buildFilePath } from '../../../locator';\nimport { handleException } from '../../../utils';\nimport type { Loader } from '../../type';\n\nexport class YAMLLoader implements Loader {\n async execute(input: string) {\n const filePath = buildFilePath(input);\n\n try {\n const file = await fs.promises.readFile(filePath, { encoding: 'utf-8' });\n return parse(file);\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, { encoding: 'utf-8' });\n return parse(file);\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 CONF = 'conf',\n YAML = 'yaml',\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 { buildFilePath, pathToLocatorInfo } from '../locator';\nimport { isFilePath } from '../utils';\nimport { ConfLoader, JSONLoader, ModuleLoader } from './built-in';\nimport { YAMLLoader } from './built-in/yaml';\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: ['.conf'], loader: LoaderId.CONF,\n },\n {\n test: ['.json'], loader: LoaderId.JSON,\n },\n {\n test: ['.yml'], loader: LoaderId.YAML,\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.CONF: {\n loader = new ConfLoader();\n break;\n }\n case LoaderId.MODULE: {\n loader = new ModuleLoader();\n break;\n }\n case LoaderId.JSON: {\n loader = new JSONLoader();\n break;\n }\n case LoaderId.YAML: {\n loader = new YAMLLoader();\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 { buildFilePath } from '../locator';\nimport type { LocatorInfo } from '../locator';\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"],"names":["hasOwnProperty","obj","prop","Object","prototype","call","hasStringProperty","isObject","item","Array","isArray","isSafeObjectKey","key","handleException","e","Error","error","message","stack","getFileNameExtension","input","allowed","extension","path","extname","undefined","indexOf","removeFileNameExtension","extensions","substring","length","toArray","isFilePath","buildLocatorOptions","options","push","process","cwd","ignore","pathToLocatorInfo","skipResolve","isAbsolute","resolve","info","parse","dir","split","join","sep","name","ext","isLocatorInfo","buildFilePath","buildFilePathWithoutExtension","locateMany","pattern","patterns","items","i","j","files","fg","absolute","onlyFiles","k","locate","element","shift","locateManySync","sync","locateSync","ConfLoader","execute","filePath","file","fs","promises","readFile","encoding","executeSync","readFileSync","contents","config","lines","match","value","destr","trim","endsWith","arrKey","slice","Math","max","concat","flat","unflatten","overwrite","isJestRuntimeEnvironment","env","JEST_WORKER_ID","isTsNodeRuntimeEnvironment","Symbol","for","getModuleExport","data","filterFn","keys","BaseError","__esModule","default","ModuleLoader","output","load","SyntaxError","ReferenceError","loadSync","jiti","locatorInfo","build","require","withExtension","code","withFilePrefix","pathToFileURL","href","constructor","createJITI","JSONLoader","JSON","YAMLLoader","LoaderId","LoaderManager","register","test","loader","rules","id","findLoader","MODULE","loaders","CONF","YAML","pluginPath","normalizePath","moduleLoader","startsWith","instance","useLoader","registerLoader","manager"],"mappings":";;;;;;;;;;;;AAAO,SAASA,cAAAA,CAAqEC,GAAM,EAAEC,IAAO,EAAA;AAChG,IAAA,OAAOC,OAAOC,SAAS,CAACJ,cAAc,CAACK,IAAI,CAACJ,GAAKC,EAAAA,IAAAA,CAAAA,CAAAA;AACrD,CAAA;AAEO,SAASI,iBAAAA,CAAwEL,GAAM,EAAEC,IAAO,EAAA;AACnG,IAAA,OAAOF,eAAeC,GAAKC,EAAAA,IAAAA,CAAAA,IAAS,OAAOD,GAAG,CAACC,KAAK,KAAK,QAAA,CAAA;AAC7D;;ACNA;;;;;IAO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AA;AACrD,IAAA,MAAMe,OAAUF,GAAAA,SAAAA,EAAAA,CAAAA;IAChB,IAAI,OAAOb,WAAW,WAAa,EAAA;QAC/Be,OAAQjB,CAAAA,QAAQ,CAACC,IAAMC,EAAAA,MAAAA,CAAAA,CAAAA;AAEvB,QAAA,OAAA;AACJ,KAAA;AAEAe,IAAAA,OAAAA,CAAQjB,QAAQ,CAACC,IAAAA,CAAAA,CAAAA;AACrB,CAAA;AAEO,eAAerB,KAAK5F,KAA2B,EAAA;AAClD,IAAA,MAAMiI,OAAUF,GAAAA,SAAAA,EAAAA,CAAAA;IAChB,IAAI,OAAO/H,UAAU,QAAU,EAAA;QAC3B,OAAOiI,OAAAA,CAAQ7E,OAAO,CAACpD,KAAAA,CAAAA,CAAAA;AAC3B,KAAA;IAEA,OAAOiI,OAAAA,CAAQ7E,OAAO,CAACpB,aAAchC,CAAAA,KAAAA,CAAAA,CAAAA,CAAAA;AACzC,CAAA;AAEO,SAAS+F,SAAS/F,KAA2B,EAAA;AAChD,IAAA,MAAMiI,OAAUF,GAAAA,SAAAA,EAAAA,CAAAA;IAChB,IAAI,OAAO/H,UAAU,QAAU,EAAA;QAC3B,OAAOiI,OAAAA,CAAQtE,WAAW,CAAC3D,KAAAA,CAAAA,CAAAA;AAC/B,KAAA;IAEA,OAAOiI,OAAAA,CAAQtE,WAAW,CAAC3B,aAAchC,CAAAA,KAAAA,CAAAA,CAAAA,CAAAA;AAC7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","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/utils/runtime.ts","../src/utils/typescript.ts","../src/locator/utils.ts","../src/locator/async.ts","../src/locator/sync.ts","../src/loader/built-in/conf/module.ts","../src/loader/built-in/module/utils.ts","../src/loader/built-in/module/module.ts","../src/loader/built-in/json/module.ts","../src/loader/built-in/yaml/module.ts","../src/loader/constants.ts","../src/loader/module.ts","../src/loader/singleton.ts","../src/loader/helpers.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\nexport function isSafeObjectKey(key: string) : boolean {\n return key !== '__proto__' &&\n key !== 'prototype' &&\n key !== 'constructor';\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\nimport path from 'node:path';\n\nexport function getFileNameExtension(\n input: string,\n allowed?: string[],\n) : string | undefined {\n const extension = path.extname(input);\n if (extension === '' || extension === '.') {\n return undefined;\n }\n\n if (\n typeof allowed === 'undefined' ||\n allowed.indexOf(extension) !== -1\n ) {\n return extension;\n }\n\n return undefined;\n}\n\nexport function removeFileNameExtension(\n input: string,\n extensions?: string[],\n) {\n const extension = getFileNameExtension(input, extensions);\n if (extension) {\n return input.substring(0, input.length - extension.length);\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';\n\nexport function isFilePath(input: string) {\n const extension = path.extname(input);\n return extension && extension !== '';\n}\n","/*\n * Copyright (c) 2024.\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) 2024.\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 { isObject } from './object';\n\nexport function isTypeScriptError(input: unknown) : input is Error {\n if (!isObject(input)) {\n return false;\n }\n\n if (typeof input.diagnosticCodes !== 'undefined') {\n return true;\n }\n\n return typeof input.message === 'string' &&\n /TS\\d+/.test(input.message);\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 { isObject, toArray } from '../utils';\nimport type { LocatorInfo, LocatorOptions } from './type';\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 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\nexport function isLocatorInfo(\n input: unknown,\n) : input is LocatorInfo {\n return isObject(input) &&\n typeof input.path === 'string' &&\n typeof input.name === 'string' &&\n typeof input.extension === 'string';\n}\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 fg from 'fast-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 let ignore : string[] | undefined;\n if (options.ignore) {\n ignore = Array.isArray(options.ignore) ? options.ignore : [options.ignore];\n }\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 fg(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n ignore,\n onlyFiles: true,\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 let ignore : string[] | undefined;\n if (options.ignore) {\n ignore = Array.isArray(options.ignore) ? options.ignore : [options.ignore];\n }\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 fg(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n ignore,\n onlyFiles: true,\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 fg from 'fast-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 let ignore : string[] | undefined;\n if (options.ignore) {\n ignore = Array.isArray(options.ignore) ? options.ignore : [options.ignore];\n }\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 = fg.sync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n ignore,\n onlyFiles: true,\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 let ignore : string[] | undefined;\n if (options.ignore) {\n ignore = Array.isArray(options.ignore) ? options.ignore : [options.ignore];\n }\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 = fg.sync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n ignore,\n onlyFiles: true,\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-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\n// Based on https://github.com/unjs/rc9 (MIT)\n\nimport { destr } from 'destr';\nimport flat from 'flat';\nimport fs from 'node:fs';\nimport { buildFilePath } from '../../../locator';\nimport { handleException, isSafeObjectKey } from '../../../utils';\nimport type { Loader } from '../../type';\n\nexport class ConfLoader implements Loader {\n async execute(input: string) {\n const filePath = buildFilePath(input);\n\n try {\n const file = await fs.promises.readFile(filePath, { encoding: 'utf-8' });\n\n return this.parse(file);\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, { encoding: 'utf-8' });\n\n return this.parse(file);\n } catch (e) {\n return handleException(e);\n }\n }\n\n parse(contents: string): Record<string, any> {\n const config: Record<string, any> = {};\n\n const lines = contents.split(/\\n|\\r|\\r\\n/);\n\n for (let i = 0; i < lines.length; i++) {\n const match = lines[i].match(/^\\s*([^\\s=]+)\\s*=\\s*(.*)?\\s*$/);\n if (!match) {\n continue;\n }\n\n // Key\n const key = match[1];\n\n if (!key || !isSafeObjectKey(key)) {\n continue;\n }\n\n const value = destr(match[2].trim() /* val */);\n\n if (key.endsWith('[]')) {\n const arrKey = key.slice(0, Math.max(0, key.length - 2));\n config[arrKey] = (config[arrKey] || []).concat(value);\n continue;\n }\n\n config[key] = value;\n }\n\n return flat.unflatten(config, { overwrite: true });\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, isObject } from '../../../utils';\nimport type { LoaderFilterFn, ModuleExport } from './type';\n\ntype ESModule = { [key: string]: any, __esModule: boolean };\nexport function isESModule(input: unknown) : input is ESModule {\n return isObject(input) &&\n // eslint-disable-next-line no-underscore-dangle\n typeof input.__esModule !== 'undefined';\n}\n\n// https://2ality.com/2017/01/babel-esm-spec-mode.html\nexport function toModuleRecord(\n data: unknown,\n) {\n if (isESModule(data)) {\n return data;\n }\n\n const output = Object.create(null, {\n __esModule: {\n value: true,\n },\n [Symbol.toStringTag]: {\n value: 'Module',\n },\n });\n\n if (isObject(data)) {\n // eslint-disable-next-line no-restricted-syntax\n for (const key in data) {\n if (hasOwnProperty(output, key)) {\n continue;\n }\n\n let descriptor = Object.getOwnPropertyDescriptor(data, key);\n if (\n !descriptor ||\n ('get' in descriptor || descriptor.writable || descriptor.configurable)\n ) {\n descriptor = {\n enumerable: true,\n get() {\n return data[key];\n },\n };\n }\n\n Object.defineProperty(output, key, descriptor);\n }\n }\n\n if (!hasOwnProperty(output, 'default')) {\n Object.defineProperty(output, 'default', {\n value: data,\n enumerable: true,\n });\n }\n\n return Object.freeze(output);\n}\n\nexport function getModuleExport(\n data: Record<string, any>,\n filterFn: LoaderFilterFn,\n): ModuleExport | undefined {\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 return undefined;\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 {\n buildFilePath,\n isLocatorInfo,\n} from '../../../locator';\nimport {\n handleException,\n hasStringProperty,\n isFilePath, isJestRuntimeEnvironment,\n isObject,\n isTsNodeRuntimeEnvironment,\n isTypeScriptError,\n} from '../../../utils';\nimport type { Loader } from '../../type';\nimport type { ModuleLoadOptions } from './type';\nimport { toModuleRecord } 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 if (\n e instanceof SyntaxError ||\n e instanceof ReferenceError ||\n isTypeScriptError(e)\n ) {\n throw e;\n }\n\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 toModuleRecord(output);\n }\n\n executeSync(input: string) {\n let output : any;\n\n try {\n output = this.loadSync(input);\n } catch (e) {\n if (\n e instanceof SyntaxError ||\n e instanceof ReferenceError ||\n isTypeScriptError(e)\n ) {\n throw e;\n }\n\n output = this.jiti(input);\n }\n\n return toModuleRecord(output);\n }\n\n // ---------------------------------------------------------------------------\n\n async load(\n data: LocatorInfo | string,\n options: ModuleLoadOptions = {},\n ) : Promise<unknown> {\n const id = this.build(data, options);\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(id);\n }\n\n return await import(id);\n } catch (e) {\n /* istanbul ignore next */\n if (\n isObject(e) &&\n hasStringProperty(e, 'code')\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(data, {\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: ModuleLoadOptions = {},\n ) : unknown {\n const id = this.build(data, options);\n\n try {\n // eslint-disable-next-line global-require,import/no-dynamic-require\n return require(id);\n } catch (e) {\n /* istanbul ignore next */\n if (\n isObject(e) &&\n hasStringProperty(e, 'code')\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 build(\n data: LocatorInfo | string,\n options: ModuleLoadOptions = {},\n ) : string {\n if (isLocatorInfo(data) || isFilePath(data)) {\n if (typeof data !== 'string') {\n data = buildFilePath(data);\n }\n\n if (options.withFilePrefix) {\n data = pathToFileURL(data).href;\n }\n }\n\n return data;\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 } from '../../../locator';\nimport { 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, { encoding: 'utf-8' });\n return JSON.parse(file);\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, { encoding: 'utf-8' });\n return JSON.parse(file);\n } catch (e) {\n return handleException(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 { parse } from 'yaml';\nimport fs from 'node:fs';\nimport { buildFilePath } from '../../../locator';\nimport { handleException } from '../../../utils';\nimport type { Loader } from '../../type';\n\nexport class YAMLLoader implements Loader {\n async execute(input: string) {\n const filePath = buildFilePath(input);\n\n try {\n const file = await fs.promises.readFile(filePath, { encoding: 'utf-8' });\n return parse(file);\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, { encoding: 'utf-8' });\n return parse(file);\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 CONF = 'conf',\n YAML = 'yaml',\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 { buildFilePath, pathToLocatorInfo } from '../locator';\nimport { isFilePath } from '../utils';\nimport { ConfLoader, JSONLoader, ModuleLoader } from './built-in';\nimport { YAMLLoader } from './built-in/yaml';\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: ['.conf'], loader: LoaderId.CONF,\n },\n {\n test: ['.json'], loader: LoaderId.JSON,\n },\n {\n test: ['.yml'], loader: LoaderId.YAML,\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.CONF: {\n loader = new ConfLoader();\n break;\n }\n case LoaderId.MODULE: {\n loader = new ModuleLoader();\n break;\n }\n case LoaderId.JSON: {\n loader = new JSONLoader();\n break;\n }\n case LoaderId.YAML: {\n loader = new YAMLLoader();\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 { buildFilePath } from '../locator';\nimport type { LocatorInfo } from '../locator';\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"],"names":["hasOwnProperty","obj","prop","Object","prototype","call","hasStringProperty","isObject","item","Array","isArray","isSafeObjectKey","key","handleException","e","Error","error","message","stack","getFileNameExtension","input","allowed","extension","path","extname","undefined","indexOf","removeFileNameExtension","extensions","substring","length","toArray","isFilePath","isJestRuntimeEnvironment","process","env","JEST_WORKER_ID","isTsNodeRuntimeEnvironment","Symbol","for","isTypeScriptError","diagnosticCodes","test","buildLocatorOptions","options","push","cwd","ignore","pathToLocatorInfo","skipResolve","isAbsolute","resolve","info","parse","dir","split","join","sep","name","ext","isLocatorInfo","buildFilePath","buildFilePathWithoutExtension","locateMany","pattern","patterns","items","i","j","files","fg","absolute","onlyFiles","k","locate","element","shift","locateManySync","sync","locateSync","ConfLoader","execute","filePath","file","fs","promises","readFile","encoding","executeSync","readFileSync","contents","config","lines","match","value","destr","trim","endsWith","arrKey","slice","Math","max","concat","flat","unflatten","overwrite","isESModule","__esModule","toModuleRecord","data","output","create","toStringTag","descriptor","getOwnPropertyDescriptor","writable","configurable","enumerable","get","defineProperty","freeze","getModuleExport","filterFn","keys","ModuleLoader","load","SyntaxError","ReferenceError","loadSync","jiti","id","build","require","withFilePrefix","code","BaseError","pathToFileURL","href","constructor","createJITI","JSONLoader","JSON","YAMLLoader","LoaderId","LoaderManager","register","loader","rules","findLoader","MODULE","loaders","CONF","YAML","pluginPath","normalizePath","moduleLoader","startsWith","instance","useLoader","registerLoader","manager"],"mappings":";;;;;;;;;;;;AAAO,SAASA,cAAAA,CAAqEC,GAAM,EAAEC,IAAO,EAAA;AAChG,IAAA,OAAOC,OAAOC,SAAS,CAACJ,cAAc,CAACK,IAAI,CAACJ,GAAKC,EAAAA,IAAAA,CAAAA,CAAAA;AACrD,CAAA;AAEO,SAASI,iBAAAA,CAAwEL,GAAM,EAAEC,IAAO,EAAA;AACnG,IAAA,OAAOF,eAAeC,GAAKC,EAAAA,IAAAA,CAAAA,IAAS,OAAOD,GAAG,CAACC,KAAK,KAAK,QAAA,CAAA;AAC7D;;ACNA;;;;;IAOO,SAASK,QAAAA,CAASC,IAAa,EAAA;IAClC,OACI,CAAC,CAACA,IACF,IAAA,OAAOA,SAAS,QAChB,IAAA,CAACC,KAAMC,CAAAA,OAAO,CAACF,IAAAA,CAAAA,CAAAA;AAEvB,CAAA;AAEO,SAASG,gBAAgBC,GAAW,EAAA;AACvC,IAAA,OAAOA,GAAQ,KAAA,WAAA,IACXA,GAAQ,KAAA,WAAA,IACRA,GAAQ,KAAA,aAAA,CAAA;AAChB;;ACTO,SAASC,gBAAgBC,CAAU,EAAA;AACtC,IAAA,IAAIA,aA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AA,EAAAA,CAAAA;IAChB,IAAI,OAAOZ,WAAW,WAAa,EAAA;QAC/Bc,OAAQf,CAAAA,QAAQ,CAACvG,IAAMwG,EAAAA,MAAAA,CAAAA,CAAAA;AAEvB,QAAA,OAAA;AACJ,KAAA;AAEAc,IAAAA,OAAAA,CAAQf,QAAQ,CAACvG,IAAAA,CAAAA,CAAAA;AACrB,CAAA;AAEO,eAAemF,KAAKzG,KAA2B,EAAA;AAClD,IAAA,MAAM4I,OAAUF,GAAAA,SAAAA,EAAAA,CAAAA;IAChB,IAAI,OAAO1I,UAAU,QAAU,EAAA;QAC3B,OAAO4I,OAAAA,CAAQ/E,OAAO,CAAC7D,KAAAA,CAAAA,CAAAA;AAC3B,KAAA;IAEA,OAAO4I,OAAAA,CAAQ/E,OAAO,CAACpB,aAAczC,CAAAA,KAAAA,CAAAA,CAAAA,CAAAA;AACzC,CAAA;AAEO,SAAS4G,SAAS5G,KAA2B,EAAA;AAChD,IAAA,MAAM4I,OAAUF,GAAAA,SAAAA,EAAAA,CAAAA;IAChB,IAAI,OAAO1I,UAAU,QAAU,EAAA;QAC3B,OAAO4I,OAAAA,CAAQxE,WAAW,CAACpE,KAAAA,CAAAA,CAAAA;AAC/B,KAAA;IAEA,OAAO4I,OAAAA,CAAQxE,WAAW,CAAC3B,aAAczC,CAAAA,KAAAA,CAAAA,CAAAA,CAAAA;AAC7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.mjs CHANGED
@@ -85,6 +85,30 @@ function isFilePath(input) {
85
85
  return extension && extension !== '';
86
86
  }
87
87
 
88
+ /*
89
+ * Copyright (c) 2024.
90
+ * Author Peter Placzek (tada5hi)
91
+ * For the full copyright and license information,
92
+ * view the LICENSE file that was distributed with this source code.
93
+ */ function isJestRuntimeEnvironment() {
94
+ return process.env && process.env.JEST_WORKER_ID !== undefined;
95
+ }
96
+ function isTsNodeRuntimeEnvironment() {
97
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
98
+ // @ts-ignore
99
+ return !!process[Symbol.for('ts-node.register.instance')];
100
+ }
101
+
102
+ function isTypeScriptError(input) {
103
+ if (!isObject(input)) {
104
+ return false;
105
+ }
106
+ if (typeof input.diagnosticCodes !== 'undefined') {
107
+ return true;
108
+ }
109
+ return typeof input.message === 'string' && /TS\d+/.test(input.message);
110
+ }
111
+
88
112
  function buildLocatorOptions(options) {
89
113
  var _options;
90
114
  options = options || {};
@@ -295,38 +319,60 @@ class ConfLoader {
295
319
  }
296
320
  }
297
321
 
298
- function isJestRuntimeEnvironment() {
299
- return process.env && process.env.JEST_WORKER_ID !== undefined;
300
- }
301
- function isTsNodeRuntimeEnvironment() {
302
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
303
- // @ts-ignore
304
- return !!process[Symbol.for('ts-node.register.instance')];
322
+ function isESModule(input) {
323
+ return isObject(input) && // eslint-disable-next-line no-underscore-dangle
324
+ typeof input.__esModule !== 'undefined';
305
325
  }
306
- function getModuleExport(data, filterFn) {
307
- if (filterFn) {
308
- const keys = Object.keys(data);
309
- for(let i = 0; i < keys.length; i++){
310
- if (filterFn(keys[i], data[keys[i]])) {
311
- return {
312
- key: keys[i],
313
- value: data[keys[i]]
326
+ // https://2ality.com/2017/01/babel-esm-spec-mode.html
327
+ function toModuleRecord(data) {
328
+ if (isESModule(data)) {
329
+ return data;
330
+ }
331
+ const output = Object.create(null, {
332
+ __esModule: {
333
+ value: true
334
+ },
335
+ [Symbol.toStringTag]: {
336
+ value: 'Module'
337
+ }
338
+ });
339
+ if (isObject(data)) {
340
+ // eslint-disable-next-line no-restricted-syntax
341
+ for(const key in data){
342
+ if (hasOwnProperty(output, key)) {
343
+ continue;
344
+ }
345
+ let descriptor = Object.getOwnPropertyDescriptor(data, key);
346
+ if (!descriptor || 'get' in descriptor || descriptor.writable || descriptor.configurable) {
347
+ descriptor = {
348
+ enumerable: true,
349
+ get () {
350
+ return data[key];
351
+ }
314
352
  };
315
353
  }
354
+ Object.defineProperty(output, key, descriptor);
316
355
  }
317
- throw new BaseError('Cannot find specific module export.');
318
356
  }
319
- if (// eslint-disable-next-line no-underscore-dangle
320
- typeof data.__esModule !== 'undefined' && typeof data.default !== 'undefined') {
321
- return {
322
- key: 'default',
323
- value: data.default
324
- };
357
+ if (!hasOwnProperty(output, 'default')) {
358
+ Object.defineProperty(output, 'default', {
359
+ value: data,
360
+ enumerable: true
361
+ });
325
362
  }
326
- return {
327
- key: 'default',
328
- value: data
329
- };
363
+ return Object.freeze(output);
364
+ }
365
+ function getModuleExport(data, filterFn) {
366
+ const keys = Object.keys(data);
367
+ for(let i = 0; i < keys.length; i++){
368
+ if (filterFn(keys[i], data[keys[i]])) {
369
+ return {
370
+ key: keys[i],
371
+ value: data[keys[i]]
372
+ };
373
+ }
374
+ }
375
+ return undefined;
330
376
  }
331
377
 
332
378
  class ModuleLoader {
@@ -335,7 +381,7 @@ class ModuleLoader {
335
381
  try {
336
382
  output = await this.load(input);
337
383
  } catch (e) {
338
- if (e instanceof SyntaxError || e instanceof ReferenceError) {
384
+ if (e instanceof SyntaxError || e instanceof ReferenceError || isTypeScriptError(e)) {
339
385
  throw e;
340
386
  }
341
387
  // jiti + ts-node
@@ -346,48 +392,38 @@ class ModuleLoader {
346
392
  output = this.jiti(input);
347
393
  }
348
394
  }
349
- return output;
395
+ return toModuleRecord(output);
350
396
  }
351
397
  executeSync(input) {
352
398
  let output;
353
399
  try {
354
400
  output = this.loadSync(input);
355
401
  } catch (e) {
356
- if (e instanceof SyntaxError || e instanceof ReferenceError) {
402
+ if (e instanceof SyntaxError || e instanceof ReferenceError || isTypeScriptError(e)) {
357
403
  throw e;
358
404
  }
359
405
  output = this.jiti(input);
360
406
  }
361
- return output;
407
+ return toModuleRecord(output);
362
408
  }
363
409
  // ---------------------------------------------------------------------------
364
- async load(data, options) {
365
- options = options || {};
366
- const [name, locatorInfo] = this.build(data, options);
410
+ async load(data, options = {}) {
411
+ const id = this.build(data, options);
367
412
  try {
368
413
  // segmentation fault
369
414
  // issue: https://github.com/nodejs/node/issues/35889
370
415
  if (isJestRuntimeEnvironment()) {
371
416
  // eslint-disable-next-line global-require,import/no-dynamic-require
372
- return require(name);
417
+ return require(id);
373
418
  }
374
- return await import(name);
419
+ return await import(id);
375
420
  } catch (e) {
376
421
  /* istanbul ignore next */ if (isObject(e) && hasStringProperty(e, 'code')) {
377
- if (locatorInfo) {
378
- if (!options.withExtension && (e.code === 'ERR_MODULE_NOT_FOUND' || e.code === 'MODULE_NOT_FOUND')) {
379
- return this.load(locatorInfo, {
380
- ...options,
381
- withExtension: true
382
- });
383
- }
384
- if (!options.withFilePrefix && (e.code === 'ERR_UNSUPPORTED_ESM_URL_SCHEME' || e.code === 'UNSUPPORTED_ESM_URL_SCHEME')) {
385
- return this.load(locatorInfo, {
386
- ...options,
387
- withExtension: true,
388
- withFilePrefix: true
389
- });
390
- }
422
+ if (!options.withFilePrefix && (e.code === 'ERR_UNSUPPORTED_ESM_URL_SCHEME' || e.code === 'UNSUPPORTED_ESM_URL_SCHEME')) {
423
+ return this.load(data, {
424
+ ...options,
425
+ withFilePrefix: true
426
+ });
391
427
  }
392
428
  throw new BaseError({
393
429
  code: e.code,
@@ -398,22 +434,13 @@ class ModuleLoader {
398
434
  /* istanbul ignore next */ return handleException(e);
399
435
  }
400
436
  }
401
- loadSync(data, options) {
402
- options = options || {};
403
- const [name, locatorInfo] = this.build(data, options);
437
+ loadSync(data, options = {}) {
438
+ const id = this.build(data, options);
404
439
  try {
405
440
  // eslint-disable-next-line global-require,import/no-dynamic-require
406
- return require(name);
441
+ return require(id);
407
442
  } catch (e) {
408
443
  /* istanbul ignore next */ if (isObject(e) && hasStringProperty(e, 'code')) {
409
- if (locatorInfo) {
410
- if (!options.withExtension && (e.code === 'ERR_MODULE_NOT_FOUND' || e.code === 'MODULE_NOT_FOUND')) {
411
- return this.loadSync(locatorInfo, {
412
- ...options,
413
- withExtension: true
414
- });
415
- }
416
- }
417
444
  throw new BaseError({
418
445
  code: e.code,
419
446
  message: hasStringProperty(e, 'message') ? e.message : undefined,
@@ -423,31 +450,16 @@ class ModuleLoader {
423
450
  return handleException(e);
424
451
  }
425
452
  }
426
- build(data, options) {
427
- let name;
428
- let locatorInfo;
429
- options = options || {};
453
+ build(data, options = {}) {
430
454
  if (isLocatorInfo(data) || isFilePath(data)) {
431
- if (typeof data === 'string') {
432
- locatorInfo = pathToLocatorInfo(data);
433
- } else {
434
- locatorInfo = data;
435
- }
436
- if (options.withExtension) {
437
- name = buildFilePath(locatorInfo);
438
- } else {
439
- name = buildFilePathWithoutExtension(locatorInfo);
455
+ if (typeof data !== 'string') {
456
+ data = buildFilePath(data);
440
457
  }
441
458
  if (options.withFilePrefix) {
442
- name = pathToFileURL(name).href;
459
+ data = pathToFileURL(data).href;
443
460
  }
444
- } else {
445
- name = data;
446
461
  }
447
- return [
448
- name,
449
- locatorInfo
450
- ];
462
+ return data;
451
463
  }
452
464
  constructor(){
453
465
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -702,5 +714,5 @@ function loadSync(input) {
702
714
  return manager.executeSync(buildFilePath(input));
703
715
  }
704
716
 
705
- export { ConfLoader, JSONLoader, LoaderManager, ModuleLoader, buildFilePath, buildFilePathWithoutExtension, buildLocatorOptions, getFileNameExtension, getModuleExport, handleException, hasOwnProperty, hasStringProperty, isFilePath, isJestRuntimeEnvironment, isLocatorInfo, isObject, isSafeObjectKey, isTsNodeRuntimeEnvironment, load, loadSync, locate, locateMany, locateManySync, locateSync, pathToLocatorInfo, registerLoader, removeFileNameExtension, toArray };
717
+ export { ConfLoader, JSONLoader, LoaderManager, ModuleLoader, buildFilePath, buildFilePathWithoutExtension, buildLocatorOptions, getFileNameExtension, getModuleExport, handleException, hasOwnProperty, hasStringProperty, isESModule, isFilePath, isJestRuntimeEnvironment, isLocatorInfo, isObject, isSafeObjectKey, isTsNodeRuntimeEnvironment, isTypeScriptError, load, loadSync, locate, locateMany, locateManySync, locateSync, pathToLocatorInfo, registerLoader, removeFileNameExtension, toArray, toModuleRecord };
706
718
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"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/conf/module.ts","../src/loader/built-in/module/utils.ts","../src/loader/built-in/module/module.ts","../src/loader/built-in/json/module.ts","../src/loader/built-in/yaml/module.ts","../src/loader/constants.ts","../src/loader/module.ts","../src/loader/singleton.ts","../src/loader/helpers.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\nexport function isSafeObjectKey(key: string) : boolean {\n return key !== '__proto__' &&\n key !== 'prototype' &&\n key !== 'constructor';\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\nimport path from 'node:path';\n\nexport function getFileNameExtension(\n input: string,\n allowed?: string[],\n) : string | undefined {\n const extension = path.extname(input);\n if (extension === '' || extension === '.') {\n return undefined;\n }\n\n if (\n typeof allowed === 'undefined' ||\n allowed.indexOf(extension) !== -1\n ) {\n return extension;\n }\n\n return undefined;\n}\n\nexport function removeFileNameExtension(\n input: string,\n extensions?: string[],\n) {\n const extension = getFileNameExtension(input, extensions);\n if (extension) {\n return input.substring(0, input.length - extension.length);\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';\n\nexport function isFilePath(input: string) {\n const extension = path.extname(input);\n return extension && extension !== '';\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 { isObject, toArray } from '../utils';\nimport type { LocatorInfo, LocatorOptions } from './type';\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 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\nexport function isLocatorInfo(\n input: unknown,\n) : input is LocatorInfo {\n return isObject(input) &&\n typeof input.path === 'string' &&\n typeof input.name === 'string' &&\n typeof input.extension === 'string';\n}\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 fg from 'fast-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 let ignore : string[] | undefined;\n if (options.ignore) {\n ignore = Array.isArray(options.ignore) ? options.ignore : [options.ignore];\n }\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 fg(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n ignore,\n onlyFiles: true,\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 let ignore : string[] | undefined;\n if (options.ignore) {\n ignore = Array.isArray(options.ignore) ? options.ignore : [options.ignore];\n }\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 fg(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n ignore,\n onlyFiles: true,\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 fg from 'fast-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 let ignore : string[] | undefined;\n if (options.ignore) {\n ignore = Array.isArray(options.ignore) ? options.ignore : [options.ignore];\n }\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 = fg.sync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n ignore,\n onlyFiles: true,\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 let ignore : string[] | undefined;\n if (options.ignore) {\n ignore = Array.isArray(options.ignore) ? options.ignore : [options.ignore];\n }\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 = fg.sync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n ignore,\n onlyFiles: true,\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-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\n// Based on https://github.com/unjs/rc9 (MIT)\n\nimport { destr } from 'destr';\nimport flat from 'flat';\nimport fs from 'node:fs';\nimport { buildFilePath } from '../../../locator';\nimport { handleException, isSafeObjectKey } from '../../../utils';\nimport type { Loader } from '../../type';\n\nexport class ConfLoader implements Loader {\n async execute(input: string) {\n const filePath = buildFilePath(input);\n\n try {\n const file = await fs.promises.readFile(filePath, { encoding: 'utf-8' });\n\n return this.parse(file);\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, { encoding: 'utf-8' });\n\n return this.parse(file);\n } catch (e) {\n return handleException(e);\n }\n }\n\n parse(contents: string): Record<string, any> {\n const config: Record<string, any> = {};\n\n const lines = contents.split(/\\n|\\r|\\r\\n/);\n\n for (let i = 0; i < lines.length; i++) {\n const match = lines[i].match(/^\\s*([^\\s=]+)\\s*=\\s*(.*)?\\s*$/);\n if (!match) {\n continue;\n }\n\n // Key\n const key = match[1];\n\n if (!key || !isSafeObjectKey(key)) {\n continue;\n }\n\n const value = destr(match[2].trim() /* val */);\n\n if (key.endsWith('[]')) {\n const arrKey = key.slice(0, Math.max(0, key.length - 2));\n config[arrKey] = (config[arrKey] || []).concat(value);\n continue;\n }\n\n config[key] = value;\n }\n\n return flat.unflatten(config, { overwrite: true });\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 { BaseError } from 'ebec';\nimport type { LoaderFilterFn, ModuleExport } from './type';\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\nexport function getModuleExport(\n data: Record<string, any>,\n filterFn?: LoaderFilterFn,\n): ModuleExport {\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 if (\n // eslint-disable-next-line no-underscore-dangle\n typeof data.__esModule !== 'undefined' &&\n typeof data.default !== 'undefined'\n ) {\n return {\n key: 'default',\n value: data.default,\n };\n }\n\n return {\n key: 'default',\n value: data,\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 { BaseError } from 'ebec';\nimport type { JITI } from 'jiti';\nimport createJITI from 'jiti';\nimport { pathToFileURL } from 'node:url';\nimport type { LocatorInfo } from '../../../locator';\nimport {\n buildFilePath,\n buildFilePathWithoutExtension,\n isLocatorInfo,\n pathToLocatorInfo,\n} from '../../../locator';\nimport {\n handleException,\n hasStringProperty, isFilePath,\n isObject,\n} from '../../../utils';\nimport type { Loader } from '../../type';\nimport type { ModuleLoadOptions } 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 if (\n e instanceof SyntaxError ||\n e instanceof ReferenceError\n ) {\n throw e;\n }\n\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 if (\n e instanceof SyntaxError ||\n e instanceof ReferenceError\n ) {\n throw e;\n }\n\n output = this.jiti(input);\n }\n\n return output;\n }\n\n // ---------------------------------------------------------------------------\n\n async load(\n data: LocatorInfo | string,\n options?: ModuleLoadOptions,\n ) : Promise<unknown> {\n options = options || {};\n const [name, locatorInfo] = this.build(data, options);\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(name);\n }\n\n return await import(name);\n } catch (e) {\n /* istanbul ignore next */\n if (\n isObject(e) &&\n hasStringProperty(e, 'code')\n ) {\n if (locatorInfo) {\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 withExtension: true,\n withFilePrefix: true,\n });\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?: ModuleLoadOptions,\n ) : unknown {\n options = options || {};\n const [name, locatorInfo] = this.build(data, options);\n\n try {\n // eslint-disable-next-line global-require,import/no-dynamic-require\n return require(name);\n } catch (e) {\n /* istanbul ignore next */\n if (\n isObject(e) &&\n hasStringProperty(e, 'code')\n ) {\n if (locatorInfo) {\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\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 build(\n data: LocatorInfo | string,\n options: ModuleLoadOptions,\n ) : [string, LocatorInfo | undefined] {\n let name : string;\n let locatorInfo : LocatorInfo | undefined;\n\n options = options || {};\n\n if (isLocatorInfo(data) || isFilePath(data)) {\n if (typeof data === 'string') {\n locatorInfo = pathToLocatorInfo(data);\n } else {\n locatorInfo = data;\n }\n\n if (options.withExtension) {\n name = buildFilePath(locatorInfo);\n } else {\n name = buildFilePathWithoutExtension(locatorInfo);\n }\n\n if (options.withFilePrefix) {\n name = pathToFileURL(name).href;\n }\n } else {\n name = data;\n }\n\n return [name, locatorInfo];\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 } from '../../../locator';\nimport { 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, { encoding: 'utf-8' });\n return JSON.parse(file);\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, { encoding: 'utf-8' });\n return JSON.parse(file);\n } catch (e) {\n return handleException(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 { parse } from 'yaml';\nimport fs from 'node:fs';\nimport { buildFilePath } from '../../../locator';\nimport { handleException } from '../../../utils';\nimport type { Loader } from '../../type';\n\nexport class YAMLLoader implements Loader {\n async execute(input: string) {\n const filePath = buildFilePath(input);\n\n try {\n const file = await fs.promises.readFile(filePath, { encoding: 'utf-8' });\n return parse(file);\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, { encoding: 'utf-8' });\n return parse(file);\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 CONF = 'conf',\n YAML = 'yaml',\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 { buildFilePath, pathToLocatorInfo } from '../locator';\nimport { isFilePath } from '../utils';\nimport { ConfLoader, JSONLoader, ModuleLoader } from './built-in';\nimport { YAMLLoader } from './built-in/yaml';\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: ['.conf'], loader: LoaderId.CONF,\n },\n {\n test: ['.json'], loader: LoaderId.JSON,\n },\n {\n test: ['.yml'], loader: LoaderId.YAML,\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.CONF: {\n loader = new ConfLoader();\n break;\n }\n case LoaderId.MODULE: {\n loader = new ModuleLoader();\n break;\n }\n case LoaderId.JSON: {\n loader = new JSONLoader();\n break;\n }\n case LoaderId.YAML: {\n loader = new YAMLLoader();\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 { buildFilePath } from '../locator';\nimport type { LocatorInfo } from '../locator';\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"],"names":["input","options","name","extension","info","pattern","cwd","ignore","items","executeSync","parse","config","value","output","code","message","stack","locatorInfo","LoaderId","test","loader","findLoader","instance","manager"],"mappings":";;;;;;;;;;;;;;;;;;AAAO;AACH;AACJ;AAEO;AACH;AACJ;;ACNA;;;;;;;AAaA;AAEO;AACH;AAGJ;;ACTO;AACH;;AAEA;;AAIA;AACI;;AAKA;AAEA;;AAKA;AACJ;;AAGJ;;ACzBO;;;;AAOH;;;AAOA;;AAGJ;AAEO;;AAKH;;AAEA;;AAGJ;;ACtCA;;;;;;AAQI;AAAuCA;AAAM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;AACJ;;AAGI;;AAGJ;AAEA;AACJ;;AAII;;AAEA;;AAGI;AACJ;AAEA;AACI;AACJ;;AAGJ;;;;AA3IQ;;AACW;AAAO;AAAQ;AAAQ;AAAQ;AAAQ;AAAM;AACpDA;AACJ;AACA;;AACW;AAAQ;AAAEA;AACrB;AACA;;AACW;AAAQ;AAAEA;AACrB;AACA;;AACW;AAAO;AAAEA;AACpB;AACH;AACL;AA8HJ;;AC1JA;AACO;;;AAGH;AAEAE;;AAGJ;;ACJO;AACH;;;AAII;AACJ;AAEAC;AACJ;AAEO;AACH;;;AAGA;;AAGJ;AAEO;AACH;;;AAGA;;AAGJ;;"}
1
+ {"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/utils/runtime.ts","../src/utils/typescript.ts","../src/locator/utils.ts","../src/locator/async.ts","../src/locator/sync.ts","../src/loader/built-in/conf/module.ts","../src/loader/built-in/module/utils.ts","../src/loader/built-in/module/module.ts","../src/loader/built-in/json/module.ts","../src/loader/built-in/yaml/module.ts","../src/loader/constants.ts","../src/loader/module.ts","../src/loader/singleton.ts","../src/loader/helpers.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\nexport function isSafeObjectKey(key: string) : boolean {\n return key !== '__proto__' &&\n key !== 'prototype' &&\n key !== 'constructor';\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\nimport path from 'node:path';\n\nexport function getFileNameExtension(\n input: string,\n allowed?: string[],\n) : string | undefined {\n const extension = path.extname(input);\n if (extension === '' || extension === '.') {\n return undefined;\n }\n\n if (\n typeof allowed === 'undefined' ||\n allowed.indexOf(extension) !== -1\n ) {\n return extension;\n }\n\n return undefined;\n}\n\nexport function removeFileNameExtension(\n input: string,\n extensions?: string[],\n) {\n const extension = getFileNameExtension(input, extensions);\n if (extension) {\n return input.substring(0, input.length - extension.length);\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';\n\nexport function isFilePath(input: string) {\n const extension = path.extname(input);\n return extension && extension !== '';\n}\n","/*\n * Copyright (c) 2024.\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) 2024.\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 { isObject } from './object';\n\nexport function isTypeScriptError(input: unknown) : input is Error {\n if (!isObject(input)) {\n return false;\n }\n\n if (typeof input.diagnosticCodes !== 'undefined') {\n return true;\n }\n\n return typeof input.message === 'string' &&\n /TS\\d+/.test(input.message);\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 { isObject, toArray } from '../utils';\nimport type { LocatorInfo, LocatorOptions } from './type';\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 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\nexport function isLocatorInfo(\n input: unknown,\n) : input is LocatorInfo {\n return isObject(input) &&\n typeof input.path === 'string' &&\n typeof input.name === 'string' &&\n typeof input.extension === 'string';\n}\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 fg from 'fast-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 let ignore : string[] | undefined;\n if (options.ignore) {\n ignore = Array.isArray(options.ignore) ? options.ignore : [options.ignore];\n }\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 fg(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n ignore,\n onlyFiles: true,\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 let ignore : string[] | undefined;\n if (options.ignore) {\n ignore = Array.isArray(options.ignore) ? options.ignore : [options.ignore];\n }\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 fg(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n ignore,\n onlyFiles: true,\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 fg from 'fast-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 let ignore : string[] | undefined;\n if (options.ignore) {\n ignore = Array.isArray(options.ignore) ? options.ignore : [options.ignore];\n }\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 = fg.sync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n ignore,\n onlyFiles: true,\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 let ignore : string[] | undefined;\n if (options.ignore) {\n ignore = Array.isArray(options.ignore) ? options.ignore : [options.ignore];\n }\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 = fg.sync(patterns[i] as string, {\n absolute: true,\n cwd: (options as LocatorOptions).path[j],\n ignore,\n onlyFiles: true,\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-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\n// Based on https://github.com/unjs/rc9 (MIT)\n\nimport { destr } from 'destr';\nimport flat from 'flat';\nimport fs from 'node:fs';\nimport { buildFilePath } from '../../../locator';\nimport { handleException, isSafeObjectKey } from '../../../utils';\nimport type { Loader } from '../../type';\n\nexport class ConfLoader implements Loader {\n async execute(input: string) {\n const filePath = buildFilePath(input);\n\n try {\n const file = await fs.promises.readFile(filePath, { encoding: 'utf-8' });\n\n return this.parse(file);\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, { encoding: 'utf-8' });\n\n return this.parse(file);\n } catch (e) {\n return handleException(e);\n }\n }\n\n parse(contents: string): Record<string, any> {\n const config: Record<string, any> = {};\n\n const lines = contents.split(/\\n|\\r|\\r\\n/);\n\n for (let i = 0; i < lines.length; i++) {\n const match = lines[i].match(/^\\s*([^\\s=]+)\\s*=\\s*(.*)?\\s*$/);\n if (!match) {\n continue;\n }\n\n // Key\n const key = match[1];\n\n if (!key || !isSafeObjectKey(key)) {\n continue;\n }\n\n const value = destr(match[2].trim() /* val */);\n\n if (key.endsWith('[]')) {\n const arrKey = key.slice(0, Math.max(0, key.length - 2));\n config[arrKey] = (config[arrKey] || []).concat(value);\n continue;\n }\n\n config[key] = value;\n }\n\n return flat.unflatten(config, { overwrite: true });\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, isObject } from '../../../utils';\nimport type { LoaderFilterFn, ModuleExport } from './type';\n\ntype ESModule = { [key: string]: any, __esModule: boolean };\nexport function isESModule(input: unknown) : input is ESModule {\n return isObject(input) &&\n // eslint-disable-next-line no-underscore-dangle\n typeof input.__esModule !== 'undefined';\n}\n\n// https://2ality.com/2017/01/babel-esm-spec-mode.html\nexport function toModuleRecord(\n data: unknown,\n) {\n if (isESModule(data)) {\n return data;\n }\n\n const output = Object.create(null, {\n __esModule: {\n value: true,\n },\n [Symbol.toStringTag]: {\n value: 'Module',\n },\n });\n\n if (isObject(data)) {\n // eslint-disable-next-line no-restricted-syntax\n for (const key in data) {\n if (hasOwnProperty(output, key)) {\n continue;\n }\n\n let descriptor = Object.getOwnPropertyDescriptor(data, key);\n if (\n !descriptor ||\n ('get' in descriptor || descriptor.writable || descriptor.configurable)\n ) {\n descriptor = {\n enumerable: true,\n get() {\n return data[key];\n },\n };\n }\n\n Object.defineProperty(output, key, descriptor);\n }\n }\n\n if (!hasOwnProperty(output, 'default')) {\n Object.defineProperty(output, 'default', {\n value: data,\n enumerable: true,\n });\n }\n\n return Object.freeze(output);\n}\n\nexport function getModuleExport(\n data: Record<string, any>,\n filterFn: LoaderFilterFn,\n): ModuleExport | undefined {\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 return undefined;\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 {\n buildFilePath,\n isLocatorInfo,\n} from '../../../locator';\nimport {\n handleException,\n hasStringProperty,\n isFilePath, isJestRuntimeEnvironment,\n isObject,\n isTsNodeRuntimeEnvironment,\n isTypeScriptError,\n} from '../../../utils';\nimport type { Loader } from '../../type';\nimport type { ModuleLoadOptions } from './type';\nimport { toModuleRecord } 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 if (\n e instanceof SyntaxError ||\n e instanceof ReferenceError ||\n isTypeScriptError(e)\n ) {\n throw e;\n }\n\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 toModuleRecord(output);\n }\n\n executeSync(input: string) {\n let output : any;\n\n try {\n output = this.loadSync(input);\n } catch (e) {\n if (\n e instanceof SyntaxError ||\n e instanceof ReferenceError ||\n isTypeScriptError(e)\n ) {\n throw e;\n }\n\n output = this.jiti(input);\n }\n\n return toModuleRecord(output);\n }\n\n // ---------------------------------------------------------------------------\n\n async load(\n data: LocatorInfo | string,\n options: ModuleLoadOptions = {},\n ) : Promise<unknown> {\n const id = this.build(data, options);\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(id);\n }\n\n return await import(id);\n } catch (e) {\n /* istanbul ignore next */\n if (\n isObject(e) &&\n hasStringProperty(e, 'code')\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(data, {\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: ModuleLoadOptions = {},\n ) : unknown {\n const id = this.build(data, options);\n\n try {\n // eslint-disable-next-line global-require,import/no-dynamic-require\n return require(id);\n } catch (e) {\n /* istanbul ignore next */\n if (\n isObject(e) &&\n hasStringProperty(e, 'code')\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 build(\n data: LocatorInfo | string,\n options: ModuleLoadOptions = {},\n ) : string {\n if (isLocatorInfo(data) || isFilePath(data)) {\n if (typeof data !== 'string') {\n data = buildFilePath(data);\n }\n\n if (options.withFilePrefix) {\n data = pathToFileURL(data).href;\n }\n }\n\n return data;\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 } from '../../../locator';\nimport { 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, { encoding: 'utf-8' });\n return JSON.parse(file);\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, { encoding: 'utf-8' });\n return JSON.parse(file);\n } catch (e) {\n return handleException(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 { parse } from 'yaml';\nimport fs from 'node:fs';\nimport { buildFilePath } from '../../../locator';\nimport { handleException } from '../../../utils';\nimport type { Loader } from '../../type';\n\nexport class YAMLLoader implements Loader {\n async execute(input: string) {\n const filePath = buildFilePath(input);\n\n try {\n const file = await fs.promises.readFile(filePath, { encoding: 'utf-8' });\n return parse(file);\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, { encoding: 'utf-8' });\n return parse(file);\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 CONF = 'conf',\n YAML = 'yaml',\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 { buildFilePath, pathToLocatorInfo } from '../locator';\nimport { isFilePath } from '../utils';\nimport { ConfLoader, JSONLoader, ModuleLoader } from './built-in';\nimport { YAMLLoader } from './built-in/yaml';\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: ['.conf'], loader: LoaderId.CONF,\n },\n {\n test: ['.json'], loader: LoaderId.JSON,\n },\n {\n test: ['.yml'], loader: LoaderId.YAML,\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.CONF: {\n loader = new ConfLoader();\n break;\n }\n case LoaderId.MODULE: {\n loader = new ModuleLoader();\n break;\n }\n case LoaderId.JSON: {\n loader = new JSONLoader();\n break;\n }\n case LoaderId.YAML: {\n loader = new YAMLLoader();\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 { buildFilePath } from '../locator';\nimport type { LocatorInfo } from '../locator';\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"],"names":["input","options","name","extension","info","pattern","cwd","ignore","items","executeSync","parse","config","get","value","output","code","message","stack","loadSync","build","data","LoaderId","test","loader","findLoader","instance","manager"],"mappings":";;;;;;;;;;;;;;;;;;AAAO;AACH;AACJ;AAEO;AACH;AACJ;;ACNA;;;;;;;AAaA;AAEO;AACH;AAGJ;;ACTO;AACH;;AAEA;;AAIA;AACI;;AAKA;AAEA;;AAKA;AACJ;;AAGJ;;ACzBO;;;;AAOH;;;AAOA;;AAGJ;AAEO;;AAKH;;AAEA;;AAGJ;;ACtCA;;;;;;AAQI;AAAuCA;AAAM;AACjD;;ACDO;;AAEH;AACJ;;ACXA;;;;;AAKC;AAGG;AAEJ;AAEO;;;AAGH;AACJ;;ACPO;;;AAGH;AAEA;;AAEA;;AAIJ;;ACTO;AASHC;AARAA;AAEAA;AACAA;AACA;AACIA;AACJ;AAEAA;;AAGJ;AAEO;AAIH;AAIID;AACJ;;;;AAMIE;AACAC;AACJ;AACJ;AAEO;AAGH;AAIJ;AAEO;;;AAGH;;;AAIA;AAEA;AACJ;AAEO;;;AAICC;;;AAGJ;AAEA;AACJ;;ACjEO;AAIHH;AAEA;AAEKI;AAAQ;;;;AAIkDJ;AAAe;AAC9E;AAEA;AAEA;;AAEQ;;AAEIK;AACAC;;AAEJ;AAEA;AACIC;AACJ;AACJ;AACJ;;AAGJ;AAEO;AAIHP;AAEA;AAEKI;AAAQ;;;;AAIkDJ;AAAe;AAC9E;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;
8
7
  withFilePrefix?: boolean;
9
8
  };
@@ -1,4 +1,9 @@
1
1
  import type { LoaderFilterFn, ModuleExport } from './type';
2
- export declare function isJestRuntimeEnvironment(): boolean;
3
- export declare function isTsNodeRuntimeEnvironment(): boolean;
4
- export declare function getModuleExport(data: Record<string, any>, filterFn?: LoaderFilterFn): ModuleExport;
2
+ type ESModule = {
3
+ [key: string]: any;
4
+ __esModule: boolean;
5
+ };
6
+ export declare function isESModule(input: unknown): input is ESModule;
7
+ export declare function toModuleRecord(data: unknown): any;
8
+ export declare function getModuleExport(data: Record<string, any>, filterFn: LoaderFilterFn): ModuleExport | undefined;
9
+ export {};
@@ -4,3 +4,5 @@ export * from './has-property';
4
4
  export * from './object';
5
5
  export * from './to-array';
6
6
  export * from './file-path';
7
+ export * from './runtime';
8
+ export * from './typescript';
@@ -0,0 +1,2 @@
1
+ export declare function isJestRuntimeEnvironment(): boolean;
2
+ export declare function isTsNodeRuntimeEnvironment(): boolean;
@@ -0,0 +1 @@
1
+ export declare function isTypeScriptError(input: unknown): input is Error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "locter",
3
- "version": "1.3.0",
3
+ "version": "2.0.1",
4
4
  "description": "A library to locate a file/module by criteria and load it!",
5
5
  "author": {
6
6
  "name": "Peter Placzek",
@@ -51,7 +51,7 @@
51
51
  "devDependencies": {
52
52
  "@rollup/plugin-esm-shim": "^0.1.5",
53
53
  "@rollup/plugin-node-resolve": "^15.2.3",
54
- "@swc/core": "^1.3.99",
54
+ "@swc/core": "^1.3.104",
55
55
  "@swc/jest": "^0.2.27",
56
56
  "@tada5hi/commitlint-config": "^1.1.4",
57
57
  "@tada5hi/eslint-config-typescript": "^1.2.7",