🎉 initiate project *astro_rewrite*

This commit is contained in:
sindrekjelsrud 2023-07-19 21:31:30 +02:00
parent ffd4d5e86c
commit 2ba37bfbe3
8658 changed files with 2268794 additions and 2538 deletions

18
node_modules/import-meta-resolve/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,18 @@
/**
* Match `import.meta.resolve` except that `parent` is required (you can pass
* `import.meta.url`).
*
* @param {string} specifier
* The module specifier to resolve relative to parent
* (`/example.js`, `./example.js`, `../example.js`, `some-package`, `fs`,
* etc).
* @param {string} parent
* The absolute parent module URL to resolve from.
* You should pass `import.meta.url` or something else.
* @returns {Promise<string>}
* Returns a promise that resolves to a full `file:`, `data:`, or `node:` URL
* to the found thing.
*/
export function resolve(specifier: string, parent: string): Promise<string>
export {moduleResolve} from './lib/resolve.js'
export type ErrnoException = import('./lib/errors.js').ErrnoException

41
node_modules/import-meta-resolve/index.js generated vendored Normal file
View file

@ -0,0 +1,41 @@
/**
* @typedef {import('./lib/errors.js').ErrnoException} ErrnoException
*/
import {defaultResolve} from './lib/resolve.js'
/**
* Match `import.meta.resolve` except that `parent` is required (you can pass
* `import.meta.url`).
*
* @param {string} specifier
* The module specifier to resolve relative to parent
* (`/example.js`, `./example.js`, `../example.js`, `some-package`, `fs`,
* etc).
* @param {string} parent
* The absolute parent module URL to resolve from.
* You should pass `import.meta.url` or something else.
* @returns {Promise<string>}
* Returns a promise that resolves to a full `file:`, `data:`, or `node:` URL
* to the found thing.
*/
export async function resolve(specifier, parent) {
if (!parent) {
throw new Error(
'Please pass `parent`: `import-meta-resolve` cannot ponyfill that'
)
}
try {
return defaultResolve(specifier, {parentURL: parent}).url
} catch (error) {
const exception = /** @type {ErrnoException} */ (error)
return exception.code === 'ERR_UNSUPPORTED_DIR_IMPORT' &&
typeof exception.url === 'string'
? exception.url
: Promise.reject(error)
}
}
export {moduleResolve} from './lib/resolve.js'

22
node_modules/import-meta-resolve/lib/errors.d.ts generated vendored Normal file
View file

@ -0,0 +1,22 @@
export namespace codes {
const ERR_INVALID_MODULE_SPECIFIER: new (...args: any[]) => Error
const ERR_INVALID_PACKAGE_CONFIG: new (...args: any[]) => Error
const ERR_INVALID_PACKAGE_TARGET: new (...args: any[]) => Error
const ERR_MODULE_NOT_FOUND: new (...args: any[]) => Error
const ERR_NETWORK_IMPORT_DISALLOWED: new (...args: any[]) => Error
const ERR_PACKAGE_IMPORT_NOT_DEFINED: new (...args: any[]) => Error
const ERR_PACKAGE_PATH_NOT_EXPORTED: new (...args: any[]) => Error
const ERR_UNSUPPORTED_DIR_IMPORT: new (...args: any[]) => Error
const ERR_UNKNOWN_FILE_EXTENSION: new (...args: any[]) => Error
const ERR_INVALID_ARG_VALUE: new (...args: any[]) => Error
const ERR_UNSUPPORTED_ESM_URL_SCHEME: new (...args: any[]) => Error
}
export type ErrnoExceptionFields = {
errnode?: number | undefined
code?: string | undefined
path?: string | undefined
syscall?: string | undefined
url?: string | undefined
}
export type ErrnoException = Error & ErrnoExceptionFields
export type MessageFunction = (...args: Array<any>) => string

389
node_modules/import-meta-resolve/lib/errors.js generated vendored Normal file
View file

@ -0,0 +1,389 @@
/**
* @typedef ErrnoExceptionFields
* @property {number | undefined} [errnode]
* @property {string | undefined} [code]
* @property {string | undefined} [path]
* @property {string | undefined} [syscall]
* @property {string | undefined} [url]
*
* @typedef {Error & ErrnoExceptionFields} ErrnoException
*/
/**
* @typedef {(...args: Array<any>) => string} MessageFunction
*/
// Manually “tree shaken” from:
// <https://github.com/nodejs/node/blob/6668c4d/lib/internal/errors.js>
// Last checked on: Jan 6, 2023.
import v8 from 'node:v8'
import process from 'node:process'
import assert from 'node:assert'
// Needed for types.
// eslint-disable-next-line no-unused-vars
import {URL} from 'node:url'
import {format, inspect} from 'node:util'
const isWindows = process.platform === 'win32'
const own = {}.hasOwnProperty
export const codes = {}
/**
* Create a list string in the form like 'A and B' or 'A, B, ..., and Z'.
* We cannot use Intl.ListFormat because it's not available in
* --without-intl builds.
*
* @param {Array<string>} array
* An array of strings.
* @param {string} [type]
* The list type to be inserted before the last element.
* @returns {string}
*/
function formatList(array, type = 'and') {
return array.length < 3
? array.join(` ${type} `)
: `${array.slice(0, -1).join(', ')}, ${type} ${array[array.length - 1]}`
}
/** @type {Map<string, MessageFunction|string>} */
const messages = new Map()
const nodeInternalPrefix = '__node_internal_'
/** @type {number} */
let userStackTraceLimit
codes.ERR_INVALID_MODULE_SPECIFIER = createError(
'ERR_INVALID_MODULE_SPECIFIER',
/**
* @param {string} request
* @param {string} reason
* @param {string} [base]
*/
(request, reason, base = undefined) => {
return `Invalid module "${request}" ${reason}${
base ? ` imported from ${base}` : ''
}`
},
TypeError
)
codes.ERR_INVALID_PACKAGE_CONFIG = createError(
'ERR_INVALID_PACKAGE_CONFIG',
/**
* @param {string} path
* @param {string} [base]
* @param {string} [message]
*/
(path, base, message) => {
return `Invalid package config ${path}${
base ? ` while importing ${base}` : ''
}${message ? `. ${message}` : ''}`
},
Error
)
codes.ERR_INVALID_PACKAGE_TARGET = createError(
'ERR_INVALID_PACKAGE_TARGET',
/**
* @param {string} pkgPath
* @param {string} key
* @param {unknown} target
* @param {boolean} [isImport=false]
* @param {string} [base]
*/
(pkgPath, key, target, isImport = false, base = undefined) => {
const relError =
typeof target === 'string' &&
!isImport &&
target.length > 0 &&
!target.startsWith('./')
if (key === '.') {
assert(isImport === false)
return (
`Invalid "exports" main target ${JSON.stringify(target)} defined ` +
`in the package config ${pkgPath}package.json${
base ? ` imported from ${base}` : ''
}${relError ? '; targets must start with "./"' : ''}`
)
}
return `Invalid "${
isImport ? 'imports' : 'exports'
}" target ${JSON.stringify(
target
)} defined for '${key}' in the package config ${pkgPath}package.json${
base ? ` imported from ${base}` : ''
}${relError ? '; targets must start with "./"' : ''}`
},
Error
)
codes.ERR_MODULE_NOT_FOUND = createError(
'ERR_MODULE_NOT_FOUND',
/**
* @param {string} path
* @param {string} base
* @param {string} [type]
*/
(path, base, type = 'package') => {
return `Cannot find ${type} '${path}' imported from ${base}`
},
Error
)
codes.ERR_NETWORK_IMPORT_DISALLOWED = createError(
'ERR_NETWORK_IMPORT_DISALLOWED',
"import of '%s' by %s is not supported: %s",
Error
)
codes.ERR_PACKAGE_IMPORT_NOT_DEFINED = createError(
'ERR_PACKAGE_IMPORT_NOT_DEFINED',
/**
* @param {string} specifier
* @param {string} packagePath
* @param {string} base
*/
(specifier, packagePath, base) => {
return `Package import specifier "${specifier}" is not defined${
packagePath ? ` in package ${packagePath}package.json` : ''
} imported from ${base}`
},
TypeError
)
codes.ERR_PACKAGE_PATH_NOT_EXPORTED = createError(
'ERR_PACKAGE_PATH_NOT_EXPORTED',
/**
* @param {string} pkgPath
* @param {string} subpath
* @param {string} [base]
*/
(pkgPath, subpath, base = undefined) => {
if (subpath === '.')
return `No "exports" main defined in ${pkgPath}package.json${
base ? ` imported from ${base}` : ''
}`
return `Package subpath '${subpath}' is not defined by "exports" in ${pkgPath}package.json${
base ? ` imported from ${base}` : ''
}`
},
Error
)
codes.ERR_UNSUPPORTED_DIR_IMPORT = createError(
'ERR_UNSUPPORTED_DIR_IMPORT',
"Directory import '%s' is not supported " +
'resolving ES modules imported from %s',
Error
)
codes.ERR_UNKNOWN_FILE_EXTENSION = createError(
'ERR_UNKNOWN_FILE_EXTENSION',
/**
* @param {string} ext
* @param {string} path
*/
(ext, path) => {
return `Unknown file extension "${ext}" for ${path}`
},
TypeError
)
codes.ERR_INVALID_ARG_VALUE = createError(
'ERR_INVALID_ARG_VALUE',
/**
* @param {string} name
* @param {unknown} value
* @param {string} [reason='is invalid']
*/
(name, value, reason = 'is invalid') => {
let inspected = inspect(value)
if (inspected.length > 128) {
inspected = `${inspected.slice(0, 128)}...`
}
const type = name.includes('.') ? 'property' : 'argument'
return `The ${type} '${name}' ${reason}. Received ${inspected}`
},
TypeError
// Note: extra classes have been shaken out.
// , RangeError
)
codes.ERR_UNSUPPORTED_ESM_URL_SCHEME = createError(
'ERR_UNSUPPORTED_ESM_URL_SCHEME',
/**
* @param {URL} url
* @param {Array<string>} supported
*/
(url, supported) => {
let message = `Only URLs with a scheme in: ${formatList(
supported
)} are supported by the default ESM loader`
if (isWindows && url.protocol.length === 2) {
message += '. On Windows, absolute paths must be valid file:// URLs'
}
message += `. Received protocol '${url.protocol}'`
return message
},
Error
)
/**
* Utility function for registering the error codes. Only used here. Exported
* *only* to allow for testing.
* @param {string} sym
* @param {MessageFunction|string} value
* @param {ErrorConstructor} def
* @returns {new (...args: Array<any>) => Error}
*/
function createError(sym, value, def) {
// Special case for SystemError that formats the error message differently
// The SystemErrors only have SystemError as their base classes.
messages.set(sym, value)
return makeNodeErrorWithCode(def, sym)
}
/**
* @param {ErrorConstructor} Base
* @param {string} key
* @returns {ErrorConstructor}
*/
function makeNodeErrorWithCode(Base, key) {
// @ts-expect-error Its a Node error.
return NodeError
/**
* @param {Array<unknown>} args
*/
function NodeError(...args) {
const limit = Error.stackTraceLimit
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = 0
const error = new Base()
// Reset the limit and setting the name property.
if (isErrorStackTraceLimitWritable()) Error.stackTraceLimit = limit
const message = getMessage(key, args, error)
Object.defineProperties(error, {
// Note: no need to implement `kIsNodeError` symbol, would be hard,
// probably.
message: {
value: message,
enumerable: false,
writable: true,
configurable: true
},
toString: {
/** @this {Error} */
value() {
return `${this.name} [${key}]: ${this.message}`
},
enumerable: false,
writable: true,
configurable: true
}
})
captureLargerStackTrace(error)
// @ts-expect-error Its a Node error.
error.code = key
return error
}
}
/**
* @returns {boolean}
*/
function isErrorStackTraceLimitWritable() {
// Do no touch Error.stackTraceLimit as V8 would attempt to install
// it again during deserialization.
try {
// @ts-expect-error: not in types?
if (v8.startupSnapshot.isBuildingSnapshot()) {
return false
}
} catch {}
const desc = Object.getOwnPropertyDescriptor(Error, 'stackTraceLimit')
if (desc === undefined) {
return Object.isExtensible(Error)
}
return own.call(desc, 'writable') && desc.writable !== undefined
? desc.writable
: desc.set !== undefined
}
/**
* This function removes unnecessary frames from Node.js core errors.
* @template {(...args: unknown[]) => unknown} T
* @param {T} fn
* @returns {T}
*/
function hideStackFrames(fn) {
// We rename the functions that will be hidden to cut off the stacktrace
// at the outermost one
const hidden = nodeInternalPrefix + fn.name
Object.defineProperty(fn, 'name', {value: hidden})
return fn
}
const captureLargerStackTrace = hideStackFrames(
/**
* @param {Error} error
* @returns {Error}
*/
// @ts-expect-error: fine
function (error) {
const stackTraceLimitIsWritable = isErrorStackTraceLimitWritable()
if (stackTraceLimitIsWritable) {
userStackTraceLimit = Error.stackTraceLimit
Error.stackTraceLimit = Number.POSITIVE_INFINITY
}
Error.captureStackTrace(error)
// Reset the limit
if (stackTraceLimitIsWritable) Error.stackTraceLimit = userStackTraceLimit
return error
}
)
/**
* @param {string} key
* @param {Array<unknown>} args
* @param {Error} self
* @returns {string}
*/
function getMessage(key, args, self) {
const message = messages.get(key)
assert(typeof message !== 'undefined', 'expected `message` to be found')
if (typeof message === 'function') {
assert(
message.length <= args.length, // Default options do not count.
`Code: ${key}; The provided arguments length (${args.length}) does not ` +
`match the required ones (${message.length}).`
)
return Reflect.apply(message, self, args)
}
const regex = /%[dfijoOs]/g
let expectedLength = 0
while (regex.exec(message) !== null) expectedLength++
assert(
expectedLength === args.length,
`Code: ${key}; The provided arguments length (${args.length}) does not ` +
`match the required ones (${expectedLength}).`
)
if (args.length === 0) return message
args.unshift(message)
return Reflect.apply(format, null, args)
}

31
node_modules/import-meta-resolve/lib/get-format.d.ts generated vendored Normal file
View file

@ -0,0 +1,31 @@
/// <reference types="node" resolution-mode="require"/>
/**
* @param {URL} url
* @param {{parentURL: string}} context
* @returns {string|null}
*/
export function defaultGetFormatWithoutErrors(
url: URL,
context: {
parentURL: string
}
): string | null
/**
* @param {string} url
* @param {{parentURL: string}} context
* @returns {string|null|void}
*/
export function defaultGetFormat(
url: string,
context: {
parentURL: string
}
): string | null | void
export type ProtocolHandler = (
parsed: URL,
context: {
parentURL: string
},
ignoreErrors: boolean
) => string | null | void
import {URL} from 'url'

120
node_modules/import-meta-resolve/lib/get-format.js generated vendored Normal file
View file

@ -0,0 +1,120 @@
// Manually “tree shaken” from:
// <https://github.com/nodejs/node/blob/6668c4d/lib/internal/modules/esm/get_format.js>
// Last checked on: Jan 6, 2023.
import path from 'node:path'
import {URL, fileURLToPath} from 'node:url'
import {getPackageType} from './resolve-get-package-type.js'
import {codes} from './errors.js'
const {ERR_UNKNOWN_FILE_EXTENSION} = codes
const hasOwnProperty = {}.hasOwnProperty
/** @type {Record<string, string>} */
const extensionFormatMap = {
// @ts-expect-error: hush.
__proto__: null,
'.cjs': 'commonjs',
'.js': 'module',
'.json': 'json',
'.mjs': 'module'
}
/**
* @param {string|null} mime
* @returns {string | null}
*/
function mimeToFormat(mime) {
if (
mime &&
/\s*(text|application)\/javascript\s*(;\s*charset=utf-?8\s*)?/i.test(mime)
)
return 'module'
if (mime === 'application/json') return 'json'
return null
}
/**
* @callback ProtocolHandler
* @param {URL} parsed
* @param {{parentURL: string}} context
* @param {boolean} ignoreErrors
* @returns {string|null|void}
*/
/**
* @type {Record<string, ProtocolHandler>}
*/
const protocolHandlers = {
// @ts-expect-error: hush.
__proto__: null,
'data:': getDataProtocolModuleFormat,
'file:': getFileProtocolModuleFormat,
'http:': getHttpProtocolModuleFormat,
'https:': getHttpProtocolModuleFormat,
'node:'() {
return 'builtin'
}
}
/**
* @param {URL} parsed
*/
function getDataProtocolModuleFormat(parsed) {
const {1: mime} = /^([^/]+\/[^;,]+)[^,]*?(;base64)?,/.exec(
parsed.pathname
) || [null, null, null]
return mimeToFormat(mime)
}
/**
* @type {ProtocolHandler}
*/
function getFileProtocolModuleFormat(url, _context, ignoreErrors) {
const filepath = fileURLToPath(url)
const ext = path.extname(filepath)
if (ext === '.js') {
return getPackageType(url) === 'module' ? 'module' : 'commonjs'
}
const format = extensionFormatMap[ext]
if (format) return format
// Explicit undefined return indicates load hook should rerun format check
if (ignoreErrors) {
return undefined
}
throw new ERR_UNKNOWN_FILE_EXTENSION(ext, filepath)
}
function getHttpProtocolModuleFormat() {
// To do: HTTPS imports.
}
/**
* @param {URL} url
* @param {{parentURL: string}} context
* @returns {string|null}
*/
export function defaultGetFormatWithoutErrors(url, context) {
if (!hasOwnProperty.call(protocolHandlers, url.protocol)) {
return null
}
return protocolHandlers[url.protocol](url, context, true) || null
}
/**
* @param {string} url
* @param {{parentURL: string}} context
* @returns {string|null|void}
*/
export function defaultGetFormat(url, context) {
const parsed = new URL(url)
return hasOwnProperty.call(protocolHandlers, parsed.protocol)
? protocolHandlers[parsed.protocol](parsed, context, false)
: null
}

View file

@ -0,0 +1,29 @@
/// <reference types="node" resolution-mode="require"/>
/**
* @param {string} path
* @param {string|URL} specifier Note: `specifier` is actually optional, not base.
* @param {URL} [base]
* @returns {PackageConfig}
*/
export function getPackageConfig(
path: string,
specifier: string | URL,
base?: URL | undefined
): PackageConfig
/**
* @param {URL} resolved
* @returns {PackageConfig}
*/
export function getPackageScopeConfig(resolved: URL): PackageConfig
export type ErrnoException = import('./errors.js').ErrnoException
export type PackageType = 'module' | 'commonjs' | 'none'
export type PackageConfig = {
pjsonPath: string
exists: boolean
main: string | undefined
name: string | undefined
type: PackageType
exports: Record<string, unknown> | undefined
imports: Record<string, unknown> | undefined
}
import {URL} from 'url'

129
node_modules/import-meta-resolve/lib/package-config.js generated vendored Normal file
View file

@ -0,0 +1,129 @@
// Manually “tree shaken” from:
// <https://github.com/nodejs/node/blob/6668c4d/lib/internal/modules/esm/package_config.js>
// Last checked on: Jan 6, 2023.
/**
* @typedef {import('./errors.js').ErrnoException} ErrnoException
*
* @typedef {'module'|'commonjs'|'none'} PackageType
*
* @typedef PackageConfig
* @property {string} pjsonPath
* @property {boolean} exists
* @property {string|undefined} main
* @property {string|undefined} name
* @property {PackageType} type
* @property {Record<string, unknown>|undefined} exports
* @property {Record<string, unknown>|undefined} imports
*/
import {URL, fileURLToPath} from 'node:url'
import {codes} from './errors.js'
import packageJsonReader from './package-json-reader.js'
const {ERR_INVALID_PACKAGE_CONFIG} = codes
/** @type {Map<string, PackageConfig>} */
const packageJsonCache = new Map()
/**
* @param {string} path
* @param {string|URL} specifier Note: `specifier` is actually optional, not base.
* @param {URL} [base]
* @returns {PackageConfig}
*/
export function getPackageConfig(path, specifier, base) {
const existing = packageJsonCache.get(path)
if (existing !== undefined) {
return existing
}
const source = packageJsonReader.read(path).string
if (source === undefined) {
/** @type {PackageConfig} */
const packageConfig = {
pjsonPath: path,
exists: false,
main: undefined,
name: undefined,
type: 'none',
exports: undefined,
imports: undefined
}
packageJsonCache.set(path, packageConfig)
return packageConfig
}
/** @type {Record<string, unknown>} */
let packageJson
try {
packageJson = JSON.parse(source)
} catch (error) {
const exception = /** @type {ErrnoException} */ (error)
throw new ERR_INVALID_PACKAGE_CONFIG(
path,
(base ? `"${specifier}" from ` : '') + fileURLToPath(base || specifier),
exception.message
)
}
const {exports, imports, main, name, type} = packageJson
/** @type {PackageConfig} */
const packageConfig = {
pjsonPath: path,
exists: true,
main: typeof main === 'string' ? main : undefined,
name: typeof name === 'string' ? name : undefined,
type: type === 'module' || type === 'commonjs' ? type : 'none',
// @ts-expect-error Assume `Record<string, unknown>`.
exports,
// @ts-expect-error Assume `Record<string, unknown>`.
imports: imports && typeof imports === 'object' ? imports : undefined
}
packageJsonCache.set(path, packageConfig)
return packageConfig
}
/**
* @param {URL} resolved
* @returns {PackageConfig}
*/
export function getPackageScopeConfig(resolved) {
let packageJsonUrl = new URL('package.json', resolved)
while (true) {
const packageJsonPath = packageJsonUrl.pathname
if (packageJsonPath.endsWith('node_modules/package.json')) break
const packageConfig = getPackageConfig(
fileURLToPath(packageJsonUrl),
resolved
)
if (packageConfig.exists) return packageConfig
const lastPackageJsonUrl = packageJsonUrl
packageJsonUrl = new URL('../package.json', packageJsonUrl)
// Terminates at root where ../package.json equals ../../package.json
// (can't just check "/package.json" for Windows support).
if (packageJsonUrl.pathname === lastPackageJsonUrl.pathname) break
}
const packageJsonPath = fileURLToPath(packageJsonUrl)
/** @type {PackageConfig} */
const packageConfig = {
pjsonPath: packageJsonPath,
exists: false,
main: undefined,
name: undefined,
type: 'none',
exports: undefined,
imports: undefined
}
packageJsonCache.set(packageJsonPath, packageConfig)
return packageConfig
}

View file

@ -0,0 +1,12 @@
export default reader
export type ErrnoException = import('./errors.js').ErrnoException
declare namespace reader {
export {read}
}
/**
* @param {string} jsonPath
* @returns {{string: string|undefined}}
*/
declare function read(jsonPath: string): {
string: string | undefined
}

View file

@ -0,0 +1,39 @@
// Manually “tree shaken” from:
// <https://github.com/nodejs/node/blob/6668c4d/lib/internal/modules/package_json_reader.js>
// Last checked on: Jan 6, 2023.
// Removed the native dependency.
// Also: no need to cache, we do that in resolve already.
/**
* @typedef {import('./errors.js').ErrnoException} ErrnoException
*/
import fs from 'node:fs'
import path from 'node:path'
const reader = {read}
export default reader
/**
* @param {string} jsonPath
* @returns {{string: string|undefined}}
*/
function read(jsonPath) {
try {
const string = fs.readFileSync(
path.toNamespacedPath(path.join(path.dirname(jsonPath), 'package.json')),
'utf8'
)
return {string}
} catch (error) {
const exception = /** @type {ErrnoException} */ (error)
if (exception.code === 'ENOENT') {
return {string: undefined}
// Throw all other errors.
/* c8 ignore next 4 */
}
throw exception
}
}

View file

@ -0,0 +1,6 @@
/**
* @param {URL} url
* @returns {PackageType}
*/
export function getPackageType(url: URL): PackageType
export type PackageType = import('./package-config.js').PackageType

View file

@ -0,0 +1,23 @@
// Manually “tree shaken” from:
// <https://github.com/nodejs/node/blob/6668c4d/lib/internal/modules/esm/resolve.js>
// Last checked on: Jan 6, 2023.
//
// This file solves a circular dependency.
// In Node.js, `getPackageType` is in `resolve.js`.
// `resolve.js` imports `get-format.js`, which needs `getPackageType`.
// We split that up so that bundlers dont fail.
/**
* @typedef {import('./package-config.js').PackageType} PackageType
*/
import {getPackageScopeConfig} from './package-config.js'
/**
* @param {URL} url
* @returns {PackageType}
*/
export function getPackageType(url) {
const packageConfig = getPackageScopeConfig(url)
return packageConfig.type
}

40
node_modules/import-meta-resolve/lib/resolve.d.ts generated vendored Normal file
View file

@ -0,0 +1,40 @@
/// <reference types="node" resolution-mode="require"/>
/**
* The Resolver Algorithm Specification as detailed in the Node docs (which is
* sync and slightly lower-level than `resolve`).
*
* @param {string} specifier
* `/example.js`, `./example.js`, `../example.js`, `some-package`, `fs`, etc.
* @param {URL} base
* Full URL (to a file) that `specifier` is resolved relative from.
* @param {Set<string>} [conditions]
* Conditions.
* @param {boolean} [preserveSymlinks]
* Keep symlinks instead of resolving them.
* @returns {URL}
* A URL object to the found thing.
*/
export function moduleResolve(
specifier: string,
base: URL,
conditions?: Set<string> | undefined,
preserveSymlinks?: boolean | undefined
): URL
/**
* @param {string} specifier
* @param {{parentURL?: string, conditions?: Array<string>}} context
* @returns {{url: string, format?: string|null}}
*/
export function defaultResolve(
specifier: string,
context?: {
parentURL?: string
conditions?: Array<string>
}
): {
url: string
format?: string | null
}
export type ErrnoException = import('./errors.js').ErrnoException
export type PackageConfig = import('./package-config.js').PackageConfig
import {URL} from 'url'

1229
node_modules/import-meta-resolve/lib/resolve.js generated vendored Normal file

File diff suppressed because it is too large Load diff

5
node_modules/import-meta-resolve/lib/utils.d.ts generated vendored Normal file
View file

@ -0,0 +1,5 @@
/**
* @param {Array<string>} [conditions]
* @returns {Set<string>}
*/
export function getConditionsSet(conditions?: string[] | undefined): Set<string>

41
node_modules/import-meta-resolve/lib/utils.js generated vendored Normal file
View file

@ -0,0 +1,41 @@
// Manually “tree shaken” from:
// <https://github.com/nodejs/node/blob/6668c4d/lib/internal/modules/esm/utils.js>
// Last checked on: Jan 6, 2023.
import {codes} from './errors.js'
const {ERR_INVALID_ARG_VALUE} = codes
// In Node itself these values are populated from CLI arguments, before any
// user code runs.
// Here we just define the defaults.
const DEFAULT_CONDITIONS = Object.freeze(['node', 'import'])
const DEFAULT_CONDITIONS_SET = new Set(DEFAULT_CONDITIONS)
function getDefaultConditions() {
return DEFAULT_CONDITIONS
}
function getDefaultConditionsSet() {
return DEFAULT_CONDITIONS_SET
}
/**
* @param {Array<string>} [conditions]
* @returns {Set<string>}
*/
export function getConditionsSet(conditions) {
if (conditions !== undefined && conditions !== getDefaultConditions()) {
if (!Array.isArray(conditions)) {
throw new ERR_INVALID_ARG_VALUE(
'conditions',
conditions,
'expected an array'
)
}
return new Set(conditions)
}
return getDefaultConditionsSet()
}

74
node_modules/import-meta-resolve/license generated vendored Normal file
View file

@ -0,0 +1,74 @@
(The MIT License)
Copyright (c) 2021 Titus Wormer <mailto:tituswormer@gmail.com>
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
---
This is a derivative work based on:
<https://github.com/nodejs/node>.
Which is licensed:
"""
Copyright Node.js contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
"""
This license applies to parts of Node.js originating from the
https://github.com/joyent/node repository:
"""
Copyright Joyent, Inc. and other Node contributors. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
"""

92
node_modules/import-meta-resolve/package.json generated vendored Normal file
View file

@ -0,0 +1,92 @@
{
"name": "import-meta-resolve",
"version": "2.2.2",
"description": "Resolve things like Node.js — ponyfill for `import.meta.resolve`",
"license": "MIT",
"keywords": [
"resolve",
"node",
"esm",
"module"
],
"repository": "wooorm/import-meta-resolve",
"bugs": "https://github.com/wooorm/import-meta-resolve/issues",
"funding": {
"type": "github",
"url": "https://github.com/sponsors/wooorm"
},
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)",
"contributors": [
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)"
],
"sideEffects": false,
"type": "module",
"main": "index.js",
"types": "index.d.ts",
"files": [
"lib/",
"index.d.ts",
"index.js"
],
"devDependencies": {
"@types/node": "^18.0.0",
"@types/semver": "^7.0.0",
"c8": "^7.0.0",
"prettier": "^2.0.0",
"remark-cli": "^11.0.0",
"remark-preset-wooorm": "^9.0.0",
"semver": "^7.0.0",
"type-coverage": "^2.0.0",
"typescript": "^4.0.0",
"xo": "^0.53.0"
},
"scripts": {
"prepack": "npm run generate && npm run build && npm run format",
"generate": "node --conditions development script.js",
"build": "tsc --build --clean && tsc --build && type-coverage",
"format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
"test-api": "node --experimental-import-meta-resolve test/baseline.js && node test/index.js",
"test-coverage": "c8 --check-coverage --branches 75 --functions 75 --lines 75 --statements 75 --reporter lcov npm run test-api",
"test": "npm run generate && npm run build && npm run format && npm run test-coverage"
},
"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
},
"xo": {
"prettier": true,
"rules": {
"complexity": "off",
"max-depth": "off",
"max-params": "off",
"no-constant-condition": "off",
"no-new": "off",
"prefer-arrow-callback": "off"
},
"ignore": [
"test/node_modules/"
]
},
"remarkConfig": {
"plugins": [
"preset-wooorm",
[
"remark-lint-maximum-heading-length",
false
]
]
},
"typeCoverage": {
"atLeast": 100,
"detail": true,
"strict": true,
"ignoreCatch": true,
"ignoreFiles": [
"lib/errors.d.ts"
]
}
}

244
node_modules/import-meta-resolve/readme.md generated vendored Normal file
View file

@ -0,0 +1,244 @@
# import-meta-resolve
[![Build][build-badge]][build]
[![Coverage][coverage-badge]][coverage]
[![Downloads][downloads-badge]][downloads]
Resolve things like Node.js.
## Contents
* [What is this?](#what-is-this)
* [When to use this?](#when-to-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`resolve(specifier, parent)`](#resolvespecifier-parent)
* [`moduleResolve(specifier, parent, conditions, preserveSymlinks)`](#moduleresolvespecifier-parent-conditions-preservesymlinks)
* [`ErrnoException`](#errnoexception)
* [Algorithm](#algorithm)
* [Differences to Node](#differences-to-node)
* [Types](#types)
* [Compatibility](#compatibility)
* [Contribute](#contribute)
* [License](#license)
## What is this?
This package is a ponyfill for [`import.meta.resolve`][native-resolve].
It supports everything you need to resolve files just like modern Node does:
import maps, export maps, loading CJS and ESM projects, all of that!
## When to use this?
As of Node.js 19.3, `import.meta.resolve` is still behind an experimental flag.
This package can be used to do what it does in Node 1419.
## Install
This package is [ESM only][esm].
In Node.js (version 14.14+ and 16.0+), install with [npm][]:
```sh
npm install import-meta-resolve
```
## Use
```js
import {resolve} from 'import-meta-resolve'
// A file:
console.log(await resolve('./index.js', import.meta.url))
//=> file:///Users/tilde/Projects/oss/import-meta-resolve/index.js
// A CJS package:
console.log(await resolve('builtins', import.meta.url))
//=> file:///Users/tilde/Projects/oss/import-meta-resolve/node_modules/builtins/index.js
// A scoped CJS package:
console.log(await resolve('@eslint/eslintrc', import.meta.url))
//=> file:///Users/tilde/Projects/oss/import-meta-resolve/node_modules/@eslint/eslintrc/lib/index.js
// A package with an export map:
console.log(await resolve('tape/lib/test', import.meta.url))
//=> file:///Users/tilde/Projects/oss/import-meta-resolve/node_modules/tape/lib/test.js
// A node builtin:
console.log(await resolve('fs', import.meta.url))
//=> node:fs
```
## API
This package exports the identifiers [`resolve`][resolve] and
[`moduleResolve`][moduleresolve].
There is no default export.
### `resolve(specifier, parent)`
Match `import.meta.resolve` except that `parent` is required (you can pass
`import.meta.url`).
###### Parameters
* `specifier` (`string`)
— the module specifier to resolve relative to parent
(`/example.js`, `./example.js`, `../example.js`, `some-package`, `fs`, etc).
* `parent` (`string`, example: `import.meta.url`)
— the absolute parent module URL to resolve from.
You should pass `import.meta.url` or something else.
###### Returns
Returns a promise that resolves to a full `file:`, `data:`, or `node:` URL
(`string`) to the found thing or rejects to an
[`ErrnoException`][errnoexception].
### `moduleResolve(specifier, parent, conditions, preserveSymlinks)`
The [“Resolver Algorithm Specification”][algo] as detailed in the Node docs
(which is sync and slightly lower-level than `resolve`).
###### Parameters
* `specifier` (`string`)
`/example.js`, `./example.js`, `../example.js`, `some-package`, `fs`, etc
* `parent` (`URL`, example: `import.meta.url`)
— full URL (to a file) that `specifier` is resolved relative from
* `conditions` (`Set<string>`, default: `new Set(['node', 'import'])`)
— conditions
* `preserveSymlinks` (`boolean`, default: `false`)
— keep symlinks instead of resolving them
###### Returns
A URL object (`URL`) to the found thing.
###### Throws
Throws an [`ErrnoException`][errnoexception].
### `ErrnoException`
One of many different errors that occur when resolving (TypeScript type).
###### Type
```ts
type ErrnoExceptionFields = Error & {
errnode?: number | undefined
code?: string | undefined
path?: string | undefined
syscall?: string | undefined
url?: string | undefined
}
```
The `code` field on errors is one of the following strings:
* `'ERR_INVALID_MODULE_SPECIFIER'`
— when `specifier` is invalid (example: `'#'`)
* `'ERR_INVALID_PACKAGE_CONFIG'`
— when a `package.json` is invalid (example: invalid JSON)
* `'ERR_INVALID_PACKAGE_TARGET'`
— when a `package.json` `exports` or `imports` is invalid (example: when it
does not start with `'./'`)
* `'ERR_MODULE_NOT_FOUND'`
— when `specifier` cannot be found in `parent` (example: `'some-missing-package'`)
* `'ERR_NETWORK_IMPORT_DISALLOWED'`
— thrown when trying to resolve a local file or builtin from a remote file
(`node:fs` relative to `'https://example.com'`)
* `'ERR_PACKAGE_IMPORT_NOT_DEFINED'`
— when a local import is not defined in an import map (example: `'#local'`
when not defined)
* `'ERR_PACKAGE_PATH_NOT_EXPORTED'`
— when an export is not defined in an export map (example: `'tape/index.js'`,
which is not in its export map)
* `'ERR_UNSUPPORTED_DIR_IMPORT'`
— when attempting to import a directory (example: `'./lib/'`)
* `'ERR_UNKNOWN_FILE_EXTENSION'`
— when somehow reading a file that has an unexpected extensions (`'./readme.md'`)
* `'ERR_INVALID_ARG_VALUE'`
— when `conditions` is incorrect
* `'ERR_UNSUPPORTED_ESM_URL_SCHEME'`
— when an unexpected protocol is found (`'xss:alert(1)'`)
## Algorithm
The algorithm for `resolve` matches how Node handles `import.meta.resolve`, with
a couple of differences.
The algorithm for `moduleResolve` matches the [Resolver Algorithm
Specification][algo] as detailed in the Node docs (which is sync and slightly
lower-level than `resolve`).
## Differences to Node
* `parent` defaulting to `import.meta.url` cannot be ponyfilled: you have to
explicitly pass it
* no support for CLI flags:
`--experimental-json-modules`, `--experimental-wasm-modules`,
`--experimental-policy`, `--experimental-network-imports`, `--no-addons`,
`--input-type`, `--preserve-symlinks`,
`--preserve-symlinks-main`, nor `--conditions` work
* no support for `WATCH_REPORT_DEPENDENCIES` env variable
* no attempt is made to add a suggestion based on how things used to work in
CJS before to not-found errors
* prototypal methods are not guarded: Node protects for example `String#slice`
or so from being tampered with, whereas this doesnt
## Types
This package is fully typed with [TypeScript][].
It exports the additional type [`ErrnoException`][errnoexception].
## Compatibility
This package is at least compatible with all maintained versions of Node.js.
As of now, that is Node.js 14.14+ and 16.0+.
## Contribute
Yes please!
See [How to Contribute to Open Source][contribute].
## License
[MIT][license] © [Titus Wormer][author]
<!-- Definitions -->
[build-badge]: https://github.com/wooorm/import-meta-resolve/workflows/main/badge.svg
[build]: https://github.com/wooorm/import-meta-resolve/actions
[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/import-meta-resolve.svg
[coverage]: https://codecov.io/github/wooorm/import-meta-resolve
[downloads-badge]: https://img.shields.io/npm/dm/import-meta-resolve.svg
[downloads]: https://www.npmjs.com/package/import-meta-resolve
[npm]: https://docs.npmjs.com/cli/install
[license]: license
[author]: https://wooorm.com
[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
[typescript]: https://www.typescriptlang.org
[contribute]: https://opensource.guide/how-to-contribute/
[algo]: https://nodejs.org/dist/latest-v14.x/docs/api/esm.html#esm_resolver_algorithm
[native-resolve]: https://nodejs.org/api/esm.html#esm_import_meta_resolve_specifier_parent
[resolve]: #resolvespecifier-parent
[moduleresolve]: #moduleResolvespecifier-parent-conditions-preserveSymlinks
[errnoexception]: #errnoexception