Skip to content

Commit fd8ebd8

Browse files
committed
merge master
2 parents b630fde + 2d07382 commit fd8ebd8

35 files changed

+1041
-399
lines changed

.changeset/eighty-poems-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: css sourcemap generation with unicode filenames

documentation/blog/2023-08-01-whats-new-in-svelte-august-2023.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ For all the patches and performance updates from this month, check out the [Svel
4646
**Learning Resources**
4747
_Featuring Svelte Contributors and Ambassadors_
4848
- [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
49-
- [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
49+
- [Svelte Sirens Stream Design Systems: Lessons Learned](https://www.youtube.com/live/YHZaiIGSqsE?feature=share) featuring Eric Liu, creator of Carbon Components Svelte and the `sveld` docgen library
5050
- This Week in Svelte:
5151
- [2023 June 30](https://www.youtube.com/watch?v=sDz4_BLoYQ4) - Svelte 4.0.1, SK 1.21, lists, screen readers, loading
5252
- [2023 July 7](https://www.youtube.com/watch?v=0tq1ph4DDFA) - Svelte 4.0.5, Kit 1.22.1, Svelte 5, local storage and markdown

documentation/docs/02-template-syntax/02-basic-markup.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ All other attributes are included unless their value is [nullish](https://develo
5656

5757
An expression might include characters that would cause syntax highlighting to fail in regular HTML, so quoting the value is permitted. The quotes do not affect how the value is parsed:
5858

59+
<!-- prettier-ignore -->
5960
```svelte
60-
<button disabled={number !== 42}>...</button>
61+
<button disabled="{number !== 42}">...</button>
6162
```
6263

6364
When the attribute name and value match (`name={name}`), they can be replaced with `{name}`.

documentation/docs/05-misc/03-typescript.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,26 @@ declare namespace svelteHTML {
140140

141141
Then make sure that `d.ts` file is referenced in your `tsconfig.json`. If it reads something like `"include": ["src/**/*"]` and your `d.ts` file is inside `src`, it should work. You may need to reload for the changes to take effect.
142142

143+
Since Svelte version 4.2 / `svelte-check` version 3.5 / VS Code extension version 107.10.0 you can also declare the typings by augmenting the `svelte/elements` module like this:
144+
145+
```ts
146+
/// file: additional-svelte-typings.d.ts
147+
import { HTMLButtonAttributes } from 'svelte/elements'
148+
149+
declare module 'svelte/elements' {
150+
export interface SvelteHTMLElements {
151+
'custom-button': HTMLButtonAttributes;
152+
}
153+
154+
// allows for more granular control over what element to add the typings to
155+
export interface HTMLButtonAttributes {
156+
'veryexperimentalattribute'?: string;
157+
}
158+
}
159+
160+
export {}; // ensure this is not an ambient module, else types will be overridden instead of augmented
161+
```
162+
143163
## Experimental advanced typings
144164

145165
A few features are missing from taking full advantage of TypeScript in more advanced use cases like typing that a component implements a certain interface, explicitly typing slots, or using generics. These things are possible using experimental advanced type capabilities. See [this RFC](https://github.com/dummdidumm/rfcs/blob/ts-typedefs-within-svelte-components/text/ts-typing-props-slots-events.md) for more information on how to make use of them.

packages/playground/start.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,12 @@ const watcher = watch([
6969
async generateBundle(_, bundle) {
7070
const result = bundle['entry-server.js'];
7171
const mod = (0, eval)(result.code);
72-
const { html } = mod.render();
72+
const { html, head } = mod.render();
7373

7474
writeFileSync(
7575
'dist/index.html',
7676
readFileSync('src/template.html', 'utf-8')
77+
.replace('<!--app-head-->', head)
7778
.replace('<!--app-html-->', html)
7879
.replace('<!--app-title-->', svelte.VERSION)
7980
);

packages/svelte/CHANGELOG.md

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

3+
## 4.2.0
4+
5+
### Minor Changes
6+
7+
- feat: move `svelteHTML` from language-tools into core to load the correct `svelte/element` types ([#9070](https://github.com/sveltejs/svelte/pull/9070))
8+
39
## 4.1.2
410

511
### Patch Changes

packages/svelte/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "svelte",
3-
"version": "4.1.2",
3+
"version": "4.2.0",
44
"description": "Cybernetically enhanced web apps",
55
"type": "module",
66
"module": "src/runtime/index.js",
@@ -19,6 +19,7 @@
1919
"motion.d.ts",
2020
"action.d.ts",
2121
"elements.d.ts",
22+
"svelte-html.d.ts",
2223
"README.md"
2324
],
2425
"exports": {
@@ -129,7 +130,7 @@
129130
"dts-buddy": "^0.1.7",
130131
"esbuild": "^0.18.11",
131132
"happy-dom": "^9.20.3",
132-
"jsdom": "^22.0.0",
133+
"jsdom": "22.0.0",
133134
"kleur": "^4.1.5",
134135
"rollup": "^3.26.2",
135136
"source-map": "^0.7.4",

packages/svelte/scripts/globals-extractor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const GLOBAL_TS_PATH = './src/compiler/utils/globals.js';
1616
const SPECIALS = ['global', 'globalThis', 'InternalError', 'process', 'undefined'];
1717

1818
const get_url = (name) =>
19-
`https://raw.githubusercontent.com/microsoft/TypeScript/main/lib/lib.${name}.d.ts`;
19+
`https://raw.githubusercontent.com/microsoft/TypeScript/main/src/lib/${name}.d.ts`;
2020
const extract_name = (split) => split.match(/^[a-zA-Z0-9_$]+/)[0];
2121

2222
const extract_functions_and_references = (name, data) => {

packages/svelte/src/compiler/utils/globals.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/** ----------------------------------------------------------------------
22
This file is automatically generated by `scripts/globals-extractor.js`.
3-
Generated At: 2023-05-24T13:16:20.777Z
3+
Generated At: 2023-08-11T04:11:50.562Z
44
---------------------------------------------------------------------- */
55

66
export default new Set([

packages/svelte/src/compiler/utils/mapped_code.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,18 @@ export function apply_preprocessor_sourcemap(filename, svelte_map, preprocessor_
292292
toUrl: {
293293
enumerable: false,
294294
value: function toUrl() {
295-
return 'data:application/json;charset=utf-8;base64,' + btoa(this.toString());
295+
let b64 = '';
296+
if (typeof window !== 'undefined' && window.btoa) {
297+
// btoa doesn't support multi-byte characters
298+
b64 = window.btoa(unescape(encodeURIComponent(this.toString())));
299+
} else if (typeof Buffer !== 'undefined') {
300+
b64 = Buffer.from(this.toString(), 'utf8').toString('base64');
301+
} else {
302+
throw new Error(
303+
'Unsupported environment: `window.btoa` or `Buffer` should be present to use toUrl.'
304+
);
305+
}
306+
return 'data:application/json;charset=utf-8;base64,' + b64;
296307
}
297308
}
298309
});

packages/svelte/src/shared/version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
* https://svelte.dev/docs/svelte-compiler#svelte-version
77
* @type {string}
88
*/
9-
export const VERSION = '4.1.2';
9+
export const VERSION = '4.2.0';
1010
export const PUBLIC_VERSION = '4';

0 commit comments

Comments
 (0)