Documentation
¶
Index ¶
- type Config
- type Import
- type ImportMap
- func (im *ImportMap) AddImport(imp ImportMeta, noSRI bool) (warnings []string, errors []error)
- func (im *ImportMap) AddImportFromSpecifier(specifier string, noSRI bool) (warnings []string, errors []error)
- func (im *ImportMap) Config() Config
- func (im *ImportMap) FetchImportMeta(imp Import) (meta ImportMeta, err error)
- func (im *ImportMap) FormatJSON(indent int) string
- func (im *ImportMap) GetScopeImports(scope string) (*Imports, bool)
- func (im *ImportMap) Integrity() *Imports
- func (im *ImportMap) MarshalJSON() ([]byte, error)
- func (im *ImportMap) ParseImport(specifier string) (meta ImportMeta, err error)
- func (im *ImportMap) RangeScopes(fn func(scope string, imports *Imports) bool)
- func (im *ImportMap) Resolve(specifier string, referrer *url.URL) (string, bool)
- func (im *ImportMap) SetConfig(config Config)
- func (im *ImportMap) SetIntegrity(integrity *Imports)
- func (im *ImportMap) SetScopeImports(scope string, imports *Imports)
- type ImportMapJson
- type ImportMeta
- type Imports
- func (i *Imports) Delete(specifier string)
- func (i *Imports) Get(specifier string) (string, bool)
- func (i *Imports) Has(specifier string) bool
- func (i *Imports) Keys() []string
- func (i *Imports) Len() int
- func (i *Imports) Range(fn func(specifier string, url string) bool)
- func (i *Imports) Set(specifier string, url string)
- type ScopeKeys
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Import ¶
type Import struct {
Name string `json:"name"`
Version string `json:"version"`
SubPath string `json:"-"`
Github bool `json:"-"`
Jsr bool `json:"-"`
External bool `json:"-"`
Dev bool `json:"-"`
}
Import represents an import from esm.sh CDN.
func ParseEsmPath ¶
ParseEsmPath parses an import from a pathname or URL.
func (Import) RegistryPrefix ¶
type ImportMap ¶
type ImportMap struct {
Imports *Imports
// contains filtered or unexported fields
}
ImportMap represents an import maps that follows the import maps specification: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap
func (*ImportMap) AddImport ¶
func (im *ImportMap) AddImport(imp ImportMeta, noSRI bool) (warnings []string, errors []error)
AddImport adds an import to the import map.
func (*ImportMap) AddImportFromSpecifier ¶
func (im *ImportMap) AddImportFromSpecifier(specifier string, noSRI bool) (warnings []string, errors []error)
AddImportFromSpecifier adds an import from a specifier to the import map.
func (*ImportMap) FetchImportMeta ¶
func (im *ImportMap) FetchImportMeta(imp Import) (meta ImportMeta, err error)
func (*ImportMap) FormatJSON ¶
FormatJSON formats the import map as a JSON string.
func (*ImportMap) GetScopeImports ¶
GetScopeImports returns the imports of the given scope.
func (*ImportMap) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*ImportMap) ParseImport ¶
func (im *ImportMap) ParseImport(specifier string) (meta ImportMeta, err error)
ParseImport gets the import metadata from a specifier. Currently, it supports the following specifiers: - npm:package[@semver][/subpath] - jsr:scope/package[@semver][/subpath] - github:owner/repo[@<branch|tag|commit>][/subpath]
func (*ImportMap) RangeScopes ¶
RangeScopes ranges over the scopes of the import map.
func (*ImportMap) Resolve ¶
Resolve resolves a specifier to a URL. It returns the URL and a boolean indicating if the specifier was found. This function follows the import maps specification: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/script/type/importmap
func (*ImportMap) SetIntegrity ¶
SetIntegrity sets the integrity of the import map.
func (*ImportMap) SetScopeImports ¶
SetScopeImports sets the imports of the given scope.
type ImportMapJson ¶
type ImportMapJson struct {
Config Config `json:"config"`
Imports map[string]string `json:"imports,omitempty"`
Scopes map[string]map[string]string `json:"scopes,omitempty"`
Integrity map[string]string `json:"integrity,omitempty"`
}
ImportMapJson represents the JSON structure of an import map.
type ImportMeta ¶
type ImportMeta struct {
Import
Module string `json:"module"`
Integrity string `json:"integrity"` // "sha384-..."
Exports []string `json:"exports"`
Imports []string `json:"imports"`
PeerImports []string `json:"peerImports"`
}
ImportMeta represents the import metadata of a import.
func (*ImportMeta) EsmSpecifier ¶
func (imp *ImportMeta) EsmSpecifier() string
EsmSpecifier returns the esm specifier of the import meta.
func (*ImportMeta) HasExternalImports ¶
func (imp *ImportMeta) HasExternalImports() bool
HasExternalImports returns true if the import has external imports.
type Imports ¶
type Imports struct {
// contains filtered or unexported fields
}
Imports represents a map of imports.