Abstracta record type representing the package schema.
the parsed package metadata as an object.
Protected Readonlypackagethe path or url of the package json(c) file.
the base class does nothing with this information; it is just there so that subclasses can make uses of this information (usually for resolving relative paths).
Protected Readonlypackagethe fetched/parsed package metadata file's raw contents.
Protected Abstractimportthe import-map entries of the package, sorted from the largest key-alias to the shortest.
each subclass will have to assign on their own, in addition to ensuring the required sorting order.
Protected Abstractexportthe export-map entries of the package, sorted from the largest key-alias to the shortest.
each subclass will have to assign on their own, in addition to ensuring the required sorting order.
Abstractgetget the package's name.
Abstractgetget the package's version string.
get the path/url to the package's json(c) file.
the base class does nothing with this information; it is just there so that subclasses can make uses of this information (usually for resolving relative paths).
this method tries to resolve the provided export path_alias of this package,
to an absolutely referenced path to the resource (using the internal exportMapSortedEntries).
if no exported resources match the given path_alias, then undefined will be returned.
for test case examples and configuration options, see the documentation comments of resolvePathFromImportMapEntries
Optionalconfig: Partial<RuntimePackageResolveImportConfig>this method tries to resolve the provided import path_alias done by some resource within this package,
using the internal importMapSortedEntries list of import-aliases that this package uses.
if no import resources match the given path_alias, then undefined will be returned
(which would probably mean that the given path_alias is already either an absolute or relative path, or perhaps incorrect altogether.
for test case examples and configuration options, see the documentation comments of resolvePathFromImportMapEntries
Optionalconfig: Partial<RuntimePackageResolveImportConfig>Staticfromcreate an instance of this class by loading a package's json(c) file from a url or local file-system path.
the resulting new instance is cached (memorized), so that it can be reused if another query with the same normalized path is provided.
why are we forcing a cache mechanism on the base class?
because the workspace children/parents, in the WorkspacePackage subclass, are referenced by their absolute path, and resolving an import through a workspace package would involve the creation of that child/parent runtime package via this method, thus leading to an exponential number of redundant re-creation of identical package manager objects.
the constructor uses a "JSONC" parser (from @oazmi/kitchensink/stringman) for the fetched files. therefore, you may provide links to ".jsonc" files, instead of parsing them yourself before calling the super constructor.
an abstraction for import-map utilities of a general javascript runtime's package object with the schema
SCHEMA.SCHEMAwould representpackage.json's schema.SCHEMAwould representdeno.json,deno.jsonc, orjsr.json's schema.