Merge remote-tracking branch 'origin/main' into svelte-custom-renderer

svelte-custom-renderer
paoloricciuti 2 months ago
commit 216f258068

@ -1,5 +0,0 @@
---
'svelte': patch
---
chore: drop dead code that make TSGO fail

@ -1,5 +0,0 @@
---
'svelte': patch
---
fix: don't (re)connect deriveds when read inside branch/root effects

@ -1,5 +0,0 @@
---
'svelte': patch
---
fix: skip unnecessary derived effect in earlier batch

@ -1,5 +0,0 @@
---
'svelte': patch
---
fix: avoid declaration tag warning in event handlers

@ -1,5 +0,0 @@
---
'svelte': patch
---
fix: abort deriveds own AbortSignal when it disconnects

@ -1,5 +0,0 @@
---
'svelte': patch
---
fix: ensure `$state.eager()` is correctly transormed for SSR output

@ -1,5 +0,0 @@
---
'svelte': patch
---
fix: correctly transform declaration tags during SSR

@ -1,5 +0,0 @@
---
'svelte': patch
---
fix: transform computed keys in keyed `{#each}` destructuring patterns

@ -1,5 +0,0 @@
---
'svelte': patch
---
fix: chain preprocessor sourcemaps with an empty `sources[0]` instead of dropping them

@ -1,5 +0,0 @@
---
"svelte": patch
---
fix: clear previous_task reference after abort in Tween to prevent memory leak on interrupted tweens

@ -1,5 +0,0 @@
---
'svelte': patch
---
fix: don't treat declaration tags as parts inside each blocks

@ -109,7 +109,7 @@ By default, error boundaries have no effect on the server — if an error occurs
Since 5.51 you can control this behaviour for boundaries with a `failed` snippet, by calling [`render(...)`](imperative-component-api#render) with a `transformError` function. Since 5.51 you can control this behaviour for boundaries with a `failed` snippet, by calling [`render(...)`](imperative-component-api#render) with a `transformError` function.
> [!NOTE] If you're using Svelte via a framework such as SvelteKit, you most likely don't have direct access to the `render(...)` call — the framework must configure `transformError` on your behalf. SvelteKit will add support for this in the near future, via the [`handleError`](../kit/hooks#Shared-hooks-handleError) hook. > [!NOTE] If you're using Svelte via a framework such as SvelteKit, you most likely don't have direct access to the `render(...)` call — the framework must configure `transformError` on your behalf. SvelteKit will add support for this in the near future, via the [`handleError`](../kit/hooks#handleError) hook.
The `transformError` function must return a JSON-stringifiable object which will be used to render the `failed` snippet. This object will be serialized and used to hydrate the snippet in the browser: The `transformError` function must return a JSON-stringifiable object which will be used to render the `failed` snippet. This object will be serialized and used to hydrate the snippet in the browser:

@ -1,5 +1,45 @@
# svelte # svelte
## 5.56.7
### Patch Changes
- chore: provide `indent` option for `print` ([#18474](https://github.com/sveltejs/svelte/pull/18474))
## 5.56.6
### Patch Changes
- perf: skip unnecessary blocker analysis when compiling components without top-level await ([#18548](https://github.com/sveltejs/svelte/pull/18548))
- fix: rerun derived that had an abort controller on reconnection ([#18551](https://github.com/sveltejs/svelte/pull/18551))
## 5.56.5
### Patch Changes
- chore: drop dead code that make TSGO fail ([#18496](https://github.com/sveltejs/svelte/pull/18496))
- fix: don't (re)connect deriveds when read inside branch/root effects ([#18527](https://github.com/sveltejs/svelte/pull/18527))
- fix: skip unnecessary derived effect in earlier batch ([#18525](https://github.com/sveltejs/svelte/pull/18525))
- fix: avoid declaration tag warning in event handlers ([#18500](https://github.com/sveltejs/svelte/pull/18500))
- fix: abort deriveds own AbortSignal when it disconnects ([#18400](https://github.com/sveltejs/svelte/pull/18400))
- fix: ensure `$state.eager()` is correctly transormed for SSR output ([#18530](https://github.com/sveltejs/svelte/pull/18530))
- fix: correctly transform declaration tags during SSR ([#18492](https://github.com/sveltejs/svelte/pull/18492))
- fix: transform computed keys in keyed `{#each}` destructuring patterns ([#18521](https://github.com/sveltejs/svelte/pull/18521))
- fix: chain preprocessor sourcemaps with an empty `sources[0]` instead of dropping them ([#18518](https://github.com/sveltejs/svelte/pull/18518))
- fix: clear previous_task reference after abort in Tween to prevent memory leak on interrupted tweens ([#18541](https://github.com/sveltejs/svelte/pull/18541))
- fix: don't treat declaration tags as parts inside each blocks ([#18507](https://github.com/sveltejs/svelte/pull/18507))
## 5.56.4 ## 5.56.4
### Patch Changes ### Patch Changes

@ -2,7 +2,7 @@
"name": "svelte", "name": "svelte",
"description": "Cybernetically enhanced web apps", "description": "Cybernetically enhanced web apps",
"license": "MIT", "license": "MIT",
"version": "5.56.4", "version": "5.56.7",
"type": "module", "type": "module",
"types": "./types/index.d.ts", "types": "./types/index.d.ts",
"engines": { "engines": {

@ -1230,6 +1230,10 @@ function calculate_blockers(instance, analysis) {
} }
} }
// With no top-level await, no binding can have a blocker and function tracing
// cannot affect the output.
if (!awaited) return;
flush_sync_group(); flush_sync_group();
for (const fn of functions) { for (const fn of functions) {

@ -30,7 +30,10 @@ export function print(ast, options = undefined) {
}), }),
...svelte_visitors(comments), ...svelte_visitors(comments),
...css_visitors ...css_visitors
}) }),
{
indent: options?.indent
}
); );
} }

@ -4,4 +4,5 @@ import type ts from 'esrap/languages/ts';
export type Options = { export type Options = {
getLeadingComments?: NonNullable<Parameters<typeof ts>[0]>['getLeadingComments'] | undefined; getLeadingComments?: NonNullable<Parameters<typeof ts>[0]>['getLeadingComments'] | undefined;
getTrailingComments?: NonNullable<Parameters<typeof ts>[0]>['getTrailingComments'] | undefined; getTrailingComments?: NonNullable<Parameters<typeof ts>[0]>['getTrailingComments'] | undefined;
indent?: string; // default tab
}; };

@ -414,6 +414,8 @@ function remove_reaction(signal, dependency) {
without_reactive_context(() => { without_reactive_context(() => {
/** @type {AbortController} */ (derived.ac).abort(STALE_REACTION); /** @type {AbortController} */ (derived.ac).abort(STALE_REACTION);
derived.ac = null; derived.ac = null;
// ensure it reruns right away next time instead of potentially returning a rejected promise as its value
set_signal_status(derived, DIRTY);
}); });
} }

@ -4,5 +4,5 @@
* The current version, as set in package.json. * The current version, as set in package.json.
* @type {string} * @type {string}
*/ */
export const VERSION = '5.56.4'; export const VERSION = '5.56.7';
export const PUBLIC_VERSION = '5'; export const PUBLIC_VERSION = '5';

@ -0,0 +1,32 @@
import { test } from '../../test';
import { tick } from 'svelte';
export default test({
async test({ assert, target }) {
const [increment, toggle, resolve] = target.querySelectorAll('button');
const [div] = target.querySelectorAll('div');
assert.htmlEqual(div.innerHTML, 'loading');
resolve.click();
await tick();
assert.htmlEqual(div.innerHTML, '0');
increment.click();
await tick();
assert.htmlEqual(div.innerHTML, 'loading');
toggle.click();
await tick();
assert.htmlEqual(div.innerHTML, '');
toggle.click();
await tick();
assert.htmlEqual(div.innerHTML, 'loading');
resolve.click(); // this one's for clearing the obsolete/aborted one from the queue
await tick();
resolve.click();
await tick();
assert.htmlEqual(div.innerHTML, '2');
}
});

@ -0,0 +1,32 @@
<script>
import { getAbortSignal } from 'svelte'
let show = $state(true)
let count = $state(0);
let queued = [];
export function sleep(value, signal) {
return new Promise((resolve, reject) => {
signal.addEventListener('abort', reject, { once: true });
queued.push(() => resolve(value));
});
}
const double = $derived(sleep(count * 2, getAbortSignal()));
</script>
<button onclick={() => count += 1}>clicks: {count}</button>
<button onclick={() => show = !show}>toggle</button>
<button onclick={() => queued.shift()?.()}>resolve</button>
<div>
{#if show}
{#await double}
loading
{:then value}
{value}
{:catch}
error
{/await}
{/if}
</div>

@ -1905,6 +1905,7 @@ declare module 'svelte/compiler' {
type Options = { type Options = {
getLeadingComments?: NonNullable<Parameters<typeof ts>[0]>['getLeadingComments'] | undefined; getLeadingComments?: NonNullable<Parameters<typeof ts>[0]>['getLeadingComments'] | undefined;
getTrailingComments?: NonNullable<Parameters<typeof ts>[0]>['getTrailingComments'] | undefined; getTrailingComments?: NonNullable<Parameters<typeof ts>[0]>['getTrailingComments'] | undefined;
indent?: string; // default tab
}; };
export {}; export {};

Loading…
Cancel
Save