Skip to content

Commit 59e32c9

Browse files
authored
Merge branch 'main' into fix/print-types
2 parents 14ed995 + f8287b0 commit 59e32c9

File tree

139 files changed

+2316
-360
lines changed

Some content is hidden

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

139 files changed

+2316
-360
lines changed

.changeset/curly-phones-cross.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/svelte/CHANGELOG.md

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

3+
## 5.45.3
4+
5+
### Patch Changes
6+
7+
- add props to state_referenced_locally ([#17266](https://github.com/sveltejs/svelte/pull/17266))
8+
9+
- fix: preserve node locations for better sourcemaps ([#17269](https://github.com/sveltejs/svelte/pull/17269))
10+
11+
- fix: handle cross-realm Promises in `hydratable` ([#17284](https://github.com/sveltejs/svelte/pull/17284))
12+
313
## 5.45.2
414

515
### 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.45.2",
5+
"version": "5.45.3",
66
"type": "module",
77
"types": "./types/index.d.ts",
88
"engines": {

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

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
/** @import { AST } from '#compiler' */
2+
/** @import { Location } from 'locate-character' */
3+
/** @import * as ESTree from 'estree' */
24
// @ts-expect-error acorn type definitions are borked in the release we use
35
import { isIdentifierStart, isIdentifierChar } from 'acorn';
46
import fragment from './state/fragment.js';
@@ -218,31 +220,45 @@ export class Parser {
218220
return result;
219221
}
220222

221-
/** @param {any} allow_reserved */
222-
read_identifier(allow_reserved = false) {
223+
/**
224+
* @returns {ESTree.Identifier & { start: number, end: number, loc: { start: Location, end: Location } }}
225+
*/
226+
read_identifier() {
223227
const start = this.index;
228+
let end = start;
229+
let name = '';
224230

225-
let i = this.index;
231+
const code = /** @type {number} */ (this.template.codePointAt(this.index));
226232

227-
const code = /** @type {number} */ (this.template.codePointAt(i));
228-
if (!isIdentifierStart(code, true)) return null;
233+
if (isIdentifierStart(code, true)) {
234+
let i = this.index;
235+
end += code <= 0xffff ? 1 : 2;
229236

230-
i += code <= 0xffff ? 1 : 2;
237+
while (end < this.template.length) {
238+
const code = /** @type {number} */ (this.template.codePointAt(end));
231239

232-
while (i < this.template.length) {
233-
const code = /** @type {number} */ (this.template.codePointAt(i));
234-
235-
if (!isIdentifierChar(code, true)) break;
236-
i += code <= 0xffff ? 1 : 2;
237-
}
240+
if (!isIdentifierChar(code, true)) break;
241+
end += code <= 0xffff ? 1 : 2;
242+
}
238243

239-
const identifier = this.template.slice(this.index, (this.index = i));
244+
name = this.template.slice(start, end);
245+
this.index = end;
240246

241-
if (!allow_reserved && is_reserved(identifier)) {
242-
e.unexpected_reserved_word(start, identifier);
247+
if (is_reserved(name)) {
248+
e.unexpected_reserved_word(start, name);
249+
}
243250
}
244251

245-
return identifier;
252+
return {
253+
type: 'Identifier',
254+
name,
255+
start,
256+
end,
257+
loc: {
258+
start: state.locator(start),
259+
end: state.locator(end)
260+
}
261+
};
246262
}
247263

248264
/** @param {RegExp} pattern */

packages/svelte/src/compiler/phases/1-parse/read/context.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
/** @import { Location } from 'locate-character' */
21
/** @import { Pattern } from 'estree' */
32
/** @import { Parser } from '../index.js' */
43
import { match_bracket } from '../utils/bracket.js';
54
import { parse_expression_at } from '../acorn.js';
65
import { regex_not_newline_characters } from '../../patterns.js';
76
import * as e from '../../../errors.js';
8-
import { locator } from '../../../state.js';
97

108
/**
119
* @param {Parser} parser
@@ -15,20 +13,13 @@ export default function read_pattern(parser) {
1513
const start = parser.index;
1614
let i = parser.index;
1715

18-
const name = parser.read_identifier();
16+
const id = parser.read_identifier();
1917

20-
if (name !== null) {
18+
if (id.name !== '') {
2119
const annotation = read_type_annotation(parser);
2220

2321
return {
24-
type: 'Identifier',
25-
name,
26-
start,
27-
loc: {
28-
start: /** @type {Location} */ (locator(start)),
29-
end: /** @type {Location} */ (locator(parser.index))
30-
},
31-
end: parser.index,
22+
...id,
3223
typeAnnotation: annotation
3324
};
3425
}

0 commit comments

Comments
 (0)