async.js — svelte Source File
Architecture documentation for async.js, a javascript file in the svelte codebase. 13 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 0ae9bf62_aa68_bcd6_7a5c_a9620e877659["async.js"] 1ad3e508_c069_abae_2e4a_bd17c8892e18["async.js"] 0ae9bf62_aa68_bcd6_7a5c_a9620e877659 --> 1ad3e508_c069_abae_2e4a_bd17c8892e18 b9aaaccb_7510_28de_bb53_f808b2cb1d5e["flatten"] 0ae9bf62_aa68_bcd6_7a5c_a9620e877659 --> b9aaaccb_7510_28de_bb53_f808b2cb1d5e d8e42d9d_2e3c_635c_19d3_b946a4341c0f["batch.js"] 0ae9bf62_aa68_bcd6_7a5c_a9620e877659 --> d8e42d9d_2e3c_635c_19d3_b946a4341c0f 517c145b_769f_b163_6854_d8f2a4412e11["Batch"] 0ae9bf62_aa68_bcd6_7a5c_a9620e877659 --> 517c145b_769f_b163_6854_d8f2a4412e11 bde4209f_8ffc_1594_4024_b1835a44bcf6["runtime.js"] 0ae9bf62_aa68_bcd6_7a5c_a9620e877659 --> bde4209f_8ffc_1594_4024_b1835a44bcf6 a08b6cc5_af73_1be4_d02f_3113cf8a8305["get"] 0ae9bf62_aa68_bcd6_7a5c_a9620e877659 --> a08b6cc5_af73_1be4_d02f_3113cf8a8305 f3948b0d_b92a_0767_ba6c_832767f4e2bb["hydration.js"] 0ae9bf62_aa68_bcd6_7a5c_a9620e877659 --> f3948b0d_b92a_0767_ba6c_832767f4e2bb b31601aa_35ce_7827_5394_99fb97fa27d2["hydrate_next"] 0ae9bf62_aa68_bcd6_7a5c_a9620e877659 --> b31601aa_35ce_7827_5394_99fb97fa27d2 40f27ad3_30bb_8f2a_3fb3_757088cf7428["set_hydrate_node"] 0ae9bf62_aa68_bcd6_7a5c_a9620e877659 --> 40f27ad3_30bb_8f2a_3fb3_757088cf7428 f5b61c69_d41c_bdb7_b931_5b8b3374332c["set_hydrating"] 0ae9bf62_aa68_bcd6_7a5c_a9620e877659 --> f5b61c69_d41c_bdb7_b931_5b8b3374332c 8bcc1a1c_73ab_4fe7_59be_b28bbe88fd3e["skip_nodes"] 0ae9bf62_aa68_bcd6_7a5c_a9620e877659 --> 8bcc1a1c_73ab_4fe7_59be_b28bbe88fd3e 6d3d606a_fb7a_54af_1ece_f1eb12f174d1["boundary.js"] 0ae9bf62_aa68_bcd6_7a5c_a9620e877659 --> 6d3d606a_fb7a_54af_1ece_f1eb12f174d1 2c67b85b_d904_f73c_3422_6086d51dc1d1["get_boundary"] 0ae9bf62_aa68_bcd6_7a5c_a9620e877659 --> 2c67b85b_d904_f73c_3422_6086d51dc1d1 style 0ae9bf62_aa68_bcd6_7a5c_a9620e877659 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/** @import { Blocker, TemplateNode, Value } from '#client' */
import { flatten } from '../../reactivity/async.js';
import { Batch, current_batch } from '../../reactivity/batch.js';
import { get } from '../../runtime.js';
import {
hydrate_next,
hydrate_node,
hydrating,
set_hydrate_node,
set_hydrating,
skip_nodes
} from '../hydration.js';
import { get_boundary } from './boundary.js';
/**
* @param {TemplateNode} node
* @param {Blocker[]} blockers
* @param {Array<() => Promise<any>>} expressions
* @param {(anchor: TemplateNode, ...deriveds: Value[]) => void} fn
*/
export function async(node, blockers = [], expressions = [], fn) {
var was_hydrating = hydrating;
var end = null;
if (was_hydrating) {
hydrate_next();
end = skip_nodes(false);
}
if (expressions.length === 0 && blockers.every((b) => b.settled)) {
fn(node);
// This is necessary because it is not guaranteed that the render function will
// advance the hydration node to $.async's end marker: it may stop at an inner
// block's end marker (in case of an inner if block for example), but it also may
// stop at the correct $.async end marker (in case of component child) - hence
// we can't just use hydrate_next()
// TODO this feels indicative of a bug elsewhere; ideally we wouldn't need
// to double-traverse in the already-resolved case
if (was_hydrating) {
set_hydrate_node(end);
}
return;
}
var boundary = get_boundary();
var batch = /** @type {Batch} */ (current_batch);
var blocking = boundary.is_rendered();
boundary.update_pending_count(1);
batch.increment(blocking);
if (was_hydrating) {
var previous_hydrate_node = hydrate_node;
set_hydrate_node(end);
}
flatten(blockers, [], expressions, (values) => {
if (was_hydrating) {
set_hydrating(true);
set_hydrate_node(previous_hydrate_node);
}
try {
// get values eagerly to avoid creating blocks if they reject
for (const d of values) get(d);
fn(node, ...values);
} finally {
if (was_hydrating) {
set_hydrating(false);
}
boundary.update_pending_count(-1);
batch.decrement(blocking);
}
});
}
Domain
Subdomains
Functions
Dependencies
Source
Frequently Asked Questions
What does async.js do?
async.js is a source file in the svelte codebase, written in javascript. It belongs to the ClientRuntime domain, Hydration subdomain.
What functions are defined in async.js?
async.js defines 1 function(s): async.
What does async.js depend on?
async.js imports 13 module(s): Batch, async.js, batch.js, boundary.js, flatten, get, get_boundary, hydrate_next, and 5 more.
Where is async.js in the architecture?
async.js is located at packages/svelte/src/internal/client/dom/blocks/async.js (domain: ClientRuntime, subdomain: Hydration, directory: packages/svelte/src/internal/client/dom/blocks).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free