Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@vltpkg/spec

Package Overview
Dependencies
Maintainers
6
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@vltpkg/spec - npm Package Compare versions

Comparing version
1.0.0-rc.10
to
1.0.0-rc.11
+131
dist/browser.d.ts
import type { Range } from '@vltpkg/semver';
import type { GitSelectorParsed, Scope, SpecLike, SpecOptions, SpecOptionsFilled, SpecType } from './types.ts';
export * from './types.ts';
export declare const kCustomInspect: unique symbol;
export declare const defaultRegistry = "https://registry.npmjs.org/";
export declare const defaultRegistryName = "npm";
export declare const defaultRegistries: {
npm: string;
gh: string;
};
export declare const defaultJsrRegistries: {
jsr: string;
};
export declare const defaultGitHosts: {
github: string;
bitbucket: string;
gitlab: string;
gist: string;
};
export declare const defaultGitHostArchives: {
github: string;
bitbucket: string;
gist: string;
gitlab: string;
};
/**
* These are just for legacy support of urls that are supported by npm
* and observed in the wild.
*
* Not configurable, because no more will be added. If you wish to define
* custom git hosts, use it with the `'git-hosts'` and `'git-host-archives'`
* options.
*/
export declare const gitHostWebsites: {
github: string;
bitbucket: string;
gist: string;
gitlab: string;
};
export declare const defaultScopeRegistries: {
'@jsr': string;
};
export declare const getOptions: (options?: SpecOptions) => SpecOptionsFilled;
/**
* Injects the Node.js dependencies into the Spec class.
*/
export type NodeJSDependenciesOptions = {
homedir: typeof import('os').homedir;
isAbsolute: typeof import('node:path').isAbsolute;
join: typeof import('node:path').join;
resolve: typeof import('node:path').resolve;
winPath: typeof import('node:path').win32;
};
export declare const isSpec: (spec: unknown) => spec is Spec;
/**
* Retrieves the short configured name of the default registry if one
* is available.
*/
export declare const currentDefaultRegistryName: (registry: string, options: SpecOptions) => string | undefined;
/**
* The base, isomorphic Spec implementation.
*/
export declare class Spec implements SpecLike<Spec> {
#private;
/**
* Create a Spec object from a full spec, name+bareSpec, or Spec object
*
* Note: If a Spec object is provided, it is returned as-is, without
* investigating whether the options match.
*/
static parse(name: string, bareSpec: string, options?: SpecOptions): Spec;
static parse(spec: string, options?: SpecOptions): Spec;
static parse(spec: Spec, options?: SpecOptions): Spec;
static parseArgs(specOrBareSpec: string, opts?: SpecOptions): Spec;
static nodejsDependencies?: NodeJSDependenciesOptions;
type: SpecType;
spec: string;
options: SpecOptionsFilled;
name: string;
scope?: Scope;
scopeRegistry?: string;
bareSpec: string;
gitRemote?: string;
gitSelector?: string;
gitSelectorParsed?: GitSelectorParsed;
gitCommittish?: string;
namedGitHost?: string;
namedGitHostPath?: string;
workspaceSpec?: string;
workspace?: string;
namedRegistry?: string;
namedJsrRegistry?: string;
registry?: string;
registrySpec?: string;
conventionalRegistryTarball?: string;
semver?: string;
range?: Range;
distTag?: string;
remoteURL?: string;
file?: string;
catalog?: string;
subspec?: Spec;
overridden: boolean;
/**
* Return the final entry in the chain of subspecs
* When deciding which thing to actually fetch, spec.final is the thing
* to look at.
*/
get final(): Spec & {
type: Exclude<SpecType, 'catalog'>;
};
/**
* Normally, the string value of a Spec is just the string passed in to
* be parsed. However, in the case of a chain of subspecs, like
* `foo@npm:bar@npm:baz@npm:quux@latest`, this simplifies out the middle
* parts of the chain, returning just `foo@npm:quux@latest`
*/
toString(): string;
['constructor']: typeof Spec;
constructor(name: string, bareSpec: string, options?: SpecOptions);
constructor(spec: string, options?: SpecOptions);
constructor(spec: Spec | string, bareOrOptions?: SpecOptions | string, options?: SpecOptions);
[kCustomInspect](): string;
/**
* Should only ever be called with the bit that comes AFTER the #
* in the git remote url.
*/
static parseGitSelector(selector: string, spec?: Spec): [parsed: GitSelectorParsed, committish?: string, range?: Range];
}
export declare const getNormalizeFile: (opts?: NodeJSDependenciesOptions) => (bareSpec: string, spec: Spec) => [path: string, uri: string];
//# sourceMappingURL=browser.d.ts.map
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":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;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,UAAU,UAAQ;IAIlB;;;;OAIG;IACH,IAAI,KAAK,IAAI,IAAI,GAAG;QAAE,IAAI,EAAE,OAAO,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAA;KAAE,CAWzD;IAED;;;;;OAKG;IACH,QAAQ;IAUA,CAAC,aAAa,CAAC,EAAE,OAAO,IAAI,CAAA;gBAExB,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW;gBACrD,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW;gBAE7C,IAAI,EAAE,IAAI,GAAG,MAAM,EACnB,aAAa,CAAC,EAAE,WAAW,GAAG,MAAM,EACpC,OAAO,CAAC,EAAE,WAAW;IA6XvB,CAAC,cAAc,CAAC,IAAI,MAAM;IAmF1B;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CACrB,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,IAAI,GACV,CAAC,MAAM,EAAE,iBAAiB,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC;CA8DnE;AAUD,eAAO,MAAM,gBAAgB,UACnB,yBAAyB,gBACtB,MAAM,QAAQ,IAAI,KAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAsHzD,CAAA"}
import { error, typeError } from '@vltpkg/error-cause';
import { parseRange } from '@vltpkg/semver';
export * from "./types.js";
export const kCustomInspect = Symbol.for('nodejs.util.inspect.custom');
export const defaultRegistry = 'https://registry.npmjs.org/';
export const defaultRegistryName = 'npm';
export const defaultRegistries = {
npm: defaultRegistry,
gh: 'https://npm.pkg.github.com/',
};
export const defaultJsrRegistries = { jsr: 'https://npm.jsr.io/' };
export const defaultGitHosts = {
github: 'git+ssh://git@github.com:$1/$2.git',
bitbucket: 'git+ssh://git@bitbucket.org:$1/$2.git',
gitlab: 'git+ssh://git@gitlab.com:$1/$2.git',
gist: 'git+ssh://git@gist.github.com/$1.git',
};
export const defaultGitHostArchives = {
github: 'https://api.github.com/repos/$1/$2/tarball/$committish',
bitbucket: 'https://bitbucket.org/$1/$2/get/$committish.tar.gz',
gist: 'https://codeload.github.com/gist/$1/tar.gz/$committish',
gitlab: 'https://gitlab.com/$1/$2/repository/archive.tar.gz?ref=$committish',
};
/**
* These are just for legacy support of urls that are supported by npm
* and observed in the wild.
*
* Not configurable, because no more will be added. If you wish to define
* custom git hosts, use it with the `'git-hosts'` and `'git-host-archives'`
* options.
*/
export const gitHostWebsites = {
github: 'https://github.com/',
bitbucket: 'https://bitbucket.org/',
gist: 'https://gist.github.com/',
gitlab: 'https://gitlab.com/',
};
export const defaultScopeRegistries = {
'@jsr': 'https://npm.jsr.io/',
};
export const getOptions = (options) => ({
catalog: {},
catalogs: {},
...options,
'jsr-registries': {
...(options?.['jsr-registries'] ?? {}),
...defaultJsrRegistries,
},
registry: options?.registry ?? defaultRegistry,
'scope-registries': options?.['scope-registries'] ?? {},
'git-hosts': options?.['git-hosts'] ?
{
...defaultGitHosts,
...options['git-hosts'],
}
: defaultGitHosts,
registries: {
...(options?.registries ?? {}),
...defaultRegistries,
},
'git-host-archives': options?.['git-host-archives'] ?
{
...defaultGitHostArchives,
...options['git-host-archives'],
}
: defaultGitHostArchives,
});
/**
* Various nameless scenarios that are handled in the
* standard spec parsing and should return an unknown name.
*
* Returns `true` if the name can not be inferred, `false` otherwise.
*/
const startsWithSpecIdentifier = (spec, options) => spec.startsWith('/') ||
spec.startsWith('./') ||
spec.startsWith('../') ||
spec.startsWith('file:') ||
spec.startsWith('http:') ||
spec.startsWith('https:') ||
spec.startsWith('workspace:') ||
spec.startsWith('catalog:') ||
spec.startsWith('git@') ||
spec.startsWith('git://') ||
spec.startsWith('git+ssh://') ||
spec.startsWith('git+http://') ||
spec.startsWith('git+https://') ||
spec.startsWith('git+file://') ||
spec.startsWith('git@github.com') ||
spec.startsWith('registry:') ||
spec.startsWith('npm:') ||
spec.startsWith('jsr:') ||
spec.startsWith('gh:') ||
// anything that starts with a known git host key, or a
// custom registered registry protocol e.g: `github:`, `custom:`
[
...Object.keys(options['git-hosts']),
...Object.keys(options.registries),
...Object.keys(options['jsr-registries']),
].some(key => spec.startsWith(`${key}:`));
/**
* Returns the location in which the first `@` value is found in a given
* string, also takes into account that a string starting with @ is
* using a scoped-name.
*/
const findFirstAt = (spec, hasScope) => spec.indexOf('@', hasScope ? 1 : 0);
/**
* Return `true` if a given spec string is likely to be a git spec.
*/
const findGitIdentifier = (spec) => spec.indexOf('#') > 2;
/**
* Return `true` if a given spec string is likely to be a file spec.
*/
const findFileIdentifier = (spec) => spec.includes('/');
export const isSpec = (spec) => typeof spec === 'object' &&
spec !== null &&
'spec' in spec &&
'bareSpec' in spec &&
'name' in spec &&
'type' in spec &&
'options' in spec &&
typeof spec.spec === 'string' &&
typeof spec.bareSpec === 'string' &&
typeof spec.name === 'string';
/**
* Retrieves the short configured name of the default registry if one
* is available.
*/
export const currentDefaultRegistryName = (registry, options) => {
for (const [name, url] of Object.entries(options.registries /* c8 ignore next */ ?? {})) {
const specRegURL = registry.endsWith('/') ? registry : registry + '/';
const knownRegURL = url.endsWith('/') ? url : url + '/';
if (specRegURL === knownRegURL) {
return name;
}
}
};
/**
* The base, isomorphic Spec implementation.
*/
export class Spec {
static parse(spec, bareOrOptions, options) {
return typeof spec === 'object' ? spec : (new this(spec, bareOrOptions, options));
}
static parseArgs(specOrBareSpec, opts) {
const options = getOptions(opts ?? {});
if (startsWithSpecIdentifier(specOrBareSpec, options)) {
const parsed = this.parse('(unknown)', specOrBareSpec, options);
// try to look into a potential parsed subspec for a name
if (parsed.subspec) {
const { namedJsrRegistry: jsrHost } = parsed;
if (!jsrHost) {
parsed.name = parsed.subspec.name;
}
parsed.spec = `${parsed.name}@${parsed.bareSpec}`;
}
return parsed;
}
else {
const hasScope = specOrBareSpec.startsWith('@');
const at = findFirstAt(specOrBareSpec, hasScope);
if (at > -1) {
return this.parse(specOrBareSpec.substring(0, at), specOrBareSpec.substring(at + 1), options);
}
else if (findGitIdentifier(specOrBareSpec) ||
(!hasScope && findFileIdentifier(specOrBareSpec))) {
return this.parse('(unknown)', specOrBareSpec, options);
}
else {
// doesn't have an @, so it's just a name with no version
return this.parse(`${specOrBareSpec}@`, options);
}
}
}
static nodejsDependencies;
type;
spec;
options;
name;
scope;
scopeRegistry;
bareSpec;
gitRemote;
gitSelector;
gitSelectorParsed;
gitCommittish;
namedGitHost;
namedGitHostPath;
workspaceSpec;
workspace;
namedRegistry;
namedJsrRegistry;
registry;
registrySpec;
conventionalRegistryTarball;
semver;
range;
distTag;
remoteURL;
file;
catalog;
subspec;
overridden = false;
#final;
#toString;
/**
* Return the final entry in the chain of subspecs
* When deciding which thing to actually fetch, spec.final is the thing
* to look at.
*/
get final() {
if (this.#final)
return this.#final;
const final = this.subspec ? this.subspec.final : this;
/* c8 ignore start - impossible */
if (final.type === 'catalog') {
throw error('invalid Spec.final value, type is "catalog"');
}
/* c8 ignore stop */
return (this.#final = final);
}
/**
* Normally, the string value of a Spec is just the string passed in to
* be parsed. However, in the case of a chain of subspecs, like
* `foo@npm:bar@npm:baz@npm:quux@latest`, this simplifies out the middle
* parts of the chain, returning just `foo@npm:quux@latest`
*/
toString() {
if (this.#toString !== undefined)
return this.#toString;
let sub = this;
// we want the SECOND from the last in the chain
while (sub.subspec?.subspec)
sub = sub.subspec;
if (sub.subspec && sub.subspec.type !== 'registry')
sub = sub.subspec;
return (this.#toString = this.name + '@' + sub.bareSpec);
}
constructor(spec, bareOrOptions, options = {}) {
if (bareOrOptions && typeof bareOrOptions === 'object') {
options = bareOrOptions;
bareOrOptions = undefined;
}
this.options = getOptions(options);
if (typeof bareOrOptions === 'string') {
this.name = spec;
this.#parseScope(spec);
this.bareSpec = bareOrOptions;
this.spec = `${this.name}@${bareOrOptions}`;
}
else {
this.spec = spec;
// Check if this spec starts with a known registry identifier
// but exclude git specs like 'git@github:a/b'
if (!spec.startsWith('git@') &&
startsWithSpecIdentifier(spec, this.options) &&
spec.includes(':') &&
[
...Object.keys(this.options.registries),
...Object.keys(defaultRegistries),
].some(key => spec.startsWith(`${key}:`))) {
// For specs like 'gh:@octocat/hello-world@1.0.0', don't split at the @
// Instead, set a temporary name and let the registry logic handle it
this.name = spec;
this.bareSpec = spec;
}
else {
const hasScope = spec.startsWith('@');
let at = findFirstAt(spec, hasScope);
if (at === -1) {
// assume that an unadorned spec is just a name at the default
// registry
at = spec.length;
spec += '@';
}
this.name = spec.substring(0, at);
if (hasScope)
this.#parseScope(this.name);
this.bareSpec = spec.substring(at + 1);
}
}
if (this.bareSpec.startsWith('catalog:')) {
this.catalog = this.bareSpec.substring('catalog:'.length);
const catalog = this.catalog ?
this.options.catalogs?.[this.catalog]
: this.options.catalog;
if (!catalog) {
throw this.#error('Named catalog not found', {
name: this.catalog,
validOptions: this.options.catalogs &&
Object.keys(this.options.catalogs),
});
}
const sub = catalog[this.name];
if (!sub) {
throw this.#error('Name not found in catalog', {
name: this.name,
validOptions: Object.keys(catalog),
});
}
this.subspec = Spec.parse(this.name, sub);
this.type = 'catalog';
return;
}
// legacy affordance: allow project urls like
// 'https://github.com/user/project#commitish' because npm suports it and
// this pattern is observed in the wild.
if (this.bareSpec.startsWith('https://')) {
for (const [name, origin] of Object.entries(gitHostWebsites)) {
if (this.bareSpec.startsWith(origin)) {
const parsed = new URL(this.bareSpec);
const [user, project] = parsed.pathname
.replace(/\.git$/, '')
.replace(/\/+/g, ' ')
.trim()
.split(' ');
if (user && project) {
this.bareSpec = `${name}:${user}/${project}${parsed.hash}`;
this.spec = `${this.name}@${this.bareSpec}`;
break;
}
}
}
}
if (this.bareSpec.startsWith('workspace:')) {
this.type = 'workspace';
const ws = this.bareSpec.substring('workspace:'.length).trim();
const w = ws.lastIndexOf('@');
if (w === -1) {
this.workspace = this.name;
}
else {
const wsName = ws.substring(0, w);
if (!wsName ||
wsName === '*' ||
wsName === '~' ||
wsName === '^' ||
(wsName.startsWith('@') ?
wsName.split('/').length !== 2 ||
wsName.substring(1).includes('@')
: wsName.includes('@'))) {
throw this.#error('workspace: name must be a path or valid package name', { found: wsName });
}
this.workspace = wsName;
}
// workspace: is the same as workspace:*
const wss = w === -1 ? ws : ws.substring(w + 1) || '*';
const range = wss === '*' ? undefined : parseRange(wss);
if (wss !== '*' && wss !== '~' && wss !== '^' && !range) {
throw this.#error('workspace: spec must be one of *, ~, or ^, or a valid semver range', {
found: wss,
wanted: `'*'|'~'|'^'|SemverRange`,
});
}
this.workspaceSpec = wss;
if (range) {
this.semver = wss;
this.range = range;
}
return;
}
if (this.bareSpec.startsWith('git://') ||
this.bareSpec.startsWith('git+ssh://') ||
this.bareSpec.startsWith('git+http://') ||
this.bareSpec.startsWith('git+https://') ||
this.bareSpec.startsWith('git+file://') ||
// legacy affordance
this.bareSpec.startsWith('git@github.com')) {
if (this.bareSpec.startsWith('git@')) {
this.bareSpec = `git+ssh://${this.bareSpec}`;
this.spec = `${this.name}@${this.bareSpec}`;
}
this.type = 'git';
// see if it's one of the known named hosts, and if so, prefer
// the shorter syntax.
for (const [name, host] of Object.entries(this.options['git-hosts'])) {
const s = host.indexOf('$');
if (s > 0 && this.bareSpec.startsWith(host.substring(0, s))) {
const p = this.bareSpec
.substring(s)
.replace(/\.git(#.*)?$/, '$1');
this.bareSpec = `${name}:${p}`;
this.spec = `${this.name}@${this.bareSpec}`;
this.#parseHostedGit(name, host);
this.type = 'git';
return;
}
}
this.#parseGitSelector(this.bareSpec);
return;
}
// Check registries before git hosts to avoid conflicts
const regs = Object.entries(this.options.registries);
if (this.bareSpec.startsWith('registry:')) {
const reg = this.bareSpec.substring('registry:'.length);
const h = reg.indexOf('#');
if (h === -1) {
throw this.#error('registry: must include name/version');
}
this.type = 'registry';
let url = reg.substring(0, h);
if (!url.endsWith('/'))
url += '/';
const regSpec = reg.substring(h + 1);
for (let [name, u] of regs) {
if (!u.endsWith('/')) {
u += '/';
this.options.registries[name] = u;
}
if (u === url)
this.namedRegistry = name;
}
this.#parseRegistrySpec(regSpec, url);
this.#guessRegistryTarball();
return;
}
for (const [host, url] of regs) {
const h = `${host}:`;
if (this.bareSpec.startsWith(h)) {
this.type = 'registry';
this.namedRegistry = host;
this.#parseRegistrySpec(this.bareSpec.substring(h.length), url).namedRegistry ??= host;
// If we parsed a spec identifier, update the name and spec format
if (this.subspec && this.name === this.bareSpec) {
this.name = this.subspec.name;
this.spec = `${this.name}@${this.bareSpec}`;
}
this.#guessRegistryTarball();
return;
}
}
// spooky
const ghosts = Object.entries(this.options['git-hosts']);
for (const [name, template] of ghosts) {
if (this.#parseHostedGit(name, template)) {
this.type = 'git';
return;
}
}
const jsrs = Object.entries(this.options['jsr-registries']);
for (const [host, url] of jsrs) {
const h = `${host}:`;
if (this.bareSpec.startsWith(h)) {
this.type = 'registry';
this.namedJsrRegistry = host;
this.#parseJsrRegistrySpec(this.bareSpec.substring(h.length), url).namedJsrRegistry ??= host;
return;
}
}
if (this.bareSpec.startsWith('https://') ||
this.bareSpec.startsWith('http://')) {
this.remoteURL = this.bareSpec;
this.type = 'remote';
return;
}
// explicit file: url
if (this.bareSpec.startsWith('file:')) {
this.type = 'file';
const [path, uri] = getNormalizeFile(this.constructor.nodejsDependencies)(this.bareSpec, this);
this.file = path;
this.bareSpec = uri.replace(/\/+$/, '');
this.spec = `${this.name}@${this.bareSpec}`;
return;
}
// legacy! once upon a time, `user/project` was a shorthand for pulling
// packages from github, instead of the more verbose and explicit
// `github:user/project`.
if (!this.bareSpec.startsWith('./') &&
!this.bareSpec.startsWith('../') &&
this.options['git-hosts'].github) {
const hash = this.bareSpec.indexOf('#');
const up = hash === -1 ? this.bareSpec : this.bareSpec.substring(0, hash);
if (up.split('/').length === 2) {
this.bareSpec = `github:${this.bareSpec}`;
this.spec = `${this.name}@${this.bareSpec}`;
this.#parseHostedGit('github', this.options['git-hosts'].github);
this.type = 'git';
return;
}
}
// if it contains a / and isn't picked up in the github shorthand,
// then convert to file: specifier
if (this.bareSpec.includes('/') ||
this.bareSpec === '.' ||
this.bareSpec === '..') {
this.type = 'file';
const [file, uri] = getNormalizeFile(this.constructor.nodejsDependencies)(`file:${this.bareSpec}`, this);
this.bareSpec = uri;
this.spec = `${this.name}@${this.bareSpec}`;
this.file = file;
return;
}
// at this point, must be either semver range or dist-tag
this.type = 'registry';
const range = parseRange(this.bareSpec);
if (range) {
this.semver = this.bareSpec.trim();
this.range = range;
}
else {
this.distTag = this.bareSpec;
}
this.registrySpec = this.bareSpec;
const { 'scope-registries': scopeRegs, registry } = this.options;
const scopeReg = this.scope && scopeRegs[this.scope];
this.registry = scopeReg ?? registry;
// no guessing the tarball for JSR registries
for (const r of Object.values(this.options['jsr-registries'])) {
if (this.registry === r)
return;
}
this.#guessRegistryTarball();
}
#parseScope(name) {
if (!name.startsWith('@'))
return;
const s = name.indexOf('/');
if (s > 1 && s < name.length - 1) {
const scope = name.substring(0, s);
this.registry = this.scopeRegistry =
this.options['scope-registries'][scope];
this.scope = scope;
}
}
#parseHostedGit(name, template) {
if (this.bareSpec.startsWith(`${name}:`)) {
const h = this.bareSpec.indexOf('#');
const bare = h === -1 ? this.bareSpec : this.bareSpec.substring(0, h);
const hash = h === -1 ? '' : this.bareSpec.substring(h);
const hostPath = bare.substring(name.length + 1);
if (!hostPath) {
throw this.#error('invalid named git host specifier');
}
const split = hostPath.split('/');
let t = template;
for (let i = 0; i < split.length; i++) {
t = t.split(`$${i + 1}`).join(split[i]);
}
t += hash;
this.namedGitHost = name;
this.namedGitHostPath = hostPath;
this.#parseGitSelector(t);
if (this.gitCommittish && !this.gitSelectorParsed?.path) {
const archiveHost = this.options['git-host-archives'][name];
if (name === 'github' &&
this.gitCommittish.startsWith('pull/') &&
this.gitCommittish.match(/\//g)?.length === 1) {
this.gitCommittish += '/head';
}
if (archiveHost) {
this.type = 'remote';
let t = archiveHost;
t = t.split('$committish').join(this.gitCommittish);
for (let i = 0; i < split.length; i++) {
t = t.split(`$${i + 1}`).join(split[i]);
}
this.remoteURL = t;
}
}
return true;
}
return false;
}
/* c8 ignore start */
[kCustomInspect]() {
return `@vltpkg/spec.Spec ${String(this)}`;
}
/* c8 ignore stop */
#guessRegistryTarball() {
// only try to guess if it's a single comparator for a single version
const { name, registry, range } = this.final;
if (!registry || !range?.isSingle)
return;
const stripScope = /^@[^/]+\//;
this.conventionalRegistryTarball = String(new URL(`/${name}/-/${name.replace(stripScope, '')}-${range}.tgz`, registry));
}
#parseRegistrySpec(s, url) {
// note: this takes priority over the scoped registry, if set
this.registry = url;
this.subspec = this.constructor.parse(s, {
...this.options,
registry: url,
});
return this.subspec;
}
#parseJsrRegistrySpec(s, url) {
this.registry = url;
// @luca/cases@jsr:1.x
if (!s.startsWith('@'))
s = `${this.name}@${s}`;
// If the name already starts with @jsr/, it's already in JSR npm
// format and should be used as-is (e.g. from lockfile hydration)
const name = s.startsWith('@jsr/') ? s : (`@jsr/${s.replace(/^@/, '').replace(/\//, '__')}`);
this.subspec = this.constructor.parse(name, {
...this.options,
'scope-registries': {
...this.options['scope-registries'],
'@jsr': url,
},
});
if (this.name === '(unknown)') {
const nextAt = s.indexOf('@', 1);
if (nextAt === -1) {
this.name = s;
}
else {
this.name = s.substring(0, s.indexOf('@', 1));
}
}
const reg = `${this.namedJsrRegistry}:`;
const n = `${reg}${this.name}`;
if (this.bareSpec.startsWith(n + '@')) {
this.bareSpec = reg + this.bareSpec.substring(n.length + 1);
}
else if (this.bareSpec === n) {
this.bareSpec = reg;
}
this.spec = this.name + '@' + this.bareSpec;
return this.subspec;
}
#error(message, extra = {}) {
return error(message, { spec: this.spec, ...extra }, this.#error);
}
#parseGitSelector(s) {
const h = s.indexOf('#');
if (h === -1) {
this.gitRemote = s;
return;
}
this.gitRemote = s.substring(0, h);
this.gitSelector = s.substring(h + 1);
const [selectorParsed, committish, range] = this.constructor.parseGitSelector(this.gitSelector, this);
this.range = range;
this.gitCommittish = committish;
this.gitSelectorParsed = selectorParsed;
}
/**
* Should only ever be called with the bit that comes AFTER the #
* in the git remote url.
*/
static parseGitSelector(selector, spec) {
if (!selector)
return [{}];
const split = selector.split('::');
const first = split[0];
let committish = undefined;
let range = undefined;
const parsed = {};
/* c8 ignore start - for TS's benefit */
if (typeof first !== 'string') {
throw typeError('impossible', {
found: first,
wanted: String,
});
}
/* c8 ignore stop */
if (!first.includes(':')) {
committish = first;
split.shift();
}
for (const kv of split) {
const c = kv.indexOf(':');
/* c8 ignore next */
if (c === -1)
continue;
const k = kv.substring(0, c);
const v = kv.substring(c + 1);
if (k === 'semver') {
if (committish) {
throw error('Cannot specify a semver range and committish value', { spec });
}
range = parseRange(v);
if (!range) {
throw error(`Invalid git tag semver range: ${v}`, { spec });
}
}
if (k === 'semver' || k === 'path') {
if (k === 'path') {
if (
/* c8 ignore next */ this.nodejsDependencies?.isAbsolute(v) ||
/(^|\/|\\)\.\.($|\\|\/)/.test(v)) {
throw error('Invalid path in git selector', { spec });
}
// normalize
/* c8 ignore start */
parsed.path = (this.nodejsDependencies ?
this.nodejsDependencies.join('/', v).substring(1)
: v).replace(/\\/g, '/');
/* c8 ignore stop */
}
else {
parsed[k] = v;
}
}
}
return [parsed, committish, range];
}
}
// normalize our kinda-sorta spec compliant `file:` specifiers
//
// For historical reasons, we need to support a lot of non-spec-compliant
// behaviors, but this massages the result into a *slightly* less offensive
// shape.
//
// The result will be either a fully compliant `file://` with an absolute path,
// or a `file:` with a relative path starting with `~`, `./`, or `../`.
export const getNormalizeFile = (opts) => (bareSpec, spec) => {
const slashes = bareSpec.substring('file:'.length, 'file://'.length);
const pref = `file:${slashes === '//' ? slashes : ''}`;
const rest = bareSpec.substring(pref.length);
// default to '/' because eol == '/' for parsing purposes
const [a = '', b = '/', c = '/', d = '/'] = rest.split('', 4);
if (!a) {
// file:// => file:.
// file: => file:.
return ['.', 'file:.'];
}
if ((a === '/' && b === '~' && c !== '/') ||
(a === '~' && b !== '/')) {
throw error(`invalid file: specifier. '~username' not supported`, { spec });
}
if (a === '~') {
// file://~ => file:~
// file://~/x => file:~/x
return /* c8 ignore start */ opts ?
[
opts.resolve(opts.homedir(), rest.substring(2)),
`file:${rest}`,
]
: [rest, `file:${rest}`];
}
if (a === '/' && b === '~') {
// file:///~ => file:~
// file:/~/x => file:~/x
/* c8 ignore start - tested in test/index.ts */
return opts ?
[
opts.resolve(opts.homedir(), rest.substring(3)),
`file:${rest.substring(1)}`,
]
: /* c8 ignore stop */
[rest.substring(1), `file:${rest.substring(1)}`];
}
if (a === '/' &&
b === '.' &&
(c === '/' || (c === '.' && d === '/'))) {
// file:/./x => file:./x
// file:///./x => file:./x
// file:/../x => file:../x
// file://../x => file:../x
return [rest.substring(1), `file:${rest.substring(1)}`];
}
if (a === '.' && (b === '/' || (b === '.' && c === '/'))) {
// file://. => file:.
// file://./x => file:./x
// file://../x => file:../x
return [rest, `file:${rest}`];
}
if (slashes === '//') {
// must be valid URI, since we ruled out relative and homedir above
// not relative, but note that file://host/share is
// windows-specific and does not work on darwin, so disallow it.
try {
const parsed = new URL(bareSpec);
if (parsed.host) {
if (parsed.host !== 'localhost') {
throw error(`invalid file:// specifier. host must be empty or 'localhost'`, {
spec,
found: parsed.host,
validOptions: ['', 'localhost'],
});
}
}
// normalize blank authority
// file://X:/foo => file:///X:/foo
// file://localhost/x => file:///x
// interpret a `file:///D:/x` as `D:/x` though
return [
parsed.pathname.replace(/^\/([a-zA-Z]:\/)/, '$1'),
`file://${parsed.pathname}`,
];
}
catch (er) {
// invalid URI for other reasons, eg file://x\u0000y/z
throw error('invalid file:// specifier', {
spec,
cause: er,
});
}
}
// no //, no authority, be ungovernable
/* c8 ignore start */
if (opts?.winPath.isAbsolute(rest)) {
// file:/absolute => file:///absolute
// file:/D:/foo => file:///D:/foo
return [rest, `file://${rest}`];
}
/* c8 ignore stop */
// file:x => file:./x
return [`./${rest}`, `file:./${rest}`];
};
//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AC,kBAAkB,EAAE,IAAI,CAAC;gBACjD,UAAU,MAAM,CAAC,QAAQ,EAAE;aAC5B,CAAA;QACH,CAAC;QAAC,OAAO,EAAE,EAAE,CAAC;YACZ,sDAAsD;YACtD,MAAM,KAAK,CAAC,2BAA2B,EAAE;gBACvC,IAAI;gBACJ,KAAK,EAAE,EAAE;aACV,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,uCAAuC;IAEvC,qBAAqB;IACrB,IAAI,IAAI,EAAE,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACnC,qCAAqC;QACrC,iCAAiC;QACjC,OAAO,CAAC,IAAI,EAAE,UAAU,IAAI,EAAE,CAAC,CAAA;IACjC,CAAC;IACD,oBAAoB;IAEpB,qBAAqB;IACrB,OAAO,CAAC,KAAK,IAAI,EAAE,EAAE,UAAU,IAAI,EAAE,CAAC,CAAA;AACxC,CAAC,CAAA","sourcesContent":["import type { ErrorCauseOptions } from '@vltpkg/error-cause'\nimport { error, typeError } from '@vltpkg/error-cause'\nimport type { Range } from '@vltpkg/semver'\nimport { parseRange } from '@vltpkg/semver'\nimport type {\n GitSelectorParsed,\n Scope,\n SpecLike,\n SpecOptions,\n SpecOptionsFilled,\n SpecType,\n} from './types.ts'\nexport * from './types.ts'\n\nexport const kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nexport const defaultRegistry = 'https://registry.npmjs.org/'\nexport const defaultRegistryName = 'npm'\n\nexport const defaultRegistries = {\n npm: defaultRegistry,\n gh: 'https://npm.pkg.github.com/',\n}\n\nexport const defaultJsrRegistries = { jsr: 'https://npm.jsr.io/' }\n\nexport const defaultGitHosts = {\n github: 'git+ssh://git@github.com:$1/$2.git',\n bitbucket: 'git+ssh://git@bitbucket.org:$1/$2.git',\n gitlab: 'git+ssh://git@gitlab.com:$1/$2.git',\n gist: 'git+ssh://git@gist.github.com/$1.git',\n}\n\nexport const defaultGitHostArchives = {\n github: 'https://api.github.com/repos/$1/$2/tarball/$committish',\n bitbucket: 'https://bitbucket.org/$1/$2/get/$committish.tar.gz',\n gist: 'https://codeload.github.com/gist/$1/tar.gz/$committish',\n gitlab:\n 'https://gitlab.com/$1/$2/repository/archive.tar.gz?ref=$committish',\n}\n\n/**\n * These are just for legacy support of urls that are supported by npm\n * and observed in the wild.\n *\n * Not configurable, because no more will be added. If you wish to define\n * custom git hosts, use it with the `'git-hosts'` and `'git-host-archives'`\n * options.\n */\nexport const gitHostWebsites = {\n github: 'https://github.com/',\n bitbucket: 'https://bitbucket.org/',\n gist: 'https://gist.github.com/',\n gitlab: 'https://gitlab.com/',\n}\n\nexport const defaultScopeRegistries = {\n '@jsr': 'https://npm.jsr.io/',\n}\n\nexport const getOptions = (\n options?: SpecOptions,\n): SpecOptionsFilled => ({\n catalog: {},\n catalogs: {},\n ...options,\n 'jsr-registries': {\n ...(options?.['jsr-registries'] ?? {}),\n ...defaultJsrRegistries,\n },\n registry: options?.registry ?? defaultRegistry,\n 'scope-registries': options?.['scope-registries'] ?? {},\n 'git-hosts':\n options?.['git-hosts'] ?\n {\n ...defaultGitHosts,\n ...options['git-hosts'],\n }\n : defaultGitHosts,\n registries: {\n ...(options?.registries ?? {}),\n ...defaultRegistries,\n },\n 'git-host-archives':\n options?.['git-host-archives'] ?\n {\n ...defaultGitHostArchives,\n ...options['git-host-archives'],\n }\n : defaultGitHostArchives,\n})\n\n/**\n * Various nameless scenarios that are handled in the\n * standard spec parsing and should return an unknown name.\n *\n * Returns `true` if the name can not be inferred, `false` otherwise.\n */\nconst startsWithSpecIdentifier = (\n spec: string,\n options: SpecOptionsFilled,\n): boolean =>\n spec.startsWith('/') ||\n spec.startsWith('./') ||\n spec.startsWith('../') ||\n spec.startsWith('file:') ||\n spec.startsWith('http:') ||\n spec.startsWith('https:') ||\n spec.startsWith('workspace:') ||\n spec.startsWith('catalog:') ||\n spec.startsWith('git@') ||\n spec.startsWith('git://') ||\n spec.startsWith('git+ssh://') ||\n spec.startsWith('git+http://') ||\n spec.startsWith('git+https://') ||\n spec.startsWith('git+file://') ||\n spec.startsWith('git@github.com') ||\n spec.startsWith('registry:') ||\n spec.startsWith('npm:') ||\n spec.startsWith('jsr:') ||\n spec.startsWith('gh:') ||\n // anything that starts with a known git host key, or a\n // custom registered registry protocol e.g: `github:`, `custom:`\n [\n ...Object.keys(options['git-hosts']),\n ...Object.keys(options.registries),\n ...Object.keys(options['jsr-registries']),\n ].some(key => spec.startsWith(`${key}:`))\n\n/**\n * Returns the location in which the first `@` value is found in a given\n * string, also takes into account that a string starting with @ is\n * using a scoped-name.\n */\nconst findFirstAt = (spec: string, hasScope: boolean) =>\n spec.indexOf('@', hasScope ? 1 : 0)\n\n/**\n * Return `true` if a given spec string is likely to be a git spec.\n */\nconst findGitIdentifier = (spec: string): boolean =>\n spec.indexOf('#') > 2\n\n/**\n * Return `true` if a given spec string is likely to be a file spec.\n */\nconst findFileIdentifier = (spec: string): boolean =>\n spec.includes('/')\n\n/**\n * Injects the Node.js dependencies into the Spec class.\n */\nexport type NodeJSDependenciesOptions = {\n homedir: typeof import('os').homedir\n isAbsolute: typeof import('node:path').isAbsolute\n join: typeof import('node:path').join\n resolve: typeof import('node:path').resolve\n winPath: typeof import('node:path').win32\n}\n\nexport const isSpec = (spec: unknown): spec is Spec =>\n typeof spec === 'object' &&\n spec !== null &&\n 'spec' in spec &&\n 'bareSpec' in spec &&\n 'name' in spec &&\n 'type' in spec &&\n 'options' in spec &&\n typeof (spec as Spec).spec === 'string' &&\n typeof (spec as Spec).bareSpec === 'string' &&\n typeof (spec as Spec).name === 'string'\n\n/**\n * Retrieves the short configured name of the default registry if one\n * is available.\n */\nexport const currentDefaultRegistryName = (\n registry: string,\n options: SpecOptions,\n): string | undefined => {\n for (const [name, url] of Object.entries(\n options.registries /* c8 ignore next */ ?? {},\n )) {\n const specRegURL =\n registry.endsWith('/') ? registry : registry + '/'\n const knownRegURL = url.endsWith('/') ? url : url + '/'\n if (specRegURL === knownRegURL) {\n return name\n }\n }\n}\n\n/**\n * The base, isomorphic Spec implementation.\n */\nexport class Spec implements SpecLike<Spec> {\n /**\n * Create a Spec object from a full spec, name+bareSpec, or Spec object\n *\n * Note: If a Spec object is provided, it is returned as-is, without\n * investigating whether the options match.\n */\n static parse(\n name: string,\n bareSpec: string,\n options?: SpecOptions,\n ): Spec\n static parse(spec: string, options?: SpecOptions): Spec\n static parse(spec: Spec, options?: SpecOptions): Spec\n static parse(\n spec: Spec | string,\n bareOrOptions?: SpecOptions | string,\n options?: SpecOptions,\n ): Spec {\n return typeof spec === 'object' ? spec : (\n new this(spec, bareOrOptions, options)\n )\n }\n\n static parseArgs(specOrBareSpec: string, opts?: SpecOptions): Spec {\n const options = getOptions(opts ?? {})\n\n if (startsWithSpecIdentifier(specOrBareSpec, options)) {\n const parsed = this.parse('(unknown)', specOrBareSpec, options)\n // try to look into a potential parsed subspec for a name\n if (parsed.subspec) {\n const { namedJsrRegistry: jsrHost } = parsed\n if (!jsrHost) {\n parsed.name = parsed.subspec.name\n }\n parsed.spec = `${parsed.name}@${parsed.bareSpec}`\n }\n return parsed\n } else {\n const hasScope = specOrBareSpec.startsWith('@')\n const at = findFirstAt(specOrBareSpec, hasScope)\n if (at > -1) {\n return this.parse(\n specOrBareSpec.substring(0, at),\n specOrBareSpec.substring(at + 1),\n options,\n )\n } else if (\n findGitIdentifier(specOrBareSpec) ||\n (!hasScope && findFileIdentifier(specOrBareSpec))\n ) {\n return this.parse('(unknown)', specOrBareSpec, options)\n } else {\n // doesn't have an @, so it's just a name with no version\n return this.parse(`${specOrBareSpec}@`, options)\n }\n }\n }\n\n static nodejsDependencies?: NodeJSDependenciesOptions\n\n type: SpecType\n spec: string\n options: SpecOptionsFilled\n name: string\n scope?: Scope\n scopeRegistry?: string\n bareSpec: string\n gitRemote?: string\n gitSelector?: string\n gitSelectorParsed?: GitSelectorParsed\n gitCommittish?: string\n namedGitHost?: string\n namedGitHostPath?: string\n workspaceSpec?: string\n workspace?: string\n namedRegistry?: string\n namedJsrRegistry?: string\n registry?: string\n registrySpec?: string\n conventionalRegistryTarball?: string\n semver?: string\n range?: Range\n distTag?: string\n remoteURL?: string\n file?: string\n catalog?: string\n subspec?: Spec\n overridden = false\n #final?: Spec & { type: Exclude<SpecType, 'catalog'> }\n #toString?: string\n\n /**\n * Return the final entry in the chain of subspecs\n * When deciding which thing to actually fetch, spec.final is the thing\n * to look at.\n */\n get final(): Spec & { type: Exclude<SpecType, 'catalog'> } {\n if (this.#final) return this.#final\n const final = this.subspec ? this.subspec.final : this\n /* c8 ignore start - impossible */\n if (final.type === 'catalog') {\n throw error('invalid Spec.final value, type is \"catalog\"')\n }\n /* c8 ignore stop */\n return (this.#final = final as this & {\n type: Exclude<SpecType, 'catalog'>\n })\n }\n\n /**\n * Normally, the string value of a Spec is just the string passed in to\n * be parsed. However, in the case of a chain of subspecs, like\n * `foo@npm:bar@npm:baz@npm:quux@latest`, this simplifies out the middle\n * parts of the chain, returning just `foo@npm:quux@latest`\n */\n toString() {\n if (this.#toString !== undefined) return this.#toString\n let sub: Spec = this\n // we want the SECOND from the last in the chain\n while (sub.subspec?.subspec) sub = sub.subspec\n if (sub.subspec && sub.subspec.type !== 'registry')\n sub = sub.subspec\n return (this.#toString = this.name + '@' + sub.bareSpec)\n }\n\n declare ['constructor']: typeof Spec\n\n constructor(name: string, bareSpec: string, options?: SpecOptions)\n constructor(spec: string, options?: SpecOptions)\n constructor(\n spec: Spec | string,\n bareOrOptions?: SpecOptions | string,\n options?: SpecOptions,\n )\n constructor(\n spec: string,\n bareOrOptions?: SpecOptions | string,\n options: SpecOptions = {},\n ) {\n if (bareOrOptions && typeof bareOrOptions === 'object') {\n options = bareOrOptions\n bareOrOptions = undefined\n }\n this.options = getOptions(options)\n\n if (typeof bareOrOptions === 'string') {\n this.name = spec\n this.#parseScope(spec)\n this.bareSpec = bareOrOptions\n this.spec = `${this.name}@${bareOrOptions}`\n } else {\n this.spec = spec\n // Check if this spec starts with a known registry identifier\n // but exclude git specs like 'git@github:a/b'\n if (\n !spec.startsWith('git@') &&\n startsWithSpecIdentifier(spec, this.options) &&\n spec.includes(':') &&\n [\n ...Object.keys(this.options.registries),\n ...Object.keys(defaultRegistries),\n ].some(key => spec.startsWith(`${key}:`))\n ) {\n // For specs like 'gh:@octocat/hello-world@1.0.0', don't split at the @\n // Instead, set a temporary name and let the registry logic handle it\n this.name = spec\n this.bareSpec = spec\n } else {\n const hasScope = spec.startsWith('@')\n let at = findFirstAt(spec, hasScope)\n if (at === -1) {\n // assume that an unadorned spec is just a name at the default\n // registry\n at = spec.length\n spec += '@'\n }\n this.name = spec.substring(0, at)\n if (hasScope) this.#parseScope(this.name)\n this.bareSpec = spec.substring(at + 1)\n }\n }\n\n if (this.bareSpec.startsWith('catalog:')) {\n this.catalog = this.bareSpec.substring('catalog:'.length)\n const catalog =\n this.catalog ?\n this.options.catalogs?.[this.catalog]\n : this.options.catalog\n if (!catalog) {\n throw this.#error('Named catalog not found', {\n name: this.catalog,\n validOptions:\n this.options.catalogs &&\n Object.keys(this.options.catalogs),\n })\n }\n const sub = catalog[this.name]\n if (!sub) {\n throw this.#error('Name not found in catalog', {\n name: this.name,\n validOptions: Object.keys(catalog),\n })\n }\n this.subspec = Spec.parse(this.name, sub)\n this.type = 'catalog'\n return\n }\n\n // legacy affordance: allow project urls like\n // 'https://github.com/user/project#commitish' because npm suports it and\n // this pattern is observed in the wild.\n if (this.bareSpec.startsWith('https://')) {\n for (const [name, origin] of Object.entries(gitHostWebsites)) {\n if (this.bareSpec.startsWith(origin)) {\n const parsed = new URL(this.bareSpec)\n const [user, project] = parsed.pathname\n .replace(/\\.git$/, '')\n .replace(/\\/+/g, ' ')\n .trim()\n .split(' ')\n if (user && project) {\n this.bareSpec = `${name}:${user}/${project}${parsed.hash}`\n this.spec = `${this.name}@${this.bareSpec}`\n break\n }\n }\n }\n }\n\n if (this.bareSpec.startsWith('workspace:')) {\n this.type = 'workspace'\n const ws = this.bareSpec.substring('workspace:'.length).trim()\n const w = ws.lastIndexOf('@')\n if (w === -1) {\n this.workspace = this.name\n } else {\n const wsName = ws.substring(0, w)\n if (\n !wsName ||\n wsName === '*' ||\n wsName === '~' ||\n wsName === '^' ||\n (wsName.startsWith('@') ?\n wsName.split('/').length !== 2 ||\n wsName.substring(1).includes('@')\n : wsName.includes('@'))\n ) {\n throw this.#error(\n 'workspace: name must be a path or valid package name',\n { found: wsName },\n )\n }\n this.workspace = wsName\n }\n // workspace: is the same as workspace:*\n const wss = w === -1 ? ws : ws.substring(w + 1) || '*'\n const range = wss === '*' ? undefined : parseRange(wss)\n if (wss !== '*' && wss !== '~' && wss !== '^' && !range) {\n throw this.#error(\n 'workspace: spec must be one of *, ~, or ^, or a valid semver range',\n {\n found: wss,\n wanted: `'*'|'~'|'^'|SemverRange`,\n },\n )\n }\n this.workspaceSpec = wss\n if (range) {\n this.semver = wss\n this.range = range\n }\n return\n }\n\n if (\n this.bareSpec.startsWith('git://') ||\n this.bareSpec.startsWith('git+ssh://') ||\n this.bareSpec.startsWith('git+http://') ||\n this.bareSpec.startsWith('git+https://') ||\n this.bareSpec.startsWith('git+file://') ||\n // legacy affordance\n this.bareSpec.startsWith('git@github.com')\n ) {\n if (this.bareSpec.startsWith('git@')) {\n this.bareSpec = `git+ssh://${this.bareSpec}`\n this.spec = `${this.name}@${this.bareSpec}`\n }\n this.type = 'git'\n // see if it's one of the known named hosts, and if so, prefer\n // the shorter syntax.\n for (const [name, host] of Object.entries(\n this.options['git-hosts'],\n )) {\n const s = host.indexOf('$')\n if (s > 0 && this.bareSpec.startsWith(host.substring(0, s))) {\n const p = this.bareSpec\n .substring(s)\n .replace(/\\.git(#.*)?$/, '$1')\n this.bareSpec = `${name}:${p}`\n this.spec = `${this.name}@${this.bareSpec}`\n this.#parseHostedGit(name, host)\n this.type = 'git'\n return\n }\n }\n this.#parseGitSelector(this.bareSpec)\n return\n }\n\n // Check registries before git hosts to avoid conflicts\n const regs = Object.entries(this.options.registries)\n if (this.bareSpec.startsWith('registry:')) {\n const reg = this.bareSpec.substring('registry:'.length)\n const h = reg.indexOf('#')\n if (h === -1) {\n throw this.#error('registry: must include name/version')\n }\n this.type = 'registry'\n let url = reg.substring(0, h)\n if (!url.endsWith('/')) url += '/'\n const regSpec = reg.substring(h + 1)\n for (let [name, u] of regs) {\n if (!u.endsWith('/')) {\n u += '/'\n this.options.registries[name] = u\n }\n if (u === url) this.namedRegistry = name\n }\n this.#parseRegistrySpec(regSpec, url)\n this.#guessRegistryTarball()\n return\n }\n\n for (const [host, url] of regs) {\n const h = `${host}:`\n if (this.bareSpec.startsWith(h)) {\n this.type = 'registry'\n this.namedRegistry = host\n this.#parseRegistrySpec(\n this.bareSpec.substring(h.length),\n url,\n ).namedRegistry ??= host\n\n // If we parsed a spec identifier, update the name and spec format\n if (this.subspec && this.name === this.bareSpec) {\n this.name = this.subspec.name\n this.spec = `${this.name}@${this.bareSpec}`\n }\n\n this.#guessRegistryTarball()\n return\n }\n }\n\n // spooky\n const ghosts = Object.entries(this.options['git-hosts'])\n for (const [name, template] of ghosts) {\n if (this.#parseHostedGit(name, template)) {\n this.type = 'git'\n return\n }\n }\n\n const jsrs = Object.entries(this.options['jsr-registries'])\n for (const [host, url] of jsrs) {\n const h = `${host}:`\n if (this.bareSpec.startsWith(h)) {\n this.type = 'registry'\n this.namedJsrRegistry = host\n this.#parseJsrRegistrySpec(\n this.bareSpec.substring(h.length),\n url,\n ).namedJsrRegistry ??= host\n return\n }\n }\n\n if (\n this.bareSpec.startsWith('https://') ||\n this.bareSpec.startsWith('http://')\n ) {\n this.remoteURL = this.bareSpec\n this.type = 'remote'\n return\n }\n\n // explicit file: url\n if (this.bareSpec.startsWith('file:')) {\n this.type = 'file'\n const [path, uri] = getNormalizeFile(\n this.constructor.nodejsDependencies,\n )(this.bareSpec, this)\n this.file = path\n this.bareSpec = uri.replace(/\\/+$/, '')\n this.spec = `${this.name}@${this.bareSpec}`\n return\n }\n\n // legacy! once upon a time, `user/project` was a shorthand for pulling\n // packages from github, instead of the more verbose and explicit\n // `github:user/project`.\n if (\n !this.bareSpec.startsWith('./') &&\n !this.bareSpec.startsWith('../') &&\n this.options['git-hosts'].github\n ) {\n const hash = this.bareSpec.indexOf('#')\n const up =\n hash === -1 ? this.bareSpec : this.bareSpec.substring(0, hash)\n if (up.split('/').length === 2) {\n this.bareSpec = `github:${this.bareSpec}`\n this.spec = `${this.name}@${this.bareSpec}`\n this.#parseHostedGit(\n 'github',\n this.options['git-hosts'].github,\n )\n this.type = 'git'\n return\n }\n }\n\n // if it contains a / and isn't picked up in the github shorthand,\n // then convert to file: specifier\n if (\n this.bareSpec.includes('/') ||\n this.bareSpec === '.' ||\n this.bareSpec === '..'\n ) {\n this.type = 'file'\n const [file, uri] = getNormalizeFile(\n this.constructor.nodejsDependencies,\n )(`file:${this.bareSpec}`, this)\n this.bareSpec = uri\n this.spec = `${this.name}@${this.bareSpec}`\n this.file = file\n return\n }\n\n // at this point, must be either semver range or dist-tag\n this.type = 'registry'\n const range = parseRange(this.bareSpec)\n if (range) {\n this.semver = this.bareSpec.trim()\n this.range = range\n } else {\n this.distTag = this.bareSpec\n }\n this.registrySpec = this.bareSpec\n const { 'scope-registries': scopeRegs, registry } = this.options\n const scopeReg = this.scope && scopeRegs[this.scope]\n this.registry = scopeReg ?? registry\n // no guessing the tarball for JSR registries\n for (const r of Object.values(this.options['jsr-registries'])) {\n if (this.registry === r) return\n }\n this.#guessRegistryTarball()\n }\n\n #parseScope(name: string) {\n if (!name.startsWith('@')) return\n const s = name.indexOf('/')\n if (s > 1 && s < name.length - 1) {\n const scope = name.substring(0, s) as Scope\n this.registry = this.scopeRegistry =\n this.options['scope-registries'][scope]\n this.scope = scope\n }\n }\n\n #parseHostedGit(name: string, template: string) {\n if (this.bareSpec.startsWith(`${name}:`)) {\n const h = this.bareSpec.indexOf('#')\n const bare =\n h === -1 ? this.bareSpec : this.bareSpec.substring(0, h)\n const hash = h === -1 ? '' : this.bareSpec.substring(h)\n const hostPath = bare.substring(name.length + 1)\n if (!hostPath) {\n throw this.#error('invalid named git host specifier')\n }\n const split = hostPath.split('/')\n let t = template\n for (let i = 0; i < split.length; i++) {\n t = t.split(`$${i + 1}`).join(split[i])\n }\n t += hash\n this.namedGitHost = name\n this.namedGitHostPath = hostPath\n this.#parseGitSelector(t)\n if (this.gitCommittish && !this.gitSelectorParsed?.path) {\n const archiveHost = this.options['git-host-archives'][name]\n if (\n name === 'github' &&\n this.gitCommittish.startsWith('pull/') &&\n this.gitCommittish.match(/\\//g)?.length === 1\n ) {\n this.gitCommittish += '/head'\n }\n if (archiveHost) {\n this.type = 'remote'\n let t = archiveHost\n t = t.split('$committish').join(this.gitCommittish)\n for (let i = 0; i < split.length; i++) {\n t = t.split(`$${i + 1}`).join(split[i])\n }\n this.remoteURL = t\n }\n }\n return true\n }\n return false\n }\n\n /* c8 ignore start */\n [kCustomInspect](): string {\n return `@vltpkg/spec.Spec ${String(this)}`\n }\n /* c8 ignore stop */\n\n #guessRegistryTarball() {\n // only try to guess if it's a single comparator for a single version\n const { name, registry, range } = this.final\n if (!registry || !range?.isSingle) return\n const stripScope = /^@[^/]+\\//\n this.conventionalRegistryTarball = String(\n new URL(\n `/${name}/-/${name.replace(stripScope, '')}-${range}.tgz`,\n registry,\n ),\n )\n }\n\n #parseRegistrySpec(s: string, url: string) {\n // note: this takes priority over the scoped registry, if set\n this.registry = url\n this.subspec = this.constructor.parse(s, {\n ...this.options,\n registry: url,\n })\n return this.subspec\n }\n\n #parseJsrRegistrySpec(s: string, url: string) {\n this.registry = url\n // @luca/cases@jsr:1.x\n if (!s.startsWith('@')) s = `${this.name}@${s}`\n // If the name already starts with @jsr/, it's already in JSR npm\n // format and should be used as-is (e.g. from lockfile hydration)\n const name =\n s.startsWith('@jsr/') ? s : (\n `@jsr/${s.replace(/^@/, '').replace(/\\//, '__')}`\n )\n this.subspec = this.constructor.parse(name, {\n ...this.options,\n 'scope-registries': {\n ...this.options['scope-registries'],\n '@jsr': url,\n },\n })\n if (this.name === '(unknown)') {\n const nextAt = s.indexOf('@', 1)\n if (nextAt === -1) {\n this.name = s\n } else {\n this.name = s.substring(0, s.indexOf('@', 1))\n }\n }\n const reg = `${this.namedJsrRegistry}:`\n const n = `${reg}${this.name}`\n if (this.bareSpec.startsWith(n + '@')) {\n this.bareSpec = reg + this.bareSpec.substring(n.length + 1)\n } else if (this.bareSpec === n) {\n this.bareSpec = reg\n }\n this.spec = this.name + '@' + this.bareSpec\n return this.subspec\n }\n\n #error(message: string, extra: ErrorCauseOptions = {}) {\n return error(message, { spec: this.spec, ...extra }, this.#error)\n }\n\n #parseGitSelector(s: string) {\n const h = s.indexOf('#')\n if (h === -1) {\n this.gitRemote = s\n return\n }\n this.gitRemote = s.substring(0, h)\n this.gitSelector = s.substring(h + 1)\n const [selectorParsed, committish, range] =\n this.constructor.parseGitSelector(this.gitSelector, this)\n this.range = range\n this.gitCommittish = committish\n this.gitSelectorParsed = selectorParsed\n }\n\n /**\n * Should only ever be called with the bit that comes AFTER the #\n * in the git remote url.\n */\n static parseGitSelector(\n selector: string,\n spec?: Spec,\n ): [parsed: GitSelectorParsed, committish?: string, range?: Range] {\n if (!selector) return [{}]\n const split = selector.split('::')\n const first = split[0]\n let committish: string | undefined = undefined\n let range: Range | undefined = undefined\n const parsed: GitSelectorParsed = {}\n\n /* c8 ignore start - for TS's benefit */\n if (typeof first !== 'string') {\n throw typeError('impossible', {\n found: first,\n wanted: String,\n })\n }\n /* c8 ignore stop */\n if (!first.includes(':')) {\n committish = first\n split.shift()\n }\n for (const kv of split) {\n const c = kv.indexOf(':')\n /* c8 ignore next */\n if (c === -1) continue\n const k = kv.substring(0, c)\n const v = kv.substring(c + 1)\n if (k === 'semver') {\n if (committish) {\n throw error(\n 'Cannot specify a semver range and committish value',\n { spec },\n )\n }\n range = parseRange(v)\n if (!range) {\n throw error(`Invalid git tag semver range: ${v}`, { spec })\n }\n }\n if (k === 'semver' || k === 'path') {\n if (k === 'path') {\n if (\n /* c8 ignore next */ this.nodejsDependencies?.isAbsolute(\n v,\n ) ||\n /(^|\\/|\\\\)\\.\\.($|\\\\|\\/)/.test(v)\n ) {\n throw error('Invalid path in git selector', { spec })\n }\n // normalize\n /* c8 ignore start */\n parsed.path = (\n this.nodejsDependencies ?\n this.nodejsDependencies.join('/', v).substring(1)\n : v).replace(/\\\\/g, '/')\n /* c8 ignore stop */\n } else {\n parsed[k] = v\n }\n }\n }\n return [parsed, committish, range]\n }\n}\n\n// normalize our kinda-sorta spec compliant `file:` specifiers\n//\n// For historical reasons, we need to support a lot of non-spec-compliant\n// behaviors, but this massages the result into a *slightly* less offensive\n// shape.\n//\n// The result will be either a fully compliant `file://` with an absolute path,\n// or a `file:` with a relative path starting with `~`, `./`, or `../`.\nexport const getNormalizeFile =\n (opts?: NodeJSDependenciesOptions) =>\n (bareSpec: string, spec: Spec): [path: string, uri: string] => {\n const slashes = bareSpec.substring(\n 'file:'.length,\n 'file://'.length,\n )\n const pref = `file:${slashes === '//' ? slashes : ''}`\n const rest = bareSpec.substring(pref.length)\n\n // default to '/' because eol == '/' for parsing purposes\n const [a = '', b = '/', c = '/', d = '/'] = rest.split('', 4)\n\n if (!a) {\n // file:// => file:.\n // file: => file:.\n return ['.', 'file:.']\n }\n\n if (\n (a === '/' && b === '~' && c !== '/') ||\n (a === '~' && b !== '/')\n ) {\n throw error(\n `invalid file: specifier. '~username' not supported`,\n { spec },\n )\n }\n\n if (a === '~') {\n // file://~ => file:~\n // file://~/x => file:~/x\n return /* c8 ignore start */ opts ?\n [\n opts.resolve(opts.homedir(), rest.substring(2)),\n `file:${rest}`,\n ]\n : [rest, `file:${rest}`]\n }\n\n if (a === '/' && b === '~') {\n // file:///~ => file:~\n // file:/~/x => file:~/x\n /* c8 ignore start - tested in test/index.ts */\n return opts ?\n [\n opts.resolve(opts.homedir(), rest.substring(3)),\n `file:${rest.substring(1)}`,\n ]\n : /* c8 ignore stop */\n [rest.substring(1), `file:${rest.substring(1)}`]\n }\n\n if (\n a === '/' &&\n b === '.' &&\n (c === '/' || (c === '.' && d === '/'))\n ) {\n // file:/./x => file:./x\n // file:///./x => file:./x\n // file:/../x => file:../x\n // file://../x => file:../x\n return [rest.substring(1), `file:${rest.substring(1)}`]\n }\n\n if (a === '.' && (b === '/' || (b === '.' && c === '/'))) {\n // file://. => file:.\n // file://./x => file:./x\n // file://../x => file:../x\n return [rest, `file:${rest}`]\n }\n\n if (slashes === '//') {\n // must be valid URI, since we ruled out relative and homedir above\n\n // not relative, but note that file://host/share is\n // windows-specific and does not work on darwin, so disallow it.\n try {\n const parsed = new URL(bareSpec)\n if (parsed.host) {\n if (parsed.host !== 'localhost') {\n throw error(\n `invalid file:// specifier. host must be empty or 'localhost'`,\n {\n spec,\n found: parsed.host,\n validOptions: ['', 'localhost'],\n },\n )\n }\n }\n // normalize blank authority\n // file://X:/foo => file:///X:/foo\n // file://localhost/x => file:///x\n // interpret a `file:///D:/x` as `D:/x` though\n return [\n parsed.pathname.replace(/^\\/([a-zA-Z]:\\/)/, '$1'),\n `file://${parsed.pathname}`,\n ]\n } catch (er) {\n // invalid URI for other reasons, eg file://x\\u0000y/z\n throw error('invalid file:// specifier', {\n spec,\n cause: er,\n })\n }\n }\n\n // no //, no authority, be ungovernable\n\n /* c8 ignore start */\n if (opts?.winPath.isAbsolute(rest)) {\n // file:/absolute => file:///absolute\n // file:/D:/foo => file:///D:/foo\n return [rest, `file://${rest}`]\n }\n /* c8 ignore stop */\n\n // file:x => file:./x\n return [`./${rest}`, `file:./${rest}`]\n }\n"]}
import type { InspectOptions } from 'node:util';
import type { SpecLike } from './browser.ts';
import { Spec as BrowserSpec, kCustomInspect } from './browser.ts';
export * from './browser.ts';
export declare class Spec extends BrowserSpec implements SpecLike<Spec> {
[kCustomInspect](_depth?: number, options?: InspectOptions): string;
}
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,IAAI,IAAI,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAGlE,cAAc,cAAc,CAAA;AAG5B,qBAAa,IAAK,SAAQ,WAAY,YAAW,QAAQ,CAAC,IAAI,CAAC;IAC7D,CAAC,cAAc,CAAC,CACd,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,cAAc,GACvB,MAAM;CAWV"}
import { homedir } from 'node:os';
import { isAbsolute, join, resolve, win32 as winPath, } from 'node:path';
import { inspect } from 'node:util';
import { Spec as BrowserSpec, kCustomInspect } from "./browser.js";
// eslint-disable-next-line import/export
export * from "./browser.js";
// eslint-disable-next-line import/export
export class Spec extends BrowserSpec {
[kCustomInspect](_depth, options) {
const str = inspect(Object.fromEntries(Object.entries(this).filter(([k, v]) => {
return k !== 'options' && v !== undefined;
})), options);
return `@vltpkg/spec.Spec ${str}`;
}
}
Spec.nodejsDependencies = {
homedir,
isAbsolute,
join,
resolve,
winPath,
};
//# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EACL,UAAU,EACV,IAAI,EACJ,OAAO,EACP,KAAK,IAAI,OAAO,GACjB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,EAAE,IAAI,IAAI,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAElE,yCAAyC;AACzC,cAAc,cAAc,CAAA;AAE5B,yCAAyC;AACzC,MAAM,OAAO,IAAK,SAAQ,WAAW;IACnC,CAAC,cAAc,CAAC,CACd,MAAe,EACf,OAAwB;QAExB,MAAM,GAAG,GAAG,OAAO,CACjB,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;YACrC,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,CAAA;QAC3C,CAAC,CAAC,CACH,EACD,OAAO,CACR,CAAA;QACD,OAAO,qBAAqB,GAAG,EAAE,CAAA;IACnC,CAAC;CACF;AAED,IAAI,CAAC,kBAAkB,GAAG;IACxB,OAAO;IACP,UAAU;IACV,IAAI;IACJ,OAAO;IACP,OAAO;CACR,CAAA","sourcesContent":["import { homedir } from 'node:os'\nimport {\n isAbsolute,\n join,\n resolve,\n win32 as winPath,\n} from 'node:path'\nimport { inspect } from 'node:util'\nimport type { InspectOptions } from 'node:util'\nimport type { SpecLike } from './browser.ts'\nimport { Spec as BrowserSpec, kCustomInspect } from './browser.ts'\n\n// eslint-disable-next-line import/export\nexport * from './browser.ts'\n\n// eslint-disable-next-line import/export\nexport class Spec extends BrowserSpec implements SpecLike<Spec> {\n [kCustomInspect](\n _depth?: number,\n options?: InspectOptions,\n ): string {\n const str = inspect(\n Object.fromEntries(\n Object.entries(this).filter(([k, v]) => {\n return k !== 'options' && v !== undefined\n }),\n ),\n options,\n )\n return `@vltpkg/spec.Spec ${str}`\n }\n}\n\nSpec.nodejsDependencies = {\n homedir,\n isAbsolute,\n join,\n resolve,\n winPath,\n}\n"]}
import type { Range } from '@vltpkg/semver';
export type SpecOptions = {
[k in keyof SpecOptionsFilled]?: SpecOptionsFilled[k];
};
export type Scope = `@${string}`;
export type SpecOptionsFilled = {
/** the registry where a spec should be resolved against */
registry: string;
/** shorthand prefix names for known registries */
registries: Record<string, string>;
/** shorthand prefix names for known git hosts */
'git-hosts': Record<string, string>;
/** tarball hosting services for hosts listed in git-hosts */
'git-host-archives': Record<string, string>;
/** registries mapped to a `@scope` */
'scope-registries': Record<Scope, string>;
/** registries that work like https://npm.jsr.io */
'jsr-registries': Record<string, string>;
catalog: Record<string, string>;
catalogs?: Record<string, Record<string, string>>;
};
export type GitSelectorParsed = {
path?: string;
semver?: string;
};
export type SpecType = 'file' | 'git' | 'registry' | 'remote' | 'workspace' | 'catalog';
export type SpecLikeBase = {
/** the type of spec that this is, ultimately */
type: SpecType;
/** the full named specifier passed to the constructor */
spec: string;
/** options passed to the constructor, plus defaults */
options: SpecOptionsFilled;
/** the name portion, so `foo` in `foo@1.x` */
name: string;
/** the name's scope, so `@acme` in `@acme/foo@1.x` */
scope?: Scope;
/**
* if the name is scoped, and there's a registry associated with the scope,
* then this is that registry
*/
scopeRegistry?: string;
/** just the part AFTER the name, so `1.x` in `foo@1.x` */
bareSpec: string;
/** the git remote to fetch from */
gitRemote?: string;
/** the committish, semver range, and/or path portion of a git remote */
gitSelector?: string;
/**
* the parsed '::'-separated key/value pairs:
* `semver:<range>` and `path:<subpath>`
*/
gitSelectorParsed?: GitSelectorParsed;
/** the commit value we will check out */
gitCommittish?: string;
/** github, gitlab, bitbucket, gist, etc. */
namedGitHost?: string;
/** the path that's parsed when we have a named git host */
namedGitHostPath?: string;
/**
* the specifier when using `workspace:` specs
* This can be either a semver range, `*`, `~`, or `^`,
* if the name is not modified. Or, it can include a workspace
* package name or path, like `workspace:packages/foo@*` or
* `workspace:@scope/foo@*`.
*/
workspaceSpec?: string;
/**
* the package name or path of the workspace being referenced
*/
workspace?: string;
/**
* In specs like `foo@npm:bar@1`, this is the 'npm' part. Other
* registries can be mapped using the `registries` option.
*/
namedRegistry?: string;
/** registry to consult to resolve this spec */
registry?: string;
/** semver range or dist-tag for resolving against a packument */
registrySpec?: string;
/**
* conventional location of the tarball on the registry, if it can be
* guessed. This is only attempted if the spec is a registry type, with a
* single version comparator. This can be used to elide resolved urls that
* are repetitive and predictable.
*/
conventionalRegistryTarball?: string;
/** spec to resolve against available versions */
semver?: string;
/** parsed semver range specifier */
range?: Range;
/** a dist-tag like 'latest' */
distTag?: string;
/**
* URL to download a tarball from, if it can be determined.
*
* This is set for url specs of course, but also git remotes on known
* hosts that provide a gitHostArchive template.
*/
remoteURL?: string;
/** file path for file:// url specs */
file?: string;
/** in `bar@npm:foo@1.x`, this is the spec for `foo@1.x` */
subspec?: SpecLikeBase;
/**
* getter that retrieves the actual spec value to be used
*/
final: SpecLikeBase;
/** Is this a spec that overrides another spec? */
overridden: boolean;
toString(): string;
};
export type SpecLike<Type extends SpecLikeBase> = SpecLikeBase & {
subspec?: Type;
final: Type;
};
//# sourceMappingURL=types.d.ts.map
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAE3C,MAAM,MAAM,WAAW,GAAG;KACvB,CAAC,IAAI,MAAM,iBAAiB,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC;CACtD,CAAA;AAED,MAAM,MAAM,KAAK,GAAG,IAAI,MAAM,EAAE,CAAA;AAEhC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAA;IAChB,kDAAkD;IAClD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAClC,iDAAiD;IACjD,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACnC,6DAA6D;IAC7D,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC3C,sCAAsC;IACtC,kBAAkB,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IACzC,mDAAmD;IACnD,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAClD,CAAA;AAED,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EAAE,MAAM,CAAA;IAEf,oCAAoC;IACpC,KAAK,CAAC,EAAE,KAAK,CAAA;IAEb,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,2DAA2D;IAC3D,OAAO,CAAC,EAAE,YAAY,CAAA;IACtB;;OAEG;IACH,KAAK,EAAE,YAAY,CAAA;IACnB,kDAAkD;IAClD,UAAU,EAAE,OAAO,CAAA;IAEnB,QAAQ,IAAI,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,QAAQ,CAAC,IAAI,SAAS,YAAY,IAAI,YAAY,GAAG;IAC/D,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,KAAK,EAAE,IAAI,CAAA;CACZ,CAAA"}
export {};
//# sourceMappingURL=types.js.map
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Range } from '@vltpkg/semver'\n\nexport type SpecOptions = {\n [k in keyof SpecOptionsFilled]?: SpecOptionsFilled[k]\n}\n\nexport type Scope = `@${string}`\n\nexport type SpecOptionsFilled = {\n /** the registry where a spec should be resolved against */\n registry: string\n /** shorthand prefix names for known registries */\n registries: Record<string, string>\n /** shorthand prefix names for known git hosts */\n 'git-hosts': Record<string, string>\n /** tarball hosting services for hosts listed in git-hosts */\n 'git-host-archives': Record<string, string>\n /** registries mapped to a `@scope` */\n 'scope-registries': Record<Scope, string>\n /** registries that work like https://npm.jsr.io */\n 'jsr-registries': Record<string, string>\n catalog: Record<string, string>\n catalogs?: Record<string, Record<string, string>>\n}\n\nexport type GitSelectorParsed = {\n path?: string\n semver?: string\n}\n\nexport type SpecType =\n | 'file'\n | 'git'\n | 'registry'\n | 'remote'\n | 'workspace'\n | 'catalog'\n\nexport type SpecLikeBase = {\n /** the type of spec that this is, ultimately */\n type: SpecType\n\n /** the full named specifier passed to the constructor */\n spec: string\n\n /** options passed to the constructor, plus defaults */\n options: SpecOptionsFilled\n\n /** the name portion, so `foo` in `foo@1.x` */\n name: string\n\n /** the name's scope, so `@acme` in `@acme/foo@1.x` */\n scope?: Scope\n\n /**\n * if the name is scoped, and there's a registry associated with the scope,\n * then this is that registry\n */\n scopeRegistry?: string\n\n /** just the part AFTER the name, so `1.x` in `foo@1.x` */\n bareSpec: string\n\n /** the git remote to fetch from */\n gitRemote?: string\n\n /** the committish, semver range, and/or path portion of a git remote */\n gitSelector?: string\n /**\n * the parsed '::'-separated key/value pairs:\n * `semver:<range>` and `path:<subpath>`\n */\n gitSelectorParsed?: GitSelectorParsed\n /** the commit value we will check out */\n gitCommittish?: string\n /** github, gitlab, bitbucket, gist, etc. */\n namedGitHost?: string\n /** the path that's parsed when we have a named git host */\n namedGitHostPath?: string\n\n /**\n * the specifier when using `workspace:` specs\n * This can be either a semver range, `*`, `~`, or `^`,\n * if the name is not modified. Or, it can include a workspace\n * package name or path, like `workspace:packages/foo@*` or\n * `workspace:@scope/foo@*`.\n */\n workspaceSpec?: string\n\n /**\n * the package name or path of the workspace being referenced\n */\n workspace?: string\n\n /**\n * In specs like `foo@npm:bar@1`, this is the 'npm' part. Other\n * registries can be mapped using the `registries` option.\n */\n namedRegistry?: string\n\n /** registry to consult to resolve this spec */\n registry?: string\n\n /** semver range or dist-tag for resolving against a packument */\n registrySpec?: string\n\n /**\n * conventional location of the tarball on the registry, if it can be\n * guessed. This is only attempted if the spec is a registry type, with a\n * single version comparator. This can be used to elide resolved urls that\n * are repetitive and predictable.\n */\n conventionalRegistryTarball?: string\n\n /** spec to resolve against available versions */\n semver?: string\n\n /** parsed semver range specifier */\n range?: Range\n\n /** a dist-tag like 'latest' */\n distTag?: string\n\n /**\n * URL to download a tarball from, if it can be determined.\n *\n * This is set for url specs of course, but also git remotes on known\n * hosts that provide a gitHostArchive template.\n */\n remoteURL?: string\n\n /** file path for file:// url specs */\n file?: string\n\n /** in `bar@npm:foo@1.x`, this is the spec for `foo@1.x` */\n subspec?: SpecLikeBase\n /**\n * getter that retrieves the actual spec value to be used\n */\n final: SpecLikeBase\n /** Is this a spec that overrides another spec? */\n overridden: boolean\n\n toString(): string\n}\n\nexport type SpecLike<Type extends SpecLikeBase> = SpecLikeBase & {\n subspec?: Type\n final: Type\n}\n"]}
+6
-22
{
"name": "@vltpkg/spec",
"description": "Package specifier library",
"version": "1.0.0-rc.10",
"version": "1.0.0-rc.11",
"repository": {

@@ -11,17 +11,5 @@ "type": "git",

"author": "vlt technology inc. <support@vlt.sh> (http://vlt.sh)",
"tshy": {
"selfLink": false,
"liveDev": true,
"dialects": [
"esm"
],
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts",
"./browser": "./src/browser.ts"
}
},
"dependencies": {
"@vltpkg/error-cause": "1.0.0-rc.10",
"@vltpkg/semver": "1.0.0-rc.10"
"@vltpkg/error-cause": "1.0.0-rc.11",
"@vltpkg/semver": "1.0.0-rc.11"
},

@@ -36,3 +24,2 @@ "devDependencies": {

"tap": "^21.5.0",
"tshy": "^3.1.0",
"typedoc": "~0.27.9",

@@ -51,3 +38,3 @@ "typescript": "5.7.3",

"prettier": "../../.prettierrc.js",
"module": "./dist/esm/index.js",
"module": "./dist/index.js",
"type": "module",

@@ -58,4 +45,3 @@ "exports": {

"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
"default": "./dist/index.js"
}

@@ -65,4 +51,3 @@ },

"import": {
"types": "./dist/esm/browser.d.ts",
"default": "./dist/esm/browser.js"
"default": "./dist/browser.js"
}

@@ -83,5 +68,4 @@ }

"posttest": "tsc --noEmit",
"tshy": "tshy",
"typecheck": "tsc --noEmit"
}
}
import type { Range } from '@vltpkg/semver';
import type { GitSelectorParsed, Scope, SpecLike, SpecOptions, SpecOptionsFilled, SpecType } from './types.ts';
export * from './types.ts';
export declare const kCustomInspect: unique symbol;
export declare const defaultRegistry = "https://registry.npmjs.org/";
export declare const defaultRegistryName = "npm";
export declare const defaultRegistries: {
npm: string;
gh: string;
};
export declare const defaultJsrRegistries: {
jsr: string;
};
export declare const defaultGitHosts: {
github: string;
bitbucket: string;
gitlab: string;
gist: string;
};
export declare const defaultGitHostArchives: {
github: string;
bitbucket: string;
gist: string;
gitlab: string;
};
/**
* These are just for legacy support of urls that are supported by npm
* and observed in the wild.
*
* Not configurable, because no more will be added. If you wish to define
* custom git hosts, use it with the `'git-hosts'` and `'git-host-archives'`
* options.
*/
export declare const gitHostWebsites: {
github: string;
bitbucket: string;
gist: string;
gitlab: string;
};
export declare const defaultScopeRegistries: {
'@jsr': string;
};
export declare const getOptions: (options?: SpecOptions) => SpecOptionsFilled;
/**
* Injects the Node.js dependencies into the Spec class.
*/
export type NodeJSDependenciesOptions = {
homedir: typeof import('os').homedir;
isAbsolute: typeof import('node:path').isAbsolute;
join: typeof import('node:path').join;
resolve: typeof import('node:path').resolve;
winPath: typeof import('node:path').win32;
};
export declare const isSpec: (spec: unknown) => spec is Spec;
/**
* Retrieves the short configured name of the default registry if one
* is available.
*/
export declare const currentDefaultRegistryName: (registry: string, options: SpecOptions) => string | undefined;
/**
* The base, isomorphic Spec implementation.
*/
export declare class Spec implements SpecLike<Spec> {
#private;
/**
* Create a Spec object from a full spec, name+bareSpec, or Spec object
*
* Note: If a Spec object is provided, it is returned as-is, without
* investigating whether the options match.
*/
static parse(name: string, bareSpec: string, options?: SpecOptions): Spec;
static parse(spec: string, options?: SpecOptions): Spec;
static parse(spec: Spec, options?: SpecOptions): Spec;
static parseArgs(specOrBareSpec: string, opts?: SpecOptions): Spec;
static nodejsDependencies?: NodeJSDependenciesOptions;
type: SpecType;
spec: string;
options: SpecOptionsFilled;
name: string;
scope?: Scope;
scopeRegistry?: string;
bareSpec: string;
gitRemote?: string;
gitSelector?: string;
gitSelectorParsed?: GitSelectorParsed;
gitCommittish?: string;
namedGitHost?: string;
namedGitHostPath?: string;
workspaceSpec?: string;
workspace?: string;
namedRegistry?: string;
namedJsrRegistry?: string;
registry?: string;
registrySpec?: string;
conventionalRegistryTarball?: string;
semver?: string;
range?: Range;
distTag?: string;
remoteURL?: string;
file?: string;
catalog?: string;
subspec?: Spec;
overridden: boolean;
/**
* Return the final entry in the chain of subspecs
* When deciding which thing to actually fetch, spec.final is the thing
* to look at.
*/
get final(): Spec & {
type: Exclude<SpecType, 'catalog'>;
};
/**
* Normally, the string value of a Spec is just the string passed in to
* be parsed. However, in the case of a chain of subspecs, like
* `foo@npm:bar@npm:baz@npm:quux@latest`, this simplifies out the middle
* parts of the chain, returning just `foo@npm:quux@latest`
*/
toString(): string;
['constructor']: typeof Spec;
constructor(name: string, bareSpec: string, options?: SpecOptions);
constructor(spec: string, options?: SpecOptions);
constructor(spec: Spec | string, bareOrOptions?: SpecOptions | string, options?: SpecOptions);
[kCustomInspect](): string;
/**
* Should only ever be called with the bit that comes AFTER the #
* in the git remote url.
*/
static parseGitSelector(selector: string, spec?: Spec): [parsed: GitSelectorParsed, committish?: string, range?: Range];
}
export declare const getNormalizeFile: (opts?: NodeJSDependenciesOptions) => (bareSpec: string, spec: Spec) => [path: string, uri: string];
//# sourceMappingURL=browser.d.ts.map
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,KAAK,EACV,iBAAiB,EACjB,KAAK,EACL,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,QAAQ,EACT,MAAM,YAAY,CAAA;AACnB,cAAc,YAAY,CAAA;AAE1B,eAAO,MAAM,cAAc,eAA2C,CAAA;AAEtE,eAAO,MAAM,eAAe,gCAAgC,CAAA;AAC5D,eAAO,MAAM,mBAAmB,QAAQ,CAAA;AAExC,eAAO,MAAM,iBAAiB;;;CAG7B,CAAA;AAED,eAAO,MAAM,oBAAoB;;CAAiC,CAAA;AAElE,eAAO,MAAM,eAAe;;;;;CAK3B,CAAA;AAED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,CAAC,EAAE,WAAW;gBAE7C,IAAI,EAAE,IAAI,GAAG,MAAM,EACnB,aAAa,CAAC,EAAE,WAAW,GAAG,MAAM,EACpC,OAAO,CAAC,EAAE,WAAW;IA6XvB,CAAC,cAAc,CAAC,IAAI,MAAM;IA8E1B;;;OAGG;IACH,MAAM,CAAC,gBAAgB,CACrB,QAAQ,EAAE,MAAM,EAChB,IAAI,CAAC,EAAE,IAAI,GACV,CAAC,MAAM,EAAE,iBAAiB,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,CAAC;CA8DnE;AAUD,eAAO,MAAM,gBAAgB,UACnB,yBAAyB,gBACtB,MAAM,QAAQ,IAAI,KAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,CAsHzD,CAAA"}
import { error, typeError } from '@vltpkg/error-cause';
import { parseRange } from '@vltpkg/semver';
export * from "./types.js";
export const kCustomInspect = Symbol.for('nodejs.util.inspect.custom');
export const defaultRegistry = 'https://registry.npmjs.org/';
export const defaultRegistryName = 'npm';
export const defaultRegistries = {
npm: defaultRegistry,
gh: 'https://npm.pkg.github.com/',
};
export const defaultJsrRegistries = { jsr: 'https://npm.jsr.io/' };
export const defaultGitHosts = {
github: 'git+ssh://git@github.com:$1/$2.git',
bitbucket: 'git+ssh://git@bitbucket.org:$1/$2.git',
gitlab: 'git+ssh://git@gitlab.com:$1/$2.git',
gist: 'git+ssh://git@gist.github.com/$1.git',
};
export const defaultGitHostArchives = {
github: 'https://api.github.com/repos/$1/$2/tarball/$committish',
bitbucket: 'https://bitbucket.org/$1/$2/get/$committish.tar.gz',
gist: 'https://codeload.github.com/gist/$1/tar.gz/$committish',
gitlab: 'https://gitlab.com/$1/$2/repository/archive.tar.gz?ref=$committish',
};
/**
* These are just for legacy support of urls that are supported by npm
* and observed in the wild.
*
* Not configurable, because no more will be added. If you wish to define
* custom git hosts, use it with the `'git-hosts'` and `'git-host-archives'`
* options.
*/
export const gitHostWebsites = {
github: 'https://github.com/',
bitbucket: 'https://bitbucket.org/',
gist: 'https://gist.github.com/',
gitlab: 'https://gitlab.com/',
};
export const defaultScopeRegistries = {
'@jsr': 'https://npm.jsr.io/',
};
export const getOptions = (options) => ({
catalog: {},
catalogs: {},
...options,
'jsr-registries': {
...(options?.['jsr-registries'] ?? {}),
...defaultJsrRegistries,
},
registry: options?.registry ?? defaultRegistry,
'scope-registries': options?.['scope-registries'] ?? {},
'git-hosts': options?.['git-hosts'] ?
{
...defaultGitHosts,
...options['git-hosts'],
}
: defaultGitHosts,
registries: {
...(options?.registries ?? {}),
...defaultRegistries,
},
'git-host-archives': options?.['git-host-archives'] ?
{
...defaultGitHostArchives,
...options['git-host-archives'],
}
: defaultGitHostArchives,
});
/**
* Various nameless scenarios that are handled in the
* standard spec parsing and should return an unknown name.
*
* Returns `true` if the name can not be inferred, `false` otherwise.
*/
const startsWithSpecIdentifier = (spec, options) => spec.startsWith('/') ||
spec.startsWith('./') ||
spec.startsWith('../') ||
spec.startsWith('file:') ||
spec.startsWith('http:') ||
spec.startsWith('https:') ||
spec.startsWith('workspace:') ||
spec.startsWith('catalog:') ||
spec.startsWith('git@') ||
spec.startsWith('git://') ||
spec.startsWith('git+ssh://') ||
spec.startsWith('git+http://') ||
spec.startsWith('git+https://') ||
spec.startsWith('git+file://') ||
spec.startsWith('git@github.com') ||
spec.startsWith('registry:') ||
spec.startsWith('npm:') ||
spec.startsWith('jsr:') ||
spec.startsWith('gh:') ||
// anything that starts with a known git host key, or a
// custom registered registry protocol e.g: `github:`, `custom:`
[
...Object.keys(options['git-hosts']),
...Object.keys(options.registries),
...Object.keys(options['jsr-registries']),
].some(key => spec.startsWith(`${key}:`));
/**
* Returns the location in which the first `@` value is found in a given
* string, also takes into account that a string starting with @ is
* using a scoped-name.
*/
const findFirstAt = (spec, hasScope) => spec.indexOf('@', hasScope ? 1 : 0);
/**
* Return `true` if a given spec string is likely to be a git spec.
*/
const findGitIdentifier = (spec) => spec.indexOf('#') > 2;
/**
* Return `true` if a given spec string is likely to be a file spec.
*/
const findFileIdentifier = (spec) => spec.includes('/');
export const isSpec = (spec) => typeof spec === 'object' &&
spec !== null &&
'spec' in spec &&
'bareSpec' in spec &&
'name' in spec &&
'type' in spec &&
'options' in spec &&
typeof spec.spec === 'string' &&
typeof spec.bareSpec === 'string' &&
typeof spec.name === 'string';
/**
* Retrieves the short configured name of the default registry if one
* is available.
*/
export const currentDefaultRegistryName = (registry, options) => {
for (const [name, url] of Object.entries(options.registries /* c8 ignore next */ ?? {})) {
const specRegURL = registry.endsWith('/') ? registry : registry + '/';
const knownRegURL = url.endsWith('/') ? url : url + '/';
if (specRegURL === knownRegURL) {
return name;
}
}
};
/**
* The base, isomorphic Spec implementation.
*/
export class Spec {
static parse(spec, bareOrOptions, options) {
return typeof spec === 'object' ? spec : (new this(spec, bareOrOptions, options));
}
static parseArgs(specOrBareSpec, opts) {
const options = getOptions(opts ?? {});
if (startsWithSpecIdentifier(specOrBareSpec, options)) {
const parsed = this.parse('(unknown)', specOrBareSpec, options);
// try to look into a potential parsed subspec for a name
if (parsed.subspec) {
const { namedJsrRegistry: jsrHost } = parsed;
if (!jsrHost) {
parsed.name = parsed.subspec.name;
}
parsed.spec = `${parsed.name}@${parsed.bareSpec}`;
}
return parsed;
}
else {
const hasScope = specOrBareSpec.startsWith('@');
const at = findFirstAt(specOrBareSpec, hasScope);
if (at > -1) {
return this.parse(specOrBareSpec.substring(0, at), specOrBareSpec.substring(at + 1), options);
}
else if (findGitIdentifier(specOrBareSpec) ||
(!hasScope && findFileIdentifier(specOrBareSpec))) {
return this.parse('(unknown)', specOrBareSpec, options);
}
else {
// doesn't have an @, so it's just a name with no version
return this.parse(`${specOrBareSpec}@`, options);
}
}
}
static nodejsDependencies;
type;
spec;
options;
name;
scope;
scopeRegistry;
bareSpec;
gitRemote;
gitSelector;
gitSelectorParsed;
gitCommittish;
namedGitHost;
namedGitHostPath;
workspaceSpec;
workspace;
namedRegistry;
namedJsrRegistry;
registry;
registrySpec;
conventionalRegistryTarball;
semver;
range;
distTag;
remoteURL;
file;
catalog;
subspec;
overridden = false;
#final;
#toString;
/**
* Return the final entry in the chain of subspecs
* When deciding which thing to actually fetch, spec.final is the thing
* to look at.
*/
get final() {
if (this.#final)
return this.#final;
const final = this.subspec ? this.subspec.final : this;
/* c8 ignore start - impossible */
if (final.type === 'catalog') {
throw error('invalid Spec.final value, type is "catalog"');
}
/* c8 ignore stop */
return (this.#final = final);
}
/**
* Normally, the string value of a Spec is just the string passed in to
* be parsed. However, in the case of a chain of subspecs, like
* `foo@npm:bar@npm:baz@npm:quux@latest`, this simplifies out the middle
* parts of the chain, returning just `foo@npm:quux@latest`
*/
toString() {
if (this.#toString !== undefined)
return this.#toString;
let sub = this;
// we want the SECOND from the last in the chain
while (sub.subspec?.subspec)
sub = sub.subspec;
if (sub.subspec && sub.subspec.type !== 'registry')
sub = sub.subspec;
return (this.#toString = this.name + '@' + sub.bareSpec);
}
constructor(spec, bareOrOptions, options = {}) {
if (bareOrOptions && typeof bareOrOptions === 'object') {
options = bareOrOptions;
bareOrOptions = undefined;
}
this.options = getOptions(options);
if (typeof bareOrOptions === 'string') {
this.name = spec;
this.#parseScope(spec);
this.bareSpec = bareOrOptions;
this.spec = `${this.name}@${bareOrOptions}`;
}
else {
this.spec = spec;
// Check if this spec starts with a known registry identifier
// but exclude git specs like 'git@github:a/b'
if (!spec.startsWith('git@') &&
startsWithSpecIdentifier(spec, this.options) &&
spec.includes(':') &&
[
...Object.keys(this.options.registries),
...Object.keys(defaultRegistries),
].some(key => spec.startsWith(`${key}:`))) {
// For specs like 'gh:@octocat/hello-world@1.0.0', don't split at the @
// Instead, set a temporary name and let the registry logic handle it
this.name = spec;
this.bareSpec = spec;
}
else {
const hasScope = spec.startsWith('@');
let at = findFirstAt(spec, hasScope);
if (at === -1) {
// assume that an unadorned spec is just a name at the default
// registry
at = spec.length;
spec += '@';
}
this.name = spec.substring(0, at);
if (hasScope)
this.#parseScope(this.name);
this.bareSpec = spec.substring(at + 1);
}
}
if (this.bareSpec.startsWith('catalog:')) {
this.catalog = this.bareSpec.substring('catalog:'.length);
const catalog = this.catalog ?
this.options.catalogs?.[this.catalog]
: this.options.catalog;
if (!catalog) {
throw this.#error('Named catalog not found', {
name: this.catalog,
validOptions: this.options.catalogs &&
Object.keys(this.options.catalogs),
});
}
const sub = catalog[this.name];
if (!sub) {
throw this.#error('Name not found in catalog', {
name: this.name,
validOptions: Object.keys(catalog),
});
}
this.subspec = Spec.parse(this.name, sub);
this.type = 'catalog';
return;
}
// legacy affordance: allow project urls like
// 'https://github.com/user/project#commitish' because npm suports it and
// this pattern is observed in the wild.
if (this.bareSpec.startsWith('https://')) {
for (const [name, origin] of Object.entries(gitHostWebsites)) {
if (this.bareSpec.startsWith(origin)) {
const parsed = new URL(this.bareSpec);
const [user, project] = parsed.pathname
.replace(/\.git$/, '')
.replace(/\/+/g, ' ')
.trim()
.split(' ');
if (user && project) {
this.bareSpec = `${name}:${user}/${project}${parsed.hash}`;
this.spec = `${this.name}@${this.bareSpec}`;
break;
}
}
}
}
if (this.bareSpec.startsWith('workspace:')) {
this.type = 'workspace';
const ws = this.bareSpec.substring('workspace:'.length).trim();
const w = ws.lastIndexOf('@');
if (w === -1) {
this.workspace = this.name;
}
else {
const wsName = ws.substring(0, w);
if (!wsName ||
wsName === '*' ||
wsName === '~' ||
wsName === '^' ||
(wsName.startsWith('@') ?
wsName.split('/').length !== 2 ||
wsName.substring(1).includes('@')
: wsName.includes('@'))) {
throw this.#error('workspace: name must be a path or valid package name', { found: wsName });
}
this.workspace = wsName;
}
// workspace: is the same as workspace:*
const wss = w === -1 ? ws : ws.substring(w + 1) || '*';
const range = wss === '*' ? undefined : parseRange(wss);
if (wss !== '*' && wss !== '~' && wss !== '^' && !range) {
throw this.#error('workspace: spec must be one of *, ~, or ^, or a valid semver range', {
found: wss,
wanted: `'*'|'~'|'^'|SemverRange`,
});
}
this.workspaceSpec = wss;
if (range) {
this.semver = wss;
this.range = range;
}
return;
}
if (this.bareSpec.startsWith('git://') ||
this.bareSpec.startsWith('git+ssh://') ||
this.bareSpec.startsWith('git+http://') ||
this.bareSpec.startsWith('git+https://') ||
this.bareSpec.startsWith('git+file://') ||
// legacy affordance
this.bareSpec.startsWith('git@github.com')) {
if (this.bareSpec.startsWith('git@')) {
this.bareSpec = `git+ssh://${this.bareSpec}`;
this.spec = `${this.name}@${this.bareSpec}`;
}
this.type = 'git';
// see if it's one of the known named hosts, and if so, prefer
// the shorter syntax.
for (const [name, host] of Object.entries(this.options['git-hosts'])) {
const s = host.indexOf('$');
if (s > 0 && this.bareSpec.startsWith(host.substring(0, s))) {
const p = this.bareSpec
.substring(s)
.replace(/\.git(#.*)?$/, '$1');
this.bareSpec = `${name}:${p}`;
this.spec = `${this.name}@${this.bareSpec}`;
this.#parseHostedGit(name, host);
this.type = 'git';
return;
}
}
this.#parseGitSelector(this.bareSpec);
return;
}
// Check registries before git hosts to avoid conflicts
const regs = Object.entries(this.options.registries);
if (this.bareSpec.startsWith('registry:')) {
const reg = this.bareSpec.substring('registry:'.length);
const h = reg.indexOf('#');
if (h === -1) {
throw this.#error('registry: must include name/version');
}
this.type = 'registry';
let url = reg.substring(0, h);
if (!url.endsWith('/'))
url += '/';
const regSpec = reg.substring(h + 1);
for (let [name, u] of regs) {
if (!u.endsWith('/')) {
u += '/';
this.options.registries[name] = u;
}
if (u === url)
this.namedRegistry = name;
}
this.#parseRegistrySpec(regSpec, url);
this.#guessRegistryTarball();
return;
}
for (const [host, url] of regs) {
const h = `${host}:`;
if (this.bareSpec.startsWith(h)) {
this.type = 'registry';
this.namedRegistry = host;
this.#parseRegistrySpec(this.bareSpec.substring(h.length), url).namedRegistry ??= host;
// If we parsed a spec identifier, update the name and spec format
if (this.subspec && this.name === this.bareSpec) {
this.name = this.subspec.name;
this.spec = `${this.name}@${this.bareSpec}`;
}
this.#guessRegistryTarball();
return;
}
}
// spooky
const ghosts = Object.entries(this.options['git-hosts']);
for (const [name, template] of ghosts) {
if (this.#parseHostedGit(name, template)) {
this.type = 'git';
return;
}
}
const jsrs = Object.entries(this.options['jsr-registries']);
for (const [host, url] of jsrs) {
const h = `${host}:`;
if (this.bareSpec.startsWith(h)) {
this.type = 'registry';
this.namedJsrRegistry = host;
this.#parseJsrRegistrySpec(this.bareSpec.substring(h.length), url).namedJsrRegistry ??= host;
return;
}
}
if (this.bareSpec.startsWith('https://') ||
this.bareSpec.startsWith('http://')) {
this.remoteURL = this.bareSpec;
this.type = 'remote';
return;
}
// explicit file: url
if (this.bareSpec.startsWith('file:')) {
this.type = 'file';
const [path, uri] = getNormalizeFile(this.constructor.nodejsDependencies)(this.bareSpec, this);
this.file = path;
this.bareSpec = uri.replace(/\/+$/, '');
this.spec = `${this.name}@${this.bareSpec}`;
return;
}
// legacy! once upon a time, `user/project` was a shorthand for pulling
// packages from github, instead of the more verbose and explicit
// `github:user/project`.
if (!this.bareSpec.startsWith('./') &&
!this.bareSpec.startsWith('../') &&
this.options['git-hosts'].github) {
const hash = this.bareSpec.indexOf('#');
const up = hash === -1 ? this.bareSpec : this.bareSpec.substring(0, hash);
if (up.split('/').length === 2) {
this.bareSpec = `github:${this.bareSpec}`;
this.spec = `${this.name}@${this.bareSpec}`;
this.#parseHostedGit('github', this.options['git-hosts'].github);
this.type = 'git';
return;
}
}
// if it contains a / and isn't picked up in the github shorthand,
// then convert to file: specifier
if (this.bareSpec.includes('/') ||
this.bareSpec === '.' ||
this.bareSpec === '..') {
this.type = 'file';
const [file, uri] = getNormalizeFile(this.constructor.nodejsDependencies)(`file:${this.bareSpec}`, this);
this.bareSpec = uri;
this.spec = `${this.name}@${this.bareSpec}`;
this.file = file;
return;
}
// at this point, must be either semver range or dist-tag
this.type = 'registry';
const range = parseRange(this.bareSpec);
if (range) {
this.semver = this.bareSpec.trim();
this.range = range;
}
else {
this.distTag = this.bareSpec;
}
this.registrySpec = this.bareSpec;
const { 'scope-registries': scopeRegs, registry } = this.options;
const scopeReg = this.scope && scopeRegs[this.scope];
this.registry = scopeReg ?? registry;
// no guessing the tarball for JSR registries
for (const r of Object.values(this.options['jsr-registries'])) {
if (this.registry === r)
return;
}
this.#guessRegistryTarball();
}
#parseScope(name) {
if (!name.startsWith('@'))
return;
const s = name.indexOf('/');
if (s > 1 && s < name.length - 1) {
const scope = name.substring(0, s);
this.registry = this.scopeRegistry =
this.options['scope-registries'][scope];
this.scope = scope;
}
}
#parseHostedGit(name, template) {
if (this.bareSpec.startsWith(`${name}:`)) {
const h = this.bareSpec.indexOf('#');
const bare = h === -1 ? this.bareSpec : this.bareSpec.substring(0, h);
const hash = h === -1 ? '' : this.bareSpec.substring(h);
const hostPath = bare.substring(name.length + 1);
if (!hostPath) {
throw this.#error('invalid named git host specifier');
}
const split = hostPath.split('/');
let t = template;
for (let i = 0; i < split.length; i++) {
t = t.split(`$${i + 1}`).join(split[i]);
}
t += hash;
this.namedGitHost = name;
this.namedGitHostPath = hostPath;
this.#parseGitSelector(t);
if (this.gitCommittish && !this.gitSelectorParsed?.path) {
const archiveHost = this.options['git-host-archives'][name];
if (name === 'github' &&
this.gitCommittish.startsWith('pull/') &&
this.gitCommittish.match(/\//g)?.length === 1) {
this.gitCommittish += '/head';
}
if (archiveHost) {
this.type = 'remote';
let t = archiveHost;
t = t.split('$committish').join(this.gitCommittish);
for (let i = 0; i < split.length; i++) {
t = t.split(`$${i + 1}`).join(split[i]);
}
this.remoteURL = t;
}
}
return true;
}
return false;
}
/* c8 ignore start */
[kCustomInspect]() {
return `@vltpkg/spec.Spec ${String(this)}`;
}
/* c8 ignore stop */
#guessRegistryTarball() {
// only try to guess if it's a single comparator for a single version
const { name, registry, range } = this.final;
if (!registry || !range?.isSingle)
return;
const stripScope = /^@[^/]+\//;
this.conventionalRegistryTarball = String(new URL(`/${name}/-/${name.replace(stripScope, '')}-${range}.tgz`, registry));
}
#parseRegistrySpec(s, url) {
// note: this takes priority over the scoped registry, if set
this.registry = url;
this.subspec = this.constructor.parse(s, {
...this.options,
registry: url,
});
return this.subspec;
}
#parseJsrRegistrySpec(s, url) {
this.registry = url;
// @luca/cases@jsr:1.x
if (!s.startsWith('@'))
s = `${this.name}@${s}`;
const name = `@jsr/${s.replace(/^@/, '').replace(/\//, '__')}`;
this.subspec = this.constructor.parse(name, {
...this.options,
'scope-registries': {
...this.options['scope-registries'],
'@jsr': url,
},
});
if (this.name === '(unknown)') {
const nextAt = s.indexOf('@', 1);
if (nextAt === -1) {
this.name = s;
}
else {
this.name = s.substring(0, s.indexOf('@', 1));
}
}
const reg = `${this.namedJsrRegistry}:`;
const n = `${reg}${this.name}`;
if (this.bareSpec.startsWith(n + '@')) {
this.bareSpec = reg + this.bareSpec.substring(n.length + 1);
}
else if (this.bareSpec === n) {
this.bareSpec = reg;
}
this.spec = this.name + '@' + this.bareSpec;
return this.subspec;
}
#error(message, extra = {}) {
return error(message, { spec: this.spec, ...extra }, this.#error);
}
#parseGitSelector(s) {
const h = s.indexOf('#');
if (h === -1) {
this.gitRemote = s;
return;
}
this.gitRemote = s.substring(0, h);
this.gitSelector = s.substring(h + 1);
const [selectorParsed, committish, range] = this.constructor.parseGitSelector(this.gitSelector, this);
this.range = range;
this.gitCommittish = committish;
this.gitSelectorParsed = selectorParsed;
}
/**
* Should only ever be called with the bit that comes AFTER the #
* in the git remote url.
*/
static parseGitSelector(selector, spec) {
if (!selector)
return [{}];
const split = selector.split('::');
const first = split[0];
let committish = undefined;
let range = undefined;
const parsed = {};
/* c8 ignore start - for TS's benefit */
if (typeof first !== 'string') {
throw typeError('impossible', {
found: first,
wanted: String,
});
}
/* c8 ignore stop */
if (!first.includes(':')) {
committish = first;
split.shift();
}
for (const kv of split) {
const c = kv.indexOf(':');
/* c8 ignore next */
if (c === -1)
continue;
const k = kv.substring(0, c);
const v = kv.substring(c + 1);
if (k === 'semver') {
if (committish) {
throw error('Cannot specify a semver range and committish value', { spec });
}
range = parseRange(v);
if (!range) {
throw error(`Invalid git tag semver range: ${v}`, { spec });
}
}
if (k === 'semver' || k === 'path') {
if (k === 'path') {
if (
/* c8 ignore next */ this.nodejsDependencies?.isAbsolute(v) ||
/(^|\/|\\)\.\.($|\\|\/)/.test(v)) {
throw error('Invalid path in git selector', { spec });
}
// normalize
/* c8 ignore start */
parsed.path = (this.nodejsDependencies ?
this.nodejsDependencies.join('/', v).substring(1)
: v).replace(/\\/g, '/');
/* c8 ignore stop */
}
else {
parsed[k] = v;
}
}
}
return [parsed, committish, range];
}
}
// normalize our kinda-sorta spec compliant `file:` specifiers
//
// For historical reasons, we need to support a lot of non-spec-compliant
// behaviors, but this massages the result into a *slightly* less offensive
// shape.
//
// The result will be either a fully compliant `file://` with an absolute path,
// or a `file:` with a relative path starting with `~`, `./`, or `../`.
export const getNormalizeFile = (opts) => (bareSpec, spec) => {
const slashes = bareSpec.substring('file:'.length, 'file://'.length);
const pref = `file:${slashes === '//' ? slashes : ''}`;
const rest = bareSpec.substring(pref.length);
// default to '/' because eol == '/' for parsing purposes
const [a = '', b = '/', c = '/', d = '/'] = rest.split('', 4);
if (!a) {
// file:// => file:.
// file: => file:.
return ['.', 'file:.'];
}
if ((a === '/' && b === '~' && c !== '/') ||
(a === '~' && b !== '/')) {
throw error(`invalid file: specifier. '~username' not supported`, { spec });
}
if (a === '~') {
// file://~ => file:~
// file://~/x => file:~/x
return /* c8 ignore start */ opts ?
[
opts.resolve(opts.homedir(), rest.substring(2)),
`file:${rest}`,
]
: [rest, `file:${rest}`];
}
if (a === '/' && b === '~') {
// file:///~ => file:~
// file:/~/x => file:~/x
/* c8 ignore start - tested in test/index.ts */
return opts ?
[
opts.resolve(opts.homedir(), rest.substring(3)),
`file:${rest.substring(1)}`,
]
: /* c8 ignore stop */
[rest.substring(1), `file:${rest.substring(1)}`];
}
if (a === '/' &&
b === '.' &&
(c === '/' || (c === '.' && d === '/'))) {
// file:/./x => file:./x
// file:///./x => file:./x
// file:/../x => file:../x
// file://../x => file:../x
return [rest.substring(1), `file:${rest.substring(1)}`];
}
if (a === '.' && (b === '/' || (b === '.' && c === '/'))) {
// file://. => file:.
// file://./x => file:./x
// file://../x => file:../x
return [rest, `file:${rest}`];
}
if (slashes === '//') {
// must be valid URI, since we ruled out relative and homedir above
// not relative, but note that file://host/share is
// windows-specific and does not work on darwin, so disallow it.
try {
const parsed = new URL(bareSpec);
if (parsed.host) {
if (parsed.host !== 'localhost') {
throw error(`invalid file:// specifier. host must be empty or 'localhost'`, {
spec,
found: parsed.host,
validOptions: ['', 'localhost'],
});
}
}
// normalize blank authority
// file://X:/foo => file:///X:/foo
// file://localhost/x => file:///x
// interpret a `file:///D:/x` as `D:/x` though
return [
parsed.pathname.replace(/^\/([a-zA-Z]:\/)/, '$1'),
`file://${parsed.pathname}`,
];
}
catch (er) {
// invalid URI for other reasons, eg file://x\u0000y/z
throw error('invalid file:// specifier', {
spec,
cause: er,
});
}
}
// no //, no authority, be ungovernable
/* c8 ignore start */
if (opts?.winPath.isAbsolute(rest)) {
// file:/absolute => file:///absolute
// file:/D:/foo => file:///D:/foo
return [rest, `file://${rest}`];
}
/* c8 ignore stop */
// file:x => file:./x
return [`./${rest}`, `file:./${rest}`];
};
//# sourceMappingURL=browser.js.map
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../../src/browser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAS3C,cAAc,YAAY,CAAA;AAE1B,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAA;AAEtE,MAAM,CAAC,MAAM,eAAe,GAAG,6BAA6B,CAAA;AAC5D,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAA;AAExC,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,GAAG,EAAE,eAAe;IACpB,EAAE,EAAE,6BAA6B;CAClC,CAAA;AAED,MAAM,CAAC,M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g/error-cause'\nimport type { Range } from '@vltpkg/semver'\nimport { parseRange } from '@vltpkg/semver'\nimport type {\n GitSelectorParsed,\n Scope,\n SpecLike,\n SpecOptions,\n SpecOptionsFilled,\n SpecType,\n} from './types.ts'\nexport * from './types.ts'\n\nexport const kCustomInspect = Symbol.for('nodejs.util.inspect.custom')\n\nexport const defaultRegistry = 'https://registry.npmjs.org/'\nexport const defaultRegistryName = 'npm'\n\nexport const defaultRegistries = {\n npm: defaultRegistry,\n gh: 'https://npm.pkg.github.com/',\n}\n\nexport const defaultJsrRegistries = { jsr: 'https://npm.jsr.io/' }\n\nexport const defaultGitHosts = {\n github: 'git+ssh://git@github.com:$1/$2.git',\n bitbucket: 'git+ssh://git@bitbucket.org:$1/$2.git',\n gitlab: 'git+ssh://git@gitlab.com:$1/$2.git',\n gist: 'git+ssh://git@gist.github.com/$1.git',\n}\n\nexport const defaultGitHostArchives = {\n github: 'https://api.github.com/repos/$1/$2/tarball/$committish',\n bitbucket: 'https://bitbucket.org/$1/$2/get/$committish.tar.gz',\n gist: 'https://codeload.github.com/gist/$1/tar.gz/$committish',\n gitlab:\n 'https://gitlab.com/$1/$2/repository/archive.tar.gz?ref=$committish',\n}\n\n/**\n * These are just for legacy support of urls that are supported by npm\n * and observed in the wild.\n *\n * Not configurable, because no more will be added. If you wish to define\n * custom git hosts, use it with the `'git-hosts'` and `'git-host-archives'`\n * options.\n */\nexport const gitHostWebsites = {\n github: 'https://github.com/',\n bitbucket: 'https://bitbucket.org/',\n gist: 'https://gist.github.com/',\n gitlab: 'https://gitlab.com/',\n}\n\nexport const defaultScopeRegistries = {\n '@jsr': 'https://npm.jsr.io/',\n}\n\nexport const getOptions = (\n options?: SpecOptions,\n): SpecOptionsFilled => ({\n catalog: {},\n catalogs: {},\n ...options,\n 'jsr-registries': {\n ...(options?.['jsr-registries'] ?? {}),\n ...defaultJsrRegistries,\n },\n registry: options?.registry ?? defaultRegistry,\n 'scope-registries': options?.['scope-registries'] ?? {},\n 'git-hosts':\n options?.['git-hosts'] ?\n {\n ...defaultGitHosts,\n ...options['git-hosts'],\n }\n : defaultGitHosts,\n registries: {\n ...(options?.registries ?? {}),\n ...defaultRegistries,\n },\n 'git-host-archives':\n options?.['git-host-archives'] ?\n {\n ...defaultGitHostArchives,\n ...options['git-host-archives'],\n }\n : defaultGitHostArchives,\n})\n\n/**\n * Various nameless scenarios that are handled in the\n * standard spec parsing and should return an unknown name.\n *\n * Returns `true` if the name can not be inferred, `false` otherwise.\n */\nconst startsWithSpecIdentifier = (\n spec: string,\n options: SpecOptionsFilled,\n): boolean =>\n spec.startsWith('/') ||\n spec.startsWith('./') ||\n spec.startsWith('../') ||\n spec.startsWith('file:') ||\n spec.startsWith('http:') ||\n spec.startsWith('https:') ||\n spec.startsWith('workspace:') ||\n spec.startsWith('catalog:') ||\n spec.startsWith('git@') ||\n spec.startsWith('git://') ||\n spec.startsWith('git+ssh://') ||\n spec.startsWith('git+http://') ||\n spec.startsWith('git+https://') ||\n spec.startsWith('git+file://') ||\n spec.startsWith('git@github.com') ||\n spec.startsWith('registry:') ||\n spec.startsWith('npm:') ||\n spec.startsWith('jsr:') ||\n spec.startsWith('gh:') ||\n // anything that starts with a known git host key, or a\n // custom registered registry protocol e.g: `github:`, `custom:`\n [\n ...Object.keys(options['git-hosts']),\n ...Object.keys(options.registries),\n ...Object.keys(options['jsr-registries']),\n ].some(key => spec.startsWith(`${key}:`))\n\n/**\n * Returns the location in which the first `@` value is found in a given\n * string, also takes into account that a string starting with @ is\n * using a scoped-name.\n */\nconst findFirstAt = (spec: string, hasScope: boolean) =>\n spec.indexOf('@', hasScope ? 1 : 0)\n\n/**\n * Return `true` if a given spec string is likely to be a git spec.\n */\nconst findGitIdentifier = (spec: string): boolean =>\n spec.indexOf('#') > 2\n\n/**\n * Return `true` if a given spec string is likely to be a file spec.\n */\nconst findFileIdentifier = (spec: string): boolean =>\n spec.includes('/')\n\n/**\n * Injects the Node.js dependencies into the Spec class.\n */\nexport type NodeJSDependenciesOptions = {\n homedir: typeof import('os').homedir\n isAbsolute: typeof import('node:path').isAbsolute\n join: typeof import('node:path').join\n resolve: typeof import('node:path').resolve\n winPath: typeof import('node:path').win32\n}\n\nexport const isSpec = (spec: unknown): spec is Spec =>\n typeof spec === 'object' &&\n spec !== null &&\n 'spec' in spec &&\n 'bareSpec' in spec &&\n 'name' in spec &&\n 'type' in spec &&\n 'options' in spec &&\n typeof (spec as Spec).spec === 'string' &&\n typeof (spec as Spec).bareSpec === 'string' &&\n typeof (spec as Spec).name === 'string'\n\n/**\n * Retrieves the short configured name of the default registry if one\n * is available.\n */\nexport const currentDefaultRegistryName = (\n registry: string,\n options: SpecOptions,\n): string | undefined => {\n for (const [name, url] of Object.entries(\n options.registries /* c8 ignore next */ ?? {},\n )) {\n const specRegURL =\n registry.endsWith('/') ? registry : registry + '/'\n const knownRegURL = url.endsWith('/') ? url : url + '/'\n if (specRegURL === knownRegURL) {\n return name\n }\n }\n}\n\n/**\n * The base, isomorphic Spec implementation.\n */\nexport class Spec implements SpecLike<Spec> {\n /**\n * Create a Spec object from a full spec, name+bareSpec, or Spec object\n *\n * Note: If a Spec object is provided, it is returned as-is, without\n * investigating whether the options match.\n */\n static parse(\n name: string,\n bareSpec: string,\n options?: SpecOptions,\n ): Spec\n static parse(spec: string, options?: SpecOptions): Spec\n static parse(spec: Spec, options?: SpecOptions): Spec\n static parse(\n spec: Spec | string,\n bareOrOptions?: SpecOptions | string,\n options?: SpecOptions,\n ): Spec {\n return typeof spec === 'object' ? spec : (\n new this(spec, bareOrOptions, options)\n )\n }\n\n static parseArgs(specOrBareSpec: string, opts?: SpecOptions): Spec {\n const options = getOptions(opts ?? {})\n\n if (startsWithSpecIdentifier(specOrBareSpec, options)) {\n const parsed = this.parse('(unknown)', specOrBareSpec, options)\n // try to look into a potential parsed subspec for a name\n if (parsed.subspec) {\n const { namedJsrRegistry: jsrHost } = parsed\n if (!jsrHost) {\n parsed.name = parsed.subspec.name\n }\n parsed.spec = `${parsed.name}@${parsed.bareSpec}`\n }\n return parsed\n } else {\n const hasScope = specOrBareSpec.startsWith('@')\n const at = findFirstAt(specOrBareSpec, hasScope)\n if (at > -1) {\n return this.parse(\n specOrBareSpec.substring(0, at),\n specOrBareSpec.substring(at + 1),\n options,\n )\n } else if (\n findGitIdentifier(specOrBareSpec) ||\n (!hasScope && findFileIdentifier(specOrBareSpec))\n ) {\n return this.parse('(unknown)', specOrBareSpec, options)\n } else {\n // doesn't have an @, so it's just a name with no version\n return this.parse(`${specOrBareSpec}@`, options)\n }\n }\n }\n\n static nodejsDependencies?: NodeJSDependenciesOptions\n\n type: SpecType\n spec: string\n options: SpecOptionsFilled\n name: string\n scope?: Scope\n scopeRegistry?: string\n bareSpec: string\n gitRemote?: string\n gitSelector?: string\n gitSelectorParsed?: GitSelectorParsed\n gitCommittish?: string\n namedGitHost?: string\n namedGitHostPath?: string\n workspaceSpec?: string\n workspace?: string\n namedRegistry?: string\n namedJsrRegistry?: string\n registry?: string\n registrySpec?: string\n conventionalRegistryTarball?: string\n semver?: string\n range?: Range\n distTag?: string\n remoteURL?: string\n file?: string\n catalog?: string\n subspec?: Spec\n overridden = false\n #final?: Spec & { type: Exclude<SpecType, 'catalog'> }\n #toString?: string\n\n /**\n * Return the final entry in the chain of subspecs\n * When deciding which thing to actually fetch, spec.final is the thing\n * to look at.\n */\n get final(): Spec & { type: Exclude<SpecType, 'catalog'> } {\n if (this.#final) return this.#final\n const final = this.subspec ? this.subspec.final : this\n /* c8 ignore start - impossible */\n if (final.type === 'catalog') {\n throw error('invalid Spec.final value, type is \"catalog\"')\n }\n /* c8 ignore stop */\n return (this.#final = final as this & {\n type: Exclude<SpecType, 'catalog'>\n })\n }\n\n /**\n * Normally, the string value of a Spec is just the string passed in to\n * be parsed. However, in the case of a chain of subspecs, like\n * `foo@npm:bar@npm:baz@npm:quux@latest`, this simplifies out the middle\n * parts of the chain, returning just `foo@npm:quux@latest`\n */\n toString() {\n if (this.#toString !== undefined) return this.#toString\n let sub: Spec = this\n // we want the SECOND from the last in the chain\n while (sub.subspec?.subspec) sub = sub.subspec\n if (sub.subspec && sub.subspec.type !== 'registry')\n sub = sub.subspec\n return (this.#toString = this.name + '@' + sub.bareSpec)\n }\n\n declare ['constructor']: typeof Spec\n\n constructor(name: string, bareSpec: string, options?: SpecOptions)\n constructor(spec: string, options?: SpecOptions)\n constructor(\n spec: Spec | string,\n bareOrOptions?: SpecOptions | string,\n options?: SpecOptions,\n )\n constructor(\n spec: string,\n bareOrOptions?: SpecOptions | string,\n options: SpecOptions = {},\n ) {\n if (bareOrOptions && typeof bareOrOptions === 'object') {\n options = bareOrOptions\n bareOrOptions = undefined\n }\n this.options = getOptions(options)\n\n if (typeof bareOrOptions === 'string') {\n this.name = spec\n this.#parseScope(spec)\n this.bareSpec = bareOrOptions\n this.spec = `${this.name}@${bareOrOptions}`\n } else {\n this.spec = spec\n // Check if this spec starts with a known registry identifier\n // but exclude git specs like 'git@github:a/b'\n if (\n !spec.startsWith('git@') &&\n startsWithSpecIdentifier(spec, this.options) &&\n spec.includes(':') &&\n [\n ...Object.keys(this.options.registries),\n ...Object.keys(defaultRegistries),\n ].some(key => spec.startsWith(`${key}:`))\n ) {\n // For specs like 'gh:@octocat/hello-world@1.0.0', don't split at the @\n // Instead, set a temporary name and let the registry logic handle it\n this.name = spec\n this.bareSpec = spec\n } else {\n const hasScope = spec.startsWith('@')\n let at = findFirstAt(spec, hasScope)\n if (at === -1) {\n // assume that an unadorned spec is just a name at the default\n // registry\n at = spec.length\n spec += '@'\n }\n this.name = spec.substring(0, at)\n if (hasScope) this.#parseScope(this.name)\n this.bareSpec = spec.substring(at + 1)\n }\n }\n\n if (this.bareSpec.startsWith('catalog:')) {\n this.catalog = this.bareSpec.substring('catalog:'.length)\n const catalog =\n this.catalog ?\n this.options.catalogs?.[this.catalog]\n : this.options.catalog\n if (!catalog) {\n throw this.#error('Named catalog not found', {\n name: this.catalog,\n validOptions:\n this.options.catalogs &&\n Object.keys(this.options.catalogs),\n })\n }\n const sub = catalog[this.name]\n if (!sub) {\n throw this.#error('Name not found in catalog', {\n name: this.name,\n validOptions: Object.keys(catalog),\n })\n }\n this.subspec = Spec.parse(this.name, sub)\n this.type = 'catalog'\n return\n }\n\n // legacy affordance: allow project urls like\n // 'https://github.com/user/project#commitish' because npm suports it and\n // this pattern is observed in the wild.\n if (this.bareSpec.startsWith('https://')) {\n for (const [name, origin] of Object.entries(gitHostWebsites)) {\n if (this.bareSpec.startsWith(origin)) {\n const parsed = new URL(this.bareSpec)\n const [user, project] = parsed.pathname\n .replace(/\\.git$/, '')\n .replace(/\\/+/g, ' ')\n .trim()\n .split(' ')\n if (user && project) {\n this.bareSpec = `${name}:${user}/${project}${parsed.hash}`\n this.spec = `${this.name}@${this.bareSpec}`\n break\n }\n }\n }\n }\n\n if (this.bareSpec.startsWith('workspace:')) {\n this.type = 'workspace'\n const ws = this.bareSpec.substring('workspace:'.length).trim()\n const w = ws.lastIndexOf('@')\n if (w === -1) {\n this.workspace = this.name\n } else {\n const wsName = ws.substring(0, w)\n if (\n !wsName ||\n wsName === '*' ||\n wsName === '~' ||\n wsName === '^' ||\n (wsName.startsWith('@') ?\n wsName.split('/').length !== 2 ||\n wsName.substring(1).includes('@')\n : wsName.includes('@'))\n ) {\n throw this.#error(\n 'workspace: name must be a path or valid package name',\n { found: wsName },\n )\n }\n this.workspace = wsName\n }\n // workspace: is the same as workspace:*\n const wss = w === -1 ? ws : ws.substring(w + 1) || '*'\n const range = wss === '*' ? undefined : parseRange(wss)\n if (wss !== '*' && wss !== '~' && wss !== '^' && !range) {\n throw this.#error(\n 'workspace: spec must be one of *, ~, or ^, or a valid semver range',\n {\n found: wss,\n wanted: `'*'|'~'|'^'|SemverRange`,\n },\n )\n }\n this.workspaceSpec = wss\n if (range) {\n this.semver = wss\n this.range = range\n }\n return\n }\n\n if (\n this.bareSpec.startsWith('git://') ||\n this.bareSpec.startsWith('git+ssh://') ||\n this.bareSpec.startsWith('git+http://') ||\n this.bareSpec.startsWith('git+https://') ||\n this.bareSpec.startsWith('git+file://') ||\n // legacy affordance\n this.bareSpec.startsWith('git@github.com')\n ) {\n if (this.bareSpec.startsWith('git@')) {\n this.bareSpec = `git+ssh://${this.bareSpec}`\n this.spec = `${this.name}@${this.bareSpec}`\n }\n this.type = 'git'\n // see if it's one of the known named hosts, and if so, prefer\n // the shorter syntax.\n for (const [name, host] of Object.entries(\n this.options['git-hosts'],\n )) {\n const s = host.indexOf('$')\n if (s > 0 && this.bareSpec.startsWith(host.substring(0, s))) {\n const p = this.bareSpec\n .substring(s)\n .replace(/\\.git(#.*)?$/, '$1')\n this.bareSpec = `${name}:${p}`\n this.spec = `${this.name}@${this.bareSpec}`\n this.#parseHostedGit(name, host)\n this.type = 'git'\n return\n }\n }\n this.#parseGitSelector(this.bareSpec)\n return\n }\n\n // Check registries before git hosts to avoid conflicts\n const regs = Object.entries(this.options.registries)\n if (this.bareSpec.startsWith('registry:')) {\n const reg = this.bareSpec.substring('registry:'.length)\n const h = reg.indexOf('#')\n if (h === -1) {\n throw this.#error('registry: must include name/version')\n }\n this.type = 'registry'\n let url = reg.substring(0, h)\n if (!url.endsWith('/')) url += '/'\n const regSpec = reg.substring(h + 1)\n for (let [name, u] of regs) {\n if (!u.endsWith('/')) {\n u += '/'\n this.options.registries[name] = u\n }\n if (u === url) this.namedRegistry = name\n }\n this.#parseRegistrySpec(regSpec, url)\n this.#guessRegistryTarball()\n return\n }\n\n for (const [host, url] of regs) {\n const h = `${host}:`\n if (this.bareSpec.startsWith(h)) {\n this.type = 'registry'\n this.namedRegistry = host\n this.#parseRegistrySpec(\n this.bareSpec.substring(h.length),\n url,\n ).namedRegistry ??= host\n\n // If we parsed a spec identifier, update the name and spec format\n if (this.subspec && this.name === this.bareSpec) {\n this.name = this.subspec.name\n this.spec = `${this.name}@${this.bareSpec}`\n }\n\n this.#guessRegistryTarball()\n return\n }\n }\n\n // spooky\n const ghosts = Object.entries(this.options['git-hosts'])\n for (const [name, template] of ghosts) {\n if (this.#parseHostedGit(name, template)) {\n this.type = 'git'\n return\n }\n }\n\n const jsrs = Object.entries(this.options['jsr-registries'])\n for (const [host, url] of jsrs) {\n const h = `${host}:`\n if (this.bareSpec.startsWith(h)) {\n this.type = 'registry'\n this.namedJsrRegistry = host\n this.#parseJsrRegistrySpec(\n this.bareSpec.substring(h.length),\n url,\n ).namedJsrRegistry ??= host\n return\n }\n }\n\n if (\n this.bareSpec.startsWith('https://') ||\n this.bareSpec.startsWith('http://')\n ) {\n this.remoteURL = this.bareSpec\n this.type = 'remote'\n return\n }\n\n // explicit file: url\n if (this.bareSpec.startsWith('file:')) {\n this.type = 'file'\n const [path, uri] = getNormalizeFile(\n this.constructor.nodejsDependencies,\n )(this.bareSpec, this)\n this.file = path\n this.bareSpec = uri.replace(/\\/+$/, '')\n this.spec = `${this.name}@${this.bareSpec}`\n return\n }\n\n // legacy! once upon a time, `user/project` was a shorthand for pulling\n // packages from github, instead of the more verbose and explicit\n // `github:user/project`.\n if (\n !this.bareSpec.startsWith('./') &&\n !this.bareSpec.startsWith('../') &&\n this.options['git-hosts'].github\n ) {\n const hash = this.bareSpec.indexOf('#')\n const up =\n hash === -1 ? this.bareSpec : this.bareSpec.substring(0, hash)\n if (up.split('/').length === 2) {\n this.bareSpec = `github:${this.bareSpec}`\n this.spec = `${this.name}@${this.bareSpec}`\n this.#parseHostedGit(\n 'github',\n this.options['git-hosts'].github,\n )\n this.type = 'git'\n return\n }\n }\n\n // if it contains a / and isn't picked up in the github shorthand,\n // then convert to file: specifier\n if (\n this.bareSpec.includes('/') ||\n this.bareSpec === '.' ||\n this.bareSpec === '..'\n ) {\n this.type = 'file'\n const [file, uri] = getNormalizeFile(\n this.constructor.nodejsDependencies,\n )(`file:${this.bareSpec}`, this)\n this.bareSpec = uri\n this.spec = `${this.name}@${this.bareSpec}`\n this.file = file\n return\n }\n\n // at this point, must be either semver range or dist-tag\n this.type = 'registry'\n const range = parseRange(this.bareSpec)\n if (range) {\n this.semver = this.bareSpec.trim()\n this.range = range\n } else {\n this.distTag = this.bareSpec\n }\n this.registrySpec = this.bareSpec\n const { 'scope-registries': scopeRegs, registry } = this.options\n const scopeReg = this.scope && scopeRegs[this.scope]\n this.registry = scopeReg ?? registry\n // no guessing the tarball for JSR registries\n for (const r of Object.values(this.options['jsr-registries'])) {\n if (this.registry === r) return\n }\n this.#guessRegistryTarball()\n }\n\n #parseScope(name: string) {\n if (!name.startsWith('@')) return\n const s = name.indexOf('/')\n if (s > 1 && s < name.length - 1) {\n const scope = name.substring(0, s) as Scope\n this.registry = this.scopeRegistry =\n this.options['scope-registries'][scope]\n this.scope = scope\n }\n }\n\n #parseHostedGit(name: string, template: string) {\n if (this.bareSpec.startsWith(`${name}:`)) {\n const h = this.bareSpec.indexOf('#')\n const bare =\n h === -1 ? this.bareSpec : this.bareSpec.substring(0, h)\n const hash = h === -1 ? '' : this.bareSpec.substring(h)\n const hostPath = bare.substring(name.length + 1)\n if (!hostPath) {\n throw this.#error('invalid named git host specifier')\n }\n const split = hostPath.split('/')\n let t = template\n for (let i = 0; i < split.length; i++) {\n t = t.split(`$${i + 1}`).join(split[i])\n }\n t += hash\n this.namedGitHost = name\n this.namedGitHostPath = hostPath\n this.#parseGitSelector(t)\n if (this.gitCommittish && !this.gitSelectorParsed?.path) {\n const archiveHost = this.options['git-host-archives'][name]\n if (\n name === 'github' &&\n this.gitCommittish.startsWith('pull/') &&\n this.gitCommittish.match(/\\//g)?.length === 1\n ) {\n this.gitCommittish += '/head'\n }\n if (archiveHost) {\n this.type = 'remote'\n let t = archiveHost\n t = t.split('$committish').join(this.gitCommittish)\n for (let i = 0; i < split.length; i++) {\n t = t.split(`$${i + 1}`).join(split[i])\n }\n this.remoteURL = t\n }\n }\n return true\n }\n return false\n }\n\n /* c8 ignore start */\n [kCustomInspect](): string {\n return `@vltpkg/spec.Spec ${String(this)}`\n }\n /* c8 ignore stop */\n\n #guessRegistryTarball() {\n // only try to guess if it's a single comparator for a single version\n const { name, registry, range } = this.final\n if (!registry || !range?.isSingle) return\n const stripScope = /^@[^/]+\\//\n this.conventionalRegistryTarball = String(\n new URL(\n `/${name}/-/${name.replace(stripScope, '')}-${range}.tgz`,\n registry,\n ),\n )\n }\n\n #parseRegistrySpec(s: string, url: string) {\n // note: this takes priority over the scoped registry, if set\n this.registry = url\n this.subspec = this.constructor.parse(s, {\n ...this.options,\n registry: url,\n })\n return this.subspec\n }\n\n #parseJsrRegistrySpec(s: string, url: string) {\n this.registry = url\n // @luca/cases@jsr:1.x\n if (!s.startsWith('@')) s = `${this.name}@${s}`\n const name = `@jsr/${s.replace(/^@/, '').replace(/\\//, '__')}`\n this.subspec = this.constructor.parse(name, {\n ...this.options,\n 'scope-registries': {\n ...this.options['scope-registries'],\n '@jsr': url,\n },\n })\n if (this.name === '(unknown)') {\n const nextAt = s.indexOf('@', 1)\n if (nextAt === -1) {\n this.name = s\n } else {\n this.name = s.substring(0, s.indexOf('@', 1))\n }\n }\n const reg = `${this.namedJsrRegistry}:`\n const n = `${reg}${this.name}`\n if (this.bareSpec.startsWith(n + '@')) {\n this.bareSpec = reg + this.bareSpec.substring(n.length + 1)\n } else if (this.bareSpec === n) {\n this.bareSpec = reg\n }\n this.spec = this.name + '@' + this.bareSpec\n return this.subspec\n }\n\n #error(message: string, extra: ErrorCauseOptions = {}) {\n return error(message, { spec: this.spec, ...extra }, this.#error)\n }\n\n #parseGitSelector(s: string) {\n const h = s.indexOf('#')\n if (h === -1) {\n this.gitRemote = s\n return\n }\n this.gitRemote = s.substring(0, h)\n this.gitSelector = s.substring(h + 1)\n const [selectorParsed, committish, range] =\n this.constructor.parseGitSelector(this.gitSelector, this)\n this.range = range\n this.gitCommittish = committish\n this.gitSelectorParsed = selectorParsed\n }\n\n /**\n * Should only ever be called with the bit that comes AFTER the #\n * in the git remote url.\n */\n static parseGitSelector(\n selector: string,\n spec?: Spec,\n ): [parsed: GitSelectorParsed, committish?: string, range?: Range] {\n if (!selector) return [{}]\n const split = selector.split('::')\n const first = split[0]\n let committish: string | undefined = undefined\n let range: Range | undefined = undefined\n const parsed: GitSelectorParsed = {}\n\n /* c8 ignore start - for TS's benefit */\n if (typeof first !== 'string') {\n throw typeError('impossible', {\n found: first,\n wanted: String,\n })\n }\n /* c8 ignore stop */\n if (!first.includes(':')) {\n committish = first\n split.shift()\n }\n for (const kv of split) {\n const c = kv.indexOf(':')\n /* c8 ignore next */\n if (c === -1) continue\n const k = kv.substring(0, c)\n const v = kv.substring(c + 1)\n if (k === 'semver') {\n if (committish) {\n throw error(\n 'Cannot specify a semver range and committish value',\n { spec },\n )\n }\n range = parseRange(v)\n if (!range) {\n throw error(`Invalid git tag semver range: ${v}`, { spec })\n }\n }\n if (k === 'semver' || k === 'path') {\n if (k === 'path') {\n if (\n /* c8 ignore next */ this.nodejsDependencies?.isAbsolute(\n v,\n ) ||\n /(^|\\/|\\\\)\\.\\.($|\\\\|\\/)/.test(v)\n ) {\n throw error('Invalid path in git selector', { spec })\n }\n // normalize\n /* c8 ignore start */\n parsed.path = (\n this.nodejsDependencies ?\n this.nodejsDependencies.join('/', v).substring(1)\n : v).replace(/\\\\/g, '/')\n /* c8 ignore stop */\n } else {\n parsed[k] = v\n }\n }\n }\n return [parsed, committish, range]\n }\n}\n\n// normalize our kinda-sorta spec compliant `file:` specifiers\n//\n// For historical reasons, we need to support a lot of non-spec-compliant\n// behaviors, but this massages the result into a *slightly* less offensive\n// shape.\n//\n// The result will be either a fully compliant `file://` with an absolute path,\n// or a `file:` with a relative path starting with `~`, `./`, or `../`.\nexport const getNormalizeFile =\n (opts?: NodeJSDependenciesOptions) =>\n (bareSpec: string, spec: Spec): [path: string, uri: string] => {\n const slashes = bareSpec.substring(\n 'file:'.length,\n 'file://'.length,\n )\n const pref = `file:${slashes === '//' ? slashes : ''}`\n const rest = bareSpec.substring(pref.length)\n\n // default to '/' because eol == '/' for parsing purposes\n const [a = '', b = '/', c = '/', d = '/'] = rest.split('', 4)\n\n if (!a) {\n // file:// => file:.\n // file: => file:.\n return ['.', 'file:.']\n }\n\n if (\n (a === '/' && b === '~' && c !== '/') ||\n (a === '~' && b !== '/')\n ) {\n throw error(\n `invalid file: specifier. '~username' not supported`,\n { spec },\n )\n }\n\n if (a === '~') {\n // file://~ => file:~\n // file://~/x => file:~/x\n return /* c8 ignore start */ opts ?\n [\n opts.resolve(opts.homedir(), rest.substring(2)),\n `file:${rest}`,\n ]\n : [rest, `file:${rest}`]\n }\n\n if (a === '/' && b === '~') {\n // file:///~ => file:~\n // file:/~/x => file:~/x\n /* c8 ignore start - tested in test/index.ts */\n return opts ?\n [\n opts.resolve(opts.homedir(), rest.substring(3)),\n `file:${rest.substring(1)}`,\n ]\n : /* c8 ignore stop */\n [rest.substring(1), `file:${rest.substring(1)}`]\n }\n\n if (\n a === '/' &&\n b === '.' &&\n (c === '/' || (c === '.' && d === '/'))\n ) {\n // file:/./x => file:./x\n // file:///./x => file:./x\n // file:/../x => file:../x\n // file://../x => file:../x\n return [rest.substring(1), `file:${rest.substring(1)}`]\n }\n\n if (a === '.' && (b === '/' || (b === '.' && c === '/'))) {\n // file://. => file:.\n // file://./x => file:./x\n // file://../x => file:../x\n return [rest, `file:${rest}`]\n }\n\n if (slashes === '//') {\n // must be valid URI, since we ruled out relative and homedir above\n\n // not relative, but note that file://host/share is\n // windows-specific and does not work on darwin, so disallow it.\n try {\n const parsed = new URL(bareSpec)\n if (parsed.host) {\n if (parsed.host !== 'localhost') {\n throw error(\n `invalid file:// specifier. host must be empty or 'localhost'`,\n {\n spec,\n found: parsed.host,\n validOptions: ['', 'localhost'],\n },\n )\n }\n }\n // normalize blank authority\n // file://X:/foo => file:///X:/foo\n // file://localhost/x => file:///x\n // interpret a `file:///D:/x` as `D:/x` though\n return [\n parsed.pathname.replace(/^\\/([a-zA-Z]:\\/)/, '$1'),\n `file://${parsed.pathname}`,\n ]\n } catch (er) {\n // invalid URI for other reasons, eg file://x\\u0000y/z\n throw error('invalid file:// specifier', {\n spec,\n cause: er,\n })\n }\n }\n\n // no //, no authority, be ungovernable\n\n /* c8 ignore start */\n if (opts?.winPath.isAbsolute(rest)) {\n // file:/absolute => file:///absolute\n // file:/D:/foo => file:///D:/foo\n return [rest, `file://${rest}`]\n }\n /* c8 ignore stop */\n\n // file:x => file:./x\n return [`./${rest}`, `file:./${rest}`]\n }\n"]}
import type { InspectOptions } from 'node:util';
import type { SpecLike } from './browser.ts';
import { Spec as BrowserSpec, kCustomInspect } from './browser.ts';
export * from './browser.ts';
export declare class Spec extends BrowserSpec implements SpecLike<Spec> {
[kCustomInspect](_depth?: number, options?: InspectOptions): string;
}
//# sourceMappingURL=index.d.ts.map
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC/C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C,OAAO,EAAE,IAAI,IAAI,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAGlE,cAAc,cAAc,CAAA;AAG5B,qBAAa,IAAK,SAAQ,WAAY,YAAW,QAAQ,CAAC,IAAI,CAAC;IAC7D,CAAC,cAAc,CAAC,CACd,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,cAAc,GACvB,MAAM;CAWV"}
import { homedir } from 'node:os';
import { isAbsolute, join, resolve, win32 as winPath, } from 'node:path';
import { inspect } from 'node:util';
import { Spec as BrowserSpec, kCustomInspect } from "./browser.js";
// eslint-disable-next-line import/export
export * from "./browser.js";
// eslint-disable-next-line import/export
export class Spec extends BrowserSpec {
[kCustomInspect](_depth, options) {
const str = inspect(Object.fromEntries(Object.entries(this).filter(([k, v]) => {
return k !== 'options' && v !== undefined;
})), options);
return `@vltpkg/spec.Spec ${str}`;
}
}
Spec.nodejsDependencies = {
homedir,
isAbsolute,
join,
resolve,
winPath,
};
//# sourceMappingURL=index.js.map
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EACL,UAAU,EACV,IAAI,EACJ,OAAO,EACP,KAAK,IAAI,OAAO,GACjB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAGnC,OAAO,EAAE,IAAI,IAAI,WAAW,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAElE,yCAAyC;AACzC,cAAc,cAAc,CAAA;AAE5B,yCAAyC;AACzC,MAAM,OAAO,IAAK,SAAQ,WAAW;IACnC,CAAC,cAAc,CAAC,CACd,MAAe,EACf,OAAwB;QAExB,MAAM,GAAG,GAAG,OAAO,CACjB,MAAM,CAAC,WAAW,CAChB,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;YACrC,OAAO,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,CAAA;QAC3C,CAAC,CAAC,CACH,EACD,OAAO,CACR,CAAA;QACD,OAAO,qBAAqB,GAAG,EAAE,CAAA;IACnC,CAAC;CACF;AAED,IAAI,CAAC,kBAAkB,GAAG;IACxB,OAAO;IACP,UAAU;IACV,IAAI;IACJ,OAAO;IACP,OAAO;CACR,CAAA","sourcesContent":["import { homedir } from 'node:os'\nimport {\n isAbsolute,\n join,\n resolve,\n win32 as winPath,\n} from 'node:path'\nimport { inspect } from 'node:util'\nimport type { InspectOptions } from 'node:util'\nimport type { SpecLike } from './browser.ts'\nimport { Spec as BrowserSpec, kCustomInspect } from './browser.ts'\n\n// eslint-disable-next-line import/export\nexport * from './browser.ts'\n\n// eslint-disable-next-line import/export\nexport class Spec extends BrowserSpec implements SpecLike<Spec> {\n [kCustomInspect](\n _depth?: number,\n options?: InspectOptions,\n ): string {\n const str = inspect(\n Object.fromEntries(\n Object.entries(this).filter(([k, v]) => {\n return k !== 'options' && v !== undefined\n }),\n ),\n options,\n )\n return `@vltpkg/spec.Spec ${str}`\n }\n}\n\nSpec.nodejsDependencies = {\n homedir,\n isAbsolute,\n join,\n resolve,\n winPath,\n}\n"]}
{
"type": "module"
}
import type { Range } from '@vltpkg/semver';
export type SpecOptions = {
[k in keyof SpecOptionsFilled]?: SpecOptionsFilled[k];
};
export type Scope = `@${string}`;
export type SpecOptionsFilled = {
/** the registry where a spec should be resolved against */
registry: string;
/** shorthand prefix names for known registries */
registries: Record<string, string>;
/** shorthand prefix names for known git hosts */
'git-hosts': Record<string, string>;
/** tarball hosting services for hosts listed in git-hosts */
'git-host-archives': Record<string, string>;
/** registries mapped to a `@scope` */
'scope-registries': Record<Scope, string>;
/** registries that work like https://npm.jsr.io */
'jsr-registries': Record<string, string>;
catalog: Record<string, string>;
catalogs?: Record<string, Record<string, string>>;
};
export type GitSelectorParsed = {
path?: string;
semver?: string;
};
export type SpecType = 'file' | 'git' | 'registry' | 'remote' | 'workspace' | 'catalog';
export type SpecLikeBase = {
/** the type of spec that this is, ultimately */
type: SpecType;
/** the full named specifier passed to the constructor */
spec: string;
/** options passed to the constructor, plus defaults */
options: SpecOptionsFilled;
/** the name portion, so `foo` in `foo@1.x` */
name: string;
/** the name's scope, so `@acme` in `@acme/foo@1.x` */
scope?: Scope;
/**
* if the name is scoped, and there's a registry associated with the scope,
* then this is that registry
*/
scopeRegistry?: string;
/** just the part AFTER the name, so `1.x` in `foo@1.x` */
bareSpec: string;
/** the git remote to fetch from */
gitRemote?: string;
/** the committish, semver range, and/or path portion of a git remote */
gitSelector?: string;
/**
* the parsed '::'-separated key/value pairs:
* `semver:<range>` and `path:<subpath>`
*/
gitSelectorParsed?: GitSelectorParsed;
/** the commit value we will check out */
gitCommittish?: string;
/** github, gitlab, bitbucket, gist, etc. */
namedGitHost?: string;
/** the path that's parsed when we have a named git host */
namedGitHostPath?: string;
/**
* the specifier when using `workspace:` specs
* This can be either a semver range, `*`, `~`, or `^`,
* if the name is not modified. Or, it can include a workspace
* package name or path, like `workspace:packages/foo@*` or
* `workspace:@scope/foo@*`.
*/
workspaceSpec?: string;
/**
* the package name or path of the workspace being referenced
*/
workspace?: string;
/**
* In specs like `foo@npm:bar@1`, this is the 'npm' part. Other
* registries can be mapped using the `registries` option.
*/
namedRegistry?: string;
/** registry to consult to resolve this spec */
registry?: string;
/** semver range or dist-tag for resolving against a packument */
registrySpec?: string;
/**
* conventional location of the tarball on the registry, if it can be
* guessed. This is only attempted if the spec is a registry type, with a
* single version comparator. This can be used to elide resolved urls that
* are repetitive and predictable.
*/
conventionalRegistryTarball?: string;
/** spec to resolve against available versions */
semver?: string;
/** parsed semver range specifier */
range?: Range;
/** a dist-tag like 'latest' */
distTag?: string;
/**
* URL to download a tarball from, if it can be determined.
*
* This is set for url specs of course, but also git remotes on known
* hosts that provide a gitHostArchive template.
*/
remoteURL?: string;
/** file path for file:// url specs */
file?: string;
/** in `bar@npm:foo@1.x`, this is the spec for `foo@1.x` */
subspec?: SpecLikeBase;
/**
* getter that retrieves the actual spec value to be used
*/
final: SpecLikeBase;
/** Is this a spec that overrides another spec? */
overridden: boolean;
toString(): string;
};
export type SpecLike<Type extends SpecLikeBase> = SpecLikeBase & {
subspec?: Type;
final: Type;
};
//# sourceMappingURL=types.d.ts.map
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAE3C,MAAM,MAAM,WAAW,GAAG;KACvB,CAAC,IAAI,MAAM,iBAAiB,CAAC,CAAC,EAAE,iBAAiB,CAAC,CAAC,CAAC;CACtD,CAAA;AAED,MAAM,MAAM,KAAK,GAAG,IAAI,MAAM,EAAE,CAAA;AAEhC,MAAM,MAAM,iBAAiB,GAAG;IAC9B,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAA;IAChB,kDAAkD;IAClD,UAAU,EAAE,MAAM,C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,iBAAiB,CAAA;IACrC,yCAAyC;IACzC,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,4CAA4C;IAC5C,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAEzB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB,iEAAiE;IACjE,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;;OAKG;IACH,2BAA2B,CAAC,EAAE,MAAM,CAAA;IAEpC,iDAAiD;IACjD,MAAM,CAAC,EAAE,MAAM,CAAA;IAEf,oCAAoC;IACpC,KAAK,CAAC,EAAE,KAAK,CAAA;IAEb,+BAA+B;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAA;IAEhB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,sCAAsC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,2DAA2D;IAC3D,OAAO,CAAC,EAAE,YAAY,CAAA;IACtB;;OAEG;IACH,KAAK,EAAE,YAAY,CAAA;IACnB,kDAAkD;IAClD,UAAU,EAAE,OAAO,CAAA;IAEnB,QAAQ,IAAI,MAAM,CAAA;CACnB,CAAA;AAED,MAAM,MAAM,QAAQ,CAAC,IAAI,SAAS,YAAY,IAAI,YAAY,GAAG;IAC/D,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,KAAK,EAAE,IAAI,CAAA;CACZ,CAAA"}
export {};
//# sourceMappingURL=types.js.map
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Range } from '@vltpkg/semver'\n\nexport type SpecOptions = {\n [k in keyof SpecOptionsFilled]?: SpecOptionsFilled[k]\n}\n\nexport type Scope = `@${string}`\n\nexport type SpecOptionsFilled = {\n /** the registry where a spec should be resolved against */\n registry: string\n /** shorthand prefix names for known registries */\n registries: Record<string, string>\n /** shorthand prefix names for known git hosts */\n 'git-hosts': Record<string, string>\n /** tarball hosting services for hosts listed in git-hosts */\n 'git-host-archives': Record<string, string>\n /** registries mapped to a `@scope` */\n 'scope-registries': Record<Scope, string>\n /** registries that work like https://npm.jsr.io */\n 'jsr-registries': Record<string, string>\n catalog: Record<string, string>\n catalogs?: Record<string, Record<string, string>>\n}\n\nexport type GitSelectorParsed = {\n path?: string\n semver?: string\n}\n\nexport type SpecType =\n | 'file'\n | 'git'\n | 'registry'\n | 'remote'\n | 'workspace'\n | 'catalog'\n\nexport type SpecLikeBase = {\n /** the type of spec that this is, ultimately */\n type: SpecType\n\n /** the full named specifier passed to the constructor */\n spec: string\n\n /** options passed to the constructor, plus defaults */\n options: SpecOptionsFilled\n\n /** the name portion, so `foo` in `foo@1.x` */\n name: string\n\n /** the name's scope, so `@acme` in `@acme/foo@1.x` */\n scope?: Scope\n\n /**\n * if the name is scoped, and there's a registry associated with the scope,\n * then this is that registry\n */\n scopeRegistry?: string\n\n /** just the part AFTER the name, so `1.x` in `foo@1.x` */\n bareSpec: string\n\n /** the git remote to fetch from */\n gitRemote?: string\n\n /** the committish, semver range, and/or path portion of a git remote */\n gitSelector?: string\n /**\n * the parsed '::'-separated key/value pairs:\n * `semver:<range>` and `path:<subpath>`\n */\n gitSelectorParsed?: GitSelectorParsed\n /** the commit value we will check out */\n gitCommittish?: string\n /** github, gitlab, bitbucket, gist, etc. */\n namedGitHost?: string\n /** the path that's parsed when we have a named git host */\n namedGitHostPath?: string\n\n /**\n * the specifier when using `workspace:` specs\n * This can be either a semver range, `*`, `~`, or `^`,\n * if the name is not modified. Or, it can include a workspace\n * package name or path, like `workspace:packages/foo@*` or\n * `workspace:@scope/foo@*`.\n */\n workspaceSpec?: string\n\n /**\n * the package name or path of the workspace being referenced\n */\n workspace?: string\n\n /**\n * In specs like `foo@npm:bar@1`, this is the 'npm' part. Other\n * registries can be mapped using the `registries` option.\n */\n namedRegistry?: string\n\n /** registry to consult to resolve this spec */\n registry?: string\n\n /** semver range or dist-tag for resolving against a packument */\n registrySpec?: string\n\n /**\n * conventional location of the tarball on the registry, if it can be\n * guessed. This is only attempted if the spec is a registry type, with a\n * single version comparator. This can be used to elide resolved urls that\n * are repetitive and predictable.\n */\n conventionalRegistryTarball?: string\n\n /** spec to resolve against available versions */\n semver?: string\n\n /** parsed semver range specifier */\n range?: Range\n\n /** a dist-tag like 'latest' */\n distTag?: string\n\n /**\n * URL to download a tarball from, if it can be determined.\n *\n * This is set for url specs of course, but also git remotes on known\n * hosts that provide a gitHostArchive template.\n */\n remoteURL?: string\n\n /** file path for file:// url specs */\n file?: string\n\n /** in `bar@npm:foo@1.x`, this is the spec for `foo@1.x` */\n subspec?: SpecLikeBase\n /**\n * getter that retrieves the actual spec value to be used\n */\n final: SpecLikeBase\n /** Is this a spec that overrides another spec? */\n overridden: boolean\n\n toString(): string\n}\n\nexport type SpecLike<Type extends SpecLikeBase> = SpecLikeBase & {\n subspec?: Type\n final: Type\n}\n"]}