pub struct EszipV2 { /* private fields */ }
Expand description
Version 2 of the Eszip format. This format supports streaming sources and source maps.
Implementations§
source§impl EszipV2
impl EszipV2
pub fn has_magic(buffer: &[u8]) -> bool
sourcepub async fn parse<R: AsyncRead + Unpin>(
reader: BufReader<R>
) -> Result<(EszipV2, impl Future<Output = Result<BufReader<R>, ParseError>>), ParseError>
pub async fn parse<R: AsyncRead + Unpin>( reader: BufReader<R> ) -> Result<(EszipV2, impl Future<Output = Result<BufReader<R>, ParseError>>), ParseError>
Parse a EszipV2 from an AsyncRead stream. This function returns once the header section of the eszip has been parsed. Once this function returns, the data section will not necessarially have been parsed yet. To parse the data section, poll/await the future returned in the second tuple slot.
sourcepub fn add_import_map(
&mut self,
kind: ModuleKind,
specifier: String,
source: Arc<[u8]>
)
pub fn add_import_map( &mut self, kind: ModuleKind, specifier: String, source: Arc<[u8]> )
Add an import map to the eszip archive. The import map will always be placed at the top of the archive, so it can be read before any other modules are loaded.
If a module with this specifier is already present, then this is a no-op (except that this specifier will now be at the top of the archive).
sourcepub fn add_opaque_data(&mut self, specifier: String, data: Arc<[u8]>)
pub fn add_opaque_data(&mut self, specifier: String, data: Arc<[u8]>)
Add an opaque data to the eszip.
sourcepub fn add_npm_snapshot(
&mut self,
snapshot: ValidSerializedNpmResolutionSnapshot
)
pub fn add_npm_snapshot( &mut self, snapshot: ValidSerializedNpmResolutionSnapshot )
Adds an npm resolution snapshot to the eszip.
sourcepub fn take_npm_snapshot(
&mut self
) -> Option<ValidSerializedNpmResolutionSnapshot>
pub fn take_npm_snapshot( &mut self ) -> Option<ValidSerializedNpmResolutionSnapshot>
Takes an npm resolution snapshot from the eszip.
sourcepub fn into_bytes(self) -> Vec<u8> ⓘ
pub fn into_bytes(self) -> Vec<u8> ⓘ
Serialize the eszip archive into a byte buffer.
sourcepub fn from_graph(
graph: ModuleGraph,
parser: &CapturingModuleParser<'_>,
emit_options: EmitOptions
) -> Result<Self, Error>
pub fn from_graph( graph: ModuleGraph, parser: &CapturingModuleParser<'_>, emit_options: EmitOptions ) -> Result<Self, Error>
Turn a deno_graph::ModuleGraph into an EszipV2. All modules from the graph will be transpiled and stored in the eszip archive.
The ordering of the modules in the graph is dependant on the module graph tree. The root module is added to the top of the archive, and the leaves to the end. This allows for efficient deserialization of the archive right into an isolate.
sourcepub fn get_module(&self, specifier: &str) -> Option<Module>
pub fn get_module(&self, specifier: &str) -> Option<Module>
Get the module metadata for a given module specifier. This function will follow redirects. The returned module has functions that can be used to obtain the module source and source map. The module returned from this function is guaranteed to be a valid module, which can be loaded into v8.
Note that this function should be used to obtain a module; if you wish to
get an import map, use get_import_map
instead.
sourcepub fn get_import_map(&self, specifier: &str) -> Option<Module>
pub fn get_import_map(&self, specifier: &str) -> Option<Module>
Get the import map for a given specifier.
Note that this function should be used to obtain an import map; the returned
“Module” is not necessarily a valid module that can be loaded into v8 (in
other words, JSONC may be returned). If you wish to get a valid module,
use get_module
instead.
sourcepub fn specifiers(&self) -> Vec<String>
pub fn specifiers(&self) -> Vec<String>
Returns a list of all the module specifiers in this eszip archive.
Trait Implementations§
source§impl IntoIterator for EszipV2
impl IntoIterator for EszipV2
Get an iterator over all the modules (including an import map, if any) in this eszip archive.
Note that the iterator will iterate over the specifiers’ “snapshot” of the
archive. If a new module is added to the archive after the iterator is
created via into_iter()
, that module will not be iterated over.