svelte 3.43.2 → 3.44.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +1 -1
- package/compiler.js +83 -48
- package/compiler.js.map +1 -1
- package/compiler.mjs +83 -48
- package/compiler.mjs.map +1 -1
- package/internal/index.js +26 -8
- package/internal/index.mjs +26 -8
- package/package.json +15 -2
- package/types/compiler/compile/Component.d.ts +2 -2
- package/types/compiler/compile/utils/check_enable_sourcemap.d.ts +2 -0
- package/types/compiler/interfaces.d.ts +5 -0
- package/types/compiler/preprocess/types.d.ts +3 -3
- package/types/compiler/utils/patterns.d.ts +2 -0
- package/types/runtime/transition/index.d.ts +4 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Svelte changelog
|
|
2
2
|
|
|
3
|
+
## 3.44.3
|
|
4
|
+
|
|
5
|
+
* Fix `bind:this` binding inside `onMount` for manually instantiated component ([#6760](https://github.com/sveltejs/svelte/issues/6760))
|
|
6
|
+
* Prevent cursor jumps for other `type="text"`-like `<input>`s ([#6914](https://github.com/sveltejs/svelte/issues/6914))
|
|
7
|
+
* Exclude `async` loops from `loopGuardTimeout` ([#6945](https://github.com/sveltejs/svelte/issues/6945))
|
|
8
|
+
|
|
9
|
+
## 3.44.2
|
|
10
|
+
|
|
11
|
+
* Fix overly restrictive preprocessor types ([#6904](https://github.com/sveltejs/svelte/pull/6904))
|
|
12
|
+
* More specific typing for crossfade function - returns a tuple, not an array ([#6926](https://github.com/sveltejs/svelte/issues/6926))
|
|
13
|
+
* Add `URLSearchParams` as a known global ([#6938](https://github.com/sveltejs/svelte/pull/6938))
|
|
14
|
+
* Add `types` field to `exports` map ([#6939](https://github.com/sveltejs/svelte/issues/6939))
|
|
15
|
+
|
|
16
|
+
## 3.44.1
|
|
17
|
+
|
|
18
|
+
* Fix code generation when a multi-line `return` statement contains comments ([code-red#36](https://github.com/Rich-Harris/code-red/issues/36))
|
|
19
|
+
* Fix code generation when `for`/`if`/`while` statements have empty bodies ([#6884](https://github.com/sveltejs/svelte/issues/6884))
|
|
20
|
+
|
|
21
|
+
## 3.44.0
|
|
22
|
+
|
|
23
|
+
* Add `enableSourcemap` compiler option ([#6835](https://github.com/sveltejs/svelte/pull/6835))
|
|
24
|
+
|
|
3
25
|
## 3.43.2
|
|
4
26
|
|
|
5
27
|
* Fix regression where user-specified `import`s were not rewritten according to the `sveltePath` option ([#6834](https://github.com/sveltejs/svelte/issues/6834))
|
package/README.md
CHANGED
|
@@ -64,7 +64,7 @@ npm run test -- -g transition
|
|
|
64
64
|
|
|
65
65
|
## svelte.dev
|
|
66
66
|
|
|
67
|
-
The source code for https://svelte.dev, including all the documentation, lives in the [site](site) directory. The site is built with [
|
|
67
|
+
The source code for https://svelte.dev, including all the documentation, lives in the [site](site) directory. The site is built with [SvelteKit](https://kit.svelte.dev).
|
|
68
68
|
|
|
69
69
|
### Is svelte.dev down?
|
|
70
70
|
|
package/compiler.js
CHANGED
|
@@ -6498,7 +6498,7 @@
|
|
|
6498
6498
|
}),
|
|
6499
6499
|
|
|
6500
6500
|
EmptyStatement(node, state) {
|
|
6501
|
-
return [];
|
|
6501
|
+
return [c(';')];
|
|
6502
6502
|
},
|
|
6503
6503
|
|
|
6504
6504
|
ParenthesizedExpression(node, state) {
|
|
@@ -6604,10 +6604,11 @@
|
|
|
6604
6604
|
|
|
6605
6605
|
ReturnStatement(node, state) {
|
|
6606
6606
|
if (node.argument) {
|
|
6607
|
+
const contains_comment = node.argument.leadingComments && node.argument.leadingComments.some((/** @type import('../utils/comments.js').CommentWithLocation */ comment) => comment.has_trailing_newline);
|
|
6607
6608
|
return [
|
|
6608
|
-
c('return '),
|
|
6609
|
+
c(contains_comment ? 'return (' : 'return '),
|
|
6609
6610
|
...handle(node.argument, state),
|
|
6610
|
-
c(';')
|
|
6611
|
+
c(contains_comment ? ');' : ';')
|
|
6611
6612
|
];
|
|
6612
6613
|
} else {
|
|
6613
6614
|
return [c('return;')];
|
|
@@ -7961,7 +7962,7 @@
|
|
|
7961
7962
|
|
|
7962
7963
|
const { enter, leave } = get_comment_handlers(comments, raw);
|
|
7963
7964
|
|
|
7964
|
-
walk(node, {
|
|
7965
|
+
return walk(node, {
|
|
7965
7966
|
enter,
|
|
7966
7967
|
|
|
7967
7968
|
/** @param {any} node */
|
|
@@ -8063,7 +8064,6 @@
|
|
|
8063
8064
|
node.update = node.update === EMPTY ? null : node.update;
|
|
8064
8065
|
}
|
|
8065
8066
|
|
|
8066
|
-
// @ts-ignore
|
|
8067
8067
|
leave(node);
|
|
8068
8068
|
}
|
|
8069
8069
|
});
|
|
@@ -8082,11 +8082,11 @@
|
|
|
8082
8082
|
const comments = [];
|
|
8083
8083
|
|
|
8084
8084
|
try {
|
|
8085
|
-
|
|
8085
|
+
let ast = /** @type {any} */ (
|
|
8086
8086
|
parse(str, acorn_opts(comments, str))
|
|
8087
8087
|
);
|
|
8088
8088
|
|
|
8089
|
-
inject(str, ast, values, comments);
|
|
8089
|
+
ast = inject(str, ast, values, comments);
|
|
8090
8090
|
|
|
8091
8091
|
return ast.body;
|
|
8092
8092
|
} catch (err) {
|
|
@@ -8107,7 +8107,7 @@
|
|
|
8107
8107
|
const comments = [];
|
|
8108
8108
|
|
|
8109
8109
|
try {
|
|
8110
|
-
|
|
8110
|
+
let expression =
|
|
8111
8111
|
/** @type {Expression & { start: Number, end: number }} */ (
|
|
8112
8112
|
parseExpressionAt(str, 0, acorn_opts(comments, str))
|
|
8113
8113
|
);
|
|
@@ -8116,7 +8116,9 @@
|
|
|
8116
8116
|
throw new Error(`Unexpected token '${match[0]}'`);
|
|
8117
8117
|
}
|
|
8118
8118
|
|
|
8119
|
-
|
|
8119
|
+
expression = /** @type {Expression & { start: Number, end: number }} */ (
|
|
8120
|
+
inject(str, expression, values, comments)
|
|
8121
|
+
);
|
|
8120
8122
|
|
|
8121
8123
|
return expression;
|
|
8122
8124
|
} catch (err) {
|
|
@@ -8137,11 +8139,11 @@
|
|
|
8137
8139
|
const comments = [];
|
|
8138
8140
|
|
|
8139
8141
|
try {
|
|
8140
|
-
|
|
8142
|
+
let expression = /** @type {any} */ (
|
|
8141
8143
|
parseExpressionAt(str, 0, acorn_opts(comments, str))
|
|
8142
8144
|
);
|
|
8143
8145
|
|
|
8144
|
-
inject(str, expression, values, comments);
|
|
8146
|
+
expression = inject(str, expression, values, comments);
|
|
8145
8147
|
|
|
8146
8148
|
return expression.properties[0];
|
|
8147
8149
|
} catch (err) {
|
|
@@ -8210,6 +8212,8 @@
|
|
|
8210
8212
|
});
|
|
8211
8213
|
|
|
8212
8214
|
const whitespace = /[ \t\r\n]/;
|
|
8215
|
+
const start_whitespace = /^[ \t\r\n]*/;
|
|
8216
|
+
const end_whitespace = /[ \t\r\n]*$/;
|
|
8213
8217
|
const dimensions = /^(?:offset|client)(?:Width|Height)$/;
|
|
8214
8218
|
|
|
8215
8219
|
function list(items, conjunction = 'or') {
|
|
@@ -16396,6 +16400,7 @@
|
|
|
16396
16400
|
'undefined',
|
|
16397
16401
|
'URIError',
|
|
16398
16402
|
'URL',
|
|
16403
|
+
'URLSearchParams',
|
|
16399
16404
|
'window'
|
|
16400
16405
|
]);
|
|
16401
16406
|
const reserved = new Set([
|
|
@@ -17224,16 +17229,10 @@
|
|
|
17224
17229
|
}
|
|
17225
17230
|
|
|
17226
17231
|
function trim_start(str) {
|
|
17227
|
-
|
|
17228
|
-
while (whitespace.test(str[i]))
|
|
17229
|
-
i += 1;
|
|
17230
|
-
return str.slice(i);
|
|
17232
|
+
return str.replace(start_whitespace, '');
|
|
17231
17233
|
}
|
|
17232
17234
|
function trim_end(str) {
|
|
17233
|
-
|
|
17234
|
-
while (whitespace.test(str[i - 1]))
|
|
17235
|
-
i -= 1;
|
|
17236
|
-
return str.slice(0, i);
|
|
17235
|
+
return str.replace(end_whitespace, '');
|
|
17237
17236
|
}
|
|
17238
17237
|
|
|
17239
17238
|
function to_string(node) {
|
|
@@ -19259,6 +19258,20 @@
|
|
|
19259
19258
|
}
|
|
19260
19259
|
}
|
|
19261
19260
|
|
|
19261
|
+
const non_textlike_input_types = new Set([
|
|
19262
|
+
'button',
|
|
19263
|
+
'checkbox',
|
|
19264
|
+
'color',
|
|
19265
|
+
'date',
|
|
19266
|
+
'datetime-local',
|
|
19267
|
+
'file',
|
|
19268
|
+
'hidden',
|
|
19269
|
+
'image',
|
|
19270
|
+
'radio',
|
|
19271
|
+
'range',
|
|
19272
|
+
'reset',
|
|
19273
|
+
'submit'
|
|
19274
|
+
]);
|
|
19262
19275
|
class BaseAttributeWrapper {
|
|
19263
19276
|
constructor(parent, block, node) {
|
|
19264
19277
|
this.node = node;
|
|
@@ -19405,7 +19418,7 @@
|
|
|
19405
19418
|
}
|
|
19406
19419
|
if (this.is_input_value) {
|
|
19407
19420
|
const type = element.node.get_static_attribute_value('type');
|
|
19408
|
-
if (type
|
|
19421
|
+
if (type !== true && !non_textlike_input_types.has(type)) {
|
|
19409
19422
|
condition = x `${condition} && ${element.var}.${property_name} !== ${should_cache ? last : value}`;
|
|
19410
19423
|
}
|
|
19411
19424
|
}
|
|
@@ -24930,6 +24943,12 @@
|
|
|
24930
24943
|
});
|
|
24931
24944
|
}
|
|
24932
24945
|
|
|
24946
|
+
function check_enable_sourcemap(enable_sourcemap, namespace) {
|
|
24947
|
+
return typeof enable_sourcemap === 'boolean'
|
|
24948
|
+
? enable_sourcemap
|
|
24949
|
+
: enable_sourcemap[namespace];
|
|
24950
|
+
}
|
|
24951
|
+
|
|
24933
24952
|
function dom(component, options) {
|
|
24934
24953
|
const { name } = component;
|
|
24935
24954
|
const renderer = new Renderer(component, options);
|
|
@@ -24944,8 +24963,14 @@
|
|
|
24944
24963
|
body.push(b `const ${renderer.file_var} = ${file};`);
|
|
24945
24964
|
}
|
|
24946
24965
|
const css = component.stylesheet.render(options.filename, !options.customElement);
|
|
24947
|
-
|
|
24948
|
-
|
|
24966
|
+
const css_sourcemap_enabled = check_enable_sourcemap(options.enableSourcemap, 'css');
|
|
24967
|
+
if (css_sourcemap_enabled) {
|
|
24968
|
+
css.map = apply_preprocessor_sourcemap(options.filename, css.map, options.sourcemap);
|
|
24969
|
+
}
|
|
24970
|
+
else {
|
|
24971
|
+
css.map = null;
|
|
24972
|
+
}
|
|
24973
|
+
const styles = css_sourcemap_enabled && component.stylesheet.has_styles && options.dev
|
|
24949
24974
|
? `${css.code}\n/*# sourceMappingURL=${css.map.toUrl()} */`
|
|
24950
24975
|
: css.code;
|
|
24951
24976
|
const add_css = component.get_unique_name('add_css');
|
|
@@ -25351,7 +25376,7 @@
|
|
|
25351
25376
|
constructor(options) {
|
|
25352
25377
|
super();
|
|
25353
25378
|
|
|
25354
|
-
${css.code && b `this.shadowRoot.innerHTML = \`<style>${css.code.replace(/\\/g, '\\\\')}${options.dev ? `\n/*# sourceMappingURL=${css.map.toUrl()} */` : ''}</style>\`;`}
|
|
25379
|
+
${css.code && b `this.shadowRoot.innerHTML = \`<style>${css.code.replace(/\\/g, '\\\\')}${css_sourcemap_enabled && options.dev ? `\n/*# sourceMappingURL=${css.map.toUrl()} */` : ''}</style>\`;`}
|
|
25355
25380
|
|
|
25356
25381
|
@init(this, { target: this.shadowRoot, props: ${init_props}, customElement: true }, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, null, ${dirty});
|
|
25357
25382
|
|
|
@@ -27753,11 +27778,12 @@
|
|
|
27753
27778
|
css.code && b `$$result.css.add(#css);`,
|
|
27754
27779
|
main
|
|
27755
27780
|
].filter(Boolean);
|
|
27781
|
+
const css_sourcemap_enabled = check_enable_sourcemap(options.enableSourcemap, 'css');
|
|
27756
27782
|
const js = b `
|
|
27757
27783
|
${css.code ? b `
|
|
27758
27784
|
const #css = {
|
|
27759
27785
|
code: "${css.code}",
|
|
27760
|
-
map: ${css.map ? string_literal(css.map.toString()) : 'null'}
|
|
27786
|
+
map: ${css_sourcemap_enabled && css.map ? string_literal(css.map.toString()) : 'null'}
|
|
27761
27787
|
};` : null}
|
|
27762
27788
|
|
|
27763
27789
|
${component.extract_javascript(component.ast.module)}
|
|
@@ -30129,7 +30155,7 @@
|
|
|
30129
30155
|
if (result) {
|
|
30130
30156
|
const { compile_options, name } = this;
|
|
30131
30157
|
const { format = 'esm' } = compile_options;
|
|
30132
|
-
const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.
|
|
30158
|
+
const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.44.3'}`;
|
|
30133
30159
|
const program = { type: 'Program', body: result.js };
|
|
30134
30160
|
walk(program, {
|
|
30135
30161
|
enter: (node, parent, key) => {
|
|
@@ -30193,17 +30219,24 @@
|
|
|
30193
30219
|
css = compile_options.customElement
|
|
30194
30220
|
? { code: null, map: null }
|
|
30195
30221
|
: result.css;
|
|
30196
|
-
const
|
|
30197
|
-
|
|
30198
|
-
|
|
30199
|
-
|
|
30200
|
-
|
|
30201
|
-
|
|
30202
|
-
|
|
30203
|
-
|
|
30204
|
-
|
|
30205
|
-
|
|
30206
|
-
|
|
30222
|
+
const js_sourcemap_enabled = check_enable_sourcemap(compile_options.enableSourcemap, 'js');
|
|
30223
|
+
if (!js_sourcemap_enabled) {
|
|
30224
|
+
js = print(program);
|
|
30225
|
+
js.map = null;
|
|
30226
|
+
}
|
|
30227
|
+
else {
|
|
30228
|
+
const sourcemap_source_filename = get_sourcemap_source_filename(compile_options);
|
|
30229
|
+
js = print(program, {
|
|
30230
|
+
sourceMapSource: sourcemap_source_filename
|
|
30231
|
+
});
|
|
30232
|
+
js.map.sources = [
|
|
30233
|
+
sourcemap_source_filename
|
|
30234
|
+
];
|
|
30235
|
+
js.map.sourcesContent = [
|
|
30236
|
+
this.source
|
|
30237
|
+
];
|
|
30238
|
+
js.map = apply_preprocessor_sourcemap(sourcemap_source_filename, js.map, compile_options.sourcemap);
|
|
30239
|
+
}
|
|
30207
30240
|
}
|
|
30208
30241
|
return {
|
|
30209
30242
|
js,
|
|
@@ -30546,11 +30579,12 @@
|
|
|
30546
30579
|
to_remove.unshift([parent, prop, index]);
|
|
30547
30580
|
};
|
|
30548
30581
|
let scope_updated = false;
|
|
30549
|
-
|
|
30582
|
+
const current_function_stack = [];
|
|
30583
|
+
let current_function = null;
|
|
30550
30584
|
walk(content, {
|
|
30551
30585
|
enter(node, parent, prop, index) {
|
|
30552
|
-
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression')
|
|
30553
|
-
|
|
30586
|
+
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression')) {
|
|
30587
|
+
current_function_stack.push(current_function = node);
|
|
30554
30588
|
}
|
|
30555
30589
|
if (map.has(node)) {
|
|
30556
30590
|
scope = map.get(node);
|
|
@@ -30575,11 +30609,12 @@
|
|
|
30575
30609
|
component.warn_on_undefined_store_value_references(node, parent, prop, scope);
|
|
30576
30610
|
},
|
|
30577
30611
|
leave(node) {
|
|
30578
|
-
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression')
|
|
30579
|
-
|
|
30612
|
+
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression')) {
|
|
30613
|
+
current_function_stack.pop();
|
|
30614
|
+
current_function = current_function_stack[current_function_stack.length - 1];
|
|
30580
30615
|
}
|
|
30581
30616
|
// do it on leave, to prevent infinite loop
|
|
30582
|
-
if (component.compile_options.dev && component.compile_options.loopGuardTimeout > 0 &&
|
|
30617
|
+
if (component.compile_options.dev && component.compile_options.loopGuardTimeout > 0 && (!current_function || (!current_function.generator && !current_function.async))) {
|
|
30583
30618
|
const to_replace_for_loop_protect = component.loop_protect(node, scope, component.compile_options.loopGuardTimeout);
|
|
30584
30619
|
if (to_replace_for_loop_protect) {
|
|
30585
30620
|
this.replace(to_replace_for_loop_protect);
|
|
@@ -31251,6 +31286,7 @@
|
|
|
31251
31286
|
'name',
|
|
31252
31287
|
'filename',
|
|
31253
31288
|
'sourcemap',
|
|
31289
|
+
'enableSourcemap',
|
|
31254
31290
|
'generate',
|
|
31255
31291
|
'errorMode',
|
|
31256
31292
|
'varsReport',
|
|
@@ -31314,7 +31350,7 @@
|
|
|
31314
31350
|
}
|
|
31315
31351
|
}
|
|
31316
31352
|
function compile(source, options = {}) {
|
|
31317
|
-
options = Object.assign({ generate: 'dom', dev: false }, options);
|
|
31353
|
+
options = Object.assign({ generate: 'dom', dev: false, enableSourcemap: true }, options);
|
|
31318
31354
|
const stats = new Stats();
|
|
31319
31355
|
const warnings = [];
|
|
31320
31356
|
validate_options(options, warnings);
|
|
@@ -31568,10 +31604,10 @@
|
|
|
31568
31604
|
const { string, map } = await replace_in_code(tag_regex, process_single_tag, source);
|
|
31569
31605
|
return { string, map, dependencies };
|
|
31570
31606
|
}
|
|
31571
|
-
async function process_markup(
|
|
31607
|
+
async function process_markup(process, source) {
|
|
31572
31608
|
const processed = await process({
|
|
31573
31609
|
content: source.source,
|
|
31574
|
-
filename
|
|
31610
|
+
filename: source.filename
|
|
31575
31611
|
});
|
|
31576
31612
|
if (processed) {
|
|
31577
31613
|
return {
|
|
@@ -31590,7 +31626,6 @@
|
|
|
31590
31626
|
}
|
|
31591
31627
|
}
|
|
31592
31628
|
async function preprocess(source, preprocessor, options) {
|
|
31593
|
-
// @ts-ignore todo: doublecheck
|
|
31594
31629
|
const filename = (options && options.filename) || preprocessor.filename; // legacy
|
|
31595
31630
|
const preprocessors = preprocessor ? (Array.isArray(preprocessor) ? preprocessor : [preprocessor]) : [];
|
|
31596
31631
|
const markup = preprocessors.map(p => p.markup).filter(Boolean);
|
|
@@ -31600,7 +31635,7 @@
|
|
|
31600
31635
|
// TODO keep track: what preprocessor generated what sourcemap?
|
|
31601
31636
|
// to make debugging easier = detect low-resolution sourcemaps in fn combine_mappings
|
|
31602
31637
|
for (const process of markup) {
|
|
31603
|
-
result.update_source(await process_markup(
|
|
31638
|
+
result.update_source(await process_markup(process, result));
|
|
31604
31639
|
}
|
|
31605
31640
|
for (const process of script) {
|
|
31606
31641
|
result.update_source(await process_tag('script', process, result));
|
|
@@ -31611,7 +31646,7 @@
|
|
|
31611
31646
|
return result.to_processed();
|
|
31612
31647
|
}
|
|
31613
31648
|
|
|
31614
|
-
const VERSION = '3.
|
|
31649
|
+
const VERSION = '3.44.3';
|
|
31615
31650
|
|
|
31616
31651
|
exports.VERSION = VERSION;
|
|
31617
31652
|
exports.compile = compile;
|