locter 2.2.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/README.MD +188 -6
  2. package/dist/index.d.mts +244 -0
  3. package/dist/index.mjs +688 -672
  4. package/dist/index.mjs.map +1 -1
  5. package/package.json +27 -34
  6. package/dist/index.cjs +0 -743
  7. package/dist/index.cjs.map +0 -1
  8. package/dist/index.d.ts +0 -3
  9. package/dist/loader/built-in/conf/index.d.ts +0 -1
  10. package/dist/loader/built-in/conf/module.d.ts +0 -6
  11. package/dist/loader/built-in/index.d.ts +0 -3
  12. package/dist/loader/built-in/json/index.d.ts +0 -1
  13. package/dist/loader/built-in/json/module.d.ts +0 -5
  14. package/dist/loader/built-in/module/index.d.ts +0 -3
  15. package/dist/loader/built-in/module/module.d.ts +0 -15
  16. package/dist/loader/built-in/module/type.d.ts +0 -8
  17. package/dist/loader/built-in/module/utils.d.ts +0 -9
  18. package/dist/loader/built-in/yaml/index.d.ts +0 -1
  19. package/dist/loader/built-in/yaml/module.d.ts +0 -5
  20. package/dist/loader/constants.d.ts +0 -6
  21. package/dist/loader/helpers.d.ts +0 -6
  22. package/dist/loader/index.d.ts +0 -3
  23. package/dist/loader/module.d.ts +0 -18
  24. package/dist/loader/singleton.d.ts +0 -2
  25. package/dist/loader/type.d.ts +0 -8
  26. package/dist/locator/async.d.ts +0 -3
  27. package/dist/locator/index.d.ts +0 -4
  28. package/dist/locator/sync.d.ts +0 -3
  29. package/dist/locator/types.d.ts +0 -15
  30. package/dist/locator/utils.d.ts +0 -7
  31. package/dist/utils/error.d.ts +0 -1
  32. package/dist/utils/file-name.d.ts +0 -2
  33. package/dist/utils/file-path.d.ts +0 -1
  34. package/dist/utils/has-property.d.ts +0 -2
  35. package/dist/utils/index.d.ts +0 -8
  36. package/dist/utils/object.d.ts +0 -2
  37. package/dist/utils/runtime.d.ts +0 -2
  38. package/dist/utils/to-array.d.ts +0 -1
  39. package/dist/utils/typescript.d.ts +0 -1
@@ -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/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, LocatorOptionsInput } from './types';\n\nexport function buildLocatorPatterns(pattern: string | string[]) : string[] {\n return Array.isArray(pattern) ?\n pattern :\n [pattern];\n}\n\nexport function buildLocatorOptions(options: LocatorOptionsInput = {}) : LocatorOptions {\n const paths = options.path ?\n toArray(options.path) :\n [];\n\n const ignore = options.ignore ?\n toArray(options.ignore) :\n [];\n\n if (paths.length === 0) {\n paths.push(process.cwd());\n }\n\n let onlyFiles : boolean;\n let onlyDirectories : boolean;\n\n if (options.onlyDirectories === options.onlyFiles) {\n onlyDirectories = false;\n onlyFiles = !options.onlyDirectories;\n } else if (typeof options.onlyFiles === 'undefined') {\n onlyDirectories = options.onlyDirectories ?? false;\n onlyFiles = !options.onlyDirectories;\n } else {\n onlyFiles = options.onlyFiles ?? true;\n onlyDirectories = !options.onlyFiles;\n }\n\n return {\n path: paths,\n ignore,\n onlyDirectories,\n onlyFiles,\n };\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 info.ext :\n undefined,\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, LocatorOptionsInput } from './types';\nimport { buildLocatorOptions, buildLocatorPatterns, pathToLocatorInfo } from './utils';\n\nexport async function locateMany(\n pattern: string | string[],\n options?: LocatorOptionsInput,\n) : Promise<LocatorInfo[]> {\n const patterns = buildLocatorPatterns(pattern);\n const opts = buildLocatorOptions(options);\n\n const items : LocatorInfo[] = [];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < opts.path.length; j++) {\n const files = await fg(patterns[i], {\n absolute: true,\n cwd: opts.path[j],\n ignore: opts.ignore,\n onlyFiles: opts.onlyFiles,\n onlyDirectories: opts.onlyDirectories,\n });\n\n for (let k = 0; k < files.length; k++) {\n items.push(pathToLocatorInfo(files[k], true));\n }\n }\n }\n\n return items;\n}\n\nexport async function locate(\n pattern: string | string[],\n options?: LocatorOptionsInput,\n) : Promise<LocatorInfo | undefined> {\n const patterns = buildLocatorPatterns(pattern);\n const opts = buildLocatorOptions(options);\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < opts.path.length; j++) {\n const files = await fg(patterns[i], {\n absolute: true,\n cwd: opts.path[j],\n ignore: opts.ignore,\n onlyFiles: opts.onlyFiles,\n onlyDirectories: opts.onlyDirectories,\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, LocatorOptionsInput } from './types';\nimport { buildLocatorOptions, buildLocatorPatterns, pathToLocatorInfo } from './utils';\n\nexport function locateManySync(\n pattern: string | string[],\n options?: LocatorOptionsInput,\n) : LocatorInfo[] {\n const patterns = buildLocatorPatterns(pattern);\n const opts = buildLocatorOptions(options);\n\n const items : LocatorInfo[] = [];\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < opts.path.length; j++) {\n const files = fg.sync(patterns[i], {\n absolute: true,\n cwd: opts.path[j],\n ignore: opts.ignore,\n onlyFiles: opts.onlyFiles,\n onlyDirectories: opts.onlyDirectories,\n });\n\n for (let k = 0; k < files.length; k++) {\n items.push(pathToLocatorInfo(files[k], true));\n }\n }\n }\n\n return items;\n}\n\nexport function locateSync(\n pattern: string | string[],\n options?: LocatorOptionsInput,\n) : LocatorInfo | undefined {\n const patterns = buildLocatorPatterns(pattern);\n const opts = buildLocatorOptions(options);\n\n for (let i = 0; i < patterns.length; i++) {\n for (let j = 0; j < opts.path.length; j++) {\n const files = fg.sync(patterns[i] as string, {\n absolute: true,\n cwd: opts.path[j],\n ignore: opts.ignore,\n onlyFiles: opts.onlyFiles,\n onlyDirectories: opts.onlyDirectories,\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 // @see https://github.com/testing-library/user-event/issues/813\n // @see https://stackoverflow.com/questions/62717394/export-default-class-exports-double-nested-default\n if (\n isESModule(data.default) &&\n data.default.default\n ) {\n return {\n ...data,\n default: data.default.default,\n };\n }\n\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 { 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\ntype Jiti = ReturnType<typeof createJiti>;\n\nexport class ModuleLoader implements Loader {\n protected instance : Jiti;\n\n constructor() {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.instance = 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.instance(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.instance(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', '.yaml'], 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 (\n info.extension &&\n test.indexOf(info.extension) !== -1\n ) {\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","pattern","ignore","onlyDirectories","onlyFiles","name","extension","info","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;AACH;AAEKC;AAAQ;AACjB;AAEO;;;;;AAWH;;;AAKA;;;AAGA;;;;;;AAMA;;;AAIIC;AACAC;AACAC;AACJ;AACJ;AAEO;AAIH;AAIIJ;AACJ;;;;AAMIK;AACAC;AAGJ;AACJ;AAEO;AAGH;AAIJ;AAEO;;;AAGH;;;AAIA;AAEA;AACJ;AAEO;;;AAICC;;;AAGJ;AAEA;AACJ;;AC9FO;AAIH;AACA;AAEA;AAEA;;AAEQ;;;AAGIL;AACAE;AACAD;AACJ;AAEA;AACIK;AACJ;AACJ;AACJ;;AAGJ;AAEO;AAIH;AACA;AAEA;;AAEQ;;;AAGIN;AACAE;AACAD;AACJ;;AAGA;AACI;AACJ;AACJ;AACJ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I;;AAA2D;;AAE/D;AACI;AACJ;AACJ;AACJ;;ACrBO;;AAEC;;AAGI;;AAAsE;AACtE;AACJ;AACI;AACJ;AACJ;AAEAA;AACI;;AAGI;;AAA2D;AAC3D;AACJ;AACI;AACJ;AACJ;AACJ;;ACnCA;;;;;;;;;;AAOYY;AAKX;;ACGM;;;AA8BK;AAAkBC;AAAMC;AAAO;AAC/B;AACJ;AAEA;AACJ;;AAGI;AACA;AACI;;AAEJ;AAEA;;AAEJ;AAEAd;AACI;AACA;AACI;;AAEJ;AAEA;;AAEJ;AAEAe;;AAEQ;AACJ;AAEA;;;;;AAQY;AACJ;AACJ;AACI;AACJ;AACJ;;AAGJ;AAEA;;;;;;;AAQI;;AAGI;AACJ;;;;AAMI;AAAoB;AAChBD;AACA;AACJ;AACA;AAAsB;AAClBA;AACA;AACJ;AACA;AAAoB;AAChBA;AACA;AACJ;AACA;AAAoB;AAChBA;AACA;AACJ;AACA;AACS;AACL;AACA;;AAGA;AACJ;AACJ;;AAGI;;AAGJ;AAEA;AACJ;;AAII;;AAEA;;AAGI;AACJ;AAEA;;AAEA;;AAGJ;;;;AA9IQ;;AACW;AAAO;AAAQ;AAAQ;AAAQ;AAAQ;AAAM;AACpDA;AACJ;AACA;;AACW;AAAQ;AAAEA;AACrB;AACA;;AACW;AAAQ;AAAEA;AACrB;AACA;;AACW;AAAQ;AAAQ;AAAEA;AAC7B;AACH;AACL;AAiIJ;;AC7JA;AACO;;;AAGH;AAEAE;;AAGJ;;ACJO;AACH;;;AAII;AACJ;AAEAC;AACJ;AAEO;AACH;;;AAGA;;AAGJ;AAEO;AACH;;;AAGA;;AAGJ;;"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/errors/base.ts","../src/errors/load.ts","../src/errors/not-found.ts","../src/errors/unknown-extension.ts","../src/utils/file-name.ts","../src/utils/has-property.ts","../src/utils/object.ts","../src/utils/to-array.ts","../src/utils/file-path.ts","../src/utils/runtime.ts","../src/utils/typescript.ts","../src/errors/wrap.ts","../src/locator/utils.ts","../src/locator/async.ts","../src/locator/sync.ts","../src/locator/up.ts","../src/loader/built-in/conf/module.ts","../src/loader/built-in/json/module.ts","../src/loader/built-in/module/utils.ts","../src/loader/built-in/module/module.ts","../src/loader/built-in/yaml/module.ts","../src/loader/module.ts","../src/loader/singleton.ts","../src/loader/helpers.ts","../src/loader/package-field.ts"],"sourcesContent":["/*\n * Copyright (c) 2026.\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 {\n BaseError,\n type ErrorOptions,\n hasInstanceof,\n markInstanceof,\n} from '@ebec/core';\n\nexport type LocterErrorOptions = ErrorOptions & {\n path?: string,\n};\n\nexport type LocterErrorInput = string | LocterErrorOptions;\n\nexport const LOCTER_ERROR_MARKER = Symbol.for('@locter/error');\n\nexport class LocterError extends BaseError {\n static override [Symbol.hasInstance](input: unknown) : boolean {\n return hasInstanceof(input, LOCTER_ERROR_MARKER);\n }\n\n public readonly path?: string;\n\n constructor(input: LocterErrorInput = {}) {\n if (typeof input === 'string') {\n super(input);\n } else {\n const { path, ...rest } = input;\n super(rest);\n this.path = path;\n }\n\n markInstanceof(this, LOCTER_ERROR_MARKER);\n }\n}\n","/*\n * Copyright (c) 2026.\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 { hasInstanceof, markInstanceof } from '@ebec/core';\nimport { LocterError, type LocterErrorInput } from './base';\n\nexport const LOCTER_LOAD_ERROR_MARKER = Symbol.for('@locter/load-error');\n\nexport class LocterLoadError extends LocterError {\n static override [Symbol.hasInstance](input: unknown) : boolean {\n return hasInstanceof(input, LOCTER_LOAD_ERROR_MARKER);\n }\n\n constructor(input: LocterErrorInput = {}) {\n super(input);\n markInstanceof(this, LOCTER_LOAD_ERROR_MARKER);\n }\n}\n","/*\n * Copyright (c) 2026.\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 { hasInstanceof, markInstanceof } from '@ebec/core';\nimport { LocterError, type LocterErrorInput } from './base';\n\nexport const LOCTER_NOT_FOUND_ERROR_MARKER = Symbol.for('@locter/not-found-error');\n\nexport class LocterNotFoundError extends LocterError {\n static override [Symbol.hasInstance](input: unknown) : boolean {\n return hasInstanceof(input, LOCTER_NOT_FOUND_ERROR_MARKER);\n }\n\n constructor(input: LocterErrorInput = {}) {\n super(input);\n markInstanceof(this, LOCTER_NOT_FOUND_ERROR_MARKER);\n }\n}\n","/*\n * Copyright (c) 2026.\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 { hasInstanceof, markInstanceof } from '@ebec/core';\nimport { LocterError, type LocterErrorInput } from './base';\n\nexport const LOCTER_UNKNOWN_EXTENSION_ERROR_MARKER = Symbol.for('@locter/unknown-extension-error');\n\nexport class LocterUnknownExtensionError extends LocterError {\n static override [Symbol.hasInstance](input: unknown) : boolean {\n return hasInstanceof(input, LOCTER_UNKNOWN_EXTENSION_ERROR_MARKER);\n }\n\n constructor(input: LocterErrorInput = {}) {\n super(input);\n markInstanceof(this, LOCTER_UNKNOWN_EXTENSION_ERROR_MARKER);\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 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.includes(extension)\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","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\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 isVitestRuntimeEnvironment() : boolean {\n return typeof process !== 'undefined' &&\n process.env.VITEST === 'true';\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) 2026.\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 { hasStringProperty, isObject } from '../utils';\nimport { LocterError } from './base';\nimport { LocterLoadError } from './load';\nimport { LocterNotFoundError } from './not-found';\n\nconst NOT_FOUND_CODES = new Set([\n 'ENOENT',\n 'MODULE_NOT_FOUND',\n 'ERR_MODULE_NOT_FOUND',\n]);\n\nexport function wrapLoaderError(input: unknown, path: string) : LocterError {\n if (input instanceof LocterError) {\n return input;\n }\n\n const code = isObject(input) && hasStringProperty(input, 'code') ?\n input.code :\n undefined;\n\n const message = isObject(input) && hasStringProperty(input, 'message') ?\n input.message :\n `Failed to load: ${path}`;\n\n if (code && NOT_FOUND_CODES.has(code)) {\n return new LocterNotFoundError({\n message,\n code,\n cause: input,\n path,\n });\n }\n\n return new LocterLoadError({\n message,\n code,\n cause: input,\n path,\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 path from 'node:path';\nimport { isObject, toArray } from '../utils';\nimport type { LocatorInfo, LocatorOptions, LocatorOptionsInput } from './types';\n\nexport function buildLocatorPatterns(pattern: string | string[]) : string[] {\n return Array.isArray(pattern) ?\n pattern :\n [pattern];\n}\n\nexport function buildLocatorOptions(options: LocatorOptionsInput = {}) : LocatorOptions {\n const cwd = options.cwd ?\n toArray(options.cwd) :\n [];\n\n const ignore = options.ignore ?\n toArray(options.ignore) :\n [];\n\n if (cwd.length === 0) {\n cwd.push(process.cwd());\n }\n\n let onlyFiles : boolean;\n let onlyDirectories : boolean;\n\n if (options.onlyDirectories === options.onlyFiles) {\n onlyDirectories = false;\n onlyFiles = !options.onlyDirectories;\n } else if (typeof options.onlyFiles === 'undefined') {\n onlyDirectories = options.onlyDirectories ?? false;\n onlyFiles = !options.onlyDirectories;\n } else {\n onlyFiles = options.onlyFiles ?? true;\n onlyDirectories = !options.onlyFiles;\n }\n\n return {\n cwd,\n ignore,\n onlyDirectories,\n onlyFiles,\n dot: options.dot ?? false,\n };\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 const directory = info.dir.split('/').join(path.sep);\n const extension = info.ext ? info.ext : undefined;\n const filePath = extension ?\n path.join(directory, info.name) + extension :\n path.join(directory, info.name);\n\n return {\n directory,\n name: info.name,\n extension,\n path: filePath,\n };\n}\n\nexport function isLocatorInfo(\n input: unknown,\n) : input is LocatorInfo {\n return isObject(input) &&\n typeof input.directory === 'string' &&\n typeof input.name === 'string' &&\n (typeof input.extension === 'undefined' || typeof input.extension === 'string') &&\n typeof input.path === 'string';\n}\n\nexport function buildFilePath(input: LocatorInfo | string) {\n if (typeof input === 'string') {\n return input;\n }\n\n return input.path;\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.directory, 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, LocatorOptionsInput } from './types';\nimport { buildLocatorOptions, buildLocatorPatterns, pathToLocatorInfo } from './utils';\n\nexport async function locateMany(\n pattern: string | string[],\n options?: LocatorOptionsInput,\n) : Promise<LocatorInfo[]> {\n const patterns = buildLocatorPatterns(pattern);\n const opts = buildLocatorOptions(options);\n\n const items : LocatorInfo[] = [];\n\n for (const p of patterns) {\n for (const cwd of opts.cwd) {\n const files = await fg(p, {\n absolute: true,\n cwd,\n ignore: opts.ignore,\n onlyFiles: opts.onlyFiles,\n onlyDirectories: opts.onlyDirectories,\n dot: opts.dot,\n });\n\n for (const file of files) {\n items.push(pathToLocatorInfo(file, true));\n }\n }\n }\n\n return items;\n}\n\nexport async function locate(\n pattern: string | string[],\n options?: LocatorOptionsInput,\n) : Promise<LocatorInfo | undefined> {\n const patterns = buildLocatorPatterns(pattern);\n const opts = buildLocatorOptions(options);\n\n for (const p of patterns) {\n for (const cwd of opts.cwd) {\n const files = await fg(p, {\n absolute: true,\n cwd,\n ignore: opts.ignore,\n onlyFiles: opts.onlyFiles,\n onlyDirectories: opts.onlyDirectories,\n dot: opts.dot,\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, LocatorOptionsInput } from './types';\nimport { buildLocatorOptions, buildLocatorPatterns, pathToLocatorInfo } from './utils';\n\nexport function locateManySync(\n pattern: string | string[],\n options?: LocatorOptionsInput,\n) : LocatorInfo[] {\n const patterns = buildLocatorPatterns(pattern);\n const opts = buildLocatorOptions(options);\n\n const items : LocatorInfo[] = [];\n\n for (const p of patterns) {\n for (const cwd of opts.cwd) {\n const files = fg.sync(p, {\n absolute: true,\n cwd,\n ignore: opts.ignore,\n onlyFiles: opts.onlyFiles,\n onlyDirectories: opts.onlyDirectories,\n dot: opts.dot,\n });\n\n for (const file of files) {\n items.push(pathToLocatorInfo(file, true));\n }\n }\n }\n\n return items;\n}\n\nexport function locateSync(\n pattern: string | string[],\n options?: LocatorOptionsInput,\n) : LocatorInfo | undefined {\n const patterns = buildLocatorPatterns(pattern);\n const opts = buildLocatorOptions(options);\n\n for (const p of patterns) {\n for (const cwd of opts.cwd) {\n const files = fg.sync(p, {\n absolute: true,\n cwd,\n ignore: opts.ignore,\n onlyFiles: opts.onlyFiles,\n onlyDirectories: opts.onlyDirectories,\n dot: opts.dot,\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) 2026.\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 { locate } from './async';\nimport { locateSync } from './sync';\nimport type { LocatorInfo, LocatorOptionsInput } from './types';\n\nexport type LocatorUpOptionsInput = Omit<LocatorOptionsInput, 'cwd'> & {\n cwd?: string,\n stopAt?: string,\n};\n\ntype WalkStep = {\n current: string,\n stopAt: string,\n baseOptions: Omit<LocatorOptionsInput, 'cwd'>,\n};\n\nfunction startWalk(options: LocatorUpOptionsInput) : WalkStep {\n const {\n cwd,\n stopAt,\n ...baseOptions\n } = options;\n const current = path.resolve(cwd ?? process.cwd());\n const ceiling = stopAt ?\n path.resolve(current, stopAt) :\n path.parse(current).root;\n\n return {\n current,\n stopAt: ceiling,\n baseOptions,\n };\n}\n\nfunction nextDirectory(current: string, stopAt: string) : string | undefined {\n if (current === stopAt) {\n return undefined;\n }\n\n const parent = path.dirname(current);\n if (parent === current) {\n return undefined;\n }\n\n return parent;\n}\n\nexport async function locateUp(\n pattern: string | string[],\n options: LocatorUpOptionsInput = {},\n) : Promise<LocatorInfo | undefined> {\n let walk = startWalk(options);\n\n while (true) {\n const found = await locate(pattern, { ...walk.baseOptions, cwd: walk.current });\n if (found) {\n return found;\n }\n\n const next = nextDirectory(walk.current, walk.stopAt);\n if (!next) {\n return undefined;\n }\n\n walk = { ...walk, current: next };\n }\n}\n\nexport function locateUpSync(\n pattern: string | string[],\n options: LocatorUpOptionsInput = {},\n) : LocatorInfo | undefined {\n let walk = startWalk(options);\n\n while (true) {\n const found = locateSync(pattern, { ...walk.baseOptions, cwd: walk.current });\n if (found) {\n return found;\n }\n\n const next = nextDirectory(walk.current, walk.stopAt);\n if (!next) {\n return undefined;\n }\n\n walk = { ...walk, current: next };\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\n// Based on https://github.com/unjs/rc9 (MIT)\n\nimport { destr } from 'destr';\nimport { unflatten } from 'flat';\nimport fs from 'node:fs';\nimport { wrapLoaderError } from '../../../errors';\nimport { buildFilePath } from '../../../locator';\nimport { 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 throw wrapLoaderError(e, filePath);\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 throw wrapLoaderError(e, filePath);\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 (const line of lines) {\n const match = line.match(/^\\s*([^\\s=]+)\\s*=\\s*(.*)?\\s*$/);\n if (!match) {\n continue;\n }\n\n const key = match[1];\n const rawValue = match[2];\n\n if (!key || !isSafeObjectKey(key)) {\n continue;\n }\n\n const value = destr(rawValue ? rawValue.trim() : '');\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 unflatten(config, { overwrite: true });\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 { wrapLoaderError } from '../../../errors';\nimport { buildFilePath } from '../../../locator';\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 throw wrapLoaderError(e, filePath);\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 throw wrapLoaderError(e, filePath);\n }\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 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 // @see https://github.com/testing-library/user-event/issues/813\n // @see https://stackoverflow.com/questions/62717394/export-default-class-exports-double-nested-default\n if (\n isESModule(data.default) &&\n data.default.default\n ) {\n return {\n ...data,\n default: data.default.default,\n };\n }\n\n return data;\n }\n\n const output = Object.create(null, {\n __esModule: { value: true },\n [Symbol.toStringTag]: { value: 'Module' },\n });\n\n if (isObject(data)) {\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 (const key of keys) {\n if (filterFn(key as string, data[key as string])) {\n return {\n key: key as string,\n value: data[key 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 { createJiti } from 'jiti';\nimport { createRequire } from 'node:module';\nimport { pathToFileURL } from 'node:url';\nimport { LocterError, wrapLoaderError } from '../../../errors';\nimport type { LocatorInfo } from '../../../locator';\nimport {\n buildFilePath,\n isLocatorInfo,\n} from '../../../locator';\nimport {\n hasStringProperty,\n isFilePath,\n isJestRuntimeEnvironment,\n isObject,\n isTsNodeRuntimeEnvironment,\n isTypeScriptError,\n} from '../../../utils';\nimport type { Loader } from '../../type';\nimport type {\n ModuleLoadFn,\n ModuleLoadOptions,\n ModuleLoadSyncFn,\n ModuleLoaderOptions,\n} from './type';\nimport { toModuleRecord } from './utils';\n\nconst require = createRequire(import.meta.url);\n\ntype Jiti = ReturnType<typeof createJiti>;\n\nfunction originalPath(data: LocatorInfo | string) : string {\n return typeof data === 'string' ? data : buildFilePath(data);\n}\n\nfunction isUnrecoverableError(error: unknown) : boolean {\n const underlying = error instanceof LocterError ? error.cause : error;\n return underlying instanceof SyntaxError ||\n underlying instanceof ReferenceError ||\n isTypeScriptError(underlying);\n}\n\nexport class ModuleLoader implements Loader {\n protected instance : Jiti;\n\n protected loadFn?: ModuleLoadFn;\n\n protected loadSyncFn?: ModuleLoadSyncFn;\n\n constructor(options: ModuleLoaderOptions = {}) {\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this.instance = createJiti(undefined, { extensions: ['.js', '.mjs', '.mts', '.cjs', '.cts', '.ts'] });\n this.loadFn = options.load;\n this.loadSyncFn = options.loadSync;\n }\n\n configure(options: ModuleLoaderOptions) : void {\n if ('load' in options) {\n this.loadFn = options.load;\n }\n if ('loadSync' in options) {\n this.loadSyncFn = options.loadSync;\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 (isUnrecoverableError(e)) {\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.instance(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 (isUnrecoverableError(e)) {\n throw e;\n }\n\n output = this.instance(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 if (this.loadFn) {\n return await this.loadFn(id);\n }\n\n // segmentation fault\n // issue: https://github.com/nodejs/node/issues/35889\n if (isJestRuntimeEnvironment()) {\n return require(id);\n }\n\n return await import(id);\n } catch (e) {\n /* istanbul ignore next */\n if (\n !options.withFilePrefix &&\n isObject(e) &&\n hasStringProperty(e, 'code') &&\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 wrapLoaderError(e, originalPath(data));\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 if (this.loadSyncFn) {\n return this.loadSyncFn(id);\n }\n\n return require(id);\n } catch (e) {\n throw wrapLoaderError(e, originalPath(data));\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 { parse } from 'yaml';\nimport fs from 'node:fs';\nimport { wrapLoaderError } from '../../../errors';\nimport { buildFilePath } from '../../../locator';\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 throw wrapLoaderError(e, filePath);\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 throw wrapLoaderError(e, filePath);\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\nimport path from 'node:path';\nimport {\n LocterError,\n LocterUnknownExtensionError,\n wrapLoaderError,\n} from '../errors';\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 { test: ['.conf'], loader: LoaderId.CONF },\n { test: ['.json'], loader: LoaderId.JSON },\n { test: ['.yml', '.yaml'], loader: LoaderId.YAML },\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 throw this.unknownExtensionError(input);\n }\n\n const loader = this.resolve(id);\n try {\n return await loader.execute(input);\n } catch (e) {\n throw wrapLoaderError(e, input);\n }\n }\n\n executeSync(input: string) : any {\n const id = this.findLoader(input);\n if (!id) {\n throw this.unknownExtensionError(input);\n }\n\n const loader = this.resolve(id);\n try {\n return loader.executeSync(input);\n } catch (e) {\n throw wrapLoaderError(e, input);\n }\n }\n\n protected unknownExtensionError(input: string) : LocterUnknownExtensionError {\n const info = pathToLocatorInfo(input);\n return new LocterUnknownExtensionError({\n message: `No loader registered for extension: ${info.extension ?? 'unknown'}`,\n path: input,\n });\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 (const rule of this.rules) {\n const { test } = rule;\n if (Array.isArray(test)) {\n if (\n info.extension &&\n test.includes(info.extension)\n ) {\n return rule.loader;\n }\n } else if (test.test(buildFilePath(info))) {\n return rule.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 LocterError({ message: `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 type { ModuleLoader } from './built-in/module';\nimport type { ModuleLoaderOptions } from './built-in/module/type';\nimport { LoaderId } from './constants';\nimport { useLoader } from './singleton';\nimport type { Loader, Rule } from './type';\n\nexport function registerLoader(rule: Rule) : void;\nexport function registerLoader(test: string[] | RegExp, loader: Loader) : void;\nexport function registerLoader(test: any, loader?: Loader) : void {\n const manager = useLoader();\n if (typeof loader !== 'undefined') {\n manager.register(test, loader);\n\n return;\n }\n\n manager.register(test);\n}\n\nexport async function load(input: LocatorInfo | string) : Promise<any> {\n const manager = useLoader();\n if (typeof input === 'string') {\n return manager.execute(input);\n }\n\n return manager.execute(buildFilePath(input));\n}\n\nexport function loadSync(input: LocatorInfo | string) : any {\n const manager = useLoader();\n if (typeof input === 'string') {\n return manager.executeSync(input);\n }\n\n return manager.executeSync(buildFilePath(input));\n}\n\n/**\n * Override the built-in module loader's `import` / `require` calls.\n *\n * Useful for test runners (e.g. Vitest) where the dynamic `import()` inside\n * `node_modules/locter` would bypass the runner's module graph. Calling this\n * from user code (e.g. a Vitest setup file) lets the runner rewrite the\n * `import()` so loaded modules share identity with statically imported ones.\n *\n * @example\n * ```ts\n * // vitest setup file\n * import { setModuleLoader } from 'locter';\n *\n * setModuleLoader({\n * load: (id) => import(id),\n * });\n * ```\n */\nexport function setModuleLoader(options: ModuleLoaderOptions) : void {\n const manager = useLoader();\n const loader = manager.resolve(LoaderId.MODULE) as ModuleLoader;\n loader.configure(options);\n}\n","/*\n * Copyright (c) 2026.\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 { LocterNotFoundError } from '../errors';\nimport type { LocatorInfo } from '../locator';\nimport {\n locate,\n locateSync,\n locateUp,\n locateUpSync,\n} from '../locator';\nimport { hasOwnProperty, isObject } from '../utils';\nimport { load, loadSync } from './helpers';\n\nexport type LoadPackageFieldOptions = {\n cwd?: string,\n walkUp?: boolean,\n stopAt?: string,\n};\n\nfunction extractField<T>(pkg: unknown, field: string) : T | undefined {\n if (!isObject(pkg) || !hasOwnProperty(pkg, field)) {\n return undefined;\n }\n return pkg[field] as T;\n}\n\nexport async function loadPackageField<T = unknown>(\n field: string,\n options: LoadPackageFieldOptions = {},\n) : Promise<T | undefined> {\n let info: LocatorInfo | undefined;\n if (options.walkUp) {\n info = await locateUp('package.json', {\n cwd: options.cwd,\n stopAt: options.stopAt,\n });\n } else {\n info = await locate('package.json', { cwd: options.cwd });\n }\n\n if (!info) {\n return undefined;\n }\n\n try {\n const pkg = await load(info);\n return extractField<T>(pkg, field);\n } catch (e) {\n if (e instanceof LocterNotFoundError) {\n return undefined;\n }\n throw e;\n }\n}\n\nexport function loadPackageFieldSync<T = unknown>(\n field: string,\n options: LoadPackageFieldOptions = {},\n) : T | undefined {\n let info: LocatorInfo | undefined;\n if (options.walkUp) {\n info = locateUpSync('package.json', {\n cwd: options.cwd,\n stopAt: options.stopAt,\n });\n } else {\n info = locateSync('package.json', { cwd: options.cwd });\n }\n\n if (!info) {\n return undefined;\n }\n\n try {\n const pkg = loadSync(info);\n return extractField<T>(pkg, field);\n } catch (e) {\n if (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,UAAU,UAAU;CAC1B,IAAI,OAAO,UAAU,UACjB,OAAO,QAAQ,YAAY,KAAK;CAGpC,OAAO,QAAQ,YAAY,cAAc,KAAK,CAAC;AACnD;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,gBAAgB,SAAqC;CAGjE,UADqB,EAAE,QAAA,QAClB,EAAE,UAAU,OAAO;AAC5B;;;AC5CA,SAAS,aAAgB,KAAc,OAA+B;CAClE,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,eAAe,KAAK,KAAK,GAC5C;CAEJ,OAAO,IAAI;AACf;AAEA,eAAsB,iBAClB,OACA,UAAmC,CAAC,GACb;CACvB,IAAI;CACJ,IAAI,QAAQ,QACR,OAAO,MAAM,SAAS,gBAAgB;EAClC,KAAK,QAAQ;EACb,QAAQ,QAAQ;CACpB,CAAC;MAED,OAAO,MAAM,OAAO,gBAAgB,EAAE,KAAK,QAAQ,IAAI,CAAC;CAG5D,IAAI,CAAC,MACD;CAGJ,IAAI;EAEA,OAAO,aAAgB,MADL,KAAK,IAAI,GACC,KAAK;CACrC,SAAS,GAAG;EACR,IAAI,aAAa,qBACb;EAEJ,MAAM;CACV;AACJ;AAEA,SAAgB,qBACZ,OACA,UAAmC,CAAC,GACtB;CACd,IAAI;CACJ,IAAI,QAAQ,QACR,OAAO,aAAa,gBAAgB;EAChC,KAAK,QAAQ;EACb,QAAQ,QAAQ;CACpB,CAAC;MAED,OAAO,WAAW,gBAAgB,EAAE,KAAK,QAAQ,IAAI,CAAC;CAG1D,IAAI,CAAC,MACD;CAGJ,IAAI;EAEA,OAAO,aADK,SAAS,IACI,GAAG,KAAK;CACrC,SAAS,GAAG;EACR,IAAI,aAAa,qBACb;EAEJ,MAAM;CACV;AACJ"}
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "locter",
3
- "version": "2.2.1",
3
+ "version": "3.0.0",
4
+ "type": "module",
4
5
  "description": "A library to locate a file/module by criteria and load it!",
5
6
  "author": {
6
7
  "name": "Peter Placzek",
@@ -14,30 +15,27 @@
14
15
  "type": "git",
15
16
  "url": "https://github.com/tada5hi/locter.git"
16
17
  },
17
- "main": "dist/index.cjs",
18
- "module": "dist/index.mjs",
19
- "types": "dist/index.d.ts",
18
+ "main": "dist/index.mjs",
19
+ "types": "dist/index.d.mts",
20
20
  "exports": {
21
21
  "./package.json": "./package.json",
22
22
  ".": {
23
- "types": "./dist/index.d.ts",
24
- "require": "./dist/index.cjs",
23
+ "types": "./dist/index.d.mts",
25
24
  "import": "./dist/index.mjs"
26
25
  }
27
26
  },
28
27
  "files": [
29
- "dist/"
28
+ "dist"
30
29
  ],
31
30
  "scripts": {
32
- "build:types": "tsc --emitDeclarationOnly",
33
- "build:js": "rollup -c",
34
- "build": "rimraf dist && npm run build:types && npm run build:js",
35
- "commit": "npx git-cz",
36
- "test": "cross-env NODE_ENV=test jest --config ./test/jest.config.js",
37
- "test:coverage": "cross-env NODE_ENV=test jest --config ./test/jest.config.js --coverage",
38
- "lint": "eslint --ext .js,.vue,.ts ./src",
31
+ "build:types": "tsc --noEmit",
32
+ "build:js": "tsdown",
33
+ "build": "npm run build:types && npm run build:js",
34
+ "test": "vitest --config test/vitest.config.ts --run",
35
+ "test:coverage": "vitest --config test/vitest.config.ts --run --coverage",
36
+ "lint": "eslint",
39
37
  "lint:fix": "npm run lint -- --fix",
40
- "prepare": "npx husky install"
38
+ "prepare": "husky"
41
39
  },
42
40
  "keywords": [
43
41
  "file",
@@ -51,32 +49,27 @@
51
49
  "transpiling",
52
50
  "typescript"
53
51
  ],
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
54
55
  "license": "MIT",
55
56
  "devDependencies": {
56
- "@rollup/plugin-esm-shim": "^0.1.8",
57
- "@rollup/plugin-node-resolve": "^16.0.3",
58
- "@swc/core": "^1.15.3",
59
- "@swc/jest": "^0.2.39",
60
- "@tada5hi/commitlint-config": "^1.2.6",
61
- "@tada5hi/eslint-config-typescript": "^1.2.17",
62
- "@tada5hi/tsconfig": "^0.6.0",
63
- "@types/flat": "^5.0.2",
64
- "@types/jest": "^30.0.0",
65
- "@types/node": "^24.10.1",
66
- "cross-env": "^10.1.0",
67
- "eslint": "^8.57.0",
57
+ "@tada5hi/commitlint-config": "^1.3.1",
58
+ "@tada5hi/eslint-config": "^2.3.0",
59
+ "@tada5hi/tsconfig": "^0.7.2",
60
+ "@vitest/coverage-v8": "^4.1.5",
61
+ "eslint": "^10.3.0",
68
62
  "husky": "^9.1.7",
69
- "jest": "^30.2.0",
70
- "rimraf": "^6.1.2",
71
- "rollup": "^4.53.3",
72
- "typescript": "^5.9.3",
73
- "workspaces-publish": "^1.5.0"
63
+ "tsdown": "^0.22.0",
64
+ "typescript": "^6.0.3",
65
+ "typescript-eslint": "^8.59.2",
66
+ "vitest": "^4.1.5"
74
67
  },
75
68
  "dependencies": {
69
+ "@ebec/core": "^1.1.0",
76
70
  "destr": "^2.0.5",
77
- "ebec": "^2.3.0",
78
71
  "fast-glob": "^3.3.3",
79
- "flat": "^5.0.2",
72
+ "flat": "^6.0.1",
80
73
  "jiti": "^2.6.1",
81
74
  "yaml": "^2.8.1"
82
75
  }