Merge branch 'main' into $state-invalidate

pull/15673/head
ComputerGuy 5 months ago committed by GitHub
commit 91bb6fa655
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -60,6 +60,43 @@ Certain lifecycle methods can only be used during component initialisation. To f
<button onclick={handleClick}>click me</button> <button onclick={handleClick}>click me</button>
``` ```
### snippet_without_render_tag
```
Attempted to render a snippet without a `{@render}` block. This would cause the snippet code to be stringified instead of its content being rendered to the DOM. To fix this, change `{snippet}` to `{@render snippet()}`.
```
A component throwing this error will look something like this (`children` is not being rendered):
```svelte
<script>
let { children } = $props();
</script>
{children}
```
...or like this (a parent component is passing a snippet where a non-snippet value is expected):
```svelte
<!--- file: Parent.svelte --->
<ChildComponent>
{#snippet label()}
<span>Hi!</span>
{/snippet}
</ChildComponent>
```
```svelte
<!--- file: Child.svelte --->
<script>
let { label } = $props();
</script>
<!-- This component doesn't expect a snippet, but the parent provided one -->
<p>{label}</p>
```
### store_invalid_shape ### store_invalid_shape
``` ```

@ -2,24 +2,6 @@
title: svelte/reactivity title: svelte/reactivity
--- ---
Svelte provides reactive versions of various built-ins like `SvelteMap`, `SvelteSet` and `SvelteURL`. These can be imported from `svelte/reactivity` and used just like their native counterparts. Svelte provides reactive versions of various built-ins like [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map), [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) and [`URL`](https://developer.mozilla.org/en-US/docs/Web/API/URL) that can be used just like their native counterparts, as well as a handful of additional utilities for handling reactivity.
```svelte
<script>
import { SvelteURL } from 'svelte/reactivity';
const url = new SvelteURL('https://example.com/path');
</script>
<!-- changes to these... -->
<input bind:value={url.protocol} />
<input bind:value={url.hostname} />
<input bind:value={url.pathname} />
<hr />
<!-- will update `href` and vice versa -->
<input bind:value={url.href} />
```
> MODULE: svelte/reactivity > MODULE: svelte/reactivity

@ -1,5 +1,29 @@
# svelte # svelte
## 5.27.3
### Patch Changes
- fix: use function declaration for snippets in server output to avoid TDZ violation ([#15789](https://github.com/sveltejs/svelte/pull/15789))
## 5.27.2
### Patch Changes
- chore: use pkg.imports for common modules ([#15787](https://github.com/sveltejs/svelte/pull/15787))
## 5.27.1
### Patch Changes
- chore: default params for html blocks ([#15778](https://github.com/sveltejs/svelte/pull/15778))
- fix: correct suggested type for custom events without detail ([#15763](https://github.com/sveltejs/svelte/pull/15763))
- fix: Throw on unrendered snippets in `dev` ([#15766](https://github.com/sveltejs/svelte/pull/15766))
- fix: avoid unnecessary read version increments ([#15777](https://github.com/sveltejs/svelte/pull/15777))
## 5.27.0 ## 5.27.0
### Minor Changes ### Minor Changes

@ -52,6 +52,41 @@ Certain lifecycle methods can only be used during component initialisation. To f
<button onclick={handleClick}>click me</button> <button onclick={handleClick}>click me</button>
``` ```
## snippet_without_render_tag
> Attempted to render a snippet without a `{@render}` block. This would cause the snippet code to be stringified instead of its content being rendered to the DOM. To fix this, change `{snippet}` to `{@render snippet()}`.
A component throwing this error will look something like this (`children` is not being rendered):
```svelte
<script>
let { children } = $props();
</script>
{children}
```
...or like this (a parent component is passing a snippet where a non-snippet value is expected):
```svelte
<!--- file: Parent.svelte --->
<ChildComponent>
{#snippet label()}
<span>Hi!</span>
{/snippet}
</ChildComponent>
```
```svelte
<!--- file: Child.svelte --->
<script>
let { label } = $props();
</script>
<!-- This component doesn't expect a snippet, but the parent provided one -->
<p>{label}</p>
```
## store_invalid_shape ## store_invalid_shape
> `%name%` is not a store with a `subscribe` method > `%name%` is not a store with a `subscribe` method

@ -2,7 +2,7 @@
"name": "svelte", "name": "svelte",
"description": "Cybernetically enhanced web apps", "description": "Cybernetically enhanced web apps",
"license": "MIT", "license": "MIT",
"version": "5.27.0", "version": "5.27.3",
"type": "module", "type": "module",
"types": "./types/index.d.ts", "types": "./types/index.d.ts",
"engines": { "engines": {
@ -103,6 +103,17 @@
"default": "./src/events/index.js" "default": "./src/events/index.js"
} }
}, },
"imports": {
"#client": "./src/internal/client/types.d.ts",
"#client/constants": "./src/internal/client/constants.js",
"#compiler": {
"types": "./src/compiler/private.d.ts",
"default": "./src/compiler/index.js"
},
"#compiler/builders": "./src/compiler/utils/builders.js",
"#server": "./src/internal/server/types.d.ts",
"#shared": "./src/internal/shared/types.d.ts"
},
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git+https://github.com/sveltejs/svelte.git", "url": "git+https://github.com/sveltejs/svelte.git",

@ -24,7 +24,12 @@ await createBundle({
output: `${dir}/types/index.d.ts`, output: `${dir}/types/index.d.ts`,
compilerOptions: { compilerOptions: {
// so that types/properties with `@internal` (and its dependencies) are removed from the output // so that types/properties with `@internal` (and its dependencies) are removed from the output
stripInternal: true stripInternal: true,
paths: Object.fromEntries(
Object.entries(pkg.imports).map(([key, value]) => {
return [key, [value.types ?? value.default ?? value]];
})
)
}, },
modules: { modules: {
[pkg.name]: `${dir}/src/index.d.ts`, [pkg.name]: `${dir}/src/index.d.ts`,

@ -1,7 +1,7 @@
/** @import { VariableDeclarator, Node, Identifier, AssignmentExpression, LabeledStatement, ExpressionStatement } from 'estree' */ /** @import { VariableDeclarator, Node, Identifier, AssignmentExpression, LabeledStatement, ExpressionStatement } from 'estree' */
/** @import { Visitors } from 'zimmerframe' */ /** @import { Visitors } from 'zimmerframe' */
/** @import { ComponentAnalysis } from '../phases/types.js' */ /** @import { ComponentAnalysis } from '../phases/types.js' */
/** @import { Scope, ScopeRoot } from '../phases/scope.js' */ /** @import { Scope } from '../phases/scope.js' */
/** @import { AST, Binding, ValidatedCompileOptions } from '#compiler' */ /** @import { AST, Binding, ValidatedCompileOptions } from '#compiler' */
import MagicString from 'magic-string'; import MagicString from 'magic-string';
import { walk } from 'zimmerframe'; import { walk } from 'zimmerframe';

@ -1,7 +1,7 @@
/** @import { Context, Visitors } from 'zimmerframe' */ /** @import { Context, Visitors } from 'zimmerframe' */
/** @import { FunctionExpression, FunctionDeclaration } from 'estree' */ /** @import { FunctionExpression, FunctionDeclaration } from 'estree' */
import { walk } from 'zimmerframe'; import { walk } from 'zimmerframe';
import * as b from '../../utils/builders.js'; import * as b from '#compiler/builders';
import * as e from '../../errors.js'; import * as e from '../../errors.js';
/** /**

@ -5,8 +5,8 @@
import { walk } from 'zimmerframe'; import { walk } from 'zimmerframe';
import * as e from '../../errors.js'; import * as e from '../../errors.js';
import * as w from '../../warnings.js'; import * as w from '../../warnings.js';
import { extract_identifiers, is_text_attribute } from '../../utils/ast.js'; import { extract_identifiers } from '../../utils/ast.js';
import * as b from '../../utils/builders.js'; import * as b from '#compiler/builders';
import { Scope, ScopeRoot, create_scopes, get_rune, set_scope } from '../scope.js'; import { Scope, ScopeRoot, create_scopes, get_rune, set_scope } from '../scope.js';
import check_graph_for_cycles from './utils/check_graph_for_cycles.js'; import check_graph_for_cycles from './utils/check_graph_for_cycles.js';
import { create_attribute, is_custom_element_node } from '../nodes.js'; import { create_attribute, is_custom_element_node } from '../nodes.js';

@ -6,7 +6,7 @@ import * as e from '../../../errors.js';
import { get_parent, object, unwrap_optional } from '../../../utils/ast.js'; import { get_parent, object, unwrap_optional } from '../../../utils/ast.js';
import { is_pure, is_safe_identifier } from './shared/utils.js'; import { is_pure, is_safe_identifier } from './shared/utils.js';
import { dev, locate_node, source } from '../../../state.js'; import { dev, locate_node, source } from '../../../state.js';
import * as b from '../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {CallExpression} node * @param {CallExpression} node

@ -1,7 +1,5 @@
/** @import { ExportNamedDeclaration, Identifier, Node } from 'estree' */ /** @import { ExportNamedDeclaration, Identifier } from 'estree' */
/** @import { Binding } from '#compiler' */
/** @import { Context } from '../types' */ /** @import { Context } from '../types' */
/** @import { Scope } from '../../scope' */
import * as e from '../../../errors.js'; import * as e from '../../../errors.js';
import { extract_identifiers } from '../../../utils/ast.js'; import { extract_identifiers } from '../../../utils/ast.js';

@ -1,5 +1,4 @@
/** @import { Expression, Identifier } from 'estree' */ /** @import { Expression, Identifier } from 'estree' */
/** @import { EachBlock } from '#compiler' */
/** @import { Context } from '../types' */ /** @import { Context } from '../types' */
import is_reference from 'is-reference'; import is_reference from 'is-reference';
import { should_proxy } from '../../3-transform/client/utils.js'; import { should_proxy } from '../../3-transform/client/utils.js';

@ -1,10 +1,7 @@
/** @import { MemberExpression, Node } from 'estree' */ /** @import { MemberExpression } from 'estree' */
/** @import { Context } from '../types' */ /** @import { Context } from '../types' */
import * as e from '../../../errors.js'; import * as e from '../../../errors.js';
import * as w from '../../../warnings.js';
import { object } from '../../../utils/ast.js';
import { is_pure, is_safe_identifier } from './shared/utils.js'; import { is_pure, is_safe_identifier } from './shared/utils.js';
import { mark_subtree_dynamic } from './shared/fragment.js';
/** /**
* @param {MemberExpression} node * @param {MemberExpression} node

@ -1,4 +1,4 @@
/** @import { AssignmentExpression, Expression, Identifier, Literal, Node, Pattern, PrivateIdentifier, Super, UpdateExpression, VariableDeclarator } from 'estree' */ /** @import { AssignmentExpression, Expression, Literal, Node, Pattern, Super, UpdateExpression, VariableDeclarator } from 'estree' */
/** @import { AST, Binding } from '#compiler' */ /** @import { AST, Binding } from '#compiler' */
/** @import { AnalysisState, Context } from '../../types' */ /** @import { AnalysisState, Context } from '../../types' */
/** @import { Scope } from '../../../scope' */ /** @import { Scope } from '../../../scope' */
@ -6,7 +6,7 @@
import * as e from '../../../../errors.js'; import * as e from '../../../../errors.js';
import { extract_identifiers } from '../../../../utils/ast.js'; import { extract_identifiers } from '../../../../utils/ast.js';
import * as w from '../../../../warnings.js'; import * as w from '../../../../warnings.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { get_rune } from '../../../scope.js'; import { get_rune } from '../../../scope.js';
/** /**

@ -3,7 +3,7 @@
/** @import { ComponentAnalysis, Analysis } from '../../types' */ /** @import { ComponentAnalysis, Analysis } from '../../types' */
/** @import { Visitors, ComponentClientTransformState, ClientTransformState } from './types' */ /** @import { Visitors, ComponentClientTransformState, ClientTransformState } from './types' */
import { walk } from 'zimmerframe'; import { walk } from 'zimmerframe';
import * as b from '../../../utils/builders.js'; import * as b from '#compiler/builders';
import { build_getter, is_state_source } from './utils.js'; import { build_getter, is_state_source } from './utils.js';
import { render_stylesheet } from '../css/index.js'; import { render_stylesheet } from '../css/index.js';
import { dev, filename } from '../../../state.js'; import { dev, filename } from '../../../state.js';

@ -3,7 +3,7 @@
/** @import { ClientTransformState, ComponentClientTransformState, ComponentContext } from './types.js' */ /** @import { ClientTransformState, ComponentClientTransformState, ComponentContext } from './types.js' */
/** @import { Analysis } from '../../types.js' */ /** @import { Analysis } from '../../types.js' */
/** @import { Scope } from '../../scope.js' */ /** @import { Scope } from '../../scope.js' */
import * as b from '../../../utils/builders.js'; import * as b from '#compiler/builders';
import { is_simple_expression } from '../../../utils/ast.js'; import { is_simple_expression } from '../../../utils/ast.js';
import { import {
PROPS_IS_LAZY_INITIAL, PROPS_IS_LAZY_INITIAL,

@ -1,7 +1,7 @@
/** @import { Expression } from 'estree' */ /** @import { Expression } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { parse_directive_name } from './shared/utils.js'; import { parse_directive_name } from './shared/utils.js';
/** /**

@ -1,7 +1,7 @@
/** @import { AssignmentExpression, AssignmentOperator, Expression, Identifier, Pattern } from 'estree' */ /** @import { AssignmentExpression, AssignmentOperator, Expression, Identifier, Pattern } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { Context } from '../types.js' */ /** @import { Context } from '../types.js' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { import {
build_assignment_value, build_assignment_value,
get_attribute_expression, get_attribute_expression,

@ -2,7 +2,7 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentClientTransformState, ComponentContext } from '../types' */ /** @import { ComponentClientTransformState, ComponentContext } from '../types' */
import { extract_identifiers } from '../../../../utils/ast.js'; import { extract_identifiers } from '../../../../utils/ast.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { create_derived } from '../utils.js'; import { create_derived } from '../utils.js';
import { get_value } from './shared/declarations.js'; import { get_value } from './shared/declarations.js';

@ -1,7 +1,7 @@
/** @import { Expression, BinaryExpression } from 'estree' */ /** @import { Expression, BinaryExpression } from 'estree' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import { dev } from '../../../../state.js'; import { dev } from '../../../../state.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {BinaryExpression} node * @param {BinaryExpression} node

@ -3,7 +3,7 @@
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import { dev, is_ignored } from '../../../../state.js'; import { dev, is_ignored } from '../../../../state.js';
import { is_text_attribute } from '../../../../utils/ast.js'; import { is_text_attribute } from '../../../../utils/ast.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { binding_properties } from '../../../bindings.js'; import { binding_properties } from '../../../bindings.js';
import { build_attribute_value } from './shared/element.js'; import { build_attribute_value } from './shared/element.js';
import { build_bind_this, validate_binding } from './shared/utils.js'; import { build_bind_this, validate_binding } from './shared/utils.js';

@ -1,7 +1,7 @@
/** @import { ArrowFunctionExpression, BlockStatement, CallExpression, Expression, FunctionDeclaration, FunctionExpression, Statement } from 'estree' */ /** @import { ArrowFunctionExpression, BlockStatement, Expression, FunctionDeclaration, FunctionExpression, Statement } from 'estree' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import { add_state_transformers } from './shared/declarations.js'; import { add_state_transformers } from './shared/declarations.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {BlockStatement} node * @param {BlockStatement} node

@ -1,6 +1,6 @@
/** @import { BreakStatement } from 'estree' */ /** @import { BreakStatement } from 'estree' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {BreakStatement} node * @param {BreakStatement} node

@ -1,7 +1,7 @@
/** @import { CallExpression, Expression, Identifier, MemberExpression, Node } from 'estree' */ /** @import { CallExpression, Expression, Identifier, MemberExpression, Node } from 'estree' */
/** @import { Context } from '../types' */ /** @import { Context } from '../types' */
import { dev, is_ignored } from '../../../../state.js'; import { dev, is_ignored } from '../../../../state.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { get_rune } from '../../../scope.js'; import { get_rune } from '../../../scope.js';
import { transform_inspect_rune } from '../../utils.js'; import { transform_inspect_rune } from '../../utils.js';
import * as e from '../../../../errors.js'; import * as e from '../../../../errors.js';

@ -1,8 +1,6 @@
/** @import { ClassBody, Expression, Identifier, Literal, MethodDefinition, PrivateIdentifier, PropertyDefinition } from 'estree' */ /** @import { ClassBody, Expression, Identifier, Literal, MethodDefinition, PrivateIdentifier, PropertyDefinition } from 'estree' */
/** @import { } from '#compiler' */
/** @import { Context, StateField } from '../types' */ /** @import { Context, StateField } from '../types' */
import { dev, is_ignored } from '../../../../state.js'; import * as b from '#compiler/builders';
import * as b from '../../../../utils/builders.js';
import { regex_invalid_identifier_chars } from '../../../patterns.js'; import { regex_invalid_identifier_chars } from '../../../patterns.js';
import { get_rune } from '../../../scope.js'; import { get_rune } from '../../../scope.js';
import { should_proxy } from '../utils.js'; import { should_proxy } from '../utils.js';

@ -1,7 +1,7 @@
/** @import { Expression } from 'estree' */ /** @import { Expression } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { build_component } from './shared/component.js'; import { build_component } from './shared/component.js';
/** /**

@ -3,7 +3,7 @@
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import { dev } from '../../../../state.js'; import { dev } from '../../../../state.js';
import { extract_identifiers } from '../../../../utils/ast.js'; import { extract_identifiers } from '../../../../utils/ast.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { create_derived } from '../utils.js'; import { create_derived } from '../utils.js';
import { get_value } from './shared/declarations.js'; import { get_value } from './shared/declarations.js';

@ -1,7 +1,7 @@
/** @import { Expression} from 'estree' */ /** @import { Expression} from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {AST.DebugTag} node * @param {AST.DebugTag} node

@ -11,7 +11,7 @@ import {
} from '../../../../../constants.js'; } from '../../../../../constants.js';
import { dev } from '../../../../state.js'; import { dev } from '../../../../state.js';
import { extract_paths, object } from '../../../../utils/ast.js'; import { extract_paths, object } from '../../../../utils/ast.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { build_getter } from '../utils.js'; import { build_getter } from '../utils.js';
import { get_value } from './shared/declarations.js'; import { get_value } from './shared/declarations.js';

@ -1,6 +1,6 @@
/** @import { ExportNamedDeclaration } from 'estree' */ /** @import { ExportNamedDeclaration } from 'estree' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {ExportNamedDeclaration} node * @param {ExportNamedDeclaration} node

@ -1,6 +1,6 @@
/** @import { Expression, ExpressionStatement } from 'estree' */ /** @import { Expression, ExpressionStatement } from 'estree' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { get_rune } from '../../../scope.js'; import { get_rune } from '../../../scope.js';
/** /**

@ -4,7 +4,7 @@
/** @import { ComponentClientTransformState, ComponentContext } from '../types' */ /** @import { ComponentClientTransformState, ComponentContext } from '../types' */
import { TEMPLATE_FRAGMENT, TEMPLATE_USE_IMPORT_NODE } from '../../../../../constants.js'; import { TEMPLATE_FRAGMENT, TEMPLATE_USE_IMPORT_NODE } from '../../../../../constants.js';
import { dev } from '../../../../state.js'; import { dev } from '../../../../state.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { sanitize_template_string } from '../../../../utils/sanitize_template_string.js'; import { sanitize_template_string } from '../../../../utils/sanitize_template_string.js';
import { clean_nodes, infer_namespace } from '../../utils.js'; import { clean_nodes, infer_namespace } from '../../utils.js';
import { process_children } from './shared/fragment.js'; import { process_children } from './shared/fragment.js';

@ -1,7 +1,7 @@
/** @import { FunctionDeclaration } from 'estree' */ /** @import { FunctionDeclaration } from 'estree' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import { build_hoisted_params } from '../utils.js'; import { build_hoisted_params } from '../utils.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {FunctionDeclaration} node * @param {FunctionDeclaration} node

@ -2,7 +2,7 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import { is_ignored } from '../../../../state.js'; import { is_ignored } from '../../../../state.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {AST.HtmlTag} node * @param {AST.HtmlTag} node
@ -11,17 +11,22 @@ import * as b from '../../../../utils/builders.js';
export function HtmlTag(node, context) { export function HtmlTag(node, context) {
context.state.template.push('<!>'); context.state.template.push('<!>');
// push into init, so that bindings run afterwards, which might trigger another run and override hydration const expression = /** @type {Expression} */ (context.visit(node.expression));
context.state.init.push(
b.stmt( const is_svg = context.state.metadata.namespace === 'svg';
b.call( const is_mathml = context.state.metadata.namespace === 'mathml';
'$.html',
context.state.node, const statement = b.stmt(
b.thunk(/** @type {Expression} */ (context.visit(node.expression))), b.call(
b.literal(context.state.metadata.namespace === 'svg'), '$.html',
b.literal(context.state.metadata.namespace === 'mathml'), context.state.node,
is_ignored(node, 'hydration_html_changed') && b.true b.thunk(expression),
) is_svg && b.true,
is_mathml && b.true,
is_ignored(node, 'hydration_html_changed') && b.true
) )
); );
// push into init, so that bindings run afterwards, which might trigger another run and override hydration
context.state.init.push(statement);
} }

@ -1,7 +1,7 @@
/** @import { Identifier, Node } from 'estree' */ /** @import { Identifier, Node } from 'estree' */
/** @import { Context } from '../types' */ /** @import { Context } from '../types' */
import is_reference from 'is-reference'; import is_reference from 'is-reference';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { build_getter } from '../utils.js'; import { build_getter } from '../utils.js';
/** /**

@ -1,7 +1,7 @@
/** @import { BlockStatement, Expression, Identifier } from 'estree' */ /** @import { BlockStatement, Expression } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {AST.IfBlock} node * @param {AST.IfBlock} node

@ -1,6 +1,6 @@
/** @import { ImportDeclaration } from 'estree' */ /** @import { ImportDeclaration } from 'estree' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {ImportDeclaration} node * @param {ImportDeclaration} node

@ -1,7 +1,7 @@
/** @import { Expression } from 'estree' */ /** @import { Expression } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {AST.KeyBlock} node * @param {AST.KeyBlock} node

@ -1,9 +1,7 @@
/** @import { Location } from 'locate-character' */
/** @import { Expression, LabeledStatement, Statement } from 'estree' */ /** @import { Expression, LabeledStatement, Statement } from 'estree' */
/** @import { ReactiveStatement } from '#compiler' */ /** @import { ReactiveStatement } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import { dev, is_ignored, locator } from '../../../../state.js'; import * as b from '#compiler/builders';
import * as b from '../../../../utils/builders.js';
import { build_getter } from '../utils.js'; import { build_getter } from '../utils.js';
/** /**

@ -1,7 +1,7 @@
/** @import { Expression } from 'estree' */ /** @import { Expression } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { create_derived } from '../utils.js'; import { create_derived } from '../utils.js';
/** /**

@ -1,6 +1,6 @@
/** @import { MemberExpression } from 'estree' */ /** @import { MemberExpression } from 'estree' */
/** @import { Context } from '../types' */ /** @import { Context } from '../types' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {MemberExpression} node * @param {MemberExpression} node

@ -1,6 +1,6 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { build_event, build_event_handler } from './shared/events.js'; import { build_event, build_event_handler } from './shared/events.js';
const modifiers = [ const modifiers = [

@ -1,7 +1,7 @@
/** @import { Expression, ImportDeclaration, MemberExpression, Program } from 'estree' */ /** @import { Expression, ImportDeclaration, MemberExpression, Program } from 'estree' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import { build_getter, is_prop_source } from '../utils.js'; import { build_getter, is_prop_source } from '../utils.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { add_state_transformers } from './shared/declarations.js'; import { add_state_transformers } from './shared/declarations.js';
/** /**

@ -1,4 +1,4 @@
/** @import { ArrayExpression, Expression, ExpressionStatement, Identifier, MemberExpression, ObjectExpression, Statement } from 'estree' */ /** @import { ArrayExpression, Expression, ExpressionStatement, Identifier, MemberExpression, ObjectExpression } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { SourceLocation } from '#shared' */ /** @import { SourceLocation } from '#shared' */
/** @import { ComponentClientTransformState, ComponentContext } from '../types' */ /** @import { ComponentClientTransformState, ComponentContext } from '../types' */
@ -13,7 +13,7 @@ import {
import { escape_html } from '../../../../../escaping.js'; import { escape_html } from '../../../../../escaping.js';
import { dev, is_ignored, locator } from '../../../../state.js'; import { dev, is_ignored, locator } from '../../../../state.js';
import { is_event_attribute, is_text_attribute } from '../../../../utils/ast.js'; import { is_event_attribute, is_text_attribute } from '../../../../utils/ast.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { is_custom_element_node } from '../../../nodes.js'; import { is_custom_element_node } from '../../../nodes.js';
import { clean_nodes, determine_namespace_for_children } from '../../utils.js'; import { clean_nodes, determine_namespace_for_children } from '../../utils.js';
import { build_getter } from '../utils.js'; import { build_getter } from '../utils.js';

@ -2,7 +2,7 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import { unwrap_optional } from '../../../../utils/ast.js'; import { unwrap_optional } from '../../../../utils/ast.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {AST.RenderTag} node * @param {AST.RenderTag} node

@ -1,7 +1,7 @@
/** @import { BlockStatement, Expression, ExpressionStatement, Literal, Property } from 'estree' */ /** @import { BlockStatement, Expression, ExpressionStatement, Literal, Property } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { build_attribute_value } from './shared/element.js'; import { build_attribute_value } from './shared/element.js';
import { memoize_expression } from './shared/utils.js'; import { memoize_expression } from './shared/utils.js';

@ -3,7 +3,7 @@
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import { dev } from '../../../../state.js'; import { dev } from '../../../../state.js';
import { extract_paths } from '../../../../utils/ast.js'; import { extract_paths } from '../../../../utils/ast.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { get_value } from './shared/declarations.js'; import { get_value } from './shared/declarations.js';
/** /**

@ -2,7 +2,7 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import { dev } from '../../../../state.js'; import { dev } from '../../../../state.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {AST.SvelteBoundary} node * @param {AST.SvelteBoundary} node

@ -3,10 +3,10 @@
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import { dev, locator } from '../../../../state.js'; import { dev, locator } from '../../../../state.js';
import { is_text_attribute } from '../../../../utils/ast.js'; import { is_text_attribute } from '../../../../utils/ast.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { determine_namespace_for_children } from '../../utils.js'; import { determine_namespace_for_children } from '../../utils.js';
import { build_attribute_value, build_set_attributes, build_set_class } from './shared/element.js'; import { build_attribute_value, build_set_attributes, build_set_class } from './shared/element.js';
import { build_render_statement, get_expression_id } from './shared/utils.js'; import { build_render_statement } from './shared/utils.js';
/** /**
* @param {AST.SvelteElement} node * @param {AST.SvelteElement} node

@ -1,7 +1,7 @@
/** @import { BlockStatement } from 'estree' */ /** @import { BlockStatement } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {AST.SvelteHead} node * @param {AST.SvelteHead} node

@ -1,6 +1,6 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { build_template_chunk } from './shared/utils.js'; import { build_template_chunk } from './shared/utils.js';
/** /**

@ -2,7 +2,7 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import { TRANSITION_GLOBAL, TRANSITION_IN, TRANSITION_OUT } from '../../../../../constants.js'; import { TRANSITION_GLOBAL, TRANSITION_IN, TRANSITION_OUT } from '../../../../../constants.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { parse_directive_name } from './shared/utils.js'; import { parse_directive_name } from './shared/utils.js';
/** /**

@ -1,7 +1,7 @@
/** @import { AssignmentExpression, Expression, UpdateExpression } from 'estree' */ /** @import { AssignmentExpression, Expression, UpdateExpression } from 'estree' */
/** @import { Context } from '../types' */ /** @import { Context } from '../types' */
import { object } from '../../../../utils/ast.js'; import { object } from '../../../../utils/ast.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { validate_mutation } from './shared/utils.js'; import { validate_mutation } from './shared/utils.js';
/** /**

@ -1,7 +1,7 @@
/** @import { Expression } from 'estree' */ /** @import { Expression } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { parse_directive_name } from './shared/utils.js'; import { parse_directive_name } from './shared/utils.js';
/** /**

@ -3,7 +3,7 @@
/** @import { ComponentClientTransformState, ComponentContext } from '../types' */ /** @import { ComponentClientTransformState, ComponentContext } from '../types' */
import { dev } from '../../../../state.js'; import { dev } from '../../../../state.js';
import { extract_paths } from '../../../../utils/ast.js'; import { extract_paths } from '../../../../utils/ast.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import * as assert from '../../../../utils/assert.js'; import * as assert from '../../../../utils/assert.js';
import { get_rune } from '../../../scope.js'; import { get_rune } from '../../../scope.js';
import { get_prop_source, is_prop_source, is_state_source, should_proxy } from '../utils.js'; import { get_prop_source, is_prop_source, is_state_source, should_proxy } from '../utils.js';

@ -3,7 +3,7 @@
/** @import { ComponentContext } from '../../types.js' */ /** @import { ComponentContext } from '../../types.js' */
import { dev, is_ignored } from '../../../../../state.js'; import { dev, is_ignored } from '../../../../../state.js';
import { get_attribute_chunks, object } from '../../../../../utils/ast.js'; import { get_attribute_chunks, object } from '../../../../../utils/ast.js';
import * as b from '../../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { build_bind_this, memoize_expression, validate_binding } from '../shared/utils.js'; import { build_bind_this, memoize_expression, validate_binding } from '../shared/utils.js';
import { build_attribute_value } from '../shared/element.js'; import { build_attribute_value } from '../shared/element.js';
import { build_event_handler } from './events.js'; import { build_event_handler } from './events.js';

@ -1,7 +1,7 @@
/** @import { Identifier } from 'estree' */ /** @import { Identifier } from 'estree' */
/** @import { ComponentContext, Context } from '../../types' */ /** @import { ComponentContext, Context } from '../../types' */
import { is_state_source } from '../../utils.js'; import { is_state_source } from '../../utils.js';
import * as b from '../../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* Turns `foo` into `$.get(foo)` * Turns `foo` into `$.get(foo)`

@ -1,11 +1,11 @@
/** @import { ArrayExpression, Expression, Identifier, ObjectExpression } from 'estree' */ /** @import { ArrayExpression, Expression, Identifier, ObjectExpression } from 'estree' */
/** @import { AST, ExpressionMetadata } from '#compiler' */ /** @import { AST, ExpressionMetadata } from '#compiler' */
/** @import { ComponentClientTransformState, ComponentContext } from '../../types' */ /** @import { ComponentContext } from '../../types' */
import { escape_html } from '../../../../../../escaping.js'; import { escape_html } from '../../../../../../escaping.js';
import { normalize_attribute } from '../../../../../../utils.js'; import { normalize_attribute } from '../../../../../../utils.js';
import { is_ignored } from '../../../../../state.js'; import { is_ignored } from '../../../../../state.js';
import { is_event_attribute } from '../../../../../utils/ast.js'; import { is_event_attribute } from '../../../../../utils/ast.js';
import * as b from '../../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { build_class_directives_object, build_style_directives_object } from '../RegularElement.js'; import { build_class_directives_object, build_style_directives_object } from '../RegularElement.js';
import { build_template_chunk, get_expression_id } from './utils.js'; import { build_template_chunk, get_expression_id } from './utils.js';

@ -3,7 +3,7 @@
/** @import { ComponentContext } from '../../types' */ /** @import { ComponentContext } from '../../types' */
import { is_capture_event, is_passive_event } from '../../../../../../utils.js'; import { is_capture_event, is_passive_event } from '../../../../../../utils.js';
import { dev, locator } from '../../../../../state.js'; import { dev, locator } from '../../../../../state.js';
import * as b from '../../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {AST.Attribute} node * @param {AST.Attribute} node

@ -3,7 +3,7 @@
/** @import { ComponentContext } from '../../types' */ /** @import { ComponentContext } from '../../types' */
import { cannot_be_set_statically } from '../../../../../../utils.js'; import { cannot_be_set_statically } from '../../../../../../utils.js';
import { is_event_attribute, is_text_attribute } from '../../../../../utils/ast.js'; import { is_event_attribute, is_text_attribute } from '../../../../../utils/ast.js';
import * as b from '../../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { is_custom_element_node } from '../../../../nodes.js'; import { is_custom_element_node } from '../../../../nodes.js';
import { build_template_chunk } from './utils.js'; import { build_template_chunk } from './utils.js';

@ -1,7 +1,7 @@
/** @import { Expression } from 'estree' */ /** @import { Expression } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../../types' */ /** @import { ComponentContext } from '../../types' */
import * as b from '../../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* *

@ -3,7 +3,7 @@
/** @import { ComponentClientTransformState, Context } from '../../types' */ /** @import { ComponentClientTransformState, Context } from '../../types' */
import { walk } from 'zimmerframe'; import { walk } from 'zimmerframe';
import { object } from '../../../../../utils/ast.js'; import { object } from '../../../../../utils/ast.js';
import * as b from '../../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { sanitize_template_string } from '../../../../../utils/sanitize_template_string.js'; import { sanitize_template_string } from '../../../../../utils/sanitize_template_string.js';
import { regex_is_valid_identifier } from '../../../../patterns.js'; import { regex_is_valid_identifier } from '../../../../patterns.js';
import is_reference from 'is-reference'; import is_reference from 'is-reference';

@ -5,7 +5,7 @@
import { walk } from 'zimmerframe'; import { walk } from 'zimmerframe';
import { set_scope } from '../../scope.js'; import { set_scope } from '../../scope.js';
import { extract_identifiers } from '../../../utils/ast.js'; import { extract_identifiers } from '../../../utils/ast.js';
import * as b from '../../../utils/builders.js'; import * as b from '#compiler/builders';
import { dev, filename } from '../../../state.js'; import { dev, filename } from '../../../state.js';
import { render_stylesheet } from '../css/index.js'; import { render_stylesheet } from '../css/index.js';
import { AssignmentExpression } from './visitors/AssignmentExpression.js'; import { AssignmentExpression } from './visitors/AssignmentExpression.js';

@ -1,7 +1,7 @@
/** @import { AssignmentExpression, AssignmentOperator, Expression, Pattern } from 'estree' */ /** @import { AssignmentExpression, AssignmentOperator, Expression, Pattern } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { Context, ServerTransformState } from '../types.js' */ /** @import { Context, ServerTransformState } from '../types.js' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { build_assignment_value } from '../../../../utils/ast.js'; import { build_assignment_value } from '../../../../utils/ast.js';
import { visit_assignment_expression } from '../../shared/assignments.js'; import { visit_assignment_expression } from '../../shared/assignments.js';

@ -1,7 +1,7 @@
/** @import { BlockStatement, Expression, Pattern } from 'estree' */ /** @import { BlockStatement, Expression, Pattern } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types.js' */ /** @import { ComponentContext } from '../types.js' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { block_close } from './shared/utils.js'; import { block_close } from './shared/utils.js';
/** /**

@ -1,7 +1,7 @@
/** @import { CallExpression, Expression } from 'estree' */ /** @import { CallExpression, Expression } from 'estree' */
/** @import { Context } from '../types.js' */ /** @import { Context } from '../types.js' */
import { is_ignored } from '../../../../state.js'; import { is_ignored } from '../../../../state.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { get_rune } from '../../../scope.js'; import { get_rune } from '../../../scope.js';
import { transform_inspect_rune } from '../../utils.js'; import { transform_inspect_rune } from '../../utils.js';

@ -2,7 +2,7 @@
/** @import { Context } from '../types.js' */ /** @import { Context } from '../types.js' */
/** @import { StateField } from '../../client/types.js' */ /** @import { StateField } from '../../client/types.js' */
import { dev } from '../../../../state.js'; import { dev } from '../../../../state.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { get_rune } from '../../../scope.js'; import { get_rune } from '../../../scope.js';
/** /**

@ -1,6 +1,6 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types.js' */ /** @import { ComponentContext } from '../types.js' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { build_inline_component } from './shared/component.js'; import { build_inline_component } from './shared/component.js';
/** /**

@ -1,7 +1,7 @@
/** @import { Expression, Pattern } from 'estree' */ /** @import { Expression, Pattern } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types.js' */ /** @import { ComponentContext } from '../types.js' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {AST.ConstTag} node * @param {AST.ConstTag} node

@ -1,7 +1,7 @@
/** @import { Expression } from 'estree' */ /** @import { Expression } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types.js' */ /** @import { ComponentContext } from '../types.js' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {AST.DebugTag} node * @param {AST.DebugTag} node

@ -1,8 +1,8 @@
/** @import { BlockStatement, Expression, Pattern, Statement } from 'estree' */ /** @import { BlockStatement, Expression, Statement } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types.js' */ /** @import { ComponentContext } from '../types.js' */
import { BLOCK_OPEN_ELSE } from '../../../../../internal/server/hydration.js'; import { BLOCK_OPEN_ELSE } from '../../../../../internal/server/hydration.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { block_close, block_open } from './shared/utils.js'; import { block_close, block_open } from './shared/utils.js';
/** /**

@ -1,6 +1,6 @@
/** @import { ExpressionStatement } from 'estree' */ /** @import { ExpressionStatement } from 'estree' */
/** @import { Context } from '../types.js' */ /** @import { Context } from '../types.js' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { get_rune } from '../../../scope.js'; import { get_rune } from '../../../scope.js';
/** /**

@ -1,7 +1,7 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext, ComponentServerTransformState } from '../types.js' */ /** @import { ComponentContext, ComponentServerTransformState } from '../types.js' */
import { clean_nodes, infer_namespace } from '../../utils.js'; import { clean_nodes, infer_namespace } from '../../utils.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { empty_comment, process_children, build_template } from './shared/utils.js'; import { empty_comment, process_children, build_template } from './shared/utils.js';
/** /**

@ -1,7 +1,7 @@
/** @import { Expression } from 'estree' */ /** @import { Expression } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types.js' */ /** @import { ComponentContext } from '../types.js' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {AST.HtmlTag} node * @param {AST.HtmlTag} node

@ -1,7 +1,7 @@
/** @import { Identifier, Node } from 'estree' */ /** @import { Identifier, Node } from 'estree' */
/** @import { Context } from '../types.js' */ /** @import { Context } from '../types.js' */
import is_reference from 'is-reference'; import is_reference from 'is-reference';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { build_getter } from './shared/utils.js'; import { build_getter } from './shared/utils.js';
/** /**

@ -1,8 +1,8 @@
/** @import { BlockStatement, Expression, IfStatement } from 'estree' */ /** @import { BlockStatement, Expression } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types.js' */ /** @import { ComponentContext } from '../types.js' */
import { BLOCK_OPEN_ELSE } from '../../../../../internal/server/hydration.js'; import { BLOCK_OPEN_ELSE } from '../../../../../internal/server/hydration.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { block_close, block_open } from './shared/utils.js'; import { block_close, block_open } from './shared/utils.js';
/** /**

@ -1,6 +1,6 @@
/** @import { ExpressionStatement, LabeledStatement } from 'estree' */ /** @import { ExpressionStatement, LabeledStatement } from 'estree' */
/** @import { Context } from '../types.js' */ /** @import { Context } from '../types.js' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {LabeledStatement} node * @param {LabeledStatement} node

@ -1,6 +1,6 @@
/** @import { MemberExpression } from 'estree' */ /** @import { MemberExpression } from 'estree' */
/** @import { Context } from '../types.js' */ /** @import { Context } from '../types.js' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {MemberExpression} node * @param {MemberExpression} node

@ -1,6 +1,6 @@
/** @import { Expression, PropertyDefinition } from 'estree' */ /** @import { Expression, PropertyDefinition } from 'estree' */
/** @import { Context } from '../types.js' */ /** @import { Context } from '../types.js' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { get_rune } from '../../../scope.js'; import { get_rune } from '../../../scope.js';
/** /**

@ -4,7 +4,7 @@
/** @import { Scope } from '../../../scope.js' */ /** @import { Scope } from '../../../scope.js' */
import { is_void } from '../../../../../utils.js'; import { is_void } from '../../../../../utils.js';
import { dev, locator } from '../../../../state.js'; import { dev, locator } from '../../../../state.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { clean_nodes, determine_namespace_for_children } from '../../utils.js'; import { clean_nodes, determine_namespace_for_children } from '../../utils.js';
import { build_element_attributes } from './shared/element.js'; import { build_element_attributes } from './shared/element.js';
import { process_children, build_template } from './shared/utils.js'; import { process_children, build_template } from './shared/utils.js';

@ -2,7 +2,7 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types.js' */ /** @import { ComponentContext } from '../types.js' */
import { unwrap_optional } from '../../../../utils/ast.js'; import { unwrap_optional } from '../../../../utils/ast.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { empty_comment } from './shared/utils.js'; import { empty_comment } from './shared/utils.js';
/** /**

@ -1,7 +1,7 @@
/** @import { BlockStatement, Expression, Literal, Property } from 'estree' */ /** @import { BlockStatement, Expression, Literal, Property } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types.js' */ /** @import { ComponentContext } from '../types.js' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { empty_comment, build_attribute_value } from './shared/utils.js'; import { empty_comment, build_attribute_value } from './shared/utils.js';
/** /**

@ -2,27 +2,28 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types.js' */ /** @import { ComponentContext } from '../types.js' */
import { dev } from '../../../../state.js'; import { dev } from '../../../../state.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {AST.SnippetBlock} node * @param {AST.SnippetBlock} node
* @param {ComponentContext} context * @param {ComponentContext} context
*/ */
export function SnippetBlock(node, context) { export function SnippetBlock(node, context) {
const fn = b.function_declaration( let fn = b.function_declaration(
node.expression, node.expression,
[b.id('$$payload'), ...node.parameters], [b.id('$$payload'), ...node.parameters],
/** @type {BlockStatement} */ (context.visit(node.body)) /** @type {BlockStatement} */ (context.visit(node.body))
); );
if (dev) {
fn.body.body.unshift(b.stmt(b.call('$.validate_snippet_args', b.id('$$payload'))));
}
// @ts-expect-error - TODO remove this hack once $$render_inner for legacy bindings is gone // @ts-expect-error - TODO remove this hack once $$render_inner for legacy bindings is gone
fn.___snippet = true; fn.___snippet = true;
if (node.metadata.can_hoist) { const statements = node.metadata.can_hoist ? context.state.hoisted : context.state.init;
context.state.hoisted.push(fn);
} else { if (dev) {
context.state.init.push(fn); fn.body.body.unshift(b.stmt(b.call('$.validate_snippet_args', b.id('$$payload'))));
statements.push(b.stmt(b.call('$.prevent_snippet_stringification', fn.id)));
} }
statements.push(fn);
} }

@ -2,7 +2,7 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */ /** @import { ComponentContext } from '../types' */
import { BLOCK_CLOSE, BLOCK_OPEN } from '../../../../../internal/server/hydration.js'; import { BLOCK_CLOSE, BLOCK_OPEN } from '../../../../../internal/server/hydration.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {AST.SvelteBoundary} node * @param {AST.SvelteBoundary} node

@ -3,7 +3,7 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types.js' */ /** @import { ComponentContext } from '../types.js' */
import { dev, locator } from '../../../../state.js'; import { dev, locator } from '../../../../state.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { determine_namespace_for_children } from '../../utils.js'; import { determine_namespace_for_children } from '../../utils.js';
import { build_element_attributes } from './shared/element.js'; import { build_element_attributes } from './shared/element.js';
import { build_template } from './shared/utils.js'; import { build_template } from './shared/utils.js';

@ -1,7 +1,7 @@
/** @import { BlockStatement } from 'estree' */ /** @import { BlockStatement } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types.js' */ /** @import { ComponentContext } from '../types.js' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {AST.SvelteHead} node * @param {AST.SvelteHead} node

@ -1,6 +1,6 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types.js' */ /** @import { ComponentContext } from '../types.js' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { build_inline_component } from './shared/component.js'; import { build_inline_component } from './shared/component.js';
/** /**

@ -1,6 +1,6 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types.js' */ /** @import { ComponentContext } from '../types.js' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { process_children, build_template } from './shared/utils.js'; import { process_children, build_template } from './shared/utils.js';
/** /**

@ -1,6 +1,6 @@
/** @import { UpdateExpression } from 'estree' */ /** @import { UpdateExpression } from 'estree' */
/** @import { Context } from '../types.js' */ /** @import { Context } from '../types.js' */
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @param {UpdateExpression} node * @param {UpdateExpression} node

@ -3,7 +3,7 @@
/** @import { Context } from '../types.js' */ /** @import { Context } from '../types.js' */
/** @import { Scope } from '../../../scope.js' */ /** @import { Scope } from '../../../scope.js' */
import { build_fallback, extract_paths } from '../../../../utils/ast.js'; import { build_fallback, extract_paths } from '../../../../utils/ast.js';
import * as b from '../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { get_rune } from '../../../scope.js'; import { get_rune } from '../../../scope.js';
import { walk } from 'zimmerframe'; import { walk } from 'zimmerframe';

@ -2,8 +2,9 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../../types.js' */ /** @import { ComponentContext } from '../../types.js' */
import { empty_comment, build_attribute_value } from './utils.js'; import { empty_comment, build_attribute_value } from './utils.js';
import * as b from '../../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { is_element_node } from '../../../../nodes.js'; import { is_element_node } from '../../../../nodes.js';
import { dev } from '../../../../../state.js';
/** /**
* @param {AST.Component | AST.SvelteComponent | AST.SvelteSelf} node * @param {AST.Component | AST.SvelteComponent | AST.SvelteSelf} node
@ -238,7 +239,13 @@ export function build_inline_component(node, expression, context) {
) )
) { ) {
// create `children` prop... // create `children` prop...
push_prop(b.prop('init', b.id('children'), slot_fn)); push_prop(
b.prop(
'init',
b.id('children'),
dev ? b.call('$.prevent_snippet_stringification', slot_fn) : slot_fn
)
);
// and `$$slots.default: true` so that `<slot>` on the child works // and `$$slots.default: true` so that `<slot>` on the child works
serialized_slots.push(b.init(slot_name, b.true)); serialized_slots.push(b.init(slot_name, b.true));

@ -1,11 +1,7 @@
/** @import { ArrayExpression, Expression, Literal, ObjectExpression } from 'estree' */ /** @import { ArrayExpression, Expression, Literal, ObjectExpression } from 'estree' */
/** @import { AST, Namespace } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext, ComponentServerTransformState } from '../../types.js' */ /** @import { ComponentContext, ComponentServerTransformState } from '../../types.js' */
import { import { is_event_attribute, is_text_attribute } from '../../../../../utils/ast.js';
get_attribute_chunks,
is_event_attribute,
is_text_attribute
} from '../../../../../utils/ast.js';
import { binding_properties } from '../../../../bindings.js'; import { binding_properties } from '../../../../bindings.js';
import { import {
create_attribute, create_attribute,
@ -13,7 +9,7 @@ import {
is_custom_element_node is_custom_element_node
} from '../../../../nodes.js'; } from '../../../../nodes.js';
import { regex_starts_with_newline } from '../../../../patterns.js'; import { regex_starts_with_newline } from '../../../../patterns.js';
import * as b from '../../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { import {
ELEMENT_IS_NAMESPACED, ELEMENT_IS_NAMESPACED,
ELEMENT_PRESERVE_ATTRIBUTE_CASE ELEMENT_PRESERVE_ATTRIBUTE_CASE

@ -1,4 +1,4 @@
/** @import { AssignmentOperator, Expression, Identifier, Node, Statement, TemplateElement } from 'estree' */ /** @import { AssignmentOperator, Expression, Identifier, Node, Statement } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { ComponentContext, ServerTransformState } from '../../types.js' */ /** @import { ComponentContext, ServerTransformState } from '../../types.js' */
@ -8,7 +8,7 @@ import {
BLOCK_OPEN, BLOCK_OPEN,
EMPTY_COMMENT EMPTY_COMMENT
} from '../../../../../../internal/server/hydration.js'; } from '../../../../../../internal/server/hydration.js';
import * as b from '../../../../../utils/builders.js'; import * as b from '#compiler/builders';
import { sanitize_template_string } from '../../../../../utils/sanitize_template_string.js'; import { sanitize_template_string } from '../../../../../utils/sanitize_template_string.js';
import { regex_whitespaces_strict } from '../../../../patterns.js'; import { regex_whitespaces_strict } from '../../../../patterns.js';

@ -2,7 +2,7 @@
/** @import { Context as ClientContext } from '../client/types.js' */ /** @import { Context as ClientContext } from '../client/types.js' */
/** @import { Context as ServerContext } from '../server/types.js' */ /** @import { Context as ServerContext } from '../server/types.js' */
import { extract_paths, is_expression_async } from '../../../utils/ast.js'; import { extract_paths, is_expression_async } from '../../../utils/ast.js';
import * as b from '../../../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* @template {ClientContext | ServerContext} Context * @template {ClientContext | ServerContext} Context

@ -8,7 +8,7 @@ import {
regex_starts_with_newline, regex_starts_with_newline,
regex_starts_with_whitespaces regex_starts_with_whitespaces
} from '../patterns.js'; } from '../patterns.js';
import * as b from '../../utils/builders.js'; import * as b from '#compiler/builders';
import * as e from '../../errors.js'; import * as e from '../../errors.js';
import { walk } from 'zimmerframe'; import { walk } from 'zimmerframe';
import { extract_identifiers } from '../../utils/ast.js'; import { extract_identifiers } from '../../utils/ast.js';

@ -4,7 +4,7 @@
import is_reference from 'is-reference'; import is_reference from 'is-reference';
import { walk } from 'zimmerframe'; import { walk } from 'zimmerframe';
import { create_expression_metadata } from './nodes.js'; import { create_expression_metadata } from './nodes.js';
import * as b from '../utils/builders.js'; import * as b from '#compiler/builders';
import * as e from '../errors.js'; import * as e from '../errors.js';
import { import {
extract_identifiers, extract_identifiers,
@ -16,10 +16,10 @@ import { is_reserved, is_rune } from '../../utils.js';
import { determine_slot } from '../utils/slot.js'; import { determine_slot } from '../utils/slot.js';
import { validate_identifier_name } from './2-analyze/visitors/shared/utils.js'; import { validate_identifier_name } from './2-analyze/visitors/shared/utils.js';
export const UNKNOWN = Symbol('unknown'); const UNKNOWN = Symbol('unknown');
/** Includes `BigInt` */ /** Includes `BigInt` */
export const NUMBER = Symbol('number'); const NUMBER = Symbol('number');
export const STRING = Symbol('string'); const STRING = Symbol('string');
export class Binding { export class Binding {
/** @type {Scope} */ /** @type {Scope} */

@ -0,0 +1,2 @@
export * from './types/index';
export * from './index';

@ -1,7 +1,7 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import * as ESTree from 'estree' */ /** @import * as ESTree from 'estree' */
import { walk } from 'zimmerframe'; import { walk } from 'zimmerframe';
import * as b from '../utils/builders.js'; import * as b from '#compiler/builders';
/** /**
* Gets the left-most identifier of a member expression or identifier. * Gets the left-most identifier of a member expression or identifier.

@ -22,7 +22,6 @@ export const HYDRATION_START = '[';
/** used to indicate that an `{:else}...` block was rendered */ /** used to indicate that an `{:else}...` block was rendered */
export const HYDRATION_START_ELSE = '[!'; export const HYDRATION_START_ELSE = '[!';
export const HYDRATION_END = ']'; export const HYDRATION_END = ']';
export const HYDRATION_AWAIT_THEN = '!';
export const HYDRATION_ERROR = {}; export const HYDRATION_ERROR = {};
export const ELEMENT_IS_NAMESPACED = 1; export const ELEMENT_IS_NAMESPACED = 1;

@ -114,7 +114,7 @@ function create_custom_event(type, detail, { bubbles = false, cancelable = false
* The event dispatcher can be typed to narrow the allowed event names and the type of the `detail` argument: * The event dispatcher can be typed to narrow the allowed event names and the type of the `detail` argument:
* ```ts * ```ts
* const dispatch = createEventDispatcher<{ * const dispatch = createEventDispatcher<{
* loaded: never; // does not take a detail argument * loaded: null; // does not take a detail argument
* change: string; // takes a detail argument of type string, which is required * change: string; // takes a detail argument of type string, which is required
* optional: number | null; // takes an optional detail argument of type number * optional: number | null; // takes an optional detail argument of type number
* }>(); * }>();

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save