diff --git a/packages/svelte/src/compiler/phases/3-transform/client/transform-client.js b/packages/svelte/src/compiler/phases/3-transform/client/transform-client.js index d37e34dc65..fee42359ed 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/transform-client.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/transform-client.js @@ -5,7 +5,7 @@ import { walk } from 'zimmerframe'; import * as b from '../../../utils/builders.js'; import { set_scope } from '../../scope.js'; -import { serialize_get_binding } from './utils.js'; +import { build_getter } from './utils.js'; import { render_stylesheet } from '../css/index.js'; import { dev, filename } from '../../../state.js'; import { AnimateDirective } from './visitors/AnimateDirective.js'; @@ -198,7 +198,7 @@ export function client_component(analysis, options) { } // We're creating an arrow function that gets the store value which minifies better for two or more references - const store_reference = serialize_get_binding(b.id(name.slice(1)), instance_state); + const store_reference = build_getter(b.id(name.slice(1)), instance_state); const store_get = b.call('$.store_get', store_reference, b.literal(name), b.id('$$stores')); store_setup.push( b.const( @@ -240,7 +240,7 @@ export function client_component(analysis, options) { /** @type {Array} */ const component_returned_object = analysis.exports.flatMap(({ name, alias }) => { const binding = instance_state.scope.get(name); - const expression = serialize_get_binding(b.id(name), instance_state); + const expression = build_getter(b.id(name), instance_state); const getter = b.get(alias ?? name, [b.return(expression)]); if (expression.type === 'Identifier') { @@ -365,7 +365,7 @@ export function client_component(analysis, options) { '$.bind_prop', b.id('$$props'), b.literal(alias ?? name), - serialize_get_binding(b.id(name), instance_state) + build_getter(b.id(name), instance_state) ) ) ); diff --git a/packages/svelte/src/compiler/phases/3-transform/client/utils.js b/packages/svelte/src/compiler/phases/3-transform/client/utils.js index 60d5ebf802..de23d1f789 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/utils.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/utils.js @@ -32,7 +32,7 @@ export function get_assignment_value(node, { state, visit }) { : // turn something like x += 1 into x = x + 1 b.binary( /** @type {BinaryOperator} */ (operator.slice(0, -1)), - serialize_get_binding(node.left, state), + build_getter(node.left, state), /** @type {Expression} */ (visit(node.right)) ); } else if ( @@ -72,7 +72,7 @@ export function is_state_source(binding, state) { * @param {ClientTransformState} state * @returns {Expression} */ -export function serialize_get_binding(node, state) { +export function build_getter(node, state) { const binding = state.scope.get(node.name); if (binding === null || node === binding.node) { @@ -130,7 +130,7 @@ export function serialize_get_binding(node, state) { * @param {{skip_proxy_and_freeze?: boolean}} [options] * @returns {Expression} */ -export function serialize_set_binding(node, context, fallback, prefix, options) { +export function build_setter(node, context, fallback, prefix, options) { const { state, visit } = context; const assignee = node.left; @@ -154,9 +154,7 @@ export function serialize_set_binding(node, context, fallback, prefix, options) const value = path.expression?.(b.id(tmp_id)); const assignment = b.assignment('=', path.node, value); original_assignments.push(assignment); - assignments.push( - serialize_set_binding(assignment, context, () => assignment, prefix, options) - ); + assignments.push(build_setter(assignment, context, () => assignment, prefix, options)); } if (assignments.every((assignment, i) => assignment === original_assignments[i])) { @@ -213,7 +211,7 @@ export function serialize_set_binding(node, context, fallback, prefix, options) assignment.right = private_state.kind === 'frozen_state' ? b.call('$.freeze', value) - : serialize_proxy_reassignment(value, private_state.id); + : build_proxy_reassignment(value, private_state.id); return assignment; } } @@ -226,7 +224,7 @@ export function serialize_set_binding(node, context, fallback, prefix, options) should_proxy_or_freeze(value, context.state.scope) ? private_state.kind === 'frozen_state' ? b.call('$.freeze', value) - : serialize_proxy_reassignment(value, private_state.id) + : build_proxy_reassignment(value, private_state.id) : value ); } @@ -250,7 +248,7 @@ export function serialize_set_binding(node, context, fallback, prefix, options) assignment.right = public_state.kind === 'frozen_state' ? b.call('$.freeze', value) - : serialize_proxy_reassignment(value, public_state.id); + : build_proxy_reassignment(value, public_state.id); return assignment; } } @@ -324,7 +322,7 @@ export function serialize_set_binding(node, context, fallback, prefix, options) if ((binding.kind === 'prop' || binding.kind === 'bindable_prop') && !is_initial_proxy) { return b.call(left, value); } else if (is_store) { - return b.call('$.store_set', serialize_get_binding(b.id(left_name), state), value); + return b.call('$.store_set', build_getter(b.id(left_name), state), value); } else { let call; if (binding.kind === 'state') { @@ -334,7 +332,7 @@ export function serialize_set_binding(node, context, fallback, prefix, options) context.state.analysis.runes && !options?.skip_proxy_and_freeze && should_proxy_or_freeze(value, context.state.scope) - ? serialize_proxy_reassignment(value, left_name) + ? build_proxy_reassignment(value, left_name) : value ); } else if (binding.kind === 'frozen_state') { @@ -357,7 +355,7 @@ export function serialize_set_binding(node, context, fallback, prefix, options) !options?.skip_proxy_and_freeze && should_proxy_or_freeze(value, context.state.scope) && binding.kind === 'bindable_prop' - ? serialize_proxy_reassignment(value, left_name) + ? build_proxy_reassignment(value, left_name) : value ); } else { @@ -401,7 +399,7 @@ export function serialize_set_binding(node, context, fallback, prefix, options) return maybe_skip_ownership_validation( b.call( '$.store_mutate', - serialize_get_binding(b.id(left_name), state), + build_getter(b.id(left_name), state), b.assignment(node.operator, /** @type {Pattern}} */ (visit_node(node.left)), value), b.call('$.untrack', b.id('$' + left_name)) ) @@ -453,7 +451,7 @@ export function serialize_set_binding(node, context, fallback, prefix, options) }; if (value.type === 'BinaryExpression' && /** @type {any} */ (value.operator) === '??') { - return b.logical('??', serialize_get_binding(b.id(left_name), state), serialize()); + return b.logical('??', build_getter(b.id(left_name), state), serialize()); } return serialize(); @@ -463,7 +461,7 @@ export function serialize_set_binding(node, context, fallback, prefix, options) * @param {Expression} value * @param {PrivateIdentifier | string} proxy_reference */ -export function serialize_proxy_reassignment(value, proxy_reference) { +export function build_proxy_reassignment(value, proxy_reference) { return dev ? b.call( '$.proxy', @@ -549,7 +547,7 @@ function get_hoistable_params(node, context) { * @param {ComponentContext} context * @returns {Pattern[]} */ -export function serialize_hoistable_params(node, context) { +export function build_hoistable_params(node, context) { const hoistable_params = get_hoistable_params(node, context); node.metadata.hoistable_params = hoistable_params; diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js index 6b52647587..fefc11bf1f 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js @@ -1,11 +1,11 @@ /** @import { AssignmentExpression } from 'estree' */ /** @import { Context } from '../types' */ -import { serialize_set_binding } from '../utils.js'; +import { build_setter } from '../utils.js'; /** * @param {AssignmentExpression} node * @param {Context} context */ export function AssignmentExpression(node, context) { - return serialize_set_binding(node, context, context.next); + return build_setter(node, context, context.next); } diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/Attribute.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/Attribute.js index 732382a5d6..1fcf110216 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/Attribute.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/Attribute.js @@ -1,7 +1,7 @@ /** @import { Attribute } from '#compiler' */ /** @import { ComponentContext } from '../types' */ import { is_event_attribute } from '../../../../utils/ast.js'; -import { serialize_event_attribute } from './shared/element.js'; +import { build_event_attribute } from './shared/element.js'; /** * @param {Attribute} node @@ -9,6 +9,6 @@ import { serialize_event_attribute } from './shared/element.js'; */ export function Attribute(node, context) { if (is_event_attribute(node)) { - serialize_event_attribute(node, context); + build_event_attribute(node, context); } } diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/BindDirective.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/BindDirective.js index 5211cbe392..c7aa8fddf2 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/BindDirective.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/BindDirective.js @@ -5,9 +5,9 @@ import { dev, is_ignored } from '../../../../state.js'; import { is_text_attribute } from '../../../../utils/ast.js'; import * as b from '../../../../utils/builders.js'; import { binding_properties } from '../../../bindings.js'; -import { serialize_set_binding } from '../utils.js'; -import { serialize_attribute_value } from './shared/element.js'; -import { serialize_bind_this, serialize_validate_binding } from './shared/utils.js'; +import { build_setter } from '../utils.js'; +import { build_attribute_value } from './shared/element.js'; +import { build_bind_this, build_validate_binding } from './shared/utils.js'; /** * @param {BindDirective} node @@ -31,7 +31,7 @@ export function BindDirective(node, context) { !is_ignored(node, 'binding_property_non_reactive') ) { context.state.init.push( - serialize_validate_binding( + build_validate_binding( context.state, node, /**@type {MemberExpression} */ (context.visit(expression)) @@ -43,7 +43,7 @@ export function BindDirective(node, context) { const assignment = b.assignment('=', expression, b.id('$$value')); const setter = b.arrow( [b.id('$$value')], - serialize_set_binding( + build_setter( assignment, context, () => /** @type {Expression} */ (context.visit(assignment)), @@ -161,7 +161,7 @@ export function BindDirective(node, context) { break; case 'this': - call = serialize_bind_this(expression, context.state.node, context); + call = build_bind_this(expression, context.state.node, context); break; case 'textContent': @@ -212,7 +212,7 @@ export function BindDirective(node, context) { if (value !== undefined) { group_getter = b.thunk( b.block([ - b.stmt(serialize_attribute_value(value, context)[1]), + b.stmt(build_attribute_value(value, context)[1]), b.return(/** @type {Expression} */ (context.visit(expression))) ]) ); diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/ClassBody.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/ClassBody.js index b817c929e2..aa9931ade3 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/ClassBody.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/ClassBody.js @@ -5,7 +5,7 @@ import { dev, is_ignored } from '../../../../state.js'; import * as b from '../../../../utils/builders.js'; import { regex_invalid_identifier_chars } from '../../../patterns.js'; import { get_rune } from '../../../scope.js'; -import { serialize_proxy_reassignment, should_proxy_or_freeze } from '../utils.js'; +import { build_proxy_reassignment, should_proxy_or_freeze } from '../utils.js'; /** * @param {ClassBody} node @@ -149,7 +149,7 @@ export function ClassBody(node, context) { 'set', definition.key, [value], - [b.stmt(b.call('$.set', member, serialize_proxy_reassignment(value, field.id)))] + [b.stmt(b.call('$.set', member, build_proxy_reassignment(value, field.id)))] ) ); } diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/Component.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/Component.js index b212fac0bc..9ecde4849e 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/Component.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/Component.js @@ -2,7 +2,7 @@ /** @import { Component } from '#compiler' */ /** @import { ComponentContext } from '../types' */ import * as b from '../../../../utils/builders.js'; -import { serialize_component } from './shared/component.js'; +import { build_component } from './shared/component.js'; /** * @param {Component} node @@ -11,7 +11,7 @@ import { serialize_component } from './shared/component.js'; export function Component(node, context) { if (node.metadata.dynamic) { // Handle dynamic references to what seems like static inline components - const component = serialize_component(node, '$$component', context, b.id('$$anchor')); + const component = build_component(node, '$$component', context, b.id('$$anchor')); context.state.init.push( b.stmt( b.call( @@ -27,6 +27,6 @@ export function Component(node, context) { return; } - const component = serialize_component(node, node.name, context); + const component = build_component(node, node.name, context); context.state.init.push(component); } diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/EachBlock.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/EachBlock.js index 8329c822bc..622c5b579f 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/EachBlock.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/EachBlock.js @@ -12,12 +12,7 @@ import { import { dev } from '../../../../state.js'; import { extract_paths, object } from '../../../../utils/ast.js'; import * as b from '../../../../utils/builders.js'; -import { - get_assignment_value, - serialize_get_binding, - serialize_set_binding, - with_loc -} from '../utils.js'; +import { get_assignment_value, build_getter, build_setter, with_loc } from '../utils.js'; /** * @param {EachBlock} node @@ -94,7 +89,7 @@ export function EachBlock(node, context) { // Legacy mode: find the parent each blocks which contain the arrays to invalidate const indirect_dependencies = collect_parent_each_blocks(context).flatMap((block) => { const array = /** @type {Expression} */ (context.visit(block.expression)); - const transitive_dependencies = serialize_transitive_dependencies( + const transitive_dependencies = build_transitive_dependencies( block.metadata.references, context ); @@ -106,7 +101,7 @@ export function EachBlock(node, context) { } else { indirect_dependencies.push(collection); - const transitive_dependencies = serialize_transitive_dependencies( + const transitive_dependencies = build_transitive_dependencies( each_node_meta.references, context ); @@ -131,9 +126,9 @@ export function EachBlock(node, context) { const create_mutation = (expression_for_id) => { return (assignment, context) => { if (assignment.left.type !== 'Identifier' && assignment.left.type !== 'MemberExpression') { - // serialize_set_binding turns other patterns into IIFEs and separates the assignments + // build_setter turns other patterns into IIFEs and separates the assignments // into separate expressions, at which point this is called again with an identifier or member expression - return serialize_set_binding(assignment, context, () => assignment); + return build_setter(assignment, context, () => assignment); } const left = object(assignment.left); @@ -282,7 +277,7 @@ function collect_parent_each_blocks(context) { * @param {Binding[]} references * @param {ComponentContext} context */ -function serialize_transitive_dependencies(references, context) { +function build_transitive_dependencies(references, context) { /** @type {Set} */ const dependencies = new Set(); @@ -293,7 +288,7 @@ function serialize_transitive_dependencies(references, context) { } } - return [...dependencies].map((dep) => serialize_get_binding({ ...dep.node }, context.state)); + return [...dependencies].map((dep) => build_getter({ ...dep.node }, context.state)); } /** diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/Fragment.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/Fragment.js index 368f33fd11..1696d9213e 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/Fragment.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/Fragment.js @@ -7,7 +7,7 @@ import { dev } from '../../../../state.js'; import * as b from '../../../../utils/builders.js'; import { clean_nodes, infer_namespace } from '../../utils.js'; import { process_children } from './shared/fragment.js'; -import { serialize_render_stmt } from './shared/utils.js'; +import { build_render_statement } from './shared/utils.js'; /** * @param {Fragment} node @@ -97,7 +97,7 @@ export function Fragment(node, context) { '$.add_locations', call, b.member(b.id(context.state.analysis.name), b.id('$.FILENAME'), true), - serialize_locations(state.locations) + build_locations(state.locations) ); } @@ -184,7 +184,7 @@ export function Fragment(node, context) { } if (state.update.length > 0) { - body.push(serialize_render_stmt(state.update)); + body.push(build_render_statement(state.update)); } body.push(...state.after_update); @@ -221,13 +221,13 @@ function get_template_function(namespace, state) { /** * @param {SourceLocation[]} locations */ -function serialize_locations(locations) { +function build_locations(locations) { return b.array( locations.map((loc) => { const expression = b.array([b.literal(loc[0]), b.literal(loc[1])]); if (loc.length === 3) { - expression.elements.push(serialize_locations(loc[2])); + expression.elements.push(build_locations(loc[2])); } return expression; diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/FunctionDeclaration.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/FunctionDeclaration.js index 8f2eca91b1..f223d748ca 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/FunctionDeclaration.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/FunctionDeclaration.js @@ -1,6 +1,6 @@ /** @import { FunctionDeclaration } from 'estree' */ /** @import { ComponentContext } from '../types' */ -import { serialize_hoistable_params } from '../utils.js'; +import { build_hoistable_params } from '../utils.js'; import * as b from '../../../../utils/builders.js'; /** @@ -13,7 +13,7 @@ export function FunctionDeclaration(node, context) { const state = { ...context.state, in_constructor: false }; if (metadata?.hoistable === true) { - const params = serialize_hoistable_params(node, context); + const params = build_hoistable_params(node, context); context.state.hoisted.push( /** @type {FunctionDeclaration} */ ({ diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/Identifier.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/Identifier.js index 7acdf179b6..ae62909eff 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/Identifier.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/Identifier.js @@ -2,7 +2,7 @@ /** @import { Context } from '../types' */ import is_reference from 'is-reference'; import * as b from '../../../../utils/builders.js'; -import { serialize_get_binding } from '../utils.js'; +import { build_getter } from '../utils.js'; /** * @param {Identifier} node @@ -36,6 +36,6 @@ export function Identifier(node, context) { } } - return serialize_get_binding(node, context.state); + return build_getter(node, context.state); } } diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/LabeledStatement.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/LabeledStatement.js index 24a6ed832c..262e44dfcb 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/LabeledStatement.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/LabeledStatement.js @@ -2,7 +2,7 @@ /** @import { ReactiveStatement } from '#compiler' */ /** @import { ComponentContext } from '../types' */ import * as b from '../../../../utils/builders.js'; -import { serialize_get_binding } from '../utils.js'; +import { build_getter } from '../utils.js'; /** * @param {LabeledStatement} node @@ -37,7 +37,7 @@ export function LabeledStatement(node, context) { if (binding.kind === 'normal') continue; const name = binding.node.name; - let serialized = serialize_get_binding(b.id(name), context.state); + let serialized = build_getter(b.id(name), context.state); // If the binding is a prop, we need to deep read it because it could be fine-grained $state // from a runes-component, where mutations don't trigger an update on the prop as a whole. diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/OnDirective.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/OnDirective.js index 171b19844e..dc7da67e16 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/OnDirective.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/OnDirective.js @@ -1,11 +1,11 @@ /** @import { OnDirective } from '#compiler' */ /** @import { ComponentContext } from '../types' */ -import { serialize_event } from './shared/element.js'; +import { build_event } from './shared/element.js'; /** * @param {OnDirective} node * @param {ComponentContext} context */ export function OnDirective(node, context) { - serialize_event(node, node.metadata.expression, context); + build_event(node, node.metadata.expression, context); } diff --git a/packages/svelte/src/compiler/phases/3-transform/client/visitors/RegularElement.js b/packages/svelte/src/compiler/phases/3-transform/client/visitors/RegularElement.js index 740fb2bb4d..0a107943aa 100644 --- a/packages/svelte/src/compiler/phases/3-transform/client/visitors/RegularElement.js +++ b/packages/svelte/src/compiler/phases/3-transform/client/visitors/RegularElement.js @@ -19,20 +19,16 @@ import { import * as b from '../../../../utils/builders.js'; import { is_custom_element_node } from '../../../nodes.js'; import { clean_nodes, determine_namespace_for_children } from '../../utils.js'; -import { serialize_get_binding } from '../utils.js'; +import { build_getter } from '../utils.js'; import { get_attribute_name, - serialize_attribute_value, - serialize_class_directives, - serialize_event_attribute, - serialize_style_directives + build_attribute_value, + build_class_directives, + build_event_attribute, + build_style_directives } from './shared/element.js'; import { process_children } from './shared/fragment.js'; -import { - serialize_render_stmt, - serialize_update, - serialize_update_assignment -} from './shared/utils.js'; +import { build_render_statement, build_update, build_update_assignment } from './shared/utils.js'; /** * @param {RegularElement} node @@ -200,7 +196,7 @@ export function RegularElement(node, context) { if (node.name === 'img') { img_might_be_lazy = true; } - serialize_element_spread_attributes( + build_element_spread_attributes( attributes, context, node, @@ -218,12 +214,12 @@ export function RegularElement(node, context) { ) { might_need_event_replaying = true; } - serialize_event_attribute(attribute, context); + build_event_attribute(attribute, context); continue; } if (needs_special_value_handling && attribute.name === 'value') { - serialize_element_special_value_attribute(node.name, node_id, attribute, context); + build_element_special_value_attribute(node.name, node_id, attribute, context); continue; } @@ -234,7 +230,7 @@ export function RegularElement(node, context) { ) { const name = get_attribute_name(node, attribute, context); const literal_value = /** @type {Literal} */ ( - serialize_attribute_value(attribute.value, context)[1] + build_attribute_value(attribute.value, context)[1] ).value; if (name !== 'class' || literal_value) { // TODO namespace=foreign probably doesn't want to do template stuff at all and instead use programmatic methods @@ -252,8 +248,8 @@ export function RegularElement(node, context) { const is = is_custom_element && child_metadata.namespace !== 'foreign' - ? serialize_custom_element_attribute_update_assignment(node_id, attribute, context) - : serialize_element_attribute_update_assignment(node, node_id, attribute, context); + ? build_custom_element_attribute_update_assignment(node_id, attribute, context) + : build_element_attribute_update_assignment(node, node_id, attribute, context); if (is) is_attributes_reactive = true; } } @@ -264,8 +260,8 @@ export function RegularElement(node, context) { } // class/style directives must be applied last since they could override class/style attributes - serialize_class_directives(class_directives, node_id, context, is_attributes_reactive); - serialize_style_directives( + build_class_directives(class_directives, node_id, context, is_attributes_reactive); + build_style_directives( style_directives, node_id, context, @@ -343,7 +339,7 @@ export function RegularElement(node, context) { context.state.init.push( b.block([ ...child_state.init, - child_state.update.length > 0 ? serialize_render_stmt(child_state.update) : b.empty, + child_state.update.length > 0 ? build_render_statement(child_state.update) : b.empty, ...child_state.after_update ]) ); @@ -399,7 +395,7 @@ function setup_select_synchronization(value_binding, context) { b.thunk( b.block( names.map((name) => { - const serialized = serialize_get_binding(b.id(name), context.state); + const serialized = build_getter(b.id(name), context.state); return b.stmt(serialized); }) ) @@ -428,7 +424,7 @@ function setup_select_synchronization(value_binding, context) { * @param {Identifier} element_id * @param {boolean} needs_select_handling */ -function serialize_element_spread_attributes( +function build_element_spread_attributes( attributes, context, element, @@ -444,7 +440,7 @@ function serialize_element_spread_attributes( if (attribute.type === 'Attribute') { const name = get_attribute_name(element, attribute, context); // TODO: handle has_call - const [, value] = serialize_attribute_value(attribute.value, context); + const [, value] = build_attribute_value(attribute.value, context); if ( name === 'is' && @@ -501,7 +497,7 @@ function serialize_element_spread_attributes( // objects could contain reactive getters -> play it safe and always assume spread attributes are reactive if (needs_isolation) { - context.state.init.push(serialize_update(update)); + context.state.init.push(build_update(update)); } else { context.state.update.push(update); } @@ -553,12 +549,12 @@ function serialize_element_spread_attributes( * @param {ComponentContext} context * @returns {boolean} */ -function serialize_element_attribute_update_assignment(element, node_id, attribute, context) { +function build_element_attribute_update_assignment(element, node_id, attribute, context) { const state = context.state; const name = get_attribute_name(element, attribute, context); const is_svg = context.state.metadata.namespace === 'svg' || element.name === 'svg'; const is_mathml = context.state.metadata.namespace === 'mathml'; - let [has_call, value] = serialize_attribute_value(attribute.value, context); + let [has_call, value] = build_attribute_value(attribute.value, context); // The foreign namespace doesn't have any special handling, everything goes through the attr function if (context.state.metadata.namespace === 'foreign') { @@ -574,7 +570,7 @@ function serialize_element_attribute_update_assignment(element, node_id, attribu if (attribute.metadata.expression.has_state) { const id = state.scope.generate(`${node_id.name}_${name}`); - serialize_update_assignment(state, id, undefined, value, statement); + build_update_assignment(state, id, undefined, value, statement); return true; } else { state.init.push(statement); @@ -619,7 +615,7 @@ function serialize_element_attribute_update_assignment(element, node_id, attribu if (attribute.metadata.expression.has_state) { if (has_call) { - state.init.push(serialize_update(update)); + state.init.push(build_update(update)); } else { state.update.push(update); } @@ -631,22 +627,22 @@ function serialize_element_attribute_update_assignment(element, node_id, attribu } /** - * Like `serialize_element_attribute_update_assignment` but without any special attribute treatment. + * Like `build_element_attribute_update_assignment` but without any special attribute treatment. * @param {Identifier} node_id * @param {Attribute} attribute * @param {ComponentContext} context * @returns {boolean} */ -function serialize_custom_element_attribute_update_assignment(node_id, attribute, context) { +function build_custom_element_attribute_update_assignment(node_id, attribute, context) { const state = context.state; const name = attribute.name; // don't lowercase, as we set the element's property, which might be case sensitive - let [has_call, value] = serialize_attribute_value(attribute.value, context); + let [has_call, value] = build_attribute_value(attribute.value, context); const update = b.stmt(b.call('$.set_custom_element_data', node_id, b.literal(name), value)); if (attribute.metadata.expression.has_state) { if (has_call) { - state.init.push(serialize_update(update)); + state.init.push(build_update(update)); } else { state.update.push(update); } @@ -667,9 +663,9 @@ function serialize_custom_element_attribute_update_assignment(node_id, attribute * @param {ComponentContext} context * @returns {boolean} */ -function serialize_element_special_value_attribute(element, node_id, attribute, context) { +function build_element_special_value_attribute(element, node_id, attribute, context) { const state = context.state; - const [, value] = serialize_attribute_value(attribute.value, context); + const [, value] = build_attribute_value(attribute.value, context); const inner_assignment = b.assignment( '=', @@ -705,7 +701,7 @@ function serialize_element_special_value_attribute(element, node_id, attribute, if (is_reactive) { const id = state.scope.generate(`${node_id.name}_value`); - serialize_update_assignment( + build_update_assignment( state, id, // `