pub struct Worker { /* private fields */ }Expand description
A running worker. Dropping it closes Node’s stdin, waits up to 2 s for it to exit, then kills it.
Implementations§
Source§impl Worker
impl Worker
Sourcepub fn start(
node: &NodeInfo,
root: &Path,
run_mode: RunMode,
) -> Result<Worker, WorkerError>
pub fn start( node: &NodeInfo, root: &Path, run_mode: RunMode, ) -> Result<Worker, WorkerError>
Start Node with the worker, in root (the project folder), with
11ty’s environment variables added to Brrrty’s own.
Sourcepub fn set_cli_dirs(&mut self, input: Option<String>, output: Option<String>)
pub fn set_cli_dirs(&mut self, input: Option<String>, output: Option<String>)
The --input and --output flags: the config sees them in directories, as 11ty’s
command line wins over the config for it.
Sourcepub fn start_with(
node: &NodeInfo,
root: &Path,
run_mode: RunMode,
order_check: bool,
) -> Result<Worker, WorkerError>
pub fn start_with( node: &NodeInfo, root: &Path, run_mode: RunMode, order_check: bool, ) -> Result<Worker, WorkerError>
Worker::start, with or without the replay check: without it
the site’s JavaScript runs once, in this worker’s Node alone, and
nothing is kept of the calls to run them again.
Sourcepub fn set_notes(
&mut self,
notes: impl Fn(&str) + Send + 'static,
first: Duration,
next: Duration,
)
pub fn set_notes( &mut self, notes: impl Fn(&str) + Send + 'static, first: Duration, next: Duration, )
Send slow-request notes to notes instead of stderr, the first
after first and then every next (tests).
Sourcepub fn exports_frozen(&self) -> Result<(), String>
pub fn exports_frozen(&self) -> Result<(), String>
Whether the worker froze the data files’ values when the pages’
calls began (Ok), or walks them after every call, and why (Err).
Trait Implementations§
Source§impl JsRuntime for Worker
impl JsRuntime for Worker
Source§fn front_matter(
&mut self,
code: &str,
file: &Path,
input_path: &str,
) -> JsResult<Decoded>
fn front_matter( &mut self, code: &str, file: &Path, input_path: &str, ) -> JsResult<Decoded>
Evaluate the ---js front matter code of file the way 11ty 3 does.
Source§fn set_argument(&mut self, arg: &Value) -> JsResult<()>
fn set_argument(&mut self, arg: &Value) -> JsResult<()>
addGlobalData values and
eleventy), sent once before any file loads.Source§fn load(&mut self, file: &Path, call: bool) -> JsResult<Decoded>
fn load(&mut self, file: &Path, call: bool) -> JsResult<Decoded>
file (absolute) as 11ty does; when call and the export is
a function, call it with the argument and await it.Source§fn load_config(&mut self, file: &Path) -> JsResult<Decoded>
fn load_config(&mut self, file: &Path) -> JsResult<Decoded>
eleventyConfig. The value is
{ returned, values, functions, unsupported }.Source§fn call(
&mut self,
f: FnHandle,
this: This<'_>,
args: &[Value],
settle: Settle,
) -> JsResult<Decoded>
fn call( &mut self, f: FnHandle, this: This<'_>, args: &[Value], settle: Settle, ) -> JsResult<Decoded>
this and args.Source§fn begin(&mut self, op: Op<'_>, filters: &mut FilterCall<'_>) -> Begun
fn begin(&mut self, op: Op<'_>, filters: &mut FilterCall<'_>) -> Begun
Begun::Sent: the render threads then wait for
their results at the same time, and the runtime never waits on
Brrrty between one request and the next. Any other runs it here.Source§fn finish(&mut self, waited: Waited) -> Finished
fn finish(&mut self, waited: Waited) -> Finished
JsRuntime::begin sent.Source§fn page_open(
&mut self,
data: &Value,
traps: &[(String, String)],
defaults: &[String],
) -> JsResult<PageId>
fn page_open( &mut self, data: &Value, traps: &[(String, String)], defaults: &[String], ) -> JsResult<PageId>
data as a page’s data object. Each of traps (a top-level
key and why) is a key Brrrty can’t supply: reading it refuses the
call. Each of defaults (a dotted computed key) that is undefined
is set to "", as 11ty’s computed data proxy does.Source§fn page_vars(
&mut self,
page: PageId,
f: FnHandle,
keys: &[String],
) -> JsResult<Vec<String>>
fn page_vars( &mut self, page: PageId, f: FnHandle, keys: &[String], ) -> JsResult<Vec<String>>
f reads of the page’s data, as 11ty’s
ComputedDataProxy.findVarsUsed finds them (keys are the page’s
computed keys).Source§fn page_call(
&mut self,
page: PageId,
f: FnHandle,
set: Option<&str>,
) -> JsResult<Decoded>
fn page_call( &mut self, page: PageId, f: FnHandle, set: Option<&str>, ) -> JsResult<Decoded>
f with the page’s data, as 11ty calls a computed function or
a permalink function, awaiting it; with set, store the result at
that dotted key of the page’s data.Source§fn page_set(&mut self, page: PageId, key: &str, value: &Value) -> JsResult<()>
fn page_set(&mut self, page: PageId, key: &str, value: &Value) -> JsResult<()>
lodash.set does.Source§fn page_close(&mut self, page: PageId)
fn page_close(&mut self, page: PageId)
Source§fn page_once(
&mut self,
data: &Value,
traps: &[(String, String)],
defaults: &[String],
f: FnHandle,
) -> JsResult<Decoded>
fn page_once( &mut self, data: &Value, traps: &[(String, String)], defaults: &[String], f: FnHandle, ) -> JsResult<Decoded>
JsRuntime::page_open, one JsRuntime::page_call of f with
nothing set, and JsRuntime::page_close: a permalink function
called for a page with no computed data open.Source§fn page_run(
&mut self,
page: PageId,
steps: &[PageStep<'_>],
) -> Vec<JsResult<Decoded>>
fn page_run( &mut self, page: PageId, steps: &[PageStep<'_>], ) -> Vec<JsResult<Decoded>>
steps in order, each as JsRuntime::page_call or
JsRuntime::page_set would run it. The list ends with the first
result that isn’t a value (a runtime may have run the steps after
it all the same: nothing is made of them).Source§fn loads_changed(&mut self) -> JsResult<Vec<(PathBuf, Decoded)>>
fn loads_changed(&mut self) -> JsResult<Vec<(PathBuf, Decoded)>>
Source§fn begin_calls(&mut self) -> JsResult<()>
fn begin_calls(&mut self) -> JsResult<()>
Refused when a template or directory data file changed a value
another file gave, or a built-in prototype.Source§fn set_filters(&mut self, filters: Filters)
fn set_filters(&mut self, filters: Filters)
this (a template, a
computed or permalink function): (name, arguments).Source§fn template_setup(
&mut self,
filters: &[String],
node: &[(String, u32)],
) -> JsResult<()>
fn template_setup( &mut self, filters: &[String], node: &[(String, u32)], ) -> JsResult<()>
this as functions
(its filters and shortcodes), in its order. Sent before any template
loads.Source§fn load_template(
&mut self,
file: &Path,
layout: bool,
) -> JsResult<LoadedTemplate>
fn load_template( &mut self, file: &Path, layout: bool, ) -> JsResult<LoadedTemplate>
file (absolute) as 11ty
does, make its instance, and read its data.Source§fn load_custom_template(
&mut self,
file: &Path,
ext: &str,
content: &str,
) -> JsResult<LoadedTemplate>
fn load_custom_template( &mut self, file: &Path, ext: &str, content: &str, ) -> JsResult<LoadedTemplate>
file (absolute), a file of the custom extension ext the JS config
added (addExtension): its content (the file without its front matter) goes to the
extension’s compile, and the page’s data to the render function that makes.Source§fn render(
&mut self,
template: TemplateId,
data: &Value,
first: Option<&Value>,
traps: &[(String, String)],
filters: &mut FilterCall<'_>,
) -> JsResult<Decoded>
fn render( &mut self, template: TemplateId, data: &Value, first: Option<&Value>, traps: &[(String, String)], filters: &mut FilterCall<'_>, ) -> JsResult<Decoded>
data (for a layout, with
content), as 11ty’s JavaScript engine does: first is the page
11ty’s first render of it set as this.page. Each of traps (a
top-level key and why) is a key Brrrty can’t supply. A filter the
template calls on this runs as filters(name, arguments); Err
refuses the render with why.Source§fn verify(&mut self) -> JsResult<()>
fn verify(&mut self) -> JsResult<()>
Refused (marked impure) names the first
difference.Source§fn reads(&mut self) -> JsResult<Vec<PathBuf>>
fn reads(&mut self) -> JsResult<Vec<PathBuf>>
Source§fn page_open_with_vars(
&mut self,
data: &Value,
traps: &[(String, String)],
defaults: &[String],
functions: &[FnHandle],
keys: &[String],
) -> JsResult<(PageId, Vec<Vec<String>>)>
fn page_open_with_vars( &mut self, data: &Value, traps: &[(String, String)], defaults: &[String], functions: &[FnHandle], keys: &[String], ) -> JsResult<(PageId, Vec<Vec<String>>)>
JsRuntime::page_open, then JsRuntime::page_vars of each of
functions in order: the page, and what each reads. When one of
them gives no list, the page is closed and that is the result.