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/compiler.mjs
CHANGED
|
@@ -6492,7 +6492,7 @@ const handlers = {
|
|
|
6492
6492
|
}),
|
|
6493
6493
|
|
|
6494
6494
|
EmptyStatement(node, state) {
|
|
6495
|
-
return [];
|
|
6495
|
+
return [c(';')];
|
|
6496
6496
|
},
|
|
6497
6497
|
|
|
6498
6498
|
ParenthesizedExpression(node, state) {
|
|
@@ -6598,10 +6598,11 @@ const handlers = {
|
|
|
6598
6598
|
|
|
6599
6599
|
ReturnStatement(node, state) {
|
|
6600
6600
|
if (node.argument) {
|
|
6601
|
+
const contains_comment = node.argument.leadingComments && node.argument.leadingComments.some((/** @type import('../utils/comments.js').CommentWithLocation */ comment) => comment.has_trailing_newline);
|
|
6601
6602
|
return [
|
|
6602
|
-
c('return '),
|
|
6603
|
+
c(contains_comment ? 'return (' : 'return '),
|
|
6603
6604
|
...handle(node.argument, state),
|
|
6604
|
-
c(';')
|
|
6605
|
+
c(contains_comment ? ');' : ';')
|
|
6605
6606
|
];
|
|
6606
6607
|
} else {
|
|
6607
6608
|
return [c('return;')];
|
|
@@ -7955,7 +7956,7 @@ const inject = (raw, node, values, comments) => {
|
|
|
7955
7956
|
|
|
7956
7957
|
const { enter, leave } = get_comment_handlers(comments, raw);
|
|
7957
7958
|
|
|
7958
|
-
walk(node, {
|
|
7959
|
+
return walk(node, {
|
|
7959
7960
|
enter,
|
|
7960
7961
|
|
|
7961
7962
|
/** @param {any} node */
|
|
@@ -8057,7 +8058,6 @@ const inject = (raw, node, values, comments) => {
|
|
|
8057
8058
|
node.update = node.update === EMPTY ? null : node.update;
|
|
8058
8059
|
}
|
|
8059
8060
|
|
|
8060
|
-
// @ts-ignore
|
|
8061
8061
|
leave(node);
|
|
8062
8062
|
}
|
|
8063
8063
|
});
|
|
@@ -8076,11 +8076,11 @@ function b(strings, ...values) {
|
|
|
8076
8076
|
const comments = [];
|
|
8077
8077
|
|
|
8078
8078
|
try {
|
|
8079
|
-
|
|
8079
|
+
let ast = /** @type {any} */ (
|
|
8080
8080
|
parse(str, acorn_opts(comments, str))
|
|
8081
8081
|
);
|
|
8082
8082
|
|
|
8083
|
-
inject(str, ast, values, comments);
|
|
8083
|
+
ast = inject(str, ast, values, comments);
|
|
8084
8084
|
|
|
8085
8085
|
return ast.body;
|
|
8086
8086
|
} catch (err) {
|
|
@@ -8101,7 +8101,7 @@ function x(strings, ...values) {
|
|
|
8101
8101
|
const comments = [];
|
|
8102
8102
|
|
|
8103
8103
|
try {
|
|
8104
|
-
|
|
8104
|
+
let expression =
|
|
8105
8105
|
/** @type {Expression & { start: Number, end: number }} */ (
|
|
8106
8106
|
parseExpressionAt(str, 0, acorn_opts(comments, str))
|
|
8107
8107
|
);
|
|
@@ -8110,7 +8110,9 @@ function x(strings, ...values) {
|
|
|
8110
8110
|
throw new Error(`Unexpected token '${match[0]}'`);
|
|
8111
8111
|
}
|
|
8112
8112
|
|
|
8113
|
-
|
|
8113
|
+
expression = /** @type {Expression & { start: Number, end: number }} */ (
|
|
8114
|
+
inject(str, expression, values, comments)
|
|
8115
|
+
);
|
|
8114
8116
|
|
|
8115
8117
|
return expression;
|
|
8116
8118
|
} catch (err) {
|
|
@@ -8131,11 +8133,11 @@ function p(strings, ...values) {
|
|
|
8131
8133
|
const comments = [];
|
|
8132
8134
|
|
|
8133
8135
|
try {
|
|
8134
|
-
|
|
8136
|
+
let expression = /** @type {any} */ (
|
|
8135
8137
|
parseExpressionAt(str, 0, acorn_opts(comments, str))
|
|
8136
8138
|
);
|
|
8137
8139
|
|
|
8138
|
-
inject(str, expression, values, comments);
|
|
8140
|
+
expression = inject(str, expression, values, comments);
|
|
8139
8141
|
|
|
8140
8142
|
return expression.properties[0];
|
|
8141
8143
|
} catch (err) {
|
|
@@ -8204,6 +8206,8 @@ const parse_expression_at = (source, index) => parseExpressionAt$1(source, index
|
|
|
8204
8206
|
});
|
|
8205
8207
|
|
|
8206
8208
|
const whitespace = /[ \t\r\n]/;
|
|
8209
|
+
const start_whitespace = /^[ \t\r\n]*/;
|
|
8210
|
+
const end_whitespace = /[ \t\r\n]*$/;
|
|
8207
8211
|
const dimensions = /^(?:offset|client)(?:Width|Height)$/;
|
|
8208
8212
|
|
|
8209
8213
|
function list(items, conjunction = 'or') {
|
|
@@ -16390,6 +16394,7 @@ const globals = new Set([
|
|
|
16390
16394
|
'undefined',
|
|
16391
16395
|
'URIError',
|
|
16392
16396
|
'URL',
|
|
16397
|
+
'URLSearchParams',
|
|
16393
16398
|
'window'
|
|
16394
16399
|
]);
|
|
16395
16400
|
const reserved = new Set([
|
|
@@ -17218,16 +17223,10 @@ function read_context(parser) {
|
|
|
17218
17223
|
}
|
|
17219
17224
|
|
|
17220
17225
|
function trim_start(str) {
|
|
17221
|
-
|
|
17222
|
-
while (whitespace.test(str[i]))
|
|
17223
|
-
i += 1;
|
|
17224
|
-
return str.slice(i);
|
|
17226
|
+
return str.replace(start_whitespace, '');
|
|
17225
17227
|
}
|
|
17226
17228
|
function trim_end(str) {
|
|
17227
|
-
|
|
17228
|
-
while (whitespace.test(str[i - 1]))
|
|
17229
|
-
i -= 1;
|
|
17230
|
-
return str.slice(0, i);
|
|
17229
|
+
return str.replace(end_whitespace, '');
|
|
17231
17230
|
}
|
|
17232
17231
|
|
|
17233
17232
|
function to_string(node) {
|
|
@@ -19253,6 +19252,20 @@ function handle_select_value_binding(attr, dependencies) {
|
|
|
19253
19252
|
}
|
|
19254
19253
|
}
|
|
19255
19254
|
|
|
19255
|
+
const non_textlike_input_types = new Set([
|
|
19256
|
+
'button',
|
|
19257
|
+
'checkbox',
|
|
19258
|
+
'color',
|
|
19259
|
+
'date',
|
|
19260
|
+
'datetime-local',
|
|
19261
|
+
'file',
|
|
19262
|
+
'hidden',
|
|
19263
|
+
'image',
|
|
19264
|
+
'radio',
|
|
19265
|
+
'range',
|
|
19266
|
+
'reset',
|
|
19267
|
+
'submit'
|
|
19268
|
+
]);
|
|
19256
19269
|
class BaseAttributeWrapper {
|
|
19257
19270
|
constructor(parent, block, node) {
|
|
19258
19271
|
this.node = node;
|
|
@@ -19399,7 +19412,7 @@ class AttributeWrapper extends BaseAttributeWrapper {
|
|
|
19399
19412
|
}
|
|
19400
19413
|
if (this.is_input_value) {
|
|
19401
19414
|
const type = element.node.get_static_attribute_value('type');
|
|
19402
|
-
if (type
|
|
19415
|
+
if (type !== true && !non_textlike_input_types.has(type)) {
|
|
19403
19416
|
condition = x `${condition} && ${element.var}.${property_name} !== ${should_cache ? last : value}`;
|
|
19404
19417
|
}
|
|
19405
19418
|
}
|
|
@@ -24924,6 +24937,12 @@ function parse_attached_sourcemap(processed, tag_name) {
|
|
|
24924
24937
|
});
|
|
24925
24938
|
}
|
|
24926
24939
|
|
|
24940
|
+
function check_enable_sourcemap(enable_sourcemap, namespace) {
|
|
24941
|
+
return typeof enable_sourcemap === 'boolean'
|
|
24942
|
+
? enable_sourcemap
|
|
24943
|
+
: enable_sourcemap[namespace];
|
|
24944
|
+
}
|
|
24945
|
+
|
|
24927
24946
|
function dom(component, options) {
|
|
24928
24947
|
const { name } = component;
|
|
24929
24948
|
const renderer = new Renderer(component, options);
|
|
@@ -24938,8 +24957,14 @@ function dom(component, options) {
|
|
|
24938
24957
|
body.push(b `const ${renderer.file_var} = ${file};`);
|
|
24939
24958
|
}
|
|
24940
24959
|
const css = component.stylesheet.render(options.filename, !options.customElement);
|
|
24941
|
-
|
|
24942
|
-
|
|
24960
|
+
const css_sourcemap_enabled = check_enable_sourcemap(options.enableSourcemap, 'css');
|
|
24961
|
+
if (css_sourcemap_enabled) {
|
|
24962
|
+
css.map = apply_preprocessor_sourcemap(options.filename, css.map, options.sourcemap);
|
|
24963
|
+
}
|
|
24964
|
+
else {
|
|
24965
|
+
css.map = null;
|
|
24966
|
+
}
|
|
24967
|
+
const styles = css_sourcemap_enabled && component.stylesheet.has_styles && options.dev
|
|
24943
24968
|
? `${css.code}\n/*# sourceMappingURL=${css.map.toUrl()} */`
|
|
24944
24969
|
: css.code;
|
|
24945
24970
|
const add_css = component.get_unique_name('add_css');
|
|
@@ -25345,7 +25370,7 @@ function dom(component, options) {
|
|
|
25345
25370
|
constructor(options) {
|
|
25346
25371
|
super();
|
|
25347
25372
|
|
|
25348
|
-
${css.code && b `this.shadowRoot.innerHTML = \`<style>${css.code.replace(/\\/g, '\\\\')}${options.dev ? `\n/*# sourceMappingURL=${css.map.toUrl()} */` : ''}</style>\`;`}
|
|
25373
|
+
${css.code && b `this.shadowRoot.innerHTML = \`<style>${css.code.replace(/\\/g, '\\\\')}${css_sourcemap_enabled && options.dev ? `\n/*# sourceMappingURL=${css.map.toUrl()} */` : ''}</style>\`;`}
|
|
25349
25374
|
|
|
25350
25375
|
@init(this, { target: this.shadowRoot, props: ${init_props}, customElement: true }, ${definition}, ${has_create_fragment ? 'create_fragment' : 'null'}, ${not_equal}, ${prop_indexes}, null, ${dirty});
|
|
25351
25376
|
|
|
@@ -27747,11 +27772,12 @@ function ssr(component, options) {
|
|
|
27747
27772
|
css.code && b `$$result.css.add(#css);`,
|
|
27748
27773
|
main
|
|
27749
27774
|
].filter(Boolean);
|
|
27775
|
+
const css_sourcemap_enabled = check_enable_sourcemap(options.enableSourcemap, 'css');
|
|
27750
27776
|
const js = b `
|
|
27751
27777
|
${css.code ? b `
|
|
27752
27778
|
const #css = {
|
|
27753
27779
|
code: "${css.code}",
|
|
27754
|
-
map: ${css.map ? string_literal(css.map.toString()) : 'null'}
|
|
27780
|
+
map: ${css_sourcemap_enabled && css.map ? string_literal(css.map.toString()) : 'null'}
|
|
27755
27781
|
};` : null}
|
|
27756
27782
|
|
|
27757
27783
|
${component.extract_javascript(component.ast.module)}
|
|
@@ -30123,7 +30149,7 @@ class Component {
|
|
|
30123
30149
|
if (result) {
|
|
30124
30150
|
const { compile_options, name } = this;
|
|
30125
30151
|
const { format = 'esm' } = compile_options;
|
|
30126
|
-
const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.
|
|
30152
|
+
const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.44.3'}`;
|
|
30127
30153
|
const program = { type: 'Program', body: result.js };
|
|
30128
30154
|
walk(program, {
|
|
30129
30155
|
enter: (node, parent, key) => {
|
|
@@ -30187,17 +30213,24 @@ class Component {
|
|
|
30187
30213
|
css = compile_options.customElement
|
|
30188
30214
|
? { code: null, map: null }
|
|
30189
30215
|
: result.css;
|
|
30190
|
-
const
|
|
30191
|
-
|
|
30192
|
-
|
|
30193
|
-
|
|
30194
|
-
|
|
30195
|
-
|
|
30196
|
-
|
|
30197
|
-
|
|
30198
|
-
|
|
30199
|
-
|
|
30200
|
-
|
|
30216
|
+
const js_sourcemap_enabled = check_enable_sourcemap(compile_options.enableSourcemap, 'js');
|
|
30217
|
+
if (!js_sourcemap_enabled) {
|
|
30218
|
+
js = print(program);
|
|
30219
|
+
js.map = null;
|
|
30220
|
+
}
|
|
30221
|
+
else {
|
|
30222
|
+
const sourcemap_source_filename = get_sourcemap_source_filename(compile_options);
|
|
30223
|
+
js = print(program, {
|
|
30224
|
+
sourceMapSource: sourcemap_source_filename
|
|
30225
|
+
});
|
|
30226
|
+
js.map.sources = [
|
|
30227
|
+
sourcemap_source_filename
|
|
30228
|
+
];
|
|
30229
|
+
js.map.sourcesContent = [
|
|
30230
|
+
this.source
|
|
30231
|
+
];
|
|
30232
|
+
js.map = apply_preprocessor_sourcemap(sourcemap_source_filename, js.map, compile_options.sourcemap);
|
|
30233
|
+
}
|
|
30201
30234
|
}
|
|
30202
30235
|
return {
|
|
30203
30236
|
js,
|
|
@@ -30540,11 +30573,12 @@ class Component {
|
|
|
30540
30573
|
to_remove.unshift([parent, prop, index]);
|
|
30541
30574
|
};
|
|
30542
30575
|
let scope_updated = false;
|
|
30543
|
-
|
|
30576
|
+
const current_function_stack = [];
|
|
30577
|
+
let current_function = null;
|
|
30544
30578
|
walk(content, {
|
|
30545
30579
|
enter(node, parent, prop, index) {
|
|
30546
|
-
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression')
|
|
30547
|
-
|
|
30580
|
+
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression')) {
|
|
30581
|
+
current_function_stack.push(current_function = node);
|
|
30548
30582
|
}
|
|
30549
30583
|
if (map.has(node)) {
|
|
30550
30584
|
scope = map.get(node);
|
|
@@ -30569,11 +30603,12 @@ class Component {
|
|
|
30569
30603
|
component.warn_on_undefined_store_value_references(node, parent, prop, scope);
|
|
30570
30604
|
},
|
|
30571
30605
|
leave(node) {
|
|
30572
|
-
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression')
|
|
30573
|
-
|
|
30606
|
+
if ((node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression')) {
|
|
30607
|
+
current_function_stack.pop();
|
|
30608
|
+
current_function = current_function_stack[current_function_stack.length - 1];
|
|
30574
30609
|
}
|
|
30575
30610
|
// do it on leave, to prevent infinite loop
|
|
30576
|
-
if (component.compile_options.dev && component.compile_options.loopGuardTimeout > 0 &&
|
|
30611
|
+
if (component.compile_options.dev && component.compile_options.loopGuardTimeout > 0 && (!current_function || (!current_function.generator && !current_function.async))) {
|
|
30577
30612
|
const to_replace_for_loop_protect = component.loop_protect(node, scope, component.compile_options.loopGuardTimeout);
|
|
30578
30613
|
if (to_replace_for_loop_protect) {
|
|
30579
30614
|
this.replace(to_replace_for_loop_protect);
|
|
@@ -31245,6 +31280,7 @@ const valid_options = [
|
|
|
31245
31280
|
'name',
|
|
31246
31281
|
'filename',
|
|
31247
31282
|
'sourcemap',
|
|
31283
|
+
'enableSourcemap',
|
|
31248
31284
|
'generate',
|
|
31249
31285
|
'errorMode',
|
|
31250
31286
|
'varsReport',
|
|
@@ -31308,7 +31344,7 @@ function validate_options(options, warnings) {
|
|
|
31308
31344
|
}
|
|
31309
31345
|
}
|
|
31310
31346
|
function compile(source, options = {}) {
|
|
31311
|
-
options = Object.assign({ generate: 'dom', dev: false }, options);
|
|
31347
|
+
options = Object.assign({ generate: 'dom', dev: false, enableSourcemap: true }, options);
|
|
31312
31348
|
const stats = new Stats();
|
|
31313
31349
|
const warnings = [];
|
|
31314
31350
|
validate_options(options, warnings);
|
|
@@ -31562,10 +31598,10 @@ async function process_tag(tag_name, preprocessor, source) {
|
|
|
31562
31598
|
const { string, map } = await replace_in_code(tag_regex, process_single_tag, source);
|
|
31563
31599
|
return { string, map, dependencies };
|
|
31564
31600
|
}
|
|
31565
|
-
async function process_markup(
|
|
31601
|
+
async function process_markup(process, source) {
|
|
31566
31602
|
const processed = await process({
|
|
31567
31603
|
content: source.source,
|
|
31568
|
-
filename
|
|
31604
|
+
filename: source.filename
|
|
31569
31605
|
});
|
|
31570
31606
|
if (processed) {
|
|
31571
31607
|
return {
|
|
@@ -31584,7 +31620,6 @@ async function process_markup(filename, process, source) {
|
|
|
31584
31620
|
}
|
|
31585
31621
|
}
|
|
31586
31622
|
async function preprocess(source, preprocessor, options) {
|
|
31587
|
-
// @ts-ignore todo: doublecheck
|
|
31588
31623
|
const filename = (options && options.filename) || preprocessor.filename; // legacy
|
|
31589
31624
|
const preprocessors = preprocessor ? (Array.isArray(preprocessor) ? preprocessor : [preprocessor]) : [];
|
|
31590
31625
|
const markup = preprocessors.map(p => p.markup).filter(Boolean);
|
|
@@ -31594,7 +31629,7 @@ async function preprocess(source, preprocessor, options) {
|
|
|
31594
31629
|
// TODO keep track: what preprocessor generated what sourcemap?
|
|
31595
31630
|
// to make debugging easier = detect low-resolution sourcemaps in fn combine_mappings
|
|
31596
31631
|
for (const process of markup) {
|
|
31597
|
-
result.update_source(await process_markup(
|
|
31632
|
+
result.update_source(await process_markup(process, result));
|
|
31598
31633
|
}
|
|
31599
31634
|
for (const process of script) {
|
|
31600
31635
|
result.update_source(await process_tag('script', process, result));
|
|
@@ -31605,7 +31640,7 @@ async function preprocess(source, preprocessor, options) {
|
|
|
31605
31640
|
return result.to_processed();
|
|
31606
31641
|
}
|
|
31607
31642
|
|
|
31608
|
-
const VERSION = '3.
|
|
31643
|
+
const VERSION = '3.44.3';
|
|
31609
31644
|
|
|
31610
31645
|
export { VERSION, compile, parse$3 as parse, preprocess, walk };
|
|
31611
31646
|
//# sourceMappingURL=compiler.mjs.map
|