Skip to content

Commit e695d81

Browse files
committed
Merge branch 'main' into gh-694
2 parents d10dfa1 + 8d2e9e5 commit e695d81

File tree

7 files changed

+67
-19
lines changed

7 files changed

+67
-19
lines changed

apps/svelte.dev/content/tutorial/02-advanced-svelte/04-advanced-bindings/04-dimensions/index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Dimensions
33
---
44

5-
You can add `clientWidth`, `clientHeight`, `offsetWidth` and `offsetHeight` bindings to any element:
5+
You can add `clientWidth`, `clientHeight`, `offsetWidth` and `offsetHeight` bindings to any element, and Svelte will update the bound values using a [`ResizeObserver`](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver):
66

77
```svelte
88
/// file: App.svelte
@@ -13,3 +13,5 @@ You can add `clientWidth`, `clientHeight`, `offsetWidth` and `offsetHeight` bind
1313
```
1414

1515
These bindings are readonly — changing the values of `w` and `h` won't have any effect on the element.
16+
17+
> [!NOTE] `display: inline` elements do not have a width or height (except for elements with 'intrinsic' dimensions, like `<img>` and `<canvas>`), and cannot be observed with a `ResizeObserver`. You will need to change the `display` style of these elements to something else, such as `inline-block`.

apps/svelte.dev/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@testing-library/svelte": "^5.2.3",
2929
"@testing-library/user-event": "^14.5.2",
3030
"@types/d3-geo": "^3.1.0",
31+
"@vercel/analytics": "^1.3.2",
3132
"@vercel/speed-insights": "^1.0.0",
3233
"@webcontainer/api": "^1.1.5",
3334
"adm-zip": "^0.5.10",
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
1-
import { dev } from '$app/environment';
2-
import { SUPABASE_URL, SUPABASE_KEY } from '$env/static/private';
1+
import { building } from '$app/environment';
2+
import { env } from '$env/dynamic/private';
33
import { createClient } from '@supabase/supabase-js';
44

5-
const client_enabled = !!(!dev || (SUPABASE_URL && SUPABASE_KEY));
5+
const enabled = !building && env.SUPABASE_URL && env.SUPABASE_KEY;
6+
7+
if (!enabled) {
8+
console.warn(
9+
`Missing SUPABASE_URL and SUPABASE_KEY environment variables. Loading and saving in the playground is disabled`
10+
);
11+
}
612

713
/**
814
* @type {import('@supabase/supabase-js').SupabaseClient<any, "public", any>}
915
*/
1016
// @ts-ignore-line
1117
export const client =
12-
client_enabled &&
13-
createClient(SUPABASE_URL, SUPABASE_KEY, {
18+
enabled &&
19+
createClient(env.SUPABASE_URL, env.SUPABASE_KEY, {
1420
global: { fetch },
1521
auth: { persistSession: false }
1622
});

apps/svelte.dev/src/lib/db/session.js

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as cookie from 'cookie';
22
import flru from 'flru';
33
import { client } from './client.js';
4+
import { error } from '@sveltejs/kit';
45

56
/** @typedef {import('./types').User} User */
67

@@ -13,27 +14,31 @@ const session_cache = flru(1000);
1314
* @param {import('./types').GitHubUser} user
1415
*/
1516
export async function create(user) {
16-
const { data, error } = await client.rpc('login', {
17+
if (!client) {
18+
error(500, 'Database client is not configured');
19+
}
20+
21+
const result = await client.rpc('login', {
1722
user_github_id: user.github_id,
1823
user_github_name: user.github_name,
1924
user_github_login: user.github_login,
2025
user_github_avatar_url: user.github_avatar_url
2126
});
2227

23-
if (error) {
24-
throw new Error(error.message);
28+
if (result.error) {
29+
throw new Error(result.error.message);
2530
}
2631

27-
session_cache.set(data.sessionid, {
28-
id: data.userid,
32+
session_cache.set(result.data.sessionid, {
33+
id: result.data.userid,
2934
github_name: user.github_name,
3035
github_login: user.github_login,
3136
github_avatar_url: user.github_avatar_url
3237
});
3338

3439
return {
35-
sessionid: data.sessionid,
36-
expires: new Date(data.expires)
40+
sessionid: result.data.sessionid,
41+
expires: new Date(result.data.expires)
3742
};
3843
}
3944

@@ -42,7 +47,7 @@ export async function create(user) {
4247
* @returns {Promise<User | null>}
4348
*/
4449
export async function read(sessionid) {
45-
if (!sessionid) return null;
50+
if (!sessionid || !client) return null;
4651

4752
if (!session_cache.get(sessionid)) {
4853
session_cache.set(
@@ -63,10 +68,14 @@ export async function read(sessionid) {
6368

6469
/** @param {string} sessionid */
6570
export async function destroy(sessionid) {
66-
const { error } = await client.rpc('logout', { sessionid });
71+
if (!client) {
72+
error(500, 'Database client is not configured');
73+
}
74+
75+
const result = await client.rpc('logout', { sessionid });
6776

68-
if (error) {
69-
throw new Error(error.message);
77+
if (result.error) {
78+
throw new Error(result.error.message);
7079
}
7180

7281
session_cache.set(sessionid, null);

apps/svelte.dev/src/routes/+layout.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
<script lang="ts">
22
import '@sveltejs/site-kit/styles/index.css';
3-
import { browser } from '$app/environment';
3+
import { browser, dev } from '$app/environment';
44
import { page } from '$app/stores';
55
import { Shell, Banner } from '@sveltejs/site-kit/components';
66
import { Nav } from '@sveltejs/site-kit/nav';
77
import { SearchBox } from '@sveltejs/site-kit/search';
88
import { injectSpeedInsights } from '@vercel/speed-insights/sveltekit';
9+
import { inject } from '@vercel/analytics';
910
import { beforeNavigate } from '$app/navigation';
1011
1112
injectSpeedInsights();
13+
inject({ mode: dev ? 'development' : 'production' });
1214
1315
// Make all navigations between SvelteKit-tutorial and non-SvelteKit-tutorial pages (and vice versa)
1416
// a full page navigation to ensure webcontainers get the correct origin restriction headers while

apps/svelte.dev/src/routes/blog/[slug]/card.png/+server.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@ import Card from './Card.svelte';
88
import DMSerifDisplay from './DMSerifDisplay-Regular.ttf?url';
99
import FiraSans from './FiraSans-Regular.ttf?url';
1010
import { blog_posts } from '$lib/server/content';
11+
import type { ServerlessConfig } from '@sveltejs/adapter-vercel';
1112

12-
export const prerender = true;
13+
export const config: ServerlessConfig = {
14+
isr: {
15+
expiration: false
16+
}
17+
};
1318

1419
export function entries() {
1520
return blog_posts.map((post) => ({

pnpm-lock.yaml

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)