svelte 3.46.2 → 3.46.5
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 +24 -0
- package/compiler.js +277 -275
- package/compiler.js.map +1 -1
- package/compiler.mjs +277 -275
- package/compiler.mjs.map +1 -1
- package/internal/index.js +3 -2
- package/internal/index.mjs +3 -2
- package/package.json +6 -9
- package/types/compiler/compile/Component.d.ts +2 -2
- package/types/compiler/compile/nodes/Text.d.ts +2 -0
- package/types/compiler/interfaces.d.ts +3 -3
- package/types/compiler/utils/push_array.d.ts +8 -0
- package/types/runtime/action/index.d.ts +41 -0
package/compiler.mjs
CHANGED
|
@@ -5814,6 +5814,7 @@ const globals = new Set([
|
|
|
5814
5814
|
'Event',
|
|
5815
5815
|
'EventSource',
|
|
5816
5816
|
'fetch',
|
|
5817
|
+
'FormData',
|
|
5817
5818
|
'global',
|
|
5818
5819
|
'globalThis',
|
|
5819
5820
|
'history',
|
|
@@ -6704,6 +6705,19 @@ function extract_identifiers(param, nodes = []) {
|
|
|
6704
6705
|
return nodes;
|
|
6705
6706
|
}
|
|
6706
6707
|
|
|
6708
|
+
/**
|
|
6709
|
+
* Does `array.push` for all `items`. Needed because `array.push(...items)` throws
|
|
6710
|
+
* "Maximum call stack size exceeded" when `items` is too big of an array.
|
|
6711
|
+
*
|
|
6712
|
+
* @param {any[]} array
|
|
6713
|
+
* @param {any[]} items
|
|
6714
|
+
*/
|
|
6715
|
+
function push_array(array, items) {
|
|
6716
|
+
for (let i = 0; i < items.length; i++) {
|
|
6717
|
+
array.push(items[i]);
|
|
6718
|
+
}
|
|
6719
|
+
}
|
|
6720
|
+
|
|
6707
6721
|
// heavily based on https://github.com/davidbonnet/astring
|
|
6708
6722
|
|
|
6709
6723
|
/** @typedef {import('estree').ArrowFunctionExpression} ArrowFunctionExpression */
|
|
@@ -6951,7 +6965,8 @@ const join = (nodes, separator) => {
|
|
|
6951
6965
|
|
|
6952
6966
|
const joined = [...nodes[0]];
|
|
6953
6967
|
for (let i = 1; i < nodes.length; i += 1) {
|
|
6954
|
-
joined.push(separator
|
|
6968
|
+
joined.push(separator);
|
|
6969
|
+
push_array(joined, nodes[i]);
|
|
6955
6970
|
}
|
|
6956
6971
|
return joined;
|
|
6957
6972
|
};
|
|
@@ -7029,9 +7044,7 @@ const handle_body = (nodes, state) => {
|
|
|
7029
7044
|
);
|
|
7030
7045
|
}
|
|
7031
7046
|
|
|
7032
|
-
chunks
|
|
7033
|
-
...body[i]
|
|
7034
|
-
);
|
|
7047
|
+
push_array(chunks, body[i]);
|
|
7035
7048
|
|
|
7036
7049
|
needed_padding = needs_padding;
|
|
7037
7050
|
}
|
|
@@ -7058,13 +7071,7 @@ const handle_var_declaration = (node, state) => {
|
|
|
7058
7071
|
|
|
7059
7072
|
const separator = c(multiple_lines ? `,\n${state.indent}\t` : ', ');
|
|
7060
7073
|
|
|
7061
|
-
|
|
7062
|
-
chunks.push(...join(declarators, separator));
|
|
7063
|
-
} else {
|
|
7064
|
-
chunks.push(
|
|
7065
|
-
...join(declarators, separator)
|
|
7066
|
-
);
|
|
7067
|
-
}
|
|
7074
|
+
push_array(chunks, join(declarators, separator));
|
|
7068
7075
|
|
|
7069
7076
|
return chunks;
|
|
7070
7077
|
};
|
|
@@ -7119,10 +7126,8 @@ const handlers = {
|
|
|
7119
7126
|
];
|
|
7120
7127
|
|
|
7121
7128
|
if (node.alternate) {
|
|
7122
|
-
chunks.push(
|
|
7123
|
-
|
|
7124
|
-
...handle(node.alternate, state)
|
|
7125
|
-
);
|
|
7129
|
+
chunks.push(c(' else '));
|
|
7130
|
+
push_array(chunks, handle(node.alternate, state));
|
|
7126
7131
|
}
|
|
7127
7132
|
|
|
7128
7133
|
return chunks;
|
|
@@ -7166,20 +7171,16 @@ const handlers = {
|
|
|
7166
7171
|
|
|
7167
7172
|
node.cases.forEach(block => {
|
|
7168
7173
|
if (block.test) {
|
|
7169
|
-
chunks.push(
|
|
7170
|
-
|
|
7171
|
-
|
|
7172
|
-
c(':')
|
|
7173
|
-
);
|
|
7174
|
+
chunks.push(c(`\n${state.indent}\tcase `));
|
|
7175
|
+
push_array(chunks, handle(block.test, { ...state, indent: `${state.indent}\t` }));
|
|
7176
|
+
chunks.push(c(':'));
|
|
7174
7177
|
} else {
|
|
7175
7178
|
chunks.push(c(`\n${state.indent}\tdefault:`));
|
|
7176
7179
|
}
|
|
7177
7180
|
|
|
7178
7181
|
block.consequent.forEach(statement => {
|
|
7179
|
-
chunks.push(
|
|
7180
|
-
|
|
7181
|
-
...handle(statement, { ...state, indent: `${state.indent}\t\t` })
|
|
7182
|
-
);
|
|
7182
|
+
chunks.push(c(`\n${state.indent}\t\t`));
|
|
7183
|
+
push_array(chunks, handle(statement, { ...state, indent: `${state.indent}\t\t` }));
|
|
7183
7184
|
});
|
|
7184
7185
|
});
|
|
7185
7186
|
|
|
@@ -7217,20 +7218,19 @@ const handlers = {
|
|
|
7217
7218
|
|
|
7218
7219
|
if (node.handler) {
|
|
7219
7220
|
if (node.handler.param) {
|
|
7220
|
-
chunks.push(
|
|
7221
|
-
|
|
7222
|
-
|
|
7223
|
-
c(') ')
|
|
7224
|
-
);
|
|
7221
|
+
chunks.push(c(' catch('));
|
|
7222
|
+
push_array(chunks, handle(node.handler.param, state));
|
|
7223
|
+
chunks.push(c(') '));
|
|
7225
7224
|
} else {
|
|
7226
7225
|
chunks.push(c(' catch '));
|
|
7227
7226
|
}
|
|
7228
7227
|
|
|
7229
|
-
chunks
|
|
7228
|
+
push_array(chunks, handle(node.handler.body, state));
|
|
7230
7229
|
}
|
|
7231
7230
|
|
|
7232
7231
|
if (node.finalizer) {
|
|
7233
|
-
chunks.push(c(' finally ')
|
|
7232
|
+
chunks.push(c(' finally '));
|
|
7233
|
+
push_array(chunks, handle(node.finalizer, state));
|
|
7234
7234
|
}
|
|
7235
7235
|
|
|
7236
7236
|
return chunks;
|
|
@@ -7260,21 +7260,19 @@ const handlers = {
|
|
|
7260
7260
|
|
|
7261
7261
|
if (node.init) {
|
|
7262
7262
|
if (node.init.type === 'VariableDeclaration') {
|
|
7263
|
-
chunks
|
|
7263
|
+
push_array(chunks, handle_var_declaration(node.init, state));
|
|
7264
7264
|
} else {
|
|
7265
|
-
chunks
|
|
7265
|
+
push_array(chunks, handle(node.init, state));
|
|
7266
7266
|
}
|
|
7267
7267
|
}
|
|
7268
7268
|
|
|
7269
7269
|
chunks.push(c('; '));
|
|
7270
|
-
if (node.test) chunks
|
|
7270
|
+
if (node.test) push_array(chunks, handle(node.test, state));
|
|
7271
7271
|
chunks.push(c('; '));
|
|
7272
|
-
if (node.update) chunks
|
|
7272
|
+
if (node.update) push_array(chunks, handle(node.update, state));
|
|
7273
7273
|
|
|
7274
|
-
chunks.push(
|
|
7275
|
-
|
|
7276
|
-
...handle(node.body, state)
|
|
7277
|
-
);
|
|
7274
|
+
chunks.push(c(') '));
|
|
7275
|
+
push_array(chunks, handle(node.body, state));
|
|
7278
7276
|
|
|
7279
7277
|
return chunks;
|
|
7280
7278
|
}),
|
|
@@ -7285,17 +7283,15 @@ const handlers = {
|
|
|
7285
7283
|
];
|
|
7286
7284
|
|
|
7287
7285
|
if (node.left.type === 'VariableDeclaration') {
|
|
7288
|
-
chunks
|
|
7286
|
+
push_array(chunks, handle_var_declaration(node.left, state));
|
|
7289
7287
|
} else {
|
|
7290
|
-
chunks
|
|
7288
|
+
push_array(chunks, handle(node.left, state));
|
|
7291
7289
|
}
|
|
7292
7290
|
|
|
7293
|
-
chunks.push(
|
|
7294
|
-
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
...handle(node.body, state)
|
|
7298
|
-
);
|
|
7291
|
+
chunks.push(c(node.type === 'ForInStatement' ? ` in ` : ` of `));
|
|
7292
|
+
push_array(chunks, handle(node.right, state));
|
|
7293
|
+
chunks.push(c(') '));
|
|
7294
|
+
push_array(chunks, handle(node.body, state));
|
|
7299
7295
|
|
|
7300
7296
|
return chunks;
|
|
7301
7297
|
}),
|
|
@@ -7309,7 +7305,7 @@ const handlers = {
|
|
|
7309
7305
|
|
|
7310
7306
|
if (node.async) chunks.push(c('async '));
|
|
7311
7307
|
chunks.push(c(node.generator ? 'function* ' : 'function '));
|
|
7312
|
-
if (node.id) chunks
|
|
7308
|
+
if (node.id) push_array(chunks, handle(node.id, state));
|
|
7313
7309
|
chunks.push(c('('));
|
|
7314
7310
|
|
|
7315
7311
|
const params = node.params.map(p => handle(p, {
|
|
@@ -7325,21 +7321,15 @@ const handlers = {
|
|
|
7325
7321
|
const separator = c(multiple_lines ? `,\n${state.indent}` : ', ');
|
|
7326
7322
|
|
|
7327
7323
|
if (multiple_lines) {
|
|
7328
|
-
chunks.push(
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
c(`\n${state.indent}`)
|
|
7332
|
-
);
|
|
7324
|
+
chunks.push(c(`\n${state.indent}\t`));
|
|
7325
|
+
push_array(chunks, join(params, separator));
|
|
7326
|
+
chunks.push(c(`\n${state.indent}`));
|
|
7333
7327
|
} else {
|
|
7334
|
-
chunks
|
|
7335
|
-
...join(params, separator)
|
|
7336
|
-
);
|
|
7328
|
+
push_array(chunks, join(params, separator));
|
|
7337
7329
|
}
|
|
7338
7330
|
|
|
7339
|
-
chunks.push(
|
|
7340
|
-
|
|
7341
|
-
...handle(node.body, state)
|
|
7342
|
-
);
|
|
7331
|
+
chunks.push(c(') '));
|
|
7332
|
+
push_array(chunks, handle(node.body, state));
|
|
7343
7333
|
|
|
7344
7334
|
return chunks;
|
|
7345
7335
|
}),
|
|
@@ -7363,17 +7353,18 @@ const handlers = {
|
|
|
7363
7353
|
ClassDeclaration(node, state) {
|
|
7364
7354
|
const chunks = [c('class ')];
|
|
7365
7355
|
|
|
7366
|
-
if (node.id)
|
|
7356
|
+
if (node.id) {
|
|
7357
|
+
push_array(chunks, handle(node.id, state));
|
|
7358
|
+
chunks.push(c(' '));
|
|
7359
|
+
}
|
|
7367
7360
|
|
|
7368
7361
|
if (node.superClass) {
|
|
7369
|
-
chunks.push(
|
|
7370
|
-
|
|
7371
|
-
|
|
7372
|
-
c(' ')
|
|
7373
|
-
);
|
|
7362
|
+
chunks.push(c('extends '));
|
|
7363
|
+
push_array(chunks, handle(node.superClass, state));
|
|
7364
|
+
chunks.push(c(' '));
|
|
7374
7365
|
}
|
|
7375
7366
|
|
|
7376
|
-
chunks
|
|
7367
|
+
push_array(chunks, handle(node.body, state));
|
|
7377
7368
|
|
|
7378
7369
|
return chunks;
|
|
7379
7370
|
},
|
|
@@ -7421,27 +7412,21 @@ const handlers = {
|
|
|
7421
7412
|
const width = get_length(chunks) + specifiers.map(get_length).reduce(sum, 0) + (2 * specifiers.length) + 6 + get_length(source);
|
|
7422
7413
|
|
|
7423
7414
|
if (width > 80) {
|
|
7424
|
-
chunks.push(
|
|
7425
|
-
|
|
7426
|
-
|
|
7427
|
-
c('\n}')
|
|
7428
|
-
);
|
|
7415
|
+
chunks.push(c(`{\n\t`));
|
|
7416
|
+
push_array(chunks, join(specifiers, c(',\n\t')));
|
|
7417
|
+
chunks.push(c('\n}'));
|
|
7429
7418
|
} else {
|
|
7430
|
-
chunks.push(
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
c(' }')
|
|
7434
|
-
);
|
|
7419
|
+
chunks.push(c(`{ `));
|
|
7420
|
+
push_array(chunks, join(specifiers, c(', ')));
|
|
7421
|
+
chunks.push(c(' }'));
|
|
7435
7422
|
}
|
|
7436
7423
|
}
|
|
7437
7424
|
|
|
7438
7425
|
chunks.push(c(' from '));
|
|
7439
7426
|
}
|
|
7440
7427
|
|
|
7441
|
-
chunks
|
|
7442
|
-
|
|
7443
|
-
c(';')
|
|
7444
|
-
);
|
|
7428
|
+
push_array(chunks, source);
|
|
7429
|
+
chunks.push(c(';'));
|
|
7445
7430
|
|
|
7446
7431
|
return chunks;
|
|
7447
7432
|
},
|
|
@@ -7467,7 +7452,7 @@ const handlers = {
|
|
|
7467
7452
|
const chunks = [c('export ')];
|
|
7468
7453
|
|
|
7469
7454
|
if (node.declaration) {
|
|
7470
|
-
chunks
|
|
7455
|
+
push_array(chunks, handle(node.declaration, state));
|
|
7471
7456
|
} else {
|
|
7472
7457
|
const specifiers = node.specifiers.map((/** @type {ExportSpecifier} */ specifier) => {
|
|
7473
7458
|
const name = handle(specifier.local, state)[0];
|
|
@@ -7483,24 +7468,18 @@ const handlers = {
|
|
|
7483
7468
|
const width = 7 + specifiers.map(get_length).reduce(sum, 0) + 2 * specifiers.length;
|
|
7484
7469
|
|
|
7485
7470
|
if (width > 80) {
|
|
7486
|
-
chunks.push(
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
c('\n}')
|
|
7490
|
-
);
|
|
7471
|
+
chunks.push(c('{\n\t'));
|
|
7472
|
+
push_array(chunks, join(specifiers, c(',\n\t')));
|
|
7473
|
+
chunks.push(c('\n}'));
|
|
7491
7474
|
} else {
|
|
7492
|
-
chunks.push(
|
|
7493
|
-
|
|
7494
|
-
|
|
7495
|
-
c(' }')
|
|
7496
|
-
);
|
|
7475
|
+
chunks.push(c('{ '));
|
|
7476
|
+
push_array(chunks, join(specifiers, c(', ')));
|
|
7477
|
+
chunks.push(c(' }'));
|
|
7497
7478
|
}
|
|
7498
7479
|
|
|
7499
7480
|
if (node.source) {
|
|
7500
|
-
chunks.push(
|
|
7501
|
-
|
|
7502
|
-
...handle(node.source, state)
|
|
7503
|
-
);
|
|
7481
|
+
chunks.push(c(' from '));
|
|
7482
|
+
push_array(chunks, handle(node.source, state));
|
|
7504
7483
|
}
|
|
7505
7484
|
}
|
|
7506
7485
|
|
|
@@ -7538,27 +7517,23 @@ const handlers = {
|
|
|
7538
7517
|
}
|
|
7539
7518
|
|
|
7540
7519
|
if (node.computed) {
|
|
7541
|
-
chunks.push(
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
c(']')
|
|
7545
|
-
);
|
|
7520
|
+
chunks.push(c('['));
|
|
7521
|
+
push_array(chunks, handle(node.key, state));
|
|
7522
|
+
chunks.push(c(']'));
|
|
7546
7523
|
} else {
|
|
7547
|
-
chunks
|
|
7524
|
+
push_array(chunks, handle(node.key, state));
|
|
7548
7525
|
}
|
|
7549
7526
|
|
|
7550
7527
|
chunks.push(c('('));
|
|
7551
7528
|
|
|
7552
7529
|
const { params } = node.value;
|
|
7553
7530
|
for (let i = 0; i < params.length; i += 1) {
|
|
7554
|
-
chunks
|
|
7531
|
+
push_array(chunks, handle(params[i], state));
|
|
7555
7532
|
if (i < params.length - 1) chunks.push(c(', '));
|
|
7556
7533
|
}
|
|
7557
7534
|
|
|
7558
|
-
chunks.push(
|
|
7559
|
-
|
|
7560
|
-
...handle(node.value.body, state)
|
|
7561
|
-
);
|
|
7535
|
+
chunks.push(c(') '));
|
|
7536
|
+
push_array(chunks, handle(node.value.body, state));
|
|
7562
7537
|
|
|
7563
7538
|
return chunks;
|
|
7564
7539
|
},
|
|
@@ -7569,18 +7544,16 @@ const handlers = {
|
|
|
7569
7544
|
if (node.async) chunks.push(c('async '));
|
|
7570
7545
|
|
|
7571
7546
|
if (node.params.length === 1 && node.params[0].type === 'Identifier') {
|
|
7572
|
-
chunks
|
|
7547
|
+
push_array(chunks, handle(node.params[0], state));
|
|
7573
7548
|
} else {
|
|
7574
7549
|
const params = node.params.map(param => handle(param, {
|
|
7575
7550
|
...state,
|
|
7576
7551
|
indent: state.indent + '\t'
|
|
7577
7552
|
}));
|
|
7578
7553
|
|
|
7579
|
-
chunks.push(
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
c(')')
|
|
7583
|
-
);
|
|
7554
|
+
chunks.push(c('('));
|
|
7555
|
+
push_array(chunks, join(params, c(', ')));
|
|
7556
|
+
chunks.push(c(')'));
|
|
7584
7557
|
}
|
|
7585
7558
|
|
|
7586
7559
|
chunks.push(c(' => '));
|
|
@@ -7589,13 +7562,11 @@ const handlers = {
|
|
|
7589
7562
|
node.body.type === 'ObjectExpression' ||
|
|
7590
7563
|
(node.body.type === 'AssignmentExpression' && node.body.left.type === 'ObjectPattern')
|
|
7591
7564
|
) {
|
|
7592
|
-
chunks.push(
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
c(')')
|
|
7596
|
-
);
|
|
7565
|
+
chunks.push(c('('));
|
|
7566
|
+
push_array(chunks, handle(node.body, state));
|
|
7567
|
+
chunks.push(c(')'));
|
|
7597
7568
|
} else {
|
|
7598
|
-
chunks
|
|
7569
|
+
push_array(chunks, handle(node.body, state));
|
|
7599
7570
|
}
|
|
7600
7571
|
|
|
7601
7572
|
return chunks;
|
|
@@ -7643,10 +7614,10 @@ const handlers = {
|
|
|
7643
7614
|
for (let i = 0; i < expressions.length; i++) {
|
|
7644
7615
|
chunks.push(
|
|
7645
7616
|
c(quasis[i].value.raw),
|
|
7646
|
-
c('${')
|
|
7647
|
-
...handle(expressions[i], state),
|
|
7648
|
-
c('}')
|
|
7617
|
+
c('${')
|
|
7649
7618
|
);
|
|
7619
|
+
push_array(chunks, handle(expressions[i], state));
|
|
7620
|
+
chunks.push(c('}'));
|
|
7650
7621
|
}
|
|
7651
7622
|
|
|
7652
7623
|
chunks.push(
|
|
@@ -7690,14 +7661,13 @@ const handlers = {
|
|
|
7690
7661
|
);
|
|
7691
7662
|
|
|
7692
7663
|
if (multiple_lines) {
|
|
7693
|
-
chunks.push(
|
|
7694
|
-
|
|
7695
|
-
|
|
7696
|
-
|
|
7697
|
-
...sparse_commas
|
|
7698
|
-
);
|
|
7664
|
+
chunks.push(c(`\n${state.indent}\t`));
|
|
7665
|
+
push_array(chunks, join(elements, c(`,\n${state.indent}\t`)));
|
|
7666
|
+
chunks.push(c(`\n${state.indent}`));
|
|
7667
|
+
push_array(chunks, sparse_commas);
|
|
7699
7668
|
} else {
|
|
7700
|
-
chunks
|
|
7669
|
+
push_array(chunks, join(elements, c(', ')));
|
|
7670
|
+
push_array(chunks, sparse_commas);
|
|
7701
7671
|
}
|
|
7702
7672
|
|
|
7703
7673
|
chunks.push(c(']'));
|
|
@@ -7717,7 +7687,7 @@ const handlers = {
|
|
|
7717
7687
|
const separator = c(', ');
|
|
7718
7688
|
|
|
7719
7689
|
node.properties.forEach((p, i) => {
|
|
7720
|
-
chunks
|
|
7690
|
+
push_array(chunks, handle(p, {
|
|
7721
7691
|
...state,
|
|
7722
7692
|
indent: state.indent + '\t'
|
|
7723
7693
|
}));
|
|
@@ -7805,13 +7775,11 @@ const handlers = {
|
|
|
7805
7775
|
chunks.push(c('*'));
|
|
7806
7776
|
}
|
|
7807
7777
|
|
|
7808
|
-
chunks.
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
|
|
7813
|
-
...handle(node.value.body, state)
|
|
7814
|
-
);
|
|
7778
|
+
push_array(chunks, node.computed ? [c('['), ...key, c(']')] : key);
|
|
7779
|
+
chunks.push(c('('));
|
|
7780
|
+
push_array(chunks, join(node.value.params.map((/** @type {Pattern} */ param) => handle(param, state)), c(', ')));
|
|
7781
|
+
chunks.push(c(') '));
|
|
7782
|
+
push_array(chunks, handle(node.value.body, state));
|
|
7815
7783
|
|
|
7816
7784
|
return chunks;
|
|
7817
7785
|
}
|
|
@@ -7836,7 +7804,7 @@ const handlers = {
|
|
|
7836
7804
|
const chunks = [c('{ ')];
|
|
7837
7805
|
|
|
7838
7806
|
for (let i = 0; i < node.properties.length; i += 1) {
|
|
7839
|
-
chunks
|
|
7807
|
+
push_array(chunks, handle(node.properties[i], state));
|
|
7840
7808
|
if (i < node.properties.length - 1) chunks.push(c(', '));
|
|
7841
7809
|
}
|
|
7842
7810
|
|
|
@@ -7866,13 +7834,11 @@ const handlers = {
|
|
|
7866
7834
|
EXPRESSIONS_PRECEDENCE[node.argument.type] <
|
|
7867
7835
|
EXPRESSIONS_PRECEDENCE.UnaryExpression
|
|
7868
7836
|
) {
|
|
7869
|
-
chunks.push(
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
c(')')
|
|
7873
|
-
);
|
|
7837
|
+
chunks.push(c('('));
|
|
7838
|
+
push_array(chunks, handle(node.argument, state));
|
|
7839
|
+
chunks.push(c(')'));
|
|
7874
7840
|
} else {
|
|
7875
|
-
chunks
|
|
7841
|
+
push_array(chunks, handle(node.argument, state));
|
|
7876
7842
|
}
|
|
7877
7843
|
|
|
7878
7844
|
return chunks;
|
|
@@ -7893,6 +7859,9 @@ const handlers = {
|
|
|
7893
7859
|
},
|
|
7894
7860
|
|
|
7895
7861
|
BinaryExpression(node, state) {
|
|
7862
|
+
/**
|
|
7863
|
+
* @type any[]
|
|
7864
|
+
*/
|
|
7896
7865
|
const chunks = [];
|
|
7897
7866
|
|
|
7898
7867
|
// TODO
|
|
@@ -7903,44 +7872,41 @@ const handlers = {
|
|
|
7903
7872
|
// }
|
|
7904
7873
|
|
|
7905
7874
|
if (needs_parens(node.left, node, false)) {
|
|
7906
|
-
chunks.push(
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
c(')')
|
|
7910
|
-
);
|
|
7875
|
+
chunks.push(c('('));
|
|
7876
|
+
push_array(chunks, handle(node.left, state));
|
|
7877
|
+
chunks.push(c(')'));
|
|
7911
7878
|
} else {
|
|
7912
|
-
chunks
|
|
7879
|
+
push_array(chunks, handle(node.left, state));
|
|
7913
7880
|
}
|
|
7914
7881
|
|
|
7915
7882
|
chunks.push(c(` ${node.operator} `));
|
|
7916
7883
|
|
|
7917
7884
|
if (needs_parens(node.right, node, true)) {
|
|
7918
|
-
chunks.push(
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
c(')')
|
|
7922
|
-
);
|
|
7885
|
+
chunks.push(c('('));
|
|
7886
|
+
push_array(chunks, handle(node.right, state));
|
|
7887
|
+
chunks.push(c(')'));
|
|
7923
7888
|
} else {
|
|
7924
|
-
chunks
|
|
7889
|
+
push_array(chunks, handle(node.right, state));
|
|
7925
7890
|
}
|
|
7926
7891
|
|
|
7927
7892
|
return chunks;
|
|
7928
7893
|
},
|
|
7929
7894
|
|
|
7930
7895
|
ConditionalExpression(node, state) {
|
|
7896
|
+
/**
|
|
7897
|
+
* @type any[]
|
|
7898
|
+
*/
|
|
7931
7899
|
const chunks = [];
|
|
7932
7900
|
|
|
7933
7901
|
if (
|
|
7934
7902
|
EXPRESSIONS_PRECEDENCE[node.test.type] >
|
|
7935
7903
|
EXPRESSIONS_PRECEDENCE.ConditionalExpression
|
|
7936
7904
|
) {
|
|
7937
|
-
chunks
|
|
7905
|
+
push_array(chunks, handle(node.test, state));
|
|
7938
7906
|
} else {
|
|
7939
|
-
chunks.push(
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
c(')')
|
|
7943
|
-
);
|
|
7907
|
+
chunks.push(c('('));
|
|
7908
|
+
push_array(chunks, handle(node.test, state));
|
|
7909
|
+
chunks.push(c(')'));
|
|
7944
7910
|
}
|
|
7945
7911
|
|
|
7946
7912
|
const child_state = { ...state, indent: state.indent + '\t' };
|
|
@@ -7954,19 +7920,15 @@ const handlers = {
|
|
|
7954
7920
|
);
|
|
7955
7921
|
|
|
7956
7922
|
if (multiple_lines) {
|
|
7957
|
-
chunks.push(
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
...alternate
|
|
7962
|
-
);
|
|
7923
|
+
chunks.push(c(`\n${state.indent}? `));
|
|
7924
|
+
push_array(chunks, consequent);
|
|
7925
|
+
chunks.push(c(`\n${state.indent}: `));
|
|
7926
|
+
push_array(chunks, alternate);
|
|
7963
7927
|
} else {
|
|
7964
|
-
chunks.push(
|
|
7965
|
-
|
|
7966
|
-
|
|
7967
|
-
|
|
7968
|
-
...alternate
|
|
7969
|
-
);
|
|
7928
|
+
chunks.push(c(` ? `));
|
|
7929
|
+
push_array(chunks, consequent);
|
|
7930
|
+
chunks.push(c(` : `));
|
|
7931
|
+
push_array(chunks, alternate);
|
|
7970
7932
|
}
|
|
7971
7933
|
|
|
7972
7934
|
return chunks;
|
|
@@ -7979,13 +7941,11 @@ const handlers = {
|
|
|
7979
7941
|
EXPRESSIONS_PRECEDENCE[node.callee.type] <
|
|
7980
7942
|
EXPRESSIONS_PRECEDENCE.CallExpression || has_call_expression(node.callee)
|
|
7981
7943
|
) {
|
|
7982
|
-
chunks.push(
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
c(')')
|
|
7986
|
-
);
|
|
7944
|
+
chunks.push(c('('));
|
|
7945
|
+
push_array(chunks, handle(node.callee, state));
|
|
7946
|
+
chunks.push(c(')'));
|
|
7987
7947
|
} else {
|
|
7988
|
-
chunks
|
|
7948
|
+
push_array(chunks, handle(node.callee, state));
|
|
7989
7949
|
}
|
|
7990
7950
|
|
|
7991
7951
|
// TODO this is copied from CallExpression — DRY it out
|
|
@@ -7998,11 +7958,9 @@ const handlers = {
|
|
|
7998
7958
|
? c(',\n' + state.indent)
|
|
7999
7959
|
: c(', ');
|
|
8000
7960
|
|
|
8001
|
-
chunks.push(
|
|
8002
|
-
|
|
8003
|
-
|
|
8004
|
-
c(')')
|
|
8005
|
-
);
|
|
7961
|
+
chunks.push(c('('));
|
|
7962
|
+
push_array(chunks, join(args, separator));
|
|
7963
|
+
chunks.push(c(')'));
|
|
8006
7964
|
|
|
8007
7965
|
return chunks;
|
|
8008
7966
|
},
|
|
@@ -8012,19 +7970,20 @@ const handlers = {
|
|
|
8012
7970
|
},
|
|
8013
7971
|
|
|
8014
7972
|
CallExpression(/** @type {CallExpression} */ node, state) {
|
|
7973
|
+
/**
|
|
7974
|
+
* @type any[]
|
|
7975
|
+
*/
|
|
8015
7976
|
const chunks = [];
|
|
8016
7977
|
|
|
8017
7978
|
if (
|
|
8018
7979
|
EXPRESSIONS_PRECEDENCE[node.callee.type] <
|
|
8019
7980
|
EXPRESSIONS_PRECEDENCE.CallExpression
|
|
8020
7981
|
) {
|
|
8021
|
-
chunks.push(
|
|
8022
|
-
|
|
8023
|
-
|
|
8024
|
-
c(')')
|
|
8025
|
-
);
|
|
7982
|
+
chunks.push(c('('));
|
|
7983
|
+
push_array(chunks, handle(node.callee, state));
|
|
7984
|
+
chunks.push(c(')'));
|
|
8026
7985
|
} else {
|
|
8027
|
-
chunks
|
|
7986
|
+
push_array(chunks, handle(node.callee, state));
|
|
8028
7987
|
}
|
|
8029
7988
|
|
|
8030
7989
|
if (/** @type {SimpleCallExpression} */ (node).optional) {
|
|
@@ -8042,49 +8001,42 @@ const handlers = {
|
|
|
8042
8001
|
indent: `${state.indent}\t`
|
|
8043
8002
|
}));
|
|
8044
8003
|
|
|
8045
|
-
chunks.push(
|
|
8046
|
-
|
|
8047
|
-
|
|
8048
|
-
c(`\n${state.indent})`)
|
|
8049
|
-
);
|
|
8004
|
+
chunks.push(c(`(\n${state.indent}\t`));
|
|
8005
|
+
push_array(chunks, join(args, c(`,\n${state.indent}\t`)));
|
|
8006
|
+
chunks.push(c(`\n${state.indent})`));
|
|
8050
8007
|
} else {
|
|
8051
|
-
chunks.push(
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
c(')')
|
|
8055
|
-
);
|
|
8008
|
+
chunks.push(c('('));
|
|
8009
|
+
push_array(chunks, join(args, c(', ')));
|
|
8010
|
+
chunks.push(c(')'));
|
|
8056
8011
|
}
|
|
8057
8012
|
|
|
8058
8013
|
return chunks;
|
|
8059
8014
|
},
|
|
8060
8015
|
|
|
8061
8016
|
MemberExpression(node, state) {
|
|
8017
|
+
/**
|
|
8018
|
+
* @type any[]
|
|
8019
|
+
*/
|
|
8062
8020
|
const chunks = [];
|
|
8063
8021
|
|
|
8064
8022
|
if (EXPRESSIONS_PRECEDENCE[node.object.type] < EXPRESSIONS_PRECEDENCE.MemberExpression) {
|
|
8065
|
-
chunks.push(
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
c(')')
|
|
8069
|
-
);
|
|
8023
|
+
chunks.push(c('('));
|
|
8024
|
+
push_array(chunks, handle(node.object, state));
|
|
8025
|
+
chunks.push(c(')'));
|
|
8070
8026
|
} else {
|
|
8071
|
-
chunks
|
|
8027
|
+
push_array(chunks, handle(node.object, state));
|
|
8072
8028
|
}
|
|
8073
8029
|
|
|
8074
8030
|
if (node.computed) {
|
|
8075
8031
|
if (node.optional) {
|
|
8076
8032
|
chunks.push(c('?.'));
|
|
8077
8033
|
}
|
|
8078
|
-
chunks.push(
|
|
8079
|
-
|
|
8080
|
-
|
|
8081
|
-
c(']')
|
|
8082
|
-
);
|
|
8034
|
+
chunks.push(c('['));
|
|
8035
|
+
push_array(chunks, handle(node.property, state));
|
|
8036
|
+
chunks.push(c(']'));
|
|
8083
8037
|
} else {
|
|
8084
|
-
chunks.push(
|
|
8085
|
-
|
|
8086
|
-
...handle(node.property, state)
|
|
8087
|
-
);
|
|
8038
|
+
chunks.push(c(node.optional ? '?.' : '.'));
|
|
8039
|
+
push_array(chunks, handle(node.property, state));
|
|
8088
8040
|
}
|
|
8089
8041
|
|
|
8090
8042
|
return chunks;
|
|
@@ -19038,6 +18990,10 @@ var compiler_errors = {
|
|
|
19038
18990
|
code: 'illegal-global',
|
|
19039
18991
|
message: `${name} is an illegal variable name`
|
|
19040
18992
|
}),
|
|
18993
|
+
illegal_variable_declaration: {
|
|
18994
|
+
code: 'illegal-variable-declaration',
|
|
18995
|
+
message: 'Cannot declare same variable name which is imported inside <script context="module">'
|
|
18996
|
+
},
|
|
19041
18997
|
cyclical_reactive_declaration: (cycle) => ({
|
|
19042
18998
|
code: 'cyclical-reactive-declaration',
|
|
19043
18999
|
message: `Cyclical dependency detected: ${cycle.join(' → ')}`
|
|
@@ -19109,7 +19065,11 @@ var compiler_errors = {
|
|
|
19109
19065
|
cyclical_const_tags: (cycle) => ({
|
|
19110
19066
|
code: 'cyclical-const-tags',
|
|
19111
19067
|
message: `Cyclical dependency detected: ${cycle.join(' → ')}`
|
|
19112
|
-
})
|
|
19068
|
+
}),
|
|
19069
|
+
invalid_component_style_directive: {
|
|
19070
|
+
code: 'invalid-component-style-directive',
|
|
19071
|
+
message: 'Style directives cannot be used on components'
|
|
19072
|
+
}
|
|
19113
19073
|
};
|
|
19114
19074
|
|
|
19115
19075
|
class Expression {
|
|
@@ -19180,7 +19140,7 @@ class Expression {
|
|
|
19180
19140
|
if (!lazy) {
|
|
19181
19141
|
dependencies.add(name);
|
|
19182
19142
|
}
|
|
19183
|
-
component.add_reference(name);
|
|
19143
|
+
component.add_reference(node, name);
|
|
19184
19144
|
component.warn_if_undefined(name, nodes[0], template_scope);
|
|
19185
19145
|
}
|
|
19186
19146
|
this.skip();
|
|
@@ -19212,7 +19172,7 @@ class Expression {
|
|
|
19212
19172
|
each_block.has_binding = true;
|
|
19213
19173
|
}
|
|
19214
19174
|
else {
|
|
19215
|
-
component.add_reference(name);
|
|
19175
|
+
component.add_reference(node, name);
|
|
19216
19176
|
const variable = component.var_lookup.get(name);
|
|
19217
19177
|
if (variable)
|
|
19218
19178
|
variable[deep ? 'mutated' : 'reassigned'] = true;
|
|
@@ -19273,7 +19233,7 @@ class Expression {
|
|
|
19273
19233
|
}
|
|
19274
19234
|
else {
|
|
19275
19235
|
dependencies.add(name);
|
|
19276
|
-
component.add_reference(name); // TODO is this redundant/misplaced?
|
|
19236
|
+
component.add_reference(node, name); // TODO is this redundant/misplaced?
|
|
19277
19237
|
}
|
|
19278
19238
|
}
|
|
19279
19239
|
else if (is_contextual(component, template_scope, name)) {
|
|
@@ -19297,11 +19257,20 @@ class Expression {
|
|
|
19297
19257
|
if (node === function_expression) {
|
|
19298
19258
|
const id = component.get_unique_name(sanitize(get_function_name(node, owner)));
|
|
19299
19259
|
const declaration = b `const ${id} = ${node}`;
|
|
19300
|
-
if (
|
|
19260
|
+
if (owner.type === 'ConstTag') {
|
|
19261
|
+
walk(node, {
|
|
19262
|
+
enter(node) {
|
|
19263
|
+
if (node.type === 'Identifier') {
|
|
19264
|
+
this.replace(block.renderer.reference(node, ctx));
|
|
19265
|
+
}
|
|
19266
|
+
}
|
|
19267
|
+
});
|
|
19268
|
+
}
|
|
19269
|
+
else if (dependencies.size === 0 && contextual_dependencies.size === 0) {
|
|
19301
19270
|
// we can hoist this out of the component completely
|
|
19302
19271
|
component.fully_hoisted.push(declaration);
|
|
19303
19272
|
this.replace(id);
|
|
19304
|
-
component.add_var({
|
|
19273
|
+
component.add_var(node, {
|
|
19305
19274
|
name: id.name,
|
|
19306
19275
|
internal: true,
|
|
19307
19276
|
hoistable: true,
|
|
@@ -19566,7 +19535,7 @@ function mark_referenced(node, scope, component) {
|
|
|
19566
19535
|
if (is_reference(node, parent)) {
|
|
19567
19536
|
const { name } = flatten_reference(node);
|
|
19568
19537
|
if (!scope.is_let(name) && !scope.names.has(name)) {
|
|
19569
|
-
component.add_reference(name);
|
|
19538
|
+
component.add_reference(node, name);
|
|
19570
19539
|
}
|
|
19571
19540
|
}
|
|
19572
19541
|
}
|
|
@@ -19718,7 +19687,7 @@ class Action extends Node$1 {
|
|
|
19718
19687
|
const object = info.name.split('.')[0];
|
|
19719
19688
|
component.warn_if_undefined(object, info, scope);
|
|
19720
19689
|
this.name = info.name;
|
|
19721
|
-
component.add_reference(object);
|
|
19690
|
+
component.add_reference(this, object);
|
|
19722
19691
|
this.expression = info.expression
|
|
19723
19692
|
? new Expression(component, this, scope, info.expression)
|
|
19724
19693
|
: null;
|
|
@@ -19785,6 +19754,7 @@ class EachBlock extends AbstractBlock {
|
|
|
19785
19754
|
this.has_animation = false;
|
|
19786
19755
|
([this.const_tags, this.children] = get_const_tags(info.children, component, this, this));
|
|
19787
19756
|
if (this.has_animation) {
|
|
19757
|
+
this.children = this.children.filter(child => !isEmptyNode(child));
|
|
19788
19758
|
if (this.children.length !== 1) {
|
|
19789
19759
|
const child = this.children.find(child => !!child.animation);
|
|
19790
19760
|
component.error(child.animation, compiler_errors.invalid_animation_sole);
|
|
@@ -19797,6 +19767,9 @@ class EachBlock extends AbstractBlock {
|
|
|
19797
19767
|
: null;
|
|
19798
19768
|
}
|
|
19799
19769
|
}
|
|
19770
|
+
function isEmptyNode(node) {
|
|
19771
|
+
return node.type === 'Text' && node.data.trim() === '';
|
|
19772
|
+
}
|
|
19800
19773
|
|
|
19801
19774
|
function string_literal(data) {
|
|
19802
19775
|
return {
|
|
@@ -19979,7 +19952,7 @@ class Transition extends Node$1 {
|
|
|
19979
19952
|
super(component, parent, scope, info);
|
|
19980
19953
|
component.warn_if_undefined(info.name, info, scope);
|
|
19981
19954
|
this.name = info.name;
|
|
19982
|
-
component.add_reference(info.name.split('.')[0]);
|
|
19955
|
+
component.add_reference(this, info.name.split('.')[0]);
|
|
19983
19956
|
this.directive = info.intro && info.outro ? 'transition' : info.intro ? 'in' : 'out';
|
|
19984
19957
|
this.is_local = info.modifiers.includes('local');
|
|
19985
19958
|
if ((info.intro && parent.intro) || (info.outro && parent.outro)) {
|
|
@@ -19998,7 +19971,7 @@ class Animation extends Node$1 {
|
|
|
19998
19971
|
super(component, parent, scope, info);
|
|
19999
19972
|
component.warn_if_undefined(info.name, info, scope);
|
|
20000
19973
|
this.name = info.name;
|
|
20001
|
-
component.add_reference(info.name.split('.')[0]);
|
|
19974
|
+
component.add_reference(this, info.name.split('.')[0]);
|
|
20002
19975
|
if (parent.animation) {
|
|
20003
19976
|
component.error(this, compiler_errors.duplicate_animation);
|
|
20004
19977
|
return;
|
|
@@ -20120,6 +20093,21 @@ class Text extends Node$1 {
|
|
|
20120
20093
|
}
|
|
20121
20094
|
return parent_element.namespace || elements_without_text.has(parent_element.name);
|
|
20122
20095
|
}
|
|
20096
|
+
keep_space() {
|
|
20097
|
+
if (this.component.component_options.preserveWhitespace)
|
|
20098
|
+
return true;
|
|
20099
|
+
return this.within_pre();
|
|
20100
|
+
}
|
|
20101
|
+
within_pre() {
|
|
20102
|
+
let node = this.parent;
|
|
20103
|
+
while (node) {
|
|
20104
|
+
if (node.type === 'Element' && node.name === 'pre') {
|
|
20105
|
+
return true;
|
|
20106
|
+
}
|
|
20107
|
+
node = node.parent;
|
|
20108
|
+
}
|
|
20109
|
+
return false;
|
|
20110
|
+
}
|
|
20123
20111
|
}
|
|
20124
20112
|
|
|
20125
20113
|
// The `foreign` namespace covers all DOM implementations that aren't HTML5.
|
|
@@ -20183,7 +20171,7 @@ class Let extends Node$1 {
|
|
|
20183
20171
|
}
|
|
20184
20172
|
|
|
20185
20173
|
const svg$1 = /^(?:altGlyph|altGlyphDef|altGlyphItem|animate|animateColor|animateMotion|animateTransform|circle|clipPath|color-profile|cursor|defs|desc|discard|ellipse|feBlend|feColorMatrix|feComponentTransfer|feComposite|feConvolveMatrix|feDiffuseLighting|feDisplacementMap|feDistantLight|feDropShadow|feFlood|feFuncA|feFuncB|feFuncG|feFuncR|feGaussianBlur|feImage|feMerge|feMergeNode|feMorphology|feOffset|fePointLight|feSpecularLighting|feSpotLight|feTile|feTurbulence|filter|font|font-face|font-face-format|font-face-name|font-face-src|font-face-uri|foreignObject|g|glyph|glyphRef|hatch|hatchpath|hkern|image|line|linearGradient|marker|mask|mesh|meshgradient|meshpatch|meshrow|metadata|missing-glyph|mpath|path|pattern|polygon|polyline|radialGradient|rect|set|solidcolor|stop|svg|switch|symbol|text|textPath|tref|tspan|unknown|use|view|vkern)$/;
|
|
20186
|
-
const aria_attributes = 'activedescendant atomic autocomplete busy checked colcount colindex colspan controls current describedby details disabled dropeffect errormessage expanded flowto grabbed haspopup hidden invalid keyshortcuts label labelledby level live modal multiline multiselectable orientation owns placeholder posinset pressed readonly relevant required roledescription rowcount rowindex rowspan selected setsize sort valuemax valuemin valuenow valuetext'.split(' ');
|
|
20174
|
+
const aria_attributes = 'activedescendant atomic autocomplete busy checked colcount colindex colspan controls current describedby description details disabled dropeffect errormessage expanded flowto grabbed haspopup hidden invalid keyshortcuts label labelledby level live modal multiline multiselectable orientation owns placeholder posinset pressed readonly relevant required roledescription rowcount rowindex rowspan selected setsize sort valuemax valuemin valuenow valuetext'.split(' ');
|
|
20187
20175
|
const aria_attribute_set = new Set(aria_attributes);
|
|
20188
20176
|
const aria_roles = 'alert alertdialog application article banner blockquote button caption cell checkbox code columnheader combobox complementary contentinfo definition deletion dialog directory document emphasis feed figure form generic graphics-document graphics-object graphics-symbol grid gridcell group heading img link list listbox listitem log main marquee math meter menu menubar menuitem menuitemcheckbox menuitemradio navigation none note option paragraph presentation progressbar radio radiogroup region row rowgroup rowheader scrollbar search searchbox separator slider spinbutton status strong subscript superscript switch tab table tablist tabpanel term textbox time timer toolbar tooltip tree treegrid treeitem'.split(' ');
|
|
20189
20177
|
const aria_role_set = new Set(aria_roles);
|
|
@@ -20941,7 +20929,7 @@ class InlineComponent extends Node$1 {
|
|
|
20941
20929
|
if (info.name !== 'svelte:component' && info.name !== 'svelte:self') {
|
|
20942
20930
|
const name = info.name.split('.')[0]; // accommodate namespaces
|
|
20943
20931
|
component.warn_if_undefined(name, info, scope);
|
|
20944
|
-
component.add_reference(name);
|
|
20932
|
+
component.add_reference(this, name);
|
|
20945
20933
|
}
|
|
20946
20934
|
this.name = info.name;
|
|
20947
20935
|
this.expression = this.name === 'svelte:component'
|
|
@@ -20974,6 +20962,8 @@ class InlineComponent extends Node$1 {
|
|
|
20974
20962
|
break;
|
|
20975
20963
|
case 'Transition':
|
|
20976
20964
|
return component.error(node, compiler_errors.invalid_transition);
|
|
20965
|
+
case 'StyleDirective':
|
|
20966
|
+
return component.error(node, compiler_errors.invalid_component_style_directive);
|
|
20977
20967
|
default:
|
|
20978
20968
|
throw new Error(`Not implemented: ${node.type}`);
|
|
20979
20969
|
}
|
|
@@ -21255,6 +21245,19 @@ class Window extends Node$1 {
|
|
|
21255
21245
|
}
|
|
21256
21246
|
}
|
|
21257
21247
|
|
|
21248
|
+
/**
|
|
21249
|
+
* Pushes all `items` into `array` using `push`, therefore mutating the array.
|
|
21250
|
+
* We do this for memory and perf reasons, and because `array.push(...items)` would
|
|
21251
|
+
* run into a "max call stack size exceeded" error with too many items (~65k).
|
|
21252
|
+
* @param array
|
|
21253
|
+
* @param items
|
|
21254
|
+
*/
|
|
21255
|
+
function push_array$1(array, items) {
|
|
21256
|
+
for (let i = 0; i < items.length; i++) {
|
|
21257
|
+
array.push(items[i]);
|
|
21258
|
+
}
|
|
21259
|
+
}
|
|
21260
|
+
|
|
21258
21261
|
function get_constructor(type) {
|
|
21259
21262
|
switch (type) {
|
|
21260
21263
|
case 'AwaitBlock': return AwaitBlock;
|
|
@@ -21291,7 +21294,7 @@ function map_children(component, parent, scope, children) {
|
|
|
21291
21294
|
if (use_ignores)
|
|
21292
21295
|
component.pop_ignores(), ignores = [];
|
|
21293
21296
|
if (node.type === 'Comment' && node.ignores.length) {
|
|
21294
|
-
ignores
|
|
21297
|
+
push_array$1(ignores, node.ignores);
|
|
21295
21298
|
}
|
|
21296
21299
|
if (last)
|
|
21297
21300
|
last.next = node;
|
|
@@ -22237,14 +22240,7 @@ class TextWrapper extends Wrapper {
|
|
|
22237
22240
|
return false;
|
|
22238
22241
|
if (/[\S\u00A0]/.test(this.data))
|
|
22239
22242
|
return false;
|
|
22240
|
-
|
|
22241
|
-
while (node) {
|
|
22242
|
-
if (node.type === 'Element' && node.name === 'pre') {
|
|
22243
|
-
return false;
|
|
22244
|
-
}
|
|
22245
|
-
node = node.parent;
|
|
22246
|
-
}
|
|
22247
|
-
return true;
|
|
22243
|
+
return !this.node.within_pre();
|
|
22248
22244
|
}
|
|
22249
22245
|
render(block, parent_node, parent_nodes) {
|
|
22250
22246
|
if (this.skip)
|
|
@@ -23439,6 +23435,7 @@ class ElementWrapper extends Wrapper {
|
|
|
23439
23435
|
node.classes.length > 0 ||
|
|
23440
23436
|
node.intro || node.outro ||
|
|
23441
23437
|
node.handlers.length > 0 ||
|
|
23438
|
+
node.styles.length > 0 ||
|
|
23442
23439
|
this.node.name === 'option' ||
|
|
23443
23440
|
renderer.options.dev) {
|
|
23444
23441
|
this.parent.cannot_use_innerhtml(); // need to use add_location
|
|
@@ -23737,7 +23734,7 @@ class ElementWrapper extends Wrapper {
|
|
|
23737
23734
|
this.attributes.forEach((attribute) => {
|
|
23738
23735
|
if (attribute.node.name === 'class') {
|
|
23739
23736
|
const dependencies = attribute.node.get_dependencies();
|
|
23740
|
-
this.class_dependencies
|
|
23737
|
+
push_array$1(this.class_dependencies, dependencies);
|
|
23741
23738
|
}
|
|
23742
23739
|
});
|
|
23743
23740
|
if (this.node.attributes.some(attr => attr.is_spread)) {
|
|
@@ -24211,7 +24208,7 @@ class IfBlockWrapper extends Wrapper {
|
|
|
24211
24208
|
block.has_intro_method = has_intros;
|
|
24212
24209
|
block.has_outro_method = has_outros;
|
|
24213
24210
|
});
|
|
24214
|
-
renderer.blocks
|
|
24211
|
+
push_array$1(renderer.blocks, blocks);
|
|
24215
24212
|
}
|
|
24216
24213
|
render(block, parent_node, parent_nodes) {
|
|
24217
24214
|
const name = this.var;
|
|
@@ -25704,7 +25701,7 @@ class FragmentWrapper {
|
|
|
25704
25701
|
// *unless* there is no whitespace between this node and its next sibling
|
|
25705
25702
|
if (this.nodes.length === 0) {
|
|
25706
25703
|
const should_trim = (next_sibling ? (next_sibling.node.type === 'Text' && /^\s/.test(next_sibling.node.data) && trimmable_at(child, next_sibling)) : !child.has_ancestor('EachBlock'));
|
|
25707
|
-
if (should_trim) {
|
|
25704
|
+
if (should_trim && !child.keep_space()) {
|
|
25708
25705
|
data = trim_end(data);
|
|
25709
25706
|
if (!data)
|
|
25710
25707
|
continue;
|
|
@@ -25732,7 +25729,7 @@ class FragmentWrapper {
|
|
|
25732
25729
|
}
|
|
25733
25730
|
if (strip_whitespace) {
|
|
25734
25731
|
const first = this.nodes[0];
|
|
25735
|
-
if (first && first.node.type === 'Text') {
|
|
25732
|
+
if (first && first.node.type === 'Text' && !first.node.keep_space()) {
|
|
25736
25733
|
first.data = trim_start(first.data);
|
|
25737
25734
|
if (!first.data) {
|
|
25738
25735
|
first.var = null;
|
|
@@ -25947,7 +25944,7 @@ class Renderer {
|
|
|
25947
25944
|
const member = this.context_lookup.get(name);
|
|
25948
25945
|
// TODO is this correct?
|
|
25949
25946
|
if (this.component.var_lookup.get(name)) {
|
|
25950
|
-
this.component.add_reference(name);
|
|
25947
|
+
this.component.add_reference(node, name);
|
|
25951
25948
|
}
|
|
25952
25949
|
if (member !== undefined) {
|
|
25953
25950
|
const replacement = x `/*${member.name}*/ ${ctx}[${member.index}]`;
|
|
@@ -26791,13 +26788,6 @@ function merge_tables(this_table, other_table) {
|
|
|
26791
26788
|
}
|
|
26792
26789
|
return [new_table, idx_map, val_changed, idx_changed];
|
|
26793
26790
|
}
|
|
26794
|
-
function pushArray(_this, other) {
|
|
26795
|
-
// We use push to mutate in place for memory and perf reasons
|
|
26796
|
-
// We use the for loop instead of _this.push(...other) to avoid the JS engine's function argument limit (65,535 in JavascriptCore)
|
|
26797
|
-
for (let i = 0; i < other.length; i++) {
|
|
26798
|
-
_this.push(other[i]);
|
|
26799
|
-
}
|
|
26800
|
-
}
|
|
26801
26791
|
class MappedCode {
|
|
26802
26792
|
constructor(string = '', map = null) {
|
|
26803
26793
|
this.string = string;
|
|
@@ -26885,9 +26875,9 @@ class MappedCode {
|
|
|
26885
26875
|
}
|
|
26886
26876
|
}
|
|
26887
26877
|
// combine last line + first line
|
|
26888
|
-
|
|
26878
|
+
push_array$1(m1.mappings[m1.mappings.length - 1], m2.mappings.shift());
|
|
26889
26879
|
// append other lines
|
|
26890
|
-
|
|
26880
|
+
push_array$1(m1.mappings, m2.mappings);
|
|
26891
26881
|
return this;
|
|
26892
26882
|
}
|
|
26893
26883
|
static from_processed(string, map) {
|
|
@@ -27078,7 +27068,7 @@ function dom(component, options) {
|
|
|
27078
27068
|
// fix order
|
|
27079
27069
|
// TODO the deconflicted names of blocks are reversed... should set them here
|
|
27080
27070
|
const blocks = renderer.blocks.slice().reverse();
|
|
27081
|
-
body
|
|
27071
|
+
push_array$1(body, blocks.map(block => {
|
|
27082
27072
|
// TODO this is a horrible mess — renderer.blocks
|
|
27083
27073
|
// contains a mixture of Blocks and Nodes
|
|
27084
27074
|
if (block.render)
|
|
@@ -27499,7 +27489,7 @@ function dom(component, options) {
|
|
|
27499
27489
|
}`
|
|
27500
27490
|
});
|
|
27501
27491
|
}
|
|
27502
|
-
declaration.body.body
|
|
27492
|
+
push_array$1(declaration.body.body, accessors);
|
|
27503
27493
|
body.push(declaration);
|
|
27504
27494
|
if (component.tag != null) {
|
|
27505
27495
|
body.push(b `
|
|
@@ -27533,7 +27523,7 @@ function dom(component, options) {
|
|
|
27533
27523
|
}
|
|
27534
27524
|
}
|
|
27535
27525
|
`[0];
|
|
27536
|
-
declaration.body.body
|
|
27526
|
+
push_array$1(declaration.body.body, accessors);
|
|
27537
27527
|
body.push(declaration);
|
|
27538
27528
|
}
|
|
27539
27529
|
return { js: flatten(body), css };
|
|
@@ -27684,7 +27674,7 @@ function remove_whitespace_children(children, next) {
|
|
|
27684
27674
|
/^\s/.test(next.data) &&
|
|
27685
27675
|
trimmable_at$1(child, next)
|
|
27686
27676
|
: !child.has_ancestor('EachBlock');
|
|
27687
|
-
if (should_trim) {
|
|
27677
|
+
if (should_trim && !child.keep_space()) {
|
|
27688
27678
|
data = trim_end(data);
|
|
27689
27679
|
if (!data)
|
|
27690
27680
|
continue;
|
|
@@ -27704,7 +27694,7 @@ function remove_whitespace_children(children, next) {
|
|
|
27704
27694
|
}
|
|
27705
27695
|
}
|
|
27706
27696
|
const first = nodes[0];
|
|
27707
|
-
if (first && first.type === 'Text') {
|
|
27697
|
+
if (first && first.type === 'Text' && !first.keep_space()) {
|
|
27708
27698
|
first.data = trim_start(first.data);
|
|
27709
27699
|
if (!first.data) {
|
|
27710
27700
|
first.var = null;
|
|
@@ -30187,6 +30177,10 @@ class Declaration$1 {
|
|
|
30187
30177
|
const first = this.node.value.children
|
|
30188
30178
|
? this.node.value.children[0]
|
|
30189
30179
|
: this.node.value;
|
|
30180
|
+
// Don't minify whitespace in custom properties, since some browsers (Chromium < 99)
|
|
30181
|
+
// treat --foo: ; and --foo:; differently
|
|
30182
|
+
if (first.type === 'Raw' && /^\s+$/.test(first.value))
|
|
30183
|
+
return;
|
|
30190
30184
|
let start = first.start;
|
|
30191
30185
|
while (/\s/.test(code.original[start]))
|
|
30192
30186
|
start += 1;
|
|
@@ -30353,7 +30347,7 @@ class Stylesheet {
|
|
|
30353
30347
|
const at_rule_declarations = node.block.children
|
|
30354
30348
|
.filter(node => node.type === 'Declaration')
|
|
30355
30349
|
.map(node => new Declaration$1(node));
|
|
30356
|
-
atrule.declarations
|
|
30350
|
+
push_array$1(atrule.declarations, at_rule_declarations);
|
|
30357
30351
|
}
|
|
30358
30352
|
current_atrule = atrule;
|
|
30359
30353
|
}
|
|
@@ -30611,26 +30605,32 @@ class Component {
|
|
|
30611
30605
|
this.stylesheet.reify();
|
|
30612
30606
|
this.stylesheet.warn_on_unused_selectors(this);
|
|
30613
30607
|
}
|
|
30614
|
-
add_var(variable, add_to_lookup = true) {
|
|
30608
|
+
add_var(node, variable, add_to_lookup = true) {
|
|
30615
30609
|
this.vars.push(variable);
|
|
30616
30610
|
if (add_to_lookup) {
|
|
30611
|
+
if (this.var_lookup.has(variable.name)) {
|
|
30612
|
+
const exists_var = this.var_lookup.get(variable.name);
|
|
30613
|
+
if (exists_var.module && exists_var.imported) {
|
|
30614
|
+
this.error(node, compiler_errors.illegal_variable_declaration);
|
|
30615
|
+
}
|
|
30616
|
+
}
|
|
30617
30617
|
this.var_lookup.set(variable.name, variable);
|
|
30618
30618
|
}
|
|
30619
30619
|
}
|
|
30620
|
-
add_reference(name) {
|
|
30620
|
+
add_reference(node, name) {
|
|
30621
30621
|
const variable = this.var_lookup.get(name);
|
|
30622
30622
|
if (variable) {
|
|
30623
30623
|
variable.referenced = true;
|
|
30624
30624
|
}
|
|
30625
30625
|
else if (is_reserved_keyword(name)) {
|
|
30626
|
-
this.add_var({
|
|
30626
|
+
this.add_var(node, {
|
|
30627
30627
|
name,
|
|
30628
30628
|
injected: true,
|
|
30629
30629
|
referenced: true
|
|
30630
30630
|
});
|
|
30631
30631
|
}
|
|
30632
30632
|
else if (name[0] === '$') {
|
|
30633
|
-
this.add_var({
|
|
30633
|
+
this.add_var(node, {
|
|
30634
30634
|
name,
|
|
30635
30635
|
injected: true,
|
|
30636
30636
|
referenced: true,
|
|
@@ -30646,7 +30646,7 @@ class Component {
|
|
|
30646
30646
|
}
|
|
30647
30647
|
else {
|
|
30648
30648
|
if (this.compile_options.varsReport === 'full') {
|
|
30649
|
-
this.add_var({ name, referenced: true }, false);
|
|
30649
|
+
this.add_var(node, { name, referenced: true }, false);
|
|
30650
30650
|
}
|
|
30651
30651
|
this.used_names.add(name);
|
|
30652
30652
|
}
|
|
@@ -30671,7 +30671,7 @@ class Component {
|
|
|
30671
30671
|
if (result) {
|
|
30672
30672
|
const { compile_options, name } = this;
|
|
30673
30673
|
const { format = 'esm' } = compile_options;
|
|
30674
|
-
const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.46.
|
|
30674
|
+
const banner = `${this.file ? `${this.file} ` : ''}generated by Svelte v${'3.46.5'}`;
|
|
30675
30675
|
const program = { type: 'Program', body: result.js };
|
|
30676
30676
|
walk(program, {
|
|
30677
30677
|
enter: (node, parent, key) => {
|
|
@@ -30882,7 +30882,7 @@ class Component {
|
|
|
30882
30882
|
extract_names(declarator.id).forEach(name => {
|
|
30883
30883
|
const variable = this.var_lookup.get(name);
|
|
30884
30884
|
variable.export_name = name;
|
|
30885
|
-
if (variable.writable && !(variable.referenced || variable.referenced_from_script || variable.subscribable)) {
|
|
30885
|
+
if (!module_script && variable.writable && !(variable.referenced || variable.referenced_from_script || variable.subscribable)) {
|
|
30886
30886
|
this.warn(declarator, compiler_warnings.unused_export_let(this.name.name, name));
|
|
30887
30887
|
}
|
|
30888
30888
|
});
|
|
@@ -30900,7 +30900,7 @@ class Component {
|
|
|
30900
30900
|
const variable = this.var_lookup.get(specifier.local.name);
|
|
30901
30901
|
if (variable) {
|
|
30902
30902
|
variable.export_name = specifier.exported.name;
|
|
30903
|
-
if (variable.writable && !(variable.referenced || variable.referenced_from_script || variable.subscribable)) {
|
|
30903
|
+
if (!module_script && variable.writable && !(variable.referenced || variable.referenced_from_script || variable.subscribable)) {
|
|
30904
30904
|
this.warn(specifier, compiler_warnings.unused_export_let(this.name.name, specifier.exported.name));
|
|
30905
30905
|
}
|
|
30906
30906
|
}
|
|
@@ -30945,11 +30945,13 @@ class Component {
|
|
|
30945
30945
|
return this.error(node, compiler_errors.illegal_declaration);
|
|
30946
30946
|
}
|
|
30947
30947
|
const writable = node.type === 'VariableDeclaration' && (node.kind === 'var' || node.kind === 'let');
|
|
30948
|
-
|
|
30948
|
+
const imported = node.type.startsWith('Import');
|
|
30949
|
+
this.add_var(node, {
|
|
30949
30950
|
name,
|
|
30950
30951
|
module: true,
|
|
30951
30952
|
hoistable: true,
|
|
30952
|
-
writable
|
|
30953
|
+
writable,
|
|
30954
|
+
imported
|
|
30953
30955
|
});
|
|
30954
30956
|
});
|
|
30955
30957
|
globals.forEach((node, name) => {
|
|
@@ -30957,7 +30959,7 @@ class Component {
|
|
|
30957
30959
|
return this.error(node, compiler_errors.illegal_subscription);
|
|
30958
30960
|
}
|
|
30959
30961
|
else {
|
|
30960
|
-
this.add_var({
|
|
30962
|
+
this.add_var(node, {
|
|
30961
30963
|
name,
|
|
30962
30964
|
global: true,
|
|
30963
30965
|
hoistable: true
|
|
@@ -31013,7 +31015,7 @@ class Component {
|
|
|
31013
31015
|
}
|
|
31014
31016
|
const writable = node.type === 'VariableDeclaration' && (node.kind === 'var' || node.kind === 'let');
|
|
31015
31017
|
const imported = node.type.startsWith('Import');
|
|
31016
|
-
this.add_var({
|
|
31018
|
+
this.add_var(node, {
|
|
31017
31019
|
name,
|
|
31018
31020
|
initialised: instance_scope.initialised_declarations.has(name),
|
|
31019
31021
|
writable,
|
|
@@ -31033,7 +31035,7 @@ class Component {
|
|
|
31033
31035
|
return;
|
|
31034
31036
|
const node = globals.get(name);
|
|
31035
31037
|
if (this.injected_reactive_declaration_vars.has(name)) {
|
|
31036
|
-
this.add_var({
|
|
31038
|
+
this.add_var(node, {
|
|
31037
31039
|
name,
|
|
31038
31040
|
injected: true,
|
|
31039
31041
|
writable: true,
|
|
@@ -31042,7 +31044,7 @@ class Component {
|
|
|
31042
31044
|
});
|
|
31043
31045
|
}
|
|
31044
31046
|
else if (is_reserved_keyword(name)) {
|
|
31045
|
-
this.add_var({
|
|
31047
|
+
this.add_var(node, {
|
|
31046
31048
|
name,
|
|
31047
31049
|
injected: true
|
|
31048
31050
|
});
|
|
@@ -31051,13 +31053,13 @@ class Component {
|
|
|
31051
31053
|
if (name === '$' || name[1] === '$') {
|
|
31052
31054
|
return this.error(node, compiler_errors.illegal_global(name));
|
|
31053
31055
|
}
|
|
31054
|
-
this.add_var({
|
|
31056
|
+
this.add_var(node, {
|
|
31055
31057
|
name,
|
|
31056
31058
|
injected: true,
|
|
31057
31059
|
mutated: true,
|
|
31058
31060
|
writable: true
|
|
31059
31061
|
});
|
|
31060
|
-
this.add_reference(name.slice(1));
|
|
31062
|
+
this.add_reference(node, name.slice(1));
|
|
31061
31063
|
const variable = this.var_lookup.get(name.slice(1));
|
|
31062
31064
|
if (variable) {
|
|
31063
31065
|
variable.subscribable = true;
|
|
@@ -31065,7 +31067,7 @@ class Component {
|
|
|
31065
31067
|
}
|
|
31066
31068
|
}
|
|
31067
31069
|
else {
|
|
31068
|
-
this.add_var({
|
|
31070
|
+
this.add_var(node, {
|
|
31069
31071
|
name,
|
|
31070
31072
|
global: true,
|
|
31071
31073
|
hoistable: true
|
|
@@ -32162,7 +32164,7 @@ async function preprocess(source, preprocessor, options) {
|
|
|
32162
32164
|
return result.to_processed();
|
|
32163
32165
|
}
|
|
32164
32166
|
|
|
32165
|
-
const VERSION = '3.46.
|
|
32167
|
+
const VERSION = '3.46.5';
|
|
32166
32168
|
|
|
32167
32169
|
export { VERSION, compile, parse$3 as parse, preprocess, walk };
|
|
32168
32170
|
//# sourceMappingURL=compiler.mjs.map
|