Skip to content

Commit 1775b2c

Browse files
committed
merge main
2 parents 62300f7 + 3d354f0 commit 1775b2c

File tree

155 files changed

+1763
-827
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+1763
-827
lines changed

.changeset/chatty-ghosts-unite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
feat: skip pending block for already-resolved promises

.changeset/fresh-wombats-learn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"svelte": patch
3+
---
4+
5+
fix: allow leading and trailing comments in mustache expression

.changeset/giant-jars-applaud.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: ensure hydration walks all nodes

.changeset/hip-months-breathe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: show correct errors for invalid runes in `.svelte.js` files

.changeset/itchy-lemons-punch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: always pass original component to HMR wrapper

.changeset/little-seals-reflect.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
feat: add ability to ignore warnings through `warningFilter` compiler option

.changeset/perfect-actors-bake.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
breaking: use structuredClone inside `$state.snapshot`

.changeset/perfect-hats-dance.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: prevent whitespaces merging across component boundaries

.changeset/pre.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"calm-ravens-sneeze",
5959
"chatty-beans-divide",
6060
"chatty-cups-drop",
61+
"chatty-ghosts-unite",
6162
"chatty-sloths-allow",
6263
"chatty-taxis-juggle",
6364
"chilled-pumas-invite",
@@ -192,6 +193,7 @@
192193
"fresh-impalas-bow",
193194
"fresh-walls-bathe",
194195
"fresh-weeks-trade",
196+
"fresh-wombats-learn",
195197
"friendly-candles-relate",
196198
"friendly-clouds-rhyme",
197199
"friendly-lies-camp",
@@ -211,6 +213,7 @@
211213
"gentle-trees-exercise",
212214
"gentle-wasps-pull",
213215
"giant-bananas-turn",
216+
"giant-jars-applaud",
214217
"giant-moons-own",
215218
"giant-planets-shake",
216219
"giant-plants-grin",
@@ -252,6 +255,7 @@
252255
"heavy-ears-rule",
253256
"hip-balloons-begin",
254257
"hip-garlics-tap",
258+
"hip-months-breathe",
255259
"hip-pumpkins-boil",
256260
"honest-buses-add",
257261
"honest-dragons-turn",
@@ -318,6 +322,7 @@
318322
"light-pens-watch",
319323
"little-ligers-exist",
320324
"little-pans-jog",
325+
"little-seals-reflect",
321326
"long-buckets-lay",
322327
"long-carrots-sneeze",
323328
"long-crews-return",
@@ -408,6 +413,8 @@
408413
"orange-masks-exercise",
409414
"orange-yaks-protect",
410415
"orange-zoos-heal",
416+
"perfect-actors-bake",
417+
"perfect-hats-dance",
411418
"pink-bikes-agree",
412419
"pink-goats-promise",
413420
"pink-mayflies-tie",
@@ -505,6 +512,7 @@
505512
"short-buses-camp",
506513
"short-countries-rush",
507514
"shy-fishes-drive",
515+
"shy-scissors-smile",
508516
"silent-apes-report",
509517
"silent-hats-stare",
510518
"silent-rabbits-join",
@@ -628,6 +636,7 @@
628636
"thin-foxes-lick",
629637
"thin-spoons-float",
630638
"thin-years-rhyme",
639+
"thirty-dogs-whisper",
631640
"thirty-flies-push",
632641
"thirty-flowers-sit",
633642
"thirty-ghosts-fix",
@@ -655,6 +664,7 @@
655664
"tough-buckets-thank",
656665
"tough-radios-punch",
657666
"tough-tomatoes-explain",
667+
"tricky-avocados-play",
658668
"tricky-ears-shout",
659669
"tricky-laws-bathe",
660670
"twelve-beans-drive",
@@ -683,6 +693,7 @@
683693
"wet-games-fly",
684694
"wet-pears-remain",
685695
"wet-wombats-repeat",
696+
"wicked-bikes-matter",
686697
"wicked-clouds-exercise",
687698
"wicked-doors-train",
688699
"wicked-emus-drive",
@@ -709,6 +720,7 @@
709720
"witty-steaks-dream",
710721
"witty-tomatoes-care",
711722
"witty-years-crash",
723+
"yellow-bananas-rhyme",
712724
"yellow-pugs-raise",
713725
"yellow-rockets-sit",
714726
"yellow-taxis-double",

.changeset/shy-scissors-smile.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: properly validate snippet/slot interop

.changeset/thirty-dogs-whisper.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: detect mutations within assignment expressions

.changeset/tricky-avocados-play.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: cache call expressions in render tag arguments

.changeset/wicked-carrots-explain.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: ensure previous transitions are properly aborted

.changeset/yellow-bananas-rhyme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: run animations in microtask so that deferred transitions can measure nodes correctly

documentation/docs/03-runes/01-state.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,32 +66,33 @@ Objects and arrays are made deeply reactive by wrapping them with [`Proxies`](ht
6666
<button onclick={() => (entries[1].text = 'baz')}>change second entry text</button>
6767
```
6868

69-
> Only POJOs (plain of JavaScript objects) are made deeply reactive. Reactivity will stop at class boundaries and leave those alone
69+
> Only POJOs (plain old JavaScript objects) are made deeply reactive. Reactivity will stop at class boundaries and leave those alone
7070
7171
## `$state.frozen`
7272

7373
State declared with `$state.frozen` cannot be mutated; it can only be _reassigned_. In other words, rather than assigning to a property of an object, or using an array method like `push`, replace the object or array altogether if you'd like to update it:
7474

75-
```svelte
76-
<script>
77-
let entries = $state([
78-
{ id: 1, text: 'foo' },
79-
{ id: 2, text: 'bar' }
80-
]);
81-
</script>
75+
```js
76+
let person = $state.frozen({
77+
name: 'Heraclitus',
78+
age: 49
79+
});
8280

83-
{#each entries as entry (entry.id)}
84-
{entry.text}
85-
{/each}
81+
// this will have no effect (and will throw an error in dev)
82+
person.age += 1;
8683

87-
<button onclick={() => (entries = [entries[0], { id: entries[1].id, text: 'baz' }])}
88-
>change second entry text</button
89-
>
84+
// this will work, because we're creating a new person
85+
person = {
86+
name: 'Heraclitus',
87+
age: 50
88+
};
9089
```
9190

9291
This can improve performance with large arrays and objects that you weren't planning to mutate anyway, since it avoids the cost of making them reactive. Note that frozen state can _contain_ reactive state (for example, a frozen array of reactive objects).
9392

94-
> Objects and arrays passed to `$state.frozen` will be shallowly frozen using `Object.freeze()`. If you don't want this, pass in a clone of the object or array instead.
93+
In development mode, the argument to `$state.frozen` will be shallowly frozen with `Object.freeze()`, to make it obvious if you accidentally mutate it.
94+
95+
> Objects and arrays passed to `$state.frozen` will have a `Symbol` property added to them to signal to Svelte that they are frozen. If you don't want this, pass in a clone of the object or array instead. The argument cannot be an existing state proxy created with `$state(...)`.
9596
9697
## `$state.snapshot`
9798

documentation/docs/03-runes/02-side-effects.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,16 +245,16 @@ In rare cases, you may need to run code _before_ the DOM updates. For this we ca
245245
<script>
246246
import { tick } from 'svelte';
247247
248-
let div;
249-
let messages = [];
248+
let div = $state();
249+
let messages = $state([]);
250250
251251
// ...
252252
253253
$effect.pre(() => {
254254
if (!div) return; // not yet mounted
255255
256-
// reference `messages` so that this code re-runs whenever it changes
257-
messages;
256+
// reference `messages` array length so that this code re-runs whenever it changes
257+
messages.length;
258258
259259
// autoscroll when new messages are added
260260
if (div.offsetHeight + div.scrollTop > div.scrollHeight - 20) {

packages/svelte/CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,45 @@
11
# svelte
22

3+
## 5.0.0-next.186
4+
5+
### Patch Changes
6+
7+
- feat: skip pending block for already-resolved promises ([#12274](https://github.com/sveltejs/svelte/pull/12274))
8+
9+
- feat: add ability to ignore warnings through `warningFilter` compiler option ([#12296](https://github.com/sveltejs/svelte/pull/12296))
10+
11+
- fix: run animations in microtask so that deferred transitions can measure nodes correctly ([#12453](https://github.com/sveltejs/svelte/pull/12453))
12+
13+
## 5.0.0-next.185
14+
15+
### Patch Changes
16+
17+
- fix: allow leading and trailing comments in mustache expression ([#11866](https://github.com/sveltejs/svelte/pull/11866))
18+
19+
- fix: ensure hydration walks all nodes ([#12448](https://github.com/sveltejs/svelte/pull/12448))
20+
21+
- fix: prevent whitespaces merging across component boundaries ([#12449](https://github.com/sveltejs/svelte/pull/12449))
22+
23+
- fix: detect mutations within assignment expressions ([#12429](https://github.com/sveltejs/svelte/pull/12429))
24+
25+
## 5.0.0-next.184
26+
27+
### Patch Changes
28+
29+
- fix: show correct errors for invalid runes in `.svelte.js` files ([#12432](https://github.com/sveltejs/svelte/pull/12432))
30+
31+
- breaking: use structuredClone inside `$state.snapshot` ([#12413](https://github.com/sveltejs/svelte/pull/12413))
32+
33+
## 5.0.0-next.183
34+
35+
### Patch Changes
36+
37+
- fix: properly validate snippet/slot interop ([#12421](https://github.com/sveltejs/svelte/pull/12421))
38+
39+
- fix: cache call expressions in render tag arguments ([#12418](https://github.com/sveltejs/svelte/pull/12418))
40+
41+
- fix: optimize `bind:group` ([#12406](https://github.com/sveltejs/svelte/pull/12406))
42+
343
## 5.0.0-next.182
444

545
### Patch Changes

packages/svelte/messages/client-errors/errors.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060

6161
> The `%rune%` rune is only available inside `.svelte` and `.svelte.js/ts` files
6262
63+
## state_frozen_invalid_argument
64+
65+
> The argument to `$state.frozen(...)` cannot be an object created with `$state(...)`. You should create a copy of it first, for example with `$state.snapshot`
66+
6367
## state_prototype_fixed
6468

6569
> Cannot set prototype of `$state` object

packages/svelte/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "svelte",
33
"description": "Cybernetically enhanced web apps",
44
"license": "MIT",
5-
"version": "5.0.0-next.182",
5+
"version": "5.0.0-next.186",
66
"type": "module",
77
"types": "./types/index.d.ts",
88
"engines": {

packages/svelte/scripts/process-messages/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,11 @@ function transform(name, dest) {
129129
}
130130
});
131131

132+
if (comments.length > 0) {
133+
// @ts-expect-error
134+
(ast.trailingComments ||= []).push(...comments);
135+
}
136+
132137
const category = messages[name];
133138

134139
// find the `export function CODE` node

packages/svelte/scripts/process-messages/templates/compile-warnings.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { warnings, ignore_stack, ignore_map } from './state.js';
1+
import { warnings, ignore_stack, ignore_map, warning_filter } from './state.js';
22
import { CompileDiagnostic } from './utils/compile_diagnostic.js';
33

44
/** @typedef {{ start?: number, end?: number }} NodeLike */
@@ -28,13 +28,15 @@ function w(node, code, message) {
2828
}
2929
if (stack && stack.at(-1)?.has(code)) return;
3030

31-
warnings.push(
32-
new InternalCompileWarning(
33-
code,
34-
message,
35-
node && node.start !== undefined ? [node.start, node.end ?? node.start] : undefined
36-
)
31+
const warning = new InternalCompileWarning(
32+
code,
33+
message,
34+
node && node.start !== undefined ? [node.start, node.end ?? node.start] : undefined
3735
);
36+
37+
if (!warning_filter(warning)) return;
38+
39+
warnings.push(warning);
3840
}
3941

4042
export const codes = CODES;

0 commit comments

Comments
 (0)