merge master

pull/9046/head
Ben McCann 3 years ago
commit 32d57a2e1b

@ -1,5 +0,0 @@
---
"svelte": patch
---
fix: Add data-* to svg attributes

@ -0,0 +1,94 @@
---
title: "What's new in Svelte: August 2023"
description: "Extending Custom Element Classes and new +server exports"
author: Dani Sandoval
authorURL: https://dreamindani.com
---
Some sweet new features have dropped in both Svelte and SvelteKit, this month. It's also great to see how many products and side projects have launched using Svelte as their core technology!
More on all that down below...
## What's new in Svelte & Language Tools
There's been a bunch of minor bugfixes since the Svelte 4 release. You can find them in the [CHANGELOG](https://github.com/sveltejs/svelte/blob/master/packages/svelte/CHANGELOG.md).
The **4.1.0 release** added the ability to further customize the custom element class that wraps the underlying Svelte component. Check out the [Custom Elements API docs](https://svelte.dev/docs/custom-elements-api) or the [PR](https://github.com/sveltejs/svelte/pull/8991) for more info!
In addition to supporting SvelteKit's new `HEAD` server method, Svelte's language tools now support Prettier v3 (**extensions-107.9.0**) and workspace trust settings are now used to support all settings in workspace (**extensions-107.8.0**).
## What's new in SvelteKit
- The `HEAD` server method is now available in API routes (**1.22.0**, [Docs](https://kit.svelte.dev/docs/routing#server), [#9753](https://github.com/sveltejs/kit/pull/9753))
- Responses with `Vary` headers are now cached, too (except for `Vary: *`) (**1.22.0**, [Docs](https://kit.svelte.dev/docs/routing#server-content-negotiation), [#9993](https://github.com/sveltejs/kit/pull/9993))
- There's now a more helpful error for preview if SvelteKit's build output doesn't exist (**1.22.2**, [#10337](https://github.com/sveltejs/kit/pull/10337))
For all the patches and performance updates from this month, check out the [SvelteKit CHANGELOG](https://github.com/sveltejs/kit/blob/master/packages/kit/CHANGELOG.md). You can also find adapter-specific CHANGELOGs in each of [the `adapter` directories](https://github.com/sveltejs/kit/tree/master/packages).
---
## Community Showcase
**Apps & Sites built with Svelte**
- [GitLight](https://github.com/ColinLienard/gitlight) brings GitHub & GitLab notifications to your desktop
- [Days](https://github.com/paprikka/days) is paprikka's life in days, inspired by Buster Benson's Life in Weeks
- [Mofi](https://mofi.loud.red/) is a content-aware fill and trim for music
- [JSON Bucket](https://github.com/Nico-Mayer/json-bucket) stores your JSON data so you can access it anywhere through generated API routes
- [Soggy Planet](https://www.cosmicplayground.org/soggy-planet) is an interactive map of Earth where sea levels rise and fall and the lights of civilization shine through the night ([Source](https://github.com/ryanatkn/cosmicplayground))
- [PaperClip](https://www.paperclipapp.xyz/) is a Chrome extension that makes it easy to memorize details from papers in machine learning, computer vision, and natural language processing.
- [Maktaba](https://www.maktaba.digital/) is a bookmark manager that "you will actually use"
- [Whispering](https://github.com/braden-w/whispering-extension) is a Chrome extension that lets you access OpenAI's Whisper API for fast transcription in the browser (including ChatGPT)
- [DocuTalk](https://docutalk.co/) is an AI Customer Support chatbot for your website
- [Krello](https://github.com/iamrishupatel/trello-clone) is a Trello clone built with Svelte, Appwrite and Flowbite
- [Been](https://beeneverywhere.net/) is a map builder with travel stats like visited countries, extreme visited points, etc.
- [image-to-social-media-thumbnail](https://brody.fyi/tools/image-to-social-media-thumbnail) lets you convert any image to a social media thumbnail
- [Svelte Capacitor Store](https://github.com/sdekna/svelte-capacitor-store) is a persistent store that uses capacitor (preferences) storage on native devices, and localStorage otherwise, making it ideal for multi-platform projects
**Learning Resources**
_Featuring Svelte Contributors and Ambassadors_
- [Exploring Svelte 4 w/ Kevin AK: Performance, Compatibility, & Web Component Support | Modern Web Pod](https://www.youtube.com/watch?v=YOL0HGGVib4) by This Dot Media
- [Svelte Sirens Stream Design Systems: Lessons Learned](https://www.youtube.com/live/YHZaiIGSqsE?feature=share) featuring Eric Liu creator of Carbon Components Svelte and Svelde the docgen library
- This Week in Svelte:
- [2023 June 30](https://www.youtube.com/watch?v=sDz4_BLoYQ4) - Svelte 4.0.1, SK 1.21, lists, screen readers, loading
- [2023 July 7](https://www.youtube.com/watch?v=0tq1ph4DDFA) - Svelte 4.0.5, Kit 1.22.1, Svelte 5, local storage and markdown
- [2023 July 21](https://www.youtube.com/watch?v=AG4_3kon3zU) - Svelte 4.1.1, SvelteKit 1.22.3, Progressive enhancement
_To Watch/Hear_
- [What is The Transitional Web? with Chris Ferdinandi](https://www.smashingmagazine.com/2023/07/smashing-podcast-episode-63/?ref=dailydevbytes.com) by Smashing Podcast
- [SvelteKit in 100 seconds](https://www.youtube.com/watch?v=H1eEFfAkIik) by Fireship
- [Primo V2 Introduction](https://www.youtube.com/watch?v=ThInVXgxJ1Q) by Primo (a [visual CMS](https://primocms.org/) based on Svelte)
- [Understanding Svelte (vs React)](https://www.youtube.com/watch?v=lYYGhm7p74Q) by Kodaps Academy
- [Is it thàt simple? - Mastering SvelteKit](https://www.youtube.com/watch?v=6Vrc1VO8pgs) by Threeveloper
- [Markdown in SvelteKit with custom Components: mdsvex](https://www.youtube.com/watch?v=VJFkyGd0FEA) by hartenfellerdev
- [How To Add Confetti for Svelte and Sveltekit 🎉](https://www.youtube.com/watch?v=gXtWSb94704) and [Make Your SvelteKit Code 10x Faster With Rust and WebAssembly](https://www.youtube.com/watch?v=Vn2bIv_J_UE) by SvelteRust
_To Read_
- [SvelteJS: My ecosystem is bigger than yours](https://hackmd.io/@roguegpu/r1RKQMdt3) by roguegpu
- [Avoid shared state on the server in SvelteKit](https://blog.aakashgoplani.in/avoid-shared-state-on-the-server-in-sveltekit) by Aakash Goplani
- [SvelteKit Fontaine: Reduce Custom Font CLS](https://rodneylab.com/sveltekit-fontaine/) by Rodney Lab
- [A Simple Guide to Redirects in Svelte Kit](https://rgbstudios.org/blog/redirects-in-svelte-kit) by Justin Golden
- [React vs Svelte (Q3 2023)](https://gee-astro-personal.vercel.app/blog/post2) by Gee
- [SvelteKit Page Reaction Component with Upstash Redis](https://scottspence.com/posts/sveltekit-page-reaction-component-with-upstash-redis) by Scott Spence
- [Building a privacy-friendly, self-hosted application architecture with SvelteKit](https://khromov.se/building-a-privacy-friendly-self-hosted-application-architecture-with-sveltekit/) and [Building a privacy-friendly, self-hosted application architecture with SvelteKit](https://khromov.se/building-a-privacy-friendly-self-hosted-application-architecture-with-sveltekit/) by Stanislav Khromov
- [Deploying Sveltekit on IIS](https://dev.to/nnutnonn/deploying-sveltekit-on-iis--5gf6) by Nutchapon Makelai
- [Streamlined Authentication and Secrets Management](https://eman.hashnode.dev/streamlined-authentication-and-secrets-management) by Eman
**Libraries, Tools & Components**
- [Melt UI](https://github.com/melt-ui/melt-ui) is a set of headless, accessible component builders for Svelte
- [MDsveX](https://github.com/pngwn/MDsveX/releases/tag/mdsvex%400.11.0) has been updated to work with Svelte 4
- [Svelte Sonner](https://github.com/wobsoriano/svelte-sonner) is an opinionated toast component for Svelte
- [WebExtensionTemplate](https://github.com/kyle-n/WebExtensionTemplate) lets you skip the boilerplate and write a Web Extension with TypeScript and Svelte or React
- [svelte-rust](https://github.com/Hugo-Dz/svelte-rust) lets you run Rust code in your Svelte app
- [SvelteKit SSE](https://github.com/tncrazvan/sveltekit-sse) provides an easy way to produce and consume server sent events
- [better-svelte-writable](https://github.com/tnthung/better-svelte-writable) provides a type-safe writable which gives you more control over the container
- [Svetch.ts](https://github.com/Bewinxed/svetch#readme) is a client/types/schema/docs generator for your API endpoints
- [sveltekit-localize-url](https://github.com/rinart73/sveltekit-localize-url) handles URL localization and routing
- [elegua](https://github.com/howesteve/elegua) is a small, reactive PWA router for Svelte
- [Molly](https://github.com/renefournier/molly/tree/main) is a bash script and npm module that helps you clean up unused Svelte components in your project
- [sveltekit-bot](https://github.com/begoon/sveltekit-bot) is a Telegram bot made with SvelteKit and Vercel
Thanks for reading! As always, feel free to let us know if we missed anything on [Reddit](https://www.reddit.com/r/sveltejs/) or [Discord](https://discord.gg/svelte).
Until next time 👋

@ -85,13 +85,13 @@ An element or component can have multiple spread attributes, interspersed with r
<Widget {...things} />
```
`$$props` references all props that are passed to a component, including ones that are not declared with `export`. It is not generally recommended, as it is difficult for Svelte to optimise. But it can be useful in rare cases for example, when you don't know at compile time what props might be passed to a component.
`$$props` references all props that are passed to a component, including ones that are not declared with `export`. Using `$$props` will not perform as well as references to a specific prop because changes to any prop will cause Svelte to recheck all usages of `$$props`. But it can be useful in some cases for example, when you don't know at compile time what props might be passed to a component.
```svelte
<Widget {...$$props} />
```
`$$restProps` contains only the props which are _not_ declared with `export`. It can be used to pass down other unknown attributes to an element in a component. It shares the same optimisation problems as `$$props`, and is likewise not recommended.
`$$restProps` contains only the props which are _not_ declared with `export`. It can be used to pass down other unknown attributes to an element in a component. It shares the same performance characteristics compared to specific property access as `$$props`.
```svelte
<input {...$$restProps} />

@ -738,7 +738,7 @@ DOMRect {
An animation is triggered when the contents of a [keyed each block](/docs/logic-blocks#each) are re-ordered. Animations do not run when an element is added or removed, only when the index of an existing data item within the each block changes. Animate directives must be on an element that is an _immediate_ child of a keyed each block.
Animations can be used with Svelte's [built-in animation functions](/docs/svelte-animate) or [custom animation functions](/docs/element-directives#custom-transition-functions).
Animations can be used with Svelte's [built-in animation functions](/docs/svelte-animate) or [custom animation functions](/docs/element-directives#custom-animation-functions).
```svelte
<!-- When `list` is reordered the animation will run-->

@ -8,13 +8,34 @@ title: Component directives
on:eventname={handler}
```
Components can emit events using [createEventDispatcher](/docs/svelte#createeventdispatcher), or by forwarding DOM events. Listening for component events looks the same as listening for DOM events:
Components can emit events using [`createEventDispatcher`](/docs/svelte#createeventdispatcher) or by forwarding DOM events.
```svelte
<!-- SomeComponent.svelte -->
<script>
import { createEventDispatcher } from 'svelte';
const dispatch = createEventDispatcher();
</script>
<!-- programmatic dispatching -->
<button on:click={() => dispatch('hello')}>
one
</button>
<!-- declarative event forwarding -->
<button on:click>
two
</button>
```
Listening for component events looks the same as listening for DOM events:
```svelte
<SomeComponent on:whatever={handler} />
```
As with DOM events, if the `on:` directive is used without a value, the component will _forward_ the event, meaning that a consumer of the component can listen for it.
As with DOM events, if the `on:` directive is used without a value, the event will be forwarded, meaning that a consumer can listen for it.
```svelte
<SomeComponent on:whatever />
@ -92,6 +113,8 @@ You can bind to component props using the same syntax as for elements.
<Keypad bind:value={pin} />
```
While Svelte props are reactive without binding, that reactivity only flows downward into the component by default. Using `bind:property` allows changes to the property from within the component to flow back up out of the component.
## bind:this
```svelte
@ -100,10 +123,10 @@ bind:this={component_instance}
Components also support `bind:this`, allowing you to interact with component instances programmatically.
> Note that we can't do `{cart.empty}` since `cart` is `undefined` when the button is first rendered and throws an error.
```svelte
<ShoppingCart bind:this={cart} />
<button on:click={() => cart.empty()}> Empty shopping cart </button>
```
> Note that we can't do `{cart.empty}` since `cart` is `undefined` when the button is first rendered and throws an error.

@ -1,5 +1,13 @@
# svelte
## 4.1.2
### Patch Changes
- fix: allow child element with slot attribute within svelte:element ([#9038](https://github.com/sveltejs/svelte/pull/9038))
- fix: Add data-\* to svg attributes ([#9036](https://github.com/sveltejs/svelte/pull/9036))
## 4.1.1
### Patch Changes

@ -1,6 +1,6 @@
{
"name": "svelte",
"version": "4.1.1",
"version": "4.1.2",
"description": "Cybernetically enhanced web apps",
"type": "module",
"module": "src/runtime/index.js",

@ -530,7 +530,6 @@ export default class Element extends Node {
this.name === 'option' ||
this.is_dynamic_element ||
this.tag_expr.dynamic_dependencies().length ||
this.is_dynamic_element ||
component.compile_options.dev
) {
this.parent.cannot_use_innerhtml(); // need to use add_location
@ -1414,7 +1413,9 @@ const regex_minus_sign = /-/;
function within_custom_element(parent) {
while (parent) {
if (parent.type === 'InlineComponent') return false;
if (parent.type === 'Element' && regex_minus_sign.test(parent.name)) return true;
if (parent.type === 'Element') {
if (regex_minus_sign.test(parent.name) || parent.is_dynamic_element) return true;
}
parent = parent.parent;
}
return false;

@ -26,11 +26,7 @@ function _distance(str1, str2) {
str1 = String(str1);
str2 = String(str2);
const distance = levenshtein(str1, str2);
if (str1.length > str2.length) {
return 1 - distance / str1.length;
} else {
return 1 - distance / str2.length;
}
return 1 - distance / Math.max(str1.length, str2.length);
}
// helper functions

@ -6,5 +6,5 @@
* https://svelte.dev/docs/svelte-compiler#svelte-version
* @type {string}
*/
export const VERSION = '4.1.1';
export const VERSION = '4.1.2';
export const PUBLIC_VERSION = '4';

@ -0,0 +1,7 @@
export default {
html: `
<dynamic-element>
<header slot='header'>header header header</header>
</dynamic-element>
`
};

@ -0,0 +1,7 @@
<script>
export let tagName = 'dynamic-element'
</script>
<svelte:element this={tagName}>
<header slot='header'>header header header</header>
</svelte:element>

File diff suppressed because it is too large Load Diff

@ -18,7 +18,7 @@
},
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.4.15",
"@supabase/supabase-js": "^2.26.0",
"@supabase/supabase-js": "^2.31.0",
"@sveltejs/repl": "0.5.0",
"cookie": "^0.5.0",
"devalue": "^4.3.2",
@ -28,35 +28,33 @@
},
"devDependencies": {
"@resvg/resvg-js": "^2.4.1",
"@sveltejs/adapter-vercel": "^3.0.2",
"@sveltejs/kit": "^1.22.2",
"@sveltejs/site-kit": "6.0.0-next.20",
"@sveltejs/vite-plugin-svelte": "^2.4.2",
"@sveltejs/adapter-vercel": "^3.0.3",
"@sveltejs/kit": "^1.22.4",
"@sveltejs/site-kit": "6.0.0-next.25",
"@sveltejs/vite-plugin-svelte": "^2.4.3",
"@types/cookie": "^0.5.1",
"@types/marked": "^5.0.0",
"@types/node": "^20.3.3",
"@types/prettier": "^2.7.3",
"browserslist": "^4.21.9",
"@types/node": "^20.4.7",
"browserslist": "^4.21.10",
"degit": "^2.8.4",
"dotenv": "^16.3.1",
"jimp": "^0.22.8",
"jimp": "^0.22.10",
"lightningcss": "^1.21.5",
"magic-string": "^0.30.1",
"marked": "^5.1.0",
"prettier": "^2.8.8",
"prettier-plugin-svelte": "^2.10.1",
"sass": "^1.63.6",
"satori": "^0.10.1",
"magic-string": "^0.30.2",
"marked": "^6.0.0",
"prettier": "^3.0.1",
"prettier-plugin-svelte": "^3.0.3",
"sass": "^1.64.2",
"satori": "^0.10.2",
"satori-html": "^0.3.2",
"shelljs": "^0.8.5",
"shiki": "^0.14.3",
"shiki-twoslash": "^3.1.2",
"svelte": "workspace:*",
"svelte-check": "^3.4.4",
"svelte-check": "^3.4.6",
"svelte-preprocess": "^5.0.4",
"tiny-glob": "^0.2.9",
"typescript": "^5.1.6",
"vite": "^4.4.3",
"vite-imagetools": "^5.0.5"
"vite": "^4.4.8",
"vite-imagetools": "^5.0.7"
}
}

@ -1,7 +1,7 @@
// @ts-check
import { mkdir, readFile, writeFile } from 'node:fs/promises';
import path from 'node:path';
import prettier from 'prettier';
import { format } from 'prettier';
import ts from 'typescript';
/** @typedef {{
@ -20,7 +20,7 @@ const modules = [];
* @param {string} code
* @param {ts.NodeArray<ts.Statement>} statements
*/
function get_types(code, statements) {
async function get_types(code, statements) {
/** @type {Extracted[]} */
const exports = [];
@ -106,14 +106,15 @@ function get_types(code, statements) {
}
}
const snippet = prettier
.format(snippet_unformatted, {
const snippet = (
await format(snippet_unformatted, {
parser: 'typescript',
printWidth: 60,
useTabs: true,
singleQuote: true,
trailingComma: 'none'
})
)
.replace(/\s*(\/\*…\*\/)\s*/g, '/*…*/')
.trim();
@ -273,7 +274,7 @@ async function read_d_ts_file(file) {
name,
comment,
// @ts-ignore
...get_types(code, statement.body?.statements)
...(await get_types(code, statement.body?.statements))
});
}
}

@ -1,9 +1,8 @@
<script>
import { Blurb } from '@sveltejs/site-kit/components';
import { Blurb, Footer, TrySection } from '@sveltejs/site-kit/home';
import Demo from './_components/Demo.svelte';
import Hero from './_components/Hero.svelte';
import Supporters from './_components/Supporters/index.svelte';
import Try from './_components/Try.svelte';
import WhosUsingSvelte from './_components/WhosUsingSvelte/index.svelte';
</script>
@ -45,7 +44,7 @@
</div>
</Blurb>
<Try />
<TrySection />
<Demo />
@ -53,33 +52,51 @@
<Supporters />
<section>
<footer>
<div class="logo" />
<div class="links">
<h4>resources</h4>
<a href="/docs">documentation</a>
<a href="/tutorial">tutorial</a>
<a href="/examples">examples</a>
<a href="/blog">blog</a>
</div>
<div class="links">
<h4>connect</h4>
<a href="https://github.com/sveltejs/svelte">github</a>
<a href="https://opencollective.com/svelte">open collective</a>
<a href="/chat">discord</a>
<a href="https://twitter.com/sveltejs">twitter</a>
</div>
<div class="copyright">
© 2023 <a href="https://github.com/sveltejs/svelte/graphs/contributors">Svelte contributors</a
>
</div>
<div class="open-source">
Svelte is <a href="https://github.com/sveltejs/svelte">free and open source software</a> released
under the MIT license
</div>
</footer>
</section>
<Footer
links={{
resources: [
{
title: 'documentation',
href: '/docs'
},
{
title: 'tutorial',
href: '/tutorial'
},
{
title: 'examples',
href: '/examples'
},
{
title: 'blog',
href: '/blog'
}
],
connect: [
{
title: 'github',
href: 'https://github.com/sveltejs/svelte'
},
{
title: 'opencollective',
href: 'https://opencollective.com/svelte'
},
{
title: 'discord',
href: '/chat'
},
{
title: 'twitter',
href: 'https://twitter.com/sveltejs'
}
]
}}
>
<span slot="copyright">
Svelte is <a href="https://github.com/sveltejs/svelte">free and open source software</a> released
under the MIT license
</span>
</Footer>
<style>
h2 {
@ -89,66 +106,4 @@
p {
font-size: var(--sk-text-m);
}
section {
background: var(--sk-back-4);
padding: 10rem 0;
}
footer {
max-width: 120rem;
padding: 0 var(--sk-page-padding-side);
margin: 0 auto;
display: grid;
grid-template-columns: repeat(2, 1fr);
grid-template-rows: 1fr;
grid-row-gap: 6rem;
}
footer .logo {
display: none;
background: url('@sveltejs/site-kit/branding/svelte-logo.svg');
background-repeat: no-repeat;
background-size: 8rem;
filter: grayscale(100%) opacity(84%);
}
footer h4 {
font-size: var(--sk-text-m);
padding-bottom: 1rem;
}
.links a {
color: var(--sk-text-2);
font-size: var(--sk-text-s);
display: block;
line-height: 1.8;
}
.open-source {
display: none;
grid-column: span 2;
}
.copyright {
grid-column: span 2;
}
@media (min-width: 500px) {
footer {
grid-template-columns: repeat(3, 1fr);
}
footer .logo {
display: block;
}
.copyright {
grid-column: span 1;
}
.open-source {
display: block;
}
}
</style>

@ -1,92 +0,0 @@
<script>
import { Section } from '@sveltejs/site-kit/components';
import { TryTerminal } from '@sveltejs/site-kit/components';
</script>
<div class="try-container">
<Section --background="var(--background-2)">
<div class="grid" style="--columns: 2">
<div class="copy">
<h2>see for yourself</h2>
<div>
Try it locally, <a target="_blank" rel="noreferrer" href="https://sveltekit.new"
>on StackBlitz</a
>, or with
<a target="_blank" href="https://learn.svelte.dev">the interactive tutorial</a>.
</div>
</div>
<div class="try">
<TryTerminal />
</div>
</div>
</Section>
</div>
<style>
.try-container {
--background-2: var(--sk-back-4);
}
:global(body.dark .try-container) {
--background-2: #444;
}
@media (prefers-color-scheme: dark) {
.try-container {
--background-2: #444;
}
:global(body.light .try-container) {
--background-2: var(--sk-back-4) !important;
}
}
.grid {
display: grid;
gap: 2em;
margin: 0 0 4rem 0;
}
.grid:last-child {
margin-bottom: 0;
}
.try {
width: 100%;
margin: 0 auto;
font-size: var(--sk-text-m);
color: var(--sk-text-1);
}
.copy {
text-align: left;
}
h2 {
display: inline-block;
width: 25rem;
margin: 0 0 1rem;
font-size: var(--sk-text-xl);
}
@media (min-width: 900px) {
.grid {
grid-template-columns: repeat(var(--columns), 1fr);
gap: 7rem;
}
.copy {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
order: 2;
}
.copy div {
max-width: 15em;
text-align: center;
}
}
</style>
Loading…
Cancel
Save