Skip to content

Commit bcff28c

Browse files
committed
Merge branch 'master' into devalue-actions
2 parents 26b2058 + f5a32e5 commit bcff28c

File tree

78 files changed

+928
-587
lines changed

Some content is hidden

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

78 files changed

+928
-587
lines changed

.changeset/brown-seas-sort.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
[breaking] narrow down possible status codes for redirects to 300-308

.changeset/curly-suits-lay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
[fix] prerendering path and layout fixes

.changeset/fair-panthers-notice.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
allow async function for `enhance` action parameter

.changeset/honest-eyes-thank.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
[fix] add Promise return type to the `enhance` action

.changeset/kind-beans-talk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sveltejs/kit": patch
3+
---
4+
5+
fix outdated config error

.changeset/kind-dragons-poke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
Run service worker during development

.changeset/pink-jokes-call.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
[feat] support throwing redirect in handle

.changeset/pre.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
"brown-nails-wait",
132132
"brown-peas-worry",
133133
"brown-pens-glow",
134+
"brown-seas-sort",
134135
"calm-pans-peel",
135136
"calm-pens-prove",
136137
"calm-pots-turn",
@@ -212,6 +213,7 @@
212213
"curly-ants-guess",
213214
"curly-doors-type",
214215
"curly-pets-vanish",
216+
"curly-suits-lay",
215217
"curvy-dots-join",
216218
"curvy-eggs-sip",
217219
"curvy-experts-try",
@@ -223,6 +225,7 @@
223225
"curvy-years-sin",
224226
"curvy-zebras-tan",
225227
"cyan-ads-pump",
228+
"cyan-beds-smoke",
226229
"cyan-cobras-explode",
227230
"cyan-dolls-guess",
228231
"cyan-elephants-accept",
@@ -301,6 +304,7 @@
301304
"empty-teachers-cheat",
302305
"empty-vans-draw",
303306
"empty-worms-appear",
307+
"fair-panthers-notice",
304308
"fair-pets-bake",
305309
"fair-rivers-repair",
306310
"fair-seas-clean",
@@ -524,6 +528,7 @@
524528
"honest-bikes-pull",
525529
"honest-coins-switch",
526530
"honest-cows-notice",
531+
"honest-eyes-thank",
527532
"honest-islands-flash",
528533
"honest-jars-report",
529534
"honest-pandas-joke",
@@ -575,6 +580,8 @@
575580
"khaki-socks-tan",
576581
"khaki-wolves-shout",
577582
"kind-adults-drum",
583+
"kind-beans-talk",
584+
"kind-dragons-poke",
578585
"kind-ducks-relate",
579586
"kind-steaks-bake",
580587
"kind-tools-shop",
@@ -847,6 +854,7 @@
847854
"pink-ducks-press",
848855
"pink-flies-mix",
849856
"pink-gorillas-watch",
857+
"pink-jokes-call",
850858
"pink-poets-begin",
851859
"plenty-cougars-invite",
852860
"plenty-crabs-relax",
@@ -922,6 +930,7 @@
922930
"proud-sloths-talk",
923931
"purple-cycles-build",
924932
"purple-dragons-work",
933+
"purple-parrots-tell",
925934
"purple-rats-wink",
926935
"purple-readers-build",
927936
"purple-windows-wink",
@@ -955,6 +964,7 @@
955964
"real-icons-study",
956965
"real-jokes-grow",
957966
"real-mice-argue",
967+
"real-onions-pull",
958968
"real-pens-watch",
959969
"real-taxis-march",
960970
"real-trainers-collect",
@@ -1008,6 +1018,7 @@
10081018
"serious-bears-listen",
10091019
"serious-books-push",
10101020
"serious-bottles-knock",
1021+
"serious-buttons-push",
10111022
"serious-dolphins-approve",
10121023
"serious-ducks-exercise",
10131024
"serious-elephants-dress",
@@ -1146,6 +1157,7 @@
11461157
"smooth-shoes-mix",
11471158
"smooth-shrimps-fly",
11481159
"smooth-waves-accept",
1160+
"smooth-years-speak",
11491161
"soft-bikes-bake",
11501162
"soft-ears-share",
11511163
"soft-gorillas-hear",
@@ -1418,6 +1430,7 @@
14181430
"warm-ads-invite",
14191431
"warm-cameras-fix",
14201432
"warm-cheetahs-wash",
1433+
"warm-deers-sneeze",
14211434
"warm-dingos-try",
14221435
"warm-frogs-tickle",
14231436
"warm-icons-teach",

.changeset/purple-apes-whisper.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'create-svelte': patch
3+
---
4+
5+
Add `style="display: contents"` to wrapper element by default

.changeset/purple-parrots-tell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
[feat] add fallback component for layouts without one

.changeset/real-onions-pull.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
Workaround for the DOM clobbering for use:enhance

.changeset/serious-buttons-push.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
[fix] don't cache prefetch errors

.changeset/slimy-laws-argue.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
Warn if `%sveltekit.body%` is direct child of `<body>`

.changeset/smooth-years-speak.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/kit': patch
3+
---
4+
5+
[breaking] use hex/unicode escape sequences for encoding special characters in route directory names

.changeset/warm-deers-sneeze.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@sveltejs/kit": patch
3+
---
4+
5+
fix `beforeNavigate` description — `routeId` -> `route.id`

documentation/docs/10-getting-started/30-project-structure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The `src` directory contains the meat of your project.
4242
- `routes` contains the [routes](/docs/routing) of your application
4343
- `app.html` is your page template — an HTML document containing the following placeholders:
4444
- `%sveltekit.head%``<link>` and `<script>` elements needed by the app, plus any `<svelte:head>` content
45-
- `%sveltekit.body%` — the markup for a rendered page. Typically this lives inside a `<div>` or other element, rather than directly inside `<body>`, to prevent bugs caused by browser extensions injecting elements that are then destroyed by the hydration process
45+
- `%sveltekit.body%` — the markup for a rendered page. This should live inside a `<div>` or other element, rather than directly inside `<body>`, to prevent bugs caused by browser extensions injecting elements that are then destroyed by the hydration process. SvelteKit will warn you in development if this is not the case
4646
- `%sveltekit.assets%` — either [`paths.assets`](/docs/configuration#paths), if specified, or a relative path to [`paths.base`](/docs/configuration#paths)
4747
- `%sveltekit.nonce%` — a [CSP](/docs/configuration#csp) nonce for manually included links and scripts, if used
4848
- `error.html` (optional) is the page that is rendered when everything else fails. It can contain the following placeholders:

documentation/docs/20-core-concepts/30-form-actions.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ Each action receives a `RequestEvent` object, allowing you to read the data with
9797
```js
9898
// @errors: 2339 2304
9999
/// file: src/routes/login/+page.server.js
100+
/** @type {import('./$types').PageServerLoad} */
101+
export async function load({ cookies }) {
102+
const user = await db.getUserFromSession(cookies.get('sessionid'));
103+
return { user };
104+
}
105+
100106
/** @type {import('./$types').Actions} */
101107
export const actions = {
102108
login: async ({ cookies, request }) => {

documentation/docs/30-advanced/10-advanced-routing.md

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -123,27 +123,42 @@ src/routes/[...catchall]/+page.svelte
123123

124124
### Encoding
125125

126-
Directory names are URI-decoded, meaning that (for example) a directory like `%40[username]` would match characters beginning with `@`:
126+
Some characters can't be used on the filesystem — `/` on Linux and Mac, `\ / : * ? " < > |` on Windows. The `#` and `%` characters have special meaning in URLs, and the `[ ] ( )` characters have special meaning to SvelteKit, so these also can't be used directly as part of your route.
127+
128+
To use these characters in your routes, you can use hexadecimal escape sequences, which have the format `[x+nn]` where `nn` is a hexadecimal character code:
129+
130+
- `\``[x+5c]`
131+
- `/``[x+2f]`
132+
- `:``[x+3a]`
133+
- `*``[x+2a]`
134+
- `?``[x+3f]`
135+
- `"``[x+22]`
136+
- `<``[x+3c]`
137+
- `>``[x+3e]`
138+
- `|``[x+7c]`
139+
- `#``[x+23]`
140+
- `%``[x+25]`
141+
- `[``[x+5b]`
142+
- `]``[x+5d]`
143+
- `(``[x+28]`
144+
- `)``[x+29]`
145+
146+
For example, to create a `/smileys/:-)` route, you would create a `src/routes/smileys/[x+3a]-[x+29]/+page.svelte` file.
147+
148+
You can determine the hexadecimal code for a character with JavaScript:
127149

128150
```js
129-
// @filename: ambient.d.ts
130-
declare global {
131-
const assert: {
132-
equal: (a: any, b: any) => boolean;
133-
};
134-
}
151+
':'.charCodeAt(0).toString(16); // '3a', hence '[x+3a]'
152+
```
135153

136-
export {};
154+
You can also use Unicode escape sequences. Generally you won't need to as you can use the unencoded character directly, but if — for some reason — you can't have a filename with an emoji in it, for example, then you can use the escaped characters. In other words, these are equivalent:
137155

138-
// @filename: index.js
139-
// ---cut---
140-
assert.equal(
141-
decodeURIComponent('%40[username]'),
142-
'@[username]'
143-
);
156+
```
157+
src/routes/[u+d83e][u+dd2a]/+page.svelte
158+
src/routes/🤪/+page.svelte
144159
```
145160

146-
To express a `%` character, use `%25`, otherwise the result will be malformed.
161+
The format for a Unicode escape sequence is `[u+nnnn]` where `nnnn` is a valid value between `0000` and `10ffff`. (Unlike JavaScript string escaping, there's no need to use surrogate pairs to represent code points above `ffff`.) To learn more about Unicode encodings, consult [Programming with Unicode](https://unicodebook.readthedocs.io/unicode_encodings.html).
147162

148163
### Advanced layouts
149164

documentation/docs/30-advanced/40-service-workers.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,12 @@ In SvelteKit, if you have a `src/service-worker.js` file (or `src/service-worker
1010
1111
Inside the service worker you have access to the [`$service-worker` module](/docs/modules#$service-worker). If your Vite config specifies `define`, this will be applied to service workers as well as your server/client builds.
1212

13-
Because it needs to be bundled (since browsers don't yet support `import` in this context), and depends on the client-side app's build manifest, **service workers only work in the production build, not in development**. To test it locally, use `vite preview`.
13+
The service worker is bundled for production, but not during development. For that reason, only browsers that support [modules in service workers](https://web.dev/es-modules-in-sw) will be able to use them at dev time. If you are manually registering your service worker, you will need to pass the `{ type: 'module' }` option in development:
14+
15+
```js
16+
import { dev } from '$app/environment';
17+
18+
navigator.serviceWorker.register('/service-worker.js', {
19+
type: dev ? 'module' : 'classic'
20+
});
21+
```

packages/create-svelte/templates/default/src/app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
%sveltekit.head%
88
</head>
99
<body data-sveltekit-prefetch>
10-
<div>%sveltekit.body%</div>
10+
<div style="display: contents">%sveltekit.body%</div>
1111
</body>
1212
</html>

packages/create-svelte/templates/skeleton/src/app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
%sveltekit.head%
88
</head>
99
<body>
10-
<div>%sveltekit.body%</div>
10+
<div style="display: contents">%sveltekit.body%</div>
1111
</body>
1212
</html>

packages/kit/CHANGELOG.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,47 @@
11
# @sveltejs/kit
22

3+
## 1.0.0-next.546
4+
5+
### Patch Changes
6+
7+
- fix outdated config error ([#7649](https://github.com/sveltejs/kit/pull/7649))
8+
9+
- [breaking] use hex/unicode escape sequences for encoding special characters in route directory names ([#7644](https://github.com/sveltejs/kit/pull/7644))
10+
11+
- fix `beforeNavigate` description — `routeId` -> `route.id` ([#7643](https://github.com/sveltejs/kit/pull/7643))
12+
13+
## 1.0.0-next.545
14+
15+
### Patch Changes
16+
17+
- [fix] prerendering path and layout fixes ([#7639](https://github.com/sveltejs/kit/pull/7639))
18+
19+
- [fix] add Promise return type to the `enhance` action ([#7629](https://github.com/sveltejs/kit/pull/7629))
20+
21+
## 1.0.0-next.544
22+
23+
### Patch Changes
24+
25+
- [breaking] narrow down possible status codes for redirects to 300-308 ([#7615](https://github.com/sveltejs/kit/pull/7615))
26+
27+
- [feat] add fallback component for layouts without one ([#7619](https://github.com/sveltejs/kit/pull/7619))
28+
29+
## 1.0.0-next.543
30+
31+
### Patch Changes
32+
33+
- Don't print search params error when prerendering fallback page ([#7598](https://github.com/sveltejs/kit/pull/7598))
34+
35+
- allow async function for `enhance` action parameter ([#7608](https://github.com/sveltejs/kit/pull/7608))
36+
37+
- Run service worker during development ([#7597](https://github.com/sveltejs/kit/pull/7597))
38+
39+
- [feat] support throwing redirect in handle ([#7612](https://github.com/sveltejs/kit/pull/7612))
40+
41+
- Workaround for the DOM clobbering for use:enhance ([#7599](https://github.com/sveltejs/kit/pull/7599))
42+
43+
- [fix] don't cache prefetch errors ([#7610](https://github.com/sveltejs/kit/pull/7610))
44+
345
## 1.0.0-next.542
446

547
### Patch Changes

packages/kit/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sveltejs/kit",
3-
"version": "1.0.0-next.542",
3+
"version": "1.0.0-next.546",
44
"repository": {
55
"type": "git",
66
"url": "https://github.com/sveltejs/kit",

packages/kit/src/core/config/options.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ const options = object(
111111
browser: object({
112112
hydrate: error(
113113
(keypath) =>
114-
`${keypath} has been removed. You can set it inside the top level +layout.js instead. See the PR for more information: https://github.com/sveltejs/kit/pull/6197`
114+
`${keypath} has been removed. You can set \`export const csr = false\` inside the top level +layout.js instead. See the PR for more information: https://github.com/sveltejs/kit/pull/6197`
115115
),
116116
router: error(
117117
(keypath) =>
118-
`${keypath} has been removed. You can set it inside the top level +layout.js instead. See the PR for more information: https://github.com/sveltejs/kit/pull/6197`
118+
`${keypath} has been removed. You can set \`export const csr = false\` inside the top level +layout.js instead. See the PR for more information: https://github.com/sveltejs/kit/pull/6197`
119119
)
120120
}),
121121

@@ -318,7 +318,10 @@ const options = object(
318318
),
319319

320320
// TODO remove for 1.0
321-
router: error((keypath) => `${keypath} has been moved to config.kit.browser.router`),
321+
router: error(
322+
(keypath) =>
323+
`${keypath} has been removed. You can set \`export const csr = false\` inside the top level +layout.js instead. See the PR for more information: https://github.com/sveltejs/kit/pull/6197`
324+
),
322325

323326
// TODO remove for 1.0
324327
routes: error(

packages/kit/src/core/generate_manifest/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ export function generate_manifest({ build_data, relative_path, routes, format =
1919
*/
2020
const reindexed = new Map();
2121
/**
22-
* @type {Set<any>} All nodes actually used in the routes definition (prerendered routes are omitted)
22+
* All nodes actually used in the routes definition (prerendered routes are omitted).
23+
* Root layout/error is always included as they are needed for 404 and root errors.
24+
* @type {Set<any>}
2325
*/
24-
const used_nodes = new Set();
26+
const used_nodes = new Set([0, 1]);
2527

2628
for (const route of routes) {
2729
if (route.page) {

0 commit comments

Comments
 (0)