UseDirective.js — svelte Source File
Architecture documentation for UseDirective.js, a javascript file in the svelte codebase. 3 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 64c70f73_5fcd_e4b8_935a_4ee4b4a90441["UseDirective.js"] d04d7971_88df_542d_dd4f_26170ce6f581["utils.js"] 64c70f73_5fcd_e4b8_935a_4ee4b4a90441 --> d04d7971_88df_542d_dd4f_26170ce6f581 adc3771e_5aef_eddf_fcf6_46eb2c97455a["parse_directive_name"] 64c70f73_5fcd_e4b8_935a_4ee4b4a90441 --> adc3771e_5aef_eddf_fcf6_46eb2c97455a 95c28355_f14c_c3cd_5a03_d5a53ca255bc["builders"] 64c70f73_5fcd_e4b8_935a_4ee4b4a90441 --> 95c28355_f14c_c3cd_5a03_d5a53ca255bc 7665e008_f37d_b860_a594_f2539a66af4e["transform-client.js"] 7665e008_f37d_b860_a594_f2539a66af4e --> 64c70f73_5fcd_e4b8_935a_4ee4b4a90441 style 64c70f73_5fcd_e4b8_935a_4ee4b4a90441 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/** @import { Expression } from 'estree' */
/** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */
import * as b from '#compiler/builders';
import { parse_directive_name } from './shared/utils.js';
/**
* @param {AST.UseDirective} node
* @param {ComponentContext} context
*/
export function UseDirective(node, context) {
const params = [b.id('$$node')];
if (node.expression) {
params.push(b.id('$$action_arg'));
}
/** @type {Expression[]} */
const args = [
context.state.node,
b.arrow(
params,
b.maybe_call(
/** @type {Expression} */ (context.visit(parse_directive_name(node.name))),
...params
)
)
];
if (node.expression) {
args.push(b.thunk(/** @type {Expression} */ (context.visit(node.expression))));
}
// actions need to run after attribute updates in order with bindings/events
let statement = b.stmt(b.call('$.action', ...args));
if (node.metadata.expression.is_async()) {
statement = b.stmt(
b.call(
'$.run_after_blockers',
node.metadata.expression.blockers(),
b.thunk(b.block([statement]))
)
);
}
context.state.init.push(statement);
context.next();
}
Domain
Subdomains
Functions
Dependencies
- builders
- parse_directive_name
- utils.js
Source
Frequently Asked Questions
What does UseDirective.js do?
UseDirective.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Transformer subdomain.
What functions are defined in UseDirective.js?
UseDirective.js defines 1 function(s): UseDirective.
What does UseDirective.js depend on?
UseDirective.js imports 3 module(s): builders, parse_directive_name, utils.js.
What files import UseDirective.js?
UseDirective.js is imported by 1 file(s): transform-client.js.
Where is UseDirective.js in the architecture?
UseDirective.js is located at packages/svelte/src/compiler/phases/3-transform/client/visitors/UseDirective.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases/3-transform/client/visitors).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free