Skip to content

Commit e3b84d5

Browse files
committed
merge main
2 parents 4201cf7 + 87d4b12 commit e3b84d5

File tree

45 files changed

+268
-69
lines changed

Some content is hidden

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

45 files changed

+268
-69
lines changed

.changeset/big-geese-act.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: only throw bind error when not passing a value

.changeset/cyan-spies-grin.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: improve global transition handling of effect cleardown

.changeset/dirty-donuts-yell.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: replace `$derived.call` with `$derived.by`

.changeset/gentle-dolls-juggle.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: improve global transition outro handling

.changeset/orange-crews-rescue.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: improve handling of object property deletions

.changeset/pre.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"beige-rabbits-shave",
1818
"big-cars-serve",
1919
"big-eyes-carry",
20+
"big-geese-act",
2021
"blue-timers-film",
2122
"brave-shrimps-kiss",
2223
"brave-walls-destroy",
@@ -38,7 +39,9 @@
3839
"curvy-cups-cough",
3940
"curvy-ties-shout",
4041
"cyan-flowers-destroy",
42+
"cyan-spies-grin",
4143
"dirty-bats-punch",
44+
"dirty-donuts-yell",
4245
"dirty-garlics-design",
4346
"dirty-tips-add",
4447
"dry-clocks-grow",
@@ -73,6 +76,7 @@
7376
"friendly-candles-relate",
7477
"friendly-lies-camp",
7578
"funny-wombats-argue",
79+
"gentle-dolls-juggle",
7680
"gentle-sheep-hug",
7781
"gentle-spies-happen",
7882
"giant-moons-own",
@@ -116,6 +120,7 @@
116120
"light-pens-watch",
117121
"long-buckets-lay",
118122
"long-crews-return",
123+
"long-lobsters-mate",
119124
"loud-cheetahs-flow",
120125
"loud-ravens-drop",
121126
"lovely-carpets-lick",
@@ -124,6 +129,7 @@
124129
"lucky-schools-hang",
125130
"lucky-toes-begin",
126131
"many-trees-fix",
132+
"mighty-files-hammer",
127133
"moody-frogs-exist",
128134
"moody-owls-cry",
129135
"nasty-lions-double",
@@ -145,7 +151,9 @@
145151
"olive-seals-sell",
146152
"olive-shirts-complain",
147153
"olive-socks-kick",
154+
"orange-crews-rescue",
148155
"orange-dingos-poke",
156+
"pink-mayflies-tie",
149157
"polite-dolphins-care",
150158
"polite-pumpkins-guess",
151159
"polite-ravens-study",
@@ -183,6 +191,7 @@
183191
"shiny-baboons-play",
184192
"shiny-shrimps-march",
185193
"short-buses-camp",
194+
"silent-apes-report",
186195
"silver-points-approve",
187196
"sixty-items-crash",
188197
"slimy-clouds-talk",
@@ -201,6 +210,7 @@
201210
"sour-forks-stare",
202211
"sour-rules-march",
203212
"sour-weeks-fix",
213+
"spicy-jeans-deliver",
204214
"spicy-plums-admire",
205215
"spotty-pens-agree",
206216
"spotty-spiders-compare",

.changeset/spicy-jeans-deliver.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 inspect fires on prop changes

documentation/docs/05-misc/01-faq.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,16 @@ Some resources for getting started with testing:
9292

9393
The official routing library is [SvelteKit](https://kit.svelte.dev/). SvelteKit provides a filesystem router, server-side rendering (SSR), and hot module reloading (HMR) in one easy-to-use package. It shares similarities with Next.js for React.
9494

95-
However, you can use any router library. A lot of people use [page.js](https://github.com/visionmedia/page.js). There's also [navaid](https://github.com/lukeed/navaid), which is very similar. And [universal-router](https://github.com/kriasoft/universal-router), which is isomorphic with child routes, but without built-in history support.
95+
However, you can use any router library. Some framework-agnostic libraries include [navaid](https://github.com/lukeed/navaid); [universal-router](https://github.com/kriasoft/universal-router), which is isomorphic; [Hono](https://hono.dev/), which supports multiple JS runtimes; and [TanStack Router](https://github.com/TanStack/router/tree/beta-agnostic), which is typesafe and supports caching.
9696

97-
If you prefer a declarative HTML approach, there's the isomorphic [svelte-routing](https://github.com/EmilTholin/svelte-routing) library and a fork of it called [svelte-navigator](https://github.com/mefechoel/svelte-navigator) containing some additional functionality.
97+
If you prefer a declarative HTML approach, the isomorphic [svelte-routing](https://github.com/EmilTholin/svelte-routing) and [svelte-pilot](https://svelte-pilot.github.io/en/link#toc) libraries are available.
9898

9999
If you need hash-based routing on the client side, check out [svelte-spa-router](https://github.com/ItalyPaleAle/svelte-spa-router) or [abstract-state-router](https://github.com/TehShrike/abstract-state-router/).
100100

101101
[Routify](https://routify.dev) is another filesystem-based router, similar to SvelteKit's router. Version 3 supports Svelte's native SSR.
102102

103+
[Vike](https://vike.dev/svelte) is another Vite-based router, like SvelteKit's router, but is still experimental.
104+
103105
You can see a [community-maintained list of routers on sveltesociety.dev](https://sveltesociety.dev/components#routers).
104106

105107
## Can I tell Svelte not to remove my unused styles?

packages/svelte/CHANGELOG.md

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

3+
## 5.0.0-next.54
4+
5+
### Patch Changes
6+
7+
- breaking: replace `$derived.call` with `$derived.by` ([#10445](https://github.com/sveltejs/svelte/pull/10445))
8+
9+
- fix: improve global transition outro handling ([#10474](https://github.com/sveltejs/svelte/pull/10474))
10+
11+
## 5.0.0-next.53
12+
13+
### Patch Changes
14+
15+
- fix: only throw bind error when not passing a value ([#10090](https://github.com/sveltejs/svelte/pull/10090))
16+
17+
- fix: improve global transition handling of effect cleardown ([#10469](https://github.com/sveltejs/svelte/pull/10469))
18+
19+
- fix: improve handling of object property deletions ([#10456](https://github.com/sveltejs/svelte/pull/10456))
20+
21+
- fix: ensure inspect fires on prop changes ([#10468](https://github.com/sveltejs/svelte/pull/10468))
22+
23+
## 5.0.0-next.52
24+
25+
### Patch Changes
26+
27+
- fix: use hybrid scoping strategy for consistent specificity increase ([#10443](https://github.com/sveltejs/svelte/pull/10443))
28+
29+
- fix: throw validation error when binding to each argument in runes mode ([#10441](https://github.com/sveltejs/svelte/pull/10441))
30+
31+
- fix: make CSS animation declaration transformation more robust ([#10432](https://github.com/sveltejs/svelte/pull/10432))
32+
33+
- fix: handle sole empty expression tags ([#10433](https://github.com/sveltejs/svelte/pull/10433))
34+
335
## 5.0.0-next.51
436

537
### Patch Changes

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.51",
5+
"version": "5.0.0-next.54",
66
"type": "module",
77
"types": "./types/index.d.ts",
88
"engines": {

packages/svelte/src/compiler/errors.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ const runes = {
210210
'invalid-runes-mode-import': (name) => `${name} cannot be used in runes mode`,
211211
'duplicate-props-rune': () => `Cannot use $props() more than once`,
212212
'invalid-each-assignment': () =>
213-
`Cannot reassign or bind to each block argument in runes mode. Use the array and index variables instead (e.g. 'array[i] = value' instead of 'entry = value')`
213+
`Cannot reassign or bind to each block argument in runes mode. Use the array and index variables instead (e.g. 'array[i] = value' instead of 'entry = value')`,
214+
'invalid-derived-call': () => `$derived.call(...) has been replaced with $derived.by(...)`
214215
};
215216

216217
/** @satisfies {Errors} */

packages/svelte/src/compiler/phases/1-parse/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ export class Parser {
147147

148148
/**
149149
* @param {string} str
150-
* @param {boolean} [required]
150+
* @param {boolean} required
151151
*/
152152
eat(str, required = false) {
153153
if (this.match(str)) {

packages/svelte/src/compiler/phases/2-analyze/css/Selector.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ function apply_selector(blocks, node, stylesheet) {
293293
matched = true;
294294
}
295295
}
296-
297296
if (matched) {
298297
return mark(block, node);
299298
}

packages/svelte/src/compiler/phases/2-analyze/css/Stylesheet.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ export class Rule {
8282
this.children.forEach((rule) => rule.apply(node));
8383
}
8484

85-
/**
86-
* @returns {boolean}
87-
*/
85+
/** @returns {boolean} */
8886
is_empty() {
8987
if (this.declarations.length > 0) return false;
9088

@@ -95,9 +93,7 @@ export class Rule {
9593
return true;
9694
}
9795

98-
/**
99-
* @returns {boolean}
100-
*/
96+
/** @returns {boolean} */
10197
is_used() {
10298
if (this.parent instanceof Atrule && is_keyframes_node(this.parent.node)) {
10399
return true;
@@ -298,7 +294,7 @@ class Atrule {
298294
}
299295

300296
is_empty() {
301-
return true; // TODO
297+
return false; // TODO
302298
}
303299

304300
is_used() {

packages/svelte/src/compiler/phases/2-analyze/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ const runes_scope_js_tweaker = {
681681
rune !== '$state' &&
682682
rune !== '$state.frozen' &&
683683
rune !== '$derived' &&
684-
rune !== '$derived.call'
684+
rune !== '$derived.by'
685685
)
686686
return;
687687

@@ -717,7 +717,7 @@ const runes_scope_tweaker = {
717717
rune !== '$state' &&
718718
rune !== '$state.frozen' &&
719719
rune !== '$derived' &&
720-
rune !== '$derived.call' &&
720+
rune !== '$derived.by' &&
721721
rune !== '$props'
722722
)
723723
return;
@@ -730,7 +730,7 @@ const runes_scope_tweaker = {
730730
? 'state'
731731
: rune === '$state.frozen'
732732
? 'frozen_state'
733-
: rune === '$derived' || rune === '$derived.call'
733+
: rune === '$derived' || rune === '$derived.by'
734734
? 'derived'
735735
: path.is_rest
736736
? 'rest_prop'

packages/svelte/src/compiler/phases/2-analyze/validation.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ function validate_call_expression(node, scope, path) {
746746
error(node, 'invalid-props-location');
747747
}
748748

749-
if (rune === '$state' || rune === '$derived' || rune === '$derived.call') {
749+
if (rune === '$state' || rune === '$derived' || rune === '$derived.by') {
750750
if (parent.type === 'VariableDeclarator') return;
751751
if (parent.type === 'PropertyDefinition' && !parent.static && !parent.computed) return;
752752
error(node, 'invalid-state-location', rune);
@@ -817,7 +817,7 @@ export const validation_runes_js = {
817817

818818
const args = /** @type {import('estree').CallExpression} */ (init).arguments;
819819

820-
if ((rune === '$derived' || rune === '$derived.call') && args.length !== 1) {
820+
if ((rune === '$derived' || rune === '$derived.by') && args.length !== 1) {
821821
error(node, 'invalid-rune-args-length', rune, [1]);
822822
} else if (rune === '$state' && args.length > 1) {
823823
error(node, 'invalid-rune-args-length', rune, [0, 1]);
@@ -842,7 +842,7 @@ export const validation_runes_js = {
842842
definition.value?.type === 'CallExpression'
843843
) {
844844
const rune = get_rune(definition.value, context.state.scope);
845-
if (rune === '$derived' || rune === '$derived.call') {
845+
if (rune === '$derived' || rune === '$derived.by') {
846846
private_derived_state.push(definition.key.name);
847847
}
848848
}
@@ -988,7 +988,7 @@ export const validation_runes = merge(validation, a11y_validators, {
988988
const args = /** @type {import('estree').CallExpression} */ (init).arguments;
989989

990990
// TODO some of this is duplicated with above, seems off
991-
if ((rune === '$derived' || rune === '$derived.call') && args.length !== 1) {
991+
if ((rune === '$derived' || rune === '$derived.by') && args.length !== 1) {
992992
error(node, 'invalid-rune-args-length', rune, [1]);
993993
} else if (rune === '$state' && args.length > 1) {
994994
error(node, 'invalid-rune-args-length', rune, [0, 1]);

packages/svelte/src/compiler/phases/3-transform/client/visitors/javascript-runes.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const javascript_visitors_runes = {
3333
rune === '$state' ||
3434
rune === '$state.frozen' ||
3535
rune === '$derived' ||
36-
rune === '$derived.call'
36+
rune === '$derived.by'
3737
) {
3838
/** @type {import('../types.js').StateField} */
3939
const field = {
@@ -42,7 +42,7 @@ export const javascript_visitors_runes = {
4242
? 'state'
4343
: rune === '$state.frozen'
4444
? 'frozen_state'
45-
: rune === '$derived.call'
45+
: rune === '$derived.by'
4646
? 'derived_call'
4747
: 'derived',
4848
// @ts-expect-error this is set in the next pass
@@ -289,12 +289,12 @@ export const javascript_visitors_runes = {
289289
continue;
290290
}
291291

292-
if (rune === '$derived' || rune === '$derived.call') {
292+
if (rune === '$derived' || rune === '$derived.by') {
293293
if (declarator.id.type === 'Identifier') {
294294
declarations.push(
295295
b.declarator(
296296
declarator.id,
297-
b.call('$.derived', rune === '$derived.call' ? value : b.thunk(value))
297+
b.call('$.derived', rune === '$derived.by' ? value : b.thunk(value))
298298
)
299299
);
300300
} else {
@@ -307,7 +307,7 @@ export const javascript_visitors_runes = {
307307
'$.derived',
308308
b.thunk(
309309
b.block([
310-
b.let(declarator.id, rune === '$derived.call' ? b.call(value) : value),
310+
b.let(declarator.id, rune === '$derived.by' ? b.call(value) : value),
311311
b.return(b.array(bindings.map((binding) => binding.node)))
312312
])
313313
)

packages/svelte/src/compiler/phases/3-transform/server/transform-server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ const javascript_visitors_runes = {
548548
: /** @type {import('estree').Expression} */ (visit(node.value.arguments[0]))
549549
};
550550
}
551-
if (rune === '$derived.call') {
551+
if (rune === '$derived.by') {
552552
return {
553553
...node,
554554
value:
@@ -582,7 +582,7 @@ const javascript_visitors_runes = {
582582
? b.id('undefined')
583583
: /** @type {import('estree').Expression} */ (visit(args[0]));
584584

585-
if (rune === '$derived.call') {
585+
if (rune === '$derived.by') {
586586
declarations.push(
587587
b.declarator(
588588
/** @type {import('estree').Pattern} */ (visit(declarator.id)),

packages/svelte/src/compiler/phases/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const Runes = /** @type {const} */ ([
3333
'$state.frozen',
3434
'$props',
3535
'$derived',
36-
'$derived.call',
36+
'$derived.by',
3737
'$effect',
3838
'$effect.pre',
3939
'$effect.active',

packages/svelte/src/compiler/phases/scope.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,8 @@ export function get_rune(node, scope) {
717717
if (n.type !== 'Identifier') return null;
718718

719719
joined = n.name + joined;
720+
721+
if (joined === '$derived.call') error(node, 'invalid-derived-call');
720722
if (!Runes.includes(/** @type {any} */ (joined))) return null;
721723

722724
const binding = scope.get(n.name);

packages/svelte/src/compiler/warnings.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ const runes = {
2424
/** @param {string} name */
2525
'non-state-reference': (name) =>
2626
`${name} is updated, but is not declared with $state(...). Changing its value will not correctly trigger updates.`,
27-
'derived-iife': () =>
28-
`Use \`$derived.call(() => {...})\` instead of \`$derived((() => {...})());\``
27+
'derived-iife': () => `Use \`$derived.by(() => {...})\` instead of \`$derived((() => {...})());\``
2928
};
3029

3130
/** @satisfies {Warnings} */

packages/svelte/src/internal/client/custom-element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ if (typeof HTMLElement === 'function') {
8989
if (!this.$$c) {
9090
// We wait one tick to let possible child slot elements be created/mounted
9191
await Promise.resolve();
92-
if (!this.$$cn) {
92+
if (!this.$$cn || this.$$c) {
9393
return;
9494
}
9595
/** @param {string} name */

packages/svelte/src/internal/client/proxy.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ const state_proxy_handler = {
157157
}
158158
if (s !== undefined) set(s, UNINITIALIZED);
159159

160-
if (prop in target) update(metadata.v);
160+
if (boolean) update(metadata.v);
161161

162162
return boolean;
163163
},

0 commit comments

Comments
 (0)